@docx-editor.dev/core 2.21.0 → 2.22.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 +41 -35
- package/dist/automation.cjs +1 -1
- package/dist/automation.d.ts +10 -10
- package/dist/automation.js +1 -1
- package/dist/binding.cjs +1 -1
- package/dist/binding.d.ts +8 -8
- package/dist/binding.js +1 -1
- package/dist/{chunk-Q2B6HX3R.js → chunk-5RKCJ5DF.js} +1 -1
- package/dist/chunk-65GJRSZ5.cjs +18 -0
- package/dist/chunk-6TBRG6SA.cjs +20 -0
- package/dist/chunk-A72MJGY7.cjs +4 -0
- package/dist/chunk-AZ7QSAXH.js +4 -0
- package/dist/chunk-BL57VQ7E.js +1 -0
- package/dist/chunk-CB6RQ3GD.cjs +11 -0
- package/dist/chunk-GG4IAKFI.js +5 -0
- package/dist/chunk-HJYLFMLX.js +2 -0
- package/dist/chunk-HL6NO7IH.cjs +2 -0
- package/dist/chunk-HZQFGB2X.cjs +5 -0
- package/dist/{chunk-X5QNSISI.js → chunk-IWAUA732.js} +1 -1
- package/dist/chunk-OZXBAEWW.js +2 -0
- package/dist/{chunk-4EHMMSFR.cjs → chunk-P5PWSRNW.cjs} +1 -1
- package/dist/{chunk-BDAY2ETZ.js → chunk-PD5XKBJA.js} +1 -1
- package/dist/chunk-REMFTPDL.cjs +2 -0
- package/dist/{chunk-Z2ETEZRU.cjs → chunk-RLKX7BIP.cjs} +1 -1
- package/dist/chunk-UGLO2GA5.cjs +1 -0
- package/dist/chunk-UOQONZVQ.js +11 -0
- package/dist/chunk-VD2MWTR6.js +20 -0
- package/dist/chunk-VIXH2OVP.js +1 -0
- package/dist/chunk-W2JIZ5JH.js +18 -0
- package/dist/chunk-W5H62AWM.cjs +1 -0
- package/dist/chunk-X2LJDR53.cjs +5 -0
- package/dist/chunk-YQXY6TQ3.js +5 -0
- package/dist/{chunk-PYXMAUNR.cjs → chunk-YYFBYVW4.cjs} +1 -1
- package/dist/collaboration/replication.cjs +1 -1
- package/dist/collaboration/replication.d.ts +4 -4
- package/dist/collaboration/replication.js +1 -1
- package/dist/collaboration.d.ts +3 -3
- package/dist/contracts/document.d.ts +2 -2
- package/dist/contracts/editor.d.ts +8 -8
- package/dist/contracts/modules.d.ts +6 -6
- package/dist/contracts/types.d.ts +1 -1
- package/dist/{custom-node-writes-05qS32px.d.ts → custom-node-writes-Ck6eOiJ3.d.ts} +2 -2
- package/dist/{document-protection-Cr59VKLO.d.ts → document-protection-CMPEonQc.d.ts} +1 -1
- package/dist/{editor-BsLSz_7y.d.ts → editor-BKDVqXyk.d.ts} +75 -50
- package/dist/editor.cjs +1 -1
- package/dist/editor.css +1 -1
- package/dist/editor.d.ts +188 -26
- package/dist/editor.js +1 -1
- package/dist/export.cjs +2 -2
- package/dist/export.d.ts +31 -14
- package/dist/export.js +2 -2
- package/dist/{font-resolver-CzwdBJDE.d.ts → font-resolver-PBc8Vuxs.d.ts} +1 -1
- package/dist/{headless-document-view-B7nAiR7P.d.ts → headless-document-view-9wjJT20Y.d.ts} +2 -2
- package/dist/{image-resources-C4ilLzog.d.ts → image-resources-B0v-XaTM.d.ts} +2 -2
- package/dist/{index-zkvqBQ9o.d.ts → index-DQA53aR1.d.ts} +139 -20
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +17 -17
- package/dist/index.js +1 -1
- package/dist/{layout-shaping-BJKVTI6i.d.ts → layout-shaping-Dyr0ZSOI.d.ts} +5 -2
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.ts +378 -33
- package/dist/layout.js +1 -1
- package/dist/{note-properties-MNztEj5s.d.ts → note-properties-D_lmG9xx.d.ts} +1 -1
- package/dist/{omml-equation-CbnW9yXd.d.ts → omml-equation-CfTm3jOK.d.ts} +1 -1
- package/dist/output.cjs +1 -1
- package/dist/output.d.ts +7 -7
- package/dist/output.js +1 -1
- package/dist/{protocol-Co_r0SZQ.d.ts → protocol-CkVDxyQ3.d.ts} +2 -2
- package/dist/{review-paragraph-order-EFaU7TqH.d.ts → review-paragraph-order-BjUs-tDd.d.ts} +1 -1
- package/dist/{revision-projection-DEIvpxiq.d.ts → revision-projection-DDVBYTIG.d.ts} +1 -1
- package/dist/{semantic-cell-selection-DXmfnDCw.d.ts → semantic-cell-selection-DW6qsmoC.d.ts} +6 -4
- package/dist/{semantic-interaction-BLu3M6Nn.d.ts → semantic-interaction-BNiYSBcB.d.ts} +1 -1
- package/dist/{semantic-paint-CPsihA6k.d.ts → semantic-paint-DE236npp.d.ts} +2 -2
- package/dist/{semantic-records-CqD0b5Ex.d.ts → semantic-records-C5OeXnaL.d.ts} +546 -567
- package/dist/store.cjs +1 -1
- package/dist/store.d.ts +19 -25
- package/dist/store.js +1 -1
- package/dist/{tree-package-fragment-CwJDixNs.d.ts → tree-package-fragment-DBb97w3F.d.ts} +2 -2
- package/dist/{tree-session-contract-D9RRWE0C.d.ts → tree-session-contract-BYat3RKx.d.ts} +10 -5
- package/dist/{types-barrel-DLB11iSY.d.ts → types-barrel-ChGvWjkO.d.ts} +11 -5
- package/package.json +2 -2
- package/dist/chunk-44LQJIKH.cjs +0 -20
- package/dist/chunk-AFG7Q622.cjs +0 -2
- package/dist/chunk-AYMSP25Q.js +0 -4
- package/dist/chunk-B4KZSKF7.cjs +0 -5
- package/dist/chunk-BNZF6DYC.cjs +0 -18
- package/dist/chunk-BQXF2PFF.js +0 -2
- package/dist/chunk-GIHKVXEO.js +0 -2
- package/dist/chunk-ITNK6C5M.cjs +0 -3
- package/dist/chunk-MP3K4LC5.js +0 -1
- package/dist/chunk-MXOO7KRI.cjs +0 -11
- package/dist/chunk-NG6IQ4SI.js +0 -11
- package/dist/chunk-Q5JPPUNR.js +0 -5
- package/dist/chunk-S35UK656.cjs +0 -2
- package/dist/chunk-TE43S3LX.cjs +0 -1
- package/dist/chunk-VH2DLEZK.js +0 -20
- package/dist/chunk-VUNFWXHF.js +0 -1
- package/dist/chunk-WQFNWLNY.cjs +0 -4
- package/dist/chunk-WZX4UGRQ.js +0 -3
- package/dist/chunk-XS4FOHH6.js +0 -18
- package/dist/chunk-XZY4Q6PJ.cjs +0 -1
package/README.md
CHANGED
|
@@ -13,58 +13,60 @@
|
|
|
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
|
|
|
20
20
|
```bash
|
|
21
21
|
npm install @docx-editor.dev/core
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
Node
|
|
24
|
+
Node.js requires `^20.16.0 || >=22.3.0`.
|
|
25
25
|
|
|
26
26
|
## Entry points
|
|
27
27
|
|
|
28
|
+
Import editor creation, font helpers, and contract types from the package root:
|
|
29
|
+
|
|
28
30
|
```ts
|
|
29
31
|
import { createDocxEditor, loadFonts, WORD_DEFAULT_FONT } from '@docx-editor.dev/core';
|
|
30
32
|
import type { Editor, EditorSnapshot } from '@docx-editor.dev/core';
|
|
31
33
|
```
|
|
32
34
|
|
|
33
|
-
The root
|
|
34
|
-
|
|
35
|
-
| Subpath
|
|
36
|
-
|
|
|
37
|
-
| `.`
|
|
38
|
-
| `./editor`
|
|
39
|
-
| `./contracts/editor`
|
|
40
|
-
| `./contracts/document`
|
|
41
|
-
| `./contracts/interaction`
|
|
42
|
-
| `./contracts/types`
|
|
43
|
-
| `./contracts/modules`
|
|
44
|
-
| `./store`
|
|
45
|
-
| `./layout`
|
|
46
|
-
| `./output`
|
|
47
|
-
| `./export`
|
|
48
|
-
| `./automation`
|
|
49
|
-
| `./collaboration`
|
|
50
|
-
| `./collaboration/replication` | Replication helpers for collaboration providers.
|
|
51
|
-
| `./styles/editor.css`
|
|
35
|
+
The root exports editor creation, contracts, font helpers, control definitions, and document types. Use subpaths to access storage, layout, and rendering.
|
|
36
|
+
|
|
37
|
+
| Subpath | Exports |
|
|
38
|
+
| --- | --- |
|
|
39
|
+
| `.` | Create an editor, the contract, fonts, the chrome registry, the document model. |
|
|
40
|
+
| `./editor` | Everything the root re-exports, plus the paginated surface and ruler geometry. |
|
|
41
|
+
| `./contracts/editor` | `Editor`, `EditorCommand`, `EditorQuery`, `EditorSnapshot`, `PageSetup`. |
|
|
42
|
+
| `./contracts/document` | The document-level edit and query vocabulary. |
|
|
43
|
+
| `./contracts/interaction` | Semantic addressing (`SemanticTarget`) and the `InteractionOutcome` an attempt answers with. |
|
|
44
|
+
| `./contracts/types` | Document model types. |
|
|
45
|
+
| `./contracts/modules` | `EditorModule` — the shape `@docx-editor.dev/pro` implements. |
|
|
46
|
+
| `./store` | The canonical tree and its transactional store. |
|
|
47
|
+
| `./layout` | The DOM-free layout pass. |
|
|
48
|
+
| `./output` | Paint layouts and selection overlays into the DOM. |
|
|
49
|
+
| `./export` | Document layout sessions for exporters. No DOM required. |
|
|
50
|
+
| `./automation` | The object model behind `@docx-editor.dev/editor-api`. |
|
|
51
|
+
| `./collaboration` | Provider-neutral collaboration session contracts. |
|
|
52
|
+
| `./collaboration/replication` | Replication helpers for collaboration providers. |
|
|
53
|
+
| `./styles/editor.css` | The one editor stylesheet, shared by packaged and custom chrome. |
|
|
52
54
|
|
|
53
55
|
## Architecture
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
bytes → bounded OPC/XML read → canonical OOXML tree → layout → painted pages → serialize
|
|
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
|
|
|
65
65
|
### Build a paginated exporter
|
|
66
66
|
|
|
67
|
-
For exports that need
|
|
67
|
+
For exports that need font-based page breaks, use `openFontBackedDocumentForExport`. It resolves the fonts used throughout the document before layout. Without a measurer, `openDocumentForExport(bytes)` uses a fixed-width approximation.
|
|
68
|
+
|
|
69
|
+
Install `@docx-editor.dev/fonts` to use packaged substitutes in this example:
|
|
68
70
|
|
|
69
71
|
```ts
|
|
70
72
|
import { readFile } from 'node:fs/promises';
|
|
@@ -73,23 +75,21 @@ import { packagedFonts } from '@docx-editor.dev/fonts';
|
|
|
73
75
|
|
|
74
76
|
const bytes = new Uint8Array(await readFile('contract.docx'));
|
|
75
77
|
const opened = await openFontBackedDocumentForExport(bytes, {
|
|
76
|
-
|
|
77
|
-
// and an optional network resolver last.
|
|
78
|
-
fonts: [callerFonts, packagedFonts(), optionalNetworkFonts],
|
|
78
|
+
fonts: packagedFonts(),
|
|
79
79
|
fontPolicy: 'strict',
|
|
80
|
-
onFontResolution: (report) =>
|
|
80
|
+
onFontResolution: (report) => console.info(report),
|
|
81
81
|
});
|
|
82
82
|
|
|
83
83
|
if (!opened.ok) throw new Error(`DOCX rejected: ${opened.reason}`);
|
|
84
84
|
try {
|
|
85
85
|
const layout = await opened.session.layout();
|
|
86
|
-
|
|
86
|
+
console.log(layout); // Replace this with your exporter.
|
|
87
87
|
} finally {
|
|
88
88
|
opened.session.dispose(); // releases document-owned shaping bytes
|
|
89
89
|
}
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
-
Let
|
|
92
|
+
Let the engine manage fonts, resources, and layout. Build your output from the returned pages. For a live `HeadlessDocumentView`, pass the editor's revision-stable measurer.
|
|
93
93
|
|
|
94
94
|
## Fidelity
|
|
95
95
|
|
|
@@ -97,7 +97,7 @@ Untouched content, unsupported OOXML, and package payloads survive editing and s
|
|
|
97
97
|
|
|
98
98
|
## Untrusted input
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
Treat DOCX files as untrusted input. The engine validates URLs and limits XML entities, archive expansion, nesting, and element counts. It does not automatically fetch external document relationships. Serialization escapes document text.
|
|
101
101
|
|
|
102
102
|
Anything you render from document data (a font name, a hyperlink target, a comment body) is still attacker-controlled at your boundary. Render it as text; do not build markup or URLs from it.
|
|
103
103
|
|
|
@@ -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 chunkREMFTPDL_cjs=require('./chunk-REMFTPDL.cjs');require('./chunk-W5H62AWM.cjs'),require('./chunk-65GJRSZ5.cjs'),require('./chunk-YYFBYVW4.cjs'),require('./chunk-FGBADUSK.cjs');var chunkHZQFGB2X_cjs=require('./chunk-HZQFGB2X.cjs'),chunkP5PWSRNW_cjs=require('./chunk-P5PWSRNW.cjs'),chunkCB6RQ3GD_cjs=require('./chunk-CB6RQ3GD.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=chunkCB6RQ3GD_cjs.jc(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 chunkHZQFGB2X_cjs.P(m.package,chunkHZQFGB2X_cjs._a(m.package,chunkCB6RQ3GD_cjs.Qb(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(chunkHZQFGB2X_cjs.bb(u));u.packageRevision===a&&(i=d,l=a);},n.fieldPageContext=(f,a,d)=>{if(u.packageRevision!==l)return null;let s=chunkREMFTPDL_cjs.e(u.currentPackage()).story(f);return s?chunkREMFTPDL_cjs.b(i,s.part,a,d):null};}let r=chunkREMFTPDL_cjs.k({port:n,capabilities:j});return y&&(c=y.attach(chunkP5PWSRNW_cjs.b(u,{documentId:y.documentId}))),{ok:true,host:r}}function G(o,t,m){let p=o.partFor(m);return p?chunkCB6RQ3GD_cjs.Ca(o,()=>{let u=chunkCB6RQ3GD_cjs.Ef(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"?chunkCB6RQ3GD_cjs.b.mutationAgent:chunkCB6RQ3GD_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=>chunkCB6RQ3GD_cjs.Sb(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=>chunkP5PWSRNW_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=chunkCB6RQ3GD_cjs.Sb(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=chunkCB6RQ3GD_cjs.Sb(t?.identity.actorId,()=>chunkHZQFGB2X_cjs.aa(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=chunkCB6RQ3GD_cjs.Sb(t?.identity.actorId,()=>chunkHZQFGB2X_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=chunkCB6RQ3GD_cjs.Sb(t?.identity.actorId,()=>chunkHZQFGB2X_cjs.$(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=chunkCB6RQ3GD_cjs.Sb(t?.identity.actorId,()=>chunkHZQFGB2X_cjs.ia(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?chunkCB6RQ3GD_cjs.kc(o.currentPackage()):null,subscribe:n=>o.subscribe(()=>n()),dispose(){m(),p=false;}}}Object.defineProperty(exports,"AUTOMATION_COMMAND_OPERATIONS",{enumerable:true,get:function(){return chunkREMFTPDL_cjs.g}});Object.defineProperty(exports,"AUTOMATION_QUERY_OPERATIONS",{enumerable:true,get:function(){return chunkREMFTPDL_cjs.f}});Object.defineProperty(exports,"AUTOMATION_SOLITARY_OPERATIONS",{enumerable:true,get:function(){return chunkREMFTPDL_cjs.h}});Object.defineProperty(exports,"HEADER_FOOTER_VARIANTS",{enumerable:true,get:function(){return chunkREMFTPDL_cjs.d}});Object.defineProperty(exports,"createAutomationPaginationProvider",{enumerable:true,get:function(){return chunkREMFTPDL_cjs.c}});Object.defineProperty(exports,"isAutomationCommand",{enumerable:true,get:function(){return chunkREMFTPDL_cjs.j}});Object.defineProperty(exports,"isSolitaryAutomationCommand",{enumerable:true,get:function(){return chunkREMFTPDL_cjs.i}});Object.defineProperty(exports,"paginationSnapshotOf",{enumerable:true,get:function(){return chunkREMFTPDL_cjs.a}});exports.SERVER_AUTOMATION_CAPABILITIES=j;exports.createServerAutomationHost=Y;
|
package/dist/automation.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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-CkVDxyQ3.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-CkVDxyQ3.js';
|
|
3
|
+
import { H as HeaderFooterVariant, N as NoteKind } from './tree-package-fragment-DBb97w3F.js';
|
|
4
|
+
import { T as TextMeasurer, S as SemanticLayout } from './semantic-records-C5OeXnaL.js';
|
|
5
|
+
import { H as HeadlessDocumentView } from './headless-document-view-9wjJT20Y.js';
|
|
6
|
+
import { X as OoxmlPackageLimits, Y as OoxmlPackageRejection } from './types-barrel-ChGvWjkO.js';
|
|
7
|
+
export { Z as RevisionBatchEntry, _ as RevisionBatchResult, $ as RevisionBatchSkipReason } from './types-barrel-ChGvWjkO.js';
|
|
8
8
|
import { CollaborationModuleContribution } from './collaboration.js';
|
|
9
|
-
import './image-resources-
|
|
10
|
-
import './revision-projection-
|
|
11
|
-
import './omml-equation-
|
|
9
|
+
import './image-resources-B0v-XaTM.js';
|
|
10
|
+
import './revision-projection-DDVBYTIG.js';
|
|
11
|
+
import './omml-equation-CfTm3jOK.js';
|
|
12
12
|
import './editor-scope-OHPwVQ5l.js';
|
|
13
13
|
import './collaboration/replication.js';
|
|
14
14
|
import './failure-DNNmwsgD.js';
|
package/dist/automation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {k,e,b as b$1}from'./chunk-
|
|
1
|
+
import {k,e,b as b$1}from'./chunk-HJYLFMLX.js';export{g as AUTOMATION_COMMAND_OPERATIONS,f as AUTOMATION_QUERY_OPERATIONS,h as AUTOMATION_SOLITARY_OPERATIONS,d as HEADER_FOOTER_VARIANTS,c as createAutomationPaginationProvider,j as isAutomationCommand,i as isSolitaryAutomationCommand,a as paginationSnapshotOf}from'./chunk-HJYLFMLX.js';import'./chunk-BL57VQ7E.js';import'./chunk-W2JIZ5JH.js';import'./chunk-PD5XKBJA.js';import'./chunk-VP7SDFCM.js';import {P,_a,bb,ia,aa,_,$}from'./chunk-GG4IAKFI.js';import {b,a}from'./chunk-5RKCJ5DF.js';import {jc,Qb,kc,Sb,Ca,Ef,b as b$2}from'./chunk-UOQONZVQ.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=jc(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 P(m.package,_a(m.package,Qb(p))),y=t.collaborationModel?.session,c=()=>{},n=K(u,y,()=>c());if(t.pagination){let i,l=-1,e$1=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$1(bb(u));u.packageRevision===a&&(i=d,l=a);},n.fieldPageContext=(f,a,d)=>{if(u.packageRevision!==l)return null;let s=e(u.currentPackage()).story(f);return s?b$1(i,s.part,a,d):null};}let r=k({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=Ef(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$2.mutationAgent:b$2.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=>Sb(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=Sb(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=Sb(t?.identity.actorId,()=>aa(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=Sb(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=Sb(t?.identity.actorId,()=>$(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=Sb(t?.identity.actorId,()=>ia(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?kc(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 chunkX2LJDR53_cjs=require('./chunk-X2LJDR53.cjs');require('./chunk-RLKX7BIP.cjs'),require('./chunk-YYFBYVW4.cjs'),require('./chunk-FGBADUSK.cjs'),require('./chunk-HZQFGB2X.cjs'),require('./chunk-P5PWSRNW.cjs'),require('./chunk-CB6RQ3GD.cjs');Object.defineProperty(exports,"PROJECTION_ORIGIN",{enumerable:true,get:function(){return chunkX2LJDR53_cjs.k}});Object.defineProperty(exports,"bodyParagraphs",{enumerable:true,get:function(){return chunkX2LJDR53_cjs.c}});Object.defineProperty(exports,"docToTreeOps",{enumerable:true,get:function(){return chunkX2LJDR53_cjs.f}});Object.defineProperty(exports,"mountTreeSurface",{enumerable:true,get:function(){return chunkX2LJDR53_cjs.l}});Object.defineProperty(exports,"openTreeSession",{enumerable:true,get:function(){return chunkX2LJDR53_cjs.j}});Object.defineProperty(exports,"partHasNode",{enumerable:true,get:function(){return chunkX2LJDR53_cjs.g}});Object.defineProperty(exports,"reconcileDoc",{enumerable:true,get:function(){return chunkX2LJDR53_cjs.h}});Object.defineProperty(exports,"runPropsOf",{enumerable:true,get:function(){return chunkX2LJDR53_cjs.b}});Object.defineProperty(exports,"treeSchema",{enumerable:true,get:function(){return chunkX2LJDR53_cjs.a}});Object.defineProperty(exports,"treeToDoc",{enumerable:true,get:function(){return chunkX2LJDR53_cjs.e}});
|
package/dist/binding.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
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-ChGvWjkO.js';
|
|
3
|
+
import { T as TreeDocxSessionView, a as TreeApplyResult } from './tree-session-contract-BYat3RKx.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-BYat3RKx.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-DBb97w3F.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-B0v-XaTM.js';
|
|
10
|
+
import './custom-node-writes-Ck6eOiJ3.js';
|
|
11
|
+
import './headless-document-view-9wjJT20Y.js';
|
|
12
12
|
import './collaboration/replication.js';
|
|
13
|
-
import './revision-projection-
|
|
13
|
+
import './revision-projection-DDVBYTIG.js';
|
|
14
14
|
import './collaboration.js';
|
|
15
15
|
import './failure-DNNmwsgD.js';
|
|
16
16
|
|
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-YQXY6TQ3.js';import'./chunk-IWAUA732.js';import'./chunk-PD5XKBJA.js';import'./chunk-VP7SDFCM.js';import'./chunk-GG4IAKFI.js';import'./chunk-5RKCJ5DF.js';import'./chunk-UOQONZVQ.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {zg,Ha,Ma,lc,kc,Aa,za,Ui,da,Ba,Qb,Kb,Jb,ea}from'./chunk-UOQONZVQ.js';var X=new Set(["document","hdr","ftr","footnotes","endnotes"]),W=24,U=512,E=zg(W);function z(o){let t=o.root;return t.namespaceUri===da&&X.has(t.localName)}function $(o){let t=[],e=r=>{if(r.kind!=="textValue"){r.namespaceUri===da&&r.localName==="p"&&t.push(r);for(let i of r.children)e(i);}};return e(o.root),t}function V(o){let t=Qb(o);let e=[],r=new Set;for(let i of $(t)){let n=Kb(i);if(!n||!Jb(n))continue;let a=n.toUpperCase();if(r.has(a))continue;r.add(a);let s=Ui(t,i.id);s!==null&&e.push(Object.freeze({paragraphId:a,nodeId:i.id,text:s}));}return Object.freeze(e)}function Y(o){let t=E.get(o.root);if(t)return t;let e=Qb(o);let r=new Map,i=new Set,n=a=>{if(a.kind!=="textValue"){if(a.namespaceUri===da&&a.localName==="p"){let s=Kb(a);if(s&&Jb(s)){let p=s.toUpperCase();i.has(p)||(i.add(p),a.kind==="paragraph"&&r.set(p,a.id));}}for(let s of a.children)n(s);}};return n(e.root),E.set(o.root,r),r}function w(o,t){if(o.length!==t.length)return false;for(let e=0;e<o.length;e+=1)if(o[e].root!==t[e])return false;return true}function B(o){let t=new Map,e=null,r=(n,a,s)=>{for(t.delete(n),t.set(n,{partName:a.name,root:a.root,nodeId:s});t.size>U;){let p=t.keys().next();if(p.done)break;t.delete(p.value);}},i=(n,a)=>{let s=t.get(n);if(!s)return null;let p=a.find(c=>c.name===s.partName);if(!p)return null;if(p.root===s.root)return {part:p,nodeId:s.nodeId};let l=Ha(p,s.nodeId);if(!l||l.kind!=="paragraph")return null;let d=Kb(l);return !d||d.toUpperCase()!==n?null:(r(n,p,s.nodeId),{part:p,nodeId:s.nodeId})};return n=>{let a=o(),s=i(n,a);if(s)return s;if(e&&e.ids.has(n)&&w(a,e.roots))return null;for(let p of a){let l=Y(p).get(n);if(l!==void 0)return r(n,p,l),{part:p,nodeId:l}}return (!e||!w(a,e.roots))&&(e={roots:a.map(p=>p.root),ids:new Set}),e.ids.size<U&&e.ids.add(n),null}}function H(o,t){return Ba(o,t)}var q=Object.freeze({kind:"body"}),F=1e6;function b(o,t){if(t<=0||t>=o.length)return false;let e=o.charCodeAt(t-1),r=o.charCodeAt(t);return e>=55296&&e<=56319&&r>=56320&&r<=57343}function Q(o,t,e){if(t===e)return [];let r=0,i=Math.min(t.length,e.length);for(;r<i&&t.charCodeAt(r)===e.charCodeAt(r);)r+=1;for(;r>0&&(b(t,r)||b(e,r));)r-=1;let n=0;for(;n<t.length-r&&n<e.length-r&&t.charCodeAt(t.length-n-1)===e.charCodeAt(e.length-n-1);)n+=1;for(;n>0&&(b(t,t.length-n)||b(e,e.length-n));)n-=1;let a=t.length-r-n,s=e.slice(r,e.length-n),p=[];return a>0&&p.push({op:"deleteText",paragraphId:o,start:r,end:r+a}),s.length>0&&p.push({op:"insertText",paragraphId:o,offset:r,text:s}),Object.freeze(p)}function K(o){let t=r=>!!r&&r.kind!=="textValue"&&r.namespaceUri===da&&r.localName==="t"&&r.attributes.every(i=>i.namespaceUri===ea&&i.localName==="space")&&r.children.every(i=>i.kind==="textValue"),e=[];for(let r of o){let i=e.at(-1);if(!t(i)||!t(r)){e.push(r);continue}let n=i.children.map(a=>a.kind==="textValue"?a.value:"").join("")+r.children.map(a=>a.kind==="textValue"?a.value:"").join("");e[e.length-1]={...i,attributes:/^\s|\s$/.test(n)?[{kind:"xmlSpace",namespaceUri:ea,localName:"space",prefix:"xml",value:"preserve"}]:[],children:[{id:i.children[0]?.id??`${i.id}/text`,kind:"textValue",value:n}]};}return e}function G(o){if(o.kind==="textValue")return o;let t=false,e=o.children.map(r=>{let i=G(r);return i!==r&&(t=true),i});if(o.namespaceUri===da&&o.localName==="r"){let r=K(e);(r.length!==e.length||r.some((i,n)=>i!==e[n]))&&(e=[...r],t=true);}return t?{...o,children:e}:o}function rr(o,t,e){let r=o.parts.get(t);if(!r)return o;let i=false,n=new Set;for(let a of e)(a.op==="insertText"||a.op==="deleteText")&&!a.revision&&n.add(a.paragraphId);for(let a of n){let s=Ha(r,a);if(!s||s.kind==="textValue")continue;let p=G(s);if(p===s)continue;let l=Ma(r,a,p,{deferValidation:true});l.ok&&(r=l.part,i=true);}return i?lc(o,r):o}function er(o,t){let e=t.documentId.trim();if(e.length===0||e.length>256)throw new TypeError("documentId must contain 1 to 256 characters");let r=()=>V(o.bodyStore().part),i,a=B(()=>{let l=o.bodyStore().part,d=o.currentPackage();if(i?.pkg===d&&i.body===l)return i.parts;let c=[l];for(let g of d.parts.values())g===l||!z(g)||c.push(g);return i={pkg:d,body:l,parts:Object.freeze(c)},i.parts}),s=(l,d)=>{if(l.length===0)return {ok:true,changed:false};let c=r(),g=new Set,h=[];for(let u of l){if(typeof u.text!="string"||u.text.length>F)return {ok:false,reason:"collaboration-text-limit"};if(typeof u.paragraphId!="string"||u.paragraphId.length===0||u.paragraphId.length>256)return {ok:false,reason:"unknown-paragraph-id"};let m=u.paragraphId.toUpperCase();if(g.has(m))return {ok:false,reason:"duplicate-paragraph-id"};g.add(m);let N=c.filter(L=>L.paragraphId===m);if(N.length!==1)return {ok:false,reason:"unknown-paragraph-id"};let T=N[0];h.push(...Q(T.nodeId,T.text,u.text));}if(h.length===0)return {ok:true,changed:false};let y=o.transact(q,u=>{for(let m of h)u.apply(m);u.applyPackage(m=>rr(m,m.mainDocumentPart,h));},{origin:d.origin,actorId:d.actorId,operationId:d.operationId,recordsHistory:false});return y.ok?{ok:true,changed:y.change!==null}:{ok:false,reason:y.detail??y.reason}};return Object.freeze({documentId:e,paragraphs:r,paragraphByNodeId(l){return r().find(d=>d.nodeId===l)??null},paragraphByStableId(l){let d=l.toUpperCase(),c=a(d);if(!c)return null;let g=Ui(c.part,c.nodeId);return g===null?null:Object.freeze({paragraphId:d,nodeId:c.nodeId,text:g})},applyParagraphText(l,d,c){return s([{paragraphId:l,text:d}],c)},applyParagraphTexts:s,applyRemotePackage(l,d){let c=o.publishRemotePackage(l,d);return c.ok?{ok:true,changed:c.change!==null}:{ok:false,reason:c.detail??c.reason}},revision:()=>o.packageRevision,subscribe:l=>o.subscribe(l),observePrimitiveJournal:l=>H(o,l),hasPendingJournals:()=>za(o),flushPendingJournals:()=>{Aa(o);},save:()=>kc(o.currentPackage()),binaryPart(l){let d=o.currentPackage();return d.partBytes.get(l)??d.partBytes.get(l.startsWith("/")?l.slice(1):`/${l}`)??null}})}export{rr as a,er as b};
|