本页签名从公共包导出生成,中文说明与当前 JSDoc 同步校验。代码标识保持原名。
扩展定义
配置项决定功能如何安装;逐步用法见 扩展模型。
@quirekit/msfe-coreExtension、Node 与 Mark 共用的声明式钩子;不接受 ProseMirror schema 字段。
ExtensionConfigts
export interface ExtensionConfig<Options extends object = Record<string, never>, Storage = Record<string, never>> {
readonly history?: "effects";
addSourceProvider?(this: ExtensionContext<Options, Storage, () => MsfeSourceProvider>): MsfeSourceProvider;
readonly name?: string;
readonly priority?: number;
readonly requires?: readonly string[];
addOptions?(this: OptionsContext<Options>): Options;
addStorage?(this: ExtensionContext<Options, Storage, () => Storage>): Storage;
addState?(this: ExtensionContext<Options, Storage, () => readonly StateSlot<unknown>[]>): readonly StateSlot<unknown>[];
addExtensions?(this: ExtensionContext<Options, Storage, () => readonly AnyExtension[]>): readonly AnyExtension[];
addCommands?(this: ExtensionContext<Options, Storage, () => Partial<RawCommands>>): Partial<RawCommands>;
addAiCapabilities?(this: ExtensionContext<Options, Storage, () => readonly unknown[]>): readonly unknown[];
addKeyboardShortcuts?(this: ExtensionContext<Options, Storage, () => Record<string, () => boolean>>): Record<string, () => boolean>;
addEditingBoundaries?(this: ExtensionContext<Options, Storage, () => readonly EditingBoundaryRule[]>): readonly EditingBoundaryRule[];
addBlockInput?(this: ExtensionContext<Options, Storage, () => readonly BlockInputRule[]>): readonly BlockInputRule[];
addInputRules?(this: ExtensionContext<Options, Storage, () => readonly InputRule[]>): readonly InputRule[];
addPasteRules?(this: ExtensionContext<Options, Storage, () => readonly PasteRule[]>): readonly PasteRule[];
addSource?(this: ExtensionContext<Options, Storage, () => SourceSpec>): SourceSpec;
addAttributes?(this: ExtensionContext<Options, Storage, () => Attributes>): Attributes;
addNodeView?(this: ExtensionContext<Options, Storage, () => MsfeNodeViewRenderer>): MsfeNodeViewRenderer;
addMarkdownExtensions?(this: ExtensionContext<Options, Storage, () => MarkdownExtension>): MarkdownExtension;
addProjections?(this: ExtensionContext<Options, Storage, () => readonly MsfeProjection[]>): readonly MsfeProjection[];
addProjectionLayers?(this: ExtensionContext<Options, Storage, () => readonly ProjectionLayer[]>): readonly ProjectionLayer[];
addCodeMirrorExtensions?(this: ExtensionContext<Options, Storage, () => CodeMirrorExtension>): CodeMirrorExtension;
onBeforeCreate?(this: ExtensionContext<Options, Storage>): void;
onCreate?(this: ExtensionContext<Options, Storage, () => void | (() => void)>): void | (() => void);
onUpdate?(this: ExtensionContext<Options, Storage, (event: MsfeChangeEvent) => void>, event: MsfeChangeEvent): void;
onTransaction?(this: ExtensionContext<Options, Storage, (event: TransactionEvent) => void>, event: TransactionEvent): void;
onSelectionUpdate?(this: ExtensionContext<Options, Storage, (event: TransactionEvent) => void>, event: TransactionEvent): void;
onFocus?(this: ExtensionContext<Options, Storage, (event: FocusEvent) => void>, event: FocusEvent): void;
onBlur?(this: ExtensionContext<Options, Storage, (event: FocusEvent) => void>, event: FocusEvent): void;
onDestroy?(this: ExtensionContext<Options, Storage>): void;
}基础预设
每项接受一个扩展定义或 false;数组不是在这里追加同名功能的入口。
@quirekit/msfe-starter-kit按功能覆盖或禁用预设;仍会诊断重复安装的语义归属。
StarterKitOptionsts
export interface StarterKitOptions {
readonly heading?: AnyExtension | false;
readonly bold?: AnyExtension | false;
readonly link?: AnyExtension | false;
readonly codeBlock?: AnyExtension | false;
readonly image?: AnyExtension | false;
readonly emphasis?: AnyExtension | false;
readonly inlineCode?: AnyExtension | false;
readonly strikethrough?: AnyExtension | false;
readonly horizontalRule?: AnyExtension | false;
readonly blockquote?: AnyExtension | false;
readonly listMarkers?: AnyExtension | false;
readonly taskItem?: AnyExtension | false;
readonly table?: AnyExtension | false;
readonly textLiterals?: AnyExtension | false;
readonly dataUrlFold?: AnyExtension | false;
}输入规则
InputRule / PasteRule 都使用此配置;完整模块见 输入规则。
@quirekit/msfe-core原生源码转换规则;输出是精确 Markdown 文本。
RuleConfigts
export interface RuleConfig {
readonly find: RegExp;
readonly handler: (context: RuleMatch) => string | null;
}容器选项
数组整体替换;controls 只管理折叠 UI,正文仍由源码编辑。
@quirekit/msfe-markdown-extras已注册名称的容器配置;语法不包含 HTML 属性或可执行渲染函数。
ContainerOptionsts
export interface ContainerOptions {
readonly types: readonly string[];
readonly detailsOpen: boolean;
readonly controls?: ComponentViewRenderer<ContainerControlProps>;
readonly toggleLabel: (expanded: boolean, title: string) => string;
}折叠控件
组件接收 view 属性;toggle 不改写 Markdown。
@quirekit/msfe-markdown-extras不改写源码的折叠控件,不引入第二份正文或选区。
ContainerControlPropsts
export interface ContainerControlProps {
readonly expanded: boolean;
readonly label: string;
readonly toggle: () => void;
}