@postnzt/docx-js-editor 0.0.33

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 (117) hide show
  1. package/dist/ClipboardManager-C0rTRkVQ.d.ts +464 -0
  2. package/dist/ClipboardManager-CgpKW2At.d.mts +464 -0
  3. package/dist/DocumentAgent-BqA9EJ3F.d.mts +442 -0
  4. package/dist/DocumentAgent-CRCXiBT7.d.ts +442 -0
  5. package/dist/FindReplaceDialog-KNJETYJX.js +1 -0
  6. package/dist/FindReplaceDialog-YW3R4FHM.mjs +1 -0
  7. package/dist/FootnotePropertiesDialog-452A4UT5.js +1 -0
  8. package/dist/FootnotePropertiesDialog-H24AC5XK.mjs +1 -0
  9. package/dist/HyperlinkDialog-GBAYMTUE.js +1 -0
  10. package/dist/HyperlinkDialog-HNYTXDCB.mjs +1 -0
  11. package/dist/ImagePositionDialog-B4RLP2W5.mjs +1 -0
  12. package/dist/ImagePositionDialog-M65BYQQE.js +1 -0
  13. package/dist/ImagePropertiesDialog-JOGW3WDU.mjs +1 -0
  14. package/dist/ImagePropertiesDialog-O4WQSF5M.js +1 -0
  15. package/dist/PageSetupDialog-2GIBTKMJ.js +1 -0
  16. package/dist/PageSetupDialog-Q7SHEZIJ.mjs +1 -0
  17. package/dist/TablePropertiesDialog-LMXWX3FI.mjs +1 -0
  18. package/dist/TablePropertiesDialog-WOZ4ES3H.js +1 -0
  19. package/dist/agentApi-BVHzyk2l.d.mts +2239 -0
  20. package/dist/agentApi-BVHzyk2l.d.ts +2239 -0
  21. package/dist/chunk-2HDYCD2Q.mjs +1 -0
  22. package/dist/chunk-377ZVTSE.js +2 -0
  23. package/dist/chunk-37SLIJPH.mjs +58 -0
  24. package/dist/chunk-4VUZBV2S.js +1 -0
  25. package/dist/chunk-6WPRCJ5A.mjs +1 -0
  26. package/dist/chunk-7MGFEP2R.mjs +26 -0
  27. package/dist/chunk-7QTNB64A.mjs +9 -0
  28. package/dist/chunk-AARNCPWR.js +1 -0
  29. package/dist/chunk-AU5NVRHP.js +2 -0
  30. package/dist/chunk-BP3V2HDD.js +261 -0
  31. package/dist/chunk-BUEMG4NW.js +1 -0
  32. package/dist/chunk-DC65PJYE.js +4 -0
  33. package/dist/chunk-DLVLK5FT.mjs +24 -0
  34. package/dist/chunk-EV3CM6TU.js +1 -0
  35. package/dist/chunk-FVUGBRDD.js +1 -0
  36. package/dist/chunk-GZOCOWWB.mjs +2 -0
  37. package/dist/chunk-H5NTJZO4.js +1 -0
  38. package/dist/chunk-IFPN3NT3.js +3 -0
  39. package/dist/chunk-KCOGY3V2.js +10 -0
  40. package/dist/chunk-KUL2SDYC.js +26 -0
  41. package/dist/chunk-LFZXSNOF.mjs +261 -0
  42. package/dist/chunk-LYBG4YI7.mjs +1 -0
  43. package/dist/chunk-M5F4SK3W.mjs +1 -0
  44. package/dist/chunk-P7WEP4JU.js +9 -0
  45. package/dist/chunk-PB7VMDDP.js +24 -0
  46. package/dist/chunk-QAZ4233N.mjs +1 -0
  47. package/dist/chunk-QSUPYUOP.js +2 -0
  48. package/dist/chunk-QTSXJRP6.mjs +1 -0
  49. package/dist/chunk-QVPR2W5S.js +1 -0
  50. package/dist/chunk-RTFUE3KK.mjs +10 -0
  51. package/dist/chunk-SCYTWBF5.mjs +111 -0
  52. package/dist/chunk-SE5EN2QL.js +1 -0
  53. package/dist/chunk-T6X4C2QO.js +111 -0
  54. package/dist/chunk-TAUMSKRE.mjs +1 -0
  55. package/dist/chunk-W53SI3XW.mjs +1 -0
  56. package/dist/chunk-WOHFANC5.mjs +3 -0
  57. package/dist/chunk-X5A54T6S.mjs +4 -0
  58. package/dist/chunk-YKBSKEBS.mjs +2 -0
  59. package/dist/chunk-Z26WOH6R.mjs +2 -0
  60. package/dist/chunk-ZJNGMDRE.js +58 -0
  61. package/dist/clipboard-Cu80iVDh.d.ts +1181 -0
  62. package/dist/clipboard-dFROLI95.d.mts +1181 -0
  63. package/dist/colorResolver-BwI_Uxp3.d.mts +662 -0
  64. package/dist/colorResolver-Dlmk3itT.d.ts +662 -0
  65. package/dist/core-plugins-reexport.d.mts +31 -0
  66. package/dist/core-plugins-reexport.d.ts +31 -0
  67. package/dist/core-plugins-reexport.js +1 -0
  68. package/dist/core-plugins-reexport.mjs +1 -0
  69. package/dist/core-reexport.d.mts +309 -0
  70. package/dist/core-reexport.d.ts +309 -0
  71. package/dist/core-reexport.js +1 -0
  72. package/dist/core-reexport.mjs +1 -0
  73. package/dist/executor-L2MVKMXO.js +1 -0
  74. package/dist/executor-XKBCCVNY.mjs +1 -0
  75. package/dist/fontLoader-BI9ZoACv.d.ts +176 -0
  76. package/dist/fontLoader-DicgJidU.d.mts +176 -0
  77. package/dist/headless-reexport.d.mts +195 -0
  78. package/dist/headless-reexport.d.ts +195 -0
  79. package/dist/headless-reexport.js +4 -0
  80. package/dist/headless-reexport.mjs +4 -0
  81. package/dist/index.css +1 -0
  82. package/dist/index.d.mts +480 -0
  83. package/dist/index.d.ts +480 -0
  84. package/dist/index.js +112 -0
  85. package/dist/index.mjs +112 -0
  86. package/dist/lib-BCT2DRYI.mjs +1 -0
  87. package/dist/lib-U35UU4OU.js +1 -0
  88. package/dist/mcp-reexport.d.mts +156 -0
  89. package/dist/mcp-reexport.d.ts +156 -0
  90. package/dist/mcp-reexport.js +16 -0
  91. package/dist/mcp-reexport.mjs +16 -0
  92. package/dist/processTemplate-5ZST2Q5L.js +1 -0
  93. package/dist/processTemplate-LRHXOWMZ.mjs +1 -0
  94. package/dist/react-Cl2n0F5S.d.ts +1091 -0
  95. package/dist/react-DZlAKNXg.d.mts +1091 -0
  96. package/dist/react.css +1 -0
  97. package/dist/react.d.mts +10 -0
  98. package/dist/react.d.ts +10 -0
  99. package/dist/react.js +1 -0
  100. package/dist/react.mjs +1 -0
  101. package/dist/registry-D4FQ9aKX.d.mts +165 -0
  102. package/dist/registry-DrYyUXQr.d.ts +165 -0
  103. package/dist/selectionRects-DEX5THEG.js +1 -0
  104. package/dist/selectionRects-SQTAHMCH.mjs +1 -0
  105. package/dist/styles.css +1 -0
  106. package/dist/types-B3LkfO0u.d.mts +310 -0
  107. package/dist/types-igZ1x_e4.d.ts +310 -0
  108. package/dist/ui.d.mts +2005 -0
  109. package/dist/ui.d.ts +2005 -0
  110. package/dist/ui.js +1 -0
  111. package/dist/ui.mjs +1 -0
  112. package/dist/variableDetector-CIqTek7A.d.mts +204 -0
  113. package/dist/variableDetector-CkYvLv62.d.ts +204 -0
  114. package/i18n/de.json +745 -0
  115. package/i18n/en.json +745 -0
  116. package/i18n/pl.json +745 -0
  117. package/package.json +127 -0
@@ -0,0 +1,442 @@
1
+ import { D as Document, T as TextFormatting, _ as StyleInfo, h as AgentContext, P as Position, R as Range, K as ParagraphFormatting, A as AgentCommand } from './agentApi-BVHzyk2l.mjs';
2
+
3
+ /**
4
+ * Selective Save Module
5
+ *
6
+ * Orchestrates selective XML patching for the save flow.
7
+ * Serializes full document.xml, validates patch safety, builds patched XML,
8
+ * and calls applyUpdatesToZip() to produce the final DOCX.
9
+ *
10
+ * Returns null on any failure, signaling the caller to fall back to full repack.
11
+ */
12
+
13
+ interface SelectiveSaveOptions {
14
+ /** Changed paragraph IDs to selectively patch */
15
+ changedParaIds: Set<string>;
16
+ /** Whether structural changes occurred (paragraph add/delete) */
17
+ structuralChange: boolean;
18
+ /** Whether any changes affected paragraphs without paraId */
19
+ hasUntrackedChanges: boolean;
20
+ }
21
+ /**
22
+ * Attempt a selective save — patch only changed paragraphs in document.xml.
23
+ * Also updates comments, headers/footers, and core properties so that
24
+ * all document parts stay in sync even when only paragraphs are patched.
25
+ *
26
+ * Returns the saved ArrayBuffer, or null if selective save is not possible
27
+ * (caller should fall back to full repack).
28
+ */
29
+ declare function attemptSelectiveSave(doc: Document, originalBuffer: ArrayBuffer, options: SelectiveSaveOptions): Promise<ArrayBuffer | null>;
30
+
31
+ /**
32
+ * Flexible input types for DOCX documents.
33
+ *
34
+ * Accepts any common binary format so consumers don't need to manually
35
+ * convert before passing data to the editor or parser.
36
+ */
37
+ /**
38
+ * Any binary representation of a DOCX file that the editor can consume.
39
+ *
40
+ * - `ArrayBuffer` — from `FileReader.readAsArrayBuffer()` or `fetch().arrayBuffer()`
41
+ * - `Uint8Array` — from Node.js `fs.readFile()` or streaming APIs
42
+ * - `Blob` — from drag-and-drop or `<input type="file">`
43
+ * - `File` — subclass of Blob, from `<input type="file">`
44
+ */
45
+ type DocxInput = ArrayBuffer | Uint8Array | Blob | File;
46
+ /**
47
+ * Normalize any {@link DocxInput} into an `ArrayBuffer` for internal use.
48
+ */
49
+ declare function toArrayBuffer(input: DocxInput): Promise<ArrayBuffer>;
50
+
51
+ /**
52
+ * DocumentAgent - High-level fluent API for programmatic document manipulation
53
+ *
54
+ * Provides a convenient interface for:
55
+ * - Reading document content and metadata
56
+ * - Editing text with formatting
57
+ * - Inserting tables, images, and hyperlinks
58
+ * - Managing template variables
59
+ * - Exporting to DOCX buffer
60
+ *
61
+ * All operations are immutable - they return a new DocumentAgent instance
62
+ * or don't modify the underlying document.
63
+ */
64
+
65
+ /**
66
+ * Options for inserting text
67
+ */
68
+ interface InsertTextOptions {
69
+ /** Text formatting */
70
+ formatting?: TextFormatting;
71
+ }
72
+ /**
73
+ * Options for inserting table
74
+ */
75
+ interface InsertTableOptions {
76
+ /** Table data (2D array of strings) */
77
+ data?: string[][];
78
+ /** Whether first row is a header */
79
+ hasHeader?: boolean;
80
+ }
81
+ /**
82
+ * Options for inserting image
83
+ */
84
+ interface InsertImageOptions {
85
+ /** Image width in pixels */
86
+ width?: number;
87
+ /** Image height in pixels */
88
+ height?: number;
89
+ /** Alt text for accessibility */
90
+ alt?: string;
91
+ }
92
+ /**
93
+ * Options for inserting hyperlink
94
+ */
95
+ interface InsertHyperlinkOptions {
96
+ /** Display text (overrides selected text) */
97
+ displayText?: string;
98
+ /** Tooltip on hover */
99
+ tooltip?: string;
100
+ }
101
+ /**
102
+ * Formatted text segment
103
+ */
104
+ interface FormattedTextSegment {
105
+ /** Text content */
106
+ text: string;
107
+ /** Applied formatting */
108
+ formatting?: TextFormatting;
109
+ /** Is part of a hyperlink */
110
+ isHyperlink?: boolean;
111
+ /** Hyperlink URL if applicable */
112
+ hyperlinkUrl?: string;
113
+ }
114
+ /**
115
+ * DocumentAgent provides a fluent API for document manipulation
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * const agent = new DocumentAgent(buffer);
120
+ *
121
+ * // Read operations
122
+ * const text = agent.getText();
123
+ * const wordCount = agent.getWordCount();
124
+ * const variables = agent.getVariables();
125
+ *
126
+ * // Write operations (returns new agent)
127
+ * const newAgent = agent
128
+ * .insertText({ paragraphIndex: 0, offset: 0 }, 'Hello ', { formatting: { bold: true } })
129
+ * .applyStyle({ paragraphIndex: 0, offset: 0 }, { paragraphIndex: 0, offset: 5 }, 'Heading1');
130
+ *
131
+ * // Export
132
+ * const newBuffer = await newAgent.toBuffer();
133
+ * ```
134
+ */
135
+ declare class DocumentAgent {
136
+ private _document;
137
+ private _pendingVariables;
138
+ /**
139
+ * Create a new DocumentAgent
140
+ *
141
+ * @param source - Document object or ArrayBuffer to parse
142
+ */
143
+ constructor(source: Document | ArrayBuffer);
144
+ /**
145
+ * Create a DocumentAgent from a DOCX buffer (async)
146
+ *
147
+ * @param buffer - DOCX file as ArrayBuffer, Uint8Array, Blob, or File
148
+ * @returns Promise resolving to DocumentAgent
149
+ */
150
+ static fromBuffer(buffer: DocxInput): Promise<DocumentAgent>;
151
+ /**
152
+ * Create a DocumentAgent from a Document object
153
+ *
154
+ * @param document - Parsed Document
155
+ * @returns DocumentAgent
156
+ */
157
+ static fromDocument(document: Document): DocumentAgent;
158
+ /**
159
+ * Get the underlying document
160
+ */
161
+ getDocument(): Document;
162
+ /**
163
+ * Get plain text content of the document
164
+ *
165
+ * @returns All document text concatenated
166
+ */
167
+ getText(): string;
168
+ /**
169
+ * Get formatted text segments
170
+ *
171
+ * @returns Array of text segments with formatting info
172
+ */
173
+ getFormattedText(): FormattedTextSegment[];
174
+ /**
175
+ * Get detected template variables
176
+ *
177
+ * @returns Array of variable names (without braces)
178
+ */
179
+ getVariables(): string[];
180
+ /**
181
+ * Get available styles from the document
182
+ *
183
+ * @returns Array of style info
184
+ */
185
+ getStyles(): StyleInfo[];
186
+ /**
187
+ * Get approximate page count
188
+ *
189
+ * Note: This is an estimate based on content length.
190
+ * Actual page count requires full layout computation.
191
+ *
192
+ * @returns Estimated page count
193
+ */
194
+ getPageCount(): number;
195
+ /**
196
+ * Get word count
197
+ *
198
+ * @returns Number of words in the document
199
+ */
200
+ getWordCount(): number;
201
+ /**
202
+ * Get character count
203
+ *
204
+ * @param includeSpaces - Whether to include whitespace
205
+ * @returns Number of characters
206
+ */
207
+ getCharacterCount(includeSpaces?: boolean): number;
208
+ /**
209
+ * Get paragraph count
210
+ *
211
+ * @returns Number of paragraphs
212
+ */
213
+ getParagraphCount(): number;
214
+ /**
215
+ * Get table count
216
+ *
217
+ * @returns Number of tables
218
+ */
219
+ getTableCount(): number;
220
+ /**
221
+ * Get document context for AI agents
222
+ *
223
+ * @param outlineMaxChars - Max characters per paragraph in outline
224
+ * @returns Agent context
225
+ */
226
+ getAgentContext(outlineMaxChars?: number): AgentContext;
227
+ /**
228
+ * Insert text at a position
229
+ *
230
+ * @param position - Where to insert
231
+ * @param text - Text to insert
232
+ * @param options - Insert options
233
+ * @returns New DocumentAgent with text inserted
234
+ */
235
+ insertText(position: Position, text: string, options?: InsertTextOptions): DocumentAgent;
236
+ /**
237
+ * Replace text in a range
238
+ *
239
+ * @param range - Range to replace
240
+ * @param text - Replacement text
241
+ * @param options - Replace options
242
+ * @returns New DocumentAgent with text replaced
243
+ */
244
+ replaceRange(range: Range, text: string, options?: InsertTextOptions): DocumentAgent;
245
+ /**
246
+ * Delete text in a range
247
+ *
248
+ * @param range - Range to delete
249
+ * @returns New DocumentAgent with text deleted
250
+ */
251
+ deleteRange(range: Range): DocumentAgent;
252
+ /**
253
+ * Apply text formatting to a range
254
+ *
255
+ * @param range - Range to format
256
+ * @param formatting - Formatting to apply
257
+ * @returns New DocumentAgent with formatting applied
258
+ */
259
+ applyFormatting(range: Range, formatting: Partial<TextFormatting>): DocumentAgent;
260
+ /**
261
+ * Apply a named style to a paragraph
262
+ *
263
+ * @param paragraphIndex - Index of the paragraph
264
+ * @param styleId - Style ID to apply
265
+ * @returns New DocumentAgent with style applied
266
+ */
267
+ applyStyle(paragraphIndex: number, styleId: string): DocumentAgent;
268
+ /**
269
+ * Apply paragraph formatting
270
+ *
271
+ * @param paragraphIndex - Index of the paragraph
272
+ * @param formatting - Formatting to apply
273
+ * @returns New DocumentAgent with formatting applied
274
+ */
275
+ applyParagraphFormatting(paragraphIndex: number, formatting: Partial<ParagraphFormatting>): DocumentAgent;
276
+ /**
277
+ * Insert a table at a position
278
+ *
279
+ * @param position - Where to insert the table
280
+ * @param rows - Number of rows
281
+ * @param cols - Number of columns
282
+ * @param options - Table options
283
+ * @returns New DocumentAgent with table inserted
284
+ */
285
+ insertTable(position: Position, rows: number, cols: number, options?: InsertTableOptions): DocumentAgent;
286
+ /**
287
+ * Insert an image at a position
288
+ *
289
+ * @param position - Where to insert the image
290
+ * @param src - Image source (base64 data URL or URL)
291
+ * @param options - Image options
292
+ * @returns New DocumentAgent with image inserted
293
+ */
294
+ insertImage(position: Position, src: string, options?: InsertImageOptions): DocumentAgent;
295
+ /**
296
+ * Insert a hyperlink
297
+ *
298
+ * @param range - Range to make into a hyperlink
299
+ * @param url - URL of the hyperlink
300
+ * @param options - Hyperlink options
301
+ * @returns New DocumentAgent with hyperlink inserted
302
+ */
303
+ insertHyperlink(range: Range, url: string, options?: InsertHyperlinkOptions): DocumentAgent;
304
+ /**
305
+ * Remove a hyperlink but keep the text
306
+ *
307
+ * @param range - Range containing the hyperlink
308
+ * @returns New DocumentAgent with hyperlink removed
309
+ */
310
+ removeHyperlink(range: Range): DocumentAgent;
311
+ /**
312
+ * Insert a paragraph break
313
+ *
314
+ * @param position - Where to break the paragraph
315
+ * @returns New DocumentAgent with paragraph broken
316
+ */
317
+ insertParagraphBreak(position: Position): DocumentAgent;
318
+ /**
319
+ * Merge consecutive paragraphs
320
+ *
321
+ * @param startParagraphIndex - First paragraph index
322
+ * @param count - Number of paragraphs to merge with the first
323
+ * @returns New DocumentAgent with paragraphs merged
324
+ */
325
+ mergeParagraphs(startParagraphIndex: number, count: number): DocumentAgent;
326
+ /**
327
+ * Set a template variable value
328
+ *
329
+ * Note: Variables are not applied until `applyVariables()` is called
330
+ *
331
+ * @param name - Variable name (without braces)
332
+ * @param value - Variable value
333
+ * @returns This DocumentAgent (for chaining)
334
+ */
335
+ setVariable(name: string, value: string): DocumentAgent;
336
+ /**
337
+ * Set multiple template variables
338
+ *
339
+ * @param variables - Map of variable names to values
340
+ * @returns This DocumentAgent (for chaining)
341
+ */
342
+ setVariables(variables: Record<string, string>): DocumentAgent;
343
+ /**
344
+ * Get pending variable values
345
+ *
346
+ * @returns Map of pending variable values
347
+ */
348
+ getPendingVariables(): Record<string, string>;
349
+ /**
350
+ * Clear pending variables
351
+ *
352
+ * @returns This DocumentAgent (for chaining)
353
+ */
354
+ clearPendingVariables(): DocumentAgent;
355
+ /**
356
+ * Apply all pending template variables
357
+ *
358
+ * Uses docxtemplater to substitute variables while preserving formatting.
359
+ *
360
+ * @param variables - Optional additional variables (merged with pending)
361
+ * @returns New DocumentAgent with variables applied
362
+ */
363
+ applyVariables(variables?: Record<string, string>): Promise<DocumentAgent>;
364
+ /**
365
+ * Export document to DOCX ArrayBuffer
366
+ *
367
+ * @returns Promise resolving to DOCX file as ArrayBuffer
368
+ */
369
+ toBuffer(options?: {
370
+ selective?: SelectiveSaveOptions;
371
+ }): Promise<ArrayBuffer>;
372
+ /**
373
+ * Export document to Blob
374
+ *
375
+ * @param mimeType - MIME type for the blob
376
+ * @returns Promise resolving to DOCX file as Blob
377
+ */
378
+ toBlob(mimeType?: string): Promise<Blob>;
379
+ /**
380
+ * Execute multiple commands in sequence
381
+ *
382
+ * @param commands - Commands to execute
383
+ * @returns New DocumentAgent with all commands applied
384
+ */
385
+ executeCommands(commands: AgentCommand[]): DocumentAgent;
386
+ /**
387
+ * Execute a single command and return new agent
388
+ */
389
+ private _executeCommand;
390
+ /**
391
+ * Get plain text from document body
392
+ */
393
+ private _getBodyText;
394
+ /**
395
+ * Get plain text from a paragraph
396
+ */
397
+ private _getParagraphText;
398
+ /**
399
+ * Get plain text from a run
400
+ */
401
+ private _getRunText;
402
+ /**
403
+ * Get plain text from a hyperlink
404
+ */
405
+ private _getHyperlinkText;
406
+ /**
407
+ * Get plain text from a table
408
+ */
409
+ private _getTableText;
410
+ /**
411
+ * Extract formatted text segments from a paragraph
412
+ */
413
+ private _extractParagraphSegments;
414
+ /**
415
+ * Parse heading level from style ID
416
+ */
417
+ private _parseHeadingLevel;
418
+ /**
419
+ * Check if document has images
420
+ */
421
+ private _hasImages;
422
+ /**
423
+ * Check if document has hyperlinks
424
+ */
425
+ private _hasHyperlinks;
426
+ }
427
+ /**
428
+ * Create a DocumentAgent from a DOCX buffer
429
+ *
430
+ * @param buffer - DOCX file as ArrayBuffer
431
+ * @returns Promise resolving to DocumentAgent
432
+ */
433
+ declare function createAgent(buffer: ArrayBuffer): Promise<DocumentAgent>;
434
+ /**
435
+ * Create a DocumentAgent from a parsed Document
436
+ *
437
+ * @param document - Parsed Document
438
+ * @returns DocumentAgent
439
+ */
440
+ declare function createAgentFromDocument(document: Document): DocumentAgent;
441
+
442
+ export { DocumentAgent as D, type FormattedTextSegment as F, type InsertHyperlinkOptions as I, type InsertImageOptions as a, type InsertTableOptions as b, type InsertTextOptions as c, attemptSelectiveSave as d, createAgent as e, createAgentFromDocument as f, type DocxInput as g, toArrayBuffer as t };