@portabletext/editor 2.6.2 → 2.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +29 -29
  2. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
  3. package/lib/_chunks-cjs/selector.is-selection-expanded.cjs +5 -5
  4. package/lib/_chunks-cjs/selector.is-selection-expanded.cjs.map +1 -1
  5. package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs +3 -3
  6. package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs.map +1 -1
  7. package/lib/_chunks-cjs/util.is-selection-collapsed.cjs +5 -5
  8. package/lib/_chunks-cjs/util.is-selection-collapsed.cjs.map +1 -1
  9. package/lib/_chunks-cjs/util.merge-text-blocks.cjs +2 -6
  10. package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +1 -1
  11. package/lib/_chunks-cjs/util.slice-blocks.cjs +106 -117
  12. package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
  13. package/lib/_chunks-cjs/util.slice-text-block.cjs +3 -3
  14. package/lib/_chunks-cjs/util.slice-text-block.cjs.map +1 -1
  15. package/lib/_chunks-dts/behavior.types.action.d.cts +10 -10
  16. package/lib/_chunks-dts/behavior.types.action.d.ts +1 -1
  17. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +3 -2
  18. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
  19. package/lib/_chunks-es/selector.is-selection-expanded.js +3 -2
  20. package/lib/_chunks-es/selector.is-selection-expanded.js.map +1 -1
  21. package/lib/_chunks-es/util.child-selection-point-to-block-offset.js +2 -1
  22. package/lib/_chunks-es/util.child-selection-point-to-block-offset.js.map +1 -1
  23. package/lib/_chunks-es/util.is-selection-collapsed.js +2 -1
  24. package/lib/_chunks-es/util.is-selection-collapsed.js.map +1 -1
  25. package/lib/_chunks-es/util.merge-text-blocks.js +2 -5
  26. package/lib/_chunks-es/util.merge-text-blocks.js.map +1 -1
  27. package/lib/_chunks-es/util.slice-blocks.js +101 -112
  28. package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
  29. package/lib/_chunks-es/util.slice-text-block.js +2 -1
  30. package/lib/_chunks-es/util.slice-text-block.js.map +1 -1
  31. package/lib/index.cjs +132 -95
  32. package/lib/index.cjs.map +1 -1
  33. package/lib/index.js +41 -4
  34. package/lib/index.js.map +1 -1
  35. package/lib/plugins/index.cjs +5 -5
  36. package/lib/plugins/index.cjs.map +1 -1
  37. package/lib/plugins/index.d.cts +3 -3
  38. package/lib/plugins/index.js +6 -5
  39. package/lib/plugins/index.js.map +1 -1
  40. package/lib/selectors/index.cjs +3 -3
  41. package/lib/selectors/index.cjs.map +1 -1
  42. package/lib/selectors/index.js +2 -1
  43. package/lib/selectors/index.js.map +1 -1
  44. package/lib/utils/index.cjs +14 -4
  45. package/lib/utils/index.cjs.map +1 -1
  46. package/lib/utils/index.d.cts +4 -11
  47. package/lib/utils/index.d.ts +2 -9
  48. package/lib/utils/index.js +4 -3
  49. package/lib/utils/index.js.map +1 -1
  50. package/package.json +10 -9
  51. package/src/behaviors/behavior.abstract.delete.ts +1 -1
  52. package/src/behaviors/behavior.abstract.deserialize.ts +1 -1
  53. package/src/behaviors/behavior.abstract.split.ts +2 -1
  54. package/src/behaviors/behavior.core.block-objects.ts +1 -1
  55. package/src/behaviors/behavior.core.lists.ts +2 -1
  56. package/src/behaviors/behavior.markdown.ts +1 -1
  57. package/src/converters/converter.text-plain.ts +2 -1
  58. package/src/editor/Editable.tsx +1 -1
  59. package/src/editor/__tests__/PortableTextEditor.test.tsx +1 -1
  60. package/src/editor/__tests__/RangeDecorations.test.tsx +1 -1
  61. package/src/editor/__tests__/self-solving.test.tsx +1 -1
  62. package/src/editor/components/render-element.tsx +1 -1
  63. package/src/editor/plugins/__tests__/withEditableAPIDelete.test.tsx +1 -1
  64. package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +2 -3
  65. package/src/editor/plugins/__tests__/withEditableAPIInsert.test.tsx +1 -1
  66. package/src/editor/plugins/__tests__/withEditableAPISelectionsOverlapping.test.tsx +1 -1
  67. package/src/editor/plugins/__tests__/withPortableTextLists.test.tsx +1 -1
  68. package/src/editor/plugins/__tests__/withPortableTextMarkModel.test.tsx +1 -1
  69. package/src/editor/plugins/__tests__/withPortableTextSelections.test.tsx +1 -1
  70. package/src/editor/plugins/__tests__/withUndoRedo.test.tsx +1 -1
  71. package/src/editor/plugins/createWithObjectKeys.ts +1 -1
  72. package/src/editor/plugins/createWithPortableTextMarkModel.ts +1 -1
  73. package/src/editor/plugins/createWithSchemaTypes.ts +2 -5
  74. package/src/internal-utils/__tests__/valueNormalization.test.tsx +1 -1
  75. package/src/internal-utils/apply-operation-to-portable-text.test.ts +1 -1
  76. package/src/internal-utils/build-index-maps.ts +1 -1
  77. package/src/internal-utils/create-test-snapshot.ts +1 -1
  78. package/src/internal-utils/drag-selection.test.ts +1 -1
  79. package/src/internal-utils/editor-selection.ts +1 -1
  80. package/src/internal-utils/operation-to-patches.ts +1 -1
  81. package/src/internal-utils/parse-blocks.test.ts +1 -1
  82. package/src/internal-utils/parse-blocks.ts +1 -38
  83. package/src/internal-utils/selection-focus-text.ts +1 -1
  84. package/src/internal-utils/selection-text.ts +1 -1
  85. package/src/internal-utils/test-editor.tsx +1 -1
  86. package/src/internal-utils/text-block-key.ts +1 -1
  87. package/src/internal-utils/text-marks.ts +1 -1
  88. package/src/internal-utils/text-selection.ts +1 -1
  89. package/src/internal-utils/to-slate-range.test.ts +1 -1
  90. package/src/internal-utils/to-slate-range.ts +1 -1
  91. package/src/internal-utils/validateValue.ts +1 -1
  92. package/src/internal-utils/value-annotations.ts +1 -1
  93. package/src/operations/behavior.operation.block.unset.ts +2 -1
  94. package/src/operations/behavior.operation.delete.ts +98 -2
  95. package/src/operations/behavior.operation.insert.block.ts +2 -1
  96. package/src/plugins/plugin.behavior.tsx +3 -1
  97. package/src/plugins/plugin.internal.auto-close-brackets.test.tsx +1 -2
  98. package/src/plugins/plugin.markdown.test.tsx +1 -2
  99. package/src/selectors/selector.get-active-annotations.ts +1 -1
  100. package/src/selectors/selector.get-active-list-item.ts +1 -1
  101. package/src/selectors/selector.get-active-style.ts +1 -1
  102. package/src/selectors/selector.get-anchor-text-block.ts +1 -1
  103. package/src/selectors/selector.get-caret-word-selection.test.ts +1 -1
  104. package/src/selectors/selector.get-focus-block-object.ts +1 -1
  105. package/src/selectors/selector.get-focus-span.ts +1 -1
  106. package/src/selectors/selector.get-focus-text-block.ts +1 -1
  107. package/src/selectors/selector.get-list-state.ts +1 -1
  108. package/src/selectors/selector.get-next-span.ts +1 -1
  109. package/src/selectors/selector.get-previous-span.ts +1 -1
  110. package/src/selectors/selector.get-selected-spans.ts +1 -1
  111. package/src/selectors/selector.get-selected-text-blocks.ts +1 -1
  112. package/src/selectors/selector.get-selection-text.ts +1 -1
  113. package/src/selectors/selector.get-trimmed-selection.test.ts +1 -1
  114. package/src/selectors/selector.get-trimmed-selection.ts +1 -1
  115. package/src/selectors/selector.is-active-annotation.ts +1 -1
  116. package/src/selectors/selector.is-point-after-selection.ts +1 -1
  117. package/src/selectors/selector.is-point-before-selection.ts +1 -1
  118. package/src/utils/index.ts +1 -2
  119. package/src/utils/util.at-the-beginning-of-block.ts +1 -1
  120. package/src/utils/util.block-offset.ts +1 -1
  121. package/src/utils/util.child-selection-point-to-block-offset.ts +1 -1
  122. package/src/utils/util.get-block-end-point.ts +1 -1
  123. package/src/utils/util.get-block-start-point.ts +1 -1
  124. package/src/utils/util.is-empty-text-block.ts +1 -1
  125. package/src/utils/util.merge-text-blocks.ts +1 -1
  126. package/src/utils/util.slice-blocks.ts +2 -2
  127. package/src/utils/util.slice-text-block.ts +2 -2
  128. package/src/utils/util.split-text-block.ts +1 -1
  129. package/src/internal-utils/terse-pt.test.ts +0 -175
  130. package/src/internal-utils/terse-pt.ts +0 -150
  131. package/src/internal-utils/test-key-generator.ts +0 -9
  132. package/src/utils/util.is-span.ts +0 -12
  133. package/src/utils/util.is-text-block.ts +0 -13
@@ -1,6 +1,6 @@
1
1
  import {compileSchema, defineSchema} from '@portabletext/schema'
2
+ import {createTestKeyGenerator} from '@portabletext/test'
2
3
  import {describe, expect, test} from 'vitest'
3
- import {createTestKeyGenerator} from './test-key-generator'
4
4
  import {toSlateRange} from './to-slate-range'
5
5
 
6
6
  describe(toSlateRange.name, () => {
@@ -1,3 +1,4 @@
1
+ import {isSpan, isTextBlock} from '@portabletext/schema'
1
2
  import type {PortableTextObject, PortableTextSpan} from '@sanity/types'
2
3
  import type {Path, Range} from 'slate'
3
4
  import type {EditorContext, EditorSnapshot} from '../editor/editor-snapshot'
@@ -8,7 +9,6 @@ import {
8
9
  import type {EditorSelectionPoint} from '../types/editor'
9
10
  import {isEqualSelectionPoints} from '../utils'
10
11
  import {blockOffsetToSpanSelectionPoint} from '../utils/util.block-offset'
11
- import {isSpan, isTextBlock} from './parse-blocks'
12
12
 
13
13
  export function toSlateRange(
14
14
  snapshot: {
@@ -1,4 +1,5 @@
1
1
  import {insert, set, setIfMissing, unset} from '@portabletext/patches'
2
+ import {isTextBlock} from '@portabletext/schema'
2
3
  import type {
3
4
  PortableTextBlock,
4
5
  PortableTextSpan,
@@ -7,7 +8,6 @@ import type {
7
8
  import {flatten, isPlainObject, uniq} from 'lodash'
8
9
  import type {EditorSchema} from '../editor/editor-schema'
9
10
  import type {InvalidValueResolution} from '../types/editor'
10
- import {isTextBlock} from './parse-blocks'
11
11
 
12
12
  export interface Validation {
13
13
  valid: boolean
@@ -1,6 +1,6 @@
1
+ import {isSpan, isTextBlock} from '@portabletext/schema'
1
2
  import type {PortableTextBlock} from '@sanity/types'
2
3
  import type {EditorSchema} from '../editor/editor-schema'
3
- import {isSpan, isTextBlock} from './parse-blocks'
4
4
 
5
5
  export function getValueAnnotations(
6
6
  schema: EditorSchema,
@@ -1,6 +1,7 @@
1
+ import {isTextBlock} from '@portabletext/schema'
1
2
  import {omit} from 'lodash'
2
3
  import {Editor, Transforms} from 'slate'
3
- import {isTextBlock, parseBlock} from '../internal-utils/parse-blocks'
4
+ import {parseBlock} from '../internal-utils/parse-blocks'
4
5
  import {toSlateRange} from '../internal-utils/to-slate-range'
5
6
  import {fromSlateValue} from '../internal-utils/values'
6
7
  import {KEY_TO_VALUE_ELEMENT} from '../internal-utils/weakMaps'
@@ -1,9 +1,18 @@
1
- import {deleteText, setSelection, Transforms} from 'slate'
1
+ import {isTextBlock} from '@portabletext/schema'
2
+ import {
3
+ deleteText,
4
+ Editor,
5
+ Element,
6
+ Range,
7
+ setSelection,
8
+ Transforms,
9
+ } from 'slate'
10
+ import {DOMEditor} from 'slate-dom'
2
11
  import {createPlaceholderBlock} from '../internal-utils/create-placeholder-block'
3
- import {isTextBlock} from '../internal-utils/parse-blocks'
4
12
  import {getBlockPath} from '../internal-utils/slate-utils'
5
13
  import {toSlateRange} from '../internal-utils/to-slate-range'
6
14
  import {getBlockKeyFromSelectionPoint} from '../selection/selection-point'
15
+ import {PortableTextSlateEditor} from '../types/editor'
7
16
  import type {BehaviorOperationImplementation} from './behavior.operations'
8
17
 
9
18
  export const deleteOperationImplementation: BehaviorOperationImplementation<
@@ -98,6 +107,32 @@ export const deleteOperationImplementation: BehaviorOperationImplementation<
98
107
  )
99
108
  }
100
109
 
110
+ if (operation.direction === 'backward' && operation.unit === 'line') {
111
+ const parentBlockEntry = Editor.above(operation.editor, {
112
+ match: (n) => Element.isElement(n) && Editor.isBlock(operation.editor, n),
113
+ at: range,
114
+ })
115
+
116
+ if (parentBlockEntry) {
117
+ const [, parentBlockPath] = parentBlockEntry
118
+ const parentElementRange = Editor.range(
119
+ operation.editor,
120
+ parentBlockPath,
121
+ range.anchor,
122
+ )
123
+
124
+ const currentLineRange = findCurrentLineRange(
125
+ operation.editor,
126
+ parentElementRange,
127
+ )
128
+
129
+ if (!Range.isCollapsed(currentLineRange)) {
130
+ Transforms.delete(operation.editor, {at: currentLineRange})
131
+ return
132
+ }
133
+ }
134
+ }
135
+
101
136
  const hanging = isTextBlock(context, endBlock) && endOffset === 0
102
137
 
103
138
  deleteText(operation.editor, {
@@ -118,3 +153,64 @@ export const deleteOperationImplementation: BehaviorOperationImplementation<
118
153
  })
119
154
  }
120
155
  }
156
+
157
+ function findCurrentLineRange(
158
+ editor: PortableTextSlateEditor,
159
+ parentRange: Range,
160
+ ): Range {
161
+ const parentRangeBoundary = Editor.range(editor, Range.end(parentRange))
162
+ const positions = Array.from(Editor.positions(editor, {at: parentRange}))
163
+
164
+ let left = 0
165
+ let right = positions.length
166
+ let middle = Math.floor(right / 2)
167
+
168
+ if (
169
+ rangesAreOnSameLine(
170
+ editor,
171
+ Editor.range(editor, positions[left]),
172
+ parentRangeBoundary,
173
+ )
174
+ ) {
175
+ return Editor.range(editor, positions[left], parentRangeBoundary)
176
+ }
177
+
178
+ if (positions.length < 2) {
179
+ return Editor.range(
180
+ editor,
181
+ positions[positions.length - 1],
182
+ parentRangeBoundary,
183
+ )
184
+ }
185
+
186
+ while (middle !== positions.length && middle !== left) {
187
+ if (
188
+ rangesAreOnSameLine(
189
+ editor,
190
+ Editor.range(editor, positions[middle]),
191
+ parentRangeBoundary,
192
+ )
193
+ ) {
194
+ right = middle
195
+ } else {
196
+ left = middle
197
+ }
198
+
199
+ middle = Math.floor((left + right) / 2)
200
+ }
201
+
202
+ return Editor.range(editor, positions[left], parentRangeBoundary)
203
+ }
204
+
205
+ function rangesAreOnSameLine(editor: DOMEditor, range1: Range, range2: Range) {
206
+ const rect1 = DOMEditor.toDOMRange(editor, range1).getBoundingClientRect()
207
+ const rect2 = DOMEditor.toDOMRange(editor, range2).getBoundingClientRect()
208
+
209
+ return domRectsIntersect(rect1, rect2) && domRectsIntersect(rect2, rect1)
210
+ }
211
+
212
+ function domRectsIntersect(rect: DOMRect, compareRect: DOMRect) {
213
+ const middle = (compareRect.top + compareRect.bottom) / 2
214
+
215
+ return rect.top <= middle && rect.bottom >= middle
216
+ }
@@ -1,7 +1,8 @@
1
+ import {isSpan} from '@portabletext/schema'
1
2
  import {isEqual} from 'lodash'
2
3
  import {Editor, Path, Point, Range, Transforms, type Descendant} from 'slate'
3
4
  import {DOMEditor} from 'slate-dom'
4
- import {isSpan, parseBlock} from '../internal-utils/parse-blocks'
5
+ import {parseBlock} from '../internal-utils/parse-blocks'
5
6
  import {
6
7
  getFocusBlock,
7
8
  getFocusChild,
@@ -14,7 +14,9 @@ export function BehaviorPlugin(props: {behaviors: Array<Behavior>}) {
14
14
  )
15
15
 
16
16
  return () => {
17
- unregisterBehaviors.forEach((unregister) => unregister())
17
+ unregisterBehaviors.forEach((unregister) => {
18
+ unregister()
19
+ })
18
20
  }
19
21
  }, [editor, props.behaviors])
20
22
 
@@ -1,11 +1,10 @@
1
1
  import {defineSchema} from '@portabletext/schema'
2
+ import {createTestKeyGenerator, getTersePt} from '@portabletext/test'
2
3
  import {page, userEvent} from '@vitest/browser/context'
3
4
  import React from 'react'
4
5
  import {describe, expect, test, vi} from 'vitest'
5
6
  import {render} from 'vitest-browser-react'
6
7
  import {EditorProvider, PortableTextEditable, type Editor} from '..'
7
- import {getTersePt} from '../internal-utils/terse-pt'
8
- import {createTestKeyGenerator} from '../internal-utils/test-key-generator'
9
8
  import {EditorRefPlugin} from './plugin.editor-ref'
10
9
  import {AutoCloseBracketsPlugin} from './plugin.internal.auto-close-brackets'
11
10
 
@@ -1,12 +1,11 @@
1
1
  import {defineSchema} from '@portabletext/schema'
2
+ import {createTestKeyGenerator, getTersePt} from '@portabletext/test'
2
3
  import {page, userEvent} from '@vitest/browser/context'
3
4
  import React from 'react'
4
5
  import {describe, expect, test, vi} from 'vitest'
5
6
  import {render} from 'vitest-browser-react'
6
7
  import {PortableTextEditable, type Editor} from '..'
7
8
  import {EditorProvider} from '../editor/editor-provider'
8
- import {getTersePt} from '../internal-utils/terse-pt'
9
- import {createTestKeyGenerator} from '../internal-utils/test-key-generator'
10
9
  import {getTextMarks} from '../internal-utils/text-marks'
11
10
  import {EditorRefPlugin} from './plugin.editor-ref'
12
11
  import {MarkdownPlugin} from './plugin.markdown'
@@ -1,6 +1,6 @@
1
+ import {isTextBlock} from '@portabletext/schema'
1
2
  import type {PortableTextObject} from '@sanity/types'
2
3
  import type {EditorSelector} from '../editor/editor-selector'
3
- import {isTextBlock} from '../internal-utils/parse-blocks'
4
4
  import {getMarkState} from './selector.get-mark-state'
5
5
  import {getSelectedBlocks} from './selector.get-selected-blocks'
6
6
 
@@ -1,6 +1,6 @@
1
+ import {isTextBlock} from '@portabletext/schema'
1
2
  import type {PortableTextListBlock} from '@sanity/types'
2
3
  import type {EditorSelector} from '../editor/editor-selector'
3
- import {isTextBlock} from '../internal-utils/parse-blocks'
4
4
  import {getSelectedBlocks} from './selector.get-selected-blocks'
5
5
 
6
6
  /**
@@ -1,6 +1,6 @@
1
+ import {isTextBlock} from '@portabletext/schema'
1
2
  import type {PortableTextTextBlock} from '@sanity/types'
2
3
  import type {EditorSelector} from '../editor/editor-selector'
3
- import {isTextBlock} from '../internal-utils/parse-blocks'
4
4
  import {getSelectedBlocks} from './selector.get-selected-blocks'
5
5
 
6
6
  /**
@@ -1,6 +1,6 @@
1
+ import {isTextBlock} from '@portabletext/schema'
1
2
  import type {PortableTextTextBlock} from '@sanity/types'
2
3
  import type {EditorSelector} from '../editor/editor-selector'
3
- import {isTextBlock} from '../internal-utils/parse-blocks'
4
4
  import type {BlockPath} from '../types/paths'
5
5
  import {getAnchorBlock} from './selector.get-anchor-block'
6
6
 
@@ -1,8 +1,8 @@
1
+ import {createTestKeyGenerator} from '@portabletext/test'
1
2
  import type {PortableTextBlock} from '@sanity/types'
2
3
  import {describe, expect, test} from 'vitest'
3
4
  import type {EditorSelection} from '..'
4
5
  import {createTestSnapshot} from '../internal-utils/create-test-snapshot'
5
- import {createTestKeyGenerator} from '../internal-utils/test-key-generator'
6
6
  import {getCaretWordSelection} from './selector.get-caret-word-selection'
7
7
 
8
8
  const keyGenerator = createTestKeyGenerator()
@@ -1,6 +1,6 @@
1
+ import {isTextBlock} from '@portabletext/schema'
1
2
  import type {PortableTextObject} from '@sanity/types'
2
3
  import type {EditorSelector} from '../editor/editor-selector'
3
- import {isTextBlock} from '../internal-utils/parse-blocks'
4
4
  import type {BlockPath} from '../types/paths'
5
5
  import {getFocusBlock} from './selector.get-focus-block'
6
6
 
@@ -1,6 +1,6 @@
1
+ import {isSpan} from '@portabletext/schema'
1
2
  import type {PortableTextSpan} from '@sanity/types'
2
3
  import type {EditorSelector} from '../editor/editor-selector'
3
- import {isSpan} from '../internal-utils/parse-blocks'
4
4
  import type {ChildPath} from '../types/paths'
5
5
  import {getFocusChild} from './selector.get-focus-child'
6
6
 
@@ -1,6 +1,6 @@
1
+ import {isTextBlock} from '@portabletext/schema'
1
2
  import type {PortableTextTextBlock} from '@sanity/types'
2
3
  import type {EditorSelector} from '../editor/editor-selector'
3
- import {isTextBlock} from '../internal-utils/parse-blocks'
4
4
  import type {BlockPath} from '../types/paths'
5
5
  import {getFocusBlock} from './selector.get-focus-block'
6
6
 
@@ -1,5 +1,5 @@
1
+ import {isTextBlock} from '@portabletext/schema'
1
2
  import type {EditorSelector} from '../editor/editor-selector'
2
- import {isTextBlock} from '../internal-utils/parse-blocks'
3
3
  import type {BlockPath} from '../types/paths'
4
4
  import {getFocusTextBlock} from './selector.get-focus-text-block'
5
5
 
@@ -1,6 +1,6 @@
1
+ import {isSpan, isTextBlock} from '@portabletext/schema'
1
2
  import type {KeyedSegment, PortableTextSpan} from '@sanity/types'
2
3
  import type {EditorSelector} from '../editor/editor-selector'
3
- import {isSpan, isTextBlock} from '../internal-utils/parse-blocks'
4
4
  import {getChildKeyFromSelectionPoint} from '../selection/selection-point'
5
5
  import {getSelectionEndBlock} from './selector.get-selection-end-block'
6
6
  import {getSelectionEndPoint} from './selector.get-selection-end-point'
@@ -1,6 +1,6 @@
1
+ import {isSpan, isTextBlock} from '@portabletext/schema'
1
2
  import type {KeyedSegment, PortableTextSpan} from '@sanity/types'
2
3
  import type {EditorSelector} from '../editor/editor-selector'
3
- import {isSpan, isTextBlock} from '../internal-utils/parse-blocks'
4
4
  import {getChildKeyFromSelectionPoint} from '../selection/selection-point'
5
5
  import {getSelectionStartBlock} from './selector.get-selection-start-block'
6
6
  import {getSelectionStartPoint} from './selector.get-selection-start-point'
@@ -1,6 +1,6 @@
1
+ import {isSpan, isTextBlock} from '@portabletext/schema'
1
2
  import type {PortableTextSpan} from '@sanity/types'
2
3
  import type {EditorSelector} from '../editor/editor-selector'
3
- import {isSpan, isTextBlock} from '../internal-utils/parse-blocks'
4
4
  import {
5
5
  getBlockKeyFromSelectionPoint,
6
6
  getChildKeyFromSelectionPoint,
@@ -1,6 +1,6 @@
1
+ import {isTextBlock} from '@portabletext/schema'
1
2
  import type {PortableTextTextBlock} from '@sanity/types'
2
3
  import type {EditorSelector} from '../editor/editor-selector'
3
- import {isTextBlock} from '../internal-utils/parse-blocks'
4
4
  import {getBlockKeyFromSelectionPoint} from '../selection/selection-point'
5
5
  import type {BlockPath} from '../types/paths'
6
6
  import {getSelectionEndPoint, getSelectionStartPoint} from '../utils'
@@ -1,5 +1,5 @@
1
+ import {isSpan, isTextBlock} from '@portabletext/schema'
1
2
  import type {EditorSelector} from '../editor/editor-selector'
2
- import {isSpan, isTextBlock} from '../internal-utils/parse-blocks'
3
3
  import {getSelectedValue} from './selector.get-selected-value'
4
4
 
5
5
  /**
@@ -1,9 +1,9 @@
1
1
  import {compileSchema, defineSchema} from '@portabletext/schema'
2
+ import {createTestKeyGenerator} from '@portabletext/test'
2
3
  import type {PortableTextBlock} from '@sanity/types'
3
4
  import {describe, expect, test} from 'vitest'
4
5
  import {createTestSnapshot} from '../internal-utils/create-test-snapshot'
5
6
  import {parseBlock} from '../internal-utils/parse-blocks'
6
- import {createTestKeyGenerator} from '../internal-utils/test-key-generator'
7
7
  import type {EditorSelection} from '../types/editor'
8
8
  import {getTrimmedSelection} from './selector.get-trimmed-selection'
9
9
 
@@ -1,6 +1,6 @@
1
+ import {isSpan, isTextBlock} from '@portabletext/schema'
1
2
  import type {PortableTextSpan} from '@sanity/types'
2
3
  import type {EditorSelector} from '../editor/editor-selector'
3
- import {isSpan, isTextBlock} from '../internal-utils/parse-blocks'
4
4
  import {
5
5
  getBlockKeyFromSelectionPoint,
6
6
  getChildKeyFromSelectionPoint,
@@ -1,5 +1,5 @@
1
+ import {isTextBlock} from '@portabletext/schema'
1
2
  import type {EditorSelector} from '../editor/editor-selector'
2
- import {isTextBlock} from '../internal-utils/parse-blocks'
3
3
  import {getActiveAnnotationsMarks} from './selector.get-active-annotation-marks'
4
4
  import {getSelectedBlocks} from './selector.get-selected-blocks'
5
5
 
@@ -1,5 +1,5 @@
1
+ import {isTextBlock} from '@portabletext/schema'
1
2
  import type {EditorSelector} from '../editor/editor-selector'
2
- import {isTextBlock} from '../internal-utils/parse-blocks'
3
3
  import {
4
4
  getBlockKeyFromSelectionPoint,
5
5
  getChildKeyFromSelectionPoint,
@@ -1,5 +1,5 @@
1
+ import {isTextBlock} from '@portabletext/schema'
1
2
  import type {EditorSelector} from '../editor/editor-selector'
2
- import {isTextBlock} from '../internal-utils/parse-blocks'
3
3
  import {
4
4
  getBlockKeyFromSelectionPoint,
5
5
  getChildKeyFromSelectionPoint,
@@ -16,8 +16,7 @@ export {isEqualSelectionPoints} from './util.is-equal-selection-points'
16
16
  export {isEqualSelections} from './util.is-equal-selections'
17
17
  export {isKeyedSegment} from './util.is-keyed-segment'
18
18
  export {isSelectionCollapsed} from './util.is-selection-collapsed'
19
- export {isSpan} from './util.is-span'
20
- export {isTextBlock} from './util.is-text-block'
19
+ export {isSpan, isTextBlock} from '@portabletext/schema'
21
20
  export {mergeTextBlocks} from './util.merge-text-blocks'
22
21
  export {reverseSelection} from './util.reverse-selection'
23
22
  export {selectionPointToBlockOffset} from './util.selection-point-to-block-offset'
@@ -1,6 +1,6 @@
1
+ import {isTextBlock} from '@portabletext/schema'
1
2
  import type {PortableTextBlock} from '@sanity/types'
2
3
  import type {EditorContext} from '../editor/editor-snapshot'
3
- import {isTextBlock} from '../internal-utils/parse-blocks'
4
4
  import {getChildKeyFromSelectionPoint} from '../selection/selection-point'
5
5
  import {isSelectionCollapsed} from './util.is-selection-collapsed'
6
6
 
@@ -1,5 +1,5 @@
1
+ import {isSpan, isTextBlock} from '@portabletext/schema'
1
2
  import type {EditorContext} from '../editor/editor-snapshot'
2
- import {isSpan, isTextBlock} from '../internal-utils/parse-blocks'
3
3
  import {
4
4
  getBlockKeyFromSelectionPoint,
5
5
  getChildKeyFromSelectionPoint,
@@ -1,5 +1,5 @@
1
+ import {isSpan, isTextBlock} from '@portabletext/schema'
1
2
  import type {EditorContext} from '../editor/editor-snapshot'
2
- import {isSpan, isTextBlock} from '../internal-utils/parse-blocks'
3
3
  import {
4
4
  getBlockKeyFromSelectionPoint,
5
5
  getChildKeyFromSelectionPoint,
@@ -1,6 +1,6 @@
1
+ import {isSpan, isTextBlock} from '@portabletext/schema'
1
2
  import type {PortableTextBlock} from '@sanity/types'
2
3
  import type {EditorContext} from '../editor/editor-snapshot'
3
- import {isSpan, isTextBlock} from '../internal-utils/parse-blocks'
4
4
  import type {EditorSelectionPoint} from '../types/editor'
5
5
  import type {BlockPath} from '../types/paths'
6
6
 
@@ -1,6 +1,6 @@
1
+ import {isTextBlock} from '@portabletext/schema'
1
2
  import type {PortableTextBlock} from '@sanity/types'
2
3
  import type {EditorContext} from '../editor/editor-snapshot'
3
- import {isTextBlock} from '../internal-utils/parse-blocks'
4
4
  import type {EditorSelectionPoint} from '../types/editor'
5
5
  import type {BlockPath} from '../types/paths'
6
6
 
@@ -1,6 +1,6 @@
1
+ import {isSpan, isTextBlock} from '@portabletext/schema'
1
2
  import type {PortableTextBlock} from '@sanity/types'
2
3
  import type {EditorContext} from '../editor/editor-snapshot'
3
- import {isSpan, isTextBlock} from '../internal-utils/parse-blocks'
4
4
  import {getTextBlockText} from './util.get-text-block-text'
5
5
 
6
6
  /**
@@ -1,7 +1,7 @@
1
+ import {isTextBlock} from '@portabletext/schema'
1
2
  import type {PortableTextTextBlock} from '@sanity/types'
2
3
  import type {EditorContext} from '..'
3
4
  import {parseBlock} from '../internal-utils/parse-blocks'
4
- import {isTextBlock} from './util.is-text-block'
5
5
 
6
6
  /**
7
7
  * @beta
@@ -1,6 +1,6 @@
1
+ import {isSpan, isTextBlock} from '@portabletext/schema'
1
2
  import type {PortableTextBlock} from '@sanity/types'
2
- import type {EditorContext} from '..'
3
- import {isSpan, isTextBlock} from '../internal-utils/parse-blocks'
3
+ import type {EditorContext} from '../editor/editor-snapshot'
4
4
  import {
5
5
  getBlockKeyFromSelectionPoint,
6
6
  getChildKeyFromSelectionPoint,
@@ -1,6 +1,6 @@
1
+ import {isSpan} from '@portabletext/schema'
1
2
  import type {PortableTextChild, PortableTextTextBlock} from '@sanity/types'
2
- import type {EditorContext} from '..'
3
- import {isSpan} from '../internal-utils/parse-blocks'
3
+ import type {EditorContext} from '../editor/editor-snapshot'
4
4
  import {
5
5
  getBlockKeyFromSelectionPoint,
6
6
  getChildKeyFromSelectionPoint,
@@ -1,7 +1,7 @@
1
+ import {isSpan} from '@portabletext/schema'
1
2
  import type {PortableTextTextBlock} from '@sanity/types'
2
3
  import type {EditorSelectionPoint} from '..'
3
4
  import type {EditorContext} from '../editor/editor-snapshot'
4
- import {isSpan} from './util.is-span'
5
5
  import {sliceTextBlock} from './util.slice-text-block'
6
6
 
7
7
  /**