@portabletext/editor 1.41.2 → 1.41.4
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 +52 -28
- package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/behavior.markdown.cjs +11 -11
- package/lib/_chunks-cjs/behavior.markdown.cjs.map +1 -1
- package/lib/_chunks-cjs/editor-provider.cjs +24 -21
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs +11 -0
- package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs.map +1 -0
- package/lib/_chunks-cjs/selector.get-text-before.cjs +2 -2
- package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-active-style.cjs +240 -0
- package/lib/_chunks-cjs/selector.is-active-style.cjs.map +1 -0
- package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs +300 -218
- package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js +27 -3
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/behavior.markdown.js +1 -1
- package/lib/_chunks-es/editor-provider.js +5 -2
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/_chunks-es/selector.get-focus-inline-object.js +13 -0
- package/lib/_chunks-es/selector.get-focus-inline-object.js.map +1 -0
- package/lib/_chunks-es/selector.get-text-before.js +1 -1
- package/lib/_chunks-es/selector.is-active-style.js +243 -0
- package/lib/_chunks-es/selector.is-active-style.js.map +1 -0
- package/lib/_chunks-es/selector.is-overlapping-selection.js +298 -217
- package/lib/_chunks-es/selector.is-overlapping-selection.js.map +1 -1
- package/lib/behaviors/index.cjs +9 -9
- package/lib/behaviors/index.cjs.map +1 -1
- package/lib/behaviors/index.js +1 -1
- package/lib/index.cjs +85 -105
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +80 -99
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +6 -6
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.js +1 -1
- package/lib/selectors/index.cjs +37 -43
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.js +5 -10
- package/lib/selectors/index.js.map +1 -1
- package/package.json +1 -1
- package/src/behaviors/behavior.core.dnd.ts +27 -0
- package/src/behaviors/behavior.core.ts +2 -0
- package/src/behaviors/behavior.default.ts +4 -0
- package/src/editor/Editable.tsx +22 -40
- package/src/internal-utils/drag-selection.test.ts +1 -1
- package/src/internal-utils/drag-selection.ts +23 -6
- package/lib/_chunks-cjs/selector.is-at-the-start-of-block.cjs +0 -322
- package/lib/_chunks-cjs/selector.is-at-the-start-of-block.cjs.map +0 -1
- package/lib/_chunks-es/selector.is-at-the-start-of-block.js +0 -324
- package/lib/_chunks-es/selector.is-at-the-start-of-block.js.map +0 -1
- package/src/internal-utils/dragging-on-drag-origin.ts +0 -22
package/src/editor/Editable.tsx
CHANGED
|
@@ -36,7 +36,6 @@ import {
|
|
|
36
36
|
import {getCompoundClientRect} from '../internal-utils/compound-client-rect'
|
|
37
37
|
import {debugWithName} from '../internal-utils/debug'
|
|
38
38
|
import {getDragSelection} from '../internal-utils/drag-selection'
|
|
39
|
-
import {draggingOnDragOrigin} from '../internal-utils/dragging-on-drag-origin'
|
|
40
39
|
import {getEventPosition} from '../internal-utils/event-position'
|
|
41
40
|
import {parseBlocks} from '../internal-utils/parse-blocks'
|
|
42
41
|
import {
|
|
@@ -943,9 +942,6 @@ export const PortableTextEditable = forwardRef<
|
|
|
943
942
|
return
|
|
944
943
|
}
|
|
945
944
|
|
|
946
|
-
// Prevent Slate from handling the event
|
|
947
|
-
event.stopPropagation()
|
|
948
|
-
|
|
949
945
|
const position = getEventPosition({
|
|
950
946
|
schema: editorActor.getSnapshot().context.schema,
|
|
951
947
|
slateEditor,
|
|
@@ -1097,6 +1093,9 @@ export const PortableTextEditable = forwardRef<
|
|
|
1097
1093
|
},
|
|
1098
1094
|
editor: slateEditor,
|
|
1099
1095
|
})
|
|
1096
|
+
|
|
1097
|
+
// Prevent Slate from handling the event
|
|
1098
|
+
return true
|
|
1100
1099
|
},
|
|
1101
1100
|
[onDragStart, editorActor, slateEditor],
|
|
1102
1101
|
)
|
|
@@ -1109,9 +1108,6 @@ export const PortableTextEditable = forwardRef<
|
|
|
1109
1108
|
return
|
|
1110
1109
|
}
|
|
1111
1110
|
|
|
1112
|
-
// Prevent Slate from handling the event
|
|
1113
|
-
event.stopPropagation()
|
|
1114
|
-
|
|
1115
1111
|
const position = getEventPosition({
|
|
1116
1112
|
schema: editorActor.getSnapshot().context.schema,
|
|
1117
1113
|
slateEditor,
|
|
@@ -1132,6 +1128,9 @@ export const PortableTextEditable = forwardRef<
|
|
|
1132
1128
|
},
|
|
1133
1129
|
editor: slateEditor,
|
|
1134
1130
|
})
|
|
1131
|
+
|
|
1132
|
+
// Prevent Slate from handling the event
|
|
1133
|
+
return true
|
|
1135
1134
|
},
|
|
1136
1135
|
[onDrag, editorActor, slateEditor],
|
|
1137
1136
|
)
|
|
@@ -1144,9 +1143,6 @@ export const PortableTextEditable = forwardRef<
|
|
|
1144
1143
|
return
|
|
1145
1144
|
}
|
|
1146
1145
|
|
|
1147
|
-
// Prevent Slate from handling the event
|
|
1148
|
-
event.stopPropagation()
|
|
1149
|
-
|
|
1150
1146
|
editorActor.send({
|
|
1151
1147
|
type: 'behavior event',
|
|
1152
1148
|
behaviorEvent: {
|
|
@@ -1157,6 +1153,9 @@ export const PortableTextEditable = forwardRef<
|
|
|
1157
1153
|
},
|
|
1158
1154
|
editor: slateEditor,
|
|
1159
1155
|
})
|
|
1156
|
+
|
|
1157
|
+
// Prevent Slate from handling the event
|
|
1158
|
+
return true
|
|
1160
1159
|
},
|
|
1161
1160
|
[onDragEnd, editorActor, slateEditor],
|
|
1162
1161
|
)
|
|
@@ -1169,9 +1168,6 @@ export const PortableTextEditable = forwardRef<
|
|
|
1169
1168
|
return
|
|
1170
1169
|
}
|
|
1171
1170
|
|
|
1172
|
-
// Prevent Slate from handling the event
|
|
1173
|
-
event.stopPropagation()
|
|
1174
|
-
|
|
1175
1171
|
const position = getEventPosition({
|
|
1176
1172
|
schema: editorActor.getSnapshot().context.schema,
|
|
1177
1173
|
slateEditor,
|
|
@@ -1193,6 +1189,9 @@ export const PortableTextEditable = forwardRef<
|
|
|
1193
1189
|
},
|
|
1194
1190
|
editor: slateEditor,
|
|
1195
1191
|
})
|
|
1192
|
+
|
|
1193
|
+
// Prevent Slate from handling the event
|
|
1194
|
+
return true
|
|
1196
1195
|
},
|
|
1197
1196
|
[onDragEnter, editorActor, slateEditor],
|
|
1198
1197
|
)
|
|
@@ -1205,9 +1204,6 @@ export const PortableTextEditable = forwardRef<
|
|
|
1205
1204
|
return
|
|
1206
1205
|
}
|
|
1207
1206
|
|
|
1208
|
-
// Prevent Slate from handling the event
|
|
1209
|
-
event.stopPropagation()
|
|
1210
|
-
|
|
1211
1207
|
const position = getEventPosition({
|
|
1212
1208
|
schema: editorActor.getSnapshot().context.schema,
|
|
1213
1209
|
slateEditor,
|
|
@@ -1218,15 +1214,6 @@ export const PortableTextEditable = forwardRef<
|
|
|
1218
1214
|
return
|
|
1219
1215
|
}
|
|
1220
1216
|
|
|
1221
|
-
const snapshot = getEditorSnapshot({
|
|
1222
|
-
editorActorSnapshot: editorActor.getSnapshot(),
|
|
1223
|
-
slateEditorInstance: slateEditor,
|
|
1224
|
-
})
|
|
1225
|
-
|
|
1226
|
-
if (draggingOnDragOrigin({snapshot, position})) {
|
|
1227
|
-
event.preventDefault()
|
|
1228
|
-
}
|
|
1229
|
-
|
|
1230
1217
|
editorActor.send({
|
|
1231
1218
|
type: 'behavior event',
|
|
1232
1219
|
behaviorEvent: {
|
|
@@ -1239,6 +1226,9 @@ export const PortableTextEditable = forwardRef<
|
|
|
1239
1226
|
editor: slateEditor,
|
|
1240
1227
|
nativeEvent: event,
|
|
1241
1228
|
})
|
|
1229
|
+
|
|
1230
|
+
// Prevent Slate from handling the event
|
|
1231
|
+
return true
|
|
1242
1232
|
},
|
|
1243
1233
|
[onDragOver, editorActor, slateEditor],
|
|
1244
1234
|
)
|
|
@@ -1251,9 +1241,6 @@ export const PortableTextEditable = forwardRef<
|
|
|
1251
1241
|
return
|
|
1252
1242
|
}
|
|
1253
1243
|
|
|
1254
|
-
// Prevent Slate from handling the event
|
|
1255
|
-
event.preventDefault()
|
|
1256
|
-
|
|
1257
1244
|
const position = getEventPosition({
|
|
1258
1245
|
schema: editorActor.getSnapshot().context.schema,
|
|
1259
1246
|
slateEditor,
|
|
@@ -1265,15 +1252,6 @@ export const PortableTextEditable = forwardRef<
|
|
|
1265
1252
|
return
|
|
1266
1253
|
}
|
|
1267
1254
|
|
|
1268
|
-
editorActor.send({
|
|
1269
|
-
type: 'behavior event',
|
|
1270
|
-
behaviorEvent: {
|
|
1271
|
-
type: 'select',
|
|
1272
|
-
selection: position.selection,
|
|
1273
|
-
},
|
|
1274
|
-
editor: slateEditor,
|
|
1275
|
-
})
|
|
1276
|
-
|
|
1277
1255
|
editorActor.send({
|
|
1278
1256
|
type: 'behavior event',
|
|
1279
1257
|
behaviorEvent: {
|
|
@@ -1284,7 +1262,11 @@ export const PortableTextEditable = forwardRef<
|
|
|
1284
1262
|
position,
|
|
1285
1263
|
},
|
|
1286
1264
|
editor: slateEditor,
|
|
1265
|
+
nativeEvent: event,
|
|
1287
1266
|
})
|
|
1267
|
+
|
|
1268
|
+
// Prevent Slate from handling the event
|
|
1269
|
+
return true
|
|
1288
1270
|
},
|
|
1289
1271
|
[onDrop, editorActor, slateEditor],
|
|
1290
1272
|
)
|
|
@@ -1297,9 +1279,6 @@ export const PortableTextEditable = forwardRef<
|
|
|
1297
1279
|
return
|
|
1298
1280
|
}
|
|
1299
1281
|
|
|
1300
|
-
// Prevent Slate from handling the event
|
|
1301
|
-
event.stopPropagation()
|
|
1302
|
-
|
|
1303
1282
|
const position = getEventPosition({
|
|
1304
1283
|
schema: editorActor.getSnapshot().context.schema,
|
|
1305
1284
|
slateEditor,
|
|
@@ -1320,6 +1299,9 @@ export const PortableTextEditable = forwardRef<
|
|
|
1320
1299
|
},
|
|
1321
1300
|
editor: slateEditor,
|
|
1322
1301
|
})
|
|
1302
|
+
|
|
1303
|
+
// Prevent Slate from handling the event
|
|
1304
|
+
return true
|
|
1323
1305
|
},
|
|
1324
1306
|
[onDragLeave, editorActor, slateEditor],
|
|
1325
1307
|
)
|
|
@@ -3,6 +3,11 @@ import * as selectors from '../selectors'
|
|
|
3
3
|
import * as utils from '../utils'
|
|
4
4
|
import type {EventPosition} from './event-position'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Given the current editor `snapshot` and an `eventSelection` representing
|
|
8
|
+
* where the drag event origins from, this function calculates the selection
|
|
9
|
+
* in the editor that should be dragged.
|
|
10
|
+
*/
|
|
6
11
|
export function getDragSelection({
|
|
7
12
|
eventSelection,
|
|
8
13
|
snapshot,
|
|
@@ -12,21 +17,33 @@ export function getDragSelection({
|
|
|
12
17
|
}) {
|
|
13
18
|
let dragSelection = eventSelection
|
|
14
19
|
|
|
15
|
-
const
|
|
20
|
+
const draggedInlineObject = selectors.getFocusInlineObject({
|
|
16
21
|
...snapshot,
|
|
17
22
|
context: {
|
|
18
23
|
...snapshot.context,
|
|
19
24
|
selection: eventSelection,
|
|
20
25
|
},
|
|
21
26
|
})
|
|
22
|
-
|
|
27
|
+
|
|
28
|
+
if (draggedInlineObject) {
|
|
29
|
+
return dragSelection
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const draggingCollapsedSelection = selectors.isSelectionCollapsed({
|
|
33
|
+
...snapshot,
|
|
34
|
+
context: {
|
|
35
|
+
...snapshot.context,
|
|
36
|
+
selection: eventSelection,
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
const draggedTextBlock = selectors.getFocusTextBlock({
|
|
23
40
|
...snapshot,
|
|
24
41
|
context: {
|
|
25
42
|
...snapshot.context,
|
|
26
43
|
selection: eventSelection,
|
|
27
44
|
},
|
|
28
45
|
})
|
|
29
|
-
const
|
|
46
|
+
const draggedSpan = selectors.getFocusSpan({
|
|
30
47
|
...snapshot,
|
|
31
48
|
context: {
|
|
32
49
|
...snapshot.context,
|
|
@@ -34,12 +51,12 @@ export function getDragSelection({
|
|
|
34
51
|
},
|
|
35
52
|
})
|
|
36
53
|
|
|
37
|
-
if (
|
|
54
|
+
if (draggingCollapsedSelection && draggedTextBlock && draggedSpan) {
|
|
38
55
|
// Looks like we are dragging an empty span
|
|
39
56
|
// Let's drag the entire block instead
|
|
40
57
|
dragSelection = {
|
|
41
|
-
anchor: utils.getBlockStartPoint(
|
|
42
|
-
focus: utils.getBlockEndPoint(
|
|
58
|
+
anchor: utils.getBlockStartPoint(draggedTextBlock),
|
|
59
|
+
focus: utils.getBlockEndPoint(draggedTextBlock),
|
|
43
60
|
}
|
|
44
61
|
}
|
|
45
62
|
|
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var util_sliceBlocks = require("./util.slice-blocks.cjs"), types = require("@sanity/types");
|
|
3
|
-
function createGuards({
|
|
4
|
-
schema
|
|
5
|
-
}) {
|
|
6
|
-
function isListBlock(block) {
|
|
7
|
-
return types.isPortableTextListBlock(block) && block._type === schema.block.name;
|
|
8
|
-
}
|
|
9
|
-
function isTextBlock(block) {
|
|
10
|
-
return types.isPortableTextTextBlock(block) && block._type === schema.block.name;
|
|
11
|
-
}
|
|
12
|
-
return {
|
|
13
|
-
isListBlock,
|
|
14
|
-
isTextBlock
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
const getFocusBlock = (snapshot) => {
|
|
18
|
-
const key = snapshot.context.selection && types.isKeySegment(snapshot.context.selection.focus.path[0]) ? snapshot.context.selection.focus.path[0]._key : void 0, node = key ? snapshot.context.value.find((block) => block._key === key) : void 0;
|
|
19
|
-
return node && key ? {
|
|
20
|
-
node,
|
|
21
|
-
path: [{
|
|
22
|
-
_key: key
|
|
23
|
-
}]
|
|
24
|
-
} : void 0;
|
|
25
|
-
}, getFocusListBlock = (snapshot) => {
|
|
26
|
-
const guards = createGuards(snapshot.context), focusBlock = getFocusBlock(snapshot);
|
|
27
|
-
return focusBlock && guards.isListBlock(focusBlock.node) ? {
|
|
28
|
-
node: focusBlock.node,
|
|
29
|
-
path: focusBlock.path
|
|
30
|
-
} : void 0;
|
|
31
|
-
}, getFocusTextBlock = (snapshot) => {
|
|
32
|
-
const focusBlock = getFocusBlock(snapshot);
|
|
33
|
-
return focusBlock && types.isPortableTextTextBlock(focusBlock.node) ? {
|
|
34
|
-
node: focusBlock.node,
|
|
35
|
-
path: focusBlock.path
|
|
36
|
-
} : void 0;
|
|
37
|
-
}, getFocusBlockObject = (snapshot) => {
|
|
38
|
-
const focusBlock = getFocusBlock(snapshot);
|
|
39
|
-
return focusBlock && !types.isPortableTextTextBlock(focusBlock.node) ? {
|
|
40
|
-
node: focusBlock.node,
|
|
41
|
-
path: focusBlock.path
|
|
42
|
-
} : void 0;
|
|
43
|
-
}, getFocusChild = (snapshot) => {
|
|
44
|
-
const focusBlock = getFocusTextBlock(snapshot);
|
|
45
|
-
if (!focusBlock)
|
|
46
|
-
return;
|
|
47
|
-
const key = snapshot.context.selection && types.isKeySegment(snapshot.context.selection.focus.path[2]) ? snapshot.context.selection.focus.path[2]._key : void 0, node = key ? focusBlock.node.children.find((span) => span._key === key) : void 0;
|
|
48
|
-
return node && key ? {
|
|
49
|
-
node,
|
|
50
|
-
path: [...focusBlock.path, "children", {
|
|
51
|
-
_key: key
|
|
52
|
-
}]
|
|
53
|
-
} : void 0;
|
|
54
|
-
}, getFocusSpan = (snapshot) => {
|
|
55
|
-
const focusChild = getFocusChild(snapshot);
|
|
56
|
-
return focusChild && types.isPortableTextSpan(focusChild.node) ? {
|
|
57
|
-
node: focusChild.node,
|
|
58
|
-
path: focusChild.path
|
|
59
|
-
} : void 0;
|
|
60
|
-
}, getFirstBlock = (snapshot) => {
|
|
61
|
-
const node = snapshot.context.value[0];
|
|
62
|
-
return node ? {
|
|
63
|
-
node,
|
|
64
|
-
path: [{
|
|
65
|
-
_key: node._key
|
|
66
|
-
}]
|
|
67
|
-
} : void 0;
|
|
68
|
-
}, getLastBlock = (snapshot) => {
|
|
69
|
-
const node = snapshot.context.value[snapshot.context.value.length - 1] ? snapshot.context.value[snapshot.context.value.length - 1] : void 0;
|
|
70
|
-
return node ? {
|
|
71
|
-
node,
|
|
72
|
-
path: [{
|
|
73
|
-
_key: node._key
|
|
74
|
-
}]
|
|
75
|
-
} : void 0;
|
|
76
|
-
}, getSelectedBlocks = (snapshot) => {
|
|
77
|
-
if (!snapshot.context.selection)
|
|
78
|
-
return [];
|
|
79
|
-
const selectedBlocks = [], startKey = snapshot.context.selection.backward ? types.isKeySegment(snapshot.context.selection.focus.path[0]) ? snapshot.context.selection.focus.path[0]._key : void 0 : types.isKeySegment(snapshot.context.selection.anchor.path[0]) ? snapshot.context.selection.anchor.path[0]._key : void 0, endKey = snapshot.context.selection.backward ? types.isKeySegment(snapshot.context.selection.anchor.path[0]) ? snapshot.context.selection.anchor.path[0]._key : void 0 : types.isKeySegment(snapshot.context.selection.focus.path[0]) ? snapshot.context.selection.focus.path[0]._key : void 0;
|
|
80
|
-
if (!startKey || !endKey)
|
|
81
|
-
return selectedBlocks;
|
|
82
|
-
for (const block of snapshot.context.value) {
|
|
83
|
-
if (block._key === startKey) {
|
|
84
|
-
if (selectedBlocks.push({
|
|
85
|
-
node: block,
|
|
86
|
-
path: [{
|
|
87
|
-
_key: block._key
|
|
88
|
-
}]
|
|
89
|
-
}), startKey === endKey)
|
|
90
|
-
break;
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
if (block._key === endKey) {
|
|
94
|
-
selectedBlocks.push({
|
|
95
|
-
node: block,
|
|
96
|
-
path: [{
|
|
97
|
-
_key: block._key
|
|
98
|
-
}]
|
|
99
|
-
});
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
selectedBlocks.length > 0 && selectedBlocks.push({
|
|
103
|
-
node: block,
|
|
104
|
-
path: [{
|
|
105
|
-
_key: block._key
|
|
106
|
-
}]
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
return selectedBlocks;
|
|
110
|
-
}, getSelectionStartBlock = (snapshot) => {
|
|
111
|
-
if (!snapshot.context.selection)
|
|
112
|
-
return;
|
|
113
|
-
const key = snapshot.context.selection.backward ? types.isKeySegment(snapshot.context.selection.focus.path[0]) ? snapshot.context.selection.focus.path[0]._key : void 0 : types.isKeySegment(snapshot.context.selection.anchor.path[0]) ? snapshot.context.selection.anchor.path[0]._key : void 0, node = key ? snapshot.context.value.find((block) => block._key === key) : void 0;
|
|
114
|
-
return node && key ? {
|
|
115
|
-
node,
|
|
116
|
-
path: [{
|
|
117
|
-
_key: key
|
|
118
|
-
}]
|
|
119
|
-
} : void 0;
|
|
120
|
-
}, getSelectionEndBlock = (snapshot) => {
|
|
121
|
-
if (!snapshot.context.selection)
|
|
122
|
-
return;
|
|
123
|
-
const key = snapshot.context.selection.backward ? types.isKeySegment(snapshot.context.selection.anchor.path[0]) ? snapshot.context.selection.anchor.path[0]._key : void 0 : types.isKeySegment(snapshot.context.selection.focus.path[0]) ? snapshot.context.selection.focus.path[0]._key : void 0, node = key ? snapshot.context.value.find((block) => block._key === key) : void 0;
|
|
124
|
-
return node && key ? {
|
|
125
|
-
node,
|
|
126
|
-
path: [{
|
|
127
|
-
_key: key
|
|
128
|
-
}]
|
|
129
|
-
} : void 0;
|
|
130
|
-
}, getPreviousBlock = (snapshot) => {
|
|
131
|
-
let previousBlock;
|
|
132
|
-
const selectionStartBlock = getSelectionStartBlock(snapshot);
|
|
133
|
-
if (!selectionStartBlock)
|
|
134
|
-
return;
|
|
135
|
-
let foundSelectionStartBlock = !1;
|
|
136
|
-
for (const block of snapshot.context.value) {
|
|
137
|
-
if (block._key === selectionStartBlock.node._key) {
|
|
138
|
-
foundSelectionStartBlock = !0;
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
previousBlock = {
|
|
142
|
-
node: block,
|
|
143
|
-
path: [{
|
|
144
|
-
_key: block._key
|
|
145
|
-
}]
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
if (foundSelectionStartBlock && previousBlock)
|
|
149
|
-
return previousBlock;
|
|
150
|
-
}, getNextBlock = (snapshot) => {
|
|
151
|
-
let nextBlock;
|
|
152
|
-
const selectionEndBlock = getSelectionEndBlock(snapshot);
|
|
153
|
-
if (!selectionEndBlock)
|
|
154
|
-
return;
|
|
155
|
-
let foundSelectionEndBlock = !1;
|
|
156
|
-
for (const block of snapshot.context.value) {
|
|
157
|
-
if (block._key === selectionEndBlock.node._key) {
|
|
158
|
-
foundSelectionEndBlock = !0;
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
if (foundSelectionEndBlock) {
|
|
162
|
-
nextBlock = {
|
|
163
|
-
node: block,
|
|
164
|
-
path: [{
|
|
165
|
-
_key: block._key
|
|
166
|
-
}]
|
|
167
|
-
};
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
if (foundSelectionEndBlock && nextBlock)
|
|
172
|
-
return nextBlock;
|
|
173
|
-
}, getSelectionEndPoint = (snapshot) => {
|
|
174
|
-
if (snapshot.context.selection)
|
|
175
|
-
return snapshot.context.selection.backward ? snapshot.context.selection.anchor : snapshot.context.selection.focus;
|
|
176
|
-
}, getSelectionStartPoint = (snapshot) => {
|
|
177
|
-
if (snapshot.context.selection)
|
|
178
|
-
return snapshot.context.selection.backward ? snapshot.context.selection.focus : snapshot.context.selection.anchor;
|
|
179
|
-
}, getNextInlineObject = (snapshot) => {
|
|
180
|
-
const focusTextBlock = getFocusTextBlock(snapshot), selectionEndPoint = getSelectionEndPoint(snapshot), selectionEndPointChildKey = selectionEndPoint && types.isKeySegment(selectionEndPoint.path[2]) ? selectionEndPoint.path[2]._key : void 0;
|
|
181
|
-
if (!focusTextBlock || !selectionEndPointChildKey)
|
|
182
|
-
return;
|
|
183
|
-
let endPointChildFound = !1, inlineObject;
|
|
184
|
-
for (const child of focusTextBlock.node.children) {
|
|
185
|
-
if (child._key === selectionEndPointChildKey) {
|
|
186
|
-
endPointChildFound = !0;
|
|
187
|
-
continue;
|
|
188
|
-
}
|
|
189
|
-
if (!util_sliceBlocks.isSpan(snapshot.context, child) && endPointChildFound) {
|
|
190
|
-
inlineObject = {
|
|
191
|
-
node: child,
|
|
192
|
-
path: [...focusTextBlock.path, "children", {
|
|
193
|
-
_key: child._key
|
|
194
|
-
}]
|
|
195
|
-
};
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return inlineObject;
|
|
200
|
-
}, getPreviousInlineObject = (snapshot) => {
|
|
201
|
-
const focusTextBlock = getFocusTextBlock(snapshot), selectionStartPoint = getSelectionStartPoint(snapshot), selectionStartPointChildKey = selectionStartPoint && types.isKeySegment(selectionStartPoint.path[2]) ? selectionStartPoint.path[2]._key : void 0;
|
|
202
|
-
if (!focusTextBlock || !selectionStartPointChildKey)
|
|
203
|
-
return;
|
|
204
|
-
let inlineObject;
|
|
205
|
-
for (const child of focusTextBlock.node.children) {
|
|
206
|
-
if (child._key === selectionStartPointChildKey)
|
|
207
|
-
break;
|
|
208
|
-
util_sliceBlocks.isSpan(snapshot.context, child) || (inlineObject = {
|
|
209
|
-
node: child,
|
|
210
|
-
path: [...focusTextBlock.path, "children", {
|
|
211
|
-
_key: child._key
|
|
212
|
-
}]
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
return inlineObject;
|
|
216
|
-
}, getSelectedSlice = (snapshot) => util_sliceBlocks.sliceBlocks({
|
|
217
|
-
blocks: snapshot.context.value,
|
|
218
|
-
selection: snapshot.context.selection
|
|
219
|
-
}), getSelectionText = (snapshot) => getSelectedSlice(snapshot).reduce((text, block) => types.isPortableTextTextBlock(block) ? text + block.children.reduce((text2, child) => types.isPortableTextSpan(child) ? text2 + child.text : text2, "") : text, ""), isSelectionCollapsed = (snapshot) => snapshot.context.selection ? JSON.stringify(snapshot.context.selection.anchor.path) === JSON.stringify(snapshot.context.selection.focus.path) && snapshot.context.selection?.anchor.offset === snapshot.context.selection?.focus.offset : !1, isSelectionExpanded = (snapshot) => !isSelectionCollapsed(snapshot), getCaretWordSelection = (snapshot) => {
|
|
220
|
-
if (!snapshot.context.selection || !isSelectionCollapsed(snapshot))
|
|
221
|
-
return null;
|
|
222
|
-
const focusTextBlock = getFocusTextBlock(snapshot), selectionStartPoint = getSelectionStartPoint(snapshot), selectionStartOffset = selectionStartPoint ? util_sliceBlocks.spanSelectionPointToBlockOffset({
|
|
223
|
-
value: snapshot.context.value,
|
|
224
|
-
selectionPoint: selectionStartPoint
|
|
225
|
-
}) : void 0;
|
|
226
|
-
if (!focusTextBlock || !selectionStartPoint || !selectionStartOffset)
|
|
227
|
-
return null;
|
|
228
|
-
const previousInlineObject = getPreviousInlineObject(snapshot), blockStartPoint = util_sliceBlocks.getBlockStartPoint(focusTextBlock), textDirectlyBefore = getSelectionText({
|
|
229
|
-
context: {
|
|
230
|
-
...snapshot.context,
|
|
231
|
-
selection: {
|
|
232
|
-
anchor: previousInlineObject ? {
|
|
233
|
-
path: previousInlineObject.path,
|
|
234
|
-
offset: 0
|
|
235
|
-
} : blockStartPoint,
|
|
236
|
-
focus: selectionStartPoint
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}).split(/\s+/).at(-1), nextInlineObject = getNextInlineObject(snapshot), blockEndPoint = util_sliceBlocks.getBlockEndPoint(focusTextBlock), textDirectlyAfter = getSelectionText({
|
|
240
|
-
context: {
|
|
241
|
-
...snapshot.context,
|
|
242
|
-
selection: {
|
|
243
|
-
anchor: selectionStartPoint,
|
|
244
|
-
focus: nextInlineObject ? {
|
|
245
|
-
path: nextInlineObject.path,
|
|
246
|
-
offset: 0
|
|
247
|
-
} : blockEndPoint
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}).split(/\s+/).at(0);
|
|
251
|
-
if ((textDirectlyBefore === void 0 || textDirectlyBefore === "") && (textDirectlyAfter === void 0 || textDirectlyAfter === ""))
|
|
252
|
-
return null;
|
|
253
|
-
const caretWordStartOffset = textDirectlyBefore ? {
|
|
254
|
-
...selectionStartOffset,
|
|
255
|
-
offset: selectionStartOffset.offset - textDirectlyBefore.length
|
|
256
|
-
} : selectionStartOffset, caretWordEndOffset = textDirectlyAfter ? {
|
|
257
|
-
...selectionStartOffset,
|
|
258
|
-
offset: selectionStartOffset.offset + textDirectlyAfter.length
|
|
259
|
-
} : selectionStartOffset, caretWordStartSelectionPoint = util_sliceBlocks.blockOffsetToSpanSelectionPoint({
|
|
260
|
-
value: snapshot.context.value,
|
|
261
|
-
blockOffset: caretWordStartOffset,
|
|
262
|
-
direction: "backward"
|
|
263
|
-
}), caretWordEndSelectionPoint = util_sliceBlocks.blockOffsetToSpanSelectionPoint({
|
|
264
|
-
value: snapshot.context.value,
|
|
265
|
-
blockOffset: caretWordEndOffset,
|
|
266
|
-
direction: "forward"
|
|
267
|
-
});
|
|
268
|
-
if (!caretWordStartSelectionPoint || !caretWordEndSelectionPoint)
|
|
269
|
-
return null;
|
|
270
|
-
const caretWordSelection = {
|
|
271
|
-
anchor: caretWordStartSelectionPoint,
|
|
272
|
-
focus: caretWordEndSelectionPoint
|
|
273
|
-
};
|
|
274
|
-
return isSelectionExpanded({
|
|
275
|
-
context: {
|
|
276
|
-
...snapshot.context,
|
|
277
|
-
selection: caretWordSelection
|
|
278
|
-
}
|
|
279
|
-
}) ? caretWordSelection : null;
|
|
280
|
-
};
|
|
281
|
-
function isAtTheEndOfBlock(block) {
|
|
282
|
-
return (snapshot) => {
|
|
283
|
-
if (!snapshot.context.selection || !isSelectionCollapsed(snapshot))
|
|
284
|
-
return !1;
|
|
285
|
-
const blockEndPoint = util_sliceBlocks.getBlockEndPoint(block);
|
|
286
|
-
return util_sliceBlocks.isEqualSelectionPoints(snapshot.context.selection.focus, blockEndPoint);
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
function isAtTheStartOfBlock(block) {
|
|
290
|
-
return (snapshot) => {
|
|
291
|
-
if (!snapshot.context.selection || !isSelectionCollapsed(snapshot))
|
|
292
|
-
return !1;
|
|
293
|
-
const blockStartPoint = util_sliceBlocks.getBlockStartPoint(block);
|
|
294
|
-
return util_sliceBlocks.isEqualSelectionPoints(snapshot.context.selection.focus, blockStartPoint);
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
exports.createGuards = createGuards;
|
|
298
|
-
exports.getCaretWordSelection = getCaretWordSelection;
|
|
299
|
-
exports.getFirstBlock = getFirstBlock;
|
|
300
|
-
exports.getFocusBlock = getFocusBlock;
|
|
301
|
-
exports.getFocusBlockObject = getFocusBlockObject;
|
|
302
|
-
exports.getFocusChild = getFocusChild;
|
|
303
|
-
exports.getFocusListBlock = getFocusListBlock;
|
|
304
|
-
exports.getFocusSpan = getFocusSpan;
|
|
305
|
-
exports.getFocusTextBlock = getFocusTextBlock;
|
|
306
|
-
exports.getLastBlock = getLastBlock;
|
|
307
|
-
exports.getNextBlock = getNextBlock;
|
|
308
|
-
exports.getNextInlineObject = getNextInlineObject;
|
|
309
|
-
exports.getPreviousBlock = getPreviousBlock;
|
|
310
|
-
exports.getPreviousInlineObject = getPreviousInlineObject;
|
|
311
|
-
exports.getSelectedBlocks = getSelectedBlocks;
|
|
312
|
-
exports.getSelectedSlice = getSelectedSlice;
|
|
313
|
-
exports.getSelectionEndBlock = getSelectionEndBlock;
|
|
314
|
-
exports.getSelectionEndPoint = getSelectionEndPoint;
|
|
315
|
-
exports.getSelectionStartBlock = getSelectionStartBlock;
|
|
316
|
-
exports.getSelectionStartPoint = getSelectionStartPoint;
|
|
317
|
-
exports.getSelectionText = getSelectionText;
|
|
318
|
-
exports.isAtTheEndOfBlock = isAtTheEndOfBlock;
|
|
319
|
-
exports.isAtTheStartOfBlock = isAtTheStartOfBlock;
|
|
320
|
-
exports.isSelectionCollapsed = isSelectionCollapsed;
|
|
321
|
-
exports.isSelectionExpanded = isSelectionExpanded;
|
|
322
|
-
//# sourceMappingURL=selector.is-at-the-start-of-block.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selector.is-at-the-start-of-block.cjs","sources":["../../src/behavior-actions/behavior.guards.ts","../../src/selectors/selectors.ts","../../src/selectors/selector.get-selection-end-point.ts","../../src/selectors/selector.get-selection-start-point.ts","../../src/selectors/selector.get-next-inline-object.ts","../../src/selectors/selector.get-previous-inline-object.ts","../../src/selectors/selector.get-selected-slice.ts","../../src/selectors/selector.get-selection-text.ts","../../src/selectors/selector.is-selection-collapsed.ts","../../src/selectors/selector.is-selection-expanded.ts","../../src/selectors/selector.get-caret-word-selection.ts","../../src/selectors/selector.is-at-the-end-of-block.ts","../../src/selectors/selector.is-at-the-start-of-block.ts"],"sourcesContent":["import {\n isPortableTextListBlock,\n isPortableTextTextBlock,\n type PortableTextListBlock,\n type PortableTextTextBlock,\n} from '@sanity/types'\nimport type {EditorSchema} from '../editor/define-schema'\n\n/**\n * @alpha\n */\nexport type BehaviorGuards = ReturnType<typeof createGuards>\n\nexport function createGuards({schema}: {schema: EditorSchema}) {\n function isListBlock(block: unknown): block is PortableTextListBlock {\n return isPortableTextListBlock(block) && block._type === schema.block.name\n }\n\n function isTextBlock(block: unknown): block is PortableTextTextBlock {\n return isPortableTextTextBlock(block) && block._type === schema.block.name\n }\n\n return {isListBlock, isTextBlock}\n}\n","import {\n isKeySegment,\n isPortableTextSpan,\n isPortableTextTextBlock,\n type KeyedSegment,\n type PortableTextBlock,\n type PortableTextListBlock,\n type PortableTextObject,\n type PortableTextSpan,\n type PortableTextTextBlock,\n} from '@sanity/types'\nimport {createGuards} from '../behavior-actions/behavior.guards'\nimport type {EditorSelector} from '../editor/editor-selector'\n\n/**\n * @public\n */\nexport const getFocusBlock: EditorSelector<\n {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n> = (snapshot) => {\n const key = snapshot.context.selection\n ? isKeySegment(snapshot.context.selection.focus.path[0])\n ? snapshot.context.selection.focus.path[0]._key\n : undefined\n : undefined\n\n const node = key\n ? snapshot.context.value.find((block) => block._key === key)\n : undefined\n\n return node && key ? {node, path: [{_key: key}]} : undefined\n}\n\n/**\n * @public\n */\nexport const getFocusListBlock: EditorSelector<\n {node: PortableTextListBlock; path: [KeyedSegment]} | undefined\n> = (snapshot) => {\n const guards = createGuards(snapshot.context)\n const focusBlock = getFocusBlock(snapshot)\n\n return focusBlock && guards.isListBlock(focusBlock.node)\n ? {node: focusBlock.node, path: focusBlock.path}\n : undefined\n}\n\n/**\n * @public\n */\nexport const getFocusTextBlock: EditorSelector<\n {node: PortableTextTextBlock; path: [KeyedSegment]} | undefined\n> = (snapshot) => {\n const focusBlock = getFocusBlock(snapshot)\n\n return focusBlock && isPortableTextTextBlock(focusBlock.node)\n ? {node: focusBlock.node, path: focusBlock.path}\n : undefined\n}\n\n/**\n * @public\n */\nexport const getFocusBlockObject: EditorSelector<\n {node: PortableTextObject; path: [KeyedSegment]} | undefined\n> = (snapshot) => {\n const focusBlock = getFocusBlock(snapshot)\n\n return focusBlock && !isPortableTextTextBlock(focusBlock.node)\n ? {node: focusBlock.node, path: focusBlock.path}\n : undefined\n}\n\n/**\n * @public\n */\nexport const getFocusChild: EditorSelector<\n | {\n node: PortableTextObject | PortableTextSpan\n path: [KeyedSegment, 'children', KeyedSegment]\n }\n | undefined\n> = (snapshot) => {\n const focusBlock = getFocusTextBlock(snapshot)\n\n if (!focusBlock) {\n return undefined\n }\n\n const key = snapshot.context.selection\n ? isKeySegment(snapshot.context.selection.focus.path[2])\n ? snapshot.context.selection.focus.path[2]._key\n : undefined\n : undefined\n\n const node = key\n ? focusBlock.node.children.find((span) => span._key === key)\n : undefined\n\n return node && key\n ? {node, path: [...focusBlock.path, 'children', {_key: key}]}\n : undefined\n}\n\n/**\n * @public\n */\nexport const getFocusSpan: EditorSelector<\n | {node: PortableTextSpan; path: [KeyedSegment, 'children', KeyedSegment]}\n | undefined\n> = (snapshot) => {\n const focusChild = getFocusChild(snapshot)\n\n return focusChild && isPortableTextSpan(focusChild.node)\n ? {node: focusChild.node, path: focusChild.path}\n : undefined\n}\n\n/**\n * @public\n */\nexport const getFirstBlock: EditorSelector<\n {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n> = (snapshot) => {\n const node = snapshot.context.value[0]\n\n return node ? {node, path: [{_key: node._key}]} : undefined\n}\n\n/**\n * @public\n */\nexport const getLastBlock: EditorSelector<\n {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n> = (snapshot) => {\n const node = snapshot.context.value[snapshot.context.value.length - 1]\n ? snapshot.context.value[snapshot.context.value.length - 1]\n : undefined\n\n return node ? {node, path: [{_key: node._key}]} : undefined\n}\n\n/**\n * @public\n */\nexport const getSelectedBlocks: EditorSelector<\n Array<{node: PortableTextBlock; path: [KeyedSegment]}>\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedBlocks: Array<{node: PortableTextBlock; path: [KeyedSegment]}> =\n []\n const startKey = snapshot.context.selection.backward\n ? isKeySegment(snapshot.context.selection.focus.path[0])\n ? snapshot.context.selection.focus.path[0]._key\n : undefined\n : isKeySegment(snapshot.context.selection.anchor.path[0])\n ? snapshot.context.selection.anchor.path[0]._key\n : undefined\n const endKey = snapshot.context.selection.backward\n ? isKeySegment(snapshot.context.selection.anchor.path[0])\n ? snapshot.context.selection.anchor.path[0]._key\n : undefined\n : isKeySegment(snapshot.context.selection.focus.path[0])\n ? snapshot.context.selection.focus.path[0]._key\n : undefined\n\n if (!startKey || !endKey) {\n return selectedBlocks\n }\n\n for (const block of snapshot.context.value) {\n if (block._key === startKey) {\n selectedBlocks.push({node: block, path: [{_key: block._key}]})\n\n if (startKey === endKey) {\n break\n }\n continue\n }\n\n if (block._key === endKey) {\n selectedBlocks.push({node: block, path: [{_key: block._key}]})\n break\n }\n\n if (selectedBlocks.length > 0) {\n selectedBlocks.push({node: block, path: [{_key: block._key}]})\n }\n }\n\n return selectedBlocks\n}\n\n/**\n * @public\n */\nexport const getSelectionStartBlock: EditorSelector<\n | {\n node: PortableTextBlock\n path: [KeyedSegment]\n }\n | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const key = snapshot.context.selection.backward\n ? isKeySegment(snapshot.context.selection.focus.path[0])\n ? snapshot.context.selection.focus.path[0]._key\n : undefined\n : isKeySegment(snapshot.context.selection.anchor.path[0])\n ? snapshot.context.selection.anchor.path[0]._key\n : undefined\n\n const node = key\n ? snapshot.context.value.find((block) => block._key === key)\n : undefined\n\n return node && key ? {node, path: [{_key: key}]} : undefined\n}\n\n/**\n * @public\n */\nexport const getSelectionEndBlock: EditorSelector<\n | {\n node: PortableTextBlock\n path: [KeyedSegment]\n }\n | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const key = snapshot.context.selection.backward\n ? isKeySegment(snapshot.context.selection.anchor.path[0])\n ? snapshot.context.selection.anchor.path[0]._key\n : undefined\n : isKeySegment(snapshot.context.selection.focus.path[0])\n ? snapshot.context.selection.focus.path[0]._key\n : undefined\n\n const node = key\n ? snapshot.context.value.find((block) => block._key === key)\n : undefined\n\n return node && key ? {node, path: [{_key: key}]} : undefined\n}\n\n/**\n * @public\n */\nexport const getPreviousBlock: EditorSelector<\n {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n> = (snapshot) => {\n let previousBlock: {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n const selectionStartBlock = getSelectionStartBlock(snapshot)\n\n if (!selectionStartBlock) {\n return undefined\n }\n\n let foundSelectionStartBlock = false\n\n for (const block of snapshot.context.value) {\n if (block._key === selectionStartBlock.node._key) {\n foundSelectionStartBlock = true\n break\n }\n\n previousBlock = {node: block, path: [{_key: block._key}]}\n }\n\n if (foundSelectionStartBlock && previousBlock) {\n return previousBlock\n }\n\n return undefined\n}\n\n/**\n * @public\n */\nexport const getNextBlock: EditorSelector<\n {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n> = (snapshot) => {\n let nextBlock: {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n const selectionEndBlock = getSelectionEndBlock(snapshot)\n\n if (!selectionEndBlock) {\n return undefined\n }\n\n let foundSelectionEndBlock = false\n\n for (const block of snapshot.context.value) {\n if (block._key === selectionEndBlock.node._key) {\n foundSelectionEndBlock = true\n continue\n }\n\n if (foundSelectionEndBlock) {\n nextBlock = {node: block, path: [{_key: block._key}]}\n break\n }\n }\n\n if (foundSelectionEndBlock && nextBlock) {\n return nextBlock\n }\n\n return undefined\n}\n","import type {EditorSelectionPoint} from '..'\nimport type {EditorSelector} from '../editor/editor-selector'\n\n/**\n * @public\n */\nexport const getSelectionEndPoint: EditorSelector<\n EditorSelectionPoint | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n return snapshot.context.selection.backward\n ? snapshot.context.selection.anchor\n : snapshot.context.selection.focus\n}\n","import type {EditorSelectionPoint} from '..'\nimport type {EditorSelector} from '../editor/editor-selector'\n\n/**\n * @public\n */\nexport const getSelectionStartPoint: EditorSelector<\n EditorSelectionPoint | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n return snapshot.context.selection.backward\n ? snapshot.context.selection.focus\n : snapshot.context.selection.anchor\n}\n","import {\n isKeySegment,\n type KeyedSegment,\n type PortableTextObject,\n} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isSpan} from '../utils'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\nimport {getFocusTextBlock} from './selectors'\n\n/**\n * @public\n */\nexport const getNextInlineObject: EditorSelector<\n | {\n node: PortableTextObject\n path: [KeyedSegment, 'children', KeyedSegment]\n }\n | undefined\n> = (snapshot) => {\n const focusTextBlock = getFocusTextBlock(snapshot)\n const selectionEndPoint = getSelectionEndPoint(snapshot)\n const selectionEndPointChildKey =\n selectionEndPoint && isKeySegment(selectionEndPoint.path[2])\n ? selectionEndPoint.path[2]._key\n : undefined\n\n if (!focusTextBlock || !selectionEndPointChildKey) {\n return undefined\n }\n\n let endPointChildFound = false\n let inlineObject:\n | {\n node: PortableTextObject\n path: [KeyedSegment, 'children', KeyedSegment]\n }\n | undefined\n\n for (const child of focusTextBlock.node.children) {\n if (child._key === selectionEndPointChildKey) {\n endPointChildFound = true\n continue\n }\n\n if (!isSpan(snapshot.context, child) && endPointChildFound) {\n inlineObject = {\n node: child,\n path: [...focusTextBlock.path, 'children', {_key: child._key}],\n }\n break\n }\n }\n\n return inlineObject\n}\n","import {\n isKeySegment,\n type KeyedSegment,\n type PortableTextObject,\n} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isSpan} from '../utils'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\nimport {getFocusTextBlock} from './selectors'\n\n/**\n * @public\n */\nexport const getPreviousInlineObject: EditorSelector<\n | {\n node: PortableTextObject\n path: [KeyedSegment, 'children', KeyedSegment]\n }\n | undefined\n> = (snapshot) => {\n const focusTextBlock = getFocusTextBlock(snapshot)\n const selectionStartPoint = getSelectionStartPoint(snapshot)\n const selectionStartPointChildKey =\n selectionStartPoint && isKeySegment(selectionStartPoint.path[2])\n ? selectionStartPoint.path[2]._key\n : undefined\n\n if (!focusTextBlock || !selectionStartPointChildKey) {\n return undefined\n }\n\n let inlineObject:\n | {\n node: PortableTextObject\n path: [KeyedSegment, 'children', KeyedSegment]\n }\n | undefined\n\n for (const child of focusTextBlock.node.children) {\n if (child._key === selectionStartPointChildKey) {\n break\n }\n\n if (!isSpan(snapshot.context, child)) {\n inlineObject = {\n node: child,\n path: [...focusTextBlock.path, 'children', {_key: child._key}],\n }\n }\n }\n\n return inlineObject\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {sliceBlocks} from '../utils'\n\n/**\n * @public\n */\nexport const getSelectedSlice: EditorSelector<Array<PortableTextBlock>> = (\n snapshot,\n) => {\n return sliceBlocks({\n blocks: snapshot.context.value,\n selection: snapshot.context.selection,\n })\n}\n","import {isPortableTextSpan, isPortableTextTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedSlice} from './selector.get-selected-slice'\n\n/**\n * @public\n */\nexport const getSelectionText: EditorSelector<string> = (snapshot) => {\n const selectedSlice = getSelectedSlice(snapshot)\n\n return selectedSlice.reduce((text, block) => {\n if (!isPortableTextTextBlock(block)) {\n return text\n }\n\n return (\n text +\n block.children.reduce((text, child) => {\n if (isPortableTextSpan(child)) {\n return text + child.text\n }\n\n return text\n }, '')\n )\n }, '')\n}\n","import type {EditorSelector} from '../editor/editor-selector'\n\n/**\n * @public\n */\nexport const isSelectionCollapsed: EditorSelector<boolean> = (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n return (\n JSON.stringify(snapshot.context.selection.anchor.path) ===\n JSON.stringify(snapshot.context.selection.focus.path) &&\n snapshot.context.selection?.anchor.offset ===\n snapshot.context.selection?.focus.offset\n )\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\n\n/**\n * @public\n */\nexport const isSelectionExpanded: EditorSelector<boolean> = (snapshot) => {\n return !isSelectionCollapsed(snapshot)\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelection} from '../types/editor'\nimport {\n blockOffsetToSpanSelectionPoint,\n getBlockEndPoint,\n getBlockStartPoint,\n spanSelectionPointToBlockOffset,\n} from '../utils'\nimport {getNextInlineObject} from './selector.get-next-inline-object'\nimport {getPreviousInlineObject} from './selector.get-previous-inline-object'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\nimport {getSelectionText} from './selector.get-selection-text'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\nimport {isSelectionExpanded} from './selector.is-selection-expanded'\nimport {getFocusTextBlock} from './selectors'\n\n/**\n * @public\n * Returns the selection of the of the word the caret is placed in.\n * Note: Only returns a word selection if the current selection is collapsed\n */\nexport const getCaretWordSelection: EditorSelector<EditorSelection> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return null\n }\n\n if (!isSelectionCollapsed(snapshot)) {\n return null\n }\n\n const focusTextBlock = getFocusTextBlock(snapshot)\n const selectionStartPoint = getSelectionStartPoint(snapshot)\n const selectionStartOffset = selectionStartPoint\n ? spanSelectionPointToBlockOffset({\n value: snapshot.context.value,\n selectionPoint: selectionStartPoint,\n })\n : undefined\n\n if (!focusTextBlock || !selectionStartPoint || !selectionStartOffset) {\n return null\n }\n\n const previousInlineObject = getPreviousInlineObject(snapshot)\n const blockStartPoint = getBlockStartPoint(focusTextBlock)\n const textBefore = getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: previousInlineObject\n ? {path: previousInlineObject.path, offset: 0}\n : blockStartPoint,\n focus: selectionStartPoint,\n },\n },\n })\n const textDirectlyBefore = textBefore.split(/\\s+/).at(-1)\n\n const nextInlineObject = getNextInlineObject(snapshot)\n const blockEndPoint = getBlockEndPoint(focusTextBlock)\n const textAfter = getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: selectionStartPoint,\n focus: nextInlineObject\n ? {path: nextInlineObject.path, offset: 0}\n : blockEndPoint,\n },\n },\n })\n const textDirectlyAfter = textAfter.split(/\\s+/).at(0)\n\n if (\n (textDirectlyBefore === undefined || textDirectlyBefore === '') &&\n (textDirectlyAfter === undefined || textDirectlyAfter === '')\n ) {\n return null\n }\n\n const caretWordStartOffset: BlockOffset = textDirectlyBefore\n ? {\n ...selectionStartOffset,\n offset: selectionStartOffset.offset - textDirectlyBefore.length,\n }\n : selectionStartOffset\n const caretWordEndOffset: BlockOffset = textDirectlyAfter\n ? {\n ...selectionStartOffset,\n offset: selectionStartOffset.offset + textDirectlyAfter.length,\n }\n : selectionStartOffset\n\n const caretWordStartSelectionPoint = blockOffsetToSpanSelectionPoint({\n value: snapshot.context.value,\n blockOffset: caretWordStartOffset,\n direction: 'backward',\n })\n const caretWordEndSelectionPoint = blockOffsetToSpanSelectionPoint({\n value: snapshot.context.value,\n blockOffset: caretWordEndOffset,\n direction: 'forward',\n })\n\n if (!caretWordStartSelectionPoint || !caretWordEndSelectionPoint) {\n return null\n }\n\n const caretWordSelection = {\n anchor: caretWordStartSelectionPoint,\n focus: caretWordEndSelectionPoint,\n }\n\n return isSelectionExpanded({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: caretWordSelection,\n },\n })\n ? caretWordSelection\n : null\n}\n","import type {KeyedSegment, PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport * as utils from '../utils'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\n\n/**\n * @public\n */\nexport function isAtTheEndOfBlock(block: {\n node: PortableTextBlock\n path: [KeyedSegment]\n}): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection || !isSelectionCollapsed(snapshot)) {\n return false\n }\n\n const blockEndPoint = utils.getBlockEndPoint(block)\n\n return utils.isEqualSelectionPoints(\n snapshot.context.selection.focus,\n blockEndPoint,\n )\n }\n}\n","import type {KeyedSegment, PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport * as utils from '../utils'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\n\n/**\n * @public\n */\nexport function isAtTheStartOfBlock(block: {\n node: PortableTextBlock\n path: [KeyedSegment]\n}): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection || !isSelectionCollapsed(snapshot)) {\n return false\n }\n\n const blockStartPoint = utils.getBlockStartPoint(block)\n\n return utils.isEqualSelectionPoints(\n snapshot.context.selection.focus,\n blockStartPoint,\n )\n }\n}\n"],"names":["createGuards","schema","isListBlock","block","isPortableTextListBlock","_type","name","isTextBlock","isPortableTextTextBlock","getFocusBlock","snapshot","key","context","selection","isKeySegment","focus","path","_key","undefined","node","value","find","getFocusListBlock","guards","focusBlock","getFocusTextBlock","getFocusBlockObject","getFocusChild","children","span","getFocusSpan","focusChild","isPortableTextSpan","getFirstBlock","getLastBlock","length","getSelectedBlocks","selectedBlocks","startKey","backward","anchor","endKey","push","getSelectionStartBlock","getSelectionEndBlock","getPreviousBlock","previousBlock","selectionStartBlock","foundSelectionStartBlock","getNextBlock","nextBlock","selectionEndBlock","foundSelectionEndBlock","getSelectionEndPoint","getSelectionStartPoint","getNextInlineObject","focusTextBlock","selectionEndPoint","selectionEndPointChildKey","endPointChildFound","inlineObject","child","isSpan","getPreviousInlineObject","selectionStartPoint","selectionStartPointChildKey","getSelectedSlice","sliceBlocks","blocks","getSelectionText","reduce","text","isSelectionCollapsed","JSON","stringify","offset","isSelectionExpanded","getCaretWordSelection","selectionStartOffset","spanSelectionPointToBlockOffset","selectionPoint","previousInlineObject","blockStartPoint","getBlockStartPoint","textDirectlyBefore","split","at","nextInlineObject","blockEndPoint","getBlockEndPoint","textDirectlyAfter","caretWordStartOffset","caretWordEndOffset","caretWordStartSelectionPoint","blockOffsetToSpanSelectionPoint","blockOffset","direction","caretWordEndSelectionPoint","caretWordSelection","isAtTheEndOfBlock","utils","isAtTheStartOfBlock"],"mappings":";;AAaO,SAASA,aAAa;AAAA,EAACC;AAA8B,GAAG;AAC7D,WAASC,YAAYC,OAAgD;AACnE,WAAOC,MAAAA,wBAAwBD,KAAK,KAAKA,MAAME,UAAUJ,OAAOE,MAAMG;AAAAA,EAAAA;AAGxE,WAASC,YAAYJ,OAAgD;AACnE,WAAOK,MAAAA,wBAAwBL,KAAK,KAAKA,MAAME,UAAUJ,OAAOE,MAAMG;AAAAA,EAAAA;AAGjE,SAAA;AAAA,IAACJ;AAAAA,IAAaK;AAAAA,EAAW;AAClC;ACNO,MAAME,gBAERC,CAAa,aAAA;AAChB,QAAMC,MAAMD,SAASE,QAAQC,aACzBC,MAAAA,aAAaJ,SAASE,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