@docx-editor.dev/pro 2.35.0-canary.20261104032723.sha-43c2012 → 2.35.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 +9 -14
- package/dist/chunk-B4OWKZIG.js +7 -0
- package/dist/chunk-OYR3V4F4.cjs +1 -0
- package/dist/chunk-VJOGWUUQ.cjs +7 -0
- package/dist/chunk-XC2ILGOO.js +1 -0
- package/dist/collaboration/hocuspocus.d.cts +3 -3
- package/dist/collaboration/hocuspocus.d.ts +3 -3
- package/dist/collaboration/index.d.cts +3 -3
- package/dist/collaboration/index.d.ts +3 -3
- package/dist/collaboration/webrtc.d.cts +3 -3
- package/dist/collaboration/webrtc.d.ts +3 -3
- package/dist/compare-worker.cjs +1 -0
- package/dist/compare-worker.d.cts +7 -0
- package/dist/compare-worker.d.ts +7 -0
- package/dist/compare-worker.js +1 -0
- package/dist/{define-custom-node-DE1KjR1r.d.ts → define-custom-node-BRNdxxZL.d.ts} +17 -0
- package/dist/{define-custom-node-CISpZvVB.d.cts → define-custom-node-CvRKwTqE.d.cts} +17 -0
- package/dist/{document-session-DZK2tAr4.d.cts → document-session-C6Zli8mp.d.cts} +2 -2
- package/dist/{document-session-B6v5LZIK.d.ts → document-session-CRhyVeWE.d.ts} +2 -2
- package/dist/{document-session-options-CxR0F5xT.d.cts → document-session-options-CuEO7l9P.d.cts} +1 -1
- package/dist/{document-session-options-CdOH-TNn.d.ts → document-session-options-hwq_FdnS.d.ts} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +90 -7
- package/dist/index.d.ts +90 -7
- package/dist/index.js +1 -1
- package/dist/react/hocuspocus.d.cts +2 -2
- package/dist/react/hocuspocus.d.ts +2 -2
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.d.cts +5 -5
- package/dist/react/index.d.ts +5 -5
- package/dist/react/index.js +1 -1
- package/dist/react/webrtc.d.cts +2 -2
- package/dist/react/webrtc.d.ts +2 -2
- package/dist/{types-DvGpDOcZ.d.cts → types-gCdUeE3e.d.cts} +1 -1
- package/dist/{types-DvGpDOcZ.d.ts → types-gCdUeE3e.d.ts} +1 -1
- package/dist/vue/index.cjs +2 -2
- package/dist/vue/index.d.cts +17 -0
- package/dist/vue/index.d.ts +17 -0
- package/dist/vue/index.js +1 -1
- package/docs/accept-reject-without-scrolling.md +31 -48
- package/docs/comment-on-found-text.md +47 -23
- package/docs/custom-review-cards.md +50 -34
- package/docs/highlight-ranges.md +26 -6
- package/docs/index.md +21 -21
- package/docs/propose-rewrite.md +87 -138
- package/docs/tracked-replacement.md +41 -20
- package/package.json +7 -4
- package/dist/chunk-L6ZMFFBX.cjs +0 -1
- package/dist/chunk-VQOLBCW6.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {b,c,d,f}from'./chunk-B4OWKZIG.js';import {a as a$1}from'./chunk-ZMBZ7CWZ.js';import {a}from'./chunk-HMU7J34H.js';import {contentControlsIn,contentControlPropertiesOf,contentControlTextOf,findNode,revisionItemsOf,collectReviewItems,paragraphOrderOfPart,readOoxmlPackage,locateSites,parseNoteScopeId,customNodePayloadsOf,customNodePayloadsByControl,segmentsOf}from'@docx-editor.dev/core/store';import {resolveReviewPane,REVISION_MARKUP_COLORS,COMPARE_DOCUMENTS_ACCEPT,compareDocumentsErrorKey,observeContentControlPopup}from'@docx-editor.dev/core/editor';import {createT,en}from'@docx-editor.dev/i18n';import {reviewItemPositionRank}from'@docx-editor.dev/core/layout';var pt=64,we=new Set(["__proto__","constructor","prototype"]);function A(e,o,t){let n=new URLSearchParams;for(let[i,s]of Object.entries(t))n.set(i,s);let r=n.toString(),a=r.length>0?`${e}:${o}?${r}`:`${e}:${o}`;return a.length>64?{ok:false,reason:"tag-overflow",length:a.length}:{ok:true,tag:a}}function M(e){if(e.length>64)return null;let o=e.indexOf(":");if(o<=0)return null;let t=e.slice(0,o),n=e.slice(o+1),r=n.indexOf("?"),a=r===-1?n:n.slice(0,r);if(a.length===0)return null;let i=Object.create(null);if(r!==-1)for(let[s,d]of new URLSearchParams(n.slice(r+1))){if(we.has(s))return null;i[s]=d;}return {prefix:t,name:a,attrs:i}}var gt=262144;function L(e,o){if(o.length===0)return {ok:false,reason:"malformed",issues:["the node carries no payload"]};if(o.length>262144)return {ok:false,reason:"malformed",issues:[`the payload is ${String(o.length)} characters; the cap is ${String(262144)}`]};let t;try{t=JSON.parse(o);}catch(a){return {ok:false,reason:"malformed",issues:[a instanceof Error?a.message:"the payload is not JSON"]}}let n=z(t);if(!e)return {ok:true,value:n};let r=e["~standard"].validate(n);return Oe(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(Ee)}:{ok:true,value:r.value}}function K(e){let o;try{o=JSON.stringify(e)??"";}catch(t){return {ok:false,reason:"malformed",issues:[t instanceof Error?t.message:"the value cannot be serialized"]}}return o.length===0?{ok:false,reason:"malformed",issues:["the value serializes to nothing"]}:o.length>262144?{ok:false,reason:"malformed",issues:[`the payload is ${String(o.length)} characters; the cap is ${String(262144)}`]}:{ok:true,value:o}}function Oe(e){return typeof e.then=="function"}function Ee(e){let o=(e.path??[]).map(t=>String(typeof t=="object"?t.key:t)).join(".");return o.length>0?`${o}: ${e.message}`:e.message}var Re=new Set(["__proto__","constructor","prototype"]);function z(e){if(Array.isArray(e))return e.map(z);if(e===null||typeof e!="object")return e;let o=Object.create(null);for(let[t,n]of Object.entries(e))Re.has(t)||(o[t]=z(n));return o}function re(e){let o=(e.path??[]).map(t=>{let n=typeof t=="object"?t.key:t;return typeof n=="number"?n:String(n)});return {message:e.message,path:o,pointer:o.join(".")}}function $(e,o){return {ok:false,code:"invalidArgs",reason:e,issues:o}}var ae="docxEditor";function _(e){return e.payloadNamespace??`urn:docx-editor.dev:custom-node:${e.tagPrefix}`}function se(e,o,t){let n=0;for(let r of customNodePayloadsOf(e,o,t).keys()){let a=/^cx(\d{1,9})$/.exec(r);if(!a)continue;let i=Number(a[1]);i>n&&(n=i);}return `cx${String(n+1)}`}function ie(e,o){let t=K(o);if(!t.ok)return {ok:false,reason:`the payload cannot be serialized: ${t.issues.join(", ")}`,issues:[]};if(!e.schema)return {ok:true,data:t.value,value:o};let r=e.schema["~standard"].validate(JSON.parse(t.value));if(Ie(r))return {ok:false,reason:`${e.name}'s schema validates asynchronously, which a write cannot await`,issues:[]};if(r.issues){let i=r.issues.map(re);return {ok:false,reason:`the payload does not match ${e.name}'s schema: `+i.map(s=>(s.pointer?`${s.pointer}: `:"")+s.message).join(", "),issues:i}}let a=K(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 Ie(e){return typeof e.then=="function"}function ce(e){return typeof e=="object"&&e!==null&&typeof e.name=="string"&&typeof e.tagPrefix=="string"}var de=/^[A-Za-z0-9_.-]+$/,Te=/['"<>&]|[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/;function Ae(e){return e.length>0&&!Te.test(e)}function Et(e){if(!de.test(e.name??""))throw new Error(`defineCustomNode: invalid name ${JSON.stringify(e.name)}`);if(!de.test(e.tagPrefix??""))throw new Error(`defineCustomNode: invalid tagPrefix ${JSON.stringify(e.tagPrefix)}`);let o=e.schema;if(o!==void 0&&typeof o?.["~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&&!Ae(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 Rt(e){a(e.licenseKey);let o=new Set;for(let t of e.nodes){let n=`${t.tagPrefix}:${t.name}`;if(o.has(n))throw new Error(`customNodesModule: two definitions claim ${JSON.stringify(n)}`);o.add(n);}return {id:"custom-nodes",customNodes:e.nodes,...e.onDiagnostic?{onCustomNodeDiagnostic:t=>{e.onDiagnostic?.(t);}}:{},customNodePayloadNamespaces:[...new Set(e.nodes.map(_))]}}function Me(e){for(let o of e.children)if(!(o.kind==="textValue"||o.localName!=="sdtPr")){for(let t of o.children)if(!(t.kind==="textValue"||t.localName!=="tag")){for(let n of t.attributes)if(n.localName==="val")return n.value}}}function le(e){if(e.kind==="textValue")return e.value;let o="";for(let t of e.children)o+=le(t);return o}function ue(e,o,t={}){if(o.length===0)return [];let n=new Map;for(let i of o){let s=`${i.tagPrefix}:${i.name}`;if(n.has(s))throw new Error(`recognizeCustomNodes: duplicate definition for ${JSON.stringify(s)}`);n.set(s,i);}let r=[],a=(i,s)=>{if(!(i.kind==="textValue"||s>64)){if(i.kind==="contentControl"){let d=Me(i),c=d!==void 0?M(d):null,m=c?n.get(`${c.prefix}:${c.name}`):void 0;if(c&&m&&d!==void 0){let g=le(i),x=Le(m,i.id,t.payloads?.get(i.id),contentControlPropertiesOf(i).dataBinding!==void 0,t.onDiagnostic),N=m.fromDocx?m.fromDocx({attrs:c.attrs,text:g,...x.present?{data:x.value}:{}}):c.attrs;if(N!==null){r.push({name:m.name,attrs:N,text:g,nodeId:i.id,tag:d,...x.present?{data:x.value}:{}});return}}}for(let d of i.children)a(d,s+1);}};return a(e.root,0),r}function Le(e,o,t,n,r){if(!t)return n&&r?.({code:"payload-missing",name:e.name,nodeId:o,issues:["the control binds a store node this document does not hold"]}),{present:false};let a=L(e.schema,t.data);return a.ok?{present:true,value:a.value}:(r?.({code:"payload-invalid",name:e.name,nodeId:o,issues:a.issues}),{present:false})}var me=(e,o,t)=>{let n=readOoxmlPackage(o);if(!n.ok)return {ok:false,code:"invalidRevised",message:`The revised document cannot be read (${n.reason}).`};let r=b(e,n.package,t);return r.ok?{ok:true,package:r.package,revisionCount:r.revisionCount,changed:r.changed}:r};function pe(e,o){let t=e.createElement("div");t.className="docx-revision-color-picker";let n=e.createElement("span");n.textContent=o.label,n.id=`${o.id}-label`;let r=e.createElement("button");r.type="button",r.className="docx-revision-color-trigger",r.setAttribute("aria-labelledby",`${n.id} ${o.id}-value`),r.setAttribute("aria-expanded","false"),r.setAttribute("aria-controls",`${o.id}-options`);let a=e.createElement("span");a.className="docx-revision-color-swatch",a.setAttribute("aria-hidden","true");let i=e.createElement("span");i.id=`${o.id}-value`,r.append(a,i);let s=e.createElement("div");s.id=`${o.id}-options`,s.className="docx-revision-color-options",s.hidden=true,s.setAttribute("role","group"),s.setAttribute("aria-labelledby",n.id);let d=new Map,c=u=>u==="auto"?"currentColor":u==="byAuthor"?"var(--doc-review-author-0)":u==="none"?"transparent":`var(--doc-revision-color-${u})`,m,g=()=>{m?.(),m=void 0,e.removeEventListener("pointerdown",x,true),s.hidden=true,r.setAttribute("aria-expanded","false");},x=u=>{t.contains(u.target)||g();};t.addEventListener("focusout",u=>{t.contains(u.relatedTarget)||g();});let N=e.createElement("div");N.className="docx-revision-color-special";let C=e.createElement("div");C.className="docx-toolbar__swatch-grid",s.append(N,C);for(let u of o.colors){let p=e.createElement("button");if(p.type="button",p.dataset.value=u,p.setAttribute("aria-label",o.translate(u)),p.title=o.translate(u),["auto","none","byAuthor"].includes(u)){p.className="docx-toolbar__swatch-clear";let f=e.createElement("span");f.className="docx-revision-color-swatch",f.style.backgroundColor=c(u),f.setAttribute("aria-hidden","true"),p.append(f,e.createTextNode(o.translate(u))),N.append(p);}else p.className="docx-toolbar__swatch",p.dataset.light="",p.style.backgroundColor=c(u),C.append(p);p.addEventListener("mousedown",f=>f.preventDefault()),p.addEventListener("click",()=>{o.change(u),g(),r.focus();}),d.set(u,p);}return r.addEventListener("click",()=>{let u=s.hidden;if(s.hidden=!u,r.setAttribute("aria-expanded",String(u)),!u){g();return}m=observeContentControlPopup(s,r),e.addEventListener("pointerdown",x,true),(Array.from(d.values()).find(p=>p.hasAttribute("data-selected"))??d.values().next().value)?.focus();}),s.addEventListener("keydown",u=>{u.key==="Escape"&&(u.preventDefault(),u.stopPropagation(),g(),r.focus());let p=Array.from(s.querySelectorAll("button")),f=p.indexOf(u.target),l=u.key==="Home"?0:u.key==="End"?p.length-1:["ArrowRight","ArrowDown"].includes(u.key)?(f+1)%p.length:["ArrowLeft","ArrowUp"].includes(u.key)?(f-1+p.length)%p.length:null;l!==null&&(u.preventDefault(),u.stopPropagation(),p[l]?.focus());}),t.append(n,r,s),{element:t,destroy:g,update(u,p){i.textContent=o.translate(u),a.style.backgroundColor=c(u),r.disabled=p;for(let[f,l]of d)l.setAttribute("aria-pressed",String(f===u)),l.toggleAttribute("data-selected",f===u),l.disabled=p;p&&g();}}}var W=["none","colorOnly","bold","italic","underline","doubleUnderline","strikethrough","doubleStrikethrough"],fe=[...W,"hidden","caret","pound"],B=0;function ge(e){let o=e.container.ownerDocument,t=null,n=e.get(),r=null,a=new Map,i=new Map,s=createT(en),d=f=>e.translate?.(`revisionMarkup.${f}`)??s(`revisionMarkup.${f}`),c=(f,l)=>{let y=o.createElement(f);return l!==void 0&&(y.textContent=l),y},m=()=>{t?.close(),t?.remove(),t=null,a.clear();for(let f of i.values())f.destroy();i.clear(),r?.isConnected&&r.focus({preventScroll:true}),r=null;},g=()=>{for(let[f,l]of a){let[y,v]=f.split("."),h=n[y];l.tagName==="INPUT"?l.checked=h:l.value=h[v],l.disabled=(y==="movedFrom"||y==="movedTo")&&!n.trackMoves;}for(let[f,l]of i){let[y,v]=f.split("."),h=n[y];l.update(h[v],(y==="movedFrom"||y==="movedTo")&&!n.trackMoves);}},x=f=>{e.set(f);},N=e.subscribe(()=>{n=e.get(),g();}),C=(f,l,y,v,h)=>{if(y==="color"||y==="background"||l==="cells"){let O=d(l==="cells"?`${y}Cells`:`${l}${y==="background"?"Background":"Color"}`),w=pe(o,{id:`docx-revision-color-${B++}`,label:O,colors:v,translate:E=>d(`values.${E}`),change:E=>x({[l]:{[y]:E}})});return i.set(`${l}.${y}`,w),f.append(w.element),w.element}let k=c("label"),I=c("span",d(l));I.className="docx-revision-markup-field-label",k.append(I);let b=c("select");for(let O of v){let w=c("option",d(`values.${O}`));w.value=O,b.append(w);}return b.value=h,b.addEventListener("change",()=>x({[l]:{[y]:b.value}})),k.append(b),f.append(k),a.set(`${l}.${y}`,b),k},u=(f,l,y)=>{let v=c("div");v.className="docx-revision-markup-row";let h=c("span",d(l));if(h.className="docx-revision-markup-row-title",h.setAttribute("aria-hidden","true"),v.append(h),C(v,l,"mark",y,n[l].mark),C(v,l,"color",["byAuthor","auto",...REVISION_MARKUP_COLORS],n[l].color),f.append(v),l!=="changedLines"){let k=c("div");k.className="docx-revision-markup-background",C(k,l,"background",["none","byAuthor",...REVISION_MARKUP_COLORS],n[l].background),f.append(k);}},p=(f,l)=>{let y=c("label"),v=c("input");v.type="checkbox",v.checked=n[l],v.addEventListener("change",()=>x({[l]:v.checked}));let h=c("p",d(`${l}Note`));h.id=`docx-revision-markup-note-${B++}`,v.setAttribute("aria-describedby",h.id),y.append(v,o.createTextNode(d(l))),f.append(y,h),a.set(l,v);};return {open(){if(e.signal.aborted)return;if(t){t.focus();return}n=e.get(),r=o.activeElement,t=c("dialog"),t.className="docx-revision-markup-dialog",t.contentEditable="false",t.setAttribute("data-docx-marker","");for(let w of ["keydown","mousedown","beforeinput"])t.addEventListener(w,E=>E.stopPropagation());let f=c("h2",d("title"));f.id=`docx-revision-markup-title-${B++}`,t.setAttribute("aria-labelledby",f.id),t.append(f),t.addEventListener("cancel",w=>{w.preventDefault(),e.cancel();});let l=c("div");l.className="docx-revision-markup-body",t.append(l);let y=w=>{let E=c("fieldset");return E.className=`docx-revision-markup-${w}`,E.append(c("legend",d(w))),l.append(E),E},v=y("markup");u(v,"insertions",W),u(v,"deletions",fe),u(v,"changedLines",["none","leftBorder","rightBorder","outsideBorder"]);let h=y("moves");p(h,"trackMoves"),u(h,"movedFrom",fe),u(h,"movedTo",W);let k=y("tableCells");for(let w of ["inserted","deleted","merged","split"])C(k,"cells",w,["byAuthor","none",...REVISION_MARKUP_COLORS],n.cells[w]);let I=y("formatting");p(I,"trackFormatting"),u(I,"formatting",W);let b=c("div");b.className="docx-revision-markup-actions";let O=(w,E)=>{let R=c("button",d(w));R.type="button",R.addEventListener("click",E),b.append(R);};O("reset",()=>e.reset()),O("cancel",()=>e.cancel()),O("ok",()=>{e.apply();}),t.append(b),e.container.append(t),g(),t.showModal(),t.querySelector("select")?.focus({preventScroll:true});},destroy(){N(),m();}}}var Ke=0;function ye(e){let o=e.container.ownerDocument,t=null,n=null,r=createT(en),a=c=>e.translate?.(c)??r(c),i=(c,m)=>{let g=a(`compareDocuments.${c}`);return m?g.replace(/\{(\w+)\}/g,(x,N)=>m[N]??x):g},s=(c,m)=>{let g=o.createElement(c);return m!==void 0&&(g.textContent=m),g},d=()=>{t?.close(),t?.remove(),t=null,n?.isConnected&&n.focus({preventScroll:true}),n=null;};return {open(){if(e.signal.aborted)return;if(t){t.focus();return}n=o.activeElement;let c=Ke++,m=false;t=s("dialog"),t.className="docx-compare-documents-dialog",t.contentEditable="false",t.setAttribute("data-docx-marker",""),t.tabIndex=-1;for(let S of ["keydown","mousedown","beforeinput"])t.addEventListener(S,P=>P.stopPropagation());t.addEventListener("cancel",S=>{S.preventDefault(),(!m||e.cancelable)&&e.cancel();});let g=s("h2",i("title"));g.id=`docx-compare-documents-title-${c}`,t.setAttribute("aria-labelledby",g.id);let x=s("p",i("description"));x.id=`docx-compare-documents-description-${c}`,t.setAttribute("aria-describedby",x.id);let N=s("p",i("trackedChangesAccepted"));N.id=`docx-compare-documents-tracked-${c}`,N.className="docx-compare-documents-tracked",e.originalHasTrackedChanges&&t.setAttribute("aria-describedby",`${x.id} ${N.id}`);let C=s("div");C.className="docx-compare-documents-body";let u=s("label"),p=s("input");p.type="file",p.accept=COMPARE_DOCUMENTS_ACCEPT,u.append(s("span",i("revisedFile")),p);let f=s("label"),l=s("input");l.type="text",l.value=e.defaultAuthor,l.autocomplete="off",f.append(s("span",i("author")),l);let y=s("label");y.className="docx-compare-documents-check";let v=s("input");v.type="checkbox",v.checked=true,y.append(v,o.createTextNode(i("detectFormatting"))),C.append(u,f,y);let h=s("p");h.className="docx-compare-documents-error",h.setAttribute("role","alert");let k=s("p");k.className="docx-compare-documents-notice",k.setAttribute("role","status");let I=()=>{h.textContent="",k.textContent="",R.textContent=i("cancel");},b=s("progress");b.className="docx-compare-documents-progress",b.max=1,b.hidden=true,b.setAttribute("aria-label",i("comparing"));let O=s("span");O.className="docx-compare-documents-phase",O.tabIndex=-1,O.hidden=true;let w=S=>{O.textContent=S,b.setAttribute("aria-valuetext",S);},E=s("div");E.className="docx-compare-documents-actions";let R=s("button",i("cancel"));R.type="button",R.addEventListener("click",()=>e.cancel());let D=s("button",i("compare"));D.type="button",E.append(R,D);let T=S=>{m=S;for(let P of [p,l,v])P.disabled=S;R.disabled=S&&!e.cancelable,b.hidden=!S,O.hidden=!S,S?w(i("comparing")):(b.removeAttribute("value"),b.removeAttribute("aria-valuetext"),O.textContent=""),D.disabled=S||!p.files?.length||!e.canApply(),D.textContent=i(S?"comparing":"compare"),b.setAttribute("aria-busy",String(S)),t?.toggleAttribute("data-docx-busy",S),S&&(R.disabled?O:R).focus({preventScroll:true});},q=S=>{let P=!S&&!D.disabled?D:p;(P.disabled?t??p:P).focus({preventScroll:true});};p.addEventListener("change",()=>{I(),T(false);}),D.addEventListener("click",async()=>{let S=p.files?.[0];if(!S){h.textContent=i("fileRequired");return}I(),T(true);let P;try{P=new Uint8Array(await S.arrayBuffer());}catch{e.signal.aborted||(h.textContent=i("readFailed"),T(false),q(true));return}if(e.signal.aborted)return;let U=await e.apply({revised:P,authorName:l.value,detectFormatChanges:v.checked},{onProgress:Y=>{b.value=Y.fraction,w(i(`phases.${Y.phase}`));}});e.signal.aborted||(U.ok?(k.textContent=i("noDifferences"),R.textContent=a("common.close")):h.textContent=a(compareDocumentsErrorKey(U)),T(false),q(!U.ok));}),t.append(g,x),e.originalHasTrackedChanges&&t.append(N),t.append(C,b,O,h,k,E),e.container.append(t),T(false),t.showModal(),p.focus({preventScroll:true});},destroy(){d();}}}function ve(e,o){let t=findNode(e,o);return !t||t.kind!=="paragraph"?[]:revisionItemsOf({id:e.id,name:e.name,contentType:e.contentType,root:t})}function qe(e,o,t,n){if(o.length===0)return [];let r=ue(e,o,{...t===void 0?{}:{payloads:t},...n===void 0?{}:{onDiagnostic:n}});if(r.length===0)return [];let a=locateSites(e),i=[];for(let s of r){let d=o.find(g=>g.name===s.name&&s.tag.startsWith(`${g.tagPrefix}:`));if(!d)continue;let c=d.reviewCard?d.reviewCard({attrs:s.attrs,text:s.text,...s.data===void 0?{}:{data:s.data}}):null;if(d.reviewCard&&c===null)continue;let m=a.get(s.nodeId);i.push({kind:"custom",id:s.nodeId,name:s.name,tag:s.tag,attrs:s.attrs,text:s.text,...s.data===void 0?{}:{data:s.data},carded:d.reviewCard!==void 0&&c!==null,title:c?.title??"",...c?.detail!==void 0?{detail:c.detail}:{},...c?.icon!==void 0?{icon:c.icon}:{},range:m?{partName:e.name,start:{paragraphId:m.paragraphId,offset:m.start},end:{paragraphId:m.paragraphId,offset:m.end}}:null});}return i}function ke(e){let o=collectReviewItems(e),t=(e.customNodes??[]).filter(ce);if(t.length===0)return o;let n=[e.storyPart],r=new Set([e.storyPart.name]);for(let d of e.furnitureParts??[])r.has(d.name)||(r.add(d.name),n.push(d));let a=[],i=new Map;for(let d of n){a.push(...qe(d,t,e.customNodePayloads,e.reportCustomNodeDiagnostic));let c=i.size;for(let[m,g]of paragraphOrderOfPart(d))i.has(m)||i.set(m,c+g);}return a.length===0?o:[...o,...a].sort((d,c)=>reviewItemPositionRank(d,i)-reviewItemPositionRank(c,i))}var Ye=3e4;function xe(e,o=Ye){return (t,n,r,{signal:a,onProgress:i})=>new Promise((s,d$1)=>{a.throwIfAborted();let c$1=e(),m=false,g,x=()=>{g!==void 0&&globalThis.clearTimeout(g),g=void 0;},N=()=>m?false:(m=true,x(),a.removeEventListener("abort",u),c$1.removeEventListener?.("message",p),c$1.removeEventListener?.("messageerror",f$1),c$1.removeEventListener?.("error",l),c$1.terminate(),true),C=(h,k)=>{N()&&d$1(new Error(h,k===void 0?void 0:{cause:k}));},u=()=>{N()&&d$1(a.reason);},p=h=>{let k=h.data;if(!(m||!d(k))){if(!f(k)){C("The compare worker sent a malformed message.");return}if(x(),k.type==="progress"){i({phase:k.phase,fraction:k.fraction});return}N()&&(k.type==="result"?s(k.result):d$1(new Error(`The compare worker failed: ${k.message}`)));}},f$1=()=>C("The compare worker sent a message that cannot be read."),l=h=>{let k=h.message;C(`The compare worker failed to run${k?`: ${k}`:""}.`);};a.addEventListener("abort",u,{once:true}),c$1.addEventListener("message",p),c$1.addEventListener("messageerror",f$1),c$1.addEventListener("error",l),g=globalThis.setTimeout(()=>C(`The compare worker did not start within ${Math.round(o/1e3)} seconds.`),o);let y=t.slice(),v=n.slice();try{c$1.postMessage({protocol:c,type:"compare",original:y,revised:v,options:{...r}},[y.buffer,v.buffer]);}catch(h){C("The compare worker could not receive the documents.",h);}})}function Ne(){if(typeof Worker>"u")throw new Error("Web workers are not available here.");return new Worker(new URL("./compare-worker.js",import.meta.url),{type:"module"})}function go(e={}){let o=e.pane===void 0?void 0:{...resolveReviewPane(e.pane)};a$1(e);let t=e.compareWorker;if(t!==void 0&&t!==false&&typeof t!="function")throw new TypeError("reviewModule: compareWorker must be false or a function that returns a Worker");let n=t===false?void 0:xe(t??Ne);return {id:"review",review:{compareDocuments:me,...n?{compareDocumentsInBackground:n}:{},createCompareDocumentsDialog:ye,createRevisionMarkupDialog:ge,displayModes:["all-markup","simple-markup","proposed","original"],collectReviewItems:ke,revisionItemsOfParagraph:ve,...o?{pane:o}:{}}}}function Se(e){return e.surface??null}function G(e,o){if(o==null)return null;let t=ie(e,o);return t.ok?{ok:true,serialized:t.data,value:t.value}:{ok:false,reason:t.reason,issues:t.issues}}function J(e,o,t,n,r){let a=_(o),i=e.session.part().name;return {namespaceUri:a,rootLocalName:ae,nodeId:r??se(e.session.currentPackage(),i,a),label:n,data:t}}function H(e){let o=e.detail?`${e.reason}: ${e.detail}`:e.reason;return {ok:false,code:tt.has(e.reason)?"invalidArgs":"unsupported",reason:o}}var tt=new Set(["payload-too-large","unaddressable-payload","store-not-authored","offset-out-of-range","invalid-range","invalid-property-value","splits-surrogate-pair"]);function X(e,o,t){let n,r;if(t!==void 0)try{n=e.text?.(t),r=e.tagAttrs?.(t);}catch(i){return {reason:`${e.name} could not describe this payload: ${i instanceof Error?i.message:String(i)}`}}let a=o.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`}:o.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:o.attrs??r??{},text:a}}function V(e){return e.getEditingMode()==="viewing"?{ok:false,code:"locked",reason:"the document is open for viewing"}:null}function Ce(e){let o=e.getActiveScope();if(o.kind==="headerFooter")return {kind:"headerFooter",rId:o.rId};if(o.kind==="note"){let t=parseNoteScopeId(o.id);if(t)return {kind:"notesPart",noteKind:t.noteKind}}return {kind:"body"}}function F(e,o){let t=Se(e),n=o===void 0?-1:o.indexOf("#"),r=o===void 0?"":n===-1?t?.session.storyParts().find(a=>findNode(a,o)!==null)?.name??"":o.slice(0,n);if(!t||r.length===0)return Ce(e);if(r===t.session.part().name)return {kind:"body"};for(let a of t.session.headerFooterResolutionBySection())for(let i of [a.headers,a.footers])for(let s of i.values())if(s.partName===r)return {kind:"headerFooter",rId:s.rId};for(let a of ["footnote","endnote"])if(t.session.partFor({kind:"notesPart",noteKind:a})?.name===r)return {kind:"notesPart",noteKind:a};return Ce(e)}function ot(e){let o=e.author()?.trim();return e.editingMode()!=="suggest"||!o?null:{author:o,date:`${new Date().toISOString().slice(0,19)}Z`}}function No(e,o,t={}){let n=Se(e);if(!n)return {ok:false,code:"notFound",reason:"no document is mounted"};let r=G(o,t.data);if(r&&!r.ok)return $(r.reason,r.issues);let a=X(o,t,r?.value);if("reason"in a)return {ok:false,code:"invalidArgs",reason:a.reason};let i=A(o.tagPrefix,o.name,a.attrs);if(!i.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${i.length} characters; Word caps w:tag at 64 \u2014 move what does not fit into the payload (\`data\`), or shorten the attrs`};let s=V(e);if(s)return s;n.flushPendingInput();let d=t.at??n.state().selection.head,c=t.lock===void 0?"contentLocked":t.lock,m=F(e,d.paragraphId),g=ot(n),x=n.session.insertCustomNode({paragraphId:d.paragraphId,offset:d.offset,tag:i.tag,text:a.text,...t.alias===void 0?{}:{alias:t.alias},...c===false?{}:{lock:c},...r?{payload:J(n,o,r.serialized,a.text)}:{},...g?{revision:g}:{}},m);return x.ok?{ok:true,changed:true,...x.nodeId===void 0?{}:{nodeId:x.nodeId}}:H(x)}function be(e){return e.surface??null}function dt(e,o){let t=null,n=a=>a.id===o?true:a.kind==="textValue"?false:a.children.some(n),r=(a,i)=>{if(!(t||a.kind==="textValue"||i>64)){if(a.kind==="paragraph"){n(a)&&(t=a);return}for(let s of a.children)r(s,i+1);}};return r(e.root,0),t}function ct(e,o){let t=new Set,n=d=>{if(t.add(d.id),d.kind!=="textValue")for(let c of d.children)n(c);},r=d=>{if(d.id===o)return d;if(d.kind==="textValue")return null;for(let c of d.children){let m=r(c);if(m)return m}return null},a=r(e);if(!a)return null;n(a);let i=Number.MAX_SAFE_INTEGER,s=-1;for(let d of segmentsOf(e))t.has(d.runId)&&(d.start<i&&(i=d.start),d.end>s&&(s=d.end));return s<0?null:{start:i,end:s}}function Po(e,o){let t=be(e);if(!t)return {ok:false,code:"notFound",reason:"no document is mounted"};let n=V(e);if(n)return n;t.flushPendingInput();let r=t.session.removeCustomNode(o,F(e,o));return r.ok?{ok:true,changed:true}:H(r)}function Io(e,o,t,n={}){let r=be(e);if(!r)return {ok:false,code:"notFound",reason:"no document is mounted"};let a=V(e);if(a)return a;r.flushPendingInput();let i=F(e,t),s=r.session.partFor(i)??r.session.part(),d=dt(s,t),c=d?ct(d,t):null,m=lt(r,t,i);if(!d||!c||!m)return {ok:false,code:"notFound",reason:"no custom node with that id"};let g=`${o.tagPrefix}:${o.name}`;if(m.identity!==null&&m.identity!==g)return {ok:false,code:"invalidArgs",reason:`node ${t} is a ${m.identity}, not a ${g}`};let x=mt(r,t,i),N=n.data===null?null:n.data===void 0?ut(x):G(o,n.data);if(N&&!N.ok)return $(N.reason,N.issues);let C=X(o,{attrs:n.attrs??(n.data===void 0?m.attrs:void 0),text:n.text??(N===null&&n.data===null?m.text:void 0)},N?.value);if("reason"in C)return {ok:false,code:"invalidArgs",reason:C.reason};let u=A(o.tagPrefix,o.name,C.attrs);if(!u.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${u.length} characters; Word caps w:tag at 64 \u2014 move what does not fit into the payload (\`data\`), or shorten the attrs`};let p=n.alias??m.alias,f=n.lock??m.lock,l=r.session.insertCustomNode({replaceControlId:t,paragraphId:d.id,offset:c.start,tag:u.tag,text:C.text,...p===void 0?{}:{alias:p},...f===false||f===void 0?{}:{lock:f},...N?{payload:J(r,o,N.serialized,C.text,x?.nodeId)}:{}},i);return l.ok?{ok:true,changed:true,...l.nodeId===void 0?{}:{nodeId:l.nodeId}}:H(l)}function lt(e,o,t){let n=e.session.partFor(t)??e.session.part(),r=contentControlsIn(n.root).find(d=>d.node.id===o);if(!r)return null;let a=contentControlPropertiesOf(r.node),i=a.tag===void 0?null:M(a.tag),s=a.lock;return {identity:i?`${i.prefix}:${i.name}`:null,attrs:i?.attrs??{},text:contentControlTextOf(r.node),alias:a.alias,lock:s==="sdtLocked"||s==="sdtContentLocked"||s==="contentLocked"?s:s==="unlocked"?false:void 0}}function ut(e){if(!e)return null;let o=L(void 0,e.data);return o.ok?{ok:true,serialized:e.data,value:o.value}:{ok:false,reason:`the stored payload is not readable: ${o.issues.join(", ")}`,issues:[]}}function mt(e,o,t){let n=e.session.partFor(t)??e.session.part();return customNodePayloadsByControl(e.session.currentPackage(),n.name,e.session.part().name).get(o)}export{pt as a,A as b,M as c,gt as d,L as e,K as f,ae as g,_ as h,ie as i,ce as j,de as k,Et as l,Rt as m,ue as n,go as o,No as p,Po as q,Io as r};
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
import * as Y from 'yjs';
|
|
9
9
|
import { HocuspocusProvider } from '@hocuspocus/provider';
|
|
10
10
|
import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
|
|
11
|
-
import { D as DocumentCollaborationHandle } from '../document-session-
|
|
12
|
-
import {
|
|
11
|
+
import { D as DocumentCollaborationHandle } from '../document-session-C6Zli8mp.cjs';
|
|
12
|
+
import { C as CollaborationBootstrap } from '../types-gCdUeE3e.cjs';
|
|
13
13
|
export { c as createCollaborationRoomId, v as validateRoomId } from '../room-id-BfudXOZz.cjs';
|
|
14
|
-
import '../document-session-options-
|
|
14
|
+
import '../document-session-options-CuEO7l9P.cjs';
|
|
15
15
|
import 'y-protocols/awareness';
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
import * as Y from 'yjs';
|
|
9
9
|
import { HocuspocusProvider } from '@hocuspocus/provider';
|
|
10
10
|
import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
|
|
11
|
-
import { D as DocumentCollaborationHandle } from '../document-session-
|
|
12
|
-
import {
|
|
11
|
+
import { D as DocumentCollaborationHandle } from '../document-session-CRhyVeWE.js';
|
|
12
|
+
import { C as CollaborationBootstrap } from '../types-gCdUeE3e.js';
|
|
13
13
|
export { c as createCollaborationRoomId, v as validateRoomId } from '../room-id-BfudXOZz.js';
|
|
14
|
-
import '../document-session-options-
|
|
14
|
+
import '../document-session-options-hwq_FdnS.js';
|
|
15
15
|
import 'y-protocols/awareness';
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
11
11
|
export { C as CollaborationModuleOptions, c as collaborationModule } from '../collaboration-module-02CIP5sN.cjs';
|
|
12
|
-
export {
|
|
13
|
-
export { C as CollaborationResourceLimit, a as CollaborationResourcePressure, b as CollaborationResourcePressureOptions, c as CollaborationResourceUsage, d as CollaborationUndoGroup, e as CollaborationUndoGroupError, f as CollaborationUndoGroupErrorCode, D as DocumentCollaborationHandle, g as DocumentCollaborationSession, h as createDocumentCollaboration, r as readCollaborationResourceUsage } from '../document-session-
|
|
12
|
+
export { C as CollaborationBootstrap, c as CollaborationHandle, b as CollaborationIdentityUpdate, a as CollaborationSession } from '../types-gCdUeE3e.cjs';
|
|
13
|
+
export { C as CollaborationResourceLimit, a as CollaborationResourcePressure, b as CollaborationResourcePressureOptions, c as CollaborationResourceUsage, d as CollaborationUndoGroup, e as CollaborationUndoGroupError, f as CollaborationUndoGroupErrorCode, D as DocumentCollaborationHandle, g as DocumentCollaborationSession, h as createDocumentCollaboration, r as readCollaborationResourceUsage } from '../document-session-C6Zli8mp.cjs';
|
|
14
14
|
import * as Y from 'yjs';
|
|
15
15
|
import { CollaborationFailureCode, EditorCollaborationSession } from '@docx-editor.dev/core/collaboration';
|
|
16
|
-
export { C as CreateDocumentCollaborationOptions } from '../document-session-options-
|
|
16
|
+
export { C as CreateDocumentCollaborationOptions } from '../document-session-options-CuEO7l9P.cjs';
|
|
17
17
|
import '@docx-editor.dev/core/editor';
|
|
18
18
|
import '../license-D-ds5Y7c.cjs';
|
|
19
19
|
import 'y-protocols/awareness';
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
11
11
|
export { C as CollaborationModuleOptions, c as collaborationModule } from '../collaboration-module-COZAgqwg.js';
|
|
12
|
-
export {
|
|
13
|
-
export { C as CollaborationResourceLimit, a as CollaborationResourcePressure, b as CollaborationResourcePressureOptions, c as CollaborationResourceUsage, d as CollaborationUndoGroup, e as CollaborationUndoGroupError, f as CollaborationUndoGroupErrorCode, D as DocumentCollaborationHandle, g as DocumentCollaborationSession, h as createDocumentCollaboration, r as readCollaborationResourceUsage } from '../document-session-
|
|
12
|
+
export { C as CollaborationBootstrap, c as CollaborationHandle, b as CollaborationIdentityUpdate, a as CollaborationSession } from '../types-gCdUeE3e.js';
|
|
13
|
+
export { C as CollaborationResourceLimit, a as CollaborationResourcePressure, b as CollaborationResourcePressureOptions, c as CollaborationResourceUsage, d as CollaborationUndoGroup, e as CollaborationUndoGroupError, f as CollaborationUndoGroupErrorCode, D as DocumentCollaborationHandle, g as DocumentCollaborationSession, h as createDocumentCollaboration, r as readCollaborationResourceUsage } from '../document-session-CRhyVeWE.js';
|
|
14
14
|
import * as Y from 'yjs';
|
|
15
15
|
import { CollaborationFailureCode, EditorCollaborationSession } from '@docx-editor.dev/core/collaboration';
|
|
16
|
-
export { C as CreateDocumentCollaborationOptions } from '../document-session-options-
|
|
16
|
+
export { C as CreateDocumentCollaborationOptions } from '../document-session-options-hwq_FdnS.js';
|
|
17
17
|
import '@docx-editor.dev/core/editor';
|
|
18
18
|
import '../license-D-ds5Y7c.js';
|
|
19
19
|
import 'y-protocols/awareness';
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
import * as Y from 'yjs';
|
|
9
9
|
import { WebrtcProvider } from 'y-webrtc';
|
|
10
10
|
import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
|
|
11
|
-
import { D as DocumentCollaborationHandle } from '../document-session-
|
|
12
|
-
import {
|
|
11
|
+
import { D as DocumentCollaborationHandle } from '../document-session-C6Zli8mp.cjs';
|
|
12
|
+
import { C as CollaborationBootstrap } from '../types-gCdUeE3e.cjs';
|
|
13
13
|
export { c as createCollaborationRoomId, v as validateRoomId } from '../room-id-BfudXOZz.cjs';
|
|
14
|
-
import '../document-session-options-
|
|
14
|
+
import '../document-session-options-CuEO7l9P.cjs';
|
|
15
15
|
import 'y-protocols/awareness';
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
import * as Y from 'yjs';
|
|
9
9
|
import { WebrtcProvider } from 'y-webrtc';
|
|
10
10
|
import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
|
|
11
|
-
import { D as DocumentCollaborationHandle } from '../document-session-
|
|
12
|
-
import {
|
|
11
|
+
import { D as DocumentCollaborationHandle } from '../document-session-CRhyVeWE.js';
|
|
12
|
+
import { C as CollaborationBootstrap } from '../types-gCdUeE3e.js';
|
|
13
13
|
export { c as createCollaborationRoomId, v as validateRoomId } from '../room-id-BfudXOZz.js';
|
|
14
|
-
import '../document-session-options-
|
|
14
|
+
import '../document-session-options-hwq_FdnS.js';
|
|
15
15
|
import 'y-protocols/awareness';
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkVJOGWUUQ_cjs=require('./chunk-VJOGWUUQ.cjs'),store=require('@docx-editor.dev/core/store');var t=globalThis;function u(o){let e=store.readOoxmlPackage(o.original);if(!e.ok)return n({ok:false,code:"invalidOriginal",message:`The original document cannot be read (${e.reason}).`});let s=store.readOoxmlPackage(o.revised);if(!s.ok)return n({ok:false,code:"invalidRevised",message:`The revised document cannot be read (${s.reason}).`});let r=chunkVJOGWUUQ_cjs.b(e.package,s.package,o.options,false,(l,m)=>t.postMessage({protocol:chunkVJOGWUUQ_cjs.c,type:"progress",phase:l,fraction:m}));return r.ok?n({ok:true,bytes:r.changed?r.bytes:null,revisionCount:r.revisionCount,changed:r.changed}):n(r)}var n=o=>({protocol:chunkVJOGWUUQ_cjs.c,type:"result",result:o});t.onmessage=o=>{if(!chunkVJOGWUUQ_cjs.d(o.data))return;if(!chunkVJOGWUUQ_cjs.e(o.data)){t.postMessage({protocol:chunkVJOGWUUQ_cjs.c,type:"error",message:"The compare request is malformed."});return}t.postMessage({protocol:chunkVJOGWUUQ_cjs.c,type:"progress",phase:"reading",fraction:0});let e;try{e=u(o.data);}catch(r){e={protocol:chunkVJOGWUUQ_cjs.c,type:"error",message:r instanceof Error?r.message:String(r)};}let s=e.type==="result"&&e.result.ok?e.result.bytes:null;t.postMessage(e,s?[s.buffer]:[]);};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The compare worker: `@docx-editor.dev/pro/compare-worker`. Start it as a module worker and
|
|
3
|
+
* pass it to `reviewModule({ compareWorker })`. It runs the compare that the Compare documents
|
|
4
|
+
* dialog asks for, off the page's main thread. It has no exports.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The compare worker: `@docx-editor.dev/pro/compare-worker`. Start it as a module worker and
|
|
3
|
+
* pass it to `reviewModule({ compareWorker })`. It runs the compare that the Compare documents
|
|
4
|
+
* dialog asks for, off the page's main thread. It has no exports.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {d,e,c,b}from'./chunk-B4OWKZIG.js';import {readOoxmlPackage}from'@docx-editor.dev/core/store';var t=globalThis;function u(o){let e=readOoxmlPackage(o.original);if(!e.ok)return n({ok:false,code:"invalidOriginal",message:`The original document cannot be read (${e.reason}).`});let s=readOoxmlPackage(o.revised);if(!s.ok)return n({ok:false,code:"invalidRevised",message:`The revised document cannot be read (${s.reason}).`});let r=b(e.package,s.package,o.options,false,(l,m)=>t.postMessage({protocol:c,type:"progress",phase:l,fraction:m}));return r.ok?n({ok:true,bytes:r.changed?r.bytes:null,revisionCount:r.revisionCount,changed:r.changed}):n(r)}var n=o=>({protocol:c,type:"result",result:o});t.onmessage=o=>{if(!d(o.data))return;if(!e(o.data)){t.postMessage({protocol:c,type:"error",message:"The compare request is malformed."});return}t.postMessage({protocol:c,type:"progress",phase:"reading",fraction:0});let e$1;try{e$1=u(o.data);}catch(r){e$1={protocol:c,type:"error",message:r instanceof Error?r.message:String(r)};}let s=e$1.type==="result"&&e$1.result.ok?e$1.result.bytes:null;t.postMessage(e$1,s?[s.buffer]:[]);};
|
|
@@ -28,6 +28,23 @@ interface ReviewModuleOptions extends ProLicenseOptions {
|
|
|
28
28
|
* value throws a `TypeError`.
|
|
29
29
|
*/
|
|
30
30
|
readonly pane?: ReviewPaneOptions;
|
|
31
|
+
/**
|
|
32
|
+
* The worker that runs the Compare documents dialog's compares off the page's main thread,
|
|
33
|
+
* so the page stays responsive, the dialog shows progress, and Cancel stops a running
|
|
34
|
+
* compare. By default, the editor starts the packaged worker,
|
|
35
|
+
* `@docx-editor.dev/pro/compare-worker`, one for each compare.
|
|
36
|
+
*
|
|
37
|
+
* Pass `false` to compare on the main thread. Pass a function that starts the worker if your
|
|
38
|
+
* bundler cannot find the packaged one. If a worker fails to start, the dialog compares on
|
|
39
|
+
* the main thread instead, and that compare cannot be stopped.
|
|
40
|
+
*
|
|
41
|
+
* @example A Vite worker import
|
|
42
|
+
* ```ts
|
|
43
|
+
* import CompareWorker from '@docx-editor.dev/pro/compare-worker?worker';
|
|
44
|
+
* reviewModule({ compareWorker: () => new CompareWorker() });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
readonly compareWorker?: (() => Worker) | false;
|
|
31
48
|
}
|
|
32
49
|
/**
|
|
33
50
|
* Build the review module. Construction never validates the key and never touches the network.
|
|
@@ -28,6 +28,23 @@ interface ReviewModuleOptions extends ProLicenseOptions {
|
|
|
28
28
|
* value throws a `TypeError`.
|
|
29
29
|
*/
|
|
30
30
|
readonly pane?: ReviewPaneOptions;
|
|
31
|
+
/**
|
|
32
|
+
* The worker that runs the Compare documents dialog's compares off the page's main thread,
|
|
33
|
+
* so the page stays responsive, the dialog shows progress, and Cancel stops a running
|
|
34
|
+
* compare. By default, the editor starts the packaged worker,
|
|
35
|
+
* `@docx-editor.dev/pro/compare-worker`, one for each compare.
|
|
36
|
+
*
|
|
37
|
+
* Pass `false` to compare on the main thread. Pass a function that starts the worker if your
|
|
38
|
+
* bundler cannot find the packaged one. If a worker fails to start, the dialog compares on
|
|
39
|
+
* the main thread instead, and that compare cannot be stopped.
|
|
40
|
+
*
|
|
41
|
+
* @example A Vite worker import
|
|
42
|
+
* ```ts
|
|
43
|
+
* import CompareWorker from '@docx-editor.dev/pro/compare-worker?worker';
|
|
44
|
+
* reviewModule({ compareWorker: () => new CompareWorker() });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
readonly compareWorker?: (() => Worker) | false;
|
|
31
48
|
}
|
|
32
49
|
/**
|
|
33
50
|
* Build the review module. Construction never validates the key and never touches the network.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { b as CollaborationIdentityUpdate, c as CollaborationHandle } from './types-
|
|
1
|
+
import { b as CollaborationIdentityUpdate, c as CollaborationHandle } from './types-gCdUeE3e.cjs';
|
|
2
2
|
import { EditorCollaborationSession, CollaborationFailureCode } from '@docx-editor.dev/core/collaboration';
|
|
3
3
|
import * as Y from 'yjs';
|
|
4
|
-
import { C as CreateDocumentCollaborationOptions } from './document-session-options-
|
|
4
|
+
import { C as CreateDocumentCollaborationOptions } from './document-session-options-CuEO7l9P.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Room-size observability.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { b as CollaborationIdentityUpdate, c as CollaborationHandle } from './types-
|
|
1
|
+
import { b as CollaborationIdentityUpdate, c as CollaborationHandle } from './types-gCdUeE3e.js';
|
|
2
2
|
import { EditorCollaborationSession, CollaborationFailureCode } from '@docx-editor.dev/core/collaboration';
|
|
3
3
|
import * as Y from 'yjs';
|
|
4
|
-
import { C as CreateDocumentCollaborationOptions } from './document-session-options-
|
|
4
|
+
import { C as CreateDocumentCollaborationOptions } from './document-session-options-hwq_FdnS.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Room-size observability.
|
package/dist/{document-session-options-CxR0F5xT.d.cts → document-session-options-CuEO7l9P.d.cts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Y from 'yjs';
|
|
2
2
|
import { Awareness } from 'y-protocols/awareness';
|
|
3
3
|
import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
|
|
4
|
-
import {
|
|
4
|
+
import { C as CollaborationBootstrap } from './types-gCdUeE3e.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Options for one full-document collaboration replica.
|
package/dist/{document-session-options-CdOH-TNn.d.ts → document-session-options-hwq_FdnS.d.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Y from 'yjs';
|
|
2
2
|
import { Awareness } from 'y-protocols/awareness';
|
|
3
3
|
import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
|
|
4
|
-
import {
|
|
4
|
+
import { C as CollaborationBootstrap } from './types-gCdUeE3e.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Options for one full-document collaboration replica.
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkOYR3V4F4_cjs=require('./chunk-OYR3V4F4.cjs'),chunkVJOGWUUQ_cjs=require('./chunk-VJOGWUUQ.cjs'),chunkQEULTKCT_cjs=require('./chunk-QEULTKCT.cjs');require('./chunk-ZZ33FL6V.cjs'),require('./chunk-IULA3QRZ.cjs');var store=require('@docx-editor.dev/core/store');function L(t,n={}){let r=F(t);if(!r)return [];let o=n.nodes??t.getCustomNodeDefinitions().filter(chunkOYR3V4F4_cjs.j);if(o.length===0)return [];let s=r.session.currentPackage(),d=r.session.part().name,m=n.onDiagnostic??(e=>{t.reportCustomNodeDiagnostic(e);});return r.session.storyParts().flatMap(e=>chunkOYR3V4F4_cjs.n(e,o,{payloads:store.customNodePayloadsByControl(s,e.name,d),onDiagnostic:m}))}function F(t){return t.surface??null}function E(t,n,r={}){if(r.destination==="internal")return {ok:true,bytes:t,unwrapped:0,removed:0};let o=store.readOoxmlPackage(t);if(!o.ok)return {ok:false,reason:`the document could not be read: ${o.reason}`};let s=new Map;for(let i of n)s.set(`${i.tagPrefix}:${i.name}`,i);let d=i=>{let p=chunkOYR3V4F4_cjs.c(i);if(!p)return "keep";let x=s.get(`${p.prefix}:${p.name}`);return x?x.preserveOnExport==="text"?"text":x.preserveOnExport===false?"remove":"keep":"keep"},m=[...new Set(n.filter(i=>i.preserveOnExport!==void 0).filter(i=>i.preserveOnExport!==true).map(chunkOYR3V4F4_cjs.h))],e=o.package,u=0,c=0,N=G(e);for(let i of N){let p=store.withExportedCustomNodes(e,{storyPartName:i,namespaces:[],decide:d});if(!p.ok)return {ok:false,reason:p.reason};e=p.pkg,u+=p.unwrapped,c+=p.removed;}let l=store.withExportedCustomNodes(e,{storyPartName:e.mainDocumentPart,namespaces:m,decide:()=>"keep"});return l.ok?(e=l.pkg,{ok:true,bytes:store.writeOoxmlPackage(e),unwrapped:u,removed:c}):{ok:false,reason:l.reason}}function G(t){let n=[];for(let[r,o]of t.parts)r!==t.mainDocumentPart&&store.isStoryPart(o)&&n.push(r);return [t.mainDocumentPart,...n]}async function H(t,n={}){let r=n.nodes??t.getCustomNodeDefinitions().filter(chunkOYR3V4F4_cjs.j),o=await t.save();return E(new Uint8Array(o),r,{...n.destination===void 0?{}:{destination:n.destination}})}function a(t){return t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Q(t,n,r,o={}){if(!chunkOYR3V4F4_cjs.k.test(t.tagPrefix)||!chunkOYR3V4F4_cjs.k.test(t.name))return {ok:false,code:"invalidArgs",reason:"the definition identity must match defineCustomNode\u2019s charset ([A-Za-z0-9_.-])"};let s=chunkOYR3V4F4_cjs.b(t.tagPrefix,t.name,n);if(!s.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${s.length} characters; Word caps w:tag at 64 \u2014 shorten the attrs`};let d=o.lock===void 0?"contentLocked":o.lock,m=o.id!==void 0&&Number.isInteger(o.id)&&o.id>0?o.id:store.fnv1a32(`${s.tag}\0${r}`)&2147483647||1,e=o.data===void 0?null:ee(t,o,r);if(e&&"reason"in e)return {ok:false,code:"invalidArgs",reason:e.reason};let u=(o.alias!==void 0?`<w:alias w:val="${a(o.alias)}"/>`:"")+`<w:tag w:val="${a(s.tag)}"/><w:id w:val="${m}"/>`+(d===false?"":`<w:lock w:val="${d}"/>`)+(e?`<w:dataBinding w:prefixMappings="${a(e.binding.prefixMappings)}" w:xpath="${a(e.binding.xpath)}" w:storeItemID="${a(e.binding.storeItemId)}"/>`:""),c=`<w:r><w:t xml:space="preserve">${a(r)}</w:t></w:r>`;return {ok:true,xml:`<w:sdt><w:sdtPr>${u}</w:sdtPr><w:sdtContent>${c}</w:sdtContent></w:sdt>`,...e?{store:e.store}:{}}}function ee(t,n,r){let o=chunkOYR3V4F4_cjs.i(t,n.data);if(!o.ok)return {reason:o.reason};let s=chunkOYR3V4F4_cjs.h(t),d=n.storeIndex!==void 0&&Number.isInteger(n.storeIndex)&&n.storeIndex>0?n.storeIndex:1,m=n.nodeId??"cx1",e=`/customXml/item${String(d)}.xml`,u=`/customXml/itemProps${String(d)}.xml`,c=store.datastoreItemIdFor(`${s} ${e} ${m}`),N=store.customNodeBinding({partName:e,propsPartName:u,itemId:c,namespaceUri:s},chunkOYR3V4F4_cjs.g,m);if(!N)return {reason:`the payload cannot be addressed by an XPath: check nodeId (${m}) and payloadNamespace`};let l=r===r.trim()?`<label>${a(r)}</label>`:`<label xml:space="preserve">${a(r)}</label>`;return {binding:N,store:{itemPartName:e,itemXml:`<${chunkOYR3V4F4_cjs.g} xmlns="${a(s)}"><node id="${a(m)}">${l}<data>${a(o.data)}</data></node></${chunkOYR3V4F4_cjs.g}>`,propsPartName:u,propsXml:`<ds:datastoreItem ds:itemID="${a(c)}" xmlns:ds="${store.DATASTORE_NAMESPACE_URI}"><ds:schemaRefs><ds:schemaRef ds:uri="${a(s)}"/></ds:schemaRefs></ds:datastoreItem>`,storeItemId:c,relationships:[{from:"/word/document.xml",type:store.CUSTOM_XML_REL,target:`../customXml/item${String(d)}.xml`},{from:e,type:store.CUSTOM_XML_PROPS_REL,target:`itemProps${String(d)}.xml`}],contentTypeOverride:{partName:u,contentType:store.CUSTOM_XML_PROPS_TYPE}}}}Object.defineProperty(exports,"CUSTOM_NODE_STORE_ROOT",{enumerable:true,get:function(){return chunkOYR3V4F4_cjs.g}});Object.defineProperty(exports,"MAX_CUSTOM_NODE_DATA_LENGTH",{enumerable:true,get:function(){return chunkOYR3V4F4_cjs.d}});Object.defineProperty(exports,"MAX_TAG_LENGTH",{enumerable:true,get:function(){return chunkOYR3V4F4_cjs.a}});Object.defineProperty(exports,"customNodeNamespace",{enumerable:true,get:function(){return chunkOYR3V4F4_cjs.h}});Object.defineProperty(exports,"customNodesModule",{enumerable:true,get:function(){return chunkOYR3V4F4_cjs.m}});Object.defineProperty(exports,"decodeCustomNodeTag",{enumerable:true,get:function(){return chunkOYR3V4F4_cjs.c}});Object.defineProperty(exports,"defineCustomNode",{enumerable:true,get:function(){return chunkOYR3V4F4_cjs.l}});Object.defineProperty(exports,"encodeCustomNodeTag",{enumerable:true,get:function(){return chunkOYR3V4F4_cjs.b}});Object.defineProperty(exports,"insertCustomNode",{enumerable:true,get:function(){return chunkOYR3V4F4_cjs.p}});Object.defineProperty(exports,"isCustomNodeDefinition",{enumerable:true,get:function(){return chunkOYR3V4F4_cjs.j}});Object.defineProperty(exports,"parseCustomNodeData",{enumerable:true,get:function(){return chunkOYR3V4F4_cjs.e}});Object.defineProperty(exports,"recognizeCustomNodes",{enumerable:true,get:function(){return chunkOYR3V4F4_cjs.n}});Object.defineProperty(exports,"removeCustomNode",{enumerable:true,get:function(){return chunkOYR3V4F4_cjs.q}});Object.defineProperty(exports,"reviewModule",{enumerable:true,get:function(){return chunkOYR3V4F4_cjs.o}});Object.defineProperty(exports,"serializeCustomNodeData",{enumerable:true,get:function(){return chunkOYR3V4F4_cjs.f}});Object.defineProperty(exports,"updateCustomNode",{enumerable:true,get:function(){return chunkOYR3V4F4_cjs.r}});Object.defineProperty(exports,"compareDocuments",{enumerable:true,get:function(){return chunkVJOGWUUQ_cjs.a}});Object.defineProperty(exports,"collaborationModule",{enumerable:true,get:function(){return chunkQEULTKCT_cjs.a}});exports.customNodeXml=Q;exports.customNodesOf=L;exports.prepareForExport=E;exports.saveForExport=H;
|
package/dist/index.d.cts
CHANGED
|
@@ -23,15 +23,99 @@
|
|
|
23
23
|
* @packageDocumentation
|
|
24
24
|
* @public
|
|
25
25
|
*/
|
|
26
|
-
import { A as AnyCustomNodeDefinition, C as CustomNodeDiagnostic, R as RecognizedCustomNode, S as StandardSchemaV1, I as InferSchemaInput, a as CustomNodeDefinition } from './define-custom-node-
|
|
27
|
-
export { b as ActivatedCustomNode, c as CustomNode, d as CustomNodeDataRejection, e as CustomNodeDataResult, f as CustomNodePayloadSource, g as CustomNodesModuleOptions, h as InferSchemaOutput, M as MAX_CUSTOM_NODE_DATA_LENGTH, i as RecognizeCustomNodesOptions, j as ReviewModuleOptions, k as StandardSchemaIssue, l as StandardSchemaResult, m as customNodesModule, n as defineCustomNode, o as isCustomNodeDefinition, p as parseCustomNodeData, r as recognizeCustomNodes, q as reviewModule, s as serializeCustomNodeData } from './define-custom-node-
|
|
26
|
+
import { A as AnyCustomNodeDefinition, C as CustomNodeDiagnostic, R as RecognizedCustomNode, S as StandardSchemaV1, I as InferSchemaInput, a as CustomNodeDefinition } from './define-custom-node-CvRKwTqE.cjs';
|
|
27
|
+
export { b as ActivatedCustomNode, c as CustomNode, d as CustomNodeDataRejection, e as CustomNodeDataResult, f as CustomNodePayloadSource, g as CustomNodesModuleOptions, h as InferSchemaOutput, M as MAX_CUSTOM_NODE_DATA_LENGTH, i as RecognizeCustomNodesOptions, j as ReviewModuleOptions, k as StandardSchemaIssue, l as StandardSchemaResult, m as customNodesModule, n as defineCustomNode, o as isCustomNodeDefinition, p as parseCustomNodeData, r as recognizeCustomNodes, q as reviewModule, s as serializeCustomNodeData } from './define-custom-node-CvRKwTqE.cjs';
|
|
28
|
+
import { CompareDocumentsEngineErrorCode, CompareDocumentsRefusalReason } from '@docx-editor.dev/core/editor';
|
|
29
|
+
export { CommentMarkerStyle, CompareDocumentsEngineErrorCode, CompareDocumentsErrorCode, CompareDocumentsRefusalReason, ResolvedReviewPane, ReviewPaneOpening, ReviewPaneOptions, ReviewPaneOverflow, RevisionDisplay } from '@docx-editor.dev/core/editor';
|
|
28
30
|
export { C as CollaborationModuleOptions, c as collaborationModule } from './collaboration-module-02CIP5sN.cjs';
|
|
29
31
|
export { P as ProLicenseOptions } from './license-D-ds5Y7c.cjs';
|
|
30
32
|
import { Editor, ExecResult } from '@docx-editor.dev/core/contracts/editor';
|
|
31
|
-
export { CommentMarkerStyle, ResolvedReviewPane, ReviewPaneOpening, ReviewPaneOptions, ReviewPaneOverflow, RevisionDisplay } from '@docx-editor.dev/core/editor';
|
|
32
33
|
import '@docx-editor.dev/core/store';
|
|
33
34
|
import '@docx-editor.dev/core/collaboration';
|
|
34
35
|
|
|
36
|
+
/** Public types of the document compare engine. */
|
|
37
|
+
|
|
38
|
+
/** Options for {@link compareDocuments}. @public */
|
|
39
|
+
interface CompareDocumentsOptions {
|
|
40
|
+
/**
|
|
41
|
+
* Author recorded on every revision. When absent, empty, or only white space, the revised
|
|
42
|
+
* document's last author (`cp:lastModifiedBy`, then `dc:creator`), else `Comparison`.
|
|
43
|
+
*/
|
|
44
|
+
readonly authorName?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Record formatting differences as formatting revisions. Default `true`. When `false`, the
|
|
47
|
+
* result takes the revised formatting untracked, so rejecting all changes gives the
|
|
48
|
+
* original text with the revised formatting.
|
|
49
|
+
*/
|
|
50
|
+
readonly detectFormatChanges?: boolean;
|
|
51
|
+
/** Write the revisions without dates. Default `false`. */
|
|
52
|
+
readonly removeDateAndTime?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Revision timestamp. Defaults to the current time, truncated to the minute. A value that is
|
|
55
|
+
* not a valid date refuses with `invalidOptions`.
|
|
56
|
+
*/
|
|
57
|
+
readonly date?: Date;
|
|
58
|
+
}
|
|
59
|
+
/** Result of {@link compareDocuments}. @public */
|
|
60
|
+
type CompareDocumentsResult = {
|
|
61
|
+
readonly ok: true;
|
|
62
|
+
/**
|
|
63
|
+
* The original document with the differences recorded as tracked changes. When nothing
|
|
64
|
+
* changed, these are the original bytes.
|
|
65
|
+
*/
|
|
66
|
+
readonly bytes: Uint8Array;
|
|
67
|
+
/**
|
|
68
|
+
* Tracked change items recorded in the body, headers, footers, and notes. A replaced word
|
|
69
|
+
* counts as two items, a deletion and an insertion; the review pane can show them as one
|
|
70
|
+
* replacement.
|
|
71
|
+
*/
|
|
72
|
+
readonly revisionCount: number;
|
|
73
|
+
/**
|
|
74
|
+
* Whether the result differs from the original. False when the documents have no
|
|
75
|
+
* differences. Can be true with no revisions: the compare can change the document
|
|
76
|
+
* without a tracked change. Examples are formatting with `detectFormatChanges: false`,
|
|
77
|
+
* style definitions, and the original's own tracked changes, which a compare accepts.
|
|
78
|
+
*/
|
|
79
|
+
readonly changed: boolean;
|
|
80
|
+
} | {
|
|
81
|
+
readonly ok: false;
|
|
82
|
+
/** Why the compare was refused. `compareDocuments.errors.<code>` translates it. */
|
|
83
|
+
readonly code: CompareDocumentsEngineErrorCode;
|
|
84
|
+
/**
|
|
85
|
+
* Set with `unsupportedContent`: what the refusal is about.
|
|
86
|
+
* `compareDocuments.reasons.<reason>` translates it.
|
|
87
|
+
*/
|
|
88
|
+
readonly reason?: CompareDocumentsRefusalReason;
|
|
89
|
+
/** Diagnostic detail, in English; not for display. */
|
|
90
|
+
readonly message: string;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Document compare: the original with the revised document's differences as tracked changes.
|
|
95
|
+
*
|
|
96
|
+
* DOM-free and layout-free. Both inputs are compared in their accepted state; the output is
|
|
97
|
+
* the original package with compared stories and any parts, relationships, and media that
|
|
98
|
+
* content taken from the revised document needs.
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Compares an original and a revised DOCX and returns the original with the differences
|
|
103
|
+
* recorded as tracked changes: insertions, deletions, moves, and, with `detectFormatChanges`,
|
|
104
|
+
* formatting revisions. An input it cannot compare gives `{ ok: false }` with a stable
|
|
105
|
+
* `code`. When the documents have no differences, `changed` is false and
|
|
106
|
+
* `bytes` are the original bytes.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* const result = compareDocuments(original, revised, { authorName: 'Legal review' });
|
|
111
|
+
* if (!result.ok) throw new Error(`compare refused: ${result.code}`);
|
|
112
|
+
* if (result.changed) await saveFile('redline.docx', result.bytes);
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* @public
|
|
116
|
+
*/
|
|
117
|
+
declare function compareDocuments(original: Uint8Array, revised: Uint8Array, options?: CompareDocumentsOptions): CompareDocumentsResult;
|
|
118
|
+
|
|
35
119
|
/** How {@link customNodesOf} narrows what it answers. */
|
|
36
120
|
interface CustomNodesOfOptions {
|
|
37
121
|
/**
|
|
@@ -57,8 +141,7 @@ interface CustomNodesOfOptions {
|
|
|
57
141
|
* }
|
|
58
142
|
* ```
|
|
59
143
|
*
|
|
60
|
-
* Reads
|
|
61
|
-
* `recognizeCustomNodes` has, since it takes one part.
|
|
144
|
+
* Reads every story: the body first, then headers, footers, footnotes, and endnotes.
|
|
62
145
|
*
|
|
63
146
|
* Derived fresh on every call from the canonical package: there is no cache to go stale, and no
|
|
64
147
|
* change event either, so re-read after an edit rather than holding the array.
|
|
@@ -488,5 +571,5 @@ type CustomNodeXmlResult = {
|
|
|
488
571
|
*/
|
|
489
572
|
declare function customNodeXml<Schema extends StandardSchemaV1 | undefined = undefined>(definition: CustomNodeDefinition<Schema>, attrs: Readonly<Record<string, string>>, text: string, options?: CustomNodeXmlOptions<Schema>): CustomNodeXmlResult;
|
|
490
573
|
|
|
491
|
-
export { AnyCustomNodeDefinition, CUSTOM_NODE_STORE_ROOT, CustomNodeDefinition, CustomNodeDiagnostic, InferSchemaInput, MAX_TAG_LENGTH, RecognizedCustomNode, StandardSchemaV1, customNodeNamespace, customNodeXml, customNodesOf, decodeCustomNodeTag, encodeCustomNodeTag, insertCustomNode, prepareForExport, removeCustomNode, saveForExport, updateCustomNode };
|
|
492
|
-
export type { CustomNodeInput, CustomNodeIssue, CustomNodeUpdate, CustomNodeWriteOutcome, CustomNodeXmlOptions, CustomNodeXmlResult, CustomNodeXmlStore, CustomNodesOfOptions, DecodedCustomNodeTag, DocumentDestination, DocumentExportOptions, DocumentExportResult, EncodeTagResult, SaveForExportOptions };
|
|
574
|
+
export { AnyCustomNodeDefinition, CUSTOM_NODE_STORE_ROOT, CustomNodeDefinition, CustomNodeDiagnostic, InferSchemaInput, MAX_TAG_LENGTH, RecognizedCustomNode, StandardSchemaV1, compareDocuments, customNodeNamespace, customNodeXml, customNodesOf, decodeCustomNodeTag, encodeCustomNodeTag, insertCustomNode, prepareForExport, removeCustomNode, saveForExport, updateCustomNode };
|
|
575
|
+
export type { CompareDocumentsOptions, CompareDocumentsResult, CustomNodeInput, CustomNodeIssue, CustomNodeUpdate, CustomNodeWriteOutcome, CustomNodeXmlOptions, CustomNodeXmlResult, CustomNodeXmlStore, CustomNodesOfOptions, DecodedCustomNodeTag, DocumentDestination, DocumentExportOptions, DocumentExportResult, EncodeTagResult, SaveForExportOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -23,15 +23,99 @@
|
|
|
23
23
|
* @packageDocumentation
|
|
24
24
|
* @public
|
|
25
25
|
*/
|
|
26
|
-
import { A as AnyCustomNodeDefinition, C as CustomNodeDiagnostic, R as RecognizedCustomNode, S as StandardSchemaV1, I as InferSchemaInput, a as CustomNodeDefinition } from './define-custom-node-
|
|
27
|
-
export { b as ActivatedCustomNode, c as CustomNode, d as CustomNodeDataRejection, e as CustomNodeDataResult, f as CustomNodePayloadSource, g as CustomNodesModuleOptions, h as InferSchemaOutput, M as MAX_CUSTOM_NODE_DATA_LENGTH, i as RecognizeCustomNodesOptions, j as ReviewModuleOptions, k as StandardSchemaIssue, l as StandardSchemaResult, m as customNodesModule, n as defineCustomNode, o as isCustomNodeDefinition, p as parseCustomNodeData, r as recognizeCustomNodes, q as reviewModule, s as serializeCustomNodeData } from './define-custom-node-
|
|
26
|
+
import { A as AnyCustomNodeDefinition, C as CustomNodeDiagnostic, R as RecognizedCustomNode, S as StandardSchemaV1, I as InferSchemaInput, a as CustomNodeDefinition } from './define-custom-node-BRNdxxZL.js';
|
|
27
|
+
export { b as ActivatedCustomNode, c as CustomNode, d as CustomNodeDataRejection, e as CustomNodeDataResult, f as CustomNodePayloadSource, g as CustomNodesModuleOptions, h as InferSchemaOutput, M as MAX_CUSTOM_NODE_DATA_LENGTH, i as RecognizeCustomNodesOptions, j as ReviewModuleOptions, k as StandardSchemaIssue, l as StandardSchemaResult, m as customNodesModule, n as defineCustomNode, o as isCustomNodeDefinition, p as parseCustomNodeData, r as recognizeCustomNodes, q as reviewModule, s as serializeCustomNodeData } from './define-custom-node-BRNdxxZL.js';
|
|
28
|
+
import { CompareDocumentsEngineErrorCode, CompareDocumentsRefusalReason } from '@docx-editor.dev/core/editor';
|
|
29
|
+
export { CommentMarkerStyle, CompareDocumentsEngineErrorCode, CompareDocumentsErrorCode, CompareDocumentsRefusalReason, ResolvedReviewPane, ReviewPaneOpening, ReviewPaneOptions, ReviewPaneOverflow, RevisionDisplay } from '@docx-editor.dev/core/editor';
|
|
28
30
|
export { C as CollaborationModuleOptions, c as collaborationModule } from './collaboration-module-COZAgqwg.js';
|
|
29
31
|
export { P as ProLicenseOptions } from './license-D-ds5Y7c.js';
|
|
30
32
|
import { Editor, ExecResult } from '@docx-editor.dev/core/contracts/editor';
|
|
31
|
-
export { CommentMarkerStyle, ResolvedReviewPane, ReviewPaneOpening, ReviewPaneOptions, ReviewPaneOverflow, RevisionDisplay } from '@docx-editor.dev/core/editor';
|
|
32
33
|
import '@docx-editor.dev/core/store';
|
|
33
34
|
import '@docx-editor.dev/core/collaboration';
|
|
34
35
|
|
|
36
|
+
/** Public types of the document compare engine. */
|
|
37
|
+
|
|
38
|
+
/** Options for {@link compareDocuments}. @public */
|
|
39
|
+
interface CompareDocumentsOptions {
|
|
40
|
+
/**
|
|
41
|
+
* Author recorded on every revision. When absent, empty, or only white space, the revised
|
|
42
|
+
* document's last author (`cp:lastModifiedBy`, then `dc:creator`), else `Comparison`.
|
|
43
|
+
*/
|
|
44
|
+
readonly authorName?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Record formatting differences as formatting revisions. Default `true`. When `false`, the
|
|
47
|
+
* result takes the revised formatting untracked, so rejecting all changes gives the
|
|
48
|
+
* original text with the revised formatting.
|
|
49
|
+
*/
|
|
50
|
+
readonly detectFormatChanges?: boolean;
|
|
51
|
+
/** Write the revisions without dates. Default `false`. */
|
|
52
|
+
readonly removeDateAndTime?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Revision timestamp. Defaults to the current time, truncated to the minute. A value that is
|
|
55
|
+
* not a valid date refuses with `invalidOptions`.
|
|
56
|
+
*/
|
|
57
|
+
readonly date?: Date;
|
|
58
|
+
}
|
|
59
|
+
/** Result of {@link compareDocuments}. @public */
|
|
60
|
+
type CompareDocumentsResult = {
|
|
61
|
+
readonly ok: true;
|
|
62
|
+
/**
|
|
63
|
+
* The original document with the differences recorded as tracked changes. When nothing
|
|
64
|
+
* changed, these are the original bytes.
|
|
65
|
+
*/
|
|
66
|
+
readonly bytes: Uint8Array;
|
|
67
|
+
/**
|
|
68
|
+
* Tracked change items recorded in the body, headers, footers, and notes. A replaced word
|
|
69
|
+
* counts as two items, a deletion and an insertion; the review pane can show them as one
|
|
70
|
+
* replacement.
|
|
71
|
+
*/
|
|
72
|
+
readonly revisionCount: number;
|
|
73
|
+
/**
|
|
74
|
+
* Whether the result differs from the original. False when the documents have no
|
|
75
|
+
* differences. Can be true with no revisions: the compare can change the document
|
|
76
|
+
* without a tracked change. Examples are formatting with `detectFormatChanges: false`,
|
|
77
|
+
* style definitions, and the original's own tracked changes, which a compare accepts.
|
|
78
|
+
*/
|
|
79
|
+
readonly changed: boolean;
|
|
80
|
+
} | {
|
|
81
|
+
readonly ok: false;
|
|
82
|
+
/** Why the compare was refused. `compareDocuments.errors.<code>` translates it. */
|
|
83
|
+
readonly code: CompareDocumentsEngineErrorCode;
|
|
84
|
+
/**
|
|
85
|
+
* Set with `unsupportedContent`: what the refusal is about.
|
|
86
|
+
* `compareDocuments.reasons.<reason>` translates it.
|
|
87
|
+
*/
|
|
88
|
+
readonly reason?: CompareDocumentsRefusalReason;
|
|
89
|
+
/** Diagnostic detail, in English; not for display. */
|
|
90
|
+
readonly message: string;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Document compare: the original with the revised document's differences as tracked changes.
|
|
95
|
+
*
|
|
96
|
+
* DOM-free and layout-free. Both inputs are compared in their accepted state; the output is
|
|
97
|
+
* the original package with compared stories and any parts, relationships, and media that
|
|
98
|
+
* content taken from the revised document needs.
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Compares an original and a revised DOCX and returns the original with the differences
|
|
103
|
+
* recorded as tracked changes: insertions, deletions, moves, and, with `detectFormatChanges`,
|
|
104
|
+
* formatting revisions. An input it cannot compare gives `{ ok: false }` with a stable
|
|
105
|
+
* `code`. When the documents have no differences, `changed` is false and
|
|
106
|
+
* `bytes` are the original bytes.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* const result = compareDocuments(original, revised, { authorName: 'Legal review' });
|
|
111
|
+
* if (!result.ok) throw new Error(`compare refused: ${result.code}`);
|
|
112
|
+
* if (result.changed) await saveFile('redline.docx', result.bytes);
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* @public
|
|
116
|
+
*/
|
|
117
|
+
declare function compareDocuments(original: Uint8Array, revised: Uint8Array, options?: CompareDocumentsOptions): CompareDocumentsResult;
|
|
118
|
+
|
|
35
119
|
/** How {@link customNodesOf} narrows what it answers. */
|
|
36
120
|
interface CustomNodesOfOptions {
|
|
37
121
|
/**
|
|
@@ -57,8 +141,7 @@ interface CustomNodesOfOptions {
|
|
|
57
141
|
* }
|
|
58
142
|
* ```
|
|
59
143
|
*
|
|
60
|
-
* Reads
|
|
61
|
-
* `recognizeCustomNodes` has, since it takes one part.
|
|
144
|
+
* Reads every story: the body first, then headers, footers, footnotes, and endnotes.
|
|
62
145
|
*
|
|
63
146
|
* Derived fresh on every call from the canonical package: there is no cache to go stale, and no
|
|
64
147
|
* change event either, so re-read after an edit rather than holding the array.
|
|
@@ -488,5 +571,5 @@ type CustomNodeXmlResult = {
|
|
|
488
571
|
*/
|
|
489
572
|
declare function customNodeXml<Schema extends StandardSchemaV1 | undefined = undefined>(definition: CustomNodeDefinition<Schema>, attrs: Readonly<Record<string, string>>, text: string, options?: CustomNodeXmlOptions<Schema>): CustomNodeXmlResult;
|
|
490
573
|
|
|
491
|
-
export { AnyCustomNodeDefinition, CUSTOM_NODE_STORE_ROOT, CustomNodeDefinition, CustomNodeDiagnostic, InferSchemaInput, MAX_TAG_LENGTH, RecognizedCustomNode, StandardSchemaV1, customNodeNamespace, customNodeXml, customNodesOf, decodeCustomNodeTag, encodeCustomNodeTag, insertCustomNode, prepareForExport, removeCustomNode, saveForExport, updateCustomNode };
|
|
492
|
-
export type { CustomNodeInput, CustomNodeIssue, CustomNodeUpdate, CustomNodeWriteOutcome, CustomNodeXmlOptions, CustomNodeXmlResult, CustomNodeXmlStore, CustomNodesOfOptions, DecodedCustomNodeTag, DocumentDestination, DocumentExportOptions, DocumentExportResult, EncodeTagResult, SaveForExportOptions };
|
|
574
|
+
export { AnyCustomNodeDefinition, CUSTOM_NODE_STORE_ROOT, CustomNodeDefinition, CustomNodeDiagnostic, InferSchemaInput, MAX_TAG_LENGTH, RecognizedCustomNode, StandardSchemaV1, compareDocuments, customNodeNamespace, customNodeXml, customNodesOf, decodeCustomNodeTag, encodeCustomNodeTag, insertCustomNode, prepareForExport, removeCustomNode, saveForExport, updateCustomNode };
|
|
575
|
+
export type { CompareDocumentsOptions, CompareDocumentsResult, CustomNodeInput, CustomNodeIssue, CustomNodeUpdate, CustomNodeWriteOutcome, CustomNodeXmlOptions, CustomNodeXmlResult, CustomNodeXmlStore, CustomNodesOfOptions, DecodedCustomNodeTag, DocumentDestination, DocumentExportOptions, DocumentExportResult, EncodeTagResult, SaveForExportOptions };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {j,n,h,k,b,i,g,c}from'./chunk-
|
|
1
|
+
import {j,n,h,k,b,i,g,c}from'./chunk-XC2ILGOO.js';export{g as CUSTOM_NODE_STORE_ROOT,d as MAX_CUSTOM_NODE_DATA_LENGTH,a as MAX_TAG_LENGTH,h as customNodeNamespace,m as customNodesModule,c as decodeCustomNodeTag,l as defineCustomNode,b as encodeCustomNodeTag,p as insertCustomNode,j as isCustomNodeDefinition,e as parseCustomNodeData,n as recognizeCustomNodes,q as removeCustomNode,o as reviewModule,f as serializeCustomNodeData,r as updateCustomNode}from'./chunk-XC2ILGOO.js';export{a as compareDocuments}from'./chunk-B4OWKZIG.js';export{a as collaborationModule}from'./chunk-EOZ44UA7.js';import'./chunk-ZMBZ7CWZ.js';import'./chunk-HMU7J34H.js';import {customNodePayloadsByControl,readOoxmlPackage,withExportedCustomNodes,writeOoxmlPackage,isStoryPart,fnv1a32,datastoreItemIdFor,customNodeBinding,CUSTOM_XML_PROPS_TYPE,CUSTOM_XML_REL,CUSTOM_XML_PROPS_REL,DATASTORE_NAMESPACE_URI}from'@docx-editor.dev/core/store';function L(t,n$1={}){let r=F(t);if(!r)return [];let o=n$1.nodes??t.getCustomNodeDefinitions().filter(j);if(o.length===0)return [];let s=r.session.currentPackage(),d=r.session.part().name,m=n$1.onDiagnostic??(e=>{t.reportCustomNodeDiagnostic(e);});return r.session.storyParts().flatMap(e=>n(e,o,{payloads:customNodePayloadsByControl(s,e.name,d),onDiagnostic:m}))}function F(t){return t.surface??null}function E(t,n,r={}){if(r.destination==="internal")return {ok:true,bytes:t,unwrapped:0,removed:0};let o=readOoxmlPackage(t);if(!o.ok)return {ok:false,reason:`the document could not be read: ${o.reason}`};let s=new Map;for(let i of n)s.set(`${i.tagPrefix}:${i.name}`,i);let d=i=>{let p=c(i);if(!p)return "keep";let x=s.get(`${p.prefix}:${p.name}`);return x?x.preserveOnExport==="text"?"text":x.preserveOnExport===false?"remove":"keep":"keep"},m=[...new Set(n.filter(i=>i.preserveOnExport!==void 0).filter(i=>i.preserveOnExport!==true).map(h))],e=o.package,u=0,c$1=0,N=G(e);for(let i of N){let p=withExportedCustomNodes(e,{storyPartName:i,namespaces:[],decide:d});if(!p.ok)return {ok:false,reason:p.reason};e=p.pkg,u+=p.unwrapped,c$1+=p.removed;}let l=withExportedCustomNodes(e,{storyPartName:e.mainDocumentPart,namespaces:m,decide:()=>"keep"});return l.ok?(e=l.pkg,{ok:true,bytes:writeOoxmlPackage(e),unwrapped:u,removed:c$1}):{ok:false,reason:l.reason}}function G(t){let n=[];for(let[r,o]of t.parts)r!==t.mainDocumentPart&&isStoryPart(o)&&n.push(r);return [t.mainDocumentPart,...n]}async function H(t,n={}){let r=n.nodes??t.getCustomNodeDefinitions().filter(j),o=await t.save();return E(new Uint8Array(o),r,{...n.destination===void 0?{}:{destination:n.destination}})}function a(t){return t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Q(t,n,r,o={}){if(!k.test(t.tagPrefix)||!k.test(t.name))return {ok:false,code:"invalidArgs",reason:"the definition identity must match defineCustomNode\u2019s charset ([A-Za-z0-9_.-])"};let s=b(t.tagPrefix,t.name,n);if(!s.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${s.length} characters; Word caps w:tag at 64 \u2014 shorten the attrs`};let d=o.lock===void 0?"contentLocked":o.lock,m=o.id!==void 0&&Number.isInteger(o.id)&&o.id>0?o.id:fnv1a32(`${s.tag}\0${r}`)&2147483647||1,e=o.data===void 0?null:ee(t,o,r);if(e&&"reason"in e)return {ok:false,code:"invalidArgs",reason:e.reason};let u=(o.alias!==void 0?`<w:alias w:val="${a(o.alias)}"/>`:"")+`<w:tag w:val="${a(s.tag)}"/><w:id w:val="${m}"/>`+(d===false?"":`<w:lock w:val="${d}"/>`)+(e?`<w:dataBinding w:prefixMappings="${a(e.binding.prefixMappings)}" w:xpath="${a(e.binding.xpath)}" w:storeItemID="${a(e.binding.storeItemId)}"/>`:""),c=`<w:r><w:t xml:space="preserve">${a(r)}</w:t></w:r>`;return {ok:true,xml:`<w:sdt><w:sdtPr>${u}</w:sdtPr><w:sdtContent>${c}</w:sdtContent></w:sdt>`,...e?{store:e.store}:{}}}function ee(t,n,r){let o=i(t,n.data);if(!o.ok)return {reason:o.reason};let s=h(t),d=n.storeIndex!==void 0&&Number.isInteger(n.storeIndex)&&n.storeIndex>0?n.storeIndex:1,m=n.nodeId??"cx1",e=`/customXml/item${String(d)}.xml`,u=`/customXml/itemProps${String(d)}.xml`,c=datastoreItemIdFor(`${s} ${e} ${m}`),N=customNodeBinding({partName:e,propsPartName:u,itemId:c,namespaceUri:s},g,m);if(!N)return {reason:`the payload cannot be addressed by an XPath: check nodeId (${m}) and payloadNamespace`};let l=r===r.trim()?`<label>${a(r)}</label>`:`<label xml:space="preserve">${a(r)}</label>`;return {binding:N,store:{itemPartName:e,itemXml:`<${g} xmlns="${a(s)}"><node id="${a(m)}">${l}<data>${a(o.data)}</data></node></${g}>`,propsPartName:u,propsXml:`<ds:datastoreItem ds:itemID="${a(c)}" xmlns:ds="${DATASTORE_NAMESPACE_URI}"><ds:schemaRefs><ds:schemaRef ds:uri="${a(s)}"/></ds:schemaRefs></ds:datastoreItem>`,storeItemId:c,relationships:[{from:"/word/document.xml",type:CUSTOM_XML_REL,target:`../customXml/item${String(d)}.xml`},{from:e,type:CUSTOM_XML_PROPS_REL,target:`itemProps${String(d)}.xml`}],contentTypeOverride:{partName:u,contentType:CUSTOM_XML_PROPS_TYPE}}}}export{Q as customNodeXml,L as customNodesOf,E as prepareForExport,H as saveForExport};
|