mui-rte icon indicating copy to clipboard operation
mui-rte copied to clipboard

How can I use styles from my html to defaultValue?

Open adrianofernande opened this issue 5 years ago • 3 comments

Checklist

Description

I'm trying to use a html text passing to defaultValue, but I can't apply styles.

Tags like strong works well, but when I use some styles this doesn't work.

Code image

Result on editor image

I already tried:

image

and this way:

image

and this way:

image

Question:

There's a way to use a styles from html in defaultValue?

adrianofernande avatar Aug 19 '20 14:08 adrianofernande

Hi, @adrianofernande draftjs not support inline styles, but you can use custom html to draftjs parser. For integrating with mui-rte you must define customControl for each inline style what you want to parse. After you will must convert you style to uppercase (more) I agree sound like dirty hack but it's works.

I prepared simple demo with 2 colors.

Maybe @niuware can suggest more elegant solution.

PS: sorry for my bad english. Fee free to correct me :)

Armanio avatar Aug 20 '20 17:08 Armanio

Hi, @adrianofernande draftjs not support inline styles, but you can use custom html to draftjs parser. For integrating with mui-rte you must define customControl for each inline style what you want to parse. After you will must convert you style to uppercase (more) I agree sound like dirty hack but it's works.

I prepared simple demo with 2 colors.

Maybe @niuware can suggest more elegant solution.

PS: sorry for my bad english. Fee free to correct me :)

Hi @Armanio,

Thank you very much for your help.

It's works very well.

And it's possible to apply more than one style. 👍

image

RESULT

image

adrianofernande avatar Aug 20 '20 18:08 adrianofernande