React-draft-wysiwyg: No support for dynamic inlineStyleRanges font-size?

Created on 13 Nov 2017  路  14Comments  路  Source: jpuri/react-draft-wysiwyg

Hey, I have a system that gets a Raw ContentState from a database and displays it as html or if the user wants to edit the text he can do that.
Displaying the right inlineStyles using draftToHtml works fine, but on the editor itself everything works except the font-size. It just doesn't pass along and it inherits the parents tag font-size (which is 60).
Here's a GIF showing the issue:
draft

The element's contentState:
{"blocks":[{"key":"ckbcl","data":{},"text":"Lorem ipsum dolor nostreu postern maquinum.","type":"unstyled","depth":0,"entityRanges":[],"inlineStyleRanges":[{"style":"fontsize-22","length":43,"offset":0},{"style":"color-#D1D1D1","length":18,"offset":0},{"style":"color-#D1D1D1","length":18,"offset":25},{"style":"color-#FFFFFF","length":7,"offset":18}]}],"entityMap":{}}

Most helpful comment

@omerdn1: its bug atm, font-size is saved only if its applied by selecting drop-down option. I will try to fix this.

All 14 comments

@omerdn1 was you able to fix this?

@volkandkaya nope, haven't gotten the chance
@jpuri any thoughts?

@omerdn1 Unfortunately not. I believe it has something to do with the custom styles and not HTML conversion as it has the same problem with JSON to Draftjs.

@jpuri any chance we could get an update on this?

@omerdn1: its bug atm, font-size is saved only if its applied by selecting drop-down option. I will try to fix this.

@jpuri how is fixing this bug going? Anything I can do to help?

@volkandkaya : thx, this would require adding inline style range for default font. Or may be adding font data at block level in meta data. Well, complex in either case :(

@jpuri @volkandkaya any news regarding this issue?

I am not able to think of a simple solution for this issue, it requires manually setting font-style in editor content, but doing that on each change will be expensive thing.

An alternative would be to add a config parameter to draftToHtml for default font size. Will that help your use-case @omerdn1. This change I can do quick.

@jpuri if we can have a default and then have the ability to swap as well that would be great.

@jpuri that sadly won't be enough for me to proceed.. gonna spend this weekend to try to come up with a solution

@volkandkaya: I do not get your point clearly - can you plz explain.

Also, I am thinking currently editor shows the default font-size always selected. I think if I remove that behavior it will be helpful - so users get an idea that font-size if default unless they explicitly set it.

@jpuri any news?

@jpuri How can we include support for more inline styles in the react-draft-wysiwyg editor ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

trongbang86 picture trongbang86  路  3Comments

jpuri picture jpuri  路  4Comments

ananddodia picture ananddodia  路  4Comments

Satherial picture Satherial  路  4Comments

volkandkaya picture volkandkaya  路  3Comments