UNPKG

@portabletext/editor

Version:

Portable Text Editor made in React

1,992 lines (1,961 loc) 164 kB
import type {Patch} from '@portabletext/patches' import type { ArraySchemaType, BlockDecoratorDefinition, BlockListDefinition, BlockStyleDefinition, ObjectSchemaType, Path, PortableTextChild, PortableTextListBlock, PortableTextTextBlock, } from '@sanity/types' import { KeyedSegment, PortableTextBlock, PortableTextObject, PortableTextSpan, } from '@sanity/types' import type { FocusEvent as FocusEvent_2, KeyboardEvent as KeyboardEvent_2, } from 'react' import type {Descendant, Operation, TextUnit} from 'slate' import type {DOMNode} from 'slate-dom' import type {ReactEditor} from 'slate-react' import { ActionArgs, ActionFunction, ActorRef, ActorRefFrom, ActorRefFromLogic, AnyActorLogic, AnyActorRef, AnyEventObject, ConditionalRequired, InputFrom, IsNotNever, MachineSnapshot, MetaObject, NonReducibleUnknown, RequiredLogicInput, StateMachine, StateValue, Values, } from 'xstate' import {GuardArgs} from 'xstate/guards' declare type AbstractBehaviorEvent = | { type: StrictExtract<AbstractBehaviorEventType, 'annotation.toggle'> annotation: { name: string value: { [prop: string]: unknown } } } | { type: StrictExtract<AbstractBehaviorEventType, 'decorator.toggle'> decorator: string at?: { anchor: BlockOffset focus: BlockOffset } } | { type: StrictExtract<AbstractBehaviorEventType, 'delete.text'> at: { anchor: BlockOffset focus: BlockOffset } } | { type: StrictExtract<AbstractBehaviorEventType, 'deserialize'> originEvent: | PickFromUnion< NativeBehaviorEvent, 'type', 'drag.drop' | 'clipboard.paste' > | InputBehaviorEvent } | { type: StrictExtract<AbstractBehaviorEventType, 'serialize'> originEvent: PickFromUnion< NativeBehaviorEvent, 'type', 'clipboard.copy' | 'clipboard.cut' | 'drag.dragstart' > } | { type: StrictExtract<AbstractBehaviorEventType, 'deserialization.success'> mimeType: MIMEType data: Array<PortableTextBlock> originEvent: | PickFromUnion< NativeBehaviorEvent, 'type', 'drag.drop' | 'clipboard.paste' > | InputBehaviorEvent } | { type: StrictExtract<AbstractBehaviorEventType, 'deserialization.failure'> mimeType: MIMEType reason: string originEvent: | PickFromUnion< NativeBehaviorEvent, 'type', 'drag.drop' | 'clipboard.paste' > | InputBehaviorEvent } | { type: StrictExtract<AbstractBehaviorEventType, 'serialization.success'> mimeType: MIMEType data: string originEvent: PickFromUnion< NativeBehaviorEvent, 'type', 'clipboard.copy' | 'clipboard.cut' | 'drag.dragstart' > } | { type: StrictExtract<AbstractBehaviorEventType, 'serialization.failure'> mimeType: MIMEType reason: string originEvent: PickFromUnion< NativeBehaviorEvent, 'type', 'clipboard.copy' | 'clipboard.cut' | 'drag.dragstart' > } | { type: StrictExtract<AbstractBehaviorEventType, 'insert.blocks'> blocks: Array<PortableTextBlock> placement: InsertPlacement } | { type: StrictExtract<AbstractBehaviorEventType, 'insert.break'> } | { type: StrictExtract<AbstractBehaviorEventType, 'insert.soft break'> } | { type: StrictExtract<AbstractBehaviorEventType, 'list item.add'> listItem: string } | { type: StrictExtract<AbstractBehaviorEventType, 'list item.remove'> listItem: string } | { type: StrictExtract<AbstractBehaviorEventType, 'list item.toggle'> listItem: string } | { type: StrictExtract<AbstractBehaviorEventType, 'move.block down'> at: [KeyedSegment] } | { type: StrictExtract<AbstractBehaviorEventType, 'move.block up'> at: [KeyedSegment] } | { type: StrictExtract<AbstractBehaviorEventType, 'select.previous block'> select?: 'start' | 'end' } | { type: StrictExtract<AbstractBehaviorEventType, 'select.next block'> select?: 'start' | 'end' } | { type: StrictExtract<AbstractBehaviorEventType, 'style.add'> style: string } | { type: StrictExtract<AbstractBehaviorEventType, 'style.remove'> style: string } | { type: StrictExtract<AbstractBehaviorEventType, 'style.toggle'> style: string } declare type AbstractBehaviorEventNamespace = ExtractNamespace<AbstractBehaviorEventType> declare type AbstractBehaviorEventType = (typeof abstractBehaviorEventTypes)[number] /************************************** * Abstract events **************************************/ declare const abstractBehaviorEventTypes: readonly [ 'annotation.toggle', 'decorator.toggle', 'delete.text', 'deserialize', 'deserialization.success', 'deserialization.failure', 'insert.blocks', 'insert.break', 'insert.soft break', 'list item.add', 'list item.remove', 'list item.toggle', 'move.block down', 'move.block up', 'select.previous block', 'select.next block', 'serialize', 'serialization.success', 'serialization.failure', 'style.add', 'style.remove', 'style.toggle', ] /** * @public */ declare type BaseDefinition = { name: string title?: string } /** * @beta */ declare type Behavior< TBehaviorEventType extends | '*' | `${BehaviorEventTypeNamespace}.*` | BehaviorEvent['type'] = | '*' | `${BehaviorEventTypeNamespace}.*` | BehaviorEvent['type'], TGuardResponse = true, TBehaviorEvent extends ResolveBehaviorEvent<TBehaviorEventType> = ResolveBehaviorEvent<TBehaviorEventType>, > = { /** * Editor Event that triggers this Behavior. */ on: TBehaviorEventType /** * Predicate function that determines if the Behavior should be executed. * Returning a non-nullable value from the guard will pass the value to the * actions and execute them. */ guard?: BehaviorGuard<TBehaviorEvent, TGuardResponse> /** * Array of Behavior Action sets. * Each set represents a step in the history stack. */ actions: Array<BehaviorActionSet<TBehaviorEvent, TGuardResponse>> } /** * @beta */ declare type BehaviorAction = | { type: 'execute' event: | AbstractBehaviorEvent | SyntheticBehaviorEvent | CustomBehaviorEvent } | { type: 'raise' event: | AbstractBehaviorEvent | SyntheticBehaviorEvent | CustomBehaviorEvent } | { type: 'noop' } | { type: 'effect' effect: () => void } /** * @beta */ declare type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = ( payload: { snapshot: EditorSnapshot event: TBehaviorEvent }, guardResponse: TGuardResponse, ) => Array<BehaviorAction> /** * @beta */ declare type BehaviorEvent = | SyntheticBehaviorEvent | AbstractBehaviorEvent | NativeBehaviorEvent | CustomBehaviorEvent declare type BehaviorEventTypeNamespace = | SyntheticBehaviorEventNamespace | AbstractBehaviorEventNamespace | NativeBehaviorEventNamespace | CustomBehaviorEventNamespace /** * @beta */ declare type BehaviorGuard<TBehaviorEvent, TGuardResponse> = (payload: { snapshot: EditorSnapshot event: TBehaviorEvent }) => TGuardResponse | false /** * @beta */ declare type BlockOffset = { path: [KeyedSegment] offset: number } /** * @public */ export declare function blockOffsetsToSelection({ value, offsets, backward, }: { value: Array<PortableTextBlock> offsets: { anchor: BlockOffset focus: BlockOffset } backward?: boolean }): EditorSelection /** * @public */ export declare function blockOffsetToBlockSelectionPoint({ value, blockOffset, }: { value: Array<PortableTextBlock> blockOffset: BlockOffset }): EditorSelectionPoint | undefined /** * @public */ export declare function blockOffsetToSelectionPoint({ value, blockOffset, direction, }: { value: Array<PortableTextBlock> blockOffset: BlockOffset direction: 'forward' | 'backward' }): EditorSelectionPoint | undefined /** * @public */ export declare function blockOffsetToSpanSelectionPoint({ value, blockOffset, direction, }: { value: Array<PortableTextBlock> blockOffset: BlockOffset direction: 'forward' | 'backward' }): | { path: [KeyedSegment, 'children', KeyedSegment] offset: number } | undefined declare type BlockWithOptionalKey = | TextBlockWithOptionalKey | ObjectBlockWithOptionalKey /** * @public */ export declare function childSelectionPointToBlockOffset({ value, selectionPoint, }: { value: Array<PortableTextBlock> selectionPoint: EditorSelectionPoint }): BlockOffset | undefined declare type ClipboardBehaviorEvent = | { type: StrictExtract<NativeBehaviorEventType, 'clipboard.copy'> originEvent: { dataTransfer: DataTransfer } position: Pick<EventPosition, 'selection'> } | { type: StrictExtract<NativeBehaviorEventType, 'clipboard.cut'> originEvent: { dataTransfer: DataTransfer } position: Pick<EventPosition, 'selection'> } | { type: StrictExtract<NativeBehaviorEventType, 'clipboard.paste'> originEvent: { dataTransfer: DataTransfer } position: Pick<EventPosition, 'selection'> } declare type Converter<TMIMEType extends MIMEType = MIMEType> = { mimeType: TMIMEType serialize: Serializer<TMIMEType> deserialize: Deserializer<TMIMEType> } declare type ConverterEvent<TMIMEType extends MIMEType = MIMEType> = | { type: 'serialize' originEvent: 'clipboard.copy' | 'clipboard.cut' | 'drag.dragstart' } | { type: 'serialization.failure' mimeType: TMIMEType originEvent: 'clipboard.copy' | 'clipboard.cut' | 'drag.dragstart' reason: string } | { type: 'serialization.success' data: string mimeType: TMIMEType originEvent: 'clipboard.copy' | 'clipboard.cut' | 'drag.dragstart' } | { type: 'deserialize' data: string } | { type: 'deserialization.failure' mimeType: TMIMEType reason: string } | { type: 'deserialization.success' data: Array<PortableTextBlock> mimeType: TMIMEType } /** * @beta */ declare type CustomBehaviorEvent< TPayload extends Record<string, unknown> = Record<string, unknown>, TType extends string = string, TInternalType extends CustomBehaviorEventType< 'custom', TType > = CustomBehaviorEventType<'custom', TType>, > = { type: TInternalType } & TPayload /************************************** * Custom events **************************************/ declare type CustomBehaviorEventNamespace = 'custom' declare type CustomBehaviorEventType< TNamespace extends CustomBehaviorEventNamespace, TType extends string = '', > = TType extends '' ? `${TNamespace}` : `${TNamespace}.${TType}` declare type Deserializer<TMIMEType extends MIMEType> = ({ snapshot, event, }: { snapshot: EditorSnapshot event: PickFromUnion<ConverterEvent<TMIMEType>, 'type', 'deserialize'> }) => PickFromUnion< ConverterEvent<TMIMEType>, 'type', 'deserialization.success' | 'deserialization.failure' > declare type DragBehaviorEvent = | { type: StrictExtract<NativeBehaviorEventType, 'drag.dragstart'> originEvent: { dataTransfer: DataTransfer } position: Pick<EventPosition, 'selection'> } | { type: StrictExtract<NativeBehaviorEventType, 'drag.drag'> originEvent: { dataTransfer: DataTransfer } } | { type: StrictExtract<NativeBehaviorEventType, 'drag.dragend'> originEvent: { dataTransfer: DataTransfer } } | { type: StrictExtract<NativeBehaviorEventType, 'drag.dragenter'> originEvent: { dataTransfer: DataTransfer } position: EventPosition } | { type: StrictExtract<NativeBehaviorEventType, 'drag.dragover'> originEvent: { dataTransfer: DataTransfer } position: EventPosition } | { type: StrictExtract<NativeBehaviorEventType, 'drag.drop'> originEvent: { dataTransfer: DataTransfer } position: EventPosition } | { type: StrictExtract<NativeBehaviorEventType, 'drag.dragleave'> originEvent: { dataTransfer: DataTransfer } } /** @beta */ declare interface EditableAPI { activeAnnotations: () => PortableTextObject[] isAnnotationActive: (annotationType: PortableTextObject['_type']) => boolean addAnnotation: < TSchemaType extends { name: string }, >( type: TSchemaType, value?: { [prop: string]: unknown }, ) => | { markDefPath: Path markDefPaths: Array<Path> spanPath: Path } | undefined blur: () => void delete: ( selection: EditorSelection, options?: EditableAPIDeleteOptions, ) => void findByPath: ( path: Path, ) => [PortableTextBlock | PortableTextChild | undefined, Path | undefined] findDOMNode: ( element: PortableTextBlock | PortableTextChild, ) => DOMNode | undefined focus: () => void focusBlock: () => PortableTextBlock | undefined focusChild: () => PortableTextChild | undefined getSelection: () => EditorSelection getFragment: () => PortableTextBlock[] | undefined getValue: () => PortableTextBlock[] | undefined hasBlockStyle: (style: string) => boolean hasListStyle: (listStyle: string) => boolean insertBlock: < TSchemaType extends { name: string }, >( type: TSchemaType, value?: { [prop: string]: unknown }, ) => Path insertChild: < TSchemaType extends { name: string }, >( type: TSchemaType, value?: { [prop: string]: unknown }, ) => Path insertBreak: () => void isCollapsedSelection: () => boolean isExpandedSelection: () => boolean isMarkActive: (mark: string) => boolean isSelectionsOverlapping: ( selectionA: EditorSelection, selectionB: EditorSelection, ) => boolean isVoid: (element: PortableTextBlock | PortableTextChild) => boolean marks: () => string[] redo: () => void removeAnnotation: < TSchemaType extends { name: string }, >( type: TSchemaType, ) => void select: (selection: EditorSelection) => void toggleBlockStyle: (blockStyle: string) => void toggleList: (listStyle: string) => void toggleMark: (mark: string) => void undo: () => void } /** @beta */ declare interface EditableAPIDeleteOptions { mode?: 'blocks' | 'children' | 'selected' } /** * @internal */ declare type EditorActor = ActorRefFrom<typeof editorMachine> /** * @public */ declare type EditorContext = { activeDecorators: Array<string> converters: Array<Converter> keyGenerator: () => string readOnly: boolean schema: EditorSchema selection: EditorSelection value: Array<PortableTextBlock> } /** * @internal */ declare const editorMachine: StateMachine< { behaviors: Set<Behavior> converters: Set<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string pendingEvents: Array<InternalPatchEvent | MutationEvent> schema: EditorSchema initialReadOnly: boolean maxBlocks: number | undefined selection: EditorSelection incomingValue: Array<PortableTextBlock> | undefined internalDrag?: { ghost?: HTMLElement origin: Pick<EventPosition, 'selection'> } slateEditor?: PortableTextSlateEditor }, | InternalPatchEvent | MutationEvent | { type: 'add behavior' behavior: Behavior } | { type: 'remove behavior' behavior: Behavior } | { type: 'update readOnly' readOnly: boolean } | { type: 'update schema' schema: EditorSchema } | { type: 'update behaviors' behaviors: Array<Behavior> } | { type: 'update key generator' keyGenerator: () => string } | { type: 'update value' value: Array<PortableTextBlock> | undefined } | { type: 'update maxBlocks' maxBlocks: number | undefined } | PatchesEvent | { type: 'blur' editor: PortableTextSlateEditor } | { type: 'focus' editor: PortableTextSlateEditor } | { type: 'normalizing' } | { type: 'done normalizing' } | { type: 'done syncing initial value' } | { type: 'behavior event' behaviorEvent: BehaviorEvent editor: PortableTextSlateEditor nativeEvent?: { preventDefault: () => void } } | { type: 'notify.patch' patch: Patch } | { type: 'notify.mutation' patches: Array<Patch> snapshot: Array<PortableTextBlock> | undefined value: Array<PortableTextBlock> | undefined } | { type: 'notify.blurred' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'notify.done loading' } | { type: 'notify.editable' } | { type: 'notify.error' name: string description: string data: unknown } | { type: 'notify.focused' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'notify.invalid value' resolution: InvalidValueResolution | null value: Array<PortableTextBlock> | undefined } | { type: 'notify.loading' } | { type: 'notify.read only' } | { type: 'notify.ready' } | { type: 'notify.selection' selection: EditorSelection } | { type: 'notify.value changed' value: Array<PortableTextBlock> | undefined } | { type: 'notify.unset' previousValue: Array<PortableTextBlock> } | { type: 'dragstart' origin: Pick<EventPosition, 'selection'> ghost?: HTMLElement } | { type: 'dragend' } | { type: 'drop' }, {}, never, Values<{ 'add behavior to context': { type: 'add behavior to context' params: NonReducibleUnknown } 'remove behavior from context': { type: 'remove behavior from context' params: NonReducibleUnknown } 'assign behaviors': { type: 'assign behaviors' params: NonReducibleUnknown } 'assign schema': { type: 'assign schema' params: NonReducibleUnknown } 'emit patch event': { type: 'emit patch event' params: NonReducibleUnknown } 'emit mutation event': { type: 'emit mutation event' params: NonReducibleUnknown } 'emit read only': { type: 'emit read only' params: NonReducibleUnknown } 'emit editable': { type: 'emit editable' params: NonReducibleUnknown } 'defer event': { type: 'defer event' params: NonReducibleUnknown } 'emit pending events': { type: 'emit pending events' params: NonReducibleUnknown } 'emit ready': { type: 'emit ready' params: NonReducibleUnknown } 'clear pending events': { type: 'clear pending events' params: NonReducibleUnknown } 'handle blur': { type: 'handle blur' params: unknown } 'handle focus': { type: 'handle focus' params: unknown } 'handle behavior event': { type: 'handle behavior event' params: unknown } }>, { type: 'slate is busy' params: unknown }, never, { 'edit mode': | { editable: | 'dragging internally' | 'idle' | { focusing: 'checking if busy' | 'busy' } } | { 'read only': 'read only' | 'determine initial edit mode' } 'setup': | 'setting up' | 'dirty' | { pristine: 'normalizing' | 'idle' } }, 'dragging internally', { behaviors?: Array<Behavior> converters?: Array<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string maxBlocks?: number readOnly?: boolean schema: EditorSchema initialValue?: Array<PortableTextBlock> }, NonReducibleUnknown, | PatchEvent | InternalPatchEvent | MutationEvent | PatchesEvent | { type: 'blurred' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'done loading' } | { type: 'editable' } | { type: 'error' name: string description: string data: unknown } | { type: 'focused' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'invalid value' resolution: InvalidValueResolution | null value: Array<PortableTextBlock> | undefined } | { type: 'loading' } | { type: 'read only' } | { type: 'ready' } | { type: 'selection' selection: EditorSelection } | { type: 'value changed' value: Array<PortableTextBlock> | undefined } | UnsetEvent, MetaObject, { readonly id: 'editor' readonly context: ({ input, }: { spawn: { <TSrc extends never>( logic: TSrc, ...[options]: never ): ActorRefFromLogic<never> <TLogic extends AnyActorLogic>( src: TLogic, ...[options]: ConditionalRequired< [ options?: | ({ id?: never systemId?: string input?: InputFrom<TLogic> | undefined syncSnapshot?: boolean } & {[K in RequiredLogicInput<TLogic>]: unknown}) | undefined, ], IsNotNever<RequiredLogicInput<TLogic>> > ): ActorRefFromLogic<TLogic> } input: { behaviors?: Array<Behavior> converters?: Array<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string maxBlocks?: number readOnly?: boolean schema: EditorSchema initialValue?: Array<PortableTextBlock> } self: ActorRef< MachineSnapshot< { behaviors: Set<Behavior> converters: Set<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string pendingEvents: Array<InternalPatchEvent | MutationEvent> schema: EditorSchema initialReadOnly: boolean maxBlocks: number | undefined selection: EditorSelection incomingValue: Array<PortableTextBlock> | undefined internalDrag?: { ghost?: HTMLElement origin: Pick<EventPosition, 'selection'> } slateEditor?: PortableTextSlateEditor }, | InternalPatchEvent | MutationEvent | { type: 'add behavior' behavior: Behavior } | { type: 'remove behavior' behavior: Behavior } | { type: 'update readOnly' readOnly: boolean } | { type: 'update schema' schema: EditorSchema } | { type: 'update behaviors' behaviors: Array<Behavior> } | { type: 'update key generator' keyGenerator: () => string } | { type: 'update value' value: Array<PortableTextBlock> | undefined } | { type: 'update maxBlocks' maxBlocks: number | undefined } | PatchesEvent | { type: 'blur' editor: PortableTextSlateEditor } | { type: 'focus' editor: PortableTextSlateEditor } | { type: 'normalizing' } | { type: 'done normalizing' } | { type: 'done syncing initial value' } | { type: 'behavior event' behaviorEvent: BehaviorEvent editor: PortableTextSlateEditor nativeEvent?: { preventDefault: () => void } } | { type: 'notify.patch' patch: Patch } | { type: 'notify.mutation' patches: Array<Patch> snapshot: Array<PortableTextBlock> | undefined value: Array<PortableTextBlock> | undefined } | { type: 'notify.blurred' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'notify.done loading' } | { type: 'notify.editable' } | { type: 'notify.error' name: string description: string data: unknown } | { type: 'notify.focused' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'notify.invalid value' resolution: InvalidValueResolution | null value: Array<PortableTextBlock> | undefined } | { type: 'notify.loading' } | { type: 'notify.read only' } | { type: 'notify.ready' } | { type: 'notify.selection' selection: EditorSelection } | { type: 'notify.value changed' value: Array<PortableTextBlock> | undefined } | { type: 'notify.unset' previousValue: Array<PortableTextBlock> } | { type: 'dragstart' origin: Pick<EventPosition, 'selection'> ghost?: HTMLElement } | { type: 'dragend' } | { type: 'drop' }, Record<string, AnyActorRef | undefined>, StateValue, string, unknown, any, any >, | InternalPatchEvent | MutationEvent | { type: 'add behavior' behavior: Behavior } | { type: 'remove behavior' behavior: Behavior } | { type: 'update readOnly' readOnly: boolean } | { type: 'update schema' schema: EditorSchema } | { type: 'update behaviors' behaviors: Array<Behavior> } | { type: 'update key generator' keyGenerator: () => string } | { type: 'update value' value: Array<PortableTextBlock> | undefined } | { type: 'update maxBlocks' maxBlocks: number | undefined } | PatchesEvent | { type: 'blur' editor: PortableTextSlateEditor } | { type: 'focus' editor: PortableTextSlateEditor } | { type: 'normalizing' } | { type: 'done normalizing' } | { type: 'done syncing initial value' } | { type: 'behavior event' behaviorEvent: BehaviorEvent editor: PortableTextSlateEditor nativeEvent?: { preventDefault: () => void } } | { type: 'notify.patch' patch: Patch } | { type: 'notify.mutation' patches: Array<Patch> snapshot: Array<PortableTextBlock> | undefined value: Array<PortableTextBlock> | undefined } | { type: 'notify.blurred' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'notify.done loading' } | { type: 'notify.editable' } | { type: 'notify.error' name: string description: string data: unknown } | { type: 'notify.focused' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'notify.invalid value' resolution: InvalidValueResolution | null value: Array<PortableTextBlock> | undefined } | { type: 'notify.loading' } | { type: 'notify.read only' } | { type: 'notify.ready' } | { type: 'notify.selection' selection: EditorSelection } | { type: 'notify.value changed' value: Array<PortableTextBlock> | undefined } | { type: 'notify.unset' previousValue: Array<PortableTextBlock> } | { type: 'dragstart' origin: Pick<EventPosition, 'selection'> ghost?: HTMLElement } | { type: 'dragend' } | { type: 'drop' }, AnyEventObject > }) => { behaviors: Set<Behavior> converters: Set<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string pendingEvents: never[] schema: EditorSchema selection: null initialReadOnly: boolean maxBlocks: number | undefined incomingValue: PortableTextBlock[] | undefined } readonly on: { readonly 'notify.blurred': { readonly actions: ActionFunction< { behaviors: Set<Behavior> converters: Set<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string pendingEvents: Array<InternalPatchEvent | MutationEvent> schema: EditorSchema initialReadOnly: boolean maxBlocks: number | undefined selection: EditorSelection incomingValue: Array<PortableTextBlock> | undefined internalDrag?: { ghost?: HTMLElement origin: Pick<EventPosition, 'selection'> } slateEditor?: PortableTextSlateEditor }, { type: 'notify.blurred' event: FocusEvent_2<HTMLDivElement, Element> }, | InternalPatchEvent | MutationEvent | { type: 'add behavior' behavior: Behavior } | { type: 'remove behavior' behavior: Behavior } | { type: 'update readOnly' readOnly: boolean } | { type: 'update schema' schema: EditorSchema } | { type: 'update behaviors' behaviors: Array<Behavior> } | { type: 'update key generator' keyGenerator: () => string } | { type: 'update value' value: Array<PortableTextBlock> | undefined } | { type: 'update maxBlocks' maxBlocks: number | undefined } | PatchesEvent | { type: 'blur' editor: PortableTextSlateEditor } | { type: 'focus' editor: PortableTextSlateEditor } | { type: 'normalizing' } | { type: 'done normalizing' } | { type: 'done syncing initial value' } | { type: 'behavior event' behaviorEvent: BehaviorEvent editor: PortableTextSlateEditor nativeEvent?: { preventDefault: () => void } } | { type: 'notify.patch' patch: Patch } | { type: 'notify.mutation' patches: Array<Patch> snapshot: Array<PortableTextBlock> | undefined value: Array<PortableTextBlock> | undefined } | { type: 'notify.blurred' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'notify.done loading' } | { type: 'notify.editable' } | { type: 'notify.error' name: string description: string data: unknown } | { type: 'notify.focused' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'notify.invalid value' resolution: InvalidValueResolution | null value: Array<PortableTextBlock> | undefined } | { type: 'notify.loading' } | { type: 'notify.read only' } | { type: 'notify.ready' } | { type: 'notify.selection' selection: EditorSelection } | { type: 'notify.value changed' value: Array<PortableTextBlock> | undefined } | { type: 'notify.unset' previousValue: Array<PortableTextBlock> } | { type: 'dragstart' origin: Pick<EventPosition, 'selection'> ghost?: HTMLElement } | { type: 'dragend' } | { type: 'drop' }, undefined, never, never, never, never, | PatchEvent | InternalPatchEvent | MutationEvent | PatchesEvent | { type: 'blurred' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'done loading' } | { type: 'editable' } | { type: 'error' name: string description: string data: unknown } | { type: 'focused' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'invalid value' resolution: InvalidValueResolution | null value: Array<PortableTextBlock> | undefined } | { type: 'loading' } | { type: 'read only' } | { type: 'ready' } | { type: 'selection' selection: EditorSelection } | { type: 'value changed' value: Array<PortableTextBlock> | undefined } | UnsetEvent > } readonly 'notify.done loading': { readonly actions: ActionFunction< { behaviors: Set<Behavior> converters: Set<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string pendingEvents: Array<InternalPatchEvent | MutationEvent> schema: EditorSchema initialReadOnly: boolean maxBlocks: number | undefined selection: EditorSelection incomingValue: Array<PortableTextBlock> | undefined internalDrag?: { ghost?: HTMLElement origin: Pick<EventPosition, 'selection'> } slateEditor?: PortableTextSlateEditor }, { type: 'notify.done loading' }, | InternalPatchEvent | MutationEvent | { type: 'add behavior' behavior: Behavior } | { type: 'remove behavior' behavior: Behavior } | { type: 'update readOnly' readOnly: boolean } | { type: 'update schema' schema: EditorSchema } | { type: 'update behaviors' behaviors: Array<Behavior> } | { type: 'update key generator' keyGenerator: () => string } | { type: 'update value' value: Array<PortableTextBlock> | undefined } | { type: 'update maxBlocks' maxBlocks: number | undefined } | PatchesEvent | { type: 'blur' editor: PortableTextSlateEditor } | { type: 'focus' editor: PortableTextSlateEditor } | { type: 'normalizing' } | { type: 'done normalizing' } | { type: 'done syncing initial value' } | { type: 'behavior event' behaviorEvent: BehaviorEvent editor: PortableTextSlateEditor nativeEvent?: { preventDefault: () => void } } | { type: 'notify.patch' patch: Patch } | { type: 'notify.mutation' patches: Array<Patch> snapshot: Array<PortableTextBlock> | undefined value: Array<PortableTextBlock> | undefined } | { type: 'notify.blurred' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'notify.done loading' } | { type: 'notify.editable' } | { type: 'notify.error' name: string description: string data: unknown } | { type: 'notify.focused' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'notify.invalid value' resolution: InvalidValueResolution | null value: Array<PortableTextBlock> | undefined } | { type: 'notify.loading' } | { type: 'notify.read only' } | { type: 'notify.ready' } | { type: 'notify.selection' selection: EditorSelection } | { type: 'notify.value changed' value: Array<PortableTextBlock> | undefined } | { type: 'notify.unset' previousValue: Array<PortableTextBlock> } | { type: 'dragstart' origin: Pick<EventPosition, 'selection'> ghost?: HTMLElement } | { type: 'dragend' } | { type: 'drop' }, undefined, never, never, never, never, | PatchEvent | InternalPatchEvent | MutationEvent | PatchesEvent | { type: 'blurred' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'done loading' } | { type: 'editable' } | { type: 'error' name: string description: string data: unknown } | { type: 'focused' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'invalid value' resolution: InvalidValueResolution | null value: Array<PortableTextBlock> | undefined } | { type: 'loading' } | { type: 'read only' } | { type: 'ready' } | { type: 'selection' selection: EditorSelection } | { type: 'value changed' value: Array<PortableTextBlock> | undefined } | UnsetEvent > } readonly 'notify.error': { readonly actions: ActionFunction< { behaviors: Set<Behavior> converters: Set<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string pendingEvents: Array<InternalPatchEvent | MutationEvent> schema: EditorSchema initialReadOnly: boolean maxBlocks: number | undefined selection: EditorSelection incomingValue: Array<PortableTextBlock> | undefined internalDrag?: { ghost?: HTMLElement origin: Pick<EventPosition, 'selection'> } slateEditor?: PortableTextSlateEditor }, { type: 'notify.error' name: string description: string data: unknown }, | InternalPatchEvent | MutationEvent | { type: 'add behavior' behavior: Behavior } | { type: 'remove behavior' behavior: Behavior } | { type: 'update readOnly' readOnly: boolean } | { type: 'update schema' schema: EditorSchema } | { type: 'update behaviors' behaviors: Array<Behavior> } | { type: 'update key generator' keyGenerator: () => string } | { type: 'update value' value: Array<PortableTextBlock> | undefined } | { type: 'update maxBlocks' maxBlocks: number | undefined } | PatchesEvent | { type: 'blur' editor: PortableTextSlateEditor } | { type: 'focus' editor: PortableTextSlateEditor } | { type: 'normalizing' } | { type: 'done normalizing' } | { type: 'done syncing initial value' } | { type: 'behavior event' behaviorEvent: BehaviorEvent editor: PortableTextSlateEditor nativeEvent?: { preventDefault: () => void } } | { type: 'notify.patch' patch: Patch } | { type: 'notify.mutation' patches: Array<Patch> snapshot: Array<PortableTextBlock> | undefined value: Array<PortableTextBlock> | undefined } | { type: 'notify.blurred' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'notify.done loading' } | { type: 'notify.editable' } | { type: 'notify.error' name: string description: string data: unknown } | { type: 'notify.focused' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'notify.invalid value' resolution: InvalidValueResolution | null value: Array<PortableTextBlock> | undefined } | { type: 'notify.loading' } | { type: 'notify.read only' } | { type: 'notify.ready' } | { type: 'notify.selection' selection: EditorSelection } | { type: 'notify.value changed' value: Array<PortableTextBlock> | undefined } | { type: 'notify.unset' previousValue: Array<PortableTextBlock> } | { type: 'dragstart' origin: Pick<EventPosition, 'selection'> ghost?: HTMLElement } | { type: 'dragend' } | { type: 'drop' }, undefined, never, never, never, never, | PatchEvent | InternalPatchEvent | MutationEvent | PatchesEvent | { type: 'blurred' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'done loading' } | { type: 'editable' } | { type: 'error' name: string description: string data: unknown } | { type: 'focused' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'invalid value' resolution: InvalidValueResolution | null value: Array<PortableTextBlock> | undefined } | { type: 'loading' } | { type: 'read only' } | { type: 'ready' } | { type: 'selection' selection: EditorSelection } | { type: 'value changed' value: Array<PortableTextBlock> | undefined } | UnsetEvent > } readonly 'notify.invalid value': { readonly actions: ActionFunction< { behaviors: Set<Behavior> converters: Set<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string pendingEvents: Array<InternalPatchEvent | MutationEvent> schema: EditorSchema initialReadOnly: boolean maxBlocks: number | undefined selection: EditorSelection incomingValue: Array<PortableTextBlock> | undefined internalDrag?: { ghost?: HTMLElement origin: Pick<EventPosition, 'selection'> } slateEditor?: PortableTextSlateEditor }, { type: 'notify.invalid value' resolution: InvalidValueResolution | null value: Array<PortableTextBlock> | undefined }, | InternalPatchEvent | MutationEvent | { type: 'add behavior' behavior: Behavior } | { type: 'remove behavior' behavior: Behavior } | { type: 'update readOnly' readOnly: boolean } | { type: 'update schema' schema: EditorSchema } | { type: 'update behaviors' behaviors: Array<Behavior> } | { type: 'update key generator' keyGenerator: () => string } | { type: 'update value' value: Array<PortableTextBlock> | undefined } | { type: 'update maxBlocks' maxBlocks: number | undefined } | PatchesEvent | { type: 'blur' editor: PortableTextSlateEditor } | { type: 'focus' editor: PortableTextSlateEditor } | { type: 'normalizing' } | { type: 'done normalizing' } | { type: 'done syncing initial value' } | { type: 'behavior event' behaviorEvent: BehaviorEvent editor: PortableTextSlateEditor nativeEvent?: { preventDefault: () => void } } | { type: 'notify.patch' patch: Patch } | { type: 'notify.mutation' patches: Array<Patch> snapshot: Array<PortableTextBlock> | undefined value: Array<PortableTextBlock> | undefined } | { type: 'notify.blurred' ev