megahertz / react-simple-wysiwyg

Simple and lightweight React WYSIWYG editor
https://megahertz.github.io/react-simple-wysiwyg/
MIT License
119 stars 21 forks source link

Color support? #43

Closed Lockhild closed 2 months ago

Lockhild commented 2 months ago

Hey! First of all, thank you for this library. I found it today and plan to replace TinyMCE in my project since it's a bit laggy when rendering inside drawers.

react-simple-wysiwyg seems to be just what I need since I really don't need a lot of features.

One feature I'm missing though is adding colors to the text and the background. I played a bit with it but didn't manage to make it work properly yet.

I was wondering, how would you implement such a feature if you would have to integrate react-colorful, for example, with react-simple-wysiwyg?

Thank you! If I land on a good solution in the meantime, I'll be back to post it here.

Lockhild commented 2 months ago

OK, nevermind, I found the solution 😄. You simply run document.execCommand('foreColor', false, color);

I wasn't familiar with that command and though that somehow I need to be able to get the selected text and was having some problems with that, but that's not needed.

Thanks for a great library once again!

megahertz commented 2 months ago

TBH, I didn't know there is a special command for changing text color :smile: