@portabletext/editor 3.3.2 → 3.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_chunks-dts/index.d.ts +7 -1
- package/package.json +16 -19
- package/src/behaviors/_exports/index.ts +0 -1
- package/src/behaviors/behavior.abstract.annotation.ts +0 -77
- package/src/behaviors/behavior.abstract.decorator.ts +0 -39
- package/src/behaviors/behavior.abstract.delete.ts +0 -273
- package/src/behaviors/behavior.abstract.deserialize.ts +0 -232
- package/src/behaviors/behavior.abstract.insert.ts +0 -525
- package/src/behaviors/behavior.abstract.keyboard.ts +0 -189
- package/src/behaviors/behavior.abstract.list-item.ts +0 -70
- package/src/behaviors/behavior.abstract.move.ts +0 -79
- package/src/behaviors/behavior.abstract.select.ts +0 -118
- package/src/behaviors/behavior.abstract.serialize.ts +0 -96
- package/src/behaviors/behavior.abstract.split.ts +0 -170
- package/src/behaviors/behavior.abstract.style.ts +0 -55
- package/src/behaviors/behavior.abstract.ts +0 -139
- package/src/behaviors/behavior.config.ts +0 -7
- package/src/behaviors/behavior.core.annotations.ts +0 -62
- package/src/behaviors/behavior.core.block-element.ts +0 -116
- package/src/behaviors/behavior.core.block-objects.ts +0 -285
- package/src/behaviors/behavior.core.decorators.ts +0 -44
- package/src/behaviors/behavior.core.dnd.ts +0 -356
- package/src/behaviors/behavior.core.insert-break.ts +0 -266
- package/src/behaviors/behavior.core.insert.ts +0 -52
- package/src/behaviors/behavior.core.lists.ts +0 -691
- package/src/behaviors/behavior.core.ts +0 -44
- package/src/behaviors/behavior.perform-event.ts +0 -354
- package/src/behaviors/behavior.types.action.ts +0 -102
- package/src/behaviors/behavior.types.behavior.ts +0 -83
- package/src/behaviors/behavior.types.event.ts +0 -667
- package/src/behaviors/behavior.types.guard.ts +0 -11
- package/src/behaviors/index.ts +0 -17
- package/src/converters/converter.json.ts +0 -53
- package/src/converters/converter.portable-text.deserialize.test.ts +0 -680
- package/src/converters/converter.portable-text.ts +0 -75
- package/src/converters/converter.text-html.deserialize.test.ts +0 -406
- package/src/converters/converter.text-html.serialize.test.ts +0 -246
- package/src/converters/converter.text-html.ts +0 -87
- package/src/converters/converter.text-markdown.ts +0 -67
- package/src/converters/converter.text-plain.test.ts +0 -245
- package/src/converters/converter.text-plain.ts +0 -126
- package/src/converters/converter.types.ts +0 -72
- package/src/converters/converters.core.ts +0 -18
- package/src/editor/Editable.tsx +0 -1012
- package/src/editor/PortableTextEditor.tsx +0 -791
- package/src/editor/components/drop-indicator.tsx +0 -17
- package/src/editor/components/render-block-object.tsx +0 -121
- package/src/editor/components/render-default-object.tsx +0 -21
- package/src/editor/components/render-element.tsx +0 -88
- package/src/editor/components/render-inline-object.tsx +0 -129
- package/src/editor/components/render-leaf.tsx +0 -64
- package/src/editor/components/render-span.tsx +0 -303
- package/src/editor/components/render-text-block.tsx +0 -265
- package/src/editor/components/render-text.tsx +0 -18
- package/src/editor/components/use-core-block-element-behaviors.ts +0 -39
- package/src/editor/create-editor.ts +0 -323
- package/src/editor/create-slate-editor.tsx +0 -64
- package/src/editor/editor-actor-context.ts +0 -4
- package/src/editor/editor-context.tsx +0 -7
- package/src/editor/editor-dom.ts +0 -220
- package/src/editor/editor-machine.ts +0 -751
- package/src/editor/editor-provider.tsx +0 -111
- package/src/editor/editor-schema.ts +0 -6
- package/src/editor/editor-selector.ts +0 -89
- package/src/editor/editor-snapshot.ts +0 -68
- package/src/editor/event-to-change.tsx +0 -49
- package/src/editor/hooks/usePortableTextEditor.ts +0 -25
- package/src/editor/hooks/usePortableTextEditorSelection.tsx +0 -28
- package/src/editor/mutation-machine.ts +0 -322
- package/src/editor/plugins/create-with-event-listeners.ts +0 -271
- package/src/editor/plugins/createWithEditableAPI.ts +0 -529
- package/src/editor/plugins/createWithHotKeys.ts +0 -68
- package/src/editor/plugins/createWithObjectKeys.ts +0 -289
- package/src/editor/plugins/createWithPatches.ts +0 -272
- package/src/editor/plugins/createWithPortableTextMarkModel.ts +0 -559
- package/src/editor/plugins/createWithSchemaTypes.ts +0 -121
- package/src/editor/plugins/slate-plugin.update-selection.ts +0 -51
- package/src/editor/plugins/slate-plugin.update-value.ts +0 -46
- package/src/editor/plugins/with-plugins.ts +0 -69
- package/src/editor/range-decorations-machine.ts +0 -421
- package/src/editor/relay-actor-context.ts +0 -4
- package/src/editor/relay-machine.ts +0 -152
- package/src/editor/sync-machine.ts +0 -961
- package/src/editor/use-editor.ts +0 -27
- package/src/editor/validate-selection-machine.test.ts +0 -47
- package/src/editor/validate-selection-machine.ts +0 -149
- package/src/editor/weakMaps.ts +0 -15
- package/src/editor/with-normalizing-node.ts +0 -14
- package/src/editor/with-performing-behavior-operation.ts +0 -21
- package/src/editor/withChanges.ts +0 -13
- package/src/editor/without-normalizing-conditional.ts +0 -13
- package/src/editor/withoutPatching.ts +0 -14
- package/src/editor.ts +0 -59
- package/src/history/behavior.operation.history.redo.ts +0 -67
- package/src/history/behavior.operation.history.undo.ts +0 -71
- package/src/history/event.history.undo.test.tsx +0 -672
- package/src/history/history.preserving-keys.test.tsx +0 -112
- package/src/history/remote-patches.ts +0 -20
- package/src/history/slate-plugin.history.ts +0 -142
- package/src/history/slate-plugin.redoing.ts +0 -21
- package/src/history/slate-plugin.undoing.ts +0 -21
- package/src/history/slate-plugin.without-history.ts +0 -23
- package/src/history/transform-operation.ts +0 -245
- package/src/history/undo-redo-collaboration.test.tsx +0 -541
- package/src/history/undo-redo.feature +0 -125
- package/src/history/undo-redo.test.tsx +0 -195
- package/src/history/undo-step.ts +0 -148
- package/src/index.ts +0 -98
- package/src/internal-utils/__tests__/ranges.test.ts +0 -23
- package/src/internal-utils/__tests__/values.test.ts +0 -110
- package/src/internal-utils/apply-operation-to-portable-text.test.ts +0 -1861
- package/src/internal-utils/apply-operation-to-portable-text.ts +0 -615
- package/src/internal-utils/applyPatch.ts +0 -644
- package/src/internal-utils/block-keys.ts +0 -9
- package/src/internal-utils/build-index-maps.test.ts +0 -464
- package/src/internal-utils/build-index-maps.ts +0 -131
- package/src/internal-utils/collapse-selection.ts +0 -36
- package/src/internal-utils/compound-client-rect.ts +0 -28
- package/src/internal-utils/create-placeholder-block.ts +0 -21
- package/src/internal-utils/create-test-snapshot.ts +0 -28
- package/src/internal-utils/debug.ts +0 -12
- package/src/internal-utils/editor-selection.test.ts +0 -44
- package/src/internal-utils/editor-selection.ts +0 -56
- package/src/internal-utils/event-position.ts +0 -318
- package/src/internal-utils/global-scope.ts +0 -27
- package/src/internal-utils/globally-scoped-context.ts +0 -39
- package/src/internal-utils/is-hotkey.test.ts +0 -114
- package/src/internal-utils/is-hotkey.ts +0 -209
- package/src/internal-utils/mime-type.ts +0 -1
- package/src/internal-utils/move-range-by-operation.ts +0 -19
- package/src/internal-utils/operation-to-patches.test.ts +0 -522
- package/src/internal-utils/operation-to-patches.ts +0 -571
- package/src/internal-utils/portable-text-node.ts +0 -209
- package/src/internal-utils/schema.ts +0 -8
- package/src/internal-utils/selection-block-keys.ts +0 -20
- package/src/internal-utils/selection-focus-text.ts +0 -40
- package/src/internal-utils/selection-text.test.ts +0 -32
- package/src/internal-utils/selection-text.ts +0 -21
- package/src/internal-utils/selection.ts +0 -77
- package/src/internal-utils/sibling-utils.ts +0 -55
- package/src/internal-utils/slate-utils.test.tsx +0 -121
- package/src/internal-utils/slate-utils.ts +0 -417
- package/src/internal-utils/split-string.ts +0 -12
- package/src/internal-utils/stop-actor.ts +0 -43
- package/src/internal-utils/string-overlap.test.ts +0 -14
- package/src/internal-utils/string-overlap.ts +0 -28
- package/src/internal-utils/string-utils.ts +0 -7
- package/src/internal-utils/text-block-key.test.ts +0 -41
- package/src/internal-utils/text-block-key.ts +0 -26
- package/src/internal-utils/text-marks.test.ts +0 -41
- package/src/internal-utils/text-marks.ts +0 -22
- package/src/internal-utils/text-selection.test.ts +0 -211
- package/src/internal-utils/text-selection.ts +0 -121
- package/src/internal-utils/to-slate-range.test.ts +0 -278
- package/src/internal-utils/to-slate-range.ts +0 -171
- package/src/internal-utils/validateValue.ts +0 -443
- package/src/internal-utils/value-annotations.ts +0 -33
- package/src/internal-utils/values.test.ts +0 -282
- package/src/internal-utils/values.ts +0 -266
- package/src/keyboard-shortcuts/default-keyboard-shortcuts.ts +0 -146
- package/src/operations/behavior.operation.annotation.add.ts +0 -99
- package/src/operations/behavior.operation.annotation.remove.ts +0 -150
- package/src/operations/behavior.operation.block.set.ts +0 -104
- package/src/operations/behavior.operation.block.unset.ts +0 -54
- package/src/operations/behavior.operation.child.set.ts +0 -107
- package/src/operations/behavior.operation.child.unset.ts +0 -116
- package/src/operations/behavior.operation.decorator.add.ts +0 -131
- package/src/operations/behavior.operation.delete.ts +0 -294
- package/src/operations/behavior.operation.insert.block.ts +0 -495
- package/src/operations/behavior.operation.insert.child.ts +0 -129
- package/src/operations/behavior.operation.insert.text.ts +0 -8
- package/src/operations/behavior.operation.move.backward.ts +0 -12
- package/src/operations/behavior.operation.move.block.ts +0 -44
- package/src/operations/behavior.operation.move.forward.ts +0 -11
- package/src/operations/behavior.operation.select.ts +0 -27
- package/src/operations/behavior.operations.ts +0 -221
- package/src/plugins/_exports/index.ts +0 -1
- package/src/plugins/index.ts +0 -3
- package/src/plugins/plugin.behavior.tsx +0 -24
- package/src/plugins/plugin.editor-ref.tsx +0 -17
- package/src/plugins/plugin.event-listener.tsx +0 -68
- package/src/plugins/plugin.internal.auto-close-brackets.test.tsx +0 -71
- package/src/plugins/plugin.internal.auto-close-brackets.ts +0 -62
- package/src/plugins/plugin.internal.change-ref.tsx +0 -19
- package/src/plugins/plugin.internal.portable-text-editor-ref.tsx +0 -16
- package/src/plugins/plugin.internal.slate-editor-ref.tsx +0 -15
- package/src/priority/priority.core.ts +0 -3
- package/src/priority/priority.sort.test.ts +0 -319
- package/src/priority/priority.sort.ts +0 -123
- package/src/priority/priority.types.ts +0 -24
- package/src/selectors/_exports/index.ts +0 -1
- package/src/selectors/drag-selection.test.ts +0 -578
- package/src/selectors/drag-selection.ts +0 -118
- package/src/selectors/index.ts +0 -54
- package/src/selectors/selector.get-active-annotation-marks.ts +0 -12
- package/src/selectors/selector.get-active-annotations.ts +0 -36
- package/src/selectors/selector.get-active-decorators.ts +0 -29
- package/src/selectors/selector.get-active-list-item.ts +0 -38
- package/src/selectors/selector.get-active-style.ts +0 -38
- package/src/selectors/selector.get-anchor-block.ts +0 -22
- package/src/selectors/selector.get-anchor-child.ts +0 -36
- package/src/selectors/selector.get-anchor-span.ts +0 -17
- package/src/selectors/selector.get-anchor-text-block.ts +0 -18
- package/src/selectors/selector.get-block-offsets.ts +0 -34
- package/src/selectors/selector.get-caret-word-selection.test.ts +0 -284
- package/src/selectors/selector.get-caret-word-selection.ts +0 -134
- package/src/selectors/selector.get-first-block.ts +0 -14
- package/src/selectors/selector.get-focus-block-object.ts +0 -18
- package/src/selectors/selector.get-focus-block.ts +0 -23
- package/src/selectors/selector.get-focus-child.ts +0 -36
- package/src/selectors/selector.get-focus-inline-object.ts +0 -17
- package/src/selectors/selector.get-focus-list-block.ts +0 -18
- package/src/selectors/selector.get-focus-span.ts +0 -18
- package/src/selectors/selector.get-focus-text-block.ts +0 -18
- package/src/selectors/selector.get-last-block.ts +0 -16
- package/src/selectors/selector.get-mark-state.test.ts +0 -325
- package/src/selectors/selector.get-mark-state.ts +0 -263
- package/src/selectors/selector.get-next-block.ts +0 -29
- package/src/selectors/selector.get-next-inline-object.ts +0 -53
- package/src/selectors/selector.get-next-inline-objects.ts +0 -50
- package/src/selectors/selector.get-next-span.ts +0 -56
- package/src/selectors/selector.get-previous-block.ts +0 -29
- package/src/selectors/selector.get-previous-inline-object.ts +0 -50
- package/src/selectors/selector.get-previous-inline-objects.ts +0 -47
- package/src/selectors/selector.get-previous-span.ts +0 -53
- package/src/selectors/selector.get-selected-blocks.ts +0 -61
- package/src/selectors/selector.get-selected-spans.test.ts +0 -347
- package/src/selectors/selector.get-selected-spans.ts +0 -155
- package/src/selectors/selector.get-selected-text-blocks.ts +0 -73
- package/src/selectors/selector.get-selected-value.test.ts +0 -834
- package/src/selectors/selector.get-selected-value.ts +0 -66
- package/src/selectors/selector.get-selection-end-block.ts +0 -33
- package/src/selectors/selector.get-selection-end-child.ts +0 -33
- package/src/selectors/selector.get-selection-end-point.ts +0 -17
- package/src/selectors/selector.get-selection-start-block.ts +0 -33
- package/src/selectors/selector.get-selection-start-child.ts +0 -33
- package/src/selectors/selector.get-selection-start-point.ts +0 -17
- package/src/selectors/selector.get-selection-text.test.ts +0 -421
- package/src/selectors/selector.get-selection-text.ts +0 -27
- package/src/selectors/selector.get-selection.ts +0 -9
- package/src/selectors/selector.get-text-after.ts +0 -46
- package/src/selectors/selector.get-text-before.ts +0 -46
- package/src/selectors/selector.get-value.ts +0 -11
- package/src/selectors/selector.is-active-annotation.test.ts +0 -320
- package/src/selectors/selector.is-active-annotation.ts +0 -52
- package/src/selectors/selector.is-active-decorator.test.ts +0 -136
- package/src/selectors/selector.is-active-decorator.ts +0 -24
- package/src/selectors/selector.is-active-list-item.ts +0 -13
- package/src/selectors/selector.is-active-style.ts +0 -13
- package/src/selectors/selector.is-at-the-end-of-block.ts +0 -30
- package/src/selectors/selector.is-at-the-start-of-block.ts +0 -30
- package/src/selectors/selector.is-overlapping-selection.test.ts +0 -304
- package/src/selectors/selector.is-overlapping-selection.ts +0 -181
- package/src/selectors/selector.is-point-after-selection.ts +0 -97
- package/src/selectors/selector.is-point-before-selection.ts +0 -97
- package/src/selectors/selector.is-selecting-entire-blocks.ts +0 -43
- package/src/selectors/selector.is-selection-collapsed.ts +0 -17
- package/src/selectors/selector.is-selection-expanded.test.ts +0 -63
- package/src/selectors/selector.is-selection-expanded.ts +0 -9
- package/src/test/_exports/index.ts +0 -1
- package/src/test/gherkin-parameter-types.ts +0 -112
- package/src/test/index.ts +0 -1
- package/src/test/vitest/_exports/index.ts +0 -1
- package/src/test/vitest/index.ts +0 -3
- package/src/test/vitest/step-context.ts +0 -13
- package/src/test/vitest/step-definitions.tsx +0 -960
- package/src/test/vitest/test-editor.tsx +0 -198
- package/src/type-utils.ts +0 -29
- package/src/types/block-offset.ts +0 -9
- package/src/types/block-with-optional-key.ts +0 -25
- package/src/types/editor.ts +0 -509
- package/src/types/options.ts +0 -13
- package/src/types/paths.ts +0 -35
- package/src/types/slate-editor.ts +0 -50
- package/src/types/slate.ts +0 -27
- package/src/utils/_exports/index.ts +0 -1
- package/src/utils/asserters.ts +0 -9
- package/src/utils/index.ts +0 -24
- package/src/utils/key-generator.ts +0 -33
- package/src/utils/parse-blocks.test.ts +0 -836
- package/src/utils/parse-blocks.ts +0 -504
- package/src/utils/util.at-the-beginning-of-block.ts +0 -32
- package/src/utils/util.block-offset-to-block-selection-point.ts +0 -28
- package/src/utils/util.block-offset-to-selection-point.ts +0 -33
- package/src/utils/util.block-offset.test.ts +0 -375
- package/src/utils/util.block-offset.ts +0 -136
- package/src/utils/util.block-offsets-to-selection.ts +0 -38
- package/src/utils/util.child-selection-point-to-block-offset.ts +0 -51
- package/src/utils/util.get-block-end-point.ts +0 -35
- package/src/utils/util.get-block-start-point.ts +0 -31
- package/src/utils/util.get-selection-end-point.ts +0 -20
- package/src/utils/util.get-selection-start-point.ts +0 -20
- package/src/utils/util.get-text-block-text.ts +0 -8
- package/src/utils/util.is-empty-text-block.ts +0 -21
- package/src/utils/util.is-equal-selection-points.ts +0 -13
- package/src/utils/util.is-equal-selections.ts +0 -20
- package/src/utils/util.is-keyed-segment.ts +0 -8
- package/src/utils/util.is-selection-collapsed.ts +0 -16
- package/src/utils/util.is-selection-expanded.ts +0 -13
- package/src/utils/util.merge-text-blocks.ts +0 -40
- package/src/utils/util.reverse-selection.ts +0 -26
- package/src/utils/util.selection-point-to-block-offset.ts +0 -30
- package/src/utils/util.selection-point.ts +0 -22
- package/src/utils/util.slice-blocks.ts +0 -221
- package/src/utils/util.slice-text-block.test.ts +0 -190
- package/src/utils/util.slice-text-block.ts +0 -89
- package/src/utils/util.split-text-block.ts +0 -54
package/src/selectors/index.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
export {getActiveAnnotations} from './selector.get-active-annotations'
|
|
2
|
-
export {getActiveListItem} from './selector.get-active-list-item'
|
|
3
|
-
export {getActiveStyle} from './selector.get-active-style'
|
|
4
|
-
export {getAnchorBlock} from './selector.get-anchor-block'
|
|
5
|
-
export {getAnchorChild} from './selector.get-anchor-child'
|
|
6
|
-
export {getAnchorSpan} from './selector.get-anchor-span'
|
|
7
|
-
export {getAnchorTextBlock} from './selector.get-anchor-text-block'
|
|
8
|
-
export {getBlockOffsets} from './selector.get-block-offsets'
|
|
9
|
-
export {getCaretWordSelection} from './selector.get-caret-word-selection'
|
|
10
|
-
export {getFirstBlock} from './selector.get-first-block'
|
|
11
|
-
export {getFocusBlock} from './selector.get-focus-block'
|
|
12
|
-
export {getFocusBlockObject} from './selector.get-focus-block-object'
|
|
13
|
-
export {getFocusChild} from './selector.get-focus-child'
|
|
14
|
-
export {getFocusInlineObject} from './selector.get-focus-inline-object'
|
|
15
|
-
export {getFocusListBlock} from './selector.get-focus-list-block'
|
|
16
|
-
export {getFocusSpan} from './selector.get-focus-span'
|
|
17
|
-
export {getFocusTextBlock} from './selector.get-focus-text-block'
|
|
18
|
-
export {getLastBlock} from './selector.get-last-block'
|
|
19
|
-
export {getMarkState, type MarkState} from './selector.get-mark-state'
|
|
20
|
-
export {getNextBlock} from './selector.get-next-block'
|
|
21
|
-
export {getNextInlineObject} from './selector.get-next-inline-object'
|
|
22
|
-
export {getNextInlineObjects} from './selector.get-next-inline-objects'
|
|
23
|
-
export {getNextSpan} from './selector.get-next-span'
|
|
24
|
-
export {getPreviousBlock} from './selector.get-previous-block'
|
|
25
|
-
export {getPreviousInlineObject} from './selector.get-previous-inline-object'
|
|
26
|
-
export {getPreviousInlineObjects} from './selector.get-previous-inline-objects'
|
|
27
|
-
export {getPreviousSpan} from './selector.get-previous-span'
|
|
28
|
-
export {getSelectedBlocks} from './selector.get-selected-blocks'
|
|
29
|
-
export {getSelectedSpans} from './selector.get-selected-spans'
|
|
30
|
-
export {getSelectedTextBlocks} from './selector.get-selected-text-blocks'
|
|
31
|
-
export {getSelectedValue} from './selector.get-selected-value'
|
|
32
|
-
export {getSelection} from './selector.get-selection'
|
|
33
|
-
export {getSelectionEndBlock} from './selector.get-selection-end-block'
|
|
34
|
-
export {getSelectionEndChild} from './selector.get-selection-end-child'
|
|
35
|
-
export {getSelectionEndPoint} from './selector.get-selection-end-point'
|
|
36
|
-
export {getSelectionStartBlock} from './selector.get-selection-start-block'
|
|
37
|
-
export {getSelectionStartChild} from './selector.get-selection-start-child'
|
|
38
|
-
export {getSelectionStartPoint} from './selector.get-selection-start-point'
|
|
39
|
-
export {getSelectionText} from './selector.get-selection-text'
|
|
40
|
-
export {getBlockTextAfter} from './selector.get-text-after'
|
|
41
|
-
export {getBlockTextBefore} from './selector.get-text-before'
|
|
42
|
-
export {getValue} from './selector.get-value'
|
|
43
|
-
export {isActiveAnnotation} from './selector.is-active-annotation'
|
|
44
|
-
export {isActiveDecorator} from './selector.is-active-decorator'
|
|
45
|
-
export {isActiveListItem} from './selector.is-active-list-item'
|
|
46
|
-
export {isActiveStyle} from './selector.is-active-style'
|
|
47
|
-
export {isAtTheEndOfBlock} from './selector.is-at-the-end-of-block'
|
|
48
|
-
export {isAtTheStartOfBlock} from './selector.is-at-the-start-of-block'
|
|
49
|
-
export {isOverlappingSelection} from './selector.is-overlapping-selection'
|
|
50
|
-
export {isPointAfterSelection} from './selector.is-point-after-selection'
|
|
51
|
-
export {isPointBeforeSelection} from './selector.is-point-before-selection'
|
|
52
|
-
export {isSelectingEntireBlocks} from './selector.is-selecting-entire-blocks'
|
|
53
|
-
export {isSelectionCollapsed} from './selector.is-selection-collapsed'
|
|
54
|
-
export {isSelectionExpanded} from './selector.is-selection-expanded'
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type {EditorSnapshot} from '../editor/editor-snapshot'
|
|
2
|
-
import {getMarkState} from './selector.get-mark-state'
|
|
3
|
-
|
|
4
|
-
export function getActiveAnnotationsMarks(snapshot: EditorSnapshot) {
|
|
5
|
-
const schema = snapshot.context.schema
|
|
6
|
-
const markState = getMarkState(snapshot)
|
|
7
|
-
|
|
8
|
-
return (markState?.marks ?? []).filter(
|
|
9
|
-
(mark) =>
|
|
10
|
-
!schema.decorators.map((decorator) => decorator.name).includes(mark),
|
|
11
|
-
)
|
|
12
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import {isTextBlock} from '@portabletext/schema'
|
|
2
|
-
import type {PortableTextObject} from '@sanity/types'
|
|
3
|
-
import type {EditorSelector} from '../editor/editor-selector'
|
|
4
|
-
import {getMarkState} from './selector.get-mark-state'
|
|
5
|
-
import {getSelectedBlocks} from './selector.get-selected-blocks'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export const getActiveAnnotations: EditorSelector<Array<PortableTextObject>> = (
|
|
11
|
-
snapshot,
|
|
12
|
-
) => {
|
|
13
|
-
if (!snapshot.context.selection) {
|
|
14
|
-
return []
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const selectedBlocks = getSelectedBlocks(snapshot)
|
|
18
|
-
const markState = getMarkState(snapshot)
|
|
19
|
-
|
|
20
|
-
const activeAnnotations = (markState?.marks ?? []).filter(
|
|
21
|
-
(mark) =>
|
|
22
|
-
!snapshot.context.schema.decorators
|
|
23
|
-
.map((decorator) => decorator.name)
|
|
24
|
-
.includes(mark),
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
const selectionMarkDefs = selectedBlocks.flatMap((block) =>
|
|
28
|
-
isTextBlock(snapshot.context, block.node)
|
|
29
|
-
? (block.node.markDefs ?? [])
|
|
30
|
-
: [],
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
return selectionMarkDefs.filter((markDef) =>
|
|
34
|
-
activeAnnotations.includes(markDef._key),
|
|
35
|
-
)
|
|
36
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type {EditorSnapshot} from '../editor/editor-snapshot'
|
|
2
|
-
import {getMarkState} from './selector.get-mark-state'
|
|
3
|
-
|
|
4
|
-
export function getActiveDecorators(snapshot: EditorSnapshot) {
|
|
5
|
-
const schema = snapshot.context.schema
|
|
6
|
-
const decoratorState = snapshot.decoratorState
|
|
7
|
-
const markState = getMarkState(snapshot)
|
|
8
|
-
const decorators = schema.decorators.map((decorator) => decorator.name)
|
|
9
|
-
|
|
10
|
-
const markStateDecorators = (markState?.marks ?? []).filter((mark) =>
|
|
11
|
-
decorators.includes(mark),
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
let activeDecorators: Array<string> = markStateDecorators
|
|
15
|
-
|
|
16
|
-
for (const decorator in decoratorState) {
|
|
17
|
-
if (decoratorState[decorator] === false) {
|
|
18
|
-
activeDecorators = activeDecorators.filter(
|
|
19
|
-
(activeDecorator) => activeDecorator !== decorator,
|
|
20
|
-
)
|
|
21
|
-
} else if (decoratorState[decorator] === true) {
|
|
22
|
-
if (!activeDecorators.includes(decorator)) {
|
|
23
|
-
activeDecorators.push(decorator)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return activeDecorators
|
|
29
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import {isTextBlock} from '@portabletext/schema'
|
|
2
|
-
import type {PortableTextListBlock} from '@sanity/types'
|
|
3
|
-
import type {EditorSelector} from '../editor/editor-selector'
|
|
4
|
-
import {getSelectedBlocks} from './selector.get-selected-blocks'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export const getActiveListItem: EditorSelector<
|
|
10
|
-
PortableTextListBlock['listItem'] | undefined
|
|
11
|
-
> = (snapshot) => {
|
|
12
|
-
if (!snapshot.context.selection) {
|
|
13
|
-
return undefined
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const selectedBlocks = getSelectedBlocks(snapshot).map((block) => block.node)
|
|
17
|
-
const selectedTextBlocks = selectedBlocks.filter((block) =>
|
|
18
|
-
isTextBlock(snapshot.context, block),
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
const firstTextBlock = selectedTextBlocks.at(0)
|
|
22
|
-
|
|
23
|
-
if (!firstTextBlock) {
|
|
24
|
-
return undefined
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const firstListItem = firstTextBlock.listItem
|
|
28
|
-
|
|
29
|
-
if (!firstListItem) {
|
|
30
|
-
return undefined
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (selectedTextBlocks.every((block) => block.listItem === firstListItem)) {
|
|
34
|
-
return firstListItem
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return undefined
|
|
38
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import {isTextBlock} from '@portabletext/schema'
|
|
2
|
-
import type {PortableTextTextBlock} from '@sanity/types'
|
|
3
|
-
import type {EditorSelector} from '../editor/editor-selector'
|
|
4
|
-
import {getSelectedBlocks} from './selector.get-selected-blocks'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export const getActiveStyle: EditorSelector<PortableTextTextBlock['style']> = (
|
|
10
|
-
snapshot,
|
|
11
|
-
) => {
|
|
12
|
-
if (!snapshot.context.selection) {
|
|
13
|
-
return undefined
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const selectedBlocks = getSelectedBlocks(snapshot).map((block) => block.node)
|
|
17
|
-
const selectedTextBlocks = selectedBlocks.filter((block) =>
|
|
18
|
-
isTextBlock(snapshot.context, block),
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
const firstTextBlock = selectedTextBlocks.at(0)
|
|
22
|
-
|
|
23
|
-
if (!firstTextBlock) {
|
|
24
|
-
return undefined
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const firstStyle = firstTextBlock.style
|
|
28
|
-
|
|
29
|
-
if (!firstStyle) {
|
|
30
|
-
return undefined
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (selectedTextBlocks.every((block) => block.style === firstStyle)) {
|
|
34
|
-
return firstStyle
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return undefined
|
|
38
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type {PortableTextBlock} from '@sanity/types'
|
|
2
|
-
import type {EditorSelector} from '../editor/editor-selector'
|
|
3
|
-
import type {BlockPath} from '../types/paths'
|
|
4
|
-
import {getBlockKeyFromSelectionPoint} from '../utils/util.selection-point'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export const getAnchorBlock: EditorSelector<
|
|
10
|
-
{node: PortableTextBlock; path: BlockPath} | undefined
|
|
11
|
-
> = (snapshot) => {
|
|
12
|
-
if (!snapshot.context.selection) {
|
|
13
|
-
return undefined
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const key = getBlockKeyFromSelectionPoint(snapshot.context.selection.anchor)
|
|
17
|
-
const index = key ? snapshot.blockIndexMap.get(key) : undefined
|
|
18
|
-
const node =
|
|
19
|
-
index !== undefined ? snapshot.context.value.at(index) : undefined
|
|
20
|
-
|
|
21
|
-
return node && key ? {node, path: [{_key: key}]} : undefined
|
|
22
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type {PortableTextObject, PortableTextSpan} from '@sanity/types'
|
|
2
|
-
import type {EditorSelector} from '../editor/editor-selector'
|
|
3
|
-
import type {ChildPath} from '../types/paths'
|
|
4
|
-
import {getChildKeyFromSelectionPoint} from '../utils/util.selection-point'
|
|
5
|
-
import {getAnchorTextBlock} from './selector.get-anchor-text-block'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export const getAnchorChild: EditorSelector<
|
|
11
|
-
| {
|
|
12
|
-
node: PortableTextObject | PortableTextSpan
|
|
13
|
-
path: ChildPath
|
|
14
|
-
}
|
|
15
|
-
| undefined
|
|
16
|
-
> = (snapshot) => {
|
|
17
|
-
if (!snapshot.context.selection) {
|
|
18
|
-
return undefined
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const anchorBlock = getAnchorTextBlock(snapshot)
|
|
22
|
-
|
|
23
|
-
if (!anchorBlock) {
|
|
24
|
-
return undefined
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const key = getChildKeyFromSelectionPoint(snapshot.context.selection.anchor)
|
|
28
|
-
|
|
29
|
-
const node = key
|
|
30
|
-
? anchorBlock.node.children.find((span) => span._key === key)
|
|
31
|
-
: undefined
|
|
32
|
-
|
|
33
|
-
return node && key
|
|
34
|
-
? {node, path: [...anchorBlock.path, 'children', {_key: key}]}
|
|
35
|
-
: undefined
|
|
36
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {isPortableTextSpan, type PortableTextSpan} from '@sanity/types'
|
|
2
|
-
import type {EditorSelector} from '../editor/editor-selector'
|
|
3
|
-
import type {ChildPath} from '../types/paths'
|
|
4
|
-
import {getAnchorChild} from './selector.get-anchor-child'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export const getAnchorSpan: EditorSelector<
|
|
10
|
-
{node: PortableTextSpan; path: ChildPath} | undefined
|
|
11
|
-
> = (snapshot) => {
|
|
12
|
-
const anchorChild = getAnchorChild(snapshot)
|
|
13
|
-
|
|
14
|
-
return anchorChild && isPortableTextSpan(anchorChild.node)
|
|
15
|
-
? {node: anchorChild.node, path: anchorChild.path}
|
|
16
|
-
: undefined
|
|
17
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {isTextBlock} from '@portabletext/schema'
|
|
2
|
-
import type {PortableTextTextBlock} from '@sanity/types'
|
|
3
|
-
import type {EditorSelector} from '../editor/editor-selector'
|
|
4
|
-
import type {BlockPath} from '../types/paths'
|
|
5
|
-
import {getAnchorBlock} from './selector.get-anchor-block'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export const getAnchorTextBlock: EditorSelector<
|
|
11
|
-
{node: PortableTextTextBlock; path: BlockPath} | undefined
|
|
12
|
-
> = (snapshot) => {
|
|
13
|
-
const anchorBlock = getAnchorBlock(snapshot)
|
|
14
|
-
|
|
15
|
-
return anchorBlock && isTextBlock(snapshot.context, anchorBlock.node)
|
|
16
|
-
? {node: anchorBlock.node, path: anchorBlock.path}
|
|
17
|
-
: undefined
|
|
18
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type {EditorSelector} from '../editor/editor-selector'
|
|
2
|
-
import type {BlockOffset} from '../types/block-offset'
|
|
3
|
-
import {spanSelectionPointToBlockOffset} from '../utils/util.block-offset'
|
|
4
|
-
import {getSelectionEndPoint} from './selector.get-selection-end-point'
|
|
5
|
-
import {getSelectionStartPoint} from './selector.get-selection-start-point'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export const getBlockOffsets: EditorSelector<
|
|
11
|
-
{start: BlockOffset; end: BlockOffset} | undefined
|
|
12
|
-
> = (snapshot) => {
|
|
13
|
-
if (!snapshot.context.selection) {
|
|
14
|
-
return undefined
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const selectionStartPoint = getSelectionStartPoint(snapshot)
|
|
18
|
-
const selectionEndPoint = getSelectionEndPoint(snapshot)
|
|
19
|
-
|
|
20
|
-
if (!selectionStartPoint || !selectionEndPoint) {
|
|
21
|
-
return undefined
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const start = spanSelectionPointToBlockOffset({
|
|
25
|
-
context: snapshot.context,
|
|
26
|
-
selectionPoint: selectionStartPoint,
|
|
27
|
-
})
|
|
28
|
-
const end = spanSelectionPointToBlockOffset({
|
|
29
|
-
context: snapshot.context,
|
|
30
|
-
selectionPoint: selectionEndPoint,
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
return start && end ? {start, end} : undefined
|
|
34
|
-
}
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import {createTestKeyGenerator} from '@portabletext/test'
|
|
2
|
-
import type {PortableTextBlock} from '@sanity/types'
|
|
3
|
-
import {describe, expect, test} from 'vitest'
|
|
4
|
-
import {createTestSnapshot} from '../internal-utils/create-test-snapshot'
|
|
5
|
-
import type {EditorSelection} from '../types/editor'
|
|
6
|
-
import {getCaretWordSelection} from './selector.get-caret-word-selection'
|
|
7
|
-
|
|
8
|
-
const keyGenerator = createTestKeyGenerator()
|
|
9
|
-
|
|
10
|
-
function snapshot(value: Array<PortableTextBlock>, selection: EditorSelection) {
|
|
11
|
-
return createTestSnapshot({
|
|
12
|
-
context: {
|
|
13
|
-
value,
|
|
14
|
-
selection,
|
|
15
|
-
keyGenerator,
|
|
16
|
-
},
|
|
17
|
-
})
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
describe(getCaretWordSelection.name, () => {
|
|
21
|
-
test('empty block', () => {
|
|
22
|
-
expect(
|
|
23
|
-
getCaretWordSelection(
|
|
24
|
-
snapshot(
|
|
25
|
-
[
|
|
26
|
-
{
|
|
27
|
-
_key: 'k0',
|
|
28
|
-
_type: 'block',
|
|
29
|
-
children: [
|
|
30
|
-
{
|
|
31
|
-
_key: 'k1',
|
|
32
|
-
_type: 'span',
|
|
33
|
-
text: '',
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
{
|
|
39
|
-
anchor: {
|
|
40
|
-
path: [{_key: 'k0'}, 'children', {_key: 'k1'}],
|
|
41
|
-
offset: 0,
|
|
42
|
-
},
|
|
43
|
-
focus: {
|
|
44
|
-
path: [{_key: 'k0'}, 'children', {_key: 'k1'}],
|
|
45
|
-
offset: 0,
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
),
|
|
49
|
-
),
|
|
50
|
-
).toEqual(null)
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
test('inline object', () => {
|
|
54
|
-
expect(
|
|
55
|
-
getCaretWordSelection(
|
|
56
|
-
snapshot(
|
|
57
|
-
[
|
|
58
|
-
{
|
|
59
|
-
_key: 'k0',
|
|
60
|
-
_type: 'block',
|
|
61
|
-
children: [
|
|
62
|
-
{
|
|
63
|
-
_key: 'k1',
|
|
64
|
-
_type: 'stock-ticker',
|
|
65
|
-
symbol: 'FOO',
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
{
|
|
71
|
-
anchor: {
|
|
72
|
-
path: [{_key: 'k0'}, 'children', {_key: 'k1'}],
|
|
73
|
-
offset: 0,
|
|
74
|
-
},
|
|
75
|
-
focus: {
|
|
76
|
-
path: [{_key: 'k0'}, 'children', {_key: 'k1'}],
|
|
77
|
-
offset: 0,
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
),
|
|
81
|
-
),
|
|
82
|
-
).toEqual(null)
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
test('between inline objects', () => {
|
|
86
|
-
expect(
|
|
87
|
-
getCaretWordSelection(
|
|
88
|
-
snapshot(
|
|
89
|
-
[
|
|
90
|
-
{
|
|
91
|
-
_key: 'k0',
|
|
92
|
-
_type: 'block',
|
|
93
|
-
children: [
|
|
94
|
-
{
|
|
95
|
-
_key: 'k1',
|
|
96
|
-
_type: 'stock-ticker',
|
|
97
|
-
symbol: 'FOO',
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
_key: 'k2',
|
|
101
|
-
_type: 'span',
|
|
102
|
-
text: '',
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
_key: 'k3',
|
|
106
|
-
_type: 'stock-ticker',
|
|
107
|
-
symbol: 'BAR',
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
{
|
|
113
|
-
anchor: {
|
|
114
|
-
path: [{_key: 'k0'}, 'children', {_key: 'k2'}],
|
|
115
|
-
offset: 0,
|
|
116
|
-
},
|
|
117
|
-
focus: {
|
|
118
|
-
path: [{_key: 'k0'}, 'children', {_key: 'k2'}],
|
|
119
|
-
offset: 0,
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
),
|
|
123
|
-
),
|
|
124
|
-
).toEqual(null)
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
test('word between inline objects', () => {
|
|
128
|
-
expect(
|
|
129
|
-
getCaretWordSelection(
|
|
130
|
-
snapshot(
|
|
131
|
-
[
|
|
132
|
-
{
|
|
133
|
-
_key: 'k0',
|
|
134
|
-
_type: 'block',
|
|
135
|
-
children: [
|
|
136
|
-
{
|
|
137
|
-
_key: 'k1',
|
|
138
|
-
_type: 'stock-ticker',
|
|
139
|
-
symbol: 'FOO',
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
_key: 'k2',
|
|
143
|
-
_type: 'span',
|
|
144
|
-
text: 'foo',
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
_key: 'k3',
|
|
148
|
-
_type: 'stock-ticker',
|
|
149
|
-
symbol: 'BAR',
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
},
|
|
153
|
-
],
|
|
154
|
-
{
|
|
155
|
-
anchor: {
|
|
156
|
-
path: [{_key: 'k0'}, 'children', {_key: 'k2'}],
|
|
157
|
-
offset: 0,
|
|
158
|
-
},
|
|
159
|
-
focus: {
|
|
160
|
-
path: [{_key: 'k0'}, 'children', {_key: 'k2'}],
|
|
161
|
-
offset: 0,
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
),
|
|
165
|
-
),
|
|
166
|
-
).toEqual({
|
|
167
|
-
anchor: {
|
|
168
|
-
path: [{_key: 'k0'}, 'children', {_key: 'k2'}],
|
|
169
|
-
offset: 0,
|
|
170
|
-
},
|
|
171
|
-
focus: {
|
|
172
|
-
path: [{_key: 'k0'}, 'children', {_key: 'k2'}],
|
|
173
|
-
offset: 3,
|
|
174
|
-
},
|
|
175
|
-
})
|
|
176
|
-
})
|
|
177
|
-
|
|
178
|
-
test('no formatting', () => {
|
|
179
|
-
expect(
|
|
180
|
-
getCaretWordSelection(
|
|
181
|
-
snapshot(
|
|
182
|
-
[
|
|
183
|
-
{
|
|
184
|
-
_key: 'k0',
|
|
185
|
-
_type: 'block',
|
|
186
|
-
children: [
|
|
187
|
-
{
|
|
188
|
-
_key: 'k1',
|
|
189
|
-
_type: 'span',
|
|
190
|
-
text: 'foo bar baz',
|
|
191
|
-
},
|
|
192
|
-
],
|
|
193
|
-
},
|
|
194
|
-
],
|
|
195
|
-
{
|
|
196
|
-
anchor: {
|
|
197
|
-
path: [{_key: 'k0'}, 'children', {_key: 'k1'}],
|
|
198
|
-
offset: 5,
|
|
199
|
-
},
|
|
200
|
-
focus: {
|
|
201
|
-
path: [{_key: 'k0'}, 'children', {_key: 'k1'}],
|
|
202
|
-
offset: 5,
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
),
|
|
206
|
-
),
|
|
207
|
-
).toEqual({
|
|
208
|
-
anchor: {
|
|
209
|
-
path: [{_key: 'k0'}, 'children', {_key: 'k1'}],
|
|
210
|
-
offset: 4,
|
|
211
|
-
},
|
|
212
|
-
focus: {
|
|
213
|
-
path: [{_key: 'k0'}, 'children', {_key: 'k1'}],
|
|
214
|
-
offset: 7,
|
|
215
|
-
},
|
|
216
|
-
})
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
test('mixed formatting', () => {
|
|
220
|
-
expect(
|
|
221
|
-
getCaretWordSelection(
|
|
222
|
-
snapshot(
|
|
223
|
-
[
|
|
224
|
-
{
|
|
225
|
-
_key: 'k0',
|
|
226
|
-
_type: 'block',
|
|
227
|
-
children: [
|
|
228
|
-
{
|
|
229
|
-
_type: 'span',
|
|
230
|
-
_key: 'k1',
|
|
231
|
-
text: 'f',
|
|
232
|
-
marks: ['strong'],
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
_type: 'span',
|
|
236
|
-
_key: 'k2',
|
|
237
|
-
marks: ['strong', 'em'],
|
|
238
|
-
text: 'oo b',
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
_type: 'span',
|
|
242
|
-
_key: 'k3',
|
|
243
|
-
marks: ['strong', 'em', 'underline'],
|
|
244
|
-
text: 'a',
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
_type: 'span',
|
|
248
|
-
_key: 'k4',
|
|
249
|
-
marks: ['strong', 'underline'],
|
|
250
|
-
text: 'r ba',
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
_type: 'span',
|
|
254
|
-
_key: 'k5',
|
|
255
|
-
marks: ['strong'],
|
|
256
|
-
text: 'z',
|
|
257
|
-
},
|
|
258
|
-
],
|
|
259
|
-
},
|
|
260
|
-
],
|
|
261
|
-
{
|
|
262
|
-
anchor: {
|
|
263
|
-
path: [{_key: 'k0'}, 'children', {_key: 'k3'}],
|
|
264
|
-
offset: 0,
|
|
265
|
-
},
|
|
266
|
-
focus: {
|
|
267
|
-
path: [{_key: 'k0'}, 'children', {_key: 'k3'}],
|
|
268
|
-
offset: 0,
|
|
269
|
-
},
|
|
270
|
-
},
|
|
271
|
-
),
|
|
272
|
-
),
|
|
273
|
-
).toEqual({
|
|
274
|
-
anchor: {
|
|
275
|
-
path: [{_key: 'k0'}, 'children', {_key: 'k2'}],
|
|
276
|
-
offset: 3,
|
|
277
|
-
},
|
|
278
|
-
focus: {
|
|
279
|
-
path: [{_key: 'k0'}, 'children', {_key: 'k4'}],
|
|
280
|
-
offset: 1,
|
|
281
|
-
},
|
|
282
|
-
})
|
|
283
|
-
})
|
|
284
|
-
})
|