UNPKG

@liveblocks/react-blocknote

Version:

An integration of BlockNote + React to enable collaboration, comments, live cursors, and more with Liveblocks.

76 lines (72 loc) 1.81 kB
'use strict'; var core = require('@blocknote/core'); var reactTiptap = require('@liveblocks/react-tiptap'); const mentionSpec = core.createInlineContentSpecFromTipTapNode( reactTiptap.MentionNode, { id: { default: "" }, notificationId: { default: "" } }, { render(inlineContent) { const el = document.createElement("liveblocks-mention"); el.setAttribute("data-id", inlineContent.props.id); el.setAttribute( "data-notification-id", inlineContent.props.notificationId ); return { dom: el }; } } ); const groupMentionSpec = core.createInlineContentSpecFromTipTapNode( reactTiptap.GroupMentionNode, { id: { default: "" }, userIds: { default: "" }, notificationId: { default: "" } }, { render(inlineContent) { const el = document.createElement("liveblocks-group-mention"); el.setAttribute("data-id", inlineContent.props.id); el.setAttribute("data-user-ids", inlineContent.props.userIds); el.setAttribute( "data-notification-id", inlineContent.props.notificationId ); return { dom: el }; } } ); const withLiveblocksSchema = (schema, liveblocksOptions = {}) => { const optionalSchema = schema || core.BlockNoteSchema.create(); if (!liveblocksOptions.mentions) { return optionalSchema; } return core.BlockNoteSchema.create({ blockSpecs: optionalSchema.blockSpecs, inlineContentSpecs: { ...optionalSchema.inlineContentSpecs, liveblocksMention: mentionSpec, liveblocksGroupMention: groupMentionSpec }, styleSpecs: optionalSchema.styleSpecs }); }; exports.withLiveblocksSchema = withLiveblocksSchema; //# sourceMappingURL=schema.cjs.map