draftjs-to-html icon indicating copy to clipboard operation
draftjs-to-html copied to clipboard

Using two Bullet point lists do not render correctly

Open mitchellwarr opened this issue 6 years ago • 7 comments

If you have content as displayed in the convertToRaw of the editorState.

7: {key: "5qoqm", text: "NumberedList   ", type: "ordered-list-item", depth: 0, inlineStyleRanges: Array(0), …}
8: {key: "dn5n", text: "sub", type: "ordered-list-item", depth: 1, inlineStyleRanges: Array(0), …}
9: {key: "53r0c", text: "sub 2", type: "ordered-list-item", depth: 2, inlineStyleRanges: Array(0), …}
10: {key: "8kagr", text: "BulletList", type: "unordered-list-item", depth: 0, inlineStyleRanges: Array(0), …}
11: {key: "2u2p6", text: "sub", type: "unordered-list-item", depth: 1, inlineStyleRanges: Array(0), …}
12: {key: "cffgo", text: "sub 2", type: "unordered-list-item", depth: 2, inlineStyleRanges: Array(0), …}

Which looks like

1. NumberedList
   1. sub
      1. sub 2
* BulletList
   * sub
       * sub 2

The html produced is

<ol>
  <li>NumberedList</li>
</ol>
<ul>
  <li>BulletList</li>
  <ol>
    <li>sub</li>
  </ol>
  <ul>
    <li>sub</li>
    <ol>
      <li>sub 2</li>
    </ol>
  <ul>
  <li>sub 2</li>
</ul>
</ul>
</ul>

Which looks like

1. NumberedList
* BulletList
   1. sub
   * sub
      1. sub 2
       * sub 2

mitchellwarr avatar Jul 16 '19 03:07 mitchellwarr

Adding a new line between the end of the numbered lists and the bullet points, makes it all render correctly

mitchellwarr avatar Jul 16 '19 03:07 mitchellwarr

Facing the exact same issue. @mitchellwarr did you manage to work around it?

jf-eirinha avatar May 11 '21 12:05 jf-eirinha

Facing the exact same issue. @mitchellwarr did you manage to work around it?

i cant remember. but this edge case is such that im ignoring the issue until my codebase can phase this WYSIWYG out with a better one

mitchellwarr avatar May 13 '21 03:05 mitchellwarr

Facing the same issue, the problem is this creates invalid HTML.

A ul or ol can only contain li's - where currently the output is nesting the second level list directly in the parent list, where it should be nested in the list item itself.

chrisrickard avatar Oct 06 '21 23:10 chrisrickard

Same issue here. Lists are directly nested under the parent list, when it should be wrapped with a <li>. https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/HTML_text_fundamentals#nesting_lists

Any updates on this issue or how to work around it?

Psycholisk avatar Oct 26 '21 07:10 Psycholisk

I really like this tool, and I greatly appreciate the work that went into it. Is it abandoned, though? Maybe the creator/maintainer got busy with work/life.

dmorrison avatar Oct 26 '21 14:10 dmorrison

Same issue here. Lists are directly nested under the parent list, when it should be wrapped with a <li>. https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/HTML_text_fundamentals#nesting_lists

Any updates on this issue or how to work around it?

I've just created a PR (#107) to fix this issue. Now we need a help from @jpuri to merge it.

duylecampos avatar Mar 09 '22 16:03 duylecampos