@portabletext/editor 1.48.7 → 1.48.9

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 (120) hide show
  1. package/lib/_chunks-cjs/behavior.core.cjs +20 -8
  2. package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
  3. package/lib/_chunks-cjs/behavior.markdown.cjs +5 -5
  4. package/lib/_chunks-cjs/behavior.markdown.cjs.map +1 -1
  5. package/lib/_chunks-cjs/editor-provider.cjs +99 -68
  6. package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
  7. package/lib/_chunks-cjs/selector.get-text-before.cjs +7 -4
  8. package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
  9. package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs +41 -45
  10. package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs.map +1 -1
  11. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +29 -23
  12. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
  13. package/lib/_chunks-cjs/util.merge-text-blocks.cjs +3 -3
  14. package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +1 -1
  15. package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs +15 -15
  16. package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs.map +1 -1
  17. package/lib/_chunks-cjs/util.slice-blocks.cjs +258 -38
  18. package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
  19. package/lib/_chunks-es/behavior.core.js +21 -10
  20. package/lib/_chunks-es/behavior.core.js.map +1 -1
  21. package/lib/_chunks-es/behavior.markdown.js +5 -6
  22. package/lib/_chunks-es/behavior.markdown.js.map +1 -1
  23. package/lib/_chunks-es/editor-provider.js +75 -45
  24. package/lib/_chunks-es/editor-provider.js.map +1 -1
  25. package/lib/_chunks-es/selector.get-text-before.js +7 -4
  26. package/lib/_chunks-es/selector.get-text-before.js.map +1 -1
  27. package/lib/_chunks-es/selector.is-overlapping-selection.js +43 -47
  28. package/lib/_chunks-es/selector.is-overlapping-selection.js.map +1 -1
  29. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +30 -26
  30. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
  31. package/lib/_chunks-es/util.merge-text-blocks.js +1 -1
  32. package/lib/_chunks-es/util.selection-point-to-block-offset.js +15 -16
  33. package/lib/_chunks-es/util.selection-point-to-block-offset.js.map +1 -1
  34. package/lib/_chunks-es/util.slice-blocks.js +258 -38
  35. package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
  36. package/lib/behaviors/index.d.cts +5 -5
  37. package/lib/behaviors/index.d.ts +5 -5
  38. package/lib/index.cjs +45 -21
  39. package/lib/index.cjs.map +1 -1
  40. package/lib/index.js +44 -21
  41. package/lib/index.js.map +1 -1
  42. package/lib/plugins/index.cjs +16 -7
  43. package/lib/plugins/index.cjs.map +1 -1
  44. package/lib/plugins/index.js +16 -7
  45. package/lib/plugins/index.js.map +1 -1
  46. package/lib/selectors/index.cjs +3 -3
  47. package/lib/selectors/index.cjs.map +1 -1
  48. package/lib/selectors/index.d.cts +2 -6
  49. package/lib/selectors/index.d.ts +2 -6
  50. package/lib/selectors/index.js +5 -5
  51. package/lib/selectors/index.js.map +1 -1
  52. package/lib/utils/index.cjs +30 -24
  53. package/lib/utils/index.cjs.map +1 -1
  54. package/lib/utils/index.d.cts +37 -31
  55. package/lib/utils/index.d.ts +37 -31
  56. package/lib/utils/index.js +30 -24
  57. package/lib/utils/index.js.map +1 -1
  58. package/package.json +1 -1
  59. package/src/behavior-actions/behavior.action.block.unset.ts +1 -1
  60. package/src/behavior-actions/behavior.action.decorator.add.ts +20 -5
  61. package/src/behaviors/behavior.abstract.decorator.ts +1 -1
  62. package/src/behaviors/behavior.abstract.delete.ts +1 -1
  63. package/src/behaviors/behavior.abstract.insert.ts +2 -2
  64. package/src/behaviors/behavior.abstract.select.ts +16 -4
  65. package/src/behaviors/behavior.abstract.split.ts +9 -6
  66. package/src/behaviors/behavior.core.block-objects.ts +5 -5
  67. package/src/behaviors/behavior.core.insert-break.ts +16 -4
  68. package/src/behaviors/behavior.core.lists.ts +4 -6
  69. package/src/behaviors/behavior.decorator-pair.ts +13 -4
  70. package/src/behaviors/behavior.default.ts +1 -1
  71. package/src/behaviors/behavior.markdown.ts +5 -5
  72. package/src/converters/converter.portable-text.ts +1 -1
  73. package/src/converters/converter.text-html.ts +1 -1
  74. package/src/converters/converter.text-plain.ts +4 -4
  75. package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +10 -2
  76. package/src/editor/plugins/createWithSchemaTypes.ts +12 -19
  77. package/src/internal-utils/__tests__/dmpToOperations.test.ts +13 -12
  78. package/src/internal-utils/drag-selection.ts +16 -4
  79. package/src/internal-utils/event-position.ts +20 -8
  80. package/src/internal-utils/parse-blocks.ts +17 -5
  81. package/src/internal-utils/validateValue.ts +6 -6
  82. package/src/plugins/plugin.decorator-shortcut.ts +2 -2
  83. package/src/selectors/selector.get-active-annotations.ts +5 -2
  84. package/src/selectors/selector.get-active-list-item.ts +4 -3
  85. package/src/selectors/selector.get-active-style.ts +4 -3
  86. package/src/selectors/selector.get-anchor-text-block.ts +3 -6
  87. package/src/selectors/selector.get-block-offsets.ts +2 -2
  88. package/src/selectors/selector.get-caret-word-selection.ts +11 -5
  89. package/src/selectors/selector.get-selected-slice.ts +1 -1
  90. package/src/selectors/selector.get-selected-spans.ts +11 -15
  91. package/src/selectors/selector.get-selected-text-blocks.ts +3 -3
  92. package/src/selectors/selector.get-selection-text.ts +3 -3
  93. package/src/selectors/selector.get-text-before.ts +5 -2
  94. package/src/selectors/selector.get-trimmed-selection.ts +20 -14
  95. package/src/selectors/selector.is-active-annotation.ts +4 -2
  96. package/src/selectors/selector.is-active-decorator.test.ts +3 -3
  97. package/src/selectors/selector.is-at-the-end-of-block.ts +4 -1
  98. package/src/selectors/selector.is-at-the-start-of-block.ts +4 -1
  99. package/src/selectors/selector.is-point-after-selection.ts +7 -6
  100. package/src/selectors/selector.is-point-before-selection.ts +7 -6
  101. package/src/selectors/selector.is-selecting-entire-blocks.ts +8 -2
  102. package/src/selectors/selectors.ts +25 -28
  103. package/src/utils/util.block-offset-to-block-selection-point.ts +4 -4
  104. package/src/utils/util.block-offset-to-selection-point.ts +5 -5
  105. package/src/utils/util.block-offset.test.ts +219 -156
  106. package/src/utils/util.block-offset.ts +14 -17
  107. package/src/utils/util.block-offsets-to-selection.ts +5 -5
  108. package/src/utils/util.child-selection-point-to-block-offset.ts +7 -10
  109. package/src/utils/util.get-block-end-point.ts +15 -15
  110. package/src/utils/util.get-block-start-point.ts +13 -12
  111. package/src/utils/util.is-empty-text-block.ts +9 -8
  112. package/src/utils/util.selection-point-to-block-offset.ts +4 -4
  113. package/src/utils/util.slice-blocks.test.ts +178 -121
  114. package/src/utils/util.slice-blocks.ts +25 -24
  115. package/src/utils/util.split-text-block.ts +18 -12
  116. package/lib/_chunks-cjs/parse-blocks.cjs +0 -205
  117. package/lib/_chunks-cjs/parse-blocks.cjs.map +0 -1
  118. package/lib/_chunks-es/parse-blocks.js +0 -206
  119. package/lib/_chunks-es/parse-blocks.js.map +0 -1
  120. package/src/behavior-actions/behavior.guards.ts +0 -24
@@ -7,10 +7,13 @@ const getBlockTextBefore = (snapshot) => {
7
7
  if (!block)
8
8
  return "";
9
9
  const startOfBlock = getBlockStartPoint({
10
- node: block,
11
- path: [{
12
- _key: block._key
13
- }]
10
+ context: snapshot.context,
11
+ block: {
12
+ node: block,
13
+ path: [{
14
+ _key: block._key
15
+ }]
16
+ }
14
17
  });
15
18
  return getSelectionText({
16
19
  context: {
@@ -1 +1 @@
1
- {"version":3,"file":"selector.get-text-before.js","sources":["../../src/selectors/selector.get-text-before.ts"],"sourcesContent":["import type {EditorSelector} from '../editor/editor-selector'\nimport {getBlockStartPoint} from '../utils/util.get-block-start-point'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {reverseSelection} from '../utils/util.reverse-selection'\nimport {getSelectionText} from './selector.get-selection-text'\n\n/**\n * @public\n */\nexport const getBlockTextBefore: EditorSelector<string> = (snapshot) => {\n if (!snapshot.context.selection) {\n return ''\n }\n\n const selection = snapshot.context.selection.backward\n ? reverseSelection(snapshot.context.selection)\n : snapshot.context.selection\n const point = selection.anchor\n const key = isKeyedSegment(point.path[0]) ? point.path[0]._key : undefined\n\n const block = key\n ? snapshot.context.value.find((block) => block._key === key)\n : undefined\n\n if (!block) {\n return ''\n }\n\n const startOfBlock = getBlockStartPoint({\n node: block,\n path: [{_key: block._key}],\n })\n\n return getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: startOfBlock,\n focus: point,\n },\n },\n })\n}\n"],"names":["getBlockTextBefore","snapshot","context","selection","point","backward","reverseSelection","anchor","key","isKeyedSegment","path","_key","undefined","block","value","find","startOfBlock","getBlockStartPoint","node","getSelectionText","focus"],"mappings":";;AASO,MAAMA,qBAA8CC,CAAa,aAAA;AAClE,MAAA,CAACA,SAASC,QAAQC;AACb,WAAA;AAMT,QAAMC,SAHYH,SAASC,QAAQC,UAAUE,WACzCC,iBAAiBL,SAASC,QAAQC,SAAS,IAC3CF,SAASC,QAAQC,WACGI,QAClBC,MAAMC,eAAeL,MAAMM,KAAK,CAAC,CAAC,IAAIN,MAAMM,KAAK,CAAC,EAAEC,OAAOC,QAE3DC,QAAQL,MACVP,SAASC,QAAQY,MAAMC,KAAMF,CAAAA,WAAUA,OAAMF,SAASH,GAAG,IACzDI;AAEJ,MAAI,CAACC;AACI,WAAA;AAGT,QAAMG,eAAeC,mBAAmB;AAAA,IACtCC,MAAML;AAAAA,IACNH,MAAM,CAAC;AAAA,MAACC,MAAME,MAAMF;AAAAA,IAAK,CAAA;AAAA,EAAA,CAC1B;AAED,SAAOQ,iBAAiB;AAAA,IAEtBjB,SAAS;AAAA,MACP,GAAGD,SAASC;AAAAA,MACZC,WAAW;AAAA,QACTI,QAAQS;AAAAA,QACRI,OAAOhB;AAAAA,MAAAA;AAAAA,IACT;AAAA,EACF,CACD;AACH;"}
1
+ {"version":3,"file":"selector.get-text-before.js","sources":["../../src/selectors/selector.get-text-before.ts"],"sourcesContent":["import type {EditorSelector} from '../editor/editor-selector'\nimport {getBlockStartPoint} from '../utils/util.get-block-start-point'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {reverseSelection} from '../utils/util.reverse-selection'\nimport {getSelectionText} from './selector.get-selection-text'\n\n/**\n * @public\n */\nexport const getBlockTextBefore: EditorSelector<string> = (snapshot) => {\n if (!snapshot.context.selection) {\n return ''\n }\n\n const selection = snapshot.context.selection.backward\n ? reverseSelection(snapshot.context.selection)\n : snapshot.context.selection\n const point = selection.anchor\n const key = isKeyedSegment(point.path[0]) ? point.path[0]._key : undefined\n\n const block = key\n ? snapshot.context.value.find((block) => block._key === key)\n : undefined\n\n if (!block) {\n return ''\n }\n\n const startOfBlock = getBlockStartPoint({\n context: snapshot.context,\n block: {\n node: block,\n path: [{_key: block._key}],\n },\n })\n\n return getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: startOfBlock,\n focus: point,\n },\n },\n })\n}\n"],"names":["getBlockTextBefore","snapshot","context","selection","point","backward","reverseSelection","anchor","key","isKeyedSegment","path","_key","undefined","block","value","find","startOfBlock","getBlockStartPoint","node","getSelectionText","focus"],"mappings":";;AASO,MAAMA,qBAA8CC,CAAa,aAAA;AAClE,MAAA,CAACA,SAASC,QAAQC;AACb,WAAA;AAMT,QAAMC,SAHYH,SAASC,QAAQC,UAAUE,WACzCC,iBAAiBL,SAASC,QAAQC,SAAS,IAC3CF,SAASC,QAAQC,WACGI,QAClBC,MAAMC,eAAeL,MAAMM,KAAK,CAAC,CAAC,IAAIN,MAAMM,KAAK,CAAC,EAAEC,OAAOC,QAE3DC,QAAQL,MACVP,SAASC,QAAQY,MAAMC,KAAMF,CAAAA,WAAUA,OAAMF,SAASH,GAAG,IACzDI;AAEJ,MAAI,CAACC;AACI,WAAA;AAGT,QAAMG,eAAeC,mBAAmB;AAAA,IACtCf,SAASD,SAASC;AAAAA,IAClBW,OAAO;AAAA,MACLK,MAAML;AAAAA,MACNH,MAAM,CAAC;AAAA,QAACC,MAAME,MAAMF;AAAAA,MAAK,CAAA;AAAA,IAAA;AAAA,EAC3B,CACD;AAED,SAAOQ,iBAAiB;AAAA,IAEtBjB,SAAS;AAAA,MACP,GAAGD,SAASC;AAAAA,MACZC,WAAW;AAAA,QACTI,QAAQS;AAAAA,QACRI,OAAOhB;AAAAA,MAAAA;AAAAA,IACT;AAAA,EACF,CACD;AACH;"}
@@ -1,22 +1,7 @@
1
- import { isSpan, sliceBlocks, spanSelectionPointToBlockOffset, getBlockStartPoint, getBlockEndPoint, blockOffsetToSpanSelectionPoint, isEqualSelectionPoints, reverseSelection } from "./util.slice-blocks.js";
2
- import { isPortableTextTextBlock, isPortableTextListBlock, isPortableTextSpan, isKeySegment } from "@sanity/types";
3
- const 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;
4
- function createGuards({
5
- schema
6
- }) {
7
- function isListBlock(block) {
8
- return isPortableTextListBlock(block) && block._type === schema.block.name;
9
- }
10
- function isTextBlock(block) {
11
- return isPortableTextTextBlock(block) && block._type === schema.block.name;
12
- }
13
- return {
14
- isListBlock,
15
- isTextBlock
16
- };
17
- }
18
- const getFocusBlock = (snapshot) => {
19
- const key = snapshot.context.selection && 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;
1
+ import { isTextBlock, isSpan, isListBlock, isKeyedSegment, isSpan$1, sliceBlocks, spanSelectionPointToBlockOffset, getBlockStartPoint, getBlockEndPoint, blockOffsetToSpanSelectionPoint, isEqualSelectionPoints, reverseSelection } from "./util.slice-blocks.js";
2
+ import { isKeySegment } from "@sanity/types";
3
+ const 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) => {
4
+ 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;
20
5
  return node && key ? {
21
6
  node,
22
7
  path: [{
@@ -24,20 +9,20 @@ const getFocusBlock = (snapshot) => {
24
9
  }]
25
10
  } : void 0;
26
11
  }, getFocusListBlock = (snapshot) => {
27
- const guards = createGuards(snapshot.context), focusBlock = getFocusBlock(snapshot);
28
- return focusBlock && guards.isListBlock(focusBlock.node) ? {
29
- node: focusBlock.node,
30
- path: focusBlock.path
12
+ const focusTextBlock = getFocusTextBlock(snapshot);
13
+ return focusTextBlock && isListBlock(snapshot.context, focusTextBlock.node) ? {
14
+ node: focusTextBlock.node,
15
+ path: focusTextBlock.path
31
16
  } : void 0;
32
17
  }, getFocusTextBlock = (snapshot) => {
33
18
  const focusBlock = getFocusBlock(snapshot);
34
- return focusBlock && isPortableTextTextBlock(focusBlock.node) ? {
19
+ return focusBlock && isTextBlock(snapshot.context, focusBlock.node) ? {
35
20
  node: focusBlock.node,
36
21
  path: focusBlock.path
37
22
  } : void 0;
38
23
  }, getFocusBlockObject = (snapshot) => {
39
24
  const focusBlock = getFocusBlock(snapshot);
40
- return focusBlock && !isPortableTextTextBlock(focusBlock.node) ? {
25
+ return focusBlock && !isTextBlock(snapshot.context, focusBlock.node) ? {
41
26
  node: focusBlock.node,
42
27
  path: focusBlock.path
43
28
  } : void 0;
@@ -45,7 +30,7 @@ const getFocusBlock = (snapshot) => {
45
30
  const focusBlock = getFocusTextBlock(snapshot);
46
31
  if (!focusBlock)
47
32
  return;
48
- const key = snapshot.context.selection && 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;
33
+ 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;
49
34
  return node && key ? {
50
35
  node,
51
36
  path: [...focusBlock.path, "children", {
@@ -54,7 +39,7 @@ const getFocusBlock = (snapshot) => {
54
39
  } : void 0;
55
40
  }, getFocusSpan = (snapshot) => {
56
41
  const focusChild = getFocusChild(snapshot);
57
- return focusChild && isPortableTextSpan(focusChild.node) ? {
42
+ return focusChild && isSpan(snapshot.context, focusChild.node) ? {
58
43
  node: focusChild.node,
59
44
  path: focusChild.path
60
45
  } : void 0;
@@ -77,7 +62,7 @@ const getFocusBlock = (snapshot) => {
77
62
  }, getSelectedBlocks = (snapshot) => {
78
63
  if (!snapshot.context.selection)
79
64
  return [];
80
- const selectedBlocks = [], startKey = snapshot.context.selection.backward ? isKeySegment(snapshot.context.selection.focus.path[0]) ? snapshot.context.selection.focus.path[0]._key : void 0 : isKeySegment(snapshot.context.selection.anchor.path[0]) ? snapshot.context.selection.anchor.path[0]._key : void 0, endKey = snapshot.context.selection.backward ? isKeySegment(snapshot.context.selection.anchor.path[0]) ? snapshot.context.selection.anchor.path[0]._key : void 0 : isKeySegment(snapshot.context.selection.focus.path[0]) ? snapshot.context.selection.focus.path[0]._key : void 0;
65
+ 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;
81
66
  if (!startKey || !endKey)
82
67
  return selectedBlocks;
83
68
  for (const block of snapshot.context.value) {
@@ -111,7 +96,7 @@ const getFocusBlock = (snapshot) => {
111
96
  }, getSelectionStartBlock = (snapshot) => {
112
97
  if (!snapshot.context.selection)
113
98
  return;
114
- const key = snapshot.context.selection.backward ? isKeySegment(snapshot.context.selection.focus.path[0]) ? snapshot.context.selection.focus.path[0]._key : void 0 : 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;
99
+ 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;
115
100
  return node && key ? {
116
101
  node,
117
102
  path: [{
@@ -121,7 +106,7 @@ const getFocusBlock = (snapshot) => {
121
106
  }, getSelectionEndBlock = (snapshot) => {
122
107
  if (!snapshot.context.selection)
123
108
  return;
124
- const key = snapshot.context.selection.backward ? isKeySegment(snapshot.context.selection.anchor.path[0]) ? snapshot.context.selection.anchor.path[0]._key : void 0 : 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;
109
+ 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;
125
110
  return node && key ? {
126
111
  node,
127
112
  path: [{
@@ -187,7 +172,7 @@ const getFocusBlock = (snapshot) => {
187
172
  endPointChildFound = !0;
188
173
  continue;
189
174
  }
190
- if (!isSpan(snapshot.context, child) && endPointChildFound) {
175
+ if (!isSpan$1(snapshot.context, child) && endPointChildFound) {
191
176
  inlineObject = {
192
177
  node: child,
193
178
  path: [...focusTextBlock.path, "children", {
@@ -206,7 +191,7 @@ const getFocusBlock = (snapshot) => {
206
191
  for (const child of focusTextBlock.node.children) {
207
192
  if (child._key === selectionStartPointChildKey)
208
193
  break;
209
- isSpan(snapshot.context, child) || (inlineObject = {
194
+ isSpan$1(snapshot.context, child) || (inlineObject = {
210
195
  node: child,
211
196
  path: [...focusTextBlock.path, "children", {
212
197
  _key: child._key
@@ -215,18 +200,21 @@ const getFocusBlock = (snapshot) => {
215
200
  }
216
201
  return inlineObject;
217
202
  }, getSelectedSlice = (snapshot) => sliceBlocks({
218
- blocks: snapshot.context.value,
219
- selection: snapshot.context.selection
220
- }), getSelectionText = (snapshot) => getSelectedSlice(snapshot).reduce((text, block) => isPortableTextTextBlock(block) ? text + block.children.reduce((text2, child) => isPortableTextSpan(child) ? text2 + child.text : text2, "") : text, ""), isSelectionExpanded = (snapshot) => !isSelectionCollapsed(snapshot), getCaretWordSelection = (snapshot) => {
203
+ context: snapshot.context,
204
+ blocks: snapshot.context.value
205
+ }), 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) => {
221
206
  if (!snapshot.context.selection || !isSelectionCollapsed(snapshot))
222
207
  return null;
223
208
  const focusTextBlock = getFocusTextBlock(snapshot), selectionStartPoint = getSelectionStartPoint(snapshot), selectionStartOffset = selectionStartPoint ? spanSelectionPointToBlockOffset({
224
- value: snapshot.context.value,
209
+ context: snapshot.context,
225
210
  selectionPoint: selectionStartPoint
226
211
  }) : void 0;
227
212
  if (!focusTextBlock || !selectionStartPoint || !selectionStartOffset)
228
213
  return null;
229
- const previousInlineObject = getPreviousInlineObject(snapshot), blockStartPoint = getBlockStartPoint(focusTextBlock), textDirectlyBefore = getSelectionText({
214
+ const previousInlineObject = getPreviousInlineObject(snapshot), blockStartPoint = getBlockStartPoint({
215
+ context: snapshot.context,
216
+ block: focusTextBlock
217
+ }), textDirectlyBefore = getSelectionText({
230
218
  context: {
231
219
  ...snapshot.context,
232
220
  selection: {
@@ -237,7 +225,10 @@ const getFocusBlock = (snapshot) => {
237
225
  focus: selectionStartPoint
238
226
  }
239
227
  }
240
- }).split(/\s+/).at(-1), nextInlineObject = getNextInlineObject(snapshot), blockEndPoint = getBlockEndPoint(focusTextBlock), textDirectlyAfter = getSelectionText({
228
+ }).split(/\s+/).at(-1), nextInlineObject = getNextInlineObject(snapshot), blockEndPoint = getBlockEndPoint({
229
+ context: snapshot.context,
230
+ block: focusTextBlock
231
+ }), textDirectlyAfter = getSelectionText({
241
232
  context: {
242
233
  ...snapshot.context,
243
234
  selection: {
@@ -258,11 +249,11 @@ const getFocusBlock = (snapshot) => {
258
249
  ...selectionStartOffset,
259
250
  offset: selectionStartOffset.offset + textDirectlyAfter.length
260
251
  } : selectionStartOffset, caretWordStartSelectionPoint = blockOffsetToSpanSelectionPoint({
261
- value: snapshot.context.value,
252
+ context: snapshot.context,
262
253
  blockOffset: caretWordStartOffset,
263
254
  direction: "backward"
264
255
  }), caretWordEndSelectionPoint = blockOffsetToSpanSelectionPoint({
265
- value: snapshot.context.value,
256
+ context: snapshot.context,
266
257
  blockOffset: caretWordEndOffset,
267
258
  direction: "forward"
268
259
  });
@@ -283,7 +274,10 @@ function isAtTheEndOfBlock(block) {
283
274
  return (snapshot) => {
284
275
  if (!snapshot.context.selection || !isSelectionCollapsed(snapshot))
285
276
  return !1;
286
- const blockEndPoint = getBlockEndPoint(block);
277
+ const blockEndPoint = getBlockEndPoint({
278
+ context: snapshot.context,
279
+ block
280
+ });
287
281
  return isEqualSelectionPoints(snapshot.context.selection.focus, blockEndPoint);
288
282
  };
289
283
  }
@@ -291,7 +285,10 @@ function isAtTheStartOfBlock(block) {
291
285
  return (snapshot) => {
292
286
  if (!snapshot.context.selection || !isSelectionCollapsed(snapshot))
293
287
  return !1;
294
- const blockStartPoint = getBlockStartPoint(block);
288
+ const blockStartPoint = getBlockStartPoint({
289
+ context: snapshot.context,
290
+ block
291
+ });
295
292
  return isEqualSelectionPoints(snapshot.context.selection.focus, blockStartPoint);
296
293
  };
297
294
  }
@@ -299,7 +296,7 @@ function isPointAfterSelection(point) {
299
296
  return (snapshot) => {
300
297
  if (!snapshot.context.selection)
301
298
  return !1;
302
- const selection = snapshot.context.selection.backward ? reverseSelection(snapshot.context.selection) : snapshot.context.selection, pointBlockKey = isKeySegment(point.path[0]) ? point.path[0]._key : void 0, pointChildKey = isKeySegment(point.path[2]) ? point.path[2]._key : void 0, endBlockKey = isKeySegment(selection.focus.path[0]) ? selection.focus.path[0]._key : void 0, endChildKey = isKeySegment(selection.focus.path[2]) ? selection.focus.path[2]._key : void 0;
299
+ 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;
303
300
  if (!pointBlockKey || !endBlockKey)
304
301
  return !1;
305
302
  let after = !1;
@@ -309,7 +306,7 @@ function isPointAfterSelection(point) {
309
306
  after = !0;
310
307
  break;
311
308
  }
312
- if (!isPortableTextTextBlock(block) || !pointChildKey || !endChildKey)
309
+ if (!isTextBlock(snapshot.context, block) || !pointChildKey || !endChildKey)
313
310
  break;
314
311
  for (const child of block.children) {
315
312
  if (child._key === endChildKey) {
@@ -334,7 +331,7 @@ function isPointBeforeSelection(point) {
334
331
  return (snapshot) => {
335
332
  if (!snapshot.context.selection)
336
333
  return !1;
337
- const selection = snapshot.context.selection.backward ? reverseSelection(snapshot.context.selection) : snapshot.context.selection, pointBlockKey = isKeySegment(point.path[0]) ? point.path[0]._key : void 0, pointChildKey = isKeySegment(point.path[2]) ? point.path[2]._key : void 0, startBlockKey = isKeySegment(selection.anchor.path[0]) ? selection.anchor.path[0]._key : void 0, startChildKey = isKeySegment(selection.anchor.path[2]) ? selection.anchor.path[2]._key : void 0;
334
+ 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;
338
335
  if (!pointBlockKey || !startBlockKey)
339
336
  return !1;
340
337
  let before = !1;
@@ -344,7 +341,7 @@ function isPointBeforeSelection(point) {
344
341
  before = !0;
345
342
  break;
346
343
  }
347
- if (!isPortableTextTextBlock(block) || !pointChildKey || !startChildKey)
344
+ if (!isTextBlock(snapshot.context, block) || !pointChildKey || !startChildKey)
348
345
  break;
349
346
  for (const child of block.children) {
350
347
  if (child._key === pointChildKey) {
@@ -423,7 +420,6 @@ function isOverlappingSelection(selection) {
423
420
  };
424
421
  }
425
422
  export {
426
- createGuards,
427
423
  getCaretWordSelection,
428
424
  getFirstBlock,
429
425
  getFocusBlock,
@@ -1 +1 @@
1
- {"version":3,"file":"selector.is-overlapping-selection.js","sources":["../../src/selectors/selector.is-selection-collapsed.ts","../../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-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","../../src/selectors/selector.is-point-after-selection.ts","../../src/selectors/selector.is-point-before-selection.ts","../../src/selectors/selector.is-overlapping-selection.ts"],"sourcesContent":["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 {\n isPortableTextListBlock,\n isPortableTextTextBlock,\n type PortableTextListBlock,\n type PortableTextTextBlock,\n} from '@sanity/types'\nimport type {EditorSchema} from '../editor/editor-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'\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","import {isKeySegment, isPortableTextTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {reverseSelection} from '../utils/util.reverse-selection'\n\n/**\n * @public\n */\nexport function isPointAfterSelection(\n point: EditorSelectionPoint,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const selection = snapshot.context.selection.backward\n ? reverseSelection(snapshot.context.selection)\n : snapshot.context.selection\n\n const pointBlockKey = isKeySegment(point.path[0])\n ? point.path[0]._key\n : undefined\n const pointChildKey = isKeySegment(point.path[2])\n ? point.path[2]._key\n : undefined\n\n const endBlockKey = isKeySegment(selection.focus.path[0])\n ? selection.focus.path[0]._key\n : undefined\n const endChildKey = isKeySegment(selection.focus.path[2])\n ? selection.focus.path[2]._key\n : undefined\n\n if (!pointBlockKey || !endBlockKey) {\n return false\n }\n\n let after = false\n\n for (const block of snapshot.context.value) {\n if (block._key === endBlockKey) {\n if (block._key !== pointBlockKey) {\n after = true\n break\n }\n\n // Both the point and the selection end in this block\n\n if (!isPortableTextTextBlock(block)) {\n break\n }\n\n if (!pointChildKey || !endChildKey) {\n break\n }\n\n for (const child of block.children) {\n if (child._key === endChildKey) {\n if (child._key !== pointChildKey) {\n after = true\n break\n }\n\n // Both the point and the selection end in this child\n\n after = point.offset > selection.focus.offset\n break\n }\n\n if (child._key === pointChildKey) {\n break\n }\n }\n }\n\n if (block._key === pointBlockKey) {\n break\n }\n }\n\n return after\n }\n}\n","import {isKeySegment, isPortableTextTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {reverseSelection} from '../utils/util.reverse-selection'\n\n/**\n * @public\n */\nexport function isPointBeforeSelection(\n point: EditorSelectionPoint,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const selection = snapshot.context.selection.backward\n ? reverseSelection(snapshot.context.selection)\n : snapshot.context.selection\n\n const pointBlockKey = isKeySegment(point.path[0])\n ? point.path[0]._key\n : undefined\n const pointChildKey = isKeySegment(point.path[2])\n ? point.path[2]._key\n : undefined\n\n const startBlockKey = isKeySegment(selection.anchor.path[0])\n ? selection.anchor.path[0]._key\n : undefined\n const startChildKey = isKeySegment(selection.anchor.path[2])\n ? selection.anchor.path[2]._key\n : undefined\n\n if (!pointBlockKey || !startBlockKey) {\n return false\n }\n\n let before = false\n\n for (const block of snapshot.context.value) {\n if (block._key === pointBlockKey) {\n if (block._key !== startBlockKey) {\n before = true\n break\n }\n\n // Both the point and the selection start in this block\n\n if (!isPortableTextTextBlock(block)) {\n break\n }\n\n if (!pointChildKey || !startChildKey) {\n break\n }\n\n for (const child of block.children) {\n if (child._key === pointChildKey) {\n if (child._key !== startChildKey) {\n before = true\n break\n }\n\n // Both the point and the selection start in this child\n\n before = point.offset < selection.anchor.offset\n break\n }\n\n if (child._key === startChildKey) {\n break\n }\n }\n }\n\n if (block._key === startBlockKey) {\n break\n }\n }\n\n return before\n }\n}\n","import type {EditorSelection} from '../types/editor'\nimport {isEqualSelectionPoints} from '../utils'\nimport type {EditorSelector} from './../editor/editor-selector'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\nimport {isPointAfterSelection} from './selector.is-point-after-selection'\nimport {isPointBeforeSelection} from './selector.is-point-before-selection'\n\n/**\n * @public\n */\nexport function isOverlappingSelection(\n selection: EditorSelection,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!selection || !snapshot.context.selection) {\n return false\n }\n\n const selectionStartPoint = getSelectionStartPoint({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection,\n },\n })\n const selectionEndPoint = getSelectionEndPoint({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection,\n },\n })\n\n const originalSelectionStartPoint = getSelectionStartPoint(snapshot)\n const originalSelectionEndPoint = getSelectionEndPoint(snapshot)\n\n if (\n !selectionStartPoint ||\n !selectionEndPoint ||\n !originalSelectionStartPoint ||\n !originalSelectionEndPoint\n ) {\n return false\n }\n\n const startPointBeforeSelection =\n isPointBeforeSelection(selectionStartPoint)(snapshot)\n const startPointAfterSelection =\n isPointAfterSelection(selectionStartPoint)(snapshot)\n const endPointBeforeSelection =\n isPointBeforeSelection(selectionEndPoint)(snapshot)\n const endPointAfterSelection =\n isPointAfterSelection(selectionEndPoint)(snapshot)\n\n const originalStartPointBeforeStartPoint = isPointBeforeSelection(\n originalSelectionStartPoint,\n )({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: selectionStartPoint,\n focus: selectionStartPoint,\n },\n },\n })\n const originalStartPointAfterStartPoint = isPointAfterSelection(\n originalSelectionStartPoint,\n )({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: selectionStartPoint,\n focus: selectionStartPoint,\n },\n },\n })\n\n const originalEndPointBeforeEndPoint = isPointBeforeSelection(\n originalSelectionEndPoint,\n )({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: selectionEndPoint,\n focus: selectionEndPoint,\n },\n },\n })\n const originalEndPointAfterEndPoint = isPointAfterSelection(\n originalSelectionEndPoint,\n )({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: selectionEndPoint,\n focus: selectionEndPoint,\n },\n },\n })\n\n const endPointEqualToOriginalStartPoint = isEqualSelectionPoints(\n selectionEndPoint,\n originalSelectionStartPoint,\n )\n const startPointEqualToOriginalEndPoint = isEqualSelectionPoints(\n selectionStartPoint,\n originalSelectionEndPoint,\n )\n\n if (endPointBeforeSelection && !endPointEqualToOriginalStartPoint) {\n return false\n }\n\n if (startPointAfterSelection && !startPointEqualToOriginalEndPoint) {\n return false\n }\n\n if (\n !originalStartPointBeforeStartPoint &&\n originalStartPointAfterStartPoint &&\n !originalEndPointBeforeEndPoint &&\n originalEndPointAfterEndPoint\n ) {\n return !endPointEqualToOriginalStartPoint\n }\n\n if (\n originalStartPointBeforeStartPoint &&\n !originalStartPointAfterStartPoint &&\n originalEndPointBeforeEndPoint &&\n !originalEndPointAfterEndPoint\n ) {\n return !startPointEqualToOriginalEndPoint\n }\n\n if (\n !startPointAfterSelection ||\n !startPointBeforeSelection ||\n !endPointAfterSelection ||\n !endPointBeforeSelection\n ) {\n return true\n }\n\n return false\n }\n}\n"],"names":["isSelectionCollapsed","snapshot","context","selection","JSON","stringify","anchor","path","focus","offset","createGuards","schema","isListBlock","block","isPortableTextListBlock","_type","name","isTextBlock","isPortableTextTextBlock","getFocusBlock","key","isKeySegment","_key","undefined","node","value","find","getFocusListBlock","guards","focusBlock","getFocusTextBlock","getFocusBlockObject","getFocusChild","children","span","getFocusSpan","focusChild","isPortableTextSpan","getFirstBlock","getLastBlock","length","getSelectedBlocks","selectedBlocks","startKey","backward","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","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","isPointAfterSelection","point","reverseSelection","pointBlockKey","pointChildKey","endBlockKey","endChildKey","after","isPointBeforeSelection","startBlockKey","startChildKey","before","isOverlappingSelection","originalSelectionStartPoint","originalSelectionEndPoint","startPointBeforeSelection","startPointAfterSelection","endPointBeforeSelection","endPointAfterSelection","originalStartPointBeforeStartPoint","originalStartPointAfterStartPoint","originalEndPointBeforeEndPoint","originalEndPointAfterEndPoint","endPointEqualToOriginalStartPoint","isEqualSelectionPoints","startPointEqualToOriginalEndPoint"],"mappings":";;AAKO,MAAMA,uBAAiDC,CAAAA,aACvDA,SAASC,QAAQC,YAKpBC,KAAKC,UAAUJ,SAASC,QAAQC,UAAUG,OAAOC,IAAI,MACnDH,KAAKC,UAAUJ,SAASC,QAAQC,UAAUK,MAAMD,IAAI,KACtDN,SAASC,QAAQC,WAAWG,OAAOG,WACjCR,SAASC,QAAQC,WAAWK,MAAMC,SAP7B;ACMJ,SAASC,aAAa;AAAA,EAACC;AA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BzC,iBAAiB,EAAE5D,QAAQ,GAE7CwH,qCAAqCX,uBACzCK,2BACF,EAAE;AAAA,MACA,GAAGlH;AAAAA,MACHC,SAAS;AAAA,QACP,GAAGD,SAASC;AAAAA,QACZC,WAAW;AAAA,UACTG,QAAQ8D;AAAAA,UACR5D,OAAO4D;AAAAA,QAAAA;AAAAA,MACT;AAAA,IAEH,CAAA,GACKsD,oCAAoCpB,sBACxCa,2BACF,EAAE;AAAA,MACA,GAAGlH;AAAAA,MACHC,SAAS;AAAA,QACP,GAAGD,SAASC;AAAAA,QACZC,WAAW;AAAA,UACTG,QAAQ8D;AAAAA,UACR5D,OAAO4D;AAAAA,QAAAA;AAAAA,MACT;AAAA,IAEH,CAAA,GAEKuD,iCAAiCb,uBACrCM,yBACF,EAAE;AAAA,MACA,GAAGnH;AAAAA,MACHC,SAAS;AAAA,QACP,GAAGD,SAASC;AAAAA,QACZC,WAAW;AAAA,UACTG,QAAQuD;AAAAA,UACRrD,OAAOqD;AAAAA,QAAAA;AAAAA,MACT;AAAA,IAEH,CAAA,GACK+D,gCAAgCtB,sBACpCc,yBACF,EAAE;AAAA,MACA,GAAGnH;AAAAA,MACHC,SAAS;AAAA,QACP,GAAGD,SAASC;AAAAA,QACZC,WAAW;AAAA,UACTG,QAAQuD;AAAAA,UACRrD,OAAOqD;AAAAA,QAAAA;AAAAA,MACT;AAAA,IACF,CACD,GAEKgE,oCAAoCC,uBACxCjE,mBACAsD,2BACF,GACMY,oCAAoCD,uBACxC1D,qBACAgD,yBACF;AAMA,WAJIG,2BAA2B,CAACM,qCAI5BP,4BAA4B,CAACS,oCACxB,KAIP,CAACN,sCACDC,qCACA,CAACC,kCACDC,gCAEO,CAACC,oCAIRJ,sCACA,CAACC,qCACDC,kCACA,CAACC,gCAEM,CAACG,oCAIR,CAACT,4BACD,CAACD,6BACD,CAACG,0BACD,CAACD;AAAAA,EAML;AACF;"}
1
+ {"version":3,"file":"selector.is-overlapping-selection.js","sources":["../../src/selectors/selector.is-selection-collapsed.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-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","../../src/selectors/selector.is-point-after-selection.ts","../../src/selectors/selector.is-point-before-selection.ts","../../src/selectors/selector.is-overlapping-selection.ts"],"sourcesContent":["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 {\n KeyedSegment,\n PortableTextBlock,\n PortableTextListBlock,\n PortableTextObject,\n PortableTextSpan,\n PortableTextTextBlock,\n} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isListBlock, isSpan, isTextBlock} from '../internal-utils/parse-blocks'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\n\n/**\n * @public\n */\nexport const getFocusBlock: EditorSelector<\n {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n> = (snapshot) => {\n const key = snapshot.context.selection\n ? isKeyedSegment(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 focusTextBlock = getFocusTextBlock(snapshot)\n\n return focusTextBlock && isListBlock(snapshot.context, focusTextBlock.node)\n ? {node: focusTextBlock.node, path: focusTextBlock.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 && isTextBlock(snapshot.context, 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 && !isTextBlock(snapshot.context, 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 ? isKeyedSegment(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 && isSpan(snapshot.context, 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 ? 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 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 ? 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\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 ? 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 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 context: snapshot.context,\n blocks: snapshot.context.value,\n })\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {isSpan, isTextBlock} from '../internal-utils/parse-blocks'\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 (!isTextBlock(snapshot.context, block)) {\n return text\n }\n\n return (\n text +\n block.children.reduce((text, child) => {\n if (isSpan(snapshot.context, child)) {\n return text + child.text\n }\n\n return text\n }, '')\n )\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 context: snapshot.context,\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({\n context: snapshot.context,\n block: focusTextBlock,\n })\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({\n context: snapshot.context,\n block: focusTextBlock,\n })\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 context: snapshot.context,\n blockOffset: caretWordStartOffset,\n direction: 'backward',\n })\n const caretWordEndSelectionPoint = blockOffsetToSpanSelectionPoint({\n context: snapshot.context,\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({\n context: snapshot.context,\n block,\n })\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({\n context: snapshot.context,\n block,\n })\n\n return utils.isEqualSelectionPoints(\n snapshot.context.selection.focus,\n blockStartPoint,\n )\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {reverseSelection} from '../utils/util.reverse-selection'\n\n/**\n * @public\n */\nexport function isPointAfterSelection(\n point: EditorSelectionPoint,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const selection = snapshot.context.selection.backward\n ? reverseSelection(snapshot.context.selection)\n : snapshot.context.selection\n\n const pointBlockKey = isKeyedSegment(point.path[0])\n ? point.path[0]._key\n : undefined\n const pointChildKey = isKeyedSegment(point.path[2])\n ? point.path[2]._key\n : undefined\n\n const endBlockKey = isKeyedSegment(selection.focus.path[0])\n ? selection.focus.path[0]._key\n : undefined\n const endChildKey = isKeyedSegment(selection.focus.path[2])\n ? selection.focus.path[2]._key\n : undefined\n\n if (!pointBlockKey || !endBlockKey) {\n return false\n }\n\n let after = false\n\n for (const block of snapshot.context.value) {\n if (block._key === endBlockKey) {\n if (block._key !== pointBlockKey) {\n after = true\n break\n }\n\n // Both the point and the selection end in this block\n\n if (!isTextBlock(snapshot.context, block)) {\n break\n }\n\n if (!pointChildKey || !endChildKey) {\n break\n }\n\n for (const child of block.children) {\n if (child._key === endChildKey) {\n if (child._key !== pointChildKey) {\n after = true\n break\n }\n\n // Both the point and the selection end in this child\n\n after = point.offset > selection.focus.offset\n break\n }\n\n if (child._key === pointChildKey) {\n break\n }\n }\n }\n\n if (block._key === pointBlockKey) {\n break\n }\n }\n\n return after\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {reverseSelection} from '../utils/util.reverse-selection'\n\n/**\n * @public\n */\nexport function isPointBeforeSelection(\n point: EditorSelectionPoint,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const selection = snapshot.context.selection.backward\n ? reverseSelection(snapshot.context.selection)\n : snapshot.context.selection\n\n const pointBlockKey = isKeyedSegment(point.path[0])\n ? point.path[0]._key\n : undefined\n const pointChildKey = isKeyedSegment(point.path[2])\n ? point.path[2]._key\n : undefined\n\n const startBlockKey = isKeyedSegment(selection.anchor.path[0])\n ? selection.anchor.path[0]._key\n : undefined\n const startChildKey = isKeyedSegment(selection.anchor.path[2])\n ? selection.anchor.path[2]._key\n : undefined\n\n if (!pointBlockKey || !startBlockKey) {\n return false\n }\n\n let before = false\n\n for (const block of snapshot.context.value) {\n if (block._key === pointBlockKey) {\n if (block._key !== startBlockKey) {\n before = true\n break\n }\n\n // Both the point and the selection start in this block\n\n if (!isTextBlock(snapshot.context, block)) {\n break\n }\n\n if (!pointChildKey || !startChildKey) {\n break\n }\n\n for (const child of block.children) {\n if (child._key === pointChildKey) {\n if (child._key !== startChildKey) {\n before = true\n break\n }\n\n // Both the point and the selection start in this child\n\n before = point.offset < selection.anchor.offset\n break\n }\n\n if (child._key === startChildKey) {\n break\n }\n }\n }\n\n if (block._key === startBlockKey) {\n break\n }\n }\n\n return before\n }\n}\n","import type {EditorSelection} from '../types/editor'\nimport {isEqualSelectionPoints} from '../utils'\nimport type {EditorSelector} from './../editor/editor-selector'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\nimport {isPointAfterSelection} from './selector.is-point-after-selection'\nimport {isPointBeforeSelection} from './selector.is-point-before-selection'\n\n/**\n * @public\n */\nexport function isOverlappingSelection(\n selection: EditorSelection,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!selection || !snapshot.context.selection) {\n return false\n }\n\n const selectionStartPoint = getSelectionStartPoint({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection,\n },\n })\n const selectionEndPoint = getSelectionEndPoint({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection,\n },\n })\n\n const originalSelectionStartPoint = getSelectionStartPoint(snapshot)\n const originalSelectionEndPoint = getSelectionEndPoint(snapshot)\n\n if (\n !selectionStartPoint ||\n !selectionEndPoint ||\n !originalSelectionStartPoint ||\n !originalSelectionEndPoint\n ) {\n return false\n }\n\n const startPointBeforeSelection =\n isPointBeforeSelection(selectionStartPoint)(snapshot)\n const startPointAfterSelection =\n isPointAfterSelection(selectionStartPoint)(snapshot)\n const endPointBeforeSelection =\n isPointBeforeSelection(selectionEndPoint)(snapshot)\n const endPointAfterSelection =\n isPointAfterSelection(selectionEndPoint)(snapshot)\n\n const originalStartPointBeforeStartPoint = isPointBeforeSelection(\n originalSelectionStartPoint,\n )({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: selectionStartPoint,\n focus: selectionStartPoint,\n },\n },\n })\n const originalStartPointAfterStartPoint = isPointAfterSelection(\n originalSelectionStartPoint,\n )({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: selectionStartPoint,\n focus: selectionStartPoint,\n },\n },\n })\n\n const originalEndPointBeforeEndPoint = isPointBeforeSelection(\n originalSelectionEndPoint,\n )({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: selectionEndPoint,\n focus: selectionEndPoint,\n },\n },\n })\n const originalEndPointAfterEndPoint = isPointAfterSelection(\n originalSelectionEndPoint,\n )({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: selectionEndPoint,\n focus: selectionEndPoint,\n },\n },\n })\n\n const endPointEqualToOriginalStartPoint = isEqualSelectionPoints(\n selectionEndPoint,\n originalSelectionStartPoint,\n )\n const startPointEqualToOriginalEndPoint = isEqualSelectionPoints(\n selectionStartPoint,\n originalSelectionEndPoint,\n )\n\n if (endPointBeforeSelection && !endPointEqualToOriginalStartPoint) {\n return false\n }\n\n if (startPointAfterSelection && !startPointEqualToOriginalEndPoint) {\n return false\n }\n\n if (\n !originalStartPointBeforeStartPoint &&\n originalStartPointAfterStartPoint &&\n !originalEndPointBeforeEndPoint &&\n originalEndPointAfterEndPoint\n ) {\n return !endPointEqualToOriginalStartPoint\n }\n\n if (\n originalStartPointBeforeStartPoint &&\n !originalStartPointAfterStartPoint &&\n originalEndPointBeforeEndPoint &&\n !originalEndPointAfterEndPoint\n ) {\n return !startPointEqualToOriginalEndPoint\n }\n\n if (\n !startPointAfterSelection ||\n !startPointBeforeSelection ||\n !endPointAfterSelection ||\n !endPointBeforeSelection\n ) {\n return true\n }\n\n return false\n }\n}\n"],"names":["isSelectionCollapsed","snapshot","context","selection","JSON","stringify","anchor","path","focus","offset","getFocusBlock","key","isKeyedSegment","_key","undefined","node","value","find","block","getFocusListBlock","focusTextBlock","getFocusTextBlock","isListBlock","focusBlock","isTextBlock","getFocusBlockObject","getFocusChild","children","span","getFocusSpan","focusChild","isSpan","getFirstBlock","getLastBlock","length","getSelectedBlocks","selectedBlocks","startKey","backward","endKey","push","getSelectionStartBlock","getSelectionEndBlock","getPreviousBlock","previousBlock","selectionStartBlock","foundSelectionStartBlock","getNextBlock","nextBlock","selectionEndBlock","foundSelectionEndBlock","getSelectionEndPoint","getSelectionStartPoint","getNextInlineObject","selectionEndPoint","selectionEndPointChildKey","isKeySegment","endPointChildFound","inlineObject","child","getPreviousInlineObject","selectionStartPoint","selectionStartPointChildKey","getSelectedSlice","sliceBlocks","blocks","getSelectionText","reduce","text","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","isPointAfterSelection","point","reverseSelection","pointBlockKey","pointChildKey","endBlockKey","endChildKey","after","isPointBeforeSelection","startBlockKey","startChildKey","before","isOverlappingSelection","originalSelectionStartPoint","originalSelectionEndPoint","startPointBeforeSelection","startPointAfterSelection","endPointBeforeSelection","endPointAfterSelection","originalStartPointBeforeStartPoint","originalStartPointAfterStartPoint","originalEndPointBeforeEndPoint","originalEndPointAfterEndPoint","endPointEqualToOriginalStartPoint","isEqualSelectionPoints","startPointEqualToOriginalEndPoint"],"mappings":";;AAKO,MAAMA,uBAAiDC,CAAAA,aACvDA,SAASC,QAAQC,YAKpBC,KAAKC,UAAUJ,SAASC,QAAQC,UAAUG,OAAOC,IAAI,MACnDH,KAAKC,UAAUJ,SAASC,QAAQC,UAAUK,MAAMD,IAAI,KACtDN,SAASC,QAAQC,WAAWG,OAAOG,WACjCR,SAASC,QAAQC,WAAWK,MAAMC,SAP7B,ICQEC,gBAERT,CAAa,aAAA;AAChB,QAAMU,MAAMV,SAASC,QAA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