@betteroffice/docx 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/dist/chunk-AEQOEQJ7.mjs +57 -0
- package/dist/chunk-AZ52IWB6.mjs +16 -0
- package/dist/{chunk-SINEY6ZF.mjs → chunk-B4IR6YP4.mjs} +1 -1
- package/dist/chunk-IFT6DUJX.mjs +1 -0
- package/dist/{chunk-H3JCIGWK.mjs → chunk-NJHOPXZW.mjs} +1 -1
- package/dist/chunk-NTQM4EYN.mjs +1 -0
- package/dist/{chunk-KXNZFTTK.mjs → chunk-WBH3SXI6.mjs} +1 -1
- package/dist/collaboration/index.d.mts +64 -0
- package/dist/collaboration/index.mjs +1 -0
- package/dist/{content-sSHuWw49.d.mts → content-DLFHRQav.d.mts} +8 -8
- package/dist/core.d.mts +148 -341
- package/dist/core.mjs +1 -1
- package/dist/{displayListQueries-p-ijSzdh.d.mts → displayListQueries-UGc_XBUv.d.mts} +1 -1
- package/dist/docx/index.d.mts +40 -520
- package/dist/docx/index.mjs +2 -2
- package/dist/editor/index.d.mts +35 -151
- package/dist/editor/index.mjs +1 -1
- package/dist/{fontLoader-Bx6DK6-2.d.mts → fontLoader-aSewHMKF.d.mts} +65 -63
- package/dist/{formatting-DoL7KBSL.d.mts → formatting-D1EPSaJP.d.mts} +1 -1
- package/dist/generated/edit/docx_edit_bg.wasm +0 -0
- package/dist/generated/layout/docx_layout_bg.wasm +0 -0
- package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
- package/dist/generated/parse/docx_parse_bg.wasm +0 -0
- package/dist/index-Bwxm3oiC.d.mts +934 -0
- package/dist/layout/index.d.mts +18 -240
- package/dist/layout/index.mjs +1 -1
- package/dist/layout/pagination/index.d.mts +10 -58
- package/dist/layout/pagination/index.mjs +1 -1
- package/dist/layout/render/index.d.mts +10 -11
- package/dist/layout/render/index.mjs +1 -1
- package/dist/plugin-api/RenderedDomContext.d.mts +8 -9
- package/dist/plugin-api/index.d.mts +191 -6
- package/dist/plugin-api/resolveItemPositions.d.mts +4 -5
- package/dist/{rustDisplayList-dqunvwxH.d.mts → rustDisplayList-CX78djsZ.d.mts} +5 -5
- package/dist/rustMeasureSource-D1KsQvVC.d.mts +106 -0
- package/dist/selectiveSave-CVoajSKE.d.mts +56 -0
- package/dist/styles/index.d.mts +4 -39
- package/dist/styles/index.mjs +1 -1
- package/dist/{styles-VxNcXLdi.d.mts → styles-Dn_o3Vo5.d.mts} +2 -2
- package/dist/types/content.d.mts +2 -2
- package/dist/types/document.d.mts +40 -14
- package/dist/{types-DNrYr6yQ.d.mts → types-DMkDbvEu.d.mts} +3 -71
- package/dist/utils/comments.d.mts +2 -2
- package/dist/utils/index.d.mts +110 -576
- package/dist/utils/index.mjs +1 -84
- package/dist/utils/stylePreview.d.mts +2 -2
- package/dist/utils/units.d.mts +33 -2
- package/dist/wasm-BGQBTR2J.mjs +1 -0
- package/dist/wasm-edit.d.mts +13 -5
- package/dist/wasm-edit.mjs +1 -1
- package/dist/wasm-opc.mjs +1 -1
- package/dist/wasm-parse.mjs +1 -1
- package/dist/yrs/index.d.mts +5 -881
- package/dist/yrs/index.mjs +1 -1
- package/dist/yrs/residentEngineWorker.mjs +1 -1
- package/package.json +16 -139
- package/dist/Subscribable-DOz6Ohoo.d.mts +0 -33
- package/dist/agent/index.d.mts +0 -531
- package/dist/agent/index.mjs +0 -1
- package/dist/chunk-34K66SY4.mjs +0 -1
- package/dist/chunk-4RCISPPE.mjs +0 -1
- package/dist/chunk-52GB3Y42.mjs +0 -1
- package/dist/chunk-6PW4CWUG.mjs +0 -1
- package/dist/chunk-7DEIW7FL.mjs +0 -1
- package/dist/chunk-7PCO5I2O.mjs +0 -1
- package/dist/chunk-BI3B33LI.mjs +0 -1
- package/dist/chunk-BIQWVK5P.mjs +0 -2
- package/dist/chunk-DXKG3HQ5.mjs +0 -16
- package/dist/chunk-FPZBTOD6.mjs +0 -1
- package/dist/chunk-FZIA7OFY.mjs +0 -1
- package/dist/chunk-GWKJ2Y4Y.mjs +0 -1
- package/dist/chunk-HJGAQIU7.mjs +0 -2
- package/dist/chunk-I6KKMUUC.mjs +0 -1
- package/dist/chunk-IL5JZJT7.mjs +0 -1
- package/dist/chunk-JY6ILTNS.mjs +0 -1
- package/dist/chunk-KEE52TT5.mjs +0 -1
- package/dist/chunk-KVKLLTDP.mjs +0 -58
- package/dist/chunk-L5ISVQ3W.mjs +0 -1
- package/dist/chunk-LDUWIM7M.mjs +0 -1
- package/dist/chunk-N5Q3YN64.mjs +0 -1
- package/dist/chunk-NEWOMDTX.mjs +0 -1
- package/dist/chunk-O2QSE2I7.mjs +0 -1
- package/dist/chunk-OJOHXQNQ.mjs +0 -1
- package/dist/chunk-OMR3TWCD.mjs +0 -2
- package/dist/chunk-P3KDV4M2.mjs +0 -1
- package/dist/chunk-Q7PO7V73.mjs +0 -1
- package/dist/chunk-QOUFE3VX.mjs +0 -1
- package/dist/chunk-TYHI7RAD.mjs +0 -1
- package/dist/chunk-UIEJWORW.mjs +0 -1
- package/dist/chunk-VAOUFAUH.mjs +0 -1
- package/dist/chunk-VBOTMRXV.mjs +0 -1
- package/dist/chunk-VCER63GQ.mjs +0 -1
- package/dist/chunk-WAUF2UC7.mjs +0 -2
- package/dist/chunk-X4XDO3LZ.mjs +0 -1
- package/dist/chunk-XQBCCJBO.mjs +0 -9
- package/dist/chunk-XWUOLYRQ.mjs +0 -2
- package/dist/chunk-XYH6XWP3.mjs +0 -10
- package/dist/chunk-YBIM6UJV.mjs +0 -8
- package/dist/chunk-YCIH2Q3E.mjs +0 -1
- package/dist/chunk-ZOV5KL7C.mjs +0 -1
- package/dist/colorResolver-n0o7H7ep.d.mts +0 -290
- package/dist/core-plugins.d.mts +0 -37
- package/dist/core-plugins.mjs +0 -1
- package/dist/docx/parser.d.mts +0 -41
- package/dist/docx/parser.mjs +0 -1
- package/dist/docx/rezip.d.mts +0 -148
- package/dist/docx/rezip.mjs +0 -1
- package/dist/docx/serializer/index.d.mts +0 -42
- package/dist/docx/serializer/index.mjs +0 -1
- package/dist/editorTree-DO5PyDK8.d.mts +0 -37
- package/dist/executor-7O2RBJ2B.mjs +0 -1
- package/dist/headerFooterLayout-0zPT64Qc.d.mts +0 -316
- package/dist/headless.d.mts +0 -69
- package/dist/headless.mjs +0 -1
- package/dist/layout/flow/index.d.mts +0 -149
- package/dist/layout/flow/index.mjs +0 -1
- package/dist/layout/measure/index.d.mts +0 -324
- package/dist/layout/measure/index.mjs +0 -1
- package/dist/layout/pagination/types.d.mts +0 -4
- package/dist/layout/pagination/types.mjs +0 -1
- package/dist/managers/AutoSaveManager.d.mts +0 -81
- package/dist/managers/AutoSaveManager.mjs +0 -1
- package/dist/managers/TableSelectionManager.d.mts +0 -74
- package/dist/managers/TableSelectionManager.mjs +0 -1
- package/dist/managers/types.d.mts +0 -113
- package/dist/managers/types.mjs +0 -0
- package/dist/mcp-cli.mjs +0 -142
- package/dist/mcp.d.mts +0 -162
- package/dist/mcp.mjs +0 -16
- package/dist/measureBlocksPipeline-Df0Bbrwy.d.mts +0 -109
- package/dist/measuredBlock-DZwz8zhD.d.mts +0 -26
- package/dist/plugin-api/types.d.mts +0 -193
- package/dist/plugin-api/types.mjs +0 -0
- package/dist/processTemplate-HDUIZFJ5.mjs +0 -1
- package/dist/registry-DMM5VTdT.d.mts +0 -165
- package/dist/rustPagination-Bj2hq013.d.mts +0 -106
- package/dist/sectionConfigs-DW3J8q0X.d.mts +0 -55
- package/dist/selectionContext-Buc9BCU1.d.mts +0 -570
- package/dist/selectiveSave-oFBJ1n71.d.mts +0 -16
- package/dist/selectiveXmlPatch-ypkxlTD_.d.mts +0 -23
- package/dist/settingsParser-CcGvtmCK.d.mts +0 -33
- package/dist/types/agentApi.d.mts +0 -456
- package/dist/types/agentApi.mjs +0 -1
- package/dist/types-dYdjUZMo.d.mts +0 -311
- package/dist/units-O5Y02RKQ.d.mts +0 -34
- package/dist/utils/headingCollector.d.mts +0 -28
- package/dist/utils/headingCollector.mjs +0 -1
- package/dist/utils/highlightColors.d.mts +0 -14
- package/dist/utils/highlightColors.mjs +0 -1
- package/dist/utils/textSelection.d.mts +0 -92
- package/dist/utils/textSelection.mjs +0 -1
- package/dist/variableDetector-Borj29SF.d.mts +0 -115
- package/dist/wasm-FZQ5XB2Y.mjs +0 -1
- package/dist/watermarkApi-DCxjutkg.d.mts +0 -38
package/dist/docx/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{h as getImageHeightPx,g as getImageWidthPx,j as getWrapDistancesPx,e as isBehindText,i as isDecorativeImage,d as isFloatingImage,f as isInFrontOfText,c as isInlineImage,a as parseDrawing,b as parseImage}from'../chunk-I6KKMUUC.mjs';import {a}from'../chunk-ZOV5KL7C.mjs';export{f as getEndnoteText,e as getFootnoteText,h as isSeparatorEndnote,g as isSeparatorFootnote,d as parseEndnoteProperties,b as parseEndnotes,c as parseFootnoteProperties,a as parseFootnotes}from'../chunk-OMR3TWCD.mjs';export{d as computeListRendering,c as createNumberingMap,e as formatNumber,h as getBulletCharacter,b as getCachedNumberingMap,i as isBulletLevel,a as parseNumbering,g as renderListMarker}from'../chunk-XWUOLYRQ.mjs';import {h,k,o,p,n,f,m,g,a as a$1,b,i,s,t,c,q as q$1,j as j$1,r,l,e}from'../chunk-HJGAQIU7.mjs';export{a as getDocumentWatermark,b as setDocumentWatermark}from'../chunk-WAUF2UC7.mjs';export{b as buildPatchedDocumentXml,a as validatePatchSafety}from'../chunk-KEE52TT5.mjs';import'../chunk-FZIA7OFY.mjs';export{a as attemptSelectiveSave}from'../chunk-OJOHXQNQ.mjs';export{s as createDocx,h as repackDocx,l as updateMultipleFiles}from'../chunk-KVKLLTDP.mjs';import'../chunk-BIQWVK5P.mjs';import {b as b$1}from'../chunk-3UBMCDME.mjs';export{b as emuToPixels,c as pixelsToEmu}from'../chunk-3UBMCDME.mjs';export{a as parseDocx}from'../chunk-LDUWIM7M.mjs';import'../chunk-DXKG3HQ5.mjs';import'../chunk-FPZBTOD6.mjs';import'../chunk-H3JCIGWK.mjs';import'../chunk-N5Q3YN64.mjs';import'../chunk-SINEY6ZF.mjs';import'../chunk-T4EZMUXM.mjs';import'../chunk-TTRUPDAB.mjs';var it=new Set(["decorative","modern","roman","script","swiss","auto"]),at=new Set(["default","fixed","variable"]);function V(e,t){let n=j$1(e,"w",t);if(!n)return;let r=o(n,"r","id");if(!r)return;let o$1={relId:r},l=o(n,"w","fontKey");l&&(o$1.fontKey=l);let i=o(n,"w","subsetted");return (i==="true"||i==="1")&&(o$1.subsetted=true),o$1}function lt(e){let t=o(e,"w","name");if(!t)return null;let n={name:t},r=j$1(e,"w","altName");if(r){let c=o(r,"w","val");c&&(n.altName=c);}let o$1=j$1(e,"w","family");if(o$1){let c=o(o$1,"w","val");c&&it.has(c)&&(n.family=c);}let l=j$1(e,"w","pitch");if(l){let c=o(l,"w","val");c&&at.has(c)&&(n.pitch=c);}let i=j$1(e,"w","charset");if(i){let c=o(i,"w","val");c&&(n.charset=c);}let a=j$1(e,"w","panose1");if(a){let c=o(a,"w","val");c&&(n.panose1=c);}let u=V(e,"embedRegular");u&&(n.embedRegular=u);let p=V(e,"embedBold");p&&(n.embedBold=p);let f=V(e,"embedItalic");f&&(n.embedItalic=f);let m=V(e,"embedBoldItalic");return m&&(n.embedBoldItalic=m),n}function st(e){if(!e||e.trim().length===0)return {fonts:[]};let t=h(e);if(!t)return console.warn("Failed to parse fontTable.xml"),{fonts:[]};let n=[];for(let r of k(t,"w","font")){let o=lt(r);o&&n.push(o);}return {fonts:n}}function ut(e,t,n,r,o,l){let i=e.includes("w")||e.includes("e"),a=e.includes("n")||e.includes("s"),u=e.includes("w")?-1:1,p=e.includes("n")?-1:1,f=i?r+t*u:r,m=a?o+n*p:o;if(i&&a&&l){let T=Math.max(f/r,m/o);f=r*T,m=o*T;}let c=T=>Math.max(20,Math.min(2e3,T));return {width:i?c(f):r,height:a?c(m):o}}function pt(e,t,n){let r=()=>t.position?.horizontal&&t.position.vertical?t.position:n?.initialPositionEmu?{horizontal:{relativeTo:"column",posOffset:n.initialPositionEmu.horizontalEmu},vertical:{relativeTo:"paragraph",posOffset:n.initialPositionEmu.verticalEmu}}:{horizontal:{relativeTo:"column",posOffset:0},vertical:{relativeTo:"paragraph",posOffset:0}};switch(e){case "inline":return {wrapType:"inline",displayMode:"inline",cssFloat:"none",wrapText:void 0,position:void 0,distTop:void 0,distBottom:void 0,distLeft:void 0,distRight:void 0};case "squareLeft":case "squareRight":{let o=e==="squareLeft"?"left":"right";return {wrapType:t.wrapType==="tight"||t.wrapType==="through"?t.wrapType:"square",displayMode:"float",cssFloat:o,wrapText:o==="left"?"right":"left",position:r()}}case "square":case "tight":case "through":{let o=t.cssFloat==="left"||t.cssFloat==="right"?t.cssFloat:"left";return {wrapType:e,displayMode:"float",cssFloat:o,wrapText:o==="left"?"right":"left",position:r()}}case "topAndBottom":return {wrapType:"topAndBottom",displayMode:"block",cssFloat:"none",wrapText:"bothSides",position:r()};case "behind":case "inFront":return {wrapType:e,displayMode:"float",cssFloat:"none",wrapText:"bothSides",position:r()}}}function ct(e,t){return e==="inline"?"inline":e==="behind"?"behind":e==="inFront"?"inFront":e==="square"||e==="tight"||e==="through"?t==="right"?"squareRight":"squareLeft":null}var ft=[{choice:"inline",i18nLabelKey:"inLineWithText",i18nDescKey:"inLineWithText",iconHint:"inline"},{choice:"squareLeft",i18nLabelKey:"squareLeft",i18nDescKey:"squareLeft",iconHint:"squareLeft"},{choice:"squareRight",i18nLabelKey:"squareRight",i18nDescKey:"squareRight",iconHint:"squareRight"},{choice:"behind",i18nLabelKey:"behindText",i18nDescKey:"behindText",iconHint:"behind"},{choice:"inFront",i18nLabelKey:"inFrontOfText",i18nDescKey:"inFrontOfText",iconHint:"inFront"}];function dt(e,t){return true}function mt(e){switch(e){case "inline":return "inline";case "square":case "tight":case "through":return "squareLeft";case "topAndBottom":return "topAndBottom";case "behind":return "behind";case "inFront":return "inFront";case "wrapRight":return "squareLeft";case "wrapLeft":return "squareRight";default:return}}var Z=["PAGE","NUMPAGES","NUMWORDS","NUMCHARS","DATE","TIME","CREATEDATE","SAVEDATE","PRINTDATE","EDITTIME","AUTHOR","TITLE","SUBJECT","KEYWORDS","COMMENTS","FILENAME","FILESIZE","TEMPLATE","REVNUM","DOCPROPERTY","DOCVARIABLE","REF","PAGEREF","NOTEREF","HYPERLINK","TOC","TOA","INDEX","SEQ","STYLEREF","AUTONUM","AUTONUMLGL","AUTONUMOUT","SECTION","SECTIONPAGES","USERADDRESS","USERNAME","USERINITIALS","FORMTEXT","FORMCHECKBOX","FORMDROPDOWN","CITATION","BIBLIOGRAPHY","IF","MERGEFIELD","NEXT","NEXTIF","ASK","SET","QUOTE","INCLUDETEXT","INCLUDEPICTURE","SYMBOL","ADVANCE"];function $(e){let n=e.trim().match(/^\\?([A-Z][A-Z0-9]*)/i)?.[1]?.toUpperCase();return n&&Z.includes(n)?n:"UNKNOWN"}function ht(e){return Z.includes(e)}function gt(e){let t=e.trim(),n=t.match(/^\\?([A-Z][A-Z0-9]*)/i)?.[0]??"",r=t.slice(n.length).trim(),o=[],l=[],i=/\\(\*|@|#|!|[a-z])\s*(?:"([^"]*)"|([^\s]*))?/gi,a;for(;a=i.exec(r);)o.push({switch:a[1],...a[2]||a[3]?{value:a[2]||a[3]}:{}}),l.push(a.index);let u=r.slice(0,l[0]??r.length).trim(),p=u.startsWith('"')&&u.endsWith('"')?u.slice(1,-1):u||void 0;return {type:$(e),raw:e,...p?{argument:p}:{},switches:o}}function xt(e){return e.switches.find(t=>t.switch==="*"||t.switch==="@")?.value}function Tt(e){return e.switches.find(t=>t.switch==="*")?.value?.toUpperCase()==="MERGEFORMAT"}function bt(e,t,n){let r=o(e,"w","instr")??"",o$1=k(e,"w","r").map(i=>{let a=p(i);return {type:"run",content:a?[{type:"text",text:a}]:[]}}),l={type:"simpleField",instruction:r,fieldType:$(r),content:o$1};return /^(1|true)$/i.test(o(e,"w","fldLock")??"")&&(l.fldLock=true),/^(1|true)$/i.test(o(e,"w","dirty")??"")&&(l.dirty=true),o$1.length&&(l.structuredResult={inline:o$1},l.fieldTree={version:1,result:l.structuredResult,displayMode:"result"}),l}function yt(){return {state:"outside",instruction:"",codeRuns:[],resultRuns:[],fldLock:false,dirty:false,nestingLevel:0}}function wt(e){return (e.type==="simpleField"?e.content:e.fieldResult).map(St).join("")}function St(e){return e.type==="run"?le(e):e.children.filter(t=>t.type==="run").map(le).join("")}function le(e){return e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function Ft(e){return e.fieldType==="PAGE"}function Et(e){return e.fieldType==="NUMPAGES"}function Ct(e){return ["DATE","TIME","CREATEDATE","SAVEDATE","PRINTDATE","EDITTIME"].includes(e.fieldType)}function It(e){return ["AUTHOR","TITLE","SUBJECT","KEYWORDS","COMMENTS","FILENAME","FILESIZE","TEMPLATE","REVNUM","DOCPROPERTY","DOCVARIABLE"].includes(e.fieldType)}function At(e){return ["REF","PAGEREF","NOTEREF"].includes(e.fieldType)}function Mt(e){return ["MERGEFIELD","IF","NEXT","NEXTIF","ASK","SET"].includes(e.fieldType)}function Bt(e){return ["TOC","TOA","INDEX"].includes(e.fieldType)}function Pt(e,t,n$1=null,r=null,o$1=null,l,i=null){let a$1={type:"hyperlink",children:[]},u=o(e,"r","id");if(u){a$1.rId=u;let g=t?.get(u);g&&(a$1.href=a(g.target));}let p$1=o(e,"w","anchor");p$1&&(a$1.anchor=p$1.slice(0,1024),a$1.href||(a$1.href=`#${a$1.anchor}`));let f=o(e,"w","tooltip");f&&(a$1.tooltip=f.slice(0,2048));let m=o(e,"w","tgtFrame");m&&(a$1.target=m.slice(0,255));let c=o(e,"w","history");(c==="1"||c==="true")&&(a$1.history=true);let T=o(e,"w","docLocation");T&&(a$1.docLocation=T.slice(0,2048));for(let g of n(e).slice(0,1e4)){if(g.name?.replace(/^.*:/,"")!=="r")continue;let A=p(g);a$1.children.push({type:"run",content:A?[{type:"text",text:A}]:[]});}return a$1.children.length&&(a$1.structuredChildren=[...a$1.children]),a$1}function Lt(e){return e.children.filter(t=>t.type==="run").flatMap(t=>t.content).map(t=>t.type==="text"?t.text:t.type==="tab"?" ":"").join("")}function Rt(e){return e.href?/^https?:\/\/|^mailto:|^tel:|^ftp:/i.test(e.href):!!e.rId&&!e.anchor}function vt(e){return !!e.anchor}function Nt(e){return e.href}function Dt(e){return e.children.some(t=>t.type==="run")}function Ot(e){return e.children.filter(t=>t.type==="run")}function Xt(e,t){return e.rId&&(e.href=a(t.get(e.rId)?.target)),e.anchor&&!e.href&&(e.href=`#${e.anchor}`),e.href}function L(e,t){return n(e).find(n=>i(n.name??"")===t)??null}function P(e,t,n$1=0){if(!e||n$1>32)return null;for(let r of n(e)){if(i(r.name??"")===t)return r;let o=P(r,t,n$1+1);if(o)return o}return null}function N(e,t){let n=o(e,null,t);if(n==="1"||n==="true"||n==="on")return true;if(n==="0"||n==="false"||n==="off")return false}function E(e,t){let n=q$1(e,null,t);return n!==void 0&&Number.isFinite(n)?n:void 0}function kt(e){return e?l(e,"p").map(()=>({type:"paragraph",formatting:{},content:[]})):[]}function Ht(e$1,t){let n={t:"top",ctr:"middle",b:"bottom",dist:"distributed",just:"justified"},r=o(e$1,null,"anchor"),o$1=o(e$1,null,"vert"),l={left:E(e$1,"lIns"),right:E(e$1,"rIns"),top:E(e$1,"tIns"),bottom:E(e$1,"bIns")},i={content:kt(t)};o$1&&o$1!=="horz"&&(i.vertical=true);let a=e(o(e$1,null,"rot"));a!==void 0&&(i.rotation=a),r&&n[r]&&(i.anchor=n[r]);let u=N(e$1,"anchorCtr");return u!==void 0&&(i.anchorCenter=u),L(e$1,"noAutofit")?i.autoFit="none":L(e$1,"normAutofit")?i.autoFit="normal":L(e$1,"spAutoFit")&&(i.autoFit="shape"),Object.values(l).some(p=>p!==void 0)&&(i.margins=l),i}function se(e){let t=L(e,"spPr")??P(e,"spPr"),n=P(e,"cNvPr"),r=L(e,"bodyPr")??P(L(e,"txBody"),"bodyPr"),o$1=P(e,"txbxContent"),l=f(t?m(t,"a:xfrm"):null),i={type:"shape",shapeType:g(t),size:l.size};l.offset&&(i.offset=l.offset),l.transform&&(i.transform=l.transform);let a=a$1(t);a&&(i.fill=a);let u=b(t);return u&&(i.outline=u),n&&(i.id=o(n,null,"id")??void 0,i.name=o(n,null,"name")??void 0,i.title=o(n,null,"title")??void 0,i.description=o(n,null,"descr")??void 0,i.hidden=N(n,"hidden"),i.decorative=N(n,"decorative")),(o$1||r)&&(i.textBody=Ht(r,o$1)),i}function ue(e){return n(e).find(t=>{let n=i(t.name??"");return n==="inline"||n==="anchor"})??null}function Wt(e){let t$1=ue(e);if(!t$1)return null;let n$1=m(t$1,"a:graphicData");if(!n$1)return null;let r=n(n$1).find(u=>["wsp","sp","cxnSp"].includes(i(u.name??"")))??P(n$1,"wsp");if(!r)return null;let o$1=se(r),l=m(t$1,"wp:extent");l&&(o$1.size={width:E(l,"cx")??0,height:E(l,"cy")??0}),i(t$1.name??"")==="anchor"&&(o$1.position=s(t$1),o$1.wrap=t(t$1));let i$1=m(t$1,"wp:docPr");i$1&&(o$1.id=o(i$1,null,"id")??o$1.id,o$1.name=o(i$1,null,"name")??o$1.name,o$1.title=o(i$1,null,"title")??o$1.title,o$1.description=o(i$1,null,"descr")??o$1.description,o$1.hidden=N(i$1,"hidden")??o$1.hidden,o$1.decorative=N(i$1,"decorative")??o$1.decorative);let a=m(t$1,"wp:effectExtent");return a&&(o$1.effectExtent={left:E(a,"l"),top:E(a,"t"),right:E(a,"r"),bottom:E(a,"b")}),o$1.relativeHeight=o$1.position?.relativeHeight,o$1}function _t(e){let t=ue(e),n$1=t?m(t,"a:graphicData"):null;return n$1?n(n$1).some(r=>["wsp","wgp","wpc","spTree","grpSp","sp","cxnSp"].includes(i(r.name??""))):false}function Vt(e){return ["line","straightConnector1","bentConnector2","bentConnector3","bentConnector4","bentConnector5","curvedConnector2","curvedConnector3","curvedConnector4","curvedConnector5"].includes(e.shapeType)}function Ut(e){return e.shapeType==="textBox"||!!e.textBody?.content.length}function zt(e){return !!e.textBody?.content.length}function pe(e){return b$1(e.size.width)}function ce(e){return b$1(e.size.height)}function jt(e){return {width:pe(e),height:ce(e)}}function Kt(e){return e.position!==void 0||e.wrap!==void 0}function qt(e){return e.fill!==void 0&&e.fill.type!=="none"}function Gt(e){return e.outline!==void 0}function Yt(e){return e.outline?.width?b$1(e.outline.width):0}function Zt(e){return e.fill?.type==="solid"?c(e.fill.color):void 0}function $t(e){return e.outline?.color?c(e.outline.color):void 0}var J=720,Q="left",Jt="none";function fe(e){let t=q$1(e,"w","pos"),n=o(e,"w","val");if(t===void 0||!n)return null;let r={position:t,alignment:n},o$1=o(e,"w","leader");return o$1&&(r.leader=o$1),r}function de(e){if(!e)return [];let t=k(e,"w","tab");if(t.length===0)return [];let n=[];for(let r of t){let o=fe(r);o&&n.push(o);}return n.sort((r,o)=>r.position-o.position),n}function Qt(e){if(!e)return;let t=j$1(e,"w","tabs"),n=de(t);return n.length>0?n:void 0}function en(e,t){if(!e&&!t)return [];if(!e)return t??[];if(!t)return [...e];let n=new Map;for(let o of e)n.set(o.position,o);for(let o of t)o.alignment==="clear"?n.delete(o.position):n.set(o.position,o);let r=Array.from(n.values());return r.sort((o,l)=>o.position-l.position),r}function ee(e,t,n){for(let o of t)if(o.position>e&&o.alignment!=="clear")return o;let r=Math.ceil((e+1)/J)*J;return r>n?{position:n,alignment:Q}:{position:r,alignment:Q}}function tn(e,t,n){let r=ee(e,t,n);return Math.max(0,r.position-e)}function nn(e,t,n,r=0){let o=ee(e,t,n),l;switch(o.alignment){case "right":l=Math.max(0,o.position-e-r);break;case "center":l=Math.max(0,o.position-e-r/2);break;case "decimal":l=Math.max(0,o.position-e-r);break;case "bar":l=Math.max(0,o.position-e);break;default:l=Math.max(0,o.position-e);break}return {width:l,alignment:o.alignment}}function on(e){switch(e){case "dot":return ".";case "hyphen":return "-";case "underscore":return "_";case "heavy":return "_";case "middleDot":return "\xB7";default:return " "}}function rn(e){return e!==void 0&&e!=="none"}function an(e,t,n,r){return {...e&&e!=="auto"?{rgb:e}:{},...e==="auto"?{auto:true}:{},...t?{themeColor:t}:{},...n?{themeTint:n}:{},...r?{themeShade:r}:{}}}function D(e){if(!e)return;let n={style:o(e,"w","val")??"none"},r=q$1(e,"w","sz");r!==void 0&&(n.size=r);let o$1=q$1(e,"w","space");o$1!==void 0&&(n.space=o$1);let l=o(e,"w","color"),i=o(e,"w","themeColor"),a=o(e,"w","themeTint"),u=o(e,"w","themeShade");(l||i||a||u)&&(n.color=an(l,i,a,u));let p=o(e,"w","shadow");(p==="1"||p==="true")&&(n.shadow=true);let f=o(e,"w","frame");return (f==="1"||f==="true")&&(n.frame=true),n}function te(e){if(!e)return;let t=q$1(e,"w","w")??0,n=o(e,"w","type")??"dxa",r="dxa";return (n==="auto"||n==="dxa"||n==="nil"||n==="pct")&&(r=n),{value:t,type:r}}function C(e){return te(e)}function U(e){if(!e)return;let t={};for(let n of ["top","bottom","left","right","insideH","insideV","start","end","tl2br","tr2bl"]){let r=D(j$1(e,"w",n));r&&(t[n]=r);}return Object.keys(t).length>0?t:void 0}function z(e){if(!e)return;let t={},n=C(j$1(e,"w","top"));n&&(t.top=n);let r=C(j$1(e,"w","bottom"));r&&(t.bottom=r);let o=C(j$1(e,"w","left"));o&&(t.left=o);let l=C(j$1(e,"w","right"));l&&(t.right=l);let i=C(j$1(e,"w","start"));i&&(t.start=i);let a=C(j$1(e,"w","end"));if(a&&(t.end=a),Object.keys(t).length!==0)return t}function j(e){if(!e)return;let t={},n=o(e,"w","fill");n&&n!=="auto"&&(t.fill={rgb:n});let r=o(e,"w","themeFill");if(r){t.fill={themeColor:r};let a=o(e,"w","themeFillTint");a&&t.fill&&(t.fill.themeTint=a);let u=o(e,"w","themeFillShade");u&&t.fill&&(t.fill.themeShade=u);}let o$1=o(e,"w","color");o$1&&o$1!=="auto"&&(t.color={rgb:o$1});let l=o(e,"w","themeColor");l&&(t.color={...t.color??{},themeColor:l,themeTint:o(e,"w","themeTint")??void 0,themeShade:o(e,"w","themeShade")??void 0});let i=o(e,"w","val");if(i&&(t.pattern=i),Object.keys(t).length!==0)return t}function K(e){if(!e)return;let t={},n=o(e,"w","val");n&&(t.value=n.slice(0,8));let r=n?parseInt(n,16):NaN;Number.isNaN(r)||(t.firstRow=(r&32)!==0,t.lastRow=(r&64)!==0,t.firstColumn=(r&128)!==0,t.lastColumn=(r&256)!==0,t.noHBand=(r&512)!==0,t.noVBand=(r&1024)!==0);for(let[o$1,l]of [["firstRow","firstRow"],["lastRow","lastRow"],["firstColumn","firstColumn"],["lastColumn","lastColumn"],["noHBand","noHBand"],["noVBand","noVBand"]]){let i=o(e,"w",o$1);i!=null&&(t[l]=!/^(0|false|off)$/i.test(i));}if(Object.keys(t).length!==0)return t}function q(e){if(!e)return;let t={},n=o(e,"w","horzAnchor");(n==="margin"||n==="page"||n==="text")&&(t.horzAnchor=n);let r=o(e,"w","vertAnchor");(r==="margin"||r==="page"||r==="text")&&(t.vertAnchor=r);let o$1=q$1(e,"w","tblpX");o$1!==void 0&&(t.tblpX=o$1);let l=o(e,"w","tblpXSpec");l&&(t.tblpXSpec=l);let i=q$1(e,"w","tblpY");i!==void 0&&(t.tblpY=i);let a=o(e,"w","tblpYSpec");a&&(t.tblpYSpec=a);let u=q$1(e,"w","topFromText");u!==void 0&&(t.topFromText=u);let p=q$1(e,"w","bottomFromText");p!==void 0&&(t.bottomFromText=p);let f=q$1(e,"w","leftFromText");f!==void 0&&(t.leftFromText=f);let m=q$1(e,"w","rightFromText");if(m!==void 0&&(t.rightFromText=m),Object.keys(t).length!==0)return t}function me(e){return e.columnWidths&&e.columnWidths.length>0?e.columnWidths.length:e.rows.length===0?0:e.rows[0].cells.reduce((t,n)=>t+(n.formatting?.gridSpan??1),0)}function he(e){return e.rows.length}function ge(e){return e.formatting?.vMerge==="continue"}function xe(e){return e.formatting?.vMerge==="restart"}function Te(e){return e.rows.length===0?false:e.rows[0].formatting?.header===true}function ln(e){if(!e)return;let t={},n=C(j$1(e,"w","tblW"));n&&(t.width=n);let r$1=o(j$1(e,"w","jc"),"w","val");(r$1==="left"||r$1==="center"||r$1==="right"||r$1==="start")&&(t.justification=r$1==="start"?"left":r$1);let o$1=C(j$1(e,"w","tblCellSpacing"));o$1&&(t.cellSpacing=o$1);let l=C(j$1(e,"w","tblInd"));l&&(t.indent=l);let i=U(j$1(e,"w","tblBorders"));i&&(t.borders=i);let a=z(j$1(e,"w","tblCellMar"));a&&(t.cellMargins=a);let u=o(j$1(e,"w","tblLayout"),"w","type");(u==="fixed"||u==="autofit")&&(t.layout=u);let p=o(j$1(e,"w","tblStyle"),"w","val");p&&(t.styleId=p);let f=q$1(j$1(e,"w","tblStyleRowBandSize"),"w","val");f!==void 0&&f>0&&f<=1024&&(t.styleRowBandSize=f);let m=q$1(j$1(e,"w","tblStyleColBandSize"),"w","val");m!==void 0&&m>0&&m<=1024&&(t.styleColBandSize=m);let c=K(j$1(e,"w","tblLook"));c&&(t.look=c);let T=j(j$1(e,"w","shd"));T&&(t.shading=T);let g=o(j$1(e,"w","tblOverlap"),"w","val");(g==="never"||g==="overlap")&&(t.overlap=g);let A=q(j$1(e,"w","tblpPr"));return A&&(t.floating=A),r(j$1(e,"w","bidiVisual"))&&(t.bidi=true),Object.keys(t).length?t:void 0}var G=91440;function R(e,t){return n(e).find(n=>i(n.name??"")===t)??null}function I(e,t){let n=q$1(e,null,t);return n!==void 0&&Number.isFinite(n)?n:void 0}function sn(e$1){if(!e$1)return {};let t={left:I(e$1,"lIns"),right:I(e$1,"rIns"),top:I(e$1,"tIns"),bottom:I(e$1,"bIns")},n=Object.values(t).some(p=>p!==void 0),r={horz:"horizontal",vert:"vertical",vert270:"vertical270",wordArtVert:"wordArtVertical",wordArtVertRtl:"wordArtVertical",eaVert:"eastAsianVertical",mongolianVert:"mongolianVertical"},o$1={t:"top",ctr:"middle",b:"bottom",dist:"distributed",just:"justified"},l=o(e$1,null,"vert"),i=o(e$1,null,"anchor"),a=R(e$1,"normAutofit"),u={vertical:l?r[l]:void 0,rotation:e(o(e$1,null,"rot")),upright:o(e$1,null,"upright")==="1"||void 0,anchor:i?o$1[i]:void 0,anchorCenter:o(e$1,null,"anchorCtr")==="1"||void 0,columns:I(e$1,"numCol"),columnSpacing:I(e$1,"spcCol"),margins:n?t:void 0,autoFit:R(e$1,"noAutofit")?"none":a?"normal":R(e$1,"spAutoFit")?"shape":void 0,fontScale:I(a,"fontScale"),lineSpacingReduction:I(a,"lnSpcReduction")};return {...n?{margins:t}:{},...Object.values(u).some(p=>p!==void 0)?{bodyProperties:u}:{}}}function un(e){return {paragraphElements:l(e,"p"),tableElements:l(e,"tbl")}}function pn(e,t,n$1,r,o,l,i$1,a){if(!e)return [];let u=[];for(let p of n(e)){let f=i(p.name??"");f==="p"?u.push(t(p,r,o,l,i$1)):f==="tbl"&&n$1&&n$1(p,r,o,l,i$1,a);}return u}function be(e){let t=n(e).find(o=>["inline","anchor"].includes(i(o.name??"")))??null,n$1=t?m(t,"a:graphic"):null,r=n$1?m(n$1,"a:graphicData"):null;return {container:t,shape:r?m(r,"wps:wsp"):null}}function cn(e){let{shape:t}=be(e);return t?ne(t):false}function ne(e){return m(e,"wps:txbx")!==null}function ye(e,t,n,r){if(!ne(e))return null;let o$1=R(e,"spPr"),l=R(e,"bodyPr"),i=R(e,"cNvPr"),a=sn(l),u={type:"textBox",size:t,content:[]};u.id=o(i,null,"id")??void 0;let p=a$1(o$1);p&&(u.fill=p);let f=b(o$1);return f&&(u.outline=f),a.margins&&(u.margins=a.margins),a.bodyProperties&&(u.bodyProperties=a.bodyProperties),n&&(u.position=n),r&&(u.wrap=r),u}function fn(e){let{container:t$1,shape:n}=be(e);if(!t$1||!n)return null;let r=m(t$1,"wp:extent"),o$1={width:I(r,"cx")??0,height:I(r,"cy")??0},l=i(t$1.name??"")==="anchor",i$1=ye(n,o$1,l?s(t$1):void 0,l?t(t$1):void 0);return i$1&&(i$1.id=o(m(t$1,"wp:docPr"),null,"id")??i$1.id),i$1}function dn(e){return m(m(e,"wps:txbx"),"w:txbxContent")}function mn(e,t,n,r){return ye(e,t,n,r)}function we(e){return b$1(e.size.width)}function Se(e){return b$1(e.size.height)}function hn(e){return {width:we(e),height:Se(e)}}function gn(e){return {top:b$1(e.margins?.top??G),bottom:b$1(e.margins?.bottom??G),left:b$1(e.margins?.left??G),right:b$1(e.margins?.right??G)}}function xn(e){return e.position!==void 0||e.wrap!==void 0}function Tn(e){return e.fill!==void 0&&e.fill.type!=="none"}function bn(e){return e.outline!==void 0}function yn(e){return e.content.length>0}function wn(e){return e.content.map(t=>t.content.filter(n=>n.type==="run").flatMap(n=>n.content).filter(n=>n.type==="text").map(n=>n.text).join("")).join(`
|
|
2
|
-
|
|
1
|
+
import {e}from'../chunk-AEQOEQJ7.mjs';export{i as attemptSelectiveSave,h as createDocx,a as parseDocx,f as repackDocx,g as updateMultipleFiles}from'../chunk-AEQOEQJ7.mjs';import'../chunk-AZ52IWB6.mjs';import'../chunk-NJHOPXZW.mjs';import'../chunk-B4IR6YP4.mjs';import'../chunk-T4EZMUXM.mjs';import'../chunk-TTRUPDAB.mjs';function E(e,t,o,r,i,p){let a=e.includes("w")||e.includes("e"),s=e.includes("n")||e.includes("s"),u=e.includes("w")?-1:1,l=e.includes("n")?-1:1,m=a?r+t*u:r,f=s?i+o*l:i;if(a&&s&&p){let g=Math.max(m/r,f/i);m=r*g,f=i*g;}let d=g=>Math.max(20,Math.min(2e3,g));return {width:a?d(m):r,height:s?d(f):i}}function q(e,t,o){let r=()=>t.position?.horizontal&&t.position.vertical?t.position:o?.initialPositionEmu?{horizontal:{relativeTo:"column",posOffset:o.initialPositionEmu.horizontalEmu},vertical:{relativeTo:"paragraph",posOffset:o.initialPositionEmu.verticalEmu}}:{horizontal:{relativeTo:"column",posOffset:0},vertical:{relativeTo:"paragraph",posOffset:0}};switch(e){case "inline":return {wrapType:"inline",displayMode:"inline",cssFloat:"none",wrapText:void 0,position:void 0,distTop:void 0,distBottom:void 0,distLeft:void 0,distRight:void 0};case "squareLeft":case "squareRight":{let i=e==="squareLeft"?"left":"right";return {wrapType:t.wrapType==="tight"||t.wrapType==="through"?t.wrapType:"square",displayMode:"float",cssFloat:i,wrapText:i==="left"?"right":"left",position:r()}}case "square":case "tight":case "through":{let i=t.cssFloat==="left"||t.cssFloat==="right"?t.cssFloat:"left";return {wrapType:e,displayMode:"float",cssFloat:i,wrapText:i==="left"?"right":"left",position:r()}}case "topAndBottom":return {wrapType:"topAndBottom",displayMode:"block",cssFloat:"none",wrapText:"bothSides",position:r()};case "behind":case "inFront":return {wrapType:e,displayMode:"float",cssFloat:"none",wrapText:"bothSides",position:r()}}}function W(e,t){return e==="inline"?"inline":e==="behind"?"behind":e==="inFront"?"inFront":e==="square"||e==="tight"||e==="through"?t==="right"?"squareRight":"squareLeft":null}var _=[{choice:"inline",i18nLabelKey:"inLineWithText",i18nDescKey:"inLineWithText",iconHint:"inline"},{choice:"squareLeft",i18nLabelKey:"squareLeft",i18nDescKey:"squareLeft",iconHint:"squareLeft"},{choice:"squareRight",i18nLabelKey:"squareRight",i18nDescKey:"squareRight",iconHint:"squareRight"},{choice:"behind",i18nLabelKey:"behindText",i18nDescKey:"behindText",iconHint:"behind"},{choice:"inFront",i18nLabelKey:"inFrontOfText",i18nDescKey:"inFrontOfText",iconHint:"inFront"}];function B(e,t){return true}function z(e){switch(e){case "inline":return "inline";case "square":case "tight":case "through":return "squareLeft";case "topAndBottom":return "topAndBottom";case "behind":return "behind";case "inFront":return "inFront";case "wrapRight":return "squareLeft";case "wrapLeft":return "squareRight";default:return}}function K(e,t){let o=t.filter(p=>p.parentId!=null);if(o.length===0)return;let r=new Map;for(let p of o){let a=r.get(p.parentId);a?a.push(p.id):r.set(p.parentId,[p.id]);}function i(p){for(let a of p)if(a.type==="paragraph"){if(!a.content.some(u=>u.type==="commentRangeStart"||u.type==="commentRangeEnd"))continue;let s=[];for(let u of a.content)if(u.type==="commentRangeStart"){s.push(u);let l=r.get(u.id);if(l)for(let m of l)s.push({type:"commentRangeStart",id:m});}else if(u.type==="commentRangeEnd"){s.push(u);let l=r.get(u.id);if(l)for(let m of l)s.push({type:"commentRangeEnd",id:m});}else s.push(u);a.content=s;}else if(a.type==="table")for(let s of a.rows)for(let u of s.cells)i(u.content);}i(e);}function X(e,t){let o=new Set(t.map(a=>a.id)),r=t.filter(a=>a.parentId!=null&&!o.has(a.parentId));if(r.length===0)return;let i=new Map;for(let a of r){let s=i.get(a.parentId);s?s.push(a.id):i.set(a.parentId,[a.id]);}function p(a){for(let s of a)if(s.type==="paragraph"){if(!s.content.some(f=>(f.type==="insertion"||f.type==="deletion")&&i.has(f.info.id)))continue;let l=[],m=s.content;for(let f=0;f<m.length;f++){let d=m[f];if((d.type==="insertion"||d.type==="deletion")&&i.has(d.info.id)){let g=i.get(d.info.id);for(let y of g)l.push({type:"commentRangeStart",id:y});l.push(d);let h=m[f+1];h&&(h.type==="insertion"||h.type==="deletion")&&h.type!==d.type&&h.info.author===d.info.author&&h.info.date===d.info.date&&(l.push(h),f++);for(let y of g)l.push({type:"commentRangeEnd",id:y});}else l.push(d);}s.content=l;}else if(s.type==="table")for(let u of s.rows)for(let l of u.cells)p(l.content);}p(e);}function $(e){let t=e?.package.headers;if(t){for(let o of t.values())if(o.watermark)return o.watermark}}function G(e){let t=e.package.headers;if(!t||t.size===0)return e;let o=false,r=new Map;for(let[i,p]of t)if(p.watermark){let{watermark:a,...s}=p;r.set(i,s),o=true;}else r.set(i,p);return o?{...e,package:{...e.package,headers:r}}:e}function N(e,t){let o=e.package.headers;if(!o||o.size===0)return e;let r=new Map;for(let[i,p]of o)r.set(i,{...p,watermark:{...t}});return {...e,package:{...e.package,headers:r}}}function j(e){let t=e.package.document,o=[];if(t.sections)for(let r of t.sections)r.properties&&o.push(r.properties);return t.finalSectionProperties&&o.push(t.finalSectionProperties),o}function U(e$1,t){let o=e$1.package,r=o.document,i=o.headers,p=j(e$1),a=new Set;if(i)for(let n of i.values())a.add(n.hdrFtrType);let s=!i||i.size===0,u=p.some(n=>n.titlePg),l=p.some(n=>n.evenAndOddHeaders),m=s,f=u&&!a.has("first"),d=l&&!a.has("even");if(!m&&!f&&!d)return e$1;let g=o.relationships?new Map(o.relationships):new Map,h=new Map(i??[]),y=new Set;for(let n of g.values())n.target&&y.add(n.target.replace(/^\/?word\//,"").toLowerCase());function P(){let n=1;for(;y.has(`header${n}.xml`);)n++;let c=`header${n}.xml`;return y.add(c.toLowerCase()),c}function v(n){let c=`rIdWmHdr${n[0].toUpperCase()}${n.slice(1)}`,I=1;for(;g.has(c);)c=`rIdWmHdr${n[0].toUpperCase()}${n.slice(1)}${I++}`;return g.set(c,{id:c,type:e.header,target:P()}),h.set(c,{type:"header",hdrFtrType:n,content:[],watermark:{...t}}),c}let T={};function F(n){return T[n]??(T[n]=v(n))}function L(n,c){let I=n?.headerReferences?[...n.headerReferences]:[];return I.some(S=>S.type===c)?n??{}:(I.push({type:c,rId:F(c)}),{...n??{},headerReferences:I})}function w(n){let c=n;return m&&(c=L(c,"default")),f&&c?.titlePg&&(c=L(c,"first")),d&&c?.evenAndOddHeaders&&(c=L(c,"even")),c}let M=w(r.finalSectionProperties),k=r.sections?.map(n=>({...n,properties:w(n.properties)??n.properties}));return {...e$1,package:{...o,relationships:g,headers:h,document:{...r,finalSectionProperties:M,...k?{sections:k}:{}}}}}function Y(e,t){if(!t)return G(e);let o=N(e,t);return U(o,t)}
|
|
2
|
+
export{_ as IMAGE_LAYOUT_OPTIONS,E as calculateResizedImageDimensions,W as deriveLayoutChoice,$ as getDocumentWatermark,K as injectReplyRangeMarkers,X as injectTCReplyRangeMarkers,B as isImageLayoutOptionEnabled,q as resolveImageLayoutAttrs,Y as setDocumentWatermark,z as toolbarValueToLayoutTarget};
|
package/dist/editor/index.d.mts
CHANGED
|
@@ -1,170 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { R as ResidentMeasurementConfig } from '../rustMeasureSource-D1KsQvVC.mjs';
|
|
2
|
+
import { L as LayoutBlock, B as BlockExtent, a as Layout, b as LayoutOptions } from '../types-DMkDbvEu.mjs';
|
|
3
|
+
import { MeasuredBlock } from '../layout/pagination/index.mjs';
|
|
4
|
+
import { D as DisplayListHeadersFooters } from '../rustDisplayList-CX78djsZ.mjs';
|
|
4
5
|
import { Document } from '../types/document.mjs';
|
|
5
|
-
import { a as
|
|
6
|
-
import { S as SectionProperties,
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { a as StyleDefinitions } from '../styles-VxNcXLdi.mjs';
|
|
10
|
-
import '../settingsParser-CcGvtmCK.mjs';
|
|
6
|
+
import { Y as YrsSession, a as YrsRenderEnv } from '../index-Bwxm3oiC.mjs';
|
|
7
|
+
import { S as SectionProperties, N as NoteKind } from '../content-DLFHRQav.mjs';
|
|
8
|
+
import '../formatting-D1EPSaJP.mjs';
|
|
9
|
+
import '../styles-Dn_o3Vo5.mjs';
|
|
11
10
|
import '../docx/wrapTypes.mjs';
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
w: number;
|
|
34
|
-
h: number;
|
|
12
|
+
interface ResidentRegionLayoutRequest {
|
|
13
|
+
bodyStory: 'body';
|
|
14
|
+
options: Pick<LayoutOptions, 'contractVersion' | 'pageGap'>;
|
|
15
|
+
regions: {
|
|
16
|
+
sections: Array<{
|
|
17
|
+
sectionId?: string;
|
|
18
|
+
properties: SectionProperties;
|
|
19
|
+
}>;
|
|
20
|
+
settings?: Document['package']['settings'];
|
|
21
|
+
watermark?: SectionProperties['watermark'];
|
|
22
|
+
};
|
|
23
|
+
notes: {
|
|
24
|
+
contents: Array<{
|
|
25
|
+
id: number;
|
|
26
|
+
noteKind: NoteKind;
|
|
27
|
+
height: 0;
|
|
28
|
+
}>;
|
|
29
|
+
};
|
|
30
|
+
renderEnv: YrsRenderEnv;
|
|
31
|
+
measurement?: ResidentMeasurementConfig;
|
|
35
32
|
}
|
|
36
|
-
/** Adapter-supplied block measurer (React's is caching). */
|
|
37
|
-
type MeasureBlocksFn = (blocks: LayoutBlock[], contentWidth: number | number[], pageGeometry?: FloatPageGeometry) => BlockExtent[];
|
|
38
33
|
interface ComputeLayoutInputs {
|
|
39
|
-
/** Legacy tree state; null when an adapter supplies yrs body blocks. */
|
|
40
|
-
state: {
|
|
41
|
-
readonly doc: {
|
|
42
|
-
readonly attrs: Record<string, any>;
|
|
43
|
-
};
|
|
44
|
-
} | null;
|
|
45
34
|
document: Document | null;
|
|
46
|
-
pageSize: PageSizePx;
|
|
47
|
-
margins: PageMargins;
|
|
48
|
-
columns: ColumnLayout | undefined;
|
|
49
|
-
finalPageSize: PageSizePx;
|
|
50
|
-
finalMargins: PageMargins;
|
|
51
|
-
finalColumns: ColumnLayout | undefined;
|
|
52
35
|
pageGap: number;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
sectionProperties: SectionProperties | null | undefined;
|
|
57
|
-
finalSectionProperties: SectionProperties | null | undefined;
|
|
58
|
-
/** Resolved HF objects for the section (default + first-page). */
|
|
59
|
-
headerContent: HeaderFooter | null | undefined;
|
|
60
|
-
footerContent: HeaderFooter | null | undefined;
|
|
61
|
-
firstPageHeaderContent: HeaderFooter | null | undefined;
|
|
62
|
-
firstPageFooterContent: HeaderFooter | null | undefined;
|
|
63
|
-
/** Optional adapter-owned body source; null falls back to ProseMirror lowering. */
|
|
64
|
-
yrsBodyBlocks?: (env: {
|
|
65
|
-
pageContentHeight: number;
|
|
66
|
-
}) => LayoutBlock[] | null;
|
|
67
|
-
/** Optional adapter-owned non-body story source; null preserves PM lowering. */
|
|
68
|
-
yrsStoryBlocks?: (storyId: string) => LayoutBlock[] | null;
|
|
69
|
-
measureBlocks: MeasureBlocksFn;
|
|
70
|
-
/**
|
|
71
|
-
* The mandatory Rust pagination engine
|
|
72
|
-
* (`layout/pagination/rustPagination.ts`). Every pagination pass — full,
|
|
73
|
-
* footnote pass 1, and each footnote-stabilization iteration — runs
|
|
74
|
-
* `paginationSource.paginate(measured, options)`. The caller must gate
|
|
75
|
-
* layout passes on the source's readiness (`isReady()` / `whenReady()`);
|
|
76
|
-
* `paginate` throws on an unloaded engine or an engine failure and the
|
|
77
|
-
* pipeline surfaces the error.
|
|
78
|
-
*
|
|
79
|
-
* The Rust engine keeps no resume checkpoints: every pass is a full
|
|
80
|
-
* relayout in native code — the measured wager that replaced the TS
|
|
81
|
-
* incremental/off-thread kernels.
|
|
82
|
-
*/
|
|
83
|
-
paginationSource: LayoutPaginationSource;
|
|
36
|
+
session: Pick<YrsSession, 'layoutDocumentWithRegionsJson'>;
|
|
37
|
+
renderEnv: YrsRenderEnv;
|
|
38
|
+
measurement: ResidentMeasurementConfig;
|
|
84
39
|
}
|
|
85
40
|
interface LayoutComputation {
|
|
86
41
|
blocks: LayoutBlock[];
|
|
87
42
|
measures: BlockExtent[];
|
|
88
43
|
layout: Layout;
|
|
89
|
-
|
|
90
|
-
footerContentForRender: HeaderFooterContent | undefined;
|
|
91
|
-
firstPageHeaderForRender: HeaderFooterContent | undefined;
|
|
92
|
-
firstPageFooterForRender: HeaderFooterContent | undefined;
|
|
93
|
-
hasTitlePg: boolean;
|
|
94
|
-
watermark: Watermark | undefined;
|
|
95
|
-
headerDistancePx: number | undefined;
|
|
96
|
-
footerDistancePx: number | undefined;
|
|
97
|
-
pageBorders: SectionProperties['pageBorders'] | undefined;
|
|
98
|
-
footnotesByPage: Map<number, FootnoteRenderItem[]> | undefined;
|
|
44
|
+
notesConverged: boolean;
|
|
99
45
|
}
|
|
100
|
-
|
|
101
|
-
* The `{ measured, options }` pair a Layout was paginated from, when that
|
|
102
|
-
* Layout came out of a compute call in this session, plus the `headersFooters`
|
|
103
|
-
* payload assembled from the same HF contents/page-level watermark the pages
|
|
104
|
-
* render with. The canvas renderer joins this with the Layout itself into the
|
|
105
|
-
* `{ measured, options, layout, headersFooters }` envelope the Rust
|
|
106
|
-
* display-list builder consumes. Every compute path (including footnote
|
|
107
|
-
* stabilization) records its final layout here; undefined means the Layout
|
|
108
|
-
* did not come from a compute call in this session.
|
|
109
|
-
*/
|
|
46
|
+
declare function buildResidentRegionLayoutRequest(document: Document | null, pageGap: number, renderEnv: YrsRenderEnv): ResidentRegionLayoutRequest;
|
|
110
47
|
declare function getLayoutKernelInputs(layout: Layout): {
|
|
111
|
-
measured:
|
|
48
|
+
measured: MeasuredBlock[];
|
|
112
49
|
options: unknown;
|
|
113
50
|
headersFooters?: DisplayListHeadersFooters;
|
|
114
51
|
} | undefined;
|
|
115
|
-
/**
|
|
116
|
-
* Run the pure layout compute pass (the 6 steps in this file's header).
|
|
117
|
-
* Every pagination pass runs through the injected Rust pagination source —
|
|
118
|
-
* the sole layout kernel. The wasm engine is synchronous native code, so
|
|
119
|
-
* edits and opens alike take this one full-pass path (the Rust engine keeps
|
|
120
|
-
* no resume checkpoints; incremental resume and the off-thread worker died
|
|
121
|
-
* with the TS kernel).
|
|
122
|
-
*/
|
|
123
52
|
declare function computeLayout(inputs: ComputeLayoutInputs): LayoutComputation;
|
|
124
53
|
|
|
125
|
-
|
|
126
|
-
* rAF-coalescing layout scheduler shared by the React and Vue adapters
|
|
127
|
-
* (issue #696 Tier 2). Rapid doc-changing transactions (a burst of
|
|
128
|
-
* keystrokes) collapse to a single layout pass per animation frame: while a
|
|
129
|
-
* frame is pending, later `schedule` calls just replace the target state, so
|
|
130
|
-
* only the final state lays out.
|
|
131
|
-
*
|
|
132
|
-
* `scheduleFrame`/`cancelFrame` are injected so a headless/test host can pass
|
|
133
|
-
* a synchronous stub; they default to requestAnimationFrame.
|
|
134
|
-
*/
|
|
135
|
-
interface LayoutScheduler<TState = unknown> {
|
|
136
|
-
/** Request a layout for `state`, coalesced into the pending frame. */
|
|
137
|
-
schedule(state: TState): void;
|
|
138
|
-
/** Cancel any pending frame (call on teardown). */
|
|
139
|
-
cancel(): void;
|
|
140
|
-
}
|
|
141
|
-
declare function createLayoutScheduler<TState>(run: (state: TState) => void, scheduleFrame?: (cb: () => void) => number, cancelFrame?: (handle: number) => void): LayoutScheduler<TState>;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Strip ProseMirror's internal `UPDATED_SCROLL` flag from a transaction so the
|
|
145
|
-
* hidden, off-screen editor's `updateState` does not force-scroll its ancestors
|
|
146
|
-
* to the selection — the paginated painter owns scroll, not the PM view.
|
|
147
|
-
*
|
|
148
|
-
* Shared by both adapters' `dispatchTransaction` (issue #696 Tier 2). React has
|
|
149
|
-
* always done this; Vue did not, so its hidden editor could yank an ancestor's
|
|
150
|
-
* scroll on edit. Centralizing the magic bit + the drift canary here keeps the
|
|
151
|
-
* two in lockstep.
|
|
152
|
-
*
|
|
153
|
-
* `Transaction.updated` is a private bitfield in `prosemirror-state` whose
|
|
154
|
-
* `UPDATED_SCROLL` bit is not exported. It is `4` in current PM
|
|
155
|
-
* (state/src/transaction.ts). If a future PM release renumbers the bits before
|
|
156
|
-
* SCROLL, `assertScrollFlagShape` logs once so the constant can be updated.
|
|
157
|
-
*/
|
|
158
|
-
/** Minimal transaction shape used by the legacy scroll-flag compatibility seam. */
|
|
159
|
-
interface ScrollFlagTransaction {
|
|
160
|
-
scrollIntoView(): ScrollFlagTransaction;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Clear the scroll-into-view flag on `transaction` in place. Call inside
|
|
164
|
-
* `dispatchTransaction` before `state.apply(transaction)`. `probeTr` should be
|
|
165
|
-
* a fresh `view.state.tr` used only for the one-shot drift canary (so the real
|
|
166
|
-
* transaction is never mutated by the probe).
|
|
167
|
-
*/
|
|
168
|
-
declare function stripScrollFlag(transaction: ScrollFlagTransaction, probeTr: ScrollFlagTransaction): void;
|
|
169
|
-
|
|
170
|
-
export { type ComputeLayoutInputs, type LayoutComputation, type LayoutScheduler, type MeasureBlocksFn, computeLayout, createLayoutScheduler, getLayoutKernelInputs, stripScrollFlag };
|
|
54
|
+
export { type ComputeLayoutInputs, type LayoutComputation, buildResidentRegionLayoutRequest, computeLayout, getLayoutKernelInputs };
|
package/dist/editor/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {I,f as f$1,w,g,j,e,n,o,l,a as a$1,C,t,b}from'../chunk-P3KDV4M2.mjs';import {f,g as g$1}from'../chunk-7DEIW7FL.mjs';import {c}from'../chunk-IL5JZJT7.mjs';import'../chunk-GWKJ2Y4Y.mjs';import'../chunk-52GB3Y42.mjs';import {a}from'../chunk-7PCO5I2O.mjs';import {d}from'../chunk-X4XDO3LZ.mjs';import'../chunk-L5ISVQ3W.mjs';import'../chunk-OMR3TWCD.mjs';import {e as e$1}from'../chunk-XWUOLYRQ.mjs';import'../chunk-HJGAQIU7.mjs';import'../chunk-FZIA7OFY.mjs';import'../chunk-OBQGPMPQ.mjs';import'../chunk-3UBMCDME.mjs';import'../chunk-FPZBTOD6.mjs';import'../chunk-H3JCIGWK.mjs';import'../chunk-SINEY6ZF.mjs';import'../chunk-T4EZMUXM.mjs';import'../chunk-TTRUPDAB.mjs';function fe(t,a){let r=t?.package?.document;if(!r)return;let o=[...(r.sections??[]).map(n=>n.properties),r.finalSectionProperties];return a.sectionIndex!==void 0?o[a.sectionIndex]??r.finalSectionProperties:o.find(n=>(n?.footnoteColumns??1)>1)??o[0]}function le(t){let a=t?.package?.document;return a?[...(a.sections??[]).map(r=>r.properties),a.finalSectionProperties]:[]}function me(t,a){let r={},o=(n,c,e)=>{let i=`${n}${c==="default"?"Default":c==="first"?"First":"Even"}`;r[i]=e;};for(let n=0;n<=a;n++){let c=t[n];for(let e of c?.headerReferences??[])o("header",e.type,e.rId);for(let e of c?.footerReferences??[])o("footer",e.type,e.rId);}return Object.keys(r).length?r:void 0}function Me(t,a){let{document:r,sectionProperties:o}=t.inputs,n=le(r),c=new Map;for(let e of a.pages){let s=e.sectionIndex??(n.length===1?0:void 0);e.sectionIndex===void 0&&s!==void 0&&(e.sectionIndex=s);let i=s!==void 0?n[s]??o:o;if(!i){t.watermark!==void 0&&e.watermark===void 0&&(e.watermark=t.watermark);continue}if(s!==void 0){let f=e.sectionId??String(s),l=c.get(f)??0,m=e.sectionPageIndex??l;c.set(f,Math.max(l,m)+1),e.sectionPageIndex=m,e.headerFooterRefs??(e.headerFooterRefs=me(n,s));let d=e.pageNumbering??i.pageNumbering;if(d){e.pageNumbering=d;let u=e.sectionPageNumber??(d.start??1)+m;e.sectionPageNumber=u,e.pageLabel??(e.pageLabel=e$1(u,d.format??"decimal"));}}e.headerDistance===void 0&&i.headerDistance!=null&&(e.headerDistance=C(i.headerDistance)),e.footerDistance===void 0&&i.footerDistance!=null&&(e.footerDistance=C(i.footerDistance)),e.pageBorders??(e.pageBorders=i.pageBorders),e.watermark??(e.watermark=i.watermark??t.watermark),e.verticalAlign??(e.verticalAlign=i.verticalAlign);}}function xe(t,a,r){let o=fe(t,a);if(!o?.footnoteColumns)return {columns:1,columnWidth:r};let n=o.footnoteColumns,e=((o.pageWidth!=null?C(o.pageWidth-(o.marginLeft??1440)-(o.marginRight??1440)):r)-(n-1)*b)/n;return {columns:n,columnWidth:Math.max(1,e)}}var pe=new WeakMap;function Be(t,a){return Me(t,a),pe.set(a,{measured:t.measured,options:t.layoutOpts,headersFooters:Ie(t,a.pages)}),a}function De(t,a){let r=String(a.length),o=[],n=(c,e)=>{let s=g$1(c,e);return s.active?s.width:void 0};for(let c of t.blocks)if(c.kind==="paragraph")for(let e of c.runs){if(e.kind!=="field"||e.fieldType!=="PAGE"&&e.fieldType!=="NUMPAGES"||e.pmStart===void 0)continue;let s={fontFamily:e.fontFamily??"Calibri",fontSize:e.fontSize??11,bold:e.bold,italic:e.italic},i=n(e.fallback||"1",s);if(i===void 0)continue;let f=[],l=true;for(let m of a){let d=n(e.fieldType==="NUMPAGES"?r:m.pageLabel??String(m.number),s);if(d===void 0){l=false;break}f.push(d);}l&&o.push({pmStart:e.pmStart,fallbackWidth:i,perPage:f});}return o.length>0?o:void 0}function Ie(t,a$1){let{inputs:r,hasTitlePg:o}=t,n=r.document?.package,c=(l,m)=>{if(!(!l||!m)){for(let[d,u]of l)if(u===m)return d}},e=[],s=(l,m,d,u)=>{if(!u||u.blocks.length===0)return;let g=De(u,a$1);e.push({rId:c(l==="header"?n?.headers:n?.footers,d)??"",kind:l,type:m,measured:a(u.blocks,u.measures),height:u.height,...u.flowHeight!==void 0?{flowHeight:u.flowHeight}:{},...u.visualTop!==void 0?{visualTop:u.visualTop}:{},...u.visualBottom!==void 0?{visualBottom:u.visualBottom}:{},...g?{fieldWidths:g}:{}});};s("header","default",r.headerContent,t.headerContentForRender),s("footer","default",r.footerContent,t.footerContentForRender),s("header","first",r.firstPageHeaderContent,t.firstPageHeaderForRender),s("footer","first",r.firstPageFooterContent,t.firstPageFooterForRender),s("header","even",t.evenPageHeader,t.evenPageHeaderForRender),s("footer","even",t.evenPageFooter,t.evenPageFooterForRender);let i=t.watermark;if(e.length===0&&!i)return;let{sectionProperties:f}=r;return {titlePg:o,evenAndOddHeaders:t.evenAndOddHeaders,...f?.headerDistance!=null?{headerDistance:C(f.headerDistance)}:{},...f?.footerDistance!=null?{footerDistance:C(f.footerDistance)}:{},...i?{watermark:i}:{},variants:e}}function we(t){return pe.get(t)}function Ee(t){let a=Oe(t),{layout:r,footnotesByPage:o}=a.hasFootnotes?We(a):{layout:t.paginationSource.paginate(a.measured,a.layoutOpts),footnotesByPage:void 0};return Be(a,r),_e(a,r,o)}function Oe(t$1){f();let{state:a$1,document:r,pageSize:o,margins:n,columns:c$1,finalPageSize:e,finalMargins:s,finalColumns:i,pageGap:f$2,contentWidth:l,theme:m,styles:d$1,sectionProperties:u,finalSectionProperties:g,headerContent:b,footerContent:C,firstPageHeaderContent:R,firstPageFooterContent:L,measureBlocks:k}=t$1,p=o.h-n.top-n.bottom,y=t$1.yrsBodyBlocks?.({pageContentHeight:p})??(a$1?c(a$1.doc,{theme:m,pageContentHeight:p}):(()=>{throw new Error("computeLayout requires either yrsBodyBlocks or a ProseMirror state")})()),h=I(y,{pageSize:o,margins:n,columns:c$1},{pageSize:e,margins:s,columns:i});let F=k(y,h,d({size:o,margins:n})),T=f$1(y),D=T.some(P=>P.noteKind==="endnote"?!!r?.package?.endnotes?.length:!!r?.package?.footnotes?.length),I$1={section:"header",pageSize:o,margins:n},w$1={section:"footer",pageSize:o,margins:n},he=a$1?.doc.attrs?.defaultTabStopTwips??r?.package.settings?.defaultTabStop??null,Pe={styles:d$1,theme:m,measureBlocks:k,defaultTabStopTwips:he,yrsStoryBlocks:t$1.yrsStoryBlocks},Fe=P=>{let v=r?.package;if(v){for(let x of [v.headers,v.footers])if(x){for(let[ve,Te]of x)if(Te===P)return `hf:${ve}`}}},H=(P,v)=>{if(!P)return;let x=t$1.yrsStoryBlocks?Fe(P):void 0;return t(P,l,v,Pe,x)},K=H(b,I$1),G=H(C,w$1),E=u?.titlePg===true,U=E?H(R,I$1):void 0,$=E?H(L,w$1):void 0,V=le(r),be=Math.max(0,V.findIndex(P=>P===u)),M=me(V,be),q=M?.headerEven?r?.package?.headers?.get(M.headerEven):void 0,j=M?.footerEven?r?.package?.footers?.get(M.footerEven):void 0,X=H(q,I$1),J=H(j,w$1),Le=r?.package?.settings?.evenAndOddHeaders===true||u?.evenAndOddHeaders===true,ke=a$1?.doc.attrs?.watermark??g?.watermark??void 0,{margins:Se,finalMargins:Ce}=w({pageSize:o,margins:n,finalMargins:s,bodyBlocks:y,headers:[K,U,X],footers:[G,$,J],warn:P=>console.warn(`[computeLayout] ${P}`)}),He=g?.sectionStart,Re={pageSize:o,margins:Se,finalPageSize:e,finalMargins:Ce,columns:i,bodyBreakType:He,pageGap:f$2};return {measured:a(y,F),layoutOpts:Re,hasFootnotes:D,footnoteRefs:T,blocks:y,measures:F,headerContentForRender:K,footerContentForRender:G,firstPageHeaderForRender:U,firstPageFooterForRender:$,evenPageHeader:q,evenPageFooter:j,evenPageHeaderForRender:X,evenPageFooterForRender:J,evenAndOddHeaders:Le,hasTitlePg:E,watermark:ke,inputs:t$1}}function We(t){let{measured:a,layoutOpts:r,footnoteRefs:o$1,blocks:n$1,measures:c,inputs:e$1}=t,{document:s,contentWidth:i,styles:f,theme:l,measureBlocks:m,state:d}=e$1,u=d?.doc.attrs?.defaultTabStopTwips??s?.package.settings?.defaultTabStop??null,g$1=(h,F)=>e$1.paginationSource.paginate(h,F),b=g$1(a,r),C=g(b.pages,o$1),R=new Map,L=new Map;for(let h of b.pages){let{columns:F,columnWidth:T}=xe(s,h,i);R.set(h.number,F);for(let D of C.get(h.number)??[])L.set(D,T);}let k=Ae(o$1,b.pages,s,C),p=j(s.package.footnotes??[],s.package.endnotes??[],o$1,h=>L.get(e(h))??i,{styles:f??void 0,theme:l??null,measureBlocks:m,defaultTabStopTwips:u,yrsStoryBlocks:e$1.yrsStoryBlocks},k),y=n({blocks:n$1,measures:c,layoutOpts:r,paginate:g$1,footnoteRefs:o$1,footnoteContentMap:p,initialLayout:b,footnoteColumns:R,mapReferencesToPages:(h,F)=>Ne(h,F,s)});return ze(y.layout,y.pageFootnoteMap,p,s),{layout:y.layout,footnotesByPage:o(y.pageFootnoteMap,p,s)}}function _(t,a,r){let o=t?.package?.settings,n=fe(t,a);return r==="endnote"?{...o?.endnotePr??{},...n?.endnotePr??{}}:{...o?.footnotePr??{},...n?.footnotePr??{}}}function ge(t,a,r){let o=[...a].find(([,n])=>n.includes(r))?.[0];return t.find(n=>n.number===o)}function Ne(t,a,r){let o=g(t,a),n=new Map,c=(e,s)=>{let i=n.get(e)??[];i.includes(s)||i.push(s),n.set(e,i);};for(let e$1 of a){let s=e(e$1),i=ge(t,o,s);if(!i)continue;let f=e$1.noteKind??"footnote",m=_(r,i,f).position??(f==="endnote"?"docEnd":"pageBottom"),d=i;if(m==="docEnd")d=t[t.length-1]??i;else if(m==="sectEnd"){let u=t.filter(g=>i.sectionId!==void 0?g.sectionId===i.sectionId:i.sectionIndex!==void 0?g.sectionIndex===i.sectionIndex:true);d=u[u.length-1]??i;}c(d.number,s);}return n}function Ae(t,a,r,o){let n=new Map,c=new Map;for(let e$2 of t){let s=e(e$2);if(n.has(s))continue;let i=ge(a,o,s);if(!i)continue;let f=e$2.noteKind??"footnote",l=_(r,i,f),m=l.numRestart==="eachPage"?`${f}:page:${i.number}`:l.numRestart==="eachSect"?`${f}:section:${i.sectionId??i.sectionIndex??0}`:`${f}:continuous`,d=c.get(m)??l.numStart??1;c.set(m,d+1),n.set(s,{displayNumber:d,displayLabel:e$1(d,l.numFmt??"decimal"),anchor:{docStart:e$2.pmPos,docEnd:e$2.pmPos+1}});}return n}function ze(t,a,r,o){for(let n of t.pages){let c=a.get(n.number);if(!c?.length)continue;let e=c.map(d=>r.get(d)).filter(d=>d!==void 0);if(!e.length)continue;let s=n.size.h-n.margins.bottom,i=n.fragments.reduce((d,u)=>Math.max(d,u.y+u.height),n.margins.top),f=new Map;for(let d of e){let u=d.noteKind??"footnote",g=f.get(u)??[];g.push(d),f.set(u,g);}let l$1=s,m=i;n.noteAreas=[...f].map(([d,u])=>{let b=_(o,n,d).position??(d==="endnote"?"docEnd":"pageBottom"),C=d==="footnote"?n.footnoteColumns??1:1,L=l(u,C).reduce((p,y)=>Math.max(p,y.reduce((h,F)=>h+F.height,0)),0)+a$1,k;return b==="beneathText"?(k=Math.min(m,s-L),m=k+L):(l$1-=L,k=l$1),{kind:d,placement:b,y:k,height:L,columns:C,sectionId:n.sectionId,notes:u.map(p=>({kind:d,id:p.id,displayLabel:p.displayLabel??String(p.displayNumber),blocks:p.blocks,measures:p.measures,height:p.height,anchorDocStart:p.anchor?.docStart,anchorDocEnd:p.anchor?.docEnd,customMarkFollows:p.customMarkFollows}))}});}}function _e(t,a,r){let{sectionProperties:o}=t.inputs;return {blocks:t.blocks,measures:t.measures,layout:a,headerContentForRender:t.headerContentForRender,footerContentForRender:t.footerContentForRender,firstPageHeaderForRender:t.firstPageHeaderForRender,firstPageFooterForRender:t.firstPageFooterForRender,hasTitlePg:t.hasTitlePg,watermark:t.watermark,headerDistancePx:o?.headerDistance!=null?C(o.headerDistance):void 0,footerDistancePx:o?.footerDistance!=null?C(o.footerDistance):void 0,pageBorders:o?.pageBorders,footnotesByPage:r?.size?r:void 0}}function Ke(t,a=o=>requestAnimationFrame(o),r=o=>cancelAnimationFrame(o)){let o=null;return {schedule(n){if(o){o.state=n;return}o={handle:0,state:n};let c=a(()=>{let e=o;o=null,e&&t(e.state);});o&&(o.handle=c);},cancel(){o&&(r(o.handle),o=null);}}}var ye=false;function Ge(t){if(!ye){ye=true;try{let a=t.scrollIntoView();(typeof a.updated!="number"||(a.updated&4)===0)&&console.warn("[docx-editor] prosemirror-state UPDATED_SCROLL bit shape changed; paginated scroll suppression may be stale. Update PM_UPDATED_SCROLL.");}catch{}}}function Ue(t,a){Ge(a);let r=t;typeof r.updated=="number"&&(r.updated&=-5);}export{Ee as computeLayout,Ke as createLayoutScheduler,we as getLayoutKernelInputs,Ue as stripScrollFlag};
|
|
1
|
+
import'../chunk-TTRUPDAB.mjs';var r=new WeakMap;function p(e){let n=e?.package.document;if(!n)return [{properties:{}}];let t=(n.sections??[]).map(o=>({sectionId:o.id??o.properties.sectionId,properties:o.properties}));return t.push({sectionId:n.finalSectionProperties?.sectionId,properties:n.finalSectionProperties??{}}),t}function a(e,n,t){let o=[];for(let s of e?.package.footnotes??[])s.noteType&&s.noteType!=="normal"||o.push({id:s.id,noteKind:"footnote",height:0});for(let s of e?.package.endnotes??[])s.noteType&&s.noteType!=="normal"||o.push({id:s.id,noteKind:"endnote",height:0});return {bodyStory:"body",options:{contractVersion:e?.package.contractVersion,pageGap:n},regions:{sections:p(e),settings:e?.package.settings,watermark:e?.package.document.finalSectionProperties?.watermark},notes:{contents:o},renderEnv:t}}function d(e){return r.get(e)}function c(e){let n=a(e.document,e.pageGap,e.renderEnv);n.measurement=e.measurement;let t=JSON.parse(e.session.layoutDocumentWithRegionsJson(JSON.stringify(n)));return r.set(t.layout,{measured:t.measured,options:t.options,...t.headersFooters?{headersFooters:t.headersFooters}:{}}),{blocks:t.measured.map(o=>o.block),measures:t.measured.map(o=>o.measure),layout:t.layout,notesConverged:t.notesConverged}}export{a as buildResidentRegionLayoutRequest,c as computeLayout,d as getLayoutKernelInputs};
|
|
@@ -1,90 +1,92 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { s as BreakContent, P as Paragraph, R as Run, g as RunContent } from './content-sSHuWw49.mjs';
|
|
1
|
+
import { C as ColorValue, e as Theme, f as ThemeColorSlot } from './formatting-D1EPSaJP.mjs';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
4
|
+
* Color Resolver - Convert OOXML colors to CSS
|
|
6
5
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* The generic color machinery (theme slots, tint/shade math, blending, the
|
|
7
|
+
* picker matrix) is re-exported here. This module keeps the WordprocessingML-
|
|
8
|
+
* specific pieces: w:highlight named colors, w:shd shading semantics, and
|
|
9
|
+
* ColorValue construction helpers.
|
|
10
|
+
*
|
|
11
|
+
* OOXML Color References:
|
|
12
|
+
* - w:color/@w:val - RGB hex or "auto"
|
|
13
|
+
* - w:color/@w:themeColor - Theme color slot
|
|
14
|
+
* - w:color/@w:themeTint - Tint modifier (0-255, hex)
|
|
15
|
+
* - w:color/@w:themeShade - Shade modifier (0-255, hex)
|
|
9
16
|
*/
|
|
10
17
|
|
|
11
18
|
/**
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
paragraphIndex: number;
|
|
17
|
-
/** Run index within the paragraph (optional) */
|
|
18
|
-
runIndex?: number;
|
|
19
|
-
/** Character offset within the run (optional) */
|
|
20
|
-
offset?: number;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Create a page break content element
|
|
24
|
-
*/
|
|
25
|
-
declare function createPageBreak(): BreakContent;
|
|
26
|
-
/**
|
|
27
|
-
* Create a column break content element
|
|
28
|
-
*/
|
|
29
|
-
declare function createColumnBreak(): BreakContent;
|
|
30
|
-
/**
|
|
31
|
-
* Create a text wrapping break (line break)
|
|
32
|
-
*/
|
|
33
|
-
declare function createLineBreak(clear?: 'none' | 'left' | 'right' | 'all'): BreakContent;
|
|
34
|
-
/**
|
|
35
|
-
* Create a run containing a page break
|
|
36
|
-
*/
|
|
37
|
-
declare function createPageBreakRun(): Run;
|
|
38
|
-
/**
|
|
39
|
-
* Create an empty paragraph with a page break before it
|
|
40
|
-
*/
|
|
41
|
-
declare function createPageBreakParagraph(): Paragraph;
|
|
42
|
-
/**
|
|
43
|
-
* Insert a page break at a position in the document
|
|
44
|
-
* This inserts a new paragraph with pageBreakBefore: true
|
|
45
|
-
*/
|
|
46
|
-
declare function insertPageBreak(doc: Document, position: InsertPosition): Document;
|
|
47
|
-
/**
|
|
48
|
-
* Create a horizontal rule paragraph
|
|
49
|
-
* Uses a paragraph with bottom border to simulate horizontal rule
|
|
19
|
+
* Resolve a highlight color name to CSS
|
|
20
|
+
*
|
|
21
|
+
* @param highlight - Highlight color name (e.g., "yellow", "cyan")
|
|
22
|
+
* @returns CSS color string or empty string for "none"
|
|
50
23
|
*/
|
|
51
|
-
declare function
|
|
24
|
+
declare function resolveHighlightColor(highlight: string | undefined): string;
|
|
52
25
|
/**
|
|
53
|
-
*
|
|
26
|
+
* Resolve a shading fill or pattern color to CSS
|
|
27
|
+
*
|
|
28
|
+
* @param color - ColorValue for fill
|
|
29
|
+
* @param theme - Theme for resolving theme colors
|
|
30
|
+
* @returns CSS color string
|
|
54
31
|
*/
|
|
55
|
-
declare function
|
|
32
|
+
declare function resolveShadingColor(color: ColorValue | undefined | null, theme: Theme | null | undefined): string;
|
|
56
33
|
/**
|
|
57
|
-
* Check if
|
|
34
|
+
* Check if a color is effectively black
|
|
35
|
+
*
|
|
36
|
+
* @param color - ColorValue object
|
|
37
|
+
* @param theme - Theme for resolving theme colors
|
|
38
|
+
* @returns True if color resolves to black or very dark
|
|
58
39
|
*/
|
|
59
|
-
declare function
|
|
40
|
+
declare function isBlack(color: ColorValue | undefined | null, theme: Theme | null | undefined): boolean;
|
|
60
41
|
/**
|
|
61
|
-
* Check if
|
|
42
|
+
* Check if a color is effectively white
|
|
43
|
+
*
|
|
44
|
+
* @param color - ColorValue object
|
|
45
|
+
* @param theme - Theme for resolving theme colors
|
|
46
|
+
* @returns True if color resolves to white or very light
|
|
62
47
|
*/
|
|
63
|
-
declare function
|
|
48
|
+
declare function isWhite(color: ColorValue | undefined | null, theme: Theme | null | undefined): boolean;
|
|
64
49
|
/**
|
|
65
|
-
*
|
|
50
|
+
* Parse a color string (various formats) to ColorValue
|
|
51
|
+
*
|
|
52
|
+
* @param colorString - Color string like "FF0000", "auto", or theme color name
|
|
53
|
+
* @returns ColorValue object
|
|
66
54
|
*/
|
|
67
|
-
declare function
|
|
55
|
+
declare function parseColorString(colorString: string | undefined): ColorValue | undefined;
|
|
68
56
|
/**
|
|
69
|
-
*
|
|
57
|
+
* Create a ColorValue from theme color reference
|
|
58
|
+
*
|
|
59
|
+
* @param themeColor - Theme color slot name
|
|
60
|
+
* @param tint - Optional tint modifier
|
|
61
|
+
* @param shade - Optional shade modifier
|
|
62
|
+
* @returns ColorValue object
|
|
70
63
|
*/
|
|
71
|
-
declare function
|
|
64
|
+
declare function createThemeColor(themeColor: ThemeColorSlot, tint?: number, shade?: number): ColorValue;
|
|
72
65
|
/**
|
|
73
|
-
*
|
|
66
|
+
* Create a ColorValue from RGB hex
|
|
67
|
+
*
|
|
68
|
+
* @param hex - 6-character hex color (no #)
|
|
69
|
+
* @returns ColorValue object
|
|
74
70
|
*/
|
|
75
|
-
declare function
|
|
71
|
+
declare function createRgbColor(hex: string): ColorValue;
|
|
76
72
|
/**
|
|
77
|
-
*
|
|
73
|
+
* Ensure a hex color string has a '#' prefix.
|
|
78
74
|
*/
|
|
79
|
-
declare function
|
|
75
|
+
declare function ensureHexPrefix(hex: string): string;
|
|
80
76
|
/**
|
|
81
|
-
*
|
|
77
|
+
* Resolve a highlight color value to a CSS-ready string.
|
|
78
|
+
* Tries OOXML named highlight first, then ensures hex prefix.
|
|
82
79
|
*/
|
|
83
|
-
declare function
|
|
80
|
+
declare function resolveHighlightToCss(value: string): string;
|
|
84
81
|
/**
|
|
85
|
-
*
|
|
82
|
+
* Check if two colors are equal
|
|
83
|
+
*
|
|
84
|
+
* @param color1 - First color
|
|
85
|
+
* @param color2 - Second color
|
|
86
|
+
* @param theme - Theme for resolving
|
|
87
|
+
* @returns True if colors resolve to the same value
|
|
86
88
|
*/
|
|
87
|
-
declare function
|
|
89
|
+
declare function colorsEqual(color1: ColorValue | undefined | null, color2: ColorValue | undefined | null, theme: Theme | null | undefined): boolean;
|
|
88
90
|
|
|
89
91
|
/**
|
|
90
92
|
* Google Fonts Loader
|
|
@@ -324,4 +326,4 @@ declare function extractFontsFromDocument(document: unknown): Set<string>;
|
|
|
324
326
|
*/
|
|
325
327
|
declare function loadDocumentFonts(document: unknown): Promise<void>;
|
|
326
328
|
|
|
327
|
-
export {
|
|
329
|
+
export { loadFontFromUrl as A, loadFontWithMapping as B, loadFontsWithMapping as C, onFontError as D, FONT_MAPPING as F, colorsEqual as a, createRgbColor as b, canRenderFont as c, createThemeColor as d, ensureHexPrefix as e, isFontLoaded as f, getLoadedFonts as g, isLoading as h, isBlack as i, isGoogleFontsEnabled as j, isWhite as k, loadFont as l, loadFontFromBuffer as m, loadFonts as n, onFontsLoaded as o, parseColorString as p, preloadCommonFonts as q, resolveHighlightColor as r, resolveHighlightToCss as s, resolveShadingColor as t, setGoogleFontsEnabled as u, type FontDefinition as v, extractFontsFromDocument as w, getGoogleFontEquivalent as x, loadDocumentFonts as y, loadFontDefinitions as z };
|
|
@@ -820,4 +820,4 @@ interface TableCellFormatting {
|
|
|
820
820
|
conditionalFormat?: ConditionalFormatStyle;
|
|
821
821
|
}
|
|
822
822
|
|
|
823
|
-
export {
|
|
823
|
+
export { generateThemeTintShadeMatrix as A, type BorderSpec as B, type ColorValue as C, getContrastingColor as D, type EmphasisMark as E, type FloatingTableProperties as F, getThemeTintShadeHex as G, lightenColor as H, resolveColor as I, resolveColorToHex as J, type LineSpacingRule as L, type ParagraphFormatting as P, type RunFontHint as R, type ShadingProperties as S, type TextModernEffects as T, type UnderlineStyle as U, type TextFormatting as a, type TableFormatting as b, type TableRowFormatting as c, type TableCellFormatting as d, type Theme as e, type ThemeColorSlot as f, type CellMargins as g, type ConditionalFormatStyle as h, type ParagraphAlignment as i, type RunLanguage as j, type TabLeader as k, type TabStop as l, type TabStopAlignment as m, type TableBorders as n, type TableLook as o, type TableMeasurement as p, type TableStyleCascade as q, type TableStyleRegion as r, type TableWidthType as s, type TextEffect as t, type ThemeColorScheme as u, type ThemeFont as v, type ThemeFontScheme as w, type ThemeMatrixCell as x, blendColors as y, darkenColor as z };
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|