Skip to content

Conversation

@denich
Copy link
Contributor

@denich denich commented Nov 1, 2017

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

@sontek
Copy link

sontek commented Nov 29, 2017

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

@denich
Copy link
Contributor Author

denich commented Dec 5, 2017

@sontek Yea, looks like it should

@FadiAboMsalam
Copy link

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

@betancourtl
Copy link

betancourtl commented Dec 22, 2018

Would love to see this merged in so I can fix an issue on one of my repos betancourtl/draft-js-custom-styles#2.

-- Edit

Actually this is not what I need, I just need to be able to apply multiple styles to an element.

@mitchellwarr
Copy link

Would appreciate this being implemented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants