@lexical/offset 0.13.1 → 0.14.1
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/LexicalOffset.dev.esm.js +311 -0
- package/LexicalOffset.esm.js +12 -0
- package/LexicalOffset.js +1 -1
- package/LexicalOffset.prod.esm.js +7 -0
- package/README.md +2 -0
- package/package.json +5 -3
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { $getNodeByKey, $isTextNode, $createRangeSelection, $isElementNode } from 'lexical';
|
|
8
|
+
|
|
9
|
+
/** @module @lexical/offset */
|
|
10
|
+
class OffsetView {
|
|
11
|
+
constructor(offsetMap, firstNode, blockOffsetSize = 1) {
|
|
12
|
+
this._offsetMap = offsetMap;
|
|
13
|
+
this._firstNode = firstNode;
|
|
14
|
+
this._blockOffsetSize = blockOffsetSize;
|
|
15
|
+
}
|
|
16
|
+
createSelectionFromOffsets(originalStart, originalEnd, diffOffsetView) {
|
|
17
|
+
const firstNode = this._firstNode;
|
|
18
|
+
if (firstNode === null) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
let start = originalStart;
|
|
22
|
+
let end = originalEnd;
|
|
23
|
+
let startOffsetNode = $searchForNodeWithOffset(firstNode, start, this._blockOffsetSize);
|
|
24
|
+
let endOffsetNode = $searchForNodeWithOffset(firstNode, end, this._blockOffsetSize);
|
|
25
|
+
if (diffOffsetView !== undefined) {
|
|
26
|
+
start = $getAdjustedOffsetFromDiff(start, startOffsetNode, diffOffsetView, this, this._blockOffsetSize);
|
|
27
|
+
startOffsetNode = $searchForNodeWithOffset(firstNode, start, this._blockOffsetSize);
|
|
28
|
+
end = $getAdjustedOffsetFromDiff(end, endOffsetNode, diffOffsetView, this, this._blockOffsetSize);
|
|
29
|
+
endOffsetNode = $searchForNodeWithOffset(firstNode, end, this._blockOffsetSize);
|
|
30
|
+
}
|
|
31
|
+
if (startOffsetNode === null || endOffsetNode === null) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
let startKey = startOffsetNode.key;
|
|
35
|
+
let endKey = endOffsetNode.key;
|
|
36
|
+
const startNode = $getNodeByKey(startKey);
|
|
37
|
+
const endNode = $getNodeByKey(endKey);
|
|
38
|
+
if (startNode === null || endNode === null) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
let startOffset = 0;
|
|
42
|
+
let endOffset = 0;
|
|
43
|
+
let startType = 'element';
|
|
44
|
+
let endType = 'element';
|
|
45
|
+
if (startOffsetNode.type === 'text') {
|
|
46
|
+
startOffset = start - startOffsetNode.start;
|
|
47
|
+
startType = 'text';
|
|
48
|
+
// If we are at the edge of a text node and we
|
|
49
|
+
// don't have a collapsed selection, then let's
|
|
50
|
+
// try and correct the offset node.
|
|
51
|
+
const sibling = startNode.getNextSibling();
|
|
52
|
+
if (start !== end && startOffset === startNode.getTextContentSize() && $isTextNode(sibling)) {
|
|
53
|
+
startOffset = 0;
|
|
54
|
+
startKey = sibling.__key;
|
|
55
|
+
}
|
|
56
|
+
} else if (startOffsetNode.type === 'inline') {
|
|
57
|
+
startKey = startNode.getParentOrThrow().getKey();
|
|
58
|
+
startOffset = end > startOffsetNode.start ? startOffsetNode.end : startOffsetNode.start;
|
|
59
|
+
}
|
|
60
|
+
if (endOffsetNode.type === 'text') {
|
|
61
|
+
endOffset = end - endOffsetNode.start;
|
|
62
|
+
endType = 'text';
|
|
63
|
+
} else if (endOffsetNode.type === 'inline') {
|
|
64
|
+
endKey = endNode.getParentOrThrow().getKey();
|
|
65
|
+
endOffset = end > endOffsetNode.start ? endOffsetNode.end : endOffsetNode.start;
|
|
66
|
+
}
|
|
67
|
+
const selection = $createRangeSelection();
|
|
68
|
+
if (selection === null) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
selection.anchor.set(startKey, startOffset, startType);
|
|
72
|
+
selection.focus.set(endKey, endOffset, endType);
|
|
73
|
+
return selection;
|
|
74
|
+
}
|
|
75
|
+
getOffsetsFromSelection(selection) {
|
|
76
|
+
const anchor = selection.anchor;
|
|
77
|
+
const focus = selection.focus;
|
|
78
|
+
const offsetMap = this._offsetMap;
|
|
79
|
+
const anchorOffset = anchor.offset;
|
|
80
|
+
const focusOffset = focus.offset;
|
|
81
|
+
let start = -1;
|
|
82
|
+
let end = -1;
|
|
83
|
+
if (anchor.type === 'text') {
|
|
84
|
+
const offsetNode = offsetMap.get(anchor.key);
|
|
85
|
+
if (offsetNode !== undefined) {
|
|
86
|
+
start = offsetNode.start + anchorOffset;
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
const node = anchor.getNode().getDescendantByIndex(anchorOffset);
|
|
90
|
+
if (node !== null) {
|
|
91
|
+
const offsetNode = offsetMap.get(node.getKey());
|
|
92
|
+
if (offsetNode !== undefined) {
|
|
93
|
+
const isAtEnd = node.getIndexWithinParent() !== anchorOffset;
|
|
94
|
+
start = isAtEnd ? offsetNode.end : offsetNode.start;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (focus.type === 'text') {
|
|
99
|
+
const offsetNode = offsetMap.get(focus.key);
|
|
100
|
+
if (offsetNode !== undefined) {
|
|
101
|
+
end = offsetNode.start + focus.offset;
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
const node = focus.getNode().getDescendantByIndex(focusOffset);
|
|
105
|
+
if (node !== null) {
|
|
106
|
+
const offsetNode = offsetMap.get(node.getKey());
|
|
107
|
+
if (offsetNode !== undefined) {
|
|
108
|
+
const isAtEnd = node.getIndexWithinParent() !== focusOffset;
|
|
109
|
+
end = isAtEnd ? offsetNode.end : offsetNode.start;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return [start, end];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function $getAdjustedOffsetFromDiff(offset, offsetNode, prevOffsetView, offsetView, blockOffsetSize) {
|
|
117
|
+
const prevOffsetMap = prevOffsetView._offsetMap;
|
|
118
|
+
const offsetMap = offsetView._offsetMap;
|
|
119
|
+
const visited = new Set();
|
|
120
|
+
let adjustedOffset = offset;
|
|
121
|
+
let currentNode = offsetNode;
|
|
122
|
+
while (currentNode !== null) {
|
|
123
|
+
const key = currentNode.key;
|
|
124
|
+
const prevNode = prevOffsetMap.get(key);
|
|
125
|
+
const diff = currentNode.end - currentNode.start;
|
|
126
|
+
visited.add(key);
|
|
127
|
+
if (prevNode === undefined) {
|
|
128
|
+
adjustedOffset += diff;
|
|
129
|
+
} else {
|
|
130
|
+
const prevDiff = prevNode.end - prevNode.start;
|
|
131
|
+
if (prevDiff !== diff) {
|
|
132
|
+
adjustedOffset += diff - prevDiff;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const sibling = currentNode.prev;
|
|
136
|
+
if (sibling !== null) {
|
|
137
|
+
currentNode = sibling;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
let parent = currentNode.parent;
|
|
141
|
+
while (parent !== null) {
|
|
142
|
+
let parentSibling = parent.prev;
|
|
143
|
+
if (parentSibling !== null) {
|
|
144
|
+
const parentSiblingKey = parentSibling.key;
|
|
145
|
+
const prevParentSibling = prevOffsetMap.get(parentSiblingKey);
|
|
146
|
+
const parentDiff = parentSibling.end - parentSibling.start;
|
|
147
|
+
visited.add(parentSiblingKey);
|
|
148
|
+
if (prevParentSibling === undefined) {
|
|
149
|
+
adjustedOffset += parentDiff;
|
|
150
|
+
} else {
|
|
151
|
+
const prevParentDiff = prevParentSibling.end - prevParentSibling.start;
|
|
152
|
+
if (prevParentDiff !== parentDiff) {
|
|
153
|
+
adjustedOffset += parentDiff - prevParentDiff;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
parentSibling = parentSibling.prev;
|
|
157
|
+
}
|
|
158
|
+
parent = parent.parent;
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Now traverse through the old offsets nodes and find any nodes we missed
|
|
164
|
+
// above, because they were not in the latest offset node view (they have been
|
|
165
|
+
// deleted).
|
|
166
|
+
const prevFirstNode = prevOffsetView._firstNode;
|
|
167
|
+
if (prevFirstNode !== null) {
|
|
168
|
+
currentNode = $searchForNodeWithOffset(prevFirstNode, offset, blockOffsetSize);
|
|
169
|
+
let alreadyVisitedParentOfCurrentNode = false;
|
|
170
|
+
while (currentNode !== null) {
|
|
171
|
+
if (!visited.has(currentNode.key)) {
|
|
172
|
+
alreadyVisitedParentOfCurrentNode = true;
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
currentNode = currentNode.parent;
|
|
176
|
+
}
|
|
177
|
+
if (!alreadyVisitedParentOfCurrentNode) {
|
|
178
|
+
while (currentNode !== null) {
|
|
179
|
+
const key = currentNode.key;
|
|
180
|
+
if (!visited.has(key)) {
|
|
181
|
+
const node = offsetMap.get(key);
|
|
182
|
+
const prevDiff = currentNode.end - currentNode.start;
|
|
183
|
+
if (node === undefined) {
|
|
184
|
+
adjustedOffset -= prevDiff;
|
|
185
|
+
} else {
|
|
186
|
+
const diff = node.end - node.start;
|
|
187
|
+
if (prevDiff !== diff) {
|
|
188
|
+
adjustedOffset += diff - prevDiff;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
currentNode = currentNode.prev;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return adjustedOffset;
|
|
197
|
+
}
|
|
198
|
+
function $searchForNodeWithOffset(firstNode, offset, blockOffsetSize) {
|
|
199
|
+
let currentNode = firstNode;
|
|
200
|
+
while (currentNode !== null) {
|
|
201
|
+
const end = currentNode.end + (currentNode.type !== 'element' || blockOffsetSize === 0 ? 1 : 0);
|
|
202
|
+
if (offset < end) {
|
|
203
|
+
const child = currentNode.child;
|
|
204
|
+
if (child !== null) {
|
|
205
|
+
currentNode = child;
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
return currentNode;
|
|
209
|
+
}
|
|
210
|
+
const sibling = currentNode.next;
|
|
211
|
+
if (sibling === null) {
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
currentNode = sibling;
|
|
215
|
+
}
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
function $createInternalOffsetNode(child, type, start, end, key, parent) {
|
|
219
|
+
return {
|
|
220
|
+
child,
|
|
221
|
+
end,
|
|
222
|
+
key,
|
|
223
|
+
next: null,
|
|
224
|
+
parent,
|
|
225
|
+
prev: null,
|
|
226
|
+
start,
|
|
227
|
+
type
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
function $createOffsetNode(state, key, parent, nodeMap, offsetMap, blockOffsetSize) {
|
|
231
|
+
const node = nodeMap.get(key);
|
|
232
|
+
if (node === undefined) {
|
|
233
|
+
{
|
|
234
|
+
throw Error(`createOffsetModel: could not find node by key`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const start = state.offset;
|
|
238
|
+
if ($isElementNode(node)) {
|
|
239
|
+
const childKeys = createChildrenArray(node, nodeMap);
|
|
240
|
+
const blockIsEmpty = childKeys.length === 0;
|
|
241
|
+
const child = blockIsEmpty ? null : $createOffsetChild(state, childKeys, null, nodeMap, offsetMap, blockOffsetSize);
|
|
242
|
+
|
|
243
|
+
// If the prev node was not a block or the block is empty, we should
|
|
244
|
+
// account for the user being able to selection the block (due to the \n).
|
|
245
|
+
if (!state.prevIsBlock || blockIsEmpty) {
|
|
246
|
+
state.prevIsBlock = true;
|
|
247
|
+
state.offset += blockOffsetSize;
|
|
248
|
+
}
|
|
249
|
+
const offsetNode = $createInternalOffsetNode(child, 'element', start, start, key, parent);
|
|
250
|
+
if (child !== null) {
|
|
251
|
+
child.parent = offsetNode;
|
|
252
|
+
}
|
|
253
|
+
const end = state.offset;
|
|
254
|
+
offsetNode.end = end;
|
|
255
|
+
offsetMap.set(key, offsetNode);
|
|
256
|
+
return offsetNode;
|
|
257
|
+
}
|
|
258
|
+
state.prevIsBlock = false;
|
|
259
|
+
const isText = $isTextNode(node);
|
|
260
|
+
const length = isText ? node.__text.length : 1;
|
|
261
|
+
const end = state.offset += length;
|
|
262
|
+
const offsetNode = $createInternalOffsetNode(null, isText ? 'text' : 'inline', start, end, key, parent);
|
|
263
|
+
offsetMap.set(key, offsetNode);
|
|
264
|
+
return offsetNode;
|
|
265
|
+
}
|
|
266
|
+
function $createOffsetChild(state, children, parent, nodeMap, offsetMap, blockOffsetSize) {
|
|
267
|
+
let firstNode = null;
|
|
268
|
+
let currentNode = null;
|
|
269
|
+
const childrenLength = children.length;
|
|
270
|
+
for (let i = 0; i < childrenLength; i++) {
|
|
271
|
+
const childKey = children[i];
|
|
272
|
+
const offsetNode = $createOffsetNode(state, childKey, parent, nodeMap, offsetMap, blockOffsetSize);
|
|
273
|
+
if (currentNode === null) {
|
|
274
|
+
firstNode = offsetNode;
|
|
275
|
+
} else {
|
|
276
|
+
offsetNode.prev = currentNode;
|
|
277
|
+
currentNode.next = offsetNode;
|
|
278
|
+
}
|
|
279
|
+
currentNode = offsetNode;
|
|
280
|
+
}
|
|
281
|
+
return firstNode;
|
|
282
|
+
}
|
|
283
|
+
function createChildrenArray(element, nodeMap) {
|
|
284
|
+
const children = [];
|
|
285
|
+
let nodeKey = element.__first;
|
|
286
|
+
while (nodeKey !== null) {
|
|
287
|
+
const node = nodeMap === null ? $getNodeByKey(nodeKey) : nodeMap.get(nodeKey);
|
|
288
|
+
if (node === null || node === undefined) {
|
|
289
|
+
{
|
|
290
|
+
throw Error(`createChildrenArray: node does not exist in nodeMap`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
children.push(nodeKey);
|
|
294
|
+
nodeKey = node.__next;
|
|
295
|
+
}
|
|
296
|
+
return children;
|
|
297
|
+
}
|
|
298
|
+
function $createOffsetView(editor, blockOffsetSize = 1, editorState) {
|
|
299
|
+
const targetEditorState = editorState || editor._pendingEditorState || editor._editorState;
|
|
300
|
+
const nodeMap = targetEditorState._nodeMap;
|
|
301
|
+
const root = nodeMap.get('root');
|
|
302
|
+
const offsetMap = new Map();
|
|
303
|
+
const state = {
|
|
304
|
+
offset: 0,
|
|
305
|
+
prevIsBlock: false
|
|
306
|
+
};
|
|
307
|
+
const node = $createOffsetChild(state, createChildrenArray(root, nodeMap), null, nodeMap, offsetMap, blockOffsetSize);
|
|
308
|
+
return new OffsetView(offsetMap, node, blockOffsetSize);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export { $createOffsetView, OffsetView, createChildrenArray };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import * as modDev from './LexicalOffset.dev.esm.js';
|
|
8
|
+
import * as modProd from './LexicalOffset.prod.esm.js';
|
|
9
|
+
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
|
+
export const $createOffsetView = mod.$createOffsetView;
|
|
11
|
+
export const OffsetView = mod.OffsetView;
|
|
12
|
+
export const createChildrenArray = mod.createChildrenArray;
|
package/LexicalOffset.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
'use strict'
|
|
8
|
-
const LexicalOffset = process.env.NODE_ENV === 'development' ? require('./LexicalOffset.dev.js') : require('./LexicalOffset.prod.js')
|
|
8
|
+
const LexicalOffset = process.env.NODE_ENV === 'development' ? require('./LexicalOffset.dev.js') : require('./LexicalOffset.prod.js');
|
|
9
9
|
module.exports = LexicalOffset;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import{$getNodeByKey as t,$isTextNode as e,$createRangeSelection as n,$isElementNode as l}from"lexical";var s=function(t){const e=new URLSearchParams;e.append("code",t);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${t}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)};class o{constructor(t,e,n=1){this._offsetMap=t,this._firstNode=e,this._blockOffsetSize=n}createSelectionFromOffsets(l,s,o){const f=this._firstNode;if(null===f)return null;let c=l,u=s,a=i(f,c,this._blockOffsetSize),d=i(f,u,this._blockOffsetSize);if(void 0!==o&&(c=r(c,a,o,this,this._blockOffsetSize),a=i(f,c,this._blockOffsetSize),u=r(u,d,o,this,this._blockOffsetSize),d=i(f,u,this._blockOffsetSize)),null===a||null===d)return null;let p=a.key,h=d.key;const g=t(p),v=t(h);if(null===g||null===v)return null;let _=0,k=0,y="element",x="element";if("text"===a.type){_=c-a.start,y="text";const t=g.getNextSibling();c!==u&&_===g.getTextContentSize()&&e(t)&&(_=0,p=t.__key)}else"inline"===a.type&&(p=g.getParentOrThrow().getKey(),_=u>a.start?a.end:a.start);"text"===d.type?(k=u-d.start,x="text"):"inline"===d.type&&(h=v.getParentOrThrow().getKey(),k=u>d.start?d.end:d.start);const S=n();return null===S?null:(S.anchor.set(p,_,y),S.focus.set(h,k,x),S)}getOffsetsFromSelection(t){const e=t.anchor,n=t.focus,l=this._offsetMap,s=e.offset,o=n.offset;let r=-1,i=-1;if("text"===e.type){const t=l.get(e.key);void 0!==t&&(r=t.start+s)}else{const t=e.getNode().getDescendantByIndex(s);if(null!==t){const e=l.get(t.getKey());if(void 0!==e){r=t.getIndexWithinParent()!==s?e.end:e.start}}}if("text"===n.type){const t=l.get(n.key);void 0!==t&&(i=t.start+n.offset)}else{const t=n.getNode().getDescendantByIndex(o);if(null!==t){const e=l.get(t.getKey());if(void 0!==e){i=t.getIndexWithinParent()!==o?e.end:e.start}}}return[r,i]}}function r(t,e,n,l,s){const o=n._offsetMap,r=l._offsetMap,f=new Set;let c=t,u=e;for(;null!==u;){const t=u.key,e=o.get(t),n=u.end-u.start;if(f.add(t),void 0===e)c+=n;else{const t=e.end-e.start;t!==n&&(c+=n-t)}const l=u.prev;if(null!==l){u=l;continue}let s=u.parent;for(;null!==s;){let t=s.prev;if(null!==t){const e=t.key,n=o.get(e),l=t.end-t.start;if(f.add(e),void 0===n)c+=l;else{const t=n.end-n.start;t!==l&&(c+=l-t)}t=t.prev}s=s.parent}break}const a=n._firstNode;if(null!==a){u=i(a,t,s);let e=!1;for(;null!==u;){if(!f.has(u.key)){e=!0;break}u=u.parent}if(!e)for(;null!==u;){const t=u.key;if(!f.has(t)){const e=r.get(t),n=u.end-u.start;if(void 0===e)c-=n;else{const t=e.end-e.start;n!==t&&(c+=t-n)}}u=u.prev}}return c}function i(t,e,n){let l=t;for(;null!==l;){if(e<l.end+("element"!==l.type||0===n?1:0)){const t=l.child;if(null!==t){l=t;continue}return l}const t=l.next;if(null===t)break;l=t}return null}function f(t,e,n,l,s,o){return{child:t,end:l,key:s,next:null,parent:o,prev:null,start:n,type:e}}function c(t,n,o,r,i,c){const d=r.get(n);void 0===d&&s(3);const p=t.offset;if(l(d)){const e=a(d,r),l=0===e.length,s=l?null:u(t,e,null,r,i,c);t.prevIsBlock&&!l||(t.prevIsBlock=!0,t.offset+=c);const h=f(s,"element",p,p,n,o);null!==s&&(s.parent=h);const g=t.offset;return h.end=g,i.set(n,h),h}t.prevIsBlock=!1;const h=e(d),g=h?d.__text.length:1,v=f(null,h?"text":"inline",p,t.offset+=g,n,o);return i.set(n,v),v}function u(t,e,n,l,s,o){let r=null,i=null;const f=e.length;for(let u=0;u<f;u++){const f=c(t,e[u],n,l,s,o);null===i?r=f:(f.prev=i,i.next=f),i=f}return r}function a(e,n){const l=[];let o=e.__first;for(;null!==o;){const e=null===n?t(o):n.get(o);null==e&&s(101),l.push(o),o=e.__next}return l}function d(t,e=1,n){const l=(n||t._pendingEditorState||t._editorState)._nodeMap,s=l.get("root"),r=new Map,i=u({offset:0,prevIsBlock:!1},a(s,l),null,l,r,e);return new o(r,i,e)}export{d as $createOffsetView,o as OffsetView,a as createChildrenArray};
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -8,14 +8,16 @@
|
|
|
8
8
|
"offset"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.14.1",
|
|
12
12
|
"main": "LexicalOffset.js",
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"lexical": "0.
|
|
14
|
+
"lexical": "0.14.1"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
18
|
"url": "https://github.com/facebook/lexical",
|
|
19
19
|
"directory": "packages/lexical-offset"
|
|
20
|
-
}
|
|
20
|
+
},
|
|
21
|
+
"module": "LexicalOffset.esm.js",
|
|
22
|
+
"sideEffects": false
|
|
21
23
|
}
|