@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/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 `
|
|
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
|
|
|
@@ -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;
|