@liveblocks/react-tiptap 3.19.5-rc1 → 3.20.0-exp1

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 (52) hide show
  1. package/dist/LiveblocksExtension.cjs +51 -5
  2. package/dist/LiveblocksExtension.cjs.map +1 -1
  3. package/dist/LiveblocksExtension.js +51 -5
  4. package/dist/LiveblocksExtension.js.map +1 -1
  5. package/dist/ai/AiExtension.cjs +2 -1
  6. package/dist/ai/AiExtension.cjs.map +1 -1
  7. package/dist/ai/AiExtension.js +2 -1
  8. package/dist/ai/AiExtension.js.map +1 -1
  9. package/dist/collaboration-liveblocks/cursors.cjs +267 -0
  10. package/dist/collaboration-liveblocks/cursors.cjs.map +1 -0
  11. package/dist/collaboration-liveblocks/cursors.js +264 -0
  12. package/dist/collaboration-liveblocks/cursors.js.map +1 -0
  13. package/dist/collaboration-liveblocks/mapping.cjs +218 -0
  14. package/dist/collaboration-liveblocks/mapping.cjs.map +1 -0
  15. package/dist/collaboration-liveblocks/mapping.js +207 -0
  16. package/dist/collaboration-liveblocks/mapping.js.map +1 -0
  17. package/dist/collaboration-liveblocks/plugin.cjs +249 -0
  18. package/dist/collaboration-liveblocks/plugin.cjs.map +1 -0
  19. package/dist/collaboration-liveblocks/plugin.js +246 -0
  20. package/dist/collaboration-liveblocks/plugin.js.map +1 -0
  21. package/dist/collaboration-liveblocks/remote.cjs +210 -0
  22. package/dist/collaboration-liveblocks/remote.cjs.map +1 -0
  23. package/dist/collaboration-liveblocks/remote.js +207 -0
  24. package/dist/collaboration-liveblocks/remote.js.map +1 -0
  25. package/dist/collaboration-liveblocks/schema.cjs +150 -0
  26. package/dist/collaboration-liveblocks/schema.cjs.map +1 -0
  27. package/dist/collaboration-liveblocks/schema.js +135 -0
  28. package/dist/collaboration-liveblocks/schema.js.map +1 -0
  29. package/dist/collaboration-liveblocks/steps.cjs +359 -0
  30. package/dist/collaboration-liveblocks/steps.cjs.map +1 -0
  31. package/dist/collaboration-liveblocks/steps.js +356 -0
  32. package/dist/collaboration-liveblocks/steps.js.map +1 -0
  33. package/dist/comments/CommentsExtension.cjs +7 -1
  34. package/dist/comments/CommentsExtension.cjs.map +1 -1
  35. package/dist/comments/CommentsExtension.js +7 -1
  36. package/dist/comments/CommentsExtension.js.map +1 -1
  37. package/dist/index.d.cts +5 -0
  38. package/dist/index.d.ts +5 -0
  39. package/dist/mentions/MentionExtension.cjs +4 -1
  40. package/dist/mentions/MentionExtension.cjs.map +1 -1
  41. package/dist/mentions/MentionExtension.js +4 -1
  42. package/dist/mentions/MentionExtension.js.map +1 -1
  43. package/dist/types.cjs.map +1 -1
  44. package/dist/types.js.map +1 -1
  45. package/dist/version.cjs +1 -1
  46. package/dist/version.cjs.map +1 -1
  47. package/dist/version.js +1 -1
  48. package/dist/version.js.map +1 -1
  49. package/package.json +6 -6
  50. package/src/styles/index.css +12 -4
  51. package/styles.css +1 -1
  52. package/styles.css.map +1 -1
@@ -0,0 +1,246 @@
1
+ import { LiveObject } from '@liveblocks/client';
2
+ import { Extension } from '@tiptap/core';
3
+ import { Slice } from '@tiptap/pm/model';
4
+ import { PluginKey, Plugin } from '@tiptap/pm/state';
5
+ import { applyRemoteStorageUpdates } from './remote.js';
6
+ import { createDefaultDocument, createLiveblocksTiptapNode, liveblocksTiptapNodeToJson, stringifyDocument } from './schema.js';
7
+ import { classifyTransaction, applyIncrementalOperations } from './steps.js';
8
+
9
+ const LIVEBLOCKS_COLLABORATION_PLUGIN_KEY = new PluginKey("liveblocks-collaboration");
10
+ function isProseMirrorJsonNode(value) {
11
+ return typeof value === "object" && value !== null && typeof value.type === "string";
12
+ }
13
+ function getInitialDocument(initialContent, view) {
14
+ if (isProseMirrorJsonNode(initialContent)) {
15
+ return initialContent;
16
+ }
17
+ const currentDocument = view.state.doc.toJSON();
18
+ if (isProseMirrorJsonNode(currentDocument)) {
19
+ return currentDocument;
20
+ }
21
+ return createDefaultDocument();
22
+ }
23
+ function replaceEditorDocument(view, document) {
24
+ let nextDocument;
25
+ try {
26
+ nextDocument = view.state.schema.nodeFromJSON(document);
27
+ } catch {
28
+ nextDocument = view.state.schema.nodeFromJSON(createDefaultDocument());
29
+ }
30
+ if (nextDocument.childCount === 0) {
31
+ nextDocument = view.state.schema.nodeFromJSON(createDefaultDocument());
32
+ }
33
+ const tr = view.state.tr.replace(
34
+ 0,
35
+ view.state.doc.content.size,
36
+ new Slice(nextDocument.content, 0, 0)
37
+ );
38
+ tr.setMeta(LIVEBLOCKS_COLLABORATION_PLUGIN_KEY, { isRemote: true }).setMeta(
39
+ "addToHistory",
40
+ false
41
+ );
42
+ view.dispatch(tr);
43
+ }
44
+ function getDocumentRoot(root, field) {
45
+ const documentRoot = root.get(field);
46
+ if (!(documentRoot instanceof LiveObject)) {
47
+ return void 0;
48
+ }
49
+ return documentRoot;
50
+ }
51
+ function setDocumentRoot(root, field, document) {
52
+ root.set(field, createLiveblocksTiptapNode(document));
53
+ }
54
+ function createLiveblocksCollaborationPlugin(options) {
55
+ const room = options.room;
56
+ if (room === void 0) {
57
+ throw new Error(
58
+ "[Liveblocks] The Liveblocks collaboration plugin requires a room."
59
+ );
60
+ }
61
+ let view;
62
+ let root;
63
+ let unsubscribe;
64
+ let destroyed = false;
65
+ let isApplyingRemoteUpdate = false;
66
+ let isApplyingLocalUpdate = false;
67
+ let lastDocument = "";
68
+ const applyStorageToEditor = (updates) => {
69
+ if (view === void 0 || root === void 0) {
70
+ return;
71
+ }
72
+ const documentRoot = getDocumentRoot(root, options.field);
73
+ if (documentRoot === void 0) {
74
+ return;
75
+ }
76
+ if (isApplyingLocalUpdate) {
77
+ return;
78
+ }
79
+ const document = liveblocksTiptapNodeToJson(documentRoot);
80
+ const serializedDocument = stringifyDocument(document);
81
+ if (serializedDocument === lastDocument) {
82
+ return;
83
+ }
84
+ if (updates !== void 0) {
85
+ const result = applyRemoteStorageUpdates(view, documentRoot, updates);
86
+ if (result.type === "applied") {
87
+ lastDocument = serializedDocument;
88
+ isApplyingRemoteUpdate = true;
89
+ try {
90
+ view.dispatch(
91
+ result.tr.setMeta(LIVEBLOCKS_COLLABORATION_PLUGIN_KEY, { isRemote: true }).setMeta("addToHistory", false)
92
+ );
93
+ } finally {
94
+ isApplyingRemoteUpdate = false;
95
+ }
96
+ return;
97
+ }
98
+ }
99
+ lastDocument = serializedDocument;
100
+ isApplyingRemoteUpdate = true;
101
+ try {
102
+ replaceEditorDocument(view, document);
103
+ } finally {
104
+ isApplyingRemoteUpdate = false;
105
+ }
106
+ };
107
+ return new Plugin({
108
+ key: LIVEBLOCKS_COLLABORATION_PLUGIN_KEY,
109
+ state: {
110
+ init: () => ({ isReady: false }),
111
+ apply(tr, state) {
112
+ const meta = tr.getMeta(LIVEBLOCKS_COLLABORATION_PLUGIN_KEY);
113
+ return meta?.isReady !== void 0 ? { ...state, isReady: meta.isReady } : state;
114
+ }
115
+ },
116
+ appendTransaction(transactions, oldState, newState) {
117
+ if (root === void 0 || isApplyingRemoteUpdate || !transactions.some((transaction) => transaction.docChanged) || transactions.some(
118
+ (transaction) => Boolean(transaction.getMeta(LIVEBLOCKS_COLLABORATION_PLUGIN_KEY))
119
+ )) {
120
+ return null;
121
+ }
122
+ const currentRoot = root;
123
+ const documentRoot = getDocumentRoot(currentRoot, options.field);
124
+ const classified = documentRoot !== void 0 ? classifyTransaction(
125
+ transactions,
126
+ oldState.doc,
127
+ newState.doc,
128
+ documentRoot
129
+ ) : { type: "unsupported" };
130
+ room.batch(() => {
131
+ if (classified.type === "incremental") {
132
+ isApplyingLocalUpdate = true;
133
+ try {
134
+ applyIncrementalOperations(classified.operations);
135
+ } finally {
136
+ isApplyingLocalUpdate = false;
137
+ }
138
+ } else {
139
+ const document = newState.doc.toJSON();
140
+ if (!isProseMirrorJsonNode(document)) {
141
+ return;
142
+ }
143
+ const serializedDocument = stringifyDocument(document);
144
+ if (serializedDocument === lastDocument) {
145
+ return;
146
+ }
147
+ lastDocument = serializedDocument;
148
+ setDocumentRoot(currentRoot, options.field, document);
149
+ }
150
+ });
151
+ return null;
152
+ },
153
+ view(editorView) {
154
+ view = editorView;
155
+ room.getStorage().then(({ root: storageRoot }) => {
156
+ if (destroyed) {
157
+ return;
158
+ }
159
+ root = storageRoot;
160
+ if (getDocumentRoot(storageRoot, options.field) === void 0) {
161
+ const initialDocument = getInitialDocument(
162
+ options.initialContent,
163
+ editorView
164
+ );
165
+ room.history.disable(() => {
166
+ setDocumentRoot(storageRoot, options.field, initialDocument);
167
+ });
168
+ }
169
+ applyStorageToEditor();
170
+ const tr = editorView.state.tr.setMeta(
171
+ LIVEBLOCKS_COLLABORATION_PLUGIN_KEY,
172
+ { isReady: true }
173
+ );
174
+ editorView.dispatch(tr);
175
+ unsubscribe = room.subscribe(storageRoot, applyStorageToEditor, {
176
+ isDeep: true
177
+ });
178
+ });
179
+ return {
180
+ update(nextView) {
181
+ view = nextView;
182
+ },
183
+ destroy() {
184
+ destroyed = true;
185
+ unsubscribe?.();
186
+ unsubscribe = void 0;
187
+ view = void 0;
188
+ root = void 0;
189
+ }
190
+ };
191
+ }
192
+ });
193
+ }
194
+ const LiveblocksCollaboration = Extension.create({
195
+ name: "collaboration",
196
+ priority: 1e3,
197
+ addOptions() {
198
+ return {
199
+ room: void 0,
200
+ field: "default",
201
+ initialContent: void 0
202
+ };
203
+ },
204
+ addStorage() {
205
+ return {
206
+ isDisabled: false
207
+ };
208
+ },
209
+ addCommands() {
210
+ return {
211
+ undo: () => ({ dispatch, tr }) => {
212
+ tr.setMeta("preventDispatch", true);
213
+ if (this.options.room === void 0 || !this.options.room.history.canUndo()) {
214
+ return false;
215
+ }
216
+ if (dispatch) {
217
+ this.options.room.history.undo();
218
+ }
219
+ return true;
220
+ },
221
+ redo: () => ({ dispatch, tr }) => {
222
+ tr.setMeta("preventDispatch", true);
223
+ if (this.options.room === void 0 || !this.options.room.history.canRedo()) {
224
+ return false;
225
+ }
226
+ if (dispatch) {
227
+ this.options.room.history.redo();
228
+ }
229
+ return true;
230
+ }
231
+ };
232
+ },
233
+ addKeyboardShortcuts() {
234
+ return {
235
+ "Mod-z": () => this.editor.commands.undo(),
236
+ "Mod-y": () => this.editor.commands.redo(),
237
+ "Shift-Mod-z": () => this.editor.commands.redo()
238
+ };
239
+ },
240
+ addProseMirrorPlugins() {
241
+ return [createLiveblocksCollaborationPlugin(this.options)];
242
+ }
243
+ });
244
+
245
+ export { LIVEBLOCKS_COLLABORATION_PLUGIN_KEY, LiveblocksCollaboration };
246
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["../../src/collaboration-liveblocks/plugin.ts"],"sourcesContent":["import type { LsonObject, StorageUpdate } from \"@liveblocks/client\";\nimport { LiveObject } from \"@liveblocks/client\";\nimport type { Content } from \"@tiptap/core\";\nimport { Extension } from \"@tiptap/core\";\nimport { Slice } from \"@tiptap/pm/model\";\nimport { Plugin, PluginKey } from \"@tiptap/pm/state\";\nimport type { EditorView } from \"@tiptap/pm/view\";\n\nimport { applyRemoteStorageUpdates } from \"./remote\";\nimport {\n createDefaultDocument,\n createLiveblocksTiptapNode,\n type LiveblocksTiptapNode,\n liveblocksTiptapNodeToJson,\n type ProseMirrorJsonNode,\n stringifyDocument,\n} from \"./schema\";\nimport { applyIncrementalOperations, classifyTransaction } from \"./steps\";\nimport type { LiveblocksTiptapRoom } from \"./types\";\n\nexport const LIVEBLOCKS_COLLABORATION_PLUGIN_KEY = new PluginKey<{\n isReady: boolean;\n}>(\"liveblocks-collaboration\");\n\ntype LiveblocksCollaborationOptions = {\n room?: LiveblocksTiptapRoom;\n field: string;\n initialContent?: Content;\n};\n\ntype LiveblocksCollaborationStorage = {\n isDisabled: boolean;\n};\n\nfunction isProseMirrorJsonNode(value: unknown): value is ProseMirrorJsonNode {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as { type?: unknown }).type === \"string\"\n );\n}\n\nfunction getInitialDocument(\n initialContent: Content | undefined,\n view: EditorView\n): ProseMirrorJsonNode {\n if (isProseMirrorJsonNode(initialContent)) {\n return initialContent;\n }\n\n const currentDocument: unknown = view.state.doc.toJSON();\n if (isProseMirrorJsonNode(currentDocument)) {\n return currentDocument;\n }\n\n return createDefaultDocument();\n}\n\nfunction replaceEditorDocument(\n view: EditorView,\n document: ProseMirrorJsonNode\n): void {\n let nextDocument;\n try {\n nextDocument = view.state.schema.nodeFromJSON(document);\n } catch {\n nextDocument = view.state.schema.nodeFromJSON(createDefaultDocument());\n }\n\n if (nextDocument.childCount === 0) {\n nextDocument = view.state.schema.nodeFromJSON(createDefaultDocument());\n }\n\n const tr = view.state.tr.replace(\n 0,\n view.state.doc.content.size,\n new Slice(nextDocument.content, 0, 0)\n );\n\n tr.setMeta(LIVEBLOCKS_COLLABORATION_PLUGIN_KEY, { isRemote: true }).setMeta(\n \"addToHistory\",\n false\n );\n\n view.dispatch(tr);\n}\n\nfunction getDocumentRoot(\n root: LiveObject<LsonObject>,\n field: string\n): LiveblocksTiptapNode | undefined {\n const documentRoot = root.get(field);\n if (!(documentRoot instanceof LiveObject)) {\n return undefined;\n }\n\n return documentRoot as LiveblocksTiptapNode;\n}\n\nfunction setDocumentRoot(\n root: LiveObject<LsonObject>,\n field: string,\n document: ProseMirrorJsonNode\n): void {\n root.set(field, createLiveblocksTiptapNode(document));\n}\n\nfunction createLiveblocksCollaborationPlugin(\n options: LiveblocksCollaborationOptions\n): Plugin {\n const room = options.room;\n if (room === undefined) {\n throw new Error(\n \"[Liveblocks] The Liveblocks collaboration plugin requires a room.\"\n );\n }\n\n let view: EditorView | undefined;\n let root: LiveObject<LsonObject> | undefined;\n let unsubscribe: (() => void) | undefined;\n let destroyed = false;\n let isApplyingRemoteUpdate = false;\n let isApplyingLocalUpdate = false;\n let lastDocument = \"\";\n\n const applyStorageToEditor = (updates?: StorageUpdate[]) => {\n if (view === undefined || root === undefined) {\n return;\n }\n\n const documentRoot = getDocumentRoot(root, options.field);\n if (documentRoot === undefined) {\n return;\n }\n\n if (isApplyingLocalUpdate) {\n return;\n }\n\n const document = liveblocksTiptapNodeToJson(documentRoot);\n const serializedDocument = stringifyDocument(document);\n\n if (serializedDocument === lastDocument) {\n return;\n }\n\n if (updates !== undefined) {\n const result = applyRemoteStorageUpdates(view, documentRoot, updates);\n if (result.type === \"applied\") {\n lastDocument = serializedDocument;\n isApplyingRemoteUpdate = true;\n try {\n view.dispatch(\n result.tr\n .setMeta(LIVEBLOCKS_COLLABORATION_PLUGIN_KEY, { isRemote: true })\n .setMeta(\"addToHistory\", false)\n );\n } finally {\n isApplyingRemoteUpdate = false;\n }\n return;\n }\n }\n\n lastDocument = serializedDocument;\n isApplyingRemoteUpdate = true;\n try {\n replaceEditorDocument(view, document);\n } finally {\n isApplyingRemoteUpdate = false;\n }\n };\n\n return new Plugin({\n key: LIVEBLOCKS_COLLABORATION_PLUGIN_KEY,\n state: {\n init: () => ({ isReady: false }),\n apply(tr, state) {\n const meta = tr.getMeta(LIVEBLOCKS_COLLABORATION_PLUGIN_KEY) as\n | { isReady?: boolean }\n | undefined;\n\n return meta?.isReady !== undefined\n ? { ...state, isReady: meta.isReady }\n : state;\n },\n },\n appendTransaction(transactions, oldState, newState) {\n if (\n root === undefined ||\n isApplyingRemoteUpdate ||\n !transactions.some((transaction) => transaction.docChanged) ||\n transactions.some((transaction) =>\n Boolean(transaction.getMeta(LIVEBLOCKS_COLLABORATION_PLUGIN_KEY))\n )\n ) {\n return null;\n }\n\n const currentRoot = root;\n\n const documentRoot = getDocumentRoot(currentRoot, options.field);\n const classified =\n documentRoot !== undefined\n ? classifyTransaction(\n transactions,\n oldState.doc,\n newState.doc,\n documentRoot\n )\n : { type: \"unsupported\" as const };\n\n room.batch(() => {\n if (classified.type === \"incremental\") {\n isApplyingLocalUpdate = true;\n try {\n applyIncrementalOperations(classified.operations);\n } finally {\n isApplyingLocalUpdate = false;\n }\n } else {\n const document: unknown = newState.doc.toJSON();\n if (!isProseMirrorJsonNode(document)) {\n return;\n }\n\n const serializedDocument = stringifyDocument(document);\n if (serializedDocument === lastDocument) {\n return;\n }\n\n lastDocument = serializedDocument;\n setDocumentRoot(currentRoot, options.field, document);\n }\n });\n\n return null;\n },\n view(editorView) {\n view = editorView;\n\n room.getStorage().then(({ root: storageRoot }) => {\n if (destroyed) {\n return;\n }\n\n root = storageRoot;\n\n if (getDocumentRoot(storageRoot, options.field) === undefined) {\n const initialDocument = getInitialDocument(\n options.initialContent,\n editorView\n );\n room.history.disable(() => {\n setDocumentRoot(storageRoot, options.field, initialDocument);\n });\n }\n\n applyStorageToEditor();\n\n const tr = editorView.state.tr.setMeta(\n LIVEBLOCKS_COLLABORATION_PLUGIN_KEY,\n { isReady: true }\n );\n editorView.dispatch(tr);\n\n unsubscribe = room.subscribe(storageRoot, applyStorageToEditor, {\n isDeep: true,\n });\n });\n\n return {\n update(nextView) {\n view = nextView;\n },\n destroy() {\n destroyed = true;\n unsubscribe?.();\n unsubscribe = undefined;\n view = undefined;\n root = undefined;\n },\n };\n },\n });\n}\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n collaboration: {\n undo: () => ReturnType;\n redo: () => ReturnType;\n };\n }\n}\n\nexport const LiveblocksCollaboration = Extension.create<\n LiveblocksCollaborationOptions,\n LiveblocksCollaborationStorage\n>({\n name: \"collaboration\",\n priority: 1000,\n\n addOptions() {\n return {\n room: undefined,\n field: \"default\",\n initialContent: undefined,\n };\n },\n\n addStorage() {\n return {\n isDisabled: false,\n };\n },\n\n addCommands() {\n return {\n undo:\n () =>\n ({ dispatch, tr }) => {\n tr.setMeta(\"preventDispatch\", true);\n\n if (\n this.options.room === undefined ||\n !this.options.room.history.canUndo()\n ) {\n return false;\n }\n\n if (dispatch) {\n this.options.room.history.undo();\n }\n\n return true;\n },\n redo:\n () =>\n ({ dispatch, tr }) => {\n tr.setMeta(\"preventDispatch\", true);\n\n if (\n this.options.room === undefined ||\n !this.options.room.history.canRedo()\n ) {\n return false;\n }\n\n if (dispatch) {\n this.options.room.history.redo();\n }\n\n return true;\n },\n };\n },\n\n addKeyboardShortcuts() {\n return {\n \"Mod-z\": () => this.editor.commands.undo(),\n \"Mod-y\": () => this.editor.commands.redo(),\n \"Shift-Mod-z\": () => this.editor.commands.redo(),\n };\n },\n\n addProseMirrorPlugins() {\n return [createLiveblocksCollaborationPlugin(this.options)];\n },\n});\n"],"names":[],"mappings":";;;;;;;;AAoBa,MAAA,mCAAA,GAAsC,IAAI,SAAA,CAEpD,0BAA0B,EAAA;AAY7B,SAAS,sBAAsB,KAA8C,EAAA;AAC3E,EAAA,OACE,OAAO,KAAU,KAAA,QAAA,IACjB,UAAU,IACV,IAAA,OAAQ,MAA6B,IAAS,KAAA,QAAA,CAAA;AAElD,CAAA;AAEA,SAAS,kBAAA,CACP,gBACA,IACqB,EAAA;AACrB,EAAI,IAAA,qBAAA,CAAsB,cAAc,CAAG,EAAA;AACzC,IAAO,OAAA,cAAA,CAAA;AAAA,GACT;AAEA,EAAA,MAAM,eAA2B,GAAA,IAAA,CAAK,KAAM,CAAA,GAAA,CAAI,MAAO,EAAA,CAAA;AACvD,EAAI,IAAA,qBAAA,CAAsB,eAAe,CAAG,EAAA;AAC1C,IAAO,OAAA,eAAA,CAAA;AAAA,GACT;AAEA,EAAA,OAAO,qBAAsB,EAAA,CAAA;AAC/B,CAAA;AAEA,SAAS,qBAAA,CACP,MACA,QACM,EAAA;AACN,EAAI,IAAA,YAAA,CAAA;AACJ,EAAI,IAAA;AACF,IAAA,YAAA,GAAe,IAAK,CAAA,KAAA,CAAM,MAAO,CAAA,YAAA,CAAa,QAAQ,CAAA,CAAA;AAAA,GAChD,CAAA,MAAA;AACN,IAAA,YAAA,GAAe,IAAK,CAAA,KAAA,CAAM,MAAO,CAAA,YAAA,CAAa,uBAAuB,CAAA,CAAA;AAAA,GACvE;AAEA,EAAI,IAAA,YAAA,CAAa,eAAe,CAAG,EAAA;AACjC,IAAA,YAAA,GAAe,IAAK,CAAA,KAAA,CAAM,MAAO,CAAA,YAAA,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AAS,EAAA,MAAM,IAAK,CAAA,MAAA,CAAO,SAAS,IAAK,EAAA;AAAA,MACzC,OAAS,EAAA,MAAM,IAAK,CAAA,MAAA,CAAO,SAAS,IAAK,EAAA;AAAA,MACzC,aAAe,EAAA,MAAM,IAAK,CAAA,MAAA,CAAO,SAAS,IAAK,EAAA;AAAA,KACjD,CAAA;AAAA,GACF;AAAA,EAEA,qBAAwB,GAAA;AACtB,IAAA,OAAO,CAAC,mCAAA,CAAoC,IAAK,CAAA,OAAO,CAAC,CAAA,CAAA;AAAA,GAC3D;AACF,CAAC;;;;"}
@@ -0,0 +1,210 @@
1
+ 'use strict';
2
+
3
+ var client = require('@liveblocks/client');
4
+ var model = require('@tiptap/pm/model');
5
+ var mapping = require('./mapping.cjs');
6
+ var schema = require('./schema.cjs');
7
+
8
+ function getMarkType(schema, type) {
9
+ return schema.marks[type];
10
+ }
11
+ function isJsonObject(value) {
12
+ return typeof value === "object" && value !== null && !Array.isArray(value);
13
+ }
14
+ function isLiveblocksTiptapNode(value) {
15
+ return value instanceof client.LiveObject && typeof value.get("id") === "string" && typeof value.get("type") === "string";
16
+ }
17
+ function getLiveblocksNodeAttrs(node) {
18
+ const attrs = node.get("attrs");
19
+ return isJsonObject(attrs) ? attrs : void 0;
20
+ }
21
+ function createSliceFromLiveblocksNode(schema$1, node) {
22
+ const nodes = schema.liveblocksTiptapNodeToJsonNodes(node).map(
23
+ (jsonNode) => schema$1.nodeFromJSON(jsonNode)
24
+ );
25
+ return new model.Slice(model.Fragment.fromArray(nodes), 0, 0);
26
+ }
27
+ function applyMarksFromAttributes(tr, schema$1, from, to, attributes) {
28
+ const marks = schema.attributesToMarks({ ...attributes });
29
+ for (const mark of marks ?? []) {
30
+ const markType = getMarkType(schema$1, mark.type);
31
+ if (markType !== void 0) {
32
+ tr.addMark(from, to, markType.create(mark.attrs));
33
+ }
34
+ }
35
+ if (marks === void 0) {
36
+ tr.removeMark(from, to);
37
+ }
38
+ }
39
+ function findNodeRangeForLiveText(index, text) {
40
+ return index.nodeRanges.find(
41
+ (range) => schema.getLiveblocksNodeText(range.node) === text
42
+ );
43
+ }
44
+ function applyRemoteStorageUpdates(view, liveRoot, updates) {
45
+ if (updates.length === 0) {
46
+ return { type: "unsupported" };
47
+ }
48
+ let tr = view.state.tr;
49
+ for (const update of updates) {
50
+ if (update.type === "LiveText") {
51
+ if (!(update.node instanceof client.LiveText)) {
52
+ return { type: "unsupported" };
53
+ }
54
+ for (const change of update.updates) {
55
+ const index = mapping.buildLiveblocksTreeIndex(tr.doc, liveRoot);
56
+ let range = mapping.findTextRangeByLiveText(index, update.node);
57
+ if (range === void 0 && change.type === "delete") {
58
+ const wrapperRange = findNodeRangeForLiveText(index, update.node);
59
+ if (wrapperRange !== void 0) {
60
+ const from2 = wrapperRange.from + change.index;
61
+ tr = tr.delete(from2, from2 + change.length);
62
+ continue;
63
+ }
64
+ return { type: "unsupported" };
65
+ }
66
+ if (range === void 0) {
67
+ return { type: "unsupported" };
68
+ }
69
+ const from = range.from + change.index - range.liveOffset;
70
+ if (change.type === "insert") {
71
+ tr = tr.insertText(change.text, from);
72
+ if (change.attributes !== void 0) {
73
+ applyMarksFromAttributes(
74
+ tr,
75
+ view.state.schema,
76
+ from,
77
+ from + change.text.length,
78
+ change.attributes
79
+ );
80
+ }
81
+ } else if (change.type === "delete") {
82
+ tr = tr.delete(from, from + change.length);
83
+ } else {
84
+ applyMarksFromAttributes(
85
+ tr,
86
+ view.state.schema,
87
+ from,
88
+ from + change.length,
89
+ change.attributes
90
+ );
91
+ }
92
+ }
93
+ continue;
94
+ }
95
+ if (update.type === "LiveList") {
96
+ for (const change of update.updates) {
97
+ const index = mapping.buildLiveblocksTreeIndex(tr.doc, liveRoot);
98
+ const range = mapping.findListRangeByLiveList(index, update.node);
99
+ if (range === void 0) {
100
+ return { type: "unsupported" };
101
+ }
102
+ if (change.type === "insert") {
103
+ if (!isLiveblocksTiptapNode(change.item)) {
104
+ return { type: "unsupported" };
105
+ }
106
+ const pos = mapping.getChildPosition(range.pmNode, range.from, change.index);
107
+ if (pos === void 0) {
108
+ return { type: "unsupported" };
109
+ }
110
+ tr = tr.replace(
111
+ pos,
112
+ pos,
113
+ createSliceFromLiveblocksNode(view.state.schema, change.item)
114
+ );
115
+ } else if (change.type === "delete") {
116
+ const from = mapping.getChildPosition(range.pmNode, range.from, change.index);
117
+ const to = mapping.getChildPosition(
118
+ range.pmNode,
119
+ range.from,
120
+ change.index + 1
121
+ );
122
+ if (from === void 0 || to === void 0) {
123
+ return { type: "unsupported" };
124
+ }
125
+ tr = tr.delete(from, to);
126
+ } else if (change.type === "set") {
127
+ if (!isLiveblocksTiptapNode(change.item)) {
128
+ return { type: "unsupported" };
129
+ }
130
+ const from = mapping.getChildPosition(range.pmNode, range.from, change.index);
131
+ const to = mapping.getChildPosition(
132
+ range.pmNode,
133
+ range.from,
134
+ change.index + 1
135
+ );
136
+ if (from === void 0 || to === void 0) {
137
+ return { type: "unsupported" };
138
+ }
139
+ tr = tr.replace(
140
+ from,
141
+ to,
142
+ createSliceFromLiveblocksNode(view.state.schema, change.item)
143
+ );
144
+ } else {
145
+ if (!isLiveblocksTiptapNode(change.item)) {
146
+ return { type: "unsupported" };
147
+ }
148
+ const from = mapping.getChildPosition(
149
+ range.pmNode,
150
+ range.from,
151
+ change.previousIndex
152
+ );
153
+ const to = mapping.getChildPosition(
154
+ range.pmNode,
155
+ range.from,
156
+ change.previousIndex + 1
157
+ );
158
+ const rawInsertPos = mapping.getChildPosition(
159
+ range.pmNode,
160
+ range.from,
161
+ change.index > change.previousIndex ? change.index + 1 : change.index
162
+ );
163
+ if (from === void 0 || to === void 0 || rawInsertPos === void 0) {
164
+ return { type: "unsupported" };
165
+ }
166
+ const slice = createSliceFromLiveblocksNode(
167
+ view.state.schema,
168
+ change.item
169
+ );
170
+ tr = tr.delete(from, to);
171
+ const insertPos = tr.mapping.map(rawInsertPos, -1);
172
+ tr = tr.replace(insertPos, insertPos, slice);
173
+ }
174
+ }
175
+ continue;
176
+ }
177
+ if (update.type === "LiveObject") {
178
+ if (!isLiveblocksTiptapNode(update.node)) {
179
+ return { type: "unsupported" };
180
+ }
181
+ const attrUpdate = update.updates.attrs;
182
+ if (attrUpdate === void 0) {
183
+ return { type: "unsupported" };
184
+ }
185
+ const index = mapping.buildLiveblocksTreeIndex(tr.doc, liveRoot);
186
+ const range = mapping.findNodeRangeByLiveNode(index, update.node);
187
+ if (range === void 0 || range.pmNode.type.name === "doc") {
188
+ return { type: "unsupported" };
189
+ }
190
+ tr = tr.setNodeMarkup(
191
+ range.from,
192
+ void 0,
193
+ attrUpdate.type === "delete" ? null : getLiveblocksNodeAttrs(update.node)
194
+ );
195
+ continue;
196
+ }
197
+ return { type: "unsupported" };
198
+ }
199
+ return { type: "applied", tr };
200
+ }
201
+ function applyRemoteLiveTextUpdates(view, liveRoot, updates) {
202
+ if (!updates.every((update) => update.type === "LiveText")) {
203
+ return { type: "unsupported" };
204
+ }
205
+ return applyRemoteStorageUpdates(view, liveRoot, updates);
206
+ }
207
+
208
+ exports.applyRemoteLiveTextUpdates = applyRemoteLiveTextUpdates;
209
+ exports.applyRemoteStorageUpdates = applyRemoteStorageUpdates;
210
+ //# sourceMappingURL=remote.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote.cjs","sources":["../../src/collaboration-liveblocks/remote.ts"],"sourcesContent":["import {\n type Json,\n type JsonObject,\n LiveObject,\n LiveText,\n type StorageUpdate,\n} from \"@liveblocks/client\";\nimport { Fragment, type MarkType, type Schema, Slice } from \"@tiptap/pm/model\";\nimport type { Transaction } from \"@tiptap/pm/state\";\nimport type { EditorView } from \"@tiptap/pm/view\";\n\nimport {\n buildLiveblocksTreeIndex,\n findListRangeByLiveList,\n findNodeRangeByLiveNode,\n findTextRangeByLiveText,\n getChildPosition,\n} from \"./mapping\";\nimport {\n attributesToMarks,\n type LiveblocksTiptapNode,\n getLiveblocksNodeText,\n liveblocksTiptapNodeToJsonNodes,\n} from \"./schema\";\n\ntype RemoteApplyResult =\n | {\n type: \"applied\";\n tr: Transaction;\n }\n | {\n type: \"unsupported\";\n };\n\nfunction getMarkType(schema: Schema, type: string): MarkType | undefined {\n return schema.marks[type];\n}\n\nfunction isJsonObject(value: unknown): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isLiveblocksTiptapNode(value: unknown): value is LiveblocksTiptapNode {\n return (\n value instanceof LiveObject &&\n typeof value.get(\"id\") === \"string\" &&\n typeof value.get(\"type\") === \"string\"\n );\n}\n\nfunction getLiveblocksNodeAttrs(\n node: LiveblocksTiptapNode\n): JsonObject | undefined {\n const attrs = node.get(\"attrs\");\n return isJsonObject(attrs) ? attrs : undefined;\n}\n\nfunction createSliceFromLiveblocksNode(\n schema: Schema,\n node: LiveblocksTiptapNode\n): Slice {\n const nodes = liveblocksTiptapNodeToJsonNodes(node).map((jsonNode) =>\n schema.nodeFromJSON(jsonNode)\n );\n\n return new Slice(Fragment.fromArray(nodes), 0, 0);\n}\n\nfunction applyMarksFromAttributes(\n tr: Transaction,\n schema: Schema,\n from: number,\n to: number,\n attributes: Record<string, Json | null>\n): void {\n const marks = attributesToMarks({ ...attributes });\n\n for (const mark of marks ?? []) {\n const markType = getMarkType(schema, mark.type);\n if (markType !== undefined) {\n tr.addMark(from, to, markType.create(mark.attrs));\n }\n }\n\n if (marks === undefined) {\n tr.removeMark(from, to);\n }\n}\n\nfunction findNodeRangeForLiveText(\n index: ReturnType<typeof buildLiveblocksTreeIndex>,\n text: LiveText\n) {\n return index.nodeRanges.find(\n (range) => getLiveblocksNodeText(range.node) === text\n );\n}\n\nexport function applyRemoteStorageUpdates(\n view: EditorView,\n liveRoot: LiveblocksTiptapNode,\n updates: readonly StorageUpdate[]\n): RemoteApplyResult {\n if (updates.length === 0) {\n return { type: \"unsupported\" };\n }\n\n let tr = view.state.tr;\n\n for (const update of updates) {\n if (update.type === \"LiveText\") {\n if (!(update.node instanceof LiveText)) {\n return { type: \"unsupported\" };\n }\n\n for (const change of update.updates) {\n const index = buildLiveblocksTreeIndex(tr.doc, liveRoot);\n let range = findTextRangeByLiveText(index, update.node);\n\n if (range === undefined && change.type === \"delete\") {\n const wrapperRange = findNodeRangeForLiveText(index, update.node);\n if (wrapperRange !== undefined) {\n const from = wrapperRange.from + change.index;\n tr = tr.delete(from, from + change.length);\n continue;\n }\n\n return { type: \"unsupported\" };\n }\n\n if (range === undefined) {\n return { type: \"unsupported\" };\n }\n\n const from = range.from + change.index - range.liveOffset;\n\n if (change.type === \"insert\") {\n tr = tr.insertText(change.text, from);\n if (change.attributes !== undefined) {\n applyMarksFromAttributes(\n tr,\n view.state.schema,\n from,\n from + change.text.length,\n change.attributes\n );\n }\n } else if (change.type === \"delete\") {\n tr = tr.delete(from, from + change.length);\n } else {\n applyMarksFromAttributes(\n tr,\n view.state.schema,\n from,\n from + change.length,\n change.attributes\n );\n }\n }\n\n continue;\n }\n\n if (update.type === \"LiveList\") {\n for (const change of update.updates) {\n const index = buildLiveblocksTreeIndex(tr.doc, liveRoot);\n const range = findListRangeByLiveList(index, update.node);\n if (range === undefined) {\n return { type: \"unsupported\" };\n }\n\n if (change.type === \"insert\") {\n if (!isLiveblocksTiptapNode(change.item)) {\n return { type: \"unsupported\" };\n }\n\n const pos = getChildPosition(range.pmNode, range.from, change.index);\n if (pos === undefined) {\n return { type: \"unsupported\" };\n }\n\n tr = tr.replace(\n pos,\n pos,\n createSliceFromLiveblocksNode(view.state.schema, change.item)\n );\n } else if (change.type === \"delete\") {\n const from = getChildPosition(range.pmNode, range.from, change.index);\n const to = getChildPosition(\n range.pmNode,\n range.from,\n change.index + 1\n );\n if (from === undefined || to === undefined) {\n return { type: \"unsupported\" };\n }\n\n tr = tr.delete(from, to);\n } else if (change.type === \"set\") {\n if (!isLiveblocksTiptapNode(change.item)) {\n return { type: \"unsupported\" };\n }\n\n const from = getChildPosition(range.pmNode, range.from, change.index);\n const to = getChildPosition(\n range.pmNode,\n range.from,\n change.index + 1\n );\n if (from === undefined || to === undefined) {\n return { type: \"unsupported\" };\n }\n\n tr = tr.replace(\n from,\n to,\n createSliceFromLiveblocksNode(view.state.schema, change.item)\n );\n } else {\n if (!isLiveblocksTiptapNode(change.item)) {\n return { type: \"unsupported\" };\n }\n\n const from = getChildPosition(\n range.pmNode,\n range.from,\n change.previousIndex\n );\n const to = getChildPosition(\n range.pmNode,\n range.from,\n change.previousIndex + 1\n );\n const rawInsertPos = getChildPosition(\n range.pmNode,\n range.from,\n change.index > change.previousIndex\n ? change.index + 1\n : change.index\n );\n if (\n from === undefined ||\n to === undefined ||\n rawInsertPos === undefined\n ) {\n return { type: \"unsupported\" };\n }\n\n const slice = createSliceFromLiveblocksNode(\n view.state.schema,\n change.item\n );\n tr = tr.delete(from, to);\n const insertPos = tr.mapping.map(rawInsertPos, -1);\n tr = tr.replace(insertPos, insertPos, slice);\n }\n }\n\n continue;\n }\n\n if (update.type === \"LiveObject\") {\n if (!isLiveblocksTiptapNode(update.node)) {\n return { type: \"unsupported\" };\n }\n\n const attrUpdate = update.updates.attrs;\n if (attrUpdate === undefined) {\n return { type: \"unsupported\" };\n }\n\n const index = buildLiveblocksTreeIndex(tr.doc, liveRoot);\n const range = findNodeRangeByLiveNode(index, update.node);\n if (range === undefined || range.pmNode.type.name === \"doc\") {\n return { type: \"unsupported\" };\n }\n\n tr = tr.setNodeMarkup(\n range.from,\n undefined,\n attrUpdate.type === \"delete\" ? null : getLiveblocksNodeAttrs(update.node)\n );\n\n continue;\n }\n\n return { type: \"unsupported\" };\n }\n\n return { type: \"applied\", tr };\n}\n\nexport function applyRemoteLiveTextUpdates(\n view: EditorView,\n liveRoot: LiveblocksTiptapNode,\n updates: readonly StorageUpdate[]\n): RemoteApplyResult {\n if (!updates.every((update) => update.type === \"LiveText\")) {\n return { type: \"unsupported\" };\n }\n\n return applyRemoteStorageUpdates(view, liveRoot, updates);\n}\n\n"],"names":["LiveObject","schema","liveblocksTiptapNodeToJsonNodes","Slice","Fragment","attributesToMarks","getLiveblocksNodeText","LiveText","buildLiveblocksTreeIndex","findTextRangeByLiveText","from","findListRangeByLiveList","getChildPosition","findNodeRangeByLiveNode"],"mappings":";;;;;;;AAkCA,SAAS,WAAA,CAAY,QAAgB,IAAoC,EAAA;AACvE,EAAO,OAAA,MAAA,CAAO,MAAM,IAAI,CAAA,CAAA;AAC1B,CAAA;AAEA,SAAS,aAAa,KAAqC,EAAA;AACzD,EAAO,OAAA,OAAO,UAAU,QAAY,IAAA,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA,CAAA;AAC5E,CAAA;AAEA,SAAS,uBAAuB,KAA+C,EAAA;AAC7E,EAAA,OACE,KAAiB,YAAAA,iBAAA,IACjB,OAAO,KAAA,CAAM,GAAI,CAAA,IAAI,CAAM,KAAA,QAAA,IAC3B,OAAO,KAAA,CAAM,GAAI,CAAA,MAAM,CAAM,KAAA,QAAA,CAAA;AAEjC,CAAA;AAEA,SAAS,uBACP,IACwB,EAAA;AACxB,EAAM,MAAA,KAAA,GAAQ,IAAK,CAAA,GAAA,CAAI,OAAO,CAAA,CAAA;AAC9B,EAAO,OAAA,YAAA,CAAa,KAAK,CAAA,GAAI,KAAQ,GAAA,KAAA,CAAA,CAAA;AACvC,CAAA;AAEA,SAAS,6BAAA,CACPC,UACA,IACO,EAAA;AACP,EAAM,MAAA,KAAA,GAAQC,sCAAgC,CAAA,IAAI,CAAE,CAAA,GAAA;AAAA,IAAI,CAAC,QAAA,KACvDD,QAAO,CAAA,YAAA,CAAa,QAAQ,CAAA;AAAA,GAC9B,CAAA;AAEA,EAAA,OAAO,IAAIE,WAAM,CAAAC,cAAA,CAAS,UAAU,KAAK,CAAA,EAAG,GAAG,CAAC,CAAA,CAAA;AAClD,CAAA;AAEA,SAAS,wBACP,CAAA,EAAA,EACAH,QACA,EAAA,IAAA,EACA,IACA,UACM,EAAA;AACN,EAAA,MAAM,KAAQ,GAAAI,wBAAA,CAAkB,EAAE,GAAG,YA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