[{"data":1,"prerenderedAt":338},["ShallowReactive",2],{"quirekit-doc:\u002Fen\u002Fguide\u002Fcontent":3},{"id":4,"title":5,"body":6,"description":326,"extension":327,"keywords":328,"locale":329,"meta":330,"navigation":331,"order":332,"path":333,"section":334,"seo":335,"stem":336,"__hash__":337},"docs\u002Fguide\u002Fcontent.en.md","Read, replace and validate content",{"type":7,"value":8,"toc":320},"minimark",[9,13,18,81,99,103,159,172,238,248,252,263,275,286,290,309,316],[10,11,12],"p",{},"Before loading server data, establish which document model it belongs to. HTML, JSON and Markdown represent content; none installs the nodes, marks or conversion rules required to understand it.",[14,15,17],"h2",{"id":16},"choose-a-representation","Choose a representation",[19,20,21,37],"table",{},[22,23,24],"thead",{},[25,26,27,31,34],"tr",{},[28,29,30],"th",{},"Content",[28,32,33],{},"Usage",[28,35,36],{},"Considerations",[38,39,40,55,68],"tbody",{},[25,41,42,46,52],{},[43,44,45],"td",{},"JSON",[43,47,48],{},[49,50,51],"code",{},"content: { type: 'doc', content: [...] }",[43,53,54],{},"Preserve your product's structure and restore with a compatible Schema",[25,56,57,60,65],{},[43,58,59],{},"HTML",[43,61,62],{},[49,63,64],{},"content: '\u003Cp>Hello\u003C\u002Fp>'",[43,66,67],{},"Strings default to HTML parsing, requiring a DOM and extension parsing rules",[25,69,70,73,78],{},[43,71,72],{},"Markdown",[43,74,75],{},[49,76,77],{},"content: '# Hello', contentType: 'markdown'",[43,79,80],{},"Select the type explicitly; conversion depends on rules provided by installed extensions",[10,82,83,86,87,90,91,94,95,98],{},[49,84,85],{},"getJSON()"," reads canonical structure, ",[49,88,89],{},"getText()"," reads plain text, ",[49,92,93],{},"getHTML()"," uses the Schema's HTML serializers, and ",[49,96,97],{},"getMarkdown()"," uses the Markdown manager. HTML output requires a browser DOM and excludes paginated surfaces, product toolbars and screenshots. Custom nodes need rules for each required format; matching visible text alone does not prove fidelity.",[14,100,102],{"id":101},"choose-the-intended-operation","Choose the intended operation",[19,104,105,118],{},[22,106,107],{},[25,108,109,112,115],{},[28,110,111],{},"Task",[28,113,114],{},"Call",[28,116,117],{},"Result",[38,119,120,133,146],{},[25,121,122,125,130],{},[43,123,124],{},"Add content at the current selection",[43,126,127],{},[49,128,129],{},"commands.insertContent(content)",[43,131,132],{},"Insert or replace the selection through ordinary edit history",[25,134,135,138,143],{},[43,136,137],{},"Replace the current document body",[43,139,140],{},[49,141,142],{},"commands.setContent(content, options)",[43,144,145],{},"Replace child content while retaining top-node attributes",[25,147,148,151,156],{},[43,149,150],{},"Open a complete document",[43,152,153],{},[49,154,155],{},"commands.replaceDocument(content, options)",[43,157,158],{},"Restore root attributes, move selection to the start, and exclude this replacement from history",[10,160,161,162,165,166,171],{},"Word document settings and style registries live in root attributes, while section nodes represent sections in the body, so restoring files requires more than ",[49,163,164],{},"setContent()",". Excluding a replacement from history does not establish a fresh editing session: isolate old tasks, subscriptions and history policy when changing business documents. Create a new Editor for a definite session boundary; Classic can ",[167,168,170],"a",{"href":169},"\u002Fen\u002Fclassic\u002Ffiles","replace its document configuration",".",[173,174,180],"pre",{"className":175,"code":176,"filename":177,"language":178,"meta":179,"style":179},"language-ts shiki shiki-themes github-light github-light github-dark","const accepted = editor.commands.replaceDocument(content, {\n  errorOnInvalidContent: true,\n  emitUpdate: false,\n})\n","Replace an already validated complete document","ts","",[49,181,182,209,221,232],{"__ignoreMap":179},[183,184,187,191,195,198,202,206],"span",{"class":185,"line":186},"line",1,[183,188,190],{"class":189},"sDD9d","const",[183,192,194],{"class":193},"sUNQB"," accepted",[183,196,197],{"class":189}," =",[183,199,201],{"class":200},"sVPnS"," editor.commands.",[183,203,205],{"class":204},"sgQzM","replaceDocument",[183,207,208],{"class":200},"(content, {\n",[183,210,212,215,218],{"class":185,"line":211},2,[183,213,214],{"class":200},"  errorOnInvalidContent: ",[183,216,217],{"class":193},"true",[183,219,220],{"class":200},",\n",[183,222,224,227,230],{"class":185,"line":223},3,[183,225,226],{"class":200},"  emitUpdate: ",[183,228,229],{"class":193},"false",[183,231,220],{"class":200},[183,233,235],{"class":185,"line":234},4,[183,236,237],{"class":200},"})\n",[10,239,240,243,244,247],{},[49,241,242],{},"errorOnInvalidContent: true"," makes invalid parsing throw, so catch errors. ",[49,245,246],{},"emitUpdate: false"," suppresses content update notifications; replacement and transaction processing still occur. It can support restoration that explicitly establishes a saved baseline, but does not silence every side effect.",[14,249,251],{"id":250},"validate-before-replacing","Validate before replacing",[10,253,254,255,258,259,262],{},"Validate the application's model\u002Fversion, node\u002Fmark\u002Fattribute names, and Schema content rules. Calling ",[49,256,257],{},"check()"," on a parsed node validates structure, but parsing may already have discarded unknown attributes. Consequently, ",[49,260,261],{},"schema.nodeFromJSON(value).check()"," alone cannot prove that the original input lost no fields.",[10,264,265,266,269,270,274],{},"Keep the original input and reject unknown fields or migrate them explicitly before conversion. The reference's ",[49,267,268],{},"files\u002Fbackup.ts"," checks names before parsing, then validates the root and child content; see ",[167,271,273],{"href":272},"\u002Fen\u002Fbuild\u002Ffiles","file operations",". On failure, retain the current draft rather than saving fallback empty content over the source.",[10,276,277,278,281,282,285],{},"Creation options ",[49,279,280],{},"enableContentCheck"," \u002F ",[49,283,284],{},"emitContentError"," report initial content errors. Construction may still establish fallback content, so successful construction does not prove a successful import. Strict restoration validates first and commits afterward.",[14,287,289],{"id":288},"updates-and-saving-state","Updates and saving state",[10,291,292,295,296,299,300,304,305,171],{},[49,293,294],{},"setEditable()"," also emits ",[49,297,298],{},"update"," by default without changing the document. Compare previous and current documents when tracking unsaved changes; see ",[167,301,303],{"href":302},"\u002Fen\u002Fconcepts\u002Flifecycle","lifecycle and events",". When saving finishes, confirm that the current document is still the submitted revision; see ",[167,306,308],{"href":307},"\u002Fen\u002Fguide\u002Fpersistence","persistence",[10,310,311,312,171],{},"Full parameter definitions are in ",[167,313,315],{"href":314},"\u002Fen\u002Fapi\u002Foptions","Editor options and events",[317,318,319],"style",{},"html pre.shiki code .sDD9d, html code.shiki .sDD9d{--shiki-default:#D73A49;--shiki-light:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sUNQB, html code.shiki .sUNQB{--shiki-default:#005CC5;--shiki-light:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sVPnS, html code.shiki .sVPnS{--shiki-default:#24292E;--shiki-light:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sgQzM, html code.shiki .sgQzM{--shiki-default:#6F42C1;--shiki-light:#6F42C1;--shiki-dark:#B392F0}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":179,"searchDepth":211,"depth":211,"links":321},[322,323,324,325],{"id":16,"depth":211,"text":17},{"id":101,"depth":211,"text":102},{"id":250,"depth":211,"text":251},{"id":288,"depth":211,"text":289},"Choose between insertion, body replacement and opening a document, while preserving the original input.","md",null,"en",{},true,5,"\u002Fen\u002Fguide\u002Fcontent","Getting started",{"title":5,"description":326},"guide\u002Fcontent.en","ood_EwEkBjFDpECrPzBEanvNXJBGbdyLHIcZ9joNu7Q",1793045210180]