@eigenpal/docx-js-editor 0.0.11 → 0.0.13
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/DocumentAgent-Ci6_T-XM.d.ts +412 -0
- package/dist/DocumentAgent-DEGFgYEN.d.cts +412 -0
- package/dist/FindReplaceDialog-BAACAU67.cjs +1 -0
- package/dist/FindReplaceDialog-RWYDRWHF.js +1 -0
- package/dist/FootnotePropertiesDialog-BC6JIPDA.cjs +1 -0
- package/dist/FootnotePropertiesDialog-CWQF5EBK.js +1 -0
- package/dist/HyperlinkDialog-EG2BSLPD.cjs +1 -0
- package/dist/HyperlinkDialog-YAVK64F4.js +1 -0
- package/dist/ImagePositionDialog-IGYS5KMK.cjs +1 -0
- package/dist/ImagePositionDialog-S6SMH7XH.js +1 -0
- package/dist/ImagePropertiesDialog-UO5QUIBS.js +1 -0
- package/dist/ImagePropertiesDialog-VGV4E4SN.cjs +1 -0
- package/dist/TablePropertiesDialog-VBOU4DID.js +1 -0
- package/dist/TablePropertiesDialog-WRM47JI6.cjs +1 -0
- package/dist/{types-BALm1KBi.d.cts → agentApi-CbVUCZRu.d.cts} +1 -308
- package/dist/{types-BALm1KBi.d.ts → agentApi-CbVUCZRu.d.ts} +1 -308
- package/dist/chunk-2ASOEN3V.js +1 -0
- package/dist/chunk-6MBDPZVD.js +111 -0
- package/dist/chunk-6YLNNCRZ.cjs +10 -0
- package/dist/chunk-BVQ2QRHA.cjs +4 -0
- package/dist/chunk-COP5BIBZ.js +10 -0
- package/dist/chunk-CZ7W7MCM.cjs +2 -0
- package/dist/chunk-E6XDMUAM.js +4 -0
- package/dist/chunk-EMKABJPH.js +1 -0
- package/dist/{chunk-TRAQI6RX.cjs → chunk-EPCZ24TY.cjs} +5 -5
- package/dist/chunk-ESI4BSBF.js +1 -0
- package/dist/chunk-FLECKDK4.cjs +58 -0
- package/dist/chunk-ITWEFKGQ.cjs +1 -0
- package/dist/chunk-KESNGXGO.js +1 -0
- package/dist/chunk-KVAT5SVD.js +2 -0
- package/dist/chunk-L34XFLQZ.cjs +1 -0
- package/dist/chunk-M7F2CUUD.js +2 -0
- package/dist/chunk-MDPDH7KS.js +58 -0
- package/dist/chunk-MTX3EEBJ.js +258 -0
- package/dist/chunk-NT2REEAA.cjs +1 -0
- package/dist/{chunk-PM4Y7OFN.js → chunk-OTG4NABM.js} +5 -5
- package/dist/chunk-OW5H5DNE.cjs +1 -0
- package/dist/chunk-PJVI53AH.js +2 -0
- package/dist/chunk-PNMZPPPI.cjs +2 -0
- package/dist/chunk-SF53KLDZ.cjs +1 -0
- package/dist/chunk-TOI5W3HK.js +8 -0
- package/dist/chunk-UAVOWAIF.cjs +8 -0
- package/dist/chunk-VN7XH644.cjs +258 -0
- package/dist/chunk-W4DUKACP.cjs +111 -0
- package/dist/chunk-XS2AQFMF.cjs +2 -0
- package/dist/chunk-ZDYHAYN6.js +1 -0
- package/dist/clipboard-BOocwmAM.d.ts +539 -0
- package/dist/clipboard-Cx7cb3kX.d.cts +539 -0
- package/dist/{colorResolver-BNj-uZ58.d.ts → colorResolver-CIDiSPWd.d.cts} +3 -411
- package/dist/{colorResolver-DiMquGWR.d.cts → colorResolver-KXbUgzWC.d.ts} +3 -411
- package/dist/core-plugins.cjs +1 -1
- package/dist/core-plugins.d.cts +4 -3
- package/dist/core-plugins.d.ts +4 -3
- package/dist/core-plugins.js +1 -1
- package/dist/core.cjs +1 -0
- package/dist/core.d.cts +23 -0
- package/dist/core.d.ts +23 -0
- package/dist/core.js +1 -0
- package/dist/headless.cjs +2 -2
- package/dist/headless.d.cts +8 -175
- package/dist/headless.d.ts +8 -175
- package/dist/headless.js +1 -1
- package/dist/index.cjs +9 -378
- package/dist/index.d.cts +17 -4161
- package/dist/index.d.ts +17 -4161
- package/dist/index.js +9 -378
- package/dist/insertOperations-CzB5b-Of.d.ts +176 -0
- package/dist/insertOperations-DKVmCV32.d.cts +176 -0
- package/dist/mcp-cli.js +21 -21
- package/dist/mcp.cjs +10 -10
- package/dist/mcp.d.cts +2 -1
- package/dist/mcp.d.ts +2 -1
- package/dist/mcp.js +9 -9
- package/dist/processTemplate-BHBTDAIC.js +1 -0
- package/dist/processTemplate-QOEAXCKA.cjs +1 -0
- package/dist/react-Be1YOl4z.d.ts +1356 -0
- package/dist/react-DPuSVbgY.d.cts +1356 -0
- package/dist/react.cjs +1 -0
- package/dist/react.css +1 -0
- package/dist/react.d.cts +9 -0
- package/dist/react.d.ts +9 -0
- package/dist/react.js +1 -0
- package/dist/{registry-CzqAPdui.d.ts → registry-D4tvj9f3.d.ts} +1 -1
- package/dist/{registry-BUTMLqSj.d.cts → registry-ngv6Bumt.d.cts} +1 -1
- package/dist/types-D96elyJF.d.cts +310 -0
- package/dist/types-xMzSPT4i.d.ts +310 -0
- package/dist/ui.cjs +1 -0
- package/dist/ui.d.cts +2103 -0
- package/dist/ui.d.ts +2103 -0
- package/dist/ui.js +1 -0
- package/dist/variableDetector-CPxKo9jP.d.cts +173 -0
- package/dist/variableDetector-DeM1N-_L.d.ts +173 -0
- package/package.json +85 -10
- package/dist/chunk-GQ4JYQWC.js +0 -58
- package/dist/chunk-H3JNHCD7.cjs +0 -10
- package/dist/chunk-L2UUZRZI.js +0 -10
- package/dist/chunk-QOIY4Y6N.cjs +0 -9
- package/dist/chunk-QYKJKSKZ.cjs +0 -58
- package/dist/chunk-TPUJJJWA.js +0 -9
package/dist/headless.d.cts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export {
|
|
1
|
+
export { D as DocumentAgent, F as FormattedTextSegment, I as InsertHyperlinkOptions, b as InsertImageOptions, c as InsertTableOptions, d as InsertTextOptions, e as createAgent, f as createAgentFromDocument } from './DocumentAgent-DEGFgYEN.cjs';
|
|
2
|
+
export { A as AgentContextOptions, T as ContextSelectionOptions, C as CreateEmptyDocumentOptions, E as ExtendedSelectionContext, U as FormattingSummary, P as ProcessTemplateOptions, a as ProcessTemplateResult, S as SelectionContextOptions, V as TemplateError, b as blendColors, c as buildExtendedSelectionContext, d as buildSelectionContext, W as buildSelectionContextFromContext, e as colorsEqual, f as createDocumentWithText, g as createEmptyDocument, h as createRgbColor, X as createTemplateProcessor, i as createThemeColor, j as darkenColor, k as emuToPixels, l as emuToTwips, m as executeCommand, n as executeCommands, o as formatPx, p as getAgentContext, q as getContrastingColor, r as getDocumentSummary, Y as getMissingVariables, Z as getSelectionFormattingSummary, s as getTemplateTags, t as halfPointsToPixels, u as isBlack, v as isWhite, w as lightenColor, x as parseColorString, y as parseDocx, z as pixelsToEmu, B as pixelsToTwips, D as pointsToPixels, _ as previewTemplate, F as processTemplate, $ as processTemplateAdvanced, G as processTemplateAsBlob, H as processTemplateDetailed, I as resolveColor, J as resolveHighlightColor, K as resolveShadingColor, L as serializeDocumentBody, M as serializeDocx, N as serializeSectionProperties, O as twipsToEmu, Q as twipsToPixels, R as validateTemplate } from './colorResolver-CIDiSPWd.cjs';
|
|
3
|
+
import { i as DocumentBody, P as Paragraph, X as TextFormatting, o as Hyperlink, y as Run, T as Table, v as Position } from './agentApi-CbVUCZRu.cjs';
|
|
4
|
+
export { A as AIAction, a as AIActionRequest, b as AgentCommand, c as AgentContext, d as AgentResponse, e as ApplyStyleCommand, a0 as ApplyVariablesCommand, B as BlockContent, a1 as DEFAULT_AI_ACTIONS, D as DeleteTextCommand, h as Document, j as DocxPackage, E as Endnote, l as Footnote, a2 as FormatParagraphCommand, m as FormatTextCommand, I as Image, p as InsertHyperlinkCommand, q as InsertImageCommand, r as InsertTableCommand, s as InsertTextCommand, L as ListLevel, N as NumberingDefinitions, t as ParagraphContext, u as ParagraphFormatting, a3 as ParagraphOutline, R as Range, w as Relationship, x as ReplaceTextCommand, z as RunContent, a4 as SectionInfo, S as SectionProperties, C as SelectionContext, G as SetVariableCommand, K as Style, M as StyleDefinitions, a5 as StyleInfo, O as SuggestedAction, Q as TableCell, U as TableRow, W as TextContent, Y as Theme, a6 as comparePositions, a7 as createCollapsedRange, a8 as createCommand, a9 as createRange, aa as getActionDescription, ab as getActionLabel, ac as isPositionInRange } from './agentApi-CbVUCZRu.cjs';
|
|
5
|
+
export { V as VariableDetectionResult, a as VariableOccurrence, c as createDocx, d as detectVariables, b as detectVariablesDetailed, e as detectVariablesInBody, f as detectVariablesInParagraph, g as documentHasVariables, h as extractVariablesFromText, i as formatVariable, j as hasTemplateVariables, k as isValidVariableName, p as parseVariable, r as removeVariables, l as repackDocx, m as replaceVariables, s as sanitizeVariableName } from './variableDetector-CPxKo9jP.cjs';
|
|
6
|
+
export { e as CommandHandler, g as CommandResult, C as CorePlugin, J as JsonSchema, L as LoadedDocument, M as McpSession, h as McpToolAnnotations, i as McpToolContent, j as McpToolContext, a as McpToolDefinition, b as McpToolHandler, c as McpToolResult, C as Plugin, k as PluginCommand, e as PluginCommandHandler, l as PluginEvent, f as PluginEventListener, P as PluginOptions, d as PluginRegistrationResult, a as ToolDefinition, b as ToolHandler, c as ToolResult, Z as ZodSchemaLike, m as isZodSchema } from './types-D96elyJF.cjs';
|
|
7
|
+
export { P as PluginRegistry, c as createPluginRegistrar, p as pluginRegistry, r as registerPlugins } from './registry-ngv6Bumt.cjs';
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* Shared Text Utilities for Agent Module
|
|
@@ -149,176 +152,6 @@ declare function getParagraphAtIndex(body: DocumentBody, index: number): Paragra
|
|
|
149
152
|
*/
|
|
150
153
|
declare function getBlockIndexForParagraph(body: DocumentBody, paragraphIndex: number): number;
|
|
151
154
|
|
|
152
|
-
/**
|
|
153
|
-
* DOCX Repacker - Repack modified document into valid DOCX
|
|
154
|
-
*
|
|
155
|
-
* Takes a Document with modified content and creates a new DOCX file
|
|
156
|
-
* by updating document.xml while preserving all other files from
|
|
157
|
-
* the original ZIP archive.
|
|
158
|
-
*
|
|
159
|
-
* This ensures round-trip fidelity:
|
|
160
|
-
* - styles.xml, theme1.xml, fontTable.xml remain untouched
|
|
161
|
-
* - Media files preserved
|
|
162
|
-
* - Relationships preserved
|
|
163
|
-
* - Only document.xml is updated with new content
|
|
164
|
-
*
|
|
165
|
-
* OOXML Package Structure:
|
|
166
|
-
* - [Content_Types].xml - Content type declarations
|
|
167
|
-
* - _rels/.rels - Package relationships
|
|
168
|
-
* - word/document.xml - Main document (modified)
|
|
169
|
-
* - word/styles.xml - Styles (preserved)
|
|
170
|
-
* - word/theme/theme1.xml - Theme (preserved)
|
|
171
|
-
* - word/numbering.xml - Numbering (preserved)
|
|
172
|
-
* - word/fontTable.xml - Font table (preserved)
|
|
173
|
-
* - word/settings.xml - Settings (preserved)
|
|
174
|
-
* - word/header*.xml - Headers (preserved)
|
|
175
|
-
* - word/footer*.xml - Footers (preserved)
|
|
176
|
-
* - word/footnotes.xml - Footnotes (preserved)
|
|
177
|
-
* - word/endnotes.xml - Endnotes (preserved)
|
|
178
|
-
* - word/media/* - Media files (preserved)
|
|
179
|
-
* - word/_rels/document.xml.rels - Document relationships (preserved)
|
|
180
|
-
* - docProps/* - Document properties (preserved)
|
|
181
|
-
*/
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Options for repacking DOCX
|
|
185
|
-
*/
|
|
186
|
-
interface RepackOptions {
|
|
187
|
-
/** Compression level (0-9, default: 6) */
|
|
188
|
-
compressionLevel?: number;
|
|
189
|
-
/** Whether to update modification date in docProps/core.xml */
|
|
190
|
-
updateModifiedDate?: boolean;
|
|
191
|
-
/** Custom modifier name for lastModifiedBy */
|
|
192
|
-
modifiedBy?: string;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Repack a Document into a valid DOCX file
|
|
196
|
-
*
|
|
197
|
-
* @param doc - Document with modified content
|
|
198
|
-
* @param options - Optional repack options
|
|
199
|
-
* @returns Promise resolving to DOCX as ArrayBuffer
|
|
200
|
-
* @throws Error if document has no original buffer for round-trip
|
|
201
|
-
*/
|
|
202
|
-
declare function repackDocx(doc: Document, options?: RepackOptions): Promise<ArrayBuffer>;
|
|
203
|
-
/**
|
|
204
|
-
* Create a new DOCX from a Document (without requiring original buffer)
|
|
205
|
-
*
|
|
206
|
-
* @param doc - Document to serialize
|
|
207
|
-
* @returns Promise resolving to DOCX as ArrayBuffer
|
|
208
|
-
*/
|
|
209
|
-
declare function createDocx(doc: Document): Promise<ArrayBuffer>;
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Variable Detector Utility
|
|
213
|
-
*
|
|
214
|
-
* Scans a DOCX document for template variables in the format {variable_name}
|
|
215
|
-
* (standard docxtemplater syntax).
|
|
216
|
-
* Returns a unique, sorted list of variable names found in the document.
|
|
217
|
-
*/
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Result of variable detection
|
|
221
|
-
*/
|
|
222
|
-
interface VariableDetectionResult {
|
|
223
|
-
/** Unique variable names sorted alphabetically */
|
|
224
|
-
variables: string[];
|
|
225
|
-
/** Total count of variable occurrences */
|
|
226
|
-
totalOccurrences: number;
|
|
227
|
-
/** Variables by location */
|
|
228
|
-
byLocation: {
|
|
229
|
-
body: string[];
|
|
230
|
-
headers: string[];
|
|
231
|
-
footers: string[];
|
|
232
|
-
footnotes: string[];
|
|
233
|
-
endnotes: string[];
|
|
234
|
-
textBoxes: string[];
|
|
235
|
-
};
|
|
236
|
-
/** Variable occurrences with positions */
|
|
237
|
-
occurrences: VariableOccurrence[];
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* A single variable occurrence with location info
|
|
241
|
-
*/
|
|
242
|
-
interface VariableOccurrence {
|
|
243
|
-
/** Variable name (without braces) */
|
|
244
|
-
name: string;
|
|
245
|
-
/** Location type */
|
|
246
|
-
location: 'body' | 'header' | 'footer' | 'footnote' | 'endnote' | 'textBox';
|
|
247
|
-
/** Paragraph index within location */
|
|
248
|
-
paragraphIndex?: number;
|
|
249
|
-
/** Section index (for headers/footers) */
|
|
250
|
-
sectionIndex?: number;
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Detect all template variables in a document
|
|
254
|
-
*
|
|
255
|
-
* @param doc - The parsed document
|
|
256
|
-
* @returns Array of unique variable names sorted alphabetically
|
|
257
|
-
*/
|
|
258
|
-
declare function detectVariables(doc: Document): string[];
|
|
259
|
-
/**
|
|
260
|
-
* Detect variables with detailed information
|
|
261
|
-
*
|
|
262
|
-
* @param doc - The parsed document
|
|
263
|
-
* @returns Detailed detection result
|
|
264
|
-
*/
|
|
265
|
-
declare function detectVariablesDetailed(doc: Document): VariableDetectionResult;
|
|
266
|
-
/**
|
|
267
|
-
* Detect variables in document body
|
|
268
|
-
*/
|
|
269
|
-
declare function detectVariablesInBody(body: DocumentBody): string[];
|
|
270
|
-
/**
|
|
271
|
-
* Detect variables in a paragraph
|
|
272
|
-
*/
|
|
273
|
-
declare function detectVariablesInParagraph(paragraph: Paragraph): string[];
|
|
274
|
-
/**
|
|
275
|
-
* Extract variable names from text
|
|
276
|
-
*
|
|
277
|
-
* @param text - The text to search
|
|
278
|
-
* @returns Array of variable names (without braces)
|
|
279
|
-
*/
|
|
280
|
-
declare function extractVariablesFromText(text: string): string[];
|
|
281
|
-
/**
|
|
282
|
-
* Check if text contains template variables
|
|
283
|
-
*/
|
|
284
|
-
declare function hasTemplateVariables(text: string): boolean;
|
|
285
|
-
/**
|
|
286
|
-
* Check if a variable name is valid
|
|
287
|
-
*/
|
|
288
|
-
declare function isValidVariableName(name: string): boolean;
|
|
289
|
-
/**
|
|
290
|
-
* Sanitize a variable name
|
|
291
|
-
*/
|
|
292
|
-
declare function sanitizeVariableName(name: string): string;
|
|
293
|
-
/**
|
|
294
|
-
* Format a variable name with braces (standard docxtemplater syntax)
|
|
295
|
-
*/
|
|
296
|
-
declare function formatVariable(name: string): string;
|
|
297
|
-
/**
|
|
298
|
-
* Parse a variable string to get the name
|
|
299
|
-
*/
|
|
300
|
-
declare function parseVariable(variable: string): string | null;
|
|
301
|
-
/**
|
|
302
|
-
* Replace variables in text with values
|
|
303
|
-
*
|
|
304
|
-
* @param text - The text containing variables
|
|
305
|
-
* @param values - Map of variable name to replacement value
|
|
306
|
-
* @returns Text with variables replaced
|
|
307
|
-
*/
|
|
308
|
-
declare function replaceVariables(text: string, values: Record<string, string>): string;
|
|
309
|
-
/**
|
|
310
|
-
* Replace all variables in text with a placeholder
|
|
311
|
-
*
|
|
312
|
-
* @param text - The text containing variables
|
|
313
|
-
* @param placeholder - Placeholder to use (default: empty string)
|
|
314
|
-
* @returns Text with variables replaced
|
|
315
|
-
*/
|
|
316
|
-
declare function removeVariables(text: string, placeholder?: string): string;
|
|
317
|
-
/**
|
|
318
|
-
* Check if document has any template variables
|
|
319
|
-
*/
|
|
320
|
-
declare function documentHasVariables(doc: Document): boolean;
|
|
321
|
-
|
|
322
155
|
/**
|
|
323
156
|
* Headless API Entry Point
|
|
324
157
|
*
|
|
@@ -359,4 +192,4 @@ declare function documentHasVariables(doc: Document): boolean;
|
|
|
359
192
|
*/
|
|
360
193
|
declare const VERSION = "0.0.2";
|
|
361
194
|
|
|
362
|
-
export {
|
|
195
|
+
export { DocumentBody, Hyperlink, Paragraph, Position, Run, Table, TextFormatting, VERSION, countCharacters, countWords, getBlockIndexForParagraph, getBodyCharacterCount, getBodyText, getBodyWordCount, getFormattingAtPosition, getHyperlinkAtPosition, getHyperlinkText, getParagraphAtIndex, getParagraphText, getParagraphs, getRunText, getTableText, getTextAfter, getTextBefore, hasHyperlinks, hasImages, hasTables, isHeadingStyle, isPositionInHyperlink, parseHeadingLevel };
|
package/dist/headless.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export {
|
|
1
|
+
export { D as DocumentAgent, F as FormattedTextSegment, I as InsertHyperlinkOptions, b as InsertImageOptions, c as InsertTableOptions, d as InsertTextOptions, e as createAgent, f as createAgentFromDocument } from './DocumentAgent-Ci6_T-XM.js';
|
|
2
|
+
export { A as AgentContextOptions, T as ContextSelectionOptions, C as CreateEmptyDocumentOptions, E as ExtendedSelectionContext, U as FormattingSummary, P as ProcessTemplateOptions, a as ProcessTemplateResult, S as SelectionContextOptions, V as TemplateError, b as blendColors, c as buildExtendedSelectionContext, d as buildSelectionContext, W as buildSelectionContextFromContext, e as colorsEqual, f as createDocumentWithText, g as createEmptyDocument, h as createRgbColor, X as createTemplateProcessor, i as createThemeColor, j as darkenColor, k as emuToPixels, l as emuToTwips, m as executeCommand, n as executeCommands, o as formatPx, p as getAgentContext, q as getContrastingColor, r as getDocumentSummary, Y as getMissingVariables, Z as getSelectionFormattingSummary, s as getTemplateTags, t as halfPointsToPixels, u as isBlack, v as isWhite, w as lightenColor, x as parseColorString, y as parseDocx, z as pixelsToEmu, B as pixelsToTwips, D as pointsToPixels, _ as previewTemplate, F as processTemplate, $ as processTemplateAdvanced, G as processTemplateAsBlob, H as processTemplateDetailed, I as resolveColor, J as resolveHighlightColor, K as resolveShadingColor, L as serializeDocumentBody, M as serializeDocx, N as serializeSectionProperties, O as twipsToEmu, Q as twipsToPixels, R as validateTemplate } from './colorResolver-KXbUgzWC.js';
|
|
3
|
+
import { i as DocumentBody, P as Paragraph, X as TextFormatting, o as Hyperlink, y as Run, T as Table, v as Position } from './agentApi-CbVUCZRu.js';
|
|
4
|
+
export { A as AIAction, a as AIActionRequest, b as AgentCommand, c as AgentContext, d as AgentResponse, e as ApplyStyleCommand, a0 as ApplyVariablesCommand, B as BlockContent, a1 as DEFAULT_AI_ACTIONS, D as DeleteTextCommand, h as Document, j as DocxPackage, E as Endnote, l as Footnote, a2 as FormatParagraphCommand, m as FormatTextCommand, I as Image, p as InsertHyperlinkCommand, q as InsertImageCommand, r as InsertTableCommand, s as InsertTextCommand, L as ListLevel, N as NumberingDefinitions, t as ParagraphContext, u as ParagraphFormatting, a3 as ParagraphOutline, R as Range, w as Relationship, x as ReplaceTextCommand, z as RunContent, a4 as SectionInfo, S as SectionProperties, C as SelectionContext, G as SetVariableCommand, K as Style, M as StyleDefinitions, a5 as StyleInfo, O as SuggestedAction, Q as TableCell, U as TableRow, W as TextContent, Y as Theme, a6 as comparePositions, a7 as createCollapsedRange, a8 as createCommand, a9 as createRange, aa as getActionDescription, ab as getActionLabel, ac as isPositionInRange } from './agentApi-CbVUCZRu.js';
|
|
5
|
+
export { V as VariableDetectionResult, a as VariableOccurrence, c as createDocx, d as detectVariables, b as detectVariablesDetailed, e as detectVariablesInBody, f as detectVariablesInParagraph, g as documentHasVariables, h as extractVariablesFromText, i as formatVariable, j as hasTemplateVariables, k as isValidVariableName, p as parseVariable, r as removeVariables, l as repackDocx, m as replaceVariables, s as sanitizeVariableName } from './variableDetector-DeM1N-_L.js';
|
|
6
|
+
export { e as CommandHandler, g as CommandResult, C as CorePlugin, J as JsonSchema, L as LoadedDocument, M as McpSession, h as McpToolAnnotations, i as McpToolContent, j as McpToolContext, a as McpToolDefinition, b as McpToolHandler, c as McpToolResult, C as Plugin, k as PluginCommand, e as PluginCommandHandler, l as PluginEvent, f as PluginEventListener, P as PluginOptions, d as PluginRegistrationResult, a as ToolDefinition, b as ToolHandler, c as ToolResult, Z as ZodSchemaLike, m as isZodSchema } from './types-xMzSPT4i.js';
|
|
7
|
+
export { P as PluginRegistry, c as createPluginRegistrar, p as pluginRegistry, r as registerPlugins } from './registry-D4tvj9f3.js';
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* Shared Text Utilities for Agent Module
|
|
@@ -149,176 +152,6 @@ declare function getParagraphAtIndex(body: DocumentBody, index: number): Paragra
|
|
|
149
152
|
*/
|
|
150
153
|
declare function getBlockIndexForParagraph(body: DocumentBody, paragraphIndex: number): number;
|
|
151
154
|
|
|
152
|
-
/**
|
|
153
|
-
* DOCX Repacker - Repack modified document into valid DOCX
|
|
154
|
-
*
|
|
155
|
-
* Takes a Document with modified content and creates a new DOCX file
|
|
156
|
-
* by updating document.xml while preserving all other files from
|
|
157
|
-
* the original ZIP archive.
|
|
158
|
-
*
|
|
159
|
-
* This ensures round-trip fidelity:
|
|
160
|
-
* - styles.xml, theme1.xml, fontTable.xml remain untouched
|
|
161
|
-
* - Media files preserved
|
|
162
|
-
* - Relationships preserved
|
|
163
|
-
* - Only document.xml is updated with new content
|
|
164
|
-
*
|
|
165
|
-
* OOXML Package Structure:
|
|
166
|
-
* - [Content_Types].xml - Content type declarations
|
|
167
|
-
* - _rels/.rels - Package relationships
|
|
168
|
-
* - word/document.xml - Main document (modified)
|
|
169
|
-
* - word/styles.xml - Styles (preserved)
|
|
170
|
-
* - word/theme/theme1.xml - Theme (preserved)
|
|
171
|
-
* - word/numbering.xml - Numbering (preserved)
|
|
172
|
-
* - word/fontTable.xml - Font table (preserved)
|
|
173
|
-
* - word/settings.xml - Settings (preserved)
|
|
174
|
-
* - word/header*.xml - Headers (preserved)
|
|
175
|
-
* - word/footer*.xml - Footers (preserved)
|
|
176
|
-
* - word/footnotes.xml - Footnotes (preserved)
|
|
177
|
-
* - word/endnotes.xml - Endnotes (preserved)
|
|
178
|
-
* - word/media/* - Media files (preserved)
|
|
179
|
-
* - word/_rels/document.xml.rels - Document relationships (preserved)
|
|
180
|
-
* - docProps/* - Document properties (preserved)
|
|
181
|
-
*/
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Options for repacking DOCX
|
|
185
|
-
*/
|
|
186
|
-
interface RepackOptions {
|
|
187
|
-
/** Compression level (0-9, default: 6) */
|
|
188
|
-
compressionLevel?: number;
|
|
189
|
-
/** Whether to update modification date in docProps/core.xml */
|
|
190
|
-
updateModifiedDate?: boolean;
|
|
191
|
-
/** Custom modifier name for lastModifiedBy */
|
|
192
|
-
modifiedBy?: string;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Repack a Document into a valid DOCX file
|
|
196
|
-
*
|
|
197
|
-
* @param doc - Document with modified content
|
|
198
|
-
* @param options - Optional repack options
|
|
199
|
-
* @returns Promise resolving to DOCX as ArrayBuffer
|
|
200
|
-
* @throws Error if document has no original buffer for round-trip
|
|
201
|
-
*/
|
|
202
|
-
declare function repackDocx(doc: Document, options?: RepackOptions): Promise<ArrayBuffer>;
|
|
203
|
-
/**
|
|
204
|
-
* Create a new DOCX from a Document (without requiring original buffer)
|
|
205
|
-
*
|
|
206
|
-
* @param doc - Document to serialize
|
|
207
|
-
* @returns Promise resolving to DOCX as ArrayBuffer
|
|
208
|
-
*/
|
|
209
|
-
declare function createDocx(doc: Document): Promise<ArrayBuffer>;
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Variable Detector Utility
|
|
213
|
-
*
|
|
214
|
-
* Scans a DOCX document for template variables in the format {variable_name}
|
|
215
|
-
* (standard docxtemplater syntax).
|
|
216
|
-
* Returns a unique, sorted list of variable names found in the document.
|
|
217
|
-
*/
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Result of variable detection
|
|
221
|
-
*/
|
|
222
|
-
interface VariableDetectionResult {
|
|
223
|
-
/** Unique variable names sorted alphabetically */
|
|
224
|
-
variables: string[];
|
|
225
|
-
/** Total count of variable occurrences */
|
|
226
|
-
totalOccurrences: number;
|
|
227
|
-
/** Variables by location */
|
|
228
|
-
byLocation: {
|
|
229
|
-
body: string[];
|
|
230
|
-
headers: string[];
|
|
231
|
-
footers: string[];
|
|
232
|
-
footnotes: string[];
|
|
233
|
-
endnotes: string[];
|
|
234
|
-
textBoxes: string[];
|
|
235
|
-
};
|
|
236
|
-
/** Variable occurrences with positions */
|
|
237
|
-
occurrences: VariableOccurrence[];
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* A single variable occurrence with location info
|
|
241
|
-
*/
|
|
242
|
-
interface VariableOccurrence {
|
|
243
|
-
/** Variable name (without braces) */
|
|
244
|
-
name: string;
|
|
245
|
-
/** Location type */
|
|
246
|
-
location: 'body' | 'header' | 'footer' | 'footnote' | 'endnote' | 'textBox';
|
|
247
|
-
/** Paragraph index within location */
|
|
248
|
-
paragraphIndex?: number;
|
|
249
|
-
/** Section index (for headers/footers) */
|
|
250
|
-
sectionIndex?: number;
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Detect all template variables in a document
|
|
254
|
-
*
|
|
255
|
-
* @param doc - The parsed document
|
|
256
|
-
* @returns Array of unique variable names sorted alphabetically
|
|
257
|
-
*/
|
|
258
|
-
declare function detectVariables(doc: Document): string[];
|
|
259
|
-
/**
|
|
260
|
-
* Detect variables with detailed information
|
|
261
|
-
*
|
|
262
|
-
* @param doc - The parsed document
|
|
263
|
-
* @returns Detailed detection result
|
|
264
|
-
*/
|
|
265
|
-
declare function detectVariablesDetailed(doc: Document): VariableDetectionResult;
|
|
266
|
-
/**
|
|
267
|
-
* Detect variables in document body
|
|
268
|
-
*/
|
|
269
|
-
declare function detectVariablesInBody(body: DocumentBody): string[];
|
|
270
|
-
/**
|
|
271
|
-
* Detect variables in a paragraph
|
|
272
|
-
*/
|
|
273
|
-
declare function detectVariablesInParagraph(paragraph: Paragraph): string[];
|
|
274
|
-
/**
|
|
275
|
-
* Extract variable names from text
|
|
276
|
-
*
|
|
277
|
-
* @param text - The text to search
|
|
278
|
-
* @returns Array of variable names (without braces)
|
|
279
|
-
*/
|
|
280
|
-
declare function extractVariablesFromText(text: string): string[];
|
|
281
|
-
/**
|
|
282
|
-
* Check if text contains template variables
|
|
283
|
-
*/
|
|
284
|
-
declare function hasTemplateVariables(text: string): boolean;
|
|
285
|
-
/**
|
|
286
|
-
* Check if a variable name is valid
|
|
287
|
-
*/
|
|
288
|
-
declare function isValidVariableName(name: string): boolean;
|
|
289
|
-
/**
|
|
290
|
-
* Sanitize a variable name
|
|
291
|
-
*/
|
|
292
|
-
declare function sanitizeVariableName(name: string): string;
|
|
293
|
-
/**
|
|
294
|
-
* Format a variable name with braces (standard docxtemplater syntax)
|
|
295
|
-
*/
|
|
296
|
-
declare function formatVariable(name: string): string;
|
|
297
|
-
/**
|
|
298
|
-
* Parse a variable string to get the name
|
|
299
|
-
*/
|
|
300
|
-
declare function parseVariable(variable: string): string | null;
|
|
301
|
-
/**
|
|
302
|
-
* Replace variables in text with values
|
|
303
|
-
*
|
|
304
|
-
* @param text - The text containing variables
|
|
305
|
-
* @param values - Map of variable name to replacement value
|
|
306
|
-
* @returns Text with variables replaced
|
|
307
|
-
*/
|
|
308
|
-
declare function replaceVariables(text: string, values: Record<string, string>): string;
|
|
309
|
-
/**
|
|
310
|
-
* Replace all variables in text with a placeholder
|
|
311
|
-
*
|
|
312
|
-
* @param text - The text containing variables
|
|
313
|
-
* @param placeholder - Placeholder to use (default: empty string)
|
|
314
|
-
* @returns Text with variables replaced
|
|
315
|
-
*/
|
|
316
|
-
declare function removeVariables(text: string, placeholder?: string): string;
|
|
317
|
-
/**
|
|
318
|
-
* Check if document has any template variables
|
|
319
|
-
*/
|
|
320
|
-
declare function documentHasVariables(doc: Document): boolean;
|
|
321
|
-
|
|
322
155
|
/**
|
|
323
156
|
* Headless API Entry Point
|
|
324
157
|
*
|
|
@@ -359,4 +192,4 @@ declare function documentHasVariables(doc: Document): boolean;
|
|
|
359
192
|
*/
|
|
360
193
|
declare const VERSION = "0.0.2";
|
|
361
194
|
|
|
362
|
-
export {
|
|
195
|
+
export { DocumentBody, Hyperlink, Paragraph, Position, Run, Table, TextFormatting, VERSION, countCharacters, countWords, getBlockIndexForParagraph, getBodyCharacterCount, getBodyText, getBodyWordCount, getFormattingAtPosition, getHyperlinkAtPosition, getHyperlinkText, getParagraphAtIndex, getParagraphText, getParagraphs, getRunText, getTableText, getTextAfter, getTextBefore, hasHyperlinks, hasImages, hasTables, isHeadingStyle, isPositionInHyperlink, parseHeadingLevel };
|
package/dist/headless.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{e as buildExtendedSelectionContext,d as buildSelectionContext,b as buildSelectionContextFromContext,h as createDocumentWithText,g as createEmptyDocument,a as getAgentContext,c as getDocumentSummary,f as getSelectionFormattingSummary}from'./chunk-TOI5W3HK.js';export{a as DocumentAgent,b as createAgent,c as createAgentFromDocument}from'./chunk-M7F2CUUD.js';export{g as DEFAULT_AI_ACTIONS,d as comparePositions,a as createCollapsedRange,h as createCommand,b as createRange,f as getActionDescription,e as getActionLabel,c as isPositionInRange}from'./chunk-EMKABJPH.js';export{l as blendColors,m as colorsEqual,i as createRgbColor,h as createThemeColor,j as darkenColor,p as emuToPixels,r as emuToTwips,x as formatPx,f as getContrastingColor,u as halfPointsToPixels,d as isBlack,e as isWhite,k as lightenColor,g as parseColorString,q as pixelsToEmu,o as pixelsToTwips,t as pointsToPixels,a as resolveColor,b as resolveHighlightColor,c as resolveShadingColor,s as twipsToEmu,n as twipsToPixels}from'./chunk-ZDYHAYN6.js';export{a as isZodSchema}from'./chunk-COP5BIBZ.js';export{j as createTemplateProcessor,g as getMissingVariables,e as getTemplateTags,h as previewTemplate,a as processTemplate,i as processTemplateAdvanced,c as processTemplateAsBlob,b as processTemplateDetailed,f as validateTemplate}from'./chunk-ESI4BSBF.js';export{a as detectVariables,b as detectVariablesDetailed,c as detectVariablesInBody,d as detectVariablesInParagraph,m as documentHasVariables,e as extractVariablesFromText,i as formatVariable,f as hasTemplateVariables,g as isValidVariableName,j as parseVariable,l as removeVariables,k as replaceVariables,h as sanitizeVariableName}from'./chunk-2ASOEN3V.js';export{e as createDocx,d as repackDocx,b as serializeDocumentBody,c as serializeDocx,a as serializeSectionProperties}from'./chunk-MDPDH7KS.js';export{a as executeCommand,b as executeCommands}from'./chunk-MMJD2DLL.js';export{p as parseDocx}from'./chunk-OTG4NABM.js';export{a as PluginRegistry,d as createPluginRegistrar,b as pluginRegistry,c as registerPlugins}from'./chunk-QHWHCIUW.js';import'./chunk-3IYNTJO5.js';function p(n){let e=[];for(let t of n.content)t.type==="run"?e.push(c(t)):t.type==="hyperlink"&&e.push(g(t));return e.join("")}function c(n){return n.content.filter(e=>e.type==="text").map(e=>e.text).join("")}function g(n){let e=[];for(let t of n.children)t.type==="run"&&e.push(c(t));return e.join("")}function m(n){let e=[];for(let t of n.rows)for(let o of t.cells)for(let r of o.content)r.type==="paragraph"&&e.push(p(r));return e.join(" ")}function Me(n){let e=[];for(let t of n.content)t.type==="paragraph"?e.push(p(t)):t.type==="table"&&e.push(m(t));return e.join(`
|
|
2
2
|
`)}function f(n){return n.split(/\s+/).filter(t=>t.length>0).length}function je(n,e=true){return e?n.length:n.replace(/\s/g,"").length}function We(n){let e=0;for(let t of n.content)t.type==="paragraph"?e+=f(p(t)):t.type==="table"&&(e+=ze(t));return e}function ze(n){let e=0;for(let t of n.rows)for(let o of t.cells)for(let r of o.content)r.type==="paragraph"&&(e+=f(p(r)));return e}function Ne(n){let e=0;for(let t of n.content)t.type==="paragraph"?e+=p(t).length:t.type==="table"&&(e+=qe(t));return e}function qe(n){let e=0;for(let t of n.rows)for(let o of t.cells)for(let r of o.content)r.type==="paragraph"&&(e+=p(r).length);return e}function Ze(n,e,t){let o=[],r=0,i=n[e.paragraphIndex];if(i){let s=p(i).slice(0,e.offset);o.unshift(s),r+=s.length;}for(let l=e.paragraphIndex-1;l>=0&&r<t;l--){let s=n[l];if(!s)continue;let u=p(s);o.unshift(u),r+=u.length;}let a=o.join(`
|
|
3
3
|
`);return a.length>t?"..."+a.slice(-t):a}function _e(n,e,t){let o=[],r=0,i=n[e.paragraphIndex];if(i){let s=p(i).slice(e.offset);o.push(s),r+=s.length;}for(let l=e.paragraphIndex+1;l<n.length&&r<t;l++){let s=n[l];if(!s)continue;let u=p(s);o.push(u),r+=u.length;}let a=o.join(`
|
|
4
4
|
`);return a.length>t?a.slice(0,t)+"...":a}function Je(n,e){let t=0;for(let o of n.content)if(o.type==="run"){let r=c(o),i=t+r.length;if(e>=t&&e<i)return o.formatting||{};t=i;}else if(o.type==="hyperlink"){let r=g(o),i=t+r.length;if(e>=t&&e<i){for(let a of o.children)if(a.type==="run")return a.formatting||{}}t=i;}return {}}function Ue(n,e){let t=0;for(let o of n.content)if(o.type==="run"){let r=c(o);t+=r.length;}else if(o.type==="hyperlink"){let r=g(o),i=t,a=t+r.length;if(e>=i&&e<a)return true;t=a;}return false}function Ge(n,e){let t=0;for(let o of n.content)if(o.type==="run"){let r=c(o);t+=r.length;}else if(o.type==="hyperlink"){let r=g(o),i=t,a=t+r.length;if(e>=i&&e<a)return o;t=a;}}function Ke(n){return n?n.toLowerCase().includes("heading"):false}function Qe(n){if(!n)return;let e=n.match(/heading\s*(\d)/i);if(e)return parseInt(e[1],10)}function Xe(n){for(let e of n.content)if(e.type==="paragraph"){for(let t of e.content)if(t.type==="run"){for(let o of t.content)if(o.type==="drawing")return true}}return false}function Ye(n){for(let e of n.content)if(e.type==="paragraph"){for(let t of e.content)if(t.type==="hyperlink")return true}return false}function $e(n){return n.content.some(e=>e.type==="table")}function x(n){return n.content.filter(e=>e.type==="paragraph")}function et(n,e){return x(n)[e]}function tt(n,e){let t=0;for(let o=0;o<n.content.length;o++)if(n.content[o].type==="paragraph"){if(t===e)return o;t++;}return -1}var ot="0.0.2";export{ot as VERSION,je as countCharacters,f as countWords,tt as getBlockIndexForParagraph,Ne as getBodyCharacterCount,Me as getBodyText,We as getBodyWordCount,Je as getFormattingAtPosition,Ge as getHyperlinkAtPosition,g as getHyperlinkText,et as getParagraphAtIndex,p as getParagraphText,x as getParagraphs,c as getRunText,m as getTableText,_e as getTextAfter,Ze as getTextBefore,Ye as hasHyperlinks,Xe as hasImages,$e as hasTables,Ke as isHeadingStyle,Ue as isPositionInHyperlink,Qe as parseHeadingLevel};
|