@portabletext/editor 1.48.7 → 1.48.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_chunks-cjs/behavior.core.cjs +20 -8
- package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/behavior.markdown.cjs +5 -5
- package/lib/_chunks-cjs/behavior.markdown.cjs.map +1 -1
- package/lib/_chunks-cjs/editor-provider.cjs +121 -90
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs +2 -2
- package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.get-text-before.cjs +7 -4
- package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs +63 -47
- package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +29 -23
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs +3 -3
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs +15 -15
- package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs.map +1 -1
- package/lib/_chunks-cjs/util.slice-blocks.cjs +258 -38
- package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js +21 -10
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/behavior.markdown.js +5 -6
- package/lib/_chunks-es/behavior.markdown.js.map +1 -1
- package/lib/_chunks-es/editor-provider.js +75 -46
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/_chunks-es/selector.get-focus-inline-object.js +1 -2
- package/lib/_chunks-es/selector.get-focus-inline-object.js.map +1 -1
- package/lib/_chunks-es/selector.get-text-before.js +7 -4
- package/lib/_chunks-es/selector.get-text-before.js.map +1 -1
- package/lib/_chunks-es/selector.is-overlapping-selection.js +61 -46
- package/lib/_chunks-es/selector.is-overlapping-selection.js.map +1 -1
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +30 -26
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
- package/lib/_chunks-es/util.merge-text-blocks.js +1 -1
- package/lib/_chunks-es/util.selection-point-to-block-offset.js +15 -16
- package/lib/_chunks-es/util.selection-point-to-block-offset.js.map +1 -1
- package/lib/_chunks-es/util.slice-blocks.js +258 -38
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
- package/lib/behaviors/index.d.cts +2552 -251
- package/lib/behaviors/index.d.ts +2552 -251
- package/lib/index.cjs +45 -21
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2350 -51
- package/lib/index.d.ts +2350 -51
- package/lib/index.js +44 -21
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +16 -7
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +2324 -24
- package/lib/plugins/index.d.ts +2324 -24
- package/lib/plugins/index.js +16 -7
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.cjs +5 -5
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +2321 -28
- package/lib/selectors/index.d.ts +2321 -28
- package/lib/selectors/index.js +5 -6
- package/lib/selectors/index.js.map +1 -1
- package/lib/utils/index.cjs +30 -24
- package/lib/utils/index.cjs.map +1 -1
- package/lib/utils/index.d.cts +2350 -44
- package/lib/utils/index.d.ts +2350 -44
- package/lib/utils/index.js +30 -24
- package/lib/utils/index.js.map +1 -1
- package/package.json +1 -2
- package/src/behavior-actions/behavior.action.block.unset.ts +1 -1
- package/src/behavior-actions/behavior.action.decorator.add.ts +20 -5
- package/src/behaviors/behavior.abstract.decorator.ts +1 -1
- package/src/behaviors/behavior.abstract.delete.ts +1 -1
- package/src/behaviors/behavior.abstract.insert.ts +2 -2
- package/src/behaviors/behavior.abstract.select.ts +16 -4
- package/src/behaviors/behavior.abstract.split.ts +9 -6
- package/src/behaviors/behavior.core.block-objects.ts +5 -5
- package/src/behaviors/behavior.core.insert-break.ts +16 -4
- package/src/behaviors/behavior.core.lists.ts +4 -6
- package/src/behaviors/behavior.decorator-pair.ts +13 -4
- package/src/behaviors/behavior.default.ts +1 -1
- package/src/behaviors/behavior.markdown.ts +5 -5
- package/src/converters/converter.portable-text.ts +1 -1
- package/src/converters/converter.text-html.ts +1 -1
- package/src/converters/converter.text-plain.ts +4 -4
- package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +10 -2
- package/src/editor/plugins/createWithSchemaTypes.ts +12 -19
- package/src/internal-utils/__tests__/dmpToOperations.test.ts +13 -12
- package/src/internal-utils/drag-selection.ts +16 -4
- package/src/internal-utils/event-position.ts +20 -8
- package/src/internal-utils/parse-blocks.ts +17 -5
- package/src/internal-utils/validateValue.ts +6 -6
- package/src/plugins/plugin.decorator-shortcut.ts +2 -2
- package/src/selectors/selector.get-active-annotations.ts +5 -2
- package/src/selectors/selector.get-active-list-item.ts +4 -3
- package/src/selectors/selector.get-active-style.ts +4 -3
- package/src/selectors/selector.get-anchor-text-block.ts +3 -6
- package/src/selectors/selector.get-block-offsets.ts +2 -2
- package/src/selectors/selector.get-caret-word-selection.ts +11 -5
- package/src/selectors/selector.get-selected-slice.ts +1 -1
- package/src/selectors/selector.get-selected-spans.ts +11 -15
- package/src/selectors/selector.get-selected-text-blocks.ts +3 -3
- package/src/selectors/selector.get-selection-text.ts +3 -3
- package/src/selectors/selector.get-text-before.ts +5 -2
- package/src/selectors/selector.get-trimmed-selection.ts +20 -14
- package/src/selectors/selector.is-active-annotation.ts +4 -2
- package/src/selectors/selector.is-active-decorator.test.ts +3 -3
- package/src/selectors/selector.is-at-the-end-of-block.ts +4 -1
- package/src/selectors/selector.is-at-the-start-of-block.ts +4 -1
- package/src/selectors/selector.is-point-after-selection.ts +7 -6
- package/src/selectors/selector.is-point-before-selection.ts +7 -6
- package/src/selectors/selector.is-selecting-entire-blocks.ts +8 -2
- package/src/selectors/selectors.ts +25 -28
- package/src/utils/util.block-offset-to-block-selection-point.ts +4 -4
- package/src/utils/util.block-offset-to-selection-point.ts +5 -5
- package/src/utils/util.block-offset.test.ts +219 -156
- package/src/utils/util.block-offset.ts +14 -17
- package/src/utils/util.block-offsets-to-selection.ts +5 -5
- package/src/utils/util.child-selection-point-to-block-offset.ts +7 -10
- package/src/utils/util.get-block-end-point.ts +15 -15
- package/src/utils/util.get-block-start-point.ts +13 -12
- package/src/utils/util.is-empty-text-block.ts +9 -8
- package/src/utils/util.selection-point-to-block-offset.ts +4 -4
- package/src/utils/util.slice-blocks.test.ts +178 -121
- package/src/utils/util.slice-blocks.ts +25 -24
- package/src/utils/util.split-text-block.ts +18 -12
- package/lib/_chunks-cjs/parse-blocks.cjs +0 -205
- package/lib/_chunks-cjs/parse-blocks.cjs.map +0 -1
- package/lib/_chunks-es/parse-blocks.js +0 -206
- package/lib/_chunks-es/parse-blocks.js.map +0 -1
- package/src/behavior-actions/behavior.guards.ts +0 -24
|
@@ -15,7 +15,10 @@ export function isAtTheEndOfBlock(block: {
|
|
|
15
15
|
return false
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const blockEndPoint = utils.getBlockEndPoint(
|
|
18
|
+
const blockEndPoint = utils.getBlockEndPoint({
|
|
19
|
+
context: snapshot.context,
|
|
20
|
+
block,
|
|
21
|
+
})
|
|
19
22
|
|
|
20
23
|
return utils.isEqualSelectionPoints(
|
|
21
24
|
snapshot.context.selection.focus,
|
|
@@ -15,7 +15,10 @@ export function isAtTheStartOfBlock(block: {
|
|
|
15
15
|
return false
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const blockStartPoint = utils.getBlockStartPoint(
|
|
18
|
+
const blockStartPoint = utils.getBlockStartPoint({
|
|
19
|
+
context: snapshot.context,
|
|
20
|
+
block,
|
|
21
|
+
})
|
|
19
22
|
|
|
20
23
|
return utils.isEqualSelectionPoints(
|
|
21
24
|
snapshot.context.selection.focus,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {isKeySegment, isPortableTextTextBlock} from '@sanity/types'
|
|
2
1
|
import type {EditorSelector} from '../editor/editor-selector'
|
|
2
|
+
import {isTextBlock} from '../internal-utils/parse-blocks'
|
|
3
3
|
import type {EditorSelectionPoint} from '../types/editor'
|
|
4
|
+
import {isKeyedSegment} from '../utils/util.is-keyed-segment'
|
|
4
5
|
import {reverseSelection} from '../utils/util.reverse-selection'
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -18,17 +19,17 @@ export function isPointAfterSelection(
|
|
|
18
19
|
? reverseSelection(snapshot.context.selection)
|
|
19
20
|
: snapshot.context.selection
|
|
20
21
|
|
|
21
|
-
const pointBlockKey =
|
|
22
|
+
const pointBlockKey = isKeyedSegment(point.path[0])
|
|
22
23
|
? point.path[0]._key
|
|
23
24
|
: undefined
|
|
24
|
-
const pointChildKey =
|
|
25
|
+
const pointChildKey = isKeyedSegment(point.path[2])
|
|
25
26
|
? point.path[2]._key
|
|
26
27
|
: undefined
|
|
27
28
|
|
|
28
|
-
const endBlockKey =
|
|
29
|
+
const endBlockKey = isKeyedSegment(selection.focus.path[0])
|
|
29
30
|
? selection.focus.path[0]._key
|
|
30
31
|
: undefined
|
|
31
|
-
const endChildKey =
|
|
32
|
+
const endChildKey = isKeyedSegment(selection.focus.path[2])
|
|
32
33
|
? selection.focus.path[2]._key
|
|
33
34
|
: undefined
|
|
34
35
|
|
|
@@ -47,7 +48,7 @@ export function isPointAfterSelection(
|
|
|
47
48
|
|
|
48
49
|
// Both the point and the selection end in this block
|
|
49
50
|
|
|
50
|
-
if (!
|
|
51
|
+
if (!isTextBlock(snapshot.context, block)) {
|
|
51
52
|
break
|
|
52
53
|
}
|
|
53
54
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {isKeySegment, isPortableTextTextBlock} from '@sanity/types'
|
|
2
1
|
import type {EditorSelector} from '../editor/editor-selector'
|
|
2
|
+
import {isTextBlock} from '../internal-utils/parse-blocks'
|
|
3
3
|
import type {EditorSelectionPoint} from '../types/editor'
|
|
4
|
+
import {isKeyedSegment} from '../utils/util.is-keyed-segment'
|
|
4
5
|
import {reverseSelection} from '../utils/util.reverse-selection'
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -18,17 +19,17 @@ export function isPointBeforeSelection(
|
|
|
18
19
|
? reverseSelection(snapshot.context.selection)
|
|
19
20
|
: snapshot.context.selection
|
|
20
21
|
|
|
21
|
-
const pointBlockKey =
|
|
22
|
+
const pointBlockKey = isKeyedSegment(point.path[0])
|
|
22
23
|
? point.path[0]._key
|
|
23
24
|
: undefined
|
|
24
|
-
const pointChildKey =
|
|
25
|
+
const pointChildKey = isKeyedSegment(point.path[2])
|
|
25
26
|
? point.path[2]._key
|
|
26
27
|
: undefined
|
|
27
28
|
|
|
28
|
-
const startBlockKey =
|
|
29
|
+
const startBlockKey = isKeyedSegment(selection.anchor.path[0])
|
|
29
30
|
? selection.anchor.path[0]._key
|
|
30
31
|
: undefined
|
|
31
|
-
const startChildKey =
|
|
32
|
+
const startChildKey = isKeyedSegment(selection.anchor.path[2])
|
|
32
33
|
? selection.anchor.path[2]._key
|
|
33
34
|
: undefined
|
|
34
35
|
|
|
@@ -47,7 +48,7 @@ export function isPointBeforeSelection(
|
|
|
47
48
|
|
|
48
49
|
// Both the point and the selection start in this block
|
|
49
50
|
|
|
50
|
-
if (!
|
|
51
|
+
if (!isTextBlock(snapshot.context, block)) {
|
|
51
52
|
break
|
|
52
53
|
}
|
|
53
54
|
|
|
@@ -24,8 +24,14 @@ export const isSelectingEntireBlocks: EditorSelector<boolean> = (snapshot) => {
|
|
|
24
24
|
return false
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const startBlockStartPoint = utils.getBlockStartPoint(
|
|
28
|
-
|
|
27
|
+
const startBlockStartPoint = utils.getBlockStartPoint({
|
|
28
|
+
context: snapshot.context,
|
|
29
|
+
block: startBlock,
|
|
30
|
+
})
|
|
31
|
+
const endBlockEndPoint = utils.getBlockEndPoint({
|
|
32
|
+
context: snapshot.context,
|
|
33
|
+
block: endBlock,
|
|
34
|
+
})
|
|
29
35
|
|
|
30
36
|
return (
|
|
31
37
|
utils.isEqualSelectionPoints(startBlockStartPoint, startPoint) &&
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
type PortableTextObject,
|
|
9
|
-
type PortableTextSpan,
|
|
10
|
-
type PortableTextTextBlock,
|
|
1
|
+
import type {
|
|
2
|
+
KeyedSegment,
|
|
3
|
+
PortableTextBlock,
|
|
4
|
+
PortableTextListBlock,
|
|
5
|
+
PortableTextObject,
|
|
6
|
+
PortableTextSpan,
|
|
7
|
+
PortableTextTextBlock,
|
|
11
8
|
} from '@sanity/types'
|
|
12
|
-
import {createGuards} from '../behavior-actions/behavior.guards'
|
|
13
9
|
import type {EditorSelector} from '../editor/editor-selector'
|
|
10
|
+
import {isListBlock, isSpan, isTextBlock} from '../internal-utils/parse-blocks'
|
|
11
|
+
import {isKeyedSegment} from '../utils/util.is-keyed-segment'
|
|
14
12
|
|
|
15
13
|
/**
|
|
16
14
|
* @public
|
|
@@ -19,7 +17,7 @@ export const getFocusBlock: EditorSelector<
|
|
|
19
17
|
{node: PortableTextBlock; path: [KeyedSegment]} | undefined
|
|
20
18
|
> = (snapshot) => {
|
|
21
19
|
const key = snapshot.context.selection
|
|
22
|
-
?
|
|
20
|
+
? isKeyedSegment(snapshot.context.selection.focus.path[0])
|
|
23
21
|
? snapshot.context.selection.focus.path[0]._key
|
|
24
22
|
: undefined
|
|
25
23
|
: undefined
|
|
@@ -37,11 +35,10 @@ export const getFocusBlock: EditorSelector<
|
|
|
37
35
|
export const getFocusListBlock: EditorSelector<
|
|
38
36
|
{node: PortableTextListBlock; path: [KeyedSegment]} | undefined
|
|
39
37
|
> = (snapshot) => {
|
|
40
|
-
const
|
|
41
|
-
const focusBlock = getFocusBlock(snapshot)
|
|
38
|
+
const focusTextBlock = getFocusTextBlock(snapshot)
|
|
42
39
|
|
|
43
|
-
return
|
|
44
|
-
? {node:
|
|
40
|
+
return focusTextBlock && isListBlock(snapshot.context, focusTextBlock.node)
|
|
41
|
+
? {node: focusTextBlock.node, path: focusTextBlock.path}
|
|
45
42
|
: undefined
|
|
46
43
|
}
|
|
47
44
|
|
|
@@ -53,7 +50,7 @@ export const getFocusTextBlock: EditorSelector<
|
|
|
53
50
|
> = (snapshot) => {
|
|
54
51
|
const focusBlock = getFocusBlock(snapshot)
|
|
55
52
|
|
|
56
|
-
return focusBlock &&
|
|
53
|
+
return focusBlock && isTextBlock(snapshot.context, focusBlock.node)
|
|
57
54
|
? {node: focusBlock.node, path: focusBlock.path}
|
|
58
55
|
: undefined
|
|
59
56
|
}
|
|
@@ -66,7 +63,7 @@ export const getFocusBlockObject: EditorSelector<
|
|
|
66
63
|
> = (snapshot) => {
|
|
67
64
|
const focusBlock = getFocusBlock(snapshot)
|
|
68
65
|
|
|
69
|
-
return focusBlock && !
|
|
66
|
+
return focusBlock && !isTextBlock(snapshot.context, focusBlock.node)
|
|
70
67
|
? {node: focusBlock.node, path: focusBlock.path}
|
|
71
68
|
: undefined
|
|
72
69
|
}
|
|
@@ -88,7 +85,7 @@ export const getFocusChild: EditorSelector<
|
|
|
88
85
|
}
|
|
89
86
|
|
|
90
87
|
const key = snapshot.context.selection
|
|
91
|
-
?
|
|
88
|
+
? isKeyedSegment(snapshot.context.selection.focus.path[2])
|
|
92
89
|
? snapshot.context.selection.focus.path[2]._key
|
|
93
90
|
: undefined
|
|
94
91
|
: undefined
|
|
@@ -111,7 +108,7 @@ export const getFocusSpan: EditorSelector<
|
|
|
111
108
|
> = (snapshot) => {
|
|
112
109
|
const focusChild = getFocusChild(snapshot)
|
|
113
110
|
|
|
114
|
-
return focusChild &&
|
|
111
|
+
return focusChild && isSpan(snapshot.context, focusChild.node)
|
|
115
112
|
? {node: focusChild.node, path: focusChild.path}
|
|
116
113
|
: undefined
|
|
117
114
|
}
|
|
@@ -153,17 +150,17 @@ export const getSelectedBlocks: EditorSelector<
|
|
|
153
150
|
const selectedBlocks: Array<{node: PortableTextBlock; path: [KeyedSegment]}> =
|
|
154
151
|
[]
|
|
155
152
|
const startKey = snapshot.context.selection.backward
|
|
156
|
-
?
|
|
153
|
+
? isKeyedSegment(snapshot.context.selection.focus.path[0])
|
|
157
154
|
? snapshot.context.selection.focus.path[0]._key
|
|
158
155
|
: undefined
|
|
159
|
-
:
|
|
156
|
+
: isKeyedSegment(snapshot.context.selection.anchor.path[0])
|
|
160
157
|
? snapshot.context.selection.anchor.path[0]._key
|
|
161
158
|
: undefined
|
|
162
159
|
const endKey = snapshot.context.selection.backward
|
|
163
|
-
?
|
|
160
|
+
? isKeyedSegment(snapshot.context.selection.anchor.path[0])
|
|
164
161
|
? snapshot.context.selection.anchor.path[0]._key
|
|
165
162
|
: undefined
|
|
166
|
-
:
|
|
163
|
+
: isKeyedSegment(snapshot.context.selection.focus.path[0])
|
|
167
164
|
? snapshot.context.selection.focus.path[0]._key
|
|
168
165
|
: undefined
|
|
169
166
|
|
|
@@ -209,10 +206,10 @@ export const getSelectionStartBlock: EditorSelector<
|
|
|
209
206
|
}
|
|
210
207
|
|
|
211
208
|
const key = snapshot.context.selection.backward
|
|
212
|
-
?
|
|
209
|
+
? isKeyedSegment(snapshot.context.selection.focus.path[0])
|
|
213
210
|
? snapshot.context.selection.focus.path[0]._key
|
|
214
211
|
: undefined
|
|
215
|
-
:
|
|
212
|
+
: isKeyedSegment(snapshot.context.selection.anchor.path[0])
|
|
216
213
|
? snapshot.context.selection.anchor.path[0]._key
|
|
217
214
|
: undefined
|
|
218
215
|
|
|
@@ -238,10 +235,10 @@ export const getSelectionEndBlock: EditorSelector<
|
|
|
238
235
|
}
|
|
239
236
|
|
|
240
237
|
const key = snapshot.context.selection.backward
|
|
241
|
-
?
|
|
238
|
+
? isKeyedSegment(snapshot.context.selection.anchor.path[0])
|
|
242
239
|
? snapshot.context.selection.anchor.path[0]._key
|
|
243
240
|
: undefined
|
|
244
|
-
:
|
|
241
|
+
: isKeyedSegment(snapshot.context.selection.focus.path[0])
|
|
245
242
|
? snapshot.context.selection.focus.path[0]._key
|
|
246
243
|
: undefined
|
|
247
244
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {EditorContext} from '../editor/editor-snapshot'
|
|
2
2
|
import type {BlockOffset} from '../types/block-offset'
|
|
3
3
|
import type {EditorSelectionPoint} from '../types/editor'
|
|
4
4
|
|
|
@@ -6,15 +6,15 @@ import type {EditorSelectionPoint} from '../types/editor'
|
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
8
|
export function blockOffsetToBlockSelectionPoint({
|
|
9
|
-
|
|
9
|
+
context,
|
|
10
10
|
blockOffset,
|
|
11
11
|
}: {
|
|
12
|
-
|
|
12
|
+
context: Pick<EditorContext, 'value'>
|
|
13
13
|
blockOffset: BlockOffset
|
|
14
14
|
}): EditorSelectionPoint | undefined {
|
|
15
15
|
let selectionPoint: EditorSelectionPoint | undefined
|
|
16
16
|
|
|
17
|
-
for (const block of value) {
|
|
17
|
+
for (const block of context.value) {
|
|
18
18
|
if (block._key === blockOffset.path[0]._key) {
|
|
19
19
|
selectionPoint = {
|
|
20
20
|
path: [{_key: block._key}],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {EditorContext} from '../editor/editor-snapshot'
|
|
2
2
|
import type {BlockOffset} from '../types/block-offset'
|
|
3
3
|
import type {EditorSelectionPoint} from '../types/editor'
|
|
4
4
|
import {blockOffsetToSpanSelectionPoint} from './util.block-offset'
|
|
@@ -8,23 +8,23 @@ import {blockOffsetToBlockSelectionPoint} from './util.block-offset-to-block-sel
|
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
10
|
export function blockOffsetToSelectionPoint({
|
|
11
|
-
|
|
11
|
+
context,
|
|
12
12
|
blockOffset,
|
|
13
13
|
direction,
|
|
14
14
|
}: {
|
|
15
|
-
|
|
15
|
+
context: Pick<EditorContext, 'schema' | 'value'>
|
|
16
16
|
blockOffset: BlockOffset
|
|
17
17
|
direction: 'forward' | 'backward'
|
|
18
18
|
}): EditorSelectionPoint | undefined {
|
|
19
19
|
const spanSelectionPoint = blockOffsetToSpanSelectionPoint({
|
|
20
|
-
|
|
20
|
+
context,
|
|
21
21
|
blockOffset,
|
|
22
22
|
direction,
|
|
23
23
|
})
|
|
24
24
|
|
|
25
25
|
if (!spanSelectionPoint) {
|
|
26
26
|
return blockOffsetToBlockSelectionPoint({
|
|
27
|
-
|
|
27
|
+
context,
|
|
28
28
|
blockOffset,
|
|
29
29
|
})
|
|
30
30
|
}
|