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

Bug: Content copied from outside the editor sometimes isn't parsed correctly #69

Closed
matthewlipski opened this issue Dec 7, 2022 · 0 comments
Assignees
Labels
bug Something isn't working prio:mid Medium priority

Comments

@matthewlipski
Copy link
Collaborator

matthewlipski commented Dec 7, 2022

While copying & pasting in BlockNote works for the majority of content, there are 2 cases in which it breaks:

  1. When pasting two elements, e.g.:
<p>Foo</p>
<p>Bar<p>

Here, both elements are parsed as blockContent` and the editor doesn't know if they should be interpreted as two separate blocks or a single, nested, block. It always chooses the latter, meaning that the example is parsed as:

{
  block: {
    textContent: "Foo",
    blockGroup: {
      block: {
        textContent: "Bar"
      } 
    } 
  }
}

In this scenario, the type of the first element is also lost, so it's always interpreted as textContent.

  1. When pasting nested elements, e.g.:
<ul>
  <li>Foo
    <ul>
      <li>Bar</li>
    </ul>
  </li>
</ul>

Here, the nesting information is lost. This is mainly applicable to list items, since paragraph and heading elements can't be nested as per the HTML spec. When pasting list items into BlockNote, they too are parsed as blockContent, which can't have nested items. Therefore, the text of each nested item is concatenated to the end of the text of the parent item and the example gets parsed as:

{
  block: {
    listItemContent: "Foo Bar",
  }
}

I've already attempted to fix these issues on the copy-paste-new-architecture branch if it's of any help, though I haven't had much success.

Once this is working we'll also need additional tests for it.

@matthewlipski matthewlipski added the bug Something isn't working label Dec 7, 2022
@matthewlipski matthewlipski changed the title Bug: Elements copied from outside the editor sometimes aren't parsed correctly Bug: Content copied from outside the editor sometimes isn't parsed correctly Dec 7, 2022
@matthewlipski matthewlipski added the prio:mid Medium priority label Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working prio:mid Medium priority
Projects
None yet
Development

No branches or pull requests

2 participants