HubSpot / draft-convert

Extensibly serialize & deserialize Draft.js ContentState with HTML.
Apache License 2.0
484 stars 94 forks source link

List Items rendered without <ul> or <li> #207

Open RafaelZasas opened 2 years ago

RafaelZasas commented 2 years ago

Ive tried the following three methods:

      if (block.type === 'ordered-list-item') {
        switch (block.depth) {
          case 1:
            return {
              start: `<li className="list-inside list-loweralpha indent-6">`,
              end: '</li>',
              nest: '<ol>',
              nestStart: '<ol>',
              nestEnd: '</ol>',
            };
          case 2:
            return (
              <ol>
                <li className="list-inside list-lowerroman indent-12">{block.text}</li>
              </ol>
            );
          default:
            return <li className="list-inside list-decimal" />;
        }
    }

This is the output:

image

This is the DOM:

image

As you can see:

I am just trying to mimic the functionality as seen in the DraftJS editor on the left. If I remove any checking for list blocks in the convertToHTML section my lists are rendered correctly in the dom but are not styled and have no bullet points (list-style-type css property).

RafaelZasas commented 2 years ago

I actually answered myself in This Stack Overflow Question.

It is still seemingly unexpected behavior that this only renders inline styles and not class styles.