@portabletext/editor 1.43.1 → 1.44.1
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.markdown.cjs +1 -1
- package/lib/_chunks-cjs/editor-provider.cjs +555 -794
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-cjs/parse-blocks.cjs +151 -0
- package/lib/_chunks-cjs/parse-blocks.cjs.map +1 -0
- package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs +2 -1
- package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs.map +1 -1
- package/lib/_chunks-cjs/{selector.is-active-style.cjs → selector.is-selecting-entire-blocks.cjs} +47 -11
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -0
- 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 +0 -149
- package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs.map +1 -1
- package/lib/_chunks-es/behavior.markdown.js +1 -1
- package/lib/_chunks-es/editor-provider.js +539 -777
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/_chunks-es/parse-blocks.js +152 -0
- package/lib/_chunks-es/parse-blocks.js.map +1 -0
- package/lib/_chunks-es/selector.is-overlapping-selection.js +2 -1
- package/lib/_chunks-es/selector.is-overlapping-selection.js.map +1 -1
- package/lib/_chunks-es/{selector.is-active-style.js → selector.is-selecting-entire-blocks.js} +49 -12
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -0
- package/lib/_chunks-es/util.merge-text-blocks.js +1 -1
- package/lib/_chunks-es/util.selection-point-to-block-offset.js +0 -149
- package/lib/_chunks-es/util.selection-point-to-block-offset.js.map +1 -1
- package/lib/behaviors/index.d.cts +2819 -6421
- package/lib/behaviors/index.d.ts +2819 -6421
- package/lib/index.cjs +4 -4
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2496 -6025
- package/lib/index.d.ts +2496 -6025
- package/lib/index.js +3 -3
- package/lib/plugins/index.cjs +1 -1
- package/lib/plugins/index.d.cts +2496 -6025
- package/lib/plugins/index.d.ts +2496 -6025
- package/lib/plugins/index.js +1 -1
- package/lib/selectors/index.cjs +12 -11
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +2464 -6018
- package/lib/selectors/index.d.ts +2464 -6018
- package/lib/selectors/index.js +2 -1
- package/lib/utils/index.d.cts +2458 -6022
- package/lib/utils/index.d.ts +2458 -6022
- package/package.json +2 -2
- package/src/behavior-actions/behavior.actions.ts +2 -152
- package/src/behaviors/behavior.default.ts +52 -120
- package/src/behaviors/behavior.internal.annotation.ts +26 -0
- package/src/behaviors/behavior.internal.decorator.ts +47 -0
- package/src/behaviors/behavior.internal.insert.ts +118 -0
- package/src/behaviors/behavior.internal.list-item.ts +61 -0
- package/src/behaviors/behavior.internal.select.ts +62 -0
- package/src/behaviors/behavior.internal.style.ts +54 -0
- package/src/behaviors/behavior.perform-event.ts +15 -13
- package/src/behaviors/behavior.types.event.ts +155 -108
- package/src/editor/create-editor.ts +2 -2
- package/src/editor/editor-machine.ts +3 -4
- package/src/editor/plugins/createWithEditableAPI.ts +1 -32
- package/src/editor/plugins/createWithPortableTextMarkModel.ts +0 -29
- package/src/internal-utils/slate-utils.ts +52 -0
- package/src/plugins/plugin.internal.editor-actor-ref.tsx +15 -0
- package/src/plugins/plugin.internal.slate-editor-ref.tsx +15 -0
- package/src/selectors/index.ts +2 -1
- package/src/selectors/selector.get-selected-text-blocks.ts +67 -0
- package/lib/_chunks-cjs/selector.is-active-style.cjs.map +0 -1
- package/lib/_chunks-es/selector.is-active-style.js.map +0 -1
- package/src/behavior-actions/behavior.action.data-transfer-set.ts +0 -7
- package/src/behavior-actions/behavior.action.deserialization.failure.ts +0 -9
- package/src/behavior-actions/behavior.action.deserialization.success.ts +0 -16
- package/src/behavior-actions/behavior.action.insert-blocks.ts +0 -140
- package/src/behavior-actions/behavior.action.list-item.ts +0 -100
- package/src/behavior-actions/behavior.action.select.next-block.ts +0 -44
- package/src/behavior-actions/behavior.action.select.previous-block.ts +0 -48
- package/src/behavior-actions/behavior.action.serialization.failure.ts +0 -9
- package/src/behavior-actions/behavior.action.serialization.success.ts +0 -17
- package/src/behavior-actions/behavior.action.style.ts +0 -108
|
@@ -18,11 +18,10 @@ import {
|
|
|
18
18
|
} from 'slate'
|
|
19
19
|
import type {DOMNode} from 'slate-dom'
|
|
20
20
|
import {ReactEditor} from 'slate-react'
|
|
21
|
-
import {isListItemActive} from '../../behavior-actions/behavior.action.list-item'
|
|
22
|
-
import {isStyleActive} from '../../behavior-actions/behavior.action.style'
|
|
23
21
|
import type {BehaviorActionImplementation} from '../../behavior-actions/behavior.actions'
|
|
24
22
|
import {debugWithName} from '../../internal-utils/debug'
|
|
25
23
|
import {toPortableTextRange, toSlateRange} from '../../internal-utils/ranges'
|
|
24
|
+
import {isListItemActive, isStyleActive} from '../../internal-utils/slate-utils'
|
|
26
25
|
import {fromSlateValue, toSlateValue} from '../../internal-utils/values'
|
|
27
26
|
import {
|
|
28
27
|
KEY_TO_VALUE_ELEMENT,
|
|
@@ -900,33 +899,3 @@ export const removeAnnotationActionImplementation: BehaviorActionImplementation<
|
|
|
900
899
|
}
|
|
901
900
|
}
|
|
902
901
|
}
|
|
903
|
-
|
|
904
|
-
export const toggleAnnotationActionImplementation: BehaviorActionImplementation<
|
|
905
|
-
'annotation.toggle',
|
|
906
|
-
AddedAnnotationPaths | undefined
|
|
907
|
-
> = ({context, action}) => {
|
|
908
|
-
const isActive = isAnnotationActive({
|
|
909
|
-
editor: action.editor,
|
|
910
|
-
annotation: {name: action.annotation.name},
|
|
911
|
-
})
|
|
912
|
-
|
|
913
|
-
if (isActive) {
|
|
914
|
-
removeAnnotationActionImplementation({
|
|
915
|
-
context,
|
|
916
|
-
action: {
|
|
917
|
-
type: 'annotation.remove',
|
|
918
|
-
annotation: action.annotation,
|
|
919
|
-
editor: action.editor,
|
|
920
|
-
},
|
|
921
|
-
})
|
|
922
|
-
} else {
|
|
923
|
-
return addAnnotationActionImplementation({
|
|
924
|
-
context,
|
|
925
|
-
action: {
|
|
926
|
-
type: 'annotation.add',
|
|
927
|
-
annotation: action.annotation,
|
|
928
|
-
editor: action.editor,
|
|
929
|
-
},
|
|
930
|
-
})
|
|
931
|
-
}
|
|
932
|
-
}
|
|
@@ -8,7 +8,6 @@ import {isPortableTextBlock, isPortableTextSpan} from '@portabletext/toolkit'
|
|
|
8
8
|
import type {PortableTextObject, PortableTextSpan} from '@sanity/types'
|
|
9
9
|
import {isEqual, uniq} from 'lodash'
|
|
10
10
|
import {Editor, Element, Node, Path, Range, Text, Transforms} from 'slate'
|
|
11
|
-
import {decoratorAddActionImplementation} from '../../behavior-actions/behavior.action.decorator.add'
|
|
12
11
|
import type {BehaviorActionImplementation} from '../../behavior-actions/behavior.actions'
|
|
13
12
|
import {debugWithName} from '../../internal-utils/debug'
|
|
14
13
|
import {getNextSpan, getPreviousSpan} from '../../internal-utils/sibling-utils'
|
|
@@ -778,31 +777,3 @@ export function isDecoratorActive({
|
|
|
778
777
|
}.marks || []
|
|
779
778
|
).includes(decorator)
|
|
780
779
|
}
|
|
781
|
-
|
|
782
|
-
export const toggleDecoratorActionImplementation: BehaviorActionImplementation<
|
|
783
|
-
'decorator.toggle'
|
|
784
|
-
> = ({context, action}) => {
|
|
785
|
-
const isActive = isDecoratorActive({
|
|
786
|
-
editor: action.editor,
|
|
787
|
-
decorator: action.decorator,
|
|
788
|
-
})
|
|
789
|
-
|
|
790
|
-
if (isActive) {
|
|
791
|
-
removeDecoratorActionImplementation({
|
|
792
|
-
context,
|
|
793
|
-
action: {
|
|
794
|
-
type: 'decorator.remove',
|
|
795
|
-
editor: action.editor,
|
|
796
|
-
decorator: action.decorator,
|
|
797
|
-
},
|
|
798
|
-
})
|
|
799
|
-
} else {
|
|
800
|
-
decoratorAddActionImplementation({
|
|
801
|
-
context,
|
|
802
|
-
action: {
|
|
803
|
-
...action,
|
|
804
|
-
type: 'decorator.add',
|
|
805
|
-
},
|
|
806
|
-
})
|
|
807
|
-
}
|
|
808
|
-
}
|
|
@@ -126,3 +126,55 @@ function isBlockElement(
|
|
|
126
126
|
))
|
|
127
127
|
)
|
|
128
128
|
}
|
|
129
|
+
|
|
130
|
+
export function isListItemActive({
|
|
131
|
+
editor,
|
|
132
|
+
listItem,
|
|
133
|
+
}: {
|
|
134
|
+
editor: Editor
|
|
135
|
+
listItem: string
|
|
136
|
+
}): boolean {
|
|
137
|
+
if (!editor.selection) {
|
|
138
|
+
return false
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const selectedBlocks = [
|
|
142
|
+
...Editor.nodes(editor, {
|
|
143
|
+
at: editor.selection,
|
|
144
|
+
match: (node) => editor.isTextBlock(node),
|
|
145
|
+
}),
|
|
146
|
+
]
|
|
147
|
+
|
|
148
|
+
if (selectedBlocks.length > 0) {
|
|
149
|
+
return selectedBlocks.every(
|
|
150
|
+
([node]) => editor.isListBlock(node) && node.listItem === listItem,
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return false
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function isStyleActive({
|
|
158
|
+
editor,
|
|
159
|
+
style,
|
|
160
|
+
}: {
|
|
161
|
+
editor: Editor
|
|
162
|
+
style: string
|
|
163
|
+
}): boolean {
|
|
164
|
+
if (!editor.selection) {
|
|
165
|
+
return false
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const selectedBlocks = [
|
|
169
|
+
...Editor.nodes(editor, {
|
|
170
|
+
at: editor.selection,
|
|
171
|
+
match: (node) => editor.isTextBlock(node),
|
|
172
|
+
}),
|
|
173
|
+
]
|
|
174
|
+
|
|
175
|
+
if (selectedBlocks.length > 0) {
|
|
176
|
+
return selectedBlocks.every(([node]) => node.style === style)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return false
|
|
180
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, {useContext} from 'react'
|
|
2
|
+
import {EditorActorContext} from '../editor/editor-actor-context'
|
|
3
|
+
import type {EditorActor} from '../editor/editor-machine'
|
|
4
|
+
|
|
5
|
+
export const InternalEditorAfterRefPlugin =
|
|
6
|
+
React.forwardRef<EditorActor | null>((_, ref) => {
|
|
7
|
+
const editorActor = useContext(EditorActorContext)
|
|
8
|
+
|
|
9
|
+
const editorActorRef = React.useRef(editorActor)
|
|
10
|
+
|
|
11
|
+
React.useImperativeHandle(ref, () => editorActorRef.current, [])
|
|
12
|
+
|
|
13
|
+
return null
|
|
14
|
+
})
|
|
15
|
+
InternalEditorAfterRefPlugin.displayName = 'InternalEditorAfterRefPlugin'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {useSlateStatic} from 'slate-react'
|
|
3
|
+
import type {PortableTextSlateEditor} from '../types/editor'
|
|
4
|
+
|
|
5
|
+
export const InternalSlateEditorRefPlugin =
|
|
6
|
+
React.forwardRef<PortableTextSlateEditor | null>((_, ref) => {
|
|
7
|
+
const slateEditor = useSlateStatic()
|
|
8
|
+
|
|
9
|
+
const slateEditorRef = React.useRef(slateEditor)
|
|
10
|
+
|
|
11
|
+
React.useImperativeHandle(ref, () => slateEditorRef.current, [])
|
|
12
|
+
|
|
13
|
+
return null
|
|
14
|
+
})
|
|
15
|
+
InternalSlateEditorRefPlugin.displayName = 'InternalSlateEditorRefPlugin'
|
package/src/selectors/index.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export {isSelectingEntireBlocks} from './selector.is-selecting-entire-blocks'
|
|
2
1
|
export {getActiveAnnotations} from './selector.get-active-annotations'
|
|
3
2
|
export {getActiveListItem} from './selector.get-active-list-item'
|
|
4
3
|
export {getActiveStyle} from './selector.get-active-style'
|
|
@@ -13,6 +12,7 @@ export {getNextInlineObject} from './selector.get-next-inline-object'
|
|
|
13
12
|
export {getPreviousInlineObject} from './selector.get-previous-inline-object'
|
|
14
13
|
export {getSelectedSlice} from './selector.get-selected-slice'
|
|
15
14
|
export {getSelectedSpans} from './selector.get-selected-spans'
|
|
15
|
+
export {getSelectedTextBlocks} from './selector.get-selected-text-blocks'
|
|
16
16
|
export {getSelection} from './selector.get-selection'
|
|
17
17
|
export {getSelectionEndPoint} from './selector.get-selection-end-point'
|
|
18
18
|
export {getSelectionStartPoint} from './selector.get-selection-start-point'
|
|
@@ -29,6 +29,7 @@ export {isAtTheStartOfBlock} from './selector.is-at-the-start-of-block'
|
|
|
29
29
|
export {isOverlappingSelection} from './selector.is-overlapping-selection'
|
|
30
30
|
export {isPointAfterSelection} from './selector.is-point-after-selection'
|
|
31
31
|
export {isPointBeforeSelection} from './selector.is-point-before-selection'
|
|
32
|
+
export {isSelectingEntireBlocks} from './selector.is-selecting-entire-blocks'
|
|
32
33
|
export {isSelectionCollapsed} from './selector.is-selection-collapsed'
|
|
33
34
|
export {isSelectionExpanded} from './selector.is-selection-expanded'
|
|
34
35
|
export * from './selectors'
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type {KeyedSegment, PortableTextTextBlock} from '@sanity/types'
|
|
2
|
+
import type {EditorSelector} from '../editor/editor-selector'
|
|
3
|
+
import {isTextBlock} from '../internal-utils/parse-blocks'
|
|
4
|
+
import {isKeyedSegment} from '../utils'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export const getSelectedTextBlocks: EditorSelector<
|
|
10
|
+
Array<{node: PortableTextTextBlock; path: [KeyedSegment]}>
|
|
11
|
+
> = (snapshot) => {
|
|
12
|
+
if (!snapshot.context.selection) {
|
|
13
|
+
return []
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const selectedTextBlocks: Array<{
|
|
17
|
+
node: PortableTextTextBlock
|
|
18
|
+
path: [KeyedSegment]
|
|
19
|
+
}> = []
|
|
20
|
+
const startKey = snapshot.context.selection.backward
|
|
21
|
+
? isKeyedSegment(snapshot.context.selection.focus.path[0])
|
|
22
|
+
? snapshot.context.selection.focus.path[0]._key
|
|
23
|
+
: undefined
|
|
24
|
+
: isKeyedSegment(snapshot.context.selection.anchor.path[0])
|
|
25
|
+
? snapshot.context.selection.anchor.path[0]._key
|
|
26
|
+
: undefined
|
|
27
|
+
const endKey = snapshot.context.selection.backward
|
|
28
|
+
? isKeyedSegment(snapshot.context.selection.anchor.path[0])
|
|
29
|
+
? snapshot.context.selection.anchor.path[0]._key
|
|
30
|
+
: undefined
|
|
31
|
+
: isKeyedSegment(snapshot.context.selection.focus.path[0])
|
|
32
|
+
? snapshot.context.selection.focus.path[0]._key
|
|
33
|
+
: undefined
|
|
34
|
+
|
|
35
|
+
if (!startKey || !endKey) {
|
|
36
|
+
return selectedTextBlocks
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
for (const block of snapshot.context.value) {
|
|
40
|
+
if (block._key === startKey) {
|
|
41
|
+
if (isTextBlock(snapshot.context.schema, block)) {
|
|
42
|
+
selectedTextBlocks.push({node: block, path: [{_key: block._key}]})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (startKey === endKey) {
|
|
46
|
+
break
|
|
47
|
+
}
|
|
48
|
+
continue
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (block._key === endKey) {
|
|
52
|
+
if (isTextBlock(snapshot.context.schema, block)) {
|
|
53
|
+
selectedTextBlocks.push({node: block, path: [{_key: block._key}]})
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
break
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (selectedTextBlocks.length > 0) {
|
|
60
|
+
if (isTextBlock(snapshot.context.schema, block)) {
|
|
61
|
+
selectedTextBlocks.push({node: block, path: [{_key: block._key}]})
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return selectedTextBlocks
|
|
67
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selector.is-active-style.cjs","sources":["../../src/selectors/selector.is-selecting-entire-blocks.ts","../../src/selectors/selector.get-selected-spans.ts","../../src/selectors/selector.get-active-annotations.ts","../../src/selectors/selector.get-active-list-item.ts","../../src/selectors/selector.get-active-style.ts","../../src/selectors/selector.get-trimmed-selection.ts","../../src/selectors/selector.is-active-annotation.ts","../../src/selectors/selector.is-active-decorator.ts","../../src/selectors/selector.is-active-list-item.ts","../../src/selectors/selector.is-active-style.ts"],"sourcesContent":["import type {EditorSelector} from '../editor/editor-selector'\nimport * as utils from '../utils'\nimport {getSelectionEndBlock, getSelectionStartBlock} from './selectors'\n\n/**\n * @public\n */\nexport const isSelectingEntireBlocks: EditorSelector<boolean> = (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const startPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.focus\n : snapshot.context.selection.anchor\n const endPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.anchor\n : snapshot.context.selection.focus\n\n const startBlock = getSelectionStartBlock(snapshot)\n const endBlock = getSelectionEndBlock(snapshot)\n\n if (!startBlock || !endBlock) {\n return false\n }\n\n const startBlockStartPoint = utils.getBlockStartPoint(startBlock)\n const endBlockEndPoint = utils.getBlockEndPoint(endBlock)\n\n return (\n utils.isEqualSelectionPoints(startBlockStartPoint, startPoint) &&\n utils.isEqualSelectionPoints(endBlockEndPoint, endPoint)\n )\n}\n","import {\n isKeySegment,\n isPortableTextSpan,\n isPortableTextTextBlock,\n type KeyedSegment,\n type PortableTextSpan,\n} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\n\n/**\n * @public\n */\nexport const getSelectedSpans: EditorSelector<\n Array<{\n node: PortableTextSpan\n path: [KeyedSegment, 'children', KeyedSegment]\n }>\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedSpans: Array<{\n node: PortableTextSpan\n path: [KeyedSegment, 'children', KeyedSegment]\n }> = []\n\n const startPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.focus\n : snapshot.context.selection.anchor\n const endPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.anchor\n : snapshot.context.selection.focus\n\n const startBlockKey = isKeySegment(startPoint.path[0])\n ? startPoint.path[0]._key\n : undefined\n const endBlockKey = isKeySegment(endPoint.path[0])\n ? endPoint.path[0]._key\n : undefined\n\n if (!startBlockKey || !endBlockKey) {\n return selectedSpans\n }\n\n const startSpanKey = isKeySegment(startPoint.path[2])\n ? startPoint.path[2]._key\n : undefined\n const endSpanKey = isKeySegment(endPoint.path[2])\n ? endPoint.path[2]._key\n : undefined\n\n let startBlockFound = false\n\n for (const block of snapshot.context.value) {\n if (block._key === startBlockKey) {\n startBlockFound = true\n }\n\n if (!isPortableTextTextBlock(block)) {\n continue\n }\n\n if (block._key === startBlockKey) {\n for (const child of block.children) {\n if (!isPortableTextSpan(child)) {\n continue\n }\n\n if (startSpanKey && child._key === startSpanKey) {\n if (startPoint.offset < child.text.length) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n\n if (startSpanKey === endSpanKey) {\n break\n }\n\n continue\n }\n\n if (endSpanKey && child._key === endSpanKey) {\n if (endPoint.offset > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n break\n }\n\n if (selectedSpans.length > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n }\n\n if (startBlockKey === endBlockKey) {\n break\n }\n\n continue\n }\n\n if (block._key === endBlockKey) {\n for (const child of block.children) {\n if (!isPortableTextSpan(child)) {\n continue\n }\n\n if (endSpanKey && child._key === endSpanKey) {\n if (endPoint.offset > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n break\n }\n\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n\n break\n }\n\n if (startBlockFound) {\n for (const child of block.children) {\n if (!isPortableTextSpan(child)) {\n continue\n }\n\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n }\n }\n\n return selectedSpans\n}\n","import {isPortableTextTextBlock, type PortableTextObject} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedSpans} from './selector.get-selected-spans'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\nimport {getFocusSpan, getSelectedBlocks} from './selectors'\n\n/**\n * @public\n */\nexport const getActiveAnnotations: EditorSelector<Array<PortableTextObject>> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedBlocks = getSelectedBlocks(snapshot)\n const selectedSpans = getSelectedSpans(snapshot)\n const focusSpan = getFocusSpan(snapshot)\n\n if (selectedSpans.length === 0 || !focusSpan) {\n return []\n }\n\n if (selectedSpans.length === 1 && isSelectionCollapsed(snapshot)) {\n if (snapshot.context.selection.focus.offset === 0) {\n return []\n }\n if (\n snapshot.context.selection.focus.offset === focusSpan.node.text.length\n ) {\n return []\n }\n }\n\n const selectionMarkDefs = selectedBlocks.flatMap((block) =>\n isPortableTextTextBlock(block.node) ? (block.node.markDefs ?? []) : [],\n )\n\n return selectionMarkDefs.filter((markDef) =>\n selectedSpans.some((span) => span.node.marks?.includes(markDef._key)),\n )\n}\n","import type {PortableTextListBlock} from '@sanity/types'\nimport {createGuards} from '../behavior-actions/behavior.guards'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedBlocks} from './selectors'\n\n/**\n * @public\n */\nexport const getActiveListItem: EditorSelector<\n PortableTextListBlock['listItem'] | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const guards = createGuards(snapshot.context)\n const selectedBlocks = getSelectedBlocks(snapshot).map((block) => block.node)\n const selectedTextBlocks = selectedBlocks.filter(guards.isTextBlock)\n\n const firstTextBlock = selectedTextBlocks.at(0)\n\n if (!firstTextBlock) {\n return undefined\n }\n\n const firstListItem = firstTextBlock.listItem\n\n if (!firstListItem) {\n return undefined\n }\n\n if (selectedTextBlocks.every((block) => block.listItem === firstListItem)) {\n return firstListItem\n }\n\n return undefined\n}\n","import type {PortableTextTextBlock} from '@sanity/types'\nimport {createGuards} from '../behavior-actions/behavior.guards'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedBlocks} from './selectors'\n\n/**\n * @public\n */\nexport const getActiveStyle: EditorSelector<PortableTextTextBlock['style']> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const guards = createGuards(snapshot.context)\n const selectedBlocks = getSelectedBlocks(snapshot).map((block) => block.node)\n const selectedTextBlocks = selectedBlocks.filter(guards.isTextBlock)\n\n const firstTextBlock = selectedTextBlocks.at(0)\n\n if (!firstTextBlock) {\n return undefined\n }\n\n const firstStyle = firstTextBlock.style\n\n if (!firstStyle) {\n return undefined\n }\n\n if (selectedTextBlocks.every((block) => block.style === firstStyle)) {\n return firstStyle\n }\n\n return undefined\n}\n","import {\n isPortableTextSpan,\n isPortableTextTextBlock,\n type PortableTextSpan,\n} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {EditorSelection, EditorSelectionPoint} from '../types/editor'\nimport {isEmptyTextBlock, isKeyedSegment} from '../utils'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\nimport {getFocusTextBlock} from './selectors'\n\n/**\n * @public\n */\nexport const getTrimmedSelection: EditorSelector<EditorSelection> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return snapshot.context.selection\n }\n\n const startPoint = getSelectionStartPoint(snapshot)\n const endPoint = getSelectionEndPoint(snapshot)\n\n if (!startPoint || !endPoint) {\n return snapshot.context.selection\n }\n\n const startBlockKey = isKeyedSegment(startPoint.path[0])\n ? startPoint.path[0]._key\n : null\n const startChildKey = isKeyedSegment(startPoint.path[2])\n ? startPoint.path[2]._key\n : null\n const endBlockKey = isKeyedSegment(endPoint.path[0])\n ? endPoint.path[0]._key\n : null\n const endChildKey = isKeyedSegment(endPoint.path[2])\n ? endPoint.path[2]._key\n : null\n\n if (!startBlockKey || !endBlockKey) {\n return snapshot.context.selection\n }\n\n let startBlockFound = false\n let adjustedStartPoint: EditorSelectionPoint | undefined\n let trimStartPoint = false\n let adjustedEndPoint: EditorSelectionPoint | undefined\n let trimEndPoint = false\n let previousPotentialEndpoint:\n | {blockKey: string; span: PortableTextSpan}\n | undefined\n\n for (const block of snapshot.context.value) {\n if (block._key === startBlockKey) {\n startBlockFound = true\n\n if (isPortableTextTextBlock(block) && isEmptyTextBlock(block)) {\n continue\n }\n }\n\n if (!startBlockFound) {\n continue\n }\n\n if (!isPortableTextTextBlock(block)) {\n continue\n }\n\n if (block._key === endBlockKey && isEmptyTextBlock(block)) {\n break\n }\n\n for (const child of block.children) {\n if (child._key === endChildKey) {\n if (!isPortableTextSpan(child) || endPoint.offset === 0) {\n adjustedEndPoint = previousPotentialEndpoint\n ? {\n path: [\n {_key: previousPotentialEndpoint.blockKey},\n 'children',\n {_key: previousPotentialEndpoint.span._key},\n ],\n offset: previousPotentialEndpoint.span.text.length,\n }\n : undefined\n\n trimEndPoint = true\n break\n }\n }\n\n if (trimStartPoint) {\n const lonelySpan =\n isPortableTextSpan(child) && block.children.length === 1\n\n if (\n (isPortableTextSpan(child) && child.text.length > 0) ||\n lonelySpan\n ) {\n adjustedStartPoint = {\n path: [{_key: block._key}, 'children', {_key: child._key}],\n offset: 0,\n }\n previousPotentialEndpoint = {blockKey: block._key, span: child}\n trimStartPoint = false\n }\n\n continue\n }\n\n if (child._key === startChildKey) {\n if (!isPortableTextSpan(child)) {\n trimStartPoint = true\n continue\n }\n\n if (startPoint.offset === child.text.length) {\n trimStartPoint = true\n previousPotentialEndpoint =\n child.text.length > 0\n ? {blockKey: block._key, span: child}\n : previousPotentialEndpoint\n continue\n }\n }\n\n previousPotentialEndpoint =\n isPortableTextSpan(child) && child.text.length > 0\n ? {blockKey: block._key, span: child}\n : previousPotentialEndpoint\n }\n\n if (block._key === endBlockKey) {\n break\n }\n }\n\n const trimmedSelection = snapshot.context.selection.backward\n ? {\n anchor: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint,\n focus: adjustedStartPoint ?? startPoint,\n backward: true,\n }\n : {\n anchor: adjustedStartPoint ?? startPoint,\n focus: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint,\n }\n\n if (\n isSelectionCollapsed({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: trimmedSelection,\n },\n })\n ) {\n const focusTextBlock = getFocusTextBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: trimmedSelection,\n },\n })\n\n if (focusTextBlock && !isEmptyTextBlock(focusTextBlock.node)) {\n return null\n }\n }\n\n return trimmedSelection\n}\n","import {isPortableTextTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedSpans} from './selector.get-selected-spans'\nimport {isSelectionExpanded} from './selector.is-selection-expanded'\nimport {getFocusSpan, getSelectedBlocks} from './selectors'\n\n/**\n * @public\n */\nexport function isActiveAnnotation(\n annotation: string,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const selectedBlocks = getSelectedBlocks(snapshot)\n const focusSpan = getFocusSpan(snapshot)\n\n const selectedSpans = isSelectionExpanded(snapshot)\n ? getSelectedSpans(snapshot)\n : focusSpan\n ? [focusSpan]\n : []\n\n if (selectedSpans.length === 0) {\n return false\n }\n\n if (\n selectedSpans.some(\n (span) => !span.node.marks || span.node.marks?.length === 0,\n )\n ) {\n return false\n }\n\n const selectionMarkDefs = selectedBlocks.flatMap((block) =>\n isPortableTextTextBlock(block.node) ? (block.node.markDefs ?? []) : [],\n )\n\n return selectedSpans.every((span) => {\n const spanMarkDefs =\n span.node.marks?.flatMap((mark) => {\n const markDef = selectionMarkDefs.find(\n (markDef) => markDef._key === mark,\n )\n\n return markDef ? [markDef._type] : []\n }) ?? []\n\n return spanMarkDefs.includes(annotation)\n })\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedSpans} from './selector.get-selected-spans'\nimport {isSelectionExpanded} from './selector.is-selection-expanded'\n\n/**\n * @public\n */\nexport function isActiveDecorator(decorator: string): EditorSelector<boolean> {\n return (snapshot) => {\n if (isSelectionExpanded(snapshot)) {\n const selectedSpans = getSelectedSpans(snapshot)\n\n return (\n selectedSpans.length > 0 &&\n selectedSpans.every((span) => span.node.marks?.includes(decorator))\n )\n }\n\n return snapshot.context.activeDecorators.includes(decorator)\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getActiveListItem} from './selector.get-active-list-item'\n\n/**\n * @public\n */\nexport function isActiveListItem(listItem: string): EditorSelector<boolean> {\n return (snapshot) => {\n const activeListItem = getActiveListItem(snapshot)\n\n return activeListItem === listItem\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getActiveStyle} from './selector.get-active-style'\n\n/**\n * @public\n */\nexport function isActiveStyle(style: string): EditorSelector<boolean> {\n return (snapshot) => {\n const activeStyle = getActiveStyle(snapshot)\n\n return activeStyle === style\n }\n}\n"],"names":["isSelectingEntireBlocks","snapshot","context","selection","startPoint","backward","focus","anchor","endPoint","startBlock","getSelectionStartBlock","endBlock","getSelectionEndBlock","startBlockStartPoint","utils","endBlockEndPoint","isEqualSelectionPoints","getSelectedSpans","selectedSpans","startBlockKey","isKeySegment","path","_key","undefined","endBlockKey","startSpanKey","endSpanKey","startBlockFound","block","value","isPortableTextTextBlock","child","children","isPortableTextSpan","offset","text","length","push","node","getActiveAnnotations","selectedBlocks","getSelectedBlocks","focusSpan","getFocusSpan","isSelectionCollapsed","flatMap","markDefs","filter","markDef","some","span","marks","includes","getActiveListItem","guards","createGuards","selectedTextBlocks","map","isTextBlock","firstTextBlock","at","firstListItem","listItem","every","getActiveStyle","firstStyle","style","getTrimmedSelection","getSelectionStartPoint","getSelectionEndPoint","isKeyedSegment","startChildKey","endChildKey","adjustedStartPoint","trimStartPoint","adjustedEndPoint","trimEndPoint","previousPotentialEndpoint","isEmptyTextBlock","blockKey","lonelySpan","trimmedSelection","focusTextBlock","getFocusTextBlock","isActiveAnnotation","annotation","isSelectionExpanded","selectionMarkDefs","mark","find","_type","isActiveDecorator","decorator","activeDecorators","isActiveListItem","isActiveStyle"],"mappings":";;AAOO,MAAMA,0BAAoDC,CAAa,aAAA;AACxE,MAAA,CAACA,SAASC,QAAQC;AACb,WAAA;AAGT,QAAMC,aAAaH,SAASC,QAAQC,UAAUE,WAC1CJ,SAASC,QAAQC,UAAUG,QAC3BL,SAASC,QAAQC,UAAUI,QACzBC,WAAWP,SAASC,QAAQC,UAAUE,WACxCJ,SAASC,QAAQC,UAAUI,SAC3BN,SAASC,QAAQC,UAAUG,OAEzBG,aAAaC,uDAAuBT,QAAQ,GAC5CU,WAAWC,qDAAqBX,QAAQ;AAE1C,MAAA,CAACQ,cAAc,CAACE;AACX,WAAA;AAGHE,QAAAA,uBAAuBC,iBAAAA,mBAAyBL,UAAU,GAC1DM,mBAAmBD,kCAAuBH,QAAQ;AAGtDG,SAAAA,iBAAAA,uBAA6BD,sBAAsBT,UAAU,KAC7DU,iBAAME,uBAAuBD,kBAAkBP,QAAQ;AAE3D,GCrBaS,mBAKRhB,CAAa,aAAA;AACZ,MAAA,CAACA,SAASC,QAAQC;AACpB,WAAO,CAAE;AAGLe,QAAAA,gBAGD,CAAA,GAECd,aAAaH,SAASC,QAAQC,UAAUE,WAC1CJ,SAASC,QAAQC,UAAUG,QAC3BL,SAASC,QAAQC,UAAUI,QACzBC,WAAWP,SAASC,QAAQC,UAAUE,WACxCJ,SAASC,QAAQC,UAAUI,SAC3BN,SAASC,QAAQC,UAAUG,OAEzBa,gBAAgBC,MAAAA,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Ka,OAAOf,WAAW,CAC5D;AAEO,aAAA;AAGT,UAAMmD,oBAAoB/C,eAAeK,QAASjB,CAAAA,UAChDE,MAAAA,wBAAwBF,MAAMU,IAAI,IAAKV,MAAMU,KAAKQ,YAAY,CAAA,IAAM,CAAA,CACtE;AAEA,WAAO5B,cAAc6C,MAAOb,CAAAA,UAExBA,KAAKZ,KAAKa,OAAON,QAAS2C,CAAS,SAAA;AACjC,YAAMxC,UAAUuC,kBAAkBE,KAC/BzC,CAAAA,aAAYA,SAAQ1B,SAASkE,IAChC;AAEA,aAAOxC,UAAU,CAACA,QAAQ0C,KAAK,IAAI,CAAE;AAAA,IACtC,CAAA,KAAK,CAEYtC,GAAAA,SAASiC,UAAU,CACxC;AAAA,EACH;AACF;AChDO,SAASM,kBAAkBC,WAA4C;AAC5E,SAAQ3F,CAAa,aAAA;AACfqF,QAAAA,gCAAAA,oBAAoBrF,QAAQ,GAAG;AAC3BiB,YAAAA,gBAAgBD,iBAAiBhB,QAAQ;AAG7CiB,aAAAA,cAAckB,SAAS,KACvBlB,cAAc6C,MAAOb,CAASA,SAAAA,KAAKZ,KAAKa,OAAOC,SAASwC,SAAS,CAAC;AAAA,IAAA;AAItE,WAAO3F,SAASC,QAAQ2F,iBAAiBzC,SAASwC,SAAS;AAAA,EAC7D;AACF;ACdO,SAASE,iBAAiBhC,UAA2C;AAClE7D,SAAAA,CAAAA,aACiBoD,kBAAkBpD,QAAQ,MAEvB6D;AAE9B;ACNO,SAASiC,cAAc7B,OAAwC;AAC5DjE,SAAAA,CAAAA,aACc+D,eAAe/D,QAAQ,MAEpBiE;AAE3B;;;;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selector.is-active-style.js","sources":["../../src/selectors/selector.is-selecting-entire-blocks.ts","../../src/selectors/selector.get-selected-spans.ts","../../src/selectors/selector.get-active-annotations.ts","../../src/selectors/selector.get-active-list-item.ts","../../src/selectors/selector.get-active-style.ts","../../src/selectors/selector.get-trimmed-selection.ts","../../src/selectors/selector.is-active-annotation.ts","../../src/selectors/selector.is-active-decorator.ts","../../src/selectors/selector.is-active-list-item.ts","../../src/selectors/selector.is-active-style.ts"],"sourcesContent":["import type {EditorSelector} from '../editor/editor-selector'\nimport * as utils from '../utils'\nimport {getSelectionEndBlock, getSelectionStartBlock} from './selectors'\n\n/**\n * @public\n */\nexport const isSelectingEntireBlocks: EditorSelector<boolean> = (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const startPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.focus\n : snapshot.context.selection.anchor\n const endPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.anchor\n : snapshot.context.selection.focus\n\n const startBlock = getSelectionStartBlock(snapshot)\n const endBlock = getSelectionEndBlock(snapshot)\n\n if (!startBlock || !endBlock) {\n return false\n }\n\n const startBlockStartPoint = utils.getBlockStartPoint(startBlock)\n const endBlockEndPoint = utils.getBlockEndPoint(endBlock)\n\n return (\n utils.isEqualSelectionPoints(startBlockStartPoint, startPoint) &&\n utils.isEqualSelectionPoints(endBlockEndPoint, endPoint)\n )\n}\n","import {\n isKeySegment,\n isPortableTextSpan,\n isPortableTextTextBlock,\n type KeyedSegment,\n type PortableTextSpan,\n} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\n\n/**\n * @public\n */\nexport const getSelectedSpans: EditorSelector<\n Array<{\n node: PortableTextSpan\n path: [KeyedSegment, 'children', KeyedSegment]\n }>\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedSpans: Array<{\n node: PortableTextSpan\n path: [KeyedSegment, 'children', KeyedSegment]\n }> = []\n\n const startPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.focus\n : snapshot.context.selection.anchor\n const endPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.anchor\n : snapshot.context.selection.focus\n\n const startBlockKey = isKeySegment(startPoint.path[0])\n ? startPoint.path[0]._key\n : undefined\n const endBlockKey = isKeySegment(endPoint.path[0])\n ? endPoint.path[0]._key\n : undefined\n\n if (!startBlockKey || !endBlockKey) {\n return selectedSpans\n }\n\n const startSpanKey = isKeySegment(startPoint.path[2])\n ? startPoint.path[2]._key\n : undefined\n const endSpanKey = isKeySegment(endPoint.path[2])\n ? endPoint.path[2]._key\n : undefined\n\n let startBlockFound = false\n\n for (const block of snapshot.context.value) {\n if (block._key === startBlockKey) {\n startBlockFound = true\n }\n\n if (!isPortableTextTextBlock(block)) {\n continue\n }\n\n if (block._key === startBlockKey) {\n for (const child of block.children) {\n if (!isPortableTextSpan(child)) {\n continue\n }\n\n if (startSpanKey && child._key === startSpanKey) {\n if (startPoint.offset < child.text.length) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n\n if (startSpanKey === endSpanKey) {\n break\n }\n\n continue\n }\n\n if (endSpanKey && child._key === endSpanKey) {\n if (endPoint.offset > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n break\n }\n\n if (selectedSpans.length > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n }\n\n if (startBlockKey === endBlockKey) {\n break\n }\n\n continue\n }\n\n if (block._key === endBlockKey) {\n for (const child of block.children) {\n if (!isPortableTextSpan(child)) {\n continue\n }\n\n if (endSpanKey && child._key === endSpanKey) {\n if (endPoint.offset > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n break\n }\n\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n\n break\n }\n\n if (startBlockFound) {\n for (const child of block.children) {\n if (!isPortableTextSpan(child)) {\n continue\n }\n\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n }\n }\n\n return selectedSpans\n}\n","import {isPortableTextTextBlock, type PortableTextObject} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedSpans} from './selector.get-selected-spans'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\nimport {getFocusSpan, getSelectedBlocks} from './selectors'\n\n/**\n * @public\n */\nexport const getActiveAnnotations: EditorSelector<Array<PortableTextObject>> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedBlocks = getSelectedBlocks(snapshot)\n const selectedSpans = getSelectedSpans(snapshot)\n const focusSpan = getFocusSpan(snapshot)\n\n if (selectedSpans.length === 0 || !focusSpan) {\n return []\n }\n\n if (selectedSpans.length === 1 && isSelectionCollapsed(snapshot)) {\n if (snapshot.context.selection.focus.offset === 0) {\n return []\n }\n if (\n snapshot.context.selection.focus.offset === focusSpan.node.text.length\n ) {\n return []\n }\n }\n\n const selectionMarkDefs = selectedBlocks.flatMap((block) =>\n isPortableTextTextBlock(block.node) ? (block.node.markDefs ?? []) : [],\n )\n\n return selectionMarkDefs.filter((markDef) =>\n selectedSpans.some((span) => span.node.marks?.includes(markDef._key)),\n )\n}\n","import type {PortableTextListBlock} from '@sanity/types'\nimport {createGuards} from '../behavior-actions/behavior.guards'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedBlocks} from './selectors'\n\n/**\n * @public\n */\nexport const getActiveListItem: EditorSelector<\n PortableTextListBlock['listItem'] | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const guards = createGuards(snapshot.context)\n const selectedBlocks = getSelectedBlocks(snapshot).map((block) => block.node)\n const selectedTextBlocks = selectedBlocks.filter(guards.isTextBlock)\n\n const firstTextBlock = selectedTextBlocks.at(0)\n\n if (!firstTextBlock) {\n return undefined\n }\n\n const firstListItem = firstTextBlock.listItem\n\n if (!firstListItem) {\n return undefined\n }\n\n if (selectedTextBlocks.every((block) => block.listItem === firstListItem)) {\n return firstListItem\n }\n\n return undefined\n}\n","import type {PortableTextTextBlock} from '@sanity/types'\nimport {createGuards} from '../behavior-actions/behavior.guards'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedBlocks} from './selectors'\n\n/**\n * @public\n */\nexport const getActiveStyle: EditorSelector<PortableTextTextBlock['style']> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const guards = createGuards(snapshot.context)\n const selectedBlocks = getSelectedBlocks(snapshot).map((block) => block.node)\n const selectedTextBlocks = selectedBlocks.filter(guards.isTextBlock)\n\n const firstTextBlock = selectedTextBlocks.at(0)\n\n if (!firstTextBlock) {\n return undefined\n }\n\n const firstStyle = firstTextBlock.style\n\n if (!firstStyle) {\n return undefined\n }\n\n if (selectedTextBlocks.every((block) => block.style === firstStyle)) {\n return firstStyle\n }\n\n return undefined\n}\n","import {\n isPortableTextSpan,\n isPortableTextTextBlock,\n type PortableTextSpan,\n} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {EditorSelection, EditorSelectionPoint} from '../types/editor'\nimport {isEmptyTextBlock, isKeyedSegment} from '../utils'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\nimport {getFocusTextBlock} from './selectors'\n\n/**\n * @public\n */\nexport const getTrimmedSelection: EditorSelector<EditorSelection> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return snapshot.context.selection\n }\n\n const startPoint = getSelectionStartPoint(snapshot)\n const endPoint = getSelectionEndPoint(snapshot)\n\n if (!startPoint || !endPoint) {\n return snapshot.context.selection\n }\n\n const startBlockKey = isKeyedSegment(startPoint.path[0])\n ? startPoint.path[0]._key\n : null\n const startChildKey = isKeyedSegment(startPoint.path[2])\n ? startPoint.path[2]._key\n : null\n const endBlockKey = isKeyedSegment(endPoint.path[0])\n ? endPoint.path[0]._key\n : null\n const endChildKey = isKeyedSegment(endPoint.path[2])\n ? endPoint.path[2]._key\n : null\n\n if (!startBlockKey || !endBlockKey) {\n return snapshot.context.selection\n }\n\n let startBlockFound = false\n let adjustedStartPoint: EditorSelectionPoint | undefined\n let trimStartPoint = false\n let adjustedEndPoint: EditorSelectionPoint | undefined\n let trimEndPoint = false\n let previousPotentialEndpoint:\n | {blockKey: string; span: PortableTextSpan}\n | undefined\n\n for (const block of snapshot.context.value) {\n if (block._key === startBlockKey) {\n startBlockFound = true\n\n if (isPortableTextTextBlock(block) && isEmptyTextBlock(block)) {\n continue\n }\n }\n\n if (!startBlockFound) {\n continue\n }\n\n if (!isPortableTextTextBlock(block)) {\n continue\n }\n\n if (block._key === endBlockKey && isEmptyTextBlock(block)) {\n break\n }\n\n for (const child of block.children) {\n if (child._key === endChildKey) {\n if (!isPortableTextSpan(child) || endPoint.offset === 0) {\n adjustedEndPoint = previousPotentialEndpoint\n ? {\n path: [\n {_key: previousPotentialEndpoint.blockKey},\n 'children',\n {_key: previousPotentialEndpoint.span._key},\n ],\n offset: previousPotentialEndpoint.span.text.length,\n }\n : undefined\n\n trimEndPoint = true\n break\n }\n }\n\n if (trimStartPoint) {\n const lonelySpan =\n isPortableTextSpan(child) && block.children.length === 1\n\n if (\n (isPortableTextSpan(child) && child.text.length > 0) ||\n lonelySpan\n ) {\n adjustedStartPoint = {\n path: [{_key: block._key}, 'children', {_key: child._key}],\n offset: 0,\n }\n previousPotentialEndpoint = {blockKey: block._key, span: child}\n trimStartPoint = false\n }\n\n continue\n }\n\n if (child._key === startChildKey) {\n if (!isPortableTextSpan(child)) {\n trimStartPoint = true\n continue\n }\n\n if (startPoint.offset === child.text.length) {\n trimStartPoint = true\n previousPotentialEndpoint =\n child.text.length > 0\n ? {blockKey: block._key, span: child}\n : previousPotentialEndpoint\n continue\n }\n }\n\n previousPotentialEndpoint =\n isPortableTextSpan(child) && child.text.length > 0\n ? {blockKey: block._key, span: child}\n : previousPotentialEndpoint\n }\n\n if (block._key === endBlockKey) {\n break\n }\n }\n\n const trimmedSelection = snapshot.context.selection.backward\n ? {\n anchor: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint,\n focus: adjustedStartPoint ?? startPoint,\n backward: true,\n }\n : {\n anchor: adjustedStartPoint ?? startPoint,\n focus: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint,\n }\n\n if (\n isSelectionCollapsed({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: trimmedSelection,\n },\n })\n ) {\n const focusTextBlock = getFocusTextBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: trimmedSelection,\n },\n })\n\n if (focusTextBlock && !isEmptyTextBlock(focusTextBlock.node)) {\n return null\n }\n }\n\n return trimmedSelection\n}\n","import {isPortableTextTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedSpans} from './selector.get-selected-spans'\nimport {isSelectionExpanded} from './selector.is-selection-expanded'\nimport {getFocusSpan, getSelectedBlocks} from './selectors'\n\n/**\n * @public\n */\nexport function isActiveAnnotation(\n annotation: string,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const selectedBlocks = getSelectedBlocks(snapshot)\n const focusSpan = getFocusSpan(snapshot)\n\n const selectedSpans = isSelectionExpanded(snapshot)\n ? getSelectedSpans(snapshot)\n : focusSpan\n ? [focusSpan]\n : []\n\n if (selectedSpans.length === 0) {\n return false\n }\n\n if (\n selectedSpans.some(\n (span) => !span.node.marks || span.node.marks?.length === 0,\n )\n ) {\n return false\n }\n\n const selectionMarkDefs = selectedBlocks.flatMap((block) =>\n isPortableTextTextBlock(block.node) ? (block.node.markDefs ?? []) : [],\n )\n\n return selectedSpans.every((span) => {\n const spanMarkDefs =\n span.node.marks?.flatMap((mark) => {\n const markDef = selectionMarkDefs.find(\n (markDef) => markDef._key === mark,\n )\n\n return markDef ? [markDef._type] : []\n }) ?? []\n\n return spanMarkDefs.includes(annotation)\n })\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedSpans} from './selector.get-selected-spans'\nimport {isSelectionExpanded} from './selector.is-selection-expanded'\n\n/**\n * @public\n */\nexport function isActiveDecorator(decorator: string): EditorSelector<boolean> {\n return (snapshot) => {\n if (isSelectionExpanded(snapshot)) {\n const selectedSpans = getSelectedSpans(snapshot)\n\n return (\n selectedSpans.length > 0 &&\n selectedSpans.every((span) => span.node.marks?.includes(decorator))\n )\n }\n\n return snapshot.context.activeDecorators.includes(decorator)\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getActiveListItem} from './selector.get-active-list-item'\n\n/**\n * @public\n */\nexport function isActiveListItem(listItem: string): EditorSelector<boolean> {\n return (snapshot) => {\n const activeListItem = getActiveListItem(snapshot)\n\n return activeListItem === listItem\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getActiveStyle} from './selector.get-active-style'\n\n/**\n * @public\n */\nexport function isActiveStyle(style: string): EditorSelector<boolean> {\n return (snapshot) => {\n const activeStyle = getActiveStyle(snapshot)\n\n return activeStyle === style\n }\n}\n"],"names":["isSelectingEntireBlocks","snapshot","context","selection","startPoint","backward","focus","anchor","endPoint","startBlock","getSelectionStartBlock","endBlock","getSelectionEndBlock","startBlockStartPoint","utils","endBlockEndPoint","getSelectedSpans","selectedSpans","startBlockKey","isKeySegment","path","_key","undefined","endBlockKey","startSpanKey","endSpanKey","startBlockFound","block","value","isPortableTextTextBlock","child","children","isPortableTextSpan","offset","text","length","push","node","getActiveAnnotations","selectedBlocks","getSelectedBlocks","focusSpan","getFocusSpan","isSelectionCollapsed","flatMap","markDefs","filter","markDef","some","span","marks","includes","getActiveListItem","guards","createGuards","selectedTextBlocks","map","isTextBlock","firstTextBlock","at","firstListItem","listItem","every","getActiveStyle","firstStyle","style","getTrimmedSelection","getSelectionStartPoint","getSelectionEndPoint","isKeyedSegment","startChildKey","endChildKey","adjustedStartPoint","trimStartPoint","adjustedEndPoint","trimEndPoint","previousPotentialEndpoint","isEmptyTextBlock","blockKey","lonelySpan","trimmedSelection","focusTextBlock","getFocusTextBlock","isActiveAnnotation","annotation","isSelectionExpanded","selectionMarkDefs","mark","find","_type","isActiveDecorator","decorator","activeDecorators","isActiveListItem","isActiveStyle"],"mappings":";;;AAOO,MAAMA,0BAAoDC,CAAa,aAAA;AACxE,MAAA,CAACA,SAASC,QAAQC;AACb,WAAA;AAGT,QAAMC,aAAaH,SAASC,QAAQC,UAAUE,WAC1CJ,SAASC,QAAQC,UAAUG,QAC3BL,SAASC,QAAQC,UAAUI,QACzBC,WAAWP,SAASC,QAAQC,UAAUE,WACxCJ,SAASC,QAAQC,UAAUI,SAC3BN,SAASC,QAAQC,UAAUG,OAEzBG,aAAaC,uBAAuBT,QAAQ,GAC5CU,WAAWC,qBAAqBX,QAAQ;AAE1C,MAAA,CAACQ,cAAc,CAACE;AACX,WAAA;AAGHE,QAAAA,uBAAuBC,mBAAyBL,UAAU,GAC1DM,mBAAmBD,iBAAuBH,QAAQ;AAGtDG,SAAAA,uBAA6BD,sBAAsBT,UAAU,KAC7DU,uBAA6BC,kBAAkBP,QAAQ;AAE3D,GCrBaQ,mBAKRf,CAAa,aAAA;AACZ,MAAA,CAACA,SAASC,QAAQC;AACpB,WAAO,CAAE;AAGLc,QAAAA,gBAGD,CAAA,GAECb,aAAaH,SAASC,QAAQC,UAAUE,WAC1CJ,SAASC,QAAQC,UAAUG,QAC3BL,SAASC,QAAQC,UAAUI,QACzBC,WAAWP,SAASC,QAAQC,UAAUE,WACxCJ,SAASC,QAAQC,UAAUI,SAC3BN,SAASC,QAAQC,UAAUG,OAEzBY,gBAAgBC,aAAaf,WAAWgB,KAAK,CAAC,CAAC,IACjDhB,WAAWgB,KAAK,CAAC,EAAEC,OACnBC,QACEC,cAAcJ,aAAaX,SAASY,KAAK,CAAC,CAAC,IAC7CZ,SAASY,KAAK,CAAC,EAAEC,OACjBC;AAEA,MAAA,CAACJ,iBAAiB,CAACK;AACdN,WAAAA;AAGHO,QAAAA,eAAeL,aAAaf,WAAWgB,KAAK,CAAC,CAAC,IAChDhB,WAAWgB,KAAK,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Q1F,CAAa,aAAA;AACfoF,QAAAA,oBAAoBpF,QAAQ,GAAG;AAC3BgB,YAAAA,gBAAgBD,iBAAiBf,QAAQ;AAG7CgB,aAAAA,cAAckB,SAAS,KACvBlB,cAAc6C,MAAOb,CAASA,SAAAA,KAAKZ,KAAKa,OAAOC,SAASwC,SAAS,CAAC;AAAA,IAAA;AAItE,WAAO1F,SAASC,QAAQ0F,iBAAiBzC,SAASwC,SAAS;AAAA,EAC7D;AACF;ACdO,SAASE,iBAAiBhC,UAA2C;AAClE5D,SAAAA,CAAAA,aACiBmD,kBAAkBnD,QAAQ,MAEvB4D;AAE9B;ACNO,SAASiC,cAAc7B,OAAwC;AAC5DhE,SAAAA,CAAAA,aACc8D,eAAe9D,QAAQ,MAEpBgE;AAE3B;"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type {BehaviorActionImplementation} from './behavior.actions'
|
|
2
|
-
|
|
3
|
-
export const deserializationFailureActionImplementation: BehaviorActionImplementation<
|
|
4
|
-
'deserialization.failure'
|
|
5
|
-
> = ({action}) => {
|
|
6
|
-
console.warn(
|
|
7
|
-
`Deserialization of ${action.mimeType} failed with reason "${action.reason}"`,
|
|
8
|
-
)
|
|
9
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {insertBlocksActionImplementation} from './behavior.action.insert-blocks'
|
|
2
|
-
import type {BehaviorActionImplementation} from './behavior.actions'
|
|
3
|
-
|
|
4
|
-
export const deserializationSuccessActionImplementation: BehaviorActionImplementation<
|
|
5
|
-
'deserialization.success'
|
|
6
|
-
> = ({context, action}) => {
|
|
7
|
-
insertBlocksActionImplementation({
|
|
8
|
-
context,
|
|
9
|
-
action: {
|
|
10
|
-
type: 'insert.blocks',
|
|
11
|
-
blocks: action.data,
|
|
12
|
-
editor: action.editor,
|
|
13
|
-
placement: 'auto',
|
|
14
|
-
},
|
|
15
|
-
})
|
|
16
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import {parseBlocks} from '../internal-utils/parse-blocks'
|
|
2
|
-
import {getFocusBlock} from '../internal-utils/slate-utils'
|
|
3
|
-
import {toSlateValue} from '../internal-utils/values'
|
|
4
|
-
import {insertBreakActionImplementation} from './behavior.action.insert-break'
|
|
5
|
-
import {insertBlock} from './behavior.action.insert.block'
|
|
6
|
-
import {selectNextBlockActionImplementation} from './behavior.action.select.next-block'
|
|
7
|
-
import {selectPreviousBlockActionImplementation} from './behavior.action.select.previous-block'
|
|
8
|
-
import type {BehaviorActionImplementation} from './behavior.actions'
|
|
9
|
-
|
|
10
|
-
export const insertBlocksActionImplementation: BehaviorActionImplementation<
|
|
11
|
-
'insert.blocks'
|
|
12
|
-
> = ({context, action}) => {
|
|
13
|
-
const parsedBlocks = parseBlocks({
|
|
14
|
-
context,
|
|
15
|
-
blocks: action.blocks,
|
|
16
|
-
options: {refreshKeys: false},
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
if (parsedBlocks.length === 0) {
|
|
20
|
-
throw new Error(`Failed to parse blocks ${JSON.stringify(action.blocks)}`)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const fragment = toSlateValue(parsedBlocks, {schemaTypes: context.schema})
|
|
24
|
-
|
|
25
|
-
if (fragment.length === 0) {
|
|
26
|
-
throw new Error(
|
|
27
|
-
`Failed to convert blocks to Slate fragment ${JSON.stringify(
|
|
28
|
-
parsedBlocks,
|
|
29
|
-
)}`,
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const [focusBlock] = getFocusBlock({editor: action.editor})
|
|
34
|
-
|
|
35
|
-
if (action.placement === 'before') {
|
|
36
|
-
let index = 0
|
|
37
|
-
|
|
38
|
-
for (const block of fragment) {
|
|
39
|
-
insertBlock({
|
|
40
|
-
block,
|
|
41
|
-
placement: index === 0 ? 'before' : 'after',
|
|
42
|
-
select: 'end',
|
|
43
|
-
editor: action.editor,
|
|
44
|
-
schema: context.schema,
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
index++
|
|
48
|
-
}
|
|
49
|
-
} else if (action.placement === 'after') {
|
|
50
|
-
for (const block of fragment) {
|
|
51
|
-
insertBlock({
|
|
52
|
-
block,
|
|
53
|
-
placement: 'after',
|
|
54
|
-
select: 'end',
|
|
55
|
-
editor: action.editor,
|
|
56
|
-
schema: context.schema,
|
|
57
|
-
})
|
|
58
|
-
}
|
|
59
|
-
} else {
|
|
60
|
-
if (focusBlock && action.editor.isTextBlock(focusBlock)) {
|
|
61
|
-
if (fragment.length === 1) {
|
|
62
|
-
insertBlock({
|
|
63
|
-
block: fragment[0],
|
|
64
|
-
placement: 'auto',
|
|
65
|
-
select: 'end',
|
|
66
|
-
editor: action.editor,
|
|
67
|
-
schema: context.schema,
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
let index = 0
|
|
74
|
-
|
|
75
|
-
for (const block of fragment) {
|
|
76
|
-
if (index === 0) {
|
|
77
|
-
insertBreakActionImplementation({
|
|
78
|
-
context,
|
|
79
|
-
action: {type: 'insert.break', editor: action.editor},
|
|
80
|
-
})
|
|
81
|
-
selectPreviousBlockActionImplementation({
|
|
82
|
-
context,
|
|
83
|
-
action: {
|
|
84
|
-
type: 'select.previous block',
|
|
85
|
-
editor: action.editor,
|
|
86
|
-
select: 'end',
|
|
87
|
-
},
|
|
88
|
-
})
|
|
89
|
-
insertBlock({
|
|
90
|
-
block,
|
|
91
|
-
placement: 'auto',
|
|
92
|
-
select: 'end',
|
|
93
|
-
editor: action.editor,
|
|
94
|
-
schema: context.schema,
|
|
95
|
-
})
|
|
96
|
-
} else if (index === fragment.length - 1) {
|
|
97
|
-
selectNextBlockActionImplementation({
|
|
98
|
-
context,
|
|
99
|
-
action: {
|
|
100
|
-
type: 'select.next block',
|
|
101
|
-
editor: action.editor,
|
|
102
|
-
select: 'start',
|
|
103
|
-
},
|
|
104
|
-
})
|
|
105
|
-
insertBlock({
|
|
106
|
-
block,
|
|
107
|
-
placement: 'auto',
|
|
108
|
-
select: 'end',
|
|
109
|
-
editor: action.editor,
|
|
110
|
-
schema: context.schema,
|
|
111
|
-
})
|
|
112
|
-
} else {
|
|
113
|
-
insertBlock({
|
|
114
|
-
block,
|
|
115
|
-
placement: 'after',
|
|
116
|
-
select: 'end',
|
|
117
|
-
editor: action.editor,
|
|
118
|
-
schema: context.schema,
|
|
119
|
-
})
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
index++
|
|
123
|
-
}
|
|
124
|
-
} else {
|
|
125
|
-
let index = 0
|
|
126
|
-
|
|
127
|
-
for (const block of fragment) {
|
|
128
|
-
insertBlock({
|
|
129
|
-
block,
|
|
130
|
-
placement: index === 0 ? 'auto' : 'after',
|
|
131
|
-
select: 'end',
|
|
132
|
-
editor: action.editor,
|
|
133
|
-
schema: context.schema,
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
index++
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|