UNPKG

@portabletext/editor

Version:

Portable Text Editor made in React

1,935 lines (1,890 loc) 128 kB
import {Patch} from '@portabletext/patches' import type { ArrayDefinition, ArraySchemaType, BlockDecoratorDefinition, BlockListDefinition, BlockStyleDefinition, KeyedSegment, ObjectSchemaType, Path, PortableTextListBlock, PortableTextObject, TypedObject, } from '@sanity/types' import { PortableTextBlock, PortableTextChild, PortableTextSpan, PortableTextTextBlock, } from '@sanity/types' import type { BaseSyntheticEvent, ClipboardEvent as ClipboardEvent_2, KeyboardEvent as KeyboardEvent_2, default as React_2, ReactElement, RefObject, } from 'react' import { Component, FocusEvent as FocusEvent_2, ForwardRefExoticComponent, JSX, MutableRefObject, PropsWithChildren, RefAttributes, TextareaHTMLAttributes, } from 'react' import type {Observable, Subject} from 'rxjs' import {Descendant} from 'slate' import type {Operation} 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 type {EventObject, Snapshot} from 'xstate' import {GuardArgs} from 'xstate/guards' import { Editor as Editor_2, InvalidValueResolution as InvalidValueResolution_2, } from '..' declare type AbstractBehaviorEvent = | { type: StrictExtract<SyntheticBehaviorEventType, 'annotation.toggle'> annotation: { name: string value: { [prop: string]: unknown } } } | { type: StrictExtract<SyntheticBehaviorEventType, 'decorator.toggle'> decorator: string at?: { anchor: BlockOffset focus: BlockOffset } } | { type: StrictExtract<SyntheticBehaviorEventType, 'delete.backward'> unit: 'character' | 'word' | 'line' | 'block' } | { type: StrictExtract<SyntheticBehaviorEventType, 'delete.block'> at: [KeyedSegment] } | { type: StrictExtract<SyntheticBehaviorEventType, 'delete.forward'> unit: 'character' | 'word' | 'line' | 'block' } | { type: StrictExtract<SyntheticBehaviorEventType, 'delete.text'> at: { anchor: BlockOffset focus: BlockOffset } } | { type: StrictExtract<SyntheticBehaviorEventType, 'deserialize'> originEvent: | PickFromUnion< NativeBehaviorEvent, 'type', 'drag.drop' | 'clipboard.paste' > | InputBehaviorEvent } | { type: StrictExtract<SyntheticBehaviorEventType, 'serialize'> originEvent: PickFromUnion< NativeBehaviorEvent, 'type', 'clipboard.copy' | 'clipboard.cut' | 'drag.dragstart' > } | { type: StrictExtract<SyntheticBehaviorEventType, 'deserialization.success'> mimeType: MIMEType data: Array<PortableTextBlock> originEvent: | PickFromUnion< NativeBehaviorEvent, 'type', 'drag.drop' | 'clipboard.paste' > | InputBehaviorEvent } | { type: StrictExtract<SyntheticBehaviorEventType, 'deserialization.failure'> mimeType: MIMEType reason: string originEvent: | PickFromUnion< NativeBehaviorEvent, 'type', 'drag.drop' | 'clipboard.paste' > | InputBehaviorEvent } | { type: StrictExtract<SyntheticBehaviorEventType, 'serialization.success'> mimeType: MIMEType data: string originEvent: PickFromUnion< NativeBehaviorEvent, 'type', 'clipboard.copy' | 'clipboard.cut' | 'drag.dragstart' > } | { type: StrictExtract<SyntheticBehaviorEventType, 'serialization.failure'> mimeType: MIMEType reason: string originEvent: PickFromUnion< NativeBehaviorEvent, 'type', 'clipboard.copy' | 'clipboard.cut' | 'drag.dragstart' > } | { type: StrictExtract<SyntheticBehaviorEventType, 'insert.blocks'> blocks: Array<BlockWithOptionalKey> placement: InsertPlacement select?: 'start' | 'end' | 'none' } | { type: StrictExtract<SyntheticBehaviorEventType, 'insert.break'> } | { type: StrictExtract<SyntheticBehaviorEventType, 'insert.soft break'> } | { type: StrictExtract<SyntheticBehaviorEventType, 'list item.add'> listItem: string } | { type: StrictExtract<SyntheticBehaviorEventType, 'list item.remove'> listItem: string } | { type: StrictExtract<SyntheticBehaviorEventType, 'list item.toggle'> listItem: string } | { type: StrictExtract<SyntheticBehaviorEventType, 'move.block down'> at: [KeyedSegment] } | { type: StrictExtract<SyntheticBehaviorEventType, 'move.block up'> at: [KeyedSegment] } | { type: StrictExtract<SyntheticBehaviorEventType, 'select.previous block'> select?: 'start' | 'end' } | { type: StrictExtract<SyntheticBehaviorEventType, 'select.next block'> select?: 'start' | 'end' } | { type: StrictExtract<SyntheticBehaviorEventType, 'split'> } | { type: StrictExtract<SyntheticBehaviorEventType, 'style.add'> style: string } | { type: StrictExtract<SyntheticBehaviorEventType, 'style.remove'> style: string } | { type: StrictExtract<SyntheticBehaviorEventType, 'style.toggle'> style: string } /************************************** * Abstract events **************************************/ declare const abstractBehaviorEventTypes: readonly [ 'annotation.toggle', 'decorator.toggle', 'delete.backward', 'delete.block', 'delete.forward', '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', 'split', 'style.add', 'style.remove', 'style.toggle', ] /** * @public */ export declare type AddedAnnotationPaths = { /** * @deprecated An annotation may be applied to multiple blocks, resulting * in multiple `markDef`'s being created. Use `markDefPaths` instead. */ markDefPath: Path markDefPaths: Array<Path> /** * @deprecated Does not return anything meaningful since an annotation * can span multiple blocks and spans. If references the span closest * to the focus point of the selection. */ spanPath: Path } /** * @public */ export 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: SyntheticBehaviorEvent } | { type: 'forward' event: NativeBehaviorEvent | SyntheticBehaviorEvent | CustomBehaviorEvent } | { type: 'raise' event: SyntheticBehaviorEvent | CustomBehaviorEvent } | { type: 'effect' effect: () => void } /** * @beta */ declare type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = ( payload: { snapshot: EditorSnapshot event: TBehaviorEvent dom: EditorDom }, guardResponse: TGuardResponse, ) => Array<BehaviorAction> declare type BehaviorConfig = { behavior: Behavior priority: EditorPriority } /** * @beta */ declare type BehaviorEvent = | SyntheticBehaviorEvent | NativeBehaviorEvent | CustomBehaviorEvent declare type BehaviorEventTypeNamespace = | SyntheticBehaviorEventNamespace | NativeBehaviorEventNamespace | CustomBehaviorEventNamespace /** * @beta */ declare type BehaviorGuard<TBehaviorEvent, TGuardResponse> = (payload: { snapshot: EditorSnapshot event: TBehaviorEvent dom: EditorDom }) => TGuardResponse | false /** @beta */ export declare interface BlockAnnotationRenderProps { block: PortableTextBlock children: ReactElement<any> editorElementRef: RefObject<HTMLElement | null> focused: boolean path: Path schemaType: ObjectSchemaType selected: boolean /** @deprecated Use `schemaType` instead */ type: ObjectSchemaType value: PortableTextObject } /** @beta */ export declare interface BlockChildRenderProps { annotations: PortableTextObject[] children: ReactElement<any> editorElementRef: RefObject<HTMLElement | null> focused: boolean path: Path selected: boolean schemaType: ObjectSchemaType /** @deprecated Use `schemaType` instead */ type: ObjectSchemaType value: PortableTextChild } /** @beta */ export declare interface BlockDecoratorRenderProps { children: ReactElement<any> editorElementRef: RefObject<HTMLElement | null> focused: boolean path: Path schemaType: BlockDecoratorDefinition selected: boolean /** @deprecated Use `schemaType` instead */ type: BlockDecoratorDefinition value: string } /** @beta */ export declare interface BlockListItemRenderProps { block: PortableTextTextBlock children: ReactElement<any> editorElementRef: RefObject<HTMLElement | null> focused: boolean level: number path: Path schemaType: BlockListDefinition selected: boolean value: string } /** * @beta */ export declare type BlockOffset = { path: [KeyedSegment] offset: number } declare type BlockPath = [ { _key: string }, ] /** @beta */ export declare interface BlockRenderProps { children: ReactElement<any> editorElementRef: RefObject<HTMLElement | null> focused: boolean level?: number listItem?: string path: BlockPath selected: boolean style?: string schemaType: ObjectSchemaType /** @deprecated Use `schemaType` instead */ type: ObjectSchemaType value: PortableTextBlock } /** @beta */ export declare interface BlockStyleRenderProps { block: PortableTextTextBlock children: ReactElement<any> editorElementRef: RefObject<HTMLElement | null> focused: boolean path: Path selected: boolean schemaType: BlockStyleDefinition value: string } declare type BlockWithOptionalKey = | TextBlockWithOptionalKey | ObjectBlockWithOptionalKey /** * The editor blurred * @beta */ export declare type BlurChange = { type: 'blur' event: FocusEvent_2<HTMLDivElement, Element> } 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'> } /** * The editor was either connected or disconnected to the network * To show out of sync warnings etc when in collaborative mode. * @beta * @deprecated The change is no longer emitted * */ export declare type ConnectionChange = { type: 'connection' value: 'online' | 'offline' } 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}` /** * @public * A helper wrapper that adds editor support, such as autocomplete and type checking, for a schema definition. * @example * ```ts * import { defineSchema } from '@portabletext/editor' * * const schemaDefinition = defineSchema({ * decorators: [{name: 'strong'}, {name: 'em'}, {name: 'underline'}], * annotations: [{name: 'link'}], * styles: [ * {name: 'normal'}, * {name: 'h1'}, * {name: 'h2'}, * {name: 'h3'}, * {name: 'blockquote'}, * ], * lists: [], * inlineObjects: [], * blockObjects: [], * } * ``` */ export declare function defineSchema< const TSchemaDefinition extends SchemaDefinition, >(definition: TSchemaDefinition): TSchemaDefinition 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: { clientX: number clientY: number 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 } dragOrigin?: Pick<EventPosition, 'selection'> position: EventPosition } | { type: StrictExtract<NativeBehaviorEventType, 'drag.drop'> originEvent: { dataTransfer: DataTransfer } dragOrigin?: Pick<EventPosition, 'selection'> position: EventPosition } | { type: StrictExtract<NativeBehaviorEventType, 'drag.dragleave'> originEvent: { dataTransfer: DataTransfer } } /** @beta */ export 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 */ export declare interface EditableAPIDeleteOptions { mode?: 'blocks' | 'children' | 'selected' } /** * @public */ export declare type Editor = { getSnapshot: () => EditorSnapshot /** * @beta */ registerBehavior: (config: {behavior: Behavior}) => () => void send: (event: EditorEvent) => void on: ActorRef<Snapshot<unknown>, EventObject, EditorEmittedEvent>['on'] } /** * @internal */ declare type EditorActor = ActorRefFrom<typeof editorMachine> /** * When the editor changes, it will emit a change item describing the change * @beta */ export declare type EditorChange = | BlurChange | ConnectionChange | ErrorChange | FocusChange | InvalidValue | LoadingChange | MutationChange | PatchChange | ReadyChange | RedoChange | SelectionChange | UndoChange | UnsetChange | ValueChange /** * @beta */ export declare type EditorChanges = Subject<EditorChange> /** * @public */ export declare type EditorConfig = { /** * @beta */ keyGenerator?: () => string /** * @deprecated Will be removed in the next major version */ maxBlocks?: number readOnly?: boolean initialValue?: Array<PortableTextBlock> } & ( | { schemaDefinition: SchemaDefinition schema?: undefined } | { schemaDefinition?: undefined schema: ArraySchemaType<PortableTextBlock> | ArrayDefinition } ) /** * @public */ export declare type EditorContext = { converters: Array<Converter> keyGenerator: () => string readOnly: boolean schema: EditorSchema selection: EditorSelection value: Array<PortableTextBlock> } declare type EditorDom = { getBlockNodes: (snapshot: EditorSnapshot) => Array<Node> getChildNodes: (snapshot: EditorSnapshot) => Array<Node> /** * Let the Editor set the drag ghost. This is to be sure that it will get * properly removed again when the drag ends. */ setDragGhost: ({ event, ghost, }: { event: PickFromUnion<BehaviorEvent, 'type', 'drag.dragstart'> ghost: { element: HTMLElement x: number y: number } }) => void } /** * @public */ export declare type EditorEmittedEvent = | { type: 'blurred' event: FocusEvent_2<HTMLDivElement, Element> } | { /** * @deprecated */ type: 'done loading' } | { type: 'editable' } | ErrorEvent_2 | { type: 'focused' event: FocusEvent_2<HTMLDivElement, Element> } | { type: 'invalid value' resolution: InvalidValueResolution | null value: Array<PortableTextBlock> | undefined } | { /** * @deprecated */ type: 'loading' } | MutationEvent | PatchEvent | { type: 'read only' } | { type: 'ready' } | { type: 'selection' selection: EditorSelection } | { type: 'value changed' value: Array<PortableTextBlock> | undefined } /** * @public */ export declare type EditorEvent = | ExternalEditorEvent | ExternalBehaviorEvent | { type: 'update value' value: Array<PortableTextBlock> | undefined } /** * @public * @deprecated * This component has been renamed. Use `EventListenerPlugin` instead. * * ``` * import {EventListenerPlugin} from '@portabletext/editor/plugins' * ``` */ export declare function EditorEventListener(props: { on: (event: EditorEmittedEvent) => void }): null /** * @internal */ declare const editorMachine: StateMachine< { behaviors: Set<BehaviorConfig> converters: Set<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string pendingEvents: Array<InternalPatchEvent | MutationEvent> pendingIncomingPatchesEvents: Array<PatchesEvent> schema: EditorSchema initialReadOnly: boolean maxBlocks: number | undefined selection: EditorSelection initialValue: Array<PortableTextBlock> | undefined internalDrag?: { origin: Pick<EventPosition, 'selection'> } dragGhost?: HTMLElement slateEditor?: PortableTextSlateEditor }, | InternalPatchEvent | MutationEvent | PatchesEvent | { type: 'update readOnly' readOnly: boolean } | { type: 'update maxBlocks' maxBlocks: number | undefined } | { type: 'add behavior' behaviorConfig: BehaviorConfig } | { type: 'remove behavior' behaviorConfig: BehaviorConfig } | { type: 'blur' editor: PortableTextSlateEditor } | { type: 'focus' editor: PortableTextSlateEditor } | { type: 'normalizing' } | { type: 'update selection' selection: EditorSelection } | { type: 'done normalizing' } | { type: 'done syncing value' } | { type: 'syncing value' } | { type: 'behavior event' behaviorEvent: BehaviorEvent editor: PortableTextSlateEditor nativeEvent?: { preventDefault: () => void } } | { type: 'set drag ghost' ghost: HTMLElement } | { type: 'dragstart' ghost?: HTMLElement origin: Pick<EventPosition, 'selection'> } | { 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 } '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 } 'defer incoming patches': { type: 'defer incoming patches' params: NonReducibleUnknown } 'emit pending incoming patches': { type: 'emit pending incoming patches' params: NonReducibleUnknown } 'clear pending incoming patches': { type: 'clear pending incoming patches' 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' | { 'set up': { 'value sync': 'syncing value' | 'idle' 'writing': | 'dirty' | { pristine: 'normalizing' | 'idle' } } } }, 'dragging internally', { converters?: Array<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string maxBlocks?: number readOnly?: boolean schema: EditorSchema initialValue?: Array<PortableTextBlock> }, NonReducibleUnknown, | 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_2 | null value: Array<PortableTextBlock> | undefined } | { type: 'loading' } | { type: 'read only' } | { type: 'ready' } | { type: 'selection' selection: EditorSelection } | { type: 'value changed' value: Array<PortableTextBlock> | undefined }, 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: { converters?: Array<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string maxBlocks?: number readOnly?: boolean schema: EditorSchema initialValue?: Array<PortableTextBlock> } self: ActorRef< MachineSnapshot< { behaviors: Set<BehaviorConfig> converters: Set<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string pendingEvents: Array<InternalPatchEvent | MutationEvent> pendingIncomingPatchesEvents: Array<PatchesEvent> schema: EditorSchema initialReadOnly: boolean maxBlocks: number | undefined selection: EditorSelection initialValue: Array<PortableTextBlock> | undefined internalDrag?: { origin: Pick<EventPosition, 'selection'> } dragGhost?: HTMLElement slateEditor?: PortableTextSlateEditor }, | InternalPatchEvent | MutationEvent | PatchesEvent | { type: 'update readOnly' readOnly: boolean } | { type: 'update maxBlocks' maxBlocks: number | undefined } | { type: 'add behavior' behaviorConfig: BehaviorConfig } | { type: 'remove behavior' behaviorConfig: BehaviorConfig } | { type: 'blur' editor: PortableTextSlateEditor } | { type: 'focus' editor: PortableTextSlateEditor } | { type: 'normalizing' } | { type: 'update selection' selection: EditorSelection } | { type: 'done normalizing' } | { type: 'done syncing value' } | { type: 'syncing value' } | { type: 'behavior event' behaviorEvent: BehaviorEvent editor: PortableTextSlateEditor nativeEvent?: { preventDefault: () => void } } | { type: 'set drag ghost' ghost: HTMLElement } | { type: 'dragstart' ghost?: HTMLElement origin: Pick<EventPosition, 'selection'> } | { type: 'dragend' } | { type: 'drop' }, Record<string, AnyActorRef | undefined>, StateValue, string, unknown, any, any >, | InternalPatchEvent | MutationEvent | PatchesEvent | { type: 'update readOnly' readOnly: boolean } | { type: 'update maxBlocks' maxBlocks: number | undefined } | { type: 'add behavior' behaviorConfig: BehaviorConfig } | { type: 'remove behavior' behaviorConfig: BehaviorConfig } | { type: 'blur' editor: PortableTextSlateEditor } | { type: 'focus' editor: PortableTextSlateEditor } | { type: 'normalizing' } | { type: 'update selection' selection: EditorSelection } | { type: 'done normalizing' } | { type: 'done syncing value' } | { type: 'syncing value' } | { type: 'behavior event' behaviorEvent: BehaviorEvent editor: PortableTextSlateEditor nativeEvent?: { preventDefault: () => void } } | { type: 'set drag ghost' ghost: HTMLElement } | { type: 'dragstart' ghost?: HTMLElement origin: Pick<EventPosition, 'selection'> } | { type: 'dragend' } | { type: 'drop' }, AnyEventObject > }) => { behaviors: Set<never> converters: Set<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string pendingEvents: never[] pendingIncomingPatchesEvents: never[] schema: EditorSchema selection: null initialReadOnly: boolean maxBlocks: number | undefined initialValue: PortableTextBlock[] | undefined } readonly on: { readonly 'add behavior': { readonly actions: 'add behavior to context' } readonly 'remove behavior': { readonly actions: 'remove behavior from context' } readonly 'update maxBlocks': { readonly actions: ActionFunction< { behaviors: Set<BehaviorConfig> converters: Set<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string pendingEvents: Array<InternalPatchEvent | MutationEvent> pendingIncomingPatchesEvents: Array<PatchesEvent> schema: EditorSchema initialReadOnly: boolean maxBlocks: number | undefined selection: EditorSelection initialValue: Array<PortableTextBlock> | undefined internalDrag?: { origin: Pick<EventPosition, 'selection'> } dragGhost?: HTMLElement slateEditor?: PortableTextSlateEditor }, { type: 'update maxBlocks' maxBlocks: number | undefined }, | InternalPatchEvent | MutationEvent | PatchesEvent | { type: 'update readOnly' readOnly: boolean } | { type: 'update maxBlocks' maxBlocks: number | undefined } | { type: 'add behavior' behaviorConfig: BehaviorConfig } | { type: 'remove behavior' behaviorConfig: BehaviorConfig } | { type: 'blur' editor: PortableTextSlateEditor } | { type: 'focus' editor: PortableTextSlateEditor } | { type: 'normalizing' } | { type: 'update selection' selection: EditorSelection } | { type: 'done normalizing' } | { type: 'done syncing value' } | { type: 'syncing value' } | { type: 'behavior event' behaviorEvent: BehaviorEvent editor: PortableTextSlateEditor nativeEvent?: { preventDefault: () => void } } | { type: 'set drag ghost' ghost: HTMLElement } | { type: 'dragstart' ghost?: HTMLElement origin: Pick<EventPosition, 'selection'> } | { type: 'dragend' } | { type: 'drop' }, undefined, never, never, never, never, never > } readonly 'update selection': { readonly actions: readonly [ ActionFunction< { behaviors: Set<BehaviorConfig> converters: Set<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string pendingEvents: Array<InternalPatchEvent | MutationEvent> pendingIncomingPatchesEvents: Array<PatchesEvent> schema: EditorSchema initialReadOnly: boolean maxBlocks: number | undefined selection: EditorSelection initialValue: Array<PortableTextBlock> | undefined internalDrag?: { origin: Pick<EventPosition, 'selection'> } dragGhost?: HTMLElement slateEditor?: PortableTextSlateEditor }, { type: 'update selection' selection: EditorSelection }, | InternalPatchEvent | MutationEvent | PatchesEvent | { type: 'update readOnly' readOnly: boolean } | { type: 'update maxBlocks' maxBlocks: number | undefined } | { type: 'add behavior' behaviorConfig: BehaviorConfig } | { type: 'remove behavior' behaviorConfig: BehaviorConfig } | { type: 'blur' editor: PortableTextSlateEditor } | { type: 'focus' editor: PortableTextSlateEditor } | { type: 'normalizing' } | { type: 'update selection' selection: EditorSelection } | { type: 'done normalizing' } | { type: 'done syncing value' } | { type: 'syncing value' } | { type: 'behavior event' behaviorEvent: BehaviorEvent editor: PortableTextSlateEditor nativeEvent?: { preventDefault: () => void } } | { type: 'set drag ghost' ghost: HTMLElement } | { type: 'dragstart' ghost?: HTMLElement origin: Pick<EventPosition, 'selection'> } | { type: 'dragend' } | { type: 'drop' }, undefined, never, never, never, never, never >, ActionFunction< { behaviors: Set<BehaviorConfig> converters: Set<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string pendingEvents: Array<InternalPatchEvent | MutationEvent> pendingIncomingPatchesEvents: Array<PatchesEvent> schema: EditorSchema initialReadOnly: boolean maxBlocks: number | undefined selection: EditorSelection initialValue: Array<PortableTextBlock> | undefined internalDrag?: { origin: Pick<EventPosition, 'selection'> } dragGhost?: HTMLElement slateEditor?: PortableTextSlateEditor }, { type: 'update selection' selection: EditorSelection }, | InternalPatchEvent | MutationEvent | PatchesEvent | { type: 'update readOnly' readOnly: boolean } | { type: 'update maxBlocks' maxBlocks: number | undefined } | { type: 'add behavior' behaviorConfig: BehaviorConfig } | { type: 'remove behavior' behaviorConfig: BehaviorConfig } | { type: 'blur' editor: PortableTextSlateEditor } | { type: 'focus' editor: PortableTextSlateEditor } | { type: 'normalizing' } | { type: 'update selection' selection: EditorSelection } | { type: 'done normalizing' } | { type: 'done syncing value' } | { type: 'syncing value' } | { type: 'behavior event' behaviorEvent: BehaviorEvent editor: PortableTextSlateEditor nativeEvent?: { preventDefault: () => void } } | { type: 'set drag ghost' ghost: HTMLElement } | { type: 'dragstart' ghost?: HTMLElement origin: Pick<EventPosition, 'selection'> } | { type: 'dragend' } | { type: 'drop' }, undefined, never, never, never, never, | 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_2 | null value: Array<PortableTextBlock> | undefined } | { type: 'loading' } | { type: 'read only' } | { type: 'ready' } | { type: 'selection' selection: EditorSelection } | { type: 'value changed' value: Array<PortableTextBlock> | undefined } >, ] } readonly 'set drag ghost': { readonly actions: ActionFunction< { behaviors: Set<BehaviorConfig> converters: Set<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string pendingEvents: Array<InternalPatchEvent | MutationEvent> pendingIncomingPatchesEvents: Array<PatchesEvent> schema: EditorSchema initialReadOnly: boolean maxBlocks: number | undefined selection: EditorSelection initialValue: Array<PortableTextBlock> | undefined internalDrag?: { origin: Pick<EventPosition, 'selection'> } dragGhost?: HTMLElement slateEditor?: PortableTextSlateEditor }, { type: 'set drag ghost' ghost: HTMLElement }, | InternalPatchEvent | MutationEvent | PatchesEvent | { type: 'update readOnly' readOnly: boolean } | { type: 'update maxBlocks' maxBlocks: number | undefined } | { type: 'add behavior' behaviorConfig: BehaviorConfig } | { type: 'remove behavior' behaviorConfig: BehaviorConfig } | { type: 'blur' editor: PortableTextSlateEditor } | { type: 'focus' editor: PortableTextSlateEditor } | { type: 'normalizing' } | { type: 'update selection' selection: EditorSelection } | { type: 'done normalizing' } | { type: 'done syncing value' } | { type: 'syncing value' } | { type: 'behavior event' behaviorEvent: BehaviorEvent editor: PortableTextSlateEditor nativeEvent?: { preventDefault: () => void } } | { type: 'set drag ghost' ghost: HTMLElement } | { type: 'dragstart' ghost?: HTMLElement origin: Pick<EventPosition, 'selection'> } | { type: 'dragend' } | { type: 'drop' }, undefined, never, never, never, never, never > } } readonly type: 'parallel' readonly states: { readonly 'edit mode': { readonly initial: 'read only' readonly states: { readonly 'read only': { readonly initial: 'determine initial edit mode' readonly on: { readonly 'behavior event': { readonly actions: 'handle behavior event' readonly guard: ({ event, }: GuardArgs< { behaviors: Set<BehaviorConfig> converters: Set<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string pendingEvents: Array<InternalPatchEvent | MutationEvent> pendingIncomingPatchesEvents: Array<PatchesEvent> schema: EditorSchema initialReadOnly: boolean maxBlocks: number | undefined selection: EditorSelection initialValue: Array<PortableTextBlock> | undefined internalDrag?: { origin: Pick<EventPosition, 'selection'> } dragGhost?: HTMLElement slateEditor?: PortableTextSlateEditor }, { type: 'behavior event' behaviorEvent: BehaviorEvent editor: PortableTextSlateEditor nativeEvent?: { preventDefault: () => void } } >) => boolean } } readonly states: { readonly 'determine initial edit mode': { readonly entry: readonly [() => void] readonly exit: readonly [() => void] readonly on: { readonly 'done syncing value': readonly [ { readonly target: '#editor.edit mode.read only.read only' readonly guard: ({ context, }: GuardArgs< { behaviors: Set<BehaviorConfig> converters: Set<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string pendingEvents: Array< InternalPatchEvent | MutationEvent > pendingIncomingPatchesEvents: Array<PatchesEvent> schema: EditorSchema initialReadOnly: boolean maxBlocks: number | undefined selection: EditorSelection initialValue: Array<PortableTextBlock> | undefined internalDrag?: { origin: Pick<EventPosition, 'selection'> } dragGhost?: HTMLElement slateEditor?: PortableTextSlateEditor }, { type: 'done syncing value' } >) => boolean }, { readonly target: '#editor.edit mode.editable' }, ] } } readonly 'read only': { readonly entry: readonly [() => void] readonly exit: readonly [() => void] readonly on: { readonly 'update readOnly': { readonly guard: ({ event, }: GuardArgs< { behaviors: Set<BehaviorConfig> converters: Set<Converter> getLegacySchema: () => PortableTextMemberSchemaTypes keyGenerator: () => string pendingEvents: Array<InternalPatchEvent | MutationEvent> pendingIncomingPatchesEvents: Array<PatchesEvent> schema: EditorSchema initialReadOnly: boolean maxBlocks: number | undefined selection: EditorSelection initialValue: Array<PortableTextBlock> | undefined