draft-js-utils icon indicating copy to clipboard operation
draft-js-utils copied to clipboard

InlineStyleFn adjustments - produce separated elements for each inline style

Open denich opened this issue 7 years ago • 5 comments

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:

  1. We have 2 inline styles: color, font size
  2. Generated following tag using draft-js-export-html
<span style="color: #000; font-size: 14px" />
  1. Want to parse it back via draft-js-import-html's customInlineFn 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

denich avatar Nov 01 '17 11:11 denich

This sounds like it'd fix #120 for me?

sontek avatar Nov 29 '17 19:11 sontek

@sontek Yea, looks like it should

denich avatar Dec 05 '17 17:12 denich

this isn't working with me inline styles the color to be specific

FadiAboMsalam avatar Apr 07 '18 17:04 FadiAboMsalam

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.

betancourtl avatar Dec 22 '18 00:12 betancourtl

Would appreciate this being implemented

mitchellwarr avatar Jul 17 '19 02:07 mitchellwarr