Core API
Generated from the public TypeScript exports of @quirekit/core.
Signatures come from current source, with Chinese descriptions checked against JSDoc. Read quick start and extensions before looking up an entry. Documents, selection, commands and lifecycle belong to the same Editor instance.
Import Editor, Extension, Node and Mark from the public entry. Generated signatures retain source declaration names such as QuireEditor; these refer to the same exports.
Start with task-oriented Editor usage, extension contracts, View options or product APIs; this page retains complete source signatures.
Editor
@quirekit/coreMITCoordinates editor state, extensions, and command execution.
export class QuireEditor {
readonly instanceId: string;
options: EditorOptions;
isInitialized: boolean;
readonly extensionManager: QuireExtensionManager;
readonly utils: QuireEditorUtils;
readonly extensions: readonly QuireAnyExtension[];
isCapturingTransaction: boolean;
isFocused: boolean;
readonly markdown: MarkdownManager;
readonly docx: DocxManager<QuireJSONContent, QuireDocxMark, QuireJSONContent>;
constructor(options?: QuireEditorOptions);
get state(): QuireEditorState;
createReadOnlySnapshot(options?: QuireEditorReadOnlySnapshotOptions): QuireEditor;
get mountedView(): QuireMountedEditorView | undefined;
get view(): QuireMountedEditorView;
get editorProps(): QuireEditorProps;
get schema(): Schema;
get storage(): Readonly<Record<string, unknown>>;
get isDestroyed(): boolean;
get isEditable(): boolean;
get isEmpty(): boolean;
get commands(): SingleCommands;
chain(): ChainedCommands;
can(): CanCommands;
$pos(pos: number): NodePos;
get $doc(): NodePos;
$node(selector: string, attributes?: Record<string, unknown>): NodePos | null;
$nodes(selector: string, attributes?: Record<string, unknown>): NodePos[];
on<EventName extends keyof QuireEditorEvents>(event: EventName, callback: (...args: [
QuireEditorEvents[EventName]
] extends [
void
] ? [
] : [
payload: QuireEditorEvents[EventName]
]) => void): this;
once<EventName extends keyof QuireEditorEvents>(event: EventName, callback: (...args: [
QuireEditorEvents[EventName]
] extends [
void
] ? [
] : [
payload: QuireEditorEvents[EventName]
]) => void): this;
off<EventName extends keyof QuireEditorEvents>(event: EventName, callback?: (...args: [
QuireEditorEvents[EventName]
] extends [
void
] ? [
] : [
payload: QuireEditorEvents[EventName]
]) => void): this;
emit<EventName extends keyof QuireEditorEvents>(event: EventName, ...args: [
QuireEditorEvents[EventName]
] extends [
void
] ? [
] : [
payload: QuireEditorEvents[EventName]
]): this;
someProp<PropName extends keyof QuireEditorProps, Result>(propName: PropName, f: (value: NonNullable<QuireEditorProps[PropName]>) => Result): Result | undefined;
someProp<PropName extends keyof QuireEditorProps>(propName: PropName): NonNullable<QuireEditorProps[PropName]> | undefined;
someProp<PropName extends keyof QuireEditorProps, Result>(propName: PropName, f?: (value: NonNullable<QuireEditorProps[PropName]>) => Result): Result | NonNullable<QuireEditorProps[PropName]> | undefined;
setOptions(options?: Partial<QuireEditorOptions>): void;
setEditable(editable: boolean, emitUpdate?: boolean): void;
setEditorProps(editorProps: Partial<QuireEditorProps>): void;
getJSON(): QuireJSONContent;
getHTML(): string;
getText(options?: QuireGetTextOptions): string;
getMarkdown(): string;
getAttributes(name: string): Record<string, unknown>;
isActive(name: string, attributes?: Record<string, unknown>): boolean;
registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): PMEditorState;
unregisterPlugin(nameOrPluginKeyToRemove: string | PluginKey | Array<string | PluginKey>): PMEditorState | undefined;
mount(options: QuireEditorMountOptions): QuireMountedEditorView;
mount(element: NonNullable<EditorOptions["element"]>): QuireMountedEditorView;
mount(optionsOrElement: QuireEditorMountOptions | NonNullable<EditorOptions["element"]>): QuireMountedEditorView;
unmount(): void;
changeMode(mode: QuireViewMode, options?: QuireEditorChangeModeOptions): QuireMountedEditorView;
setContent(content: QuireEditorContent, options?: QuireSetContentOptions): void;
dispatchTransaction(transaction: Transaction): void;
captureTransaction(callback: () => void): Transaction | null;
destroy(): void;
}Extension definitions
@quirekit/coreMITBase class for Tiptap-compatible behavior-only QuireKit extensions.
export class Extension<Options extends object = object, Storage extends object = object> extends Extendable<Options, Storage, QuireExtensionConfig<Options, Storage>> implements QuireExtension<Options, Storage> {
override type: QuireExtensionKind;
constructor(config: QuireExtensionConfig<Options, Storage>, configuredOptions?: Partial<Options>);
static create<Options extends object = object, Storage extends object = object>(config: QuireExtensionConfigInput<Options, Storage>): Extension<Options, Storage>;
get kind(): QuireExtensionKind;
get priority(): number | undefined;
get keyboardShortcutPriority(): number | undefined;
get topNodeName(): string | undefined;
get commands(): AnyCommands | undefined;
get keyboardShortcuts(): QuireKeyboardShortcutMap | undefined;
get inputRules(): QuireInputRuleList;
get pasteRules(): QuirePasteRuleList;
get nodes(): QuireNodeSpecMap;
get marks(): QuireMarkSpecMap;
get plugins(): QuirePluginList;
get canvasTextStyle(): QuireNodeCanvasTextStyleMap | undefined;
get htmlSerializationTransforms(): QuireNodeHTMLSerializationTransformMap | undefined;
get markdownSerializationTransforms(): QuireNodeMarkdownSerializationTransformMap | undefined;
get layoutProviders(): readonly QuireLayoutProviderEntry[];
get documentProfiles(): readonly QuireDocumentProfileEntry[];
get selectionAdapters(): readonly QuireSelectionAdapterEntry[];
get viewAdapters(): readonly QuireViewAdapter[];
get viewEventHandlers(): QuireExtensionViewEventHandlerMap | undefined;
get extensions(): readonly QuireAnyExtension[];
get onBeforeCreate(): QuireExtensionBeforeCreateHook<Options, Storage> | undefined;
get onCreate(): QuireExtensionCreateHook<Options, Storage> | undefined;
get onUpdate(): QuireExtensionUpdateHook<Options, Storage> | undefined;
get onDestroy(): QuireExtensionDestroyHook<Options, Storage> | undefined;
get onFocus(): QuireExtensionFocusHook<Options, Storage> | undefined;
get onBlur(): QuireExtensionBlurHook<Options, Storage> | undefined;
get dispatchTransaction(): QuireExtensionDispatchTransactionHook<Options, Storage> | undefined;
get transformPastedHTML(): QuireTransformPastedHTMLHook<Options, Storage> | undefined;
get markdownTokenName(): string | undefined;
get parseMarkdown(): QuireMarkdownConfigFields["parseMarkdown"] | undefined;
get renderMarkdown(): QuireMarkdownConfigFields["renderMarkdown"] | undefined;
get markdownTokenizer(): MarkdownTokenizer | undefined;
get markdownOptions(): QuireMarkdownOptions | undefined;
get attributes(): readonly QuireSchemaAttributeContribution[];
override configure(options?: Partial<Options>): Extension<Options, Storage>;
override extend<ExtendedOptions extends object = Options, ExtendedStorage extends object = Storage>(extension?: Partial<QuireExtensionConfig<ExtendedOptions, ExtendedStorage>>): Extension<ExtendedOptions, ExtendedStorage>;
}@quirekit/coreMITTiptap-compatible class for node-owning QuireKit extensions.
export class Node<Options extends object = object, Storage extends object = object> extends Extendable<Options, Storage, QuireNodeConfig<Options, Storage>> implements QuireExtension<Options, Storage> {
override type: QuireExtensionKind;
constructor(config: QuireNodeConfigInput<Options, Storage>);
get kind(): QuireExtensionKind;
get priority(): number | undefined;
get keyboardShortcutPriority(): number | undefined;
get topNodeName(): string | undefined;
get commands(): AnyCommands | undefined;
get keyboardShortcuts(): QuireKeyboardShortcutMap | undefined;
get inputRules(): QuireInputRuleList;
get pasteRules(): QuirePasteRuleList;
get extensions(): readonly QuireAnyExtension[];
get nodes(): QuireNodeSpecMap;
get marks(): QuireMarkSpecMap;
get plugins(): QuirePluginList;
get canvasTextStyle(): QuireNodeCanvasTextStyleMap | undefined;
get layoutProviders(): readonly QuireLayoutProviderEntry[];
get documentProfiles(): readonly QuireDocumentProfileEntry[];
get selectionAdapters(): readonly QuireSelectionAdapterEntry[];
get viewEventHandlers(): QuireExtensionViewEventHandlerMap | undefined;
get onBeforeCreate(): QuireExtensionBeforeCreateHook<Options, Storage> | undefined;
get onCreate(): QuireExtensionCreateHook<Options, Storage> | undefined;
get onUpdate(): QuireExtensionUpdateHook<Options, Storage> | undefined;
get onDestroy(): QuireExtensionDestroyHook<Options, Storage> | undefined;
get onFocus(): QuireExtensionFocusHook<Options, Storage> | undefined;
get onBlur(): QuireExtensionBlurHook<Options, Storage> | undefined;
get dispatchTransaction(): QuireExtensionDispatchTransactionHook<Options, Storage> | undefined;
get transformPastedHTML(): QuireTransformPastedHTMLHook<Options, Storage> | undefined;
get markdownTokenName(): string | undefined;
get parseMarkdown(): QuireMarkdownConfigFields["parseMarkdown"] | undefined;
get renderMarkdown(): QuireMarkdownConfigFields["renderMarkdown"] | undefined;
get markdownTokenizer(): MarkdownTokenizer | undefined;
get markdownOptions(): QuireMarkdownOptions | undefined;
get attributes(): readonly QuireSchemaAttributeContribution[];
static create<Options extends object = object, Storage extends object = object>(config: QuireNodeConfigInput<Options, Storage>): Node<Options, Storage>;
static create<Options extends object = object, Storage extends object = object>(config: NodeConfig<Options, Storage> | (() => NodeConfig<Options, Storage>)): Node<Options, Storage>;
static create<Options extends object = object, Storage extends object = object>(config: QuireNodeConfigInput<Options, Storage> | NodeConfig<Options, Storage> | (() => NodeConfig<Options, Storage>)): Node<Options, Storage>;
override configure(options?: Partial<Options>): Node<Options, Storage>;
override extend<ExtendedOptions extends object = Options, ExtendedStorage extends object = Storage>(config?: Partial<QuireNodeConfig<ExtendedOptions, ExtendedStorage>>): Node<ExtendedOptions, ExtendedStorage>;
override extend<ExtendedOptions extends object = Options, ExtendedStorage extends object = Storage, ExtendedConfig extends QuireExtendableConfig<ExtendedOptions, ExtendedStorage> = QuireExtendableConfig<ExtendedOptions, ExtendedStorage>>(config?: Partial<ExtendedConfig>): Node<ExtendedOptions, ExtendedStorage>;
}@quirekit/coreMITTiptap-compatible class for mark-owning QuireKit extensions.
export class Mark<Options extends object = object, Storage extends object = object> extends Extendable<Options, Storage, QuireMarkConfig<Options, Storage>> implements QuireExtension<Options, Storage> {
override type: QuireExtensionKind;
constructor(config: QuireMarkConfigInput<Options, Storage>);
get kind(): QuireExtensionKind;
get priority(): number | undefined;
get keyboardShortcutPriority(): number | undefined;
get topNodeName(): string | undefined;
get commands(): AnyCommands | undefined;
get keyboardShortcuts(): QuireKeyboardShortcutMap | undefined;
get inputRules(): QuireInputRuleList;
get pasteRules(): QuirePasteRuleList;
get extensions(): readonly QuireAnyExtension[];
get nodes(): QuireNodeSpecMap;
get marks(): QuireMarkSpecMap;
get plugins(): QuirePluginList;
get canvasStyle(): QuireMarkCanvasStyleMap | undefined;
get viewEventHandlers(): QuireExtensionViewEventHandlerMap | undefined;
get onBeforeCreate(): QuireExtensionBeforeCreateHook<Options, Storage> | undefined;
get onCreate(): QuireExtensionCreateHook<Options, Storage> | undefined;
get onUpdate(): QuireExtensionUpdateHook<Options, Storage> | undefined;
get onDestroy(): QuireExtensionDestroyHook<Options, Storage> | undefined;
get onFocus(): QuireExtensionFocusHook<Options, Storage> | undefined;
get onBlur(): QuireExtensionBlurHook<Options, Storage> | undefined;
get dispatchTransaction(): QuireExtensionDispatchTransactionHook<Options, Storage> | undefined;
get transformPastedHTML(): QuireTransformPastedHTMLHook<Options, Storage> | undefined;
get markdownTokenName(): string | undefined;
get parseMarkdown(): QuireMarkdownConfigFields["parseMarkdown"] | undefined;
get renderMarkdown(): QuireMarkdownConfigFields["renderMarkdown"] | undefined;
get markdownTokenizer(): MarkdownTokenizer | undefined;
get markdownOptions(): QuireMarkdownOptions | undefined;
get attributes(): readonly QuireSchemaAttributeContribution[];
static create<Options extends object = object, Storage extends object = object>(config: QuireMarkConfigInput<Options, Storage>): Mark<Options, Storage>;
static create<Options extends object = object, Storage extends object = object>(config: MarkConfig<Options, Storage> | (() => MarkConfig<Options, Storage>)): Mark<Options, Storage>;
static create<Options extends object = object, Storage extends object = object>(config: QuireMarkConfigInput<Options, Storage> | MarkConfig<Options, Storage> | (() => MarkConfig<Options, Storage>)): Mark<Options, Storage>;
override configure(options?: Partial<Options>): Mark<Options, Storage>;
override extend<ExtendedOptions extends object = Options, ExtendedStorage extends object = Storage>(config?: Partial<QuireMarkConfig<ExtendedOptions, ExtendedStorage>>): Mark<ExtendedOptions, ExtendedStorage>;
override extend<ExtendedOptions extends object = Options, ExtendedStorage extends object = Storage, ExtendedConfig extends QuireExtendableConfig<ExtendedOptions, ExtendedStorage> = QuireExtendableConfig<ExtendedOptions, ExtendedStorage>>(config?: Partial<ExtendedConfig>): Mark<ExtendedOptions, ExtendedStorage>;
}Command descriptions and attributes
@quirekit/coreMITDeclares a command with an Agent-facing description. The result is still the command factory Tiptap expects from `addCommands()`; the description rides on the function, so merging and overriding commands by name keep each description with its implementation. @param definition - Description and the command factory. @returns A command factory carrying the frozen description.
function defineCommand<Run extends CommandSpec>(definition: QuireCommandDefinition<Run>): Run@quirekit/coreMITMerges HTML attributes the way extension render callbacks usually expect: classes are deduplicated, styles are merged by CSS property, and later non-special attributes replace earlier values. @param objects - Attribute objects to merge from left to right. @returns Merged HTML attribute object.
function mergeAttributes(...objects: readonly (Readonly<Record<string, unknown>> | null | undefined)[]): Record<string, unknown>