Skip to content

feat: add support for tiptap / liveblocks comments #1442

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

Merged
merged 2 commits into from
Feb 17, 2025

Conversation

YousefED
Copy link
Collaborator

@YousefED YousefED commented Feb 17, 2025

This PR:

  • adds an "add comment" button to the Formatting Toolbar if a commenting plugin has been registered on TipTap
  • adds a support to tag certain Marks that are not relevant for BlockNote, such as Marks. TipTap / Liveblocks comment plugins currently rely on marks to associate Comments as annotations to the document, even though they're not really document content. By tagging Marks as blocknoteIgnore it's possible to use these marks while not affecting the rest of BlockNote. In Tiptap, this can be done like this:
Mark.create(
...

extendMarkSchema(extension) {
    if (extension.name === "comment") { // "comment" is the name of the mark
      return {
        blocknoteIgnore: true,
      };
    }
    return {};
  }
...

Copy link

vercel bot commented Feb 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Feb 17, 2025 6:24pm
blocknote-website ✅ Ready (Inspect) Visit Preview Feb 17, 2025 6:24pm

@@ -130,6 +131,11 @@ export function contentNodeToInlineContent<
} else {
const config = styleSchema[mark.type.name];
if (!config) {
if (mark.type.spec.group?.includes("blocknoteIgnore")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we store something else in the spec rather than using the group for this?

Or maybe by the mark's name?

This feels kind of wrong to use the group for this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair. Prefer just to add anything else on the spec? (i.e.: (mark.type.spec as any).blocknoteIgnore = true)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, looks like the type should be already be open to allowing that sort of modifcation:

    /**
    Mark specs can include additional properties that can be
    inspected through [`MarkType.spec`](https://prosemirror.net/docs/ref/#model.MarkType.spec) when
    working with the mark.
    */
    [key: string]: any;
}

Copy link
Collaborator Author

@YousefED YousefED Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, and it can be added in tiptap with:

extendMarkSchema(extension) {
    if (extension.name === "comment") { // if "comment" is the name of the comment mark
      return {
        blocknoteIgnore: true,
      };
    }
    return {};
  },

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, much cleaner!

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

Successfully merging this pull request may close these issues.

3 participants