draft-js-utils
draft-js-utils copied to clipboard
InlineStyleFn adjustments - produce separated elements for each inline style
Current implementation of InlineStyleFn()
accepts whole style set but can produce only one element. It leads to the troubles when you'll want to parse it back using draft-js-import-html
because it can produce only one inline style per one element.
Ex:
- We have 2 inline styles: color, font size
- Generated following tag using
draft-js-export-html
<span style="color: #000; font-size: 14px" />
- Want to parse it back via
draft-js-import-html
'scustomInlineFn
but it can produce only one style:
customInlineFn: (element, { Style }) => {
if (element.style.color) {
return Style('color-' + element.style.color); // this one
}
if (element.style.fontSize) {
return Style('font-size-' + element.style.fontSize); // or this one
}
}
The solution (implemented): generate separated element for each inline style (like it's done via inlineStyles
)
Alternative solution: support returning Style
's array from customInlineFn
import method
This sounds like it'd fix #120 for me?
@sontek Yea, looks like it should
this isn't working with me inline styles the color to be specific
Would love to see this merged in so I can fix an issue on one of my repos https://github.com/webdeveloperpr/draft-js-custom-styles/issues/2.
-- Edit
Actually this is not what I need, I just need to be able to apply multiple styles to an element.
Would appreciate this being implemented