[{"data":1,"prerenderedAt":814},["ShallowReactive",2],{"ofd-doc:\u002Fen\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":36,"path":212,"section":213,"seo":214,"stem":215,"__hash__":216},"docs\u002Fintegration\u002Fembed.en.md","Embed the workspace",{"type":7,"value":8,"toc":196},"minimark",[9,14,23,46,50,57,61,87,91,164,192],[10,11,13],"h2",{"id":12},"run-the-repository-example","Run the repository example",[15,16,17,18,22],"p",{},"In a workspace with access to QuireKit OFD Editor, use the repository's Node 22 and pnpm versions. The following starts the editor at ",[19,20,21],"code",{},"http:\u002F\u002F127.0.0.1:8998\u002F",". The application entry is supplied through the commercial workspace.",[24,25,30],"pre",{"className":26,"code":27,"language":28,"meta":29,"style":29},"language-sh shiki shiki-themes github-light github-light github-dark","pnpm install\npnpm --filter @quirekit\u002Fofd-editor-demo dev\n","sh","",[19,31,32,40],{"__ignoreMap":29},[33,34,37],"span",{"class":35,"line":36},"line",1,[33,38,39],{},"pnpm install\n",[33,41,43],{"class":35,"line":42},2,[33,44,45],{},"pnpm --filter @quirekit\u002Fofd-editor-demo dev\n",[10,47,49],{"id":48},"mount-into-a-page","Mount into a page",[15,51,52,53,56],{},"Give the host an empty element with a defined height. The browser entry uses Vue, Vite and UnoCSS. Use the QuireKit preset and source-scanning configuration from the preview application. Call ",[19,54,55],{},"mountFile(element, file)"," once the DOM exists, then call the returned cleanup when removing the element or leaving the route. With SSR, load this module during client mount.",[58,59],"docs-recipe",{"name":60},"recipes\u002Fmount",[15,62,63,66,67,70,71,74,75,78,79,82,83,86],{},[19,64,65],{},"initialDocument.read(signal)"," can also fetch bytes through your existing authenticated transport. Respect cancellation when the document changes or the workspace closes. Omitting ",[19,68,69],{},"initialDocument"," starts a blank document. ",[19,72,73],{},"onSessionChange"," publishes the current ",[19,76,77],{},"editor"," and ",[19,80,81],{},"view"," and receives ",[19,84,85],{},"undefined"," on teardown.",[10,88,90],{"id":89},"connect-host-services","Connect host services",[92,93,94,107],"table",{},[95,96,97],"thead",{},[98,99,100,104],"tr",{},[101,102,103],"th",{},"Option",[101,105,106],{},"Host responsibility",[108,109,110,125,141,151],"tbody",{},[98,111,112,122],{},[113,114,115,118,119],"td",{},[19,116,117],{},"documentTemplates"," \u002F ",[19,120,121],{},"templatePresets",[113,123,124],{},"Writable versioned library and optional read-only catalog",[98,126,127,138],{},[113,128,129,118,132,118,135],{},[19,130,131],{},"drafts",[19,133,134],{},"batch",[19,136,137],{},"sheetMappings",[113,139,140],{},"Business records, bulk creation and shared column mappings",[98,142,143,148],{},[113,144,145],{},[19,146,147],{},"printService",[113,149,150],{},"Authorized queue and receipts",[98,152,153,161],{},[113,154,155,118,158],{},[19,156,157],{},"loadSigning",[19,159,160],{},"licenseKey",[113,162,163],{},"Signing service and seal sources, and the deployment license key",[15,165,166,167,170,171,173,174,177,178,181,182,187,188],{},"Use the mounted session for template operations and ",[19,168,169],{},"printDocument()",". The latter commits active text and field values before capturing a native print input. Configure ",[19,172,131],{}," to write back to the business system. When ",[19,175,176],{},"openBusinessDraft"," returns ",[19,179,180],{},"pending",", let the workspace resolve unsaved changes before treating the switch as complete. ",[183,184,186],"a",{"href":185},"\u002Fen\u002Fapi","Session API"," · ",[183,189,191],{"href":190},"\u002Fen\u002Fintegration\u002Fhttp","Workstation 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":29,"searchDepth":42,"depth":42,"links":197},[198,199,200],{"id":12,"depth":42,"text":13},{"id":48,"depth":42,"text":49},{"id":89,"depth":42,"text":90},"Mount a file in your page and connect its lifecycle, templates and business drafts to your system.","md",[204,205,206,207,208],"mount","destroy","Vue","SDK","工作台","en",{},true,"\u002Fen\u002Fintegration\u002Fembed","Integration",{"title":5,"description":201},"integration\u002Fembed.en","8XbMPGIgR6NmoJuxV9sVN98QNbfwKvbWCxmNQ5_K3K4","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":24,"props":225,"children":229},"element",{"className":226,"code":227,"language":228,"meta":29,"style":29},"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":19,"props":231,"children":232},{"__ignoreMap":29},[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":33,"props":234,"children":235},{"class":35,"line":36},[236,243,249,254,259,264,270],{"type":224,"tag":33,"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":33,"props":244,"children":246},{"style":245},"--shiki-default:#24292E;--shiki-light:#24292E;--shiki-dark:#E1E4E8",[247],{"type":241,"value":248}," { Editor, ",{"type":224,"tag":33,"props":250,"children":251},{"style":238},[252],{"type":241,"value":253},"type",{"type":224,"tag":33,"props":255,"children":256},{"style":245},[257],{"type":241,"value":258}," OFDEditorOptions } ",{"type":224,"tag":33,"props":260,"children":261},{"style":238},[262],{"type":241,"value":263},"from",{"type":224,"tag":33,"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":33,"props":271,"children":272},{"style":245},[273],{"type":241,"value":274},";\n",{"type":224,"tag":33,"props":276,"children":277},{"class":35,"line":42},[278],{"type":224,"tag":33,"props":279,"children":280},{"emptyLinePlaceholder":211},[281],{"type":241,"value":282},"\n",{"type":224,"tag":33,"props":284,"children":286},{"class":35,"line":285},3,[287],{"type":224,"tag":33,"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":33,"props":294,"children":296},{"class":35,"line":295},4,[297],{"type":224,"tag":33,"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":33,"props":303,"children":305},{"class":35,"line":304},5,[306,311,316,321],{"type":224,"tag":33,"props":307,"children":308},{"style":289},[309],{"type":241,"value":310}," * ",{"type":224,"tag":33,"props":312,"children":313},{"style":238},[314],{"type":241,"value":315},"@param",{"type":224,"tag":33,"props":317,"children":318},{"style":245},[319],{"type":241,"value":320}," target",{"type":224,"tag":33,"props":322,"children":323},{"style":289},[324],{"type":241,"value":325}," - Empty element sized by the host.\n",{"type":224,"tag":33,"props":327,"children":329},{"class":35,"line":328},6,[330,334,338,343],{"type":224,"tag":33,"props":331,"children":332},{"style":289},[333],{"type":241,"value":310},{"type":224,"tag":33,"props":335,"children":336},{"style":238},[337],{"type":241,"value":315},{"type":224,"tag":33,"props":339,"children":340},{"style":245},[341],{"type":241,"value":342}," file",{"type":224,"tag":33,"props":344,"children":345},{"style":289},[346],{"type":241,"value":347}," - File chosen by the user.\n",{"type":224,"tag":33,"props":349,"children":351},{"class":35,"line":350},7,[352,356,360,365],{"type":224,"tag":33,"props":353,"children":354},{"style":289},[355],{"type":241,"value":310},{"type":224,"tag":33,"props":357,"children":358},{"style":238},[359],{"type":241,"value":315},{"type":224,"tag":33,"props":361,"children":362},{"style":245},[363],{"type":241,"value":364}," options",{"type":224,"tag":33,"props":366,"children":367},{"style":289},[368],{"type":241,"value":369}," - Host services and session observer.\n",{"type":224,"tag":33,"props":371,"children":373},{"class":35,"line":372},8,[374,378,383],{"type":224,"tag":33,"props":375,"children":376},{"style":289},[377],{"type":241,"value":310},{"type":224,"tag":33,"props":379,"children":380},{"style":238},[381],{"type":241,"value":382},"@returns",{"type":224,"tag":33,"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":33,"props":389,"children":391},{"class":35,"line":390},9,[392],{"type":224,"tag":33,"props":393,"children":394},{"style":289},[395],{"type":241,"value":396}," *\u002F\n",{"type":224,"tag":33,"props":398,"children":400},{"class":35,"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":33,"props":402,"children":403},{"style":238},[404],{"type":241,"value":405},"export",{"type":224,"tag":33,"props":407,"children":408},{"style":238},[409],{"type":241,"value":410}," function",{"type":224,"tag":33,"props":412,"children":414},{"style":413},"--shiki-default:#6F42C1;--shiki-light:#6F42C1;--shiki-dark:#B392F0",[415],{"type":241,"value":416}," mountFile",{"type":224,"tag":33,"props":418,"children":419},{"style":245},[420],{"type":241,"value":421},"(",{"type":224,"tag":33,"props":423,"children":425},{"style":424},"--shiki-default:#E36209;--shiki-light:#E36209;--shiki-dark:#FFAB70",[426],{"type":241,"value":427},"target",{"type":224,"tag":33,"props":429,"children":430},{"style":238},[431],{"type":241,"value":432},":",{"type":224,"tag":33,"props":434,"children":435},{"style":413},[436],{"type":241,"value":437}," HTMLElement",{"type":224,"tag":33,"props":439,"children":440},{"style":245},[441],{"type":241,"value":442},", ",{"type":224,"tag":33,"props":444,"children":445},{"style":424},[446],{"type":241,"value":447},"file",{"type":224,"tag":33,"props":449,"children":450},{"style":238},[451],{"type":241,"value":432},{"type":224,"tag":33,"props":453,"children":454},{"style":413},[455],{"type":241,"value":456}," File",{"type":224,"tag":33,"props":458,"children":459},{"style":245},[460],{"type":241,"value":442},{"type":224,"tag":33,"props":462,"children":463},{"style":424},[464],{"type":241,"value":465},"options",{"type":224,"tag":33,"props":467,"children":468},{"style":238},[469],{"type":241,"value":432},{"type":224,"tag":33,"props":471,"children":472},{"style":413},[473],{"type":241,"value":474}," OFDEditorOptions",{"type":224,"tag":33,"props":476,"children":477},{"style":238},[478],{"type":241,"value":479}," =",{"type":224,"tag":33,"props":481,"children":482},{"style":245},[483],{"type":241,"value":484}," {})",{"type":224,"tag":33,"props":486,"children":487},{"style":238},[488],{"type":241,"value":432},{"type":224,"tag":33,"props":490,"children":491},{"style":245},[492],{"type":241,"value":493}," () ",{"type":224,"tag":33,"props":495,"children":496},{"style":238},[497],{"type":241,"value":498},"=>",{"type":224,"tag":33,"props":500,"children":502},{"style":501},"--shiki-default:#005CC5;--shiki-light:#005CC5;--shiki-dark:#79B8FF",[503],{"type":241,"value":504}," void",{"type":224,"tag":33,"props":506,"children":507},{"style":245},[508],{"type":241,"value":509}," {\n",{"type":224,"tag":33,"props":511,"children":513},{"class":35,"line":512},11,[514,519,524,528,533,538],{"type":224,"tag":33,"props":515,"children":516},{"style":238},[517],{"type":241,"value":518},"  const",{"type":224,"tag":33,"props":520,"children":521},{"style":501},[522],{"type":241,"value":523}," editor",{"type":224,"tag":33,"props":525,"children":526},{"style":238},[527],{"type":241,"value":479},{"type":224,"tag":33,"props":529,"children":530},{"style":238},[531],{"type":241,"value":532}," new",{"type":224,"tag":33,"props":534,"children":535},{"style":413},[536],{"type":241,"value":537}," Editor",{"type":224,"tag":33,"props":539,"children":540},{"style":245},[541],{"type":241,"value":542},"({\n",{"type":224,"tag":33,"props":544,"children":546},{"class":35,"line":545},12,[547,552],{"type":224,"tag":33,"props":548,"children":549},{"style":238},[550],{"type":241,"value":551},"    ...",{"type":224,"tag":33,"props":553,"children":554},{"style":245},[555],{"type":241,"value":556},"options,\n",{"type":224,"tag":33,"props":558,"children":560},{"class":35,"line":559},13,[561],{"type":224,"tag":33,"props":562,"children":563},{"style":245},[564],{"type":241,"value":565},"    initialDocument: {\n",{"type":224,"tag":33,"props":567,"children":569},{"class":35,"line":568},14,[570],{"type":224,"tag":33,"props":571,"children":572},{"style":245},[573],{"type":241,"value":574},"      name: file.name,\n",{"type":224,"tag":33,"props":576,"children":578},{"class":35,"line":577},15,[579,584,588,593,598,602],{"type":224,"tag":33,"props":580,"children":581},{"style":289},[582],{"type":241,"value":583},"      \u002F** ",{"type":224,"tag":33,"props":585,"children":586},{"style":238},[587],{"type":241,"value":315},{"type":224,"tag":33,"props":589,"children":590},{"style":245},[591],{"type":241,"value":592}," signal",{"type":224,"tag":33,"props":594,"children":595},{"style":289},[596],{"type":241,"value":597}," - Cancelled when the host leaves the file. ",{"type":224,"tag":33,"props":599,"children":600},{"style":238},[601],{"type":241,"value":382},{"type":224,"tag":33,"props":603,"children":604},{"style":289},[605],{"type":241,"value":606}," The selected file bytes. *\u002F\n",{"type":224,"tag":33,"props":608,"children":610},{"class":35,"line":609},16,[611,616,621,625,630],{"type":224,"tag":33,"props":612,"children":613},{"style":238},[614],{"type":241,"value":615},"      async",{"type":224,"tag":33,"props":617,"children":618},{"style":413},[619],{"type":241,"value":620}," read",{"type":224,"tag":33,"props":622,"children":623},{"style":245},[624],{"type":241,"value":421},{"type":224,"tag":33,"props":626,"children":627},{"style":424},[628],{"type":241,"value":629},"signal",{"type":224,"tag":33,"props":631,"children":632},{"style":245},[633],{"type":241,"value":634},") {\n",{"type":224,"tag":33,"props":636,"children":638},{"class":35,"line":637},17,[639,644,649],{"type":224,"tag":33,"props":640,"children":641},{"style":245},[642],{"type":241,"value":643},"        signal.",{"type":224,"tag":33,"props":645,"children":646},{"style":413},[647],{"type":241,"value":648},"throwIfAborted",{"type":224,"tag":33,"props":650,"children":651},{"style":245},[652],{"type":241,"value":653},"();\n",{"type":224,"tag":33,"props":655,"children":657},{"class":35,"line":656},18,[658,663,668,672,676,681,685,690,695,700],{"type":224,"tag":33,"props":659,"children":660},{"style":238},[661],{"type":241,"value":662},"        const",{"type":224,"tag":33,"props":664,"children":665},{"style":501},[666],{"type":241,"value":667}," bytes",{"type":224,"tag":33,"props":669,"children":670},{"style":238},[671],{"type":241,"value":479},{"type":224,"tag":33,"props":673,"children":674},{"style":238},[675],{"type":241,"value":532},{"type":224,"tag":33,"props":677,"children":678},{"style":413},[679],{"type":241,"value":680}," Uint8Array",{"type":224,"tag":33,"props":682,"children":683},{"style":245},[684],{"type":241,"value":421},{"type":224,"tag":33,"props":686,"children":687},{"style":238},[688],{"type":241,"value":689},"await",{"type":224,"tag":33,"props":691,"children":692},{"style":245},[693],{"type":241,"value":694}," file.",{"type":224,"tag":33,"props":696,"children":697},{"style":413},[698],{"type":241,"value":699},"arrayBuffer",{"type":224,"tag":33,"props":701,"children":702},{"style":245},[703],{"type":241,"value":704},"());\n",{"type":224,"tag":33,"props":706,"children":708},{"class":35,"line":707},19,[709,713,717],{"type":224,"tag":33,"props":710,"children":711},{"style":245},[712],{"type":241,"value":643},{"type":224,"tag":33,"props":714,"children":715},{"style":413},[716],{"type":241,"value":648},{"type":224,"tag":33,"props":718,"children":719},{"style":245},[720],{"type":241,"value":653},{"type":224,"tag":33,"props":722,"children":724},{"class":35,"line":723},20,[725,730],{"type":224,"tag":33,"props":726,"children":727},{"style":238},[728],{"type":241,"value":729},"        return",{"type":224,"tag":33,"props":731,"children":732},{"style":245},[733],{"type":241,"value":734}," bytes;\n",{"type":224,"tag":33,"props":736,"children":738},{"class":35,"line":737},21,[739],{"type":224,"tag":33,"props":740,"children":741},{"style":245},[742],{"type":241,"value":743},"      },\n",{"type":224,"tag":33,"props":745,"children":747},{"class":35,"line":746},22,[748],{"type":224,"tag":33,"props":749,"children":750},{"style":245},[751],{"type":241,"value":752},"    },\n",{"type":224,"tag":33,"props":754,"children":756},{"class":35,"line":755},23,[757,762,766],{"type":224,"tag":33,"props":758,"children":759},{"style":245},[760],{"type":241,"value":761},"  }).",{"type":224,"tag":33,"props":763,"children":764},{"style":413},[765],{"type":241,"value":204},{"type":224,"tag":33,"props":767,"children":768},{"style":245},[769],{"type":241,"value":770},"(target);\n",{"type":224,"tag":33,"props":772,"children":774},{"class":35,"line":773},24,[775,780,784,788,793,797],{"type":224,"tag":33,"props":776,"children":777},{"style":238},[778],{"type":241,"value":779},"  return",{"type":224,"tag":33,"props":781,"children":782},{"style":245},[783],{"type":241,"value":493},{"type":224,"tag":33,"props":785,"children":786},{"style":238},[787],{"type":241,"value":498},{"type":224,"tag":33,"props":789,"children":790},{"style":245},[791],{"type":241,"value":792}," editor.",{"type":224,"tag":33,"props":794,"children":795},{"style":413},[796],{"type":241,"value":205},{"type":224,"tag":33,"props":798,"children":799},{"style":245},[800],{"type":241,"value":653},{"type":224,"tag":33,"props":802,"children":804},{"class":35,"line":803},25,[805],{"type":224,"tag":33,"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},1795456058633]