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

[PRO]: TableOfContents w/ Collab keeps adding extra blank nodes to content #4829

Open
1 of 2 tasks
qctechjunkie opened this issue Jan 24, 2024 · 1 comment
Open
1 of 2 tasks
Labels
Category: Pro The issue or pull request is related to the pro packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug

Comments

@qctechjunkie
Copy link

Which packages did you experience the bug in?

react, extension-table-of-contents, extension-collaboration

What Tiptap version are you using?

2.1.16

What’s the bug you are facing?

We are seeing a bug where empty lines are created when running collab and table of contents (ToC) together. Specificlly when asking ToC to index paragraph nodes. Before collab sync is complete, ToC will index the empty editor's default placeholder paragraph.

<p id="8fa..." data-toc-id="8fa66..." data-placeholder="Body Copy" class="is-empty"><br class="ProseMirror-trailingBreak"></p>

  • This only occurs when the ToC is configured to index paragraphs
    • Removing 'paragraph' as an anchor type in the config resolves
    • anchorTypes: ['heading', 'paragraph'],
  • If the ToC could be instructed to skip “is-empty” classed items this would resolve as well

The reason collab begins with an empty editor instead of the content from the record is that TipTap has a duplication problem when starting with content provided in the content prop

If the content is passed in client side, Collab sees this as a change/addition to the content it has, and doubles everything on each page load.

What browser are you using?

Chrome

Code example

No response

What did you expect to happen?

We would expect Table of Contents (ToC) to ignore empty paragraph nodes until content is actually in the node. Or have ToC wait for Collab sync, if Collab is enabled, before indexing the content.

Anything to add? (optional)

No response

Did you update your dependencies?

  • Yes, I’ve updated my dependencies to use the latest version of all packages.

Are you sponsoring us?

  • Yes, I’m a sponsor. 💖
@qctechjunkie qctechjunkie added Category: Pro The issue or pull request is related to the pro packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug labels Jan 24, 2024
@github-project-automation github-project-automation bot moved this to Triage open in Tiptap Jan 24, 2024
@mattkindy
Copy link

mattkindy commented Jul 3, 2024

I believe I was experiencing this even without indexing paragraph nodes when the document was initially empty, with this extension setup:

import { TableOfContents as ToC } from "@tiptap-pro/extension-table-of-contents";

export const TableOfContents = ToC.extend({
  anchorTypes: ["heading"],
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Pro The issue or pull request is related to the pro packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug
Projects
No open projects
Status: Triage open
Development

No branches or pull requests

2 participants