betancourtl / draft-js-custom-styles

Create custom inline styles for draft-js in a sane way
MIT License
34 stars 17 forks source link

Are you able to use it for alignment of selected text? #17

Closed JMA12 closed 5 years ago

JMA12 commented 5 years ago

Can this be used for alignment of selected texts?

steveostudios commented 5 years ago

@JMA12 I couldn't figure out how to do this. I spent a day trying to do this as well. I think the reason you may not be able to to it is because this library applies styles inline, and aligning texts needs to be placed on the block level. To me it doesn't look like this applies styles to a block. Luckily Draft JS does do block styling! (https://draftjs.org/docs/advanced-topics-block-styling).

Hope that helps!

betancourtl commented 5 years ago

I haven't used this in a very very long time, if I remember correctly @steveostudios is right, you need to style blocks using the blockStyleFn

JMA12 commented 5 years ago

Thanks @steveostudios and @webdeveloperpr

Already found the solution using toggleBlockType function from RichUtils.