@docx-editor.dev/pro 2.31.0 → 2.33.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.
Files changed (107) hide show
  1. package/README.md +41 -3
  2. package/dist/chunk-25A5N6OL.js +1 -0
  3. package/dist/chunk-3HW2VWFW.js +1 -0
  4. package/dist/chunk-3MIZFGHH.cjs +1 -0
  5. package/dist/chunk-46N5DWZV.cjs +1 -0
  6. package/dist/chunk-65JEI6FY.cjs +5 -0
  7. package/dist/chunk-ENMURXLJ.js +1 -0
  8. package/dist/chunk-EOZ44UA7.js +1 -0
  9. package/dist/chunk-GLYQ72LS.cjs +6 -0
  10. package/dist/{chunk-RYF4SNKX.cjs → chunk-GOUTDQFX.cjs} +1 -1
  11. package/dist/chunk-HMU7J34H.js +1 -0
  12. package/dist/chunk-IULA3QRZ.cjs +1 -0
  13. package/dist/chunk-QEULTKCT.cjs +1 -0
  14. package/dist/{chunk-OT5R3IYV.cjs → chunk-QOXYHVBM.cjs} +1 -1
  15. package/dist/chunk-SINNHH3H.js +1 -0
  16. package/dist/chunk-SL6K2CUL.js +6 -0
  17. package/dist/chunk-STTJA26X.js +1 -0
  18. package/dist/chunk-VY7374QP.cjs +1 -0
  19. package/dist/chunk-WGBOER6G.js +1 -0
  20. package/dist/chunk-WX43PF3Z.cjs +1 -0
  21. package/dist/chunk-WYVEFRAM.js +5 -0
  22. package/dist/collaboration/hocuspocus.cjs +1 -1
  23. package/dist/collaboration/hocuspocus.d.cts +3 -3
  24. package/dist/collaboration/hocuspocus.d.ts +3 -3
  25. package/dist/collaboration/hocuspocus.js +1 -1
  26. package/dist/collaboration/index.cjs +2 -2
  27. package/dist/collaboration/index.d.cts +65 -8
  28. package/dist/collaboration/index.d.ts +65 -8
  29. package/dist/collaboration/index.js +2 -2
  30. package/dist/collaboration/webrtc.cjs +1 -1
  31. package/dist/collaboration/webrtc.d.cts +3 -3
  32. package/dist/collaboration/webrtc.d.ts +3 -3
  33. package/dist/collaboration/webrtc.js +1 -1
  34. package/dist/{collaboration-module-DWn2heE1.d.cts → collaboration-module-02CIP5sN.d.cts} +2 -20
  35. package/dist/{collaboration-module-DWn2heE1.d.ts → collaboration-module-COZAgqwg.d.ts} +2 -20
  36. package/dist/{define-custom-node-D0c36PpZ.d.ts → define-custom-node-CISpZvVB.d.cts} +8 -3
  37. package/dist/{define-custom-node-CNRQG1TI.d.cts → define-custom-node-DE1KjR1r.d.ts} +8 -3
  38. package/dist/document-session-4NUOLWKQ.cjs +1 -0
  39. package/dist/document-session-5VAD24RH.js +1 -0
  40. package/dist/{document-session-_v9vqiSX.d.cts → document-session-B-MlORjE.d.cts} +105 -9
  41. package/dist/{document-session-Bxs4_GgX.d.ts → document-session-B-iH-YCU.d.ts} +105 -9
  42. package/dist/{document-session-options-DelOC7PX.d.ts → document-session-options-CdOH-TNn.d.ts} +1 -1
  43. package/dist/{document-session-options-CfKypp9c.d.cts → document-session-options-CxR0F5xT.d.cts} +1 -1
  44. package/dist/drawing/index.cjs +1 -0
  45. package/dist/drawing/index.d.cts +112 -0
  46. package/dist/drawing/index.d.ts +112 -0
  47. package/dist/drawing/index.js +1 -0
  48. package/dist/index.cjs +1 -1
  49. package/dist/index.d.cts +4 -3
  50. package/dist/index.d.ts +4 -3
  51. package/dist/index.js +1 -1
  52. package/dist/license-D-ds5Y7c.d.cts +20 -0
  53. package/dist/license-D-ds5Y7c.d.ts +20 -0
  54. package/dist/metafile-raster-3MCAHWYO.js +1 -0
  55. package/dist/metafile-raster-DWGCWQTU.cjs +1 -0
  56. package/dist/metafile-replay-GHPEUR2W.js +1 -0
  57. package/dist/metafile-replay-NZWGGGZR.cjs +1 -0
  58. package/dist/react/hocuspocus.cjs +1 -1
  59. package/dist/react/hocuspocus.d.cts +2 -2
  60. package/dist/react/hocuspocus.d.ts +2 -2
  61. package/dist/react/hocuspocus.js +1 -1
  62. package/dist/react/index.cjs +2 -2
  63. package/dist/react/index.d.cts +176 -34
  64. package/dist/react/index.d.ts +176 -34
  65. package/dist/react/index.js +2 -2
  66. package/dist/react/webrtc.cjs +1 -1
  67. package/dist/react/webrtc.d.cts +2 -2
  68. package/dist/react/webrtc.d.ts +2 -2
  69. package/dist/react/webrtc.js +1 -1
  70. package/dist/{types-BQ1vBt5Q.d.ts → types-DvGpDOcZ.d.cts} +9 -1
  71. package/dist/{types-BQ1vBt5Q.d.cts → types-DvGpDOcZ.d.ts} +9 -1
  72. package/dist/{types-6EmrEn4n.d.cts → types-bt2k1VO0.d.cts} +9 -1
  73. package/dist/{types-6EmrEn4n.d.ts → types-bt2k1VO0.d.ts} +9 -1
  74. package/dist/vue/hocuspocus.cjs +1 -1
  75. package/dist/vue/hocuspocus.d.cts +2 -2
  76. package/dist/vue/hocuspocus.d.ts +2 -2
  77. package/dist/vue/hocuspocus.js +1 -1
  78. package/dist/vue/index.cjs +2 -2
  79. package/dist/vue/index.d.cts +149 -30
  80. package/dist/vue/index.d.ts +149 -30
  81. package/dist/vue/index.js +2 -2
  82. package/dist/vue/webrtc.cjs +1 -1
  83. package/dist/vue/webrtc.d.cts +2 -2
  84. package/dist/vue/webrtc.d.ts +2 -2
  85. package/dist/vue/webrtc.js +1 -1
  86. package/docs/accept-reject-without-scrolling.md +95 -0
  87. package/docs/comment-on-found-text.md +72 -0
  88. package/docs/custom-review-cards.md +178 -0
  89. package/docs/highlight-ranges.md +48 -0
  90. package/docs/index.md +36 -0
  91. package/docs/propose-rewrite.md +247 -0
  92. package/docs/tracked-replacement.md +68 -0
  93. package/package.json +12 -5
  94. package/dist/chunk-32WEH2XH.cjs +0 -1
  95. package/dist/chunk-DLYVBBO7.js +0 -1
  96. package/dist/chunk-FD2KDBHX.cjs +0 -1
  97. package/dist/chunk-L567WP3J.js +0 -5
  98. package/dist/chunk-MJECUVHQ.cjs +0 -5
  99. package/dist/chunk-MWO2ZUEJ.js +0 -1
  100. package/dist/chunk-Q2VBO66F.js +0 -1
  101. package/dist/chunk-Q5JTCGJI.js +0 -1
  102. package/dist/chunk-QLZH2Q2C.cjs +0 -1
  103. package/dist/chunk-SNQCYZLT.js +0 -1
  104. package/dist/chunk-UOAEJRVX.js +0 -1
  105. package/dist/chunk-ZSAAX6HV.cjs +0 -1
  106. package/dist/document-session-3VC43WNI.cjs +0 -1
  107. package/dist/document-session-J2YKWERI.js +0 -1
@@ -1,5 +1,5 @@
1
1
  import { ReviewPaneOptions, EditorModule } from '@docx-editor.dev/core/editor';
2
- import { P as ProLicenseOptions } from './collaboration-module-DWn2heE1.js';
2
+ import { P as ProLicenseOptions } from './license-D-ds5Y7c.cjs';
3
3
  import { OoxmlPart } from '@docx-editor.dev/core/store';
4
4
 
5
5
  /**
@@ -9,7 +9,8 @@ import { OoxmlPart } from '@docx-editor.dev/core/store';
9
9
  * Registering it is the whole enablement story: the review chrome slots light
10
10
  * up through the same `toolbarCommandState` they were disabled by, suggesting
11
11
  * mode becomes reachable, and the editor renders revisions in markup rather
12
- * than the free tier's final-state projection.
12
+ * than the free tier's final-state projection. It also installs the drawing renderers, as
13
+ * `drawingModule()` from `@docx-editor.dev/pro/drawing` does.
13
14
  */
14
15
 
15
16
  /**
@@ -28,7 +29,11 @@ interface ReviewModuleOptions extends ProLicenseOptions {
28
29
  */
29
30
  readonly pane?: ReviewPaneOptions;
30
31
  }
31
- /** Build the review module. Construction never validates the key and never touches the network. */
32
+ /**
33
+ * Build the review module. Construction never validates the key and never touches the network.
34
+ * It installs the drawing renderers process-wide, so charts, SmartArt layout, drawing effects,
35
+ * WordArt, and metafile pictures render without a separate `drawingModule()`.
36
+ */
32
37
  declare function reviewModule(options?: ReviewModuleOptions): EditorModule;
33
38
 
34
39
  /**
@@ -1,5 +1,5 @@
1
1
  import { ReviewPaneOptions, EditorModule } from '@docx-editor.dev/core/editor';
2
- import { P as ProLicenseOptions } from './collaboration-module-DWn2heE1.cjs';
2
+ import { P as ProLicenseOptions } from './license-D-ds5Y7c.js';
3
3
  import { OoxmlPart } from '@docx-editor.dev/core/store';
4
4
 
5
5
  /**
@@ -9,7 +9,8 @@ import { OoxmlPart } from '@docx-editor.dev/core/store';
9
9
  * Registering it is the whole enablement story: the review chrome slots light
10
10
  * up through the same `toolbarCommandState` they were disabled by, suggesting
11
11
  * mode becomes reachable, and the editor renders revisions in markup rather
12
- * than the free tier's final-state projection.
12
+ * than the free tier's final-state projection. It also installs the drawing renderers, as
13
+ * `drawingModule()` from `@docx-editor.dev/pro/drawing` does.
13
14
  */
14
15
 
15
16
  /**
@@ -28,7 +29,11 @@ interface ReviewModuleOptions extends ProLicenseOptions {
28
29
  */
29
30
  readonly pane?: ReviewPaneOptions;
30
31
  }
31
- /** Build the review module. Construction never validates the key and never touches the network. */
32
+ /**
33
+ * Build the review module. Construction never validates the key and never touches the network.
34
+ * It installs the drawing renderers process-wide, so charts, SmartArt layout, drawing effects,
35
+ * WordArt, and metafile pictures render without a separate `drawingModule()`.
36
+ */
32
37
  declare function reviewModule(options?: ReviewModuleOptions): EditorModule;
33
38
 
34
39
  /**
@@ -0,0 +1 @@
1
+ 'use strict';var chunk65JEI6FY_cjs=require('./chunk-65JEI6FY.cjs');Object.defineProperty(exports,"ATTACH_WATCHDOG_MS_FOR_TESTS",{enumerable:true,get:function(){return chunk65JEI6FY_cjs.q}});Object.defineProperty(exports,"createDocumentCollaboration",{enumerable:true,get:function(){return chunk65JEI6FY_cjs.r}});Object.defineProperty(exports,"readCollaborationDocument",{enumerable:true,get:function(){return chunk65JEI6FY_cjs.p}});
@@ -0,0 +1 @@
1
+ export{q as ATTACH_WATCHDOG_MS_FOR_TESTS,r as createDocumentCollaboration,p as readCollaborationDocument}from'./chunk-WYVEFRAM.js';
@@ -1,7 +1,7 @@
1
+ import { b as CollaborationIdentityUpdate, c as CollaborationHandle } from './types-DvGpDOcZ.cjs';
1
2
  import { EditorCollaborationSession, CollaborationFailureCode } from '@docx-editor.dev/core/collaboration';
2
3
  import * as Y from 'yjs';
3
- import { c as CollaborationHandle, b as CollaborationIdentityUpdate } from './types-BQ1vBt5Q.cjs';
4
- import { C as CreateDocumentCollaborationOptions } from './document-session-options-CfKypp9c.cjs';
4
+ import { C as CreateDocumentCollaborationOptions } from './document-session-options-CxR0F5xT.cjs';
5
5
 
6
6
  /**
7
7
  * Room-size observability.
@@ -63,13 +63,48 @@ interface CollaborationResourceUsage {
63
63
  declare function readCollaborationResourceUsage(ydoc: Y.Doc): CollaborationResourceUsage;
64
64
 
65
65
  /**
66
- * Full-document collaboration over the canonical primitive journal.
66
+ * Why `beginUndoGroup` refused.
67
67
  *
68
- * Local direction: the canonical store commits, emits ONE journal, and the journal is applied
69
- * to shared state in one Yjs transaction. Remote direction: a shared-state change materializes
70
- * one canonical package, which the port publishes as one revision. The two never chase each
71
- * other, because a remote publication deliberately emits no journal.
68
+ * - `undo-group-already-open`: this session already has an open group. Groups do not nest
69
+ * and two operations cannot share one session's group. End the open group first, or give
70
+ * each concurrent operation its own session.
71
+ * - `editor-attached`: an editor that people edit through is attached to this session. Use
72
+ * the editor's own `beginHistoryGroup()` there.
73
+ * - `collaboration-session-destroyed`: the session was destroyed.
74
+ * @public
75
+ */
76
+ type CollaborationUndoGroupErrorCode = 'undo-group-already-open' | 'editor-attached' | 'collaboration-session-destroyed';
77
+ /**
78
+ * Thrown by `beginUndoGroup` when the session cannot open a group. Branch on `code`.
79
+ * @public
72
80
  */
81
+ declare class CollaborationUndoGroupError extends Error {
82
+ /** Stable refusal code. */
83
+ readonly code: CollaborationUndoGroupErrorCode;
84
+ constructor(
85
+ /** Stable refusal code. */
86
+ code: CollaborationUndoGroupErrorCode);
87
+ }
88
+ /**
89
+ * One open undo group of a collaboration session.
90
+ *
91
+ * Every local write the session publishes while the group is open becomes part of one undo
92
+ * step, however long the group stays open. `end()` closes the step, so the next write
93
+ * starts a new one, however soon it follows.
94
+ * @public
95
+ */
96
+ interface CollaborationUndoGroup {
97
+ /** `closed` after `end()`, after the session is destroyed, or after an editor attaches. */
98
+ readonly state: 'open' | 'closed';
99
+ /**
100
+ * Publish committed local writes into the group, then close it. Reverts nothing. Safe to
101
+ * call more than once, and after the session is destroyed.
102
+ *
103
+ * Commands a runtime still queues are not committed yet. Call `end()` after
104
+ * `runtime.run()` resolves, so its last `context.sync()` lands inside the group.
105
+ */
106
+ end(): void;
107
+ }
73
108
 
74
109
  /**
75
110
  * Full-document collaboration session: the engine-facing seam, the transport status a
@@ -105,7 +140,68 @@ interface DocumentCollaborationSession extends EditorCollaborationSession {
105
140
  * schedule rather than per keystroke.
106
141
  */
107
142
  resourceUsage(): CollaborationResourceUsage;
143
+ /**
144
+ * Open an explicit undo group: every local write this session publishes until `end()` is
145
+ * one undo step. For a server or headless replica, such as an agent's.
146
+ *
147
+ * Without a group, local writes that land within 500 ms of each other share one undo step.
148
+ * A group replaces that timing rule. Its first write starts a new step, however soon it
149
+ * follows the previous write. Its later writes join that step, however long the group
150
+ * stays open. The first write after `end()` starts a new step.
151
+ *
152
+ * Each boundary publishes the writes that are already committed. A runtime commits its
153
+ * queued commands only at `context.sync()`, so call `end()` after `runtime.run()` resolves,
154
+ * not inside the callback before its last sync.
155
+ *
156
+ * - Undo and redo refuse while the group is open: `undo()` and `redo()` return false, and
157
+ * `canUndo()` and `canRedo()` report false. {@link DocumentCollaborationSession.undoGroupOpen}
158
+ * tells this refusal apart from an empty history. End the group first.
159
+ * - A refused write does not end the group. Later writes join the same step as the
160
+ * earlier ones. To revert the whole operation, end the group and call `undo()` once.
161
+ * - Only local writes join the group. Other participants' edits stay out of it, and an
162
+ * undo of the group keeps them. It can also remove text that others typed in a
163
+ * paragraph the group inserted (#1398). When they removed everything the group wrote,
164
+ * its undo changes nothing and never reverts an older step.
165
+ * - An undo of an ungrouped step never reverts a group's step below it. Ungrouped history
166
+ * otherwise undoes as it does without groups. If a peer removed everything that the top
167
+ * ungrouped step wrote, that `undo()` changes nothing and returns true. Call `undo()`
168
+ * again to revert the group.
169
+ * - Destroying the session, or attaching an editor to it, closes an open group.
170
+ *
171
+ * @throws CollaborationUndoGroupError with `undo-group-already-open` when this session
172
+ * already has an open group, `editor-attached` when an editor that people edit through is
173
+ * attached (use the editor's `beginHistoryGroup()` there), or
174
+ * `collaboration-session-destroyed` after `destroy()`. Groups do not nest. Give each
175
+ * concurrent operation its own session.
176
+ *
177
+ * @example
178
+ * ```ts
179
+ * const group = session.beginUndoGroup();
180
+ * try {
181
+ * await runtime.run(async (context) => {
182
+ * context.document.body.insertParagraph('Task A', 'End');
183
+ * await context.sync();
184
+ * });
185
+ * } finally {
186
+ * group.end();
187
+ * }
188
+ * session.undo(); // reverts Task A only
189
+ * ```
190
+ */
191
+ beginUndoGroup(): CollaborationUndoGroup;
192
+ /** Whether an undo group from {@link DocumentCollaborationSession.beginUndoGroup} is open. */
193
+ readonly undoGroupOpen: boolean;
108
194
  }
195
+
196
+ /**
197
+ * Full-document collaboration over the canonical primitive journal.
198
+ *
199
+ * Local direction: the canonical store commits, emits ONE journal, and the journal is applied
200
+ * to shared state in one Yjs transaction. Remote direction: a shared-state change materializes
201
+ * one canonical package, which the port publishes as one revision. The two never chase each
202
+ * other, because a remote publication deliberately emits no journal.
203
+ */
204
+
109
205
  /** Owned full-document collaboration replica. @public */
110
206
  type DocumentCollaborationHandle = CollaborationHandle<DocumentCollaborationSession>;
111
207
 
@@ -142,5 +238,5 @@ type DocumentCollaborationHandle = CollaborationHandle<DocumentCollaborationSess
142
238
  */
143
239
  declare function createDocumentCollaboration(options: CreateDocumentCollaborationOptions): Promise<DocumentCollaborationHandle>;
144
240
 
145
- export { createDocumentCollaboration as c, readCollaborationResourceUsage as r };
146
- export type { CollaborationResourceUsage as C, DocumentCollaborationHandle as D, DocumentCollaborationSession as a };
241
+ export { CollaborationUndoGroupError as b, createDocumentCollaboration as e, readCollaborationResourceUsage as r };
242
+ export type { CollaborationResourceUsage as C, DocumentCollaborationHandle as D, CollaborationUndoGroup as a, CollaborationUndoGroupErrorCode as c, DocumentCollaborationSession as d };
@@ -1,7 +1,7 @@
1
+ import { b as CollaborationIdentityUpdate, c as CollaborationHandle } from './types-DvGpDOcZ.js';
1
2
  import { EditorCollaborationSession, CollaborationFailureCode } from '@docx-editor.dev/core/collaboration';
2
3
  import * as Y from 'yjs';
3
- import { c as CollaborationHandle, b as CollaborationIdentityUpdate } from './types-BQ1vBt5Q.js';
4
- import { C as CreateDocumentCollaborationOptions } from './document-session-options-DelOC7PX.js';
4
+ import { C as CreateDocumentCollaborationOptions } from './document-session-options-CdOH-TNn.js';
5
5
 
6
6
  /**
7
7
  * Room-size observability.
@@ -63,13 +63,48 @@ interface CollaborationResourceUsage {
63
63
  declare function readCollaborationResourceUsage(ydoc: Y.Doc): CollaborationResourceUsage;
64
64
 
65
65
  /**
66
- * Full-document collaboration over the canonical primitive journal.
66
+ * Why `beginUndoGroup` refused.
67
67
  *
68
- * Local direction: the canonical store commits, emits ONE journal, and the journal is applied
69
- * to shared state in one Yjs transaction. Remote direction: a shared-state change materializes
70
- * one canonical package, which the port publishes as one revision. The two never chase each
71
- * other, because a remote publication deliberately emits no journal.
68
+ * - `undo-group-already-open`: this session already has an open group. Groups do not nest
69
+ * and two operations cannot share one session's group. End the open group first, or give
70
+ * each concurrent operation its own session.
71
+ * - `editor-attached`: an editor that people edit through is attached to this session. Use
72
+ * the editor's own `beginHistoryGroup()` there.
73
+ * - `collaboration-session-destroyed`: the session was destroyed.
74
+ * @public
75
+ */
76
+ type CollaborationUndoGroupErrorCode = 'undo-group-already-open' | 'editor-attached' | 'collaboration-session-destroyed';
77
+ /**
78
+ * Thrown by `beginUndoGroup` when the session cannot open a group. Branch on `code`.
79
+ * @public
72
80
  */
81
+ declare class CollaborationUndoGroupError extends Error {
82
+ /** Stable refusal code. */
83
+ readonly code: CollaborationUndoGroupErrorCode;
84
+ constructor(
85
+ /** Stable refusal code. */
86
+ code: CollaborationUndoGroupErrorCode);
87
+ }
88
+ /**
89
+ * One open undo group of a collaboration session.
90
+ *
91
+ * Every local write the session publishes while the group is open becomes part of one undo
92
+ * step, however long the group stays open. `end()` closes the step, so the next write
93
+ * starts a new one, however soon it follows.
94
+ * @public
95
+ */
96
+ interface CollaborationUndoGroup {
97
+ /** `closed` after `end()`, after the session is destroyed, or after an editor attaches. */
98
+ readonly state: 'open' | 'closed';
99
+ /**
100
+ * Publish committed local writes into the group, then close it. Reverts nothing. Safe to
101
+ * call more than once, and after the session is destroyed.
102
+ *
103
+ * Commands a runtime still queues are not committed yet. Call `end()` after
104
+ * `runtime.run()` resolves, so its last `context.sync()` lands inside the group.
105
+ */
106
+ end(): void;
107
+ }
73
108
 
74
109
  /**
75
110
  * Full-document collaboration session: the engine-facing seam, the transport status a
@@ -105,7 +140,68 @@ interface DocumentCollaborationSession extends EditorCollaborationSession {
105
140
  * schedule rather than per keystroke.
106
141
  */
107
142
  resourceUsage(): CollaborationResourceUsage;
143
+ /**
144
+ * Open an explicit undo group: every local write this session publishes until `end()` is
145
+ * one undo step. For a server or headless replica, such as an agent's.
146
+ *
147
+ * Without a group, local writes that land within 500 ms of each other share one undo step.
148
+ * A group replaces that timing rule. Its first write starts a new step, however soon it
149
+ * follows the previous write. Its later writes join that step, however long the group
150
+ * stays open. The first write after `end()` starts a new step.
151
+ *
152
+ * Each boundary publishes the writes that are already committed. A runtime commits its
153
+ * queued commands only at `context.sync()`, so call `end()` after `runtime.run()` resolves,
154
+ * not inside the callback before its last sync.
155
+ *
156
+ * - Undo and redo refuse while the group is open: `undo()` and `redo()` return false, and
157
+ * `canUndo()` and `canRedo()` report false. {@link DocumentCollaborationSession.undoGroupOpen}
158
+ * tells this refusal apart from an empty history. End the group first.
159
+ * - A refused write does not end the group. Later writes join the same step as the
160
+ * earlier ones. To revert the whole operation, end the group and call `undo()` once.
161
+ * - Only local writes join the group. Other participants' edits stay out of it, and an
162
+ * undo of the group keeps them. It can also remove text that others typed in a
163
+ * paragraph the group inserted (#1398). When they removed everything the group wrote,
164
+ * its undo changes nothing and never reverts an older step.
165
+ * - An undo of an ungrouped step never reverts a group's step below it. Ungrouped history
166
+ * otherwise undoes as it does without groups. If a peer removed everything that the top
167
+ * ungrouped step wrote, that `undo()` changes nothing and returns true. Call `undo()`
168
+ * again to revert the group.
169
+ * - Destroying the session, or attaching an editor to it, closes an open group.
170
+ *
171
+ * @throws CollaborationUndoGroupError with `undo-group-already-open` when this session
172
+ * already has an open group, `editor-attached` when an editor that people edit through is
173
+ * attached (use the editor's `beginHistoryGroup()` there), or
174
+ * `collaboration-session-destroyed` after `destroy()`. Groups do not nest. Give each
175
+ * concurrent operation its own session.
176
+ *
177
+ * @example
178
+ * ```ts
179
+ * const group = session.beginUndoGroup();
180
+ * try {
181
+ * await runtime.run(async (context) => {
182
+ * context.document.body.insertParagraph('Task A', 'End');
183
+ * await context.sync();
184
+ * });
185
+ * } finally {
186
+ * group.end();
187
+ * }
188
+ * session.undo(); // reverts Task A only
189
+ * ```
190
+ */
191
+ beginUndoGroup(): CollaborationUndoGroup;
192
+ /** Whether an undo group from {@link DocumentCollaborationSession.beginUndoGroup} is open. */
193
+ readonly undoGroupOpen: boolean;
108
194
  }
195
+
196
+ /**
197
+ * Full-document collaboration over the canonical primitive journal.
198
+ *
199
+ * Local direction: the canonical store commits, emits ONE journal, and the journal is applied
200
+ * to shared state in one Yjs transaction. Remote direction: a shared-state change materializes
201
+ * one canonical package, which the port publishes as one revision. The two never chase each
202
+ * other, because a remote publication deliberately emits no journal.
203
+ */
204
+
109
205
  /** Owned full-document collaboration replica. @public */
110
206
  type DocumentCollaborationHandle = CollaborationHandle<DocumentCollaborationSession>;
111
207
 
@@ -142,5 +238,5 @@ type DocumentCollaborationHandle = CollaborationHandle<DocumentCollaborationSess
142
238
  */
143
239
  declare function createDocumentCollaboration(options: CreateDocumentCollaborationOptions): Promise<DocumentCollaborationHandle>;
144
240
 
145
- export { createDocumentCollaboration as c, readCollaborationResourceUsage as r };
146
- export type { CollaborationResourceUsage as C, DocumentCollaborationHandle as D, DocumentCollaborationSession as a };
241
+ export { CollaborationUndoGroupError as b, createDocumentCollaboration as e, readCollaborationResourceUsage as r };
242
+ export type { CollaborationResourceUsage as C, DocumentCollaborationHandle as D, CollaborationUndoGroup as a, CollaborationUndoGroupErrorCode as c, DocumentCollaborationSession as d };
@@ -1,7 +1,7 @@
1
1
  import * as Y from 'yjs';
2
2
  import { Awareness } from 'y-protocols/awareness';
3
3
  import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
4
- import { a as CollaborationBootstrap } from './types-BQ1vBt5Q.js';
4
+ import { a as CollaborationBootstrap } from './types-DvGpDOcZ.js';
5
5
 
6
6
  /**
7
7
  * Options for one full-document collaboration replica.
@@ -1,7 +1,7 @@
1
1
  import * as Y from 'yjs';
2
2
  import { Awareness } from 'y-protocols/awareness';
3
3
  import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
4
- import { a as CollaborationBootstrap } from './types-BQ1vBt5Q.cjs';
4
+ import { a as CollaborationBootstrap } from './types-DvGpDOcZ.cjs';
5
5
 
6
6
  /**
7
7
  * Options for one full-document collaboration replica.
@@ -0,0 +1 @@
1
+ 'use strict';var chunkGLYQ72LS_cjs=require('../chunk-GLYQ72LS.cjs');require('../chunk-IULA3QRZ.cjs');Object.defineProperty(exports,"drawingModule",{enumerable:true,get:function(){return chunkGLYQ72LS_cjs.b}});Object.defineProperty(exports,"installDrawing",{enumerable:true,get:function(){return chunkGLYQ72LS_cjs.a}});
@@ -0,0 +1,112 @@
1
+ /**
2
+ * `@docx-editor.dev/pro/drawing` — advanced drawing rendering.
3
+ *
4
+ * The free engine paints pictures, shapes with fills, gradients, patterns, lines and outer
5
+ * shadows, text boxes, groups, canvases, text watermarks, and every SmartArt diagram saved
6
+ * with its drawing. This module adds:
7
+ *
8
+ * - charts, drawn from the values cached in their chart parts. Treemap, sunburst and map
9
+ * charts, and charts that mix a pie or radar plot with other plot types, do not render;
10
+ * - the layout of a SmartArt diagram saved without its drawing;
11
+ * - shape and picture effects: glow, inner shadow, reflection, soft edge, and the rim of a
12
+ * dark-edged bevel;
13
+ * - WordArt: VML text paths outside a watermark, fitted to the shape, between two guides, or
14
+ * along an arch, with gradient fills, shadows and 3-D extrusion;
15
+ * - EMF and WMF pictures: a vector replay for PDF export, and a browser raster that honors a
16
+ * metafile's own drawing origin.
17
+ *
18
+ * Without it, or for a chart it does not render, a chart saved with a fallback picture or
19
+ * drawing shows that fallback. In every state a chart selects as an object: picture commands
20
+ * are refused, and deleting it removes the chart with its fallback, as one tracked deletion
21
+ * of the whole chart when change tracking is on. Copy and cut of a selection that includes a
22
+ * chart are refused. The editor shows a labeled placeholder for other visible charts with
23
+ * usable bounds, including a skipped `mc:Choice` with an empty `mc:Fallback`, and a diagram
24
+ * saved without its drawing, and inline WordArt; floating WordArt does not show. The editor still rasterizes
25
+ * EMF and WMF pictures, and a shape paints without those effects. PDF export always includes
26
+ * this module.
27
+ *
28
+ * The renderers serve every editor and export in the process. Install them before any
29
+ * document opens; a later install logs a console warning once. `reviewModule()` installs them
30
+ * too. The metafile replay and `emf-converter` load on first use, only when a document holds a
31
+ * metafile picture.
32
+ *
33
+ * @example Enable advanced drawing rendering in an editor
34
+ * ```ts
35
+ * import { createDocxEditor } from '@docx-editor.dev/core/editor';
36
+ * import { drawingModule } from '@docx-editor.dev/pro/drawing';
37
+ *
38
+ * // Next.js; with Vite, read import.meta.env.VITE_DOCX_LICENSE.
39
+ * const modules = [drawingModule({ licenseKey: process.env.NEXT_PUBLIC_DOCX_LICENSE })];
40
+ * const editor = createDocxEditor({ document: bytes, modules });
41
+ * ```
42
+ *
43
+ * @packageDocumentation
44
+ * @public
45
+ */
46
+ import { EditorModule } from '@docx-editor.dev/core/editor';
47
+ import { P as ProLicenseOptions } from '../license-D-ds5Y7c.cjs';
48
+
49
+ /**
50
+ * `@docx-editor.dev/pro/drawing` — advanced drawing rendering.
51
+ *
52
+ * The free engine paints pictures, shapes with fills, gradients, patterns, lines and outer
53
+ * shadows, text boxes, groups, canvases, text watermarks, and every SmartArt diagram saved
54
+ * with its drawing. This module adds:
55
+ *
56
+ * - charts, drawn from the values cached in their chart parts. Treemap, sunburst and map
57
+ * charts, and charts that mix a pie or radar plot with other plot types, do not render;
58
+ * - the layout of a SmartArt diagram saved without its drawing;
59
+ * - shape and picture effects: glow, inner shadow, reflection, soft edge, and the rim of a
60
+ * dark-edged bevel;
61
+ * - WordArt: VML text paths outside a watermark, fitted to the shape, between two guides, or
62
+ * along an arch, with gradient fills, shadows and 3-D extrusion;
63
+ * - EMF and WMF pictures: a vector replay for PDF export, and a browser raster that honors a
64
+ * metafile's own drawing origin.
65
+ *
66
+ * Without it, or for a chart it does not render, a chart saved with a fallback picture or
67
+ * drawing shows that fallback. In every state a chart selects as an object: picture commands
68
+ * are refused, and deleting it removes the chart with its fallback, as one tracked deletion
69
+ * of the whole chart when change tracking is on. Copy and cut of a selection that includes a
70
+ * chart are refused. The editor shows a labeled placeholder for other visible charts with
71
+ * usable bounds, including a skipped `mc:Choice` with an empty `mc:Fallback`, and a diagram
72
+ * saved without its drawing, and inline WordArt; floating WordArt does not show. The editor still rasterizes
73
+ * EMF and WMF pictures, and a shape paints without those effects. PDF export always includes
74
+ * this module.
75
+ *
76
+ * The renderers serve every editor and export in the process. Install them before any
77
+ * document opens; a later install logs a console warning once. `reviewModule()` installs them
78
+ * too. The metafile replay and `emf-converter` load on first use, only when a document holds a
79
+ * metafile picture.
80
+ *
81
+ * @example Enable advanced drawing rendering in an editor
82
+ * ```ts
83
+ * import { createDocxEditor } from '@docx-editor.dev/core/editor';
84
+ * import { drawingModule } from '@docx-editor.dev/pro/drawing';
85
+ *
86
+ * // Next.js; with Vite, read import.meta.env.VITE_DOCX_LICENSE.
87
+ * const modules = [drawingModule({ licenseKey: process.env.NEXT_PUBLIC_DOCX_LICENSE })];
88
+ * const editor = createDocxEditor({ document: bytes, modules });
89
+ * ```
90
+ *
91
+ * @packageDocumentation
92
+ * @public
93
+ */
94
+
95
+ /**
96
+ * Install the drawing renderers (charts, SmartArt layout, effects, WordArt, and metafiles) for
97
+ * every editor and export in this process, without an editor module: for headless
98
+ * conversion. Installing again is harmless. A host without the EigenPal Pro License leaves
99
+ * this call out; its charts then show their fallback pictures or drawings, or placeholders.
100
+ *
101
+ * @public
102
+ */
103
+ declare function installDrawing(options?: ProLicenseOptions): void;
104
+ /**
105
+ * The drawing module for `createDocxEditor({ modules })`. Creating it installs the drawing
106
+ * renderers process-wide, as {@link installDrawing} does.
107
+ *
108
+ * @public
109
+ */
110
+ declare function drawingModule(options?: ProLicenseOptions): EditorModule;
111
+
112
+ export { ProLicenseOptions, drawingModule, installDrawing };
@@ -0,0 +1,112 @@
1
+ /**
2
+ * `@docx-editor.dev/pro/drawing` — advanced drawing rendering.
3
+ *
4
+ * The free engine paints pictures, shapes with fills, gradients, patterns, lines and outer
5
+ * shadows, text boxes, groups, canvases, text watermarks, and every SmartArt diagram saved
6
+ * with its drawing. This module adds:
7
+ *
8
+ * - charts, drawn from the values cached in their chart parts. Treemap, sunburst and map
9
+ * charts, and charts that mix a pie or radar plot with other plot types, do not render;
10
+ * - the layout of a SmartArt diagram saved without its drawing;
11
+ * - shape and picture effects: glow, inner shadow, reflection, soft edge, and the rim of a
12
+ * dark-edged bevel;
13
+ * - WordArt: VML text paths outside a watermark, fitted to the shape, between two guides, or
14
+ * along an arch, with gradient fills, shadows and 3-D extrusion;
15
+ * - EMF and WMF pictures: a vector replay for PDF export, and a browser raster that honors a
16
+ * metafile's own drawing origin.
17
+ *
18
+ * Without it, or for a chart it does not render, a chart saved with a fallback picture or
19
+ * drawing shows that fallback. In every state a chart selects as an object: picture commands
20
+ * are refused, and deleting it removes the chart with its fallback, as one tracked deletion
21
+ * of the whole chart when change tracking is on. Copy and cut of a selection that includes a
22
+ * chart are refused. The editor shows a labeled placeholder for other visible charts with
23
+ * usable bounds, including a skipped `mc:Choice` with an empty `mc:Fallback`, and a diagram
24
+ * saved without its drawing, and inline WordArt; floating WordArt does not show. The editor still rasterizes
25
+ * EMF and WMF pictures, and a shape paints without those effects. PDF export always includes
26
+ * this module.
27
+ *
28
+ * The renderers serve every editor and export in the process. Install them before any
29
+ * document opens; a later install logs a console warning once. `reviewModule()` installs them
30
+ * too. The metafile replay and `emf-converter` load on first use, only when a document holds a
31
+ * metafile picture.
32
+ *
33
+ * @example Enable advanced drawing rendering in an editor
34
+ * ```ts
35
+ * import { createDocxEditor } from '@docx-editor.dev/core/editor';
36
+ * import { drawingModule } from '@docx-editor.dev/pro/drawing';
37
+ *
38
+ * // Next.js; with Vite, read import.meta.env.VITE_DOCX_LICENSE.
39
+ * const modules = [drawingModule({ licenseKey: process.env.NEXT_PUBLIC_DOCX_LICENSE })];
40
+ * const editor = createDocxEditor({ document: bytes, modules });
41
+ * ```
42
+ *
43
+ * @packageDocumentation
44
+ * @public
45
+ */
46
+ import { EditorModule } from '@docx-editor.dev/core/editor';
47
+ import { P as ProLicenseOptions } from '../license-D-ds5Y7c.js';
48
+
49
+ /**
50
+ * `@docx-editor.dev/pro/drawing` — advanced drawing rendering.
51
+ *
52
+ * The free engine paints pictures, shapes with fills, gradients, patterns, lines and outer
53
+ * shadows, text boxes, groups, canvases, text watermarks, and every SmartArt diagram saved
54
+ * with its drawing. This module adds:
55
+ *
56
+ * - charts, drawn from the values cached in their chart parts. Treemap, sunburst and map
57
+ * charts, and charts that mix a pie or radar plot with other plot types, do not render;
58
+ * - the layout of a SmartArt diagram saved without its drawing;
59
+ * - shape and picture effects: glow, inner shadow, reflection, soft edge, and the rim of a
60
+ * dark-edged bevel;
61
+ * - WordArt: VML text paths outside a watermark, fitted to the shape, between two guides, or
62
+ * along an arch, with gradient fills, shadows and 3-D extrusion;
63
+ * - EMF and WMF pictures: a vector replay for PDF export, and a browser raster that honors a
64
+ * metafile's own drawing origin.
65
+ *
66
+ * Without it, or for a chart it does not render, a chart saved with a fallback picture or
67
+ * drawing shows that fallback. In every state a chart selects as an object: picture commands
68
+ * are refused, and deleting it removes the chart with its fallback, as one tracked deletion
69
+ * of the whole chart when change tracking is on. Copy and cut of a selection that includes a
70
+ * chart are refused. The editor shows a labeled placeholder for other visible charts with
71
+ * usable bounds, including a skipped `mc:Choice` with an empty `mc:Fallback`, and a diagram
72
+ * saved without its drawing, and inline WordArt; floating WordArt does not show. The editor still rasterizes
73
+ * EMF and WMF pictures, and a shape paints without those effects. PDF export always includes
74
+ * this module.
75
+ *
76
+ * The renderers serve every editor and export in the process. Install them before any
77
+ * document opens; a later install logs a console warning once. `reviewModule()` installs them
78
+ * too. The metafile replay and `emf-converter` load on first use, only when a document holds a
79
+ * metafile picture.
80
+ *
81
+ * @example Enable advanced drawing rendering in an editor
82
+ * ```ts
83
+ * import { createDocxEditor } from '@docx-editor.dev/core/editor';
84
+ * import { drawingModule } from '@docx-editor.dev/pro/drawing';
85
+ *
86
+ * // Next.js; with Vite, read import.meta.env.VITE_DOCX_LICENSE.
87
+ * const modules = [drawingModule({ licenseKey: process.env.NEXT_PUBLIC_DOCX_LICENSE })];
88
+ * const editor = createDocxEditor({ document: bytes, modules });
89
+ * ```
90
+ *
91
+ * @packageDocumentation
92
+ * @public
93
+ */
94
+
95
+ /**
96
+ * Install the drawing renderers (charts, SmartArt layout, effects, WordArt, and metafiles) for
97
+ * every editor and export in this process, without an editor module: for headless
98
+ * conversion. Installing again is harmless. A host without the EigenPal Pro License leaves
99
+ * this call out; its charts then show their fallback pictures or drawings, or placeholders.
100
+ *
101
+ * @public
102
+ */
103
+ declare function installDrawing(options?: ProLicenseOptions): void;
104
+ /**
105
+ * The drawing module for `createDocxEditor({ modules })`. Creating it installs the drawing
106
+ * renderers process-wide, as {@link installDrawing} does.
107
+ *
108
+ * @public
109
+ */
110
+ declare function drawingModule(options?: ProLicenseOptions): EditorModule;
111
+
112
+ export { ProLicenseOptions, drawingModule, installDrawing };
@@ -0,0 +1 @@
1
+ export{b as drawingModule,a as installDrawing}from'../chunk-SL6K2CUL.js';import'../chunk-HMU7J34H.js';
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var chunkFD2KDBHX_cjs=require('./chunk-FD2KDBHX.cjs'),chunkQLZH2Q2C_cjs=require('./chunk-QLZH2Q2C.cjs'),store=require('@docx-editor.dev/core/store');function U(t,n={}){let r=L(t);if(!r)return [];let o=n.nodes??t.getCustomNodeDefinitions().filter(chunkFD2KDBHX_cjs.j);if(o.length===0)return [];let s=r.session.currentPackage(),d=r.session.part().name,m=n.onDiagnostic??(e=>{t.reportCustomNodeDiagnostic(e);});return r.session.storyParts().flatMap(e=>chunkFD2KDBHX_cjs.n(e,o,{payloads:store.customNodePayloadsByControl(s,e.name,d),onDiagnostic:m}))}function L(t){return t.surface??null}function E(t,n,r={}){if(r.destination==="internal")return {ok:true,bytes:t,unwrapped:0,removed:0};let o=store.readOoxmlPackage(t);if(!o.ok)return {ok:false,reason:`the document could not be read: ${o.reason}`};let s=new Map;for(let i of n)s.set(`${i.tagPrefix}:${i.name}`,i);let d=i=>{let p=chunkFD2KDBHX_cjs.c(i);if(!p)return "keep";let x=s.get(`${p.prefix}:${p.name}`);return x?x.preserveOnExport==="text"?"text":x.preserveOnExport===false?"remove":"keep":"keep"},m=[...new Set(n.filter(i=>i.preserveOnExport!==void 0).filter(i=>i.preserveOnExport!==true).map(chunkFD2KDBHX_cjs.h))],e=o.package,u=0,c=0,g=V(e);for(let i of g){let p=store.withExportedCustomNodes(e,{storyPartName:i,namespaces:[],decide:d});if(!p.ok)return {ok:false,reason:p.reason};e=p.pkg,u+=p.unwrapped,c+=p.removed;}let l=store.withExportedCustomNodes(e,{storyPartName:e.mainDocumentPart,namespaces:m,decide:()=>"keep"});return l.ok?(e=l.pkg,{ok:true,bytes:store.writeOoxmlPackage(e),unwrapped:u,removed:c}):{ok:false,reason:l.reason}}function V(t){let n=[];for(let[r,o]of t.parts)r!==t.mainDocumentPart&&store.isStoryPart(o)&&n.push(r);return [t.mainDocumentPart,...n]}async function G(t,n={}){let r=n.nodes??t.getCustomNodeDefinitions().filter(chunkFD2KDBHX_cjs.j),o=await t.save();return E(new Uint8Array(o),r,{...n.destination===void 0?{}:{destination:n.destination}})}function a(t){return t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function K(t,n,r,o={}){if(!chunkFD2KDBHX_cjs.k.test(t.tagPrefix)||!chunkFD2KDBHX_cjs.k.test(t.name))return {ok:false,code:"invalidArgs",reason:"the definition identity must match defineCustomNode\u2019s charset ([A-Za-z0-9_.-])"};let s=chunkFD2KDBHX_cjs.b(t.tagPrefix,t.name,n);if(!s.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${s.length} characters; Word caps w:tag at 64 \u2014 shorten the attrs`};let d=o.lock===void 0?"contentLocked":o.lock,m=o.id!==void 0&&Number.isInteger(o.id)&&o.id>0?o.id:store.fnv1a32(`${s.tag}\0${r}`)&2147483647||1,e=o.data===void 0?null:Q(t,o,r);if(e&&"reason"in e)return {ok:false,code:"invalidArgs",reason:e.reason};let u=(o.alias!==void 0?`<w:alias w:val="${a(o.alias)}"/>`:"")+`<w:tag w:val="${a(s.tag)}"/><w:id w:val="${m}"/>`+(d===false?"":`<w:lock w:val="${d}"/>`)+(e?`<w:dataBinding w:prefixMappings="${a(e.binding.prefixMappings)}" w:xpath="${a(e.binding.xpath)}" w:storeItemID="${a(e.binding.storeItemId)}"/>`:""),c=`<w:r><w:t xml:space="preserve">${a(r)}</w:t></w:r>`;return {ok:true,xml:`<w:sdt><w:sdtPr>${u}</w:sdtPr><w:sdtContent>${c}</w:sdtContent></w:sdt>`,...e?{store:e.store}:{}}}function Q(t,n,r){let o=chunkFD2KDBHX_cjs.i(t,n.data);if(!o.ok)return {reason:o.reason};let s=chunkFD2KDBHX_cjs.h(t),d=n.storeIndex!==void 0&&Number.isInteger(n.storeIndex)&&n.storeIndex>0?n.storeIndex:1,m=n.nodeId??"cx1",e=`/customXml/item${String(d)}.xml`,u=`/customXml/itemProps${String(d)}.xml`,c=store.datastoreItemIdFor(`${s} ${e} ${m}`),g=store.customNodeBinding({partName:e,propsPartName:u,itemId:c,namespaceUri:s},chunkFD2KDBHX_cjs.g,m);if(!g)return {reason:`the payload cannot be addressed by an XPath: check nodeId (${m}) and payloadNamespace`};let l=r===r.trim()?`<label>${a(r)}</label>`:`<label xml:space="preserve">${a(r)}</label>`;return {binding:g,store:{itemPartName:e,itemXml:`<${chunkFD2KDBHX_cjs.g} xmlns="${a(s)}"><node id="${a(m)}">${l}<data>${a(o.data)}</data></node></${chunkFD2KDBHX_cjs.g}>`,propsPartName:u,propsXml:`<ds:datastoreItem ds:itemID="${a(c)}" xmlns:ds="${store.DATASTORE_NAMESPACE_URI}"><ds:schemaRefs><ds:schemaRef ds:uri="${a(s)}"/></ds:schemaRefs></ds:datastoreItem>`,storeItemId:c,relationships:[{from:"/word/document.xml",type:store.CUSTOM_XML_REL,target:`../customXml/item${String(d)}.xml`},{from:e,type:store.CUSTOM_XML_PROPS_REL,target:`itemProps${String(d)}.xml`}],contentTypeOverride:{partName:u,contentType:store.CUSTOM_XML_PROPS_TYPE}}}}Object.defineProperty(exports,"CUSTOM_NODE_STORE_ROOT",{enumerable:true,get:function(){return chunkFD2KDBHX_cjs.g}});Object.defineProperty(exports,"MAX_CUSTOM_NODE_DATA_LENGTH",{enumerable:true,get:function(){return chunkFD2KDBHX_cjs.d}});Object.defineProperty(exports,"MAX_TAG_LENGTH",{enumerable:true,get:function(){return chunkFD2KDBHX_cjs.a}});Object.defineProperty(exports,"customNodeNamespace",{enumerable:true,get:function(){return chunkFD2KDBHX_cjs.h}});Object.defineProperty(exports,"customNodesModule",{enumerable:true,get:function(){return chunkFD2KDBHX_cjs.m}});Object.defineProperty(exports,"decodeCustomNodeTag",{enumerable:true,get:function(){return chunkFD2KDBHX_cjs.c}});Object.defineProperty(exports,"defineCustomNode",{enumerable:true,get:function(){return chunkFD2KDBHX_cjs.l}});Object.defineProperty(exports,"encodeCustomNodeTag",{enumerable:true,get:function(){return chunkFD2KDBHX_cjs.b}});Object.defineProperty(exports,"insertCustomNode",{enumerable:true,get:function(){return chunkFD2KDBHX_cjs.p}});Object.defineProperty(exports,"isCustomNodeDefinition",{enumerable:true,get:function(){return chunkFD2KDBHX_cjs.j}});Object.defineProperty(exports,"parseCustomNodeData",{enumerable:true,get:function(){return chunkFD2KDBHX_cjs.e}});Object.defineProperty(exports,"recognizeCustomNodes",{enumerable:true,get:function(){return chunkFD2KDBHX_cjs.n}});Object.defineProperty(exports,"removeCustomNode",{enumerable:true,get:function(){return chunkFD2KDBHX_cjs.q}});Object.defineProperty(exports,"reviewModule",{enumerable:true,get:function(){return chunkFD2KDBHX_cjs.o}});Object.defineProperty(exports,"serializeCustomNodeData",{enumerable:true,get:function(){return chunkFD2KDBHX_cjs.f}});Object.defineProperty(exports,"updateCustomNode",{enumerable:true,get:function(){return chunkFD2KDBHX_cjs.r}});Object.defineProperty(exports,"collaborationModule",{enumerable:true,get:function(){return chunkQLZH2Q2C_cjs.b}});exports.customNodeXml=K;exports.customNodesOf=U;exports.prepareForExport=E;exports.saveForExport=G;
1
+ 'use strict';var chunkVY7374QP_cjs=require('./chunk-VY7374QP.cjs'),chunkQEULTKCT_cjs=require('./chunk-QEULTKCT.cjs');require('./chunk-GLYQ72LS.cjs'),require('./chunk-IULA3QRZ.cjs');var store=require('@docx-editor.dev/core/store');function U(t,n={}){let r=L(t);if(!r)return [];let o=n.nodes??t.getCustomNodeDefinitions().filter(chunkVY7374QP_cjs.j);if(o.length===0)return [];let s=r.session.currentPackage(),d=r.session.part().name,m=n.onDiagnostic??(e=>{t.reportCustomNodeDiagnostic(e);});return r.session.storyParts().flatMap(e=>chunkVY7374QP_cjs.n(e,o,{payloads:store.customNodePayloadsByControl(s,e.name,d),onDiagnostic:m}))}function L(t){return t.surface??null}function E(t,n,r={}){if(r.destination==="internal")return {ok:true,bytes:t,unwrapped:0,removed:0};let o=store.readOoxmlPackage(t);if(!o.ok)return {ok:false,reason:`the document could not be read: ${o.reason}`};let s=new Map;for(let i of n)s.set(`${i.tagPrefix}:${i.name}`,i);let d=i=>{let p=chunkVY7374QP_cjs.c(i);if(!p)return "keep";let x=s.get(`${p.prefix}:${p.name}`);return x?x.preserveOnExport==="text"?"text":x.preserveOnExport===false?"remove":"keep":"keep"},m=[...new Set(n.filter(i=>i.preserveOnExport!==void 0).filter(i=>i.preserveOnExport!==true).map(chunkVY7374QP_cjs.h))],e=o.package,u=0,c=0,g=V(e);for(let i of g){let p=store.withExportedCustomNodes(e,{storyPartName:i,namespaces:[],decide:d});if(!p.ok)return {ok:false,reason:p.reason};e=p.pkg,u+=p.unwrapped,c+=p.removed;}let l=store.withExportedCustomNodes(e,{storyPartName:e.mainDocumentPart,namespaces:m,decide:()=>"keep"});return l.ok?(e=l.pkg,{ok:true,bytes:store.writeOoxmlPackage(e),unwrapped:u,removed:c}):{ok:false,reason:l.reason}}function V(t){let n=[];for(let[r,o]of t.parts)r!==t.mainDocumentPart&&store.isStoryPart(o)&&n.push(r);return [t.mainDocumentPart,...n]}async function G(t,n={}){let r=n.nodes??t.getCustomNodeDefinitions().filter(chunkVY7374QP_cjs.j),o=await t.save();return E(new Uint8Array(o),r,{...n.destination===void 0?{}:{destination:n.destination}})}function a(t){return t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function K(t,n,r,o={}){if(!chunkVY7374QP_cjs.k.test(t.tagPrefix)||!chunkVY7374QP_cjs.k.test(t.name))return {ok:false,code:"invalidArgs",reason:"the definition identity must match defineCustomNode\u2019s charset ([A-Za-z0-9_.-])"};let s=chunkVY7374QP_cjs.b(t.tagPrefix,t.name,n);if(!s.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${s.length} characters; Word caps w:tag at 64 \u2014 shorten the attrs`};let d=o.lock===void 0?"contentLocked":o.lock,m=o.id!==void 0&&Number.isInteger(o.id)&&o.id>0?o.id:store.fnv1a32(`${s.tag}\0${r}`)&2147483647||1,e=o.data===void 0?null:Q(t,o,r);if(e&&"reason"in e)return {ok:false,code:"invalidArgs",reason:e.reason};let u=(o.alias!==void 0?`<w:alias w:val="${a(o.alias)}"/>`:"")+`<w:tag w:val="${a(s.tag)}"/><w:id w:val="${m}"/>`+(d===false?"":`<w:lock w:val="${d}"/>`)+(e?`<w:dataBinding w:prefixMappings="${a(e.binding.prefixMappings)}" w:xpath="${a(e.binding.xpath)}" w:storeItemID="${a(e.binding.storeItemId)}"/>`:""),c=`<w:r><w:t xml:space="preserve">${a(r)}</w:t></w:r>`;return {ok:true,xml:`<w:sdt><w:sdtPr>${u}</w:sdtPr><w:sdtContent>${c}</w:sdtContent></w:sdt>`,...e?{store:e.store}:{}}}function Q(t,n,r){let o=chunkVY7374QP_cjs.i(t,n.data);if(!o.ok)return {reason:o.reason};let s=chunkVY7374QP_cjs.h(t),d=n.storeIndex!==void 0&&Number.isInteger(n.storeIndex)&&n.storeIndex>0?n.storeIndex:1,m=n.nodeId??"cx1",e=`/customXml/item${String(d)}.xml`,u=`/customXml/itemProps${String(d)}.xml`,c=store.datastoreItemIdFor(`${s} ${e} ${m}`),g=store.customNodeBinding({partName:e,propsPartName:u,itemId:c,namespaceUri:s},chunkVY7374QP_cjs.g,m);if(!g)return {reason:`the payload cannot be addressed by an XPath: check nodeId (${m}) and payloadNamespace`};let l=r===r.trim()?`<label>${a(r)}</label>`:`<label xml:space="preserve">${a(r)}</label>`;return {binding:g,store:{itemPartName:e,itemXml:`<${chunkVY7374QP_cjs.g} xmlns="${a(s)}"><node id="${a(m)}">${l}<data>${a(o.data)}</data></node></${chunkVY7374QP_cjs.g}>`,propsPartName:u,propsXml:`<ds:datastoreItem ds:itemID="${a(c)}" xmlns:ds="${store.DATASTORE_NAMESPACE_URI}"><ds:schemaRefs><ds:schemaRef ds:uri="${a(s)}"/></ds:schemaRefs></ds:datastoreItem>`,storeItemId:c,relationships:[{from:"/word/document.xml",type:store.CUSTOM_XML_REL,target:`../customXml/item${String(d)}.xml`},{from:e,type:store.CUSTOM_XML_PROPS_REL,target:`itemProps${String(d)}.xml`}],contentTypeOverride:{partName:u,contentType:store.CUSTOM_XML_PROPS_TYPE}}}}Object.defineProperty(exports,"CUSTOM_NODE_STORE_ROOT",{enumerable:true,get:function(){return chunkVY7374QP_cjs.g}});Object.defineProperty(exports,"MAX_CUSTOM_NODE_DATA_LENGTH",{enumerable:true,get:function(){return chunkVY7374QP_cjs.d}});Object.defineProperty(exports,"MAX_TAG_LENGTH",{enumerable:true,get:function(){return chunkVY7374QP_cjs.a}});Object.defineProperty(exports,"customNodeNamespace",{enumerable:true,get:function(){return chunkVY7374QP_cjs.h}});Object.defineProperty(exports,"customNodesModule",{enumerable:true,get:function(){return chunkVY7374QP_cjs.m}});Object.defineProperty(exports,"decodeCustomNodeTag",{enumerable:true,get:function(){return chunkVY7374QP_cjs.c}});Object.defineProperty(exports,"defineCustomNode",{enumerable:true,get:function(){return chunkVY7374QP_cjs.l}});Object.defineProperty(exports,"encodeCustomNodeTag",{enumerable:true,get:function(){return chunkVY7374QP_cjs.b}});Object.defineProperty(exports,"insertCustomNode",{enumerable:true,get:function(){return chunkVY7374QP_cjs.p}});Object.defineProperty(exports,"isCustomNodeDefinition",{enumerable:true,get:function(){return chunkVY7374QP_cjs.j}});Object.defineProperty(exports,"parseCustomNodeData",{enumerable:true,get:function(){return chunkVY7374QP_cjs.e}});Object.defineProperty(exports,"recognizeCustomNodes",{enumerable:true,get:function(){return chunkVY7374QP_cjs.n}});Object.defineProperty(exports,"removeCustomNode",{enumerable:true,get:function(){return chunkVY7374QP_cjs.q}});Object.defineProperty(exports,"reviewModule",{enumerable:true,get:function(){return chunkVY7374QP_cjs.o}});Object.defineProperty(exports,"serializeCustomNodeData",{enumerable:true,get:function(){return chunkVY7374QP_cjs.f}});Object.defineProperty(exports,"updateCustomNode",{enumerable:true,get:function(){return chunkVY7374QP_cjs.r}});Object.defineProperty(exports,"collaborationModule",{enumerable:true,get:function(){return chunkQEULTKCT_cjs.a}});exports.customNodeXml=K;exports.customNodesOf=U;exports.prepareForExport=E;exports.saveForExport=G;