@docx-editor.dev/pro 2.32.0 → 2.33.0

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.
Files changed (78) hide show
  1. package/README.md +17 -3
  2. package/dist/{chunk-3WTOHPAB.js → chunk-25A5N6OL.js} +1 -1
  3. package/dist/chunk-3HW2VWFW.js +1 -0
  4. package/dist/chunk-3MIZFGHH.cjs +1 -0
  5. package/dist/chunk-46N5DWZV.cjs +1 -0
  6. package/dist/chunk-65JEI6FY.cjs +5 -0
  7. package/dist/chunk-ENMURXLJ.js +1 -0
  8. package/dist/chunk-EOZ44UA7.js +1 -0
  9. package/dist/chunk-GLYQ72LS.cjs +6 -0
  10. package/dist/{chunk-RYF4SNKX.cjs → chunk-GOUTDQFX.cjs} +1 -1
  11. package/dist/chunk-HMU7J34H.js +1 -0
  12. package/dist/chunk-IULA3QRZ.cjs +1 -0
  13. package/dist/chunk-QEULTKCT.cjs +1 -0
  14. package/dist/{chunk-OT5R3IYV.cjs → chunk-QOXYHVBM.cjs} +1 -1
  15. package/dist/chunk-SINNHH3H.js +1 -0
  16. package/dist/chunk-SL6K2CUL.js +6 -0
  17. package/dist/chunk-STTJA26X.js +1 -0
  18. package/dist/chunk-VY7374QP.cjs +1 -0
  19. package/dist/chunk-WGBOER6G.js +1 -0
  20. package/dist/{chunk-MHB6ID2P.cjs → chunk-WX43PF3Z.cjs} +1 -1
  21. package/dist/chunk-WYVEFRAM.js +5 -0
  22. package/dist/collaboration/hocuspocus.cjs +1 -1
  23. package/dist/collaboration/hocuspocus.js +1 -1
  24. package/dist/collaboration/index.cjs +2 -2
  25. package/dist/collaboration/index.d.cts +2 -1
  26. package/dist/collaboration/index.d.ts +2 -1
  27. package/dist/collaboration/index.js +1 -1
  28. package/dist/collaboration/webrtc.cjs +1 -1
  29. package/dist/collaboration/webrtc.js +1 -1
  30. package/dist/{collaboration-module-DWn2heE1.d.cts → collaboration-module-02CIP5sN.d.cts} +2 -20
  31. package/dist/{collaboration-module-DWn2heE1.d.ts → collaboration-module-COZAgqwg.d.ts} +2 -20
  32. package/dist/{define-custom-node-D0c36PpZ.d.ts → define-custom-node-CISpZvVB.d.cts} +8 -3
  33. package/dist/{define-custom-node-CNRQG1TI.d.cts → define-custom-node-DE1KjR1r.d.ts} +8 -3
  34. package/dist/document-session-4NUOLWKQ.cjs +1 -0
  35. package/dist/document-session-5VAD24RH.js +1 -0
  36. package/dist/drawing/index.cjs +1 -0
  37. package/dist/drawing/index.d.cts +112 -0
  38. package/dist/drawing/index.d.ts +112 -0
  39. package/dist/drawing/index.js +1 -0
  40. package/dist/index.cjs +1 -1
  41. package/dist/index.d.cts +4 -3
  42. package/dist/index.d.ts +4 -3
  43. package/dist/index.js +1 -1
  44. package/dist/license-D-ds5Y7c.d.cts +20 -0
  45. package/dist/license-D-ds5Y7c.d.ts +20 -0
  46. package/dist/metafile-raster-3MCAHWYO.js +1 -0
  47. package/dist/metafile-raster-DWGCWQTU.cjs +1 -0
  48. package/dist/metafile-replay-GHPEUR2W.js +1 -0
  49. package/dist/metafile-replay-NZWGGGZR.cjs +1 -0
  50. package/dist/react/hocuspocus.cjs +1 -1
  51. package/dist/react/hocuspocus.js +1 -1
  52. package/dist/react/index.cjs +2 -2
  53. package/dist/react/index.d.cts +81 -22
  54. package/dist/react/index.d.ts +81 -22
  55. package/dist/react/index.js +2 -2
  56. package/dist/react/webrtc.cjs +1 -1
  57. package/dist/react/webrtc.js +1 -1
  58. package/dist/vue/hocuspocus.cjs +1 -1
  59. package/dist/vue/hocuspocus.js +1 -1
  60. package/dist/vue/index.cjs +2 -2
  61. package/dist/vue/index.d.cts +61 -18
  62. package/dist/vue/index.d.ts +61 -18
  63. package/dist/vue/index.js +2 -2
  64. package/dist/vue/webrtc.cjs +1 -1
  65. package/dist/vue/webrtc.js +1 -1
  66. package/package.json +11 -5
  67. package/dist/chunk-AVZO5ZHZ.js +0 -1
  68. package/dist/chunk-DLYVBBO7.js +0 -1
  69. package/dist/chunk-GAGYRL3L.js +0 -5
  70. package/dist/chunk-HMSOWKXT.js +0 -1
  71. package/dist/chunk-I6HVINA4.cjs +0 -1
  72. package/dist/chunk-MWO2ZUEJ.js +0 -1
  73. package/dist/chunk-PMS3PGOE.cjs +0 -1
  74. package/dist/chunk-Q2VBO66F.js +0 -1
  75. package/dist/chunk-QLZH2Q2C.cjs +0 -1
  76. package/dist/chunk-YOWEY5F3.cjs +0 -5
  77. package/dist/document-session-B35ZX2W4.js +0 -1
  78. package/dist/document-session-V3O7XBJY.cjs +0 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@docx-editor.dev/pro",
3
- "version": "2.32.0",
4
- "description": "Commercial capabilities for @docx-editor.dev: the review module (comments, tracked changes, markup rendering), custom inline nodes, and realtime collaboration.",
3
+ "version": "2.33.0",
4
+ "description": "Commercial capabilities for @docx-editor.dev: the review module (comments, tracked changes, markup rendering), custom inline nodes, realtime collaboration, and advanced drawing rendering.",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "exports": {
@@ -55,6 +55,11 @@
55
55
  "import": "./dist/collaboration/hocuspocus.js",
56
56
  "require": "./dist/collaboration/hocuspocus.cjs"
57
57
  },
58
+ "./drawing": {
59
+ "types": "./dist/drawing/index.d.ts",
60
+ "import": "./dist/drawing/index.js",
61
+ "require": "./dist/drawing/index.cjs"
62
+ },
58
63
  "./package.json": "./package.json"
59
64
  },
60
65
  "files": [
@@ -71,9 +76,9 @@
71
76
  "license:add": "license-check-and-add add -f license-check.json"
72
77
  },
73
78
  "peerDependencies": {
74
- "@docx-editor.dev/core": "~2.32.0",
75
- "@docx-editor.dev/react": "~2.32.0",
76
- "@docx-editor.dev/vue": "~2.32.0",
79
+ "@docx-editor.dev/core": "~2.33.0",
80
+ "@docx-editor.dev/react": "~2.33.0",
81
+ "@docx-editor.dev/vue": "~2.33.0",
77
82
  "react": "^18.0.0 || ^19.0.0",
78
83
  "react-dom": "^18.0.0 || ^19.0.0",
79
84
  "vue": "^3.3.0",
@@ -108,6 +113,7 @@
108
113
  }
109
114
  },
110
115
  "dependencies": {
116
+ "emf-converter": "2.0.2",
111
117
  "y-protocols": "^1.0.7"
112
118
  },
113
119
  "devDependencies": {
@@ -1 +0,0 @@
1
- import {a}from'./chunk-Q2VBO66F.js';import {contentControlsIn,contentControlPropertiesOf,contentControlTextOf,findNode,revisionItemsOf,collectReviewItems,paragraphOrderOfPart,locateSites,parseNoteScopeId,customNodePayloadsOf,customNodePayloadsByControl,segmentsOf}from'@docx-editor.dev/core/store';import {resolveReviewPane,REVISION_MARKUP_COLORS,observeContentControlPopup}from'@docx-editor.dev/core/editor';import {createT,en}from'@docx-editor.dev/i18n';import {reviewItemPositionRank}from'@docx-editor.dev/core/layout';var Ue=64,le=new Set(["__proto__","constructor","prototype"]);function E(e,t,n){let o=new URLSearchParams;for(let[s,d]of Object.entries(n))o.set(s,d);let r=o.toString(),a=r.length>0?`${e}:${t}?${r}`:`${e}:${t}`;return a.length>64?{ok:false,reason:"tag-overflow",length:a.length}:{ok:true,tag:a}}function P(e){if(e.length>64)return null;let t=e.indexOf(":");if(t<=0)return null;let n=e.slice(0,t),o=e.slice(t+1),r=o.indexOf("?"),a=r===-1?o:o.slice(0,r);if(a.length===0)return null;let s=Object.create(null);if(r!==-1)for(let[d,i]of new URLSearchParams(o.slice(r+1))){if(le.has(d))return null;s[d]=i;}return {prefix:n,name:a,attrs:s}}var Ke=262144;function A(e,t){if(t.length===0)return {ok:false,reason:"malformed",issues:["the node carries no payload"]};if(t.length>262144)return {ok:false,reason:"malformed",issues:[`the payload is ${String(t.length)} characters; the cap is ${String(262144)}`]};let n;try{n=JSON.parse(t);}catch(a){return {ok:false,reason:"malformed",issues:[a instanceof Error?a.message:"the payload is not JSON"]}}let o=H(n);if(!e)return {ok:true,value:o};let r=e["~standard"].validate(o);return ce(r)?{ok:false,reason:"async",issues:["the schema validates asynchronously, which the read path cannot await"]}:r.issues?{ok:false,reason:"invalid",issues:r.issues.map(ue)}:{ok:true,value:r.value}}function F(e){let t;try{t=JSON.stringify(e)??"";}catch(n){return {ok:false,reason:"malformed",issues:[n instanceof Error?n.message:"the value cannot be serialized"]}}return t.length===0?{ok:false,reason:"malformed",issues:["the value serializes to nothing"]}:t.length>262144?{ok:false,reason:"malformed",issues:[`the payload is ${String(t.length)} characters; the cap is ${String(262144)}`]}:{ok:true,value:t}}function ce(e){return typeof e.then=="function"}function ue(e){let t=(e.path??[]).map(n=>String(typeof n=="object"?n.key:n)).join(".");return t.length>0?`${t}: ${e.message}`:e.message}var me=new Set(["__proto__","constructor","prototype"]);function H(e){if(Array.isArray(e))return e.map(H);if(e===null||typeof e!="object")return e;let t=Object.create(null);for(let[n,o]of Object.entries(e))me.has(n)||(t[n]=H(o));return t}function B(e){let t=(e.path??[]).map(n=>{let o=typeof n=="object"?n.key:n;return typeof o=="number"?o:String(o)});return {message:e.message,path:t,pointer:t.join(".")}}function D(e,t){return {ok:false,code:"invalidArgs",reason:e,issues:t}}var G="docxEditor";function T(e){return e.payloadNamespace??`urn:docx-editor.dev:custom-node:${e.tagPrefix}`}function J(e,t,n){let o=0;for(let r of customNodePayloadsOf(e,t,n).keys()){let a=/^cx(\d{1,9})$/.exec(r);if(!a)continue;let s=Number(a[1]);s>o&&(o=s);}return `cx${String(o+1)}`}function X(e,t){let n=F(t);if(!n.ok)return {ok:false,reason:`the payload cannot be serialized: ${n.issues.join(", ")}`,issues:[]};if(!e.schema)return {ok:true,data:n.value,value:t};let r=e.schema["~standard"].validate(JSON.parse(n.value));if(pe(r))return {ok:false,reason:`${e.name}'s schema validates asynchronously, which a write cannot await`,issues:[]};if(r.issues){let s=r.issues.map(B);return {ok:false,reason:`the payload does not match ${e.name}'s schema: `+s.map(d=>(d.pointer?`${d.pointer}: `:"")+d.message).join(", "),issues:s}}let a=F(r.value);return a.ok?{ok:true,data:a.value,value:r.value}:{ok:false,reason:`the payload cannot be serialized: ${a.issues.join(", ")}`,issues:[]}}function pe(e){return typeof e.then=="function"}function Y(e){return typeof e=="object"&&e!==null&&typeof e.name=="string"&&typeof e.tagPrefix=="string"}var q=/^[A-Za-z0-9_.-]+$/,ge=/['"<>&]|[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/;function he(e){return e.length>0&&!ge.test(e)}function ot(e){if(!q.test(e.name??""))throw new Error(`defineCustomNode: invalid name ${JSON.stringify(e.name)}`);if(!q.test(e.tagPrefix??""))throw new Error(`defineCustomNode: invalid tagPrefix ${JSON.stringify(e.tagPrefix)}`);let t=e.schema;if(t!==void 0&&typeof t?.["~standard"]?.validate!="function")throw new Error(`defineCustomNode: ${JSON.stringify(e.name)} has a schema that does not implement Standard Schema`);if(e.payloadNamespace!==void 0&&!he(e.payloadNamespace))throw new Error(`defineCustomNode: ${JSON.stringify(e.name)} has a payloadNamespace that cannot be written into an XPath \u2014 no quotes, angle brackets, ampersands or control characters: ${JSON.stringify(e.payloadNamespace)}`);if(e.preserveOnExport!==void 0&&e.preserveOnExport!==true&&e.preserveOnExport!==false&&e.preserveOnExport!=="text")throw new Error(`defineCustomNode: ${JSON.stringify(e.name)} has an unknown preserveOnExport ${JSON.stringify(e.preserveOnExport)}`);return Object.freeze({...e,dataOf:o=>{if(!o||o.data===void 0||o.name!==void 0&&o.name!==e.name)return;if(!e.schema)return o.data;let r=e.schema["~standard"].validate(o.data);if(typeof r.then=="function")return;let a=r;return a.issues?void 0:a.value}})}function rt(e){a(e.licenseKey);let t=new Set;for(let n of e.nodes){let o=`${n.tagPrefix}:${n.name}`;if(t.has(o))throw new Error(`customNodesModule: two definitions claim ${JSON.stringify(o)}`);t.add(o);}return {id:"custom-nodes",customNodes:e.nodes,...e.onDiagnostic?{onCustomNodeDiagnostic:n=>{e.onDiagnostic?.(n);}}:{},customNodePayloadNamespaces:[...new Set(e.nodes.map(T))]}}function ve(e){for(let t of e.children)if(!(t.kind==="textValue"||t.localName!=="sdtPr")){for(let n of t.children)if(!(n.kind==="textValue"||n.localName!=="tag")){for(let o of n.attributes)if(o.localName==="val")return o.value}}}function Z(e){if(e.kind==="textValue")return e.value;let t="";for(let n of e.children)t+=Z(n);return t}function Q(e,t,n={}){if(t.length===0)return [];let o=new Map;for(let s of t){let d=`${s.tagPrefix}:${s.name}`;if(o.has(d))throw new Error(`recognizeCustomNodes: duplicate definition for ${JSON.stringify(d)}`);o.set(d,s);}let r=[],a=(s,d)=>{if(!(s.kind==="textValue"||d>64)){if(s.kind==="contentControl"){let i=ve(s),l=i!==void 0?P(i):null,f=l?o.get(`${l.prefix}:${l.name}`):void 0;if(l&&f&&i!==void 0){let g=Z(s),v=xe(f,s.id,n.payloads?.get(s.id),contentControlPropertiesOf(s).dataBinding!==void 0,n.onDiagnostic),k=f.fromDocx?f.fromDocx({attrs:l.attrs,text:g,...v.present?{data:v.value}:{}}):l.attrs;if(k!==null){r.push({name:f.name,attrs:k,text:g,nodeId:s.id,tag:i,...v.present?{data:v.value}:{}});return}}}for(let i of s.children)a(i,d+1);}};return a(e.root,0),r}function xe(e,t,n,o,r){if(!n)return o&&r?.({code:"payload-missing",name:e.name,nodeId:t,issues:["the control binds a store node this document does not hold"]}),{present:false};let a=A(e.schema,n.data);return a.ok?{present:true,value:a.value}:(r?.({code:"payload-invalid",name:e.name,nodeId:t,issues:a.issues}),{present:false})}function ee(e,t){let n=e.createElement("div");n.className="docx-revision-color-picker";let o=e.createElement("span");o.textContent=t.label,o.id=`${t.id}-label`;let r=e.createElement("button");r.type="button",r.className="docx-revision-color-trigger",r.setAttribute("aria-labelledby",`${o.id} ${t.id}-value`),r.setAttribute("aria-expanded","false"),r.setAttribute("aria-controls",`${t.id}-options`);let a=e.createElement("span");a.className="docx-revision-color-swatch",a.setAttribute("aria-hidden","true");let s=e.createElement("span");s.id=`${t.id}-value`,r.append(a,s);let d=e.createElement("div");d.id=`${t.id}-options`,d.className="docx-revision-color-options",d.hidden=true,d.setAttribute("role","group"),d.setAttribute("aria-labelledby",o.id);let i=new Map,l=c=>c==="auto"?"currentColor":c==="byAuthor"?"var(--doc-review-author-0)":c==="none"?"transparent":`var(--doc-revision-color-${c})`,f,g=()=>{f?.(),f=void 0,e.removeEventListener("pointerdown",v,true),d.hidden=true,r.setAttribute("aria-expanded","false");},v=c=>{n.contains(c.target)||g();};n.addEventListener("focusout",c=>{n.contains(c.relatedTarget)||g();});let k=e.createElement("div");k.className="docx-revision-color-special";let S=e.createElement("div");S.className="docx-toolbar__swatch-grid",d.append(k,S);for(let c of t.colors){let p=e.createElement("button");if(p.type="button",p.dataset.value=c,p.setAttribute("aria-label",t.translate(c)),p.title=t.translate(c),["auto","none","byAuthor"].includes(c)){p.className="docx-toolbar__swatch-clear";let m=e.createElement("span");m.className="docx-revision-color-swatch",m.style.backgroundColor=l(c),m.setAttribute("aria-hidden","true"),p.append(m,e.createTextNode(t.translate(c))),k.append(p);}else p.className="docx-toolbar__swatch",p.dataset.light="",p.style.backgroundColor=l(c),S.append(p);p.addEventListener("mousedown",m=>m.preventDefault()),p.addEventListener("click",()=>{t.change(c),g(),r.focus();}),i.set(c,p);}return r.addEventListener("click",()=>{let c=d.hidden;if(d.hidden=!c,r.setAttribute("aria-expanded",String(c)),!c){g();return}f=observeContentControlPopup(d,r),e.addEventListener("pointerdown",v,true),(Array.from(i.values()).find(p=>p.hasAttribute("data-selected"))??i.values().next().value)?.focus();}),d.addEventListener("keydown",c=>{c.key==="Escape"&&(c.preventDefault(),c.stopPropagation(),g(),r.focus());let p=Array.from(d.querySelectorAll("button")),m=p.indexOf(c.target),u=c.key==="Home"?0:c.key==="End"?p.length-1:["ArrowRight","ArrowDown"].includes(c.key)?(m+1)%p.length:["ArrowLeft","ArrowUp"].includes(c.key)?(m-1+p.length)%p.length:null;u!==null&&(c.preventDefault(),c.stopPropagation(),p[u]?.focus());}),n.append(o,r,d),{element:n,destroy:g,update(c,p){s.textContent=t.translate(c),a.style.backgroundColor=l(c),r.disabled=p;for(let[m,u]of i)u.setAttribute("aria-pressed",String(m===c)),u.toggleAttribute("data-selected",m===c),u.disabled=p;p&&g();}}}var M=["none","colorOnly","bold","italic","underline","doubleUnderline","strikethrough","doubleStrikethrough"],te=[...M,"hidden","caret","pound"],j=0;function ne(e){let t=e.container.ownerDocument,n=null,o=e.get(),r=null,a=new Map,s=new Map,d=createT(en),i=m=>e.translate?.(`revisionMarkup.${m}`)??d(`revisionMarkup.${m}`),l=(m,u)=>{let y=t.createElement(m);return u!==void 0&&(y.textContent=u),y},f=()=>{n?.close(),n?.remove(),n=null,a.clear();for(let m of s.values())m.destroy();s.clear(),r?.isConnected&&r.focus({preventScroll:true}),r=null;},g=()=>{for(let[m,u]of a){let[y,h]=m.split("."),x=o[y];u.tagName==="INPUT"?u.checked=x:u.value=x[h],u.disabled=(y==="movedFrom"||y==="movedTo")&&!o.trackMoves;}for(let[m,u]of s){let[y,h]=m.split("."),x=o[y];u.update(x[h],(y==="movedFrom"||y==="movedTo")&&!o.trackMoves);}},v=m=>{e.set(m);},k=e.subscribe(()=>{o=e.get(),g();}),S=(m,u,y,h,x)=>{if(y==="color"||y==="background"||u==="cells"){let R=i(u==="cells"?`${y}Cells`:`${u}${y==="background"?"Background":"Color"}`),N=ee(t,{id:`docx-revision-color-${j++}`,label:R,colors:h,translate:C=>i(`values.${C}`),change:C=>v({[u]:{[y]:C}})});return s.set(`${u}.${y}`,N),m.append(N.element),N.element}let O=l("label"),b=l("span",i(u));b.className="docx-revision-markup-field-label",O.append(b);let w=l("select");for(let R of h){let N=l("option",i(`values.${R}`));N.value=R,w.append(N);}return w.value=x,w.addEventListener("change",()=>v({[u]:{[y]:w.value}})),O.append(w),m.append(O),a.set(`${u}.${y}`,w),O},c=(m,u,y)=>{let h=l("div");h.className="docx-revision-markup-row";let x=l("span",i(u));if(x.className="docx-revision-markup-row-title",x.setAttribute("aria-hidden","true"),h.append(x),S(h,u,"mark",y,o[u].mark),S(h,u,"color",["byAuthor","auto",...REVISION_MARKUP_COLORS],o[u].color),m.append(h),u!=="changedLines"){let O=l("div");O.className="docx-revision-markup-background",S(O,u,"background",["none","byAuthor",...REVISION_MARKUP_COLORS],o[u].background),m.append(O);}},p=(m,u)=>{let y=l("label"),h=l("input");h.type="checkbox",h.checked=o[u],h.addEventListener("change",()=>v({[u]:h.checked}));let x=l("p",i(`${u}Note`));x.id=`docx-revision-markup-note-${j++}`,h.setAttribute("aria-describedby",x.id),y.append(h,t.createTextNode(i(u))),m.append(y,x),a.set(u,h);};return {open(){if(e.signal.aborted)return;if(n){n.focus();return}o=e.get(),r=t.activeElement,n=l("dialog"),n.className="docx-revision-markup-dialog",n.contentEditable="false",n.setAttribute("data-docx-marker","");for(let N of ["keydown","mousedown","beforeinput"])n.addEventListener(N,C=>C.stopPropagation());let m=l("h2",i("title"));m.id=`docx-revision-markup-title-${j++}`,n.setAttribute("aria-labelledby",m.id),n.append(m),n.addEventListener("cancel",N=>{N.preventDefault(),e.cancel();});let u=l("div");u.className="docx-revision-markup-body",n.append(u);let y=N=>{let C=l("fieldset");return C.className=`docx-revision-markup-${N}`,C.append(l("legend",i(N))),u.append(C),C},h=y("markup");c(h,"insertions",M),c(h,"deletions",te),c(h,"changedLines",["none","leftBorder","rightBorder","outsideBorder"]);let x=y("moves");p(x,"trackMoves"),c(x,"movedFrom",te),c(x,"movedTo",M);let O=y("tableCells");for(let N of ["inserted","deleted","merged","split"])S(O,"cells",N,["byAuthor","none",...REVISION_MARKUP_COLORS],o.cells[N]);let b=y("formatting");p(b,"trackFormatting"),c(b,"formatting",M);let w=l("div");w.className="docx-revision-markup-actions";let R=(N,C)=>{let V=l("button",i(N));V.type="button",V.addEventListener("click",C),w.append(V);};R("reset",()=>e.reset()),R("cancel",()=>e.cancel()),R("ok",()=>{e.apply();}),n.append(w),e.container.append(n),g(),n.showModal(),n.querySelector("select")?.focus({preventScroll:true});},destroy(){k(),f();}}}function re(e,t){let n=findNode(e,t);return !n||n.kind!=="paragraph"?[]:revisionItemsOf({id:e.id,name:e.name,contentType:e.contentType,root:n})}function Ie(e,t,n,o){if(t.length===0)return [];let r=Q(e,t,{...n===void 0?{}:{payloads:n},...o===void 0?{}:{onDiagnostic:o}});if(r.length===0)return [];let a=locateSites(e),s=[];for(let d of r){let i=t.find(g=>g.name===d.name&&d.tag.startsWith(`${g.tagPrefix}:`));if(!i)continue;let l=i.reviewCard?i.reviewCard({attrs:d.attrs,text:d.text,...d.data===void 0?{}:{data:d.data}}):null;if(i.reviewCard&&l===null)continue;let f=a.get(d.nodeId);s.push({kind:"custom",id:d.nodeId,name:d.name,tag:d.tag,attrs:d.attrs,text:d.text,...d.data===void 0?{}:{data:d.data},carded:i.reviewCard!==void 0&&l!==null,title:l?.title??"",...l?.detail!==void 0?{detail:l.detail}:{},...l?.icon!==void 0?{icon:l.icon}:{},range:f?{partName:e.name,start:{paragraphId:f.paragraphId,offset:f.start},end:{paragraphId:f.paragraphId,offset:f.end}}:null});}return s}function ae(e){let t=collectReviewItems(e),n=(e.customNodes??[]).filter(Y);if(n.length===0)return t;let o=[e.storyPart],r=new Set([e.storyPart.name]);for(let i of e.furnitureParts??[])r.has(i.name)||(r.add(i.name),o.push(i));let a=[],s=new Map;for(let i of o){a.push(...Ie(i,n,e.customNodePayloads,e.reportCustomNodeDiagnostic));let l=s.size;for(let[f,g]of paragraphOrderOfPart(i))s.has(f)||s.set(f,l+g);}return a.length===0?t:[...t,...a].sort((i,l)=>reviewItemPositionRank(i,s)-reviewItemPositionRank(l,s))}function Et(e={}){let t=e.pane===void 0?void 0:{...resolveReviewPane(e.pane)};return a(e.licenseKey),{id:"review",review:{createRevisionMarkupDialog:ne,displayModes:["all-markup","simple-markup","proposed","original"],collectReviewItems:ae,revisionItemsOfParagraph:re,...t?{pane:t}:{}}}}function de(e){return e.surface??null}function U(e,t){if(t==null)return null;let n=X(e,t);return n.ok?{ok:true,serialized:n.data,value:n.value}:{ok:false,reason:n.reason,issues:n.issues}}function W(e,t,n,o,r){let a=T(t),s=e.session.part().name;return {namespaceUri:a,rootLocalName:G,nodeId:r??J(e.session.currentPackage(),s,a),label:o,data:n}}function $(e){let t=e.detail?`${e.reason}: ${e.detail}`:e.reason;return {ok:false,code:Ae.has(e.reason)?"invalidArgs":"unsupported",reason:t}}var Ae=new Set(["payload-too-large","unaddressable-payload","store-not-authored","offset-out-of-range","invalid-range","invalid-property-value","splits-surrogate-pair"]);function K(e,t,n){let o,r;if(n!==void 0)try{o=e.text?.(n),r=e.tagAttrs?.(n);}catch(s){return {reason:`${e.name} could not describe this payload: ${s instanceof Error?s.message:String(s)}`}}let a=t.text??o;return a===void 0?{reason:e.text?`${e.name} derives its text from \`data\`, so pass one \u2014 or pass \`text\` directly`:`${e.name} declares no \`text\`, so \`text\` is required`}:t.attrs===void 0&&e.tagAttrs&&r===void 0?{reason:`${e.name} derives its tag attrs from \`data\`, so pass one \u2014 or pass \`attrs\` directly`}:{attrs:t.attrs??r??{},text:a}}function L(e){return e.getEditingMode()==="viewing"?{ok:false,code:"locked",reason:"the document is open for viewing"}:null}function se(e){let t=e.getActiveScope();if(t.kind==="headerFooter")return {kind:"headerFooter",rId:t.rId};if(t.kind==="note"){let n=parseNoteScopeId(t.id);if(n)return {kind:"notesPart",noteKind:n.noteKind}}return {kind:"body"}}function _(e,t){let n=de(e),o=t===void 0?"":t.slice(0,t.indexOf("#"));if(!n||o.length===0)return se(e);if(o===n.session.part().name)return {kind:"body"};for(let r of n.session.headerFooterResolutionBySection())for(let a of [r.headers,r.footers])for(let s of a.values())if(s.partName===o)return {kind:"headerFooter",rId:s.rId};for(let r of ["footnote","endnote"])if(n.session.partFor({kind:"notesPart",noteKind:r})?.name===o)return {kind:"notesPart",noteKind:r};return se(e)}function De(e){let t=e.author()?.trim();return e.editingMode()!=="suggest"||!t?null:{author:t,date:`${new Date().toISOString().slice(0,19)}Z`}}function $t(e,t,n={}){let o=de(e);if(!o)return {ok:false,code:"notFound",reason:"no document is mounted"};let r=U(t,n.data);if(r&&!r.ok)return D(r.reason,r.issues);let a=K(t,n,r?.value);if("reason"in a)return {ok:false,code:"invalidArgs",reason:a.reason};let s=E(t.tagPrefix,t.name,a.attrs);if(!s.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${s.length} characters; Word caps w:tag at 64 \u2014 move what does not fit into the payload (\`data\`), or shorten the attrs`};let d=L(e);if(d)return d;o.flushPendingInput();let i=n.at??o.state().selection.head,l=n.lock===void 0?"contentLocked":n.lock,f=_(e,i.paragraphId),g=De(o),v=o.session.insertCustomNode({paragraphId:i.paragraphId,offset:i.offset,tag:s.tag,text:a.text,...n.alias===void 0?{}:{alias:n.alias},...l===false?{}:{lock:l},...r?{payload:W(o,t,r.serialized,a.text)}:{},...g?{revision:g}:{}},f);return v.ok?{ok:true,changed:true,...v.nodeId===void 0?{}:{nodeId:v.nodeId}}:$(v)}function ie(e){return e.surface??null}function Ve(e,t){let n=null,o=a=>a.id===t?true:a.kind==="textValue"?false:a.children.some(o),r=(a,s)=>{if(!(n||a.kind==="textValue"||s>64)){if(a.kind==="paragraph"){o(a)&&(n=a);return}for(let d of a.children)r(d,s+1);}};return r(e.root,0),n}function He(e,t){let n=new Set,o=i=>{if(n.add(i.id),i.kind!=="textValue")for(let l of i.children)o(l);},r=i=>{if(i.id===t)return i;if(i.kind==="textValue")return null;for(let l of i.children){let f=r(l);if(f)return f}return null},a=r(e);if(!a)return null;o(a);let s=Number.MAX_SAFE_INTEGER,d=-1;for(let i of segmentsOf(e))n.has(i.runId)&&(i.start<s&&(s=i.start),i.end>d&&(d=i.end));return d<0?null:{start:s,end:d}}function Ut(e,t){let n=ie(e);if(!n)return {ok:false,code:"notFound",reason:"no document is mounted"};let o=L(e);if(o)return o;n.flushPendingInput();let r=n.session.removeCustomNode(t,_(e,t));return r.ok?{ok:true,changed:true}:$(r)}function Wt(e,t,n,o={}){let r=ie(e);if(!r)return {ok:false,code:"notFound",reason:"no document is mounted"};let a=L(e);if(a)return a;r.flushPendingInput();let s=_(e,n),d=r.session.partFor(s)??r.session.part(),i=Ve(d,n),l=i?He(i,n):null,f=Fe(r,n,s);if(!i||!l||!f)return {ok:false,code:"notFound",reason:"no custom node with that id"};let g=`${t.tagPrefix}:${t.name}`;if(f.identity!==null&&f.identity!==g)return {ok:false,code:"invalidArgs",reason:`node ${n} is a ${f.identity}, not a ${g}`};let v=je(r,n,s),k=o.data===null?null:o.data===void 0?ze(v):U(t,o.data);if(k&&!k.ok)return D(k.reason,k.issues);let S=K(t,{attrs:o.attrs??(o.data===void 0?f.attrs:void 0),text:o.text??(k===null&&o.data===null?f.text:void 0)},k?.value);if("reason"in S)return {ok:false,code:"invalidArgs",reason:S.reason};let c=E(t.tagPrefix,t.name,S.attrs);if(!c.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${c.length} characters; Word caps w:tag at 64 \u2014 move what does not fit into the payload (\`data\`), or shorten the attrs`};let p=o.alias??f.alias,m=o.lock??f.lock,u=r.session.insertCustomNode({replaceControlId:n,paragraphId:i.id,offset:l.start,tag:c.tag,text:S.text,...p===void 0?{}:{alias:p},...m===false||m===void 0?{}:{lock:m},...k?{payload:W(r,t,k.serialized,S.text,v?.nodeId)}:{}},s);return u.ok?{ok:true,changed:true,...u.nodeId===void 0?{}:{nodeId:u.nodeId}}:$(u)}function Fe(e,t,n){let o=e.session.partFor(n)??e.session.part(),r=contentControlsIn(o.root).find(i=>i.node.id===t);if(!r)return null;let a=contentControlPropertiesOf(r.node),s=a.tag===void 0?null:P(a.tag),d=a.lock;return {identity:s?`${s.prefix}:${s.name}`:null,attrs:s?.attrs??{},text:contentControlTextOf(r.node),alias:a.alias,lock:d==="sdtLocked"||d==="sdtContentLocked"||d==="contentLocked"?d:d==="unlocked"?false:void 0}}function ze(e){if(!e)return null;let t=A(void 0,e.data);return t.ok?{ok:true,serialized:e.data,value:t.value}:{ok:false,reason:`the stored payload is not readable: ${t.issues.join(", ")}`,issues:[]}}function je(e,t,n){let o=e.session.partFor(n)??e.session.part();return customNodePayloadsByControl(e.session.currentPackage(),o.name,e.session.part().name).get(t)}export{Ue as a,E as b,P as c,Ke as d,A as e,F as f,G as g,T as h,X as i,Y as j,q as k,ot as l,rt as m,Q as n,Et as o,$t as p,Ut as q,Wt as r};
@@ -1 +0,0 @@
1
- import {b as b$1}from'./chunk-Q2VBO66F.js';import {shallowRef,watch,getCurrentInstance,onMounted,getCurrentScope,onScopeDispose}from'vue';import {isCollaborationFailureCode}from'@docx-editor.dev/core/collaboration';var b=new Map;function g(o=queueMicrotask,n=()=>{},l=()=>{}){let r=null,d=0,m=()=>{d+=1;};return {autoKey:null,current:()=>r,adopt(a){m(),r&&r!==a&&r.destroy(),r=a;},leave(){m();let a=r;r=null,a?.destroy();},reclaimOwner(){m(),l();},disposeOwner(){let a=++d,u=r;o(()=>{a===d&&(u?.destroy(),r===u&&(r=null),n());});}}}function E(o){let n=b.get(o);if(n)return n;let l=g(queueMicrotask,()=>{b.get(o)===l&&b.delete(o);},()=>{b.has(o)||b.set(o,l);});return l}var B=Object.freeze([]);function W(o,n){for(let l of n)if(l.collaboration)throw new Error(`${o}: host \`modules\` already include a collaboration contribution. This hook supplies \`collaborationModule({ session })\`. Pass review and custom-node modules only.`)}function j(o){if(typeof o=="object"&&o!==null&&"code"in o){let n=o.code;if(typeof n=="string"&&isCollaborationFailureCode(n)){let l=o.detail;return typeof l=="string"&&l.length>0?{code:n,detail:l}:{code:n}}}return o instanceof Error&&o.message.length>0?{code:"transport",detail:o.message}:{code:"transport"}}function I(o,n){if(!(n instanceof Uint8Array))throw new TypeError(`${o}: leave requires the current document bytes \u2014 pass \`await editor.save()\` so the edits made in the room survive locally.`)}var $=0;function Y(o){let n=E(`${o.ownerKey}#${$+=1}`),l=n.current(),r=(e,t)=>(W(o.hookName,e),t?Object.freeze([...e,b$1({session:t})]):e),d=shallowRef(null);d.value=l;let m=shallowRef(l?.document??null),a=shallowRef(l?.session??null),u=shallowRef(o.autoRoomOf()!==null&&l===null),c=shallowRef(null),p=shallowRef(r(o.hostModulesOf(),l?.session??null)),y=0,T=null,h=o.createRoomOf(),w=e=>{d.value=e,m.value=e?.document??null,a.value=e?.session??null,p.value=r(o.hostModulesOf(),e?.session??null);},C=async e=>{let t=++y;T=e,u.value=true,c.value=null;try{let i=await h(e);return t!==y?(i.destroy(),null):(n.adopt(i),w(i),null)}catch(i){let s=j(i);return t!==y||(c.value=s),s}finally{t===y&&(u.value=false);}},F=e=>(n.autoKey=null,C(e)),M=e=>{I(o.hookName,e),y+=1,n.leave(),d.value=null,a.value=null,m.value=e,u.value=false,c.value=null,p.value=r(o.hostModulesOf(),null);},H=e=>{n.autoKey=null,M(e);},K=async e=>{let t=T;if(t===null)throw new Error(`${o.hookName}: rejoin needs a room this composable connected before. Call connect first.`);return M(e),C(o.rejoinOptionsOf(t))};watch(()=>o.createRoomOf(),e=>{h=e;},{immediate:true}),watch(()=>o.hostModulesOf(),e=>{p.value=r(e,a.value);}),watch(a,(e,t,i)=>{if(!e)return;let s=null,S=()=>{let O=e.statusSnapshot();if(O.status!=="error"){s&&c.value===s&&(c.value=null),s=null;return}s=O.reason??O.lastFailure??{code:"transport"},c.value=s;};S(),i(e.subscribeStatus(()=>S()));},{immediate:true}),watch(()=>{let e=o.autoRoomOf();if(!e)return "";let t=o.identityOf(e);return `${t.name}\0${t.color??""}`},()=>{let e=o.autoRoomOf(),t=a.value;if(!e||!t)return;let i=o.identityOf(e);t.setIdentity?.({name:i.name,...i.color!==void 0?{color:i.color}:{}});});let R=e=>{let t=o.autoRoomOf();if(n.autoKey!==null&&n.autoKey!==e&&(y+=1,n.autoKey=null,n.current()&&n.leave(),w(null),u.value=false,c.value=null),!(!e||!t)){if(n.current()){w(n.current());return}u.value=true,n.autoKey=e,C(t).catch(()=>{});}};return watch(()=>o.autoKeyOf(),R),getCurrentInstance()?onMounted(()=>{n.reclaimOwner();let e=n.current();e&&w(e),R(o.autoKeyOf());}):typeof globalThis.window<"u"&&R(o.autoKeyOf()),getCurrentScope()&&onScopeDispose(()=>{y+=1,n.disposeOwner();}),{room:d,document:m,modules:p,session:a,pending:u,error:c,connect:F,leave:H,rejoin:K}}export{B as a,Y as b};