本页用于查类型,入门步骤见快速接入,选择配置与更新方式见配置与生命周期。类型从 @quirekit/classic-editor 公开导入;Vue 宿主的运行时创建使用 /vue 入口。
创建配置
preset 决定模型与默认能力,plugins 安装产品插件,extensions 追加正文扩展。media 与 host 是实例创建时的服务边界,不能通过更新配置替换。
@quirekit/classic-editorAGPL-3.0-only创建 Classic 产品实例的配置,包含模型、插件、界面与宿主服务。
export interface ClassicEditorOptions {
readonly element?: HTMLElement | null | undefined;
readonly document?: QuireEditorContent | undefined;
readonly preset?: ClassicEditorPreset | undefined;
readonly locale?: ClassicEditorLocale | undefined;
readonly surfaceMode?: ClassicEditorSurfaceMode | undefined;
readonly features?: ClassicEditorFeatureOptions | undefined;
readonly plugins?: readonly ClassicEditorPlugin[] | undefined;
readonly extensions?: readonly QuireAnyExtension[] | undefined;
readonly editable?: boolean | undefined;
readonly view?: ClassicEditorViewOptions | undefined;
readonly canvasRuntime?: Readonly<Partial<CanvasMountedViewRuntimeOptions>> | undefined;
readonly svgRuntime?: Readonly<Partial<SvgMountedViewRuntimeOptions>> | undefined;
readonly theme?: QuireKitTheme | undefined;
readonly shell?: ClassicEditorShellOptions | undefined;
readonly ui?: ClassicEditorUiProfileOptions | undefined;
readonly webFonts?: ClassicEditorWebFontOptions | false | undefined;
readonly media?: ClassicEditorMediaServices | undefined;
readonly host?: ClassicEditorHostServices | undefined;
}更新配置
语言、只读和内置预设的主题更新保留编辑会话;结构配置仍重建 Core。plugins / extensions 替换实例数组,features / shell 等按字段合并;不能把数组更新理解为追加。具体规则见配置说明。
@quirekit/classic-editorAGPL-3.0-onlyClassic 产品更新选项。语言、只读及内置预设主题更新保留会话;结构配置重建 Core,未传正文时保留当前内容。
export interface ClassicEditorUpdateOptions {
readonly document?: QuireEditorContent | undefined;
readonly preset?: ClassicEditorPreset | undefined;
readonly locale?: ClassicEditorLocale | undefined;
readonly features?: ClassicEditorFeatureOptions | undefined;
readonly plugins?: readonly ClassicEditorPlugin[] | undefined;
readonly extensions?: readonly QuireAnyExtension[] | undefined;
readonly editable?: boolean | undefined;
readonly view?: ClassicEditorViewOptions | undefined;
readonly canvasRuntime?: Readonly<Partial<CanvasMountedViewRuntimeOptions>> | undefined;
readonly svgRuntime?: Readonly<Partial<SvgMountedViewRuntimeOptions>> | undefined;
readonly theme?: QuireKitTheme | undefined;
readonly shell?: ClassicEditorShellOptions | undefined;
readonly ui?: ClassicEditorUiProfileOptions | undefined;
readonly webFonts?: ClassicEditorWebFontOptions | false | undefined;
}产品实例
在 update()、unmount() 之后重新读取 instance.editor。不要缓存旧 Core 继续发命令。getJSON() 返回规范内容;产品名称、宿主文档 ID、媒体字节和存储确认由应用分别管理。
@quirekit/classic-editorAGPL-3.0-onlycreateClassicEditor 返回的产品实例,负责挂载、配置、文件服务和最终销毁。
export interface ClassicEditorInstance {
readonly isMounted: boolean;
readonly isDestroyed: boolean;
readonly editor: QuireEditor | undefined;
readonly root: HTMLElement | undefined;
readonly features: ClassicEditorResolvedFeatures;
readonly locale: ClassicEditorLocale;
readonly documentName: string;
readonly backend: ClassicEditorViewBackend;
readonly registry: ClassicEditorRegistrySnapshot;
readonly ui: ClassicEditorUiController;
readonly documentFontStatus: ClassicEditorDocumentFontStatus;
readPageLayout?(document: PMNode): readonly ClassicEditorPageLayout[] | null;
readonly fontLibrary: ClassicEditorFontLibrary | undefined;
readonly media: ClassicEditorMediaServices;
readonly hostResources: ClassicEditorHostResourceController;
readonly tasks: ClassicEditorTaskFeedbackController;
readonly resourceTasks: ClassicEditorHostResourceTaskController;
setDocumentName(name: string): void;
mount(element: HTMLElement): void;
unmount(): void;
update(options: ClassicEditorUpdateOptions): void;
isContributionAvailable(behavior: ClassicEditorBehavior, payload?: unknown): boolean;
canExecuteContribution(behavior: ClassicEditorBehavior, payload?: unknown): boolean;
executeContribution(behavior: ClassicEditorBehavior, payload?: unknown, trigger?: ClassicEditorBehaviorTrigger): boolean | Promise<boolean>;
refreshProductUi(): void;
createReadOnlySnapshot(document: PMNode): QuireEditor;
importDocument(serviceId: string, input: ClassicEditorImportArtifact, options?: ClassicEditorImportOptions): Promise<void>;
exportDocument(serviceId: string): Promise<ClassicEditorExportArtifact>;
getJSON(): QuireJSONContent;
destroy(): void;
}界面控制器
缩放、标尺与侧栏使用 instance.ui 更新,保持当前文档和历史。subscribe() 返回释放函数,页面退出时调用。面板 ID 对应已安装的 sidebar contribution;此接口不会自动创建缺失面板。
@quirekit/classic-editorAGPL-3.0-only产品临时界面状态的控制器,调整缩放、标尺与侧栏而不改写正文。
export interface ClassicEditorUiController {
readonly state: ClassicEditorUiState;
setZoom(percent: number): void;
setZoomMode(mode: ClassicEditorZoomMode): void;
setRulerVisible(visible: boolean): void;
setInvisibleCharactersVisible(visible: boolean): void;
setHiddenTextVisible(visible: boolean): void;
subscribe(listener: ClassicEditorUiStateListener): () => void;
setSidebarVisible(side: "left" | "right", visible: boolean): void;
toggleSidebar(side: "left" | "right"): void;
openSidebarPanel(side: "left" | "right", panelId: string, options?: ClassicEditorSidebarOpenOptions): void;
closeSidebar(side: "left" | "right"): void;
setSemanticSnapshot(snapshot: ClassicEditorUiSemanticSnapshot): void;
}导入取消与提交
宿主通过 signal 取消准备过程。自定义服务必须在 context.commit() 内执行一次同步的文档命令;失效目标会在写入前被拒绝。调用示例与迁移说明见文件操作。
@quirekit/classic-editorAGPL-3.0-only宿主打开文档时可提供的取消选项。
export interface ClassicEditorImportOptions {
readonly signal?: AbortSignal | undefined;
}@quirekit/classic-editorAGPL-3.0-only实例为文档导入服务提供的最终写入边界。解析完成后必须经 commit 同步提交。
export interface ClassicEditorImportContext extends ClassicEditorServiceContext {
readonly signal: AbortSignal;
commit(write: () => boolean): void;
}预设呈现更新
本上下文只用于刷新已有会话的呈现,不能替代安装新扩展或更改模型。宿主显式颜色覆盖仍应优先。
@quirekit/classic-editorAGPL-3.0-only预设刷新呈现时接收的现有编辑会话与配置。
export interface ClassicEditorPresetPresentationContext {
readonly editor: QuireEditor;
readonly theme: QuireKitTheme;
readonly locale: ClassicEditorLocale;
readonly canvasRuntime: Readonly<Partial<CanvasMountedViewRuntimeOptions>>;
readonly svgRuntime: Readonly<Partial<SvgMountedViewRuntimeOptions>>;
}媒体与字体
接入流程见持久媒体与字体。二进制资源、浏览器字体和文档逻辑身份分别管理。
@quirekit/classic-editorAGPL-3.0-only一个 Classic 实例及其挂载视图共享的媒体服务。
export interface ClassicEditorMediaServices {
readonly sink: QuireMediaAssetSink;
readonly registrar?: QuireMediaAssetRegistrar | undefined;
readonly resolver: QuireMediaAssetResolver;
createAssetId(kind: QuireMediaAssetKind): string;
}@quirekit/classic-editorAGPL-3.0-only宿主为外部字体库提供的策略与来源配置。
export interface ClassicEditorWebFontOptions {
readonly families: readonly ClassicEditorWebFontFamily[];
readonly mountedFamilies?: readonly ClassicEditorMountedFontFamily[] | undefined;
readonly sources?: readonly ClassicEditorWebFontSource[] | undefined;
readonly persistence?: ClassicEditorFontLibraryPersistence | undefined;
readonly catalogs: readonly QuireWebFontCatalog[];
readonly cache?: QuireWebFontCache | undefined;
readonly fetch?: QuireWebFontFetch | undefined;
readonly maxAssetBytes?: number | undefined;
readonly maxConcurrentAssets?: number | undefined;
}@quirekit/classic-editorAGPL-3.0-only挂载后用于显式安装和管理外部字体的产品接口。
export interface ClassicEditorFontLibrary {
readonly families: readonly ClassicEditorWebFontFamily[];
readonly sources: readonly ClassicEditorWebFontSource[];
readonly importedFamilies: readonly ClassicEditorImportedWebFontFamily[];
readonly mountedFamilies: readonly ClassicEditorMountedFontFamily[];
readonly recentFamilies: readonly string[];
rememberRecentFamily(family: string): void;
getInstallations(): readonly QuireWebFontInstallation[];
subscribe(listener: () => void): () => void;
getSourceSettings(sourceId: string): ClassicEditorWebFontSourceSettings;
configureSource(sourceId: string, settings: ClassicEditorWebFontSourceSettings): void;
search(sourceId: string, query: string, subsets?: readonly string[]): Promise<readonly ClassicEditorWebFontFamily[]>;
browse?(sourceId: string, query: string, limit: number, cursor?: string, subsets?: readonly string[]): Promise<ClassicEditorWebFontCatalogPage>;
inspectCustomSource?(descriptorUrl: string): Promise<ClassicEditorCustomWebFontSourceRecord>;
enableCustomSource?(record: ClassicEditorCustomWebFontSourceRecord): void;
inspectStylesheetSource?(url: string, name?: string): Promise<ClassicEditorStylesheetFontSourceRecord>;
enableStylesheetSource?(record: ClassicEditorStylesheetFontSourceRecord): void;
removeCustomSource?(sourceId: string): void;
previewFamily(family: ClassicEditorWebFontFamily): Promise<void>;
importFamily(family: ClassicEditorWebFontFamily, download?: boolean): Promise<void>;
removeFamily(family: ClassicEditorWebFontFamily | string): Promise<void>;
getStatus(family: string): QuireWebFontStatus;
install(family: string): Promise<void>;
}@quirekit/classic-editorAGPL-3.0-only当前正文逻辑字体和实际渲染字体的产品状态。
export interface ClassicEditorDocumentFontStatus {
readonly requestedFamily: string | null;
readonly renderedFamily: string | null;
readonly status: ClassicEditorDocumentFontStatusKind;
readonly source: QuireFontSubstitutionCandidateSource | null;
}