@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.
- package/dist/ClipboardManager-C0rTRkVQ.d.ts +464 -0
- package/dist/ClipboardManager-CgpKW2At.d.mts +464 -0
- package/dist/DocumentAgent-BqA9EJ3F.d.mts +442 -0
- package/dist/DocumentAgent-CRCXiBT7.d.ts +442 -0
- package/dist/FindReplaceDialog-KNJETYJX.js +1 -0
- package/dist/FindReplaceDialog-YW3R4FHM.mjs +1 -0
- package/dist/FootnotePropertiesDialog-452A4UT5.js +1 -0
- package/dist/FootnotePropertiesDialog-H24AC5XK.mjs +1 -0
- package/dist/HyperlinkDialog-GBAYMTUE.js +1 -0
- package/dist/HyperlinkDialog-HNYTXDCB.mjs +1 -0
- package/dist/ImagePositionDialog-B4RLP2W5.mjs +1 -0
- package/dist/ImagePositionDialog-M65BYQQE.js +1 -0
- package/dist/ImagePropertiesDialog-JOGW3WDU.mjs +1 -0
- package/dist/ImagePropertiesDialog-O4WQSF5M.js +1 -0
- package/dist/PageSetupDialog-2GIBTKMJ.js +1 -0
- package/dist/PageSetupDialog-Q7SHEZIJ.mjs +1 -0
- package/dist/TablePropertiesDialog-LMXWX3FI.mjs +1 -0
- package/dist/TablePropertiesDialog-WOZ4ES3H.js +1 -0
- package/dist/agentApi-BVHzyk2l.d.mts +2239 -0
- package/dist/agentApi-BVHzyk2l.d.ts +2239 -0
- package/dist/chunk-2HDYCD2Q.mjs +1 -0
- package/dist/chunk-377ZVTSE.js +2 -0
- package/dist/chunk-37SLIJPH.mjs +58 -0
- package/dist/chunk-4VUZBV2S.js +1 -0
- package/dist/chunk-6WPRCJ5A.mjs +1 -0
- package/dist/chunk-7MGFEP2R.mjs +26 -0
- package/dist/chunk-7QTNB64A.mjs +9 -0
- package/dist/chunk-AARNCPWR.js +1 -0
- package/dist/chunk-AU5NVRHP.js +2 -0
- package/dist/chunk-BP3V2HDD.js +261 -0
- package/dist/chunk-BUEMG4NW.js +1 -0
- package/dist/chunk-DC65PJYE.js +4 -0
- package/dist/chunk-DLVLK5FT.mjs +24 -0
- package/dist/chunk-EV3CM6TU.js +1 -0
- package/dist/chunk-FVUGBRDD.js +1 -0
- package/dist/chunk-GZOCOWWB.mjs +2 -0
- package/dist/chunk-H5NTJZO4.js +1 -0
- package/dist/chunk-IFPN3NT3.js +3 -0
- package/dist/chunk-KCOGY3V2.js +10 -0
- package/dist/chunk-KUL2SDYC.js +26 -0
- package/dist/chunk-LFZXSNOF.mjs +261 -0
- package/dist/chunk-LYBG4YI7.mjs +1 -0
- package/dist/chunk-M5F4SK3W.mjs +1 -0
- package/dist/chunk-P7WEP4JU.js +9 -0
- package/dist/chunk-PB7VMDDP.js +24 -0
- package/dist/chunk-QAZ4233N.mjs +1 -0
- package/dist/chunk-QSUPYUOP.js +2 -0
- package/dist/chunk-QTSXJRP6.mjs +1 -0
- package/dist/chunk-QVPR2W5S.js +1 -0
- package/dist/chunk-RTFUE3KK.mjs +10 -0
- package/dist/chunk-SCYTWBF5.mjs +111 -0
- package/dist/chunk-SE5EN2QL.js +1 -0
- package/dist/chunk-T6X4C2QO.js +111 -0
- package/dist/chunk-TAUMSKRE.mjs +1 -0
- package/dist/chunk-W53SI3XW.mjs +1 -0
- package/dist/chunk-WOHFANC5.mjs +3 -0
- package/dist/chunk-X5A54T6S.mjs +4 -0
- package/dist/chunk-YKBSKEBS.mjs +2 -0
- package/dist/chunk-Z26WOH6R.mjs +2 -0
- package/dist/chunk-ZJNGMDRE.js +58 -0
- package/dist/clipboard-Cu80iVDh.d.ts +1181 -0
- package/dist/clipboard-dFROLI95.d.mts +1181 -0
- package/dist/colorResolver-BwI_Uxp3.d.mts +662 -0
- package/dist/colorResolver-Dlmk3itT.d.ts +662 -0
- package/dist/core-plugins-reexport.d.mts +31 -0
- package/dist/core-plugins-reexport.d.ts +31 -0
- package/dist/core-plugins-reexport.js +1 -0
- package/dist/core-plugins-reexport.mjs +1 -0
- package/dist/core-reexport.d.mts +309 -0
- package/dist/core-reexport.d.ts +309 -0
- package/dist/core-reexport.js +1 -0
- package/dist/core-reexport.mjs +1 -0
- package/dist/executor-L2MVKMXO.js +1 -0
- package/dist/executor-XKBCCVNY.mjs +1 -0
- package/dist/fontLoader-BI9ZoACv.d.ts +176 -0
- package/dist/fontLoader-DicgJidU.d.mts +176 -0
- package/dist/headless-reexport.d.mts +195 -0
- package/dist/headless-reexport.d.ts +195 -0
- package/dist/headless-reexport.js +4 -0
- package/dist/headless-reexport.mjs +4 -0
- package/dist/index.css +1 -0
- package/dist/index.d.mts +480 -0
- package/dist/index.d.ts +480 -0
- package/dist/index.js +112 -0
- package/dist/index.mjs +112 -0
- package/dist/lib-BCT2DRYI.mjs +1 -0
- package/dist/lib-U35UU4OU.js +1 -0
- package/dist/mcp-reexport.d.mts +156 -0
- package/dist/mcp-reexport.d.ts +156 -0
- package/dist/mcp-reexport.js +16 -0
- package/dist/mcp-reexport.mjs +16 -0
- package/dist/processTemplate-5ZST2Q5L.js +1 -0
- package/dist/processTemplate-LRHXOWMZ.mjs +1 -0
- package/dist/react-Cl2n0F5S.d.ts +1091 -0
- package/dist/react-DZlAKNXg.d.mts +1091 -0
- package/dist/react.css +1 -0
- package/dist/react.d.mts +10 -0
- package/dist/react.d.ts +10 -0
- package/dist/react.js +1 -0
- package/dist/react.mjs +1 -0
- package/dist/registry-D4FQ9aKX.d.mts +165 -0
- package/dist/registry-DrYyUXQr.d.ts +165 -0
- package/dist/selectionRects-DEX5THEG.js +1 -0
- package/dist/selectionRects-SQTAHMCH.mjs +1 -0
- package/dist/styles.css +1 -0
- package/dist/types-B3LkfO0u.d.mts +310 -0
- package/dist/types-igZ1x_e4.d.ts +310 -0
- package/dist/ui.d.mts +2005 -0
- package/dist/ui.d.ts +2005 -0
- package/dist/ui.js +1 -0
- package/dist/ui.mjs +1 -0
- package/dist/variableDetector-CIqTek7A.d.mts +204 -0
- package/dist/variableDetector-CkYvLv62.d.ts +204 -0
- package/i18n/de.json +745 -0
- package/i18n/en.json +745 -0
- package/i18n/pl.json +745 -0
- package/package.json +127 -0
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
import { D as Document, d as DocumentBody, V as SectionProperties, 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 } from './agentApi-BVHzyk2l.mjs';
|
|
2
|
+
import { g as DocxInput } from './DocumentAgent-BqA9EJ3F.mjs';
|
|
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;
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Command Executor
|
|
276
|
+
*
|
|
277
|
+
* Executes agent commands on a document immutably:
|
|
278
|
+
* - Handles all command types from AgentCommand
|
|
279
|
+
* - Preserves surrounding formatting
|
|
280
|
+
* - Returns new document (immutable updates)
|
|
281
|
+
*/
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Execute an agent command on a document
|
|
285
|
+
* Returns a new document with the command applied (immutable)
|
|
286
|
+
*
|
|
287
|
+
* Dispatch order:
|
|
288
|
+
* 1. Try plugin handlers first (allows plugins to override built-in commands)
|
|
289
|
+
* 2. Fall back to built-in handlers
|
|
290
|
+
*
|
|
291
|
+
* @param doc - The document to modify
|
|
292
|
+
* @param command - The command to execute
|
|
293
|
+
* @returns New document with command applied
|
|
294
|
+
*/
|
|
295
|
+
declare function executeCommand(doc: Document, command: AgentCommand): Document;
|
|
296
|
+
/**
|
|
297
|
+
* Execute multiple commands in sequence
|
|
298
|
+
*
|
|
299
|
+
* @param doc - The document to modify
|
|
300
|
+
* @param commands - Commands to execute in order
|
|
301
|
+
* @returns New document with all commands applied
|
|
302
|
+
*/
|
|
303
|
+
declare function executeCommands(doc: Document, commands: AgentCommand[]): Document;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Agent Context Builder
|
|
307
|
+
*
|
|
308
|
+
* Generates context objects for AI/LLM consumption from DOCX documents.
|
|
309
|
+
* The context provides a structured summary of the document that can be
|
|
310
|
+
* used by AI agents to understand the document structure and content.
|
|
311
|
+
*
|
|
312
|
+
* All outputs are JSON serializable for easy transmission to AI backends.
|
|
313
|
+
*/
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Options for building agent context
|
|
317
|
+
*/
|
|
318
|
+
interface AgentContextOptions {
|
|
319
|
+
/** Maximum characters per paragraph in outline (default: 100) */
|
|
320
|
+
outlineMaxChars?: number;
|
|
321
|
+
/** Maximum paragraphs to include in outline (default: 50) */
|
|
322
|
+
maxOutlineParagraphs?: number;
|
|
323
|
+
/** Include table content in context (default: false) */
|
|
324
|
+
includeTableContent?: boolean;
|
|
325
|
+
/** Include detailed formatting info (default: false) */
|
|
326
|
+
includeFormatting?: boolean;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Options for building selection context
|
|
330
|
+
*/
|
|
331
|
+
interface SelectionContextOptions$1 {
|
|
332
|
+
/** Characters of context before/after selection (default: 200) */
|
|
333
|
+
contextChars?: number;
|
|
334
|
+
/** Include suggested actions (default: true) */
|
|
335
|
+
includeSuggestions?: boolean;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Build agent context from a document
|
|
339
|
+
*
|
|
340
|
+
* @param doc - The parsed document
|
|
341
|
+
* @param options - Context building options
|
|
342
|
+
* @returns AgentContext object (JSON serializable)
|
|
343
|
+
*/
|
|
344
|
+
declare function getAgentContext(doc: Document, options?: AgentContextOptions): AgentContext;
|
|
345
|
+
/**
|
|
346
|
+
* Build selection context for AI operations
|
|
347
|
+
*
|
|
348
|
+
* @param doc - The parsed document
|
|
349
|
+
* @param range - The selected range
|
|
350
|
+
* @param options - Selection context options
|
|
351
|
+
* @returns SelectionContext object (JSON serializable)
|
|
352
|
+
*/
|
|
353
|
+
declare function buildSelectionContext$1(doc: Document, range: Range, options?: SelectionContextOptions$1): SelectionContext;
|
|
354
|
+
/**
|
|
355
|
+
* Get a simple document summary for quick context
|
|
356
|
+
*
|
|
357
|
+
* @param doc - The parsed document
|
|
358
|
+
* @returns Summary string
|
|
359
|
+
*/
|
|
360
|
+
declare function getDocumentSummary(doc: Document): string;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Selection Context Builder
|
|
364
|
+
*
|
|
365
|
+
* Builds rich context objects from document selections for AI operations.
|
|
366
|
+
* Includes selected text, formatting, surrounding context, and suggested actions.
|
|
367
|
+
*/
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Options for building selection context
|
|
371
|
+
*/
|
|
372
|
+
interface SelectionContextOptions {
|
|
373
|
+
/** Characters of context before selection (default: 200) */
|
|
374
|
+
contextCharsBefore?: number;
|
|
375
|
+
/** Characters of context after selection (default: 200) */
|
|
376
|
+
contextCharsAfter?: number;
|
|
377
|
+
/** Include suggested actions (default: true) */
|
|
378
|
+
includeSuggestions?: boolean;
|
|
379
|
+
/** Include document summary (default: true) */
|
|
380
|
+
includeDocumentSummary?: boolean;
|
|
381
|
+
/** Maximum suggested actions (default: 8) */
|
|
382
|
+
maxSuggestions?: number;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Extended selection context with additional details
|
|
386
|
+
*/
|
|
387
|
+
interface ExtendedSelectionContext extends SelectionContext {
|
|
388
|
+
/** Document summary for additional context */
|
|
389
|
+
documentSummary?: string;
|
|
390
|
+
/** Selection word count */
|
|
391
|
+
wordCount?: number;
|
|
392
|
+
/** Selection character count */
|
|
393
|
+
characterCount?: number;
|
|
394
|
+
/** Is selection multi-paragraph */
|
|
395
|
+
isMultiParagraph?: boolean;
|
|
396
|
+
/** Selected paragraph indices */
|
|
397
|
+
paragraphIndices?: number[];
|
|
398
|
+
/** Language detection hint */
|
|
399
|
+
detectedLanguage?: string;
|
|
400
|
+
/** Content type hints */
|
|
401
|
+
contentType?: 'prose' | 'list' | 'heading' | 'table' | 'mixed';
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Selection formatting summary
|
|
405
|
+
*/
|
|
406
|
+
interface FormattingSummary {
|
|
407
|
+
/** Predominant formatting */
|
|
408
|
+
predominant: Partial<TextFormatting>;
|
|
409
|
+
/** Is formatting consistent across selection */
|
|
410
|
+
isConsistent: boolean;
|
|
411
|
+
/** All formatting found */
|
|
412
|
+
allFormatting: Partial<TextFormatting>[];
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Build selection context for AI operations
|
|
416
|
+
*
|
|
417
|
+
* @param doc - The parsed document
|
|
418
|
+
* @param range - The selected range
|
|
419
|
+
* @param options - Selection context options
|
|
420
|
+
* @returns SelectionContext object
|
|
421
|
+
*/
|
|
422
|
+
declare function buildSelectionContext(doc: Document, range: Range, options?: SelectionContextOptions): SelectionContext;
|
|
423
|
+
/**
|
|
424
|
+
* Build extended selection context with additional details
|
|
425
|
+
*
|
|
426
|
+
* @param doc - The parsed document
|
|
427
|
+
* @param range - The selected range
|
|
428
|
+
* @param options - Selection context options
|
|
429
|
+
* @returns ExtendedSelectionContext object
|
|
430
|
+
*/
|
|
431
|
+
declare function buildExtendedSelectionContext(doc: Document, range: Range, options?: SelectionContextOptions): ExtendedSelectionContext;
|
|
432
|
+
/**
|
|
433
|
+
* Get formatting summary for a selection
|
|
434
|
+
*
|
|
435
|
+
* @param doc - The parsed document
|
|
436
|
+
* @param range - The selected range
|
|
437
|
+
* @returns FormattingSummary object
|
|
438
|
+
*/
|
|
439
|
+
declare function getSelectionFormattingSummary(doc: Document, range: Range): FormattingSummary;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Convert twips to pixels (at 96 DPI)
|
|
443
|
+
*
|
|
444
|
+
* 1 inch = 1440 twips = 96 pixels
|
|
445
|
+
* → 1 twip = 96/1440 pixels = 1/15 pixels
|
|
446
|
+
*/
|
|
447
|
+
declare function twipsToPixels(twips: number): number;
|
|
448
|
+
/**
|
|
449
|
+
* Convert pixels to twips
|
|
450
|
+
*/
|
|
451
|
+
declare function pixelsToTwips(px: number): number;
|
|
452
|
+
/**
|
|
453
|
+
* Convert EMUs to pixels (at 96 DPI)
|
|
454
|
+
*
|
|
455
|
+
* 1 inch = 914400 EMUs = 96 pixels
|
|
456
|
+
* Returns 0 for null/undefined/NaN inputs.
|
|
457
|
+
*/
|
|
458
|
+
declare function emuToPixels(emu: number | undefined | null): number;
|
|
459
|
+
/**
|
|
460
|
+
* Convert pixels to EMUs
|
|
461
|
+
*/
|
|
462
|
+
declare function pixelsToEmu(px: number): number;
|
|
463
|
+
/**
|
|
464
|
+
* Convert EMUs to twips
|
|
465
|
+
*/
|
|
466
|
+
declare function emuToTwips(emu: number): number;
|
|
467
|
+
/**
|
|
468
|
+
* Convert twips to EMUs
|
|
469
|
+
*/
|
|
470
|
+
declare function twipsToEmu(twips: number): number;
|
|
471
|
+
/**
|
|
472
|
+
* Convert points to pixels (at 96 DPI)
|
|
473
|
+
*
|
|
474
|
+
* 1 inch = 72 points = 96 pixels
|
|
475
|
+
* → 1 point = 96/72 pixels = 4/3 pixels
|
|
476
|
+
*/
|
|
477
|
+
declare function pointsToPixels(points: number): number;
|
|
478
|
+
/**
|
|
479
|
+
* Convert half-points to pixels (at 96 DPI)
|
|
480
|
+
*
|
|
481
|
+
* Half-points are commonly used for font sizes in OOXML (w:sz).
|
|
482
|
+
*/
|
|
483
|
+
declare function halfPointsToPixels(halfPoints: number): number;
|
|
484
|
+
/**
|
|
485
|
+
* Format a pixel value as CSS string
|
|
486
|
+
*/
|
|
487
|
+
declare function formatPx(px: number): string;
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Color Resolver - Convert OOXML colors to CSS
|
|
491
|
+
*
|
|
492
|
+
* Handles:
|
|
493
|
+
* - Theme color references (accent1, dk1, etc.)
|
|
494
|
+
* - RGB hex values
|
|
495
|
+
* - "auto" colors (context-dependent)
|
|
496
|
+
* - Tint/shade modifications
|
|
497
|
+
*
|
|
498
|
+
* OOXML Color References:
|
|
499
|
+
* - w:color/@w:val - RGB hex or "auto"
|
|
500
|
+
* - w:color/@w:themeColor - Theme color slot
|
|
501
|
+
* - w:color/@w:themeTint - Tint modifier (0-255, hex)
|
|
502
|
+
* - w:color/@w:themeShade - Shade modifier (0-255, hex)
|
|
503
|
+
*
|
|
504
|
+
* Tint/Shade Calculations:
|
|
505
|
+
* - Tint makes color lighter (blend with white)
|
|
506
|
+
* - Shade makes color darker (blend with black)
|
|
507
|
+
* - Value is in hex (00-FF), converted to 0-1 for calculation
|
|
508
|
+
*/
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Resolve a ColorValue to a CSS color string
|
|
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")
|
|
517
|
+
*/
|
|
518
|
+
declare function resolveColor(color: ColorValue | undefined | null, theme: Theme | null | undefined, defaultColor?: string): string;
|
|
519
|
+
/**
|
|
520
|
+
* Resolve a highlight color name to CSS
|
|
521
|
+
*
|
|
522
|
+
* @param highlight - Highlight color name (e.g., "yellow", "cyan")
|
|
523
|
+
* @returns CSS color string or empty string for "none"
|
|
524
|
+
*/
|
|
525
|
+
declare function resolveHighlightColor(highlight: string | undefined): string;
|
|
526
|
+
/**
|
|
527
|
+
* Resolve a shading fill or pattern color to CSS
|
|
528
|
+
*
|
|
529
|
+
* @param color - ColorValue for fill
|
|
530
|
+
* @param theme - Theme for resolving theme colors
|
|
531
|
+
* @returns CSS color string
|
|
532
|
+
*/
|
|
533
|
+
declare function resolveShadingColor(color: ColorValue | undefined | null, theme: Theme | null | undefined): string;
|
|
534
|
+
/**
|
|
535
|
+
* Check if a color is effectively black
|
|
536
|
+
*
|
|
537
|
+
* @param color - ColorValue object
|
|
538
|
+
* @param theme - Theme for resolving theme colors
|
|
539
|
+
* @returns True if color resolves to black or very dark
|
|
540
|
+
*/
|
|
541
|
+
declare function isBlack(color: ColorValue | undefined | null, theme: Theme | null | undefined): boolean;
|
|
542
|
+
/**
|
|
543
|
+
* Check if a color is effectively white
|
|
544
|
+
*
|
|
545
|
+
* @param color - ColorValue object
|
|
546
|
+
* @param theme - Theme for resolving theme colors
|
|
547
|
+
* @returns True if color resolves to white or very light
|
|
548
|
+
*/
|
|
549
|
+
declare function isWhite(color: ColorValue | undefined | null, theme: Theme | null | undefined): boolean;
|
|
550
|
+
/**
|
|
551
|
+
* Get contrasting text color for a background
|
|
552
|
+
*
|
|
553
|
+
* @param backgroundColor - Background ColorValue
|
|
554
|
+
* @param theme - Theme for resolving theme colors
|
|
555
|
+
* @returns Black or white hex color for best contrast
|
|
556
|
+
*/
|
|
557
|
+
declare function getContrastingColor(backgroundColor: ColorValue | undefined | null, theme: Theme | null | undefined): string;
|
|
558
|
+
/**
|
|
559
|
+
* Parse a color string (various formats) to ColorValue
|
|
560
|
+
*
|
|
561
|
+
* @param colorString - Color string like "FF0000", "auto", or theme color name
|
|
562
|
+
* @returns ColorValue object
|
|
563
|
+
*/
|
|
564
|
+
declare function parseColorString(colorString: string | undefined): ColorValue | undefined;
|
|
565
|
+
/**
|
|
566
|
+
* Create a ColorValue from theme color reference
|
|
567
|
+
*
|
|
568
|
+
* @param themeColor - Theme color slot name
|
|
569
|
+
* @param tint - Optional tint modifier
|
|
570
|
+
* @param shade - Optional shade modifier
|
|
571
|
+
* @returns ColorValue object
|
|
572
|
+
*/
|
|
573
|
+
declare function createThemeColor(themeColor: ThemeColorSlot, tint?: number, shade?: number): ColorValue;
|
|
574
|
+
/**
|
|
575
|
+
* Create a ColorValue from RGB hex
|
|
576
|
+
*
|
|
577
|
+
* @param hex - 6-character hex color (no #)
|
|
578
|
+
* @returns ColorValue object
|
|
579
|
+
*/
|
|
580
|
+
declare function createRgbColor(hex: string): ColorValue;
|
|
581
|
+
/**
|
|
582
|
+
* Darken a color by a percentage
|
|
583
|
+
*
|
|
584
|
+
* @param color - ColorValue to darken
|
|
585
|
+
* @param theme - Theme for resolving
|
|
586
|
+
* @param percent - Percentage to darken (0-100)
|
|
587
|
+
* @returns CSS color string
|
|
588
|
+
*/
|
|
589
|
+
declare function darkenColor(color: ColorValue | undefined | null, theme: Theme | null | undefined, percent: number): string;
|
|
590
|
+
/**
|
|
591
|
+
* Lighten a color by a percentage
|
|
592
|
+
*
|
|
593
|
+
* @param color - ColorValue to lighten
|
|
594
|
+
* @param theme - Theme for resolving
|
|
595
|
+
* @param percent - Percentage to lighten (0-100)
|
|
596
|
+
* @returns CSS color string
|
|
597
|
+
*/
|
|
598
|
+
declare function lightenColor(color: ColorValue | undefined | null, theme: Theme | null | undefined, percent: number): string;
|
|
599
|
+
/**
|
|
600
|
+
* Blend two colors together
|
|
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
|
|
607
|
+
*/
|
|
608
|
+
declare function blendColors(color1: ColorValue | undefined | null, color2: ColorValue | undefined | null, ratio: number, theme: Theme | null | undefined): string;
|
|
609
|
+
/**
|
|
610
|
+
* Ensure a hex color string has a '#' prefix.
|
|
611
|
+
*/
|
|
612
|
+
declare function ensureHexPrefix(hex: string): string;
|
|
613
|
+
/**
|
|
614
|
+
* Resolve a highlight color value to a CSS-ready string.
|
|
615
|
+
* Tries OOXML named highlight first, then ensures hex prefix.
|
|
616
|
+
*/
|
|
617
|
+
declare function resolveHighlightToCss(value: string): string;
|
|
618
|
+
/**
|
|
619
|
+
* Theme color matrix cell
|
|
620
|
+
*/
|
|
621
|
+
interface ThemeMatrixCell {
|
|
622
|
+
/** Resolved hex color (6 chars, no #) */
|
|
623
|
+
hex: string;
|
|
624
|
+
/** Theme color slot */
|
|
625
|
+
themeSlot: ThemeColorSlot;
|
|
626
|
+
/** Tint hex modifier if applicable (e.g., "CC") */
|
|
627
|
+
tint?: string;
|
|
628
|
+
/** Shade hex modifier if applicable (e.g., "BF") */
|
|
629
|
+
shade?: string;
|
|
630
|
+
/** Human-readable label (e.g., "Accent 1, Lighter 60%") */
|
|
631
|
+
label: string;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Compute a single tinted or shaded hex color from a base color.
|
|
635
|
+
*
|
|
636
|
+
* @param baseHex - 6-character hex color (no #)
|
|
637
|
+
* @param type - 'tint' to lighten, 'shade' to darken
|
|
638
|
+
* @param fraction - Amount (0-1). For tint: 0=no change, 1=white. For shade: 0=black, 1=no change.
|
|
639
|
+
* @returns 6-character hex color (no #)
|
|
640
|
+
*/
|
|
641
|
+
declare function getThemeTintShadeHex(baseHex: string, type: 'tint' | 'shade', fraction: number): string;
|
|
642
|
+
/**
|
|
643
|
+
* Generate the 10×6 theme color matrix for an advanced color picker.
|
|
644
|
+
*
|
|
645
|
+
* Columns: lt1, dk1, lt2, dk2, accent1-6 (matches Word's order)
|
|
646
|
+
* Rows: base, 80% tint, 60% tint, 40% tint, 25% shade, 50% shade
|
|
647
|
+
*
|
|
648
|
+
* @param colorScheme - Theme color scheme (falls back to Office 2016 defaults)
|
|
649
|
+
* @returns 6 rows × 10 columns of ThemeMatrixCell
|
|
650
|
+
*/
|
|
651
|
+
declare function generateThemeTintShadeMatrix(colorScheme?: ThemeColorScheme | null): ThemeMatrixCell[][];
|
|
652
|
+
/**
|
|
653
|
+
* Check if two colors are equal
|
|
654
|
+
*
|
|
655
|
+
* @param color1 - First color
|
|
656
|
+
* @param color2 - Second color
|
|
657
|
+
* @param theme - Theme for resolving
|
|
658
|
+
* @returns True if colors resolve to the same value
|
|
659
|
+
*/
|
|
660
|
+
declare function colorsEqual(color1: ColorValue | undefined | null, color2: ColorValue | undefined | null, theme: Theme | null | undefined): boolean;
|
|
661
|
+
|
|
662
|
+
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 };
|