jpuri / draftjs-to-html

Library for converting Draftjs editor content state to HTML
MIT License
321 stars 143 forks source link

Inline style does not get included in HTML #42

Open henryson opened 6 years ago

henryson commented 6 years ago

I use draftjs-color-picker version 1.0.2 and draftToHtml version 0.8.3 and this is my code:

const contentRaw = convertToRaw(this.state.editorState.getCurrentContent())
const contentHtml = draftToHtml(contentRaw)

contentRaw:

{
blocks: Array(1)
0: data: {}
depth: 0
entityRanges: []
inlineStyleRanges: Array(1)
0: {offset: 4, length: 4, style: "CUSTOM_COLOR_rgba(74, 144, 226, 1)"}
length: 1
__proto__: Array(0)
key: "2h4he"
text: "One blue color"
...

contentHtml: <p>One blue color</p>

When I look at demo of https://jpuri.github.io/react-draft-wysiwyg/#/demo I can see that the same code produces styled HTML.

Why does it not work for me?

henryson commented 6 years ago

I found out the reason myself. The draftjs-color-picker has a different format of color inline style prefix, I assumed the editor used this plugin. I later noticed that it was not part of the DraftJS Plugins.

JMA12 commented 5 years ago

Are you able to come up with a solution with this?

henryson commented 5 years ago

I don't remember other than that I confused it for a draftjs plugin. But we moved from draftjs to other editor.

Cheers, Josef

On Fri, Jun 21, 2019 at 4:58 AM +0200, "JMA12" notifications@github.com wrote:

Are you able to come up with a solution with this?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

JMA12 commented 5 years ago

Aww, I see.

Btw thanks, cheers

SujithChowdari commented 3 years ago

Well,, I have a similar problem and first demo here in this link also has this issue? I wonder if this is a limitation of the editor itself? In that case it's a major issue https://jpuri.github.io/react-draft-wysiwyg/#/demo