import type { Draft } from 'mutative'; /** Shared type contracts for Plate plugin definitions. */ import type { DefinitionOf as RuntimeDefinitionOf, RuntimePluginDependencyReference, RuntimePluginDefinition, RuntimePluginReference, EditorCoreStateView, EditorDirectUpdate, EditorReadMethodTree, EditorUpdateTransaction, Editor as RuntimeEditor, Element, Path, PropertyValueDescriptor, SchemaContent, SchemaContentOptions, SchemaContentRootContribution, SchemaElement, SchemaProperty, SchemaPropertyDefinition, SchemaPropertyHandle, SchemaTextPropertyOptions, Text, EditorSchemaSourceProvider, RuntimePluginDependencyReferenceFor, RuntimePluginInstalledCapabilitiesOf, } from '../../facade'; import type { AnyObject } from '../types/AnyObject'; import type { Nullable } from '../types/Nullable'; import type { InferPluginAdditionalSchemaPropertyHandles, InferPluginElementType, InferPluginMarkKey, InferPluginSchema, InferPluginSchemaContribution, } from './pluginSchemaModel.internal'; declare const pluginDefinition: unique symbol; /** Exact normalized definition witness carried by every plugin descriptor. */ export interface PluginDefinitionWitness { readonly [pluginDefinition]: (definition: D) => D; } type ExactPluginDefinitionOf

= P extends PluginDefinitionWitness ? D : never; /** * Compact inferred definition carried by every Base plugin descriptor. * * Author callbacks are normalized to their capability results before reaching * this boundary, so declarations do not serialize callback graphs. */ export type BasePluginDefinition = Readonly<{ activate?: true; api?: object; dataTransferFormats?: true; formats?: true; commands?: true; conflicts?: ReadonlyArray>; contributions?: true; corrections?: true; decorate?: true; dependencies?: ReadonlyArray>; editOnly?: true; effectTypes?: true; enabled?: boolean; initialState?: object; initialViewState?: object; inject?: true; inputRules?: true; name: string; on?: true; override?: true; read?: EditorReadMethodTree; readMiddleware?: true; render?: true; rules?: true; schema?: PluginSchemaDeclaration; selectors?: object; shortcuts?: true; stateFields?: true; targetPlugins?: ReadonlyArray; update?: object; validate?: true; }>; /** Erased runtime boundary for heterogeneous plugin definitions. */ export type AnyBasePluginDefinition = BasePluginDefinition; type PublicDependencyReference

= P extends PluginReference ? PluginReference : P extends Readonly<{ enabled: infer TEnabled extends boolean; name: infer TName extends string; }> ? Readonly<{ enabled: TEnabled; name: TName }> : P extends Readonly<{ name: infer TName extends string }> ? Readonly<{ name: TName }> : RuntimePluginDependencyReference; type PublicDependencyReferences = TReferences extends readonly unknown[] ? { readonly [TIndex in keyof TReferences]: PublicDependencyReference< TReferences[TIndex] >; } : readonly []; type PublicPluginDefinition = Readonly<{ [ TKey in keyof D as TKey extends '__pluginWritableProperties' ? never : TKey ]: TKey extends 'conflicts' | 'dependencies' ? PublicDependencyReferences : D[TKey]; }>; /** Extract the exact normalized public definition from a Base or Plate descriptor. */ export type DefinitionOf

= P extends unknown ? [ExactPluginDefinitionOf

] extends [never] ? RuntimeDefinitionOf

extends infer D extends AnyBasePluginDefinition ? D : never : ExactPluginDefinitionOf

extends infer D extends AnyBasePluginDefinition ? PublicPluginDefinition : never : never; type IsAny = 0 extends 1 & T ? true : false; type HasSchemaProperties = [ keyof InferPluginAdditionalSchemaPropertyHandles, ] extends [never] ? false : true; /** Primary persisted identity exposed by one exact consumer portal. */ export type PluginConsumerSchemaView< C extends AnyBasePluginDefinition = BasePluginDefinition, > = [InferPluginElementType] extends [never] ? [InferPluginMarkKey] extends [never] ? never : Readonly<{ key: InferPluginMarkKey }> : Readonly<{ type: InferPluginElementType }>; type DynamicPluginAuthorSchemaView = Readonly<{ key?: string; properties?: Readonly>; type?: string; }>; type ExactPluginAuthorSchemaView = ([ InferPluginElementType, ] extends [never] ? [InferPluginMarkKey] extends [never] ? Readonly> : Readonly<{ key: InferPluginMarkKey }> : Readonly<{ type: InferPluginElementType }>) & (HasSchemaProperties extends true ? Readonly<{ properties: InferPluginAdditionalSchemaPropertyHandles; }> : Readonly>); /** Resolved schema data available while authoring one plugin. */ export type PluginAuthorSchemaView< C extends AnyBasePluginDefinition = BasePluginDefinition, > = IsAny extends true ? DynamicPluginAuthorSchemaView : C extends Readonly<{ schema: PluginSchemaDeclaration }> ? ExactPluginAuthorSchemaView : string extends C['name'] ? DynamicPluginAuthorSchemaView : ExactPluginAuthorSchemaView; type PluginConsumerSchemaField = [ PluginConsumerSchemaView, ] extends [never] ? Readonly> : Readonly<{ schema: PluginConsumerSchemaView }>; type PluginAuthorSchemaField = [ keyof PluginAuthorSchemaView, ] extends [never] ? Readonly> : Readonly<{ schema: PluginAuthorSchemaView }>; export type BaseInjectProps = { /** * Object whose keys are node values and values are classNames which will be * extended. */ classNames?: Record; /** Node key to map to the styles. */ nodeKey?: string; /** * Style key to override. * * @default nodeKey */ styleKey?: string; /** * Text this injection runs on. `'nodeKey'` runs it, `query` and transforms * included, only on text whose node key value is not null or undefined, and * on every text when no node key resolves. `'all'` runs it on every text and * overrides an inherited `'nodeKey'`. Elements are unaffected. * * @default 'all' */ textScope?: 'all' | 'nodeKey'; }; export type PluginBase< C extends AnyBasePluginDefinition = BasePluginDefinition, > = EditorSchemaSourceProvider<() => InferPluginSchemaContribution> & { /** Component or intrinsic HTML tag rendered for this plugin's schema node. */ component?: NodeComponent; /** Unique name for this plugin. */ name: C['name']; /** Plugins that must be installed before this plugin. */ dependencies: InferDependencies; inject: Nullable<{ /** Plugins whose element children are excluded. */ excludeBelowPlugins?: ReadonlyArray; /** Plugins whose elements are excluded. */ excludePlugins?: ReadonlyArray; /** Whether to filter blocks */ isBlock?: boolean; /** Whether to filter elements */ isElement?: boolean; /** Whether to filter leaves */ isLeaf?: boolean; /** Filter nodes with path above this level. */ maxLevel?: number; }>; /** Initial value used to create this plugin's editor-local store. */ initialState: InferPluginStoreState; override: {}; /** Plugins targeted by this plugin's schema and render behavior. */ readonly targetPlugins: InferTargetPlugins; render: Nullable<{ mark?: Readonly<{ /** Optional secondary leaf renderer when the primary component is placed around text. */ leafComponent?: NodeComponent; /** Render the primary component around each leaf or once around the text node. */ placement?: 'leaf' | 'text'; }>; /** * Whether rendering this plugin's element reads content after the element, * such as a table of contents listing every heading. Static rendering * reuses a block while it and every block before it are unchanged; these * elements render again whenever the document changes. */ readsDocument?: boolean; }>; slots: Nullable<{ /** Wraps the Editable content and its lifecycle effects. */ wrapContent?: NodeComponent<{ children: any }>; /** Wraps the complete editor root for the mounted view. */ wrapRoot?: NodeComponent<{ children: any }>; }>; rules: { /** * Defines actions on insert break based on block state. * * - `'default'`: Default behavior * - `'exit'`: Leave the nearest structure through `tx.break.exit`, landing * a block after it. A text block that should be left before its * container, such as a callout, declares `ownsExit` in its schema. * - `'lift'`: Lift the current block out of the nearest matching ancestor * - `'reset'`: Reset block to default paragraph type * - `'lineBreak'`: Insert newline character * - `'deleteExit'`: Delete backward, then leave the nearest structure as * `'exit'` does */ break?: BreakRules; /** * Defines actions on delete based on block state. * * - `'default'`: Default behavior * - `'lift'`: Lift the current block out of the nearest matching ancestor * - `'reset'`: Reset block to default paragraph type */ delete?: DeleteRules; /** Defines the behavior of merging nodes. */ merge?: MergeRules; /** Defines the behavior of normalizing nodes. */ normalize?: NormalizeRules; /** Defines the behavior of selection. */ selection?: SelectionRules; }; /** Pure declarative contribution to the editor schema. */ readonly schema: InferPluginSchema; /** Selectors for the plugin. */ selectors: InferSelectors; /** * Configures edit-only behavior for various plugin functionalities. * * - If `true` (boolean): * * - `render`, `on`, and `inject.nodeProps` are active only when the * editor is NOT read-only. * - If an object ({@link EditOnlyConfig}): Allows fine-grained control: * * - `render`: Edit-only by default (true if not specified). Set to `false` to * always be active. * - `on`: Edit-only by default (true if not specified). Set to `false` to * always be active. * - `inject` (for `inject.nodeProps`): Edit-only by default (true if not * specified). Set to `false` to always be active. */ editOnly?: EditOnlyConfig | boolean; /** * Enables or disables the plugin. Used by Plate to determine if the plugin * should be used. */ enabled?: InferEnabled; }; declare const platePluginReference: unique symbol; export interface PluginReference< TName extends string = string, > extends RuntimePluginReference { /** Plate-owned type projection over the shared plugin descriptor identity. */ readonly [platePluginReference]: true; readonly name: TName; } declare const pluginDependency: unique symbol; /** Exact source carried by an inferred Plate dependency without expanding it. */ export interface PluginDependency { /** * Nominal dependency source. * * @internal */ readonly [pluginDependency]: (plugin: TPlugin) => TPlugin; } /** * Recover the exact source behind one compact Plate dependency. * * @internal */ export type PluginDependencySource

= P extends PluginDependency ? TPlugin : never; type NormalizeRuntimeDefinition = TDefinition extends RuntimePluginDefinition ? Readonly<{ [ TKey in keyof TDefinition as TKey extends | 'schema' | keyof BasePluginDefinition ? TKey extends 'schema' ? never : TKey : never ]: TDefinition[TKey]; }> & Readonly<{ name: TDefinition['name'] }> : never; type DependencyInstalledDefinitionOf

= NormalizeRuntimeDefinition< RuntimePluginInstalledCapabilitiesOf

>; type RuntimeDependencyInstalledDefinitionOf

= [ DependencyInstalledDefinitionOf

, ] extends [never] ? DependencyInstalledDefinitionOf> : DependencyInstalledDefinitionOf

; type SourcePluginDefinitionOf = TSource extends AnyBasePluginDefinition ? TSource : ExactPluginDefinitionOf extends infer D extends AnyBasePluginDefinition ? D : never; type SourcePluginInstalledDefinitionOf

= PluginDependencySource

extends infer TSource ? [TSource] extends [never] ? never : SourcePluginDefinitionOf extends infer D extends AnyBasePluginDefinition ? | D | (D extends { dependencies: infer TDependencies extends readonly unknown[]; } ? SourcePluginInstalledDefinitionOf : never) : never : never; type PluginDependencyInstalledDefinitionOf

= [ SourcePluginInstalledDefinitionOf

, ] extends [never] ? ExactPluginDefinitionOf

| RuntimeDependencyInstalledDefinitionOf

: SourcePluginInstalledDefinitionOf

; type PluginBlockContentOptions = Omit & Readonly<{ default?: PluginReference | SchemaContentOptions['default']; }>; export type PluginSchemaReferences = Readonly<{ /** Plate normal-flow block content, excluding nested structural elements. */ blockContent: (options?: PluginBlockContentOptions) => SchemaContent; }>; export type PluginSchemaContext< C extends AnyBasePluginDefinition = BasePluginDefinition, > = Readonly<{ initialState: Readonly>; name: C['name']; plugins: PluginSchemaReferences; targetElementTypes: readonly string[]; }>; export type PluginSchemaMark = | PropertyValueDescriptor | Readonly< SchemaTextPropertyOptions & { key?: string; property: PropertyValueDescriptor; } >; export type PluginSchemaElement = SchemaElement & Readonly<{ /** Whether this element is legal in Plate normal block content. */ blockContent?: boolean; /** Default persisted discriminator before closed-application overrides. */ type?: string; }>; export type PluginSchemaPropertyMap = Readonly< Record >; type PluginElementSchemaDeclaration = Readonly<{ contentRoots?: readonly SchemaContentRootContribution[]; element: PluginSchemaElement; mark?: never; properties?: PluginSchemaPropertyMap; }>; type PluginSchemaText = Readonly<{ contentRoots?: readonly SchemaContentRootContribution[]; element?: never; mark: PluginSchemaMark; properties?: PluginSchemaPropertyMap; }>; type PluginSchemaProperties = Readonly<{ contentRoots?: readonly SchemaContentRootContribution[]; element?: never; mark?: never; properties: PluginSchemaPropertyMap; }>; type PluginSchemaContentRoots = Readonly<{ contentRoots: readonly SchemaContentRootContribution[]; element?: never; mark?: never; properties?: PluginSchemaPropertyMap; }>; export type PluginSchemaDeclaration = | PluginSchemaContentRoots | PluginElementSchemaDeclaration | PluginSchemaProperties | PluginSchemaText; /** A frozen schema contribution or a pure configured contribution factory. */ export type PluginSchema< C extends AnyBasePluginDefinition = BasePluginDefinition, > = | ((context: PluginSchemaContext) => PluginSchemaDeclaration) | PluginSchemaDeclaration; type PluginRuntimeContext< C extends AnyBasePluginDefinition = BasePluginDefinition, > = Readonly<{ /** API owned by the current plugin, without the plugin-name namespace wrapper. */ api: InferOwnApi; /** Whether this plugin is installed and enabled in the target editor. */ installed: boolean; /** Capability identity and API/update namespace. */ name: C['name']; /** One-shot updates owned by the current plugin, without its name namespace. */ update: EditorDirectUpdate>; /** State-bound reads owned by the current plugin. */ read: InferOwnRead; /** Mutable editor-local state and pure named selectors owned by this plugin. */ store: PluginStore; }>; /** Consumer capabilities projected by one exact plugin portal. */ export type PluginPortalContext< C extends AnyBasePluginDefinition = BasePluginDefinition, > = PluginRuntimeContext & PluginConsumerSchemaField & Readonly<{ /** This plugin's state in the view the portal was built for. */ viewStore: PluginViewStore; }>; /** Capabilities and compiled schema handles available in author callbacks. */ export type PluginBaseContext< C extends AnyBasePluginDefinition = BasePluginDefinition, > = PluginRuntimeContext & PluginAuthorSchemaField & Readonly<{ /** * This plugin's state in the view a read state or transaction runs in: a * reader for a read state, a writer for a transaction. */ viewStoreOf: PluginViewStoreOf; }>; export type BaseTransformOptions = GetInjectNodePropsOptions & { nodeValue?: unknown; value?: unknown; }; // ----------------------------------------------------------------------------- type StructuralRulePluginPortal

= [ DefinitionOf

, ] extends [never] ? PluginPortalContext : PluginPortalContext>; /** Read-only editor capabilities available while resolving a structural rule. */ export type StructuralRuleEditor = Omit & { plugin( plugin: P ): StructuralRulePluginPortal

; }; export type StructuralRuleContext< C extends AnyBasePluginDefinition = BasePluginDefinition, > = { editor: StructuralRuleEditor; node: Element; path: Path; plugin: PluginReference; } & PluginBaseContext; type StructuralRuleResolver = { bivarianceHack(context: StructuralRuleContext): TAction | undefined; }['bivarianceHack']; export type RuleDecision< TAction, C extends AnyBasePluginDefinition = BasePluginDefinition, > = TAction | StructuralRuleResolver; type BreakAction = | 'default' | 'deleteExit' | 'exit' | 'lift' | 'none' | 'reset'; export type BreakRules< C extends AnyBasePluginDefinition = BasePluginDefinition, > = { /** Action when Enter is pressed in an empty block. */ empty?: RuleDecision; /** * Action when Enter is pressed at the end of an empty line. This is typically * used with `default: 'lineBreak'`. * * Example: * * ```tsx *

* This is some text\n * | *
* ``` * * Plugin resolution refuses a static `'exit'` or `'deleteExit'` on a text * block that is not an object and whose schema element does not declare * `ownsExit: true`, because exit from a nested block would land after its * container instead of after the block. A rule written as a function is not * checked. */ emptyLineEnd?: RuleDecision<'default' | 'deleteExit' | 'exit', C>; /** * Default action when Enter is pressed. Defaults to splitting the block. * Use `'none'` to handle Enter without changing the document. */ default?: RuleDecision< 'default' | 'deleteExit' | 'exit' | 'lineBreak' | 'none', C >; /** * If true, the new block after splitting resets to its container's default * type. When the container has no default it can become, the split stays * and the new block keeps its type. */ splitReset?: RuleDecision; }; export type MergeRules< C extends AnyBasePluginDefinition = BasePluginDefinition, > = { /** * Whether to remove the node when it's empty. A join into an empty node in a * required prefix slot, such as a title, keeps that node and moves the next * sibling's content into it whatever this returns, when that content fits * the slot as it stands, no required block is left to build and the update * has not moved the node into its slot or replaced it. That exception also * needs the sibling to hold only text and inlines and own no content root, * neither node to be a void, an atom or read-only, and an empty sibling to * carry the node's text properties. Backspace still reads this rule before * that merge. With `false` it merges at once, and with `true` the sibling's * delete rules run first. `AuthoredPlugin` turns this exception off. */ removeEmpty?: RuleDecision; }; export type NormalizeRules< C extends AnyBasePluginDefinition = BasePluginDefinition, > = { /** Whether to remove nodes with empty text. */ removeEmpty?: RuleDecision; }; export type DeleteRules< C extends AnyBasePluginDefinition = BasePluginDefinition, > = { /** * Action when Backspace is pressed at the start of the block. This applies * whether the block is empty or not. * * Example: * * ```tsx *
* |Text *
* ``` */ start?: RuleDecision<'default' | 'lift' | 'reset', C>; /** * Action when a deletion starts from or leaves the block empty. `'reset'` * converts the emptied block to its container's default type; when the * container has no default it can become, the deletion stays and the block * keeps its type. */ empty?: RuleDecision<'default' | 'reset', C>; }; export type SelectionRules = { /** * Defines the selection behavior at the boundaries of nodes. * * - `directional`: Selection affinity is determined by the direction of cursor * movement. Maintains inward or outward affinity based on approach. * - `outward`: Forces outward affinity. Typing at the edge of a mark will not * apply the mark to new text. * - `hard`: Creates a 'hard' edge that requires two key presses to move across. * Uses offset-based navigation. * - `default`: Uses the editor's default behavior. */ affinity?: 'default' | 'directional' | 'hard' | 'outward'; }; export type EditOnlyConfig = { /** * If true, `on` DOM event handlers are only active when the editor is not * read-only. Commit, transaction, node, and text observations always run. * * @default true (when `editOnly` is an object or `true` boolean) */ on?: boolean; /** * If true, `inject.nodeProps` is only active when the editor is not * read-only. * * @default true (when `editOnly` is an object or `true` boolean) */ inject?: boolean; /** * If true, `render` functions are only active when the editor is not * read-only. * * @default true (when `editOnly` is an object or `true` boolean) */ render?: boolean; /** * If true, structural slots are only active when the editor is not read-only. * * @default true (when `editOnly` is an object or `true` boolean) */ slots?: boolean; }; export type GetInjectNodePropsOptions = { /** Existing className. */ className?: string; /** Style value or className key. */ element?: Element; /** Current node path when the node is rendered with path context. */ path?: Path; /** Existing style. */ style?: AnyObject; /** Style value or className key. */ text?: Text; }; export type GetInjectNodePropsReturnType = AnyObject & { className?: string; style?: AnyObject; }; export type InferName

= P extends { name: infer N } ? N : never; export type InferApi

= P extends { api: infer A extends object } ? A : {}; /** The runtime binds a callable read root to itself, so callers never supply its `this`. */ export type InferRead

= P extends { read: infer R extends EditorReadMethodTree; } ? R extends (...args: never[]) => unknown ? OmitThisParameter & { [K in keyof R]: R[K] } : R : {}; export type InferUpdate

= P extends { update: infer U extends object } ? U : {}; export type InferEnabled

= P extends { enabled?: infer E } ? IsAny extends true ? boolean : Extract extends never ? boolean : Extract : boolean; export type InferTargetPlugins

= string extends P['name'] ? ReadonlyArray : P extends { targetPlugins: infer TPlugins extends ReadonlyArray< PluginReference | string >; } ? TPlugins : readonly []; export type InferDependencies

= P extends { dependencies?: infer D extends ReadonlyArray< RuntimePluginReference | PluginReference >; } ? D : readonly []; export type InferConflicts

= P extends { conflicts?: infer D extends ReadonlyArray< RuntimePluginReference | PluginReference >; } ? D : readonly []; type InferDependencyDefinition

= Extract< PluginDependencyInstalledDefinitionOf

, AnyBasePluginDefinition >; export type InferDependencyDefinitions = InferDependencyDefinition[number]>; export type InferOwnApi

= InferApi

; /** Runtime state shape after plugin descriptors become nominal references. */ export type NormalizePluginState = IsAny extends true ? T : T extends RuntimeEditor ? T : T extends PluginReference ? PluginReference : T extends (...args: never[]) => unknown ? T : T extends readonly unknown[] ? { readonly [TIndex in keyof T]: NormalizePluginState; } : T extends Readonly> ? { readonly [TKey in keyof T]: NormalizePluginState } : T; export type InferPluginStoreState

= P extends { initialState: infer StoreState; } ? StoreState : {}; export type InferSelectors

= P extends { selectors: infer S } ? S : {}; export type PluginSelector< TState extends object = object, TArgs extends unknown[] = unknown[], TResult = unknown, > = (state: Readonly, ...args: TArgs) => TResult; export type PluginSelectors = Record< string, PluginSelector >; type PluginSelectorMethod = TSelector extends ( state: any, ...args: infer TArgs ) => infer TResult ? (...args: TArgs) => TResult : never; /** Public selector call shape without the implementation-only state input. */ export type PluginSelectorMethods = { [TKey in keyof TSelectors]: PluginSelectorMethod; }; type NormalizedPluginSelector< TState extends object, TSelector, > = TSelector extends (...args: infer TArgs) => infer TResult ? PluginSelector : never; /** Rebind selector methods to one compact, nameable plugin state. */ export type NormalizePluginSelectors< TState extends object, TSelectors extends object, > = { [TKey in keyof TSelectors]: NormalizedPluginSelector< TState, TSelectors[TKey] >; }; export type PluginSelectorArgs = T extends ( state: infer _TState, ...args: infer TArgs ) => unknown ? TArgs : never; export type PluginSelectorReturn = T extends ( state: infer _TState, ...args: never[] ) => infer TResult ? TResult : never; type IsBroadPluginDefinition = IsAny extends true ? true : [keyof InferPluginStoreState] extends [never] ? [keyof InferSelectors] extends [never] ? true : false : false; type PluginStoreKey = IsBroadPluginDefinition extends true ? PropertyKey : keyof InferPluginStoreState | keyof InferSelectors; type PluginStoreValue< C extends AnyBasePluginDefinition, K extends PluginStoreKey, > = K extends keyof InferSelectors ? IsBroadPluginDefinition extends true ? unknown : PluginSelectorReturn[K]> : IsBroadPluginDefinition extends true ? unknown : K extends keyof InferPluginStoreState ? InferPluginStoreState[K] : never; export type PluginStore< C extends AnyBasePluginDefinition = AnyBasePluginDefinition, > = { /** Read the complete current plugin state. */ get(): Readonly>; /** Read one state field or evaluate one named selector. */ get>( key: K, ...args: IsBroadPluginDefinition extends true ? unknown[] : K extends keyof InferSelectors ? PluginSelectorArgs[K]> : [] ): PluginStoreValue; /** Replace fields or update the current plugin state through a draft. */ set( value: | Partial> | ((state: Draft>) => void) ): void; /** * Subscribe to raw state changes. A listener that throws goes to the editor's * `lifecycleErrorSink`, and the other listeners still run. The throw fails * neither the write nor an update around it. */ subscribe: ( listener: ( state: InferPluginStoreState, previousState: InferPluginStoreState ) => void ) => () => void; }; export type InferPluginViewState

= P extends { initialViewState: infer ViewState; } ? ViewState : {}; export type PluginViewStoreReader< C extends AnyBasePluginDefinition = AnyBasePluginDefinition, > = { get(): Readonly>; get>( key: K ): InferPluginViewState[K]; }; export type PluginViewStoreWriter< C extends AnyBasePluginDefinition = AnyBasePluginDefinition, > = PluginViewStoreReader & { set( value: | Partial> | ((state: Draft>) => void) ): void; }; export type PluginViewStore< C extends AnyBasePluginDefinition = AnyBasePluginDefinition, > = PluginViewStoreWriter & { /** * Subscribe to raw view state changes. A listener that throws goes to the * editor's `lifecycleErrorSink`, and the other listeners still run. The throw * fails neither the write nor an update around it. */ subscribe: ( listener: ( state: InferPluginViewState, previousState: InferPluginViewState ) => void ) => () => void; }; export type PluginViewStoreOf< C extends AnyBasePluginDefinition = AnyBasePluginDefinition, > = { ( tx: Readonly> ): PluginViewStoreWriter; ( state: Readonly> ): PluginViewStoreReader; }; export type InferPluginReadGroups

= { readonly [TName in P['name']]: InferRead

; }; export type InferPluginUpdateGroups

= { readonly [TName in P['name']]: InferUpdate

; }; export type InferOwnRead

= InferRead

; export type InferOwnUpdate

= InferUpdate

; /** * Renders a component for editor nodes declared by `schema.element` or * `schema.mark` that match this plugin's type. This is the primary render * method for plugin-specific node content. * * @default DefaultElement for elements, DefaultLeaf for leaves */ export type NodeComponent = | ((props: T) => any) | (new (props: T) => any) | keyof HTMLElementTagNameMap; export type WithAnyName< C extends AnyBasePluginDefinition = BasePluginDefinition, > = IsAny extends true ? C : string extends C['name'] ? C : Omit & { name: string }; export type WithRequiredName

= | (P extends { name: string } ? P : never) | { name: string };