@portabletext/editor 1.15.2 → 1.16.0
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 +30 -28
- package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.get-text-before.cjs +14 -14
- package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
- package/lib/_chunks-cjs/{selectors.cjs → selector.is-selection-collapsed.cjs} +8 -8
- package/lib/_chunks-cjs/selector.is-selection-collapsed.cjs.map +1 -0
- package/lib/_chunks-es/behavior.core.js +12 -10
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/selector.get-text-before.js +14 -14
- package/lib/_chunks-es/selector.get-text-before.js.map +1 -1
- package/lib/_chunks-es/{selectors.js → selector.is-selection-collapsed.js} +8 -8
- package/lib/_chunks-es/selector.is-selection-collapsed.js.map +1 -0
- package/lib/behaviors/index.cjs +35 -35
- package/lib/behaviors/index.cjs.map +1 -1
- package/lib/behaviors/index.d.cts +40 -45
- package/lib/behaviors/index.d.ts +40 -45
- package/lib/behaviors/index.js +20 -20
- package/lib/behaviors/index.js.map +1 -1
- package/lib/index.cjs +868 -542
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +3791 -4503
- package/lib/index.d.ts +3791 -4503
- package/lib/index.js +865 -541
- package/lib/index.js.map +1 -1
- package/lib/selectors/index.cjs +166 -16
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +62 -17
- package/lib/selectors/index.d.ts +62 -17
- package/lib/selectors/index.js +154 -3
- package/lib/selectors/index.js.map +1 -1
- package/package.json +11 -11
- package/src/behavior-actions/behavior.action-utils.insert-block.ts +3 -5
- package/src/behavior-actions/behavior.actions.ts +6 -6
- package/src/behavior-actions/behavior.guards.ts +2 -6
- package/src/behaviors/behavior.code-editor.ts +5 -9
- package/src/behaviors/behavior.core.block-objects.ts +14 -20
- package/src/behaviors/behavior.core.lists.ts +13 -19
- package/src/behaviors/behavior.links.ts +6 -6
- package/src/behaviors/behavior.markdown.ts +27 -40
- package/src/behaviors/behavior.types.ts +7 -7
- package/src/behaviors/index.ts +1 -0
- package/src/editor/Editable.tsx +11 -4
- package/src/editor/PortableTextEditor.tsx +4 -5
- package/src/editor/{hooks/useSyncValue.test.tsx → __tests__/sync-value.test.tsx} +42 -23
- package/src/editor/components/Synchronizer.tsx +53 -80
- package/src/{utils/getPortableTextMemberSchemaTypes.ts → editor/create-editor-schema.ts} +3 -3
- package/src/editor/create-editor.ts +2 -2
- package/src/editor/define-schema.ts +8 -3
- package/src/editor/editor-machine.ts +136 -104
- package/src/editor/editor-provider.tsx +0 -3
- package/src/editor/editor-selector.ts +6 -13
- package/src/editor/editor-snapshot.ts +5 -6
- package/src/editor/get-active-decorators.ts +20 -0
- package/src/editor/mutation-machine.ts +100 -0
- package/src/editor/plugins/__tests__/withPortableTextMarkModel.test.tsx +21 -15
- package/src/editor/plugins/createWithMaxBlocks.ts +1 -1
- package/src/editor/plugins/createWithPatches.ts +0 -4
- package/src/editor/plugins/createWithPlaceholderBlock.ts +1 -1
- package/src/editor/plugins/createWithPortableTextSelections.ts +4 -1
- package/src/editor/plugins/createWithUndoRedo.ts +3 -3
- package/src/editor/sync-machine.ts +657 -0
- package/src/editor/withSyncRangeDecorations.ts +17 -5
- package/src/index.ts +3 -5
- package/src/selectors/_exports/index.ts +1 -0
- package/src/selectors/index.ts +10 -4
- package/src/selectors/selector.get-active-style.ts +37 -0
- package/src/selectors/selector.get-selected-spans.ts +136 -0
- package/src/selectors/selector.is-active-annotation.ts +49 -0
- package/src/selectors/selector.is-active-decorator.ts +21 -0
- package/src/selectors/selector.is-active-list-item.ts +13 -0
- package/src/selectors/selector.is-active-style.ts +13 -0
- package/src/selectors/selector.is-selection-collapsed.ts +12 -0
- package/src/selectors/selector.is-selection-expanded.ts +9 -0
- package/src/selectors/selectors.ts +0 -11
- package/src/utils/__tests__/operationToPatches.test.ts +2 -2
- package/src/utils/__tests__/patchToOperations.test.ts +2 -2
- package/src/utils/__tests__/values.test.ts +2 -2
- package/src/utils/weakMaps.ts +0 -3
- package/src/utils/withChanges.ts +1 -8
- package/lib/_chunks-cjs/selectors.cjs.map +0 -1
- package/lib/_chunks-es/selectors.js.map +0 -1
- package/src/editor/hooks/useSyncValue.ts +0 -426
package/src/index.ts
CHANGED
|
@@ -17,6 +17,8 @@ export {
|
|
|
17
17
|
type BaseDefinition,
|
|
18
18
|
type SchemaDefinition,
|
|
19
19
|
} from './editor/define-schema'
|
|
20
|
+
export type {PortableTextMemberSchemaTypes} from './types/editor'
|
|
21
|
+
export type {EditorSchema} from './editor/define-schema'
|
|
20
22
|
export {PortableTextEditable} from './editor/Editable'
|
|
21
23
|
export type {PortableTextEditableProps} from './editor/Editable'
|
|
22
24
|
export {EditorEventListener} from './editor/editor-event-listener'
|
|
@@ -35,11 +37,7 @@ export {
|
|
|
35
37
|
useEditor,
|
|
36
38
|
type EditorProviderProps,
|
|
37
39
|
} from './editor/editor-provider'
|
|
38
|
-
export {
|
|
39
|
-
useEditorSelector,
|
|
40
|
-
type EditorSelector,
|
|
41
|
-
type EditorSelectorSnapshot,
|
|
42
|
-
} from './editor/editor-selector'
|
|
40
|
+
export {useEditorSelector, type EditorSelector} from './editor/editor-selector'
|
|
43
41
|
export type {EditorContext, EditorSnapshot} from './editor/editor-snapshot'
|
|
44
42
|
export {usePortableTextEditor} from './editor/hooks/usePortableTextEditor'
|
|
45
43
|
export {usePortableTextEditorSelection} from './editor/hooks/usePortableTextEditorSelection'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../index'
|
package/src/selectors/index.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
EditorSelector,
|
|
3
|
-
EditorSelectorSnapshot,
|
|
4
|
-
} from '../editor/editor-selector'
|
|
1
|
+
export type {EditorSelector} from '../editor/editor-selector'
|
|
5
2
|
export type {EditorContext, EditorSnapshot} from '../editor/editor-snapshot'
|
|
6
3
|
export type {
|
|
7
4
|
EditorSelection,
|
|
@@ -9,7 +6,16 @@ export type {
|
|
|
9
6
|
PortableTextMemberSchemaTypes,
|
|
10
7
|
} from '../types/editor'
|
|
11
8
|
|
|
9
|
+
export type {EditorSchema} from '../editor/define-schema'
|
|
12
10
|
export {getActiveListItem} from './selector.get-active-list-item'
|
|
11
|
+
export {getActiveStyle} from './selector.get-active-style'
|
|
12
|
+
export {getSelectedSpans} from './selector.get-selected-spans'
|
|
13
13
|
export {getSelectionText} from './selector.get-selection-text'
|
|
14
14
|
export {getBlockTextBefore} from './selector.get-text-before'
|
|
15
|
+
export {isActiveAnnotation} from './selector.is-active-annotation'
|
|
16
|
+
export {isActiveDecorator} from './selector.is-active-decorator'
|
|
17
|
+
export {isActiveListItem} from './selector.is-active-list-item'
|
|
18
|
+
export {isActiveStyle} from './selector.is-active-style'
|
|
19
|
+
export {isSelectionCollapsed} from './selector.is-selection-collapsed'
|
|
20
|
+
export {isSelectionExpanded} from './selector.is-selection-expanded'
|
|
15
21
|
export * from './selectors'
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type {PortableTextTextBlock} from '@sanity/types'
|
|
2
|
+
import {createGuards} from '../behavior-actions/behavior.guards'
|
|
3
|
+
import type {EditorSelector} from '../editor/editor-selector'
|
|
4
|
+
import {getSelectedBlocks} from './selectors'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @alpha
|
|
8
|
+
*/
|
|
9
|
+
export const getActiveStyle: EditorSelector<PortableTextTextBlock['style']> = ({
|
|
10
|
+
context,
|
|
11
|
+
}) => {
|
|
12
|
+
if (!context.selection) {
|
|
13
|
+
return undefined
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const guards = createGuards(context)
|
|
17
|
+
const selectedBlocks = getSelectedBlocks({context}).map((block) => block.node)
|
|
18
|
+
const selectedTextBlocks = selectedBlocks.filter(guards.isTextBlock)
|
|
19
|
+
|
|
20
|
+
const firstTextBlock = selectedTextBlocks.at(0)
|
|
21
|
+
|
|
22
|
+
if (!firstTextBlock) {
|
|
23
|
+
return undefined
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const firstStyle = firstTextBlock.style
|
|
27
|
+
|
|
28
|
+
if (!firstStyle) {
|
|
29
|
+
return undefined
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (selectedTextBlocks.every((block) => block.style === firstStyle)) {
|
|
33
|
+
return firstStyle
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return undefined
|
|
37
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isKeySegment,
|
|
3
|
+
isPortableTextSpan,
|
|
4
|
+
isPortableTextTextBlock,
|
|
5
|
+
type KeyedSegment,
|
|
6
|
+
type PortableTextSpan,
|
|
7
|
+
} from '@sanity/types'
|
|
8
|
+
import type {EditorSelector} from '../editor/editor-selector'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @alpha
|
|
12
|
+
*/
|
|
13
|
+
export const getSelectedSpans: EditorSelector<
|
|
14
|
+
Array<{
|
|
15
|
+
node: PortableTextSpan
|
|
16
|
+
path: [KeyedSegment, 'children', KeyedSegment]
|
|
17
|
+
}>
|
|
18
|
+
> = ({context}) => {
|
|
19
|
+
if (!context.selection) {
|
|
20
|
+
return []
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const selectedSpans: Array<{
|
|
24
|
+
node: PortableTextSpan
|
|
25
|
+
path: [KeyedSegment, 'children', KeyedSegment]
|
|
26
|
+
}> = []
|
|
27
|
+
|
|
28
|
+
const startPoint = context.selection.backward
|
|
29
|
+
? context.selection.focus
|
|
30
|
+
: context.selection.anchor
|
|
31
|
+
const endPoint = context.selection.backward
|
|
32
|
+
? context.selection.anchor
|
|
33
|
+
: context.selection.focus
|
|
34
|
+
|
|
35
|
+
const startBlockKey = isKeySegment(startPoint.path[0])
|
|
36
|
+
? startPoint.path[0]._key
|
|
37
|
+
: undefined
|
|
38
|
+
const endBlockKey = isKeySegment(endPoint.path[0])
|
|
39
|
+
? endPoint.path[0]._key
|
|
40
|
+
: undefined
|
|
41
|
+
|
|
42
|
+
if (!startBlockKey || !endBlockKey) {
|
|
43
|
+
return selectedSpans
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const startSpanKey = isKeySegment(startPoint.path[2])
|
|
47
|
+
? startPoint.path[2]._key
|
|
48
|
+
: undefined
|
|
49
|
+
const endSpanKey = isKeySegment(endPoint.path[2])
|
|
50
|
+
? endPoint.path[2]._key
|
|
51
|
+
: undefined
|
|
52
|
+
|
|
53
|
+
for (const block of context.value) {
|
|
54
|
+
if (!isPortableTextTextBlock(block)) {
|
|
55
|
+
continue
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (block._key === startBlockKey) {
|
|
59
|
+
for (const child of block.children) {
|
|
60
|
+
if (!isPortableTextSpan(child)) {
|
|
61
|
+
continue
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (startSpanKey && child._key === startSpanKey) {
|
|
65
|
+
selectedSpans.push({
|
|
66
|
+
node: child,
|
|
67
|
+
path: [{_key: block._key}, 'children', {_key: child._key}],
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
if (startBlockKey === endBlockKey) {
|
|
71
|
+
break
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (endSpanKey && child._key === endSpanKey) {
|
|
76
|
+
selectedSpans.push({
|
|
77
|
+
node: child,
|
|
78
|
+
path: [{_key: block._key}, 'children', {_key: child._key}],
|
|
79
|
+
})
|
|
80
|
+
break
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (selectedSpans.length > 0) {
|
|
84
|
+
selectedSpans.push({
|
|
85
|
+
node: child,
|
|
86
|
+
path: [{_key: block._key}, 'children', {_key: child._key}],
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (startBlockKey === endBlockKey) {
|
|
92
|
+
break
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
continue
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (block._key === endBlockKey) {
|
|
99
|
+
for (const child of block.children) {
|
|
100
|
+
if (!isPortableTextSpan(child)) {
|
|
101
|
+
continue
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (endSpanKey && child._key === endSpanKey) {
|
|
105
|
+
selectedSpans.push({
|
|
106
|
+
node: child,
|
|
107
|
+
path: [{_key: block._key}, 'children', {_key: child._key}],
|
|
108
|
+
})
|
|
109
|
+
break
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
selectedSpans.push({
|
|
113
|
+
node: child,
|
|
114
|
+
path: [{_key: block._key}, 'children', {_key: child._key}],
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
break
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (selectedSpans.length > 0) {
|
|
122
|
+
for (const child of block.children) {
|
|
123
|
+
if (!isPortableTextSpan(child)) {
|
|
124
|
+
continue
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
selectedSpans.push({
|
|
128
|
+
node: child,
|
|
129
|
+
path: [{_key: block._key}, 'children', {_key: child._key}],
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return selectedSpans
|
|
136
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {isPortableTextTextBlock} from '@sanity/types'
|
|
2
|
+
import type {EditorSelector} from '../editor/editor-selector'
|
|
3
|
+
import {getSelectedSpans} from './selector.get-selected-spans'
|
|
4
|
+
import {getSelectedBlocks} from './selectors'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @alpha
|
|
8
|
+
*/
|
|
9
|
+
export function isActiveAnnotation(
|
|
10
|
+
annotation: string,
|
|
11
|
+
): EditorSelector<boolean> {
|
|
12
|
+
return (snapshot) => {
|
|
13
|
+
if (!snapshot.context.selection) {
|
|
14
|
+
return false
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const selectedBlocks = getSelectedBlocks(snapshot)
|
|
18
|
+
const selectedSpans = getSelectedSpans(snapshot)
|
|
19
|
+
|
|
20
|
+
if (selectedSpans.length === 0) {
|
|
21
|
+
return false
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (
|
|
25
|
+
selectedSpans.some(
|
|
26
|
+
(span) => !span.node.marks || span.node.marks?.length === 0,
|
|
27
|
+
)
|
|
28
|
+
) {
|
|
29
|
+
return false
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const selectionMarkDefs = selectedBlocks.flatMap((block) =>
|
|
33
|
+
isPortableTextTextBlock(block.node) ? (block.node.markDefs ?? []) : [],
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
return selectedSpans.every((span) => {
|
|
37
|
+
const spanMarkDefs =
|
|
38
|
+
span.node.marks?.flatMap((mark) => {
|
|
39
|
+
const markDef = selectionMarkDefs.find(
|
|
40
|
+
(markDef) => markDef._key === mark,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
return markDef ? [markDef._type] : []
|
|
44
|
+
}) ?? []
|
|
45
|
+
|
|
46
|
+
return spanMarkDefs.includes(annotation)
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type {EditorSelector} from '../editor/editor-selector'
|
|
2
|
+
import {getSelectedSpans} from './selector.get-selected-spans'
|
|
3
|
+
import {isSelectionExpanded} from './selector.is-selection-expanded'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @alpha
|
|
7
|
+
*/
|
|
8
|
+
export function isActiveDecorator(decorator: string): EditorSelector<boolean> {
|
|
9
|
+
return (snapshot) => {
|
|
10
|
+
if (isSelectionExpanded(snapshot)) {
|
|
11
|
+
const selectedSpans = getSelectedSpans(snapshot)
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
selectedSpans.length > 0 &&
|
|
15
|
+
selectedSpans.every((span) => span.node.marks?.includes(decorator))
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return snapshot.context.activeDecorators.includes(decorator)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type {EditorSelector} from '../editor/editor-selector'
|
|
2
|
+
import {getActiveListItem} from './selector.get-active-list-item'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @alpha
|
|
6
|
+
*/
|
|
7
|
+
export function isActiveListItem(listItem: string): EditorSelector<boolean> {
|
|
8
|
+
return (snapshot) => {
|
|
9
|
+
const activeListItem = getActiveListItem(snapshot)
|
|
10
|
+
|
|
11
|
+
return activeListItem === listItem
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type {EditorSelector} from '../editor/editor-selector'
|
|
2
|
+
import {getActiveStyle} from './selector.get-active-style'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @alpha
|
|
6
|
+
*/
|
|
7
|
+
export function isActiveStyle(style: string): EditorSelector<boolean> {
|
|
8
|
+
return (snapshot) => {
|
|
9
|
+
const activeStyle = getActiveStyle(snapshot)
|
|
10
|
+
|
|
11
|
+
return activeStyle === style
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type {EditorSelector} from '../editor/editor-selector'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @alpha
|
|
5
|
+
*/
|
|
6
|
+
export const isSelectionCollapsed: EditorSelector<boolean> = ({context}) => {
|
|
7
|
+
return (
|
|
8
|
+
JSON.stringify(context.selection?.anchor.path) ===
|
|
9
|
+
JSON.stringify(context.selection?.focus.path) &&
|
|
10
|
+
context.selection?.anchor.offset === context.selection?.focus.offset
|
|
11
|
+
)
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type {EditorSelector} from '../editor/editor-selector'
|
|
2
|
+
import {isSelectionCollapsed} from './selector.is-selection-collapsed'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @alpha
|
|
6
|
+
*/
|
|
7
|
+
export const isSelectionExpanded: EditorSelector<boolean> = ({context}) => {
|
|
8
|
+
return !isSelectionCollapsed({context})
|
|
9
|
+
}
|
|
@@ -12,17 +12,6 @@ import {
|
|
|
12
12
|
import {createGuards} from '../behavior-actions/behavior.guards'
|
|
13
13
|
import type {EditorSelector} from '../editor/editor-selector'
|
|
14
14
|
|
|
15
|
-
/**
|
|
16
|
-
* @alpha
|
|
17
|
-
*/
|
|
18
|
-
export const selectionIsCollapsed: EditorSelector<boolean> = ({context}) => {
|
|
19
|
-
return (
|
|
20
|
-
JSON.stringify(context.selection?.anchor.path) ===
|
|
21
|
-
JSON.stringify(context.selection?.focus.path) &&
|
|
22
|
-
context.selection?.anchor.offset === context.selection?.focus.offset
|
|
23
|
-
)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
15
|
/**
|
|
27
16
|
* @alpha
|
|
28
17
|
*/
|
|
@@ -4,13 +4,13 @@ import {beforeEach, describe, expect, it} from 'vitest'
|
|
|
4
4
|
import {createActor} from 'xstate'
|
|
5
5
|
import {coreBehaviors} from '../../behaviors/behavior.core'
|
|
6
6
|
import {schemaType} from '../../editor/__tests__/PortableTextEditorTester'
|
|
7
|
+
import {createEditorSchema} from '../../editor/create-editor-schema'
|
|
7
8
|
import {editorMachine} from '../../editor/editor-machine'
|
|
8
9
|
import {defaultKeyGenerator} from '../../editor/key-generator'
|
|
9
10
|
import {withPlugins} from '../../editor/plugins/with-plugins'
|
|
10
|
-
import {getPortableTextMemberSchemaTypes} from '../getPortableTextMemberSchemaTypes'
|
|
11
11
|
import {createOperationToPatches} from '../operationToPatches'
|
|
12
12
|
|
|
13
|
-
const schemaTypes =
|
|
13
|
+
const schemaTypes = createEditorSchema(schemaType)
|
|
14
14
|
|
|
15
15
|
const operationToPatches = createOperationToPatches(schemaTypes)
|
|
16
16
|
|
|
@@ -4,14 +4,14 @@ import {beforeEach, describe, expect, it} from 'vitest'
|
|
|
4
4
|
import {createActor} from 'xstate'
|
|
5
5
|
import {coreBehaviors} from '../../behaviors/behavior.core'
|
|
6
6
|
import {schemaType} from '../../editor/__tests__/PortableTextEditorTester'
|
|
7
|
+
import {createEditorSchema} from '../../editor/create-editor-schema'
|
|
7
8
|
import {editorMachine} from '../../editor/editor-machine'
|
|
8
9
|
import {defaultKeyGenerator} from '../../editor/key-generator'
|
|
9
10
|
import {withPlugins} from '../../editor/plugins/with-plugins'
|
|
10
11
|
import {createApplyPatch} from '../applyPatch'
|
|
11
|
-
import {getPortableTextMemberSchemaTypes} from '../getPortableTextMemberSchemaTypes'
|
|
12
12
|
import {VOID_CHILD_KEY} from '../values'
|
|
13
13
|
|
|
14
|
-
const schemaTypes =
|
|
14
|
+
const schemaTypes = createEditorSchema(schemaType)
|
|
15
15
|
|
|
16
16
|
const patchToOperations = createApplyPatch(schemaTypes)
|
|
17
17
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {describe, expect, it} from 'vitest'
|
|
2
2
|
import {schemaType} from '../../editor/__tests__/PortableTextEditorTester'
|
|
3
|
-
import {
|
|
3
|
+
import {createEditorSchema} from '../../editor/create-editor-schema'
|
|
4
4
|
import {fromSlateValue, toSlateValue} from '../values'
|
|
5
5
|
|
|
6
|
-
const schemaTypes =
|
|
6
|
+
const schemaTypes = createEditorSchema(schemaType)
|
|
7
7
|
|
|
8
8
|
describe('toSlateValue', () => {
|
|
9
9
|
it('checks undefined', () => {
|
package/src/utils/weakMaps.ts
CHANGED
|
@@ -4,9 +4,6 @@ import type {EditorSelection} from '..'
|
|
|
4
4
|
// Is the editor currently receiving remote changes that are being applied to the content?
|
|
5
5
|
export const IS_PROCESSING_REMOTE_CHANGES: WeakMap<Editor, boolean> =
|
|
6
6
|
new WeakMap()
|
|
7
|
-
// Is the editor currently producing local changes that are not yet submitted?
|
|
8
|
-
export const IS_PROCESSING_LOCAL_CHANGES: WeakMap<Editor, boolean> =
|
|
9
|
-
new WeakMap()
|
|
10
7
|
|
|
11
8
|
// Is the editor dragging something?
|
|
12
9
|
export const IS_DRAGGING: WeakMap<Editor, boolean> = new WeakMap()
|
package/src/utils/withChanges.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import type {Editor} from 'slate'
|
|
2
|
-
import {
|
|
3
|
-
IS_PROCESSING_LOCAL_CHANGES,
|
|
4
|
-
IS_PROCESSING_REMOTE_CHANGES,
|
|
5
|
-
} from './weakMaps'
|
|
2
|
+
import {IS_PROCESSING_REMOTE_CHANGES} from './weakMaps'
|
|
6
3
|
|
|
7
4
|
export function withRemoteChanges(editor: Editor, fn: () => void): void {
|
|
8
5
|
const prev = isChangingRemotely(editor) || false
|
|
@@ -14,7 +11,3 @@ export function withRemoteChanges(editor: Editor, fn: () => void): void {
|
|
|
14
11
|
export function isChangingRemotely(editor: Editor): boolean | undefined {
|
|
15
12
|
return IS_PROCESSING_REMOTE_CHANGES.get(editor)
|
|
16
13
|
}
|
|
17
|
-
|
|
18
|
-
export function isChangingLocally(editor: Editor): boolean | undefined {
|
|
19
|
-
return IS_PROCESSING_LOCAL_CHANGES.get(editor)
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.cjs","sources":["../../src/behavior-actions/behavior.guards.ts","../../src/selectors/selectors.ts"],"sourcesContent":["import {\n isPortableTextListBlock,\n isPortableTextTextBlock,\n type PortableTextListBlock,\n type PortableTextTextBlock,\n} from '@sanity/types'\nimport type {PortableTextMemberSchemaTypes} from '../types/editor'\n\n/**\n * @alpha\n */\nexport type BehaviorGuards = ReturnType<typeof createGuards>\n\nexport function createGuards({\n schema,\n}: {\n schema: PortableTextMemberSchemaTypes\n}) {\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 * @alpha\n */\nexport const selectionIsCollapsed: EditorSelector<boolean> = ({context}) => {\n return (\n JSON.stringify(context.selection?.anchor.path) ===\n JSON.stringify(context.selection?.focus.path) &&\n context.selection?.anchor.offset === context.selection?.focus.offset\n )\n}\n\n/**\n * @alpha\n */\nexport const getFocusBlock: EditorSelector<\n {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n> = ({context}) => {\n const key = context.selection\n ? isKeySegment(context.selection.focus.path[0])\n ? context.selection.focus.path[0]._key\n : undefined\n : undefined\n\n const node = key\n ? context.value.find((block) => block._key === key)\n : undefined\n\n return node && key ? {node, path: [{_key: key}]} : undefined\n}\n\n/**\n * @alpha\n */\nexport const getFocusListBlock: EditorSelector<\n {node: PortableTextListBlock; path: [KeyedSegment]} | undefined\n> = ({context}) => {\n const guards = createGuards(context)\n const focusBlock = getFocusBlock({context})\n\n return focusBlock && guards.isListBlock(focusBlock.node)\n ? {node: focusBlock.node, path: focusBlock.path}\n : undefined\n}\n\n/**\n * @alpha\n */\nexport const getFocusTextBlock: EditorSelector<\n {node: PortableTextTextBlock; path: [KeyedSegment]} | undefined\n> = ({context}) => {\n const focusBlock = getFocusBlock({context})\n\n return focusBlock && isPortableTextTextBlock(focusBlock.node)\n ? {node: focusBlock.node, path: focusBlock.path}\n : undefined\n}\n\n/**\n * @alpha\n */\nexport const getFocusBlockObject: EditorSelector<\n {node: PortableTextObject; path: [KeyedSegment]} | undefined\n> = ({context}) => {\n const focusBlock = getFocusBlock({context})\n\n return focusBlock && !isPortableTextTextBlock(focusBlock.node)\n ? {node: focusBlock.node, path: focusBlock.path}\n : undefined\n}\n\n/**\n * @alpha\n */\nexport const getFocusChild: EditorSelector<\n | {\n node: PortableTextObject | PortableTextSpan\n path: [KeyedSegment, 'children', KeyedSegment]\n }\n | undefined\n> = ({context}) => {\n const focusBlock = getFocusTextBlock({context})\n\n if (!focusBlock) {\n return undefined\n }\n\n const key = context.selection\n ? isKeySegment(context.selection.focus.path[2])\n ? 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 * @alpha\n */\nexport const getFocusSpan: EditorSelector<\n | {node: PortableTextSpan; path: [KeyedSegment, 'children', KeyedSegment]}\n | undefined\n> = ({context}) => {\n const focusChild = getFocusChild({context})\n\n return focusChild && isPortableTextSpan(focusChild.node)\n ? {node: focusChild.node, path: focusChild.path}\n : undefined\n}\n\n/**\n * @alpha\n */\nexport const getFirstBlock: EditorSelector<\n {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n> = ({context}) => {\n const node = context.value[0]\n\n return node ? {node, path: [{_key: node._key}]} : undefined\n}\n\n/**\n * @alpha\n */\nexport const getLastBlock: EditorSelector<\n {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n> = ({context}) => {\n const node = context.value[context.value.length - 1]\n ? context.value[context.value.length - 1]\n : undefined\n\n return node ? {node, path: [{_key: node._key}]} : undefined\n}\n\n/**\n * @alpha\n */\nexport const getSelectedBlocks: EditorSelector<\n Array<{node: PortableTextBlock; path: [KeyedSegment]}>\n> = ({context}) => {\n if (!context.selection) {\n return []\n }\n\n const selectedBlocks: Array<{node: PortableTextBlock; path: [KeyedSegment]}> =\n []\n const startKey = context.selection.backward\n ? isKeySegment(context.selection.focus.path[0])\n ? context.selection.focus.path[0]._key\n : undefined\n : isKeySegment(context.selection.anchor.path[0])\n ? context.selection.anchor.path[0]._key\n : undefined\n const endKey = context.selection.backward\n ? isKeySegment(context.selection.anchor.path[0])\n ? context.selection.anchor.path[0]._key\n : undefined\n : isKeySegment(context.selection.focus.path[0])\n ? context.selection.focus.path[0]._key\n : undefined\n\n if (!startKey || !endKey) {\n return selectedBlocks\n }\n\n for (const block of 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 * @alpha\n */\nexport const getSelectionStartBlock: EditorSelector<\n | {\n node: PortableTextBlock\n path: [KeyedSegment]\n }\n | undefined\n> = ({context}) => {\n if (!context.selection) {\n return undefined\n }\n\n const key = context.selection.backward\n ? isKeySegment(context.selection.focus.path[0])\n ? context.selection.focus.path[0]._key\n : undefined\n : isKeySegment(context.selection.anchor.path[0])\n ? context.selection.anchor.path[0]._key\n : undefined\n\n const node = key\n ? context.value.find((block) => block._key === key)\n : undefined\n\n return node && key ? {node, path: [{_key: key}]} : undefined\n}\n\n/**\n * @alpha\n */\nexport const getSelectionEndBlock: EditorSelector<\n | {\n node: PortableTextBlock\n path: [KeyedSegment]\n }\n | undefined\n> = ({context}) => {\n if (!context.selection) {\n return undefined\n }\n\n const key = context.selection.backward\n ? isKeySegment(context.selection.anchor.path[0])\n ? context.selection.anchor.path[0]._key\n : undefined\n : isKeySegment(context.selection.focus.path[0])\n ? context.selection.focus.path[0]._key\n : undefined\n\n const node = key\n ? context.value.find((block) => block._key === key)\n : undefined\n\n return node && key ? {node, path: [{_key: key}]} : undefined\n}\n\n/**\n * @alpha\n */\nexport const getPreviousBlock: EditorSelector<\n {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n> = ({context}) => {\n let previousBlock: {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n const selectionStartBlock = getSelectionStartBlock({context})\n\n if (!selectionStartBlock) {\n return undefined\n }\n\n let foundSelectionStartBlock = false\n\n for (const block of 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 * @alpha\n */\nexport const getNextBlock: EditorSelector<\n {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n> = ({context}) => {\n let nextBlock: {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n const selectionEndBlock = getSelectionEndBlock({context})\n\n if (!selectionEndBlock) {\n return undefined\n }\n\n let foundSelectionEndBlock = false\n\n for (const block of 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"],"names":["createGuards","schema","isListBlock","block","isPortableTextListBlock","_type","name","isTextBlock","isPortableTextTextBlock","selectionIsCollapsed","context","JSON","stringify","selection","anchor","path","focus","offset","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"],"mappings":";;AAaO,SAASA,aAAa;AAAA,EAC3BC;AAGF,GAAG;AACD,WAASC,YAAYC,OAAgD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CAAQ;AAExD,MAAI,CAAC4C;AACH;AAGF,MAAIC,yBAAyB;AAElBpD,aAAAA,SAASO,QAAQc,OAAO;AACjC,QAAIrB,MAAMkB,SAASiC,kBAAkB/B,KAAKF,MAAM;AACrB,+BAAA;AACzB;AAAA,IAAA;AAGF,QAAIkC,wBAAwB;AACd,kBAAA;AAAA,QAAChC,MAAMpB;AAAAA,QAAOY,MAAM,CAAC;AAAA,UAACM,MAAMlB,MAAMkB;AAAAA,QAAK,CAAA;AAAA,MAAC;AACpD;AAAA,IAAA;AAAA,EACF;AAGF,MAAIkC,0BAA0BF;AACrBA,WAAAA;AAIX;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.js","sources":["../../src/behavior-actions/behavior.guards.ts","../../src/selectors/selectors.ts"],"sourcesContent":["import {\n isPortableTextListBlock,\n isPortableTextTextBlock,\n type PortableTextListBlock,\n type PortableTextTextBlock,\n} from '@sanity/types'\nimport type {PortableTextMemberSchemaTypes} from '../types/editor'\n\n/**\n * @alpha\n */\nexport type BehaviorGuards = ReturnType<typeof createGuards>\n\nexport function createGuards({\n schema,\n}: {\n schema: PortableTextMemberSchemaTypes\n}) {\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 * @alpha\n */\nexport const selectionIsCollapsed: EditorSelector<boolean> = ({context}) => {\n return (\n JSON.stringify(context.selection?.anchor.path) ===\n JSON.stringify(context.selection?.focus.path) &&\n context.selection?.anchor.offset === context.selection?.focus.offset\n )\n}\n\n/**\n * @alpha\n */\nexport const getFocusBlock: EditorSelector<\n {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n> = ({context}) => {\n const key = context.selection\n ? isKeySegment(context.selection.focus.path[0])\n ? context.selection.focus.path[0]._key\n : undefined\n : undefined\n\n const node = key\n ? context.value.find((block) => block._key === key)\n : undefined\n\n return node && key ? {node, path: [{_key: key}]} : undefined\n}\n\n/**\n * @alpha\n */\nexport const getFocusListBlock: EditorSelector<\n {node: PortableTextListBlock; path: [KeyedSegment]} | undefined\n> = ({context}) => {\n const guards = createGuards(context)\n const focusBlock = getFocusBlock({context})\n\n return focusBlock && guards.isListBlock(focusBlock.node)\n ? {node: focusBlock.node, path: focusBlock.path}\n : undefined\n}\n\n/**\n * @alpha\n */\nexport const getFocusTextBlock: EditorSelector<\n {node: PortableTextTextBlock; path: [KeyedSegment]} | undefined\n> = ({context}) => {\n const focusBlock = getFocusBlock({context})\n\n return focusBlock && isPortableTextTextBlock(focusBlock.node)\n ? {node: focusBlock.node, path: focusBlock.path}\n : undefined\n}\n\n/**\n * @alpha\n */\nexport const getFocusBlockObject: EditorSelector<\n {node: PortableTextObject; path: [KeyedSegment]} | undefined\n> = ({context}) => {\n const focusBlock = getFocusBlock({context})\n\n return focusBlock && !isPortableTextTextBlock(focusBlock.node)\n ? {node: focusBlock.node, path: focusBlock.path}\n : undefined\n}\n\n/**\n * @alpha\n */\nexport const getFocusChild: EditorSelector<\n | {\n node: PortableTextObject | PortableTextSpan\n path: [KeyedSegment, 'children', KeyedSegment]\n }\n | undefined\n> = ({context}) => {\n const focusBlock = getFocusTextBlock({context})\n\n if (!focusBlock) {\n return undefined\n }\n\n const key = context.selection\n ? isKeySegment(context.selection.focus.path[2])\n ? 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 * @alpha\n */\nexport const getFocusSpan: EditorSelector<\n | {node: PortableTextSpan; path: [KeyedSegment, 'children', KeyedSegment]}\n | undefined\n> = ({context}) => {\n const focusChild = getFocusChild({context})\n\n return focusChild && isPortableTextSpan(focusChild.node)\n ? {node: focusChild.node, path: focusChild.path}\n : undefined\n}\n\n/**\n * @alpha\n */\nexport const getFirstBlock: EditorSelector<\n {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n> = ({context}) => {\n const node = context.value[0]\n\n return node ? {node, path: [{_key: node._key}]} : undefined\n}\n\n/**\n * @alpha\n */\nexport const getLastBlock: EditorSelector<\n {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n> = ({context}) => {\n const node = context.value[context.value.length - 1]\n ? context.value[context.value.length - 1]\n : undefined\n\n return node ? {node, path: [{_key: node._key}]} : undefined\n}\n\n/**\n * @alpha\n */\nexport const getSelectedBlocks: EditorSelector<\n Array<{node: PortableTextBlock; path: [KeyedSegment]}>\n> = ({context}) => {\n if (!context.selection) {\n return []\n }\n\n const selectedBlocks: Array<{node: PortableTextBlock; path: [KeyedSegment]}> =\n []\n const startKey = context.selection.backward\n ? isKeySegment(context.selection.focus.path[0])\n ? context.selection.focus.path[0]._key\n : undefined\n : isKeySegment(context.selection.anchor.path[0])\n ? context.selection.anchor.path[0]._key\n : undefined\n const endKey = context.selection.backward\n ? isKeySegment(context.selection.anchor.path[0])\n ? context.selection.anchor.path[0]._key\n : undefined\n : isKeySegment(context.selection.focus.path[0])\n ? context.selection.focus.path[0]._key\n : undefined\n\n if (!startKey || !endKey) {\n return selectedBlocks\n }\n\n for (const block of 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 * @alpha\n */\nexport const getSelectionStartBlock: EditorSelector<\n | {\n node: PortableTextBlock\n path: [KeyedSegment]\n }\n | undefined\n> = ({context}) => {\n if (!context.selection) {\n return undefined\n }\n\n const key = context.selection.backward\n ? isKeySegment(context.selection.focus.path[0])\n ? context.selection.focus.path[0]._key\n : undefined\n : isKeySegment(context.selection.anchor.path[0])\n ? context.selection.anchor.path[0]._key\n : undefined\n\n const node = key\n ? context.value.find((block) => block._key === key)\n : undefined\n\n return node && key ? {node, path: [{_key: key}]} : undefined\n}\n\n/**\n * @alpha\n */\nexport const getSelectionEndBlock: EditorSelector<\n | {\n node: PortableTextBlock\n path: [KeyedSegment]\n }\n | undefined\n> = ({context}) => {\n if (!context.selection) {\n return undefined\n }\n\n const key = context.selection.backward\n ? isKeySegment(context.selection.anchor.path[0])\n ? context.selection.anchor.path[0]._key\n : undefined\n : isKeySegment(context.selection.focus.path[0])\n ? context.selection.focus.path[0]._key\n : undefined\n\n const node = key\n ? context.value.find((block) => block._key === key)\n : undefined\n\n return node && key ? {node, path: [{_key: key}]} : undefined\n}\n\n/**\n * @alpha\n */\nexport const getPreviousBlock: EditorSelector<\n {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n> = ({context}) => {\n let previousBlock: {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n const selectionStartBlock = getSelectionStartBlock({context})\n\n if (!selectionStartBlock) {\n return undefined\n }\n\n let foundSelectionStartBlock = false\n\n for (const block of 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 * @alpha\n */\nexport const getNextBlock: EditorSelector<\n {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n> = ({context}) => {\n let nextBlock: {node: PortableTextBlock; path: [KeyedSegment]} | undefined\n const selectionEndBlock = getSelectionEndBlock({context})\n\n if (!selectionEndBlock) {\n return undefined\n }\n\n let foundSelectionEndBlock = false\n\n for (const block of 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"],"names":["createGuards","schema","isListBlock","block","isPortableTextListBlock","_type","name","isTextBlock","isPortableTextTextBlock","selectionIsCollapsed","context","JSON","stringify","selection","anchor","path","focus","offset","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"],"mappings":";AAaO,SAASA,aAAa;AAAA,EAC3BC;AAGF,GAAG;AACD,WAASC,YAAYC,OAAgD;AACnE,WAAOC,wBAAwBD,KAAK,KAAKA,MAAME,UAAUJ,OAAOE,MAAMG;AAAAA,EAAAA;AAGxE,WAASC,YAAYJ,OAAgD;AACnE,WAAOK,wBAAwBL,KAAK,KAAKA,MAAME,UAAUJ,OAAOE,MAAMG;AAAAA,EAAAA;AAGjE,SAAA;AAAA,IAACJ;AAAAA,IAAaK;AAAAA,EAAW;AAClC;ACVO,MAAME,uBAAgDA,CAAC;AAAA,EAACC;AAAO,MAAM;AAjB5E,MAAA,IAAA,IAAA,IAAA;AAmBIC,SAAAA,KAAKC,WAAUF,KAAAA,QAAQG,cAARH,OAAAA,SAAAA,GAAmBI,OAAOC,IAAI,MAC3CJ,KAAKC,WAAUF,KAAQG,QAAAA,cAARH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