@liveblocks/react-tiptap 3.21.0-exp1 → 3.21.0-exp10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/LiveblocksExtension.cjs +3 -2
  2. package/dist/LiveblocksExtension.cjs.map +1 -1
  3. package/dist/LiveblocksExtension.js +3 -2
  4. package/dist/LiveblocksExtension.js.map +1 -1
  5. package/dist/collaboration-liveblocks/cursors.cjs +10 -211
  6. package/dist/collaboration-liveblocks/cursors.cjs.map +1 -1
  7. package/dist/collaboration-liveblocks/cursors.js +6 -209
  8. package/dist/collaboration-liveblocks/cursors.js.map +1 -1
  9. package/dist/collaboration-liveblocks/plugin.cjs +13 -189
  10. package/dist/collaboration-liveblocks/plugin.cjs.map +1 -1
  11. package/dist/collaboration-liveblocks/plugin.js +12 -190
  12. package/dist/collaboration-liveblocks/plugin.js.map +1 -1
  13. package/dist/collaboration-liveblocks/schema.cjs +23 -139
  14. package/dist/collaboration-liveblocks/schema.cjs.map +1 -1
  15. package/dist/collaboration-liveblocks/schema.js +5 -128
  16. package/dist/collaboration-liveblocks/schema.js.map +1 -1
  17. package/dist/comments/CommentsExtension.cjs +3 -2
  18. package/dist/comments/CommentsExtension.cjs.map +1 -1
  19. package/dist/comments/CommentsExtension.js +2 -1
  20. package/dist/comments/CommentsExtension.js.map +1 -1
  21. package/dist/index.d.cts +1 -0
  22. package/dist/index.d.ts +1 -0
  23. package/dist/mentions/MentionExtension.cjs +6 -4
  24. package/dist/mentions/MentionExtension.cjs.map +1 -1
  25. package/dist/mentions/MentionExtension.js +5 -3
  26. package/dist/mentions/MentionExtension.js.map +1 -1
  27. package/dist/types.cjs.map +1 -1
  28. package/dist/types.js.map +1 -1
  29. package/dist/version.cjs +1 -1
  30. package/dist/version.cjs.map +1 -1
  31. package/dist/version.js +1 -1
  32. package/dist/version.js.map +1 -1
  33. package/package.json +7 -6
  34. package/dist/collaboration-liveblocks/mapping.cjs +0 -218
  35. package/dist/collaboration-liveblocks/mapping.cjs.map +0 -1
  36. package/dist/collaboration-liveblocks/mapping.js +0 -207
  37. package/dist/collaboration-liveblocks/mapping.js.map +0 -1
  38. package/dist/collaboration-liveblocks/remote.cjs +0 -210
  39. package/dist/collaboration-liveblocks/remote.cjs.map +0 -1
  40. package/dist/collaboration-liveblocks/remote.js +0 -207
  41. package/dist/collaboration-liveblocks/remote.js.map +0 -1
  42. package/dist/collaboration-liveblocks/steps.cjs +0 -359
  43. package/dist/collaboration-liveblocks/steps.cjs.map +0 -1
  44. package/dist/collaboration-liveblocks/steps.js +0 -356
  45. package/dist/collaboration-liveblocks/steps.js.map +0 -1
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type {\n ContextualPromptContext,\n ContextualPromptResponse,\n MentionData,\n Relax,\n TextEditorType,\n ThreadData,\n} from \"@liveblocks/core\";\nimport type { LiveblocksYjsProvider } from \"@liveblocks/yjs\";\nimport type { Content, Range } from \"@tiptap/core\";\nimport { PluginKey } from \"@tiptap/pm/state\";\nimport type { DecorationSet } from \"@tiptap/pm/view\";\nimport type { ChainedCommands, SingleCommands } from \"@tiptap/react\";\nimport type { ProsemirrorBinding } from \"y-prosemirror\";\nimport type { Doc, PermanentUserData, Snapshot } from \"yjs\";\n\nexport const LIVEBLOCKS_MENTION_KEY = new PluginKey(\"lb-plugin-mention\");\nexport const LIVEBLOCKS_MENTION_PASTE_KEY = new PluginKey(\n \"lb-plugin-mention-paste\"\n);\nexport const LIVEBLOCKS_MENTION_NOTIFIER_KEY = new PluginKey(\n \"lb-plugin-mention-notify\"\n);\n\nexport const LIVEBLOCKS_MENTION_EXTENSION = \"liveblocksMentionExt\";\nexport const LIVEBLOCKS_MENTION_TYPE = \"liveblocksMention\";\nexport const LIVEBLOCKS_GROUP_MENTION_TYPE = \"liveblocksGroupMention\";\n\nexport const THREADS_ACTIVE_SELECTION_PLUGIN = new PluginKey(\n \"lb-threads-active-selection-plugin\"\n);\nexport const THREADS_PLUGIN_KEY = new PluginKey<ThreadPluginState>(\n \"lb-threads-plugin\"\n);\nexport const AI_TOOLBAR_SELECTION_PLUGIN = new PluginKey(\n \"lb-ai-toolbar-selection-plugin\"\n);\n\nexport const LIVEBLOCKS_COMMENT_MARK_TYPE = \"liveblocksCommentMark\";\n\n/**\n * @beta\n */\nexport type ResolveContextualPromptArgs = {\n /**\n * The prompt being requested by the user.\n */\n prompt: string;\n\n /**\n * The context of the document and its current selection.\n */\n context: ContextualPromptContext;\n\n /**\n * The previous request and its response, if this is a follow-up request.\n */\n previous?: {\n prompt: string;\n response: ContextualPromptResponse;\n };\n\n /**\n * An abort signal that can be used to cancel requests.\n */\n signal: AbortSignal;\n};\n\n/**\n * @beta\n */\nexport type ResolveContextualPromptResponse = ContextualPromptResponse;\n\nexport interface AiConfiguration {\n /**\n * The AI's name. (\"Ask {name} anything…\", \"{name} is thinking…\", etc)\n */\n name?: string;\n\n /**\n * A function that returns an a response to a contextual prompt.\n */\n resolveContextualPrompt?: (\n args: ResolveContextualPromptArgs\n ) => Promise<ContextualPromptResponse>;\n}\n\nexport type LiveblocksExtensionOptions = {\n collaborationMode?: \"yjs\" | \"liveblocks\";\n field?: string;\n comments?: boolean; // | CommentsConfiguration\n mentions?: boolean; // | MentionsConfiguration\n ai?: boolean | AiConfiguration;\n offlineSupport_experimental?: boolean;\n threads_experimental?: ThreadData[];\n initialContent?: Content;\n enablePermanentUserData?: boolean;\n /**\n * @internal\n * For reporting another text editor type from a\n * text editor extended from `TipTap` such as our `BlockNote` integration.\n *\n * Only useful for Liveblocks developers, not for end users.\n */\n textEditorType?: TextEditorType;\n};\n\nexport type LiveblocksExtensionStorage =\n | {\n mode: \"yjs\";\n unsubs: (() => void)[];\n doc: Doc;\n provider: LiveblocksYjsProvider;\n permanentUserData?: PermanentUserData;\n }\n | {\n mode: \"liveblocks\";\n unsubs: (() => void)[];\n };\n\nexport type CommentsExtensionStorage = {\n pendingComment: boolean;\n};\n\nexport const enum ThreadPluginActions {\n SET_ACTIVE_THREAD_IDS = \"SET_ACTIVE_THREAD_IDS\",\n}\n\nexport type AiExtensionOptions = Required<\n Pick<AiConfiguration, \"name\" | \"resolveContextualPrompt\">\n> & {\n doc: Doc | undefined;\n pud: PermanentUserData | undefined;\n};\n\n/**\n * The state of the AI toolbar.\n *\n * ┌────────────────────────────────────────────────────────────────────────────────┐\n * │ │\n * │ ┌──────────────────────────────────────────────┐ │\n * ▼ ▼ │ │\n * ┌───────$closeAiToolbar()───────┐ │ │\n * ▼ ◇ ◇ ◇\n * ┌───────────────────────┐ ┌───────────────────────┐ ┌───────────────────────┐ ┌───────────────────────┐\n * │ CLOSED │ │ ASKING │ │ THINKING │ │ REVIEWING │\n * └───────────────────────┘ └───────────────────────┘ └───────────────────────┘ └───────────────────────┘\n * ▲ ◇ ◇ ▲ ▲ ◇ ▲ ▲ ◇ ▲ ◇ ◇\n * │ │ └───$openAiToolbarAsking()──┘ │ │ └ ─ ─ ─ ─ ─ ─⚠─ ─ ─ ─ ─ ─ ─│─├── ─ ─ ─ ─ ─ ─✓─ ─ ─ ─ ─ ─ ─ ┘ │ │\n * │ │ │ ▼ │ │ │ │\n * │ └─────────────────$startAiToolbarThinking(prompt)──────────────┘ │ │ │\n * │ │ ▲ │ │ │\n * │ │ └──────────────────────────────┼───────────────────────────────┘ │\n * │ │ │ │\n * │ └───$cancelAiToolbarThinking()───┘ │\n * │ │\n * └─────────────────────────────────────$acceptAiToolbarResponse()─────────────────────────────────────┘\n *\n */\nexport type AiToolbarState = Relax<\n | {\n phase: \"closed\";\n }\n | {\n phase: \"asking\";\n\n /**\n * The selection stored when opening the AI toolbar.\n */\n initialSelection: Range;\n\n /**\n * The custom prompt being written in the toolbar.\n */\n customPrompt: string;\n\n /**\n * A potential error that occurred during the last AI request.\n */\n error?: Error;\n }\n | {\n phase: \"thinking\";\n\n /**\n * The selection stored when opening the AI toolbar.\n */\n initialSelection: Range;\n\n /**\n * The custom prompt being written in the toolbar.\n */\n customPrompt: string;\n\n /**\n * An abort controller to cancel the AI request.\n */\n abortController: AbortController;\n\n /**\n * The prompt sent to the AI.\n */\n prompt: string;\n\n /**\n * The previous response if this \"thinking\" phase is a refinement.\n */\n previousResponse?: ContextualPromptResponse;\n }\n | {\n phase: \"reviewing\";\n\n /**\n * The selection stored when opening the AI toolbar.\n */\n initialSelection: Range;\n\n /**\n * The custom prompt being written in the toolbar.\n */\n customPrompt: string;\n\n /**\n * The prompt sent to the AI.\n */\n prompt: string;\n\n /**\n * The response of the AI request.\n */\n response: ContextualPromptResponse;\n }\n>;\n\nexport type AiExtensionStorage = {\n name: string;\n state: AiToolbarState;\n snapshot?: Snapshot;\n};\n\ndeclare module \"@tiptap/core\" {\n interface Storage {\n liveblocksAi: AiExtensionStorage;\n liveblocksExtension: LiveblocksExtensionStorage;\n liveblocksComments: CommentsExtensionStorage;\n }\n // TODO: this is already defined in collaboration-caret, we shouldn't need it, but something isn't working\n // maybe because we use configure?\n interface Commands<ReturnType> {\n collaborationCaret: {\n /**\n * Update details of the current user\n * @example editor.commands.updateUser({ name: 'John Doe', color: '#305500' })\n */\n updateUser: (attributes: Record<string, any>) => ReturnType;\n /**\n * Update details of the current user\n *\n * @deprecated The \"user\" command is deprecated. Please use \"updateUser\" instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret\n */\n user: (attributes: Record<string, any>) => ReturnType;\n };\n\n collaboration: {\n /**\n * Undo recent changes\n * @example editor.commands.undo()\n */\n undo: () => ReturnType;\n /**\n * Reapply reverted changes\n * @example editor.commands.redo()\n */\n redo: () => ReturnType;\n };\n }\n}\nexport type ThreadPluginState = {\n threadPositions: Map<string, { from: number; to: number }>;\n activeThreadIds: string[];\n decorations: DecorationSet;\n};\n\nexport type FloatingPosition = \"top\" | \"bottom\";\n\nexport type ExtendedCommands<\n T extends string,\n A extends any[] = [],\n> = SingleCommands & Record<T, (...args: A) => boolean>;\n\nexport type ExtendedChainedCommands<\n T extends string,\n A extends any[] = [],\n> = ChainedCommands & Record<T, (...args: A) => ChainedCommands>;\n\nexport type ChainedAiCommands = ChainedCommands & {\n [K in keyof AiCommands]: (\n ...args: Parameters<AiCommands[K]>\n ) => ChainedCommands;\n};\n\nexport type CommentsCommands<ReturnType = boolean> = {\n /**\n * Add a comment\n */\n addComment: (id: string) => ReturnType;\n selectThread: (id: string | null) => ReturnType;\n addPendingComment: () => ReturnType;\n\n /** @internal */\n closePendingComment: () => ReturnType;\n};\n\nexport type AiCommands<ReturnType = boolean> = {\n /**\n * Open the AI toolbar, with an optional prompt.\n */\n askAi: (prompt?: string) => ReturnType;\n\n /**\n * Close the AI toolbar.\n */\n closeAi: () => ReturnType;\n\n // Transitions (see AiToolbarState)\n\n /**\n * @internal\n * @transition\n *\n * Close the AI toolbar.\n */\n $closeAiToolbar: () => ReturnType;\n\n /**\n * @internal\n * @transition\n *\n * Accept the current AI response and close the AI toolbar.\n */\n $acceptAiToolbarResponse: () => ReturnType;\n\n /**\n * @internal\n * @transition\n *\n * Open the AI toolbar in the \"asking\" phase.\n */\n $openAiToolbarAsking: () => ReturnType;\n\n /**\n * @internal\n * @transition\n *\n * Set (and open if not already open) the AI toolbar in the \"thinking\" phase with the given prompt.\n */\n $startAiToolbarThinking: (\n prompt: string,\n withPreviousResponse?: boolean\n ) => ReturnType;\n\n /**\n * @internal\n * @transition\n *\n * Cancel the current \"thinking\" phase, going back to the \"asking\" phase.\n */\n $cancelAiToolbarThinking: () => ReturnType;\n\n // Other\n\n /**\n * @internal\n *\n * Show the diff of the current \"reviewing\" phase.\n */\n _showAiToolbarReviewingDiff: () => ReturnType;\n\n /**\n * @internal\n *\n * Handle the success of the current \"thinking\" phase.\n */\n _handleAiToolbarThinkingSuccess: (\n response: ContextualPromptResponse\n ) => ReturnType;\n\n /**\n * @internal\n *\n * Handle an error of the current \"thinking\" phase.\n */\n _handleAiToolbarThinkingError: (error: unknown) => ReturnType;\n\n /**\n * @internal\n *\n * Update the current custom AI prompt.\n */\n _updateAiToolbarCustomPrompt: (\n customPrompt: string | ((currentCustomPrompt: string) => string)\n ) => ReturnType;\n};\n\nexport type YSyncPluginState = {\n binding: ProsemirrorBinding;\n};\n\nexport type TiptapMentionData = MentionData & {\n notificationId: string;\n};\n\nexport type SerializedTiptapMentionData = TiptapMentionData extends infer T\n ? T extends { kind: \"group\" }\n ? Omit<T, \"userIds\"> & { userIds?: string }\n : T\n : never;\n"],"names":["ThreadPluginActions"],"mappings":";;AAgBa,MAAA,sBAAA,GAAyB,IAAI,SAAA,CAAU,mBAAmB,EAAA;AAChE,MAAM,+BAA+B,IAAI,SAAA;AAAA,EAC9C,yBAAA;AACF,EAAA;AACO,MAAM,kCAAkC,IAAI,SAAA;AAAA,EACjD,0BAAA;AACF,EAAA;AAEO,MAAM,4BAA+B,GAAA,uBAAA;AACrC,MAAM,uBAA0B,GAAA,oBAAA;AAChC,MAAM,6BAAgC,GAAA,yBAAA;AAEtC,MAAM,kCAAkC,IAAI,SAAA;AAAA,EACjD,oCAAA;AACF,EAAA;AACO,MAAM,qBAAqB,IAAI,SAAA;AAAA,EACpC,mBAAA;AACF,EAAA;AACO,MAAM,8BAA8B,IAAI,SAAA;AAAA,EAC7C,gCAAA;AACF,EAAA;AAEO,MAAM,4BAA+B,GAAA,wBAAA;AAsF1B,IAAA,mBAAA,qBAAAA,oBAAX,KAAA;AACL,EAAAA,qBAAA,uBAAwB,CAAA,GAAA,uBAAA,CAAA;AADR,EAAAA,OAAAA,oBAAAA,CAAAA;AAAA,CAAA,EAAA,mBAAA,IAAA,EAAA;;;;"}
1
+ {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type {\n ContextualPromptContext,\n ContextualPromptResponse,\n MentionData,\n Relax,\n TextEditorType,\n ThreadData,\n} from \"@liveblocks/core\";\nimport type { LiveblocksYjsProvider } from \"@liveblocks/yjs\";\nimport type { Content, Range } from \"@tiptap/core\";\nimport { PluginKey } from \"@tiptap/pm/state\";\nimport type { DecorationSet } from \"@tiptap/pm/view\";\nimport type { ChainedCommands, SingleCommands } from \"@tiptap/react\";\nimport type { ProsemirrorBinding } from \"y-prosemirror\";\nimport type { Doc, PermanentUserData, Snapshot } from \"yjs\";\n\nexport const LIVEBLOCKS_MENTION_KEY = new PluginKey(\"lb-plugin-mention\");\nexport const LIVEBLOCKS_MENTION_PASTE_KEY = new PluginKey(\n \"lb-plugin-mention-paste\"\n);\nexport const LIVEBLOCKS_MENTION_NOTIFIER_KEY = new PluginKey(\n \"lb-plugin-mention-notify\"\n);\n\nexport const LIVEBLOCKS_MENTION_EXTENSION = \"liveblocksMentionExt\";\nexport const LIVEBLOCKS_MENTION_TYPE = \"liveblocksMention\";\nexport const LIVEBLOCKS_GROUP_MENTION_TYPE = \"liveblocksGroupMention\";\n\nexport const THREADS_ACTIVE_SELECTION_PLUGIN = new PluginKey(\n \"lb-threads-active-selection-plugin\"\n);\nexport const THREADS_PLUGIN_KEY = new PluginKey<ThreadPluginState>(\n \"lb-threads-plugin\"\n);\nexport const AI_TOOLBAR_SELECTION_PLUGIN = new PluginKey(\n \"lb-ai-toolbar-selection-plugin\"\n);\n\nexport const LIVEBLOCKS_COMMENT_MARK_TYPE = \"liveblocksCommentMark\";\n\n/**\n * @beta\n */\nexport type ResolveContextualPromptArgs = {\n /**\n * The prompt being requested by the user.\n */\n prompt: string;\n\n /**\n * The context of the document and its current selection.\n */\n context: ContextualPromptContext;\n\n /**\n * The previous request and its response, if this is a follow-up request.\n */\n previous?: {\n prompt: string;\n response: ContextualPromptResponse;\n };\n\n /**\n * An abort signal that can be used to cancel requests.\n */\n signal: AbortSignal;\n};\n\n/**\n * @beta\n */\nexport type ResolveContextualPromptResponse = ContextualPromptResponse;\n\nexport interface AiConfiguration {\n /**\n * The AI's name. (\"Ask {name} anything…\", \"{name} is thinking…\", etc)\n */\n name?: string;\n\n /**\n * A function that returns an a response to a contextual prompt.\n */\n resolveContextualPrompt?: (\n args: ResolveContextualPromptArgs\n ) => Promise<ContextualPromptResponse>;\n}\n\nexport type LiveblocksExtensionOptions = {\n collaborationMode?: \"yjs\" | \"liveblocks\";\n field?: string;\n comments?: boolean; // | CommentsConfiguration\n mentions?: boolean; // | MentionsConfiguration\n /**\n * @internal\n * Allows editor wrappers that add Liveblocks mention nodes through their own\n * schema layer to reuse the mention plugins without registering duplicate\n * TipTap node extensions.\n */\n mentionNodes?: boolean;\n ai?: boolean | AiConfiguration;\n offlineSupport_experimental?: boolean;\n threads_experimental?: ThreadData[];\n initialContent?: Content;\n enablePermanentUserData?: boolean;\n /**\n * @internal\n * For reporting another text editor type from a\n * text editor extended from `TipTap` such as our `BlockNote` integration.\n *\n * Only useful for Liveblocks developers, not for end users.\n */\n textEditorType?: TextEditorType;\n};\n\nexport type LiveblocksExtensionStorage =\n | {\n mode: \"yjs\";\n unsubs: (() => void)[];\n doc: Doc;\n provider: LiveblocksYjsProvider;\n permanentUserData?: PermanentUserData;\n }\n | {\n mode: \"liveblocks\";\n unsubs: (() => void)[];\n };\n\nexport type CommentsExtensionStorage = {\n pendingComment: boolean;\n};\n\nexport const enum ThreadPluginActions {\n SET_ACTIVE_THREAD_IDS = \"SET_ACTIVE_THREAD_IDS\",\n}\n\nexport type AiExtensionOptions = Required<\n Pick<AiConfiguration, \"name\" | \"resolveContextualPrompt\">\n> & {\n doc: Doc | undefined;\n pud: PermanentUserData | undefined;\n};\n\n/**\n * The state of the AI toolbar.\n *\n * ┌────────────────────────────────────────────────────────────────────────────────┐\n * │ │\n * │ ┌──────────────────────────────────────────────┐ │\n * ▼ ▼ │ │\n * ┌───────$closeAiToolbar()───────┐ │ │\n * ▼ ◇ ◇ ◇\n * ┌───────────────────────┐ ┌───────────────────────┐ ┌───────────────────────┐ ┌───────────────────────┐\n * │ CLOSED │ │ ASKING │ │ THINKING │ │ REVIEWING │\n * └───────────────────────┘ └───────────────────────┘ └───────────────────────┘ └───────────────────────┘\n * ▲ ◇ ◇ ▲ ▲ ◇ ▲ ▲ ◇ ▲ ◇ ◇\n * │ │ └───$openAiToolbarAsking()──┘ │ │ └ ─ ─ ─ ─ ─ ─⚠─ ─ ─ ─ ─ ─ ─│─├── ─ ─ ─ ─ ─ ─✓─ ─ ─ ─ ─ ─ ─ ┘ │ │\n * │ │ │ ▼ │ │ │ │\n * │ └─────────────────$startAiToolbarThinking(prompt)──────────────┘ │ │ │\n * │ │ ▲ │ │ │\n * │ │ └──────────────────────────────┼───────────────────────────────┘ │\n * │ │ │ │\n * │ └───$cancelAiToolbarThinking()───┘ │\n * │ │\n * └─────────────────────────────────────$acceptAiToolbarResponse()─────────────────────────────────────┘\n *\n */\nexport type AiToolbarState = Relax<\n | {\n phase: \"closed\";\n }\n | {\n phase: \"asking\";\n\n /**\n * The selection stored when opening the AI toolbar.\n */\n initialSelection: Range;\n\n /**\n * The custom prompt being written in the toolbar.\n */\n customPrompt: string;\n\n /**\n * A potential error that occurred during the last AI request.\n */\n error?: Error;\n }\n | {\n phase: \"thinking\";\n\n /**\n * The selection stored when opening the AI toolbar.\n */\n initialSelection: Range;\n\n /**\n * The custom prompt being written in the toolbar.\n */\n customPrompt: string;\n\n /**\n * An abort controller to cancel the AI request.\n */\n abortController: AbortController;\n\n /**\n * The prompt sent to the AI.\n */\n prompt: string;\n\n /**\n * The previous response if this \"thinking\" phase is a refinement.\n */\n previousResponse?: ContextualPromptResponse;\n }\n | {\n phase: \"reviewing\";\n\n /**\n * The selection stored when opening the AI toolbar.\n */\n initialSelection: Range;\n\n /**\n * The custom prompt being written in the toolbar.\n */\n customPrompt: string;\n\n /**\n * The prompt sent to the AI.\n */\n prompt: string;\n\n /**\n * The response of the AI request.\n */\n response: ContextualPromptResponse;\n }\n>;\n\nexport type AiExtensionStorage = {\n name: string;\n state: AiToolbarState;\n snapshot?: Snapshot;\n};\n\ndeclare module \"@tiptap/core\" {\n interface Storage {\n liveblocksAi: AiExtensionStorage;\n liveblocksExtension: LiveblocksExtensionStorage;\n liveblocksComments: CommentsExtensionStorage;\n }\n // TODO: this is already defined in collaboration-caret, we shouldn't need it, but something isn't working\n // maybe because we use configure?\n interface Commands<ReturnType> {\n collaborationCaret: {\n /**\n * Update details of the current user\n * @example editor.commands.updateUser({ name: 'John Doe', color: '#305500' })\n */\n updateUser: (attributes: Record<string, any>) => ReturnType;\n /**\n * Update details of the current user\n *\n * @deprecated The \"user\" command is deprecated. Please use \"updateUser\" instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret\n */\n user: (attributes: Record<string, any>) => ReturnType;\n };\n\n collaboration: {\n /**\n * Undo recent changes\n * @example editor.commands.undo()\n */\n undo: () => ReturnType;\n /**\n * Reapply reverted changes\n * @example editor.commands.redo()\n */\n redo: () => ReturnType;\n };\n }\n}\nexport type ThreadPluginState = {\n threadPositions: Map<string, { from: number; to: number }>;\n activeThreadIds: string[];\n decorations: DecorationSet;\n};\n\nexport type FloatingPosition = \"top\" | \"bottom\";\n\nexport type ExtendedCommands<\n T extends string,\n A extends any[] = [],\n> = SingleCommands & Record<T, (...args: A) => boolean>;\n\nexport type ExtendedChainedCommands<\n T extends string,\n A extends any[] = [],\n> = ChainedCommands & Record<T, (...args: A) => ChainedCommands>;\n\nexport type ChainedAiCommands = ChainedCommands & {\n [K in keyof AiCommands]: (\n ...args: Parameters<AiCommands[K]>\n ) => ChainedCommands;\n};\n\nexport type CommentsCommands<ReturnType = boolean> = {\n /**\n * Add a comment\n */\n addComment: (id: string) => ReturnType;\n selectThread: (id: string | null) => ReturnType;\n addPendingComment: () => ReturnType;\n\n /** @internal */\n closePendingComment: () => ReturnType;\n};\n\nexport type AiCommands<ReturnType = boolean> = {\n /**\n * Open the AI toolbar, with an optional prompt.\n */\n askAi: (prompt?: string) => ReturnType;\n\n /**\n * Close the AI toolbar.\n */\n closeAi: () => ReturnType;\n\n // Transitions (see AiToolbarState)\n\n /**\n * @internal\n * @transition\n *\n * Close the AI toolbar.\n */\n $closeAiToolbar: () => ReturnType;\n\n /**\n * @internal\n * @transition\n *\n * Accept the current AI response and close the AI toolbar.\n */\n $acceptAiToolbarResponse: () => ReturnType;\n\n /**\n * @internal\n * @transition\n *\n * Open the AI toolbar in the \"asking\" phase.\n */\n $openAiToolbarAsking: () => ReturnType;\n\n /**\n * @internal\n * @transition\n *\n * Set (and open if not already open) the AI toolbar in the \"thinking\" phase with the given prompt.\n */\n $startAiToolbarThinking: (\n prompt: string,\n withPreviousResponse?: boolean\n ) => ReturnType;\n\n /**\n * @internal\n * @transition\n *\n * Cancel the current \"thinking\" phase, going back to the \"asking\" phase.\n */\n $cancelAiToolbarThinking: () => ReturnType;\n\n // Other\n\n /**\n * @internal\n *\n * Show the diff of the current \"reviewing\" phase.\n */\n _showAiToolbarReviewingDiff: () => ReturnType;\n\n /**\n * @internal\n *\n * Handle the success of the current \"thinking\" phase.\n */\n _handleAiToolbarThinkingSuccess: (\n response: ContextualPromptResponse\n ) => ReturnType;\n\n /**\n * @internal\n *\n * Handle an error of the current \"thinking\" phase.\n */\n _handleAiToolbarThinkingError: (error: unknown) => ReturnType;\n\n /**\n * @internal\n *\n * Update the current custom AI prompt.\n */\n _updateAiToolbarCustomPrompt: (\n customPrompt: string | ((currentCustomPrompt: string) => string)\n ) => ReturnType;\n};\n\nexport type YSyncPluginState = {\n binding: ProsemirrorBinding;\n};\n\nexport type TiptapMentionData = MentionData & {\n notificationId: string;\n};\n\nexport type SerializedTiptapMentionData = TiptapMentionData extends infer T\n ? T extends { kind: \"group\" }\n ? Omit<T, \"userIds\"> & { userIds?: string }\n : T\n : never;\n"],"names":["ThreadPluginActions"],"mappings":";;AAgBa,MAAA,sBAAA,GAAyB,IAAI,SAAA,CAAU,mBAAmB,EAAA;AAChE,MAAM,+BAA+B,IAAI,SAAA;AAAA,EAC9C,yBAAA;AACF,EAAA;AACO,MAAM,kCAAkC,IAAI,SAAA;AAAA,EACjD,0BAAA;AACF,EAAA;AAEO,MAAM,4BAA+B,GAAA,uBAAA;AACrC,MAAM,uBAA0B,GAAA,oBAAA;AAChC,MAAM,6BAAgC,GAAA,yBAAA;AAEtC,MAAM,kCAAkC,IAAI,SAAA;AAAA,EACjD,oCAAA;AACF,EAAA;AACO,MAAM,qBAAqB,IAAI,SAAA;AAAA,EACpC,mBAAA;AACF,EAAA;AACO,MAAM,8BAA8B,IAAI,SAAA;AAAA,EAC7C,gCAAA;AACF,EAAA;AAEO,MAAM,4BAA+B,GAAA,wBAAA;AA6F1B,IAAA,mBAAA,qBAAAA,oBAAX,KAAA;AACL,EAAAA,qBAAA,uBAAwB,CAAA,GAAA,uBAAA,CAAA;AADR,EAAAA,OAAAA,oBAAAA,CAAAA;AAAA,CAAA,EAAA,mBAAA,IAAA,EAAA;;;;"}
package/dist/version.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const PKG_NAME = "@liveblocks/react-tiptap";
4
- const PKG_VERSION = typeof "3.21.0-exp1" === "string" && "3.21.0-exp1";
4
+ const PKG_VERSION = typeof "3.21.0-exp10" === "string" && "3.21.0-exp10";
5
5
  const PKG_FORMAT = typeof "cjs" === "string" && "cjs";
6
6
 
7
7
  exports.PKG_FORMAT = PKG_FORMAT;
@@ -1 +1 @@
1
- {"version":3,"file":"version.cjs","sources":["../src/version.ts"],"sourcesContent":["declare const __VERSION__: string;\ndeclare const ROLLUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react-tiptap\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof ROLLUP_FORMAT === \"string\" && ROLLUP_FORMAT;\n"],"names":[],"mappings":";;AAGO,MAAM,QAAW,GAAA,2BAAA;AACX,MAAA,WAAA,GAAc,OAAO,aAAA,KAAgB,QAAY,IAAA,cAAA;AACjD,MAAA,UAAA,GAAa,OAAO,KAAA,KAAkB,QAAY,IAAA;;;;;;"}
1
+ {"version":3,"file":"version.cjs","sources":["../src/version.ts"],"sourcesContent":["declare const __VERSION__: string;\ndeclare const ROLLUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react-tiptap\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof ROLLUP_FORMAT === \"string\" && ROLLUP_FORMAT;\n"],"names":[],"mappings":";;AAGO,MAAM,QAAW,GAAA,2BAAA;AACX,MAAA,WAAA,GAAc,OAAO,cAAA,KAAgB,QAAY,IAAA,eAAA;AACjD,MAAA,UAAA,GAAa,OAAO,KAAA,KAAkB,QAAY,IAAA;;;;;;"}
package/dist/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const PKG_NAME = "@liveblocks/react-tiptap";
2
- const PKG_VERSION = typeof "3.21.0-exp1" === "string" && "3.21.0-exp1";
2
+ const PKG_VERSION = typeof "3.21.0-exp10" === "string" && "3.21.0-exp10";
3
3
  const PKG_FORMAT = typeof "esm" === "string" && "esm";
4
4
 
5
5
  export { PKG_FORMAT, PKG_NAME, PKG_VERSION };
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../src/version.ts"],"sourcesContent":["declare const __VERSION__: string;\ndeclare const ROLLUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react-tiptap\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof ROLLUP_FORMAT === \"string\" && ROLLUP_FORMAT;\n"],"names":[],"mappings":"AAGO,MAAM,QAAW,GAAA,2BAAA;AACX,MAAA,WAAA,GAAc,OAAO,aAAA,KAAgB,QAAY,IAAA,cAAA;AACjD,MAAA,UAAA,GAAa,OAAO,KAAA,KAAkB,QAAY,IAAA;;;;"}
1
+ {"version":3,"file":"version.js","sources":["../src/version.ts"],"sourcesContent":["declare const __VERSION__: string;\ndeclare const ROLLUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react-tiptap\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof ROLLUP_FORMAT === \"string\" && ROLLUP_FORMAT;\n"],"names":[],"mappings":"AAGO,MAAM,QAAW,GAAA,2BAAA;AACX,MAAA,WAAA,GAAc,OAAO,cAAA,KAAgB,QAAY,IAAA,eAAA;AACjD,MAAA,UAAA,GAAa,OAAO,KAAA,KAAkB,QAAY,IAAA;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveblocks/react-tiptap",
3
- "version": "3.21.0-exp1",
3
+ "version": "3.21.0-exp10",
4
4
  "description": "An integration of TipTap + React to enable collaboration, comments, live cursors, and more with Liveblocks.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Liveblocks Inc.",
@@ -37,11 +37,12 @@
37
37
  "cmdk": "^1.0.4",
38
38
  "radix-ui": "^1.4.0",
39
39
  "y-prosemirror": "^1.3.7",
40
- "@liveblocks/client": "3.21.0-exp1",
41
- "@liveblocks/react": "3.21.0-exp1",
42
- "@liveblocks/core": "3.21.0-exp1",
43
- "@liveblocks/react-ui": "3.21.0-exp1",
44
- "@liveblocks/yjs": "3.21.0-exp1"
40
+ "@liveblocks/client": "3.21.0-exp10",
41
+ "@liveblocks/core": "3.21.0-exp10",
42
+ "@liveblocks/prosemirror": "3.21.0-exp10",
43
+ "@liveblocks/react-ui": "3.21.0-exp10",
44
+ "@liveblocks/react": "3.21.0-exp10",
45
+ "@liveblocks/yjs": "3.21.0-exp10"
45
46
  },
46
47
  "peerDependencies": {
47
48
  "@tiptap/core": "^3",
@@ -1,218 +0,0 @@
1
- 'use strict';
2
-
3
- var schema = require('./schema.cjs');
4
-
5
- function selectionToLiveblocksPosition(selection) {
6
- return {
7
- anchor: selection.anchor,
8
- head: selection.head
9
- };
10
- }
11
- function clampLiveblocksPosition(position, max) {
12
- return {
13
- anchor: Math.max(0, Math.min(position.anchor, max)),
14
- head: Math.max(0, Math.min(position.head, max))
15
- };
16
- }
17
- function childStart(parent, parentPos) {
18
- return parent.type.name === "doc" ? parentPos : parentPos + 1;
19
- }
20
- function indexChildren(nodeRanges, listRanges, textRanges, pmParent, liveParent, parentPos) {
21
- const liveContent = schema.getLiveblocksNodeContent(liveParent);
22
- if (liveContent === void 0) {
23
- return;
24
- }
25
- listRanges.push({
26
- content: liveContent,
27
- from: parentPos,
28
- node: liveParent,
29
- nodeId: schema.getLiveblocksNodeId(liveParent),
30
- pmNode: pmParent,
31
- to: parentPos + pmParent.nodeSize
32
- });
33
- let pmChildIndex = 0;
34
- let pmOffset = 0;
35
- const start = childStart(pmParent, parentPos);
36
- for (let liveIndex = 0; liveIndex < liveContent.length; liveIndex++) {
37
- const liveChild = liveContent.get(liveIndex);
38
- const pmChild = pmParent.maybeChild(pmChildIndex);
39
- if (liveChild === void 0 || pmChild === null) {
40
- return;
41
- }
42
- const from = start + pmOffset;
43
- const to = from + pmChild.nodeSize;
44
- nodeRanges.push({
45
- childIndex: liveIndex,
46
- content: liveContent,
47
- from,
48
- node: liveChild,
49
- nodeId: schema.getLiveblocksNodeId(liveChild),
50
- parent: liveParent,
51
- pmNode: pmChild,
52
- to
53
- });
54
- if (schema.getLiveblocksNodeType(liveChild) === "text") {
55
- const text = schema.getLiveblocksNodeText(liveChild);
56
- if (text === void 0) {
57
- return;
58
- }
59
- let liveOffset = 0;
60
- let remaining = text.length;
61
- while (remaining > 0) {
62
- const textChild = pmParent.maybeChild(pmChildIndex);
63
- if (textChild === null || !textChild.isText) {
64
- return;
65
- }
66
- const length = Math.min(remaining, textChild.nodeSize);
67
- const textFrom = start + pmOffset;
68
- textRanges.push({
69
- from: textFrom,
70
- to: textFrom + length,
71
- liveOffset,
72
- node: liveChild,
73
- nodeId: schema.getLiveblocksNodeId(liveChild),
74
- text
75
- });
76
- liveOffset += length;
77
- remaining -= length;
78
- pmOffset += textChild.nodeSize;
79
- pmChildIndex++;
80
- }
81
- } else {
82
- indexChildren(
83
- nodeRanges,
84
- listRanges,
85
- textRanges,
86
- pmChild,
87
- liveChild,
88
- from
89
- );
90
- pmOffset += pmChild.nodeSize;
91
- pmChildIndex++;
92
- }
93
- }
94
- }
95
- function buildLiveblocksTreeIndex(pmDoc, liveRoot) {
96
- const nodeRanges = [
97
- {
98
- from: 0,
99
- node: liveRoot,
100
- nodeId: schema.getLiveblocksNodeId(liveRoot),
101
- pmNode: pmDoc,
102
- to: pmDoc.content.size
103
- }
104
- ];
105
- const listRanges = [];
106
- const textRanges = [];
107
- indexChildren(nodeRanges, listRanges, textRanges, pmDoc, liveRoot, 0);
108
- return { listRanges, nodeRanges, textRanges };
109
- }
110
- function findTextRangeAtPosition(index, position) {
111
- return index.textRanges.find(
112
- (range) => position >= range.from && position <= range.to
113
- );
114
- }
115
- function findTextRangeAtPositionInChildren(pmParent, liveParent, parentPos, position) {
116
- const liveContent = schema.getLiveblocksNodeContent(liveParent);
117
- if (liveContent === void 0) {
118
- return void 0;
119
- }
120
- let pmChildIndex = 0;
121
- let pmOffset = 0;
122
- const start = childStart(pmParent, parentPos);
123
- for (let liveIndex = 0; liveIndex < liveContent.length; liveIndex++) {
124
- const liveChild = liveContent.get(liveIndex);
125
- const pmChild = pmParent.maybeChild(pmChildIndex);
126
- if (liveChild === void 0 || pmChild === null) {
127
- return void 0;
128
- }
129
- if (schema.getLiveblocksNodeType(liveChild) === "text") {
130
- const text = schema.getLiveblocksNodeText(liveChild);
131
- if (text === void 0) {
132
- return void 0;
133
- }
134
- let liveOffset = 0;
135
- let remaining = text.length;
136
- while (remaining > 0) {
137
- const textChild = pmParent.maybeChild(pmChildIndex);
138
- if (textChild === null || !textChild.isText) {
139
- return void 0;
140
- }
141
- const length = Math.min(remaining, textChild.nodeSize);
142
- const from = start + pmOffset;
143
- const to = from + length;
144
- if (position >= from && position <= to) {
145
- return {
146
- from,
147
- to,
148
- liveOffset,
149
- node: liveChild,
150
- nodeId: schema.getLiveblocksNodeId(liveChild),
151
- text
152
- };
153
- }
154
- liveOffset += length;
155
- remaining -= length;
156
- pmOffset += textChild.nodeSize;
157
- pmChildIndex++;
158
- }
159
- } else {
160
- const from = start + pmOffset;
161
- const to = from + pmChild.nodeSize;
162
- if (position >= from && position <= to) {
163
- return findTextRangeAtPositionInChildren(
164
- pmChild,
165
- liveChild,
166
- from,
167
- position
168
- );
169
- }
170
- pmOffset += pmChild.nodeSize;
171
- pmChildIndex++;
172
- }
173
- }
174
- return void 0;
175
- }
176
- function findTextRangeAtPositionInDocument(pmDoc, liveRoot, position) {
177
- return findTextRangeAtPositionInChildren(pmDoc, liveRoot, 0, position);
178
- }
179
- function findTextRangesInRange(index, from, to) {
180
- return index.textRanges.filter(
181
- (range) => Math.max(range.from, from) < Math.min(range.to, to)
182
- );
183
- }
184
- function findTextRangeByLiveText(index, text) {
185
- return index.textRanges.find((range) => range.text === text);
186
- }
187
- function findNodeRangeByLiveNode(index, node) {
188
- return index.nodeRanges.find((range) => range.node === node);
189
- }
190
- function findListRangeByLiveList(index, content) {
191
- return index.listRanges.find((range) => range.content === content);
192
- }
193
- function getChildPosition(parent, parentPos, index) {
194
- if (index < 0 || index > parent.childCount) {
195
- return void 0;
196
- }
197
- let offset = 0;
198
- for (let childIndex = 0; childIndex < index; childIndex++) {
199
- const child = parent.maybeChild(childIndex);
200
- if (child === null) {
201
- return void 0;
202
- }
203
- offset += child.nodeSize;
204
- }
205
- return childStart(parent, parentPos) + offset;
206
- }
207
-
208
- exports.buildLiveblocksTreeIndex = buildLiveblocksTreeIndex;
209
- exports.clampLiveblocksPosition = clampLiveblocksPosition;
210
- exports.findListRangeByLiveList = findListRangeByLiveList;
211
- exports.findNodeRangeByLiveNode = findNodeRangeByLiveNode;
212
- exports.findTextRangeAtPosition = findTextRangeAtPosition;
213
- exports.findTextRangeAtPositionInDocument = findTextRangeAtPositionInDocument;
214
- exports.findTextRangeByLiveText = findTextRangeByLiveText;
215
- exports.findTextRangesInRange = findTextRangesInRange;
216
- exports.getChildPosition = getChildPosition;
217
- exports.selectionToLiveblocksPosition = selectionToLiveblocksPosition;
218
- //# sourceMappingURL=mapping.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mapping.cjs","sources":["../../src/collaboration-liveblocks/mapping.ts"],"sourcesContent":["import type { LiveList, LiveText } from \"@liveblocks/client\";\nimport type { Node as ProseMirrorNode } from \"@tiptap/pm/model\";\nimport type { Selection } from \"@tiptap/pm/state\";\n\nimport {\n getLiveblocksNodeContent,\n getLiveblocksNodeId,\n getLiveblocksNodeText,\n getLiveblocksNodeType,\n type LiveblocksTiptapNode,\n} from \"./schema\";\n\nexport type LiveblocksTiptapPosition = {\n anchor: number;\n head: number;\n};\n\nexport function selectionToLiveblocksPosition(\n selection: Selection\n): LiveblocksTiptapPosition {\n return {\n anchor: selection.anchor,\n head: selection.head,\n };\n}\n\nexport function clampLiveblocksPosition(\n position: LiveblocksTiptapPosition,\n max: number\n): LiveblocksTiptapPosition {\n return {\n anchor: Math.max(0, Math.min(position.anchor, max)),\n head: Math.max(0, Math.min(position.head, max)),\n };\n}\n\nexport type LiveblocksTextRange = {\n from: number;\n to: number;\n liveOffset: number;\n node: LiveblocksTiptapNode;\n nodeId: string;\n text: LiveText;\n};\n\nexport type LiveblocksNodeRange = {\n childIndex?: number;\n content?: LiveList<LiveblocksTiptapNode>;\n from: number;\n node: LiveblocksTiptapNode;\n nodeId: string;\n parent?: LiveblocksTiptapNode;\n pmNode: ProseMirrorNode;\n to: number;\n};\n\nexport type LiveblocksListRange = {\n content: LiveList<LiveblocksTiptapNode>;\n from: number;\n node: LiveblocksTiptapNode;\n nodeId: string;\n pmNode: ProseMirrorNode;\n to: number;\n};\n\nexport type LiveblocksTreeIndex = {\n listRanges: LiveblocksListRange[];\n nodeRanges: LiveblocksNodeRange[];\n textRanges: LiveblocksTextRange[];\n};\n\nfunction childStart(parent: ProseMirrorNode, parentPos: number): number {\n return parent.type.name === \"doc\" ? parentPos : parentPos + 1;\n}\n\nfunction indexChildren(\n nodeRanges: LiveblocksNodeRange[],\n listRanges: LiveblocksListRange[],\n textRanges: LiveblocksTextRange[],\n pmParent: ProseMirrorNode,\n liveParent: LiveblocksTiptapNode,\n parentPos: number\n): void {\n const liveContent = getLiveblocksNodeContent(liveParent);\n if (liveContent === undefined) {\n return;\n }\n\n listRanges.push({\n content: liveContent,\n from: parentPos,\n node: liveParent,\n nodeId: getLiveblocksNodeId(liveParent),\n pmNode: pmParent,\n to: parentPos + pmParent.nodeSize,\n });\n\n let pmChildIndex = 0;\n let pmOffset = 0;\n const start = childStart(pmParent, parentPos);\n\n for (let liveIndex = 0; liveIndex < liveContent.length; liveIndex++) {\n const liveChild = liveContent.get(liveIndex);\n const pmChild = pmParent.maybeChild(pmChildIndex);\n if (liveChild === undefined || pmChild === null) {\n return;\n }\n\n const from = start + pmOffset;\n const to = from + pmChild.nodeSize;\n\n nodeRanges.push({\n childIndex: liveIndex,\n content: liveContent,\n from,\n node: liveChild,\n nodeId: getLiveblocksNodeId(liveChild),\n parent: liveParent,\n pmNode: pmChild,\n to,\n });\n\n if (getLiveblocksNodeType(liveChild) === \"text\") {\n const text = getLiveblocksNodeText(liveChild);\n if (text === undefined) {\n return;\n }\n\n let liveOffset = 0;\n let remaining = text.length;\n\n while (remaining > 0) {\n const textChild = pmParent.maybeChild(pmChildIndex);\n if (textChild === null || !textChild.isText) {\n return;\n }\n\n const length = Math.min(remaining, textChild.nodeSize);\n const textFrom = start + pmOffset;\n\n textRanges.push({\n from: textFrom,\n to: textFrom + length,\n liveOffset,\n node: liveChild,\n nodeId: getLiveblocksNodeId(liveChild),\n text,\n });\n\n liveOffset += length;\n remaining -= length;\n pmOffset += textChild.nodeSize;\n pmChildIndex++;\n }\n } else {\n indexChildren(\n nodeRanges,\n listRanges,\n textRanges,\n pmChild,\n liveChild,\n from\n );\n pmOffset += pmChild.nodeSize;\n pmChildIndex++;\n }\n }\n}\n\nexport function buildLiveblocksTreeIndex(\n pmDoc: ProseMirrorNode,\n liveRoot: LiveblocksTiptapNode\n): LiveblocksTreeIndex {\n const nodeRanges: LiveblocksNodeRange[] = [\n {\n from: 0,\n node: liveRoot,\n nodeId: getLiveblocksNodeId(liveRoot),\n pmNode: pmDoc,\n to: pmDoc.content.size,\n },\n ];\n const listRanges: LiveblocksListRange[] = [];\n const textRanges: LiveblocksTextRange[] = [];\n indexChildren(nodeRanges, listRanges, textRanges, pmDoc, liveRoot, 0);\n return { listRanges, nodeRanges, textRanges };\n}\n\nexport function findTextRangeAtPosition(\n index: LiveblocksTreeIndex,\n position: number\n): LiveblocksTextRange | undefined {\n return index.textRanges.find(\n (range) => position >= range.from && position <= range.to\n );\n}\n\nfunction findTextRangeAtPositionInChildren(\n pmParent: ProseMirrorNode,\n liveParent: LiveblocksTiptapNode,\n parentPos: number,\n position: number\n): LiveblocksTextRange | undefined {\n const liveContent = getLiveblocksNodeContent(liveParent);\n if (liveContent === undefined) {\n return undefined;\n }\n\n let pmChildIndex = 0;\n let pmOffset = 0;\n const start = childStart(pmParent, parentPos);\n\n for (let liveIndex = 0; liveIndex < liveContent.length; liveIndex++) {\n const liveChild = liveContent.get(liveIndex);\n const pmChild = pmParent.maybeChild(pmChildIndex);\n if (liveChild === undefined || pmChild === null) {\n return undefined;\n }\n\n if (getLiveblocksNodeType(liveChild) === \"text\") {\n const text = getLiveblocksNodeText(liveChild);\n if (text === undefined) {\n return undefined;\n }\n\n let liveOffset = 0;\n let remaining = text.length;\n\n while (remaining > 0) {\n const textChild = pmParent.maybeChild(pmChildIndex);\n if (textChild === null || !textChild.isText) {\n return undefined;\n }\n\n const length = Math.min(remaining, textChild.nodeSize);\n const from = start + pmOffset;\n const to = from + length;\n\n if (position >= from && position <= to) {\n return {\n from,\n to,\n liveOffset,\n node: liveChild,\n nodeId: getLiveblocksNodeId(liveChild),\n text,\n };\n }\n\n liveOffset += length;\n remaining -= length;\n pmOffset += textChild.nodeSize;\n pmChildIndex++;\n }\n } else {\n const from = start + pmOffset;\n const to = from + pmChild.nodeSize;\n\n if (position >= from && position <= to) {\n return findTextRangeAtPositionInChildren(\n pmChild,\n liveChild,\n from,\n position\n );\n }\n\n pmOffset += pmChild.nodeSize;\n pmChildIndex++;\n }\n }\n\n return undefined;\n}\n\nexport function findTextRangeAtPositionInDocument(\n pmDoc: ProseMirrorNode,\n liveRoot: LiveblocksTiptapNode,\n position: number\n): LiveblocksTextRange | undefined {\n return findTextRangeAtPositionInChildren(pmDoc, liveRoot, 0, position);\n}\n\nexport function findTextRangesInRange(\n index: LiveblocksTreeIndex,\n from: number,\n to: number\n): LiveblocksTextRange[] {\n return index.textRanges.filter(\n (range) => Math.max(range.from, from) < Math.min(range.to, to)\n );\n}\n\nexport function findTextRangeByLiveText(\n index: LiveblocksTreeIndex,\n text: LiveText\n): LiveblocksTextRange | undefined {\n return index.textRanges.find((range) => range.text === text);\n}\n\nexport function findNodeRangeByLiveNode(\n index: LiveblocksTreeIndex,\n node: LiveblocksTiptapNode\n): LiveblocksNodeRange | undefined {\n return index.nodeRanges.find((range) => range.node === node);\n}\n\nexport function findListRangeByLiveList(\n index: LiveblocksTreeIndex,\n content: unknown\n): LiveblocksListRange | undefined {\n return index.listRanges.find((range) => range.content === content);\n}\n\nexport function getChildPosition(\n parent: ProseMirrorNode,\n parentPos: number,\n index: number\n): number | undefined {\n if (index < 0 || index > parent.childCount) {\n return undefined;\n }\n\n let offset = 0;\n for (let childIndex = 0; childIndex < index; childIndex++) {\n const child = parent.maybeChild(childIndex);\n if (child === null) {\n return undefined;\n }\n\n offset += child.nodeSize;\n }\n\n return childStart(parent, parentPos) + offset;\n}\n"],"names":["getLiveblocksNodeContent","getLiveblocksNodeId","getLiveblocksNodeType","getLiveblocksNodeText"],"mappings":";;;;AAiBO,SAAS,8BACd,SAC0B,EAAA;AAC1B,EAAO,OAAA;AAAA,IACL,QAAQ,SAAU,CAAA,MAAA;AAAA,IAClB,MAAM,SAAU,CAAA,IAAA;AAAA,GAClB,CAAA;AACF,CAAA;AAEgB,SAAA,uBAAA,CACd,UACA,GAC0B,EAAA;AAC1B,EAAO,OAAA;AAAA,IACL,MAAA,EAAQ,KAAK,GAAI,CAAA,CAAA,EAAG,KAAK,GAAI,CAAA,QAAA,CAAS,MAA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A,CAAA;AAC1C,IAAA,IAAI,UAAU,IAAM,EAAA;AAClB,MAAO,OAAA,KAAA,CAAA,CAAA;AAAA,KACT;AAEA,IAAA,MAAA,IAAU,KAAM,CAAA,QAAA,CAAA;AAAA,GAClB;AAEA,EAAO,OAAA,UAAA,CAAW,MAAQ,EAAA,SAAS,CAAI,GAAA,MAAA,CAAA;AACzC;;;;;;;;;;;;;"}
@@ -1,207 +0,0 @@
1
- import { getLiveblocksNodeContent, getLiveblocksNodeId, getLiveblocksNodeType, getLiveblocksNodeText } from './schema.js';
2
-
3
- function selectionToLiveblocksPosition(selection) {
4
- return {
5
- anchor: selection.anchor,
6
- head: selection.head
7
- };
8
- }
9
- function clampLiveblocksPosition(position, max) {
10
- return {
11
- anchor: Math.max(0, Math.min(position.anchor, max)),
12
- head: Math.max(0, Math.min(position.head, max))
13
- };
14
- }
15
- function childStart(parent, parentPos) {
16
- return parent.type.name === "doc" ? parentPos : parentPos + 1;
17
- }
18
- function indexChildren(nodeRanges, listRanges, textRanges, pmParent, liveParent, parentPos) {
19
- const liveContent = getLiveblocksNodeContent(liveParent);
20
- if (liveContent === void 0) {
21
- return;
22
- }
23
- listRanges.push({
24
- content: liveContent,
25
- from: parentPos,
26
- node: liveParent,
27
- nodeId: getLiveblocksNodeId(liveParent),
28
- pmNode: pmParent,
29
- to: parentPos + pmParent.nodeSize
30
- });
31
- let pmChildIndex = 0;
32
- let pmOffset = 0;
33
- const start = childStart(pmParent, parentPos);
34
- for (let liveIndex = 0; liveIndex < liveContent.length; liveIndex++) {
35
- const liveChild = liveContent.get(liveIndex);
36
- const pmChild = pmParent.maybeChild(pmChildIndex);
37
- if (liveChild === void 0 || pmChild === null) {
38
- return;
39
- }
40
- const from = start + pmOffset;
41
- const to = from + pmChild.nodeSize;
42
- nodeRanges.push({
43
- childIndex: liveIndex,
44
- content: liveContent,
45
- from,
46
- node: liveChild,
47
- nodeId: getLiveblocksNodeId(liveChild),
48
- parent: liveParent,
49
- pmNode: pmChild,
50
- to
51
- });
52
- if (getLiveblocksNodeType(liveChild) === "text") {
53
- const text = getLiveblocksNodeText(liveChild);
54
- if (text === void 0) {
55
- return;
56
- }
57
- let liveOffset = 0;
58
- let remaining = text.length;
59
- while (remaining > 0) {
60
- const textChild = pmParent.maybeChild(pmChildIndex);
61
- if (textChild === null || !textChild.isText) {
62
- return;
63
- }
64
- const length = Math.min(remaining, textChild.nodeSize);
65
- const textFrom = start + pmOffset;
66
- textRanges.push({
67
- from: textFrom,
68
- to: textFrom + length,
69
- liveOffset,
70
- node: liveChild,
71
- nodeId: getLiveblocksNodeId(liveChild),
72
- text
73
- });
74
- liveOffset += length;
75
- remaining -= length;
76
- pmOffset += textChild.nodeSize;
77
- pmChildIndex++;
78
- }
79
- } else {
80
- indexChildren(
81
- nodeRanges,
82
- listRanges,
83
- textRanges,
84
- pmChild,
85
- liveChild,
86
- from
87
- );
88
- pmOffset += pmChild.nodeSize;
89
- pmChildIndex++;
90
- }
91
- }
92
- }
93
- function buildLiveblocksTreeIndex(pmDoc, liveRoot) {
94
- const nodeRanges = [
95
- {
96
- from: 0,
97
- node: liveRoot,
98
- nodeId: getLiveblocksNodeId(liveRoot),
99
- pmNode: pmDoc,
100
- to: pmDoc.content.size
101
- }
102
- ];
103
- const listRanges = [];
104
- const textRanges = [];
105
- indexChildren(nodeRanges, listRanges, textRanges, pmDoc, liveRoot, 0);
106
- return { listRanges, nodeRanges, textRanges };
107
- }
108
- function findTextRangeAtPosition(index, position) {
109
- return index.textRanges.find(
110
- (range) => position >= range.from && position <= range.to
111
- );
112
- }
113
- function findTextRangeAtPositionInChildren(pmParent, liveParent, parentPos, position) {
114
- const liveContent = getLiveblocksNodeContent(liveParent);
115
- if (liveContent === void 0) {
116
- return void 0;
117
- }
118
- let pmChildIndex = 0;
119
- let pmOffset = 0;
120
- const start = childStart(pmParent, parentPos);
121
- for (let liveIndex = 0; liveIndex < liveContent.length; liveIndex++) {
122
- const liveChild = liveContent.get(liveIndex);
123
- const pmChild = pmParent.maybeChild(pmChildIndex);
124
- if (liveChild === void 0 || pmChild === null) {
125
- return void 0;
126
- }
127
- if (getLiveblocksNodeType(liveChild) === "text") {
128
- const text = getLiveblocksNodeText(liveChild);
129
- if (text === void 0) {
130
- return void 0;
131
- }
132
- let liveOffset = 0;
133
- let remaining = text.length;
134
- while (remaining > 0) {
135
- const textChild = pmParent.maybeChild(pmChildIndex);
136
- if (textChild === null || !textChild.isText) {
137
- return void 0;
138
- }
139
- const length = Math.min(remaining, textChild.nodeSize);
140
- const from = start + pmOffset;
141
- const to = from + length;
142
- if (position >= from && position <= to) {
143
- return {
144
- from,
145
- to,
146
- liveOffset,
147
- node: liveChild,
148
- nodeId: getLiveblocksNodeId(liveChild),
149
- text
150
- };
151
- }
152
- liveOffset += length;
153
- remaining -= length;
154
- pmOffset += textChild.nodeSize;
155
- pmChildIndex++;
156
- }
157
- } else {
158
- const from = start + pmOffset;
159
- const to = from + pmChild.nodeSize;
160
- if (position >= from && position <= to) {
161
- return findTextRangeAtPositionInChildren(
162
- pmChild,
163
- liveChild,
164
- from,
165
- position
166
- );
167
- }
168
- pmOffset += pmChild.nodeSize;
169
- pmChildIndex++;
170
- }
171
- }
172
- return void 0;
173
- }
174
- function findTextRangeAtPositionInDocument(pmDoc, liveRoot, position) {
175
- return findTextRangeAtPositionInChildren(pmDoc, liveRoot, 0, position);
176
- }
177
- function findTextRangesInRange(index, from, to) {
178
- return index.textRanges.filter(
179
- (range) => Math.max(range.from, from) < Math.min(range.to, to)
180
- );
181
- }
182
- function findTextRangeByLiveText(index, text) {
183
- return index.textRanges.find((range) => range.text === text);
184
- }
185
- function findNodeRangeByLiveNode(index, node) {
186
- return index.nodeRanges.find((range) => range.node === node);
187
- }
188
- function findListRangeByLiveList(index, content) {
189
- return index.listRanges.find((range) => range.content === content);
190
- }
191
- function getChildPosition(parent, parentPos, index) {
192
- if (index < 0 || index > parent.childCount) {
193
- return void 0;
194
- }
195
- let offset = 0;
196
- for (let childIndex = 0; childIndex < index; childIndex++) {
197
- const child = parent.maybeChild(childIndex);
198
- if (child === null) {
199
- return void 0;
200
- }
201
- offset += child.nodeSize;
202
- }
203
- return childStart(parent, parentPos) + offset;
204
- }
205
-
206
- export { buildLiveblocksTreeIndex, clampLiveblocksPosition, findListRangeByLiveList, findNodeRangeByLiveNode, findTextRangeAtPosition, findTextRangeAtPositionInDocument, findTextRangeByLiveText, findTextRangesInRange, getChildPosition, selectionToLiveblocksPosition };
207
- //# sourceMappingURL=mapping.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mapping.js","sources":["../../src/collaboration-liveblocks/mapping.ts"],"sourcesContent":["import type { LiveList, LiveText } from \"@liveblocks/client\";\nimport type { Node as ProseMirrorNode } from \"@tiptap/pm/model\";\nimport type { Selection } from \"@tiptap/pm/state\";\n\nimport {\n getLiveblocksNodeContent,\n getLiveblocksNodeId,\n getLiveblocksNodeText,\n getLiveblocksNodeType,\n type LiveblocksTiptapNode,\n} from \"./schema\";\n\nexport type LiveblocksTiptapPosition = {\n anchor: number;\n head: number;\n};\n\nexport function selectionToLiveblocksPosition(\n selection: Selection\n): LiveblocksTiptapPosition {\n return {\n anchor: selection.anchor,\n head: selection.head,\n };\n}\n\nexport function clampLiveblocksPosition(\n position: LiveblocksTiptapPosition,\n max: number\n): LiveblocksTiptapPosition {\n return {\n anchor: Math.max(0, Math.min(position.anchor, max)),\n head: Math.max(0, Math.min(position.head, max)),\n };\n}\n\nexport type LiveblocksTextRange = {\n from: number;\n to: number;\n liveOffset: number;\n node: LiveblocksTiptapNode;\n nodeId: string;\n text: LiveText;\n};\n\nexport type LiveblocksNodeRange = {\n childIndex?: number;\n content?: LiveList<LiveblocksTiptapNode>;\n from: number;\n node: LiveblocksTiptapNode;\n nodeId: string;\n parent?: LiveblocksTiptapNode;\n pmNode: ProseMirrorNode;\n to: number;\n};\n\nexport type LiveblocksListRange = {\n content: LiveList<LiveblocksTiptapNode>;\n from: number;\n node: LiveblocksTiptapNode;\n nodeId: string;\n pmNode: ProseMirrorNode;\n to: number;\n};\n\nexport type LiveblocksTreeIndex = {\n listRanges: LiveblocksListRange[];\n nodeRanges: LiveblocksNodeRange[];\n textRanges: LiveblocksTextRange[];\n};\n\nfunction childStart(parent: ProseMirrorNode, parentPos: number): number {\n return parent.type.name === \"doc\" ? parentPos : parentPos + 1;\n}\n\nfunction indexChildren(\n nodeRanges: LiveblocksNodeRange[],\n listRanges: LiveblocksListRange[],\n textRanges: LiveblocksTextRange[],\n pmParent: ProseMirrorNode,\n liveParent: LiveblocksTiptapNode,\n parentPos: number\n): void {\n const liveContent = getLiveblocksNodeContent(liveParent);\n if (liveContent === undefined) {\n return;\n }\n\n listRanges.push({\n content: liveContent,\n from: parentPos,\n node: liveParent,\n nodeId: getLiveblocksNodeId(liveParent),\n pmNode: pmParent,\n to: parentPos + pmParent.nodeSize,\n });\n\n let pmChildIndex = 0;\n let pmOffset = 0;\n const start = childStart(pmParent, parentPos);\n\n for (let liveIndex = 0; liveIndex < liveContent.length; liveIndex++) {\n const liveChild = liveContent.get(liveIndex);\n const pmChild = pmParent.maybeChild(pmChildIndex);\n if (liveChild === undefined || pmChild === null) {\n return;\n }\n\n const from = start + pmOffset;\n const to = from + pmChild.nodeSize;\n\n nodeRanges.push({\n childIndex: liveIndex,\n content: liveContent,\n from,\n node: liveChild,\n nodeId: getLiveblocksNodeId(liveChild),\n parent: liveParent,\n pmNode: pmChild,\n to,\n });\n\n if (getLiveblocksNodeType(liveChild) === \"text\") {\n const text = getLiveblocksNodeText(liveChild);\n if (text === undefined) {\n return;\n }\n\n let liveOffset = 0;\n let remaining = text.length;\n\n while (remaining > 0) {\n const textChild = pmParent.maybeChild(pmChildIndex);\n if (textChild === null || !textChild.isText) {\n return;\n }\n\n const length = Math.min(remaining, textChild.nodeSize);\n const textFrom = start + pmOffset;\n\n textRanges.push({\n from: textFrom,\n to: textFrom + length,\n liveOffset,\n node: liveChild,\n nodeId: getLiveblocksNodeId(liveChild),\n text,\n });\n\n liveOffset += length;\n remaining -= length;\n pmOffset += textChild.nodeSize;\n pmChildIndex++;\n }\n } else {\n indexChildren(\n nodeRanges,\n listRanges,\n textRanges,\n pmChild,\n liveChild,\n from\n );\n pmOffset += pmChild.nodeSize;\n pmChildIndex++;\n }\n }\n}\n\nexport function buildLiveblocksTreeIndex(\n pmDoc: ProseMirrorNode,\n liveRoot: LiveblocksTiptapNode\n): LiveblocksTreeIndex {\n const nodeRanges: LiveblocksNodeRange[] = [\n {\n from: 0,\n node: liveRoot,\n nodeId: getLiveblocksNodeId(liveRoot),\n pmNode: pmDoc,\n to: pmDoc.content.size,\n },\n ];\n const listRanges: LiveblocksListRange[] = [];\n const textRanges: LiveblocksTextRange[] = [];\n indexChildren(nodeRanges, listRanges, textRanges, pmDoc, liveRoot, 0);\n return { listRanges, nodeRanges, textRanges };\n}\n\nexport function findTextRangeAtPosition(\n index: LiveblocksTreeIndex,\n position: number\n): LiveblocksTextRange | undefined {\n return index.textRanges.find(\n (range) => position >= range.from && position <= range.to\n );\n}\n\nfunction findTextRangeAtPositionInChildren(\n pmParent: ProseMirrorNode,\n liveParent: LiveblocksTiptapNode,\n parentPos: number,\n position: number\n): LiveblocksTextRange | undefined {\n const liveContent = getLiveblocksNodeContent(liveParent);\n if (liveContent === undefined) {\n return undefined;\n }\n\n let pmChildIndex = 0;\n let pmOffset = 0;\n const start = childStart(pmParent, parentPos);\n\n for (let liveIndex = 0; liveIndex < liveContent.length; liveIndex++) {\n const liveChild = liveContent.get(liveIndex);\n const pmChild = pmParent.maybeChild(pmChildIndex);\n if (liveChild === undefined || pmChild === null) {\n return undefined;\n }\n\n if (getLiveblocksNodeType(liveChild) === \"text\") {\n const text = getLiveblocksNodeText(liveChild);\n if (text === undefined) {\n return undefined;\n }\n\n let liveOffset = 0;\n let remaining = text.length;\n\n while (remaining > 0) {\n const textChild = pmParent.maybeChild(pmChildIndex);\n if (textChild === null || !textChild.isText) {\n return undefined;\n }\n\n const length = Math.min(remaining, textChild.nodeSize);\n const from = start + pmOffset;\n const to = from + length;\n\n if (position >= from && position <= to) {\n return {\n from,\n to,\n liveOffset,\n node: liveChild,\n nodeId: getLiveblocksNodeId(liveChild),\n text,\n };\n }\n\n liveOffset += length;\n remaining -= length;\n pmOffset += textChild.nodeSize;\n pmChildIndex++;\n }\n } else {\n const from = start + pmOffset;\n const to = from + pmChild.nodeSize;\n\n if (position >= from && position <= to) {\n return findTextRangeAtPositionInChildren(\n pmChild,\n liveChild,\n from,\n position\n );\n }\n\n pmOffset += pmChild.nodeSize;\n pmChildIndex++;\n }\n }\n\n return undefined;\n}\n\nexport function findTextRangeAtPositionInDocument(\n pmDoc: ProseMirrorNode,\n liveRoot: LiveblocksTiptapNode,\n position: number\n): LiveblocksTextRange | undefined {\n return findTextRangeAtPositionInChildren(pmDoc, liveRoot, 0, position);\n}\n\nexport function findTextRangesInRange(\n index: LiveblocksTreeIndex,\n from: number,\n to: number\n): LiveblocksTextRange[] {\n return index.textRanges.filter(\n (range) => Math.max(range.from, from) < Math.min(range.to, to)\n );\n}\n\nexport function findTextRangeByLiveText(\n index: LiveblocksTreeIndex,\n text: LiveText\n): LiveblocksTextRange | undefined {\n return index.textRanges.find((range) => range.text === text);\n}\n\nexport function findNodeRangeByLiveNode(\n index: LiveblocksTreeIndex,\n node: LiveblocksTiptapNode\n): LiveblocksNodeRange | undefined {\n return index.nodeRanges.find((range) => range.node === node);\n}\n\nexport function findListRangeByLiveList(\n index: LiveblocksTreeIndex,\n content: unknown\n): LiveblocksListRange | undefined {\n return index.listRanges.find((range) => range.content === content);\n}\n\nexport function getChildPosition(\n parent: ProseMirrorNode,\n parentPos: number,\n index: number\n): number | undefined {\n if (index < 0 || index > parent.childCount) {\n return undefined;\n }\n\n let offset = 0;\n for (let childIndex = 0; childIndex < index; childIndex++) {\n const child = parent.maybeChild(childIndex);\n if (child === null) {\n return undefined;\n }\n\n offset += child.nodeSize;\n }\n\n return childStart(parent, parentPos) + offset;\n}\n"],"names":[],"mappings":";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