@portabletext/editor 3.3.3 → 3.3.5
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 +21 -1667
- package/lib/index.js +511 -9010
- package/lib/index.js.map +1 -1
- package/package.json +14 -15
- 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 -107
- 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
|
@@ -1,1461 +1,16 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import * as _sanity_types4 from "@sanity/types";
|
|
3
2
|
import { ArrayDefinition, ArraySchemaType, BlockDecoratorDefinition, BlockListDefinition, BlockStyleDefinition, ObjectSchemaType, Path, PortableTextBlock, PortableTextBlock as PortableTextBlock$1, PortableTextChild, PortableTextChild as PortableTextChild$1, PortableTextListBlock, PortableTextObject, PortableTextObject as PortableTextObject$2, PortableTextSpan, PortableTextSpan as PortableTextSpan$2, PortableTextTextBlock, PortableTextTextBlock as PortableTextTextBlock$2, TypedObject } from "@sanity/types";
|
|
3
|
+
import { BaseRange, Descendant, Operation } from "slate";
|
|
4
4
|
import * as xstate228 from "xstate";
|
|
5
5
|
import { ActorRef, ActorRefFrom, EventObject, Snapshot } from "xstate";
|
|
6
|
-
import * as
|
|
7
|
-
import React$1, { BaseSyntheticEvent, ClipboardEvent
|
|
6
|
+
import * as react18 from "react";
|
|
7
|
+
import React$1, { BaseSyntheticEvent, ClipboardEvent, Component, FocusEvent, JSX, KeyboardEvent as KeyboardEvent$1, MutableRefObject, PropsWithChildren, ReactElement, RefObject, TextareaHTMLAttributes } from "react";
|
|
8
8
|
import { Patch, Patch as Patch$1 } from "@portabletext/patches";
|
|
9
9
|
import * as _portabletext_schema5 from "@portabletext/schema";
|
|
10
10
|
import { AnnotationDefinition, AnnotationSchemaType, BaseDefinition, BlockObjectDefinition, BlockObjectSchemaType, DecoratorDefinition, DecoratorSchemaType, FieldDefinition, InlineObjectDefinition, InlineObjectSchemaType, ListDefinition, ListSchemaType, PortableTextObject as PortableTextObject$1, PortableTextSpan as PortableTextSpan$1, PortableTextTextBlock as PortableTextTextBlock$1, Schema, SchemaDefinition, SchemaDefinition as SchemaDefinition$1, StyleDefinition, StyleSchemaType, defineSchema } from "@portabletext/schema";
|
|
11
11
|
import { Observable, Subject } from "rxjs";
|
|
12
|
+
import { ReactEditor } from "slate-react";
|
|
12
13
|
import * as xstate_guards12 from "xstate/guards";
|
|
13
|
-
type LeafEdge = 'start' | 'end';
|
|
14
|
-
type MaximizeMode = RangeMode | 'all';
|
|
15
|
-
type MoveUnit = 'offset' | 'character' | 'word' | 'line';
|
|
16
|
-
type RangeDirection = TextDirection | 'outward' | 'inward';
|
|
17
|
-
type RangeMode = 'highest' | 'lowest';
|
|
18
|
-
type SelectionEdge = 'anchor' | 'focus' | 'start' | 'end';
|
|
19
|
-
type SelectionMode = 'all' | 'highest' | 'lowest';
|
|
20
|
-
type TextDirection = 'forward' | 'backward';
|
|
21
|
-
type TextUnit = 'character' | 'word' | 'line' | 'block';
|
|
22
|
-
type TextUnitAdjustment = TextUnit | 'offset';
|
|
23
|
-
interface TextDeleteOptions {
|
|
24
|
-
at?: Location;
|
|
25
|
-
distance?: number;
|
|
26
|
-
unit?: TextUnit;
|
|
27
|
-
reverse?: boolean;
|
|
28
|
-
hanging?: boolean;
|
|
29
|
-
voids?: boolean;
|
|
30
|
-
}
|
|
31
|
-
interface TextInsertFragmentOptions {
|
|
32
|
-
at?: Location;
|
|
33
|
-
hanging?: boolean;
|
|
34
|
-
voids?: boolean;
|
|
35
|
-
batchDirty?: boolean;
|
|
36
|
-
}
|
|
37
|
-
interface TextInsertTextOptions {
|
|
38
|
-
at?: Location;
|
|
39
|
-
voids?: boolean;
|
|
40
|
-
}
|
|
41
|
-
interface TextTransforms {
|
|
42
|
-
/**
|
|
43
|
-
* Delete content in the editor.
|
|
44
|
-
*/
|
|
45
|
-
delete: (editor: Editor$1, options?: TextDeleteOptions) => void;
|
|
46
|
-
/**
|
|
47
|
-
* Insert a fragment in the editor
|
|
48
|
-
* at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
|
|
49
|
-
*/
|
|
50
|
-
insertFragment: (editor: Editor$1, fragment: Node$1[], options?: TextInsertFragmentOptions) => void;
|
|
51
|
-
/**
|
|
52
|
-
* Insert a string of text in the editor
|
|
53
|
-
* at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
|
|
54
|
-
*/
|
|
55
|
-
insertText: (editor: Editor$1, text: string, options?: TextInsertTextOptions) => void;
|
|
56
|
-
}
|
|
57
|
-
declare const TextTransforms: TextTransforms;
|
|
58
|
-
interface NodeInsertNodesOptions<T$1 extends Node$1> {
|
|
59
|
-
at?: Location;
|
|
60
|
-
match?: NodeMatch<T$1>;
|
|
61
|
-
mode?: RangeMode;
|
|
62
|
-
hanging?: boolean;
|
|
63
|
-
select?: boolean;
|
|
64
|
-
voids?: boolean;
|
|
65
|
-
batchDirty?: boolean;
|
|
66
|
-
}
|
|
67
|
-
interface NodeTransforms {
|
|
68
|
-
/**
|
|
69
|
-
* Insert nodes in the editor
|
|
70
|
-
* at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
|
|
71
|
-
*/
|
|
72
|
-
insertNodes: <T$1 extends Node$1>(editor: Editor$1, nodes: Node$1 | Node$1[], options?: NodeInsertNodesOptions<T$1>) => void;
|
|
73
|
-
/**
|
|
74
|
-
* Lift nodes at a specific location upwards in the document tree, splitting
|
|
75
|
-
* their parent in two if necessary.
|
|
76
|
-
*/
|
|
77
|
-
liftNodes: <T$1 extends Node$1>(editor: Editor$1, options?: {
|
|
78
|
-
at?: Location;
|
|
79
|
-
match?: NodeMatch<T$1>;
|
|
80
|
-
mode?: MaximizeMode;
|
|
81
|
-
voids?: boolean;
|
|
82
|
-
}) => void;
|
|
83
|
-
/**
|
|
84
|
-
* Merge a node at a location with the previous node of the same depth,
|
|
85
|
-
* removing any empty containing nodes after the merge if necessary.
|
|
86
|
-
*/
|
|
87
|
-
mergeNodes: <T$1 extends Node$1>(editor: Editor$1, options?: {
|
|
88
|
-
at?: Location;
|
|
89
|
-
match?: NodeMatch<T$1>;
|
|
90
|
-
mode?: RangeMode;
|
|
91
|
-
hanging?: boolean;
|
|
92
|
-
voids?: boolean;
|
|
93
|
-
}) => void;
|
|
94
|
-
/**
|
|
95
|
-
* Move the nodes at a location to a new location.
|
|
96
|
-
*/
|
|
97
|
-
moveNodes: <T$1 extends Node$1>(editor: Editor$1, options: {
|
|
98
|
-
at?: Location;
|
|
99
|
-
match?: NodeMatch<T$1>;
|
|
100
|
-
mode?: MaximizeMode;
|
|
101
|
-
to: Path$1;
|
|
102
|
-
voids?: boolean;
|
|
103
|
-
}) => void;
|
|
104
|
-
/**
|
|
105
|
-
* Remove the nodes at a specific location in the document.
|
|
106
|
-
*/
|
|
107
|
-
removeNodes: <T$1 extends Node$1>(editor: Editor$1, options?: {
|
|
108
|
-
at?: Location;
|
|
109
|
-
match?: NodeMatch<T$1>;
|
|
110
|
-
mode?: RangeMode;
|
|
111
|
-
hanging?: boolean;
|
|
112
|
-
voids?: boolean;
|
|
113
|
-
}) => void;
|
|
114
|
-
/**
|
|
115
|
-
* Set new properties on the nodes at a location.
|
|
116
|
-
*/
|
|
117
|
-
setNodes: <T$1 extends Node$1>(editor: Editor$1, props: Partial<T$1>, options?: {
|
|
118
|
-
at?: Location;
|
|
119
|
-
match?: NodeMatch<T$1>;
|
|
120
|
-
mode?: MaximizeMode;
|
|
121
|
-
hanging?: boolean;
|
|
122
|
-
split?: boolean;
|
|
123
|
-
voids?: boolean;
|
|
124
|
-
compare?: PropsCompare;
|
|
125
|
-
merge?: PropsMerge;
|
|
126
|
-
}) => void;
|
|
127
|
-
/**
|
|
128
|
-
* Split the nodes at a specific location.
|
|
129
|
-
*/
|
|
130
|
-
splitNodes: <T$1 extends Node$1>(editor: Editor$1, options?: {
|
|
131
|
-
at?: Location;
|
|
132
|
-
match?: NodeMatch<T$1>;
|
|
133
|
-
mode?: RangeMode;
|
|
134
|
-
always?: boolean;
|
|
135
|
-
height?: number;
|
|
136
|
-
voids?: boolean;
|
|
137
|
-
}) => void;
|
|
138
|
-
/**
|
|
139
|
-
* Unset properties on the nodes at a location.
|
|
140
|
-
*/
|
|
141
|
-
unsetNodes: <T$1 extends Node$1>(editor: Editor$1, props: string | string[], options?: {
|
|
142
|
-
at?: Location;
|
|
143
|
-
match?: NodeMatch<T$1>;
|
|
144
|
-
mode?: MaximizeMode;
|
|
145
|
-
hanging?: boolean;
|
|
146
|
-
split?: boolean;
|
|
147
|
-
voids?: boolean;
|
|
148
|
-
}) => void;
|
|
149
|
-
/**
|
|
150
|
-
* Unwrap the nodes at a location from a parent node, splitting the parent if
|
|
151
|
-
* necessary to ensure that only the content in the range is unwrapped.
|
|
152
|
-
*/
|
|
153
|
-
unwrapNodes: <T$1 extends Node$1>(editor: Editor$1, options?: {
|
|
154
|
-
at?: Location;
|
|
155
|
-
match?: NodeMatch<T$1>;
|
|
156
|
-
mode?: MaximizeMode;
|
|
157
|
-
split?: boolean;
|
|
158
|
-
voids?: boolean;
|
|
159
|
-
}) => void;
|
|
160
|
-
/**
|
|
161
|
-
* Wrap the nodes at a location in a new container node, splitting the edges
|
|
162
|
-
* of the range first to ensure that only the content in the range is wrapped.
|
|
163
|
-
*/
|
|
164
|
-
wrapNodes: <T$1 extends Node$1>(editor: Editor$1, element: Element$1, options?: {
|
|
165
|
-
at?: Location;
|
|
166
|
-
match?: NodeMatch<T$1>;
|
|
167
|
-
mode?: MaximizeMode;
|
|
168
|
-
split?: boolean;
|
|
169
|
-
voids?: boolean;
|
|
170
|
-
}) => void;
|
|
171
|
-
}
|
|
172
|
-
declare const NodeTransforms: NodeTransforms;
|
|
173
|
-
/**
|
|
174
|
-
* The `Editor` interface stores all the state of a Slate editor. It is extended
|
|
175
|
-
* by plugins that wish to add their own helpers and implement new behaviors.
|
|
176
|
-
*/
|
|
177
|
-
interface BaseEditor {
|
|
178
|
-
children: Descendant[];
|
|
179
|
-
selection: Selection$1;
|
|
180
|
-
operations: Operation[];
|
|
181
|
-
marks: EditorMarks | null;
|
|
182
|
-
apply: (operation: Operation) => void;
|
|
183
|
-
getDirtyPaths: (operation: Operation) => Path$1[];
|
|
184
|
-
getFragment: () => Descendant[];
|
|
185
|
-
isElementReadOnly: (element: Element$1) => boolean;
|
|
186
|
-
isSelectable: (element: Element$1) => boolean;
|
|
187
|
-
markableVoid: (element: Element$1) => boolean;
|
|
188
|
-
normalizeNode: (entry: NodeEntry, options?: {
|
|
189
|
-
operation?: Operation;
|
|
190
|
-
fallbackElement?: () => Element$1;
|
|
191
|
-
}) => void;
|
|
192
|
-
onChange: (options?: {
|
|
193
|
-
operation?: Operation;
|
|
194
|
-
}) => void;
|
|
195
|
-
shouldNormalize: ({
|
|
196
|
-
iteration,
|
|
197
|
-
dirtyPaths,
|
|
198
|
-
operation
|
|
199
|
-
}: {
|
|
200
|
-
iteration: number;
|
|
201
|
-
initialDirtyPathsLength: number;
|
|
202
|
-
dirtyPaths: Path$1[];
|
|
203
|
-
operation?: Operation;
|
|
204
|
-
}) => boolean;
|
|
205
|
-
addMark: OmitFirstArg<typeof Editor$1.addMark>;
|
|
206
|
-
collapse: OmitFirstArg<typeof Transforms.collapse>;
|
|
207
|
-
delete: OmitFirstArg<typeof Transforms.delete>;
|
|
208
|
-
deleteBackward: (unit: TextUnit) => void;
|
|
209
|
-
deleteForward: (unit: TextUnit) => void;
|
|
210
|
-
deleteFragment: OmitFirstArg<typeof Editor$1.deleteFragment>;
|
|
211
|
-
deselect: OmitFirstArg<typeof Transforms.deselect>;
|
|
212
|
-
insertBreak: OmitFirstArg<typeof Editor$1.insertBreak>;
|
|
213
|
-
insertFragment: OmitFirstArg<typeof Transforms.insertFragment>;
|
|
214
|
-
insertNode: OmitFirstArg<typeof Editor$1.insertNode>;
|
|
215
|
-
insertNodes: OmitFirstArg<typeof Transforms.insertNodes>;
|
|
216
|
-
insertSoftBreak: OmitFirstArg<typeof Editor$1.insertSoftBreak>;
|
|
217
|
-
insertText: OmitFirstArg<typeof Transforms.insertText>;
|
|
218
|
-
liftNodes: OmitFirstArg<typeof Transforms.liftNodes>;
|
|
219
|
-
mergeNodes: OmitFirstArg<typeof Transforms.mergeNodes>;
|
|
220
|
-
move: OmitFirstArg<typeof Transforms.move>;
|
|
221
|
-
moveNodes: OmitFirstArg<typeof Transforms.moveNodes>;
|
|
222
|
-
normalize: OmitFirstArg<typeof Editor$1.normalize>;
|
|
223
|
-
removeMark: OmitFirstArg<typeof Editor$1.removeMark>;
|
|
224
|
-
removeNodes: OmitFirstArg<typeof Transforms.removeNodes>;
|
|
225
|
-
select: OmitFirstArg<typeof Transforms.select>;
|
|
226
|
-
setNodes: <T$1 extends Node$1>(props: Partial<T$1>, options?: {
|
|
227
|
-
at?: Location;
|
|
228
|
-
match?: NodeMatch<T$1>;
|
|
229
|
-
mode?: MaximizeMode;
|
|
230
|
-
hanging?: boolean;
|
|
231
|
-
split?: boolean;
|
|
232
|
-
voids?: boolean;
|
|
233
|
-
compare?: PropsCompare;
|
|
234
|
-
merge?: PropsMerge;
|
|
235
|
-
}) => void;
|
|
236
|
-
setNormalizing: OmitFirstArg<typeof Editor$1.setNormalizing>;
|
|
237
|
-
setPoint: OmitFirstArg<typeof Transforms.setPoint>;
|
|
238
|
-
setSelection: OmitFirstArg<typeof Transforms.setSelection>;
|
|
239
|
-
splitNodes: OmitFirstArg<typeof Transforms.splitNodes>;
|
|
240
|
-
unsetNodes: OmitFirstArg<typeof Transforms.unsetNodes>;
|
|
241
|
-
unwrapNodes: OmitFirstArg<typeof Transforms.unwrapNodes>;
|
|
242
|
-
withoutNormalizing: OmitFirstArg<typeof Editor$1.withoutNormalizing>;
|
|
243
|
-
wrapNodes: OmitFirstArg<typeof Transforms.wrapNodes>;
|
|
244
|
-
above: <T$1 extends Ancestor>(options?: EditorAboveOptions<T$1>) => NodeEntry<T$1> | undefined;
|
|
245
|
-
after: OmitFirstArg<typeof Editor$1.after>;
|
|
246
|
-
before: OmitFirstArg<typeof Editor$1.before>;
|
|
247
|
-
edges: OmitFirstArg<typeof Editor$1.edges>;
|
|
248
|
-
elementReadOnly: OmitFirstArg<typeof Editor$1.elementReadOnly>;
|
|
249
|
-
end: OmitFirstArg<typeof Editor$1.end>;
|
|
250
|
-
first: OmitFirstArg<typeof Editor$1.first>;
|
|
251
|
-
fragment: OmitFirstArg<typeof Editor$1.fragment>;
|
|
252
|
-
getMarks: OmitFirstArg<typeof Editor$1.marks>;
|
|
253
|
-
hasBlocks: OmitFirstArg<typeof Editor$1.hasBlocks>;
|
|
254
|
-
hasInlines: OmitFirstArg<typeof Editor$1.hasInlines>;
|
|
255
|
-
hasPath: OmitFirstArg<typeof Editor$1.hasPath>;
|
|
256
|
-
hasTexts: OmitFirstArg<typeof Editor$1.hasTexts>;
|
|
257
|
-
isBlock: OmitFirstArg<typeof Editor$1.isBlock>;
|
|
258
|
-
isEdge: OmitFirstArg<typeof Editor$1.isEdge>;
|
|
259
|
-
isEmpty: OmitFirstArg<typeof Editor$1.isEmpty>;
|
|
260
|
-
isEnd: OmitFirstArg<typeof Editor$1.isEnd>;
|
|
261
|
-
isInline: OmitFirstArg<typeof Editor$1.isInline>;
|
|
262
|
-
isNormalizing: OmitFirstArg<typeof Editor$1.isNormalizing>;
|
|
263
|
-
isStart: OmitFirstArg<typeof Editor$1.isStart>;
|
|
264
|
-
isVoid: OmitFirstArg<typeof Editor$1.isVoid>;
|
|
265
|
-
last: OmitFirstArg<typeof Editor$1.last>;
|
|
266
|
-
leaf: OmitFirstArg<typeof Editor$1.leaf>;
|
|
267
|
-
levels: <T$1 extends Node$1>(options?: EditorLevelsOptions<T$1>) => Generator<NodeEntry<T$1>, void, undefined>;
|
|
268
|
-
next: <T$1 extends Descendant>(options?: EditorNextOptions<T$1>) => NodeEntry<T$1> | undefined;
|
|
269
|
-
node: OmitFirstArg<typeof Editor$1.node>;
|
|
270
|
-
nodes: <T$1 extends Node$1>(options?: EditorNodesOptions<T$1>) => Generator<NodeEntry<T$1>, void, undefined>;
|
|
271
|
-
parent: OmitFirstArg<typeof Editor$1.parent>;
|
|
272
|
-
path: OmitFirstArg<typeof Editor$1.path>;
|
|
273
|
-
pathRef: OmitFirstArg<typeof Editor$1.pathRef>;
|
|
274
|
-
pathRefs: OmitFirstArg<typeof Editor$1.pathRefs>;
|
|
275
|
-
point: OmitFirstArg<typeof Editor$1.point>;
|
|
276
|
-
pointRef: OmitFirstArg<typeof Editor$1.pointRef>;
|
|
277
|
-
pointRefs: OmitFirstArg<typeof Editor$1.pointRefs>;
|
|
278
|
-
positions: OmitFirstArg<typeof Editor$1.positions>;
|
|
279
|
-
previous: <T$1 extends Node$1>(options?: EditorPreviousOptions<T$1>) => NodeEntry<T$1> | undefined;
|
|
280
|
-
range: OmitFirstArg<typeof Editor$1.range>;
|
|
281
|
-
rangeRef: OmitFirstArg<typeof Editor$1.rangeRef>;
|
|
282
|
-
rangeRefs: OmitFirstArg<typeof Editor$1.rangeRefs>;
|
|
283
|
-
start: OmitFirstArg<typeof Editor$1.start>;
|
|
284
|
-
string: OmitFirstArg<typeof Editor$1.string>;
|
|
285
|
-
unhangRange: OmitFirstArg<typeof Editor$1.unhangRange>;
|
|
286
|
-
void: OmitFirstArg<typeof Editor$1.void>;
|
|
287
|
-
shouldMergeNodesRemovePrevNode: OmitFirstArg<typeof Editor$1.shouldMergeNodesRemovePrevNode>;
|
|
288
|
-
}
|
|
289
|
-
type Editor$1 = ExtendedType<'Editor', BaseEditor>;
|
|
290
|
-
type BaseSelection = Range | null;
|
|
291
|
-
type Selection$1 = ExtendedType<'Selection', BaseSelection>;
|
|
292
|
-
type EditorMarks = Omit<Text, 'text'>;
|
|
293
|
-
interface EditorAboveOptions<T$1 extends Ancestor> {
|
|
294
|
-
at?: Location;
|
|
295
|
-
match?: NodeMatch<T$1>;
|
|
296
|
-
mode?: MaximizeMode;
|
|
297
|
-
voids?: boolean;
|
|
298
|
-
}
|
|
299
|
-
interface EditorAfterOptions {
|
|
300
|
-
distance?: number;
|
|
301
|
-
unit?: TextUnitAdjustment;
|
|
302
|
-
voids?: boolean;
|
|
303
|
-
}
|
|
304
|
-
interface EditorBeforeOptions {
|
|
305
|
-
distance?: number;
|
|
306
|
-
unit?: TextUnitAdjustment;
|
|
307
|
-
voids?: boolean;
|
|
308
|
-
}
|
|
309
|
-
interface EditorDirectedDeletionOptions {
|
|
310
|
-
unit?: TextUnit;
|
|
311
|
-
}
|
|
312
|
-
interface EditorElementReadOnlyOptions {
|
|
313
|
-
at?: Location;
|
|
314
|
-
mode?: MaximizeMode;
|
|
315
|
-
voids?: boolean;
|
|
316
|
-
}
|
|
317
|
-
interface EditorFragmentDeletionOptions {
|
|
318
|
-
direction?: TextDirection;
|
|
319
|
-
}
|
|
320
|
-
interface EditorIsEditorOptions {
|
|
321
|
-
deep?: boolean;
|
|
322
|
-
}
|
|
323
|
-
interface EditorLeafOptions {
|
|
324
|
-
depth?: number;
|
|
325
|
-
edge?: LeafEdge;
|
|
326
|
-
}
|
|
327
|
-
interface EditorLevelsOptions<T$1 extends Node$1> {
|
|
328
|
-
at?: Location;
|
|
329
|
-
match?: NodeMatch<T$1>;
|
|
330
|
-
reverse?: boolean;
|
|
331
|
-
voids?: boolean;
|
|
332
|
-
}
|
|
333
|
-
interface EditorNextOptions<T$1 extends Descendant> {
|
|
334
|
-
at?: Location;
|
|
335
|
-
match?: NodeMatch<T$1>;
|
|
336
|
-
mode?: SelectionMode;
|
|
337
|
-
voids?: boolean;
|
|
338
|
-
}
|
|
339
|
-
interface EditorNodeOptions {
|
|
340
|
-
depth?: number;
|
|
341
|
-
edge?: LeafEdge;
|
|
342
|
-
}
|
|
343
|
-
interface EditorNodesOptions<T$1 extends Node$1> {
|
|
344
|
-
at?: Location | Span;
|
|
345
|
-
match?: NodeMatch<T$1>;
|
|
346
|
-
mode?: SelectionMode;
|
|
347
|
-
universal?: boolean;
|
|
348
|
-
reverse?: boolean;
|
|
349
|
-
voids?: boolean;
|
|
350
|
-
pass?: (entry: NodeEntry) => boolean;
|
|
351
|
-
}
|
|
352
|
-
interface EditorNormalizeOptions {
|
|
353
|
-
force?: boolean;
|
|
354
|
-
operation?: Operation;
|
|
355
|
-
}
|
|
356
|
-
interface EditorParentOptions {
|
|
357
|
-
depth?: number;
|
|
358
|
-
edge?: LeafEdge;
|
|
359
|
-
}
|
|
360
|
-
interface EditorPathOptions {
|
|
361
|
-
depth?: number;
|
|
362
|
-
edge?: LeafEdge;
|
|
363
|
-
}
|
|
364
|
-
interface EditorPathRefOptions {
|
|
365
|
-
affinity?: TextDirection | null;
|
|
366
|
-
}
|
|
367
|
-
interface EditorPointOptions {
|
|
368
|
-
edge?: LeafEdge;
|
|
369
|
-
}
|
|
370
|
-
interface EditorPointRefOptions {
|
|
371
|
-
affinity?: TextDirection | null;
|
|
372
|
-
}
|
|
373
|
-
interface EditorPositionsOptions {
|
|
374
|
-
at?: Location;
|
|
375
|
-
unit?: TextUnitAdjustment;
|
|
376
|
-
reverse?: boolean;
|
|
377
|
-
voids?: boolean;
|
|
378
|
-
}
|
|
379
|
-
interface EditorPreviousOptions<T$1 extends Node$1> {
|
|
380
|
-
at?: Location;
|
|
381
|
-
match?: NodeMatch<T$1>;
|
|
382
|
-
mode?: SelectionMode;
|
|
383
|
-
voids?: boolean;
|
|
384
|
-
}
|
|
385
|
-
interface EditorRangeRefOptions {
|
|
386
|
-
affinity?: RangeDirection | null;
|
|
387
|
-
}
|
|
388
|
-
interface EditorStringOptions {
|
|
389
|
-
voids?: boolean;
|
|
390
|
-
}
|
|
391
|
-
interface EditorUnhangRangeOptions {
|
|
392
|
-
voids?: boolean;
|
|
393
|
-
}
|
|
394
|
-
interface EditorVoidOptions {
|
|
395
|
-
at?: Location;
|
|
396
|
-
mode?: MaximizeMode;
|
|
397
|
-
voids?: boolean;
|
|
398
|
-
}
|
|
399
|
-
interface EditorInterface {
|
|
400
|
-
/**
|
|
401
|
-
* Get the ancestor above a location in the document.
|
|
402
|
-
*/
|
|
403
|
-
above: <T$1 extends Ancestor>(editor: Editor$1, options?: EditorAboveOptions<T$1>) => NodeEntry<T$1> | undefined;
|
|
404
|
-
/**
|
|
405
|
-
* Add a custom property to the leaf text nodes in the current selection.
|
|
406
|
-
*
|
|
407
|
-
* If the selection is currently collapsed, the marks will be added to the
|
|
408
|
-
* `editor.marks` property instead, and applied when text is inserted next.
|
|
409
|
-
*/
|
|
410
|
-
addMark: (editor: Editor$1, key: string, value: any) => void;
|
|
411
|
-
/**
|
|
412
|
-
* Get the point after a location.
|
|
413
|
-
*/
|
|
414
|
-
after: (editor: Editor$1, at: Location, options?: EditorAfterOptions) => Point | undefined;
|
|
415
|
-
/**
|
|
416
|
-
* Get the point before a location.
|
|
417
|
-
*/
|
|
418
|
-
before: (editor: Editor$1, at: Location, options?: EditorBeforeOptions) => Point | undefined;
|
|
419
|
-
/**
|
|
420
|
-
* Delete content in the editor backward from the current selection.
|
|
421
|
-
*/
|
|
422
|
-
deleteBackward: (editor: Editor$1, options?: EditorDirectedDeletionOptions) => void;
|
|
423
|
-
/**
|
|
424
|
-
* Delete content in the editor forward from the current selection.
|
|
425
|
-
*/
|
|
426
|
-
deleteForward: (editor: Editor$1, options?: EditorDirectedDeletionOptions) => void;
|
|
427
|
-
/**
|
|
428
|
-
* Delete the content in the current selection.
|
|
429
|
-
*/
|
|
430
|
-
deleteFragment: (editor: Editor$1, options?: EditorFragmentDeletionOptions) => void;
|
|
431
|
-
/**
|
|
432
|
-
* Get the start and end points of a location.
|
|
433
|
-
*/
|
|
434
|
-
edges: (editor: Editor$1, at: Location) => [Point, Point];
|
|
435
|
-
/**
|
|
436
|
-
* Match a read-only element in the current branch of the editor.
|
|
437
|
-
*/
|
|
438
|
-
elementReadOnly: (editor: Editor$1, options?: EditorElementReadOnlyOptions) => NodeEntry<Element$1> | undefined;
|
|
439
|
-
/**
|
|
440
|
-
* Get the end point of a location.
|
|
441
|
-
*/
|
|
442
|
-
end: (editor: Editor$1, at: Location) => Point;
|
|
443
|
-
/**
|
|
444
|
-
* Get the first node at a location.
|
|
445
|
-
*/
|
|
446
|
-
first: (editor: Editor$1, at: Location) => NodeEntry;
|
|
447
|
-
/**
|
|
448
|
-
* Get the fragment at a location.
|
|
449
|
-
*/
|
|
450
|
-
fragment: (editor: Editor$1, at: Location) => Descendant[];
|
|
451
|
-
/**
|
|
452
|
-
* Check if a node has block children.
|
|
453
|
-
*/
|
|
454
|
-
hasBlocks: (editor: Editor$1, element: Element$1) => boolean;
|
|
455
|
-
/**
|
|
456
|
-
* Check if a node has inline and text children.
|
|
457
|
-
*/
|
|
458
|
-
hasInlines: (editor: Editor$1, element: Element$1) => boolean;
|
|
459
|
-
hasPath: (editor: Editor$1, path: Path$1) => boolean;
|
|
460
|
-
/**
|
|
461
|
-
* Check if a node has text children.
|
|
462
|
-
*/
|
|
463
|
-
hasTexts: (editor: Editor$1, element: Element$1) => boolean;
|
|
464
|
-
/**
|
|
465
|
-
* Insert a block break at the current selection.
|
|
466
|
-
*
|
|
467
|
-
* If the selection is currently expanded, it will be deleted first.
|
|
468
|
-
*/
|
|
469
|
-
insertBreak: (editor: Editor$1) => void;
|
|
470
|
-
/**
|
|
471
|
-
* Inserts a fragment
|
|
472
|
-
* at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
|
|
473
|
-
*/
|
|
474
|
-
insertFragment: (editor: Editor$1, fragment: Node$1[], options?: TextInsertFragmentOptions) => void;
|
|
475
|
-
/**
|
|
476
|
-
* Atomically inserts `nodes`
|
|
477
|
-
* at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
|
|
478
|
-
*/
|
|
479
|
-
insertNode: <T$1 extends Node$1>(editor: Editor$1, node: Node$1, options?: NodeInsertNodesOptions<T$1>) => void;
|
|
480
|
-
/**
|
|
481
|
-
* Insert a soft break at the current selection.
|
|
482
|
-
*
|
|
483
|
-
* If the selection is currently expanded, it will be deleted first.
|
|
484
|
-
*/
|
|
485
|
-
insertSoftBreak: (editor: Editor$1) => void;
|
|
486
|
-
/**
|
|
487
|
-
* Insert a string of text
|
|
488
|
-
* at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
|
|
489
|
-
*/
|
|
490
|
-
insertText: (editor: Editor$1, text: string, options?: TextInsertTextOptions) => void;
|
|
491
|
-
/**
|
|
492
|
-
* Check if a value is a block `Element` object.
|
|
493
|
-
*/
|
|
494
|
-
isBlock: (editor: Editor$1, value: Element$1) => boolean;
|
|
495
|
-
/**
|
|
496
|
-
* Check if a point is an edge of a location.
|
|
497
|
-
*/
|
|
498
|
-
isEdge: (editor: Editor$1, point: Point, at: Location) => boolean;
|
|
499
|
-
/**
|
|
500
|
-
* Check if a value is an `Editor` object.
|
|
501
|
-
*/
|
|
502
|
-
isEditor: (value: any, options?: EditorIsEditorOptions) => value is Editor$1;
|
|
503
|
-
/**
|
|
504
|
-
* Check if a value is a read-only `Element` object.
|
|
505
|
-
*/
|
|
506
|
-
isElementReadOnly: (editor: Editor$1, element: Element$1) => boolean;
|
|
507
|
-
/**
|
|
508
|
-
* Check if an element is empty, accounting for void nodes.
|
|
509
|
-
*/
|
|
510
|
-
isEmpty: (editor: Editor$1, element: Element$1) => boolean;
|
|
511
|
-
/**
|
|
512
|
-
* Check if a point is the end point of a location.
|
|
513
|
-
*/
|
|
514
|
-
isEnd: (editor: Editor$1, point: Point, at: Location) => boolean;
|
|
515
|
-
/**
|
|
516
|
-
* Check if a value is an inline `Element` object.
|
|
517
|
-
*/
|
|
518
|
-
isInline: (editor: Editor$1, value: Element$1) => boolean;
|
|
519
|
-
/**
|
|
520
|
-
* Check if the editor is currently normalizing after each operation.
|
|
521
|
-
*/
|
|
522
|
-
isNormalizing: (editor: Editor$1) => boolean;
|
|
523
|
-
/**
|
|
524
|
-
* Check if a value is a selectable `Element` object.
|
|
525
|
-
*/
|
|
526
|
-
isSelectable: (editor: Editor$1, element: Element$1) => boolean;
|
|
527
|
-
/**
|
|
528
|
-
* Check if a point is the start point of a location.
|
|
529
|
-
*/
|
|
530
|
-
isStart: (editor: Editor$1, point: Point, at: Location) => boolean;
|
|
531
|
-
/**
|
|
532
|
-
* Check if a value is a void `Element` object.
|
|
533
|
-
*/
|
|
534
|
-
isVoid: (editor: Editor$1, value: Element$1) => boolean;
|
|
535
|
-
/**
|
|
536
|
-
* Get the last node at a location.
|
|
537
|
-
*/
|
|
538
|
-
last: (editor: Editor$1, at: Location) => NodeEntry;
|
|
539
|
-
/**
|
|
540
|
-
* Get the leaf text node at a location.
|
|
541
|
-
*/
|
|
542
|
-
leaf: (editor: Editor$1, at: Location, options?: EditorLeafOptions) => NodeEntry<Text>;
|
|
543
|
-
/**
|
|
544
|
-
* Iterate through all of the levels at a location.
|
|
545
|
-
*/
|
|
546
|
-
levels: <T$1 extends Node$1>(editor: Editor$1, options?: EditorLevelsOptions<T$1>) => Generator<NodeEntry<T$1>, void, undefined>;
|
|
547
|
-
/**
|
|
548
|
-
* Get the marks that would be added to text at the current selection.
|
|
549
|
-
*/
|
|
550
|
-
marks: (editor: Editor$1) => Omit<Text, 'text'> | null;
|
|
551
|
-
/**
|
|
552
|
-
* Get the matching node in the branch of the document after a location.
|
|
553
|
-
*/
|
|
554
|
-
next: <T$1 extends Descendant>(editor: Editor$1, options?: EditorNextOptions<T$1>) => NodeEntry<T$1> | undefined;
|
|
555
|
-
/**
|
|
556
|
-
* Get the node at a location.
|
|
557
|
-
*/
|
|
558
|
-
node: (editor: Editor$1, at: Location, options?: EditorNodeOptions) => NodeEntry;
|
|
559
|
-
/**
|
|
560
|
-
* Iterate through all of the nodes in the Editor.
|
|
561
|
-
*/
|
|
562
|
-
nodes: <T$1 extends Node$1>(editor: Editor$1, options?: EditorNodesOptions<T$1>) => Generator<NodeEntry<T$1>, void, undefined>;
|
|
563
|
-
/**
|
|
564
|
-
* Normalize any dirty objects in the editor.
|
|
565
|
-
*/
|
|
566
|
-
normalize: (editor: Editor$1, options?: EditorNormalizeOptions) => void;
|
|
567
|
-
/**
|
|
568
|
-
* Get the parent node of a location.
|
|
569
|
-
*/
|
|
570
|
-
parent: (editor: Editor$1, at: Location, options?: EditorParentOptions) => NodeEntry<Ancestor>;
|
|
571
|
-
/**
|
|
572
|
-
* Get the path of a location.
|
|
573
|
-
*/
|
|
574
|
-
path: (editor: Editor$1, at: Location, options?: EditorPathOptions) => Path$1;
|
|
575
|
-
/**
|
|
576
|
-
* Create a mutable ref for a `Path` object, which will stay in sync as new
|
|
577
|
-
* operations are applied to the editor.
|
|
578
|
-
*/
|
|
579
|
-
pathRef: (editor: Editor$1, path: Path$1, options?: EditorPathRefOptions) => PathRef;
|
|
580
|
-
/**
|
|
581
|
-
* Get the set of currently tracked path refs of the editor.
|
|
582
|
-
*/
|
|
583
|
-
pathRefs: (editor: Editor$1) => Set<PathRef>;
|
|
584
|
-
/**
|
|
585
|
-
* Get the start or end point of a location.
|
|
586
|
-
*/
|
|
587
|
-
point: (editor: Editor$1, at: Location, options?: EditorPointOptions) => Point;
|
|
588
|
-
/**
|
|
589
|
-
* Create a mutable ref for a `Point` object, which will stay in sync as new
|
|
590
|
-
* operations are applied to the editor.
|
|
591
|
-
*/
|
|
592
|
-
pointRef: (editor: Editor$1, point: Point, options?: EditorPointRefOptions) => PointRef;
|
|
593
|
-
/**
|
|
594
|
-
* Get the set of currently tracked point refs of the editor.
|
|
595
|
-
*/
|
|
596
|
-
pointRefs: (editor: Editor$1) => Set<PointRef>;
|
|
597
|
-
/**
|
|
598
|
-
* Return all the positions in `at` range where a `Point` can be placed.
|
|
599
|
-
*
|
|
600
|
-
* By default, moves forward by individual offsets at a time, but
|
|
601
|
-
* the `unit` option can be used to to move by character, word, line, or block.
|
|
602
|
-
*
|
|
603
|
-
* The `reverse` option can be used to change iteration direction.
|
|
604
|
-
*
|
|
605
|
-
* Note: By default void nodes are treated as a single point and iteration
|
|
606
|
-
* will not happen inside their content unless you pass in true for the
|
|
607
|
-
* `voids` option, then iteration will occur.
|
|
608
|
-
*/
|
|
609
|
-
positions: (editor: Editor$1, options?: EditorPositionsOptions) => Generator<Point, void, undefined>;
|
|
610
|
-
/**
|
|
611
|
-
* Get the matching node in the branch of the document before a location.
|
|
612
|
-
*/
|
|
613
|
-
previous: <T$1 extends Node$1>(editor: Editor$1, options?: EditorPreviousOptions<T$1>) => NodeEntry<T$1> | undefined;
|
|
614
|
-
/**
|
|
615
|
-
* Get a range of a location.
|
|
616
|
-
*/
|
|
617
|
-
range: (editor: Editor$1, at: Location, to?: Location) => Range;
|
|
618
|
-
/**
|
|
619
|
-
* Create a mutable ref for a `Range` object, which will stay in sync as new
|
|
620
|
-
* operations are applied to the editor.
|
|
621
|
-
*/
|
|
622
|
-
rangeRef: (editor: Editor$1, range: Range, options?: EditorRangeRefOptions) => RangeRef;
|
|
623
|
-
/**
|
|
624
|
-
* Get the set of currently tracked range refs of the editor.
|
|
625
|
-
*/
|
|
626
|
-
rangeRefs: (editor: Editor$1) => Set<RangeRef>;
|
|
627
|
-
/**
|
|
628
|
-
* Remove a custom property from all of the leaf text nodes in the current
|
|
629
|
-
* selection.
|
|
630
|
-
*
|
|
631
|
-
* If the selection is currently collapsed, the removal will be stored on
|
|
632
|
-
* `editor.marks` and applied to the text inserted next.
|
|
633
|
-
*/
|
|
634
|
-
removeMark: (editor: Editor$1, key: string) => void;
|
|
635
|
-
/**
|
|
636
|
-
* Manually set if the editor should currently be normalizing.
|
|
637
|
-
*
|
|
638
|
-
* Note: Using this incorrectly can leave the editor in an invalid state.
|
|
639
|
-
*
|
|
640
|
-
*/
|
|
641
|
-
setNormalizing: (editor: Editor$1, isNormalizing: boolean) => void;
|
|
642
|
-
/**
|
|
643
|
-
* Get the start point of a location.
|
|
644
|
-
*/
|
|
645
|
-
start: (editor: Editor$1, at: Location) => Point;
|
|
646
|
-
/**
|
|
647
|
-
* Get the text string content of a location.
|
|
648
|
-
*
|
|
649
|
-
* Note: by default the text of void nodes is considered to be an empty
|
|
650
|
-
* string, regardless of content, unless you pass in true for the voids option
|
|
651
|
-
*/
|
|
652
|
-
string: (editor: Editor$1, at: Location, options?: EditorStringOptions) => string;
|
|
653
|
-
/**
|
|
654
|
-
* Convert a range into a non-hanging one.
|
|
655
|
-
*/
|
|
656
|
-
unhangRange: (editor: Editor$1, range: Range, options?: EditorUnhangRangeOptions) => Range;
|
|
657
|
-
/**
|
|
658
|
-
* Match a void node in the current branch of the editor.
|
|
659
|
-
*/
|
|
660
|
-
void: (editor: Editor$1, options?: EditorVoidOptions) => NodeEntry<Element$1> | undefined;
|
|
661
|
-
/**
|
|
662
|
-
* Call a function, deferring normalization until after it completes.
|
|
663
|
-
*/
|
|
664
|
-
withoutNormalizing: (editor: Editor$1, fn: () => void) => void;
|
|
665
|
-
/**
|
|
666
|
-
* Call a function, Determine whether or not remove the previous node when merge.
|
|
667
|
-
*/
|
|
668
|
-
shouldMergeNodesRemovePrevNode: (editor: Editor$1, prevNodeEntry: NodeEntry, curNodeEntry: NodeEntry) => boolean;
|
|
669
|
-
}
|
|
670
|
-
declare const Editor$1: EditorInterface;
|
|
671
|
-
/**
|
|
672
|
-
* A helper type for narrowing matched nodes with a predicate.
|
|
673
|
-
*/
|
|
674
|
-
type NodeMatch<T$1 extends Node$1> = ((node: Node$1, path: Path$1) => node is T$1) | ((node: Node$1, path: Path$1) => boolean);
|
|
675
|
-
type PropsCompare = (prop: Partial<Node$1>, node: Partial<Node$1>) => boolean;
|
|
676
|
-
type PropsMerge = (prop: Partial<Node$1>, node: Partial<Node$1>) => object;
|
|
677
|
-
type OmitFirstArg<F> = F extends ((x: any, ...args: infer P) => infer R) ? (...args: P) => R : never;
|
|
678
|
-
/**
|
|
679
|
-
* `Element` objects are a type of node in a Slate document that contain other
|
|
680
|
-
* element nodes or text nodes. They can be either "blocks" or "inlines"
|
|
681
|
-
* depending on the Slate editor's configuration.
|
|
682
|
-
*/
|
|
683
|
-
interface BaseElement {
|
|
684
|
-
children: Descendant[];
|
|
685
|
-
}
|
|
686
|
-
type Element$1 = ExtendedType<'Element', BaseElement>;
|
|
687
|
-
interface ElementIsElementOptions {
|
|
688
|
-
deep?: boolean;
|
|
689
|
-
}
|
|
690
|
-
interface ElementInterface {
|
|
691
|
-
/**
|
|
692
|
-
* Check if a value implements the 'Ancestor' interface.
|
|
693
|
-
*/
|
|
694
|
-
isAncestor: (value: any, options?: ElementIsElementOptions) => value is Ancestor;
|
|
695
|
-
/**
|
|
696
|
-
* Check if a value implements the `Element` interface.
|
|
697
|
-
*/
|
|
698
|
-
isElement: (value: any, options?: ElementIsElementOptions) => value is Element$1;
|
|
699
|
-
/**
|
|
700
|
-
* Check if a value is an array of `Element` objects.
|
|
701
|
-
*/
|
|
702
|
-
isElementList: (value: any, options?: ElementIsElementOptions) => value is Element$1[];
|
|
703
|
-
/**
|
|
704
|
-
* Check if a set of props is a partial of Element.
|
|
705
|
-
*/
|
|
706
|
-
isElementProps: (props: any) => props is Partial<Element$1>;
|
|
707
|
-
/**
|
|
708
|
-
* Check if a value implements the `Element` interface and has elementKey with selected value.
|
|
709
|
-
* Default it check to `type` key value
|
|
710
|
-
*/
|
|
711
|
-
isElementType: <T$1 extends Element$1>(value: any, elementVal: string, elementKey?: string) => value is T$1;
|
|
712
|
-
/**
|
|
713
|
-
* Check if an element matches set of properties.
|
|
714
|
-
*
|
|
715
|
-
* Note: this checks custom properties, and it does not ensure that any
|
|
716
|
-
* children are equivalent.
|
|
717
|
-
*/
|
|
718
|
-
matches: (element: Element$1, props: Partial<Element$1>) => boolean;
|
|
719
|
-
}
|
|
720
|
-
declare const Element$1: ElementInterface;
|
|
721
|
-
/**
|
|
722
|
-
* `ElementEntry` objects refer to an `Element` and the `Path` where it can be
|
|
723
|
-
* found inside a root node.
|
|
724
|
-
*/
|
|
725
|
-
type ElementEntry = [Element$1, Path$1];
|
|
726
|
-
/**
|
|
727
|
-
* The `Location` interface is a union of the ways to refer to a specific
|
|
728
|
-
* location in a Slate document: paths, points or ranges.
|
|
729
|
-
*
|
|
730
|
-
* Methods will often accept a `Location` instead of requiring only a `Path`,
|
|
731
|
-
* `Point` or `Range`. This eliminates the need for developers to manage
|
|
732
|
-
* converting between the different interfaces in their own code base.
|
|
733
|
-
*/
|
|
734
|
-
type Location = Path$1 | Point | Range;
|
|
735
|
-
interface LocationInterface {
|
|
736
|
-
/**
|
|
737
|
-
* Check if a value implements the `Location` interface.
|
|
738
|
-
*/
|
|
739
|
-
isLocation: (value: any) => value is Location;
|
|
740
|
-
}
|
|
741
|
-
declare const Location: LocationInterface;
|
|
742
|
-
/**
|
|
743
|
-
* The `Span` interface is a low-level way to refer to locations in nodes
|
|
744
|
-
* without using `Point` which requires leaf text nodes to be present.
|
|
745
|
-
*/
|
|
746
|
-
type Span = [Path$1, Path$1];
|
|
747
|
-
interface SpanInterface {
|
|
748
|
-
/**
|
|
749
|
-
* Check if a value implements the `Span` interface.
|
|
750
|
-
*/
|
|
751
|
-
isSpan: (value: any) => value is Span;
|
|
752
|
-
}
|
|
753
|
-
declare const Span: SpanInterface;
|
|
754
|
-
type Node$1 = Editor$1 | Element$1 | Text;
|
|
755
|
-
interface NodeAncestorsOptions {
|
|
756
|
-
reverse?: boolean;
|
|
757
|
-
}
|
|
758
|
-
interface NodeChildrenOptions {
|
|
759
|
-
reverse?: boolean;
|
|
760
|
-
}
|
|
761
|
-
interface NodeDescendantsOptions {
|
|
762
|
-
from?: Path$1;
|
|
763
|
-
to?: Path$1;
|
|
764
|
-
reverse?: boolean;
|
|
765
|
-
pass?: (node: NodeEntry) => boolean;
|
|
766
|
-
}
|
|
767
|
-
interface NodeElementsOptions {
|
|
768
|
-
from?: Path$1;
|
|
769
|
-
to?: Path$1;
|
|
770
|
-
reverse?: boolean;
|
|
771
|
-
pass?: (node: NodeEntry) => boolean;
|
|
772
|
-
}
|
|
773
|
-
interface NodeIsNodeOptions {
|
|
774
|
-
deep?: boolean;
|
|
775
|
-
}
|
|
776
|
-
interface NodeLevelsOptions {
|
|
777
|
-
reverse?: boolean;
|
|
778
|
-
}
|
|
779
|
-
interface NodeNodesOptions {
|
|
780
|
-
from?: Path$1;
|
|
781
|
-
to?: Path$1;
|
|
782
|
-
reverse?: boolean;
|
|
783
|
-
pass?: (entry: NodeEntry) => boolean;
|
|
784
|
-
}
|
|
785
|
-
interface NodeTextsOptions {
|
|
786
|
-
from?: Path$1;
|
|
787
|
-
to?: Path$1;
|
|
788
|
-
reverse?: boolean;
|
|
789
|
-
pass?: (node: NodeEntry) => boolean;
|
|
790
|
-
}
|
|
791
|
-
interface NodeInterface {
|
|
792
|
-
/**
|
|
793
|
-
* Get the node at a specific path, asserting that it's an ancestor node.
|
|
794
|
-
*/
|
|
795
|
-
ancestor: (root: Node$1, path: Path$1) => Ancestor;
|
|
796
|
-
/**
|
|
797
|
-
* Return a generator of all the ancestor nodes above a specific path.
|
|
798
|
-
*
|
|
799
|
-
* By default the order is top-down, from highest to lowest ancestor in
|
|
800
|
-
* the tree, but you can pass the `reverse: true` option to go bottom-up.
|
|
801
|
-
*/
|
|
802
|
-
ancestors: (root: Node$1, path: Path$1, options?: NodeAncestorsOptions) => Generator<NodeEntry<Ancestor>, void, undefined>;
|
|
803
|
-
/**
|
|
804
|
-
* Get the child of a node at a specific index.
|
|
805
|
-
*/
|
|
806
|
-
child: (root: Node$1, index: number) => Descendant;
|
|
807
|
-
/**
|
|
808
|
-
* Iterate over the children of a node at a specific path.
|
|
809
|
-
*/
|
|
810
|
-
children: (root: Node$1, path: Path$1, options?: NodeChildrenOptions) => Generator<NodeEntry<Descendant>, void, undefined>;
|
|
811
|
-
/**
|
|
812
|
-
* Get an entry for the common ancesetor node of two paths.
|
|
813
|
-
*/
|
|
814
|
-
common: (root: Node$1, path: Path$1, another: Path$1) => NodeEntry;
|
|
815
|
-
/**
|
|
816
|
-
* Get the node at a specific path, asserting that it's a descendant node.
|
|
817
|
-
*/
|
|
818
|
-
descendant: (root: Node$1, path: Path$1) => Descendant;
|
|
819
|
-
/**
|
|
820
|
-
* Return a generator of all the descendant node entries inside a root node.
|
|
821
|
-
*/
|
|
822
|
-
descendants: (root: Node$1, options?: NodeDescendantsOptions) => Generator<NodeEntry<Descendant>, void, undefined>;
|
|
823
|
-
/**
|
|
824
|
-
* Return a generator of all the element nodes inside a root node. Each iteration
|
|
825
|
-
* will return an `ElementEntry` tuple consisting of `[Element, Path]`. If the
|
|
826
|
-
* root node is an element it will be included in the iteration as well.
|
|
827
|
-
*/
|
|
828
|
-
elements: (root: Node$1, options?: NodeElementsOptions) => Generator<ElementEntry, void, undefined>;
|
|
829
|
-
/**
|
|
830
|
-
* Extract props from a Node.
|
|
831
|
-
*/
|
|
832
|
-
extractProps: (node: Node$1) => NodeProps;
|
|
833
|
-
/**
|
|
834
|
-
* Get the first leaf node entry in a root node from a path.
|
|
835
|
-
*/
|
|
836
|
-
first: (root: Node$1, path: Path$1) => NodeEntry;
|
|
837
|
-
/**
|
|
838
|
-
* Get the sliced fragment represented by a range inside a root node.
|
|
839
|
-
*/
|
|
840
|
-
fragment: <T$1 extends Ancestor = Editor$1>(root: T$1, range: Range) => T$1['children'];
|
|
841
|
-
/**
|
|
842
|
-
* Get the descendant node referred to by a specific path. If the path is an
|
|
843
|
-
* empty array, it refers to the root node itself.
|
|
844
|
-
*/
|
|
845
|
-
get: (root: Node$1, path: Path$1) => Node$1;
|
|
846
|
-
/**
|
|
847
|
-
* Similar to get, but returns undefined if the node does not exist.
|
|
848
|
-
*/
|
|
849
|
-
getIf: (root: Node$1, path: Path$1) => Node$1 | undefined;
|
|
850
|
-
/**
|
|
851
|
-
* Check if a descendant node exists at a specific path.
|
|
852
|
-
*/
|
|
853
|
-
has: (root: Node$1, path: Path$1) => boolean;
|
|
854
|
-
/**
|
|
855
|
-
* Check if a value implements the `Node` interface.
|
|
856
|
-
*/
|
|
857
|
-
isNode: (value: any, options?: NodeIsNodeOptions) => value is Node$1;
|
|
858
|
-
/**
|
|
859
|
-
* Check if a value is a list of `Node` objects.
|
|
860
|
-
*/
|
|
861
|
-
isNodeList: (value: any, options?: NodeIsNodeOptions) => value is Node$1[];
|
|
862
|
-
/**
|
|
863
|
-
* Get the last leaf node entry in a root node from a path.
|
|
864
|
-
*/
|
|
865
|
-
last: (root: Node$1, path: Path$1) => NodeEntry;
|
|
866
|
-
/**
|
|
867
|
-
* Get the node at a specific path, ensuring it's a leaf text node.
|
|
868
|
-
*/
|
|
869
|
-
leaf: (root: Node$1, path: Path$1) => Text;
|
|
870
|
-
/**
|
|
871
|
-
* Return a generator of the in a branch of the tree, from a specific path.
|
|
872
|
-
*
|
|
873
|
-
* By default the order is top-down, from highest to lowest node in the tree,
|
|
874
|
-
* but you can pass the `reverse: true` option to go bottom-up.
|
|
875
|
-
*/
|
|
876
|
-
levels: (root: Node$1, path: Path$1, options?: NodeLevelsOptions) => Generator<NodeEntry, void, undefined>;
|
|
877
|
-
/**
|
|
878
|
-
* Check if a node matches a set of props.
|
|
879
|
-
*/
|
|
880
|
-
matches: (node: Node$1, props: Partial<Node$1>) => boolean;
|
|
881
|
-
/**
|
|
882
|
-
* Return a generator of all the node entries of a root node. Each entry is
|
|
883
|
-
* returned as a `[Node, Path]` tuple, with the path referring to the node's
|
|
884
|
-
* position inside the root node.
|
|
885
|
-
*/
|
|
886
|
-
nodes: (root: Node$1, options?: NodeNodesOptions) => Generator<NodeEntry, void, undefined>;
|
|
887
|
-
/**
|
|
888
|
-
* Get the parent of a node at a specific path.
|
|
889
|
-
*/
|
|
890
|
-
parent: (root: Node$1, path: Path$1) => Ancestor;
|
|
891
|
-
/**
|
|
892
|
-
* Get the concatenated text string of a node's content.
|
|
893
|
-
*
|
|
894
|
-
* Note that this will not include spaces or line breaks between block nodes.
|
|
895
|
-
* It is not a user-facing string, but a string for performing offset-related
|
|
896
|
-
* computations for a node.
|
|
897
|
-
*/
|
|
898
|
-
string: (node: Node$1) => string;
|
|
899
|
-
/**
|
|
900
|
-
* Return a generator of all leaf text nodes in a root node.
|
|
901
|
-
*/
|
|
902
|
-
texts: (root: Node$1, options?: NodeTextsOptions) => Generator<NodeEntry<Text>, void, undefined>;
|
|
903
|
-
}
|
|
904
|
-
declare const Node$1: NodeInterface;
|
|
905
|
-
/**
|
|
906
|
-
* The `Descendant` union type represents nodes that are descendants in the
|
|
907
|
-
* tree. It is returned as a convenience in certain cases to narrow a value
|
|
908
|
-
* further than the more generic `Node` union.
|
|
909
|
-
*/
|
|
910
|
-
type Descendant = Element$1 | Text;
|
|
911
|
-
/**
|
|
912
|
-
* The `Ancestor` union type represents nodes that are ancestors in the tree.
|
|
913
|
-
* It is returned as a convenience in certain cases to narrow a value further
|
|
914
|
-
* than the more generic `Node` union.
|
|
915
|
-
*/
|
|
916
|
-
type Ancestor = Editor$1 | Element$1;
|
|
917
|
-
/**
|
|
918
|
-
* `NodeEntry` objects are returned when iterating over the nodes in a Slate
|
|
919
|
-
* document tree. They consist of the node and its `Path` relative to the root
|
|
920
|
-
* node in the document.
|
|
921
|
-
*/
|
|
922
|
-
type NodeEntry<T$1 extends Node$1 = Node$1> = [T$1, Path$1];
|
|
923
|
-
/**
|
|
924
|
-
* Convenience type for returning the props of a node.
|
|
925
|
-
*/
|
|
926
|
-
type NodeProps = Omit<Editor$1, 'children'> | Omit<Element$1, 'children'> | Omit<Text, 'text'>;
|
|
927
|
-
type BaseInsertNodeOperation = {
|
|
928
|
-
type: 'insert_node';
|
|
929
|
-
path: Path$1;
|
|
930
|
-
node: Node$1;
|
|
931
|
-
};
|
|
932
|
-
type InsertNodeOperation = ExtendedType<'InsertNodeOperation', BaseInsertNodeOperation>;
|
|
933
|
-
type BaseInsertTextOperation = {
|
|
934
|
-
type: 'insert_text';
|
|
935
|
-
path: Path$1;
|
|
936
|
-
offset: number;
|
|
937
|
-
text: string;
|
|
938
|
-
};
|
|
939
|
-
type InsertTextOperation = ExtendedType<'InsertTextOperation', BaseInsertTextOperation>;
|
|
940
|
-
type BaseMergeNodeOperation = {
|
|
941
|
-
type: 'merge_node';
|
|
942
|
-
path: Path$1;
|
|
943
|
-
position: number;
|
|
944
|
-
properties: Partial<Node$1>;
|
|
945
|
-
};
|
|
946
|
-
type MergeNodeOperation = ExtendedType<'MergeNodeOperation', BaseMergeNodeOperation>;
|
|
947
|
-
type BaseMoveNodeOperation = {
|
|
948
|
-
type: 'move_node';
|
|
949
|
-
path: Path$1;
|
|
950
|
-
newPath: Path$1;
|
|
951
|
-
};
|
|
952
|
-
type MoveNodeOperation = ExtendedType<'MoveNodeOperation', BaseMoveNodeOperation>;
|
|
953
|
-
type BaseRemoveNodeOperation = {
|
|
954
|
-
type: 'remove_node';
|
|
955
|
-
path: Path$1;
|
|
956
|
-
node: Node$1;
|
|
957
|
-
};
|
|
958
|
-
type RemoveNodeOperation = ExtendedType<'RemoveNodeOperation', BaseRemoveNodeOperation>;
|
|
959
|
-
type BaseRemoveTextOperation = {
|
|
960
|
-
type: 'remove_text';
|
|
961
|
-
path: Path$1;
|
|
962
|
-
offset: number;
|
|
963
|
-
text: string;
|
|
964
|
-
};
|
|
965
|
-
type RemoveTextOperation = ExtendedType<'RemoveTextOperation', BaseRemoveTextOperation>;
|
|
966
|
-
type BaseSetNodeOperation = {
|
|
967
|
-
type: 'set_node';
|
|
968
|
-
path: Path$1;
|
|
969
|
-
properties: Partial<Node$1>;
|
|
970
|
-
newProperties: Partial<Node$1>;
|
|
971
|
-
};
|
|
972
|
-
type SetNodeOperation = ExtendedType<'SetNodeOperation', BaseSetNodeOperation>;
|
|
973
|
-
type BaseSetSelectionOperation = {
|
|
974
|
-
type: 'set_selection';
|
|
975
|
-
properties: null;
|
|
976
|
-
newProperties: Range;
|
|
977
|
-
} | {
|
|
978
|
-
type: 'set_selection';
|
|
979
|
-
properties: Partial<Range>;
|
|
980
|
-
newProperties: Partial<Range>;
|
|
981
|
-
} | {
|
|
982
|
-
type: 'set_selection';
|
|
983
|
-
properties: Range;
|
|
984
|
-
newProperties: null;
|
|
985
|
-
};
|
|
986
|
-
type SetSelectionOperation = ExtendedType<'SetSelectionOperation', BaseSetSelectionOperation>;
|
|
987
|
-
type BaseSplitNodeOperation = {
|
|
988
|
-
type: 'split_node';
|
|
989
|
-
path: Path$1;
|
|
990
|
-
position: number;
|
|
991
|
-
properties: Partial<Node$1>;
|
|
992
|
-
};
|
|
993
|
-
type SplitNodeOperation = ExtendedType<'SplitNodeOperation', BaseSplitNodeOperation>;
|
|
994
|
-
type NodeOperation = InsertNodeOperation | MergeNodeOperation | MoveNodeOperation | RemoveNodeOperation | SetNodeOperation | SplitNodeOperation;
|
|
995
|
-
type SelectionOperation = SetSelectionOperation;
|
|
996
|
-
type TextOperation = InsertTextOperation | RemoveTextOperation;
|
|
997
|
-
/**
|
|
998
|
-
* `Operation` objects define the low-level instructions that Slate editors use
|
|
999
|
-
* to apply changes to their internal state. Representing all changes as
|
|
1000
|
-
* operations is what allows Slate editors to easily implement history,
|
|
1001
|
-
* collaboration, and other features.
|
|
1002
|
-
*/
|
|
1003
|
-
type BaseOperation = NodeOperation | SelectionOperation | TextOperation;
|
|
1004
|
-
type Operation = ExtendedType<'Operation', BaseOperation>;
|
|
1005
|
-
interface OperationInterface {
|
|
1006
|
-
/**
|
|
1007
|
-
* Check if a value is a `NodeOperation` object.
|
|
1008
|
-
*/
|
|
1009
|
-
isNodeOperation: (value: any) => value is NodeOperation;
|
|
1010
|
-
/**
|
|
1011
|
-
* Check if a value is an `Operation` object.
|
|
1012
|
-
*/
|
|
1013
|
-
isOperation: (value: any) => value is Operation;
|
|
1014
|
-
/**
|
|
1015
|
-
* Check if a value is a list of `Operation` objects.
|
|
1016
|
-
*/
|
|
1017
|
-
isOperationList: (value: any) => value is Operation[];
|
|
1018
|
-
/**
|
|
1019
|
-
* Check if a value is a `SelectionOperation` object.
|
|
1020
|
-
*/
|
|
1021
|
-
isSelectionOperation: (value: any) => value is SelectionOperation;
|
|
1022
|
-
/**
|
|
1023
|
-
* Check if a value is a `TextOperation` object.
|
|
1024
|
-
*/
|
|
1025
|
-
isTextOperation: (value: any) => value is TextOperation;
|
|
1026
|
-
/**
|
|
1027
|
-
* Invert an operation, returning a new operation that will exactly undo the
|
|
1028
|
-
* original when applied.
|
|
1029
|
-
*/
|
|
1030
|
-
inverse: (op: Operation) => Operation;
|
|
1031
|
-
}
|
|
1032
|
-
declare const Operation: OperationInterface;
|
|
1033
|
-
/**
|
|
1034
|
-
* `PathRef` objects keep a specific path in a document synced over time as new
|
|
1035
|
-
* operations are applied to the editor. You can access their `current` property
|
|
1036
|
-
* at any time for the up-to-date path value.
|
|
1037
|
-
*/
|
|
1038
|
-
interface PathRef {
|
|
1039
|
-
current: Path$1 | null;
|
|
1040
|
-
affinity: 'forward' | 'backward' | null;
|
|
1041
|
-
unref(): Path$1 | null;
|
|
1042
|
-
}
|
|
1043
|
-
interface PathRefInterface {
|
|
1044
|
-
/**
|
|
1045
|
-
* Transform the path ref's current value by an operation.
|
|
1046
|
-
*/
|
|
1047
|
-
transform: (ref: PathRef, op: Operation) => void;
|
|
1048
|
-
}
|
|
1049
|
-
declare const PathRef: PathRefInterface;
|
|
1050
|
-
/**
|
|
1051
|
-
* `Path` arrays are a list of indexes that describe a node's exact position in
|
|
1052
|
-
* a Slate node tree. Although they are usually relative to the root `Editor`
|
|
1053
|
-
* object, they can be relative to any `Node` object.
|
|
1054
|
-
*/
|
|
1055
|
-
type Path$1 = number[];
|
|
1056
|
-
interface PathAncestorsOptions {
|
|
1057
|
-
reverse?: boolean;
|
|
1058
|
-
}
|
|
1059
|
-
interface PathLevelsOptions {
|
|
1060
|
-
reverse?: boolean;
|
|
1061
|
-
}
|
|
1062
|
-
interface PathTransformOptions {
|
|
1063
|
-
affinity?: TextDirection | null;
|
|
1064
|
-
}
|
|
1065
|
-
interface PathInterface {
|
|
1066
|
-
/**
|
|
1067
|
-
* Get a list of ancestor paths for a given path.
|
|
1068
|
-
*
|
|
1069
|
-
* The paths are sorted from shallowest to deepest ancestor. However, if the
|
|
1070
|
-
* `reverse: true` option is passed, they are reversed.
|
|
1071
|
-
*/
|
|
1072
|
-
ancestors: (path: Path$1, options?: PathAncestorsOptions) => Path$1[];
|
|
1073
|
-
/**
|
|
1074
|
-
* Get the common ancestor path of two paths.
|
|
1075
|
-
*/
|
|
1076
|
-
common: (path: Path$1, another: Path$1) => Path$1;
|
|
1077
|
-
/**
|
|
1078
|
-
* Compare a path to another, returning an integer indicating whether the path
|
|
1079
|
-
* was before, at, or after the other.
|
|
1080
|
-
*
|
|
1081
|
-
* Note: Two paths of unequal length can still receive a `0` result if one is
|
|
1082
|
-
* directly above or below the other. If you want exact matching, use
|
|
1083
|
-
* [[Path.equals]] instead.
|
|
1084
|
-
*/
|
|
1085
|
-
compare: (path: Path$1, another: Path$1) => -1 | 0 | 1;
|
|
1086
|
-
/**
|
|
1087
|
-
* Check if a path ends after one of the indexes in another.
|
|
1088
|
-
*/
|
|
1089
|
-
endsAfter: (path: Path$1, another: Path$1) => boolean;
|
|
1090
|
-
/**
|
|
1091
|
-
* Check if a path ends at one of the indexes in another.
|
|
1092
|
-
*/
|
|
1093
|
-
endsAt: (path: Path$1, another: Path$1) => boolean;
|
|
1094
|
-
/**
|
|
1095
|
-
* Check if a path ends before one of the indexes in another.
|
|
1096
|
-
*/
|
|
1097
|
-
endsBefore: (path: Path$1, another: Path$1) => boolean;
|
|
1098
|
-
/**
|
|
1099
|
-
* Check if a path is exactly equal to another.
|
|
1100
|
-
*/
|
|
1101
|
-
equals: (path: Path$1, another: Path$1) => boolean;
|
|
1102
|
-
/**
|
|
1103
|
-
* Check if the path of previous sibling node exists
|
|
1104
|
-
*/
|
|
1105
|
-
hasPrevious: (path: Path$1) => boolean;
|
|
1106
|
-
/**
|
|
1107
|
-
* Check if a path is after another.
|
|
1108
|
-
*/
|
|
1109
|
-
isAfter: (path: Path$1, another: Path$1) => boolean;
|
|
1110
|
-
/**
|
|
1111
|
-
* Check if a path is an ancestor of another.
|
|
1112
|
-
*/
|
|
1113
|
-
isAncestor: (path: Path$1, another: Path$1) => boolean;
|
|
1114
|
-
/**
|
|
1115
|
-
* Check if a path is before another.
|
|
1116
|
-
*/
|
|
1117
|
-
isBefore: (path: Path$1, another: Path$1) => boolean;
|
|
1118
|
-
/**
|
|
1119
|
-
* Check if a path is a child of another.
|
|
1120
|
-
*/
|
|
1121
|
-
isChild: (path: Path$1, another: Path$1) => boolean;
|
|
1122
|
-
/**
|
|
1123
|
-
* Check if a path is equal to or an ancestor of another.
|
|
1124
|
-
*/
|
|
1125
|
-
isCommon: (path: Path$1, another: Path$1) => boolean;
|
|
1126
|
-
/**
|
|
1127
|
-
* Check if a path is a descendant of another.
|
|
1128
|
-
*/
|
|
1129
|
-
isDescendant: (path: Path$1, another: Path$1) => boolean;
|
|
1130
|
-
/**
|
|
1131
|
-
* Check if a path is the parent of another.
|
|
1132
|
-
*/
|
|
1133
|
-
isParent: (path: Path$1, another: Path$1) => boolean;
|
|
1134
|
-
/**
|
|
1135
|
-
* Check is a value implements the `Path` interface.
|
|
1136
|
-
*/
|
|
1137
|
-
isPath: (value: any) => value is Path$1;
|
|
1138
|
-
/**
|
|
1139
|
-
* Check if a path is a sibling of another.
|
|
1140
|
-
*/
|
|
1141
|
-
isSibling: (path: Path$1, another: Path$1) => boolean;
|
|
1142
|
-
/**
|
|
1143
|
-
* Get a list of paths at every level down to a path. Note: this is the same
|
|
1144
|
-
* as `Path.ancestors`, but including the path itself.
|
|
1145
|
-
*
|
|
1146
|
-
* The paths are sorted from shallowest to deepest. However, if the `reverse:
|
|
1147
|
-
* true` option is passed, they are reversed.
|
|
1148
|
-
*/
|
|
1149
|
-
levels: (path: Path$1, options?: PathLevelsOptions) => Path$1[];
|
|
1150
|
-
/**
|
|
1151
|
-
* Given a path, get the path to the next sibling node.
|
|
1152
|
-
*/
|
|
1153
|
-
next: (path: Path$1) => Path$1;
|
|
1154
|
-
/**
|
|
1155
|
-
* Returns whether this operation can affect paths or not. Used as an
|
|
1156
|
-
* optimization when updating dirty paths during normalization
|
|
1157
|
-
*
|
|
1158
|
-
* NOTE: This *must* be kept in sync with the implementation of 'transform'
|
|
1159
|
-
* below
|
|
1160
|
-
*/
|
|
1161
|
-
operationCanTransformPath: (operation: Operation) => operation is InsertNodeOperation | RemoveNodeOperation | MergeNodeOperation | SplitNodeOperation | MoveNodeOperation;
|
|
1162
|
-
/**
|
|
1163
|
-
* Given a path, return a new path referring to the parent node above it.
|
|
1164
|
-
*/
|
|
1165
|
-
parent: (path: Path$1) => Path$1;
|
|
1166
|
-
/**
|
|
1167
|
-
* Given a path, get the path to the previous sibling node.
|
|
1168
|
-
*/
|
|
1169
|
-
previous: (path: Path$1) => Path$1;
|
|
1170
|
-
/**
|
|
1171
|
-
* Get a path relative to an ancestor.
|
|
1172
|
-
*/
|
|
1173
|
-
relative: (path: Path$1, ancestor: Path$1) => Path$1;
|
|
1174
|
-
/**
|
|
1175
|
-
* Transform a path by an operation.
|
|
1176
|
-
*/
|
|
1177
|
-
transform: (path: Path$1, operation: Operation, options?: PathTransformOptions) => Path$1 | null;
|
|
1178
|
-
}
|
|
1179
|
-
declare const Path$1: PathInterface;
|
|
1180
|
-
/**
|
|
1181
|
-
* `PointRef` objects keep a specific point in a document synced over time as new
|
|
1182
|
-
* operations are applied to the editor. You can access their `current` property
|
|
1183
|
-
* at any time for the up-to-date point value.
|
|
1184
|
-
*/
|
|
1185
|
-
interface PointRef {
|
|
1186
|
-
current: Point | null;
|
|
1187
|
-
affinity: TextDirection | null;
|
|
1188
|
-
unref(): Point | null;
|
|
1189
|
-
}
|
|
1190
|
-
interface PointRefInterface {
|
|
1191
|
-
/**
|
|
1192
|
-
* Transform the point ref's current value by an operation.
|
|
1193
|
-
*/
|
|
1194
|
-
transform: (ref: PointRef, op: Operation) => void;
|
|
1195
|
-
}
|
|
1196
|
-
declare const PointRef: PointRefInterface;
|
|
1197
|
-
/**
|
|
1198
|
-
* `Point` objects refer to a specific location in a text node in a Slate
|
|
1199
|
-
* document. Its path refers to the location of the node in the tree, and its
|
|
1200
|
-
* offset refers to the distance into the node's string of text. Points can
|
|
1201
|
-
* only refer to `Text` nodes.
|
|
1202
|
-
*/
|
|
1203
|
-
interface BasePoint {
|
|
1204
|
-
path: Path$1;
|
|
1205
|
-
offset: number;
|
|
1206
|
-
}
|
|
1207
|
-
type Point = ExtendedType<'Point', BasePoint>;
|
|
1208
|
-
interface PointTransformOptions {
|
|
1209
|
-
affinity?: TextDirection | null;
|
|
1210
|
-
}
|
|
1211
|
-
interface PointInterface {
|
|
1212
|
-
/**
|
|
1213
|
-
* Compare a point to another, returning an integer indicating whether the
|
|
1214
|
-
* point was before, at, or after the other.
|
|
1215
|
-
*/
|
|
1216
|
-
compare: (point: Point, another: Point) => -1 | 0 | 1;
|
|
1217
|
-
/**
|
|
1218
|
-
* Check if a point is after another.
|
|
1219
|
-
*/
|
|
1220
|
-
isAfter: (point: Point, another: Point) => boolean;
|
|
1221
|
-
/**
|
|
1222
|
-
* Check if a point is before another.
|
|
1223
|
-
*/
|
|
1224
|
-
isBefore: (point: Point, another: Point) => boolean;
|
|
1225
|
-
/**
|
|
1226
|
-
* Check if a point is exactly equal to another.
|
|
1227
|
-
*/
|
|
1228
|
-
equals: (point: Point, another: Point) => boolean;
|
|
1229
|
-
/**
|
|
1230
|
-
* Check if a value implements the `Point` interface.
|
|
1231
|
-
*/
|
|
1232
|
-
isPoint: (value: any) => value is Point;
|
|
1233
|
-
/**
|
|
1234
|
-
* Transform a point by an operation.
|
|
1235
|
-
*/
|
|
1236
|
-
transform: (point: Point, op: Operation, options?: PointTransformOptions) => Point | null;
|
|
1237
|
-
}
|
|
1238
|
-
declare const Point: PointInterface;
|
|
1239
|
-
/**
|
|
1240
|
-
* `PointEntry` objects are returned when iterating over `Point` objects that
|
|
1241
|
-
* belong to a range.
|
|
1242
|
-
*/
|
|
1243
|
-
type PointEntry = [Point, 'anchor' | 'focus'];
|
|
1244
|
-
/**
|
|
1245
|
-
* `RangeRef` objects keep a specific range in a document synced over time as new
|
|
1246
|
-
* operations are applied to the editor. You can access their `current` property
|
|
1247
|
-
* at any time for the up-to-date range value.
|
|
1248
|
-
*/
|
|
1249
|
-
interface RangeRef {
|
|
1250
|
-
current: Range | null;
|
|
1251
|
-
affinity: 'forward' | 'backward' | 'outward' | 'inward' | null;
|
|
1252
|
-
unref(): Range | null;
|
|
1253
|
-
}
|
|
1254
|
-
interface RangeRefInterface {
|
|
1255
|
-
/**
|
|
1256
|
-
* Transform the range ref's current value by an operation.
|
|
1257
|
-
*/
|
|
1258
|
-
transform: (ref: RangeRef, op: Operation) => void;
|
|
1259
|
-
}
|
|
1260
|
-
declare const RangeRef: RangeRefInterface;
|
|
1261
|
-
/**
|
|
1262
|
-
* `Range` objects are a set of points that refer to a specific span of a Slate
|
|
1263
|
-
* document. They can define a span inside a single node or a can span across
|
|
1264
|
-
* multiple nodes.
|
|
1265
|
-
*/
|
|
1266
|
-
interface BaseRange {
|
|
1267
|
-
anchor: Point;
|
|
1268
|
-
focus: Point;
|
|
1269
|
-
}
|
|
1270
|
-
type Range = ExtendedType<'Range', BaseRange>;
|
|
1271
|
-
interface RangeEdgesOptions {
|
|
1272
|
-
reverse?: boolean;
|
|
1273
|
-
}
|
|
1274
|
-
interface RangeTransformOptions {
|
|
1275
|
-
affinity?: RangeDirection | null;
|
|
1276
|
-
}
|
|
1277
|
-
interface RangeInterface {
|
|
1278
|
-
/**
|
|
1279
|
-
* Get the start and end points of a range, in the order in which they appear
|
|
1280
|
-
* in the document.
|
|
1281
|
-
*/
|
|
1282
|
-
edges: (range: Range, options?: RangeEdgesOptions) => [Point, Point];
|
|
1283
|
-
/**
|
|
1284
|
-
* Get the end point of a range.
|
|
1285
|
-
*/
|
|
1286
|
-
end: (range: Range) => Point;
|
|
1287
|
-
/**
|
|
1288
|
-
* Check if a range is exactly equal to another.
|
|
1289
|
-
*/
|
|
1290
|
-
equals: (range: Range, another: Range) => boolean;
|
|
1291
|
-
/**
|
|
1292
|
-
* Check if a range includes a path, a point or part of another range.
|
|
1293
|
-
*/
|
|
1294
|
-
includes: (range: Range, target: Path$1 | Point | Range) => boolean;
|
|
1295
|
-
/**
|
|
1296
|
-
* Check if a range includes another range.
|
|
1297
|
-
*/
|
|
1298
|
-
surrounds: (range: Range, target: Range) => boolean;
|
|
1299
|
-
/**
|
|
1300
|
-
* Get the intersection of a range with another.
|
|
1301
|
-
*/
|
|
1302
|
-
intersection: (range: Range, another: Range) => Range | null;
|
|
1303
|
-
/**
|
|
1304
|
-
* Check if a range is backward, meaning that its anchor point appears in the
|
|
1305
|
-
* document _after_ its focus point.
|
|
1306
|
-
*/
|
|
1307
|
-
isBackward: (range: Range) => boolean;
|
|
1308
|
-
/**
|
|
1309
|
-
* Check if a range is collapsed, meaning that both its anchor and focus
|
|
1310
|
-
* points refer to the exact same position in the document.
|
|
1311
|
-
*/
|
|
1312
|
-
isCollapsed: (range: Range) => boolean;
|
|
1313
|
-
/**
|
|
1314
|
-
* Check if a range is expanded.
|
|
1315
|
-
*
|
|
1316
|
-
* This is the opposite of [[Range.isCollapsed]] and is provided for legibility.
|
|
1317
|
-
*/
|
|
1318
|
-
isExpanded: (range: Range) => boolean;
|
|
1319
|
-
/**
|
|
1320
|
-
* Check if a range is forward.
|
|
1321
|
-
*
|
|
1322
|
-
* This is the opposite of [[Range.isBackward]] and is provided for legibility.
|
|
1323
|
-
*/
|
|
1324
|
-
isForward: (range: Range) => boolean;
|
|
1325
|
-
/**
|
|
1326
|
-
* Check if a value implements the [[Range]] interface.
|
|
1327
|
-
*/
|
|
1328
|
-
isRange: (value: any) => value is Range;
|
|
1329
|
-
/**
|
|
1330
|
-
* Iterate through all of the point entries in a range.
|
|
1331
|
-
*/
|
|
1332
|
-
points: (range: Range) => Generator<PointEntry, void, undefined>;
|
|
1333
|
-
/**
|
|
1334
|
-
* Get the start point of a range.
|
|
1335
|
-
*/
|
|
1336
|
-
start: (range: Range) => Point;
|
|
1337
|
-
/**
|
|
1338
|
-
* Transform a range by an operation.
|
|
1339
|
-
*/
|
|
1340
|
-
transform: (range: Range, op: Operation, options?: RangeTransformOptions) => Range | null;
|
|
1341
|
-
}
|
|
1342
|
-
declare const Range: RangeInterface;
|
|
1343
|
-
/**
|
|
1344
|
-
* Extendable Custom Types Interface
|
|
1345
|
-
*/
|
|
1346
|
-
type ExtendableTypes = 'Editor' | 'Element' | 'Text' | 'Selection' | 'Range' | 'Point' | 'Operation' | 'InsertNodeOperation' | 'InsertTextOperation' | 'MergeNodeOperation' | 'MoveNodeOperation' | 'RemoveNodeOperation' | 'RemoveTextOperation' | 'SetNodeOperation' | 'SetSelectionOperation' | 'SplitNodeOperation';
|
|
1347
|
-
interface CustomTypes {
|
|
1348
|
-
[key: string]: unknown;
|
|
1349
|
-
}
|
|
1350
|
-
type ExtendedType<K$1 extends ExtendableTypes, B> = unknown extends CustomTypes[K$1] ? B : CustomTypes[K$1];
|
|
1351
|
-
/**
|
|
1352
|
-
* `Text` objects represent the nodes that contain the actual text content of a
|
|
1353
|
-
* Slate document along with any formatting properties. They are always leaf
|
|
1354
|
-
* nodes in the document tree as they cannot contain any children.
|
|
1355
|
-
*/
|
|
1356
|
-
interface BaseText {
|
|
1357
|
-
text: string;
|
|
1358
|
-
}
|
|
1359
|
-
type Text = ExtendedType<'Text', BaseText>;
|
|
1360
|
-
interface LeafPosition {
|
|
1361
|
-
start: number;
|
|
1362
|
-
end: number;
|
|
1363
|
-
isFirst?: true;
|
|
1364
|
-
isLast?: true;
|
|
1365
|
-
}
|
|
1366
|
-
interface TextEqualsOptions {
|
|
1367
|
-
loose?: boolean;
|
|
1368
|
-
}
|
|
1369
|
-
type DecoratedRange$1 = Range & {
|
|
1370
|
-
/**
|
|
1371
|
-
* Customize how another decoration is merged into a text node. If not specified, `Object.assign` would be used.
|
|
1372
|
-
* It is useful for overlapping decorations with the same key but different values.
|
|
1373
|
-
*/
|
|
1374
|
-
merge?: (leaf: Text, decoration: object) => void;
|
|
1375
|
-
};
|
|
1376
|
-
interface TextInterface {
|
|
1377
|
-
/**
|
|
1378
|
-
* Check if two text nodes are equal.
|
|
1379
|
-
*
|
|
1380
|
-
* When loose is set, the text is not compared. This is
|
|
1381
|
-
* used to check whether sibling text nodes can be merged.
|
|
1382
|
-
*/
|
|
1383
|
-
equals: (text: Text, another: Text, options?: TextEqualsOptions) => boolean;
|
|
1384
|
-
/**
|
|
1385
|
-
* Check if a value implements the `Text` interface.
|
|
1386
|
-
*/
|
|
1387
|
-
isText: (value: any) => value is Text;
|
|
1388
|
-
/**
|
|
1389
|
-
* Check if a value is a list of `Text` objects.
|
|
1390
|
-
*/
|
|
1391
|
-
isTextList: (value: any) => value is Text[];
|
|
1392
|
-
/**
|
|
1393
|
-
* Check if some props are a partial of Text.
|
|
1394
|
-
*/
|
|
1395
|
-
isTextProps: (props: any) => props is Partial<Text>;
|
|
1396
|
-
/**
|
|
1397
|
-
* Check if an text matches set of properties.
|
|
1398
|
-
*
|
|
1399
|
-
* Note: this is for matching custom properties, and it does not ensure that
|
|
1400
|
-
* the `text` property are two nodes equal.
|
|
1401
|
-
*/
|
|
1402
|
-
matches: (text: Text, props: Partial<Text>) => boolean;
|
|
1403
|
-
/**
|
|
1404
|
-
* Get the leaves for a text node given decorations.
|
|
1405
|
-
*/
|
|
1406
|
-
decorations: (node: Text, decorations: DecoratedRange$1[]) => {
|
|
1407
|
-
leaf: Text;
|
|
1408
|
-
position?: LeafPosition;
|
|
1409
|
-
}[];
|
|
1410
|
-
}
|
|
1411
|
-
declare const Text: TextInterface;
|
|
1412
|
-
interface GeneralTransforms {
|
|
1413
|
-
/**
|
|
1414
|
-
* Transform the editor by an operation.
|
|
1415
|
-
*/
|
|
1416
|
-
transform: (editor: Editor$1, op: Operation) => void;
|
|
1417
|
-
}
|
|
1418
|
-
declare const GeneralTransforms: GeneralTransforms;
|
|
1419
|
-
interface SelectionCollapseOptions {
|
|
1420
|
-
edge?: SelectionEdge;
|
|
1421
|
-
}
|
|
1422
|
-
interface SelectionMoveOptions {
|
|
1423
|
-
distance?: number;
|
|
1424
|
-
unit?: MoveUnit;
|
|
1425
|
-
reverse?: boolean;
|
|
1426
|
-
edge?: SelectionEdge;
|
|
1427
|
-
}
|
|
1428
|
-
interface SelectionSetPointOptions {
|
|
1429
|
-
edge?: SelectionEdge;
|
|
1430
|
-
}
|
|
1431
|
-
interface SelectionTransforms {
|
|
1432
|
-
/**
|
|
1433
|
-
* Collapse the selection.
|
|
1434
|
-
*/
|
|
1435
|
-
collapse: (editor: Editor$1, options?: SelectionCollapseOptions) => void;
|
|
1436
|
-
/**
|
|
1437
|
-
* Unset the selection.
|
|
1438
|
-
*/
|
|
1439
|
-
deselect: (editor: Editor$1) => void;
|
|
1440
|
-
/**
|
|
1441
|
-
* Move the selection's point forward or backward.
|
|
1442
|
-
*/
|
|
1443
|
-
move: (editor: Editor$1, options?: SelectionMoveOptions) => void;
|
|
1444
|
-
/**
|
|
1445
|
-
* Set the selection to a new value.
|
|
1446
|
-
*/
|
|
1447
|
-
select: (editor: Editor$1, target: Location) => void;
|
|
1448
|
-
/**
|
|
1449
|
-
* Set new properties on one of the selection's points.
|
|
1450
|
-
*/
|
|
1451
|
-
setPoint: (editor: Editor$1, props: Partial<Point>, options?: SelectionSetPointOptions) => void;
|
|
1452
|
-
/**
|
|
1453
|
-
* Set new properties on the selection.
|
|
1454
|
-
*/
|
|
1455
|
-
setSelection: (editor: Editor$1, props: Partial<Range>) => void;
|
|
1456
|
-
}
|
|
1457
|
-
declare const SelectionTransforms: SelectionTransforms;
|
|
1458
|
-
declare const Transforms: GeneralTransforms & NodeTransforms & SelectionTransforms & TextTransforms;
|
|
1459
14
|
type MIMEType = `${string}/${string}`;
|
|
1460
15
|
/**
|
|
1461
16
|
* @internal
|
|
@@ -1509,201 +64,6 @@ type Deserializer<TMIMEType extends MIMEType> = ({
|
|
|
1509
64
|
snapshot: EditorSnapshot;
|
|
1510
65
|
event: PickFromUnion<ConverterEvent<TMIMEType>, 'type', 'deserialize'>;
|
|
1511
66
|
}) => PickFromUnion<ConverterEvent<TMIMEType>, 'type', 'deserialization.success' | 'deserialization.failure'>;
|
|
1512
|
-
type StringDiff = {
|
|
1513
|
-
start: number;
|
|
1514
|
-
end: number;
|
|
1515
|
-
text: string;
|
|
1516
|
-
};
|
|
1517
|
-
type TextDiff = {
|
|
1518
|
-
id: number;
|
|
1519
|
-
path: Path$1;
|
|
1520
|
-
diff: StringDiff;
|
|
1521
|
-
};
|
|
1522
|
-
declare global {
|
|
1523
|
-
interface Window {
|
|
1524
|
-
Selection: (typeof Selection)['constructor'];
|
|
1525
|
-
DataTransfer: (typeof DataTransfer)['constructor'];
|
|
1526
|
-
Node: (typeof Node)['constructor'];
|
|
1527
|
-
}
|
|
1528
|
-
}
|
|
1529
|
-
type DOMPoint = [Node, number];
|
|
1530
|
-
/**
|
|
1531
|
-
* An auto-incrementing identifier for keys.
|
|
1532
|
-
*/
|
|
1533
|
-
/**
|
|
1534
|
-
* A class that keeps track of a key string. We use a full class here because we
|
|
1535
|
-
* want to be able to use them as keys in `WeakMap` objects.
|
|
1536
|
-
*/
|
|
1537
|
-
declare class Key {
|
|
1538
|
-
id: string;
|
|
1539
|
-
constructor();
|
|
1540
|
-
}
|
|
1541
|
-
/**
|
|
1542
|
-
* A DOM-specific version of the `Editor` interface.
|
|
1543
|
-
*/
|
|
1544
|
-
interface DOMEditor extends BaseEditor {
|
|
1545
|
-
hasEditableTarget: (editor: DOMEditor, target: EventTarget | null) => target is DOMNode;
|
|
1546
|
-
hasRange: (editor: DOMEditor, range: Range) => boolean;
|
|
1547
|
-
hasSelectableTarget: (editor: DOMEditor, target: EventTarget | null) => boolean;
|
|
1548
|
-
hasTarget: (editor: DOMEditor, target: EventTarget | null) => target is DOMNode;
|
|
1549
|
-
insertData: (data: DataTransfer) => void;
|
|
1550
|
-
insertFragmentData: (data: DataTransfer) => boolean;
|
|
1551
|
-
insertTextData: (data: DataTransfer) => boolean;
|
|
1552
|
-
isTargetInsideNonReadonlyVoid: (editor: DOMEditor, target: EventTarget | null) => boolean;
|
|
1553
|
-
setFragmentData: (data: DataTransfer, originEvent?: 'drag' | 'copy' | 'cut') => void;
|
|
1554
|
-
}
|
|
1555
|
-
interface DOMEditorInterface {
|
|
1556
|
-
/**
|
|
1557
|
-
* Experimental and android specific: Get pending diffs
|
|
1558
|
-
*/
|
|
1559
|
-
androidPendingDiffs: (editor: Editor$1) => TextDiff[] | undefined;
|
|
1560
|
-
/**
|
|
1561
|
-
* Experimental and android specific: Flush all pending diffs and cancel composition at the next possible time.
|
|
1562
|
-
*/
|
|
1563
|
-
androidScheduleFlush: (editor: Editor$1) => void;
|
|
1564
|
-
/**
|
|
1565
|
-
* Blur the editor.
|
|
1566
|
-
*/
|
|
1567
|
-
blur: (editor: DOMEditor) => void;
|
|
1568
|
-
/**
|
|
1569
|
-
* Deselect the editor.
|
|
1570
|
-
*/
|
|
1571
|
-
deselect: (editor: DOMEditor) => void;
|
|
1572
|
-
/**
|
|
1573
|
-
* Find the DOM node that implements DocumentOrShadowRoot for the editor.
|
|
1574
|
-
*/
|
|
1575
|
-
findDocumentOrShadowRoot: (editor: DOMEditor) => Document | ShadowRoot;
|
|
1576
|
-
/**
|
|
1577
|
-
* Get the target range from a DOM `event`.
|
|
1578
|
-
*/
|
|
1579
|
-
findEventRange: (editor: DOMEditor, event: any) => Range;
|
|
1580
|
-
/**
|
|
1581
|
-
* Find a key for a Slate node.
|
|
1582
|
-
*/
|
|
1583
|
-
findKey: (editor: DOMEditor, node: Node$1) => Key;
|
|
1584
|
-
/**
|
|
1585
|
-
* Find the path of Slate node.
|
|
1586
|
-
*/
|
|
1587
|
-
findPath: (editor: DOMEditor, node: Node$1) => Path$1;
|
|
1588
|
-
/**
|
|
1589
|
-
* Focus the editor.
|
|
1590
|
-
*/
|
|
1591
|
-
focus: (editor: DOMEditor, options?: {
|
|
1592
|
-
retries: number;
|
|
1593
|
-
}) => void;
|
|
1594
|
-
/**
|
|
1595
|
-
* Return the host window of the current editor.
|
|
1596
|
-
*/
|
|
1597
|
-
getWindow: (editor: DOMEditor) => Window;
|
|
1598
|
-
/**
|
|
1599
|
-
* Check if a DOM node is within the editor.
|
|
1600
|
-
*/
|
|
1601
|
-
hasDOMNode: (editor: DOMEditor, target: DOMNode, options?: {
|
|
1602
|
-
editable?: boolean;
|
|
1603
|
-
}) => boolean;
|
|
1604
|
-
/**
|
|
1605
|
-
* Check if the target is editable and in the editor.
|
|
1606
|
-
*/
|
|
1607
|
-
hasEditableTarget: (editor: DOMEditor, target: EventTarget | null) => target is DOMNode;
|
|
1608
|
-
/**
|
|
1609
|
-
*
|
|
1610
|
-
*/
|
|
1611
|
-
hasRange: (editor: DOMEditor, range: Range) => boolean;
|
|
1612
|
-
/**
|
|
1613
|
-
* Check if the target can be selectable
|
|
1614
|
-
*/
|
|
1615
|
-
hasSelectableTarget: (editor: DOMEditor, target: EventTarget | null) => boolean;
|
|
1616
|
-
/**
|
|
1617
|
-
* Check if the target is in the editor.
|
|
1618
|
-
*/
|
|
1619
|
-
hasTarget: (editor: DOMEditor, target: EventTarget | null) => target is DOMNode;
|
|
1620
|
-
/**
|
|
1621
|
-
* Insert data from a `DataTransfer` into the editor.
|
|
1622
|
-
*/
|
|
1623
|
-
insertData: (editor: DOMEditor, data: DataTransfer) => void;
|
|
1624
|
-
/**
|
|
1625
|
-
* Insert fragment data from a `DataTransfer` into the editor.
|
|
1626
|
-
*/
|
|
1627
|
-
insertFragmentData: (editor: DOMEditor, data: DataTransfer) => boolean;
|
|
1628
|
-
/**
|
|
1629
|
-
* Insert text data from a `DataTransfer` into the editor.
|
|
1630
|
-
*/
|
|
1631
|
-
insertTextData: (editor: DOMEditor, data: DataTransfer) => boolean;
|
|
1632
|
-
/**
|
|
1633
|
-
* Check if the user is currently composing inside the editor.
|
|
1634
|
-
*/
|
|
1635
|
-
isComposing: (editor: DOMEditor) => boolean;
|
|
1636
|
-
/**
|
|
1637
|
-
* Check if the editor is focused.
|
|
1638
|
-
*/
|
|
1639
|
-
isFocused: (editor: DOMEditor) => boolean;
|
|
1640
|
-
/**
|
|
1641
|
-
* Check if the editor is in read-only mode.
|
|
1642
|
-
*/
|
|
1643
|
-
isReadOnly: (editor: DOMEditor) => boolean;
|
|
1644
|
-
/**
|
|
1645
|
-
* Check if the target is inside void and in an non-readonly editor.
|
|
1646
|
-
*/
|
|
1647
|
-
isTargetInsideNonReadonlyVoid: (editor: DOMEditor, target: EventTarget | null) => boolean;
|
|
1648
|
-
/**
|
|
1649
|
-
* Sets data from the currently selected fragment on a `DataTransfer`.
|
|
1650
|
-
*/
|
|
1651
|
-
setFragmentData: (editor: DOMEditor, data: DataTransfer, originEvent?: 'drag' | 'copy' | 'cut') => void;
|
|
1652
|
-
/**
|
|
1653
|
-
* Find the native DOM element from a Slate node.
|
|
1654
|
-
*/
|
|
1655
|
-
toDOMNode: (editor: DOMEditor, node: Node$1) => HTMLElement;
|
|
1656
|
-
/**
|
|
1657
|
-
* Find a native DOM selection point from a Slate point.
|
|
1658
|
-
*/
|
|
1659
|
-
toDOMPoint: (editor: DOMEditor, point: Point) => DOMPoint;
|
|
1660
|
-
/**
|
|
1661
|
-
* Find a native DOM range from a Slate `range`.
|
|
1662
|
-
*
|
|
1663
|
-
* Notice: the returned range will always be ordinal regardless of the direction of Slate `range` due to DOM API limit.
|
|
1664
|
-
*
|
|
1665
|
-
* there is no way to create a reverse DOM Range using Range.setStart/setEnd
|
|
1666
|
-
* according to https://dom.spec.whatwg.org/#concept-range-bp-set.
|
|
1667
|
-
*/
|
|
1668
|
-
toDOMRange: (editor: DOMEditor, range: Range) => DOMRange;
|
|
1669
|
-
/**
|
|
1670
|
-
* Find a Slate node from a native DOM `element`.
|
|
1671
|
-
*/
|
|
1672
|
-
toSlateNode: (editor: DOMEditor, domNode: DOMNode) => Node$1;
|
|
1673
|
-
/**
|
|
1674
|
-
* Find a Slate point from a DOM selection's `domNode` and `domOffset`.
|
|
1675
|
-
*/
|
|
1676
|
-
toSlatePoint: <T$1 extends boolean>(editor: DOMEditor, domPoint: DOMPoint, options: {
|
|
1677
|
-
exactMatch: boolean;
|
|
1678
|
-
suppressThrow: T$1;
|
|
1679
|
-
/**
|
|
1680
|
-
* The direction to search for Slate leaf nodes if `domPoint` is
|
|
1681
|
-
* non-editable and non-void.
|
|
1682
|
-
*/
|
|
1683
|
-
searchDirection?: 'forward' | 'backward';
|
|
1684
|
-
}) => T$1 extends true ? Point | null : Point;
|
|
1685
|
-
/**
|
|
1686
|
-
* Find a Slate range from a DOM range or selection.
|
|
1687
|
-
*/
|
|
1688
|
-
toSlateRange: <T$1 extends boolean>(editor: DOMEditor, domRange: DOMRange | DOMStaticRange | DOMSelection, options: {
|
|
1689
|
-
exactMatch: boolean;
|
|
1690
|
-
suppressThrow: T$1;
|
|
1691
|
-
}) => T$1 extends true ? Range | null : Range;
|
|
1692
|
-
}
|
|
1693
|
-
declare const DOMEditor: DOMEditorInterface;
|
|
1694
|
-
/**
|
|
1695
|
-
* A React and DOM-specific version of the `Editor` interface.
|
|
1696
|
-
*/
|
|
1697
|
-
interface ReactEditor extends DOMEditor {
|
|
1698
|
-
/**
|
|
1699
|
-
* Determines the chunk size used by the children chunking optimization. If
|
|
1700
|
-
* null is returned (which is the default), the chunking optimization is
|
|
1701
|
-
* disabled.
|
|
1702
|
-
*/
|
|
1703
|
-
getChunkSize: (node: Ancestor) => number | null;
|
|
1704
|
-
}
|
|
1705
|
-
interface ReactEditorInterface extends DOMEditorInterface {}
|
|
1706
|
-
declare const ReactEditor: ReactEditorInterface;
|
|
1707
67
|
/**
|
|
1708
68
|
* @public
|
|
1709
69
|
*/
|
|
@@ -1887,7 +247,7 @@ declare class PortableTextEditor extends Component<PortableTextEditorProps<Inter
|
|
|
1887
247
|
componentDidUpdate(prevProps: PortableTextEditorProps): void;
|
|
1888
248
|
componentWillUnmount(): void;
|
|
1889
249
|
setEditable: (editable: EditableAPI) => void;
|
|
1890
|
-
render():
|
|
250
|
+
render(): react18.JSX.Element;
|
|
1891
251
|
/**
|
|
1892
252
|
* @deprecated
|
|
1893
253
|
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
@@ -2296,7 +656,7 @@ type PortableTextEditableProps = Omit<TextareaHTMLAttributes<HTMLDivElement>, 'o
|
|
|
2296
656
|
* ```
|
|
2297
657
|
* @group Components
|
|
2298
658
|
*/
|
|
2299
|
-
declare const PortableTextEditable:
|
|
659
|
+
declare const PortableTextEditable: react18.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react18.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
|
|
2300
660
|
/**
|
|
2301
661
|
* @public
|
|
2302
662
|
*/
|
|
@@ -2557,7 +917,7 @@ type OnPasteResult = {
|
|
|
2557
917
|
type OnPasteResultOrPromise = OnPasteResult | Promise<OnPasteResult>;
|
|
2558
918
|
/** @beta */
|
|
2559
919
|
interface PasteData {
|
|
2560
|
-
event: ClipboardEvent
|
|
920
|
+
event: ClipboardEvent;
|
|
2561
921
|
path: Path;
|
|
2562
922
|
schemaTypes: PortableTextMemberSchemaTypes;
|
|
2563
923
|
value: PortableTextBlock[] | undefined;
|
|
@@ -2572,7 +932,7 @@ type OnPasteFn = (data: PasteData) => OnPasteResultOrPromise;
|
|
|
2572
932
|
/** @beta */
|
|
2573
933
|
type OnBeforeInputFn = (event: InputEvent) => void;
|
|
2574
934
|
/** @beta */
|
|
2575
|
-
type OnCopyFn = (event: ClipboardEvent
|
|
935
|
+
type OnCopyFn = (event: ClipboardEvent<HTMLDivElement | HTMLSpanElement>) => undefined | unknown;
|
|
2576
936
|
/** @beta */
|
|
2577
937
|
type PatchObservable = Observable<{
|
|
2578
938
|
patches: Patch[];
|
|
@@ -2644,17 +1004,17 @@ interface BlockListItemRenderProps {
|
|
|
2644
1004
|
value: string;
|
|
2645
1005
|
}
|
|
2646
1006
|
/** @beta */
|
|
2647
|
-
type RenderBlockFunction = (props: BlockRenderProps) => JSX
|
|
1007
|
+
type RenderBlockFunction = (props: BlockRenderProps) => JSX.Element;
|
|
2648
1008
|
/** @beta */
|
|
2649
|
-
type RenderChildFunction = (props: BlockChildRenderProps) => JSX
|
|
1009
|
+
type RenderChildFunction = (props: BlockChildRenderProps) => JSX.Element;
|
|
2650
1010
|
/** @beta */
|
|
2651
|
-
type RenderEditableFunction = (props: PortableTextEditableProps) => JSX
|
|
1011
|
+
type RenderEditableFunction = (props: PortableTextEditableProps) => JSX.Element;
|
|
2652
1012
|
/** @beta */
|
|
2653
|
-
type RenderAnnotationFunction = (props: BlockAnnotationRenderProps) => JSX
|
|
1013
|
+
type RenderAnnotationFunction = (props: BlockAnnotationRenderProps) => JSX.Element;
|
|
2654
1014
|
/** @beta */
|
|
2655
1015
|
type RenderPlaceholderFunction = () => React.ReactNode;
|
|
2656
1016
|
/** @beta */
|
|
2657
|
-
type RenderStyleFunction = (props: BlockStyleRenderProps) => JSX
|
|
1017
|
+
type RenderStyleFunction = (props: BlockStyleRenderProps) => JSX.Element;
|
|
2658
1018
|
/** @beta */
|
|
2659
1019
|
interface BlockStyleRenderProps {
|
|
2660
1020
|
block: PortableTextTextBlock;
|
|
@@ -2667,9 +1027,9 @@ interface BlockStyleRenderProps {
|
|
|
2667
1027
|
value: string;
|
|
2668
1028
|
}
|
|
2669
1029
|
/** @beta */
|
|
2670
|
-
type RenderListItemFunction = (props: BlockListItemRenderProps) => JSX
|
|
1030
|
+
type RenderListItemFunction = (props: BlockListItemRenderProps) => JSX.Element;
|
|
2671
1031
|
/** @beta */
|
|
2672
|
-
type RenderDecoratorFunction = (props: BlockDecoratorRenderProps) => JSX
|
|
1032
|
+
type RenderDecoratorFunction = (props: BlockDecoratorRenderProps) => JSX.Element;
|
|
2673
1033
|
/** @beta */
|
|
2674
1034
|
type ScrollSelectionIntoViewFunction = (editor: PortableTextEditor, domRange: globalThis.Range) => void;
|
|
2675
1035
|
/**
|
|
@@ -2926,12 +1286,6 @@ type BlockOffset = {
|
|
|
2926
1286
|
path: BlockPath;
|
|
2927
1287
|
offset: number;
|
|
2928
1288
|
};
|
|
2929
|
-
declare global {
|
|
2930
|
-
type DOMNode = typeof globalThis.Node;
|
|
2931
|
-
type DOMRange = typeof globalThis.Range;
|
|
2932
|
-
type DOMSelection = typeof globalThis.Selection;
|
|
2933
|
-
type DOMStaticRange = typeof globalThis.StaticRange;
|
|
2934
|
-
}
|
|
2935
1289
|
type TextBlockWithOptionalKey = Omit<PortableTextTextBlock$1, '_key'> & {
|
|
2936
1290
|
_key?: PortableTextTextBlock$1['_key'];
|
|
2937
1291
|
};
|
|
@@ -3148,7 +1502,7 @@ declare const editorMachine: xstate228.StateMachine<{
|
|
|
3148
1502
|
initialValue?: Array<PortableTextBlock>;
|
|
3149
1503
|
}, xstate228.NonReducibleUnknown, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
3150
1504
|
type: "blurred";
|
|
3151
|
-
event:
|
|
1505
|
+
event: react18.FocusEvent<HTMLDivElement, Element>;
|
|
3152
1506
|
} | {
|
|
3153
1507
|
type: "done loading";
|
|
3154
1508
|
} | {
|
|
@@ -3160,7 +1514,7 @@ declare const editorMachine: xstate228.StateMachine<{
|
|
|
3160
1514
|
data: unknown;
|
|
3161
1515
|
} | {
|
|
3162
1516
|
type: "focused";
|
|
3163
|
-
event:
|
|
1517
|
+
event: react18.FocusEvent<HTMLDivElement, Element>;
|
|
3164
1518
|
} | {
|
|
3165
1519
|
type: "invalid value";
|
|
3166
1520
|
resolution: InvalidValueResolution | null;
|
|
@@ -3727,7 +2081,7 @@ declare const editorMachine: xstate228.StateMachine<{
|
|
|
3727
2081
|
editor: PortableTextSlateEditor;
|
|
3728
2082
|
}, undefined, never, never, never, never, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
3729
2083
|
type: "blurred";
|
|
3730
|
-
event:
|
|
2084
|
+
event: react18.FocusEvent<HTMLDivElement, Element>;
|
|
3731
2085
|
} | {
|
|
3732
2086
|
type: "done loading";
|
|
3733
2087
|
} | {
|
|
@@ -3739,7 +2093,7 @@ declare const editorMachine: xstate228.StateMachine<{
|
|
|
3739
2093
|
data: unknown;
|
|
3740
2094
|
} | {
|
|
3741
2095
|
type: "focused";
|
|
3742
|
-
event:
|
|
2096
|
+
event: react18.FocusEvent<HTMLDivElement, Element>;
|
|
3743
2097
|
} | {
|
|
3744
2098
|
type: "invalid value";
|
|
3745
2099
|
resolution: InvalidValueResolution | null;
|
|
@@ -4559,7 +2913,7 @@ declare const editorMachine: xstate228.StateMachine<{
|
|
|
4559
2913
|
editor: PortableTextSlateEditor;
|
|
4560
2914
|
}, undefined, never, never, never, never, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
4561
2915
|
type: "blurred";
|
|
4562
|
-
event:
|
|
2916
|
+
event: react18.FocusEvent<HTMLDivElement, Element>;
|
|
4563
2917
|
} | {
|
|
4564
2918
|
type: "done loading";
|
|
4565
2919
|
} | {
|
|
@@ -4571,7 +2925,7 @@ declare const editorMachine: xstate228.StateMachine<{
|
|
|
4571
2925
|
data: unknown;
|
|
4572
2926
|
} | {
|
|
4573
2927
|
type: "focused";
|
|
4574
|
-
event:
|
|
2928
|
+
event: react18.FocusEvent<HTMLDivElement, Element>;
|
|
4575
2929
|
} | {
|
|
4576
2930
|
type: "invalid value";
|
|
4577
2931
|
resolution: InvalidValueResolution | null;
|