以下接口从当前包的公开入口生成。浏览器负责挂载工作台,服务端可单独使用模板、HTTP 和打印子路径。嵌入示例 · HTTP 接入
浏览器工作台
Editor
@quirekit/ofd-editor商业许可在浏览器中创建独立的商业 OFD 工作台。mount 挂载,destroy 释放会话和视图。
Editorts
export class Editor {
constructor(options?: OFDEditorOptions);
mount(target: string | Element): this;
destroy(): void;
}OFDMountedEditorSession
@quirekit/ofd-editor商业许可工作台完成文档切换后,通过 onSessionChange 发布当前会话。以下操作都作用于此会话。
OFDMountedEditorSessionts
export interface OFDMountedEditorSession extends OFDEditorSession {
getBusinessDraft(): import("./drafts/types").OFDDraftEntry | undefined;
openBusinessDraft(id: string): Promise<"opened" | "pending" | "failed">;
saveBusinessDraft(id?: string): Promise<boolean>;
readonly templateStore: import("./templates/types").OFDTemplateStore;
getEditingTemplate(): import("./templates/types").OFDTemplateEntry | undefined;
openTemplate(entry: import("./templates/types").OFDTemplateEntry, mode: "new-document" | "edit-template"): Promise<"opened" | "pending" | "failed">;
saveAsTemplate(name: string): Promise<import("./templates/types").OFDTemplateEntry>;
updateTemplate(): Promise<boolean>;
printDocument(): import("./printing/types").OFDPrintDocument;
}模板及填写服务
instantiateOFDTemplate
@quirekit/ofd-editor/templates商业许可从可编辑的模板字节生成独立 OFD,为每个文档体分配新的 DocID,同时保留模板的对象和资源引用。prepare 可初始化领域数据,reference 可记录来源版本。
instantiateOFDTemplatets
function instantiateOFDTemplate(bytes: Uint8Array, prepare?: (source: OFDSourceDocument) => OFDSourceDocument, reference?: OFDTemplateReference): Uint8ArraydescribeOFDTemplateFields
@quirekit/ofd-editor/http商业许可从指定版本的原生模板读取可填写字段、明细组及空值请求示例。
describeOFDTemplateFieldsts
function describeOFDTemplateFields(source: OFDSourceDocument): { schema: { $schema: string; title: string; type: string; required: string[]; additionalProperties: boolean; properties: { version: { const: number; }; context: { type: string; additionalProperties: boolean; required: string[]; properties: { patientId: { type: string; minLength: number; maxLength: number; pattern: string; }; encounterId: { type: string; minLength: number; maxLength: number; pattern: string; }; }; }; values: { type: string; additionalProperties: boolean; properties: { [k: string]: { title: string; type: string; }; }; }; repeats: { type: string; additionalProperties: boolean; properties: { [k: string]: { title: string; type: string; minItems: number; maxItems: number; items: { type: string; additionalProperties: boolean; properties: { [k: string]: { title: string; type: string; }; }; }; }; }; }; rowKeys: { type: string; additionalProperties: boolean; properties: { [k: string]: { readonly enum: string[]; }; }; }; assets: { type: string; maxProperties: number; patternProperties: { "^[1-9][0-9]{0,9}$": { type: string; contentEncoding: string; }; }; additionalProperties: boolean; }; corrections: { type: string; maxItems: number; items: boolean | { oneOf: object[]; }; }; approved: { type: string; maxItems: number; items: { type: string; pattern: string; }; }; }; }; example: import("@quirekit/ofd-editor-core/forms").OFDFormFillData; documentType?: string | undefined; standard?: string | undefined; fields: { codeSystem?: string | undefined; element?: string | undefined; required?: boolean; key: string; label: string; kind: import("@quirekit/ofd-editor-core/forms").OFDFormControlKind; multiline?: boolean; maxLength?: number; preset?: import("@quirekit/ofd-editor-core/forms").OFDFormPreset; format?: string; options?: readonly import("@quirekit/ofd-editor-core/forms").OFDFormOption[]; }[]; groups: { fields: { codeSystem?: string | undefined; element?: string | undefined; required?: boolean; key: string; label: string; kind: import("@quirekit/ofd-editor-core/forms").OFDFormControlKind; multiline?: boolean; maxLength?: number; preset?: import("@quirekit/ofd-editor-core/forms").OFDFormPreset; format?: string; options?: readonly import("@quirekit/ofd-editor-core/forms").OFDFormOption[]; }[]; required?: boolean | undefined; key: string; label: string; capacity: number; }[]; }fillOFDTemplate
@quirekit/ofd-editor/http商业许可用标准填写数据或兼容快照从模板生成独立工作文档。可传入书写字体和来源版本,返回文档与尚待完成的检查项。
fillOFDTemplatets
function fillOFDTemplate(master: Uint8Array, input: unknown, fallbackFont?: OFDFlowEmbeddedFont, reference?: import("../../templates/types").OFDTemplateReference): { document: OFDSourceDocument; issues: readonly import("@quirekit/ofd-editor-core/forms").OFDFormInputIssue[]; accepted: number; changed: boolean; conflicts: import("@quirekit/ofd-editor-core/forms").OFDFormFillChange[]; }handleOFDHttpRequest
@quirekit/ofd-editor/http商业许可在宿主授权的存储、模板或打印服务上处理一个 Fetch Request。mount 指定路径前缀,返回 JSON、OFD 文件或 HTTP 错误响应。
handleOFDHttpRequestts
function handleOFDHttpRequest(request: Request, services: OFDHttpServices, mount?: string): Promise<Response>打印服务
parseOFDPrintRange
@quirekit/ofd-editor/print商业许可按物理页码总数解析从 1 开始的页码或范围。返回按原件顺序排列的去重页码,越界或逆序范围会报错。
parseOFDPrintRangets
function parseOFDPrintRange(text: string, count: number): number[]OFDPrintService
@quirekit/ofd-editor/print商业许可将已经过校验的原生 OFD 作业交给宿主队列,返回可跟踪的回执。
OFDPrintServicets
export interface OFDPrintService {
readonly label: string;
submit(job: OFDPrintJob, signal: AbortSignal): Promise<OFDPrintReceipt>;
status?(jobId: string, signal: AbortSignal): Promise<OFDPrintJobStatus>;
}