Skip to content

Parsing nested bullet points HTML - Blocks #431

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

Closed
caioebueno opened this issue Nov 30, 2023 · 1 comment
Closed

Parsing nested bullet points HTML - Blocks #431

caioebueno opened this issue Nov 30, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@caioebueno
Copy link

In my app I am persisting the state of the editor in HTML using the blocksToHTML function. If I parse from blocks to HTML and parse the HTML to blocks later, it looses the nested bullet points and all points become in the same level.

EXP:
Screenshot 2023-11-30 at 10 25 23 AM

This input after parsed results in the following HTML (includes the nested items)

<ul>
  <li>
    <p class="_inlineContent_nstdf_297">Point A</p>
    <ul>
      <li>
        <p class="_inlineContent_nstdf_297">Point A1</p>
      </li>
    </ul>
  </li>
  <li>
    <p class="_inlineContent_nstdf_297">Point B</p>
  </li>
</ul>
<p class="_inlineContent_nstdf_297"></p>

After parsing to blocks and using as initial content this is the result

Screenshot 2023-11-30 at 10 28 35 AM

This is the result of parsing blocks to HTML again

<ul>
  <li>
    <p class="_inlineContent_nstdf_297">Point A</p>
  </li>
  <li>
    <p class="_inlineContent_nstdf_297">Point A1</p>
  </li>
  <li>
    <p class="_inlineContent_nstdf_297">Point B</p>
  </li>
</ul>
<p class="_inlineContent_nstdf_297"></p>
@caioebueno caioebueno added the bug Something isn't working label Nov 30, 2023
@YousefED
Copy link
Collaborator

It's recommended to store JSON to persist your blocks, see also the warning @ https://www.blocknotejs.org/docs/converting-blocks

Nevertheless, this will be fixed by #426

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants