@portabletext/editor 1.48.7 → 1.48.8
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/behavior.core.cjs +20 -8
- package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/behavior.markdown.cjs +5 -5
- package/lib/_chunks-cjs/behavior.markdown.cjs.map +1 -1
- package/lib/_chunks-cjs/editor-provider.cjs +121 -90
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs +2 -2
- package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.get-text-before.cjs +7 -4
- package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs +63 -47
- package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +29 -23
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs +3 -3
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs +15 -15
- package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs.map +1 -1
- package/lib/_chunks-cjs/util.slice-blocks.cjs +258 -38
- package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js +21 -10
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/behavior.markdown.js +5 -6
- package/lib/_chunks-es/behavior.markdown.js.map +1 -1
- package/lib/_chunks-es/editor-provider.js +75 -46
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/_chunks-es/selector.get-focus-inline-object.js +1 -2
- package/lib/_chunks-es/selector.get-focus-inline-object.js.map +1 -1
- package/lib/_chunks-es/selector.get-text-before.js +7 -4
- package/lib/_chunks-es/selector.get-text-before.js.map +1 -1
- package/lib/_chunks-es/selector.is-overlapping-selection.js +61 -46
- package/lib/_chunks-es/selector.is-overlapping-selection.js.map +1 -1
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +30 -26
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
- package/lib/_chunks-es/util.merge-text-blocks.js +1 -1
- package/lib/_chunks-es/util.selection-point-to-block-offset.js +15 -16
- package/lib/_chunks-es/util.selection-point-to-block-offset.js.map +1 -1
- package/lib/_chunks-es/util.slice-blocks.js +258 -38
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
- package/lib/behaviors/index.d.cts +2552 -251
- package/lib/behaviors/index.d.ts +2552 -251
- package/lib/index.cjs +45 -21
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2350 -51
- package/lib/index.d.ts +2350 -51
- package/lib/index.js +44 -21
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +16 -7
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +2324 -24
- package/lib/plugins/index.d.ts +2324 -24
- package/lib/plugins/index.js +16 -7
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.cjs +5 -5
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +2321 -28
- package/lib/selectors/index.d.ts +2321 -28
- package/lib/selectors/index.js +5 -6
- package/lib/selectors/index.js.map +1 -1
- package/lib/utils/index.cjs +30 -24
- package/lib/utils/index.cjs.map +1 -1
- package/lib/utils/index.d.cts +2350 -44
- package/lib/utils/index.d.ts +2350 -44
- package/lib/utils/index.js +30 -24
- package/lib/utils/index.js.map +1 -1
- package/package.json +1 -2
- package/src/behavior-actions/behavior.action.block.unset.ts +1 -1
- package/src/behavior-actions/behavior.action.decorator.add.ts +20 -5
- package/src/behaviors/behavior.abstract.decorator.ts +1 -1
- package/src/behaviors/behavior.abstract.delete.ts +1 -1
- package/src/behaviors/behavior.abstract.insert.ts +2 -2
- package/src/behaviors/behavior.abstract.select.ts +16 -4
- package/src/behaviors/behavior.abstract.split.ts +9 -6
- package/src/behaviors/behavior.core.block-objects.ts +5 -5
- package/src/behaviors/behavior.core.insert-break.ts +16 -4
- package/src/behaviors/behavior.core.lists.ts +4 -6
- package/src/behaviors/behavior.decorator-pair.ts +13 -4
- package/src/behaviors/behavior.default.ts +1 -1
- package/src/behaviors/behavior.markdown.ts +5 -5
- package/src/converters/converter.portable-text.ts +1 -1
- package/src/converters/converter.text-html.ts +1 -1
- package/src/converters/converter.text-plain.ts +4 -4
- package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +10 -2
- package/src/editor/plugins/createWithSchemaTypes.ts +12 -19
- package/src/internal-utils/__tests__/dmpToOperations.test.ts +13 -12
- package/src/internal-utils/drag-selection.ts +16 -4
- package/src/internal-utils/event-position.ts +20 -8
- package/src/internal-utils/parse-blocks.ts +17 -5
- package/src/internal-utils/validateValue.ts +6 -6
- package/src/plugins/plugin.decorator-shortcut.ts +2 -2
- package/src/selectors/selector.get-active-annotations.ts +5 -2
- package/src/selectors/selector.get-active-list-item.ts +4 -3
- package/src/selectors/selector.get-active-style.ts +4 -3
- package/src/selectors/selector.get-anchor-text-block.ts +3 -6
- package/src/selectors/selector.get-block-offsets.ts +2 -2
- package/src/selectors/selector.get-caret-word-selection.ts +11 -5
- package/src/selectors/selector.get-selected-slice.ts +1 -1
- package/src/selectors/selector.get-selected-spans.ts +11 -15
- package/src/selectors/selector.get-selected-text-blocks.ts +3 -3
- package/src/selectors/selector.get-selection-text.ts +3 -3
- package/src/selectors/selector.get-text-before.ts +5 -2
- package/src/selectors/selector.get-trimmed-selection.ts +20 -14
- package/src/selectors/selector.is-active-annotation.ts +4 -2
- package/src/selectors/selector.is-active-decorator.test.ts +3 -3
- package/src/selectors/selector.is-at-the-end-of-block.ts +4 -1
- package/src/selectors/selector.is-at-the-start-of-block.ts +4 -1
- package/src/selectors/selector.is-point-after-selection.ts +7 -6
- package/src/selectors/selector.is-point-before-selection.ts +7 -6
- package/src/selectors/selector.is-selecting-entire-blocks.ts +8 -2
- package/src/selectors/selectors.ts +25 -28
- package/src/utils/util.block-offset-to-block-selection-point.ts +4 -4
- package/src/utils/util.block-offset-to-selection-point.ts +5 -5
- package/src/utils/util.block-offset.test.ts +219 -156
- package/src/utils/util.block-offset.ts +14 -17
- package/src/utils/util.block-offsets-to-selection.ts +5 -5
- package/src/utils/util.child-selection-point-to-block-offset.ts +7 -10
- package/src/utils/util.get-block-end-point.ts +15 -15
- package/src/utils/util.get-block-start-point.ts +13 -12
- package/src/utils/util.is-empty-text-block.ts +9 -8
- package/src/utils/util.selection-point-to-block-offset.ts +4 -4
- package/src/utils/util.slice-blocks.test.ts +178 -121
- package/src/utils/util.slice-blocks.ts +25 -24
- package/src/utils/util.split-text-block.ts +18 -12
- package/lib/_chunks-cjs/parse-blocks.cjs +0 -205
- package/lib/_chunks-cjs/parse-blocks.cjs.map +0 -1
- package/lib/_chunks-es/parse-blocks.js +0 -206
- package/lib/_chunks-es/parse-blocks.js.map +0 -1
- package/src/behavior-actions/behavior.guards.ts +0 -24
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
2
|
+
var util_sliceBlocks = require("./util.slice-blocks.cjs"), selector_isOverlappingSelection = require("./selector.is-overlapping-selection.cjs");
|
|
3
3
|
const getSelectedSpans = (snapshot) => {
|
|
4
4
|
if (!snapshot.context.selection)
|
|
5
5
|
return [];
|
|
6
|
-
const selectedSpans = [], 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, startBlockKey =
|
|
6
|
+
const selectedSpans = [], 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, startBlockKey = util_sliceBlocks.isKeyedSegment(startPoint.path[0]) ? startPoint.path[0]._key : void 0, endBlockKey = util_sliceBlocks.isKeyedSegment(endPoint.path[0]) ? endPoint.path[0]._key : void 0;
|
|
7
7
|
if (!startBlockKey || !endBlockKey)
|
|
8
8
|
return selectedSpans;
|
|
9
|
-
const startSpanKey =
|
|
9
|
+
const startSpanKey = util_sliceBlocks.isKeyedSegment(startPoint.path[2]) ? startPoint.path[2]._key : void 0, endSpanKey = util_sliceBlocks.isKeyedSegment(endPoint.path[2]) ? endPoint.path[2]._key : void 0;
|
|
10
10
|
let startBlockFound = !1;
|
|
11
11
|
for (const block of snapshot.context.value)
|
|
12
|
-
if (block._key === startBlockKey && (startBlockFound = !0), !!
|
|
12
|
+
if (block._key === startBlockKey && (startBlockFound = !0), !!util_sliceBlocks.isTextBlock(snapshot.context, block)) {
|
|
13
13
|
if (block._key === startBlockKey) {
|
|
14
14
|
for (const child of block.children)
|
|
15
|
-
if (
|
|
15
|
+
if (util_sliceBlocks.isSpan(snapshot.context, child)) {
|
|
16
16
|
if (startSpanKey && child._key === startSpanKey) {
|
|
17
17
|
if (startPoint.offset < child.text.length && selectedSpans.push({
|
|
18
18
|
node: child,
|
|
@@ -51,7 +51,7 @@ const getSelectedSpans = (snapshot) => {
|
|
|
51
51
|
}
|
|
52
52
|
if (block._key === endBlockKey) {
|
|
53
53
|
for (const child of block.children)
|
|
54
|
-
if (
|
|
54
|
+
if (util_sliceBlocks.isSpan(snapshot.context, child)) {
|
|
55
55
|
if (endSpanKey && child._key === endSpanKey) {
|
|
56
56
|
endPoint.offset > 0 && selectedSpans.push({
|
|
57
57
|
node: child,
|
|
@@ -76,7 +76,7 @@ const getSelectedSpans = (snapshot) => {
|
|
|
76
76
|
}
|
|
77
77
|
if (startBlockFound)
|
|
78
78
|
for (const child of block.children)
|
|
79
|
-
|
|
79
|
+
util_sliceBlocks.isSpan(snapshot.context, child) && selectedSpans.push({
|
|
80
80
|
node: child,
|
|
81
81
|
path: [{
|
|
82
82
|
_key: block._key
|
|
@@ -98,11 +98,11 @@ const getSelectedSpans = (snapshot) => {
|
|
|
98
98
|
if (snapshot.context.selection.focus.offset === focusSpan.node.text.length)
|
|
99
99
|
return [];
|
|
100
100
|
}
|
|
101
|
-
return selectedBlocks.flatMap((block) =>
|
|
101
|
+
return selectedBlocks.flatMap((block) => util_sliceBlocks.isTextBlock(snapshot.context, block.node) ? block.node.markDefs ?? [] : []).filter((markDef) => selectedSpans.some((span) => span.node.marks?.includes(markDef._key)));
|
|
102
102
|
}, getActiveListItem = (snapshot) => {
|
|
103
103
|
if (!snapshot.context.selection)
|
|
104
104
|
return;
|
|
105
|
-
const
|
|
105
|
+
const selectedTextBlocks = selector_isOverlappingSelection.getSelectedBlocks(snapshot).map((block) => block.node).filter((block) => util_sliceBlocks.isTextBlock(snapshot.context, block)), firstTextBlock = selectedTextBlocks.at(0);
|
|
106
106
|
if (!firstTextBlock)
|
|
107
107
|
return;
|
|
108
108
|
const firstListItem = firstTextBlock.listItem;
|
|
@@ -111,7 +111,7 @@ const getSelectedSpans = (snapshot) => {
|
|
|
111
111
|
}, getActiveStyle = (snapshot) => {
|
|
112
112
|
if (!snapshot.context.selection)
|
|
113
113
|
return;
|
|
114
|
-
const
|
|
114
|
+
const selectedTextBlocks = selector_isOverlappingSelection.getSelectedBlocks(snapshot).map((block) => block.node).filter((block) => util_sliceBlocks.isTextBlock(snapshot.context, block)), firstTextBlock = selectedTextBlocks.at(0);
|
|
115
115
|
if (!firstTextBlock)
|
|
116
116
|
return;
|
|
117
117
|
const firstStyle = firstTextBlock.style;
|
|
@@ -125,7 +125,7 @@ const getSelectedSpans = (snapshot) => {
|
|
|
125
125
|
return selectedTextBlocks;
|
|
126
126
|
for (const block of snapshot.context.value) {
|
|
127
127
|
if (block._key === startKey) {
|
|
128
|
-
if (
|
|
128
|
+
if (util_sliceBlocks.isTextBlock(snapshot.context, block) && selectedTextBlocks.push({
|
|
129
129
|
node: block,
|
|
130
130
|
path: [{
|
|
131
131
|
_key: block._key
|
|
@@ -135,7 +135,7 @@ const getSelectedSpans = (snapshot) => {
|
|
|
135
135
|
continue;
|
|
136
136
|
}
|
|
137
137
|
if (block._key === endKey) {
|
|
138
|
-
|
|
138
|
+
util_sliceBlocks.isTextBlock(snapshot.context, block) && selectedTextBlocks.push({
|
|
139
139
|
node: block,
|
|
140
140
|
path: [{
|
|
141
141
|
_key: block._key
|
|
@@ -143,7 +143,7 @@ const getSelectedSpans = (snapshot) => {
|
|
|
143
143
|
});
|
|
144
144
|
break;
|
|
145
145
|
}
|
|
146
|
-
selectedTextBlocks.length > 0 &&
|
|
146
|
+
selectedTextBlocks.length > 0 && util_sliceBlocks.isTextBlock(snapshot.context, block) && selectedTextBlocks.push({
|
|
147
147
|
node: block,
|
|
148
148
|
path: [{
|
|
149
149
|
_key: block._key
|
|
@@ -162,11 +162,11 @@ const getSelectedSpans = (snapshot) => {
|
|
|
162
162
|
return snapshot.context.selection;
|
|
163
163
|
let startBlockFound = !1, adjustedStartPoint, trimStartPoint = !1, adjustedEndPoint, trimEndPoint = !1, previousPotentialEndpoint;
|
|
164
164
|
for (const block of snapshot.context.value)
|
|
165
|
-
if (!(block._key === startBlockKey && (startBlockFound = !0,
|
|
166
|
-
if (block._key === endBlockKey && util_sliceBlocks.isEmptyTextBlock(block))
|
|
165
|
+
if (!(block._key === startBlockKey && (startBlockFound = !0, util_sliceBlocks.isTextBlock(snapshot.context, block) && util_sliceBlocks.isEmptyTextBlock(snapshot.context, block))) && startBlockFound && util_sliceBlocks.isTextBlock(snapshot.context, block)) {
|
|
166
|
+
if (block._key === endBlockKey && util_sliceBlocks.isEmptyTextBlock(snapshot.context, block))
|
|
167
167
|
break;
|
|
168
168
|
for (const child of block.children) {
|
|
169
|
-
if (child._key === endChildKey && (!
|
|
169
|
+
if (child._key === endChildKey && (!util_sliceBlocks.isSpan(snapshot.context, child) || endPoint.offset === 0)) {
|
|
170
170
|
adjustedEndPoint = previousPotentialEndpoint ? {
|
|
171
171
|
path: [{
|
|
172
172
|
_key: previousPotentialEndpoint.blockKey
|
|
@@ -178,8 +178,8 @@ const getSelectedSpans = (snapshot) => {
|
|
|
178
178
|
break;
|
|
179
179
|
}
|
|
180
180
|
if (trimStartPoint) {
|
|
181
|
-
const lonelySpan =
|
|
182
|
-
(
|
|
181
|
+
const lonelySpan = util_sliceBlocks.isSpan(snapshot.context, child) && block.children.length === 1;
|
|
182
|
+
(util_sliceBlocks.isSpan(snapshot.context, child) && child.text.length > 0 || lonelySpan) && (adjustedStartPoint = {
|
|
183
183
|
path: [{
|
|
184
184
|
_key: block._key
|
|
185
185
|
}, "children", {
|
|
@@ -193,7 +193,7 @@ const getSelectedSpans = (snapshot) => {
|
|
|
193
193
|
continue;
|
|
194
194
|
}
|
|
195
195
|
if (child._key === startChildKey) {
|
|
196
|
-
if (!
|
|
196
|
+
if (!util_sliceBlocks.isSpan(snapshot.context, child)) {
|
|
197
197
|
trimStartPoint = !0;
|
|
198
198
|
continue;
|
|
199
199
|
}
|
|
@@ -205,7 +205,7 @@ const getSelectedSpans = (snapshot) => {
|
|
|
205
205
|
continue;
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
-
previousPotentialEndpoint =
|
|
208
|
+
previousPotentialEndpoint = util_sliceBlocks.isSpan(snapshot.context, child) && child.text.length > 0 ? {
|
|
209
209
|
blockKey: block._key,
|
|
210
210
|
span: child
|
|
211
211
|
} : previousPotentialEndpoint;
|
|
@@ -233,7 +233,7 @@ const getSelectedSpans = (snapshot) => {
|
|
|
233
233
|
selection: trimmedSelection
|
|
234
234
|
}
|
|
235
235
|
});
|
|
236
|
-
if (focusTextBlock && !util_sliceBlocks.isEmptyTextBlock(focusTextBlock.node))
|
|
236
|
+
if (focusTextBlock && !util_sliceBlocks.isEmptyTextBlock(snapshot.context, focusTextBlock.node))
|
|
237
237
|
return null;
|
|
238
238
|
}
|
|
239
239
|
return trimmedSelection;
|
|
@@ -245,7 +245,7 @@ function isActiveAnnotation(annotation) {
|
|
|
245
245
|
const selectedBlocks = selector_isOverlappingSelection.getSelectedBlocks(snapshot), focusSpan = selector_isOverlappingSelection.getFocusSpan(snapshot), selectedSpans = selector_isOverlappingSelection.isSelectionExpanded(snapshot) ? getSelectedSpans(snapshot) : focusSpan ? [focusSpan] : [];
|
|
246
246
|
if (selectedSpans.length === 0 || selectedSpans.some((span) => !span.node.marks || span.node.marks?.length === 0))
|
|
247
247
|
return !1;
|
|
248
|
-
const selectionMarkDefs = selectedBlocks.flatMap((block) =>
|
|
248
|
+
const selectionMarkDefs = selectedBlocks.flatMap((block) => util_sliceBlocks.isTextBlock(snapshot.context, block.node) ? block.node.markDefs ?? [] : []);
|
|
249
249
|
return selectedSpans.every((span) => (span.node.marks?.flatMap((mark) => {
|
|
250
250
|
const markDef = selectionMarkDefs.find((markDef2) => markDef2._key === mark);
|
|
251
251
|
return markDef ? [markDef._type] : [];
|
|
@@ -273,7 +273,13 @@ const isSelectingEntireBlocks = (snapshot) => {
|
|
|
273
273
|
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 = selector_isOverlappingSelection.getSelectionStartBlock(snapshot), endBlock = selector_isOverlappingSelection.getSelectionEndBlock(snapshot);
|
|
274
274
|
if (!startBlock || !endBlock)
|
|
275
275
|
return !1;
|
|
276
|
-
const startBlockStartPoint = util_sliceBlocks.getBlockStartPoint(
|
|
276
|
+
const startBlockStartPoint = util_sliceBlocks.getBlockStartPoint({
|
|
277
|
+
context: snapshot.context,
|
|
278
|
+
block: startBlock
|
|
279
|
+
}), endBlockEndPoint = util_sliceBlocks.getBlockEndPoint({
|
|
280
|
+
context: snapshot.context,
|
|
281
|
+
block: endBlock
|
|
282
|
+
});
|
|
277
283
|
return util_sliceBlocks.isEqualSelectionPoints(startBlockStartPoint, startPoint) && util_sliceBlocks.isEqualSelectionPoints(endBlockEndPoint, endPoint);
|
|
278
284
|
};
|
|
279
285
|
exports.getActiveAnnotations = getActiveAnnotations;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selector.is-selecting-entire-blocks.cjs","sources":["../../src/selectors/selector.get-selected-spans.ts","../../src/selectors/selector.get-active-annotations.ts","../../src/selectors/selector.get-active-list-item.ts","../../src/selectors/selector.get-active-style.ts","../../src/selectors/selector.get-selected-text-blocks.ts","../../src/selectors/selector.get-trimmed-selection.ts","../../src/selectors/selector.is-active-annotation.ts","../../src/selectors/selector.is-active-decorator.ts","../../src/selectors/selector.is-active-list-item.ts","../../src/selectors/selector.is-active-style.ts","../../src/selectors/selector.is-selecting-entire-blocks.ts"],"sourcesContent":["import {\n isKeySegment,\n isPortableTextSpan,\n isPortableTextTextBlock,\n type KeyedSegment,\n type PortableTextSpan,\n} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\n\n/**\n * @public\n */\nexport const getSelectedSpans: EditorSelector<\n Array<{\n node: PortableTextSpan\n path: [KeyedSegment, 'children', KeyedSegment]\n }>\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedSpans: Array<{\n node: PortableTextSpan\n path: [KeyedSegment, 'children', KeyedSegment]\n }> = []\n\n const startPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.focus\n : snapshot.context.selection.anchor\n const endPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.anchor\n : snapshot.context.selection.focus\n\n const startBlockKey = isKeySegment(startPoint.path[0])\n ? startPoint.path[0]._key\n : undefined\n const endBlockKey = isKeySegment(endPoint.path[0])\n ? endPoint.path[0]._key\n : undefined\n\n if (!startBlockKey || !endBlockKey) {\n return selectedSpans\n }\n\n const startSpanKey = isKeySegment(startPoint.path[2])\n ? startPoint.path[2]._key\n : undefined\n const endSpanKey = isKeySegment(endPoint.path[2])\n ? endPoint.path[2]._key\n : undefined\n\n let startBlockFound = false\n\n for (const block of snapshot.context.value) {\n if (block._key === startBlockKey) {\n startBlockFound = true\n }\n\n if (!isPortableTextTextBlock(block)) {\n continue\n }\n\n if (block._key === startBlockKey) {\n for (const child of block.children) {\n if (!isPortableTextSpan(child)) {\n continue\n }\n\n if (startSpanKey && child._key === startSpanKey) {\n if (startPoint.offset < child.text.length) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n\n if (startSpanKey === endSpanKey) {\n break\n }\n\n continue\n }\n\n if (endSpanKey && child._key === endSpanKey) {\n if (endPoint.offset > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n break\n }\n\n if (selectedSpans.length > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n }\n\n if (startBlockKey === endBlockKey) {\n break\n }\n\n continue\n }\n\n if (block._key === endBlockKey) {\n for (const child of block.children) {\n if (!isPortableTextSpan(child)) {\n continue\n }\n\n if (endSpanKey && child._key === endSpanKey) {\n if (endPoint.offset > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n break\n }\n\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n\n break\n }\n\n if (startBlockFound) {\n for (const child of block.children) {\n if (!isPortableTextSpan(child)) {\n continue\n }\n\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n }\n }\n\n return selectedSpans\n}\n","import {isPortableTextTextBlock, type PortableTextObject} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedSpans} from './selector.get-selected-spans'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\nimport {getFocusSpan, getSelectedBlocks} from './selectors'\n\n/**\n * @public\n */\nexport const getActiveAnnotations: EditorSelector<Array<PortableTextObject>> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedBlocks = getSelectedBlocks(snapshot)\n const selectedSpans = getSelectedSpans(snapshot)\n const focusSpan = getFocusSpan(snapshot)\n\n if (selectedSpans.length === 0 || !focusSpan) {\n return []\n }\n\n if (selectedSpans.length === 1 && isSelectionCollapsed(snapshot)) {\n if (snapshot.context.selection.focus.offset === 0) {\n return []\n }\n if (\n snapshot.context.selection.focus.offset === focusSpan.node.text.length\n ) {\n return []\n }\n }\n\n const selectionMarkDefs = selectedBlocks.flatMap((block) =>\n isPortableTextTextBlock(block.node) ? (block.node.markDefs ?? []) : [],\n )\n\n return selectionMarkDefs.filter((markDef) =>\n selectedSpans.some((span) => span.node.marks?.includes(markDef._key)),\n )\n}\n","import type {PortableTextListBlock} from '@sanity/types'\nimport {createGuards} from '../behavior-actions/behavior.guards'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedBlocks} from './selectors'\n\n/**\n * @public\n */\nexport const getActiveListItem: EditorSelector<\n PortableTextListBlock['listItem'] | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const guards = createGuards(snapshot.context)\n const selectedBlocks = getSelectedBlocks(snapshot).map((block) => block.node)\n const selectedTextBlocks = selectedBlocks.filter(guards.isTextBlock)\n\n const firstTextBlock = selectedTextBlocks.at(0)\n\n if (!firstTextBlock) {\n return undefined\n }\n\n const firstListItem = firstTextBlock.listItem\n\n if (!firstListItem) {\n return undefined\n }\n\n if (selectedTextBlocks.every((block) => block.listItem === firstListItem)) {\n return firstListItem\n }\n\n return undefined\n}\n","import type {PortableTextTextBlock} from '@sanity/types'\nimport {createGuards} from '../behavior-actions/behavior.guards'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedBlocks} from './selectors'\n\n/**\n * @public\n */\nexport const getActiveStyle: EditorSelector<PortableTextTextBlock['style']> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const guards = createGuards(snapshot.context)\n const selectedBlocks = getSelectedBlocks(snapshot).map((block) => block.node)\n const selectedTextBlocks = selectedBlocks.filter(guards.isTextBlock)\n\n const firstTextBlock = selectedTextBlocks.at(0)\n\n if (!firstTextBlock) {\n return undefined\n }\n\n const firstStyle = firstTextBlock.style\n\n if (!firstStyle) {\n return undefined\n }\n\n if (selectedTextBlocks.every((block) => block.style === firstStyle)) {\n return firstStyle\n }\n\n return undefined\n}\n","import type {KeyedSegment, PortableTextTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport {isKeyedSegment} from '../utils'\n\n/**\n * @public\n */\nexport const getSelectedTextBlocks: EditorSelector<\n Array<{node: PortableTextTextBlock; path: [KeyedSegment]}>\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedTextBlocks: Array<{\n node: PortableTextTextBlock\n path: [KeyedSegment]\n }> = []\n const startKey = snapshot.context.selection.backward\n ? isKeyedSegment(snapshot.context.selection.focus.path[0])\n ? snapshot.context.selection.focus.path[0]._key\n : undefined\n : isKeyedSegment(snapshot.context.selection.anchor.path[0])\n ? snapshot.context.selection.anchor.path[0]._key\n : undefined\n const endKey = snapshot.context.selection.backward\n ? isKeyedSegment(snapshot.context.selection.anchor.path[0])\n ? snapshot.context.selection.anchor.path[0]._key\n : undefined\n : isKeyedSegment(snapshot.context.selection.focus.path[0])\n ? snapshot.context.selection.focus.path[0]._key\n : undefined\n\n if (!startKey || !endKey) {\n return selectedTextBlocks\n }\n\n for (const block of snapshot.context.value) {\n if (block._key === startKey) {\n if (isTextBlock(snapshot.context.schema, block)) {\n selectedTextBlocks.push({node: block, path: [{_key: block._key}]})\n }\n\n if (startKey === endKey) {\n break\n }\n continue\n }\n\n if (block._key === endKey) {\n if (isTextBlock(snapshot.context.schema, block)) {\n selectedTextBlocks.push({node: block, path: [{_key: block._key}]})\n }\n\n break\n }\n\n if (selectedTextBlocks.length > 0) {\n if (isTextBlock(snapshot.context.schema, block)) {\n selectedTextBlocks.push({node: block, path: [{_key: block._key}]})\n }\n }\n }\n\n return selectedTextBlocks\n}\n","import {\n isPortableTextSpan,\n isPortableTextTextBlock,\n type PortableTextSpan,\n} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {EditorSelection, EditorSelectionPoint} from '../types/editor'\nimport {isEmptyTextBlock, isKeyedSegment} from '../utils'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\nimport {getFocusTextBlock} from './selectors'\n\n/**\n * @public\n */\nexport const getTrimmedSelection: EditorSelector<EditorSelection> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return snapshot.context.selection\n }\n\n const startPoint = getSelectionStartPoint(snapshot)\n const endPoint = getSelectionEndPoint(snapshot)\n\n if (!startPoint || !endPoint) {\n return snapshot.context.selection\n }\n\n const startBlockKey = isKeyedSegment(startPoint.path[0])\n ? startPoint.path[0]._key\n : null\n const startChildKey = isKeyedSegment(startPoint.path[2])\n ? startPoint.path[2]._key\n : null\n const endBlockKey = isKeyedSegment(endPoint.path[0])\n ? endPoint.path[0]._key\n : null\n const endChildKey = isKeyedSegment(endPoint.path[2])\n ? endPoint.path[2]._key\n : null\n\n if (!startBlockKey || !endBlockKey) {\n return snapshot.context.selection\n }\n\n let startBlockFound = false\n let adjustedStartPoint: EditorSelectionPoint | undefined\n let trimStartPoint = false\n let adjustedEndPoint: EditorSelectionPoint | undefined\n let trimEndPoint = false\n let previousPotentialEndpoint:\n | {blockKey: string; span: PortableTextSpan}\n | undefined\n\n for (const block of snapshot.context.value) {\n if (block._key === startBlockKey) {\n startBlockFound = true\n\n if (isPortableTextTextBlock(block) && isEmptyTextBlock(block)) {\n continue\n }\n }\n\n if (!startBlockFound) {\n continue\n }\n\n if (!isPortableTextTextBlock(block)) {\n continue\n }\n\n if (block._key === endBlockKey && isEmptyTextBlock(block)) {\n break\n }\n\n for (const child of block.children) {\n if (child._key === endChildKey) {\n if (!isPortableTextSpan(child) || endPoint.offset === 0) {\n adjustedEndPoint = previousPotentialEndpoint\n ? {\n path: [\n {_key: previousPotentialEndpoint.blockKey},\n 'children',\n {_key: previousPotentialEndpoint.span._key},\n ],\n offset: previousPotentialEndpoint.span.text.length,\n }\n : undefined\n\n trimEndPoint = true\n break\n }\n }\n\n if (trimStartPoint) {\n const lonelySpan =\n isPortableTextSpan(child) && block.children.length === 1\n\n if (\n (isPortableTextSpan(child) && child.text.length > 0) ||\n lonelySpan\n ) {\n adjustedStartPoint = {\n path: [{_key: block._key}, 'children', {_key: child._key}],\n offset: 0,\n }\n previousPotentialEndpoint = {blockKey: block._key, span: child}\n trimStartPoint = false\n }\n\n continue\n }\n\n if (child._key === startChildKey) {\n if (!isPortableTextSpan(child)) {\n trimStartPoint = true\n continue\n }\n\n if (startPoint.offset === child.text.length) {\n trimStartPoint = true\n previousPotentialEndpoint =\n child.text.length > 0\n ? {blockKey: block._key, span: child}\n : previousPotentialEndpoint\n continue\n }\n }\n\n previousPotentialEndpoint =\n isPortableTextSpan(child) && child.text.length > 0\n ? {blockKey: block._key, span: child}\n : previousPotentialEndpoint\n }\n\n if (block._key === endBlockKey) {\n break\n }\n }\n\n const trimmedSelection = snapshot.context.selection.backward\n ? {\n anchor: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint,\n focus: adjustedStartPoint ?? startPoint,\n backward: true,\n }\n : {\n anchor: adjustedStartPoint ?? startPoint,\n focus: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint,\n }\n\n if (\n isSelectionCollapsed({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: trimmedSelection,\n },\n })\n ) {\n const focusTextBlock = getFocusTextBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: trimmedSelection,\n },\n })\n\n if (focusTextBlock && !isEmptyTextBlock(focusTextBlock.node)) {\n return null\n }\n }\n\n return trimmedSelection\n}\n","import {isPortableTextTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedSpans} from './selector.get-selected-spans'\nimport {isSelectionExpanded} from './selector.is-selection-expanded'\nimport {getFocusSpan, getSelectedBlocks} from './selectors'\n\n/**\n * @public\n */\nexport function isActiveAnnotation(\n annotation: string,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const selectedBlocks = getSelectedBlocks(snapshot)\n const focusSpan = getFocusSpan(snapshot)\n\n const selectedSpans = isSelectionExpanded(snapshot)\n ? getSelectedSpans(snapshot)\n : focusSpan\n ? [focusSpan]\n : []\n\n if (selectedSpans.length === 0) {\n return false\n }\n\n if (\n selectedSpans.some(\n (span) => !span.node.marks || span.node.marks?.length === 0,\n )\n ) {\n return false\n }\n\n const selectionMarkDefs = selectedBlocks.flatMap((block) =>\n isPortableTextTextBlock(block.node) ? (block.node.markDefs ?? []) : [],\n )\n\n return selectedSpans.every((span) => {\n const spanMarkDefs =\n span.node.marks?.flatMap((mark) => {\n const markDef = selectionMarkDefs.find(\n (markDef) => markDef._key === mark,\n )\n\n return markDef ? [markDef._type] : []\n }) ?? []\n\n return spanMarkDefs.includes(annotation)\n })\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedSpans} from './selector.get-selected-spans'\nimport {isSelectionExpanded} from './selector.is-selection-expanded'\n\n/**\n * @public\n */\nexport function isActiveDecorator(decorator: string): EditorSelector<boolean> {\n return (snapshot) => {\n if (isSelectionExpanded(snapshot)) {\n const selectedSpans = getSelectedSpans(snapshot)\n\n return (\n selectedSpans.length > 0 &&\n selectedSpans.every((span) => span.node.marks?.includes(decorator))\n )\n }\n\n return snapshot.context.activeDecorators.includes(decorator)\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getActiveListItem} from './selector.get-active-list-item'\n\n/**\n * @public\n */\nexport function isActiveListItem(listItem: string): EditorSelector<boolean> {\n return (snapshot) => {\n const activeListItem = getActiveListItem(snapshot)\n\n return activeListItem === listItem\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getActiveStyle} from './selector.get-active-style'\n\n/**\n * @public\n */\nexport function isActiveStyle(style: string): EditorSelector<boolean> {\n return (snapshot) => {\n const activeStyle = getActiveStyle(snapshot)\n\n return activeStyle === style\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport * as utils from '../utils'\nimport {getSelectionEndBlock, getSelectionStartBlock} from './selectors'\n\n/**\n * @public\n */\nexport const isSelectingEntireBlocks: EditorSelector<boolean> = (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const startPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.focus\n : snapshot.context.selection.anchor\n const endPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.anchor\n : snapshot.context.selection.focus\n\n const startBlock = getSelectionStartBlock(snapshot)\n const endBlock = getSelectionEndBlock(snapshot)\n\n if (!startBlock || !endBlock) {\n return false\n }\n\n const startBlockStartPoint = utils.getBlockStartPoint(startBlock)\n const endBlockEndPoint = utils.getBlockEndPoint(endBlock)\n\n return (\n utils.isEqualSelectionPoints(startBlockStartPoint, startPoint) &&\n utils.isEqualSelectionPoints(endBlockEndPoint, endPoint)\n )\n}\n"],"names":["getSelectedSpans","snapshot","context","selection","selectedSpans","startPoint","backward","focus","anchor","endPoint","startBlockKey","isKeySegment","path","_key","undefined","endBlockKey","startSpanKey","endSpanKey","startBlockFound","block","value","isPortableTextTextBlock","child","children","isPortableTextSpan","offset","text","length","push","node","getActiveAnnotations","selectedBlocks","getSelectedBlocks","focusSpan","getFocusSpan","isSelectionCollapsed","flatMap","markDefs","filter","markDef","some","span","marks","includes","getActiveListItem","guards","createGuards","selectedTextBlocks","map","isTextBlock","firstTextBlock","at","firstListItem","listItem","every","getActiveStyle","firstStyle","style","getSelectedTextBlocks","startKey","isKeyedSegment","endKey","schema","getTrimmedSelection","getSelectionStartPoint","getSelectionEndPoint","startChildKey","endChildKey","adjustedStartPoint","trimStartPoint","adjustedEndPoint","trimEndPoint","previousPotentialEndpoint","isEmptyTextBlock","blockKey","lonelySpan","trimmedSelection","focusTextBlock","getFocusTextBlock","isActiveAnnotation","annotation","isSelectionExpanded","selectionMarkDefs","mark","find","_type","isActiveDecorator","decorator","activeDecorators","isActiveListItem","isActiveStyle","isSelectingEntireBlocks","startBlock","getSelectionStartBlock","endBlock","getSelectionEndBlock","startBlockStartPoint","utils","endBlockEndPoint","isEqualSelectionPoints"],"mappings":";;AAYO,MAAMA,mBAKRC,CAAa,aAAA;AACZ,MAAA,CAACA,SAASC,QAAQC;AACpB,WAAO,CAAE;AAGLC,QAAAA,gBAGD,CAAA,GAECC,aAAaJ,SAASC,QAAQC,UAAUG,WAC1CL,SAASC,QAAQC,UAAUI,QAC3BN,SAASC,QAAQC,UAAUK,QACzBC,WAAWR,SAASC,QAAQC,UAAUG,WACxCL,SAASC,QAAQC,UAAUK,SAC3BP,SAASC,QAAQC,UAAUI,OAEzBG,gBAAgBC,MAAAA,aAAaN,WAAWO,KAAK,CAAC,CAAC,IACjDP,WAAWO,KAAK,CAAC,EAAEC,OACnBC,QACEC,cAAcJ,mBAAaF,SAASG,KAAK,CAAC,CAAC,IAC7CH,SAASG,KAAK,CAAC,EAAEC,OACjBC;AAEA,MAAA,CAACJ,iBAAiB,CAACK;AACdX,WAAAA;AAGHY,QAAAA,eAAeL,MAAAA,aAAaN,WAAWO,KAAK,CAAC,CAAC,IAChDP,WAAWO,KAAK,CAAC,EAAEC,OACnBC,QACEG,aAAaN,MAAAA,aAAaF,SAASG,KAAK,CAAC,CAAC,IAC5CH,SAASG,KAAK,CAAC,EAAEC,OACjBC;AAEJ,MAAII,kBAAkB;AAEXC,aAAAA,SAASlB,SAASC,QAAQkB;AAC/BD,QAAAA,MAAMN,SAASH,kBACjBQ,kBAAkB,KAGhB,CAACG,CAAAA,8BAAwBF,KAAK,GAIlC;AAAIA,UAAAA,MAAMN,SAASH,eAAe;AAChC,mBAAWY,SAAS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zF,QAAQ;AAE3D;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"selector.is-selecting-entire-blocks.cjs","sources":["../../src/selectors/selector.get-selected-spans.ts","../../src/selectors/selector.get-active-annotations.ts","../../src/selectors/selector.get-active-list-item.ts","../../src/selectors/selector.get-active-style.ts","../../src/selectors/selector.get-selected-text-blocks.ts","../../src/selectors/selector.get-trimmed-selection.ts","../../src/selectors/selector.is-active-annotation.ts","../../src/selectors/selector.is-active-decorator.ts","../../src/selectors/selector.is-active-list-item.ts","../../src/selectors/selector.is-active-style.ts","../../src/selectors/selector.is-selecting-entire-blocks.ts"],"sourcesContent":["import type {KeyedSegment, PortableTextSpan} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isSpan, isTextBlock} from '../internal-utils/parse-blocks'\nimport {isKeyedSegment} from '../utils'\n\n/**\n * @public\n */\nexport const getSelectedSpans: EditorSelector<\n Array<{\n node: PortableTextSpan\n path: [KeyedSegment, 'children', KeyedSegment]\n }>\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedSpans: Array<{\n node: PortableTextSpan\n path: [KeyedSegment, 'children', KeyedSegment]\n }> = []\n\n const startPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.focus\n : snapshot.context.selection.anchor\n const endPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.anchor\n : snapshot.context.selection.focus\n\n const startBlockKey = isKeyedSegment(startPoint.path[0])\n ? startPoint.path[0]._key\n : undefined\n const endBlockKey = isKeyedSegment(endPoint.path[0])\n ? endPoint.path[0]._key\n : undefined\n\n if (!startBlockKey || !endBlockKey) {\n return selectedSpans\n }\n\n const startSpanKey = isKeyedSegment(startPoint.path[2])\n ? startPoint.path[2]._key\n : undefined\n const endSpanKey = isKeyedSegment(endPoint.path[2])\n ? endPoint.path[2]._key\n : undefined\n\n let startBlockFound = false\n\n for (const block of snapshot.context.value) {\n if (block._key === startBlockKey) {\n startBlockFound = true\n }\n\n if (!isTextBlock(snapshot.context, block)) {\n continue\n }\n\n if (block._key === startBlockKey) {\n for (const child of block.children) {\n if (!isSpan(snapshot.context, child)) {\n continue\n }\n\n if (startSpanKey && child._key === startSpanKey) {\n if (startPoint.offset < child.text.length) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n\n if (startSpanKey === endSpanKey) {\n break\n }\n\n continue\n }\n\n if (endSpanKey && child._key === endSpanKey) {\n if (endPoint.offset > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n break\n }\n\n if (selectedSpans.length > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n }\n\n if (startBlockKey === endBlockKey) {\n break\n }\n\n continue\n }\n\n if (block._key === endBlockKey) {\n for (const child of block.children) {\n if (!isSpan(snapshot.context, child)) {\n continue\n }\n\n if (endSpanKey && child._key === endSpanKey) {\n if (endPoint.offset > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n break\n }\n\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n\n break\n }\n\n if (startBlockFound) {\n for (const child of block.children) {\n if (!isSpan(snapshot.context, child)) {\n continue\n }\n\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n }\n }\n\n return selectedSpans\n}\n","import type {PortableTextObject} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport {getSelectedSpans} from './selector.get-selected-spans'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\nimport {getFocusSpan, getSelectedBlocks} from './selectors'\n\n/**\n * @public\n */\nexport const getActiveAnnotations: EditorSelector<Array<PortableTextObject>> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedBlocks = getSelectedBlocks(snapshot)\n const selectedSpans = getSelectedSpans(snapshot)\n const focusSpan = getFocusSpan(snapshot)\n\n if (selectedSpans.length === 0 || !focusSpan) {\n return []\n }\n\n if (selectedSpans.length === 1 && isSelectionCollapsed(snapshot)) {\n if (snapshot.context.selection.focus.offset === 0) {\n return []\n }\n if (\n snapshot.context.selection.focus.offset === focusSpan.node.text.length\n ) {\n return []\n }\n }\n\n const selectionMarkDefs = selectedBlocks.flatMap((block) =>\n isTextBlock(snapshot.context, block.node)\n ? (block.node.markDefs ?? [])\n : [],\n )\n\n return selectionMarkDefs.filter((markDef) =>\n selectedSpans.some((span) => span.node.marks?.includes(markDef._key)),\n )\n}\n","import type {PortableTextListBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport {getSelectedBlocks} from './selectors'\n\n/**\n * @public\n */\nexport const getActiveListItem: EditorSelector<\n PortableTextListBlock['listItem'] | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const selectedBlocks = getSelectedBlocks(snapshot).map((block) => block.node)\n const selectedTextBlocks = selectedBlocks.filter((block) =>\n isTextBlock(snapshot.context, block),\n )\n\n const firstTextBlock = selectedTextBlocks.at(0)\n\n if (!firstTextBlock) {\n return undefined\n }\n\n const firstListItem = firstTextBlock.listItem\n\n if (!firstListItem) {\n return undefined\n }\n\n if (selectedTextBlocks.every((block) => block.listItem === firstListItem)) {\n return firstListItem\n }\n\n return undefined\n}\n","import type {PortableTextTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport {getSelectedBlocks} from './selectors'\n\n/**\n * @public\n */\nexport const getActiveStyle: EditorSelector<PortableTextTextBlock['style']> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const selectedBlocks = getSelectedBlocks(snapshot).map((block) => block.node)\n const selectedTextBlocks = selectedBlocks.filter((block) =>\n isTextBlock(snapshot.context, block),\n )\n\n const firstTextBlock = selectedTextBlocks.at(0)\n\n if (!firstTextBlock) {\n return undefined\n }\n\n const firstStyle = firstTextBlock.style\n\n if (!firstStyle) {\n return undefined\n }\n\n if (selectedTextBlocks.every((block) => block.style === firstStyle)) {\n return firstStyle\n }\n\n return undefined\n}\n","import type {KeyedSegment, PortableTextTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport {isKeyedSegment} from '../utils'\n\n/**\n * @public\n */\nexport const getSelectedTextBlocks: EditorSelector<\n Array<{node: PortableTextTextBlock; path: [KeyedSegment]}>\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedTextBlocks: Array<{\n node: PortableTextTextBlock\n path: [KeyedSegment]\n }> = []\n const startKey = snapshot.context.selection.backward\n ? isKeyedSegment(snapshot.context.selection.focus.path[0])\n ? snapshot.context.selection.focus.path[0]._key\n : undefined\n : isKeyedSegment(snapshot.context.selection.anchor.path[0])\n ? snapshot.context.selection.anchor.path[0]._key\n : undefined\n const endKey = snapshot.context.selection.backward\n ? isKeyedSegment(snapshot.context.selection.anchor.path[0])\n ? snapshot.context.selection.anchor.path[0]._key\n : undefined\n : isKeyedSegment(snapshot.context.selection.focus.path[0])\n ? snapshot.context.selection.focus.path[0]._key\n : undefined\n\n if (!startKey || !endKey) {\n return selectedTextBlocks\n }\n\n for (const block of snapshot.context.value) {\n if (block._key === startKey) {\n if (isTextBlock(snapshot.context, block)) {\n selectedTextBlocks.push({node: block, path: [{_key: block._key}]})\n }\n\n if (startKey === endKey) {\n break\n }\n continue\n }\n\n if (block._key === endKey) {\n if (isTextBlock(snapshot.context, block)) {\n selectedTextBlocks.push({node: block, path: [{_key: block._key}]})\n }\n\n break\n }\n\n if (selectedTextBlocks.length > 0) {\n if (isTextBlock(snapshot.context, block)) {\n selectedTextBlocks.push({node: block, path: [{_key: block._key}]})\n }\n }\n }\n\n return selectedTextBlocks\n}\n","import type {PortableTextSpan} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isSpan, isTextBlock} from '../internal-utils/parse-blocks'\nimport type {EditorSelection, EditorSelectionPoint} from '../types/editor'\nimport {isEmptyTextBlock, isKeyedSegment} from '../utils'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\nimport {getFocusTextBlock} from './selectors'\n\n/**\n * @public\n */\nexport const getTrimmedSelection: EditorSelector<EditorSelection> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return snapshot.context.selection\n }\n\n const startPoint = getSelectionStartPoint(snapshot)\n const endPoint = getSelectionEndPoint(snapshot)\n\n if (!startPoint || !endPoint) {\n return snapshot.context.selection\n }\n\n const startBlockKey = isKeyedSegment(startPoint.path[0])\n ? startPoint.path[0]._key\n : null\n const startChildKey = isKeyedSegment(startPoint.path[2])\n ? startPoint.path[2]._key\n : null\n const endBlockKey = isKeyedSegment(endPoint.path[0])\n ? endPoint.path[0]._key\n : null\n const endChildKey = isKeyedSegment(endPoint.path[2])\n ? endPoint.path[2]._key\n : null\n\n if (!startBlockKey || !endBlockKey) {\n return snapshot.context.selection\n }\n\n let startBlockFound = false\n let adjustedStartPoint: EditorSelectionPoint | undefined\n let trimStartPoint = false\n let adjustedEndPoint: EditorSelectionPoint | undefined\n let trimEndPoint = false\n let previousPotentialEndpoint:\n | {blockKey: string; span: PortableTextSpan}\n | undefined\n\n for (const block of snapshot.context.value) {\n if (block._key === startBlockKey) {\n startBlockFound = true\n\n if (\n isTextBlock(snapshot.context, block) &&\n isEmptyTextBlock(snapshot.context, block)\n ) {\n continue\n }\n }\n\n if (!startBlockFound) {\n continue\n }\n\n if (!isTextBlock(snapshot.context, block)) {\n continue\n }\n\n if (\n block._key === endBlockKey &&\n isEmptyTextBlock(snapshot.context, block)\n ) {\n break\n }\n\n for (const child of block.children) {\n if (child._key === endChildKey) {\n if (!isSpan(snapshot.context, child) || endPoint.offset === 0) {\n adjustedEndPoint = previousPotentialEndpoint\n ? {\n path: [\n {_key: previousPotentialEndpoint.blockKey},\n 'children',\n {_key: previousPotentialEndpoint.span._key},\n ],\n offset: previousPotentialEndpoint.span.text.length,\n }\n : undefined\n\n trimEndPoint = true\n break\n }\n }\n\n if (trimStartPoint) {\n const lonelySpan =\n isSpan(snapshot.context, child) && block.children.length === 1\n\n if (\n (isSpan(snapshot.context, child) && child.text.length > 0) ||\n lonelySpan\n ) {\n adjustedStartPoint = {\n path: [{_key: block._key}, 'children', {_key: child._key}],\n offset: 0,\n }\n previousPotentialEndpoint = {blockKey: block._key, span: child}\n trimStartPoint = false\n }\n\n continue\n }\n\n if (child._key === startChildKey) {\n if (!isSpan(snapshot.context, child)) {\n trimStartPoint = true\n continue\n }\n\n if (startPoint.offset === child.text.length) {\n trimStartPoint = true\n previousPotentialEndpoint =\n child.text.length > 0\n ? {blockKey: block._key, span: child}\n : previousPotentialEndpoint\n continue\n }\n }\n\n previousPotentialEndpoint =\n isSpan(snapshot.context, child) && child.text.length > 0\n ? {blockKey: block._key, span: child}\n : previousPotentialEndpoint\n }\n\n if (block._key === endBlockKey) {\n break\n }\n }\n\n const trimmedSelection = snapshot.context.selection.backward\n ? {\n anchor: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint,\n focus: adjustedStartPoint ?? startPoint,\n backward: true,\n }\n : {\n anchor: adjustedStartPoint ?? startPoint,\n focus: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint,\n }\n\n if (\n isSelectionCollapsed({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: trimmedSelection,\n },\n })\n ) {\n const focusTextBlock = getFocusTextBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: trimmedSelection,\n },\n })\n\n if (\n focusTextBlock &&\n !isEmptyTextBlock(snapshot.context, focusTextBlock.node)\n ) {\n return null\n }\n }\n\n return trimmedSelection\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport {getSelectedSpans} from './selector.get-selected-spans'\nimport {isSelectionExpanded} from './selector.is-selection-expanded'\nimport {getFocusSpan, getSelectedBlocks} from './selectors'\n\n/**\n * @public\n */\nexport function isActiveAnnotation(\n annotation: string,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const selectedBlocks = getSelectedBlocks(snapshot)\n const focusSpan = getFocusSpan(snapshot)\n\n const selectedSpans = isSelectionExpanded(snapshot)\n ? getSelectedSpans(snapshot)\n : focusSpan\n ? [focusSpan]\n : []\n\n if (selectedSpans.length === 0) {\n return false\n }\n\n if (\n selectedSpans.some(\n (span) => !span.node.marks || span.node.marks?.length === 0,\n )\n ) {\n return false\n }\n\n const selectionMarkDefs = selectedBlocks.flatMap((block) =>\n isTextBlock(snapshot.context, block.node)\n ? (block.node.markDefs ?? [])\n : [],\n )\n\n return selectedSpans.every((span) => {\n const spanMarkDefs =\n span.node.marks?.flatMap((mark) => {\n const markDef = selectionMarkDefs.find(\n (markDef) => markDef._key === mark,\n )\n\n return markDef ? [markDef._type] : []\n }) ?? []\n\n return spanMarkDefs.includes(annotation)\n })\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedSpans} from './selector.get-selected-spans'\nimport {isSelectionExpanded} from './selector.is-selection-expanded'\n\n/**\n * @public\n */\nexport function isActiveDecorator(decorator: string): EditorSelector<boolean> {\n return (snapshot) => {\n if (isSelectionExpanded(snapshot)) {\n const selectedSpans = getSelectedSpans(snapshot)\n\n return (\n selectedSpans.length > 0 &&\n selectedSpans.every((span) => span.node.marks?.includes(decorator))\n )\n }\n\n return snapshot.context.activeDecorators.includes(decorator)\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getActiveListItem} from './selector.get-active-list-item'\n\n/**\n * @public\n */\nexport function isActiveListItem(listItem: string): EditorSelector<boolean> {\n return (snapshot) => {\n const activeListItem = getActiveListItem(snapshot)\n\n return activeListItem === listItem\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getActiveStyle} from './selector.get-active-style'\n\n/**\n * @public\n */\nexport function isActiveStyle(style: string): EditorSelector<boolean> {\n return (snapshot) => {\n const activeStyle = getActiveStyle(snapshot)\n\n return activeStyle === style\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport * as utils from '../utils'\nimport {getSelectionEndBlock, getSelectionStartBlock} from './selectors'\n\n/**\n * @public\n */\nexport const isSelectingEntireBlocks: EditorSelector<boolean> = (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const startPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.focus\n : snapshot.context.selection.anchor\n const endPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.anchor\n : snapshot.context.selection.focus\n\n const startBlock = getSelectionStartBlock(snapshot)\n const endBlock = getSelectionEndBlock(snapshot)\n\n if (!startBlock || !endBlock) {\n return false\n }\n\n const startBlockStartPoint = utils.getBlockStartPoint({\n context: snapshot.context,\n block: startBlock,\n })\n const endBlockEndPoint = utils.getBlockEndPoint({\n context: snapshot.context,\n block: endBlock,\n })\n\n return (\n utils.isEqualSelectionPoints(startBlockStartPoint, startPoint) &&\n utils.isEqualSelectionPoints(endBlockEndPoint, endPoint)\n )\n}\n"],"names":["getSelectedSpans","snapshot","context","selection","selectedSpans","startPoint","backward","focus","anchor","endPoint","startBlockKey","isKeyedSegment","path","_key","undefined","endBlockKey","startSpanKey","endSpanKey","startBlockFound","block","value","isTextBlock","child","children","isSpan","offset","text","length","push","node","getActiveAnnotations","selectedBlocks","getSelectedBlocks","focusSpan","getFocusSpan","isSelectionCollapsed","flatMap","markDefs","filter","markDef","some","span","marks","includes","getActiveListItem","selectedTextBlocks","map","firstTextBlock","at","firstListItem","listItem","every","getActiveStyle","firstStyle","style","getSelectedTextBlocks","startKey","endKey","getTrimmedSelection","getSelectionStartPoint","getSelectionEndPoint","startChildKey","endChildKey","adjustedStartPoint","trimStartPoint","adjustedEndPoint","trimEndPoint","previousPotentialEndpoint","isEmptyTextBlock","blockKey","lonelySpan","trimmedSelection","focusTextBlock","getFocusTextBlock","isActiveAnnotation","annotation","isSelectionExpanded","selectionMarkDefs","mark","find","_type","isActiveDecorator","decorator","activeDecorators","isActiveListItem","isActiveStyle","isSelectingEntireBlocks","startBlock","getSelectionStartBlock","endBlock","getSelectionEndBlock","startBlockStartPoint","utils","endBlockEndPoint","isEqualSelectionPoints"],"mappings":";;AAQO,MAAMA,mBAKRC,CAAa,aAAA;AACZ,MAAA,CAACA,SAASC,QAAQC;AACpB,WAAO,CAAE;AAGLC,QAAAA,gBAGD,CAAA,GAECC,aAAaJ,SAASC,QAAQC,UAAUG,WAC1CL,SAASC,QAAQC,UAAUI,QAC3BN,SAASC,QAAQC,UAAUK,QACzBC,WAAWR,SAASC,QAAQC,UAAUG,WACxCL,SAASC,QAAQC,UAAUK,SAC3BP,SAASC,QAAQC,UAAUI,OAEzBG,gBAAgBC,iBAAAA,eAAeN,WAAWO,KAAK,CAAC,CAAC,IACnDP,WAAWO,KAAK,CAAC,EAAEC,OACnBC,QACEC,cAAcJ,gCAAeF,SAASG,KAAK,CAAC,CAAC,IAC/CH,SAASG,KAAK,CAAC,EAAEC,OACjBC;AAEA,MAAA,CAACJ,iBAAiB,CAACK;AACdX,WAAAA;AAGHY,QAAAA,eAAeL,iBAAAA,eAAeN,WAAWO,KAAK,CAAC,CAAC,IAClDP,WAAWO,KAAK,CAAC,EAAEC,OACnBC,QACEG,aAAaN,iBAAAA,eAAeF,SAASG,KAAK,CAAC,CAAC,IAC9CH,SAASG,KAAK,CAAC,EAAEC,OACjBC;AAEJ,MAAII,kBAAkB;AAEXC,aAAAA,SAASlB,SAASC,QAAQkB;AAC/BD,QAAAA,MAAMN,SAASH,kBACjBQ,kBAAkB,KAGhB,EAACG,6BAAYpB,SAASC,SAASiB,KAAK,GAI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,iBAAAA,mBAAyB;AAAA,IACpD1F,SAASD,SAASC;AAAAA,IAClBiB,OAAOoE;AAAAA,EAAAA,CACR,GACKM,mBAAmBD,kCAAuB;AAAA,IAC9C1F,SAASD,SAASC;AAAAA,IAClBiB,OAAOsE;AAAAA,EAAAA,CACR;AAGCG,SAAAA,iBAAAA,uBAA6BD,sBAAsBtF,UAAU,KAC7DuF,iBAAME,uBAAuBD,kBAAkBpF,QAAQ;AAE3D;;;;;;;;;;;;"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
2
|
+
var util_sliceBlocks = require("./util.slice-blocks.cjs");
|
|
3
3
|
function isTextBlock(context, block) {
|
|
4
|
-
return
|
|
4
|
+
return util_sliceBlocks.isTypedObject(block) && block._type === context.schema.block.name;
|
|
5
5
|
}
|
|
6
6
|
function mergeTextBlocks({
|
|
7
7
|
context,
|
|
8
8
|
targetBlock,
|
|
9
9
|
incomingBlock
|
|
10
10
|
}) {
|
|
11
|
-
const parsedIncomingBlock =
|
|
11
|
+
const parsedIncomingBlock = util_sliceBlocks.parseBlock({
|
|
12
12
|
context,
|
|
13
13
|
block: incomingBlock,
|
|
14
14
|
options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.merge-text-blocks.cjs","sources":["../../src/utils/util.is-text-block.ts","../../src/utils/util.merge-text-blocks.ts"],"sourcesContent":["import type {PortableTextTextBlock} from '@sanity/types'\nimport type {EditorContext} from '..'\nimport {isTypedObject} from '../internal-utils/asserters'\n\n/**\n * @public\n */\nexport function isTextBlock(\n context: Pick<EditorContext, 'schema'>,\n block: unknown,\n): block is PortableTextTextBlock {\n return isTypedObject(block) && block._type === context.schema.block.name\n}\n","import type {PortableTextTextBlock} from '@sanity/types'\nimport type {EditorContext} from '..'\nimport {parseBlock} from '../internal-utils/parse-blocks'\nimport {isTextBlock} from './util.is-text-block'\n\n/**\n * @beta\n */\nexport function mergeTextBlocks({\n context,\n targetBlock,\n incomingBlock,\n}: {\n context: Pick<EditorContext, 'keyGenerator' | 'schema'>\n targetBlock: PortableTextTextBlock\n incomingBlock: PortableTextTextBlock\n}) {\n const parsedIncomingBlock = parseBlock({\n context,\n block: incomingBlock,\n options: {refreshKeys: true},\n })\n\n if (!parsedIncomingBlock || !isTextBlock(context, parsedIncomingBlock)) {\n return targetBlock\n }\n\n return {\n ...targetBlock,\n children: [...targetBlock.children, ...parsedIncomingBlock.children],\n markDefs: [\n ...(targetBlock.markDefs ?? []),\n ...(parsedIncomingBlock.markDefs ?? []),\n ],\n }\n}\n"],"names":["isTextBlock","context","block","isTypedObject","_type","schema","name","mergeTextBlocks","targetBlock","incomingBlock","parsedIncomingBlock","parseBlock","options","refreshKeys","children","markDefs"],"mappings":";;AAOgBA,SAAAA,YACdC,SACAC,OACgC;AAChC,SAAOC,
|
|
1
|
+
{"version":3,"file":"util.merge-text-blocks.cjs","sources":["../../src/utils/util.is-text-block.ts","../../src/utils/util.merge-text-blocks.ts"],"sourcesContent":["import type {PortableTextTextBlock} from '@sanity/types'\nimport type {EditorContext} from '..'\nimport {isTypedObject} from '../internal-utils/asserters'\n\n/**\n * @public\n */\nexport function isTextBlock(\n context: Pick<EditorContext, 'schema'>,\n block: unknown,\n): block is PortableTextTextBlock {\n return isTypedObject(block) && block._type === context.schema.block.name\n}\n","import type {PortableTextTextBlock} from '@sanity/types'\nimport type {EditorContext} from '..'\nimport {parseBlock} from '../internal-utils/parse-blocks'\nimport {isTextBlock} from './util.is-text-block'\n\n/**\n * @beta\n */\nexport function mergeTextBlocks({\n context,\n targetBlock,\n incomingBlock,\n}: {\n context: Pick<EditorContext, 'keyGenerator' | 'schema'>\n targetBlock: PortableTextTextBlock\n incomingBlock: PortableTextTextBlock\n}) {\n const parsedIncomingBlock = parseBlock({\n context,\n block: incomingBlock,\n options: {refreshKeys: true},\n })\n\n if (!parsedIncomingBlock || !isTextBlock(context, parsedIncomingBlock)) {\n return targetBlock\n }\n\n return {\n ...targetBlock,\n children: [...targetBlock.children, ...parsedIncomingBlock.children],\n markDefs: [\n ...(targetBlock.markDefs ?? []),\n ...(parsedIncomingBlock.markDefs ?? []),\n ],\n }\n}\n"],"names":["isTextBlock","context","block","isTypedObject","_type","schema","name","mergeTextBlocks","targetBlock","incomingBlock","parsedIncomingBlock","parseBlock","options","refreshKeys","children","markDefs"],"mappings":";;AAOgBA,SAAAA,YACdC,SACAC,OACgC;AAChC,SAAOC,+BAAcD,KAAK,KAAKA,MAAME,UAAUH,QAAQI,OAAOH,MAAMI;AACtE;ACJO,SAASC,gBAAgB;AAAA,EAC9BN;AAAAA,EACAO;AAAAA,EACAC;AAKF,GAAG;AACD,QAAMC,sBAAsBC,iBAAAA,WAAW;AAAA,IACrCV;AAAAA,IACAC,OAAOO;AAAAA,IACPG,SAAS;AAAA,MAACC,aAAa;AAAA,IAAA;AAAA,EAAI,CAC5B;AAED,SAAI,CAACH,uBAAuB,CAACV,YAAYC,SAASS,mBAAmB,IAC5DF,cAGF;AAAA,IACL,GAAGA;AAAAA,IACHM,UAAU,CAAC,GAAGN,YAAYM,UAAU,GAAGJ,oBAAoBI,QAAQ;AAAA,IACnEC,UAAU,CACR,GAAIP,YAAYO,YAAY,CAAA,GAC5B,GAAIL,oBAAoBK,YAAY,CAAG,CAAA;AAAA,EAE3C;AACF;;;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var util_sliceBlocks = require("./util.slice-blocks.cjs")
|
|
2
|
+
var util_sliceBlocks = require("./util.slice-blocks.cjs");
|
|
3
3
|
function blockOffsetToBlockSelectionPoint({
|
|
4
|
-
|
|
4
|
+
context,
|
|
5
5
|
blockOffset
|
|
6
6
|
}) {
|
|
7
7
|
let selectionPoint;
|
|
8
|
-
for (const block of value)
|
|
8
|
+
for (const block of context.value)
|
|
9
9
|
if (block._key === blockOffset.path[0]._key) {
|
|
10
10
|
selectionPoint = {
|
|
11
11
|
path: [{
|
|
@@ -18,30 +18,30 @@ function blockOffsetToBlockSelectionPoint({
|
|
|
18
18
|
return selectionPoint;
|
|
19
19
|
}
|
|
20
20
|
function blockOffsetToSelectionPoint({
|
|
21
|
-
|
|
21
|
+
context,
|
|
22
22
|
blockOffset,
|
|
23
23
|
direction
|
|
24
24
|
}) {
|
|
25
25
|
return util_sliceBlocks.blockOffsetToSpanSelectionPoint({
|
|
26
|
-
|
|
26
|
+
context,
|
|
27
27
|
blockOffset,
|
|
28
28
|
direction
|
|
29
29
|
}) || blockOffsetToBlockSelectionPoint({
|
|
30
|
-
|
|
30
|
+
context,
|
|
31
31
|
blockOffset
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
function blockOffsetsToSelection({
|
|
35
|
-
|
|
35
|
+
context,
|
|
36
36
|
offsets,
|
|
37
37
|
backward
|
|
38
38
|
}) {
|
|
39
39
|
const anchor = blockOffsetToSelectionPoint({
|
|
40
|
-
|
|
40
|
+
context,
|
|
41
41
|
blockOffset: offsets.anchor,
|
|
42
42
|
direction: backward ? "backward" : "forward"
|
|
43
43
|
}), focus = blockOffsetToSelectionPoint({
|
|
44
|
-
|
|
44
|
+
context,
|
|
45
45
|
blockOffset: offsets.focus,
|
|
46
46
|
direction: backward ? "forward" : "backward"
|
|
47
47
|
});
|
|
@@ -52,14 +52,14 @@ function blockOffsetsToSelection({
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
function childSelectionPointToBlockOffset({
|
|
55
|
-
|
|
55
|
+
context,
|
|
56
56
|
selectionPoint
|
|
57
57
|
}) {
|
|
58
58
|
let offset = 0;
|
|
59
59
|
const blockKey = util_sliceBlocks.isKeyedSegment(selectionPoint.path[0]) ? selectionPoint.path[0]._key : void 0, childKey = util_sliceBlocks.isKeyedSegment(selectionPoint.path[2]) ? selectionPoint.path[2]._key : void 0;
|
|
60
60
|
if (!(!blockKey || !childKey)) {
|
|
61
|
-
for (const block of value)
|
|
62
|
-
if (block._key === blockKey &&
|
|
61
|
+
for (const block of context.value)
|
|
62
|
+
if (block._key === blockKey && util_sliceBlocks.isTextBlock(context, block))
|
|
63
63
|
for (const child of block.children) {
|
|
64
64
|
if (child._key === childKey)
|
|
65
65
|
return {
|
|
@@ -68,12 +68,12 @@ function childSelectionPointToBlockOffset({
|
|
|
68
68
|
}],
|
|
69
69
|
offset: offset + selectionPoint.offset
|
|
70
70
|
};
|
|
71
|
-
|
|
71
|
+
util_sliceBlocks.isSpan(context, child) && (offset += child.text.length);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
function selectionPointToBlockOffset({
|
|
76
|
-
|
|
76
|
+
context,
|
|
77
77
|
selectionPoint
|
|
78
78
|
}) {
|
|
79
79
|
return selectionPoint.path.length === 1 && util_sliceBlocks.isKeyedSegment(selectionPoint.path[0]) ? {
|
|
@@ -82,7 +82,7 @@ function selectionPointToBlockOffset({
|
|
|
82
82
|
}],
|
|
83
83
|
offset: selectionPoint.offset
|
|
84
84
|
} : childSelectionPointToBlockOffset({
|
|
85
|
-
|
|
85
|
+
context,
|
|
86
86
|
selectionPoint
|
|
87
87
|
});
|
|
88
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.selection-point-to-block-offset.cjs","sources":["../../src/utils/util.block-offset-to-block-selection-point.ts","../../src/utils/util.block-offset-to-selection-point.ts","../../src/utils/util.block-offsets-to-selection.ts","../../src/utils/util.child-selection-point-to-block-offset.ts","../../src/utils/util.selection-point-to-block-offset.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"util.selection-point-to-block-offset.cjs","sources":["../../src/utils/util.block-offset-to-block-selection-point.ts","../../src/utils/util.block-offset-to-selection-point.ts","../../src/utils/util.block-offsets-to-selection.ts","../../src/utils/util.child-selection-point-to-block-offset.ts","../../src/utils/util.selection-point-to-block-offset.ts"],"sourcesContent":["import type {EditorContext} from '../editor/editor-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\n\n/**\n * @public\n */\nexport function blockOffsetToBlockSelectionPoint({\n context,\n blockOffset,\n}: {\n context: Pick<EditorContext, 'value'>\n blockOffset: BlockOffset\n}): EditorSelectionPoint | undefined {\n let selectionPoint: EditorSelectionPoint | undefined\n\n for (const block of context.value) {\n if (block._key === blockOffset.path[0]._key) {\n selectionPoint = {\n path: [{_key: block._key}],\n offset: blockOffset.offset,\n }\n break\n }\n }\n\n return selectionPoint\n}\n","import type {EditorContext} from '../editor/editor-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {blockOffsetToSpanSelectionPoint} from './util.block-offset'\nimport {blockOffsetToBlockSelectionPoint} from './util.block-offset-to-block-selection-point'\n\n/**\n * @public\n */\nexport function blockOffsetToSelectionPoint({\n context,\n blockOffset,\n direction,\n}: {\n context: Pick<EditorContext, 'schema' | 'value'>\n blockOffset: BlockOffset\n direction: 'forward' | 'backward'\n}): EditorSelectionPoint | undefined {\n const spanSelectionPoint = blockOffsetToSpanSelectionPoint({\n context,\n blockOffset,\n direction,\n })\n\n if (!spanSelectionPoint) {\n return blockOffsetToBlockSelectionPoint({\n context,\n blockOffset,\n })\n }\n\n return spanSelectionPoint\n}\n","import type {EditorSelection} from '..'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport {blockOffsetToSelectionPoint} from './util.block-offset-to-selection-point'\n\n/**\n * @public\n */\nexport function blockOffsetsToSelection({\n context,\n offsets,\n backward,\n}: {\n context: Pick<EditorContext, 'schema' | 'value'>\n offsets: {anchor: BlockOffset; focus: BlockOffset}\n backward?: boolean\n}): EditorSelection {\n const anchor = blockOffsetToSelectionPoint({\n context,\n blockOffset: offsets.anchor,\n direction: backward ? 'backward' : 'forward',\n })\n const focus = blockOffsetToSelectionPoint({\n context,\n blockOffset: offsets.focus,\n direction: backward ? 'forward' : 'backward',\n })\n\n if (!anchor || !focus) {\n return null\n }\n\n return {\n anchor,\n focus,\n backward,\n }\n}\n","import type {EditorContext} from '../editor/editor-snapshot'\nimport {isSpan, isTextBlock} from '../internal-utils/parse-blocks'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {isKeyedSegment} from './util.is-keyed-segment'\n\n/**\n * @public\n */\nexport function childSelectionPointToBlockOffset({\n context,\n selectionPoint,\n}: {\n context: Pick<EditorContext, 'schema' | 'value'>\n selectionPoint: EditorSelectionPoint\n}): BlockOffset | undefined {\n let offset = 0\n\n const blockKey = isKeyedSegment(selectionPoint.path[0])\n ? selectionPoint.path[0]._key\n : undefined\n const childKey = isKeyedSegment(selectionPoint.path[2])\n ? selectionPoint.path[2]._key\n : undefined\n\n if (!blockKey || !childKey) {\n return undefined\n }\n\n for (const block of context.value) {\n if (block._key !== blockKey) {\n continue\n }\n\n if (!isTextBlock(context, block)) {\n continue\n }\n\n for (const child of block.children) {\n if (child._key === childKey) {\n return {\n path: [{_key: block._key}],\n offset: offset + selectionPoint.offset,\n }\n }\n\n if (isSpan(context, child)) {\n offset += child.text.length\n }\n }\n }\n}\n","import type {EditorContext} from '../editor/editor-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {childSelectionPointToBlockOffset} from './util.child-selection-point-to-block-offset'\nimport {isKeyedSegment} from './util.is-keyed-segment'\n\n/**\n * @public\n */\nexport function selectionPointToBlockOffset({\n context,\n selectionPoint,\n}: {\n context: Pick<EditorContext, 'schema' | 'value'>\n selectionPoint: EditorSelectionPoint\n}): BlockOffset | undefined {\n if (\n selectionPoint.path.length === 1 &&\n isKeyedSegment(selectionPoint.path[0])\n ) {\n return {\n path: [{_key: selectionPoint.path[0]._key}],\n offset: selectionPoint.offset,\n }\n }\n\n return childSelectionPointToBlockOffset({\n context,\n selectionPoint,\n })\n}\n"],"names":["blockOffsetToBlockSelectionPoint","context","blockOffset","selectionPoint","block","value","_key","path","offset","blockOffsetToSelectionPoint","direction","blockOffsetToSpanSelectionPoint","blockOffsetsToSelection","offsets","backward","anchor","focus","childSelectionPointToBlockOffset","blockKey","isKeyedSegment","undefined","childKey","isTextBlock","child","children","isSpan","text","length","selectionPointToBlockOffset"],"mappings":";;AAOO,SAASA,iCAAiC;AAAA,EAC/CC;AAAAA,EACAC;AAIF,GAAqC;AAC/BC,MAAAA;AAEJ,aAAWC,SAASH,QAAQI;AAC1B,QAAID,MAAME,SAASJ,YAAYK,KAAK,CAAC,EAAED,MAAM;AAC1B,uBAAA;AAAA,QACfC,MAAM,CAAC;AAAA,UAACD,MAAMF,MAAME;AAAAA,QAAAA,CAAK;AAAA,QACzBE,QAAQN,YAAYM;AAAAA,MACtB;AACA;AAAA,IAAA;AAIGL,SAAAA;AACT;AClBO,SAASM,4BAA4B;AAAA,EAC1CR;AAAAA,EACAC;AAAAA,EACAQ;AAKF,GAAqC;AAOnC,SAN2BC,iBAAAA,gCAAgC;AAAA,IACzDV;AAAAA,IACAC;AAAAA,IACAQ;AAAAA,EAAAA,CACD,KAGQV,iCAAiC;AAAA,IACtCC;AAAAA,IACAC;AAAAA,EAAAA,CACD;AAIL;ACxBO,SAASU,wBAAwB;AAAA,EACtCX;AAAAA,EACAY;AAAAA,EACAC;AAKF,GAAoB;AAClB,QAAMC,SAASN,4BAA4B;AAAA,IACzCR;AAAAA,IACAC,aAAaW,QAAQE;AAAAA,IACrBL,WAAWI,WAAW,aAAa;AAAA,EAAA,CACpC,GACKE,QAAQP,4BAA4B;AAAA,IACxCR;AAAAA,IACAC,aAAaW,QAAQG;AAAAA,IACrBN,WAAWI,WAAW,YAAY;AAAA,EAAA,CACnC;AAED,SAAI,CAACC,UAAU,CAACC,QACP,OAGF;AAAA,IACLD;AAAAA,IACAC;AAAAA,IACAF;AAAAA,EACF;AACF;AC5BO,SAASG,iCAAiC;AAAA,EAC/ChB;AAAAA,EACAE;AAIF,GAA4B;AAC1B,MAAIK,SAAS;AAEPU,QAAAA,WAAWC,iBAAAA,eAAehB,eAAeI,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