react-draft-wysiwyg icon indicating copy to clipboard operation
react-draft-wysiwyg copied to clipboard

Changing Font or Font Size Removes Text Styling

Open mshryock64 opened this issue 5 years ago • 12 comments

Something we noticed on our implementation and were able to recreate on the demo page is that when changing font or font size, any text styling (bold, italics, strike-through, color, etc.) previously set is reset.

To clarify, the previously typed text keeps those styles, but you must re-enable them for any text typed after changing font or font size.

Is this a design decision, or a bug? We would like to be able to maintain any text options after changing font or font size. Is there a workaround for this?

mshryock64 avatar May 29 '19 18:05 mshryock64

@jpuri

Yeah I faced this issue too. Can we have a solution for this?

rinkisingh8181 avatar Jul 04 '19 11:07 rinkisingh8181

@mshryock64 Did you find a solution to above issue that you mentioned above?

rinkisingh8181 avatar Jul 04 '19 11:07 rinkisingh8181

@rinkisingh8181 I did not. It's currently low-priority for our project, but if this can't/won't be resolved we'll look at some other editor options.

mshryock64 avatar Jul 05 '19 14:07 mshryock64

@mshryock64 @rinkisingh8181 did you find any solution or workaround to this issue?

Sigurdlex avatar Mar 19 '20 14:03 Sigurdlex

are there any updates for this?

Currently if I change the font size or font family - and type something to editor it is not displayed correctly (it displays everything the same without font changes), however, content state is correctly updated, and I can display it as a rendered HTML string inside another element.

I hope you guys found some solution to this :)

inanmadak avatar Sep 17 '20 08:09 inanmadak

I saved the editor content in the database when I edit the Editor with the previous content, the font size and font family reset automatically, I tried lots of draft-js functions to fix it but unable to fix it, and finally I found a solution to just add entityMap: {} in the initialContentState, use initialContentState instead of defaultEditorState, it should work, Here is the Screen shots of my code. Thanks image image

hussainMansoor876 avatar Jan 26 '22 21:01 hussainMansoor876

@inanmadak @Sigurdlex @rinkisingh8181 @mshryock64 please check the solution

hussainMansoor876 avatar Jan 26 '22 21:01 hussainMansoor876

Hey Everyone I am facing issue when i convert the output of React Draft Wysiwyg Editor to HTML, the issue is that everything is applying to text in the output but font size, font style is not working Can anyone please guide @hussainMansoor876 @inanmadak @Sigurdlex @rinkisingh8181 @mshryock64

AbdullahTaseer avatar Apr 24 '24 09:04 AbdullahTaseer

@AbdullahTaseer Could you please share the screenshots of your code here

hussainMansoor876 avatar Apr 24 '24 10:04 hussainMansoor876

Screenshot 2024-04-24 151859 image

@hussainMansoor876

AbdullahTaseer avatar Apr 24 '24 10:04 AbdullahTaseer

@AbdullahTaseer Are you importing css file of it? import "react-draft-wysiwyg/dist/react-draft-wysiwyg.css"

hussainMansoor876 avatar Apr 24 '24 10:04 hussainMansoor876

and you need to add toolbar options const toolbarOptions = { options: ['blockType', 'inline', 'list', 'link', 'history', 'colorPicker',], inline: { options: ['bold', 'italic', 'underline', 'strikethrough'], }, list: { options: ['unordered', 'ordered'], }, blockType: { options: ['Normal', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'P'], }, history: { inDropdown: false, options: ['undo', 'redo'], } } image

hussainMansoor876 avatar Apr 24 '24 10:04 hussainMansoor876