sstur / draft-js-utils

DraftJS: import/export ContentState to and from HTML/Markdown
ISC License
883 stars 234 forks source link

whitespace bold #195

Open jqoker opened 5 years ago

jqoker commented 5 years ago

when using bold style to whitespace, whitespace will lost

for example:

origin: text[whitespace]bold after: textbold

this whitespace between text and bold lost

dibell commented 5 years ago

I too have just noticed this. Given the draft-js definition below, the space between 'bold' and 'italic' is lost. I have found that the space is retained if you include it in the bold style.

{
  "blocks": [
    {
      "key": "tase",
      "text": "this is a bold italic",
      "type": "unstyled",
      "depth": 0,
      "inlineStyleRanges": [
        {
          "offset": 10,
          "length": 4,
          "style": "BOLD"
        },
        {
          "offset": 15,
          "length": 6,
          "style": "ITALIC"
        }
      ],
      "entityRanges": [],
      "data": {}
    }
  ],
  "entityMap": {}
}
dibell commented 5 years ago

Having traced this further it is not an issue in draft-js-utils, it is in draft-js-export-pdfmake where I see the single space being filtered. See https://github.com/datagenno/draft-js-export-pdfmake/issues/3