@liveblocks/prosemirror 0.0.0 → 3.21.0-exp4
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.
- package/LICENSE +16 -0
- package/README.md +3 -0
- package/dist/cursors.cjs +217 -0
- package/dist/cursors.cjs.map +1 -0
- package/dist/cursors.js +211 -0
- package/dist/cursors.js.map +1 -0
- package/dist/index.cjs +24 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +109 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/mapping.cjs +218 -0
- package/dist/mapping.cjs.map +1 -0
- package/dist/mapping.js +207 -0
- package/dist/mapping.js.map +1 -0
- package/dist/plugin.cjs +227 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.js +223 -0
- package/dist/plugin.js.map +1 -0
- package/dist/remote.cjs +210 -0
- package/dist/remote.cjs.map +1 -0
- package/dist/remote.js +207 -0
- package/dist/remote.js.map +1 -0
- package/dist/schema.cjs +149 -0
- package/dist/schema.cjs.map +1 -0
- package/dist/schema.js +135 -0
- package/dist/schema.js.map +1 -0
- package/dist/steps.cjs +359 -0
- package/dist/steps.cjs.map +1 -0
- package/dist/steps.js +356 -0
- package/dist/steps.js.map +1 -0
- package/dist/version.cjs +10 -0
- package/dist/version.cjs.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +55 -3
- package/index.js +0 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { JsonObject, LiveObject, LsonObject, StorageUpdate, LiveList, LiveText } from '@liveblocks/client';
|
|
2
|
+
import { PluginKey, Plugin } from 'prosemirror-state';
|
|
3
|
+
import { DecorationSet } from 'prosemirror-view';
|
|
4
|
+
|
|
5
|
+
type LiveblocksProsemirrorRoom = {
|
|
6
|
+
batch(callback: () => void): void;
|
|
7
|
+
getOthers(): readonly {
|
|
8
|
+
connectionId: number;
|
|
9
|
+
info?: JsonObject;
|
|
10
|
+
presence: JsonObject;
|
|
11
|
+
}[];
|
|
12
|
+
getStorage(): Promise<{
|
|
13
|
+
root: LiveObject<LsonObject>;
|
|
14
|
+
}>;
|
|
15
|
+
history: {
|
|
16
|
+
canUndo(): boolean;
|
|
17
|
+
canRedo(): boolean;
|
|
18
|
+
disable<T>(callback: () => T): T;
|
|
19
|
+
undo(): void;
|
|
20
|
+
redo(): void;
|
|
21
|
+
};
|
|
22
|
+
subscribe(node: LiveObject<LsonObject>, callback: (updates: StorageUpdate[]) => void, options: {
|
|
23
|
+
isDeep: true;
|
|
24
|
+
}): () => void;
|
|
25
|
+
updatePresence(patch: JsonObject): void;
|
|
26
|
+
events: {
|
|
27
|
+
others: {
|
|
28
|
+
subscribe(callback: () => void): () => void;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
declare const LIVEBLOCKS_CARET_PRESENCE_KEY = "liveblocksTiptap";
|
|
34
|
+
type CursorUser = {
|
|
35
|
+
name?: string;
|
|
36
|
+
color?: string;
|
|
37
|
+
};
|
|
38
|
+
type CursorPresence = {
|
|
39
|
+
field: string;
|
|
40
|
+
anchor: number;
|
|
41
|
+
head: number;
|
|
42
|
+
user?: CursorUser;
|
|
43
|
+
};
|
|
44
|
+
type CollaborationCaretStorage = {
|
|
45
|
+
users: {
|
|
46
|
+
clientId: number;
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
}[];
|
|
49
|
+
};
|
|
50
|
+
type RemoteCursor = {
|
|
51
|
+
anchor: number;
|
|
52
|
+
connectionId: number;
|
|
53
|
+
head: number;
|
|
54
|
+
rawAnchor: number;
|
|
55
|
+
rawHead: number;
|
|
56
|
+
user?: CursorUser;
|
|
57
|
+
};
|
|
58
|
+
type CollaborationCaretPluginState = {
|
|
59
|
+
cursors: RemoteCursor[];
|
|
60
|
+
decorations: DecorationSet;
|
|
61
|
+
};
|
|
62
|
+
type CollaborationCaretOptions = {
|
|
63
|
+
room?: LiveblocksProsemirrorRoom;
|
|
64
|
+
field: string;
|
|
65
|
+
user: CursorUser;
|
|
66
|
+
};
|
|
67
|
+
declare const LIVEBLOCKS_CARET_PLUGIN_KEY: PluginKey<CollaborationCaretPluginState>;
|
|
68
|
+
declare function getCursorUser(value: unknown): CursorUser | undefined;
|
|
69
|
+
declare function presencePatch(presence: CursorPresence): JsonObject;
|
|
70
|
+
declare function createLiveblocksCollaborationCaretPlugin(options: CollaborationCaretOptions, storage: CollaborationCaretStorage): Plugin;
|
|
71
|
+
|
|
72
|
+
type ProseMirrorJsonNode = {
|
|
73
|
+
type: string;
|
|
74
|
+
attrs?: JsonObject;
|
|
75
|
+
content?: ProseMirrorJsonNode[];
|
|
76
|
+
text?: string;
|
|
77
|
+
marks?: ProseMirrorJsonMark[];
|
|
78
|
+
};
|
|
79
|
+
type ProseMirrorJsonMark = {
|
|
80
|
+
type: string;
|
|
81
|
+
attrs?: JsonObject;
|
|
82
|
+
};
|
|
83
|
+
type LiveblocksProsemirrorNodeData = {
|
|
84
|
+
id: string;
|
|
85
|
+
type: string;
|
|
86
|
+
attrs?: JsonObject;
|
|
87
|
+
content?: LiveList<LiveblocksProsemirrorNode>;
|
|
88
|
+
text?: LiveText;
|
|
89
|
+
};
|
|
90
|
+
type LiveblocksProsemirrorNode = LiveObject<LiveblocksProsemirrorNodeData>;
|
|
91
|
+
declare function createLiveblocksProsemirrorNode(node: ProseMirrorJsonNode): LiveblocksProsemirrorNode;
|
|
92
|
+
declare function getLiveblocksNodeId(node: LiveblocksProsemirrorNode): string;
|
|
93
|
+
declare function getLiveblocksNodeContent(node: LiveblocksProsemirrorNode): LiveList<LiveblocksProsemirrorNode> | undefined;
|
|
94
|
+
declare function getLiveblocksNodeText(node: LiveblocksProsemirrorNode): LiveText | undefined;
|
|
95
|
+
declare function liveblocksProsemirrorNodeToJsonNodes(node: LiveblocksProsemirrorNode): ProseMirrorJsonNode[];
|
|
96
|
+
declare function liveblocksProsemirrorNodeToJson(node: LiveblocksProsemirrorNode, fallbackDocument?: () => ProseMirrorJsonNode): ProseMirrorJsonNode;
|
|
97
|
+
|
|
98
|
+
declare const LIVEBLOCKS_COLLABORATION_PLUGIN_KEY: PluginKey<{
|
|
99
|
+
isReady: boolean;
|
|
100
|
+
}>;
|
|
101
|
+
type LiveblocksCollaborationOptions = {
|
|
102
|
+
room?: LiveblocksProsemirrorRoom;
|
|
103
|
+
field: string;
|
|
104
|
+
initialContent?: ProseMirrorJsonNode;
|
|
105
|
+
fallbackDocument?: () => ProseMirrorJsonNode;
|
|
106
|
+
};
|
|
107
|
+
declare function createLiveblocksCollaborationPlugin(options: LiveblocksCollaborationOptions): Plugin;
|
|
108
|
+
|
|
109
|
+
export { CollaborationCaretOptions, CollaborationCaretPluginState, CollaborationCaretStorage, CursorUser, LIVEBLOCKS_CARET_PLUGIN_KEY, LIVEBLOCKS_CARET_PRESENCE_KEY, LIVEBLOCKS_COLLABORATION_PLUGIN_KEY, LiveblocksCollaborationOptions, LiveblocksProsemirrorNode, LiveblocksProsemirrorRoom, ProseMirrorJsonMark, ProseMirrorJsonNode, RemoteCursor, createLiveblocksCollaborationCaretPlugin, createLiveblocksCollaborationPlugin, createLiveblocksProsemirrorNode, getCursorUser, getLiveblocksNodeContent, getLiveblocksNodeId, getLiveblocksNodeText, liveblocksProsemirrorNodeToJson, liveblocksProsemirrorNodeToJsonNodes, presencePatch };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { detectDupes } from '@liveblocks/core';
|
|
2
|
+
import { PKG_NAME, PKG_VERSION, PKG_FORMAT } from './version.js';
|
|
3
|
+
export { LIVEBLOCKS_CARET_PLUGIN_KEY, LIVEBLOCKS_CARET_PRESENCE_KEY, createLiveblocksCollaborationCaretPlugin, getCursorUser, presencePatch } from './cursors.js';
|
|
4
|
+
export { LIVEBLOCKS_COLLABORATION_PLUGIN_KEY, createLiveblocksCollaborationPlugin } from './plugin.js';
|
|
5
|
+
export { createLiveblocksProsemirrorNode, getLiveblocksNodeContent, getLiveblocksNodeId, getLiveblocksNodeText, liveblocksProsemirrorNodeToJson, liveblocksProsemirrorNodeToJsonNodes } from './schema.js';
|
|
6
|
+
|
|
7
|
+
detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport type {\n CollaborationCaretOptions,\n CollaborationCaretPluginState,\n CollaborationCaretStorage,\n CursorUser,\n RemoteCursor,\n} from \"./cursors\";\nexport {\n createLiveblocksCollaborationCaretPlugin,\n getCursorUser,\n LIVEBLOCKS_CARET_PLUGIN_KEY,\n LIVEBLOCKS_CARET_PRESENCE_KEY,\n presencePatch,\n} from \"./cursors\";\nexport type { LiveblocksCollaborationOptions } from \"./plugin\";\nexport {\n createLiveblocksCollaborationPlugin,\n LIVEBLOCKS_COLLABORATION_PLUGIN_KEY,\n} from \"./plugin\";\nexport type {\n LiveblocksProsemirrorNode,\n ProseMirrorJsonMark,\n ProseMirrorJsonNode,\n} from \"./schema\";\nexport {\n createLiveblocksProsemirrorNode,\n getLiveblocksNodeContent,\n getLiveblocksNodeId,\n getLiveblocksNodeText,\n liveblocksProsemirrorNodeToJson,\n liveblocksProsemirrorNodeToJsonNodes,\n} from \"./schema\";\nexport type { LiveblocksProsemirrorRoom } from \"./types\";\n"],"names":[],"mappings":";;;;;;AAIA,WAAY,CAAA,QAAA,EAAU,aAAa,UAAU,CAAA"}
|
package/dist/mapping.cjs
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapping.cjs","sources":["../src/mapping.ts"],"sourcesContent":["import type { LiveList, LiveText } from \"@liveblocks/client\";\nimport type { Node as ProseMirrorNode } from \"prosemirror-model\";\nimport type { Selection } from \"prosemirror-state\";\n\nimport {\n getLiveblocksNodeContent,\n getLiveblocksNodeId,\n getLiveblocksNodeText,\n getLiveblocksNodeType,\n type LiveblocksProsemirrorNode,\n} from \"./schema\";\n\nexport type LiveblocksProsemirrorPosition = {\n anchor: number;\n head: number;\n};\n\nexport function selectionToLiveblocksPosition(\n selection: Selection\n): LiveblocksProsemirrorPosition {\n return {\n anchor: selection.anchor,\n head: selection.head,\n };\n}\n\nexport function clampLiveblocksPosition(\n position: LiveblocksProsemirrorPosition,\n max: number\n): LiveblocksProsemirrorPosition {\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: LiveblocksProsemirrorNode;\n nodeId: string;\n text: LiveText;\n};\n\nexport type LiveblocksNodeRange = {\n childIndex?: number;\n content?: LiveList<LiveblocksProsemirrorNode>;\n from: number;\n node: LiveblocksProsemirrorNode;\n nodeId: string;\n parent?: LiveblocksProsemirrorNode;\n pmNode: ProseMirrorNode;\n to: number;\n};\n\nexport type LiveblocksListRange = {\n content: LiveList<LiveblocksProsemirrorNode>;\n from: number;\n node: LiveblocksProsemirrorNode;\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: LiveblocksProsemirrorNode,\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: LiveblocksProsemirrorNode\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: LiveblocksProsemirrorNode,\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: LiveblocksProsemirrorNode,\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: LiveblocksProsemirrorNode\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,SAC+B,EAAA;AAC/B,EAAO,OAAA;AAAA,IACL,QAAQ,SAAU,CAAA,MAAA;AAAA,IAClB,MAAM,SAAU,CAAA,IAAA;AAAA,GAClB,CAAA;AACF,CAAA;AAEgB,SAAA,uBAAA,CACd,UACA,GAC+B,EAAA;AAC/B,EAAO,OAAA;AAAA,IACL,MAAA,EAAQ,KAAK,GAAI,CAAA,CAAA,EAAG,KAAK,GAAI,CAAA,QAAA,CAAS,MAAQ,EAAA,GAAG,CAAC,CAAA;AAAA,IAClD,IAAA,EAAM,KAAK,GAAI,CAAA,CAAA,EAAG,KAAK,GAAI,CAAA,QAAA,CAAS,IAAM,EAAA,GAAG,CAAC,CAAA;AAAA,GAChD,CAAA;AACF,CAAA;AAqCA,SAAS,UAAA,CAAW,QAAyB,SAA2B,EAAA;AACtE,EAAA,OAAO,MAAO,CAAA,IAAA,CAAK,IAAS,KAAA,KAAA,GAAQ,YAAY,SAAY,GAAA,CAAA,CAAA;AAC9D,CAAA;AAEA,SA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odeId, 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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapping.js","sources":["../src/mapping.ts"],"sourcesContent":["import type { LiveList, LiveText } from \"@liveblocks/client\";\nimport type { Node as ProseMirrorNode } from \"prosemirror-model\";\nimport type { Selection } from \"prosemirror-state\";\n\nimport {\n getLiveblocksNodeContent,\n getLiveblocksNodeId,\n getLiveblocksNodeText,\n getLiveblocksNodeType,\n type LiveblocksProsemirrorNode,\n} from \"./schema\";\n\nexport type LiveblocksProsemirrorPosition = {\n anchor: number;\n head: number;\n};\n\nexport function selectionToLiveblocksPosition(\n selection: Selection\n): LiveblocksProsemirrorPosition {\n return {\n anchor: selection.anchor,\n head: selection.head,\n };\n}\n\nexport function clampLiveblocksPosition(\n position: LiveblocksProsemirrorPosition,\n max: number\n): LiveblocksProsemirrorPosition {\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: LiveblocksProsemirrorNode;\n nodeId: string;\n text: LiveText;\n};\n\nexport type LiveblocksNodeRange = {\n childIndex?: number;\n content?: LiveList<LiveblocksProsemirrorNode>;\n from: number;\n node: LiveblocksProsemirrorNode;\n nodeId: string;\n parent?: LiveblocksProsemirrorNode;\n pmNode: ProseMirrorNode;\n to: number;\n};\n\nexport type LiveblocksListRange = {\n content: LiveList<LiveblocksProsemirrorNode>;\n from: number;\n node: LiveblocksProsemirrorNode;\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: LiveblocksProsemirrorNode,\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: LiveblocksProsemirrorNode\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: LiveblocksProsemirrorNode,\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: LiveblocksProsemirrorNode,\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: LiveblocksProsemirrorNode\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":";;AAiBO,SAAS,8BACd,SAC+B,EAAA;AAC/B,EAAO,OAAA;AAAA,IACL,QAAQ,SAAU,CAAA,MAAA;AAAA,IAClB,MAAM,SAAU,CAAA,IAAA;AAAA,GAClB,CAAA;AACF,CAAA;AAEgB,SAAA,uBAAA,CACd,UACA,GAC+B,EAAA;AAC/B,EAAO,OAAA;AAAA,IACL,MAAA,EAAQ,KAAK,GAAI,CAAA,CAAA,EAAG,KAAK,GAAI,CAAA,QAAA,CAAS,MAAQ,EAAA,GAAG,CAAC,CAAA;AAAA,IAClD,IAAA,EAAM,KAAK,GAAI,CAAA,CAAA,EAAG,KAAK,GAAI,CAAA,QAAA,CAAS,IAAM,EAAA,GAAG,CAAC,CAAA;AAAA,GAChD,CAAA;AACF,CAAA;AAqCA,SAAS,UAAA,CAAW,QAAyB,SAA2B,EAAA;AACtE,EAAA,OAAO,MAAO,CAAA,IAAA,CAAK,IAAS,KAAA,KAAA,GAAQ,YAAY,SAAY,GAAA,CAAA,CAAA;AAC9D,CAAA;AAEA,SAAS,cACP,UACA,EAAA,UAAA,EACA,UACA,EAAA,QAAA,EACA,YACA,SACM,EAAA;AACN,EAAM,MAAA,WAAA,GAAc,yBAAyB,UAAU,CAAA,CAAA;AACvD,EAAA,IAAI,gBAAgB,KAAW,CAAA,EAAA;AAC7B,IAAA,OAAA;AAAA,GACF;AAEA,EAAA,UAAA,CAAW,IAAK,CAAA;AAAA,IACd,OAAS,EAAA,WAAA;AAAA,IACT,IAAM,EAAA,SAAA;AAAA,IACN,IAAM,EAAA,UAAA;AAAA,IACN,MAAA,EAAQ,oBAAoB,UAAU,CA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