@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/README.md CHANGED
@@ -17,18 +17,19 @@
17
17
 
18
18
  # @docx-editor.dev/pro
19
19
 
20
- Add review, collaboration, and custom content to the [docx-editor.dev](https://docx-editor.dev) React and Vue editors. The package provides these capabilities:
20
+ Add advanced drawing rendering, review, collaboration, and custom content to the [docx-editor.dev](https://docx-editor.dev) React and Vue editors. The package provides these capabilities:
21
21
 
22
22
  - [Tracked changes](https://www.docx-editor.dev/docs/2.x/pro/tracked-changes): Suggesting mode, markup rendering, accept, and reject.
23
23
  - [Comments](https://www.docx-editor.dev/docs/2.x/pro/comments): Threads anchored to a range, with replies.
24
24
  - [Collaboration](https://www.docx-editor.dev/docs/2.x/pro/collaboration): Provider-neutral sessions with WebRTC and Hocuspocus helpers.
25
25
  - [Custom nodes](https://www.docx-editor.dev/docs/2.x/pro/custom-nodes): Inline node types stored as content controls.
26
+ - [Advanced drawing rendering](https://www.docx-editor.dev/docs/2.x/pro/drawing): Charts, SmartArt layout, shape effects, WordArt, and EMF and WMF pictures.
26
27
 
27
28
  ```bash
28
29
  npm install @docx-editor.dev/react @docx-editor.dev/core @docx-editor.dev/pro
29
30
  ```
30
31
 
31
- The framework-neutral entry is `@docx-editor.dev/pro`. Framework chrome lives at `@docx-editor.dev/pro/react` and `@docx-editor.dev/pro/vue`.
32
+ The framework-neutral entry is `@docx-editor.dev/pro`. Framework chrome lives at `@docx-editor.dev/pro/react` and `@docx-editor.dev/pro/vue`. Drawing rendering is at `@docx-editor.dev/pro/drawing` for both frameworks; `reviewModule()` installs it too.
32
33
 
33
34
  ## Register a module
34
35
 
@@ -154,11 +155,24 @@ The review hooks need `reviewModule()` from `@docx-editor.dev/pro` in the editor
154
155
 
155
156
  This package ships the task recipes in [`docs/index.md`](./docs/index.md). They are also on the site: [Task recipes](https://www.docx-editor.dev/docs/2.x/recipes).
156
157
 
158
+ ## Render charts and advanced drawings
159
+
160
+ Register `drawingModule()` to render charts, SmartArt saved without its drawing, shape effects, WordArt, and EMF and WMF pictures. If you already register `reviewModule()`, you don't need it.
161
+
162
+ ```ts
163
+ import { drawingModule } from '@docx-editor.dev/pro/drawing';
164
+
165
+ // Next.js; with Vite, read import.meta.env.VITE_DOCX_LICENSE.
166
+ const MODULES = [drawingModule({ licenseKey: process.env.NEXT_PUBLIC_DOCX_LICENSE })];
167
+ ```
168
+
169
+ For headless use, call `installDrawing()` from the same entry before you open documents.
170
+
157
171
  ## Licensing
158
172
 
159
173
  This package uses the [EigenPal Pro License](https://github.com/eigenpal/docx-editor/blob/main/packages/pro/LICENSE.md). See [pricing](https://www.docx-editor.dev/pricing) for license and support options.
160
174
 
161
- `reviewModule`, `customNodesModule`, and `collaborationModule` accept an optional `licenseKey`. Construction never validates it and never touches the network.
175
+ `reviewModule`, `customNodesModule`, `collaborationModule`, `drawingModule`, and `installDrawing` accept an optional `licenseKey`. Pass the key once, to any of them. The key is optional and is never validated or sent anywhere: every module works the same with or without it. Production use requires an EigenPal Pro License, and the key identifies yours when you contact support. The key is not a secret, so you can ship it in browser code. Construction never validates it and never touches the network.
162
176
 
163
177
  ## Documentation
164
178
 
@@ -1 +1 @@
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};
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-WYVEFRAM.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};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-EOZ44UA7.js';import {useState,useRef,useCallback,useEffect,useMemo}from'react';import {isCollaborationFailureCode}from'@docx-editor.dev/core/collaboration';var T=new Map;function N(e=queueMicrotask,r=()=>{},o=()=>{}){let t=null,a=0,c=()=>{a+=1;};return {autoKey:null,current:()=>t,adopt(i){c(),t&&t!==i&&t.destroy(),t=i;},leave(){c();let i=t;t=null,i?.destroy();},reclaimOwner(){c(),o();},disposeOwner(){let i=++a,C=t;e(()=>{i===a&&(C?.destroy(),t===C&&(t=null),r());});}}}function I(e){let r=T.get(e);if(r)return r;let o=N(queueMicrotask,()=>{T.get(e)===o&&T.delete(e);},()=>{T.has(e)||T.set(e,o);});return o}var Z=Object.freeze([]);function L(e,r){for(let o of r)if(o.collaboration)throw new Error(`${e}: host \`modules\` already include a collaboration contribution. This hook supplies \`collaborationModule({ session })\`. Pass review and custom-node modules only.`)}function B(e){if(typeof e=="object"&&e!==null&&"code"in e){let r=e.code;if(typeof r=="string"&&isCollaborationFailureCode(r)){let o=e.detail;return typeof o=="string"&&o.length>0?{code:r,detail:o}:{code:r}}}return e instanceof Error&&e.message.length>0?{code:"transport",detail:e.message}:{code:"transport"}}function Y(e,r){if(!(r instanceof Uint8Array))throw new TypeError(`${e}: leave requires the current document bytes \u2014 pass \`await editor.save()\` so the edits made in the room survive locally.`)}var _=0;function oo(e){let[r]=useState(()=>_+=1),[o]=useState(()=>I(`${e.ownerKey}#${r}`)),t=useRef(e);t.current=e,L(e.hookName,e.hostModules);let a$1=useRef(0),c=useRef(null),[i,C]=useState(()=>o.current()),[E,H]=useState(()=>o.current()?.document??null),[k,h]=useState(()=>e.autoRoom!==null&&o.current()===null),[K,d]=useState(null),m=useCallback(n=>{C(n),H(n?.document??null);},[]),y=useCallback(async n=>{let l=++a$1.current;c.current=n,h(true),d(null);try{let s=await t.current.createRoom(n);return l!==a$1.current?(s.destroy(),null):(o.adopt(s),m(s),null)}catch(s){let f=B(s);return l!==a$1.current||d(f),f}finally{l===a$1.current&&h(false);}},[o,m]),U=useCallback(n=>(o.autoKey=null,y(n)),[y]),O=useCallback(n=>{Y(t.current.hookName,n),a$1.current+=1,o.leave(),C(null),H(n),h(false),d(null);},[o]),A=useCallback(n=>{o.autoKey=null,O(n);},[O]),D=useCallback(async n=>{let l=c.current;if(l===null)throw new Error(`${t.current.hookName}: rejoin needs a room this hook connected before. Call connect first.`);return O(n),y(t.current.rejoinOptionsOf(l))},[y,O]);useEffect(()=>{o.reclaimOwner();let n=o.current();return n&&m(n),()=>{a$1.current+=1,o.disposeOwner();}},[o,m]);let u=i?.session??null,x=useRef(null);useEffect(()=>{if(!u)return;let n=()=>{let l=u.statusSnapshot();if(l.status!=="error"){let f=x.current;x.current=null,f&&d(W=>W===f?null:W);return}let s=l.reason??l.lastFailure??{code:"transport"};x.current=s,d(s);};return n(),u.subscribeStatus(()=>n())},[u]);let R=t.current.autoRoom?t.current.identityOf(t.current.autoRoom):null,q=R?`${R.name}\0${R.color??""}`:"",P=useRef(R);P.current=R,useEffect(()=>{let n=P.current;if(!u||!n)return;u.setIdentity?.({name:n.name,...n.color!==void 0?{color:n.color}:{}});},[q,u]);let M=e.autoKey;useEffect(()=>{let n=t.current.autoRoom;if(o.autoKey!==null&&o.autoKey!==M&&(a$1.current+=1,o.autoKey=null,o.current()&&o.leave(),m(null),d(null),h(false)),!n||o.current())return;o.autoKey=M;let s=false;return queueMicrotask(()=>{s||o.current()||y(n).catch(()=>{});}),()=>{s=true;}},[M,y,o,m]);let F=e.hostModules,w=i?.session??null,S=useMemo(()=>w?Object.freeze([...F,a({session:w})]):F,[F,w]);return useMemo(()=>({room:i,document:E,modules:S,session:w,pending:k,error:K,connect:U,leave:A,rejoin:D}),[U,E,K,A,S,k,D,i,w])}export{Z as a,oo as b};
@@ -0,0 +1 @@
1
+ 'use strict';function _(e,r,t){let n=Math.max(1,Math.min(t.dpiScale??1,4)),o=Math.round(e*n),i=Math.round(r*n);t.maxWidth&&o>t.maxWidth&&(i=Math.round(i*(t.maxWidth/o)),o=t.maxWidth),t.maxHeight&&i>t.maxHeight&&(o=Math.round(o*(t.maxHeight/i)),i=t.maxHeight);let f=Math.max(1,Math.floor(t.maxCanvasDimension??1/0));return o=Math.max(1,Math.min(o,f)),i=Math.max(1,Math.min(i,f)),{x:o/e,y:i/r}}function x(e,r,t){let n=new Uint8Array(16),o=new DataView(n.buffer);return o.setUint32(0,e,true),o.setUint32(4,16,true),o.setInt32(8,r,true),o.setInt32(12,t,true),n}function R(e,r){if(e.length<88)return e;let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=t.getUint32(4,true);if(n<88||n>e.length)return e;let o=t.getInt32(8,true),i=t.getInt32(12,true),f=t.getInt32(16,true)-o,E=t.getInt32(20,true)-i;if(!(f>0&&E>0))return e;let d=new Set;for(let a=n;a+8<=e.length;){let s=t.getUint32(a+4,true);if(s<8||a+s>e.length)break;d.add(t.getUint32(a,true)),a+=s;}if(!d.has(9)||!d.has(11))return e;let l=_(f,E,r),u=new Uint8Array(e.length+32);u.set(e.subarray(0,n)),u.set(x(10,0,0),n),u.set(x(12,Math.round(-o*l.x),Math.round(-i*l.y)),n+16),u.set(e.subarray(n),n+32);let c=new DataView(u.buffer);c.setUint32(48,u.length,true),c.setUint32(52,t.getUint32(52,true)+2,true);for(let a=n+32;a+8<=u.length;){let s=c.getUint32(a,true),T=c.getUint32(a+4,true);if(T<8||a+T>u.length)break;if(T>=16&&s===11)c.setInt32(a+8,Math.round(c.getInt32(a+8,true)*l.x),true),c.setInt32(a+12,Math.round(c.getInt32(a+12,true)*l.y),true);else if(T>=16&&s===12){let h=c.getInt32(a+8,true),w=c.getInt32(a+12,true);c.setInt32(a+8,Math.round((h-o)*l.x),true),c.setInt32(a+12,Math.round((w-i)*l.y),true);}a+=T;}return u}var M=new Set([762,764,247,505,322,1791]),A=16,O=new Map([[0,"windows-1252"],[1,"windows-1252"],[128,"shift_jis"],[129,"euc-kr"],[134,"gbk"],[136,"big5"],[161,"windows-1253"],[162,"windows-1254"],[163,"windows-1258"],[177,"windows-1255"],[178,"windows-1256"],[186,"windows-1257"],[204,"windows-1251"],[222,"windows-874"],[238,"windows-1250"]]);function g(e,r,t,n){let o="";for(let i=r;i<r+t&&i<n;i++){let f=e.getUint8(i);if(f===0)break;o+=String.fromCharCode(f);}return o}function I(e,r,t){if(r+19>t)return null;let n=g(e,r+18,32,t).trim(),o=n.length<=31&&/^[\x20-\x21\x23-\x26\x28-\x7e\xa0-\xff]*$/.test(n);return {charset:e.getUint8(r+13),face:o?n:""}}function U(e){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),t=e.length>=22&&r.getUint32(0,true)===2596720087?22:0;if(t+18>e.length||r.getUint16(t+2,true)!==9)return [];t+=18;let n=[],o=d=>{let l=n.indexOf(null);l!==-1?n[l]=d:n.length<4096&&n.push(d);},i=null,f=0,E=[];for(let d=0;d<2e5&&t+6<=e.length;d++){let l=r.getUint32(t,true),u=r.getUint16(t+4,true);if(l<3||t+l*2>e.length||u===0)break;let c=t+6,a=t+l*2;if(u===763)o(I(r,c,a)??"other");else if(M.has(u))o("other");else if(u===496&&c+2<=a){let s=r.getUint16(c,true);s<n.length&&(n[s]=null);}else if(u===302&&c+2<=a)f=r.getUint16(c,true);else if(u===301&&c+2<=a){let s=n[r.getUint16(c,true)];s&&s!=="other"&&(i=s);}else if(u===1313&&c+2<=a){let s=r.getInt16(c,true);s>0&&c+2+s<=a&&E.push({bytes:g(r,c+2,s,a),font:i,align:f});}else if(u===2610&&c+8<=a){let s=r.getInt16(c+4,true),T=(r.getUint16(c+6,true)&4)!==0,h=c+8+(T?8:0);s>0&&h+s<=a&&E.push({bytes:g(r,h,s,a),font:i,align:f});}t=a;}return E}var m=new Map;function b(e,r){let t=O.get(r);if(!t)return e;let n=m.get(t);if(n===void 0){try{n=new TextDecoder(t);}catch{n=null;}m.set(t,n);}if(!n)return e;let o=new Uint8Array(e.length);for(let i=0;i<e.length;i++)o[i]=e.charCodeAt(i);return n.decode(o)}function S(e){let r=0;return t=>{let n=Math.min(e.length,r+A);for(let o=r;o<n;o++){let i=e[o];if(i.bytes!==t)continue;r=o+1;let f=i.align&24,E=i.align&6;return {text:i.font?b(t,i.font.charset):t,face:i.font?.face??"",baseline:f===24?"alphabetic":f===8?"bottom":"top",align:E===6?"center":E===2?"right":"left"}}return null}}exports.a=R;exports.b=U;exports.c=S;
@@ -0,0 +1 @@
1
+ 'use strict';var editor=require('@docx-editor.dev/core/editor'),core=require('@docx-editor.dev/core'),collaboration=require('@docx-editor.dev/core/collaboration');var X=Object.freeze({scale:96/72,top:0,left:null,side:"right",compactCardLeft:null,compact:false}),g=16,N=300,h=12;function C(e){return e?.getAttribute("data-review-side")==="left"?"left":"right"}var _=".docx-paginated-surface:not(.docx-editor__loading-surface)";function y(e){return e?.querySelector(_)??null}function ee(e,t,n){return e&&t>0&&t<n}function P(e,t){let n=e.offsetParent,o=y(n),i=o&&n?o.getBoundingClientRect():null,d=i&&n?n.getBoundingClientRect():null,l=C(n);if(!i||!d||!n)return {scale:t,top:0,left:null,side:l,compactCardLeft:null};let r=n.scrollLeft-d.left-n.clientLeft,p=i.top-d.top-n.clientTop+n.scrollTop;if(l==="left"){let a=i.left+r-g-e.offsetWidth;return {scale:t,top:p,left:a,side:l,compactCardLeft:n.scrollLeft+h-a}}let f=i.right+r+g;return {scale:t,top:p,left:f,side:l,compactCardLeft:n.scrollLeft+n.clientWidth-f-N-h}}function te(e,t){return e.scale===t.scale&&e.top===t.top&&e.left===t.left&&e.side===t.side&&e.compactCardLeft===t.compactCardLeft}function ne(e,t,n,o={}){let i=e.offsetParent,d=editor.hostWindowOf(e),l=null,r=null,p=()=>{o.beforeMeasure?.(i),n(P(e,t.getRenderScale()));},f=()=>{if(l=y(i),r?.disconnect(),r=null,!i||typeof d.ResizeObserver!="function")return;let c=new Set([i]);for(let u of Array.from(i.children))u!==e&&editor.isHTMLElementNode(u)&&c.add(u);C(i)==="left"&&c.add(e);for(let u=l;u&&u!==i;u=u.parentElement)c.add(u);r=new d.ResizeObserver(a);for(let u of c)r.observe(u);};function a(){y(i)!==l&&f(),p();}f(),p();let s=[()=>r?.disconnect()];if(i&&typeof d.MutationObserver=="function"){let c=new d.MutationObserver(u=>{u.some(m=>m.type==="childList"||m.attributeName==="data-review-side")&&f(),p();});c.observe(i,{childList:true,attributes:true,attributeFilter:["style","data-review-side"]}),s.push(()=>c.disconnect());}if(o.trackScroll&&i){let c=0,u=()=>{c===0&&(c=d.requestAnimationFrame(()=>{c=0,a();}));};i.addEventListener("scroll",u,{passive:true}),s.push(()=>{c!==0&&d.cancelAnimationFrame(c),i.removeEventListener("scroll",u);});}return ()=>{for(let c of s)c();}}function oe(e){let t=e.offsetParent;return t?editor.hostWindowOf(e).getComputedStyle(e).position!=="absolute"?"the column element is not absolutely positioned. Give it position: absolute.":y(t)?null:"the column element's offset parent does not contain the editor's pages. Render it directly inside DocxEditor.Viewport, with no positioned element in between.":"the column element has no offset parent. Render it inside DocxEditor.Viewport, and hide it with visibility: hidden rather than display: none while metrics.left is null."}var E=new Set;function re(e){!D()||E.has(e)||(E.add(e),console.warn(`[docx-editor] useReviewRailMetrics: ${e}`));}function D(){let e;try{e=undefined?.DEV;}catch{e=void 0;}return typeof e=="boolean"?e:typeof process<"u"&&false}var S=600,le=Object.freeze({top:Number.POSITIVE_INFINITY,bottom:Number.NEGATIVE_INFINITY});function se(e,t,n){let o=editor.hostWindowOf(t),i=()=>({top:t.scrollTop-S,bottom:t.scrollTop+t.clientHeight+S}),d=null,l=null,r=0,p=()=>{r=0;let c=l??i();l=null,!(d&&d.top===c.top&&d.bottom===c.bottom)&&(d=c,n(c));},f=0,a=()=>{l=i(),r===0&&(r=o.requestAnimationFrame(p)),e.setAttribute("data-scrolling",""),o.clearTimeout(f),f=o.setTimeout(()=>e.removeAttribute("data-scrolling"),150);};p(),t.addEventListener("scroll",a,{passive:true});let s=new o.ResizeObserver(a);return s.observe(t),()=>{r!==0&&o.cancelAnimationFrame(r),o.clearTimeout(f),t.removeEventListener("scroll",a),s.disconnect();}}function de(e,t,n={}){let i=(Array.isArray(t)?t:[t]).flatMap(r=>r.kind==="revision"?[r.key]:[]),{author:d,date:l}=n;return !e||i.length===0||l!==void 0&&(!(l instanceof Date)||Number.isNaN(l.getTime()))?false:e.exec({type:"setReviewChangesAuthor",keys:i,...d===void 0?{}:{author:d},...l===void 0?{}:{date:`${l.toISOString().slice(0,19)}Z`}}).ok}function W(e,t){let n=new Map,o=new Set,{gap:i,scale:d}=t,l=(a,s)=>(t.heightOf(a.key,s)+i)/d,r=(a,s)=>a.anchorY!==null&&Math.abs(s-a.anchorY)*d>t.collapseAfterPx&&!a.isActive&&t.collapsible(a),p=e.findIndex(a=>a.isActive&&a.anchorY!==null),f=Number.NEGATIVE_INFINITY;for(let a=Math.max(p,0);a<e.length;a+=1){let s=e[a],c=s.anchorY===null?Number.isFinite(f)?f:0:Math.max(s.anchorY,f);n.set(s.key,c);let u=r(s,c);u&&o.add(s.key),f=c+l(s,u);}for(let a=p-1;a>=0;a-=1){let s=e[a],c=n.get(e[a+1].key),u=v=>{let b=c-l(s,v);return s.anchorY===null?b:Math.min(s.anchorY,b)},m=r(s,u(true));m&&o.add(s.key),n.set(s.key,u(m));}return {positions:n,collapsed:o}}function fe(e,t,n){return W(e.map(o=>({key:o.key,anchorY:o.anchorY,isActive:"isActive"in o&&o.isActive===true})),{gap:n.gap,scale:n.scale,collapseAfterPx:Number.POSITIVE_INFINITY,heightOf:o=>t.get(o)??n.defaultHeight,collapsible:()=>false}).positions}function q(e){return e.detail!==void 0&&core.reviewCodeOfSkip(e)!==core.reviewCodeOfSkip({reason:e.reason})?e.detail:e.reason}function K(e,t,n,o){if(n.ok)return null;let d=((e==="accept"||e==="reject")&&typeof n.reason=="string"?core.reviewCodeOfRefusal(n.reason):null)??core.diagnosticCodeOfRefusal(n.reason,n.code),l=n.reason==="collaboration-session-destroyed";return {action:e,key:t,code:d,sequence:o,final:l}}function U(e,t=e.snapshot?.()){return JSON.stringify(t?.hiddenReviewAuthors??[])}function z(e,t,n=false){if(n)return "review.refusedSessionEnded";switch(e){case "edit.refresh-in-progress":return "review.refusedRefresh";case "edit.read-only":return "review.refusedViewing";case "edit.protected-content":return "review.refusedProtected";case "edit.collaboration-not-ready":return "review.refusedCollaboration";case "review.retained-structure":return "review.refusedRetainedStructure";case "review.incomplete-group":return "review.refusedIncompleteGroup";case "review.revision-unsupported":return "review.refusedUnsupported";case "review.stale-revision":return "review.refusedStale";case "review.locked-content":return "review.refusedLockedContent";case "review.bound-content":return "review.refusedBoundContent";default:return t}}function ve(e,t){return t(z(e.code,V(e.action),e.final))}function V(e){return e==="reply"?"review.replyRefused":e==="comment"?"review.commentRefused":"review.actionRefused"}function I(e){let t=e.snapshot();return [e.getDocumentHandle().revision,e.getEditingMode(),t.editable,t.collaborationStatus,U(e,t)].join(":")}var T=new WeakMap;function Re(e){let t=T.get(e);if(t)return t;let n=null,o=0,i=new Set,d=null,l=null,r=()=>{for(let s of [...i])s();},p=()=>{let s=n!==null&&i.size>0;if(s&&!d){let c=e.on("change",f),u=e.on("selectionChange",f),m=e.on("error",f);d=()=>{c(),u(),m();};}else !s&&d&&(d(),d=null);};function f(){n&&n.at!==I(e)&&(n=null,p(),r());}let a={get:()=>n?.refusal??null,record(s,c,u){let m=K(s,c,u,o+1);m&&(o=m.sequence);let v=m!==null||n!==null;n=m?{refusal:m,at:I(e)}:null,p(),v&&r();},subscribe(s){return i.add(s),l??=e.on("reviewChangesResolved",({action:c,skipped:u})=>{let m=u.find(v=>v.reason!=="unknown-revision");a.record(c,m?m.pairKey??m.key:null,m?{ok:false,code:"unsupported",reason:`${q(m)}: the change stays pending`}:{ok:true,changed:true});}),p(),queueMicrotask(f),()=>{i.delete(s),i.size===0&&(l?.(),l=null),p();}}};return T.set(e,a),a}function be(e,t,n){let o=e.closest(".docx-editor__scroll-container")??e.offsetParent;if(!o)return ()=>{};let i=d=>{if(d.defaultPrevented||d.button!==0||!t.snapshot().selectionCollapsed)return;let l=d.target;if(!editor.isElementNode(l)||e.contains(l))return;let r=l.closest(".docx-paginated-surface");if(!r||!o.contains(r))return;let p=r.closest(".docx-editor__scroll-container");if(p&&p!==o)return;let f=t.getReviewItems({placement:false}).find(a=>a.isActive);f?.kind==="comment"&&!f.resolved&&n(f.key);};return o.addEventListener("click",i),()=>o.removeEventListener("click",i)}var R=8;function M(e){let t=/^var\(--doc-review-author-(\d{1,2})\)$/.exec(e);return t?Number(t[1])%R:null}function j(e,t,n,o){let i=new Map(e.map(r=>[r.author,r])),d=new Map,l=new Map;for(let r of t){if(l.has(r.actorId))continue;let p=collaboration.safeParticipantColor(o?.(r.name));if(p!==void 0){l.set(r.actorId,{color:p,slot:M(p)});continue}let f=collaboration.safeParticipantColor(r.color);if(f!==void 0){l.set(r.actorId,{color:f,slot:null});continue}let a=i.get(r.name),s=collaboration.safeParticipantColor(n?.(r.name));if(s!==void 0){l.set(r.actorId,{color:s,slot:M(s)??(a?a.slot%R:null)});continue}if(a!==void 0){let u=a.slot%R;l.set(r.actorId,{color:collaboration.safeParticipantColor(a.color)??`var(--doc-review-author-${u})`,slot:u});continue}let c=d.get(r.name);c===void 0&&(c=e.length+d.size,d.set(r.name,c)),l.set(r.actorId,{color:`var(--doc-review-author-${c%R})`,slot:c%R});}return l}function Ee(e,t,n,o){return j(e,[t],n,o).get(t.actorId)}function xe(e){let t=e.trim().split(/\s+/,2),n="";for(let o of t){let i=[...o][0];i!==void 0&&(n+=i.toUpperCase());}return n}function Ce(e){return [...e].sort((t,n)=>{if(t.isLocal!==n.isLocal)return t.isLocal?-1:1;let o=t.name.localeCompare(n.name);return o!==0?o:t.actorId<n.actorId?-1:t.actorId>n.actorId?1:0})}function Se(e,t,n){for(let o of e)if(o.author===t)return o.style?.avatarUrl;return n?.(t)?.avatarUrl}var O=new Map;function Ie(e){let t=e==="en"?"":e,n=O.get(t);if(!n){let o={month:"short",day:"numeric",hour:"numeric",minute:"2-digit"};try{n=new Intl.DateTimeFormat(t||void 0,o);}catch{n=new Intl.DateTimeFormat(void 0,o);}O.set(t,n);}return n}var $='a[href], button, input, select, textarea, [contenteditable]:not([contenteditable="false"]), .docx-review__reply-box';function B(e){return editor.isElementNode(e)&&e.closest($)!==null}function Oe(e){return B(e)||editor.isElementNode(e)&&e.closest("[data-review-selectable]")!==null}var ke=Object.freeze({connecting:"collaboration.status.connecting",offline:"collaboration.status.offline",offlinePaused:"collaboration.status.offlinePaused",syncing:"collaboration.status.syncing",waiting:"collaboration.status.waiting",stalled:"collaboration.status.stalled",editRefused:"collaboration.status.editRefused",outOfSync:"collaboration.status.outOfSync",upgradeRequired:"collaboration.status.upgradeRequired",newRoomRequired:"collaboration.status.newRoomRequired"}),J=new Set(["concurrent-seed","blob-digest-mismatch","blob-store-full","too-many-nodes","too-many-parts","too-many-relationships","too-many-children","too-many-attributes","tree-too-deep"]),Z=new Set(["collaboration-format-mismatch","protocol-version-mismatch","schema-version-mismatch"]);function Ne(e){switch(e.status){case "inactive":case "destroyed":return null;case "initializing":return "connecting";case "error":return e.reasonCode!==void 0&&Z.has(e.reasonCode)?"upgradeRequired":e.reasonCode!==void 0&&J.has(e.reasonCode)?"newRoomRequired":e.recovering?"syncing":"outOfSync";case "disconnected":return e.offlineEditing?"offline":"offlinePaused";case "ready":return e.waiting?e.stalled?"stalled":"waiting":e.refusedRecently?"editRefused":null}}exports.A=Se;exports.B=ke;exports.C=Ne;exports.a=X;exports.b=N;exports.c=ee;exports.d=te;exports.e=ne;exports.f=oe;exports.g=re;exports.h=S;exports.i=le;exports.j=se;exports.k=de;exports.l=W;exports.m=fe;exports.n=U;exports.o=z;exports.p=ve;exports.q=V;exports.r=Re;exports.s=be;exports.t=Ie;exports.u=B;exports.v=Oe;exports.w=j;exports.x=Ee;exports.y=xe;exports.z=Ce;