@zeke-02/docx-editor 0.0.35 → 0.5.2
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 +34 -29
- package/dist/{ClipboardManager-C1l58nzE.d.ts → ClipboardManager-CVKX0v9q.d.ts} +1 -1
- package/dist/{ClipboardManager-Cjb_v74d.d.mts → ClipboardManager-V3aaMnWE.d.mts} +1 -1
- package/dist/{DocumentAgent-E8OX_8j0.d.mts → DocumentAgent-BWflKHpH.d.mts} +1 -1
- package/dist/{DocumentAgent-iedmc_8s.d.ts → DocumentAgent-DsdXtetF.d.ts} +1 -1
- package/dist/{FindReplaceDialog-YW3R4FHM.mjs → FindReplaceDialog-L3YF5HIS.mjs} +1 -1
- package/dist/FindReplaceDialog-SEBWC5P7.js +1 -0
- package/dist/{FootnotePropertiesDialog-LNFJXQUG.mjs → FootnotePropertiesDialog-TNVJJCY6.mjs} +1 -1
- package/dist/{FootnotePropertiesDialog-7QX54WQT.js → FootnotePropertiesDialog-XQ7NIFIU.js} +1 -1
- package/dist/{HyperlinkDialog-HNYTXDCB.mjs → HyperlinkDialog-FR4IZZ7E.mjs} +1 -1
- package/dist/HyperlinkDialog-WEK6JSAC.js +1 -0
- package/dist/{ImagePositionDialog-M65BYQQE.js → ImagePositionDialog-2YXRAGZS.js} +1 -1
- package/dist/{ImagePositionDialog-B4RLP2W5.mjs → ImagePositionDialog-JSZSIKF5.mjs} +1 -1
- package/dist/ImagePropertiesDialog-527MFLQO.mjs +1 -0
- package/dist/{ImagePropertiesDialog-O4WQSF5M.js → ImagePropertiesDialog-HG4K3IE7.js} +1 -1
- package/dist/PageSetupDialog-GALVJMUB.js +1 -0
- package/dist/PageSetupDialog-TGQIAMI7.mjs +1 -0
- package/dist/SplitCellDialog-JIAC3RYV.js +1 -0
- package/dist/SplitCellDialog-NP3JJYHD.mjs +1 -0
- package/dist/{TablePropertiesDialog-WOZ4ES3H.js → TablePropertiesDialog-T7D4HSVP.js} +1 -1
- package/dist/TablePropertiesDialog-TIK4AA5M.mjs +1 -0
- package/dist/{clipboard-BWhM0CRj.d.mts → TableToolbar-DUgmob2I.d.ts} +227 -135
- package/dist/{clipboard-BvkuNZub.d.ts → TableToolbar-YL74HNS1.d.mts} +227 -135
- package/dist/{agentApi-mv532p8I.d.mts → agentApi-DLt94vXk.d.mts} +83 -5
- package/dist/{agentApi-mv532p8I.d.ts → agentApi-DLt94vXk.d.ts} +83 -5
- package/dist/chunk-23SXXIZS.js +111 -0
- package/dist/chunk-3F52AP2Q.js +1 -0
- package/dist/chunk-42O5GXM5.mjs +82 -0
- package/dist/chunk-54ULJEHM.mjs +1 -0
- package/dist/chunk-5XK326FI.mjs +1 -0
- package/dist/chunk-76IYR7C7.mjs +1 -0
- package/dist/chunk-AGRIVA4G.js +1 -0
- package/dist/chunk-BTCQ2QI3.mjs +3 -0
- package/dist/chunk-BXRC4U3X.mjs +2 -0
- package/dist/chunk-CPAYKE6X.mjs +1 -0
- package/dist/chunk-DACWLFKI.mjs +1 -0
- package/dist/{chunk-377ZVTSE.js → chunk-EHFEG3TX.js} +1 -1
- package/dist/chunk-EPBFWE36.js +2 -0
- package/dist/chunk-FXES3YDB.js +82 -0
- package/dist/chunk-HI66BSGS.mjs +9 -0
- package/dist/chunk-INTPVEO6.mjs +9 -0
- package/dist/chunk-IOAGVW6Q.mjs +2 -0
- package/dist/chunk-JCEWC5QL.mjs +4 -0
- package/dist/chunk-JTIUFACT.js +1 -0
- package/dist/{chunk-KCOGY3V2.js → chunk-LUF7PWIC.js} +4 -4
- package/dist/chunk-LVGJKS7Y.mjs +24 -0
- package/dist/chunk-MGEN6GOE.mjs +2 -0
- package/dist/chunk-MOE2ZGUE.js +18 -0
- package/dist/chunk-MWLHJWB6.js +9 -0
- package/dist/chunk-OFYVDN3U.mjs +2 -0
- package/dist/chunk-P4VSHBGZ.js +2 -0
- package/dist/chunk-P5FQHIES.mjs +1 -0
- package/dist/chunk-PBC7XAYZ.js +3 -0
- package/dist/chunk-PEMB6SZT.js +2 -0
- package/dist/chunk-PKEOQIQO.mjs +2 -0
- package/dist/chunk-PQMSZTBB.js +9 -0
- package/dist/chunk-Q7UDQXAF.js +1 -0
- package/dist/chunk-QGTAIC5E.js +1 -0
- package/dist/chunk-R3QMYPL5.mjs +59 -0
- package/dist/chunk-RBUTXXQJ.mjs +18 -0
- package/dist/chunk-RRWYZ2TS.mjs +111 -0
- package/dist/chunk-S3STEPVO.js +182 -0
- package/dist/{chunk-AU5NVRHP.js → chunk-SFUM35DH.js} +2 -2
- package/dist/chunk-SNLC6EK2.js +1 -0
- package/dist/chunk-TMTLIGLZ.js +59 -0
- package/dist/{chunk-RTFUE3KK.mjs → chunk-TSE2PWFX.mjs} +3 -3
- package/dist/chunk-UKESXQS5.mjs +182 -0
- package/dist/chunk-UWYD42WV.js +4 -0
- package/dist/chunk-UXVACQCY.mjs +1 -0
- package/dist/{chunk-Z26WOH6R.mjs → chunk-W4EIKDM6.mjs} +2 -2
- package/dist/chunk-WNS2RBQD.js +2 -0
- package/dist/chunk-YC5KZSYD.js +24 -0
- package/dist/chunk-Z3KMSHUP.js +1 -0
- package/dist/core-plugins-reexport.d.mts +4 -4
- package/dist/core-plugins-reexport.d.ts +4 -4
- package/dist/core-plugins-reexport.js +1 -1
- package/dist/core-plugins-reexport.mjs +1 -1
- package/dist/core-reexport.d.mts +47 -16
- package/dist/core-reexport.d.ts +47 -16
- package/dist/core-reexport.js +1 -1
- package/dist/core-reexport.mjs +1 -1
- package/dist/{colorResolver-C5fQ4fxP.d.mts → documentSerializer-DtS_-oGA.d.mts} +378 -376
- package/dist/{colorResolver-Bp9flT3l.d.ts → documentSerializer-Wj1p2ASa.d.ts} +378 -376
- package/dist/executor-C3VXF7QA.mjs +1 -0
- package/dist/executor-GDBV3AGV.js +1 -0
- package/dist/headless-reexport.d.mts +14 -12
- package/dist/headless-reexport.d.ts +14 -12
- package/dist/headless-reexport.js +1 -4
- package/dist/headless-reexport.mjs +1 -4
- package/dist/index.css +1 -1
- package/dist/index.d.mts +284 -172
- package/dist/index.d.ts +284 -172
- package/dist/index.js +17 -9
- package/dist/index.mjs +17 -9
- package/dist/{fontLoader-0G00frKD.d.mts → insertOperations-BTH1Asas.d.mts} +86 -86
- package/dist/{fontLoader-DPdt4JvW.d.ts → insertOperations-CbUnXAXH.d.ts} +86 -86
- package/dist/layout-bridge-EA4DJ227.js +1 -0
- package/dist/layout-bridge-XDPSO6GO.mjs +1 -0
- package/dist/mcp-reexport.d.mts +2 -2
- package/dist/mcp-reexport.d.ts +2 -2
- package/dist/mcp-reexport.js +8 -8
- package/dist/mcp-reexport.mjs +7 -7
- package/dist/processTemplate-MJ2PCSO5.js +1 -0
- package/dist/{processTemplate-LRHXOWMZ.mjs → processTemplate-W2C5PXZB.mjs} +1 -1
- package/dist/{react-1OO-DXvx.d.ts → react-B0W16SV6.d.ts} +384 -166
- package/dist/{react-B1dSZ_w1.d.mts → react-D0Pn1nww.d.mts} +384 -166
- package/dist/react.css +1 -1
- package/dist/react.d.mts +5 -5
- package/dist/react.d.ts +5 -5
- package/dist/react.js +1 -1
- package/dist/react.mjs +1 -1
- package/dist/{registry-BWGKcKc1.d.ts → registry-CH9V-IX0.d.ts} +1 -1
- package/dist/{registry-8XOdjHGC.d.mts → registry-CWBKYlNW.d.mts} +1 -1
- package/dist/styles.css +1 -1
- package/dist/{types-DIBvJ7AJ.d.mts → types-UDsUq8D3.d.mts} +1 -1
- package/dist/{types-CfAiObQo.d.ts → types-jbivc9Lj.d.ts} +1 -1
- package/dist/ui.d.mts +33 -83
- package/dist/ui.d.ts +33 -83
- package/dist/ui.js +1 -1
- package/dist/ui.mjs +1 -1
- package/dist/{variableDetector-DNO18eZ1.d.mts → variableDetector-CdQ7ZTzA.d.mts} +1 -1
- package/dist/{variableDetector-BIJFVpkl.d.ts → variableDetector-DsRV3A9z.d.ts} +1 -1
- package/i18n/de.json +49 -2
- package/i18n/en.json +55 -8
- package/i18n/he.json +792 -0
- package/i18n/pl.json +49 -2
- package/i18n/pt-BR.json +792 -0
- package/i18n/tr.json +792 -0
- package/i18n/zh-CN.json +792 -0
- package/package.json +17 -5
- package/dist/FindReplaceDialog-KNJETYJX.js +0 -1
- package/dist/HyperlinkDialog-GBAYMTUE.js +0 -1
- package/dist/ImagePropertiesDialog-JOGW3WDU.mjs +0 -1
- package/dist/PageSetupDialog-2GIBTKMJ.js +0 -1
- package/dist/PageSetupDialog-Q7SHEZIJ.mjs +0 -1
- package/dist/TablePropertiesDialog-LMXWX3FI.mjs +0 -1
- package/dist/chunk-2HDYCD2Q.mjs +0 -1
- package/dist/chunk-37SLIJPH.mjs +0 -58
- package/dist/chunk-3OKYQQQ5.js +0 -111
- package/dist/chunk-4VUZBV2S.js +0 -1
- package/dist/chunk-6YRWZ32V.js +0 -261
- package/dist/chunk-7MGFEP2R.mjs +0 -26
- package/dist/chunk-7QTNB64A.mjs +0 -9
- package/dist/chunk-AARNCPWR.js +0 -1
- package/dist/chunk-DC65PJYE.js +0 -4
- package/dist/chunk-DLVLK5FT.mjs +0 -24
- package/dist/chunk-EV3CM6TU.js +0 -1
- package/dist/chunk-FVUGBRDD.js +0 -1
- package/dist/chunk-FW5LYOOZ.mjs +0 -111
- package/dist/chunk-GZOCOWWB.mjs +0 -2
- package/dist/chunk-KUL2SDYC.js +0 -26
- package/dist/chunk-LYBG4YI7.mjs +0 -1
- package/dist/chunk-M5F4SK3W.mjs +0 -1
- package/dist/chunk-P7WEP4JU.js +0 -9
- package/dist/chunk-PB7VMDDP.js +0 -24
- package/dist/chunk-QAZ4233N.mjs +0 -1
- package/dist/chunk-QSUPYUOP.js +0 -2
- package/dist/chunk-QTSXJRP6.mjs +0 -1
- package/dist/chunk-S67UBZDL.mjs +0 -261
- package/dist/chunk-SE5EN2QL.js +0 -1
- package/dist/chunk-X5A54T6S.mjs +0 -4
- package/dist/chunk-YKBSKEBS.mjs +0 -2
- package/dist/chunk-ZJNGMDRE.js +0 -58
- package/dist/executor-L2MVKMXO.js +0 -1
- package/dist/executor-XKBCCVNY.mjs +0 -1
- package/dist/processTemplate-5ZST2Q5L.js +0 -1
- package/dist/selectionRects-DEX5THEG.js +0 -1
- package/dist/selectionRects-SQTAHMCH.mjs +0 -1
|
@@ -1,275 +1,5 @@
|
|
|
1
|
-
import { D as Document,
|
|
2
|
-
import { g as DocxInput } from './DocumentAgent-
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Main Parser Orchestrator - Unified parseDocx function
|
|
6
|
-
*
|
|
7
|
-
* Coordinates all sub-parsers to produce a complete Document model.
|
|
8
|
-
* Handles loading order, dependency resolution, and font preloading.
|
|
9
|
-
*
|
|
10
|
-
* Parsing order:
|
|
11
|
-
* 1. Unzip DOCX package
|
|
12
|
-
* 2. Parse relationships
|
|
13
|
-
* 3. Parse theme (needed for style color/font resolution)
|
|
14
|
-
* 4. Parse styles (depends on theme)
|
|
15
|
-
* 5. Parse numbering
|
|
16
|
-
* 6. Parse document body (depends on styles, theme, numbering, rels)
|
|
17
|
-
* 7. Parse headers/footers (depends on styles, theme, numbering, rels)
|
|
18
|
-
* 8. Parse footnotes/endnotes (depends on styles, theme, numbering, rels)
|
|
19
|
-
* 9. Extract and load fonts
|
|
20
|
-
* 10. Build media file map
|
|
21
|
-
* 11. Assemble final Document
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Progress callback for tracking parsing stages
|
|
26
|
-
*/
|
|
27
|
-
type ProgressCallback = (stage: string, percent: number) => void;
|
|
28
|
-
/**
|
|
29
|
-
* Parsing options
|
|
30
|
-
*/
|
|
31
|
-
interface ParseOptions {
|
|
32
|
-
/** Progress callback for tracking parsing stages */
|
|
33
|
-
onProgress?: ProgressCallback;
|
|
34
|
-
/** Whether to preload fonts (default: true) */
|
|
35
|
-
preloadFonts?: boolean;
|
|
36
|
-
/** Whether to parse headers/footers (default: true) */
|
|
37
|
-
parseHeadersFooters?: boolean;
|
|
38
|
-
/** Whether to parse footnotes/endnotes (default: true) */
|
|
39
|
-
parseNotes?: boolean;
|
|
40
|
-
/** Whether to detect template variables (default: true) */
|
|
41
|
-
detectVariables?: boolean;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Parse a DOCX file into a complete Document model
|
|
45
|
-
*
|
|
46
|
-
* @param input - DOCX file as ArrayBuffer, Uint8Array, Blob, or File
|
|
47
|
-
* @param options - Parsing options
|
|
48
|
-
* @returns Promise resolving to Document
|
|
49
|
-
* @throws Error if parsing fails
|
|
50
|
-
*/
|
|
51
|
-
declare function parseDocx(input: DocxInput, options?: ParseOptions): Promise<Document>;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Document Serializer - Serialize complete document.xml
|
|
55
|
-
*
|
|
56
|
-
* Converts Document objects back to valid document.xml OOXML format.
|
|
57
|
-
* Combines all content (paragraphs, tables) with section properties
|
|
58
|
-
* and proper namespace declarations.
|
|
59
|
-
*
|
|
60
|
-
* OOXML Reference:
|
|
61
|
-
* - Document root: w:document
|
|
62
|
-
* - Document body: w:body
|
|
63
|
-
* - Section properties: w:sectPr
|
|
64
|
-
*/
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Serialize section properties (w:sectPr)
|
|
68
|
-
*/
|
|
69
|
-
declare function serializeSectionProperties(props: SectionProperties | undefined): string;
|
|
70
|
-
/**
|
|
71
|
-
* Serialize a DocumentBody to document.xml body content
|
|
72
|
-
*
|
|
73
|
-
* @param body - The document body to serialize
|
|
74
|
-
* @returns XML string for the body element (without body tags)
|
|
75
|
-
*/
|
|
76
|
-
declare function serializeDocumentBody(body: DocumentBody): string;
|
|
77
|
-
/**
|
|
78
|
-
* Serialize a complete Document to valid document.xml
|
|
79
|
-
*
|
|
80
|
-
* @param doc - The document to serialize
|
|
81
|
-
* @returns Complete XML string for document.xml
|
|
82
|
-
*/
|
|
83
|
-
declare function serializeDocument(doc: Document): string;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Template Processing Utility
|
|
87
|
-
*
|
|
88
|
-
* Uses docxtemplater to substitute template variables in DOCX documents:
|
|
89
|
-
* - Processes {variable_name} patterns (docxtemplater default syntax)
|
|
90
|
-
* - Preserves all formatting (fonts, styles, colors, tables)
|
|
91
|
-
* - Error handling with useful messages
|
|
92
|
-
*/
|
|
93
|
-
/**
|
|
94
|
-
* Options for template processing
|
|
95
|
-
*/
|
|
96
|
-
interface ProcessTemplateOptions {
|
|
97
|
-
/** How to handle undefined variables */
|
|
98
|
-
nullGetter?: 'keep' | 'empty' | 'error';
|
|
99
|
-
/** Custom parser for variable names */
|
|
100
|
-
parser?: (tag: string) => {
|
|
101
|
-
get: (scope: Record<string, unknown>) => unknown;
|
|
102
|
-
};
|
|
103
|
-
/** Line breaks: keep raw \n or convert to w:br */
|
|
104
|
-
linebreaks?: boolean;
|
|
105
|
-
/** Delimiter settings */
|
|
106
|
-
delimiters?: {
|
|
107
|
-
start?: string;
|
|
108
|
-
end?: string;
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Result of template processing
|
|
113
|
-
*/
|
|
114
|
-
interface ProcessTemplateResult {
|
|
115
|
-
/** The processed document buffer */
|
|
116
|
-
buffer: ArrayBuffer;
|
|
117
|
-
/** Variables that were found and replaced */
|
|
118
|
-
replacedVariables: string[];
|
|
119
|
-
/** Variables that were not replaced (no value provided) */
|
|
120
|
-
unreplacedVariables: string[];
|
|
121
|
-
/** Any warnings during processing */
|
|
122
|
-
warnings: string[];
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Error details from template processing
|
|
126
|
-
*/
|
|
127
|
-
interface TemplateError {
|
|
128
|
-
/** Error message */
|
|
129
|
-
message: string;
|
|
130
|
-
/** Variable name that caused the error (if applicable) */
|
|
131
|
-
variable?: string;
|
|
132
|
-
/** Error type */
|
|
133
|
-
type: 'parse' | 'render' | 'undefined' | 'unknown';
|
|
134
|
-
/** Original error */
|
|
135
|
-
originalError?: Error;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Process a DOCX template with variable substitution
|
|
139
|
-
*
|
|
140
|
-
* @param buffer - The DOCX file as ArrayBuffer
|
|
141
|
-
* @param variables - Map of variable names to values
|
|
142
|
-
* @param options - Processing options
|
|
143
|
-
* @returns Processed DOCX as ArrayBuffer
|
|
144
|
-
*/
|
|
145
|
-
declare function processTemplate(buffer: ArrayBuffer, variables: Record<string, string>, options?: ProcessTemplateOptions): ArrayBuffer;
|
|
146
|
-
/**
|
|
147
|
-
* Process template with detailed result
|
|
148
|
-
*
|
|
149
|
-
* @param buffer - The DOCX file as ArrayBuffer
|
|
150
|
-
* @param variables - Map of variable names to values
|
|
151
|
-
* @param options - Processing options
|
|
152
|
-
* @returns Detailed processing result
|
|
153
|
-
*/
|
|
154
|
-
declare function processTemplateDetailed(buffer: ArrayBuffer, variables: Record<string, string>, options?: ProcessTemplateOptions): ProcessTemplateResult;
|
|
155
|
-
/**
|
|
156
|
-
* Process template and return as Blob
|
|
157
|
-
*
|
|
158
|
-
* @param buffer - The DOCX file as ArrayBuffer
|
|
159
|
-
* @param variables - Map of variable names to values
|
|
160
|
-
* @param options - Processing options
|
|
161
|
-
* @returns Processed DOCX as Blob
|
|
162
|
-
*/
|
|
163
|
-
declare function processTemplateAsBlob(buffer: ArrayBuffer, variables: Record<string, string>, options?: ProcessTemplateOptions): Blob;
|
|
164
|
-
/**
|
|
165
|
-
* Get all template tags in a document without processing
|
|
166
|
-
*
|
|
167
|
-
* @param buffer - The DOCX file as ArrayBuffer
|
|
168
|
-
* @returns List of tag names found
|
|
169
|
-
*/
|
|
170
|
-
declare function getTemplateTags(buffer: ArrayBuffer): string[];
|
|
171
|
-
/**
|
|
172
|
-
* Validate that a document is a valid docxtemplater template
|
|
173
|
-
*
|
|
174
|
-
* @param buffer - The DOCX file as ArrayBuffer
|
|
175
|
-
* @returns Validation result
|
|
176
|
-
*/
|
|
177
|
-
declare function validateTemplate(buffer: ArrayBuffer): {
|
|
178
|
-
valid: boolean;
|
|
179
|
-
errors: TemplateError[];
|
|
180
|
-
tags: string[];
|
|
181
|
-
};
|
|
182
|
-
/**
|
|
183
|
-
* Check if all required variables have values
|
|
184
|
-
*
|
|
185
|
-
* @param tags - List of template tags
|
|
186
|
-
* @param variables - Provided variable values
|
|
187
|
-
* @returns Missing variable names
|
|
188
|
-
*/
|
|
189
|
-
declare function getMissingVariables(tags: string[], variables: Record<string, string>): string[];
|
|
190
|
-
/**
|
|
191
|
-
* Preview what the document will look like after processing
|
|
192
|
-
* Returns the document text with variables replaced (for preview purposes)
|
|
193
|
-
*
|
|
194
|
-
* @param buffer - The DOCX file as ArrayBuffer
|
|
195
|
-
* @param variables - Map of variable names to values
|
|
196
|
-
* @returns Preview text
|
|
197
|
-
*/
|
|
198
|
-
declare function previewTemplate(buffer: ArrayBuffer, variables: Record<string, string>): string;
|
|
199
|
-
/**
|
|
200
|
-
* Process template with conditional sections
|
|
201
|
-
* Supports #if, #unless, #each loops
|
|
202
|
-
*
|
|
203
|
-
* @param buffer - The DOCX file as ArrayBuffer
|
|
204
|
-
* @param data - Full data object (can include arrays, nested objects)
|
|
205
|
-
* @param options - Processing options
|
|
206
|
-
* @returns Processed DOCX as ArrayBuffer
|
|
207
|
-
*/
|
|
208
|
-
declare function processTemplateAdvanced(buffer: ArrayBuffer, data: Record<string, unknown>, options?: ProcessTemplateOptions): ArrayBuffer;
|
|
209
|
-
/**
|
|
210
|
-
* Create a template processor with preset options
|
|
211
|
-
*/
|
|
212
|
-
declare function createTemplateProcessor(defaultOptions?: ProcessTemplateOptions): (buffer: ArrayBuffer, variables: Record<string, string>) => ArrayBuffer;
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Create Document Utility
|
|
216
|
-
*
|
|
217
|
-
* Provides functions to create new documents programmatically.
|
|
218
|
-
*/
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Options for creating an empty document
|
|
222
|
-
*/
|
|
223
|
-
interface CreateEmptyDocumentOptions {
|
|
224
|
-
/** Page width in twips (default: 12240 = 8.5 inches) */
|
|
225
|
-
pageWidth?: number;
|
|
226
|
-
/** Page height in twips (default: 15840 = 11 inches) */
|
|
227
|
-
pageHeight?: number;
|
|
228
|
-
/** Page orientation (default: 'portrait') */
|
|
229
|
-
orientation?: 'portrait' | 'landscape';
|
|
230
|
-
/** Top margin in twips (default: 1440 = 1 inch) */
|
|
231
|
-
marginTop?: number;
|
|
232
|
-
/** Bottom margin in twips (default: 1440 = 1 inch) */
|
|
233
|
-
marginBottom?: number;
|
|
234
|
-
/** Left margin in twips (default: 1440 = 1 inch) */
|
|
235
|
-
marginLeft?: number;
|
|
236
|
-
/** Right margin in twips (default: 1440 = 1 inch) */
|
|
237
|
-
marginRight?: number;
|
|
238
|
-
/** Initial text content (default: empty string) */
|
|
239
|
-
initialText?: string;
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Create an empty document with a single paragraph
|
|
243
|
-
*
|
|
244
|
-
* @param options - Optional configuration for the document
|
|
245
|
-
* @returns A new empty Document object
|
|
246
|
-
*
|
|
247
|
-
* @example
|
|
248
|
-
* ```ts
|
|
249
|
-
* // Create a blank document
|
|
250
|
-
* const doc = createEmptyDocument();
|
|
251
|
-
*
|
|
252
|
-
* // Create with custom margins
|
|
253
|
-
* const doc = createEmptyDocument({
|
|
254
|
-
* marginTop: 720, // 0.5 inch
|
|
255
|
-
* marginBottom: 720,
|
|
256
|
-
* });
|
|
257
|
-
*
|
|
258
|
-
* // Create with initial text
|
|
259
|
-
* const doc = createEmptyDocument({
|
|
260
|
-
* initialText: 'Hello, World!'
|
|
261
|
-
* });
|
|
262
|
-
* ```
|
|
263
|
-
*/
|
|
264
|
-
declare function createEmptyDocument(options?: CreateEmptyDocumentOptions): Document;
|
|
265
|
-
/**
|
|
266
|
-
* Create a document with a single paragraph containing the given text
|
|
267
|
-
*
|
|
268
|
-
* @param text - The text content for the document
|
|
269
|
-
* @param options - Optional configuration for the document
|
|
270
|
-
* @returns A new Document object with the specified text
|
|
271
|
-
*/
|
|
272
|
-
declare function createDocumentWithText(text: string, options?: Omit<CreateEmptyDocumentOptions, 'initialText'>): Document;
|
|
1
|
+
import { D as Document, A as AgentCommand, h as AgentContext, R as Range, W as SelectionContext, T as TextFormatting, ao as ColorValue, a3 as Theme, ap as ThemeColorSlot, al as ThemeColorScheme, d as DocumentBody, V as SectionProperties } from './agentApi-DLt94vXk.mjs';
|
|
2
|
+
import { g as DocxInput } from './DocumentAgent-BWflKHpH.mjs';
|
|
273
3
|
|
|
274
4
|
/**
|
|
275
5
|
* Command Executor
|
|
@@ -457,7 +187,9 @@ declare function pixelsToTwips(px: number): number;
|
|
|
457
187
|
*/
|
|
458
188
|
declare function emuToPixels(emu: number | undefined | null): number;
|
|
459
189
|
/**
|
|
460
|
-
* Convert pixels to EMUs
|
|
190
|
+
* Convert pixels to EMUs.
|
|
191
|
+
* EMU coordinates in OOXML are integer-typed (xs:long); rounding here keeps
|
|
192
|
+
* floating-point drift (e.g. 52 px → 495299.99999999994) out of the document.
|
|
461
193
|
*/
|
|
462
194
|
declare function pixelsToEmu(px: number): number;
|
|
463
195
|
/**
|
|
@@ -506,157 +238,427 @@ declare function formatPx(px: number): string;
|
|
|
506
238
|
* - Shade makes color darker (blend with black)
|
|
507
239
|
* - Value is in hex (00-FF), converted to 0-1 for calculation
|
|
508
240
|
*/
|
|
509
|
-
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Resolve a ColorValue to a CSS color string
|
|
244
|
+
*
|
|
245
|
+
* @param color - ColorValue object with rgb, themeColor, tint/shade, or auto
|
|
246
|
+
* @param theme - Theme for resolving theme colors
|
|
247
|
+
* @param defaultColor - Default color if auto or undefined (default: black)
|
|
248
|
+
* @returns CSS color string (e.g., "#FF0000" or "inherit")
|
|
249
|
+
*/
|
|
250
|
+
declare function resolveColor(color: ColorValue | undefined | null, theme: Theme | null | undefined, defaultColor?: string): string;
|
|
251
|
+
/**
|
|
252
|
+
* Resolve a highlight color name to CSS
|
|
253
|
+
*
|
|
254
|
+
* @param highlight - Highlight color name (e.g., "yellow", "cyan")
|
|
255
|
+
* @returns CSS color string or empty string for "none"
|
|
256
|
+
*/
|
|
257
|
+
declare function resolveHighlightColor(highlight: string | undefined): string;
|
|
258
|
+
/**
|
|
259
|
+
* Resolve a shading fill or pattern color to CSS
|
|
260
|
+
*
|
|
261
|
+
* @param color - ColorValue for fill
|
|
262
|
+
* @param theme - Theme for resolving theme colors
|
|
263
|
+
* @returns CSS color string
|
|
264
|
+
*/
|
|
265
|
+
declare function resolveShadingColor(color: ColorValue | undefined | null, theme: Theme | null | undefined): string;
|
|
266
|
+
/**
|
|
267
|
+
* Check if a color is effectively black
|
|
268
|
+
*
|
|
269
|
+
* @param color - ColorValue object
|
|
270
|
+
* @param theme - Theme for resolving theme colors
|
|
271
|
+
* @returns True if color resolves to black or very dark
|
|
272
|
+
*/
|
|
273
|
+
declare function isBlack(color: ColorValue | undefined | null, theme: Theme | null | undefined): boolean;
|
|
274
|
+
/**
|
|
275
|
+
* Check if a color is effectively white
|
|
276
|
+
*
|
|
277
|
+
* @param color - ColorValue object
|
|
278
|
+
* @param theme - Theme for resolving theme colors
|
|
279
|
+
* @returns True if color resolves to white or very light
|
|
280
|
+
*/
|
|
281
|
+
declare function isWhite(color: ColorValue | undefined | null, theme: Theme | null | undefined): boolean;
|
|
282
|
+
/**
|
|
283
|
+
* Get contrasting text color for a background
|
|
284
|
+
*
|
|
285
|
+
* @param backgroundColor - Background ColorValue
|
|
286
|
+
* @param theme - Theme for resolving theme colors
|
|
287
|
+
* @returns Black or white hex color for best contrast
|
|
288
|
+
*/
|
|
289
|
+
declare function getContrastingColor(backgroundColor: ColorValue | undefined | null, theme: Theme | null | undefined): string;
|
|
290
|
+
/**
|
|
291
|
+
* Parse a color string (various formats) to ColorValue
|
|
292
|
+
*
|
|
293
|
+
* @param colorString - Color string like "FF0000", "auto", or theme color name
|
|
294
|
+
* @returns ColorValue object
|
|
295
|
+
*/
|
|
296
|
+
declare function parseColorString(colorString: string | undefined): ColorValue | undefined;
|
|
297
|
+
/**
|
|
298
|
+
* Create a ColorValue from theme color reference
|
|
299
|
+
*
|
|
300
|
+
* @param themeColor - Theme color slot name
|
|
301
|
+
* @param tint - Optional tint modifier
|
|
302
|
+
* @param shade - Optional shade modifier
|
|
303
|
+
* @returns ColorValue object
|
|
304
|
+
*/
|
|
305
|
+
declare function createThemeColor(themeColor: ThemeColorSlot, tint?: number, shade?: number): ColorValue;
|
|
306
|
+
/**
|
|
307
|
+
* Create a ColorValue from RGB hex
|
|
308
|
+
*
|
|
309
|
+
* @param hex - 6-character hex color (no #)
|
|
310
|
+
* @returns ColorValue object
|
|
311
|
+
*/
|
|
312
|
+
declare function createRgbColor(hex: string): ColorValue;
|
|
313
|
+
/**
|
|
314
|
+
* Darken a color by a percentage
|
|
315
|
+
*
|
|
316
|
+
* @param color - ColorValue to darken
|
|
317
|
+
* @param theme - Theme for resolving
|
|
318
|
+
* @param percent - Percentage to darken (0-100)
|
|
319
|
+
* @returns CSS color string
|
|
320
|
+
*/
|
|
321
|
+
declare function darkenColor(color: ColorValue | undefined | null, theme: Theme | null | undefined, percent: number): string;
|
|
322
|
+
/**
|
|
323
|
+
* Lighten a color by a percentage
|
|
324
|
+
*
|
|
325
|
+
* @param color - ColorValue to lighten
|
|
326
|
+
* @param theme - Theme for resolving
|
|
327
|
+
* @param percent - Percentage to lighten (0-100)
|
|
328
|
+
* @returns CSS color string
|
|
329
|
+
*/
|
|
330
|
+
declare function lightenColor(color: ColorValue | undefined | null, theme: Theme | null | undefined, percent: number): string;
|
|
331
|
+
/**
|
|
332
|
+
* Blend two colors together
|
|
333
|
+
*
|
|
334
|
+
* @param color1 - First color
|
|
335
|
+
* @param color2 - Second color
|
|
336
|
+
* @param ratio - Blend ratio (0 = all color1, 1 = all color2)
|
|
337
|
+
* @param theme - Theme for resolving
|
|
338
|
+
* @returns CSS color string
|
|
339
|
+
*/
|
|
340
|
+
declare function blendColors(color1: ColorValue | undefined | null, color2: ColorValue | undefined | null, ratio: number, theme: Theme | null | undefined): string;
|
|
341
|
+
/**
|
|
342
|
+
* Ensure a hex color string has a '#' prefix.
|
|
343
|
+
*/
|
|
344
|
+
declare function ensureHexPrefix(hex: string): string;
|
|
345
|
+
/**
|
|
346
|
+
* Resolve a highlight color value to a CSS-ready string.
|
|
347
|
+
* Tries OOXML named highlight first, then ensures hex prefix.
|
|
348
|
+
*/
|
|
349
|
+
declare function resolveHighlightToCss(value: string): string;
|
|
350
|
+
/**
|
|
351
|
+
* Theme color matrix cell
|
|
352
|
+
*/
|
|
353
|
+
interface ThemeMatrixCell {
|
|
354
|
+
/** Resolved hex color (6 chars, no #) */
|
|
355
|
+
hex: string;
|
|
356
|
+
/** Theme color slot */
|
|
357
|
+
themeSlot: ThemeColorSlot;
|
|
358
|
+
/** Tint hex modifier if applicable (e.g., "CC") */
|
|
359
|
+
tint?: string;
|
|
360
|
+
/** Shade hex modifier if applicable (e.g., "BF") */
|
|
361
|
+
shade?: string;
|
|
362
|
+
/** Human-readable label (e.g., "Accent 1, Lighter 60%") */
|
|
363
|
+
label: string;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Compute a single tinted or shaded hex color from a base color.
|
|
367
|
+
*
|
|
368
|
+
* @param baseHex - 6-character hex color (no #)
|
|
369
|
+
* @param type - 'tint' to lighten, 'shade' to darken
|
|
370
|
+
* @param fraction - Amount (0-1). For tint: 0=no change, 1=white. For shade: 0=black, 1=no change.
|
|
371
|
+
* @returns 6-character hex color (no #)
|
|
372
|
+
*/
|
|
373
|
+
declare function getThemeTintShadeHex(baseHex: string, type: 'tint' | 'shade', fraction: number): string;
|
|
374
|
+
/**
|
|
375
|
+
* Generate the 10×6 theme color matrix for an advanced color picker.
|
|
376
|
+
*
|
|
377
|
+
* Columns: lt1, dk1, lt2, dk2, accent1-6 (matches Word's order)
|
|
378
|
+
* Rows: base, 80% tint, 60% tint, 40% tint, 25% shade, 50% shade
|
|
379
|
+
*
|
|
380
|
+
* @param colorScheme - Theme color scheme (falls back to Office 2016 defaults)
|
|
381
|
+
* @returns 6 rows × 10 columns of ThemeMatrixCell
|
|
382
|
+
*/
|
|
383
|
+
declare function generateThemeTintShadeMatrix(colorScheme?: ThemeColorScheme | null): ThemeMatrixCell[][];
|
|
384
|
+
/**
|
|
385
|
+
* Check if two colors are equal
|
|
386
|
+
*
|
|
387
|
+
* @param color1 - First color
|
|
388
|
+
* @param color2 - Second color
|
|
389
|
+
* @param theme - Theme for resolving
|
|
390
|
+
* @returns True if colors resolve to the same value
|
|
391
|
+
*/
|
|
392
|
+
declare function colorsEqual(color1: ColorValue | undefined | null, color2: ColorValue | undefined | null, theme: Theme | null | undefined): boolean;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Create Document Utility
|
|
396
|
+
*
|
|
397
|
+
* Provides functions to create new documents programmatically.
|
|
398
|
+
*/
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Options for creating an empty document
|
|
402
|
+
*/
|
|
403
|
+
interface CreateEmptyDocumentOptions {
|
|
404
|
+
/** Page width in twips (default: 12240 = 8.5 inches) */
|
|
405
|
+
pageWidth?: number;
|
|
406
|
+
/** Page height in twips (default: 15840 = 11 inches) */
|
|
407
|
+
pageHeight?: number;
|
|
408
|
+
/** Page orientation (default: 'portrait') */
|
|
409
|
+
orientation?: 'portrait' | 'landscape';
|
|
410
|
+
/** Top margin in twips (default: 1440 = 1 inch) */
|
|
411
|
+
marginTop?: number;
|
|
412
|
+
/** Bottom margin in twips (default: 1440 = 1 inch) */
|
|
413
|
+
marginBottom?: number;
|
|
414
|
+
/** Left margin in twips (default: 1440 = 1 inch) */
|
|
415
|
+
marginLeft?: number;
|
|
416
|
+
/** Right margin in twips (default: 1440 = 1 inch) */
|
|
417
|
+
marginRight?: number;
|
|
418
|
+
/** Initial text content (default: empty string) */
|
|
419
|
+
initialText?: string;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Create an empty document with a single paragraph
|
|
423
|
+
*
|
|
424
|
+
* @param options - Optional configuration for the document
|
|
425
|
+
* @returns A new empty Document object
|
|
426
|
+
*
|
|
427
|
+
* @example
|
|
428
|
+
* ```ts
|
|
429
|
+
* // Create a blank document
|
|
430
|
+
* const doc = createEmptyDocument();
|
|
431
|
+
*
|
|
432
|
+
* // Create with custom margins
|
|
433
|
+
* const doc = createEmptyDocument({
|
|
434
|
+
* marginTop: 720, // 0.5 inch
|
|
435
|
+
* marginBottom: 720,
|
|
436
|
+
* });
|
|
437
|
+
*
|
|
438
|
+
* // Create with initial text
|
|
439
|
+
* const doc = createEmptyDocument({
|
|
440
|
+
* initialText: 'Hello, World!'
|
|
441
|
+
* });
|
|
442
|
+
* ```
|
|
443
|
+
*/
|
|
444
|
+
declare function createEmptyDocument(options?: CreateEmptyDocumentOptions): Document;
|
|
445
|
+
/**
|
|
446
|
+
* Create a document with a single paragraph containing the given text
|
|
447
|
+
*
|
|
448
|
+
* @param text - The text content for the document
|
|
449
|
+
* @param options - Optional configuration for the document
|
|
450
|
+
* @returns A new Document object with the specified text
|
|
451
|
+
*/
|
|
452
|
+
declare function createDocumentWithText(text: string, options?: Omit<CreateEmptyDocumentOptions, 'initialText'>): Document;
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Template Processing Utility
|
|
456
|
+
*
|
|
457
|
+
* Uses docxtemplater to substitute template variables in DOCX documents:
|
|
458
|
+
* - Processes {variable_name} patterns (docxtemplater default syntax)
|
|
459
|
+
* - Preserves all formatting (fonts, styles, colors, tables)
|
|
460
|
+
* - Error handling with useful messages
|
|
461
|
+
*/
|
|
510
462
|
/**
|
|
511
|
-
*
|
|
512
|
-
*
|
|
513
|
-
* @param color - ColorValue object with rgb, themeColor, tint/shade, or auto
|
|
514
|
-
* @param theme - Theme for resolving theme colors
|
|
515
|
-
* @param defaultColor - Default color if auto or undefined (default: black)
|
|
516
|
-
* @returns CSS color string (e.g., "#FF0000" or "inherit")
|
|
463
|
+
* Options for template processing
|
|
517
464
|
*/
|
|
518
|
-
|
|
465
|
+
interface ProcessTemplateOptions {
|
|
466
|
+
/** How to handle undefined variables */
|
|
467
|
+
nullGetter?: 'keep' | 'empty' | 'error';
|
|
468
|
+
/** Custom parser for variable names */
|
|
469
|
+
parser?: (tag: string) => {
|
|
470
|
+
get: (scope: Record<string, unknown>) => unknown;
|
|
471
|
+
};
|
|
472
|
+
/** Line breaks: keep raw \n or convert to w:br */
|
|
473
|
+
linebreaks?: boolean;
|
|
474
|
+
/** Delimiter settings */
|
|
475
|
+
delimiters?: {
|
|
476
|
+
start?: string;
|
|
477
|
+
end?: string;
|
|
478
|
+
};
|
|
479
|
+
}
|
|
519
480
|
/**
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
* @param highlight - Highlight color name (e.g., "yellow", "cyan")
|
|
523
|
-
* @returns CSS color string or empty string for "none"
|
|
481
|
+
* Result of template processing
|
|
524
482
|
*/
|
|
525
|
-
|
|
483
|
+
interface ProcessTemplateResult {
|
|
484
|
+
/** The processed document buffer */
|
|
485
|
+
buffer: ArrayBuffer;
|
|
486
|
+
/** Variables that were found and replaced */
|
|
487
|
+
replacedVariables: string[];
|
|
488
|
+
/** Variables that were not replaced (no value provided) */
|
|
489
|
+
unreplacedVariables: string[];
|
|
490
|
+
/** Any warnings during processing */
|
|
491
|
+
warnings: string[];
|
|
492
|
+
}
|
|
526
493
|
/**
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
* @param color - ColorValue for fill
|
|
530
|
-
* @param theme - Theme for resolving theme colors
|
|
531
|
-
* @returns CSS color string
|
|
494
|
+
* Error details from template processing
|
|
532
495
|
*/
|
|
533
|
-
|
|
496
|
+
interface TemplateError {
|
|
497
|
+
/** Error message */
|
|
498
|
+
message: string;
|
|
499
|
+
/** Variable name that caused the error (if applicable) */
|
|
500
|
+
variable?: string;
|
|
501
|
+
/** Error type */
|
|
502
|
+
type: 'parse' | 'render' | 'undefined' | 'unknown';
|
|
503
|
+
/** Original error */
|
|
504
|
+
originalError?: Error;
|
|
505
|
+
}
|
|
534
506
|
/**
|
|
535
|
-
*
|
|
507
|
+
* Process a DOCX template with variable substitution
|
|
536
508
|
*
|
|
537
|
-
* @param
|
|
538
|
-
* @param
|
|
539
|
-
* @
|
|
509
|
+
* @param buffer - The DOCX file as ArrayBuffer
|
|
510
|
+
* @param variables - Map of variable names to values
|
|
511
|
+
* @param options - Processing options
|
|
512
|
+
* @returns Processed DOCX as ArrayBuffer
|
|
540
513
|
*/
|
|
541
|
-
declare function
|
|
514
|
+
declare function processTemplate(buffer: ArrayBuffer, variables: Record<string, string>, options?: ProcessTemplateOptions): ArrayBuffer;
|
|
542
515
|
/**
|
|
543
|
-
*
|
|
516
|
+
* Process template with detailed result
|
|
544
517
|
*
|
|
545
|
-
* @param
|
|
546
|
-
* @param
|
|
547
|
-
* @
|
|
518
|
+
* @param buffer - The DOCX file as ArrayBuffer
|
|
519
|
+
* @param variables - Map of variable names to values
|
|
520
|
+
* @param options - Processing options
|
|
521
|
+
* @returns Detailed processing result
|
|
548
522
|
*/
|
|
549
|
-
declare function
|
|
523
|
+
declare function processTemplateDetailed(buffer: ArrayBuffer, variables: Record<string, string>, options?: ProcessTemplateOptions): ProcessTemplateResult;
|
|
550
524
|
/**
|
|
551
|
-
*
|
|
525
|
+
* Process template and return as Blob
|
|
552
526
|
*
|
|
553
|
-
* @param
|
|
554
|
-
* @param
|
|
555
|
-
* @
|
|
527
|
+
* @param buffer - The DOCX file as ArrayBuffer
|
|
528
|
+
* @param variables - Map of variable names to values
|
|
529
|
+
* @param options - Processing options
|
|
530
|
+
* @returns Processed DOCX as Blob
|
|
556
531
|
*/
|
|
557
|
-
declare function
|
|
532
|
+
declare function processTemplateAsBlob(buffer: ArrayBuffer, variables: Record<string, string>, options?: ProcessTemplateOptions): Blob;
|
|
558
533
|
/**
|
|
559
|
-
*
|
|
534
|
+
* Get all template tags in a document without processing
|
|
560
535
|
*
|
|
561
|
-
* @param
|
|
562
|
-
* @returns
|
|
536
|
+
* @param buffer - The DOCX file as ArrayBuffer
|
|
537
|
+
* @returns List of tag names found
|
|
563
538
|
*/
|
|
564
|
-
declare function
|
|
539
|
+
declare function getTemplateTags(buffer: ArrayBuffer): string[];
|
|
565
540
|
/**
|
|
566
|
-
*
|
|
541
|
+
* Validate that a document is a valid docxtemplater template
|
|
567
542
|
*
|
|
568
|
-
* @param
|
|
569
|
-
* @
|
|
570
|
-
* @param shade - Optional shade modifier
|
|
571
|
-
* @returns ColorValue object
|
|
543
|
+
* @param buffer - The DOCX file as ArrayBuffer
|
|
544
|
+
* @returns Validation result
|
|
572
545
|
*/
|
|
573
|
-
declare function
|
|
546
|
+
declare function validateTemplate(buffer: ArrayBuffer): {
|
|
547
|
+
valid: boolean;
|
|
548
|
+
errors: TemplateError[];
|
|
549
|
+
tags: string[];
|
|
550
|
+
};
|
|
574
551
|
/**
|
|
575
|
-
*
|
|
552
|
+
* Check if all required variables have values
|
|
576
553
|
*
|
|
577
|
-
* @param
|
|
578
|
-
* @
|
|
554
|
+
* @param tags - List of template tags
|
|
555
|
+
* @param variables - Provided variable values
|
|
556
|
+
* @returns Missing variable names
|
|
579
557
|
*/
|
|
580
|
-
declare function
|
|
558
|
+
declare function getMissingVariables(tags: string[], variables: Record<string, string>): string[];
|
|
581
559
|
/**
|
|
582
|
-
*
|
|
560
|
+
* Preview what the document will look like after processing
|
|
561
|
+
* Returns the document text with variables replaced (for preview purposes)
|
|
583
562
|
*
|
|
584
|
-
* @param
|
|
585
|
-
* @param
|
|
586
|
-
* @
|
|
587
|
-
* @returns CSS color string
|
|
563
|
+
* @param buffer - The DOCX file as ArrayBuffer
|
|
564
|
+
* @param variables - Map of variable names to values
|
|
565
|
+
* @returns Preview text
|
|
588
566
|
*/
|
|
589
|
-
declare function
|
|
567
|
+
declare function previewTemplate(buffer: ArrayBuffer, variables: Record<string, string>): string;
|
|
590
568
|
/**
|
|
591
|
-
*
|
|
569
|
+
* Process template with conditional sections
|
|
570
|
+
* Supports #if, #unless, #each loops
|
|
592
571
|
*
|
|
593
|
-
* @param
|
|
594
|
-
* @param
|
|
595
|
-
* @param
|
|
596
|
-
* @returns
|
|
572
|
+
* @param buffer - The DOCX file as ArrayBuffer
|
|
573
|
+
* @param data - Full data object (can include arrays, nested objects)
|
|
574
|
+
* @param options - Processing options
|
|
575
|
+
* @returns Processed DOCX as ArrayBuffer
|
|
597
576
|
*/
|
|
598
|
-
declare function
|
|
577
|
+
declare function processTemplateAdvanced(buffer: ArrayBuffer, data: Record<string, unknown>, options?: ProcessTemplateOptions): ArrayBuffer;
|
|
599
578
|
/**
|
|
600
|
-
*
|
|
601
|
-
*
|
|
602
|
-
* @param color1 - First color
|
|
603
|
-
* @param color2 - Second color
|
|
604
|
-
* @param ratio - Blend ratio (0 = all color1, 1 = all color2)
|
|
605
|
-
* @param theme - Theme for resolving
|
|
606
|
-
* @returns CSS color string
|
|
579
|
+
* Create a template processor with preset options
|
|
607
580
|
*/
|
|
608
|
-
declare function
|
|
581
|
+
declare function createTemplateProcessor(defaultOptions?: ProcessTemplateOptions): (buffer: ArrayBuffer, variables: Record<string, string>) => ArrayBuffer;
|
|
582
|
+
|
|
609
583
|
/**
|
|
610
|
-
*
|
|
584
|
+
* Main Parser Orchestrator - Unified parseDocx function
|
|
585
|
+
*
|
|
586
|
+
* Coordinates all sub-parsers to produce a complete Document model.
|
|
587
|
+
* Handles loading order, dependency resolution, and font preloading.
|
|
588
|
+
*
|
|
589
|
+
* Parsing order:
|
|
590
|
+
* 1. Unzip DOCX package
|
|
591
|
+
* 2. Parse relationships
|
|
592
|
+
* 3. Parse theme (needed for style color/font resolution)
|
|
593
|
+
* 4. Parse styles (depends on theme)
|
|
594
|
+
* 5. Parse numbering
|
|
595
|
+
* 6. Parse document body (depends on styles, theme, numbering, rels)
|
|
596
|
+
* 7. Parse headers/footers (depends on styles, theme, numbering, rels)
|
|
597
|
+
* 8. Parse footnotes/endnotes (depends on styles, theme, numbering, rels)
|
|
598
|
+
* 9. Extract and load fonts
|
|
599
|
+
* 10. Build media file map
|
|
600
|
+
* 11. Assemble final Document
|
|
611
601
|
*/
|
|
612
|
-
|
|
602
|
+
|
|
613
603
|
/**
|
|
614
|
-
*
|
|
615
|
-
* Tries OOXML named highlight first, then ensures hex prefix.
|
|
604
|
+
* Progress callback for tracking parsing stages
|
|
616
605
|
*/
|
|
617
|
-
|
|
606
|
+
type ProgressCallback = (stage: string, percent: number) => void;
|
|
618
607
|
/**
|
|
619
|
-
*
|
|
608
|
+
* Parsing options
|
|
620
609
|
*/
|
|
621
|
-
interface
|
|
622
|
-
/**
|
|
623
|
-
|
|
624
|
-
/**
|
|
625
|
-
|
|
626
|
-
/**
|
|
627
|
-
|
|
628
|
-
/**
|
|
629
|
-
|
|
630
|
-
/**
|
|
631
|
-
|
|
610
|
+
interface ParseOptions {
|
|
611
|
+
/** Progress callback for tracking parsing stages */
|
|
612
|
+
onProgress?: ProgressCallback;
|
|
613
|
+
/** Whether to preload fonts (default: true) */
|
|
614
|
+
preloadFonts?: boolean;
|
|
615
|
+
/** Whether to parse headers/footers (default: true) */
|
|
616
|
+
parseHeadersFooters?: boolean;
|
|
617
|
+
/** Whether to parse footnotes/endnotes (default: true) */
|
|
618
|
+
parseNotes?: boolean;
|
|
619
|
+
/** Whether to detect template variables (default: true) */
|
|
620
|
+
detectVariables?: boolean;
|
|
632
621
|
}
|
|
633
622
|
/**
|
|
634
|
-
*
|
|
623
|
+
* Parse a DOCX file into a complete Document model
|
|
635
624
|
*
|
|
636
|
-
* @param
|
|
637
|
-
* @param
|
|
638
|
-
* @
|
|
639
|
-
* @
|
|
625
|
+
* @param input - DOCX file as ArrayBuffer, Uint8Array, Blob, or File
|
|
626
|
+
* @param options - Parsing options
|
|
627
|
+
* @returns Promise resolving to Document
|
|
628
|
+
* @throws Error if parsing fails
|
|
640
629
|
*/
|
|
641
|
-
declare function
|
|
630
|
+
declare function parseDocx(input: DocxInput, options?: ParseOptions): Promise<Document>;
|
|
631
|
+
|
|
642
632
|
/**
|
|
643
|
-
*
|
|
633
|
+
* Document Serializer - Serialize complete document.xml
|
|
644
634
|
*
|
|
645
|
-
*
|
|
646
|
-
*
|
|
635
|
+
* Converts Document objects back to valid document.xml OOXML format.
|
|
636
|
+
* Combines all content (paragraphs, tables) with section properties
|
|
637
|
+
* and proper namespace declarations.
|
|
647
638
|
*
|
|
648
|
-
*
|
|
649
|
-
*
|
|
639
|
+
* OOXML Reference:
|
|
640
|
+
* - Document root: w:document
|
|
641
|
+
* - Document body: w:body
|
|
642
|
+
* - Section properties: w:sectPr
|
|
650
643
|
*/
|
|
651
|
-
|
|
644
|
+
|
|
652
645
|
/**
|
|
653
|
-
*
|
|
646
|
+
* Serialize section properties (w:sectPr)
|
|
647
|
+
*/
|
|
648
|
+
declare function serializeSectionProperties(props: SectionProperties | undefined): string;
|
|
649
|
+
/**
|
|
650
|
+
* Serialize a DocumentBody to document.xml body content
|
|
654
651
|
*
|
|
655
|
-
* @param
|
|
656
|
-
* @
|
|
657
|
-
* @param theme - Theme for resolving
|
|
658
|
-
* @returns True if colors resolve to the same value
|
|
652
|
+
* @param body - The document body to serialize
|
|
653
|
+
* @returns XML string for the body element (without body tags)
|
|
659
654
|
*/
|
|
660
|
-
declare function
|
|
655
|
+
declare function serializeDocumentBody(body: DocumentBody): string;
|
|
656
|
+
/**
|
|
657
|
+
* Serialize a complete Document to valid document.xml
|
|
658
|
+
*
|
|
659
|
+
* @param doc - The document to serialize
|
|
660
|
+
* @returns Complete XML string for document.xml
|
|
661
|
+
*/
|
|
662
|
+
declare function serializeDocument(doc: Document): string;
|
|
661
663
|
|
|
662
664
|
export { validateTemplate as $, type AgentContextOptions as A, isWhite as B, type CreateEmptyDocumentOptions as C, lightenColor as D, type ExtendedSelectionContext as E, type FormattingSummary as F, parseColorString as G, parseDocx as H, pixelsToEmu as I, pixelsToTwips as J, pointsToPixels as K, previewTemplate as L, processTemplate as M, processTemplateAdvanced as N, processTemplateAsBlob as O, type ProcessTemplateOptions as P, processTemplateDetailed as Q, resolveColor as R, type SelectionContextOptions$1 as S, type TemplateError as T, resolveHighlightColor as U, resolveShadingColor as V, serializeDocumentBody as W, serializeDocument as X, serializeSectionProperties as Y, twipsToEmu as Z, twipsToPixels as _, type ProcessTemplateResult as a, type ThemeMatrixCell as a0, ensureHexPrefix as a1, generateThemeTintShadeMatrix as a2, getThemeTintShadeHex as a3, resolveHighlightToCss as a4, type SelectionContextOptions as b, blendColors as c, buildExtendedSelectionContext as d, buildSelectionContext as e, buildSelectionContext$1 as f, colorsEqual as g, createDocumentWithText as h, createEmptyDocument as i, createRgbColor as j, createTemplateProcessor as k, createThemeColor as l, darkenColor as m, emuToPixels as n, emuToTwips as o, executeCommand as p, executeCommands as q, formatPx as r, getAgentContext as s, getContrastingColor as t, getDocumentSummary as u, getMissingVariables as v, getSelectionFormattingSummary as w, getTemplateTags as x, halfPointsToPixels as y, isBlack as z };
|