@docx-editor.dev/core 2.21.1 → 2.23.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 +11 -5
- package/dist/automation.cjs +1 -1
- package/dist/automation.d.ts +13 -12
- package/dist/automation.js +1 -1
- package/dist/binding.cjs +1 -1
- package/dist/binding.d.ts +11 -10
- package/dist/binding.js +1 -1
- package/dist/chunk-4OAXZNBU.js +5 -0
- package/dist/chunk-6745I4XF.cjs +20 -0
- package/dist/chunk-6KA3L3FR.cjs +11 -0
- package/dist/chunk-6QS5WL63.js +1 -0
- package/dist/{chunk-E5OUYRNM.cjs → chunk-BUDXZ7T2.cjs} +5 -5
- package/dist/chunk-DYRXA5UJ.cjs +2 -0
- package/dist/chunk-DZOGUV7O.js +1 -0
- package/dist/chunk-EHT4LKKZ.cjs +1 -0
- package/dist/chunk-F5LAOPAD.js +20 -0
- package/dist/chunk-FWX535CS.cjs +1 -0
- package/dist/chunk-GRVRQBKU.js +1 -0
- package/dist/chunk-JN62FLHE.cjs +4 -0
- package/dist/{chunk-BF2TOG2V.js → chunk-KRBBWATQ.js} +1 -1
- package/dist/chunk-KV5HFE23.cjs +2 -0
- package/dist/{chunk-T5B4NMKF.cjs → chunk-PCPBDYEL.cjs} +1 -1
- package/dist/chunk-Q4RDWB3U.cjs +18 -0
- package/dist/{chunk-4TYA4RLP.cjs → chunk-QK23BSRK.cjs} +1 -1
- package/dist/chunk-QTFAXWVI.cjs +1 -0
- package/dist/chunk-RLO64PHP.cjs +1 -0
- package/dist/chunk-T7RGKBCE.cjs +5 -0
- package/dist/{chunk-FPDIJ4RF.js → chunk-UMBHUW6R.js} +1 -1
- package/dist/chunk-VE6H5EJA.js +5 -0
- package/dist/chunk-WHG23WNI.js +1 -0
- package/dist/chunk-XBYZTDF7.js +4 -0
- package/dist/chunk-XRBPZCNK.js +11 -0
- package/dist/chunk-Y5JCIWTF.js +2 -0
- package/dist/chunk-ZA6HEWUM.js +2 -0
- package/dist/chunk-ZCRSPN4Q.js +18 -0
- package/dist/collaboration/replication.cjs +1 -1
- package/dist/collaboration/replication.d.ts +6 -5
- package/dist/collaboration/replication.js +1 -1
- package/dist/collaboration.d.ts +7 -6
- package/dist/contracts/document.d.ts +4 -3
- package/dist/contracts/editor.d.ts +9 -9
- package/dist/contracts/interaction.d.ts +2 -1
- package/dist/contracts/modules.d.ts +9 -8
- package/dist/contracts/types.d.ts +1 -1
- package/dist/{custom-node-writes-CncR6KfC.d.ts → custom-node-writes-77rvPW2-.d.ts} +4 -3
- package/dist/{document-protection-DM6mA8Rf.d.ts → document-protection-CYIjO-li.d.ts} +3 -2
- package/dist/{editor-BRh7GuZF.d.ts → editor-DhUQsWWH.d.ts} +179 -52
- package/dist/editor.cjs +1 -1
- package/dist/editor.css +1 -1
- package/dist/editor.d.ts +181 -28
- package/dist/editor.js +1 -1
- package/dist/export.cjs +2 -2
- package/dist/export.d.ts +36 -18
- package/dist/export.js +2 -2
- package/dist/{failure-DNNmwsgD.d.ts → failure-BIPVQbRm.d.ts} +2 -1
- package/dist/{font-resolver-DwuQYj3P.d.ts → font-resolver-BwoHFBlr.d.ts} +3 -2
- package/dist/{headless-document-view-C3fc_jV0.d.ts → headless-document-view-Cc3fFWhv.d.ts} +4 -3
- package/dist/{image-resources-DxF-SN_8.d.ts → image-resources-DkuzBnTM.d.ts} +3 -2
- package/dist/{index-3pNnG4z4.d.ts → index-BYaCkGKO.d.ts} +179 -26
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +18 -18
- package/dist/index.js +1 -1
- package/dist/{layout-shaping-_GGjhhVc.d.ts → layout-shaping-DpWQG26a.d.ts} +7 -3
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.ts +473 -64
- package/dist/layout.js +1 -1
- package/dist/{note-properties-CjT31AuP.d.ts → note-properties-DMfKK3QU.d.ts} +3 -2
- package/dist/{omml-equation-Bk3OP1fv.d.ts → omml-equation-BY7OdfGY.d.ts} +3 -2
- package/dist/output.cjs +1 -1
- package/dist/output.d.ts +9 -8
- package/dist/output.js +1 -1
- package/dist/{protocol-CrbTIW2Z.d.ts → protocol-CPAakntQ.d.ts} +4 -3
- package/dist/{review-paragraph-order-D3KZohIL.d.ts → review-paragraph-order-B0BP_wJP.d.ts} +1 -1
- package/dist/{revision-projection-kVd7p6Wd.d.ts → revision-projection-CVJeA2jp.d.ts} +3 -2
- package/dist/{semantic-cell-selection-CkSsZHDL.d.ts → semantic-cell-selection-B8GF_H2e.d.ts} +10 -6
- package/dist/{semantic-interaction-Z2Xa68U5.d.ts → semantic-interaction-DQjtIruQ.d.ts} +3 -2
- package/dist/{semantic-paint-BHKprI9P.d.ts → semantic-paint-DoPl85nR.d.ts} +4 -3
- package/dist/{semantic-records-StH-AnHK.d.ts → semantic-records-DB0VgWsr.d.ts} +1125 -1039
- package/dist/store.cjs +1 -1
- package/dist/store.d.ts +17 -16
- package/dist/store.js +1 -1
- package/dist/{tree-package-fragment-CpEV1gl3.d.ts → tree-package-fragment-BIyGh6L8.d.ts} +4 -3
- package/dist/{tree-session-contract-CTT9nM7Z.d.ts → tree-session-contract-CHcCnz3W.d.ts} +7 -6
- package/dist/{types-barrel-PwcfEkaX.d.ts → types-barrel-DN_-gaRX.d.ts} +72 -5
- package/package.json +3 -3
- package/dist/chunk-25OQBAKA.js +0 -2
- package/dist/chunk-3B3DQMSL.js +0 -11
- package/dist/chunk-3P3DNJYM.js +0 -5
- package/dist/chunk-3PA64KPK.js +0 -5
- package/dist/chunk-7N77EN2Z.cjs +0 -2
- package/dist/chunk-AGWWNVIJ.cjs +0 -1
- package/dist/chunk-DFTVN25X.cjs +0 -5
- package/dist/chunk-DGONGMAV.js +0 -2
- package/dist/chunk-DZYKU2HG.js +0 -1
- package/dist/chunk-F4H3LC6M.cjs +0 -2
- package/dist/chunk-FGBADUSK.cjs +0 -1
- package/dist/chunk-IUTTOBQW.cjs +0 -20
- package/dist/chunk-IYCXQAFT.cjs +0 -4
- package/dist/chunk-JL3SI5SZ.js +0 -18
- package/dist/chunk-OFWUHH52.js +0 -20
- package/dist/chunk-OKY6JRJL.js +0 -4
- package/dist/chunk-P24FHMQW.cjs +0 -1
- package/dist/chunk-QBKAOSVF.cjs +0 -18
- package/dist/chunk-RA2TDTEQ.cjs +0 -1
- package/dist/chunk-U5GUJKTS.js +0 -1
- package/dist/chunk-VP7SDFCM.js +0 -1
- package/dist/chunk-XRYSPKKC.js +0 -1
- package/dist/chunk-ZZRCVDQU.cjs +0 -11
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
# @docx-editor.dev/core
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Use the [docx-editor.dev](https://docx-editor.dev) engine to read, edit, render, and save DOCX files. The engine stores document content in a canonical tree. It has no framework dependency.
|
|
17
17
|
|
|
18
18
|
Install this package alongside the React or Vue adapter. Both adapters require it as a peer dependency. You can also use its public contracts to build your own adapter.
|
|
19
19
|
|
|
@@ -32,9 +32,9 @@ import { createDocxEditor, loadFonts, WORD_DEFAULT_FONT } from '@docx-editor.dev
|
|
|
32
32
|
import type { Editor, EditorSnapshot } from '@docx-editor.dev/core';
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
The root
|
|
35
|
+
The root exports editor creation, contracts, font helpers, control definitions, and document types. Use subpaths to access storage, layout, and rendering.
|
|
36
36
|
|
|
37
|
-
| Subpath |
|
|
37
|
+
| Subpath | Exports |
|
|
38
38
|
| --- | --- |
|
|
39
39
|
| `.` | Create an editor, the contract, fonts, the chrome registry, the document model. |
|
|
40
40
|
| `./editor` | Everything the root re-exports, plus the paginated surface and ruler geometry. |
|
|
@@ -56,9 +56,9 @@ The root covers most uses: creating an editor, the `Editor` contract it implemen
|
|
|
56
56
|
|
|
57
57
|
The engine reads DOCX bytes into a canonical OOXML tree. Layout reads the tree and produces painted pages. Saving serializes the tree back into a DOCX package.
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
The document tree holds all editing state. The engine displays editable pages and converts browser input into tree operations.
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
Typed nodes supply layout properties. Generic nodes preserve other element structures, including unsupported extensions.
|
|
62
62
|
|
|
63
63
|
Export sessions default to `all-markup`, which shows inserted and deleted text. Use `displayMode: 'proposed'` for the accepted view or `displayMode: 'original'` for the rejected view.
|
|
64
64
|
|
|
@@ -107,6 +107,12 @@ Anything you render from document data (a font name, a hyperlink target, a comme
|
|
|
107
107
|
- [Architecture](https://www.docx-editor.dev/docs/2.x/core/architecture)
|
|
108
108
|
- [Word fidelity](https://www.docx-editor.dev/docs/2.x/word-fidelity)
|
|
109
109
|
|
|
110
|
+
## Accept server updates
|
|
111
|
+
|
|
112
|
+
Import `createDocumentRefresh` from `@docx-editor.dev/core/editor`. Use `createDocumentRefresh(editor)` to accept complete DOCX results from your server. The controller preserves the editor instance and scroll position. Each accepted file resets selection and undo history. Results after local edits and collaborative sessions are refused.
|
|
113
|
+
|
|
114
|
+
For highlights, change navigation, and recovery, see [Document refresh API](https://www.docx-editor.dev/docs/2.x/guides/document-refresh).
|
|
115
|
+
|
|
110
116
|
## License
|
|
111
117
|
|
|
112
118
|
Apache-2.0
|
package/dist/automation.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkKV5HFE23_cjs=require('./chunk-KV5HFE23.cjs');require('./chunk-RLO64PHP.cjs'),require('./chunk-Q4RDWB3U.cjs'),require('./chunk-QTFAXWVI.cjs'),require('./chunk-EHT4LKKZ.cjs');var chunkT7RGKBCE_cjs=require('./chunk-T7RGKBCE.cjs'),chunkQK23BSRK_cjs=require('./chunk-QK23BSRK.cjs'),chunk6KA3L3FR_cjs=require('./chunk-6KA3L3FR.cjs');var j=Object.freeze({document:true,save:true,events:true,selection:false,scrolling:false,layout:false}),D=Object.freeze({kind:"body"});function Y(o,t={}){let m=chunk6KA3L3FR_cjs.Id(o,t.limits??{});if(!m.ok)return {ok:false,reason:m.reason,...m.limit===void 0?{}:{limit:m.limit},...m.detail?{detail:m.detail}:{}};let p=m.package.parts.get(m.package.mainDocumentPart);if(!p)return {ok:false,reason:"no-main-document-part",detail:m.package.mainDocumentPart};let u=new chunkT7RGKBCE_cjs.Q(m.package,chunkT7RGKBCE_cjs.Ia(m.package,chunk6KA3L3FR_cjs.eb(p))),y=t.collaborationModel?.session,c=()=>{},n=K(u,y,()=>c());if(t.pagination){let i,l=-1,e=t.pagination;n.prepare=async f=>{if(!f.operations.some(s=>s.op==="updateFieldResult"))return;i=void 0;let a=u.packageRevision,d=await e(chunkT7RGKBCE_cjs.La(u));u.packageRevision===a&&(i=d,l=a);},n.fieldPageContext=(f,a,d)=>{if(u.packageRevision!==l)return null;let s=chunkKV5HFE23_cjs.g(u.currentPackage()).story(f);return s?chunkKV5HFE23_cjs.d(i,s.part,a,d):null};}let r=chunkKV5HFE23_cjs.m({port:n,capabilities:j});return y&&(c=y.attach(chunkQK23BSRK_cjs.b(u,{documentId:y.documentId}))),{ok:true,host:r}}function G(o,t,m){let p=o.partFor(m);return p?chunk6KA3L3FR_cjs.Ca(o,()=>{let u=chunk6KA3L3FR_cjs.Gf(o.currentPackage(),t,p.name);return u?(o.replacePackageShell(u.pkg),u.relationshipId):null},u=>u!==null):null}function K(o,t,m=()=>{}){let p=true,u=0,y=()=>t?(u+=1,{origin:t.identity.role==="agent"?chunk6KA3L3FR_cjs.b.mutationAgent:chunk6KA3L3FR_cjs.b.mutationHuman,actorId:t.identity.actorId,operationId:`${t.identity.actorId}:${t.sessionId}:automation:${u}`,recordsHistory:false}):{},c=n=>(t?.flushPendingJournals(),n);return {localChangeTracking:true,revision:()=>o.packageRevision,currentPackage:()=>p?o.currentPackage():null,apply(n,r=D,i=[]){if(!p)return {ok:false,reason:"disposed"};let l=n(d=>chunk6KA3L3FR_cjs.gb(t?.identity.actorId,()=>G(o,d,r)));if(l===null)return {ok:false,reason:"unsupported-target"};let e=t?.gateOperations(l,r);if(e)return {ok:false,reason:e};let f=t?o.partFor(r)?.name:void 0,a=o.transact(r,d=>{for(let s of i)d.applyPackage(s);for(let s of l)d.apply(s);f&&d.applyPackage(s=>chunkQK23BSRK_cjs.a(s,f,l));},y());return a.ok?c({ok:true,changed:a.change!==null}):{ok:false,reason:a.detail?`${a.reason}: ${a.detail}`:a.reason}},applyLifecycle(n){if(!p)return {ok:false,reason:"disposed"};let r=t?.gateOperations([n],D);if(r)return {ok:false,reason:r};let i=chunk6KA3L3FR_cjs.gb(t?.identity.actorId,()=>o.applyLifecycleOp(n));return i.ok?c({ok:true,changed:i.change!==null}):{ok:false,reason:i.detail?`${i.reason}: ${i.detail}`:i.reason}},applyCommentWrites(n,r){if(!p)return {ok:false,reason:"disposed"};if(n.length===0)return {ok:true,changed:false};let i=t?.gateOperations([],r);if(i)return {ok:false,reason:i};let l=o.resolveStory(r);if(!l.ok)return {ok:false,reason:l.reason};if(l.store.graftPackage(()=>o.currentPackage()),n.every(a=>a.kind==="delete")){let a=n.find(s=>s.kind==="delete"),d=chunk6KA3L3FR_cjs.gb(t?.identity.actorId,()=>chunkT7RGKBCE_cjs.ba(o,n.flatMap(s=>s.kind==="delete"?[{commentId:s.commentId,...s.parentCommentId===void 0?{}:{parentCommentId:s.parentCommentId}}]:[]),r,a?.kind==="delete"?a.noteId:void 0));return d?c({ok:true,changed:d}):{ok:false,reason:"comment-delete-refused"}}if(n.length!==1)return {ok:false,reason:"mixed-comment-writes"};let e=n[0];if(e.kind==="create"||e.kind==="reply"){let a=chunk6KA3L3FR_cjs.gb(t?.identity.actorId,()=>chunkT7RGKBCE_cjs.$(o,{anchor:e.anchor,author:e.author,text:e.text,...e.date===void 0?{}:{date:e.date},...e.kind==="reply"?{replyToCommentId:e.parentCommentId}:{}},r));return a.ok?c({ok:true,changed:true,..."commentId"in a?{commentId:a.commentId}:{}}):{ok:false,reason:a.reason}}if(e.kind!=="resolve")return {ok:false,reason:"unsupported-comment-write"};let f=chunk6KA3L3FR_cjs.gb(t?.identity.actorId,()=>chunkT7RGKBCE_cjs.aa(o,e.commentId,e.resolved));return f.ok?c({ok:true,changed:true}):{ok:false,reason:f.reason}},applyCustomNodeWrite(n,r){if(!p)return {ok:false,reason:"disposed"};let i=t?.gateOperations([],r);if(i)return {ok:false,reason:i};let l=o.resolveStory(r);if(!l.ok)return {ok:false,reason:l.reason};let e=chunk6KA3L3FR_cjs.gb(t?.identity.actorId,()=>chunkT7RGKBCE_cjs.ja(o,n,r));return e.ok?c({ok:true,changed:e.change!==null}):{ok:false,reason:e.detail?`${e.reason}: ${e.detail}`:e.reason}},save:()=>p?chunk6KA3L3FR_cjs.Jd(o.currentPackage()):null,subscribe:n=>o.subscribe(()=>n()),dispose(){m(),p=false;}}}Object.defineProperty(exports,"AUTOMATION_COMMAND_OPERATIONS",{enumerable:true,get:function(){return chunkKV5HFE23_cjs.i}});Object.defineProperty(exports,"AUTOMATION_QUERY_OPERATIONS",{enumerable:true,get:function(){return chunkKV5HFE23_cjs.h}});Object.defineProperty(exports,"AUTOMATION_SOLITARY_OPERATIONS",{enumerable:true,get:function(){return chunkKV5HFE23_cjs.j}});Object.defineProperty(exports,"HEADER_FOOTER_VARIANTS",{enumerable:true,get:function(){return chunkKV5HFE23_cjs.f}});Object.defineProperty(exports,"createAutomationPaginationProvider",{enumerable:true,get:function(){return chunkKV5HFE23_cjs.e}});Object.defineProperty(exports,"isAutomationCommand",{enumerable:true,get:function(){return chunkKV5HFE23_cjs.l}});Object.defineProperty(exports,"isSolitaryAutomationCommand",{enumerable:true,get:function(){return chunkKV5HFE23_cjs.k}});Object.defineProperty(exports,"paginationSnapshotOf",{enumerable:true,get:function(){return chunkKV5HFE23_cjs.c}});exports.SERVER_AUTOMATION_CAPABILITIES=j;exports.createServerAutomationHost=Y;
|
package/dist/automation.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { A as AutomationCapabilities, a as AutomationHost } from './protocol-
|
|
2
|
-
export { b as AUTOMATION_COMMAND_OPERATIONS, c as AUTOMATION_QUERY_OPERATIONS, d as AUTOMATION_SOLITARY_OPERATIONS, e as AutomationAlignment, f as AutomationBatchRequest, g as AutomationBatchResponse, h as AutomationChangeEvent, i as AutomationContentControlLock, j as AutomationContentControlRangeLocation, k as AutomationContentControlScope, l as AutomationContentControlSubtype, m as AutomationContentControlValue, n as AutomationError, o as AutomationErrorCode, p as AutomationFontRead, q as AutomationFontWrite, r as AutomationHandle, s as AutomationHandleRef, t as AutomationObjectKind, u as AutomationOperation, v as AutomationOperationKind, w as AutomationOperationResult, x as AutomationPageOrientation, y as AutomationPageSetupRead, z as AutomationPageSetupWrite, B as AutomationParagraphFormatRead, C as AutomationParagraphFormatWrite, D as AutomationParagraphRef, E as AutomationPoint, F as AutomationSaveResult, G as AutomationSearchOptions, H as AutomationSelectionMode, I as AutomationSpan, J as AutomationSpanRef, K as AutomationTextProjection, L as AutomationUnsubscribe, M as AutomationValue, N as isAutomationCommand, O as isSolitaryAutomationCommand } from './protocol-
|
|
3
|
-
import { H as HeaderFooterVariant, N as NoteKind } from './tree-package-fragment-
|
|
4
|
-
import { T as TextMeasurer, S as SemanticLayout } from './semantic-records-
|
|
5
|
-
import { H as HeadlessDocumentView } from './headless-document-view-
|
|
6
|
-
import { X as OoxmlPackageLimits, Y as OoxmlPackageRejection } from './types-barrel-
|
|
7
|
-
export { Z as RevisionBatchEntry, _ as RevisionBatchResult, $ as RevisionBatchSkipReason } from './types-barrel-
|
|
1
|
+
import { A as AutomationCapabilities, a as AutomationHost } from './protocol-CPAakntQ.js';
|
|
2
|
+
export { b as AUTOMATION_COMMAND_OPERATIONS, c as AUTOMATION_QUERY_OPERATIONS, d as AUTOMATION_SOLITARY_OPERATIONS, e as AutomationAlignment, f as AutomationBatchRequest, g as AutomationBatchResponse, h as AutomationChangeEvent, i as AutomationContentControlLock, j as AutomationContentControlRangeLocation, k as AutomationContentControlScope, l as AutomationContentControlSubtype, m as AutomationContentControlValue, n as AutomationError, o as AutomationErrorCode, p as AutomationFontRead, q as AutomationFontWrite, r as AutomationHandle, s as AutomationHandleRef, t as AutomationObjectKind, u as AutomationOperation, v as AutomationOperationKind, w as AutomationOperationResult, x as AutomationPageOrientation, y as AutomationPageSetupRead, z as AutomationPageSetupWrite, B as AutomationParagraphFormatRead, C as AutomationParagraphFormatWrite, D as AutomationParagraphRef, E as AutomationPoint, F as AutomationSaveResult, G as AutomationSearchOptions, H as AutomationSelectionMode, I as AutomationSpan, J as AutomationSpanRef, K as AutomationTextProjection, L as AutomationUnsubscribe, M as AutomationValue, N as isAutomationCommand, O as isSolitaryAutomationCommand } from './protocol-CPAakntQ.js';
|
|
3
|
+
import { H as HeaderFooterVariant, N as NoteKind } from './tree-package-fragment-BIyGh6L8.js';
|
|
4
|
+
import { T as TextMeasurer, S as SemanticLayout } from './semantic-records-DB0VgWsr.js';
|
|
5
|
+
import { H as HeadlessDocumentView } from './headless-document-view-Cc3fFWhv.js';
|
|
6
|
+
import { X as OoxmlPackageLimits, Y as OoxmlPackageRejection } from './types-barrel-DN_-gaRX.js';
|
|
7
|
+
export { Z as RevisionBatchEntry, _ as RevisionBatchResult, $ as RevisionBatchSkipReason } from './types-barrel-DN_-gaRX.js';
|
|
8
8
|
import { CollaborationModuleContribution } from './collaboration.js';
|
|
9
|
-
import './image-resources-
|
|
10
|
-
import './revision-projection-
|
|
11
|
-
import './omml-equation-
|
|
9
|
+
import './image-resources-DkuzBnTM.js';
|
|
10
|
+
import './revision-projection-CVJeA2jp.js';
|
|
11
|
+
import './omml-equation-BY7OdfGY.js';
|
|
12
12
|
import './editor-scope-OHPwVQ5l.js';
|
|
13
13
|
import './collaboration/replication.js';
|
|
14
|
-
import './failure-
|
|
14
|
+
import './failure-BIPVQbRm.js';
|
|
15
15
|
|
|
16
16
|
/** The variants a section can declare furniture for. */
|
|
17
17
|
declare const HEADER_FOOTER_VARIANTS: readonly HeaderFooterVariant[];
|
|
@@ -111,4 +111,5 @@ interface ServerAutomationHostOptions {
|
|
|
111
111
|
*/
|
|
112
112
|
declare function createServerAutomationHost(bytes: Uint8Array, options?: ServerAutomationHostOptions): ServerAutomationHostResult;
|
|
113
113
|
|
|
114
|
-
export { AutomationCapabilities, AutomationHost,
|
|
114
|
+
export { AutomationCapabilities, AutomationHost, HEADER_FOOTER_VARIANTS, SERVER_AUTOMATION_CAPABILITIES, createAutomationPaginationProvider, createServerAutomationHost, paginationSnapshotOf };
|
|
115
|
+
export type { AutomationPaginationOptions, AutomationPaginationProvider, AutomationPaginationSnapshot, AutomationStoryId, ServerAutomationHostOptions, ServerAutomationHostRejection, ServerAutomationHostResult };
|
package/dist/automation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {m,g,d}from'./chunk-ZA6HEWUM.js';export{i as AUTOMATION_COMMAND_OPERATIONS,h as AUTOMATION_QUERY_OPERATIONS,j as AUTOMATION_SOLITARY_OPERATIONS,f as HEADER_FOOTER_VARIANTS,e as createAutomationPaginationProvider,l as isAutomationCommand,k as isSolitaryAutomationCommand,c as paginationSnapshotOf}from'./chunk-ZA6HEWUM.js';import'./chunk-WHG23WNI.js';import'./chunk-ZCRSPN4Q.js';import'./chunk-DZOGUV7O.js';import'./chunk-6QS5WL63.js';import {Q,Ia,La,ja,ba,$,aa}from'./chunk-VE6H5EJA.js';import {b,a}from'./chunk-KRBBWATQ.js';import {Id,eb,Jd,gb,Ca,Gf,b as b$1}from'./chunk-XRBPZCNK.js';var j=Object.freeze({document:true,save:true,events:true,selection:false,scrolling:false,layout:false}),D=Object.freeze({kind:"body"});function Y(o,t={}){let m$1=Id(o,t.limits??{});if(!m$1.ok)return {ok:false,reason:m$1.reason,...m$1.limit===void 0?{}:{limit:m$1.limit},...m$1.detail?{detail:m$1.detail}:{}};let p=m$1.package.parts.get(m$1.package.mainDocumentPart);if(!p)return {ok:false,reason:"no-main-document-part",detail:m$1.package.mainDocumentPart};let u=new Q(m$1.package,Ia(m$1.package,eb(p))),y=t.collaborationModel?.session,c=()=>{},n=K(u,y,()=>c());if(t.pagination){let i,l=-1,e=t.pagination;n.prepare=async f=>{if(!f.operations.some(s=>s.op==="updateFieldResult"))return;i=void 0;let a=u.packageRevision,d=await e(La(u));u.packageRevision===a&&(i=d,l=a);},n.fieldPageContext=(f,a,d$1)=>{if(u.packageRevision!==l)return null;let s=g(u.currentPackage()).story(f);return s?d(i,s.part,a,d$1):null};}let r=m({port:n,capabilities:j});return y&&(c=y.attach(b(u,{documentId:y.documentId}))),{ok:true,host:r}}function G(o,t,m){let p=o.partFor(m);return p?Ca(o,()=>{let u=Gf(o.currentPackage(),t,p.name);return u?(o.replacePackageShell(u.pkg),u.relationshipId):null},u=>u!==null):null}function K(o,t,m=()=>{}){let p=true,u=0,y=()=>t?(u+=1,{origin:t.identity.role==="agent"?b$1.mutationAgent:b$1.mutationHuman,actorId:t.identity.actorId,operationId:`${t.identity.actorId}:${t.sessionId}:automation:${u}`,recordsHistory:false}):{},c=n=>(t?.flushPendingJournals(),n);return {localChangeTracking:true,revision:()=>o.packageRevision,currentPackage:()=>p?o.currentPackage():null,apply(n,r=D,i=[]){if(!p)return {ok:false,reason:"disposed"};let l=n(d=>gb(t?.identity.actorId,()=>G(o,d,r)));if(l===null)return {ok:false,reason:"unsupported-target"};let e=t?.gateOperations(l,r);if(e)return {ok:false,reason:e};let f=t?o.partFor(r)?.name:void 0,a$1=o.transact(r,d=>{for(let s of i)d.applyPackage(s);for(let s of l)d.apply(s);f&&d.applyPackage(s=>a(s,f,l));},y());return a$1.ok?c({ok:true,changed:a$1.change!==null}):{ok:false,reason:a$1.detail?`${a$1.reason}: ${a$1.detail}`:a$1.reason}},applyLifecycle(n){if(!p)return {ok:false,reason:"disposed"};let r=t?.gateOperations([n],D);if(r)return {ok:false,reason:r};let i=gb(t?.identity.actorId,()=>o.applyLifecycleOp(n));return i.ok?c({ok:true,changed:i.change!==null}):{ok:false,reason:i.detail?`${i.reason}: ${i.detail}`:i.reason}},applyCommentWrites(n,r){if(!p)return {ok:false,reason:"disposed"};if(n.length===0)return {ok:true,changed:false};let i=t?.gateOperations([],r);if(i)return {ok:false,reason:i};let l=o.resolveStory(r);if(!l.ok)return {ok:false,reason:l.reason};if(l.store.graftPackage(()=>o.currentPackage()),n.every(a=>a.kind==="delete")){let a=n.find(s=>s.kind==="delete"),d=gb(t?.identity.actorId,()=>ba(o,n.flatMap(s=>s.kind==="delete"?[{commentId:s.commentId,...s.parentCommentId===void 0?{}:{parentCommentId:s.parentCommentId}}]:[]),r,a?.kind==="delete"?a.noteId:void 0));return d?c({ok:true,changed:d}):{ok:false,reason:"comment-delete-refused"}}if(n.length!==1)return {ok:false,reason:"mixed-comment-writes"};let e=n[0];if(e.kind==="create"||e.kind==="reply"){let a=gb(t?.identity.actorId,()=>$(o,{anchor:e.anchor,author:e.author,text:e.text,...e.date===void 0?{}:{date:e.date},...e.kind==="reply"?{replyToCommentId:e.parentCommentId}:{}},r));return a.ok?c({ok:true,changed:true,..."commentId"in a?{commentId:a.commentId}:{}}):{ok:false,reason:a.reason}}if(e.kind!=="resolve")return {ok:false,reason:"unsupported-comment-write"};let f=gb(t?.identity.actorId,()=>aa(o,e.commentId,e.resolved));return f.ok?c({ok:true,changed:true}):{ok:false,reason:f.reason}},applyCustomNodeWrite(n,r){if(!p)return {ok:false,reason:"disposed"};let i=t?.gateOperations([],r);if(i)return {ok:false,reason:i};let l=o.resolveStory(r);if(!l.ok)return {ok:false,reason:l.reason};let e=gb(t?.identity.actorId,()=>ja(o,n,r));return e.ok?c({ok:true,changed:e.change!==null}):{ok:false,reason:e.detail?`${e.reason}: ${e.detail}`:e.reason}},save:()=>p?Jd(o.currentPackage()):null,subscribe:n=>o.subscribe(()=>n()),dispose(){m(),p=false;}}}export{j as SERVER_AUTOMATION_CAPABILITIES,Y as createServerAutomationHost};
|
package/dist/binding.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkBUDXZ7T2_cjs=require('./chunk-BUDXZ7T2.cjs');require('./chunk-PCPBDYEL.cjs'),require('./chunk-QTFAXWVI.cjs'),require('./chunk-EHT4LKKZ.cjs'),require('./chunk-T7RGKBCE.cjs'),require('./chunk-QK23BSRK.cjs'),require('./chunk-6KA3L3FR.cjs');Object.defineProperty(exports,"PROJECTION_ORIGIN",{enumerable:true,get:function(){return chunkBUDXZ7T2_cjs.k}});Object.defineProperty(exports,"bodyParagraphs",{enumerable:true,get:function(){return chunkBUDXZ7T2_cjs.c}});Object.defineProperty(exports,"docToTreeOps",{enumerable:true,get:function(){return chunkBUDXZ7T2_cjs.f}});Object.defineProperty(exports,"mountTreeSurface",{enumerable:true,get:function(){return chunkBUDXZ7T2_cjs.l}});Object.defineProperty(exports,"openTreeSession",{enumerable:true,get:function(){return chunkBUDXZ7T2_cjs.j}});Object.defineProperty(exports,"partHasNode",{enumerable:true,get:function(){return chunkBUDXZ7T2_cjs.g}});Object.defineProperty(exports,"reconcileDoc",{enumerable:true,get:function(){return chunkBUDXZ7T2_cjs.h}});Object.defineProperty(exports,"runPropsOf",{enumerable:true,get:function(){return chunkBUDXZ7T2_cjs.b}});Object.defineProperty(exports,"treeSchema",{enumerable:true,get:function(){return chunkBUDXZ7T2_cjs.a}});Object.defineProperty(exports,"treeToDoc",{enumerable:true,get:function(){return chunkBUDXZ7T2_cjs.e}});
|
package/dist/binding.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Node, Schema } from 'prosemirror-model';
|
|
2
|
-
import { a0 as OoxmlProperty, Y as OoxmlPackageRejection } from './types-barrel-
|
|
3
|
-
import { T as TreeDocxSessionView, a as TreeApplyResult } from './tree-session-contract-
|
|
4
|
-
export { D as DocumentStyleEntry, M as MapResult, b as TreeApplyOptions, c as TreeBindingRejection, d as bodyParagraphs, e as docToTreeOps, p as partHasNode, r as reconcileDoc, t as treeToDoc } from './tree-session-contract-
|
|
2
|
+
import { a0 as OoxmlProperty, Y as OoxmlPackageRejection } from './types-barrel-DN_-gaRX.js';
|
|
3
|
+
import { T as TreeDocxSessionView, a as TreeApplyResult } from './tree-session-contract-CHcCnz3W.js';
|
|
4
|
+
export { D as DocumentStyleEntry, M as MapResult, b as TreeApplyOptions, c as TreeBindingRejection, d as bodyParagraphs, e as docToTreeOps, p as partHasNode, r as reconcileDoc, t as treeToDoc } from './tree-session-contract-CHcCnz3W.js';
|
|
5
5
|
import { ReviewModuleContribution } from './contracts/modules.js';
|
|
6
|
-
export { S as StoryScope, a as StoryTargetRejection } from './tree-package-fragment-
|
|
6
|
+
export { S as StoryScope, a as StoryTargetRejection } from './tree-package-fragment-BIyGh6L8.js';
|
|
7
7
|
import { EditorView } from 'prosemirror-view';
|
|
8
8
|
import './editor-scope-OHPwVQ5l.js';
|
|
9
|
-
import './image-resources-
|
|
10
|
-
import './custom-node-writes-
|
|
11
|
-
import './headless-document-view-
|
|
9
|
+
import './image-resources-DkuzBnTM.js';
|
|
10
|
+
import './custom-node-writes-77rvPW2-.js';
|
|
11
|
+
import './headless-document-view-Cc3fFWhv.js';
|
|
12
12
|
import './collaboration/replication.js';
|
|
13
|
-
import './revision-projection-
|
|
13
|
+
import './revision-projection-CVJeA2jp.js';
|
|
14
14
|
import './collaboration.js';
|
|
15
|
-
import './failure-
|
|
15
|
+
import './failure-BIPVQbRm.js';
|
|
16
16
|
|
|
17
17
|
/** Attributes carried by a projected paragraph. */
|
|
18
18
|
interface ParagraphAttrs {
|
|
@@ -149,4 +149,5 @@ interface TreeSurface {
|
|
|
149
149
|
*/
|
|
150
150
|
declare function mountTreeSurface(mount: HTMLElement, session: TreeDocxSession, options?: TreeSurfaceOptions): TreeSurface;
|
|
151
151
|
|
|
152
|
-
export {
|
|
152
|
+
export { PROJECTION_ORIGIN, TreeApplyResult, TreeDocxSessionView, mountTreeSurface, openTreeSession, runPropsOf, treeSchema };
|
|
153
|
+
export type { OpenTreeSessionResult, ParagraphAttrs, TreeDocxSession, TreeSessionRejection, TreeSurface, TreeSurfaceOptions, TreeSurfaceState };
|
package/dist/binding.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{k as PROJECTION_ORIGIN,c as bodyParagraphs,f as docToTreeOps,l as mountTreeSurface,j as openTreeSession,g as partHasNode,h as reconcileDoc,b as runPropsOf,a as treeSchema,e as treeToDoc}from'./chunk-
|
|
1
|
+
export{k as PROJECTION_ORIGIN,c as bodyParagraphs,f as docToTreeOps,l as mountTreeSurface,j as openTreeSession,g as partHasNode,h as reconcileDoc,b as runPropsOf,a as treeSchema,e as treeToDoc}from'./chunk-4OAXZNBU.js';import'./chunk-UMBHUW6R.js';import'./chunk-DZOGUV7O.js';import'./chunk-6QS5WL63.js';import'./chunk-VE6H5EJA.js';import'./chunk-KRBBWATQ.js';import'./chunk-XRBPZCNK.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import {c,e,b as b$2}from'./chunk-UMBHUW6R.js';import {d}from'./chunk-DZOGUV7O.js';import {d as d$1}from'./chunk-6QS5WL63.js';import {Q,Ia,ga,ka,ja,ba,aa,$,Z,_ as _$1,ha,Ga,a,ma,pa,Ba,b as b$3}from'./chunk-VE6H5EJA.js';import {b as b$1,a as a$1}from'./chunk-KRBBWATQ.js';import {Yg,b,lc,Ha,Id,eb,Ca,Af,zf,Ac,vi,Ii,Gf,if as _if,Hf,cg,bg,ih,ee,rj,ce,be,E as E$1,lh,mh,ge,pc,Ua,he,oc,Sc,da,Lf,Pg,gb,Jd,Ia as Ia$1,la,na,ka as ka$1,ma as ma$1,ig,rc,tc,_a,Za,nh,cf,pe,yc,nc,$d,hc,Xb,Zb,Nb,Wa,Zc,Hc}from'./chunk-XRBPZCNK.js';import {Schema}from'prosemirror-model';import {EditorState,TextSelection}from'prosemirror-state';import {EditorView}from'prosemirror-view';import {keymap}from'prosemirror-keymap';import {joinBackward,deleteSelection,joinForward,splitBlock,selectTextblockEnd,selectTextblockStart,baseKeymap}from'prosemirror-commands';function Y(t){return t.attributes?.val}function W(t){let e=Y(t);return e===void 0||!(e==="0"||e==="false"||e==="off")}var Oo=/^[0-9A-Fa-f]{6}$/,ve=/^\d{1,6}$/,So=/^-?\d{1,6}$/;function Ye(t){return t===void 0||t==="auto"?null:Oo.test(t)?`#${t}`:null}var bo={single:"solid",words:"solid",thick:"solid",double:"double",dotted:"dotted",dottedHeavy:"dotted",dash:"dashed",dashedHeavy:"dashed",dashLong:"dashed",dashLongHeavy:"dashed",dotDash:"dashed",dashDotHeavy:"dashed",dotDotDash:"dashed",dashDotDotHeavy:"dashed",wave:"wavy",wavyHeavy:"wavy",wavyDouble:"wavy"},Ro={black:"#000000",blue:"#0000ff",cyan:"#00ffff",darkBlue:"#000080",darkCyan:"#008080",darkGray:"#808080",darkGreen:"#008000",darkMagenta:"#800080",darkRed:"#800000",darkYellow:"#808000",green:"#00ff00",lightGray:"#c0c0c0",magenta:"#ff00ff",red:"#ff0000",yellow:"#ffff00",white:"#ffffff"};function vo(t){return !t||!/^[\w \-.+]{1,64}$/.test(t)?null:`"${t}"`}function K(t,e=false){return t===void 0||!(e?So:ve).test(t)?null:`${Number(t)/20}pt`}function Rn(t){let e=[],n=[],o=null,s=null;for(let a of t)switch(a.localName){case "b":e.push(`font-weight:${W(a)?"bold":"normal"}`);break;case "i":e.push(`font-style:${W(a)?"italic":"normal"}`);break;case "u":{let r=Y(a)??"single";if(r==="none"||!W(a))break;n.push("underline"),o=bo[r]??"solid",s=Ye(a.attributes?.color);break}case "strike":W(a)&&n.push("line-through");break;case "dstrike":W(a)&&n.push("line-through");break;case "caps":W(a)&&e.push("text-transform:uppercase");break;case "smallCaps":W(a)&&e.push("font-variant:small-caps");break;case "vertAlign":{let r=Y(a);r==="superscript"?e.push("vertical-align:super","font-size:0.75em"):r==="subscript"&&e.push("vertical-align:sub","font-size:0.75em");break}case "color":{let r=Ye(Y(a));r&&e.push(`color:${r}`);break}case "highlight":{let r=Ro[Y(a)??""];r&&e.push(`background-color:${r}`);break}case "sz":{let r=Y(a);r!==void 0&&ve.test(r)&&e.push(`font-size:${Number(r)/2}pt`);break}case "rFonts":{let r=vo(a.attributes?.ascii??a.attributes?.hAnsi);r&&e.push(`font-family:${r}`);break}case "spacing":{let r=K(Y(a),true);r&&e.push(`letter-spacing:${r}`);break}}return n.length>0&&(e.push(`text-decoration-line:${[...new Set(n)].join(" ")}`),o&&e.push(`text-decoration-style:${o}`),s&&e.push(`text-decoration-color:${s}`)),e.join(";")}var To={left:"left",start:"left",right:"right",end:"right",center:"center",both:"justify",distribute:"justify"};function vn(t){let e=[];for(let n of t)switch(n.localName){case "jc":{let o=To[Y(n)??""];o&&e.push(`text-align:${o}`);break}case "ind":{let o=K(n.attributes?.left??n.attributes?.start,true),s=K(n.attributes?.right??n.attributes?.end,true),a=K(n.attributes?.firstLine),r=K(n.attributes?.hanging);o&&e.push(`margin-left:${o}`),s&&e.push(`margin-right:${s}`),a?e.push(`text-indent:${a}`):r&&e.push(`text-indent:-${r}`);break}case "spacing":{let o=K(n.attributes?.before),s=K(n.attributes?.after);o&&e.push(`margin-top:${o}`),s&&e.push(`margin-bottom:${s}`);let a=n.attributes?.line,r=n.attributes?.lineRule;a!==void 0&&ve.test(a)&&r!=="exact"&&r!=="atLeast"?e.push(`line-height:${(Number(a)/240).toFixed(3)}`):a!==void 0&&ve.test(a)&&e.push(`line-height:${Number(a)/20}pt`);break}case "shd":{let o=Ye(n.attributes?.fill);o&&e.push(`background-color:${o}`);break}case "pageBreakBefore":W(n)&&e.push("break-before:page");break;}return e.join(";")}var E=new Schema({nodes:{doc:{content:"paragraph+"},paragraph:{content:"inline*",group:"block",attrs:{nodeId:{default:null},props:{default:[]}},toDOM:t=>{let e=vn(t.attrs.props??[]);return ["p",{"data-node-id":String(t.attrs.nodeId??""),...e?{style:e}:{}},0]},parseDOM:[{tag:"p",getAttrs:t=>typeof t=="string"?null:{nodeId:t.getAttribute("data-node-id")||null,props:[]}}]},text:{group:"inline"},tab:{inline:true,group:"inline",atom:true,selectable:false,toDOM:()=>["span",{"data-token":"tab",class:"docx-tab"},"\u2192"],parseDOM:[{tag:'span[data-token="tab"]'}]},hardBreak:{inline:true,group:"inline",atom:true,selectable:false,toDOM:()=>["br"],parseDOM:[{tag:"br"}]},pageBreak:{inline:true,group:"inline",atom:true,selectable:false,toDOM:()=>["span",{"data-token":"page-break",class:"docx-page-break"}],parseDOM:[{tag:'span[data-token="page-break"]'}]},unknownInline:{inline:true,group:"inline",atom:true,selectable:false,draggable:false,attrs:{nodeId:{default:null},label:{default:""}},toDOM:t=>["span",{"data-token":"unknown","data-node-id":String(t.attrs.nodeId??""),contenteditable:"false",class:"docx-unknown-inline",title:String(t.attrs.label||"Content this editor cannot edit yet. It is preserved.")}],parseDOM:[{tag:'span[data-token="unknown"]',getAttrs:t=>typeof t=="string"?false:{nodeId:t.getAttribute("data-node-id")||null,label:""}}]}},marks:{runProps:{attrs:{props:{default:[]}},excludes:"runProps",toDOM:t=>{let e=t.attrs.props??[],n=Rn(e);return ["span",{"data-run-props":Io(e),...n?{style:n}:{}},0]},parseDOM:[{tag:"span[data-run-props]",getAttrs:t=>{if(typeof t=="string")return false;let e=Eo(t.getAttribute("data-run-props"));return e?{props:e}:false}}]}}});function Io(t){return JSON.stringify(Array.isArray(t)?t:[])}function Eo(t){if(!t)return null;try{let e=JSON.parse(t);if(!Array.isArray(e))return null;let n=[];for(let o of e){if(typeof o!="object"||o===null)return null;let s=o;if(typeof s.localName!="string"||s.attributes!==void 0&&(typeof s.attributes!="object"||s.attributes===null))return null;n.push(s.attributes===void 0?{localName:s.localName}:{localName:s.localName,attributes:s.attributes});}return n}catch{return null}}function Je(t){for(let e of t.marks)if(e.type.name==="runProps")return e.attrs.props??[];return []}function Te(t,e){return JSON.stringify(Ne(t))===JSON.stringify(Ne(e))}function Ne(t){return [...t].map(e=>({localName:e.localName,attributes:Object.fromEntries(Object.entries(e.attributes??{}).sort(([n],[o])=>n<o?-1:1))})).sort((e,n)=>e.localName<n.localName?-1:1)}function Ue(t){if(!t||t.kind==="textValue")return [];let e=[];for(let n of t.children){if(n.kind==="textValue"||n.localName==="rPrChange"||n.localName==="pPrChange")continue;let o={};for(let s of n.attributes)o[s.localName]=s.value;e.push(Object.keys(o).length>0?{localName:n.localName,attributes:o}:{localName:n.localName});}return e}function Tn(t){return t.kind==="textValue"?"":`${{drawing:"Picture",pict:"Picture",object:"Embedded object",fldSimple:"Field",hyperlink:"Hyperlink",sdt:"Content control",tbl:"Table"}[t.localName]??t.localName} \u2014 preserved, not editable yet`}function A(t){if(t.kind==="textValue")return [];let e=[],n=a=>{if(a.kind!=="run")return;let r=a.children.find(u=>u.kind==="runProperties"),d=Ue(r);for(let u of a.children)if(u.kind!=="runProperties"){if(u.kind==="tab"){e.push({kind:"tab"});continue}if(u.kind==="hardBreak"){e.push(Wa(u)?{kind:"pageBreak"}:{kind:"hardBreak"});continue}if(u.kind==="text"){let m="";for(let f of u.children)f.kind==="textValue"&&(m+=f.value);m.length>0&&e.push({kind:"text",text:m,props:d});continue}e.push({kind:"unknown",nodeId:u.id,label:Tn(u),modelLength:u.kind==="drawing"||Zc(u)||Hc(u)?1:0});}},o=a=>{if(a.kind==="run"){n(a);return}e.push({kind:"unknown",nodeId:a.id,label:Tn(a),modelLength:0});},s=(a,r)=>{for(let d of a)if(!(d.kind==="textValue"||d.kind==="paragraphProperties")&&!(r>=la)){if(na(d)&&!ka$1(d.kind)&&r<la){s(d.children.filter(u=>!ig(d,u)),ma$1(d,r));continue}if(rc(d)){let u=tc(d);u&&s(u,ma$1(d,r));continue}o(d);}};return s(t.children,0),e}function ne(t){let e=[],n=o=>{if(o.kind!=="textValue"){if(o.kind==="body"){for(let s of o.children)s.kind==="paragraph"&&e.push(s);return}for(let s of o.children)n(s);}};return n(t.root),e}var Nn=Yg(16),In=new WeakMap;function Mo(t,e){let n=In.get(t);if(!n){let o=[];pc([t],o,0),n=Object.freeze(o),In.set(t,n);}for(let o of n)e.push(o);}function F(t){let e=Nn.get(t);if(e)return e;let n=[];for(let o of lc(t))if(o.root.kind!=="textValue")for(let s of o.root.children)Mo(s,n);return Nn.set(t,n),n}function X(t){let e=ne(t).map(n=>{let o=n.kind==="textValue"?void 0:n.children.find(a=>a.kind==="paragraphProperties"),s=A(n).map(a=>{switch(a.kind){case "text":return E.text(a.text,a.props.length>0?[E.marks.runProps.create({props:a.props})]:[]);case "tab":return E.node("tab");case "hardBreak":return E.node("hardBreak");case "pageBreak":return E.node("pageBreak");default:return E.node("unknownInline",{nodeId:a.nodeId,label:a.label})}});return E.node("paragraph",{nodeId:n.id,props:Ue(o)},s)});return E.node("doc",null,e.length>0?e:[E.node("paragraph")])}function wo(t,e){let n=[];return t.forEach(o=>{if(o.isText&&o.text){n.push({kind:"text",text:o.text,props:Je(o)});return}o.type.name==="tab"?n.push({kind:"tab"}):o.type.name==="hardBreak"?n.push({kind:"hardBreak"}):o.type.name==="pageBreak"?n.push({kind:"pageBreak"}):o.type.name==="unknownInline"&&n.push({kind:"unknown",nodeId:String(o.attrs.nodeId??""),label:String(o.attrs.label??""),modelLength:e.has(String(o.attrs.nodeId??""))?1:0});}),n}function w(t){let e="";for(let n of t)n.kind==="text"?e+=n.text:n.kind==="tab"?e+=" ":n.kind==="hardBreak"?e+=`
|
|
2
|
+
`:n.kind==="pageBreak"?e+=Ua:n.modelLength===1&&(e+=he);return e}function L(t){let e=[],n=0;for(let o of t)o.kind==="text"?n+=o.text.length:o.kind==="tab"||o.kind==="hardBreak"||o.kind==="pageBreak"?n+=1:(e.push(`${o.nodeId}@${n}`),n+=o.modelLength);return e}function Co(t,e){if(t===e)return null;let n=0,o=Math.min(t.length,e.length);for(;n<o&&t[n]===e[n];)n+=1;let s=t.length,a=e.length;for(;s>n&&a>n&&t[s-1]===e[a-1];)s-=1,a-=1;return {start:n,endBefore:s,endAfter:a}}function En(t){let e=[];for(let n of t)if(n.kind==="text")for(let o=0;o<n.text.length;o+=1)e.push(n.props);else n.kind==="tab"||n.kind==="hardBreak"||n.kind==="pageBreak"?e.push(e[e.length-1]??[]):n.kind==="unknown"&&n.modelLength===1&&e.push([]);return e}function Do(t,e,n,o,s){let a=[],r=w(e),d=w(n),u=Co(r,d),m=[],f=0,x=false;for(let y of e){if(y.kind!=="unknown"){f+=y.kind==="text"?y.text.length:1;continue}let c=f;y.modelLength===1&&u&&(u.start<f+1&&u.endBefore>f&&(x=true),u.endBefore<=f&&(c+=u.endAfter-u.endBefore)),m.push(`${y.nodeId}@${c}`),f+=y.modelLength;}if(x||JSON.stringify(m)!==JSON.stringify(L(n)))return {ok:false,reason:"unknown-content-moved",detail:t};if(Te(o,s)||a.push({op:"setParagraphProperties",paragraphId:t,properties:Ne(s)}),u&&(u.endBefore>u.start&&a.push({op:"deleteText",paragraphId:t,start:u.start,end:u.endBefore}),u.endAfter>u.start)){let y=d.slice(u.start,u.endAfter),c=u.start,h="",P=()=>{h.length!==0&&(a.push({op:"insertText",paragraphId:t,offset:c,text:h}),c+=h.length,h="");};for(let b of y)b===" "?(P(),a.push({op:"insertTab",paragraphId:t,offset:c}),c+=1):b===`
|
|
3
|
+
`?(P(),a.push({op:"insertHardBreak",paragraphId:t,offset:c}),c+=1):b===Ua?(P(),a.push({op:"insertPageBreak",paragraphId:t,offset:c}),c+=1):h+=b;P();}if(!u){let y=En(e),c=En(n),h=0;for(;h<c.length;){if(Te(y[h]??[],c[h])){h+=1;continue}let P=h,b=c[h];for(;h<c.length&&Te(c[h],b)&&!Te(y[h]??[],c[h]);)h+=1;a.push({op:"setRunProperties",paragraphId:t,start:P,end:h,properties:Ne(b)});}}return {ok:true,ops:a}}function Ge(t,e){let n=ne(t),o=new Set;for(let d of n)for(let u of A(d))u.kind==="unknown"&&u.modelLength===1&&o.add(u.nodeId);let s=d=>wo(d,o),a=[];if(e.forEach(d=>{d.type.name==="paragraph"&&a.push(d);}),a.length!==e.childCount)return {ok:false,reason:"unsupported-node"};let r=a.length-n.length;if(r===0){let d=[];for(let[u,m]of a.entries()){let f=n[u];if(m.attrs.nodeId!==f.id)return {ok:false,reason:"paragraph-reordered",detail:String(m.attrs.nodeId)};let x=Do(f.id,A(f),s(m),Ue(f.kind==="textValue"?void 0:f.children.find(y=>y.kind==="paragraphProperties")),m.attrs.props??[]);if(!x.ok)return x;d.push(...x.ops);}return {ok:true,ops:d}}return r===1?Ao(n,a,s):r===-1?Fo(n,a,s):{ok:false,reason:"paragraph-count-unexplained",detail:String(r)}}function Ao(t,e,n){for(let o=0;o<t.length;o+=1){let s=t[o],a=e[o],r=e[o+1];if(!a||!r||a.attrs.nodeId!==s.id)continue;let d=r.attrs.nodeId;if(d!==null&&d!==s.id)continue;let u=n(a),m=n(r),f=A(s),x=w(u);if(x+w(m)===w(f)&&JSON.stringify(L([...u,...m]))===JSON.stringify(L(f))&&Mn(t,e,o,n)&&wn(t,e,o+1,o+2,n))return {ok:true,ops:[{op:"splitParagraph",paragraphId:s.id,offset:x.length}]}}return {ok:false,reason:"split-not-clean"}}function Fo(t,e,n){for(let o=0;o+1<t.length;o+=1){let s=t[o],a=t[o+1],r=e[o];if(!r||r.attrs.nodeId!==s.id)continue;let d=[...A(s),...A(a)],u=n(r);if(w(u)===w(d)&&JSON.stringify(L(u))===JSON.stringify(L(d))&&Mn(t,e,o,n)&&wn(t,e,o+2,o+1,n))return {ok:true,ops:[{op:"joinParagraphs",firstId:s.id,secondId:a.id}]}}return {ok:false,reason:"join-not-clean"}}function Mn(t,e,n,o){for(let s=0;s<n;s+=1){let a=e[s],r=t[s];if(!a||a.attrs.nodeId!==r.id||w(o(a))!==w(A(r))||JSON.stringify(L(o(a)))!==JSON.stringify(L(A(r))))return false}return true}function wn(t,e,n,o,s){for(let a=0;n+a<t.length;a+=1){let r=t[n+a],d=e[o+a];if(!d||d.attrs.nodeId!==r.id||w(s(d))!==w(A(r))||JSON.stringify(L(s(d)))!==JSON.stringify(L(A(r))))return false}return true}function Bo(t,e){return Ha(t,e)!==null}function Ke(t,e,n){if(!n||n.created.length>0||n.deleted.length>0||n.splitJoin.length>0)return X(e);let o=new Map;t.forEach(u=>{let m=u.attrs.nodeId;typeof m=="string"&&o.set(m,u);});let s=new Set(n.dirty),a=ne(e);if(a.length!==t.childCount)return X(e);let r=X(e),d=[];for(let[u,m]of a.entries()){let f=o.get(m.id);d.push(f&&!s.has(m.id)?f:r.child(u));}return E.node("doc",null,d)}var Lo=8*1024*1024;function Cn(){let t=new WeakMap;return e=>{let n=t.get(e);if(n)return n.slice();let o=Jd(e);return t=new WeakMap,o.byteLength<=Lo&&t.set(e,o.slice()),o}}function An(t){return F(t).map(e=>rj(t,e.id)??"").join(`
|
|
4
|
+
`)}var _o=64,Dn=new WeakMap;function Xe(t,e=0){if(e>_o)return false;let n=Dn.get(t);if(n!==void 0)return n;let o=false;for(let s of t.children)if(s.kind!=="textValue"&&(s.kind==="commentRangeStart"||s.kind==="commentReference"||Xe(s,e+1))){o=true;break}return Dn.set(t,o),o}function jo(t,e){let n=t.kind==="revision"?t.ranges[0]??null:t.range;if(!n)return null;let o=e.get(n.start.paragraphId);return o===void 0?null:o}function Fn(t,e,n){for(let s of e)if(s.ranges.length===0)return false;let o=new Set;for(let s of t)s.kind!=="revision"||s.ranges.length>0||Ln(s,n)||o.add(ma(s));for(let s of e)if(o.has(ma(s)))return false;return true}function Bn(t,e,n,o){let s=e.get(n);if(s===void 0)return [...t];let a=[],r=null;for(let d of t){if(d.kind==="revision"&&Ln(d,n)){r===null&&(r=a.length);continue}if(r===null){let u=jo(d,e);u!==null&&u>s&&(r=a.length);}a.push(d);}if(r===null&&(r=a.length),o.length>0){let d=o.length<2?[...o]:[...o].sort((u,m)=>pa(u,e)-pa(m,e));a.splice(r,0,...d);}return Ba(a)}function Ln(t,e){return t.ranges.length>0&&t.ranges.every(n=>n.start.paragraphId===e&&n.end.paragraphId===e)}function Ho(t,e){return t.range?t.range.start.paragraphId===e||t.range.end.paragraphId===e:false}function $o(t,e){return t.revisionKind==="structural"&&t.ranges.some(n=>n.start.paragraphId===e||n.end.paragraphId===e)}function zo(t,e){return t.ranges.length===0||!t.ranges.some(o=>o.start.paragraphId===e||o.end.paragraphId===e)?false:!t.ranges.every(o=>o.start.paragraphId===e&&o.end.paragraphId===e)}function _n(t,e,n,o,s,a,r){if(t.fromRevision!==e.bodyRevision||r!==e.packageRevision+1||t.story!==void 0&&t.story.kind!=="body"||t.impact!=="text-local"||t.dirty.length!==1||t.created.length>0||t.deleted.length>0||t.splitJoin.length>0||e.commentsPart!==s||e.commentsExtendedPart!==a)return null;let d=t.dirty[0],u=Ha(o,d);if(!u||u.kind!=="paragraph")return null;let m=Ia$1(o,d);if(m){let f=m.children.findIndex(y=>y.id===d),x=m.children[f-1];if(x?.kind==="paragraph"&&vi({...o,root:x}).some(y=>y.paragraphMark))return null}for(let f of n){if(f.kind==="comment"){if(Ho(f,d))return null;continue}if(f.kind==="custom"){if(f.range?.start.paragraphId===d)return null;continue}if($o(f,d)||zo(f,d))return null}return d}var $n=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u,Wo=["ascii","hAnsi","cs","eastAsia"],Yo=["asciiTheme","hAnsiTheme","cstheme","eastAsiaTheme"],Jo=128,Uo=/[\u0000-\u001F\u007F-\u009F]/;function C(t){return t.kind!=="textValue"}function V(t,e){return t.attributes.find(n=>n.localName===e)?.value}function zn(t,e){let n=new Map;for(let s of t)for(let a of s.children)if(C(a))for(let[r,d]of Jn(a,e))n.has(r)||n.set(r,d);let o=[...n.values()];return o.sort((s,a)=>s<a?-1:s>a?1:0),o}var Ve=new WeakMap,Wn=16,Yn=32;function Jn(t,e,n=0){let o=e?.major??null,s=e?.minor??null,a=e?.majorEastAsia??null,r=e?.minorEastAsia??null,d=e?.majorBidi??null,u=e?.minorBidi??null,m=Ve.get(t);if(m&&m.major===o&&m.minor===s&&m.majorEastAsia===a&&m.minorEastAsia===r&&m.majorBidi===d&&m.minorBidi===u)return m.byFold;if(t.children.length>=Wn&&n<Yn&&t.localName!=="rFonts"){let c=new Map;for(let h of t.children)if(C(h))for(let[P,b]of Jn(h,e,n+1))c.has(P)||c.set(P,b);return Ve.set(t,{major:o,minor:s,majorEastAsia:a,minorEastAsia:r,majorBidi:d,minorBidi:u,byFold:c}),c}let f=new Map,x=c=>{if(!c||!$n.test(c))return;let h=c.toLowerCase();f.has(h)||f.set(h,c);},y=[t];for(;y.length>0;){let c=y.pop();if(C(c)){if(c.localName==="rFonts"){for(let h of Wo)x(V(c,h));if(e)for(let h of Yo)x(b$3(V(c,h),e));}for(let h=c.children.length-1;h>=0;h-=1)y.push(c.children[h]);}}return Ve.set(t,{major:o,minor:s,majorEastAsia:a,minorEastAsia:r,majorBidi:d,minorBidi:u,byFold:f}),f}function Un(t){let e=new Map;for(let o of t)for(let s of o.children)if(C(s))for(let[a,r]of Gn(s))e.has(a)||e.set(a,r);let n=[...e.values()];return n.sort((o,s)=>o<s?-1:o>s?1:0),n}var jn=new WeakMap,Go=new Map;function Gn(t,e=0){let n=jn.get(t);if(n)return n;let o=r=>{let d=r.size===0?Go:r;return jn.set(t,d),d},s=new Map;if(t.children.length>=Wn&&e<Yn&&t.localName!=="sym"){for(let r of t.children)if(C(r))for(let[d,u]of Gn(r,e+1))s.has(d)||s.set(d,u);return o(s)}let a=[t];for(;a.length>0;){let r=a.pop();if(C(r)){if(r.localName==="sym"&&r.namespaceUri===da){let d=r.attributes.find(m=>m.localName==="font"&&(m.namespaceUri===da||m.namespaceUri===""))?.value,u=b$2(d);u!==null&&!s.has(u.toLowerCase())&&s.set(u.toLowerCase(),u);}for(let d=r.children.length-1;d>=0;d-=1)a.push(r.children[d]);}}return o(s)}function Kn(t){let e=[...t];for(;e.length>0;){let n=e.pop();if(C(n)){if(n.localName==="t"&&n.namespaceUri===da){for(let o of n.children)if(!C(o)&&o.value.length>0)return true;continue}for(let o of n.children)e.push(o);}}return false}var Ko=new Set(["paragraph","character","table","numbering"]),Xo=/^[0-9A-Fa-f]{6}$/,Vo=16,Hn=new Map([["normal",0],["title",1],["subtitle",2],["heading 1",11],["heading 2",12],["heading 3",13],["heading 4",14],["heading 5",15],["heading 6",16],["heading 7",17],["heading 8",18],["heading 9",19]]);function Xn(t){return t.children}function Qe(t,e){for(let n of Xn(t))if(C(n)&&n.localName===e)return n}function Qo(t){return Hn.get(t.name.toLowerCase())??Hn.get(t.styleId.toLowerCase())??Number.MAX_SAFE_INTEGER}function Ze(t){return t===void 0||t.length===0||t.length>Jo||Uo.test(t)?null:t}function Vn(t,e){if(!t)return [];let n=new Map;for(let a of t.children){if(!C(a)||a.localName!=="style")continue;let r=Ze(V(a,"styleId"));r!==null&&!n.has(r)&&n.set(r,a);}let o=a=>{let r=false,d=false,u=null,m=false,f=false,x=new Set,y=a;for(let P=0;P<Vo&&y!==null&&!x.has(y);P+=1){x.add(y);let b=n.get(y);if(!b)break;let R=Qe(b,"rPr");for(let v of R?Xn(R):[]){if(!C(v))continue;let T=V(v,"val"),D=T!=="0"&&T!=="false"&&T!=="off";v.localName==="b"&&!m?(r=D,m=true):v.localName==="i"&&!f?(d=D,f=true):v.localName==="color"&&u===null&&T&&Xo.test(T)&&(u=T);}let O=Qe(b,"basedOn");y=O?Ze(V(O,"val")):null;}let c=e?.(a),h=c?.fontFamily??null;return {fontFamily:h!==null&&$n.test(h)?h:null,fontSizePt:c?.fontSizeHalfPoints!=null&&c.fontSizeHalfPoints>0?c.fontSizeHalfPoints/2:null,bold:r,italic:d,color:u}},s=[];for(let[a,r]of n){let d=V(r,"type");if(d===void 0||!Ko.has(d))continue;let u=Qe(r,"name"),m=Ze(u?V(u,"val"):void 0);s.push({styleId:a,name:m??a,type:d,preview:o(a)});}return s.map((a,r)=>({entry:a,index:r,rank:Qo(a)})).sort((a,r)=>a.rank-r.rank||a.index-r.index).map(a=>a.entry)}var Zo=128,qo=/[\u0000-\u001F\u007F-\u009F]/,er=/[\u0000-\u001F\u007F-\u009F]/g,tr=200;function et(t){return t.kind!=="textValue"}function Qn(t,e){for(let n of t.children)if(et(n)&&n.localName===e)return n}function qe(t,e){return t.attributes.find(n=>n.localName===e)?.value}function nr(t){let e=new Map;if(!t)return e;for(let n of t.children){if(!et(n)||n.localName!=="style"||qe(n,"type")!=="paragraph")continue;let o=qe(n,"styleId");if(o===void 0||o.length===0||o.length>Zo||qo.test(o))continue;let s=d$1(n);s!==null&&e.set(o,s);}return e}function tt(t){let e=Qn(t,"pPr"),n=e?Qn(e,"pStyle"):void 0;return n?qe(n,"val"):void 0}function Zn(t,e){let n=nr(e);if(n.size===0)return [];let o=[];for(let s of ne(t)){if(!et(s))continue;let a=tt(s);if(a===void 0)continue;let r=n.get(a);if(r===void 0)continue;let u=(rj(t,s.id)??"").replace(er," ").trim().slice(0,tr);u.length!==0&&o.push({text:u,level:r,blockId:s.id});}return o}function or(t,e,n){let o=new Map,s=n(t);for(let a of s){let r=o.get(a.hostParagraphId);r?r.push(a):o.set(a.hostParagraphId,[a]);}return o}function rr(t,e,n){let o=[];for(let s of oc(t.root)){let a=e.get(s.id);if(a)for(let r of a)o.push(r);}return o}function qn(t,e,n=nh){let o=[],s=new Map;for(let a of t){if(o.push(a),a.scope?.kind==="note")continue;let r=s.get(a.part);r||(r=or(a.part,e,n),s.set(a.part,r));for(let d of rr(a,r)){let u=a.scope;o.push({part:a.part,root:d.root,scope:{kind:"frame",id:d.root.id,drawingNodeId:d.drawingNodeId,hostParagraphId:d.hostParagraphId,...u?.kind==="headerFooter"?{owner:u}:{}}});}}return o}var Ie=48,ar=/[\u0000-\u001F\u007F-\u009F]/g;function sr(t){let e=[],n=cf(t),o=new Map;for(let s of n.segments)pe(s.node)&&o.set(s.node.id,s.formatRunIds??[]);return yc(t.children,0,s=>{if(s.kind==="run"){e.push({id:s.id,start:n.spanOf(s)?.start??0});return}if(pe(s))for(let a of o.get(s.id)??[]){let r=n.spanOf(a);r&&e.push({id:a,start:r.start});}},{descendRevisions:true}),e}function ir(t){let e=nc(t);return e?[{part:t,root:e}]:[]}function lr(t,e){let n=[];for(let o of ["header","footer"])for(let s of t){let a=o==="header"?s.headers:s.footers;for(let[r,d]of a){if(!$d(s,r)||e.has(d.part))continue;e.add(d.part);let u=lc(d.part).find(m=>m.kind===o);u&&n.push({part:d.part,root:u.root,scope:{kind:"headerFooter",rId:d.rId}});}}return n}function eo(t,e,n){if(!t)return [];let o=[];for(let s of hc(t.root)){let a=Xb(s);!Zb(s)||a===null||!n.has(a)||o.push({part:t,root:s,scope:{kind:"note",id:Nb(e,a)}});}return o}function dr(t,e){let n=ir(t);if(e){let o=new Set;for(let s of lr(e.headerFooterBySection,o))n.push(s);for(let s of eo(e.footnotes,"footnote",e.referencedNoteIds.footnote))n.push(s);for(let s of eo(e.endnotes,"endnote",e.referencedNoteIds.endnote))n.push(s);}return qn(n)}function to(t,e){if(t.length===0)return {index:0,offset:e};for(let n=t.length-1;n>=0;n-=1){let o=t[n].start;if(e>=o)return {index:n,offset:e-o}}return {index:0,offset:e}}function cr(t,e,n){let o=t.findIndex(s=>s.id===e);return o<0?null:{index:o,offset:n}}function nt(t,e){return t.replace(ar," ").slice(0,e)}function no(t,e,n={},o){let s={matches:[],truncated:false};if(!Ga(e))return s;let a=n.limit!==void 0&&Number.isInteger(n.limit)&&n.limit>0?Math.min(n.limit,2e3):2e3,r={...n.matchCase===void 0?{}:{matchCase:n.matchCase},...n.wholeWord===void 0?{}:{wholeWord:n.wholeWord}},d$1=[],u=n.stories==="body"?void 0:o;for(let m of dr(t,u)){let f=0;for(let x of oc(m.root)){if(x.kind!=="paragraph")continue;let y=f;f+=1;let c=rj(m.part,x.id)??"",h=d(x,c);if(h.text.length===0)continue;let P=a-d$1.length,b=h.findOccurrences(e,Math.max(P,1),r);if(P===0&&b.matches.length>0)return {matches:d$1,truncated:true};let R=null;for(let O of b.matches){let v=O.start+O.length;R??=sr(x);let T=h.resultRunAddressAt(O.start),D=T?cr(R,T.runId,T.offset)??to(R,O.rawStart):to(R,O.rawStart);d$1.push({blockId:x.id,start:O.rawStart,length:O.rawEnd-O.rawStart,paragraphIndex:y,runIndex:D.index,runOffset:D.offset,...m.scope?{scope:m.scope}:{},text:nt(h.text.slice(O.start,v),256),contextBefore:nt(h.text.slice(Math.max(0,O.start-Ie),O.start),Ie),contextAfter:nt(h.text.slice(v,v+Ie),Ie)});}if(b.truncated)return {matches:d$1,truncated:true}}}return {matches:d$1,truncated:false}}var ur=["lt1","dk1","lt2","dk2","accent1","accent2","accent3","accent4","accent5","accent6"];function oe(t,e=null){return a(t,e)}function oo(t){let e=Sc(t),n=[];for(let o of ur){let s=e.get(o);if(!s)return [];n.push({slot:o,hex:s});}return n}var ro=new WeakMap;function rt(t){let e=ro.get(t);if(e!==void 0)return e;let n=_a(t),o=n===null||!Za(n)?null:n;return ro.set(t,o),o}var ot=class{#e;#t;constructor(e,n){this.#e=e,this.#t=n;}get size(){return this.#e.size}get(e){if(this.#e.has(e))return this.#t.find(n=>e.startsWith(`${n.name}#`))}has(e){return this.get(e)!==void 0}*entries(){for(let e of this.#e.keys()){let n=this.get(e);n&&(yield [e,n]);}}keys(){return this.#e.keys()}*values(){for(let[,e]of this.entries())yield e;}[Symbol.iterator](){return this.entries()}forEach(e,n){for(let[o,s]of this.entries())e.call(n,s,o,this);}};function ao(t,e){return Object.freeze({...t,partByNode:new ot(t.ordinalByNode,e)})}function so(t){let e=new Map,n=new Map,o=new Map,s=new Set,a=new Map,r=new Map,d=0;for(let u of t)for(let m of F(u)){o.set(m.id,d),a.set(m.id,u),d+=1;let f=rt(m);if(f===null)continue;e.set(m.id,f);let x=f.toUpperCase(),y=r.get(x);y?(y.push(m.id),s.add(x)):(r.set(x,[m.id]),n.set(x,m.id));}return Object.freeze({paraIdByNode:e,nodeByParaId:n,ordinalByNode:o,ambiguousParaIds:s,partByNode:a,claimantsByParaId:r})}function io(t,e){let n=t.indexOf("#");if(n<=0)return null;let o=t.slice(0,n),s=e.body.name===o?e.body:void 0;s??=e.openStories.find(d=>d.name===o);let a=s?void 0:e.otherStories.find(d=>d.name===o);if(s??=a?e.normalize(a):void 0,!s)return null;let r=Ha(s,t);return r?.kind==="paragraph"?rt(r):null}var lo={committed:false,rejected:false,opCount:0};function _(t,e){return e===void 0?{committed:false,rejected:true,opCount:t}:{committed:false,rejected:true,opCount:t,reason:e}}function co(t,e,n={}){let o=e.filter(f=>f.ops.length>0),s=n.partOps??[],a=[...o,...s].reduce((f,x)=>f+x.ops.length,0);if(a===0)return n.packageEdits?.length?_(0,"invalidArgs"):lo;if([...o,...s].some(f=>f.ops.some(Lf))||[...o,...s].some(f=>f.ops.some(Pg)))return _(a,"invalidArgs");let[r,...d]=o,u=[];for(let f of d){let x=t.partFor(f.scope);if(!x)return _(a,"unknown-part");u.push({partName:x.name,ops:f.ops});}let m=t.transact(r?.scope??{kind:"body"},f=>{for(let x of n.packageEdits??[])f.applyPackage(x);for(let x of r?.ops??[])f.apply(x);for(let x of u)for(let y of x.ops)f.applyTo(x.partName,y);for(let x of s)for(let y of x.ops)f.applyTo(x.partName,y);},n);return m.ok?{committed:true,rejected:false,opCount:a}:_(a,m.reason)}function uo(t,e,n,o,s,a){let r=a.partOps??[],d=e.length+r.reduce((x,y)=>x+y.ops.length,0);if(d===0&&!a.packageEdits?.length)return lo;if(r.some(x=>x.ops.some(y=>Lf(y)||Pg(y))))return _(d,"invalidArgs");let u=e.filter(x=>Lf(x)||Pg(x)).length;if(u>0){if(r.length||a.packageEdits?.length||u!==e.length||e.length!==1)return _(e.length,"invalidArgs");let x=gb(a.actorId,()=>t.applyLifecycleOp(e[0]));return x.ok?{committed:true,rejected:false,opCount:1}:_(1,x.detail??x.reason)}let m=a.recordsHistory===false&&a.actorId&&a.operationId?t.partFor(s)?.name:void 0,f=t.transact(s,x=>{n!==void 0&&x.selectionBefore(n),o!==void 0&&x.selectionAfter(o);for(let y of a.packageEdits??[])x.applyPackage(y);for(let y of e)x.apply(y);for(let y of r)for(let c of y.ops)x.applyTo(y.partName,c);m&&x.applyPackage(y=>a$1(y,m,e));},a);return f.ok?{committed:true,rejected:false,opCount:d}:_(d,f.reason)}var pr=Object.freeze([]);function fr(t,e$1={}){let n=Id(t);if(!n.ok)return {ok:false,reason:n.reason,...n.detail?{detail:n.detail}:{}};let o=n.package,s=o.parts.get(o.mainDocumentPart);if(!s)return {ok:false,reason:"no-main-document-tree",detail:o.mainDocumentPart};let a=eb(s),r=new Q(o,Ia(o,a)),d=null,u=null,m=null,f=null,x=null;r.subscribe(i=>{f=i,x=r.currentPackage();});let y=()=>r.bodyStore(),c$1=()=>r.currentPackage(),h=Cn(),P=Object.freeze({kind:"body"}),b=(i,l)=>{let p=l?.find(k=>k.type==="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings");if(!p)return;let g=E$1(p);return g.mode==="Internal"&&g.target.ok?i.parts.get(g.target.partName):void 0},R=(i,l,p)=>{if(i.mainRelationships!==p||i.settingsPart!==b(l,p))return false;for(let g of i.resolution)for(let k of [g.headers,g.footers])for(let S of k.values())if(l.parts.get(S.partName)!==S.part)return false;return true},O=()=>{let i=c$1(),l=i.relationships.get(i.mainDocumentPart);if(d&&f&&x===i&&R(d,i,l)&&d.packageRevision===f.fromRevision&&r.packageRevision===f.toRevision&&f.story?.kind==="body"&&f.impact==="text-local"&&f.created.length===0&&f.deleted.length===0&&f.splitJoin.length===0&&(d={...d,packageRevision:r.packageRevision,pkg:i,mainRelationships:l,settingsPart:b(i,l)}),!d||d.packageRevision!==r.packageRevision||d.pkg!==i){let p=ce(i);d={packageRevision:r.packageRevision,pkg:i,mainRelationships:l,settingsPart:b(i,l),resolution:p,parts:be(p)};}return d},v="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",T="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",D=null,j=()=>{let i=c$1(),l=(i.relationships.get(i.mainDocumentPart)??[]).find(k=>k.type===v),p;if(l){let k=E$1(l);k.mode==="Internal"&&k.target.ok&&(p=i.parts.get(k.target.partName));}p??=i.parts.get("/word/styles.xml");let g=p?.root??null;return g!==D&&(D=g,ie=null,G=null),D},J=null,B=null,Ee=()=>{let i=c$1();if(J===i)return B;J=i;let l=(i.relationships.get(i.mainDocumentPart)??[]).find(g=>g.type===T),p;if(l){let g=E$1(l);g.mode==="Internal"&&g.target.ok&&(p=i.parts.get(g.target.partName));}return p??=i.parts.get("/word/numbering.xml"),B=p?.root??null,B},fo="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",at=null,ue=null,U=()=>{let i=c$1();if(at===i)return ue;at=i;let l=(i.relationships.get(i.mainDocumentPart)??[]).find(k=>k.type===fo),p;if(l){let k=E$1(l);k.mode==="Internal"&&k.target.ok&&(p=i.parts.get(k.target.partName));}p??=i.parts.get("/word/settings.xml");let g=p?.root??null;return g!==ue&&(ue=g,me=null,ie=null,G=null),ue},mo="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",go="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",st=(i,l)=>{let p=c$1(),g=(p.relationships.get("/")??[]).find(S=>S.type===i),k;if(g){let S=E$1(g);S.mode==="Internal"&&S.target.ok&&(k=p.parts.get(S.target.partName));}return k??p.parts.get(l)},it=null,Me=lh,yo=()=>{let i=c$1();if(it===i)return Me;it=i;let l=st(mo,"/docProps/core.xml"),p=st(go,"/docProps/app.xml");return Me=mh(l?.root??null,p?.root??null),Me},ho="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",lt=null,pe=null,Q$1=()=>{let i=c$1();if(lt===i)return pe;lt=i;let l=(i.relationships.get(i.mainDocumentPart)??[]).find(k=>k.type===ho),p;if(l){let k=E$1(l);k.mode==="Internal"&&k.target.ok&&(p=i.parts.get(k.target.partName));}p??=i.parts.get("/word/theme/theme1.xml");let g=p?.root??null;return g!==pe&&(pe=g,me=null,we=null,ie=null,G=null),pe},xo="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",fe=null,ko=()=>{if(fe)return fe;let i=c$1(),l=(i.relationships.get(i.mainDocumentPart)??[]).find(g=>g.type===xo),p;if(l){let g=E$1(l);g.mode==="Internal"&&g.target.ok&&(p=i.parts.get(g.target.partName));}return p??=i.parts.get("/word/fontTable.xml"),fe=Object.freeze(ge(i,p)),fe},re=null,Z$1=null,ae=null,se=null,ie=null,we=null,me=null,dt=()=>{let i=[y().part.root],l=new Set;for(let p of H())l.has(p)||(l.add(p),i.push(p.root));return i},Ce=()=>{let i=dt(),l=j();return l&&i.splice(1,0,l),i},G=null,ge$1=null,le=null,de=null,q=null,ct=new WeakMap,ye=null,ut=i=>{let l=ct.get(i);if(l)return l;let p=eb(i);return ct.set(i,p),p},pt=()=>{let i=r.packageRevision,l=r.openStoryToken();if(!q||q.revision!==i||q.openStories!==l){let p=r.openStoryParts(),g=new Set(p.map(M=>M.name)),k=H().filter(M=>!g.has(M.name)).map(ut),S=[y().part,...p,...k],N=q,I=N!==null&&f!==null&&N.openStories===l&&N.revision===f.fromRevision&&i===f.toRevision&&f.impact==="text-local"&&f.created.length===0&&f.deleted.length===0&&f.splitJoin.length===0&&N.parts.length===S.length&&N.parts.every((M,ee)=>M.name===S[ee]?.name);q={revision:i,openStories:l,parts:S,index:I&&N?ao(N.index,S):so(S)};}return q.index},ft=()=>{let i=y().part.name,l=new Map;for(let p of [y().part,...H()])for(let[g,k]of ha(c$1(),p.name,i))l.set(g,k);return l},Po=()=>[y().part,...H()],H=()=>{let i=[],l=new Set;for(let g of O().parts)for(let k of [g.headers,g.footers])for(let S of k.values())l.has(S)||(l.add(S),i.push(S));let p=c$1();for(let g of ["footnote","endnote"]){let k=bg(p,g);!k||l.has(k)||(l.add(k),i.push(k));}return i};return {ok:true,session:{editable:F(y().part).length>0,paragraphIds:()=>F(y().part).map(i=>i.id),paragraphIdsIn(i=P){let l=r.partFor(i);return l?F(l).map(p=>p.id):[]},part:()=>y().part,partFor:i=>r.partFor(i),currentPackage:c$1,collaborationPort:i=>b$1(r,{documentId:i}),applyTreeOps(i,l,p,g=P,k={}){return uo(r,i,l,p,g,k)},applyTreeOpsAtomic(i,l={}){return co(r,i,l)},projectDoc:()=>X(y().part),reconcile:i=>Ke(i,y().part,f),lastCommitWasStructural:()=>f!==null&&(f.created.length>0||f.deleted.length>0||f.splitJoin.length>0||f.impact==="global"),applyPmDoc(i){let l=y(),p=Ge(l.part,i);if(!p.ok)return {committed:false,rejected:true,opCount:0,reason:p.reason};if(p.ops.length===0)return {committed:false,rejected:false,opCount:0};let g=r.transact(P,k=>{for(let S of p.ops)k.apply(S);});return g.ok?{committed:true,rejected:false,opCount:p.ops.length}:{committed:false,rejected:true,opCount:p.ops.length,reason:g.reason}},storyParts:Po,bodyText:()=>An(y().part),storyText(i){let l=r.partFor(i);return l?F(l).map(p=>rj(l,p.id)??"").join(`
|
|
5
|
+
`):null},revision:()=>y().revision,revisionFor:i=>r.revisionFor(i),packageRevision:()=>r.packageRevision,canUndo:()=>r.canUndo,canRedo:()=>r.canRedo,undo:()=>{let i=r.selectionForUndo();return r.undo()===null?null:i},redo:()=>{let i=r.selectionForRedo();return r.redo()===null?null:i},beginComposition:(i=P)=>{r.beginComposition(i);},endComposition:()=>r.endComposition(),subscribe(i){return r.subscribe(i)},save(){return h(c$1())},headerFooterParts:()=>{let i=O().parts;return i[i.length-1]??ee(c$1())},headerFooterPartsBySection:()=>O().parts,headerFooterResolutionBySection:()=>O().resolution,documentFonts(){return re&&re.revision===r.packageRevision||(re={revision:r.packageRevision,fonts:zn(Ce(),oe(Q$1(),U()))}),re.fonts},symbolFontFamilies(){return ae&&ae.revision===r.packageRevision||(ae={revision:r.packageRevision,fonts:Un(Ce())}),ae.fonts},renderedFontFamilies(){let i=j();return Z$1&&Z$1.revision===r.packageRevision&&Z$1.styles===i||(Z$1={revision:r.packageRevision,styles:i,families:e(dt(),i,oe(Q$1(),U()))}),Z$1.families},rendersText(){return se&&se.revision===r.packageRevision||(se={revision:r.packageRevision,rendersText:Kn(Ce())}),se.rendersText},documentStyles(){let i=j(),l=Q$1(),p=U();G??=c(i,oe(l,p));let g=G;return ie??=Vn(i,k=>g(k)),ie},stylesRoot:()=>j(),documentThemeFonts(){let i=Q$1(),l=U();return me??=oe(i,l),me},numberingRoot:()=>Ee(),settingsRoot:()=>U(),documentProperties:()=>yo(),trackingSettings:()=>ih(U()),documentThemeColors(){let i=Q$1();return we??=oo(i),we},effectiveRunDefaults(i,l){let p=j(),g=Q$1(),k=U();G??=c(p,oe(g,k));let S=y();if(!ge$1||ge$1.revision!==S.revision){let N=new Map;for(let I of F(S.part))I.kind!=="textValue"&&N.set(I.id,tt(I)??null);ge$1={revision:S.revision,byId:N};}return G(ge$1.byId.get(i)??null,l)},documentOutline(){let i=y();return le&&le.revision===i.revision||(le={revision:i.revision,outline:Zn(i.part,j())}),le.outline},findText(i,l){let p=y(),g=r.packageRevision,k=`${l?.matchCase===true?"c":""}${l?.wholeWord===true?"w":""}${l?.limit??""}:${l?.stories??"all"}\0${i}`;if(de&&de.revision===g&&de.key===k)return de.result;let S=c$1(),N={footnote:new Set,endnote:new Set};for(let M of cg(p.part))N[M.noteKind].add(M.noteId);let I=no(p.part,i,l??{},{headerFooterBySection:O().resolution,footnotes:bg(S,"footnote")??null,endnotes:bg(S,"endnote")??null,referencedNoteIds:N});return de={revision:g,key:k,result:I},I},embeddedFonts:ko,paragraphAnchors:pt,paraIdOf:i=>io(i,{body:y().part,openStories:r.openStoryParts(),otherStories:H(),normalize:ut}),nodeIdOf:i=>pt().nodeByParaId.get(i.toUpperCase())??null,relationshipTarget:(i,l=P)=>{let p=c$1(),g=r.partFor(l);return g?Hf(p,g.name,i):null},bookmarks:()=>{let i=r.packageRevision;if(!ye||ye.revision!==i){let l=new Map(_if(y().part));for(let p of H())for(let[g,k]of _if(p))l.has(g)||l.set(g,k);ye={revision:i,index:l};}return ye.index},ensureHyperlinkRelationship(i,l=P){let p=r.partFor(l);return p?Ca(r,()=>{let g=c$1(),k=Gf(g,i,p.name);return k?(k.pkg!==g&&r.replacePackageShell(k.pkg),k.relationshipId):null},g=>g!==null):null},reviewItems(){let i=e$1.reviewModel;if(!i)return pr;let l=y(),p=`${r.packageRevision}:${l.revision}`;if(u&&u.revisionKey===p)return u.items;let g=c$1(),k=g.parts.get(Z(g,l.part.name)),S=g.parts.get(_$1(g,l.part.name)),N=H(),I=u&&f?_n(f,u,u.items,l.part,k,S,r.packageRevision):null,M,ee;if(I&&u){let mt=i.revisionItemsOfParagraph(l.part,I);Fn(u.items,mt,I)?(M=Bn(u.items,u.paragraphOrder,I,mt),ee=u.paragraphOrder):(ee=Ii(l.part),M=i.collectReviewItems({storyPart:l.part,furnitureParts:N,stylesPart:Ac(g),commentsPart:k,commentsExtendedPart:S,customNodePayloads:ft()}));}else ee=Ii(l.part),M=i.collectReviewItems({storyPart:l.part,furnitureParts:N,stylesPart:Ac(g),commentsPart:k,commentsExtendedPart:S,customNodePayloads:ft()});return u={revisionKey:p,bodyRevision:l.revision,packageRevision:r.packageRevision,items:M,paragraphOrder:ee,commentsPart:k,commentsExtendedPart:S},u.items},hasReviewContent(){let i=r.packageRevision;if(!m||m.revision!==i){let l=Ac(c$1()),p=[y().part,...H(),...l?[l]:[]];m={revision:i,present:p.some(g=>vi(g).length>0||Xe(g.root))};}return m.present},replyToComment(i,l,p,g,k,S=P,N){let I=$(r,{anchor:{paragraphId:l.paragraphId,start:l.start,end:l.end,...l.endParagraphId===void 0?{}:{endParagraphId:l.endParagraphId}},author:g,text:p,...k===void 0?{}:{date:k},...i===null?{}:{replyToCommentId:i},...N===void 0?{}:{actorId:N}},S);return I.ok?I.commentId:null},setCommentResolved(i,l){return aa(r,i,l).ok},deleteComment(i,l=P,p){return this.deleteComments([{commentId:i}],l,p)},deleteComments(i,l=P,p){return ba(r,i,l,p)},insertCustomNode(i,l=P){return ja(r,i,l)},removeCustomNode(i,l=P){return ka(r,i,l)},sweepCustomNodePayloads(i){return Ca(r,()=>{let l=y(),p=ga(r.currentPackage(),l.part.name,i);return p.ok?p.removed.length===0?{ok:true,removed:[]}:(r.replacePackageShell(p.pkg),{ok:true,removed:p.removed}):{ok:false,reason:p.reason}},l=>l.ok&&l.removed.length>0)},ensureListDefinition(i){return Ca(r,()=>{let l=zf(c$1(),i);return l?(r.replacePackageShell(l.pkg),J=null,B=null,l.numId):null},l=>l!==null)},ensureNumberingLevel(i,l,p){return Ca(r,()=>{let g=c$1(),k=Af(g,i,l,p);return k?k!==g?(r.replacePackageShell(k),J=null,B=null,{ok:true,changed:true}):{ok:true,changed:false}:{ok:false,changed:false}},g=>g.changed).ok},insertImage(i,l){return r.insertImage(i,l)},replaceImage(i,l,p,g,k,S){return r.replaceImage(i,l,p,g,k,S)},deleteImage(i,l){return r.deleteImage(i,l)},deleteImageTracked(i,l,p){return r.deleteImageTracked(i,l,p)},applyImageProperties(i,l){return r.applyImageProperties(i,l)},applyFragmentPaste(i,l){return r.applyFragmentPaste(i,l)}}}}var mr=b.projection;function vr(t,e,n){let o=t.filter(s=>s.localName!==e);return o.length!==t.length?o:[...o,n?{localName:e,attributes:n}:{localName:e}]}function Tr(t,e,n={}){let o=null,s=false,a=()=>n.onChange?.(r()),r=()=>({revision:e.revision(),canUndo:e.canUndo(),canRedo:e.canRedo(),lastRejection:o}),d=c=>{s=true;let h=m.state.tr.replaceWith(0,m.state.doc.content.size,c.content);h.setMeta("addToHistory",false),m.dispatch(h),s=false;},u=c=>()=>(c()&&(d(e.projectDoc()),a()),true),m=new EditorView(t,{state:EditorState.create({doc:e.projectDoc(),plugins:[keymap({...baseKeymap,Home:selectTextblockStart,End:selectTextblockEnd,"Mod-z":u(()=>e.undo()!==null),"Mod-y":u(()=>e.redo()!==null),"Shift-Mod-z":u(()=>e.redo()!==null),"Mod-b":(c,h)=>y(c,h,"b"),"Mod-i":(c,h)=>y(c,h,"i"),"Mod-u":(c,h)=>y(c,h,"u",{val:"single"})})]}),editable:()=>e.editable,handleDOMEvents:{keydown:c=>(f(c),false),beforeinput:(c,h)=>{let P=h;if(c.composing)return false;f(c);let b=P.inputType;if(b==="insertText"&&P.data!=null){P.preventDefault();let{from:R,to:O}=c.state.selection;return c.dispatch(c.state.tr.insertText(P.data,R,O)),true}if(b==="deleteContentBackward"){P.preventDefault();let{from:R,empty:O}=c.state.selection;return O?R>0?c.dispatch(c.state.tr.delete(R-1,R)):joinBackward(c.state,c.dispatch):deleteSelection(c.state,c.dispatch),true}if(b==="deleteContentForward"){P.preventDefault();let{from:R,to:O,empty:v}=c.state.selection;return v?O<c.state.doc.content.size?c.dispatch(c.state.tr.delete(R,R+1)):joinForward(c.state,c.dispatch):deleteSelection(c.state,c.dispatch),true}return b==="insertParagraph"?(P.preventDefault(),splitBlock(c.state,c.dispatch),true):false},compositionstart:()=>(e.beginComposition(),false),compositionend:()=>(e.endComposition(),a(),false)},dispatchTransaction(c){let h=m.state.apply(c);if(s||!c.docChanged){m.updateState(h);return}let P=e.applyPmDoc(h.doc);if(P.rejected){o=String(P.reason??"rejected"),m.updateState(h),d(e.projectDoc()),a();return}o=null,m.updateState(P.committed&&e.lastCommitWasStructural()?x(h):h),a();}});function f(c){if(c.composing||s)return;let h=c.dom.ownerDocument.getSelection(),P=h?.anchorNode,b=h?.focusNode;if(!(!h||!P||!b)&&!(!c.dom.contains(P)||!c.dom.contains(b)))try{let R=c.posAtDOM(P,h.anchorOffset),O=c.posAtDOM(b,h.focusOffset),v=c.state.selection;if(v.anchor===R&&v.head===O)return;let T=TextSelection.create(c.state.doc,R,O);c.dispatch(c.state.tr.setSelection(T).setMeta("addToHistory",!1));}catch{}}function x(c){let h=e.paragraphIds(),P=c.tr,b=false,R=0;return c.doc.forEach((O,v)=>{let T=h[R];R+=1,!(O.type.name!=="paragraph"||T===void 0)&&O.attrs.nodeId!==T&&(P=P.setNodeMarkup(v,void 0,{...O.attrs,nodeId:T}),b=true);}),b?c.apply(P.setMeta("addToHistory",false)):c}function y(c,h,P,b){let R=E.marks.runProps;if(!h)return true;let{from:O,to:v,empty:T}=c.selection;if(T)return true;let j=c.doc.resolve(O).marks().find(Ee=>Ee.type===R)?.attrs.props??[],J=vr(j,P,b),B=c.tr;return B.removeMark(O,v,R),J.length>0&&B.addMark(O,v,R.create({props:J})),h(B),true}return {view:m,state:r,undo:()=>u(()=>e.undo()!==null)(),redo:()=>u(()=>e.redo()!==null)(),toggleRunProperty(c,h){y(m.state,m.dispatch.bind(m),c,h);},destroy:()=>m.destroy()}}export{E as a,Je as b,ne as c,F as d,X as e,Ge as f,Bo as g,Ke as h,tt as i,fr as j,mr as k,Tr as l};
|