@docx-editor.dev/pro 2.32.0 → 2.34.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.
- package/README.md +17 -3
- package/dist/chunk-3HW2VWFW.js +1 -0
- package/dist/chunk-3MIZFGHH.cjs +1 -0
- package/dist/chunk-4TS2D6OV.js +11 -0
- package/dist/chunk-5HK5RAD7.cjs +11 -0
- package/dist/chunk-ENMURXLJ.js +1 -0
- package/dist/chunk-EOZ44UA7.js +1 -0
- package/dist/{chunk-RYF4SNKX.cjs → chunk-GOUTDQFX.cjs} +1 -1
- package/dist/chunk-GSBQ5AHL.cjs +1 -0
- package/dist/chunk-HMU7J34H.js +1 -0
- package/dist/chunk-IFDU5O5J.js +1 -0
- package/dist/chunk-IULA3QRZ.cjs +1 -0
- package/dist/chunk-L6ZMFFBX.cjs +1 -0
- package/dist/chunk-NTBGYQX4.js +1 -0
- package/dist/chunk-QEULTKCT.cjs +1 -0
- package/dist/{chunk-OT5R3IYV.cjs → chunk-QOXYHVBM.cjs} +1 -1
- package/dist/chunk-STTJA26X.js +1 -0
- package/dist/chunk-UPKBD6AH.cjs +1 -0
- package/dist/chunk-VQOLBCW6.js +1 -0
- package/dist/chunk-ZMBZ7CWZ.js +6 -0
- package/dist/chunk-ZZ33FL6V.cjs +6 -0
- package/dist/collaboration/hocuspocus.cjs +1 -1
- package/dist/collaboration/hocuspocus.d.cts +1 -1
- package/dist/collaboration/hocuspocus.d.ts +1 -1
- package/dist/collaboration/hocuspocus.js +1 -1
- package/dist/collaboration/index.cjs +2 -2
- package/dist/collaboration/index.d.cts +3 -2
- package/dist/collaboration/index.d.ts +3 -2
- package/dist/collaboration/index.js +2 -2
- package/dist/collaboration/webrtc.cjs +1 -1
- package/dist/collaboration/webrtc.d.cts +1 -1
- package/dist/collaboration/webrtc.d.ts +1 -1
- package/dist/collaboration/webrtc.js +1 -1
- package/dist/{collaboration-module-DWn2heE1.d.cts → collaboration-module-02CIP5sN.d.cts} +2 -20
- package/dist/{collaboration-module-DWn2heE1.d.ts → collaboration-module-COZAgqwg.d.ts} +2 -20
- package/dist/{define-custom-node-D0c36PpZ.d.ts → define-custom-node-CISpZvVB.d.cts} +8 -3
- package/dist/{define-custom-node-CNRQG1TI.d.cts → define-custom-node-DE1KjR1r.d.ts} +8 -3
- package/dist/{document-session-B-iH-YCU.d.ts → document-session-B6v5LZIK.d.ts} +94 -9
- package/dist/{document-session-B-MlORjE.d.cts → document-session-DZK2tAr4.d.cts} +94 -9
- package/dist/document-session-RPP3WEJ7.cjs +1 -0
- package/dist/document-session-S2N54WP6.js +1 -0
- package/dist/drawing/index.cjs +1 -0
- package/dist/drawing/index.d.cts +112 -0
- package/dist/drawing/index.d.ts +112 -0
- package/dist/drawing/index.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +1 -1
- package/dist/license-D-ds5Y7c.d.cts +20 -0
- package/dist/license-D-ds5Y7c.d.ts +20 -0
- package/dist/metafile-raster-3MCAHWYO.js +1 -0
- package/dist/metafile-raster-DWGCWQTU.cjs +1 -0
- package/dist/metafile-replay-SDHSTWYT.js +1 -0
- package/dist/metafile-replay-YZ2LHLBT.cjs +1 -0
- package/dist/react/hocuspocus.cjs +1 -1
- package/dist/react/hocuspocus.js +1 -1
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.d.cts +81 -22
- package/dist/react/index.d.ts +81 -22
- package/dist/react/index.js +2 -2
- package/dist/react/webrtc.cjs +1 -1
- package/dist/react/webrtc.js +1 -1
- package/dist/vue/hocuspocus.cjs +1 -1
- package/dist/vue/hocuspocus.js +1 -1
- package/dist/vue/index.cjs +2 -2
- package/dist/vue/index.d.cts +61 -18
- package/dist/vue/index.d.ts +61 -18
- package/dist/vue/index.js +2 -2
- package/dist/vue/webrtc.cjs +1 -1
- package/dist/vue/webrtc.js +1 -1
- package/package.json +11 -5
- package/dist/chunk-3WTOHPAB.js +0 -1
- package/dist/chunk-AVZO5ZHZ.js +0 -1
- package/dist/chunk-DLYVBBO7.js +0 -1
- package/dist/chunk-GAGYRL3L.js +0 -5
- package/dist/chunk-HMSOWKXT.js +0 -1
- package/dist/chunk-I6HVINA4.cjs +0 -1
- package/dist/chunk-MHB6ID2P.cjs +0 -1
- package/dist/chunk-MWO2ZUEJ.js +0 -1
- package/dist/chunk-PMS3PGOE.cjs +0 -1
- package/dist/chunk-Q2VBO66F.js +0 -1
- package/dist/chunk-QLZH2Q2C.cjs +0 -1
- package/dist/chunk-YOWEY5F3.cjs +0 -5
- package/dist/document-session-B35ZX2W4.js +0 -1
- 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.
|
|
4
|
-
"description": "Commercial capabilities for @docx-editor.dev: the review module (comments, tracked changes, markup rendering), custom inline nodes, and
|
|
3
|
+
"version": "2.34.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.
|
|
75
|
-
"@docx-editor.dev/react": "~2.
|
|
76
|
-
"@docx-editor.dev/vue": "~2.
|
|
79
|
+
"@docx-editor.dev/core": "~2.34.0",
|
|
80
|
+
"@docx-editor.dev/react": "~2.34.0",
|
|
81
|
+
"@docx-editor.dev/vue": "~2.34.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": {
|
package/dist/chunk-3WTOHPAB.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {e,b,p,a,f,j as j$1,i as i$1,g,k as k$1,l,m as m$1}from'./chunk-GAGYRL3L.js';import*as i from'yjs';var x="roomGeneration",M="docx-room-generation",G=4409,R=2,c=new Set,_=1024;async function D(n,e){let t=n.buffer instanceof ArrayBuffer?n:n.slice(),o=new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256",t)),r="";for(let a of o)r+=a.toString(16).padStart(2,"0");return `${e}:${r}`}function N(n){if(c.size>=_){let e=c.values().next().value;e!==void 0&&c.delete(e);}c.add(n);}function U(n){let e$1=n.getMap(e).get(x);return typeof e$1=="string"?e$1:""}async function j(n,e$1={}){let t=e$1.minimumGain??R,o=await D(n,t);if(c.has(o))return null;let r=new i.Doc;try{i.applyUpdate(r,n);let s=r.getMap(e).get("documentId");if(typeof s!="string")throw new b("not-initialized");let l=await I(p(r),s);return n.byteLength/Math.max(1,l.byteLength)>=t?l:(N(o),null)}finally{r.destroy();}}async function I(n,e,t){let o=new i.Doc,r=a(o),a$1=new f(o);try{let s=new j$1(o.getMap(i$1)),l$1=await g(a$1,k$1(n,t),s);if(!l$1.ok)throw new b(l$1.code);return o.transact(()=>{a$1.schema.meta.set("documentId",e),a$1.schema.meta.set(x,globalThis.crypto.randomUUID()),l(o);}),m$1(o),i.encodeStateAsUpdate(o)}finally{a$1.destroy(),r(),o.destroy();}}function J(n){let e$1=n.getMap(e).get("initialized")===true;return JSON.stringify({type:M,generation:e$1?U(n):null})}function V(n){return n.code===G||n.reason==="room-generation-changed"}var T=new Set([0,1,3,4,6]),k=5,w=Symbol("docx-room-generation-checked");function W(n){let e=P(n.update);if(!e)throw m();if(e.type===k){let t=Y(e.payload);if(t===void 0)return;if(t!==null&&t!==U(n.document))throw m();n.context[w]=true;return}if(T.has(e.type)&&n.context[w]!==true)throw m()}function m(){return Object.assign(new Error("room-generation-changed"),{code:G,reason:"room-generation-changed"})}function Y(n){if(n===null||n.length>512)return;let e;try{e=JSON.parse(n);}catch{return}if(typeof e!="object"||e===null)return;let t=e;if(t.type===M)return t.generation===null?null:typeof t.generation=="string"&&t.generation.length<=128?t.generation:void 0}function P(n){let e={at:0};if(C(n,e)===null)return null;let o=O(n,e);return o===null?null:{type:o,payload:o===k?C(n,e):null}}function O(n,e){let t=0,o=1;for(let r=0;r<8;r+=1){let a=n[e.at];if(a===void 0)return null;if(e.at+=1,t+=(a&127)*o,a<128)return t;o*=128;}return null}function C(n,e){let t=O(n,e);if(t===null||e.at+t>n.length)return null;let o=new TextDecoder().decode(n.subarray(e.at,e.at+t));return e.at+=t,o}export{U as a,j as b,I as c,J as d,V as e,W as f};
|
package/dist/chunk-AVZO5ZHZ.js
DELETED
|
@@ -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};
|
package/dist/chunk-DLYVBBO7.js
DELETED
|
@@ -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};
|