@portabletext/editor 4.1.1 → 4.1.3
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/lib/_chunks-es/selector.is-at-the-start-of-block.js +113 -205
- package/lib/_chunks-es/selector.is-at-the-start-of-block.js.map +1 -1
- package/lib/_chunks-es/util.slice-blocks.js +29 -4
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
- package/lib/index.js +240 -176
- package/lib/index.js.map +1 -1
- package/lib/selectors/index.js +18 -2
- package/lib/selectors/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getBlockKeyFromSelectionPoint, getChildKeyFromSelectionPoint, getSelectionEndPoint as getSelectionEndPoint$1, getSelectionStartPoint as getSelectionStartPoint$1, isEqualSelectionPoints, getBlockStartPoint, getBlockEndPoint, sliceBlocks, isSelectionCollapsed as isSelectionCollapsed$1, blockOffsetToSpanSelectionPoint, isKeyedSegment, spanSelectionPointToBlockOffset, isListBlock } from "./util.slice-blocks.js";
|
|
2
1
|
import { isTextBlock, isSpan } from "@portabletext/schema";
|
|
2
|
+
import { getBlockKeyFromSelectionPoint, getChildKeyFromSelectionPoint, isEqualPaths, getSelectionStartPoint as getSelectionStartPoint$1, getSelectionEndPoint as getSelectionEndPoint$1, isEqualSelectionPoints, getBlockStartPoint, getBlockEndPoint, sliceBlocks, isSelectionCollapsed as isSelectionCollapsed$1, blockOffsetToSpanSelectionPoint, isKeyedSegment, spanSelectionPointToBlockOffset, isListBlock } from "./util.slice-blocks.js";
|
|
3
3
|
const getFocusBlock = (snapshot) => {
|
|
4
4
|
if (!snapshot.context.selection)
|
|
5
5
|
return;
|
|
@@ -42,121 +42,58 @@ const getFocusBlock = (snapshot) => {
|
|
|
42
42
|
if (snapshot.context.selection)
|
|
43
43
|
return snapshot.context.selection.backward ? snapshot.context.selection.focus : snapshot.context.selection.anchor;
|
|
44
44
|
};
|
|
45
|
-
function
|
|
45
|
+
function getSelectedChildren(options) {
|
|
46
|
+
const filter = options?.filter;
|
|
46
47
|
return (snapshot) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const startPoint = getSelectionStartPoint$1(snapshot.context.selection), startBlockKey = getBlockKeyFromSelectionPoint(startPoint), startChildKey = getChildKeyFromSelectionPoint(startPoint), pointBlockKey = getBlockKeyFromSelectionPoint(point), pointChildKey = getChildKeyFromSelectionPoint(point);
|
|
77
|
-
if (!pointBlockKey || !startBlockKey)
|
|
78
|
-
return !1;
|
|
79
|
-
const startBlockIndex = snapshot.blockIndexMap.get(startBlockKey), pointBlockIndex = snapshot.blockIndexMap.get(pointBlockKey);
|
|
80
|
-
if (startBlockIndex === void 0 || pointBlockIndex === void 0)
|
|
81
|
-
return !1;
|
|
82
|
-
if (pointBlockIndex < startBlockIndex)
|
|
83
|
-
return !0;
|
|
84
|
-
if (pointBlockIndex > startBlockIndex)
|
|
85
|
-
return !1;
|
|
86
|
-
const pointBlock = snapshot.context.value.at(pointBlockIndex);
|
|
87
|
-
if (!pointBlock || !isTextBlock(snapshot.context, pointBlock))
|
|
88
|
-
return !1;
|
|
89
|
-
let pointChildIndex, startChildIndex, childIndex = -1;
|
|
90
|
-
for (const child of pointBlock.children) {
|
|
91
|
-
if (childIndex++, child._key === pointChildKey && child._key === startChildKey)
|
|
92
|
-
return point.offset < startPoint.offset;
|
|
93
|
-
if (child._key === pointChildKey && (pointChildIndex = childIndex), child._key === startChildKey && (startChildIndex = childIndex), pointChildIndex !== void 0 && startChildIndex !== void 0)
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
return pointChildIndex === void 0 || startChildIndex === void 0 ? !1 : pointChildIndex < startChildIndex;
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
function isOverlappingSelection(selection) {
|
|
100
|
-
return (snapshot) => {
|
|
101
|
-
if (!selection || !snapshot.context.selection)
|
|
102
|
-
return !1;
|
|
103
|
-
const selectionStartPoint = getSelectionStartPoint({
|
|
104
|
-
context: {
|
|
105
|
-
...snapshot.context,
|
|
106
|
-
selection
|
|
107
|
-
}
|
|
108
|
-
}), selectionEndPoint = getSelectionEndPoint({
|
|
109
|
-
context: {
|
|
110
|
-
...snapshot.context,
|
|
111
|
-
selection
|
|
112
|
-
}
|
|
113
|
-
}), originalSelectionStartPoint = getSelectionStartPoint(snapshot), originalSelectionEndPoint = getSelectionEndPoint(snapshot);
|
|
114
|
-
if (!selectionStartPoint || !selectionEndPoint || !originalSelectionStartPoint || !originalSelectionEndPoint)
|
|
115
|
-
return !1;
|
|
116
|
-
const startPointEqualToOriginalStartPoint = isEqualSelectionPoints(selectionStartPoint, originalSelectionStartPoint), endPointEqualToOriginalEndPoint = isEqualSelectionPoints(selectionEndPoint, originalSelectionEndPoint);
|
|
117
|
-
if (startPointEqualToOriginalStartPoint && endPointEqualToOriginalEndPoint)
|
|
118
|
-
return !0;
|
|
119
|
-
const startPointBeforeSelection = isPointBeforeSelection(selectionStartPoint)(snapshot), startPointAfterSelection = isPointAfterSelection(selectionStartPoint)(snapshot), endPointBeforeSelection = isPointBeforeSelection(selectionEndPoint)(snapshot), endPointAfterSelection = isPointAfterSelection(selectionEndPoint)(snapshot), originalStartPointBeforeStartPoint = isPointBeforeSelection(originalSelectionStartPoint)({
|
|
120
|
-
...snapshot,
|
|
121
|
-
context: {
|
|
122
|
-
...snapshot.context,
|
|
123
|
-
selection: {
|
|
124
|
-
anchor: selectionStartPoint,
|
|
125
|
-
focus: selectionStartPoint
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}), originalStartPointAfterStartPoint = isPointAfterSelection(originalSelectionStartPoint)({
|
|
129
|
-
...snapshot,
|
|
130
|
-
context: {
|
|
131
|
-
...snapshot.context,
|
|
132
|
-
selection: {
|
|
133
|
-
anchor: selectionStartPoint,
|
|
134
|
-
focus: selectionStartPoint
|
|
48
|
+
const startPoint = getSelectionStartPoint(snapshot), endPoint = getSelectionEndPoint(snapshot);
|
|
49
|
+
if (!startPoint || !endPoint)
|
|
50
|
+
return [];
|
|
51
|
+
const startBlockKey = getBlockKeyFromSelectionPoint(startPoint), endBlockKey = getBlockKeyFromSelectionPoint(endPoint), startChildKey = getChildKeyFromSelectionPoint(startPoint), endChildKey = getChildKeyFromSelectionPoint(endPoint);
|
|
52
|
+
if (!startBlockKey || !endBlockKey)
|
|
53
|
+
return [];
|
|
54
|
+
const startBlockIndex = snapshot.blockIndexMap.get(startBlockKey), endBlockIndex = snapshot.blockIndexMap.get(endBlockKey);
|
|
55
|
+
if (startBlockIndex === void 0 || endBlockIndex === void 0)
|
|
56
|
+
return [];
|
|
57
|
+
const selectedChildren = [], minBlockIndex = Math.min(startBlockIndex, endBlockIndex), maxBlockIndex = Math.max(startBlockIndex, endBlockIndex), blocks = snapshot.context.value.slice(minBlockIndex, maxBlockIndex + 1);
|
|
58
|
+
let startChildFound = !1;
|
|
59
|
+
for (const block of blocks) {
|
|
60
|
+
if (!isTextBlock(snapshot.context, block))
|
|
61
|
+
continue;
|
|
62
|
+
const isStartBlock = block._key === startBlockKey, isEndBlock = block._key === endBlockKey, isMiddleBlock = !isStartBlock && !isEndBlock;
|
|
63
|
+
for (const child of block.children) {
|
|
64
|
+
const isStartChild = child._key === startChildKey, isEndChild = child._key === endChildKey, addChild = () => {
|
|
65
|
+
(!filter || filter(child)) && selectedChildren.push({
|
|
66
|
+
node: child,
|
|
67
|
+
path: [{
|
|
68
|
+
_key: block._key
|
|
69
|
+
}, "children", {
|
|
70
|
+
_key: child._key
|
|
71
|
+
}]
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
if (isMiddleBlock) {
|
|
75
|
+
addChild();
|
|
76
|
+
continue;
|
|
135
77
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
...snapshot.context,
|
|
141
|
-
selection: {
|
|
142
|
-
anchor: selectionEndPoint,
|
|
143
|
-
focus: selectionEndPoint
|
|
78
|
+
if (isStartChild) {
|
|
79
|
+
if (startChildFound = !0, isSpan(snapshot.context, child) ? startPoint.offset < child.text.length && addChild() : addChild(), startChildKey === endChildKey)
|
|
80
|
+
break;
|
|
81
|
+
continue;
|
|
144
82
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
context: {
|
|
149
|
-
...snapshot.context,
|
|
150
|
-
selection: {
|
|
151
|
-
anchor: selectionEndPoint,
|
|
152
|
-
focus: selectionEndPoint
|
|
83
|
+
if (isEndChild) {
|
|
84
|
+
isSpan(snapshot.context, child) ? endPoint.offset > 0 && addChild() : addChild();
|
|
85
|
+
break;
|
|
153
86
|
}
|
|
87
|
+
startChildFound && addChild();
|
|
154
88
|
}
|
|
155
|
-
|
|
156
|
-
|
|
89
|
+
if (isStartBlock && startBlockKey === endBlockKey)
|
|
90
|
+
break;
|
|
91
|
+
isStartBlock && (startChildFound = !0);
|
|
92
|
+
}
|
|
93
|
+
return selectedChildren;
|
|
157
94
|
};
|
|
158
95
|
}
|
|
159
|
-
const isSelectionCollapsed = (snapshot) => snapshot.context.selection ?
|
|
96
|
+
const isSelectionCollapsed = (snapshot) => snapshot.context.selection ? isEqualPaths(snapshot.context.selection.anchor.path, snapshot.context.selection.focus.path) && snapshot.context.selection.anchor.offset === snapshot.context.selection.focus.offset : !1, getFocusInlineObject = (snapshot) => {
|
|
160
97
|
const focusChild = getFocusChild(snapshot);
|
|
161
98
|
return focusChild && !isSpan(snapshot.context, focusChild.node) ? {
|
|
162
99
|
node: focusChild.node,
|
|
@@ -226,7 +163,68 @@ const isSelectionCollapsed = (snapshot) => snapshot.context.selection ? JSON.str
|
|
|
226
163
|
}
|
|
227
164
|
}
|
|
228
165
|
});
|
|
229
|
-
}
|
|
166
|
+
};
|
|
167
|
+
function comparePoints(snapshot, pointA, pointB) {
|
|
168
|
+
const blockKeyA = getBlockKeyFromSelectionPoint(pointA), blockKeyB = getBlockKeyFromSelectionPoint(pointB);
|
|
169
|
+
if (!blockKeyA)
|
|
170
|
+
throw new Error(`Cannot compare points: no block key found for ${pointA}`);
|
|
171
|
+
if (!blockKeyB)
|
|
172
|
+
throw new Error(`Cannot compare points: no block key found for ${pointB}`);
|
|
173
|
+
const blockIndexA = snapshot.blockIndexMap.get(blockKeyA), blockIndexB = snapshot.blockIndexMap.get(blockKeyB);
|
|
174
|
+
if (blockIndexA === void 0)
|
|
175
|
+
throw new Error(`Cannot compare points: block "${blockKeyA}" not found`);
|
|
176
|
+
if (blockIndexB === void 0)
|
|
177
|
+
throw new Error(`Cannot compare points: block "${blockKeyB}" not found`);
|
|
178
|
+
if (blockIndexA < blockIndexB)
|
|
179
|
+
return -1;
|
|
180
|
+
if (blockIndexA > blockIndexB)
|
|
181
|
+
return 1;
|
|
182
|
+
const block = snapshot.context.value.at(blockIndexA);
|
|
183
|
+
if (!block || !isTextBlock(snapshot.context, block))
|
|
184
|
+
return 0;
|
|
185
|
+
const childKeyA = getChildKeyFromSelectionPoint(pointA), childKeyB = getChildKeyFromSelectionPoint(pointB);
|
|
186
|
+
if (!childKeyA)
|
|
187
|
+
throw new Error(`Cannot compare points: no child key found for ${pointA}`);
|
|
188
|
+
if (!childKeyB)
|
|
189
|
+
throw new Error(`Cannot compare points: no child key found for ${pointB}`);
|
|
190
|
+
let childIndexA, childIndexB;
|
|
191
|
+
for (let i = 0; i < block.children.length; i++) {
|
|
192
|
+
const child = block.children.at(i);
|
|
193
|
+
if (child) {
|
|
194
|
+
if (child._key === childKeyA && child._key === childKeyB)
|
|
195
|
+
return pointA.offset < pointB.offset ? -1 : pointA.offset > pointB.offset ? 1 : 0;
|
|
196
|
+
if (child._key === childKeyA && (childIndexA = i), child._key === childKeyB && (childIndexB = i), childIndexA !== void 0 && childIndexB !== void 0)
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (childIndexA === void 0)
|
|
201
|
+
throw new Error(`Cannot compare points: child "${childKeyA}" not found`);
|
|
202
|
+
if (childIndexB === void 0)
|
|
203
|
+
throw new Error(`Cannot compare points: child "${childKeyB}" not found`);
|
|
204
|
+
return childIndexA < childIndexB ? -1 : childIndexA > childIndexB ? 1 : 0;
|
|
205
|
+
}
|
|
206
|
+
function isOverlappingSelection(selection) {
|
|
207
|
+
return (snapshot) => {
|
|
208
|
+
const editorSelection = snapshot.context.selection;
|
|
209
|
+
if (!selection || !editorSelection)
|
|
210
|
+
return !1;
|
|
211
|
+
const selectionStart = getSelectionStartPoint$1(selection), selectionEnd = getSelectionEndPoint$1(selection), editorSelectionStart = getSelectionStartPoint$1(editorSelection), editorSelectionEnd = getSelectionEndPoint$1(editorSelection), selectionStartBlockKey = getBlockKeyFromSelectionPoint(selectionStart), selectionEndBlockKey = getBlockKeyFromSelectionPoint(selectionEnd), editorSelectionStartBlockKey = getBlockKeyFromSelectionPoint(editorSelectionStart), editorSelectionEndBlockKey = getBlockKeyFromSelectionPoint(editorSelectionEnd);
|
|
212
|
+
if (!selectionStartBlockKey || !selectionEndBlockKey || !editorSelectionStartBlockKey || !editorSelectionEndBlockKey)
|
|
213
|
+
return !1;
|
|
214
|
+
const selectionStartBlockIndex = snapshot.blockIndexMap.get(selectionStartBlockKey), selectionEndBlockIndex = snapshot.blockIndexMap.get(selectionEndBlockKey), editorSelectionStartBlockIndex = snapshot.blockIndexMap.get(editorSelectionStartBlockKey), editorSelectionEndBlockIndex = snapshot.blockIndexMap.get(editorSelectionEndBlockKey);
|
|
215
|
+
if (selectionStartBlockIndex === void 0 || selectionEndBlockIndex === void 0 || editorSelectionStartBlockIndex === void 0 || editorSelectionEndBlockIndex === void 0)
|
|
216
|
+
return !1;
|
|
217
|
+
const [selectionMinBlockIndex, selectionMaxBlockIndex] = selectionStartBlockIndex <= selectionEndBlockIndex ? [selectionStartBlockIndex, selectionEndBlockIndex] : [selectionEndBlockIndex, selectionStartBlockIndex], [editorSelectionMinBlockIndex, editorSelectionMaxBlockIndex] = editorSelectionStartBlockIndex <= editorSelectionEndBlockIndex ? [editorSelectionStartBlockIndex, editorSelectionEndBlockIndex] : [editorSelectionEndBlockIndex, editorSelectionStartBlockIndex];
|
|
218
|
+
return selectionMaxBlockIndex < editorSelectionMinBlockIndex || selectionMinBlockIndex > editorSelectionMaxBlockIndex ? !1 : hasPointLevelOverlap(snapshot, selectionStart, selectionEnd, editorSelectionStart, editorSelectionEnd);
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function hasPointLevelOverlap(snapshot, selectionStart, selectionEnd, editorSelectionStart, editorSelectionEnd) {
|
|
222
|
+
if (isEqualSelectionPoints(selectionStart, editorSelectionStart) && isEqualSelectionPoints(selectionEnd, editorSelectionEnd))
|
|
223
|
+
return !0;
|
|
224
|
+
const selectionStartVsEditorSelectionStart = comparePoints(snapshot, selectionStart, editorSelectionStart), selectionStartVsEditorSelectionEnd = comparePoints(snapshot, selectionStart, editorSelectionEnd), selectionEndVsEditorSelectionStart = comparePoints(snapshot, selectionEnd, editorSelectionStart), selectionEndVsEditorSelectionEnd = comparePoints(snapshot, selectionEnd, editorSelectionEnd), editorSelectionStartVsSelectionStart = comparePoints(snapshot, editorSelectionStart, selectionStart), editorSelectionEndVsSelectionEnd = comparePoints(snapshot, editorSelectionEnd, selectionEnd), selectionStartBeforeEditorSelectionStart = selectionStartVsEditorSelectionStart === -1, selectionStartAfterEditorSelectionEnd = selectionStartVsEditorSelectionEnd === 1, selectionEndBeforeEditorSelectionStart = selectionEndVsEditorSelectionStart === -1, selectionEndAfterEditorSelectionEnd = selectionEndVsEditorSelectionEnd === 1, editorSelectionStartBeforeSelectionStart = editorSelectionStartVsSelectionStart === -1, editorSelectionStartAfterSelectionStart = editorSelectionStartVsSelectionStart === 1, editorSelectionEndBeforeSelectionEnd = editorSelectionEndVsSelectionEnd === -1, editorSelectionEndAfterSelectionEnd = editorSelectionEndVsSelectionEnd === 1, selectionStartEqualEditorSelectionEnd = isEqualSelectionPoints(selectionStart, editorSelectionEnd), selectionEndEqualEditorSelectionStart = isEqualSelectionPoints(selectionEnd, editorSelectionStart);
|
|
225
|
+
return !selectionEndEqualEditorSelectionStart && !selectionStartEqualEditorSelectionEnd && !editorSelectionStartBeforeSelectionStart && !editorSelectionStartAfterSelectionStart && !editorSelectionEndBeforeSelectionEnd && !editorSelectionEndAfterSelectionEnd || selectionEndBeforeEditorSelectionStart && !selectionEndEqualEditorSelectionStart || selectionStartAfterEditorSelectionEnd && !selectionStartEqualEditorSelectionEnd ? !1 : !editorSelectionStartBeforeSelectionStart && editorSelectionStartAfterSelectionStart && !editorSelectionEndBeforeSelectionEnd && editorSelectionEndAfterSelectionEnd ? !selectionEndEqualEditorSelectionStart : editorSelectionStartBeforeSelectionStart && !editorSelectionStartAfterSelectionStart && editorSelectionEndBeforeSelectionEnd && !editorSelectionEndAfterSelectionEnd ? !selectionStartEqualEditorSelectionEnd : !selectionStartAfterEditorSelectionEnd || !selectionStartBeforeEditorSelectionStart || !selectionEndAfterEditorSelectionEnd || !selectionEndBeforeEditorSelectionStart;
|
|
226
|
+
}
|
|
227
|
+
const isSelectionExpanded$1 = (snapshot) => snapshot.context.selection !== null && !isSelectionCollapsed(snapshot), isSelectingEntireBlocks = (snapshot) => {
|
|
230
228
|
if (!snapshot.context.selection)
|
|
231
229
|
return !1;
|
|
232
230
|
const startPoint = snapshot.context.selection.backward ? snapshot.context.selection.focus : snapshot.context.selection.anchor, endPoint = snapshot.context.selection.backward ? snapshot.context.selection.anchor : snapshot.context.selection.focus, startBlock = getSelectionStartBlock(snapshot), endBlock = getSelectionEndBlock(snapshot);
|
|
@@ -311,99 +309,9 @@ const getNextSpan = (snapshot) => {
|
|
|
311
309
|
});
|
|
312
310
|
}
|
|
313
311
|
return previousSpan;
|
|
314
|
-
}, getSelectedSpans = (snapshot) => {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
const selectedSpans = [], startPoint = getSelectionStartPoint(snapshot), endPoint = getSelectionEndPoint(snapshot);
|
|
318
|
-
if (!startPoint || !endPoint)
|
|
319
|
-
return selectedSpans;
|
|
320
|
-
const startBlockKey = getBlockKeyFromSelectionPoint(startPoint), endBlockKey = getBlockKeyFromSelectionPoint(endPoint), startSpanKey = getChildKeyFromSelectionPoint(startPoint), endSpanKey = getChildKeyFromSelectionPoint(endPoint);
|
|
321
|
-
if (!startBlockKey || !endBlockKey)
|
|
322
|
-
return selectedSpans;
|
|
323
|
-
const startBlockIndex = snapshot.blockIndexMap.get(startBlockKey), endBlockIndex = snapshot.blockIndexMap.get(endBlockKey);
|
|
324
|
-
if (startBlockIndex === void 0 || endBlockIndex === void 0)
|
|
325
|
-
return selectedSpans;
|
|
326
|
-
const slicedValue = snapshot.context.value.slice(startBlockIndex, endBlockIndex + 1);
|
|
327
|
-
let startBlockFound = !1;
|
|
328
|
-
for (const block of slicedValue)
|
|
329
|
-
if (block._key === startBlockKey && (startBlockFound = !0), !!isTextBlock(snapshot.context, block)) {
|
|
330
|
-
if (block._key === startBlockKey) {
|
|
331
|
-
for (const child of block.children)
|
|
332
|
-
if (isSpan(snapshot.context, child)) {
|
|
333
|
-
if (startSpanKey && child._key === startSpanKey) {
|
|
334
|
-
if (startPoint.offset < child.text.length && selectedSpans.push({
|
|
335
|
-
node: child,
|
|
336
|
-
path: [{
|
|
337
|
-
_key: block._key
|
|
338
|
-
}, "children", {
|
|
339
|
-
_key: child._key
|
|
340
|
-
}]
|
|
341
|
-
}), startSpanKey === endSpanKey)
|
|
342
|
-
break;
|
|
343
|
-
continue;
|
|
344
|
-
}
|
|
345
|
-
if (endSpanKey && child._key === endSpanKey) {
|
|
346
|
-
endPoint.offset > 0 && selectedSpans.push({
|
|
347
|
-
node: child,
|
|
348
|
-
path: [{
|
|
349
|
-
_key: block._key
|
|
350
|
-
}, "children", {
|
|
351
|
-
_key: child._key
|
|
352
|
-
}]
|
|
353
|
-
});
|
|
354
|
-
break;
|
|
355
|
-
}
|
|
356
|
-
selectedSpans.length > 0 && selectedSpans.push({
|
|
357
|
-
node: child,
|
|
358
|
-
path: [{
|
|
359
|
-
_key: block._key
|
|
360
|
-
}, "children", {
|
|
361
|
-
_key: child._key
|
|
362
|
-
}]
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
if (startBlockKey === endBlockKey)
|
|
366
|
-
break;
|
|
367
|
-
continue;
|
|
368
|
-
}
|
|
369
|
-
if (block._key === endBlockKey) {
|
|
370
|
-
for (const child of block.children)
|
|
371
|
-
if (isSpan(snapshot.context, child)) {
|
|
372
|
-
if (endSpanKey && child._key === endSpanKey) {
|
|
373
|
-
endPoint.offset > 0 && selectedSpans.push({
|
|
374
|
-
node: child,
|
|
375
|
-
path: [{
|
|
376
|
-
_key: block._key
|
|
377
|
-
}, "children", {
|
|
378
|
-
_key: child._key
|
|
379
|
-
}]
|
|
380
|
-
});
|
|
381
|
-
break;
|
|
382
|
-
}
|
|
383
|
-
selectedSpans.push({
|
|
384
|
-
node: child,
|
|
385
|
-
path: [{
|
|
386
|
-
_key: block._key
|
|
387
|
-
}, "children", {
|
|
388
|
-
_key: child._key
|
|
389
|
-
}]
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
break;
|
|
393
|
-
}
|
|
394
|
-
if (startBlockFound)
|
|
395
|
-
for (const child of block.children)
|
|
396
|
-
isSpan(snapshot.context, child) && selectedSpans.push({
|
|
397
|
-
node: child,
|
|
398
|
-
path: [{
|
|
399
|
-
_key: block._key
|
|
400
|
-
}, "children", {
|
|
401
|
-
_key: child._key
|
|
402
|
-
}]
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
return selectedSpans;
|
|
406
|
-
}, getMarkState = (snapshot) => {
|
|
312
|
+
}, getSelectedSpans = (snapshot) => snapshot.context.selection ? getSelectedChildren({
|
|
313
|
+
filter: (child) => isSpan(snapshot.context, child)
|
|
314
|
+
})(snapshot) : [], getMarkState = (snapshot) => {
|
|
407
315
|
if (!snapshot.context.selection)
|
|
408
316
|
return;
|
|
409
317
|
let selection = snapshot.context.selection;
|
|
@@ -844,6 +752,7 @@ function isAtTheStartOfBlock(block) {
|
|
|
844
752
|
};
|
|
845
753
|
}
|
|
846
754
|
export {
|
|
755
|
+
comparePoints,
|
|
847
756
|
getActiveAnnotations,
|
|
848
757
|
getActiveAnnotationsMarks,
|
|
849
758
|
getActiveDecorators,
|
|
@@ -866,6 +775,7 @@ export {
|
|
|
866
775
|
getPreviousInlineObject,
|
|
867
776
|
getPreviousSpan,
|
|
868
777
|
getSelectedBlocks,
|
|
778
|
+
getSelectedChildren,
|
|
869
779
|
getSelectedSpans,
|
|
870
780
|
getSelectedTextBlocks,
|
|
871
781
|
getSelectedValue,
|
|
@@ -883,8 +793,6 @@ export {
|
|
|
883
793
|
isAtTheEndOfBlock,
|
|
884
794
|
isAtTheStartOfBlock,
|
|
885
795
|
isOverlappingSelection,
|
|
886
|
-
isPointAfterSelection,
|
|
887
|
-
isPointBeforeSelection,
|
|
888
796
|
isSelectingEntireBlocks,
|
|
889
797
|
isSelectionCollapsed,
|
|
890
798
|
isSelectionExpanded$1 as isSelectionExpanded
|