Bourquardez Joachim

Joined

50 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in How do i can add text-alignment to trix ?

Hello. Im trying to add text-alignment functionnality to a trix rich-text editor in a rails 6 app (its for a blog).

I find somes example on stack overflow or trix github about adding colors, h tags or underline. everything works, but nothing for text align.

From my understanding of trix this, in the javascript file, should work

Trix.config.textAttributes.alignLeft = {
style: { textAlign: "left" },
parser: function(element) {
    return element.style.alignLeft === "left"
},
inheritable: true

and after i add a button in the toolbar with data-trix-attribute="alignLeft"
This format worked for colors or underline but not for text-align.
Im struggling for few days with this issue, if you have any idea dont hesite :-).
thanks a lot