Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable default behavior of list elements being wrapped in ul/ol #203

Open
chesterkmr opened this issue Dec 9, 2021 · 2 comments
Open

Comments

@chesterkmr
Copy link

I have render map defined where list elements is not being wrapped with ul or ol.
So output of lists looks like this
<li>item 1</li>
<li>item 2</li>
etc...

But when im trying to convert editor state to html using draft-convert list elements are wrapped with ul by default.

Is there any way to avoid this behavior or possibility to use custom render map when converting?

@augustoostapechen
Copy link

augustoostapechen commented Dec 15, 2021

Try this:

if (block.type === 'ordered-list-item') {
     return {
         start: `<li>`,
         end: '</li>',
         nest: '<ol>',
         nestStart: '<ol>',
         nestEnd: '</ol>'
     }
 }

You also can pass a inline style in the li tag like this.

if (block.type === 'ordered-list-item') {
     return {
         start: `<li style="
             textAlign: ${alignText ?  'right', 'left'};
             width: '285mm';
             fontSize: '19px';
             fontFamily: 'Montserrat, sans-serif';
             fontWeight: '500';
         ">`,
         end: '</li>',
         nest: '<ol>',
         nestStart: '<ol>',
         nestEnd: '</ol>'
     }
 }

@RafaelZasas
Copy link

RafaelZasas commented Mar 15, 2022

This solution is not working for me.
The dom is still only showing <li> and className or styles are not being rendered.
Any help would be appreciated.

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

No branches or pull requests

3 participants