@portabletext/editor 2.13.3 → 2.13.5
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-cjs/{selector.is-selection-expanded.cjs → selector.get-selection-text.cjs} +25 -25
- package/lib/_chunks-cjs/selector.get-selection-text.cjs.map +1 -0
- package/lib/_chunks-cjs/selector.get-text-before.cjs +4 -4
- package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
- package/lib/_chunks-cjs/{selector.is-selecting-entire-blocks.cjs → selector.is-active-style.cjs} +408 -399
- package/lib/_chunks-cjs/selector.is-active-style.cjs.map +1 -0
- package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs +3 -3
- package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs.map +1 -1
- package/lib/_chunks-cjs/{util.slice-blocks.cjs → util.get-text-block-text.cjs} +25 -26
- package/lib/_chunks-cjs/util.get-text-block-text.cjs.map +1 -0
- package/lib/_chunks-cjs/{util.is-selection-collapsed.cjs → util.is-empty-text-block.cjs} +9 -9
- package/lib/_chunks-cjs/util.is-empty-text-block.cjs.map +1 -0
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs +2 -2
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.slice-text-block.cjs +5 -5
- package/lib/_chunks-cjs/util.slice-text-block.cjs.map +1 -1
- package/lib/_chunks-dts/behavior.types.action.d.cts +271 -271
- package/lib/_chunks-dts/behavior.types.action.d.ts +322 -322
- package/lib/_chunks-es/{selector.is-selection-expanded.js → selector.get-selection-text.js} +20 -20
- package/lib/_chunks-es/selector.get-selection-text.js.map +1 -0
- package/lib/_chunks-es/selector.get-text-before.js +2 -2
- package/lib/_chunks-es/selector.get-text-before.js.map +1 -1
- package/lib/_chunks-es/{selector.is-selecting-entire-blocks.js → selector.is-active-style.js} +385 -376
- package/lib/_chunks-es/selector.is-active-style.js.map +1 -0
- package/lib/_chunks-es/util.child-selection-point-to-block-offset.js +1 -1
- package/lib/_chunks-es/util.child-selection-point-to-block-offset.js.map +1 -1
- package/lib/_chunks-es/{util.slice-blocks.js → util.get-text-block-text.js} +25 -26
- package/lib/_chunks-es/util.get-text-block-text.js.map +1 -0
- package/lib/_chunks-es/{util.is-selection-collapsed.js → util.is-empty-text-block.js} +8 -8
- package/lib/_chunks-es/util.is-empty-text-block.js.map +1 -0
- package/lib/_chunks-es/util.merge-text-blocks.js +1 -1
- package/lib/_chunks-es/util.merge-text-blocks.js.map +1 -1
- package/lib/_chunks-es/util.slice-text-block.js +1 -1
- package/lib/_chunks-es/util.slice-text-block.js.map +1 -1
- package/lib/index.cjs +225 -225
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +18 -18
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +21 -21
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +4 -4
- package/lib/plugins/index.d.ts +4 -4
- package/lib/plugins/index.js +3 -3
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.cjs +52 -52
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.js +5 -5
- package/lib/selectors/index.js.map +1 -1
- package/lib/utils/index.cjs +14 -14
- package/lib/utils/index.cjs.map +1 -1
- package/lib/utils/index.d.ts +2 -2
- package/lib/utils/index.js +3 -3
- package/lib/utils/index.js.map +1 -1
- package/package.json +14 -14
- package/src/behaviors/behavior.abstract.annotation.ts +3 -3
- package/src/behaviors/behavior.abstract.decorator.ts +2 -2
- package/src/behaviors/behavior.abstract.delete.ts +25 -16
- package/src/behaviors/behavior.abstract.deserialize.ts +4 -3
- package/src/behaviors/behavior.abstract.insert.ts +6 -7
- package/src/behaviors/behavior.abstract.keyboard.ts +7 -8
- package/src/behaviors/behavior.abstract.list-item.ts +2 -1
- package/src/behaviors/behavior.abstract.move.ts +2 -1
- package/src/behaviors/behavior.abstract.select.ts +4 -2
- package/src/behaviors/behavior.abstract.split.ts +33 -24
- package/src/behaviors/behavior.abstract.style.ts +2 -1
- package/src/behaviors/behavior.abstract.ts +8 -7
- package/src/behaviors/behavior.core.annotations.ts +8 -7
- package/src/behaviors/behavior.core.block-element.ts +7 -5
- package/src/behaviors/behavior.core.block-objects.ts +25 -27
- package/src/behaviors/behavior.core.dnd.ts +10 -8
- package/src/behaviors/behavior.core.insert-break.ts +45 -36
- package/src/behaviors/behavior.core.lists.ts +31 -25
- package/src/behaviors/behavior.decorator-pair.ts +26 -23
- package/src/behaviors/behavior.markdown.ts +26 -21
- package/src/converters/converter.portable-text.ts +3 -3
- package/src/converters/converter.text-html.serialize.test.ts +1 -1
- package/src/converters/converter.text-html.ts +3 -3
- package/src/converters/converter.text-plain.test.ts +1 -1
- package/src/converters/converter.text-plain.ts +3 -3
- package/src/editor/Editable.tsx +2 -2
- package/src/editor/components/render-span.tsx +3 -5
- package/src/editor/create-editor.ts +2 -2
- package/src/editor/create-slate-editor.tsx +1 -4
- package/src/editor/editor-dom.ts +2 -2
- package/src/editor/plugins/createWithEditableAPI.ts +5 -10
- package/src/editor/plugins/createWithMaxBlocks.ts +2 -2
- package/src/editor/plugins/createWithObjectKeys.ts +2 -2
- package/src/editor/plugins/createWithPatches.ts +3 -10
- package/src/editor/plugins/createWithPlaceholderBlock.ts +2 -2
- package/src/editor/plugins/createWithPortableTextMarkModel.ts +2 -2
- package/src/editor/plugins/createWithSchemaTypes.ts +1 -1
- package/src/editor/plugins/createWithUndoRedo.ts +6 -6
- package/src/editor/plugins/slate-plugin.update-selection.ts +1 -1
- package/src/editor/sync-machine.ts +2 -5
- package/src/{internal-utils → editor}/weakMaps.ts +1 -1
- package/src/editor/with-undo-step.ts +1 -1
- package/src/index.ts +1 -1
- package/src/internal-utils/applyPatch.ts +2 -2
- package/src/internal-utils/build-index-maps.test.ts +1 -1
- package/src/internal-utils/create-test-snapshot.ts +1 -1
- package/src/internal-utils/event-position.ts +11 -9
- package/src/internal-utils/operation-to-patches.test.ts +1 -1
- package/src/internal-utils/portable-text-node.ts +1 -1
- package/src/internal-utils/selection-block-keys.ts +1 -1
- package/src/internal-utils/selection-focus-text.ts +1 -1
- package/src/internal-utils/to-slate-range.ts +4 -4
- package/src/operations/behavior.operation.annotation.add.ts +1 -1
- package/src/operations/behavior.operation.block.set.ts +1 -1
- package/src/operations/behavior.operation.block.unset.ts +2 -2
- package/src/operations/behavior.operation.decorator.add.ts +11 -9
- package/src/operations/behavior.operation.delete.ts +1 -1
- package/src/operations/behavior.operation.insert.block.ts +2 -2
- package/src/operations/behavior.operation.insert.child.ts +1 -1
- package/src/operations/behavior.operation.move.block.ts +1 -1
- package/src/plugins/plugin.behavior.tsx +1 -1
- package/src/plugins/plugin.decorator-shortcut.ts +3 -3
- package/src/plugins/plugin.internal.auto-close-brackets.ts +2 -1
- package/src/plugins/plugin.one-line.tsx +11 -11
- package/src/priority/priority.types.ts +1 -1
- package/src/{internal-utils → selectors}/drag-selection.test.ts +1 -1
- package/src/{internal-utils → selectors}/drag-selection.ts +26 -19
- package/src/selectors/selector.get-anchor-block.ts +1 -1
- package/src/selectors/selector.get-anchor-child.ts +1 -1
- package/src/selectors/selector.get-block-offsets.ts +3 -3
- package/src/selectors/selector.get-caret-word-selection.test.ts +1 -1
- package/src/selectors/selector.get-focus-block.ts +1 -1
- package/src/selectors/selector.get-focus-child.ts +1 -1
- package/src/selectors/selector.get-focus-list-block.ts +1 -1
- package/src/selectors/selector.get-list-state.test.ts +1 -1
- package/src/selectors/selector.get-mark-state.ts +1 -1
- package/src/selectors/selector.get-next-inline-object.ts +1 -1
- package/src/selectors/selector.get-next-span.ts +1 -1
- package/src/selectors/selector.get-previous-inline-object.ts +1 -1
- package/src/selectors/selector.get-previous-span.ts +1 -1
- package/src/selectors/selector.get-selected-blocks.ts +1 -1
- package/src/selectors/selector.get-selected-spans.test.ts +1 -1
- package/src/selectors/selector.get-selected-spans.ts +2 -2
- package/src/selectors/selector.get-selected-text-blocks.ts +3 -2
- package/src/selectors/selector.get-selected-value.test.ts +87 -1
- package/src/selectors/selector.get-selected-value.ts +4 -6
- package/src/selectors/selector.get-selection-end-point.ts +1 -1
- package/src/selectors/selector.get-selection-start-point.ts +1 -1
- package/src/selectors/selector.get-selection-text.test.ts +1 -1
- package/src/selectors/selector.get-selection.ts +1 -1
- package/src/selectors/selector.get-text-before.ts +1 -1
- package/src/selectors/selector.get-trimmed-selection.test.ts +1 -1
- package/src/selectors/selector.get-trimmed-selection.ts +5 -7
- package/src/selectors/selector.is-active-decorator.test.ts +2 -1
- package/src/selectors/selector.is-at-the-end-of-block.ts +4 -3
- package/src/selectors/selector.is-at-the-start-of-block.ts +4 -3
- package/src/selectors/selector.is-overlapping-selection.test.ts +1 -1
- package/src/selectors/selector.is-overlapping-selection.ts +1 -1
- package/src/selectors/selector.is-point-after-selection.ts +3 -3
- package/src/selectors/selector.is-point-before-selection.ts +3 -3
- package/src/selectors/selector.is-selecting-entire-blocks.ts +7 -5
- package/src/test/gherkin-parameter-types.ts +3 -3
- package/src/test/vitest/step-definitions.tsx +19 -9
- package/src/types/paths.ts +4 -1
- package/src/utils/util.at-the-beginning-of-block.ts +1 -1
- package/src/utils/util.block-offset.ts +4 -4
- package/src/utils/util.block-offsets-to-selection.ts +1 -1
- package/src/utils/util.child-selection-point-to-block-offset.ts +3 -3
- package/src/utils/util.get-selection-end-point.ts +1 -1
- package/src/utils/util.get-selection-start-point.ts +1 -1
- package/src/utils/util.merge-text-blocks.ts +2 -2
- package/src/utils/util.selection-point-to-block-offset.ts +1 -1
- package/src/{selection/selection-point.ts → utils/util.selection-point.ts} +1 -1
- package/src/utils/util.slice-blocks.ts +6 -6
- package/src/utils/util.slice-text-block.test.ts +3 -1
- package/src/utils/util.slice-text-block.ts +3 -3
- package/src/utils/util.split-text-block.ts +1 -1
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +0 -1
- package/lib/_chunks-cjs/selector.is-selection-expanded.cjs.map +0 -1
- package/lib/_chunks-cjs/util.is-selection-collapsed.cjs.map +0 -1
- package/lib/_chunks-cjs/util.slice-blocks.cjs.map +0 -1
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +0 -1
- package/lib/_chunks-es/selector.is-selection-expanded.js.map +0 -1
- package/lib/_chunks-es/util.is-selection-collapsed.js.map +0 -1
- package/lib/_chunks-es/util.slice-blocks.js.map +0 -1
- /package/src/{internal-utils → editor}/withChanges.ts +0 -0
- /package/src/{internal-utils → editor}/withUndoRedo.ts +0 -0
- /package/src/{internal-utils → editor}/withoutPatching.ts +0 -0
- /package/src/{internal-utils → utils}/asserters.ts +0 -0
- /package/src/{editor → utils}/key-generator.ts +0 -0
- /package/src/{internal-utils → utils}/parse-blocks.test.ts +0 -0
- /package/src/{internal-utils → utils}/parse-blocks.ts +0 -0
package/lib/_chunks-cjs/{selector.is-selecting-entire-blocks.cjs → selector.is-active-style.cjs}
RENAMED
|
@@ -1,16 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
return
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
var types = require("@sanity/types"), selector_getSelectionText = require("./selector.get-selection-text.cjs"), util_isEmptyTextBlock = require("./util.is-empty-text-block.cjs"), schema = require("@portabletext/schema"), util_getTextBlockText = require("./util.get-text-block-text.cjs");
|
|
3
|
+
const getFocusInlineObject = (snapshot) => {
|
|
4
|
+
const focusChild = selector_getSelectionText.getFocusChild(snapshot);
|
|
5
|
+
return focusChild && !types.isPortableTextSpan(focusChild.node) ? {
|
|
6
|
+
node: focusChild.node,
|
|
7
|
+
path: focusChild.path
|
|
8
|
+
} : void 0;
|
|
9
|
+
}, getSelectedBlocks = (snapshot) => {
|
|
10
|
+
if (!snapshot.context.selection)
|
|
11
|
+
return [];
|
|
12
|
+
const selectedBlocks = [], startPoint = util_getTextBlockText.getSelectionStartPoint(snapshot.context.selection), endPoint = util_getTextBlockText.getSelectionEndPoint(snapshot.context.selection), startKey = util_getTextBlockText.getBlockKeyFromSelectionPoint(startPoint), endKey = util_getTextBlockText.getBlockKeyFromSelectionPoint(endPoint);
|
|
13
|
+
if (!startKey || !endKey)
|
|
14
|
+
return selectedBlocks;
|
|
15
|
+
const startBlockIndex = snapshot.blockIndexMap.get(startKey), endBlockIndex = snapshot.blockIndexMap.get(endKey);
|
|
16
|
+
if (startBlockIndex === void 0 || endBlockIndex === void 0)
|
|
17
|
+
return selectedBlocks;
|
|
18
|
+
const slicedValue = snapshot.context.value.slice(startBlockIndex, endBlockIndex + 1);
|
|
19
|
+
for (const block of slicedValue) {
|
|
20
|
+
if (block._key === startKey) {
|
|
21
|
+
if (selectedBlocks.push({
|
|
22
|
+
node: block,
|
|
23
|
+
path: [{
|
|
24
|
+
_key: block._key
|
|
25
|
+
}]
|
|
26
|
+
}), startKey === endKey)
|
|
27
|
+
break;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (block._key === endKey) {
|
|
31
|
+
selectedBlocks.push({
|
|
32
|
+
node: block,
|
|
33
|
+
path: [{
|
|
34
|
+
_key: block._key
|
|
35
|
+
}]
|
|
36
|
+
});
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
selectedBlocks.length > 0 && selectedBlocks.push({
|
|
40
|
+
node: block,
|
|
41
|
+
path: [{
|
|
42
|
+
_key: block._key
|
|
43
|
+
}]
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return selectedBlocks;
|
|
47
|
+
}, getSelectionEndBlock = (snapshot) => {
|
|
48
|
+
const endPoint = util_getTextBlockText.getSelectionEndPoint(snapshot.context.selection);
|
|
12
49
|
if (endPoint)
|
|
13
|
-
return
|
|
50
|
+
return selector_getSelectionText.getFocusBlock({
|
|
14
51
|
...snapshot,
|
|
15
52
|
context: {
|
|
16
53
|
...snapshot.context,
|
|
@@ -20,14 +57,167 @@ const getSelectionEndBlock = (snapshot) => {
|
|
|
20
57
|
}
|
|
21
58
|
}
|
|
22
59
|
});
|
|
60
|
+
}, getSelectionStartBlock = (snapshot) => {
|
|
61
|
+
const startPoint = util_getTextBlockText.getSelectionStartPoint(snapshot.context.selection);
|
|
62
|
+
if (startPoint)
|
|
63
|
+
return selector_getSelectionText.getFocusBlock({
|
|
64
|
+
...snapshot,
|
|
65
|
+
context: {
|
|
66
|
+
...snapshot.context,
|
|
67
|
+
selection: {
|
|
68
|
+
anchor: startPoint,
|
|
69
|
+
focus: startPoint
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
23
73
|
}, getSelectionEndPoint = (snapshot) => {
|
|
24
74
|
if (snapshot.context.selection)
|
|
25
75
|
return snapshot.context.selection.backward ? snapshot.context.selection.anchor : snapshot.context.selection.focus;
|
|
26
|
-
}
|
|
76
|
+
};
|
|
77
|
+
function isPointAfterSelection(point) {
|
|
78
|
+
return (snapshot) => {
|
|
79
|
+
if (!snapshot.context.selection)
|
|
80
|
+
return !1;
|
|
81
|
+
const endPoint = util_getTextBlockText.getSelectionEndPoint(snapshot.context.selection), endBlockKey = util_getTextBlockText.getBlockKeyFromSelectionPoint(endPoint), endChildKey = util_getTextBlockText.getChildKeyFromSelectionPoint(endPoint), pointBlockKey = util_getTextBlockText.getBlockKeyFromSelectionPoint(point), pointChildKey = util_getTextBlockText.getChildKeyFromSelectionPoint(point);
|
|
82
|
+
if (!pointBlockKey || !endBlockKey)
|
|
83
|
+
return !1;
|
|
84
|
+
const pointBlockIndex = snapshot.blockIndexMap.get(pointBlockKey), endBlockIndex = snapshot.blockIndexMap.get(endBlockKey);
|
|
85
|
+
if (pointBlockIndex === void 0 || endBlockIndex === void 0)
|
|
86
|
+
return !1;
|
|
87
|
+
if (pointBlockIndex > endBlockIndex)
|
|
88
|
+
return !0;
|
|
89
|
+
if (pointBlockIndex < endBlockIndex)
|
|
90
|
+
return !1;
|
|
91
|
+
const pointBlock = snapshot.context.value.at(pointBlockIndex);
|
|
92
|
+
if (!pointBlock || !schema.isTextBlock(snapshot.context, pointBlock))
|
|
93
|
+
return !1;
|
|
94
|
+
let pointChildIndex, endChildIndex, childIndex = -1;
|
|
95
|
+
for (const child of pointBlock.children) {
|
|
96
|
+
if (childIndex++, child._key === pointChildKey && child._key === endChildKey)
|
|
97
|
+
return point.offset > endPoint.offset;
|
|
98
|
+
if (child._key === pointChildKey && (pointChildIndex = childIndex), child._key === endChildKey && (endChildIndex = childIndex), pointChildIndex !== void 0 && endChildIndex !== void 0)
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
return pointChildIndex === void 0 || endChildIndex === void 0 ? !1 : pointChildIndex > endChildIndex;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function isPointBeforeSelection(point) {
|
|
105
|
+
return (snapshot) => {
|
|
106
|
+
if (!snapshot.context.selection)
|
|
107
|
+
return !1;
|
|
108
|
+
const startPoint = util_getTextBlockText.getSelectionStartPoint(snapshot.context.selection), startBlockKey = util_getTextBlockText.getBlockKeyFromSelectionPoint(startPoint), startChildKey = util_getTextBlockText.getChildKeyFromSelectionPoint(startPoint), pointBlockKey = util_getTextBlockText.getBlockKeyFromSelectionPoint(point), pointChildKey = util_getTextBlockText.getChildKeyFromSelectionPoint(point);
|
|
109
|
+
if (!pointBlockKey || !startBlockKey)
|
|
110
|
+
return !1;
|
|
111
|
+
const startBlockIndex = snapshot.blockIndexMap.get(startBlockKey), pointBlockIndex = snapshot.blockIndexMap.get(pointBlockKey);
|
|
112
|
+
if (startBlockIndex === void 0 || pointBlockIndex === void 0)
|
|
113
|
+
return !1;
|
|
114
|
+
if (pointBlockIndex < startBlockIndex)
|
|
115
|
+
return !0;
|
|
116
|
+
if (pointBlockIndex > startBlockIndex)
|
|
117
|
+
return !1;
|
|
118
|
+
const pointBlock = snapshot.context.value.at(pointBlockIndex);
|
|
119
|
+
if (!pointBlock || !schema.isTextBlock(snapshot.context, pointBlock))
|
|
120
|
+
return !1;
|
|
121
|
+
let pointChildIndex, startChildIndex, childIndex = -1;
|
|
122
|
+
for (const child of pointBlock.children) {
|
|
123
|
+
if (childIndex++, child._key === pointChildKey && child._key === startChildKey)
|
|
124
|
+
return point.offset < startPoint.offset;
|
|
125
|
+
if (child._key === pointChildKey && (pointChildIndex = childIndex), child._key === startChildKey && (startChildIndex = childIndex), pointChildIndex !== void 0 && startChildIndex !== void 0)
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
return pointChildIndex === void 0 || startChildIndex === void 0 ? !1 : pointChildIndex < startChildIndex;
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function isOverlappingSelection(selection) {
|
|
132
|
+
return (snapshot) => {
|
|
133
|
+
if (!selection || !snapshot.context.selection)
|
|
134
|
+
return !1;
|
|
135
|
+
const selectionStartPoint = selector_getSelectionText.getSelectionStartPoint({
|
|
136
|
+
context: {
|
|
137
|
+
...snapshot.context,
|
|
138
|
+
selection
|
|
139
|
+
}
|
|
140
|
+
}), selectionEndPoint = getSelectionEndPoint({
|
|
141
|
+
context: {
|
|
142
|
+
...snapshot.context,
|
|
143
|
+
selection
|
|
144
|
+
}
|
|
145
|
+
}), originalSelectionStartPoint = selector_getSelectionText.getSelectionStartPoint(snapshot), originalSelectionEndPoint = getSelectionEndPoint(snapshot);
|
|
146
|
+
if (!selectionStartPoint || !selectionEndPoint || !originalSelectionStartPoint || !originalSelectionEndPoint)
|
|
147
|
+
return !1;
|
|
148
|
+
const startPointEqualToOriginalStartPoint = util_isEmptyTextBlock.isEqualSelectionPoints(selectionStartPoint, originalSelectionStartPoint), endPointEqualToOriginalEndPoint = util_isEmptyTextBlock.isEqualSelectionPoints(selectionEndPoint, originalSelectionEndPoint);
|
|
149
|
+
if (startPointEqualToOriginalStartPoint && endPointEqualToOriginalEndPoint)
|
|
150
|
+
return !0;
|
|
151
|
+
const startPointBeforeSelection = isPointBeforeSelection(selectionStartPoint)(snapshot), startPointAfterSelection = isPointAfterSelection(selectionStartPoint)(snapshot), endPointBeforeSelection = isPointBeforeSelection(selectionEndPoint)(snapshot), endPointAfterSelection = isPointAfterSelection(selectionEndPoint)(snapshot), originalStartPointBeforeStartPoint = isPointBeforeSelection(originalSelectionStartPoint)({
|
|
152
|
+
...snapshot,
|
|
153
|
+
context: {
|
|
154
|
+
...snapshot.context,
|
|
155
|
+
selection: {
|
|
156
|
+
anchor: selectionStartPoint,
|
|
157
|
+
focus: selectionStartPoint
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}), originalStartPointAfterStartPoint = isPointAfterSelection(originalSelectionStartPoint)({
|
|
161
|
+
...snapshot,
|
|
162
|
+
context: {
|
|
163
|
+
...snapshot.context,
|
|
164
|
+
selection: {
|
|
165
|
+
anchor: selectionStartPoint,
|
|
166
|
+
focus: selectionStartPoint
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}), originalEndPointBeforeEndPoint = isPointBeforeSelection(originalSelectionEndPoint)({
|
|
170
|
+
...snapshot,
|
|
171
|
+
context: {
|
|
172
|
+
...snapshot.context,
|
|
173
|
+
selection: {
|
|
174
|
+
anchor: selectionEndPoint,
|
|
175
|
+
focus: selectionEndPoint
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}), originalEndPointAfterEndPoint = isPointAfterSelection(originalSelectionEndPoint)({
|
|
179
|
+
...snapshot,
|
|
180
|
+
context: {
|
|
181
|
+
...snapshot.context,
|
|
182
|
+
selection: {
|
|
183
|
+
anchor: selectionEndPoint,
|
|
184
|
+
focus: selectionEndPoint
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}), startPointEqualToOriginalEndPoint = util_isEmptyTextBlock.isEqualSelectionPoints(selectionStartPoint, originalSelectionEndPoint), endPointEqualToOriginalStartPoint = util_isEmptyTextBlock.isEqualSelectionPoints(selectionEndPoint, originalSelectionStartPoint);
|
|
188
|
+
return !endPointEqualToOriginalStartPoint && !startPointEqualToOriginalEndPoint && !originalStartPointBeforeStartPoint && !originalStartPointAfterStartPoint && !originalEndPointBeforeEndPoint && !originalEndPointAfterEndPoint || endPointBeforeSelection && !endPointEqualToOriginalStartPoint || startPointAfterSelection && !startPointEqualToOriginalEndPoint ? !1 : !originalStartPointBeforeStartPoint && originalStartPointAfterStartPoint && !originalEndPointBeforeEndPoint && originalEndPointAfterEndPoint ? !endPointEqualToOriginalStartPoint : originalStartPointBeforeStartPoint && !originalStartPointAfterStartPoint && originalEndPointBeforeEndPoint && !originalEndPointAfterEndPoint ? !startPointEqualToOriginalEndPoint : !startPointAfterSelection || !startPointBeforeSelection || !endPointAfterSelection || !endPointBeforeSelection;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
const isSelectingEntireBlocks = (snapshot) => {
|
|
192
|
+
if (!snapshot.context.selection)
|
|
193
|
+
return !1;
|
|
194
|
+
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);
|
|
195
|
+
if (!startBlock || !endBlock)
|
|
196
|
+
return !1;
|
|
197
|
+
const startBlockStartPoint = util_getTextBlockText.getBlockStartPoint({
|
|
198
|
+
context: snapshot.context,
|
|
199
|
+
block: startBlock
|
|
200
|
+
}), endBlockEndPoint = util_isEmptyTextBlock.getBlockEndPoint({
|
|
201
|
+
context: snapshot.context,
|
|
202
|
+
block: endBlock
|
|
203
|
+
});
|
|
204
|
+
return util_isEmptyTextBlock.isEqualSelectionPoints(startBlockStartPoint, startPoint) && util_isEmptyTextBlock.isEqualSelectionPoints(endBlockEndPoint, endPoint);
|
|
205
|
+
};
|
|
206
|
+
function isBlockPath(path) {
|
|
207
|
+
const firstSegment = path.at(0);
|
|
208
|
+
return path.length === 1 && firstSegment !== void 0 && isRecord(firstSegment) && "_key" in firstSegment && typeof firstSegment._key == "string";
|
|
209
|
+
}
|
|
210
|
+
function isRecord(value) {
|
|
211
|
+
return !!value && (typeof value == "object" || typeof value == "function");
|
|
212
|
+
}
|
|
213
|
+
function isSelectionExpanded(selection) {
|
|
214
|
+
return selection ? !util_isEmptyTextBlock.isSelectionCollapsed(selection) : !1;
|
|
215
|
+
}
|
|
216
|
+
const getNextSpan = (snapshot) => {
|
|
27
217
|
const selectionEndBlock = getSelectionEndBlock(snapshot), selectionEndPoint = getSelectionEndPoint(snapshot);
|
|
28
218
|
if (!selectionEndBlock || !selectionEndPoint || !schema.isTextBlock(snapshot.context, selectionEndBlock.node))
|
|
29
219
|
return;
|
|
30
|
-
const selectionEndPointChildKey =
|
|
220
|
+
const selectionEndPointChildKey = util_getTextBlockText.getChildKeyFromSelectionPoint(selectionEndPoint);
|
|
31
221
|
let endPointChildFound = !1, nextSpan;
|
|
32
222
|
for (const child of selectionEndBlock.node.children) {
|
|
33
223
|
if (child._key === selectionEndPointChildKey) {
|
|
@@ -45,24 +235,11 @@ const getSelectionEndBlock = (snapshot) => {
|
|
|
45
235
|
}
|
|
46
236
|
}
|
|
47
237
|
return nextSpan;
|
|
48
|
-
}, getSelectionStartBlock = (snapshot) => {
|
|
49
|
-
const startPoint = util_sliceBlocks.getSelectionStartPoint(snapshot.context.selection);
|
|
50
|
-
if (startPoint)
|
|
51
|
-
return selector_isSelectionExpanded.getFocusBlock({
|
|
52
|
-
...snapshot,
|
|
53
|
-
context: {
|
|
54
|
-
...snapshot.context,
|
|
55
|
-
selection: {
|
|
56
|
-
anchor: startPoint,
|
|
57
|
-
focus: startPoint
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
238
|
}, getPreviousSpan = (snapshot) => {
|
|
62
|
-
const selectionStartBlock = getSelectionStartBlock(snapshot), selectionStartPoint =
|
|
239
|
+
const selectionStartBlock = getSelectionStartBlock(snapshot), selectionStartPoint = selector_getSelectionText.getSelectionStartPoint(snapshot);
|
|
63
240
|
if (!selectionStartBlock || !selectionStartPoint || !schema.isTextBlock(snapshot.context, selectionStartBlock.node))
|
|
64
241
|
return;
|
|
65
|
-
const selectionStartPointChildKey =
|
|
242
|
+
const selectionStartPointChildKey = util_getTextBlockText.getChildKeyFromSelectionPoint(selectionStartPoint);
|
|
66
243
|
let previousSpan;
|
|
67
244
|
for (const child of selectionStartBlock.node.children) {
|
|
68
245
|
if (child._key === selectionStartPointChildKey)
|
|
@@ -78,10 +255,10 @@ const getSelectionEndBlock = (snapshot) => {
|
|
|
78
255
|
}, getSelectedSpans = (snapshot) => {
|
|
79
256
|
if (!snapshot.context.selection)
|
|
80
257
|
return [];
|
|
81
|
-
const selectedSpans = [], startPoint =
|
|
258
|
+
const selectedSpans = [], startPoint = selector_getSelectionText.getSelectionStartPoint(snapshot), endPoint = getSelectionEndPoint(snapshot);
|
|
82
259
|
if (!startPoint || !endPoint)
|
|
83
260
|
return selectedSpans;
|
|
84
|
-
const startBlockKey =
|
|
261
|
+
const startBlockKey = util_getTextBlockText.getBlockKeyFromSelectionPoint(startPoint), endBlockKey = util_getTextBlockText.getBlockKeyFromSelectionPoint(endPoint), startSpanKey = util_getTextBlockText.getChildKeyFromSelectionPoint(startPoint), endSpanKey = util_getTextBlockText.getChildKeyFromSelectionPoint(endPoint);
|
|
85
262
|
if (!startBlockKey || !endBlockKey)
|
|
86
263
|
return selectedSpans;
|
|
87
264
|
const startBlockIndex = snapshot.blockIndexMap.get(startBlockKey), endBlockIndex = snapshot.blockIndexMap.get(endBlockKey);
|
|
@@ -171,10 +348,10 @@ const getSelectionEndBlock = (snapshot) => {
|
|
|
171
348
|
if (!snapshot.context.selection)
|
|
172
349
|
return;
|
|
173
350
|
let selection = snapshot.context.selection;
|
|
174
|
-
if (!
|
|
351
|
+
if (!selector_getSelectionText.getFocusTextBlock(snapshot))
|
|
175
352
|
return;
|
|
176
353
|
if (isBlockPath(selection.anchor.path)) {
|
|
177
|
-
const spanSelectionPoint =
|
|
354
|
+
const spanSelectionPoint = util_getTextBlockText.blockOffsetToSpanSelectionPoint({
|
|
178
355
|
context: snapshot.context,
|
|
179
356
|
blockOffset: {
|
|
180
357
|
path: selection.anchor.path,
|
|
@@ -188,7 +365,7 @@ const getSelectionEndBlock = (snapshot) => {
|
|
|
188
365
|
} : selection;
|
|
189
366
|
}
|
|
190
367
|
if (isBlockPath(selection.focus.path)) {
|
|
191
|
-
const spanSelectionPoint =
|
|
368
|
+
const spanSelectionPoint = util_getTextBlockText.blockOffsetToSpanSelectionPoint({
|
|
192
369
|
context: snapshot.context,
|
|
193
370
|
blockOffset: {
|
|
194
371
|
path: selection.focus.path,
|
|
@@ -201,7 +378,7 @@ const getSelectionEndBlock = (snapshot) => {
|
|
|
201
378
|
focus: spanSelectionPoint
|
|
202
379
|
} : selection;
|
|
203
380
|
}
|
|
204
|
-
const focusSpan =
|
|
381
|
+
const focusSpan = selector_getSelectionText.getFocusSpan({
|
|
205
382
|
...snapshot,
|
|
206
383
|
context: {
|
|
207
384
|
...snapshot.context,
|
|
@@ -303,69 +480,104 @@ const getSelectionEndBlock = (snapshot) => {
|
|
|
303
480
|
state: "unchanged",
|
|
304
481
|
marks
|
|
305
482
|
};
|
|
306
|
-
}
|
|
483
|
+
};
|
|
484
|
+
function getActiveDecorators(snapshot) {
|
|
485
|
+
const schema2 = snapshot.context.schema, decoratorState = snapshot.decoratorState, markState = getMarkState(snapshot), decorators = schema2.decorators.map((decorator) => decorator.name);
|
|
486
|
+
let activeDecorators = (markState?.marks ?? []).filter((mark) => decorators.includes(mark));
|
|
487
|
+
for (const decorator in decoratorState)
|
|
488
|
+
decoratorState[decorator] === !1 ? activeDecorators = activeDecorators.filter((activeDecorator) => activeDecorator !== decorator) : decoratorState[decorator] === !0 && (activeDecorators.includes(decorator) || activeDecorators.push(decorator));
|
|
489
|
+
return activeDecorators;
|
|
490
|
+
}
|
|
491
|
+
const getTrimmedSelection = (snapshot) => {
|
|
307
492
|
if (!snapshot.context.selection)
|
|
308
|
-
return
|
|
309
|
-
const
|
|
310
|
-
if (!
|
|
311
|
-
return
|
|
312
|
-
const startBlockIndex = snapshot.blockIndexMap.get(
|
|
493
|
+
return snapshot.context.selection;
|
|
494
|
+
const startPoint = util_getTextBlockText.getSelectionStartPoint(snapshot.context.selection), endPoint = util_getTextBlockText.getSelectionEndPoint(snapshot.context.selection), startBlockKey = util_getTextBlockText.getBlockKeyFromSelectionPoint(startPoint), startChildKey = util_getTextBlockText.getChildKeyFromSelectionPoint(startPoint), endBlockKey = util_getTextBlockText.getBlockKeyFromSelectionPoint(endPoint), endChildKey = util_getTextBlockText.getChildKeyFromSelectionPoint(endPoint);
|
|
495
|
+
if (!startBlockKey || !endBlockKey)
|
|
496
|
+
return snapshot.context.selection;
|
|
497
|
+
const startBlockIndex = snapshot.blockIndexMap.get(startBlockKey), endBlockIndex = snapshot.blockIndexMap.get(endBlockKey);
|
|
313
498
|
if (startBlockIndex === void 0 || endBlockIndex === void 0)
|
|
314
|
-
return
|
|
499
|
+
return snapshot.context.selection;
|
|
315
500
|
const slicedValue = snapshot.context.value.slice(startBlockIndex, endBlockIndex + 1);
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
path: [{
|
|
321
|
-
_key: block._key
|
|
322
|
-
}]
|
|
323
|
-
}), startKey === endKey)
|
|
501
|
+
let startBlockFound = !1, adjustedStartPoint, trimStartPoint = !1, adjustedEndPoint, trimEndPoint = !1, previousPotentialEndpoint;
|
|
502
|
+
for (const block of slicedValue)
|
|
503
|
+
if (!(block._key === startBlockKey && (startBlockFound = !0, schema.isTextBlock(snapshot.context, block) && util_isEmptyTextBlock.isEmptyTextBlock(snapshot.context, block))) && startBlockFound && schema.isTextBlock(snapshot.context, block)) {
|
|
504
|
+
if (block._key === endBlockKey && util_isEmptyTextBlock.isEmptyTextBlock(snapshot.context, block))
|
|
324
505
|
break;
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
},
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
},
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
506
|
+
for (const child of block.children) {
|
|
507
|
+
if (child._key === endChildKey && (!schema.isSpan(snapshot.context, child) || endPoint.offset === 0)) {
|
|
508
|
+
adjustedEndPoint = previousPotentialEndpoint ? {
|
|
509
|
+
path: [{
|
|
510
|
+
_key: previousPotentialEndpoint.blockKey
|
|
511
|
+
}, "children", {
|
|
512
|
+
_key: previousPotentialEndpoint.span._key
|
|
513
|
+
}],
|
|
514
|
+
offset: previousPotentialEndpoint.span.text.length
|
|
515
|
+
} : void 0, trimEndPoint = !0;
|
|
516
|
+
break;
|
|
517
|
+
}
|
|
518
|
+
if (trimStartPoint) {
|
|
519
|
+
const lonelySpan = schema.isSpan(snapshot.context, child) && block.children.length === 1;
|
|
520
|
+
(schema.isSpan(snapshot.context, child) && child.text.length > 0 || lonelySpan) && (adjustedStartPoint = {
|
|
521
|
+
path: [{
|
|
522
|
+
_key: block._key
|
|
523
|
+
}, "children", {
|
|
524
|
+
_key: child._key
|
|
525
|
+
}],
|
|
526
|
+
offset: 0
|
|
527
|
+
}, previousPotentialEndpoint = {
|
|
528
|
+
blockKey: block._key,
|
|
529
|
+
span: child
|
|
530
|
+
}, trimStartPoint = !1);
|
|
531
|
+
continue;
|
|
532
|
+
}
|
|
533
|
+
if (child._key === startChildKey) {
|
|
534
|
+
if (!schema.isSpan(snapshot.context, child)) {
|
|
535
|
+
trimStartPoint = !0;
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
if (startPoint.offset === child.text.length) {
|
|
539
|
+
trimStartPoint = !0, previousPotentialEndpoint = child.text.length > 0 ? {
|
|
540
|
+
blockKey: block._key,
|
|
541
|
+
span: child
|
|
542
|
+
} : previousPotentialEndpoint;
|
|
543
|
+
continue;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
previousPotentialEndpoint = schema.isSpan(snapshot.context, child) && child.text.length > 0 ? {
|
|
547
|
+
blockKey: block._key,
|
|
548
|
+
span: child
|
|
549
|
+
} : previousPotentialEndpoint;
|
|
550
|
+
}
|
|
551
|
+
if (block._key === endBlockKey)
|
|
552
|
+
break;
|
|
553
|
+
}
|
|
554
|
+
const trimmedSelection = snapshot.context.selection.backward ? {
|
|
555
|
+
anchor: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint,
|
|
556
|
+
focus: adjustedStartPoint ?? startPoint,
|
|
557
|
+
backward: !0
|
|
558
|
+
} : {
|
|
559
|
+
anchor: adjustedStartPoint ?? startPoint,
|
|
560
|
+
focus: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint
|
|
561
|
+
};
|
|
562
|
+
if (selector_getSelectionText.isSelectionCollapsed({
|
|
563
|
+
context: {
|
|
564
|
+
...snapshot.context,
|
|
565
|
+
selection: trimmedSelection
|
|
566
|
+
}
|
|
567
|
+
})) {
|
|
568
|
+
const focusTextBlock = selector_getSelectionText.getFocusTextBlock({
|
|
569
|
+
...snapshot,
|
|
570
|
+
context: {
|
|
571
|
+
...snapshot.context,
|
|
572
|
+
selection: trimmedSelection
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
if (focusTextBlock && !util_isEmptyTextBlock.isEmptyTextBlock(snapshot.context, focusTextBlock.node))
|
|
576
|
+
return null;
|
|
577
|
+
}
|
|
578
|
+
return trimmedSelection;
|
|
367
579
|
}, getNextInlineObject = (snapshot) => {
|
|
368
|
-
const focusTextBlock =
|
|
580
|
+
const focusTextBlock = selector_getSelectionText.getFocusTextBlock(snapshot), selectionEndPoint = getSelectionEndPoint(snapshot), selectionEndPointChildKey = selectionEndPoint && types.isKeySegment(selectionEndPoint.path[2]) ? selectionEndPoint.path[2]._key : void 0;
|
|
369
581
|
if (!focusTextBlock || !selectionEndPointChildKey)
|
|
370
582
|
return;
|
|
371
583
|
let endPointChildFound = !1, inlineObject;
|
|
@@ -386,18 +598,18 @@ const getSelectionEndBlock = (snapshot) => {
|
|
|
386
598
|
}
|
|
387
599
|
return inlineObject;
|
|
388
600
|
}, getCaretWordSelection = (snapshot) => {
|
|
389
|
-
if (!snapshot.context.selection || !
|
|
601
|
+
if (!snapshot.context.selection || !selector_getSelectionText.isSelectionCollapsed(snapshot))
|
|
390
602
|
return null;
|
|
391
|
-
const focusTextBlock =
|
|
603
|
+
const focusTextBlock = selector_getSelectionText.getFocusTextBlock(snapshot), selectionStartPoint = selector_getSelectionText.getSelectionStartPoint(snapshot), selectionStartOffset = selectionStartPoint ? util_getTextBlockText.spanSelectionPointToBlockOffset({
|
|
392
604
|
context: snapshot.context,
|
|
393
605
|
selectionPoint: selectionStartPoint
|
|
394
606
|
}) : void 0;
|
|
395
607
|
if (!focusTextBlock || !selectionStartPoint || !selectionStartOffset)
|
|
396
608
|
return null;
|
|
397
|
-
const previousInlineObject =
|
|
609
|
+
const previousInlineObject = selector_getSelectionText.getPreviousInlineObject(snapshot), blockStartPoint = util_getTextBlockText.getBlockStartPoint({
|
|
398
610
|
context: snapshot.context,
|
|
399
611
|
block: focusTextBlock
|
|
400
|
-
}), textDirectlyBefore =
|
|
612
|
+
}), textDirectlyBefore = selector_getSelectionText.getSelectionText({
|
|
401
613
|
...snapshot,
|
|
402
614
|
context: {
|
|
403
615
|
...snapshot.context,
|
|
@@ -409,10 +621,10 @@ const getSelectionEndBlock = (snapshot) => {
|
|
|
409
621
|
focus: selectionStartPoint
|
|
410
622
|
}
|
|
411
623
|
}
|
|
412
|
-
}).split(/\s+/).at(-1), nextInlineObject = getNextInlineObject(snapshot), blockEndPoint =
|
|
624
|
+
}).split(/\s+/).at(-1), nextInlineObject = getNextInlineObject(snapshot), blockEndPoint = util_isEmptyTextBlock.getBlockEndPoint({
|
|
413
625
|
context: snapshot.context,
|
|
414
626
|
block: focusTextBlock
|
|
415
|
-
}), textDirectlyAfter =
|
|
627
|
+
}), textDirectlyAfter = selector_getSelectionText.getSelectionText({
|
|
416
628
|
...snapshot,
|
|
417
629
|
context: {
|
|
418
630
|
...snapshot.context,
|
|
@@ -433,11 +645,11 @@ const getSelectionEndBlock = (snapshot) => {
|
|
|
433
645
|
} : selectionStartOffset, caretWordEndOffset = textDirectlyAfter ? {
|
|
434
646
|
...selectionStartOffset,
|
|
435
647
|
offset: selectionStartOffset.offset + textDirectlyAfter.length
|
|
436
|
-
} : selectionStartOffset, caretWordStartSelectionPoint =
|
|
648
|
+
} : selectionStartOffset, caretWordStartSelectionPoint = util_getTextBlockText.blockOffsetToSpanSelectionPoint({
|
|
437
649
|
context: snapshot.context,
|
|
438
650
|
blockOffset: caretWordStartOffset,
|
|
439
651
|
direction: "backward"
|
|
440
|
-
}), caretWordEndSelectionPoint =
|
|
652
|
+
}), caretWordEndSelectionPoint = util_getTextBlockText.blockOffsetToSpanSelectionPoint({
|
|
441
653
|
context: snapshot.context,
|
|
442
654
|
blockOffset: caretWordEndOffset,
|
|
443
655
|
direction: "forward"
|
|
@@ -448,46 +660,31 @@ const getSelectionEndBlock = (snapshot) => {
|
|
|
448
660
|
anchor: caretWordStartSelectionPoint,
|
|
449
661
|
focus: caretWordEndSelectionPoint
|
|
450
662
|
};
|
|
451
|
-
return
|
|
663
|
+
return selector_getSelectionText.isSelectionExpanded({
|
|
452
664
|
context: {
|
|
453
665
|
...snapshot.context,
|
|
454
666
|
selection: caretWordSelection
|
|
455
667
|
}
|
|
456
668
|
}) ? caretWordSelection : null;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
669
|
+
};
|
|
670
|
+
function getActiveAnnotationsMarks(snapshot) {
|
|
671
|
+
const schema2 = snapshot.context.schema;
|
|
672
|
+
return (getMarkState(snapshot)?.marks ?? []).filter((mark) => !schema2.decorators.map((decorator) => decorator.name).includes(mark));
|
|
673
|
+
}
|
|
674
|
+
function isActiveAnnotation(annotation, options) {
|
|
675
|
+
return (snapshot) => {
|
|
676
|
+
if ((options?.mode ?? "full") === "partial")
|
|
677
|
+
return selector_getSelectionText.getSelectedValue(snapshot).flatMap((block) => schema.isTextBlock(snapshot.context, block) ? block.markDefs ?? [] : []).some((markDef) => markDef._type === annotation);
|
|
678
|
+
const selectionMarkDefs = getSelectedBlocks(snapshot).flatMap((block) => schema.isTextBlock(snapshot.context, block.node) ? block.node.markDefs ?? [] : []), activeAnnotations = getActiveAnnotationsMarks(snapshot);
|
|
679
|
+
return selectionMarkDefs.filter((markDef) => markDef._type === annotation && activeAnnotations.includes(markDef._key)).length > 0;
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
const getFocusBlockObject = (snapshot) => {
|
|
683
|
+
const focusBlock = selector_getSelectionText.getFocusBlock(snapshot);
|
|
467
684
|
return focusBlock && !schema.isTextBlock(snapshot.context, focusBlock.node) ? {
|
|
468
685
|
node: focusBlock.node,
|
|
469
686
|
path: focusBlock.path
|
|
470
687
|
} : void 0;
|
|
471
|
-
}, getFocusInlineObject = (snapshot) => {
|
|
472
|
-
const focusChild = selector_isSelectionExpanded.getFocusChild(snapshot);
|
|
473
|
-
return focusChild && !types.isPortableTextSpan(focusChild.node) ? {
|
|
474
|
-
node: focusChild.node,
|
|
475
|
-
path: focusChild.path
|
|
476
|
-
} : void 0;
|
|
477
|
-
}, getFocusListBlock = (snapshot) => {
|
|
478
|
-
const focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot);
|
|
479
|
-
return focusTextBlock && util_sliceBlocks.isListBlock(snapshot.context, focusTextBlock.node) ? {
|
|
480
|
-
node: focusTextBlock.node,
|
|
481
|
-
path: focusTextBlock.path
|
|
482
|
-
} : void 0;
|
|
483
|
-
}, getLastBlock = (snapshot) => {
|
|
484
|
-
const node = snapshot.context.value[snapshot.context.value.length - 1] ? snapshot.context.value[snapshot.context.value.length - 1] : void 0;
|
|
485
|
-
return node ? {
|
|
486
|
-
node,
|
|
487
|
-
path: [{
|
|
488
|
-
_key: node._key
|
|
489
|
-
}]
|
|
490
|
-
} : void 0;
|
|
491
688
|
}, getNextBlock = (snapshot) => {
|
|
492
689
|
const selectionEndBlock = getSelectionEndBlock(snapshot);
|
|
493
690
|
if (!selectionEndBlock)
|
|
@@ -516,10 +713,70 @@ const getSelectionEndBlock = (snapshot) => {
|
|
|
516
713
|
_key: previousBlock._key
|
|
517
714
|
}]
|
|
518
715
|
} : void 0;
|
|
716
|
+
}, getFirstBlock = (snapshot) => {
|
|
717
|
+
const node = snapshot.context.value[0];
|
|
718
|
+
return node ? {
|
|
719
|
+
node,
|
|
720
|
+
path: [{
|
|
721
|
+
_key: node._key
|
|
722
|
+
}]
|
|
723
|
+
} : void 0;
|
|
724
|
+
}, getLastBlock = (snapshot) => {
|
|
725
|
+
const node = snapshot.context.value[snapshot.context.value.length - 1] ? snapshot.context.value[snapshot.context.value.length - 1] : void 0;
|
|
726
|
+
return node ? {
|
|
727
|
+
node,
|
|
728
|
+
path: [{
|
|
729
|
+
_key: node._key
|
|
730
|
+
}]
|
|
731
|
+
} : void 0;
|
|
732
|
+
};
|
|
733
|
+
function isAtTheEndOfBlock(block) {
|
|
734
|
+
return (snapshot) => {
|
|
735
|
+
if (!snapshot.context.selection || !selector_getSelectionText.isSelectionCollapsed(snapshot))
|
|
736
|
+
return !1;
|
|
737
|
+
const blockEndPoint = util_isEmptyTextBlock.getBlockEndPoint({
|
|
738
|
+
context: snapshot.context,
|
|
739
|
+
block
|
|
740
|
+
});
|
|
741
|
+
return util_isEmptyTextBlock.isEqualSelectionPoints(snapshot.context.selection.focus, blockEndPoint);
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
function isAtTheStartOfBlock(block) {
|
|
745
|
+
return (snapshot) => {
|
|
746
|
+
if (!snapshot.context.selection || !selector_getSelectionText.isSelectionCollapsed(snapshot))
|
|
747
|
+
return !1;
|
|
748
|
+
const blockStartPoint = util_getTextBlockText.getBlockStartPoint({
|
|
749
|
+
context: snapshot.context,
|
|
750
|
+
block
|
|
751
|
+
});
|
|
752
|
+
return util_isEmptyTextBlock.isEqualSelectionPoints(snapshot.context.selection.focus, blockStartPoint);
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
const getFocusListBlock = (snapshot) => {
|
|
756
|
+
const focusTextBlock = selector_getSelectionText.getFocusTextBlock(snapshot);
|
|
757
|
+
return focusTextBlock && util_getTextBlockText.isListBlock(snapshot.context, focusTextBlock.node) ? {
|
|
758
|
+
node: focusTextBlock.node,
|
|
759
|
+
path: focusTextBlock.path
|
|
760
|
+
} : void 0;
|
|
761
|
+
};
|
|
762
|
+
function isActiveDecorator(decorator) {
|
|
763
|
+
return (snapshot) => {
|
|
764
|
+
if (selector_getSelectionText.isSelectionExpanded(snapshot)) {
|
|
765
|
+
const selectedSpans = getSelectedSpans(snapshot);
|
|
766
|
+
return selectedSpans.length > 0 && selectedSpans.every((span) => span.node.marks?.includes(decorator));
|
|
767
|
+
}
|
|
768
|
+
return getActiveDecorators(snapshot).includes(decorator);
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
const getActiveAnnotations = (snapshot) => {
|
|
772
|
+
if (!snapshot.context.selection)
|
|
773
|
+
return [];
|
|
774
|
+
const selectedBlocks = getSelectedBlocks(snapshot), activeAnnotations = (getMarkState(snapshot)?.marks ?? []).filter((mark) => !snapshot.context.schema.decorators.map((decorator) => decorator.name).includes(mark));
|
|
775
|
+
return selectedBlocks.flatMap((block) => schema.isTextBlock(snapshot.context, block.node) ? block.node.markDefs ?? [] : []).filter((markDef) => activeAnnotations.includes(markDef._key));
|
|
519
776
|
}, getSelectedTextBlocks = (snapshot) => {
|
|
520
777
|
if (!snapshot.context.selection)
|
|
521
778
|
return [];
|
|
522
|
-
const selectedTextBlocks = [], startPoint =
|
|
779
|
+
const selectedTextBlocks = [], startPoint = util_getTextBlockText.getSelectionStartPoint(snapshot.context.selection), endPoint = util_getTextBlockText.getSelectionEndPoint(snapshot.context.selection), startBlockKey = util_getTextBlockText.getBlockKeyFromSelectionPoint(startPoint), endBlockKey = util_getTextBlockText.getBlockKeyFromSelectionPoint(endPoint);
|
|
523
780
|
if (!startBlockKey || !endBlockKey)
|
|
524
781
|
return selectedTextBlocks;
|
|
525
782
|
const startBlockIndex = snapshot.blockIndexMap.get(startBlockKey), endBlockIndex = snapshot.blockIndexMap.get(endBlockKey);
|
|
@@ -554,280 +811,32 @@ const getSelectionEndBlock = (snapshot) => {
|
|
|
554
811
|
});
|
|
555
812
|
}
|
|
556
813
|
return selectedTextBlocks;
|
|
557
|
-
},
|
|
814
|
+
}, getActiveListItem = (snapshot) => {
|
|
558
815
|
if (!snapshot.context.selection)
|
|
559
|
-
return
|
|
560
|
-
const
|
|
561
|
-
if (!
|
|
562
|
-
return
|
|
563
|
-
const
|
|
564
|
-
if (
|
|
565
|
-
return
|
|
566
|
-
const slicedValue = snapshot.context.value.slice(startBlockIndex, endBlockIndex + 1);
|
|
567
|
-
let startBlockFound = !1, adjustedStartPoint, trimStartPoint = !1, adjustedEndPoint, trimEndPoint = !1, previousPotentialEndpoint;
|
|
568
|
-
for (const block of slicedValue)
|
|
569
|
-
if (!(block._key === startBlockKey && (startBlockFound = !0, schema.isTextBlock(snapshot.context, block) && util_isSelectionCollapsed.isEmptyTextBlock(snapshot.context, block))) && startBlockFound && schema.isTextBlock(snapshot.context, block)) {
|
|
570
|
-
if (block._key === endBlockKey && util_isSelectionCollapsed.isEmptyTextBlock(snapshot.context, block))
|
|
571
|
-
break;
|
|
572
|
-
for (const child of block.children) {
|
|
573
|
-
if (child._key === endChildKey && (!schema.isSpan(snapshot.context, child) || endPoint.offset === 0)) {
|
|
574
|
-
adjustedEndPoint = previousPotentialEndpoint ? {
|
|
575
|
-
path: [{
|
|
576
|
-
_key: previousPotentialEndpoint.blockKey
|
|
577
|
-
}, "children", {
|
|
578
|
-
_key: previousPotentialEndpoint.span._key
|
|
579
|
-
}],
|
|
580
|
-
offset: previousPotentialEndpoint.span.text.length
|
|
581
|
-
} : void 0, trimEndPoint = !0;
|
|
582
|
-
break;
|
|
583
|
-
}
|
|
584
|
-
if (trimStartPoint) {
|
|
585
|
-
const lonelySpan = schema.isSpan(snapshot.context, child) && block.children.length === 1;
|
|
586
|
-
(schema.isSpan(snapshot.context, child) && child.text.length > 0 || lonelySpan) && (adjustedStartPoint = {
|
|
587
|
-
path: [{
|
|
588
|
-
_key: block._key
|
|
589
|
-
}, "children", {
|
|
590
|
-
_key: child._key
|
|
591
|
-
}],
|
|
592
|
-
offset: 0
|
|
593
|
-
}, previousPotentialEndpoint = {
|
|
594
|
-
blockKey: block._key,
|
|
595
|
-
span: child
|
|
596
|
-
}, trimStartPoint = !1);
|
|
597
|
-
continue;
|
|
598
|
-
}
|
|
599
|
-
if (child._key === startChildKey) {
|
|
600
|
-
if (!schema.isSpan(snapshot.context, child)) {
|
|
601
|
-
trimStartPoint = !0;
|
|
602
|
-
continue;
|
|
603
|
-
}
|
|
604
|
-
if (startPoint.offset === child.text.length) {
|
|
605
|
-
trimStartPoint = !0, previousPotentialEndpoint = child.text.length > 0 ? {
|
|
606
|
-
blockKey: block._key,
|
|
607
|
-
span: child
|
|
608
|
-
} : previousPotentialEndpoint;
|
|
609
|
-
continue;
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
previousPotentialEndpoint = schema.isSpan(snapshot.context, child) && child.text.length > 0 ? {
|
|
613
|
-
blockKey: block._key,
|
|
614
|
-
span: child
|
|
615
|
-
} : previousPotentialEndpoint;
|
|
616
|
-
}
|
|
617
|
-
if (block._key === endBlockKey)
|
|
618
|
-
break;
|
|
619
|
-
}
|
|
620
|
-
const trimmedSelection = snapshot.context.selection.backward ? {
|
|
621
|
-
anchor: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint,
|
|
622
|
-
focus: adjustedStartPoint ?? startPoint,
|
|
623
|
-
backward: !0
|
|
624
|
-
} : {
|
|
625
|
-
anchor: adjustedStartPoint ?? startPoint,
|
|
626
|
-
focus: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint
|
|
627
|
-
};
|
|
628
|
-
if (selector_isSelectionExpanded.isSelectionCollapsed({
|
|
629
|
-
context: {
|
|
630
|
-
...snapshot.context,
|
|
631
|
-
selection: trimmedSelection
|
|
632
|
-
}
|
|
633
|
-
})) {
|
|
634
|
-
const focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock({
|
|
635
|
-
...snapshot,
|
|
636
|
-
context: {
|
|
637
|
-
...snapshot.context,
|
|
638
|
-
selection: trimmedSelection
|
|
639
|
-
}
|
|
640
|
-
});
|
|
641
|
-
if (focusTextBlock && !util_isSelectionCollapsed.isEmptyTextBlock(snapshot.context, focusTextBlock.node))
|
|
642
|
-
return null;
|
|
643
|
-
}
|
|
644
|
-
return trimmedSelection;
|
|
816
|
+
return;
|
|
817
|
+
const selectedTextBlocks = getSelectedBlocks(snapshot).map((block) => block.node).filter((block) => schema.isTextBlock(snapshot.context, block)), firstTextBlock = selectedTextBlocks.at(0);
|
|
818
|
+
if (!firstTextBlock)
|
|
819
|
+
return;
|
|
820
|
+
const firstListItem = firstTextBlock.listItem;
|
|
821
|
+
if (firstListItem && selectedTextBlocks.every((block) => block.listItem === firstListItem))
|
|
822
|
+
return firstListItem;
|
|
645
823
|
};
|
|
646
|
-
function getActiveAnnotationsMarks(snapshot) {
|
|
647
|
-
const schema2 = snapshot.context.schema;
|
|
648
|
-
return (getMarkState(snapshot)?.marks ?? []).filter((mark) => !schema2.decorators.map((decorator) => decorator.name).includes(mark));
|
|
649
|
-
}
|
|
650
|
-
function isActiveAnnotation(annotation, options) {
|
|
651
|
-
return (snapshot) => {
|
|
652
|
-
if ((options?.mode ?? "full") === "partial")
|
|
653
|
-
return selector_isSelectionExpanded.getSelectedValue(snapshot).flatMap((block) => schema.isTextBlock(snapshot.context, block) ? block.markDefs ?? [] : []).some((markDef) => markDef._type === annotation);
|
|
654
|
-
const selectionMarkDefs = getSelectedBlocks(snapshot).flatMap((block) => schema.isTextBlock(snapshot.context, block.node) ? block.node.markDefs ?? [] : []), activeAnnotations = getActiveAnnotationsMarks(snapshot);
|
|
655
|
-
return selectionMarkDefs.filter((markDef) => markDef._type === annotation && activeAnnotations.includes(markDef._key)).length > 0;
|
|
656
|
-
};
|
|
657
|
-
}
|
|
658
|
-
function getActiveDecorators(snapshot) {
|
|
659
|
-
const schema2 = snapshot.context.schema, decoratorState = snapshot.decoratorState, markState = getMarkState(snapshot), decorators = schema2.decorators.map((decorator) => decorator.name);
|
|
660
|
-
let activeDecorators = (markState?.marks ?? []).filter((mark) => decorators.includes(mark));
|
|
661
|
-
for (const decorator in decoratorState)
|
|
662
|
-
decoratorState[decorator] === !1 ? activeDecorators = activeDecorators.filter((activeDecorator) => activeDecorator !== decorator) : decoratorState[decorator] === !0 && (activeDecorators.includes(decorator) || activeDecorators.push(decorator));
|
|
663
|
-
return activeDecorators;
|
|
664
|
-
}
|
|
665
|
-
function isActiveDecorator(decorator) {
|
|
666
|
-
return (snapshot) => {
|
|
667
|
-
if (selector_isSelectionExpanded.isSelectionExpanded(snapshot)) {
|
|
668
|
-
const selectedSpans = getSelectedSpans(snapshot);
|
|
669
|
-
return selectedSpans.length > 0 && selectedSpans.every((span) => span.node.marks?.includes(decorator));
|
|
670
|
-
}
|
|
671
|
-
return getActiveDecorators(snapshot).includes(decorator);
|
|
672
|
-
};
|
|
673
|
-
}
|
|
674
824
|
function isActiveListItem(listItem) {
|
|
675
825
|
return (snapshot) => getActiveListItem(snapshot) === listItem;
|
|
676
826
|
}
|
|
827
|
+
const getActiveStyle = (snapshot) => {
|
|
828
|
+
if (!snapshot.context.selection)
|
|
829
|
+
return;
|
|
830
|
+
const selectedTextBlocks = getSelectedBlocks(snapshot).map((block) => block.node).filter((block) => schema.isTextBlock(snapshot.context, block)), firstTextBlock = selectedTextBlocks.at(0);
|
|
831
|
+
if (!firstTextBlock)
|
|
832
|
+
return;
|
|
833
|
+
const firstStyle = firstTextBlock.style;
|
|
834
|
+
if (firstStyle && selectedTextBlocks.every((block) => block.style === firstStyle))
|
|
835
|
+
return firstStyle;
|
|
836
|
+
};
|
|
677
837
|
function isActiveStyle(style) {
|
|
678
838
|
return (snapshot) => getActiveStyle(snapshot) === style;
|
|
679
839
|
}
|
|
680
|
-
function isAtTheEndOfBlock(block) {
|
|
681
|
-
return (snapshot) => {
|
|
682
|
-
if (!snapshot.context.selection || !selector_isSelectionExpanded.isSelectionCollapsed(snapshot))
|
|
683
|
-
return !1;
|
|
684
|
-
const blockEndPoint = util_isSelectionCollapsed.getBlockEndPoint({
|
|
685
|
-
context: snapshot.context,
|
|
686
|
-
block
|
|
687
|
-
});
|
|
688
|
-
return util_isSelectionCollapsed.isEqualSelectionPoints(snapshot.context.selection.focus, blockEndPoint);
|
|
689
|
-
};
|
|
690
|
-
}
|
|
691
|
-
function isAtTheStartOfBlock(block) {
|
|
692
|
-
return (snapshot) => {
|
|
693
|
-
if (!snapshot.context.selection || !selector_isSelectionExpanded.isSelectionCollapsed(snapshot))
|
|
694
|
-
return !1;
|
|
695
|
-
const blockStartPoint = util_sliceBlocks.getBlockStartPoint({
|
|
696
|
-
context: snapshot.context,
|
|
697
|
-
block
|
|
698
|
-
});
|
|
699
|
-
return util_isSelectionCollapsed.isEqualSelectionPoints(snapshot.context.selection.focus, blockStartPoint);
|
|
700
|
-
};
|
|
701
|
-
}
|
|
702
|
-
function isPointAfterSelection(point) {
|
|
703
|
-
return (snapshot) => {
|
|
704
|
-
if (!snapshot.context.selection)
|
|
705
|
-
return !1;
|
|
706
|
-
const endPoint = util_sliceBlocks.getSelectionEndPoint(snapshot.context.selection), endBlockKey = util_sliceBlocks.getBlockKeyFromSelectionPoint(endPoint), endChildKey = util_sliceBlocks.getChildKeyFromSelectionPoint(endPoint), pointBlockKey = util_sliceBlocks.getBlockKeyFromSelectionPoint(point), pointChildKey = util_sliceBlocks.getChildKeyFromSelectionPoint(point);
|
|
707
|
-
if (!pointBlockKey || !endBlockKey)
|
|
708
|
-
return !1;
|
|
709
|
-
const pointBlockIndex = snapshot.blockIndexMap.get(pointBlockKey), endBlockIndex = snapshot.blockIndexMap.get(endBlockKey);
|
|
710
|
-
if (pointBlockIndex === void 0 || endBlockIndex === void 0)
|
|
711
|
-
return !1;
|
|
712
|
-
if (pointBlockIndex > endBlockIndex)
|
|
713
|
-
return !0;
|
|
714
|
-
if (pointBlockIndex < endBlockIndex)
|
|
715
|
-
return !1;
|
|
716
|
-
const pointBlock = snapshot.context.value.at(pointBlockIndex);
|
|
717
|
-
if (!pointBlock || !schema.isTextBlock(snapshot.context, pointBlock))
|
|
718
|
-
return !1;
|
|
719
|
-
let pointChildIndex, endChildIndex, childIndex = -1;
|
|
720
|
-
for (const child of pointBlock.children) {
|
|
721
|
-
if (childIndex++, child._key === pointChildKey && child._key === endChildKey)
|
|
722
|
-
return point.offset > endPoint.offset;
|
|
723
|
-
if (child._key === pointChildKey && (pointChildIndex = childIndex), child._key === endChildKey && (endChildIndex = childIndex), pointChildIndex !== void 0 && endChildIndex !== void 0)
|
|
724
|
-
break;
|
|
725
|
-
}
|
|
726
|
-
return pointChildIndex === void 0 || endChildIndex === void 0 ? !1 : pointChildIndex > endChildIndex;
|
|
727
|
-
};
|
|
728
|
-
}
|
|
729
|
-
function isPointBeforeSelection(point) {
|
|
730
|
-
return (snapshot) => {
|
|
731
|
-
if (!snapshot.context.selection)
|
|
732
|
-
return !1;
|
|
733
|
-
const startPoint = util_sliceBlocks.getSelectionStartPoint(snapshot.context.selection), startBlockKey = util_sliceBlocks.getBlockKeyFromSelectionPoint(startPoint), startChildKey = util_sliceBlocks.getChildKeyFromSelectionPoint(startPoint), pointBlockKey = util_sliceBlocks.getBlockKeyFromSelectionPoint(point), pointChildKey = util_sliceBlocks.getChildKeyFromSelectionPoint(point);
|
|
734
|
-
if (!pointBlockKey || !startBlockKey)
|
|
735
|
-
return !1;
|
|
736
|
-
const startBlockIndex = snapshot.blockIndexMap.get(startBlockKey), pointBlockIndex = snapshot.blockIndexMap.get(pointBlockKey);
|
|
737
|
-
if (startBlockIndex === void 0 || pointBlockIndex === void 0)
|
|
738
|
-
return !1;
|
|
739
|
-
if (pointBlockIndex < startBlockIndex)
|
|
740
|
-
return !0;
|
|
741
|
-
if (pointBlockIndex > startBlockIndex)
|
|
742
|
-
return !1;
|
|
743
|
-
const pointBlock = snapshot.context.value.at(pointBlockIndex);
|
|
744
|
-
if (!pointBlock || !schema.isTextBlock(snapshot.context, pointBlock))
|
|
745
|
-
return !1;
|
|
746
|
-
let pointChildIndex, startChildIndex, childIndex = -1;
|
|
747
|
-
for (const child of pointBlock.children) {
|
|
748
|
-
if (childIndex++, child._key === pointChildKey && child._key === startChildKey)
|
|
749
|
-
return point.offset < startPoint.offset;
|
|
750
|
-
if (child._key === pointChildKey && (pointChildIndex = childIndex), child._key === startChildKey && (startChildIndex = childIndex), pointChildIndex !== void 0 && startChildIndex !== void 0)
|
|
751
|
-
break;
|
|
752
|
-
}
|
|
753
|
-
return pointChildIndex === void 0 || startChildIndex === void 0 ? !1 : pointChildIndex < startChildIndex;
|
|
754
|
-
};
|
|
755
|
-
}
|
|
756
|
-
function isOverlappingSelection(selection) {
|
|
757
|
-
return (snapshot) => {
|
|
758
|
-
if (!selection || !snapshot.context.selection)
|
|
759
|
-
return !1;
|
|
760
|
-
const selectionStartPoint = selector_isSelectionExpanded.getSelectionStartPoint({
|
|
761
|
-
context: {
|
|
762
|
-
...snapshot.context,
|
|
763
|
-
selection
|
|
764
|
-
}
|
|
765
|
-
}), selectionEndPoint = getSelectionEndPoint({
|
|
766
|
-
context: {
|
|
767
|
-
...snapshot.context,
|
|
768
|
-
selection
|
|
769
|
-
}
|
|
770
|
-
}), originalSelectionStartPoint = selector_isSelectionExpanded.getSelectionStartPoint(snapshot), originalSelectionEndPoint = getSelectionEndPoint(snapshot);
|
|
771
|
-
if (!selectionStartPoint || !selectionEndPoint || !originalSelectionStartPoint || !originalSelectionEndPoint)
|
|
772
|
-
return !1;
|
|
773
|
-
const startPointEqualToOriginalStartPoint = util_isSelectionCollapsed.isEqualSelectionPoints(selectionStartPoint, originalSelectionStartPoint), endPointEqualToOriginalEndPoint = util_isSelectionCollapsed.isEqualSelectionPoints(selectionEndPoint, originalSelectionEndPoint);
|
|
774
|
-
if (startPointEqualToOriginalStartPoint && endPointEqualToOriginalEndPoint)
|
|
775
|
-
return !0;
|
|
776
|
-
const startPointBeforeSelection = isPointBeforeSelection(selectionStartPoint)(snapshot), startPointAfterSelection = isPointAfterSelection(selectionStartPoint)(snapshot), endPointBeforeSelection = isPointBeforeSelection(selectionEndPoint)(snapshot), endPointAfterSelection = isPointAfterSelection(selectionEndPoint)(snapshot), originalStartPointBeforeStartPoint = isPointBeforeSelection(originalSelectionStartPoint)({
|
|
777
|
-
...snapshot,
|
|
778
|
-
context: {
|
|
779
|
-
...snapshot.context,
|
|
780
|
-
selection: {
|
|
781
|
-
anchor: selectionStartPoint,
|
|
782
|
-
focus: selectionStartPoint
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
}), originalStartPointAfterStartPoint = isPointAfterSelection(originalSelectionStartPoint)({
|
|
786
|
-
...snapshot,
|
|
787
|
-
context: {
|
|
788
|
-
...snapshot.context,
|
|
789
|
-
selection: {
|
|
790
|
-
anchor: selectionStartPoint,
|
|
791
|
-
focus: selectionStartPoint
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
}), originalEndPointBeforeEndPoint = isPointBeforeSelection(originalSelectionEndPoint)({
|
|
795
|
-
...snapshot,
|
|
796
|
-
context: {
|
|
797
|
-
...snapshot.context,
|
|
798
|
-
selection: {
|
|
799
|
-
anchor: selectionEndPoint,
|
|
800
|
-
focus: selectionEndPoint
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
}), originalEndPointAfterEndPoint = isPointAfterSelection(originalSelectionEndPoint)({
|
|
804
|
-
...snapshot,
|
|
805
|
-
context: {
|
|
806
|
-
...snapshot.context,
|
|
807
|
-
selection: {
|
|
808
|
-
anchor: selectionEndPoint,
|
|
809
|
-
focus: selectionEndPoint
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
}), startPointEqualToOriginalEndPoint = util_isSelectionCollapsed.isEqualSelectionPoints(selectionStartPoint, originalSelectionEndPoint), endPointEqualToOriginalStartPoint = util_isSelectionCollapsed.isEqualSelectionPoints(selectionEndPoint, originalSelectionStartPoint);
|
|
813
|
-
return !endPointEqualToOriginalStartPoint && !startPointEqualToOriginalEndPoint && !originalStartPointBeforeStartPoint && !originalStartPointAfterStartPoint && !originalEndPointBeforeEndPoint && !originalEndPointAfterEndPoint || endPointBeforeSelection && !endPointEqualToOriginalStartPoint || startPointAfterSelection && !startPointEqualToOriginalEndPoint ? !1 : !originalStartPointBeforeStartPoint && originalStartPointAfterStartPoint && !originalEndPointBeforeEndPoint && originalEndPointAfterEndPoint ? !endPointEqualToOriginalStartPoint : originalStartPointBeforeStartPoint && !originalStartPointAfterStartPoint && originalEndPointBeforeEndPoint && !originalEndPointAfterEndPoint ? !startPointEqualToOriginalEndPoint : !startPointAfterSelection || !startPointBeforeSelection || !endPointAfterSelection || !endPointBeforeSelection;
|
|
814
|
-
};
|
|
815
|
-
}
|
|
816
|
-
const isSelectingEntireBlocks = (snapshot) => {
|
|
817
|
-
if (!snapshot.context.selection)
|
|
818
|
-
return !1;
|
|
819
|
-
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);
|
|
820
|
-
if (!startBlock || !endBlock)
|
|
821
|
-
return !1;
|
|
822
|
-
const startBlockStartPoint = util_sliceBlocks.getBlockStartPoint({
|
|
823
|
-
context: snapshot.context,
|
|
824
|
-
block: startBlock
|
|
825
|
-
}), endBlockEndPoint = util_isSelectionCollapsed.getBlockEndPoint({
|
|
826
|
-
context: snapshot.context,
|
|
827
|
-
block: endBlock
|
|
828
|
-
});
|
|
829
|
-
return util_isSelectionCollapsed.isEqualSelectionPoints(startBlockStartPoint, startPoint) && util_isSelectionCollapsed.isEqualSelectionPoints(endBlockEndPoint, endPoint);
|
|
830
|
-
};
|
|
831
840
|
exports.getActiveAnnotations = getActiveAnnotations;
|
|
832
841
|
exports.getActiveAnnotationsMarks = getActiveAnnotationsMarks;
|
|
833
842
|
exports.getActiveDecorators = getActiveDecorators;
|
|
@@ -860,4 +869,4 @@ exports.isOverlappingSelection = isOverlappingSelection;
|
|
|
860
869
|
exports.isPointAfterSelection = isPointAfterSelection;
|
|
861
870
|
exports.isPointBeforeSelection = isPointBeforeSelection;
|
|
862
871
|
exports.isSelectingEntireBlocks = isSelectingEntireBlocks;
|
|
863
|
-
//# sourceMappingURL=selector.is-
|
|
872
|
+
//# sourceMappingURL=selector.is-active-style.cjs.map
|