@portabletext/editor 1.48.9 → 1.48.11

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.
Files changed (80) hide show
  1. package/lib/_chunks-cjs/editor-provider.cjs +879 -169
  2. package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
  3. package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs +2 -2
  4. package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs.map +1 -1
  5. package/lib/_chunks-cjs/selector.get-text-before.cjs +2 -2
  6. package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
  7. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +464 -19
  8. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
  9. package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs +9 -1
  10. package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs.map +1 -1
  11. package/lib/_chunks-cjs/util.slice-blocks.cjs +2 -2
  12. package/lib/_chunks-es/editor-provider.js +773 -65
  13. package/lib/_chunks-es/editor-provider.js.map +1 -1
  14. package/lib/_chunks-es/selector.get-focus-inline-object.js +1 -1
  15. package/lib/_chunks-es/selector.get-text-before.js +1 -1
  16. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +448 -3
  17. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
  18. package/lib/_chunks-es/util.selection-point-to-block-offset.js +9 -1
  19. package/lib/_chunks-es/util.selection-point-to-block-offset.js.map +1 -1
  20. package/lib/_chunks-es/util.slice-blocks.js +2 -2
  21. package/lib/behaviors/index.cjs +27 -377
  22. package/lib/behaviors/index.cjs.map +1 -1
  23. package/lib/behaviors/index.d.cts +3696 -13915
  24. package/lib/behaviors/index.d.ts +3696 -13915
  25. package/lib/behaviors/index.js +22 -377
  26. package/lib/behaviors/index.js.map +1 -1
  27. package/lib/index.cjs +17 -17
  28. package/lib/index.cjs.map +1 -1
  29. package/lib/index.d.cts +3008 -394
  30. package/lib/index.d.ts +3008 -394
  31. package/lib/index.js +4 -5
  32. package/lib/index.js.map +1 -1
  33. package/lib/plugins/index.cjs +347 -30
  34. package/lib/plugins/index.cjs.map +1 -1
  35. package/lib/plugins/index.d.cts +3008 -395
  36. package/lib/plugins/index.d.ts +3008 -395
  37. package/lib/plugins/index.js +324 -8
  38. package/lib/plugins/index.js.map +1 -1
  39. package/lib/selectors/index.cjs +29 -29
  40. package/lib/selectors/index.cjs.map +1 -1
  41. package/lib/selectors/index.d.cts +3007 -387
  42. package/lib/selectors/index.d.ts +3007 -387
  43. package/lib/selectors/index.js +2 -3
  44. package/lib/selectors/index.js.map +1 -1
  45. package/lib/utils/index.cjs +5 -5
  46. package/lib/utils/index.cjs.map +1 -1
  47. package/lib/utils/index.d.cts +3008 -389
  48. package/lib/utils/index.d.ts +3008 -389
  49. package/lib/utils/index.js +2 -3
  50. package/lib/utils/index.js.map +1 -1
  51. package/package.json +1 -1
  52. package/src/behaviors/behavior.emoji-picker.ts +0 -6
  53. package/src/behaviors/behavior.markdown.ts +0 -48
  54. package/src/behaviors/index.ts +0 -15
  55. package/src/editor/create-editor.ts +0 -3
  56. package/src/editor/editor-machine.ts +105 -52
  57. package/src/editor/sync-machine.ts +10 -4
  58. package/src/internal-utils/__tests__/operationToPatches.test.ts +0 -2
  59. package/src/internal-utils/__tests__/patchToOperations.test.ts +0 -2
  60. package/src/plugins/plugin.core.tsx +1 -1
  61. package/lib/_chunks-cjs/behavior.core.cjs +0 -700
  62. package/lib/_chunks-cjs/behavior.core.cjs.map +0 -1
  63. package/lib/_chunks-cjs/behavior.markdown.cjs +0 -321
  64. package/lib/_chunks-cjs/behavior.markdown.cjs.map +0 -1
  65. package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs +0 -449
  66. package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs.map +0 -1
  67. package/lib/_chunks-cjs/util.get-selection-start-point.cjs +0 -10
  68. package/lib/_chunks-cjs/util.get-selection-start-point.cjs.map +0 -1
  69. package/lib/_chunks-es/behavior.core.js +0 -703
  70. package/lib/_chunks-es/behavior.core.js.map +0 -1
  71. package/lib/_chunks-es/behavior.markdown.js +0 -325
  72. package/lib/_chunks-es/behavior.markdown.js.map +0 -1
  73. package/lib/_chunks-es/selector.is-overlapping-selection.js +0 -451
  74. package/lib/_chunks-es/selector.is-overlapping-selection.js.map +0 -1
  75. package/lib/_chunks-es/util.get-selection-start-point.js +0 -11
  76. package/lib/_chunks-es/util.get-selection-start-point.js.map +0 -1
  77. package/src/behaviors/behavior.code-editor.ts +0 -77
  78. package/src/behaviors/behavior.links.ts +0 -84
  79. package/src/internal-utils/looks-like-url.test.ts +0 -19
  80. package/src/internal-utils/looks-like-url.ts +0 -15
@@ -1,5 +1,5 @@
1
1
  import { isPortableTextSpan } from "@sanity/types";
2
- import { getFocusChild } from "./selector.is-overlapping-selection.js";
2
+ import { getFocusChild } from "./selector.is-selecting-entire-blocks.js";
3
3
  const getFocusInlineObject = (snapshot) => {
4
4
  const focusChild = getFocusChild(snapshot);
5
5
  return focusChild && !isPortableTextSpan(focusChild.node) ? {
@@ -1,5 +1,5 @@
1
1
  import { getBlockStartPoint, isKeyedSegment, reverseSelection } from "./util.slice-blocks.js";
2
- import { getSelectionText } from "./selector.is-overlapping-selection.js";
2
+ import { getSelectionText } from "./selector.is-selecting-entire-blocks.js";
3
3
  const getBlockTextBefore = (snapshot) => {
4
4
  if (!snapshot.context.selection)
5
5
  return "";
@@ -1,5 +1,5 @@
1
- import { isTextBlock, isSpan, isKeyedSegment, isEmptyTextBlock, getBlockStartPoint, getBlockEndPoint, isEqualSelectionPoints } from "./util.slice-blocks.js";
2
- import { getSelectedBlocks, getFocusSpan, isSelectionCollapsed, getSelectionStartPoint, getSelectionEndPoint, getFocusTextBlock, isSelectionExpanded, getSelectionStartBlock, getSelectionEndBlock } from "./selector.is-overlapping-selection.js";
1
+ import { isTextBlock, isSpan$1 as isSpan, isKeyedSegment, isListBlock, isSpan as isSpan$1, sliceBlocks, spanSelectionPointToBlockOffset, getBlockStartPoint, getBlockEndPoint, blockOffsetToSpanSelectionPoint, isEmptyTextBlock, isEqualSelectionPoints, reverseSelection } from "./util.slice-blocks.js";
2
+ import { isKeySegment } from "@sanity/types";
3
3
  const getSelectedSpans = (snapshot) => {
4
4
  if (!snapshot.context.selection)
5
5
  return [];
@@ -86,6 +86,162 @@ const getSelectedSpans = (snapshot) => {
86
86
  });
87
87
  }
88
88
  return selectedSpans;
89
+ }, 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, getFocusBlock = (snapshot) => {
90
+ const key = snapshot.context.selection && isKeyedSegment(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;
91
+ return node && key ? {
92
+ node,
93
+ path: [{
94
+ _key: key
95
+ }]
96
+ } : void 0;
97
+ }, getFocusListBlock = (snapshot) => {
98
+ const focusTextBlock = getFocusTextBlock(snapshot);
99
+ return focusTextBlock && isListBlock(snapshot.context, focusTextBlock.node) ? {
100
+ node: focusTextBlock.node,
101
+ path: focusTextBlock.path
102
+ } : void 0;
103
+ }, getFocusTextBlock = (snapshot) => {
104
+ const focusBlock = getFocusBlock(snapshot);
105
+ return focusBlock && isTextBlock(snapshot.context, focusBlock.node) ? {
106
+ node: focusBlock.node,
107
+ path: focusBlock.path
108
+ } : void 0;
109
+ }, getFocusBlockObject = (snapshot) => {
110
+ const focusBlock = getFocusBlock(snapshot);
111
+ return focusBlock && !isTextBlock(snapshot.context, focusBlock.node) ? {
112
+ node: focusBlock.node,
113
+ path: focusBlock.path
114
+ } : void 0;
115
+ }, getFocusChild = (snapshot) => {
116
+ const focusBlock = getFocusTextBlock(snapshot);
117
+ if (!focusBlock)
118
+ return;
119
+ const key = snapshot.context.selection && isKeyedSegment(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;
120
+ return node && key ? {
121
+ node,
122
+ path: [...focusBlock.path, "children", {
123
+ _key: key
124
+ }]
125
+ } : void 0;
126
+ }, getFocusSpan = (snapshot) => {
127
+ const focusChild = getFocusChild(snapshot);
128
+ return focusChild && isSpan(snapshot.context, focusChild.node) ? {
129
+ node: focusChild.node,
130
+ path: focusChild.path
131
+ } : void 0;
132
+ }, getFirstBlock = (snapshot) => {
133
+ const node = snapshot.context.value[0];
134
+ return node ? {
135
+ node,
136
+ path: [{
137
+ _key: node._key
138
+ }]
139
+ } : void 0;
140
+ }, getLastBlock = (snapshot) => {
141
+ const node = snapshot.context.value[snapshot.context.value.length - 1] ? snapshot.context.value[snapshot.context.value.length - 1] : void 0;
142
+ return node ? {
143
+ node,
144
+ path: [{
145
+ _key: node._key
146
+ }]
147
+ } : void 0;
148
+ }, getSelectedBlocks = (snapshot) => {
149
+ if (!snapshot.context.selection)
150
+ return [];
151
+ const selectedBlocks = [], startKey = snapshot.context.selection.backward ? isKeyedSegment(snapshot.context.selection.focus.path[0]) ? snapshot.context.selection.focus.path[0]._key : void 0 : isKeyedSegment(snapshot.context.selection.anchor.path[0]) ? snapshot.context.selection.anchor.path[0]._key : void 0, endKey = snapshot.context.selection.backward ? isKeyedSegment(snapshot.context.selection.anchor.path[0]) ? snapshot.context.selection.anchor.path[0]._key : void 0 : isKeyedSegment(snapshot.context.selection.focus.path[0]) ? snapshot.context.selection.focus.path[0]._key : void 0;
152
+ if (!startKey || !endKey)
153
+ return selectedBlocks;
154
+ for (const block of snapshot.context.value) {
155
+ if (block._key === startKey) {
156
+ if (selectedBlocks.push({
157
+ node: block,
158
+ path: [{
159
+ _key: block._key
160
+ }]
161
+ }), startKey === endKey)
162
+ break;
163
+ continue;
164
+ }
165
+ if (block._key === endKey) {
166
+ selectedBlocks.push({
167
+ node: block,
168
+ path: [{
169
+ _key: block._key
170
+ }]
171
+ });
172
+ break;
173
+ }
174
+ selectedBlocks.length > 0 && selectedBlocks.push({
175
+ node: block,
176
+ path: [{
177
+ _key: block._key
178
+ }]
179
+ });
180
+ }
181
+ return selectedBlocks;
182
+ }, getSelectionStartBlock = (snapshot) => {
183
+ if (!snapshot.context.selection)
184
+ return;
185
+ const key = snapshot.context.selection.backward ? isKeyedSegment(snapshot.context.selection.focus.path[0]) ? snapshot.context.selection.focus.path[0]._key : void 0 : isKeyedSegment(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;
186
+ return node && key ? {
187
+ node,
188
+ path: [{
189
+ _key: key
190
+ }]
191
+ } : void 0;
192
+ }, getSelectionEndBlock = (snapshot) => {
193
+ if (!snapshot.context.selection)
194
+ return;
195
+ const key = snapshot.context.selection.backward ? isKeyedSegment(snapshot.context.selection.anchor.path[0]) ? snapshot.context.selection.anchor.path[0]._key : void 0 : isKeyedSegment(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;
196
+ return node && key ? {
197
+ node,
198
+ path: [{
199
+ _key: key
200
+ }]
201
+ } : void 0;
202
+ }, getPreviousBlock = (snapshot) => {
203
+ let previousBlock;
204
+ const selectionStartBlock = getSelectionStartBlock(snapshot);
205
+ if (!selectionStartBlock)
206
+ return;
207
+ let foundSelectionStartBlock = !1;
208
+ for (const block of snapshot.context.value) {
209
+ if (block._key === selectionStartBlock.node._key) {
210
+ foundSelectionStartBlock = !0;
211
+ break;
212
+ }
213
+ previousBlock = {
214
+ node: block,
215
+ path: [{
216
+ _key: block._key
217
+ }]
218
+ };
219
+ }
220
+ if (foundSelectionStartBlock && previousBlock)
221
+ return previousBlock;
222
+ }, getNextBlock = (snapshot) => {
223
+ let nextBlock;
224
+ const selectionEndBlock = getSelectionEndBlock(snapshot);
225
+ if (!selectionEndBlock)
226
+ return;
227
+ let foundSelectionEndBlock = !1;
228
+ for (const block of snapshot.context.value) {
229
+ if (block._key === selectionEndBlock.node._key) {
230
+ foundSelectionEndBlock = !0;
231
+ continue;
232
+ }
233
+ if (foundSelectionEndBlock) {
234
+ nextBlock = {
235
+ node: block,
236
+ path: [{
237
+ _key: block._key
238
+ }]
239
+ };
240
+ break;
241
+ }
242
+ }
243
+ if (foundSelectionEndBlock && nextBlock)
244
+ return nextBlock;
89
245
  }, getActiveAnnotations = (snapshot) => {
90
246
  if (!snapshot.context.selection)
91
247
  return [];
@@ -117,6 +273,119 @@ const getSelectedSpans = (snapshot) => {
117
273
  const firstStyle = firstTextBlock.style;
118
274
  if (firstStyle && selectedTextBlocks.every((block) => block.style === firstStyle))
119
275
  return firstStyle;
276
+ }, getSelectionEndPoint = (snapshot) => {
277
+ if (snapshot.context.selection)
278
+ return snapshot.context.selection.backward ? snapshot.context.selection.anchor : snapshot.context.selection.focus;
279
+ }, getSelectionStartPoint = (snapshot) => {
280
+ if (snapshot.context.selection)
281
+ return snapshot.context.selection.backward ? snapshot.context.selection.focus : snapshot.context.selection.anchor;
282
+ }, getNextInlineObject = (snapshot) => {
283
+ const focusTextBlock = getFocusTextBlock(snapshot), selectionEndPoint = getSelectionEndPoint(snapshot), selectionEndPointChildKey = selectionEndPoint && isKeySegment(selectionEndPoint.path[2]) ? selectionEndPoint.path[2]._key : void 0;
284
+ if (!focusTextBlock || !selectionEndPointChildKey)
285
+ return;
286
+ let endPointChildFound = !1, inlineObject;
287
+ for (const child of focusTextBlock.node.children) {
288
+ if (child._key === selectionEndPointChildKey) {
289
+ endPointChildFound = !0;
290
+ continue;
291
+ }
292
+ if (!isSpan$1(snapshot.context, child) && endPointChildFound) {
293
+ inlineObject = {
294
+ node: child,
295
+ path: [...focusTextBlock.path, "children", {
296
+ _key: child._key
297
+ }]
298
+ };
299
+ break;
300
+ }
301
+ }
302
+ return inlineObject;
303
+ }, getPreviousInlineObject = (snapshot) => {
304
+ const focusTextBlock = getFocusTextBlock(snapshot), selectionStartPoint = getSelectionStartPoint(snapshot), selectionStartPointChildKey = selectionStartPoint && isKeySegment(selectionStartPoint.path[2]) ? selectionStartPoint.path[2]._key : void 0;
305
+ if (!focusTextBlock || !selectionStartPointChildKey)
306
+ return;
307
+ let inlineObject;
308
+ for (const child of focusTextBlock.node.children) {
309
+ if (child._key === selectionStartPointChildKey)
310
+ break;
311
+ isSpan$1(snapshot.context, child) || (inlineObject = {
312
+ node: child,
313
+ path: [...focusTextBlock.path, "children", {
314
+ _key: child._key
315
+ }]
316
+ });
317
+ }
318
+ return inlineObject;
319
+ }, getSelectedSlice = (snapshot) => sliceBlocks({
320
+ context: snapshot.context,
321
+ blocks: snapshot.context.value
322
+ }), getSelectionText = (snapshot) => getSelectedSlice(snapshot).reduce((text, block) => isTextBlock(snapshot.context, block) ? text + block.children.reduce((text2, child) => isSpan(snapshot.context, child) ? text2 + child.text : text2, "") : text, ""), isSelectionExpanded = (snapshot) => !isSelectionCollapsed(snapshot), getCaretWordSelection = (snapshot) => {
323
+ if (!snapshot.context.selection || !isSelectionCollapsed(snapshot))
324
+ return null;
325
+ const focusTextBlock = getFocusTextBlock(snapshot), selectionStartPoint = getSelectionStartPoint(snapshot), selectionStartOffset = selectionStartPoint ? spanSelectionPointToBlockOffset({
326
+ context: snapshot.context,
327
+ selectionPoint: selectionStartPoint
328
+ }) : void 0;
329
+ if (!focusTextBlock || !selectionStartPoint || !selectionStartOffset)
330
+ return null;
331
+ const previousInlineObject = getPreviousInlineObject(snapshot), blockStartPoint = getBlockStartPoint({
332
+ context: snapshot.context,
333
+ block: focusTextBlock
334
+ }), textDirectlyBefore = getSelectionText({
335
+ context: {
336
+ ...snapshot.context,
337
+ selection: {
338
+ anchor: previousInlineObject ? {
339
+ path: previousInlineObject.path,
340
+ offset: 0
341
+ } : blockStartPoint,
342
+ focus: selectionStartPoint
343
+ }
344
+ }
345
+ }).split(/\s+/).at(-1), nextInlineObject = getNextInlineObject(snapshot), blockEndPoint = getBlockEndPoint({
346
+ context: snapshot.context,
347
+ block: focusTextBlock
348
+ }), textDirectlyAfter = getSelectionText({
349
+ context: {
350
+ ...snapshot.context,
351
+ selection: {
352
+ anchor: selectionStartPoint,
353
+ focus: nextInlineObject ? {
354
+ path: nextInlineObject.path,
355
+ offset: 0
356
+ } : blockEndPoint
357
+ }
358
+ }
359
+ }).split(/\s+/).at(0);
360
+ if ((textDirectlyBefore === void 0 || textDirectlyBefore === "") && (textDirectlyAfter === void 0 || textDirectlyAfter === ""))
361
+ return null;
362
+ const caretWordStartOffset = textDirectlyBefore ? {
363
+ ...selectionStartOffset,
364
+ offset: selectionStartOffset.offset - textDirectlyBefore.length
365
+ } : selectionStartOffset, caretWordEndOffset = textDirectlyAfter ? {
366
+ ...selectionStartOffset,
367
+ offset: selectionStartOffset.offset + textDirectlyAfter.length
368
+ } : selectionStartOffset, caretWordStartSelectionPoint = blockOffsetToSpanSelectionPoint({
369
+ context: snapshot.context,
370
+ blockOffset: caretWordStartOffset,
371
+ direction: "backward"
372
+ }), caretWordEndSelectionPoint = blockOffsetToSpanSelectionPoint({
373
+ context: snapshot.context,
374
+ blockOffset: caretWordEndOffset,
375
+ direction: "forward"
376
+ });
377
+ if (!caretWordStartSelectionPoint || !caretWordEndSelectionPoint)
378
+ return null;
379
+ const caretWordSelection = {
380
+ anchor: caretWordStartSelectionPoint,
381
+ focus: caretWordEndSelectionPoint
382
+ };
383
+ return isSelectionExpanded({
384
+ context: {
385
+ ...snapshot.context,
386
+ selection: caretWordSelection
387
+ }
388
+ }) ? caretWordSelection : null;
120
389
  }, getSelectedTextBlocks = (snapshot) => {
121
390
  if (!snapshot.context.selection)
122
391
  return [];
@@ -267,6 +536,155 @@ function isActiveListItem(listItem) {
267
536
  function isActiveStyle(style) {
268
537
  return (snapshot) => getActiveStyle(snapshot) === style;
269
538
  }
539
+ function isAtTheEndOfBlock(block) {
540
+ return (snapshot) => {
541
+ if (!snapshot.context.selection || !isSelectionCollapsed(snapshot))
542
+ return !1;
543
+ const blockEndPoint = getBlockEndPoint({
544
+ context: snapshot.context,
545
+ block
546
+ });
547
+ return isEqualSelectionPoints(snapshot.context.selection.focus, blockEndPoint);
548
+ };
549
+ }
550
+ function isAtTheStartOfBlock(block) {
551
+ return (snapshot) => {
552
+ if (!snapshot.context.selection || !isSelectionCollapsed(snapshot))
553
+ return !1;
554
+ const blockStartPoint = getBlockStartPoint({
555
+ context: snapshot.context,
556
+ block
557
+ });
558
+ return isEqualSelectionPoints(snapshot.context.selection.focus, blockStartPoint);
559
+ };
560
+ }
561
+ function isPointAfterSelection(point) {
562
+ return (snapshot) => {
563
+ if (!snapshot.context.selection)
564
+ return !1;
565
+ const selection = snapshot.context.selection.backward ? reverseSelection(snapshot.context.selection) : snapshot.context.selection, pointBlockKey = isKeyedSegment(point.path[0]) ? point.path[0]._key : void 0, pointChildKey = isKeyedSegment(point.path[2]) ? point.path[2]._key : void 0, endBlockKey = isKeyedSegment(selection.focus.path[0]) ? selection.focus.path[0]._key : void 0, endChildKey = isKeyedSegment(selection.focus.path[2]) ? selection.focus.path[2]._key : void 0;
566
+ if (!pointBlockKey || !endBlockKey)
567
+ return !1;
568
+ let after = !1;
569
+ for (const block of snapshot.context.value) {
570
+ if (block._key === endBlockKey) {
571
+ if (block._key !== pointBlockKey) {
572
+ after = !0;
573
+ break;
574
+ }
575
+ if (!isTextBlock(snapshot.context, block) || !pointChildKey || !endChildKey)
576
+ break;
577
+ for (const child of block.children) {
578
+ if (child._key === endChildKey) {
579
+ if (child._key !== pointChildKey) {
580
+ after = !0;
581
+ break;
582
+ }
583
+ after = point.offset > selection.focus.offset;
584
+ break;
585
+ }
586
+ if (child._key === pointChildKey)
587
+ break;
588
+ }
589
+ }
590
+ if (block._key === pointBlockKey)
591
+ break;
592
+ }
593
+ return after;
594
+ };
595
+ }
596
+ function isPointBeforeSelection(point) {
597
+ return (snapshot) => {
598
+ if (!snapshot.context.selection)
599
+ return !1;
600
+ const selection = snapshot.context.selection.backward ? reverseSelection(snapshot.context.selection) : snapshot.context.selection, pointBlockKey = isKeyedSegment(point.path[0]) ? point.path[0]._key : void 0, pointChildKey = isKeyedSegment(point.path[2]) ? point.path[2]._key : void 0, startBlockKey = isKeyedSegment(selection.anchor.path[0]) ? selection.anchor.path[0]._key : void 0, startChildKey = isKeyedSegment(selection.anchor.path[2]) ? selection.anchor.path[2]._key : void 0;
601
+ if (!pointBlockKey || !startBlockKey)
602
+ return !1;
603
+ let before = !1;
604
+ for (const block of snapshot.context.value) {
605
+ if (block._key === pointBlockKey) {
606
+ if (block._key !== startBlockKey) {
607
+ before = !0;
608
+ break;
609
+ }
610
+ if (!isTextBlock(snapshot.context, block) || !pointChildKey || !startChildKey)
611
+ break;
612
+ for (const child of block.children) {
613
+ if (child._key === pointChildKey) {
614
+ if (child._key !== startChildKey) {
615
+ before = !0;
616
+ break;
617
+ }
618
+ before = point.offset < selection.anchor.offset;
619
+ break;
620
+ }
621
+ if (child._key === startChildKey)
622
+ break;
623
+ }
624
+ }
625
+ if (block._key === startBlockKey)
626
+ break;
627
+ }
628
+ return before;
629
+ };
630
+ }
631
+ function isOverlappingSelection(selection) {
632
+ return (snapshot) => {
633
+ if (!selection || !snapshot.context.selection)
634
+ return !1;
635
+ const selectionStartPoint = getSelectionStartPoint({
636
+ context: {
637
+ ...snapshot.context,
638
+ selection
639
+ }
640
+ }), selectionEndPoint = getSelectionEndPoint({
641
+ context: {
642
+ ...snapshot.context,
643
+ selection
644
+ }
645
+ }), originalSelectionStartPoint = getSelectionStartPoint(snapshot), originalSelectionEndPoint = getSelectionEndPoint(snapshot);
646
+ if (!selectionStartPoint || !selectionEndPoint || !originalSelectionStartPoint || !originalSelectionEndPoint)
647
+ return !1;
648
+ const startPointBeforeSelection = isPointBeforeSelection(selectionStartPoint)(snapshot), startPointAfterSelection = isPointAfterSelection(selectionStartPoint)(snapshot), endPointBeforeSelection = isPointBeforeSelection(selectionEndPoint)(snapshot), endPointAfterSelection = isPointAfterSelection(selectionEndPoint)(snapshot), originalStartPointBeforeStartPoint = isPointBeforeSelection(originalSelectionStartPoint)({
649
+ ...snapshot,
650
+ context: {
651
+ ...snapshot.context,
652
+ selection: {
653
+ anchor: selectionStartPoint,
654
+ focus: selectionStartPoint
655
+ }
656
+ }
657
+ }), originalStartPointAfterStartPoint = isPointAfterSelection(originalSelectionStartPoint)({
658
+ ...snapshot,
659
+ context: {
660
+ ...snapshot.context,
661
+ selection: {
662
+ anchor: selectionStartPoint,
663
+ focus: selectionStartPoint
664
+ }
665
+ }
666
+ }), originalEndPointBeforeEndPoint = isPointBeforeSelection(originalSelectionEndPoint)({
667
+ ...snapshot,
668
+ context: {
669
+ ...snapshot.context,
670
+ selection: {
671
+ anchor: selectionEndPoint,
672
+ focus: selectionEndPoint
673
+ }
674
+ }
675
+ }), originalEndPointAfterEndPoint = isPointAfterSelection(originalSelectionEndPoint)({
676
+ ...snapshot,
677
+ context: {
678
+ ...snapshot.context,
679
+ selection: {
680
+ anchor: selectionEndPoint,
681
+ focus: selectionEndPoint
682
+ }
683
+ }
684
+ }), endPointEqualToOriginalStartPoint = isEqualSelectionPoints(selectionEndPoint, originalSelectionStartPoint), startPointEqualToOriginalEndPoint = isEqualSelectionPoints(selectionStartPoint, originalSelectionEndPoint);
685
+ return endPointBeforeSelection && !endPointEqualToOriginalStartPoint || startPointAfterSelection && !startPointEqualToOriginalEndPoint ? !1 : !originalStartPointBeforeStartPoint && originalStartPointAfterStartPoint && !originalEndPointBeforeEndPoint && originalEndPointAfterEndPoint ? !endPointEqualToOriginalStartPoint : originalStartPointBeforeStartPoint && !originalStartPointAfterStartPoint && originalEndPointBeforeEndPoint && !originalEndPointAfterEndPoint ? !startPointEqualToOriginalEndPoint : !startPointAfterSelection || !startPointBeforeSelection || !endPointAfterSelection || !endPointBeforeSelection;
686
+ };
687
+ }
270
688
  const isSelectingEntireBlocks = (snapshot) => {
271
689
  if (!snapshot.context.selection)
272
690
  return !1;
@@ -286,13 +704,40 @@ export {
286
704
  getActiveAnnotations,
287
705
  getActiveListItem,
288
706
  getActiveStyle,
707
+ getCaretWordSelection,
708
+ getFirstBlock,
709
+ getFocusBlock,
710
+ getFocusBlockObject,
711
+ getFocusChild,
712
+ getFocusListBlock,
713
+ getFocusSpan,
714
+ getFocusTextBlock,
715
+ getLastBlock,
716
+ getNextBlock,
717
+ getNextInlineObject,
718
+ getPreviousBlock,
719
+ getPreviousInlineObject,
720
+ getSelectedBlocks,
721
+ getSelectedSlice,
289
722
  getSelectedSpans,
290
723
  getSelectedTextBlocks,
724
+ getSelectionEndBlock,
725
+ getSelectionEndPoint,
726
+ getSelectionStartBlock,
727
+ getSelectionStartPoint,
728
+ getSelectionText,
291
729
  getTrimmedSelection,
292
730
  isActiveAnnotation,
293
731
  isActiveDecorator,
294
732
  isActiveListItem,
295
733
  isActiveStyle,
296
- isSelectingEntireBlocks
734
+ isAtTheEndOfBlock,
735
+ isAtTheStartOfBlock,
736
+ isOverlappingSelection,
737
+ isPointAfterSelection,
738
+ isPointBeforeSelection,
739
+ isSelectingEntireBlocks,
740
+ isSelectionCollapsed,
741
+ isSelectionExpanded
297
742
  };
298
743
  //# sourceMappingURL=selector.is-selecting-entire-blocks.js.map