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

Adding <hr> breaks loading from automerge #25

Open
kythyria opened this issue Oct 15, 2024 · 0 comments
Open

Adding <hr> breaks loading from automerge #25

kythyria opened this issue Oct 15, 2024 · 0 comments

Comments

@kythyria
Copy link

kythyria commented Oct 15, 2024

Attempting to modify the schema in src/schema.ts to add support for <hr> looks initially like it will work, but instead attempting to load a document with one in causes automerge-prosemirror to crash during initialization:

Uncaught Error: Match cannot be null
    set currentMatch traversal.ts:619
    newBlock         traversal.ts:650
    traverseSpans    traversal.ts:597
    pmDocFromSpans   traversal.ts:64
    init             index.ts:84
    <anonymous>      main.ts:40

It crashes in a similar way--the top four frames are identical--while-you-edit if two copies of the page are open pointing at the same document.

The actual substantial change to repro is to copy src/schema.ts and modify the bit about horizontal rules to read

    /// A horizontal rule (`<hr>`).
    horizontal_rule: {
      automerge: {
          block: "__ext__horizontal-rule",
          isEmbed: true,
      },
      group: "block",
      parseDOM: [{ tag: "hr" }],
      toDOM() {
        return hrDOM
      },
    } as NodeSpec,

then pass the resulting schemaAdapter to init().

https://github.com/kythyria/automerge-prosemirror-issue-badblocks is a vanilla JS example sufficient to reproduce, npm run dev, open the URL, try inserting a <hr> using the toolbar (could probably paste one too), observe that reloading the page fails, as does opening it in a second tab.

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

1 participant