@docx-editor.dev/pro 2.10.0 → 2.11.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 +1 -7
- package/dist/chunk-32RB7HPL.js +3 -0
- package/dist/chunk-4HGT2OVX.cjs +3 -0
- package/dist/chunk-6DEUT2RQ.js +1 -0
- package/dist/chunk-7QSJBMZV.js +3 -0
- package/dist/chunk-EMO6YTKO.cjs +1 -0
- package/dist/chunk-GDTCNTK7.cjs +1 -0
- package/dist/chunk-HJB77VBO.js +1 -0
- package/dist/chunk-LUUFBXJ5.cjs +1 -0
- package/dist/chunk-NQW54J56.js +1 -0
- package/dist/chunk-Q2VBO66F.js +1 -0
- package/dist/chunk-Q4YPX2DT.cjs +1 -0
- package/dist/chunk-QLZH2Q2C.cjs +1 -0
- package/dist/chunk-W3V54DWZ.js +1 -0
- package/dist/chunk-YJM6R76M.cjs +3 -0
- package/dist/collaboration/hocuspocus.cjs +1 -0
- package/dist/collaboration/hocuspocus.d.cts +58 -0
- package/dist/collaboration/hocuspocus.d.ts +58 -0
- package/dist/collaboration/hocuspocus.js +1 -0
- package/dist/collaboration/index.cjs +2 -0
- package/dist/collaboration/index.d.cts +22 -0
- package/dist/collaboration/index.d.ts +22 -0
- package/dist/collaboration/index.js +2 -0
- package/dist/collaboration/webrtc.cjs +2 -0
- package/dist/collaboration/webrtc.d.cts +86 -0
- package/dist/collaboration/webrtc.d.ts +86 -0
- package/dist/collaboration/webrtc.js +2 -0
- package/dist/collaboration-module-BgRxhW5b.d.cts +45 -0
- package/dist/collaboration-module-BgRxhW5b.d.ts +45 -0
- package/dist/{define-custom-node-Bk8kFO27.d.cts → define-custom-node-B_p2nr9T.d.cts} +2 -20
- package/dist/{define-custom-node-Bk8kFO27.d.ts → define-custom-node-BehI3jWX.d.ts} +2 -20
- package/dist/document-session-2B3QFWBQ.cjs +1 -0
- package/dist/document-session-6UET6BWT.js +1 -0
- package/dist/document-session-DVa53DAw.d.cts +94 -0
- package/dist/document-session-DiBuzWwA.d.ts +94 -0
- package/dist/document-session-RGNZHMWF.js +1 -0
- package/dist/document-session-TU7WVBRB.cjs +1 -0
- package/dist/hocuspocus-EUC4BGDD.js +1 -0
- package/dist/hocuspocus-YIKH6ENE.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1 -1
- package/dist/react/hocuspocus.cjs +1 -0
- package/dist/react/hocuspocus.d.cts +104 -0
- package/dist/react/hocuspocus.d.ts +104 -0
- package/dist/react/hocuspocus.js +1 -0
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.d.cts +320 -5
- package/dist/react/index.d.ts +320 -5
- package/dist/react/index.js +2 -2
- package/dist/react/webrtc.cjs +1 -0
- package/dist/react/webrtc.d.cts +98 -0
- package/dist/react/webrtc.d.ts +98 -0
- package/dist/react/webrtc.js +1 -0
- package/dist/room-id-BfudXOZz.d.cts +13 -0
- package/dist/room-id-BfudXOZz.d.ts +13 -0
- package/dist/session-BH7Qgyp6.d.cts +140 -0
- package/dist/session-BH7Qgyp6.d.ts +140 -0
- package/dist/session-okdqygLg.d.cts +82 -0
- package/dist/session-okdqygLg.d.ts +82 -0
- package/dist/vue/hocuspocus.cjs +1 -0
- package/dist/vue/hocuspocus.d.cts +105 -0
- package/dist/vue/hocuspocus.d.ts +105 -0
- package/dist/vue/hocuspocus.js +1 -0
- package/dist/vue/index.cjs +2 -2
- package/dist/vue/index.d.cts +437 -1
- package/dist/vue/index.d.ts +437 -1
- package/dist/vue/index.js +2 -2
- package/dist/vue/webrtc.cjs +1 -0
- package/dist/vue/webrtc.d.cts +99 -0
- package/dist/vue/webrtc.d.ts +99 -0
- package/dist/vue/webrtc.js +1 -0
- package/dist/webrtc-36GPPCW4.js +2 -0
- package/dist/webrtc-CDIFHCQY.cjs +2 -0
- package/package.json +62 -7
- package/dist/chunk-4LFF2FXG.cjs +0 -1
- package/dist/chunk-TH5PXU6L.js +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)
|
|
3
|
+
"version": "2.11.0",
|
|
4
|
+
"description": "Commercial capabilities for @docx-editor.dev: the review module (comments, tracked changes, markup rendering), custom inline nodes, and realtime collaboration.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -15,11 +15,46 @@
|
|
|
15
15
|
"import": "./dist/react/index.js",
|
|
16
16
|
"require": "./dist/react/index.cjs"
|
|
17
17
|
},
|
|
18
|
+
"./react/webrtc": {
|
|
19
|
+
"types": "./dist/react/webrtc.d.ts",
|
|
20
|
+
"import": "./dist/react/webrtc.js",
|
|
21
|
+
"require": "./dist/react/webrtc.cjs"
|
|
22
|
+
},
|
|
23
|
+
"./react/hocuspocus": {
|
|
24
|
+
"types": "./dist/react/hocuspocus.d.ts",
|
|
25
|
+
"import": "./dist/react/hocuspocus.js",
|
|
26
|
+
"require": "./dist/react/hocuspocus.cjs"
|
|
27
|
+
},
|
|
18
28
|
"./vue": {
|
|
19
29
|
"types": "./dist/vue/index.d.ts",
|
|
20
30
|
"import": "./dist/vue/index.js",
|
|
21
31
|
"require": "./dist/vue/index.cjs"
|
|
22
32
|
},
|
|
33
|
+
"./vue/webrtc": {
|
|
34
|
+
"types": "./dist/vue/webrtc.d.ts",
|
|
35
|
+
"import": "./dist/vue/webrtc.js",
|
|
36
|
+
"require": "./dist/vue/webrtc.cjs"
|
|
37
|
+
},
|
|
38
|
+
"./vue/hocuspocus": {
|
|
39
|
+
"types": "./dist/vue/hocuspocus.d.ts",
|
|
40
|
+
"import": "./dist/vue/hocuspocus.js",
|
|
41
|
+
"require": "./dist/vue/hocuspocus.cjs"
|
|
42
|
+
},
|
|
43
|
+
"./collaboration": {
|
|
44
|
+
"types": "./dist/collaboration/index.d.ts",
|
|
45
|
+
"import": "./dist/collaboration/index.js",
|
|
46
|
+
"require": "./dist/collaboration/index.cjs"
|
|
47
|
+
},
|
|
48
|
+
"./collaboration/webrtc": {
|
|
49
|
+
"types": "./dist/collaboration/webrtc.d.ts",
|
|
50
|
+
"import": "./dist/collaboration/webrtc.js",
|
|
51
|
+
"require": "./dist/collaboration/webrtc.cjs"
|
|
52
|
+
},
|
|
53
|
+
"./collaboration/hocuspocus": {
|
|
54
|
+
"types": "./dist/collaboration/hocuspocus.d.ts",
|
|
55
|
+
"import": "./dist/collaboration/hocuspocus.js",
|
|
56
|
+
"require": "./dist/collaboration/hocuspocus.cjs"
|
|
57
|
+
},
|
|
23
58
|
"./package.json": "./package.json"
|
|
24
59
|
},
|
|
25
60
|
"files": [
|
|
@@ -35,12 +70,15 @@
|
|
|
35
70
|
"license:add": "license-check-and-add add -f license-check.json"
|
|
36
71
|
},
|
|
37
72
|
"peerDependencies": {
|
|
38
|
-
"@docx-editor.dev/core": "~2.
|
|
39
|
-
"@docx-editor.dev/react": "~2.
|
|
40
|
-
"@docx-editor.dev/vue": "~2.
|
|
73
|
+
"@docx-editor.dev/core": "~2.11.0",
|
|
74
|
+
"@docx-editor.dev/react": "~2.11.0",
|
|
75
|
+
"@docx-editor.dev/vue": "~2.11.0",
|
|
41
76
|
"react": "^18.0.0 || ^19.0.0",
|
|
42
77
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
43
|
-
"vue": "^3.3.0"
|
|
78
|
+
"vue": "^3.3.0",
|
|
79
|
+
"yjs": "^13.6.32",
|
|
80
|
+
"y-webrtc": "^10.3.0",
|
|
81
|
+
"@hocuspocus/provider": "^4.6.0"
|
|
44
82
|
},
|
|
45
83
|
"peerDependenciesMeta": {
|
|
46
84
|
"@docx-editor.dev/react": {
|
|
@@ -57,14 +95,28 @@
|
|
|
57
95
|
},
|
|
58
96
|
"vue": {
|
|
59
97
|
"optional": true
|
|
98
|
+
},
|
|
99
|
+
"yjs": {
|
|
100
|
+
"optional": true
|
|
101
|
+
},
|
|
102
|
+
"y-webrtc": {
|
|
103
|
+
"optional": true
|
|
104
|
+
},
|
|
105
|
+
"@hocuspocus/provider": {
|
|
106
|
+
"optional": true
|
|
60
107
|
}
|
|
61
108
|
},
|
|
109
|
+
"dependencies": {
|
|
110
|
+
"y-protocols": "^1.0.7"
|
|
111
|
+
},
|
|
62
112
|
"devDependencies": {
|
|
63
113
|
"@docx-editor.dev/core": "workspace:*",
|
|
114
|
+
"@docx-editor.dev/editor-api": "workspace:*",
|
|
64
115
|
"@docx-editor.dev/i18n": "workspace:*",
|
|
65
116
|
"@docx-editor.dev/react": "workspace:*",
|
|
66
117
|
"@docx-editor.dev/vue": "workspace:*",
|
|
67
118
|
"@happy-dom/global-registrator": "^20.8.3",
|
|
119
|
+
"@hocuspocus/provider": "^4.6.0",
|
|
68
120
|
"@testing-library/react": "^16.0.0",
|
|
69
121
|
"@types/react": "^19.2.18",
|
|
70
122
|
"fflate": "^0.8.2",
|
|
@@ -72,13 +124,16 @@
|
|
|
72
124
|
"react": "^19.0.0",
|
|
73
125
|
"react-dom": "^19.0.0",
|
|
74
126
|
"typescript": "^5.3.3",
|
|
127
|
+
"y-webrtc": "^10.3.0",
|
|
128
|
+
"yjs": "^13.6.32",
|
|
75
129
|
"zod": "^4.4.3"
|
|
76
130
|
},
|
|
77
131
|
"keywords": [
|
|
78
132
|
"docx",
|
|
79
133
|
"tracked-changes",
|
|
80
134
|
"comments",
|
|
81
|
-
"content-controls"
|
|
135
|
+
"content-controls",
|
|
136
|
+
"collaboration"
|
|
82
137
|
],
|
|
83
138
|
"author": {
|
|
84
139
|
"name": "EigenPal, Inc.",
|
package/dist/chunk-4LFF2FXG.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var store=require('@docx-editor.dev/core/store'),layout=require('@docx-editor.dev/core/layout');function g(e){}var Oe=64,H=new Set(["__proto__","constructor","prototype"]);function h(e,t,o){let n=new URLSearchParams;for(let[s,d]of Object.entries(o))n.set(s,d);let r=n.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 N(e){if(e.length>64)return null;let t=e.indexOf(":");if(t<=0)return null;let o=e.slice(0,t),n=e.slice(t+1),r=n.indexOf("?"),a=r===-1?n:n.slice(0,r);if(a.length===0)return null;let s=Object.create(null);if(r!==-1)for(let[d,i]of new URLSearchParams(n.slice(r+1))){if(H.has(d))return null;s[d]=i;}return {prefix:o,name:a,attrs:s}}var Ie=262144;function x(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 o;try{o=JSON.parse(t);}catch(a){return {ok:false,reason:"malformed",issues:[a instanceof Error?a.message:"the payload is not JSON"]}}let n=R(o);if(!e)return {ok:true,value:n};let r=e["~standard"].validate(n);return B(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(q)}:{ok:true,value:r.value}}function P(e){let t;try{t=JSON.stringify(e)??"";}catch(o){return {ok:false,reason:"malformed",issues:[o instanceof Error?o.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 B(e){return typeof e.then=="function"}function q(e){let t=(e.path??[]).map(o=>String(typeof o=="object"?o.key:o)).join(".");return t.length>0?`${t}: ${e.message}`:e.message}var Y=new Set(["__proto__","constructor","prototype"]);function R(e){if(Array.isArray(e))return e.map(R);if(e===null||typeof e!="object")return e;let t=Object.create(null);for(let[o,n]of Object.entries(e))Y.has(o)||(t[o]=R(n));return t}function $(e){let t=(e.path??[]).map(o=>{let n=typeof o=="object"?o.key:o;return typeof n=="number"?n:String(n)});return {message:e.message,path:t,pointer:t.join(".")}}function S(e,t){return {ok:false,code:"invalidArgs",reason:e,issues:t}}var _="docxEditor";function v(e){return e.payloadNamespace??`urn:docx-editor.dev:custom-node:${e.tagPrefix}`}function b(e,t,o){let n=0;for(let r of store.customNodePayloadsOf(e,t,o).keys()){let a=/^cx(\d{1,9})$/.exec(r);if(!a)continue;let s=Number(a[1]);s>n&&(n=s);}return `cx${String(n+1)}`}function M(e,t){let o=P(t);if(!o.ok)return {ok:false,reason:`the payload cannot be serialized: ${o.issues.join(", ")}`,issues:[]};if(!e.schema)return {ok:true,data:o.value,value:t};let r=e.schema["~standard"].validate(JSON.parse(o.value));if(Q(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($);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=P(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 Q(e){return typeof e.then=="function"}function V(e){return typeof e=="object"&&e!==null&&typeof e.name=="string"&&typeof e.tagPrefix=="string"}var L=/^[A-Za-z0-9_.-]+$/,te=/['"<>&]|[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/;function oe(e){return e.length>0&&!te.test(e)}function Ve(e){if(!L.test(e.name??""))throw new Error(`defineCustomNode: invalid name ${JSON.stringify(e.name)}`);if(!L.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&&!oe(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:n=>{if(!n||n.data===void 0||n.name!==void 0&&n.name!==e.name)return;if(!e.schema)return n.data;let r=e.schema["~standard"].validate(n.data);if(typeof r.then=="function")return;let a=r;return a.issues?void 0:a.value}})}function ze(e){g(e.licenseKey);let t=new Set;for(let o of e.nodes){let n=`${o.tagPrefix}:${o.name}`;if(t.has(n))throw new Error(`customNodesModule: two definitions claim ${JSON.stringify(n)}`);t.add(n);}return {id:"custom-nodes",customNodes:e.nodes,...e.onDiagnostic?{onCustomNodeDiagnostic:o=>{e.onDiagnostic?.(o);}}:{},customNodePayloadNamespaces:[...new Set(e.nodes.map(v))]}}function ne(e){for(let t of e.children)if(!(t.kind==="textValue"||t.localName!=="sdtPr")){for(let o of t.children)if(!(o.kind==="textValue"||o.localName!=="tag")){for(let n of o.attributes)if(n.localName==="val")return n.value}}}function z(e){if(e.kind==="textValue")return e.value;let t="";for(let o of e.children)t+=z(o);return t}function j(e,t,o={}){if(t.length===0)return [];let n=new Map;for(let s of t){let d=`${s.tagPrefix}:${s.name}`;if(n.has(d))throw new Error(`recognizeCustomNodes: duplicate definition for ${JSON.stringify(d)}`);n.set(d,s);}let r=[],a=(s,d)=>{if(!(s.kind==="textValue"||d>64)){if(s.kind==="contentControl"){let i=ne(s),u=i!==void 0?N(i):null,c=u?n.get(`${u.prefix}:${u.name}`):void 0;if(u&&c&&i!==void 0){let l=z(s),f=re(c,s.id,o.payloads?.get(s.id),store.contentControlPropertiesOf(s).dataBinding!==void 0,o.onDiagnostic),m=c.fromDocx?c.fromDocx({attrs:u.attrs,text:l,...f.present?{data:f.value}:{}}):u.attrs;if(m!==null){r.push({name:c.name,attrs:m,text:l,nodeId:s.id,tag:i,...f.present?{data:f.value}:{}});return}}}for(let i of s.children)a(i,d+1);}};return a(e.root,0),r}function re(e,t,o,n,r){if(!o)return n&&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=x(e.schema,o.data);return a.ok?{present:true,value:a.value}:(r?.({code:"payload-invalid",name:e.name,nodeId:t,issues:a.issues}),{present:false})}function W(e,t){let o=store.findNode(e,t);return !o||o.kind!=="paragraph"?[]:store.revisionItemsOf({id:e.id,name:e.name,contentType:e.contentType,root:o})}function ce(e,t,o,n){if(t.length===0)return [];let r=j(e,t,{...o===void 0?{}:{payloads:o},...n===void 0?{}:{onDiagnostic:n}});if(r.length===0)return [];let a=store.locateSites(e),s=[];for(let d of r){let i=t.find(l=>l.name===d.name&&d.tag.startsWith(`${l.tagPrefix}:`));if(!i)continue;let u=i.reviewCard?i.reviewCard({attrs:d.attrs,text:d.text,...d.data===void 0?{}:{data:d.data}}):null;if(i.reviewCard&&u===null)continue;let c=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&&u!==null,title:u?.title??"",...u?.detail!==void 0?{detail:u.detail}:{},...u?.icon!==void 0?{icon:u.icon}:{},range:c?{partName:e.name,start:{paragraphId:c.paragraphId,offset:c.start},end:{paragraphId:c.paragraphId,offset:c.end}}:null});}return s}function K(e){let t=store.collectReviewItems(e),o=(e.customNodes??[]).filter(V);if(o.length===0)return t;let n=[e.storyPart],r=new Set([e.storyPart.name]);for(let i of e.furnitureParts??[])r.has(i.name)||(r.add(i.name),n.push(i));let a=[],s=new Map;for(let i of n){a.push(...ce(i,o,e.customNodePayloads,e.reportCustomNodeDiagnostic));let u=s.size;for(let[c,l]of store.paragraphOrderOfPart(i))s.has(c)||s.set(c,u+l);}return a.length===0?t:[...t,...a].sort((i,u)=>layout.reviewItemPositionRank(i,s)-layout.reviewItemPositionRank(u,s))}function ot(e={}){return g(e.licenseKey),{id:"review",review:{displayModes:["all-markup","proposed","original"],collectReviewItems:K,revisionItemsOfParagraph:W}}}function G(e){return e.surface??null}function E(e,t){if(t==null)return null;let o=M(e,t);return o.ok?{ok:true,serialized:o.data,value:o.value}:{ok:false,reason:o.reason,issues:o.issues}}function D(e,t,o,n,r){let a=v(t),s=e.session.part().name;return {namespaceUri:a,rootLocalName:_,nodeId:r??b(e.session.currentPackage(),s,a),label:n,data:o}}function k(e){let t=e.detail?`${e.reason}: ${e.detail}`:e.reason;return {ok:false,code:me.has(e.reason)?"invalidArgs":"unsupported",reason:t}}var me=new Set(["payload-too-large","unaddressable-payload","store-not-authored","offset-out-of-range","invalid-range","invalid-property-value","splits-surrogate-pair"]);function A(e,t,o){let n,r;if(o!==void 0)try{n=e.text?.(o),r=e.tagAttrs?.(o);}catch(s){return {reason:`${e.name} could not describe this payload: ${s instanceof Error?s.message:String(s)}`}}let a=t.text??n;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 C(e){return e.getEditingMode()==="viewing"?{ok:false,code:"locked",reason:"the document is open for viewing"}:null}function U(e){let t=e.getActiveScope();if(t.kind==="headerFooter")return {kind:"headerFooter",rId:t.rId};if(t.kind==="note"){let o=store.parseNoteScopeId(t.id);if(o)return {kind:"notesPart",noteKind:o.noteKind}}return {kind:"body"}}function O(e,t){let o=G(e),n=t===void 0?"":t.slice(0,t.indexOf("#"));if(!o||n.length===0)return U(e);if(n===o.session.part().name)return {kind:"body"};for(let r of o.session.headerFooterResolutionBySection())for(let a of [r.headers,r.footers])for(let s of a.values())if(s.partName===n)return {kind:"headerFooter",rId:s.rId};for(let r of ["footnote","endnote"])if(o.session.partFor({kind:"notesPart",noteKind:r})?.name===n)return {kind:"notesPart",noteKind:r};return U(e)}function it(e,t,o={}){let n=G(e);if(!n)return {ok:false,code:"notFound",reason:"no document is mounted"};let r=E(t,o.data);if(r&&!r.ok)return S(r.reason,r.issues);let a=A(t,o,r?.value);if("reason"in a)return {ok:false,code:"invalidArgs",reason:a.reason};let s=h(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=C(e);if(d)return d;n.flushPendingInput();let i=o.at??n.state().selection.head,u=o.lock===void 0?"contentLocked":o.lock,c=O(e,i.paragraphId),l=n.session.insertCustomNode({paragraphId:i.paragraphId,offset:i.offset,tag:s.tag,text:a.text,...o.alias===void 0?{}:{alias:o.alias},...u===false?{}:{lock:u},...r?{payload:D(n,t,r.serialized,a.text)}:{}},c);return l.ok?{ok:true,changed:true,...l.nodeId===void 0?{}:{nodeId:l.nodeId}}:k(l)}function J(e){return e.surface??null}function Ne(e,t){let o=null,n=a=>a.id===t?true:a.kind==="textValue"?false:a.children.some(n),r=(a,s)=>{if(!(o||a.kind==="textValue"||s>64)){if(a.kind==="paragraph"){n(a)&&(o=a);return}for(let d of a.children)r(d,s+1);}};return r(e.root,0),o}function xe(e,t){let o=new Set,n=i=>{if(o.add(i.id),i.kind!=="textValue")for(let u of i.children)n(u);},r=i=>{if(i.id===t)return i;if(i.kind==="textValue")return null;for(let u of i.children){let c=r(u);if(c)return c}return null},a=r(e);if(!a)return null;n(a);let s=Number.MAX_SAFE_INTEGER,d=-1;for(let i of store.segmentsOf(e))o.has(i.runId)&&(i.start<s&&(s=i.start),i.end>d&&(d=i.end));return d<0?null:{start:s,end:d}}function gt(e,t){let o=J(e);if(!o)return {ok:false,code:"notFound",reason:"no document is mounted"};let n=C(e);if(n)return n;o.flushPendingInput();let r=o.session.removeCustomNode(t,O(e,t));return r.ok?{ok:true,changed:true}:k(r)}function ht(e,t,o,n={}){let r=J(e);if(!r)return {ok:false,code:"notFound",reason:"no document is mounted"};let a=C(e);if(a)return a;r.flushPendingInput();let s=O(e,o),d=r.session.partFor(s)??r.session.part(),i=Ne(d,o),u=i?xe(i,o):null,c=Se(r,o,s);if(!i||!u||!c)return {ok:false,code:"notFound",reason:"no custom node with that id"};let l=`${t.tagPrefix}:${t.name}`;if(c.identity!==null&&c.identity!==l)return {ok:false,code:"invalidArgs",reason:`node ${o} is a ${c.identity}, not a ${l}`};let f=ke(r,o,s),m=n.data===null?null:n.data===void 0?ve(f):E(t,n.data);if(m&&!m.ok)return S(m.reason,m.issues);let p=A(t,{attrs:n.attrs??(n.data===void 0?c.attrs:void 0),text:n.text??(m===null&&n.data===null?c.text:void 0)},m?.value);if("reason"in p)return {ok:false,code:"invalidArgs",reason:p.reason};let w=h(t.tagPrefix,t.name,p.attrs);if(!w.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${w.length} characters; Word caps w:tag at 64 \u2014 move what does not fit into the payload (\`data\`), or shorten the attrs`};let T=n.alias??c.alias,I=n.lock??c.lock,y=r.session.insertCustomNode({replaceControlId:o,paragraphId:i.id,offset:u.start,tag:w.tag,text:p.text,...T===void 0?{}:{alias:T},...I===false||I===void 0?{}:{lock:I},...m?{payload:D(r,t,m.serialized,p.text,f?.nodeId)}:{}},s);return y.ok?{ok:true,changed:true,...y.nodeId===void 0?{}:{nodeId:y.nodeId}}:k(y)}function Se(e,t,o){let n=e.session.partFor(o)??e.session.part(),r=store.contentControlsIn(n.root).find(i=>i.node.id===t);if(!r)return null;let a=store.contentControlPropertiesOf(r.node),s=a.tag===void 0?null:N(a.tag),d=a.lock;return {identity:s?`${s.prefix}:${s.name}`:null,attrs:s?.attrs??{},text:store.contentControlTextOf(r.node),alias:a.alias,lock:d==="sdtLocked"||d==="sdtContentLocked"||d==="contentLocked"?d:d==="unlocked"?false:void 0}}function ve(e){if(!e)return null;let t=x(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 ke(e,t,o){let n=e.session.partFor(o)??e.session.part();return store.customNodePayloadsByControl(e.session.currentPackage(),n.name,e.session.part().name).get(t)}exports.a=Oe;exports.b=h;exports.c=N;exports.d=Ie;exports.e=x;exports.f=P;exports.g=_;exports.h=v;exports.i=M;exports.j=V;exports.k=L;exports.l=Ve;exports.m=ze;exports.n=j;exports.o=ot;exports.p=it;exports.q=gt;exports.r=ht;
|
package/dist/chunk-TH5PXU6L.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {contentControlsIn,contentControlPropertiesOf,contentControlTextOf,findNode,revisionItemsOf,collectReviewItems,paragraphOrderOfPart,locateSites,parseNoteScopeId,customNodePayloadsOf,customNodePayloadsByControl,segmentsOf}from'@docx-editor.dev/core/store';import {reviewItemPositionRank}from'@docx-editor.dev/core/layout';function g(e){}var Oe=64,H=new Set(["__proto__","constructor","prototype"]);function h(e,t,o){let n=new URLSearchParams;for(let[s,d]of Object.entries(o))n.set(s,d);let r=n.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 N(e){if(e.length>64)return null;let t=e.indexOf(":");if(t<=0)return null;let o=e.slice(0,t),n=e.slice(t+1),r=n.indexOf("?"),a=r===-1?n:n.slice(0,r);if(a.length===0)return null;let s=Object.create(null);if(r!==-1)for(let[d,i]of new URLSearchParams(n.slice(r+1))){if(H.has(d))return null;s[d]=i;}return {prefix:o,name:a,attrs:s}}var Ie=262144;function x(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 o;try{o=JSON.parse(t);}catch(a){return {ok:false,reason:"malformed",issues:[a instanceof Error?a.message:"the payload is not JSON"]}}let n=R(o);if(!e)return {ok:true,value:n};let r=e["~standard"].validate(n);return B(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(q)}:{ok:true,value:r.value}}function P(e){let t;try{t=JSON.stringify(e)??"";}catch(o){return {ok:false,reason:"malformed",issues:[o instanceof Error?o.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 B(e){return typeof e.then=="function"}function q(e){let t=(e.path??[]).map(o=>String(typeof o=="object"?o.key:o)).join(".");return t.length>0?`${t}: ${e.message}`:e.message}var Y=new Set(["__proto__","constructor","prototype"]);function R(e){if(Array.isArray(e))return e.map(R);if(e===null||typeof e!="object")return e;let t=Object.create(null);for(let[o,n]of Object.entries(e))Y.has(o)||(t[o]=R(n));return t}function $(e){let t=(e.path??[]).map(o=>{let n=typeof o=="object"?o.key:o;return typeof n=="number"?n:String(n)});return {message:e.message,path:t,pointer:t.join(".")}}function S(e,t){return {ok:false,code:"invalidArgs",reason:e,issues:t}}var _="docxEditor";function v(e){return e.payloadNamespace??`urn:docx-editor.dev:custom-node:${e.tagPrefix}`}function b(e,t,o){let n=0;for(let r of customNodePayloadsOf(e,t,o).keys()){let a=/^cx(\d{1,9})$/.exec(r);if(!a)continue;let s=Number(a[1]);s>n&&(n=s);}return `cx${String(n+1)}`}function M(e,t){let o=P(t);if(!o.ok)return {ok:false,reason:`the payload cannot be serialized: ${o.issues.join(", ")}`,issues:[]};if(!e.schema)return {ok:true,data:o.value,value:t};let r=e.schema["~standard"].validate(JSON.parse(o.value));if(Q(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($);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=P(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 Q(e){return typeof e.then=="function"}function V(e){return typeof e=="object"&&e!==null&&typeof e.name=="string"&&typeof e.tagPrefix=="string"}var L=/^[A-Za-z0-9_.-]+$/,te=/['"<>&]|[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/;function oe(e){return e.length>0&&!te.test(e)}function Ve(e){if(!L.test(e.name??""))throw new Error(`defineCustomNode: invalid name ${JSON.stringify(e.name)}`);if(!L.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&&!oe(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:n=>{if(!n||n.data===void 0||n.name!==void 0&&n.name!==e.name)return;if(!e.schema)return n.data;let r=e.schema["~standard"].validate(n.data);if(typeof r.then=="function")return;let a=r;return a.issues?void 0:a.value}})}function ze(e){g(e.licenseKey);let t=new Set;for(let o of e.nodes){let n=`${o.tagPrefix}:${o.name}`;if(t.has(n))throw new Error(`customNodesModule: two definitions claim ${JSON.stringify(n)}`);t.add(n);}return {id:"custom-nodes",customNodes:e.nodes,...e.onDiagnostic?{onCustomNodeDiagnostic:o=>{e.onDiagnostic?.(o);}}:{},customNodePayloadNamespaces:[...new Set(e.nodes.map(v))]}}function ne(e){for(let t of e.children)if(!(t.kind==="textValue"||t.localName!=="sdtPr")){for(let o of t.children)if(!(o.kind==="textValue"||o.localName!=="tag")){for(let n of o.attributes)if(n.localName==="val")return n.value}}}function z(e){if(e.kind==="textValue")return e.value;let t="";for(let o of e.children)t+=z(o);return t}function j(e,t,o={}){if(t.length===0)return [];let n=new Map;for(let s of t){let d=`${s.tagPrefix}:${s.name}`;if(n.has(d))throw new Error(`recognizeCustomNodes: duplicate definition for ${JSON.stringify(d)}`);n.set(d,s);}let r=[],a=(s,d)=>{if(!(s.kind==="textValue"||d>64)){if(s.kind==="contentControl"){let i=ne(s),u=i!==void 0?N(i):null,c=u?n.get(`${u.prefix}:${u.name}`):void 0;if(u&&c&&i!==void 0){let l=z(s),f=re(c,s.id,o.payloads?.get(s.id),contentControlPropertiesOf(s).dataBinding!==void 0,o.onDiagnostic),m=c.fromDocx?c.fromDocx({attrs:u.attrs,text:l,...f.present?{data:f.value}:{}}):u.attrs;if(m!==null){r.push({name:c.name,attrs:m,text:l,nodeId:s.id,tag:i,...f.present?{data:f.value}:{}});return}}}for(let i of s.children)a(i,d+1);}};return a(e.root,0),r}function re(e,t,o,n,r){if(!o)return n&&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=x(e.schema,o.data);return a.ok?{present:true,value:a.value}:(r?.({code:"payload-invalid",name:e.name,nodeId:t,issues:a.issues}),{present:false})}function W(e,t){let o=findNode(e,t);return !o||o.kind!=="paragraph"?[]:revisionItemsOf({id:e.id,name:e.name,contentType:e.contentType,root:o})}function ce(e,t,o,n){if(t.length===0)return [];let r=j(e,t,{...o===void 0?{}:{payloads:o},...n===void 0?{}:{onDiagnostic:n}});if(r.length===0)return [];let a=locateSites(e),s=[];for(let d of r){let i=t.find(l=>l.name===d.name&&d.tag.startsWith(`${l.tagPrefix}:`));if(!i)continue;let u=i.reviewCard?i.reviewCard({attrs:d.attrs,text:d.text,...d.data===void 0?{}:{data:d.data}}):null;if(i.reviewCard&&u===null)continue;let c=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&&u!==null,title:u?.title??"",...u?.detail!==void 0?{detail:u.detail}:{},...u?.icon!==void 0?{icon:u.icon}:{},range:c?{partName:e.name,start:{paragraphId:c.paragraphId,offset:c.start},end:{paragraphId:c.paragraphId,offset:c.end}}:null});}return s}function K(e){let t=collectReviewItems(e),o=(e.customNodes??[]).filter(V);if(o.length===0)return t;let n=[e.storyPart],r=new Set([e.storyPart.name]);for(let i of e.furnitureParts??[])r.has(i.name)||(r.add(i.name),n.push(i));let a=[],s=new Map;for(let i of n){a.push(...ce(i,o,e.customNodePayloads,e.reportCustomNodeDiagnostic));let u=s.size;for(let[c,l]of paragraphOrderOfPart(i))s.has(c)||s.set(c,u+l);}return a.length===0?t:[...t,...a].sort((i,u)=>reviewItemPositionRank(i,s)-reviewItemPositionRank(u,s))}function ot(e={}){return g(e.licenseKey),{id:"review",review:{displayModes:["all-markup","proposed","original"],collectReviewItems:K,revisionItemsOfParagraph:W}}}function G(e){return e.surface??null}function E(e,t){if(t==null)return null;let o=M(e,t);return o.ok?{ok:true,serialized:o.data,value:o.value}:{ok:false,reason:o.reason,issues:o.issues}}function D(e,t,o,n,r){let a=v(t),s=e.session.part().name;return {namespaceUri:a,rootLocalName:_,nodeId:r??b(e.session.currentPackage(),s,a),label:n,data:o}}function k(e){let t=e.detail?`${e.reason}: ${e.detail}`:e.reason;return {ok:false,code:me.has(e.reason)?"invalidArgs":"unsupported",reason:t}}var me=new Set(["payload-too-large","unaddressable-payload","store-not-authored","offset-out-of-range","invalid-range","invalid-property-value","splits-surrogate-pair"]);function A(e,t,o){let n,r;if(o!==void 0)try{n=e.text?.(o),r=e.tagAttrs?.(o);}catch(s){return {reason:`${e.name} could not describe this payload: ${s instanceof Error?s.message:String(s)}`}}let a=t.text??n;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 C(e){return e.getEditingMode()==="viewing"?{ok:false,code:"locked",reason:"the document is open for viewing"}:null}function U(e){let t=e.getActiveScope();if(t.kind==="headerFooter")return {kind:"headerFooter",rId:t.rId};if(t.kind==="note"){let o=parseNoteScopeId(t.id);if(o)return {kind:"notesPart",noteKind:o.noteKind}}return {kind:"body"}}function O(e,t){let o=G(e),n=t===void 0?"":t.slice(0,t.indexOf("#"));if(!o||n.length===0)return U(e);if(n===o.session.part().name)return {kind:"body"};for(let r of o.session.headerFooterResolutionBySection())for(let a of [r.headers,r.footers])for(let s of a.values())if(s.partName===n)return {kind:"headerFooter",rId:s.rId};for(let r of ["footnote","endnote"])if(o.session.partFor({kind:"notesPart",noteKind:r})?.name===n)return {kind:"notesPart",noteKind:r};return U(e)}function it(e,t,o={}){let n=G(e);if(!n)return {ok:false,code:"notFound",reason:"no document is mounted"};let r=E(t,o.data);if(r&&!r.ok)return S(r.reason,r.issues);let a=A(t,o,r?.value);if("reason"in a)return {ok:false,code:"invalidArgs",reason:a.reason};let s=h(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=C(e);if(d)return d;n.flushPendingInput();let i=o.at??n.state().selection.head,u=o.lock===void 0?"contentLocked":o.lock,c=O(e,i.paragraphId),l=n.session.insertCustomNode({paragraphId:i.paragraphId,offset:i.offset,tag:s.tag,text:a.text,...o.alias===void 0?{}:{alias:o.alias},...u===false?{}:{lock:u},...r?{payload:D(n,t,r.serialized,a.text)}:{}},c);return l.ok?{ok:true,changed:true,...l.nodeId===void 0?{}:{nodeId:l.nodeId}}:k(l)}function J(e){return e.surface??null}function Ne(e,t){let o=null,n=a=>a.id===t?true:a.kind==="textValue"?false:a.children.some(n),r=(a,s)=>{if(!(o||a.kind==="textValue"||s>64)){if(a.kind==="paragraph"){n(a)&&(o=a);return}for(let d of a.children)r(d,s+1);}};return r(e.root,0),o}function xe(e,t){let o=new Set,n=i=>{if(o.add(i.id),i.kind!=="textValue")for(let u of i.children)n(u);},r=i=>{if(i.id===t)return i;if(i.kind==="textValue")return null;for(let u of i.children){let c=r(u);if(c)return c}return null},a=r(e);if(!a)return null;n(a);let s=Number.MAX_SAFE_INTEGER,d=-1;for(let i of segmentsOf(e))o.has(i.runId)&&(i.start<s&&(s=i.start),i.end>d&&(d=i.end));return d<0?null:{start:s,end:d}}function gt(e,t){let o=J(e);if(!o)return {ok:false,code:"notFound",reason:"no document is mounted"};let n=C(e);if(n)return n;o.flushPendingInput();let r=o.session.removeCustomNode(t,O(e,t));return r.ok?{ok:true,changed:true}:k(r)}function ht(e,t,o,n={}){let r=J(e);if(!r)return {ok:false,code:"notFound",reason:"no document is mounted"};let a=C(e);if(a)return a;r.flushPendingInput();let s=O(e,o),d=r.session.partFor(s)??r.session.part(),i=Ne(d,o),u=i?xe(i,o):null,c=Se(r,o,s);if(!i||!u||!c)return {ok:false,code:"notFound",reason:"no custom node with that id"};let l=`${t.tagPrefix}:${t.name}`;if(c.identity!==null&&c.identity!==l)return {ok:false,code:"invalidArgs",reason:`node ${o} is a ${c.identity}, not a ${l}`};let f=ke(r,o,s),m=n.data===null?null:n.data===void 0?ve(f):E(t,n.data);if(m&&!m.ok)return S(m.reason,m.issues);let p=A(t,{attrs:n.attrs??(n.data===void 0?c.attrs:void 0),text:n.text??(m===null&&n.data===null?c.text:void 0)},m?.value);if("reason"in p)return {ok:false,code:"invalidArgs",reason:p.reason};let w=h(t.tagPrefix,t.name,p.attrs);if(!w.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${w.length} characters; Word caps w:tag at 64 \u2014 move what does not fit into the payload (\`data\`), or shorten the attrs`};let T=n.alias??c.alias,I=n.lock??c.lock,y=r.session.insertCustomNode({replaceControlId:o,paragraphId:i.id,offset:u.start,tag:w.tag,text:p.text,...T===void 0?{}:{alias:T},...I===false||I===void 0?{}:{lock:I},...m?{payload:D(r,t,m.serialized,p.text,f?.nodeId)}:{}},s);return y.ok?{ok:true,changed:true,...y.nodeId===void 0?{}:{nodeId:y.nodeId}}:k(y)}function Se(e,t,o){let n=e.session.partFor(o)??e.session.part(),r=contentControlsIn(n.root).find(i=>i.node.id===t);if(!r)return null;let a=contentControlPropertiesOf(r.node),s=a.tag===void 0?null:N(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 ve(e){if(!e)return null;let t=x(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 ke(e,t,o){let n=e.session.partFor(o)??e.session.part();return customNodePayloadsByControl(e.session.currentPackage(),n.name,e.session.part().name).get(t)}export{Oe as a,h as b,N as c,Ie as d,x as e,P as f,_ as g,v as h,M as i,V as j,L as k,Ve as l,ze as m,j as n,ot as o,it as p,gt as q,ht as r};
|