本页用于查字段,调用步骤见 Editor 用法。所有签名均来自 @quirekit/core 的公开入口,不需要从内部目录导入类型。
创建配置
extensions、Schema 与命令在创建时建立;setOptions() 不会重新编译扩展。element 存在时选择的 mode 必须已有适配器,省略 mode 选择 retained html,而不是原生 dom。
事件可在创建选项中使用 onCreate、onUpdate 等回调。create 在构造期间同步发生,因此 new Editor() 返回后才订阅 create 会错过它;在 onCreate 中使用回调参数的 editor。
@quirekit/coreMIT创建 Editor 时的内容、扩展、视图与事件配置。
QuireEditorOptionsts
export interface QuireEditorOptions extends QuireEditorEventCallbacks {
readonly content?: QuireEditorContent;
readonly contentType?: QuireMarkdownContentType | undefined;
readonly markdown?: QuireMarkdownManagerOptions | undefined;
readonly docx?: QuireDocxManagerOptions | undefined;
readonly schema?: Schema;
readonly editorProps?: QuireEditorProps | undefined;
readonly parseOptions?: ParseOptions | undefined;
readonly autofocus?: FocusPosition | undefined;
readonly editable?: boolean | undefined;
readonly textDirection?: "ltr" | "rtl" | "auto" | undefined;
readonly injectCSS?: boolean | undefined;
readonly injectNonce?: string | undefined;
readonly coreExtensionOptions?: CoreExtensionOptions | undefined;
readonly enableCoreExtensions?: boolean | Partial<Record<CoreExtensionName, false>> | undefined;
readonly enableContentCheck?: boolean | undefined;
readonly emitContentError?: boolean | undefined;
readonly enableExtensionDispatchTransaction?: boolean | undefined;
readonly enableInputRules?: QuireEnableRules | undefined;
readonly enablePasteRules?: QuireEnableRules | undefined;
readonly extensions?: readonly QuireAnyExtension[];
readonly element?: Element | {
readonly mount: HTMLElement;
} | ((editor: HTMLElement) => void) | null | undefined;
readonly mode?: QuireViewMode;
readonly viewId?: string;
}内容替换选项
setContent() 与 replaceDocument() 共用这些选项。省略 emitUpdate 时正常通知更新;errorOnInvalidContent 需要显式启用。语义和校验限制见内容读写。
@quirekit/coreMIT正文替换与完整文档恢复共用的解析和更新通知选项。
QuireSetContentOptionsts
export interface QuireSetContentOptions extends SetContentOptions {
readonly contentType?: QuireMarkdownContentType | undefined;
readonly parseOptions?: ParseOptions;
readonly errorOnInvalidContent?: boolean;
readonly emitUpdate?: boolean;
}事件表
事件通知描述状态或输入事实,不是第二条修改通道。transaction 还携带 appendedTransactions;需要判断实际正文是否改变时,比较接受后的文档与旧文档,不能只看根事务。update 默认也可由 setEditable() 触发,见事件用法。
@quirekit/coreMITEditor 通过 on、once 与 off 暴露的公开事件及其负载类型。
QuireEditorEventsts
export interface QuireEditorEvents {
readonly mount: EditorEvents["mount"];
readonly unmount: EditorEvents["unmount"];
readonly beforeCreate: QuireEditorEventPayload;
readonly create: QuireEditorEventPayload;
readonly contentError: EditorEvents["contentError"];
readonly beforeTransaction: QuireEditorBeforeTransactionEvent;
readonly transaction: QuireEditorTransactionEvent;
readonly selectionUpdate: QuireEditorSelectionUpdateEvent;
readonly focus: QuireEditorFocusEvent;
readonly blur: QuireEditorBlurEvent;
readonly paste: QuireEditorPasteEvent;
readonly clipboardPasteResult: QuireClipboardPasteResult;
readonly drop: QuireEditorDropEvent;
readonly delete: QuireEditorDeleteEvent;
readonly update: QuireEditorUpdateEvent;
readonly destroy: void;
}