[{"data":1,"prerenderedAt":814},["ShallowReactive",2],{"ofd-doc:\u002Fintegration\u002Fembed":3,"ofd-source:recipes\u002Fmount.ts":217,"mdc-4mwuw9-key":218},{"id":4,"title":5,"body":6,"description":201,"extension":202,"keywords":203,"locale":209,"meta":210,"navigation":211,"order":35,"path":212,"section":213,"seo":214,"stem":215,"__hash__":216},"docs\u002Fintegration\u002Fembed.zh-CN.md","嵌入工作台",{"type":7,"value":8,"toc":196},"minimark",[9,13,22,45,48,55,59,85,88,161,192],[10,11,12],"h2",{"id":12},"运行仓库示例",[14,15,16,17,21],"p",{},"在已获得 QuireKit OFD 编辑器的工作区，用仓库指定的 Node 22 和 pnpm 运行以下命令。工作台位于 ",[18,19,20],"code",{},"http:\u002F\u002F127.0.0.1:8998\u002F","。该应用入口目前通过商业工作区提供。",[23,24,29],"pre",{"className":25,"code":26,"language":27,"meta":28,"style":28},"language-sh shiki shiki-themes github-light github-light github-dark","pnpm install\npnpm --filter @quirekit\u002Fofd-editor-demo dev\n","sh","",[18,30,31,39],{"__ignoreMap":28},[32,33,36],"span",{"class":34,"line":35},"line",1,[32,37,38],{},"pnpm install\n",[32,40,42],{"class":34,"line":41},2,[32,43,44],{},"pnpm --filter @quirekit\u002Fofd-editor-demo dev\n",[10,46,47],{"id":47},"挂载到页面",[14,49,50,51,54],{},"在宿主中准备一个有明确高度的空元素。工作台的浏览器入口依赖 Vue、Vite 与 UnoCSS，复用预览应用的 QuireKit preset 和样式扫描配置。在 DOM 可用后调用 ",[18,52,53],{},"mountFile(element, file)","，切换路由或移除容器时调用它返回的清理函数。对于 SSR，在客户端挂载阶段加载此模块。",[56,57],"docs-recipe",{"name":58},"recipes\u002Fmount",[14,60,61,64,65,68,69,72,73,76,77,80,81,84],{},[18,62,63],{},"initialDocument.read(signal)"," 也可以通过宿主原有的认证请求读取 OFD 字节，切换文档或销毁页面时要遵守取消信号。省略 ",[18,66,67],{},"initialDocument"," 会打开空白文档。",[18,70,71],{},"onSessionChange"," 发布当前的 ",[18,74,75],{},"editor"," 和 ",[18,78,79],{},"view","，宿主据此更新保存、打印等操作；销毁后回调收到 ",[18,82,83],{},"undefined","。",[10,86,87],{"id":87},"选择需要接入的服务",[89,90,91,104],"table",{},[92,93,94],"thead",{},[95,96,97,101],"tr",{},[98,99,100],"th",{},"选项",[98,102,103],{},"由宿主提供",[105,106,107,122,138,148],"tbody",{},[95,108,109,119],{},[110,111,112,115,116],"td",{},[18,113,114],{},"documentTemplates"," \u002F ",[18,117,118],{},"templatePresets",[110,120,121],{},"可写版本库和可选的只读模板目录",[95,123,124,135],{},[110,125,126,115,129,115,132],{},[18,127,128],{},"drafts",[18,130,131],{},"batch",[18,133,134],{},"sheetMappings",[110,136,137],{},"业务草稿、批量生成和共享表格映射",[95,139,140,145],{},[110,141,142],{},[18,143,144],{},"printService",[110,146,147],{},"已授权的打印队列与回执查询",[95,149,150,158],{},[110,151,152,115,155],{},[18,153,154],{},"loadSigning",[18,156,157],{},"licenseKey",[110,159,160],{},"签章服务和印章来源，以及部署使用的授权码",[14,162,163,164,167,168,170,171,173,174,177,178,181,182,187,188],{},"模板操作及 ",[18,165,166],{},"printDocument()"," 可直接在当前会话调用。",[18,169,166],{}," 会先提交正在输入的文字和表单值。要让保存能写回业务系统，需要配置 ",[18,172,128],{},"，并处理 ",[18,175,176],{},"openBusinessDraft"," 返回的 ",[18,179,180],{},"pending"," 状态，让用户先处理未保存的内容。",[183,184,186],"a",{"href":185},"\u002Fapi","会话 API"," · ",[183,189,191],{"href":190},"\u002Fintegration\u002Fhttp","工作站 HTTP",[193,194,195],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":28,"searchDepth":41,"depth":41,"links":197},[198,199,200],{"id":12,"depth":41,"text":12},{"id":47,"depth":41,"text":47},{"id":87,"depth":41,"text":87},"在自己的页面打开 OFD，把文件生命周期、模板库和业务草稿接到现有系统。","md",[204,205,206,207,208],"mount","destroy","Vue","SDK","工作台","zh-CN",{},true,"\u002Fintegration\u002Fembed","系统接入",{"title":5,"description":201},"integration\u002Fembed.zh-CN","Hoa1Ygdfx8g6QuKJpyhZeTzOwz9pdIPmgNgzSnPW9EY","import { Editor, type OFDEditorOptions } from \"@quirekit\u002Fofd-editor\";\n\n\u002F**\n * Opens an authorized file in a host element and gives its owner a teardown function.\n * @param target - Empty element sized by the host.\n * @param file - File chosen by the user.\n * @param options - Host services and session observer.\n * @returns Cleanup to run when leaving the document or removing the element.\n *\u002F\nexport function mountFile(target: HTMLElement, file: File, options: OFDEditorOptions = {}): () => void {\n  const editor = new Editor({\n    ...options,\n    initialDocument: {\n      name: file.name,\n      \u002F** @param signal - Cancelled when the host leaves the file. @returns The selected file bytes. *\u002F\n      async read(signal) {\n        signal.throwIfAborted();\n        const bytes = new Uint8Array(await file.arrayBuffer());\n        signal.throwIfAborted();\n        return bytes;\n      },\n    },\n  }).mount(target);\n  return () => editor.destroy();\n}\n",{"data":219,"body":220},{},{"type":221,"children":222},"root",[223,810],{"type":224,"tag":23,"props":225,"children":229},"element",{"className":226,"code":227,"language":228,"meta":28,"style":28},"language-ts shiki shiki-themes github-light github-light github-dark","import { Editor, type OFDEditorOptions } from \"@quirekit\u002Fofd-editor\";\n\n\u002F**\n * Opens an authorized file in a host element and gives its owner a teardown function.\n * @param target - Empty element sized by the host.\n * @param file - File chosen by the user.\n * @param options - Host services and session observer.\n * @returns Cleanup to run when leaving the document or removing the element.\n *\u002F\nexport function mountFile(target: HTMLElement, file: File, options: OFDEditorOptions = {}): () => void {\n  const editor = new Editor({\n    ...options,\n    initialDocument: {\n      name: file.name,\n      \u002F** @param signal - Cancelled when the host leaves the file. @returns The selected file bytes. *\u002F\n      async read(signal) {\n        signal.throwIfAborted();\n        const bytes = new Uint8Array(await file.arrayBuffer());\n        signal.throwIfAborted();\n        return bytes;\n      },\n    },\n  }).mount(target);\n  return () => editor.destroy();\n}\n\n","ts",[230],{"type":224,"tag":18,"props":231,"children":232},{"__ignoreMap":28},[233,275,283,293,302,326,348,370,388,397,510,543,557,566,575,607,635,654,705,721,735,744,753,771,801],{"type":224,"tag":32,"props":234,"children":235},{"class":34,"line":35},[236,243,249,254,259,264,270],{"type":224,"tag":32,"props":237,"children":239},{"style":238},"--shiki-default:#D73A49;--shiki-light:#D73A49;--shiki-dark:#F97583",[240],{"type":241,"value":242},"text","import",{"type":224,"tag":32,"props":244,"children":246},{"style":245},"--shiki-default:#24292E;--shiki-light:#24292E;--shiki-dark:#E1E4E8",[247],{"type":241,"value":248}," { Editor, ",{"type":224,"tag":32,"props":250,"children":251},{"style":238},[252],{"type":241,"value":253},"type",{"type":224,"tag":32,"props":255,"children":256},{"style":245},[257],{"type":241,"value":258}," OFDEditorOptions } ",{"type":224,"tag":32,"props":260,"children":261},{"style":238},[262],{"type":241,"value":263},"from",{"type":224,"tag":32,"props":265,"children":267},{"style":266},"--shiki-default:#032F62;--shiki-light:#032F62;--shiki-dark:#9ECBFF",[268],{"type":241,"value":269}," \"@quirekit\u002Fofd-editor\"",{"type":224,"tag":32,"props":271,"children":272},{"style":245},[273],{"type":241,"value":274},";\n",{"type":224,"tag":32,"props":276,"children":277},{"class":34,"line":41},[278],{"type":224,"tag":32,"props":279,"children":280},{"emptyLinePlaceholder":211},[281],{"type":241,"value":282},"\n",{"type":224,"tag":32,"props":284,"children":286},{"class":34,"line":285},3,[287],{"type":224,"tag":32,"props":288,"children":290},{"style":289},"--shiki-default:#6A737D;--shiki-light:#6A737D;--shiki-dark:#6A737D",[291],{"type":241,"value":292},"\u002F**\n",{"type":224,"tag":32,"props":294,"children":296},{"class":34,"line":295},4,[297],{"type":224,"tag":32,"props":298,"children":299},{"style":289},[300],{"type":241,"value":301}," * Opens an authorized file in a host element and gives its owner a teardown function.\n",{"type":224,"tag":32,"props":303,"children":305},{"class":34,"line":304},5,[306,311,316,321],{"type":224,"tag":32,"props":307,"children":308},{"style":289},[309],{"type":241,"value":310}," * ",{"type":224,"tag":32,"props":312,"children":313},{"style":238},[314],{"type":241,"value":315},"@param",{"type":224,"tag":32,"props":317,"children":318},{"style":245},[319],{"type":241,"value":320}," target",{"type":224,"tag":32,"props":322,"children":323},{"style":289},[324],{"type":241,"value":325}," - Empty element sized by the host.\n",{"type":224,"tag":32,"props":327,"children":329},{"class":34,"line":328},6,[330,334,338,343],{"type":224,"tag":32,"props":331,"children":332},{"style":289},[333],{"type":241,"value":310},{"type":224,"tag":32,"props":335,"children":336},{"style":238},[337],{"type":241,"value":315},{"type":224,"tag":32,"props":339,"children":340},{"style":245},[341],{"type":241,"value":342}," file",{"type":224,"tag":32,"props":344,"children":345},{"style":289},[346],{"type":241,"value":347}," - File chosen by the user.\n",{"type":224,"tag":32,"props":349,"children":351},{"class":34,"line":350},7,[352,356,360,365],{"type":224,"tag":32,"props":353,"children":354},{"style":289},[355],{"type":241,"value":310},{"type":224,"tag":32,"props":357,"children":358},{"style":238},[359],{"type":241,"value":315},{"type":224,"tag":32,"props":361,"children":362},{"style":245},[363],{"type":241,"value":364}," options",{"type":224,"tag":32,"props":366,"children":367},{"style":289},[368],{"type":241,"value":369}," - Host services and session observer.\n",{"type":224,"tag":32,"props":371,"children":373},{"class":34,"line":372},8,[374,378,383],{"type":224,"tag":32,"props":375,"children":376},{"style":289},[377],{"type":241,"value":310},{"type":224,"tag":32,"props":379,"children":380},{"style":238},[381],{"type":241,"value":382},"@returns",{"type":224,"tag":32,"props":384,"children":385},{"style":289},[386],{"type":241,"value":387}," Cleanup to run when leaving the document or removing the element.\n",{"type":224,"tag":32,"props":389,"children":391},{"class":34,"line":390},9,[392],{"type":224,"tag":32,"props":393,"children":394},{"style":289},[395],{"type":241,"value":396}," *\u002F\n",{"type":224,"tag":32,"props":398,"children":400},{"class":34,"line":399},10,[401,406,411,417,422,428,433,438,443,448,452,457,461,466,470,475,480,485,489,494,499,505],{"type":224,"tag":32,"props":402,"children":403},{"style":238},[404],{"type":241,"value":405},"export",{"type":224,"tag":32,"props":407,"children":408},{"style":238},[409],{"type":241,"value":410}," function",{"type":224,"tag":32,"props":412,"children":414},{"style":413},"--shiki-default:#6F42C1;--shiki-light:#6F42C1;--shiki-dark:#B392F0",[415],{"type":241,"value":416}," mountFile",{"type":224,"tag":32,"props":418,"children":419},{"style":245},[420],{"type":241,"value":421},"(",{"type":224,"tag":32,"props":423,"children":425},{"style":424},"--shiki-default:#E36209;--shiki-light:#E36209;--shiki-dark:#FFAB70",[426],{"type":241,"value":427},"target",{"type":224,"tag":32,"props":429,"children":430},{"style":238},[431],{"type":241,"value":432},":",{"type":224,"tag":32,"props":434,"children":435},{"style":413},[436],{"type":241,"value":437}," HTMLElement",{"type":224,"tag":32,"props":439,"children":440},{"style":245},[441],{"type":241,"value":442},", ",{"type":224,"tag":32,"props":444,"children":445},{"style":424},[446],{"type":241,"value":447},"file",{"type":224,"tag":32,"props":449,"children":450},{"style":238},[451],{"type":241,"value":432},{"type":224,"tag":32,"props":453,"children":454},{"style":413},[455],{"type":241,"value":456}," File",{"type":224,"tag":32,"props":458,"children":459},{"style":245},[460],{"type":241,"value":442},{"type":224,"tag":32,"props":462,"children":463},{"style":424},[464],{"type":241,"value":465},"options",{"type":224,"tag":32,"props":467,"children":468},{"style":238},[469],{"type":241,"value":432},{"type":224,"tag":32,"props":471,"children":472},{"style":413},[473],{"type":241,"value":474}," OFDEditorOptions",{"type":224,"tag":32,"props":476,"children":477},{"style":238},[478],{"type":241,"value":479}," =",{"type":224,"tag":32,"props":481,"children":482},{"style":245},[483],{"type":241,"value":484}," {})",{"type":224,"tag":32,"props":486,"children":487},{"style":238},[488],{"type":241,"value":432},{"type":224,"tag":32,"props":490,"children":491},{"style":245},[492],{"type":241,"value":493}," () ",{"type":224,"tag":32,"props":495,"children":496},{"style":238},[497],{"type":241,"value":498},"=>",{"type":224,"tag":32,"props":500,"children":502},{"style":501},"--shiki-default:#005CC5;--shiki-light:#005CC5;--shiki-dark:#79B8FF",[503],{"type":241,"value":504}," void",{"type":224,"tag":32,"props":506,"children":507},{"style":245},[508],{"type":241,"value":509}," {\n",{"type":224,"tag":32,"props":511,"children":513},{"class":34,"line":512},11,[514,519,524,528,533,538],{"type":224,"tag":32,"props":515,"children":516},{"style":238},[517],{"type":241,"value":518},"  const",{"type":224,"tag":32,"props":520,"children":521},{"style":501},[522],{"type":241,"value":523}," editor",{"type":224,"tag":32,"props":525,"children":526},{"style":238},[527],{"type":241,"value":479},{"type":224,"tag":32,"props":529,"children":530},{"style":238},[531],{"type":241,"value":532}," new",{"type":224,"tag":32,"props":534,"children":535},{"style":413},[536],{"type":241,"value":537}," Editor",{"type":224,"tag":32,"props":539,"children":540},{"style":245},[541],{"type":241,"value":542},"({\n",{"type":224,"tag":32,"props":544,"children":546},{"class":34,"line":545},12,[547,552],{"type":224,"tag":32,"props":548,"children":549},{"style":238},[550],{"type":241,"value":551},"    ...",{"type":224,"tag":32,"props":553,"children":554},{"style":245},[555],{"type":241,"value":556},"options,\n",{"type":224,"tag":32,"props":558,"children":560},{"class":34,"line":559},13,[561],{"type":224,"tag":32,"props":562,"children":563},{"style":245},[564],{"type":241,"value":565},"    initialDocument: {\n",{"type":224,"tag":32,"props":567,"children":569},{"class":34,"line":568},14,[570],{"type":224,"tag":32,"props":571,"children":572},{"style":245},[573],{"type":241,"value":574},"      name: file.name,\n",{"type":224,"tag":32,"props":576,"children":578},{"class":34,"line":577},15,[579,584,588,593,598,602],{"type":224,"tag":32,"props":580,"children":581},{"style":289},[582],{"type":241,"value":583},"      \u002F** ",{"type":224,"tag":32,"props":585,"children":586},{"style":238},[587],{"type":241,"value":315},{"type":224,"tag":32,"props":589,"children":590},{"style":245},[591],{"type":241,"value":592}," signal",{"type":224,"tag":32,"props":594,"children":595},{"style":289},[596],{"type":241,"value":597}," - Cancelled when the host leaves the file. ",{"type":224,"tag":32,"props":599,"children":600},{"style":238},[601],{"type":241,"value":382},{"type":224,"tag":32,"props":603,"children":604},{"style":289},[605],{"type":241,"value":606}," The selected file bytes. *\u002F\n",{"type":224,"tag":32,"props":608,"children":610},{"class":34,"line":609},16,[611,616,621,625,630],{"type":224,"tag":32,"props":612,"children":613},{"style":238},[614],{"type":241,"value":615},"      async",{"type":224,"tag":32,"props":617,"children":618},{"style":413},[619],{"type":241,"value":620}," read",{"type":224,"tag":32,"props":622,"children":623},{"style":245},[624],{"type":241,"value":421},{"type":224,"tag":32,"props":626,"children":627},{"style":424},[628],{"type":241,"value":629},"signal",{"type":224,"tag":32,"props":631,"children":632},{"style":245},[633],{"type":241,"value":634},") {\n",{"type":224,"tag":32,"props":636,"children":638},{"class":34,"line":637},17,[639,644,649],{"type":224,"tag":32,"props":640,"children":641},{"style":245},[642],{"type":241,"value":643},"        signal.",{"type":224,"tag":32,"props":645,"children":646},{"style":413},[647],{"type":241,"value":648},"throwIfAborted",{"type":224,"tag":32,"props":650,"children":651},{"style":245},[652],{"type":241,"value":653},"();\n",{"type":224,"tag":32,"props":655,"children":657},{"class":34,"line":656},18,[658,663,668,672,676,681,685,690,695,700],{"type":224,"tag":32,"props":659,"children":660},{"style":238},[661],{"type":241,"value":662},"        const",{"type":224,"tag":32,"props":664,"children":665},{"style":501},[666],{"type":241,"value":667}," bytes",{"type":224,"tag":32,"props":669,"children":670},{"style":238},[671],{"type":241,"value":479},{"type":224,"tag":32,"props":673,"children":674},{"style":238},[675],{"type":241,"value":532},{"type":224,"tag":32,"props":677,"children":678},{"style":413},[679],{"type":241,"value":680}," Uint8Array",{"type":224,"tag":32,"props":682,"children":683},{"style":245},[684],{"type":241,"value":421},{"type":224,"tag":32,"props":686,"children":687},{"style":238},[688],{"type":241,"value":689},"await",{"type":224,"tag":32,"props":691,"children":692},{"style":245},[693],{"type":241,"value":694}," file.",{"type":224,"tag":32,"props":696,"children":697},{"style":413},[698],{"type":241,"value":699},"arrayBuffer",{"type":224,"tag":32,"props":701,"children":702},{"style":245},[703],{"type":241,"value":704},"());\n",{"type":224,"tag":32,"props":706,"children":708},{"class":34,"line":707},19,[709,713,717],{"type":224,"tag":32,"props":710,"children":711},{"style":245},[712],{"type":241,"value":643},{"type":224,"tag":32,"props":714,"children":715},{"style":413},[716],{"type":241,"value":648},{"type":224,"tag":32,"props":718,"children":719},{"style":245},[720],{"type":241,"value":653},{"type":224,"tag":32,"props":722,"children":724},{"class":34,"line":723},20,[725,730],{"type":224,"tag":32,"props":726,"children":727},{"style":238},[728],{"type":241,"value":729},"        return",{"type":224,"tag":32,"props":731,"children":732},{"style":245},[733],{"type":241,"value":734}," bytes;\n",{"type":224,"tag":32,"props":736,"children":738},{"class":34,"line":737},21,[739],{"type":224,"tag":32,"props":740,"children":741},{"style":245},[742],{"type":241,"value":743},"      },\n",{"type":224,"tag":32,"props":745,"children":747},{"class":34,"line":746},22,[748],{"type":224,"tag":32,"props":749,"children":750},{"style":245},[751],{"type":241,"value":752},"    },\n",{"type":224,"tag":32,"props":754,"children":756},{"class":34,"line":755},23,[757,762,766],{"type":224,"tag":32,"props":758,"children":759},{"style":245},[760],{"type":241,"value":761},"  }).",{"type":224,"tag":32,"props":763,"children":764},{"style":413},[765],{"type":241,"value":204},{"type":224,"tag":32,"props":767,"children":768},{"style":245},[769],{"type":241,"value":770},"(target);\n",{"type":224,"tag":32,"props":772,"children":774},{"class":34,"line":773},24,[775,780,784,788,793,797],{"type":224,"tag":32,"props":776,"children":777},{"style":238},[778],{"type":241,"value":779},"  return",{"type":224,"tag":32,"props":781,"children":782},{"style":245},[783],{"type":241,"value":493},{"type":224,"tag":32,"props":785,"children":786},{"style":238},[787],{"type":241,"value":498},{"type":224,"tag":32,"props":789,"children":790},{"style":245},[791],{"type":241,"value":792}," editor.",{"type":224,"tag":32,"props":794,"children":795},{"style":413},[796],{"type":241,"value":205},{"type":224,"tag":32,"props":798,"children":799},{"style":245},[800],{"type":241,"value":653},{"type":224,"tag":32,"props":802,"children":804},{"class":34,"line":803},25,[805],{"type":224,"tag":32,"props":806,"children":807},{"style":245},[808],{"type":241,"value":809},"}\n",{"type":224,"tag":193,"props":811,"children":812},{},[813],{"type":241,"value":195},1795456058408]