@eigenpal/docx-js-editor 0.0.17 → 0.0.19
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-D6dkOFg6.d.ts +436 -0
- package/dist/ClipboardManager-EZ0C6Onq.d.cts +436 -0
- package/dist/DocumentAgent-B0EC8lPC.d.cts +412 -0
- package/dist/DocumentAgent-BcCDg7i2.d.ts +412 -0
- package/dist/{FindReplaceDialog-MMDEJORP.js → FindReplaceDialog-AWQXKEUQ.js} +2 -2
- package/dist/{FindReplaceDialog-MMDEJORP.js.map → FindReplaceDialog-AWQXKEUQ.js.map} +1 -1
- package/dist/{FindReplaceDialog-K4GRE4JB.cjs → FindReplaceDialog-I4SZDSVP.cjs} +2 -2
- package/dist/{FindReplaceDialog-K4GRE4JB.cjs.map → FindReplaceDialog-I4SZDSVP.cjs.map} +1 -1
- package/dist/{FootnotePropertiesDialog-V3YOIJCV.cjs → FootnotePropertiesDialog-73VT2ZVZ.cjs} +2 -2
- package/dist/{FootnotePropertiesDialog-V3YOIJCV.cjs.map → FootnotePropertiesDialog-73VT2ZVZ.cjs.map} +1 -1
- package/dist/{FootnotePropertiesDialog-HG4267LR.js → FootnotePropertiesDialog-ZM3EF3EF.js} +2 -2
- package/dist/{FootnotePropertiesDialog-HG4267LR.js.map → FootnotePropertiesDialog-ZM3EF3EF.js.map} +1 -1
- package/dist/{HyperlinkDialog-SCSX4RP7.js → HyperlinkDialog-BA25XUT5.js} +2 -2
- package/dist/{HyperlinkDialog-SCSX4RP7.js.map → HyperlinkDialog-BA25XUT5.js.map} +1 -1
- package/dist/{HyperlinkDialog-YPKURBZK.cjs → HyperlinkDialog-V63LPOT2.cjs} +2 -2
- package/dist/{HyperlinkDialog-YPKURBZK.cjs.map → HyperlinkDialog-V63LPOT2.cjs.map} +1 -1
- package/dist/{ImagePositionDialog-CJYJ35PI.js → ImagePositionDialog-AIAMKPFK.js} +2 -2
- package/dist/{ImagePositionDialog-CJYJ35PI.js.map → ImagePositionDialog-AIAMKPFK.js.map} +1 -1
- package/dist/{ImagePositionDialog-IMVI7EXA.cjs → ImagePositionDialog-KMK7ROV2.cjs} +2 -2
- package/dist/{ImagePositionDialog-IMVI7EXA.cjs.map → ImagePositionDialog-KMK7ROV2.cjs.map} +1 -1
- package/dist/{ImagePropertiesDialog-P7WN2ALR.js → ImagePropertiesDialog-ERFCUVCW.js} +2 -2
- package/dist/{ImagePropertiesDialog-P7WN2ALR.js.map → ImagePropertiesDialog-ERFCUVCW.js.map} +1 -1
- package/dist/{ImagePropertiesDialog-YS4KJRN7.cjs → ImagePropertiesDialog-USMMRK6X.cjs} +2 -2
- package/dist/{ImagePropertiesDialog-YS4KJRN7.cjs.map → ImagePropertiesDialog-USMMRK6X.cjs.map} +1 -1
- package/dist/{TablePropertiesDialog-CUQXUBQN.cjs → TablePropertiesDialog-72CIUAZT.cjs} +2 -2
- package/dist/{TablePropertiesDialog-CUQXUBQN.cjs.map → TablePropertiesDialog-72CIUAZT.cjs.map} +1 -1
- package/dist/{TablePropertiesDialog-ZHAYVHPZ.js → TablePropertiesDialog-EMUEVYB3.js} +2 -2
- package/dist/{TablePropertiesDialog-ZHAYVHPZ.js.map → TablePropertiesDialog-EMUEVYB3.js.map} +1 -1
- package/dist/agentApi-BFVyKagE.d.cts +2227 -0
- package/dist/agentApi-BFVyKagE.d.ts +2227 -0
- package/dist/chunk-2CHPKB5A.cjs +112 -0
- package/dist/chunk-2CHPKB5A.cjs.map +1 -0
- package/dist/chunk-2QOEHCBX.js +2 -0
- package/dist/chunk-2QOEHCBX.js.map +1 -0
- package/dist/chunk-4QT5LPBA.cjs +24 -0
- package/dist/chunk-4QT5LPBA.cjs.map +1 -0
- package/dist/chunk-5DYSI4O4.cjs +60 -0
- package/dist/chunk-5DYSI4O4.cjs.map +1 -0
- package/dist/chunk-5FJXHXFV.cjs +2 -0
- package/dist/chunk-5FJXHXFV.cjs.map +1 -0
- package/dist/chunk-6FEWNF6B.js +4 -0
- package/dist/chunk-6FEWNF6B.js.map +1 -0
- package/dist/chunk-6LF5HZCV.js +10 -0
- package/dist/chunk-6LF5HZCV.js.map +1 -0
- package/dist/chunk-7JSPKVOW.js +2 -0
- package/dist/chunk-7JSPKVOW.js.map +1 -0
- package/dist/chunk-C33XDRDJ.cjs +28 -0
- package/dist/chunk-C33XDRDJ.cjs.map +1 -0
- package/dist/chunk-CV5WFE7K.js +24 -0
- package/dist/chunk-CV5WFE7K.js.map +1 -0
- package/dist/chunk-CXJRNISO.js +2 -0
- package/dist/chunk-CXJRNISO.js.map +1 -0
- package/dist/chunk-DP6Q75ZD.js +28 -0
- package/dist/chunk-DP6Q75ZD.js.map +1 -0
- package/dist/chunk-FDANI5P4.cjs +2 -0
- package/dist/chunk-FDANI5P4.cjs.map +1 -0
- package/dist/chunk-FGVGZLBL.js +2 -0
- package/dist/chunk-FGVGZLBL.js.map +1 -0
- package/dist/chunk-GJ4GKSDU.cjs +2 -0
- package/dist/chunk-GJ4GKSDU.cjs.map +1 -0
- package/dist/chunk-GWBTKVFD.cjs +2 -0
- package/dist/chunk-GWBTKVFD.cjs.map +1 -0
- package/dist/chunk-JOYPFQW2.js +2 -0
- package/dist/chunk-JOYPFQW2.js.map +1 -0
- package/dist/chunk-L54YNLSE.js +2 -0
- package/dist/chunk-L54YNLSE.js.map +1 -0
- package/dist/chunk-LPGMLJMO.js +259 -0
- package/dist/chunk-LPGMLJMO.js.map +1 -0
- package/dist/chunk-OHG7ROFC.js +11 -0
- package/dist/chunk-OHG7ROFC.js.map +1 -0
- package/dist/chunk-PANKMCFX.cjs +4 -0
- package/dist/chunk-PANKMCFX.cjs.map +1 -0
- package/dist/chunk-QDV75OJ4.js +112 -0
- package/dist/chunk-QDV75OJ4.js.map +1 -0
- package/dist/chunk-QEBO3EQP.cjs +2 -0
- package/dist/{chunk-V3MCDVZE.cjs.map → chunk-QEBO3EQP.cjs.map} +1 -1
- package/dist/chunk-QVIZ775M.cjs +259 -0
- package/dist/chunk-QVIZ775M.cjs.map +1 -0
- package/dist/chunk-RMUMR42R.cjs +10 -0
- package/dist/chunk-RMUMR42R.cjs.map +1 -0
- package/dist/chunk-T2HQYRA7.cjs +2 -0
- package/dist/chunk-T2HQYRA7.cjs.map +1 -0
- package/dist/chunk-ULXNEG66.js +60 -0
- package/dist/chunk-ULXNEG66.js.map +1 -0
- package/dist/chunk-WD2HTKRR.cjs +2 -0
- package/dist/chunk-WD2HTKRR.cjs.map +1 -0
- package/dist/chunk-XZNOV52K.cjs +11 -0
- package/dist/chunk-XZNOV52K.cjs.map +1 -0
- package/dist/chunk-Y6VCTLCJ.js +2 -0
- package/dist/{chunk-AL62KQYJ.js.map → chunk-Y6VCTLCJ.js.map} +1 -1
- package/dist/{TableToolbar-RHX9L4h9.d.ts → clipboard-CqE-UZ2d.d.cts} +125 -2
- package/dist/{TableToolbar-RHX9L4h9.d.cts → clipboard-beGtyabO.d.ts} +125 -2
- package/dist/colorResolver-B5YbO_a4.d.ts +618 -0
- package/dist/colorResolver-Cu46bSKr.d.cts +618 -0
- package/dist/core-plugins-reexport.cjs +1 -1
- package/dist/core-plugins-reexport.cjs.map +1 -1
- package/dist/core-plugins-reexport.d.cts +31 -1
- package/dist/core-plugins-reexport.d.ts +31 -1
- package/dist/core-plugins-reexport.js +1 -1
- package/dist/core-plugins-reexport.js.map +1 -1
- package/dist/core-reexport.cjs +1 -1
- package/dist/core-reexport.cjs.map +1 -1
- package/dist/core-reexport.d.cts +309 -4
- package/dist/core-reexport.d.ts +309 -4
- package/dist/core-reexport.js +1 -1
- package/dist/core-reexport.js.map +1 -1
- package/dist/executor-K5RXUTTR.js +2 -0
- package/dist/executor-K5RXUTTR.js.map +1 -0
- package/dist/executor-XIPIU3H4.cjs +2 -0
- package/dist/executor-XIPIU3H4.cjs.map +1 -0
- package/dist/fontLoader-CFKpg0Ri.d.ts +176 -0
- package/dist/fontLoader-HZYfILUm.d.cts +176 -0
- package/dist/headless-reexport.cjs +4 -1
- package/dist/headless-reexport.cjs.map +1 -1
- package/dist/headless-reexport.d.cts +195 -1
- package/dist/headless-reexport.d.ts +195 -1
- package/dist/headless-reexport.js +4 -1
- package/dist/headless-reexport.js.map +1 -1
- package/dist/index.cjs +9 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +2 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.cts +261 -30
- package/dist/index.d.ts +261 -30
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/mcp-reexport.cjs +16 -1
- package/dist/mcp-reexport.cjs.map +1 -1
- package/dist/mcp-reexport.d.cts +156 -1
- package/dist/mcp-reexport.d.ts +156 -1
- package/dist/mcp-reexport.js +16 -1
- package/dist/mcp-reexport.js.map +1 -1
- package/dist/processTemplate-G37IM66O.js +2 -0
- package/dist/processTemplate-G37IM66O.js.map +1 -0
- package/dist/processTemplate-RFBGVH7T.cjs +2 -0
- package/dist/processTemplate-RFBGVH7T.cjs.map +1 -0
- package/dist/react-BjOCdeTs.d.ts +1027 -0
- package/dist/react-UzAn4o7l.d.cts +1027 -0
- package/dist/react.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.css +2 -0
- package/dist/react.css.map +1 -0
- package/dist/react.d.cts +10 -860
- package/dist/react.d.ts +10 -860
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/registry-CV6nYWqP.d.ts +165 -0
- package/dist/registry-DjacfR6Q.d.cts +165 -0
- package/dist/selectionRects-6DU7HN7E.js +2 -0
- package/dist/selectionRects-6DU7HN7E.js.map +1 -0
- package/dist/selectionRects-YZSC24ZP.cjs +2 -0
- package/dist/selectionRects-YZSC24ZP.cjs.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/types-Bnp8rvJn.d.cts +310 -0
- package/dist/types-DwZ3xysp.d.ts +310 -0
- package/dist/ui.cjs +1 -1
- package/dist/ui.d.cts +3 -5
- package/dist/ui.d.ts +3 -5
- package/dist/ui.js +1 -1
- package/dist/variableDetector-BaDeXz7D.d.ts +173 -0
- package/dist/variableDetector-CMhJtM96.d.cts +173 -0
- package/package.json +10 -3
- package/dist/chunk-7FEY3YWC.cjs +0 -3
- package/dist/chunk-7FEY3YWC.cjs.map +0 -1
- package/dist/chunk-AL62KQYJ.js +0 -2
- package/dist/chunk-MXGYESPA.cjs +0 -178
- package/dist/chunk-MXGYESPA.cjs.map +0 -1
- package/dist/chunk-NMYD4OJZ.js +0 -3
- package/dist/chunk-NMYD4OJZ.js.map +0 -1
- package/dist/chunk-OD33FUTO.js +0 -178
- package/dist/chunk-OD33FUTO.js.map +0 -1
- package/dist/chunk-V3MCDVZE.cjs +0 -2
- package/dist/chunk-VIEW4NAF.js +0 -112
- package/dist/chunk-VIEW4NAF.js.map +0 -1
- package/dist/chunk-ZX4CSEL3.cjs +0 -112
- package/dist/chunk-ZX4CSEL3.cjs.map +0 -1
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { D as Document, B as BreakContent, a as Paragraph, b as Run, c as RunContent } from './agentApi-BFVyKagE.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Insert Operations Utility
|
|
5
|
+
*
|
|
6
|
+
* Utility functions for inserting content into the document.
|
|
7
|
+
* Provides functions for inserting page breaks, horizontal rules, and other elements.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Insert position in the document
|
|
12
|
+
*/
|
|
13
|
+
interface InsertPosition {
|
|
14
|
+
/** Paragraph index in the document body */
|
|
15
|
+
paragraphIndex: number;
|
|
16
|
+
/** Run index within the paragraph (optional) */
|
|
17
|
+
runIndex?: number;
|
|
18
|
+
/** Character offset within the run (optional) */
|
|
19
|
+
offset?: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create a page break content element
|
|
23
|
+
*/
|
|
24
|
+
declare function createPageBreak(): BreakContent;
|
|
25
|
+
/**
|
|
26
|
+
* Create a column break content element
|
|
27
|
+
*/
|
|
28
|
+
declare function createColumnBreak(): BreakContent;
|
|
29
|
+
/**
|
|
30
|
+
* Create a text wrapping break (line break)
|
|
31
|
+
*/
|
|
32
|
+
declare function createLineBreak(clear?: 'none' | 'left' | 'right' | 'all'): BreakContent;
|
|
33
|
+
/**
|
|
34
|
+
* Create a run containing a page break
|
|
35
|
+
*/
|
|
36
|
+
declare function createPageBreakRun(): Run;
|
|
37
|
+
/**
|
|
38
|
+
* Create an empty paragraph with a page break before it
|
|
39
|
+
*/
|
|
40
|
+
declare function createPageBreakParagraph(): Paragraph;
|
|
41
|
+
/**
|
|
42
|
+
* Insert a page break at a position in the document
|
|
43
|
+
* This inserts a new paragraph with pageBreakBefore: true
|
|
44
|
+
*/
|
|
45
|
+
declare function insertPageBreak(doc: Document, position: InsertPosition): Document;
|
|
46
|
+
/**
|
|
47
|
+
* Create a horizontal rule paragraph
|
|
48
|
+
* Uses a paragraph with bottom border to simulate horizontal rule
|
|
49
|
+
*/
|
|
50
|
+
declare function createHorizontalRule(): Paragraph;
|
|
51
|
+
/**
|
|
52
|
+
* Insert a horizontal rule at a position in the document
|
|
53
|
+
*/
|
|
54
|
+
declare function insertHorizontalRule(doc: Document, position: InsertPosition): Document;
|
|
55
|
+
/**
|
|
56
|
+
* Check if content is a page break
|
|
57
|
+
*/
|
|
58
|
+
declare function isPageBreak(content: RunContent): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Check if content is a column break
|
|
61
|
+
*/
|
|
62
|
+
declare function isColumnBreak(content: RunContent): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Check if content is a line break
|
|
65
|
+
*/
|
|
66
|
+
declare function isLineBreak(content: RunContent): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Check if content is any type of break
|
|
69
|
+
*/
|
|
70
|
+
declare function isBreakContent(content: RunContent): content is BreakContent;
|
|
71
|
+
/**
|
|
72
|
+
* Check if a paragraph has pageBreakBefore
|
|
73
|
+
*/
|
|
74
|
+
declare function hasPageBreakBefore(paragraph: Paragraph): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Count page breaks in a document
|
|
77
|
+
*/
|
|
78
|
+
declare function countPageBreaks(doc: Document): number;
|
|
79
|
+
/**
|
|
80
|
+
* Find all page break positions in a document
|
|
81
|
+
*/
|
|
82
|
+
declare function findPageBreaks(doc: Document): InsertPosition[];
|
|
83
|
+
/**
|
|
84
|
+
* Remove a page break at a specific position
|
|
85
|
+
*/
|
|
86
|
+
declare function removePageBreak(doc: Document, position: InsertPosition): Document;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Google Fonts Loader
|
|
90
|
+
*
|
|
91
|
+
* Dynamically loads fonts from Google Fonts API with:
|
|
92
|
+
* - Loading state tracking
|
|
93
|
+
* - Duplicate prevention
|
|
94
|
+
* - Callback notifications
|
|
95
|
+
* - Font availability detection
|
|
96
|
+
*/
|
|
97
|
+
/**
|
|
98
|
+
* Load a font from Google Fonts
|
|
99
|
+
*
|
|
100
|
+
* @param fontFamily - The font family name to load
|
|
101
|
+
* @param options - Optional configuration
|
|
102
|
+
* @returns Promise resolving to true if font loaded successfully, false otherwise
|
|
103
|
+
*/
|
|
104
|
+
declare function loadFont(fontFamily: string, options?: {
|
|
105
|
+
weights?: number[];
|
|
106
|
+
styles?: ('normal' | 'italic')[];
|
|
107
|
+
}): Promise<boolean>;
|
|
108
|
+
/**
|
|
109
|
+
* Load multiple fonts from Google Fonts
|
|
110
|
+
*
|
|
111
|
+
* @param families - Array of font family names to load
|
|
112
|
+
* @param options - Optional configuration
|
|
113
|
+
* @returns Promise resolving when all fonts are loaded (or failed)
|
|
114
|
+
*/
|
|
115
|
+
declare function loadFonts(families: string[], options?: {
|
|
116
|
+
weights?: number[];
|
|
117
|
+
styles?: ('normal' | 'italic')[];
|
|
118
|
+
}): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Check if a font is loaded
|
|
121
|
+
*
|
|
122
|
+
* @param fontFamily - The font family name to check
|
|
123
|
+
* @returns true if the font is loaded, false otherwise
|
|
124
|
+
*/
|
|
125
|
+
declare function isFontLoaded(fontFamily: string): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Check if any fonts are currently loading
|
|
128
|
+
*
|
|
129
|
+
* @returns true if any fonts are loading, false otherwise
|
|
130
|
+
*/
|
|
131
|
+
declare function isLoading(): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Get list of all loaded fonts
|
|
134
|
+
*
|
|
135
|
+
* @returns Array of loaded font family names
|
|
136
|
+
*/
|
|
137
|
+
declare function getLoadedFonts(): string[];
|
|
138
|
+
/**
|
|
139
|
+
* Register a callback to be notified when fonts are loaded
|
|
140
|
+
*
|
|
141
|
+
* @param callback - Function to call when fonts are loaded
|
|
142
|
+
* @returns Cleanup function to remove the callback
|
|
143
|
+
*/
|
|
144
|
+
declare function onFontsLoaded(callback: (fonts: string[]) => void): () => void;
|
|
145
|
+
/**
|
|
146
|
+
* Check if a font is available on the system using canvas measurement
|
|
147
|
+
*
|
|
148
|
+
* This uses the technique of comparing text width with the target font
|
|
149
|
+
* vs a known fallback font. If they differ, the font is available.
|
|
150
|
+
*
|
|
151
|
+
* @param fontFamily - The font family name to check
|
|
152
|
+
* @param fallbackFont - Fallback font to compare against
|
|
153
|
+
* @returns true if font is available, false otherwise
|
|
154
|
+
*/
|
|
155
|
+
declare function canRenderFont(fontFamily: string, fallbackFont?: string): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Load a font from a raw buffer (e.g., embedded in DOCX)
|
|
158
|
+
*
|
|
159
|
+
* @param fontFamily - The font family name
|
|
160
|
+
* @param buffer - Font file buffer (TTF, OTF, WOFF, WOFF2)
|
|
161
|
+
* @param options - Font options
|
|
162
|
+
* @returns Promise resolving when font is loaded
|
|
163
|
+
*/
|
|
164
|
+
declare function loadFontFromBuffer(fontFamily: string, buffer: ArrayBuffer, options?: {
|
|
165
|
+
weight?: number | string;
|
|
166
|
+
style?: 'normal' | 'italic';
|
|
167
|
+
}): Promise<boolean>;
|
|
168
|
+
/**
|
|
169
|
+
* Preload a list of common document fonts
|
|
170
|
+
*
|
|
171
|
+
* This preloads fonts commonly used in DOCX documents that have
|
|
172
|
+
* Google Fonts equivalents.
|
|
173
|
+
*/
|
|
174
|
+
declare function preloadCommonFonts(): Promise<void>;
|
|
175
|
+
|
|
176
|
+
export { type InsertPosition as I, countPageBreaks as a, createColumnBreak as b, canRenderFont as c, createHorizontalRule as d, createLineBreak as e, createPageBreak as f, createPageBreakParagraph as g, createPageBreakRun as h, findPageBreaks as i, getLoadedFonts as j, hasPageBreakBefore as k, insertHorizontalRule as l, insertPageBreak as m, isBreakContent as n, isColumnBreak as o, isFontLoaded as p, isLoading as q, isLineBreak as r, isPageBreak as s, loadFont as t, loadFontFromBuffer as u, loadFonts as v, onFontsLoaded as w, preloadCommonFonts as x, removePageBreak as y };
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkT2HQYRA7_cjs=require('./chunk-T2HQYRA7.cjs'),chunkRMUMR42R_cjs=require('./chunk-RMUMR42R.cjs'),chunkGJ4GKSDU_cjs=require('./chunk-GJ4GKSDU.cjs'),chunkXZNOV52K_cjs=require('./chunk-XZNOV52K.cjs'),chunk5DYSI4O4_cjs=require('./chunk-5DYSI4O4.cjs'),chunkGWBTKVFD_cjs=require('./chunk-GWBTKVFD.cjs'),chunkC33XDRDJ_cjs=require('./chunk-C33XDRDJ.cjs'),chunkWD2HTKRR_cjs=require('./chunk-WD2HTKRR.cjs'),chunk4QT5LPBA_cjs=require('./chunk-4QT5LPBA.cjs');require('./chunk-QEBO3EQP.cjs');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
|
+
`)}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
|
+
`);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
|
+
`);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";Object.defineProperty(exports,"DEFAULT_AI_ACTIONS",{enumerable:true,get:function(){return chunkT2HQYRA7_cjs.g}});Object.defineProperty(exports,"comparePositions",{enumerable:true,get:function(){return chunkT2HQYRA7_cjs.d}});Object.defineProperty(exports,"createCollapsedRange",{enumerable:true,get:function(){return chunkT2HQYRA7_cjs.a}});Object.defineProperty(exports,"createCommand",{enumerable:true,get:function(){return chunkT2HQYRA7_cjs.h}});Object.defineProperty(exports,"createRange",{enumerable:true,get:function(){return chunkT2HQYRA7_cjs.b}});Object.defineProperty(exports,"getActionDescription",{enumerable:true,get:function(){return chunkT2HQYRA7_cjs.f}});Object.defineProperty(exports,"getActionLabel",{enumerable:true,get:function(){return chunkT2HQYRA7_cjs.e}});Object.defineProperty(exports,"isPositionInRange",{enumerable:true,get:function(){return chunkT2HQYRA7_cjs.c}});Object.defineProperty(exports,"DocumentAgent",{enumerable:true,get:function(){return chunkRMUMR42R_cjs.c}});Object.defineProperty(exports,"buildExtendedSelectionContext",{enumerable:true,get:function(){return chunkRMUMR42R_cjs.j}});Object.defineProperty(exports,"buildSelectionContext",{enumerable:true,get:function(){return chunkRMUMR42R_cjs.i}});Object.defineProperty(exports,"buildSelectionContextFromContext",{enumerable:true,get:function(){return chunkRMUMR42R_cjs.g}});Object.defineProperty(exports,"createAgent",{enumerable:true,get:function(){return chunkRMUMR42R_cjs.d}});Object.defineProperty(exports,"createAgentFromDocument",{enumerable:true,get:function(){return chunkRMUMR42R_cjs.e}});Object.defineProperty(exports,"createDocumentWithText",{enumerable:true,get:function(){return chunkRMUMR42R_cjs.b}});Object.defineProperty(exports,"createEmptyDocument",{enumerable:true,get:function(){return chunkRMUMR42R_cjs.a}});Object.defineProperty(exports,"getAgentContext",{enumerable:true,get:function(){return chunkRMUMR42R_cjs.f}});Object.defineProperty(exports,"getDocumentSummary",{enumerable:true,get:function(){return chunkRMUMR42R_cjs.h}});Object.defineProperty(exports,"getSelectionFormattingSummary",{enumerable:true,get:function(){return chunkRMUMR42R_cjs.k}});Object.defineProperty(exports,"blendColors",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.l}});Object.defineProperty(exports,"colorsEqual",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.m}});Object.defineProperty(exports,"createRgbColor",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.i}});Object.defineProperty(exports,"createThemeColor",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.h}});Object.defineProperty(exports,"darkenColor",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.j}});Object.defineProperty(exports,"emuToPixels",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.p}});Object.defineProperty(exports,"emuToTwips",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.r}});Object.defineProperty(exports,"formatPx",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.x}});Object.defineProperty(exports,"getContrastingColor",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.f}});Object.defineProperty(exports,"halfPointsToPixels",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.u}});Object.defineProperty(exports,"isBlack",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.d}});Object.defineProperty(exports,"isWhite",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.e}});Object.defineProperty(exports,"lightenColor",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.k}});Object.defineProperty(exports,"parseColorString",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.g}});Object.defineProperty(exports,"pixelsToEmu",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.q}});Object.defineProperty(exports,"pixelsToTwips",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.o}});Object.defineProperty(exports,"pointsToPixels",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.t}});Object.defineProperty(exports,"resolveColor",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.a}});Object.defineProperty(exports,"resolveHighlightColor",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.b}});Object.defineProperty(exports,"resolveShadingColor",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.c}});Object.defineProperty(exports,"twipsToEmu",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.s}});Object.defineProperty(exports,"twipsToPixels",{enumerable:true,get:function(){return chunkGJ4GKSDU_cjs.n}});Object.defineProperty(exports,"detectVariables",{enumerable:true,get:function(){return chunkXZNOV52K_cjs.a}});Object.defineProperty(exports,"detectVariablesDetailed",{enumerable:true,get:function(){return chunkXZNOV52K_cjs.b}});Object.defineProperty(exports,"detectVariablesInBody",{enumerable:true,get:function(){return chunkXZNOV52K_cjs.c}});Object.defineProperty(exports,"detectVariablesInParagraph",{enumerable:true,get:function(){return chunkXZNOV52K_cjs.d}});Object.defineProperty(exports,"documentHasVariables",{enumerable:true,get:function(){return chunkXZNOV52K_cjs.m}});Object.defineProperty(exports,"extractVariablesFromText",{enumerable:true,get:function(){return chunkXZNOV52K_cjs.e}});Object.defineProperty(exports,"formatVariable",{enumerable:true,get:function(){return chunkXZNOV52K_cjs.i}});Object.defineProperty(exports,"hasTemplateVariables",{enumerable:true,get:function(){return chunkXZNOV52K_cjs.f}});Object.defineProperty(exports,"isValidVariableName",{enumerable:true,get:function(){return chunkXZNOV52K_cjs.g}});Object.defineProperty(exports,"isZodSchema",{enumerable:true,get:function(){return chunkXZNOV52K_cjs.n}});Object.defineProperty(exports,"parseVariable",{enumerable:true,get:function(){return chunkXZNOV52K_cjs.j}});Object.defineProperty(exports,"removeVariables",{enumerable:true,get:function(){return chunkXZNOV52K_cjs.l}});Object.defineProperty(exports,"replaceVariables",{enumerable:true,get:function(){return chunkXZNOV52K_cjs.k}});Object.defineProperty(exports,"sanitizeVariableName",{enumerable:true,get:function(){return chunkXZNOV52K_cjs.h}});Object.defineProperty(exports,"createDocx",{enumerable:true,get:function(){return chunk5DYSI4O4_cjs.e}});Object.defineProperty(exports,"repackDocx",{enumerable:true,get:function(){return chunk5DYSI4O4_cjs.d}});Object.defineProperty(exports,"serializeDocumentBody",{enumerable:true,get:function(){return chunk5DYSI4O4_cjs.b}});Object.defineProperty(exports,"serializeDocx",{enumerable:true,get:function(){return chunk5DYSI4O4_cjs.c}});Object.defineProperty(exports,"serializeSectionProperties",{enumerable:true,get:function(){return chunk5DYSI4O4_cjs.a}});Object.defineProperty(exports,"executeCommand",{enumerable:true,get:function(){return chunkGWBTKVFD_cjs.a}});Object.defineProperty(exports,"executeCommands",{enumerable:true,get:function(){return chunkGWBTKVFD_cjs.b}});Object.defineProperty(exports,"parseDocx",{enumerable:true,get:function(){return chunkC33XDRDJ_cjs.q}});Object.defineProperty(exports,"PluginRegistry",{enumerable:true,get:function(){return chunkWD2HTKRR_cjs.a}});Object.defineProperty(exports,"createPluginRegistrar",{enumerable:true,get:function(){return chunkWD2HTKRR_cjs.d}});Object.defineProperty(exports,"pluginRegistry",{enumerable:true,get:function(){return chunkWD2HTKRR_cjs.b}});Object.defineProperty(exports,"registerPlugins",{enumerable:true,get:function(){return chunkWD2HTKRR_cjs.c}});Object.defineProperty(exports,"createTemplateProcessor",{enumerable:true,get:function(){return chunk4QT5LPBA_cjs.j}});Object.defineProperty(exports,"getMissingVariables",{enumerable:true,get:function(){return chunk4QT5LPBA_cjs.g}});Object.defineProperty(exports,"getTemplateTags",{enumerable:true,get:function(){return chunk4QT5LPBA_cjs.e}});Object.defineProperty(exports,"previewTemplate",{enumerable:true,get:function(){return chunk4QT5LPBA_cjs.h}});Object.defineProperty(exports,"processTemplate",{enumerable:true,get:function(){return chunk4QT5LPBA_cjs.a}});Object.defineProperty(exports,"processTemplateAdvanced",{enumerable:true,get:function(){return chunk4QT5LPBA_cjs.i}});Object.defineProperty(exports,"processTemplateAsBlob",{enumerable:true,get:function(){return chunk4QT5LPBA_cjs.c}});Object.defineProperty(exports,"processTemplateDetailed",{enumerable:true,get:function(){return chunk4QT5LPBA_cjs.b}});Object.defineProperty(exports,"validateTemplate",{enumerable:true,get:function(){return chunk4QT5LPBA_cjs.f}});exports.VERSION=ot;exports.countCharacters=je;exports.countWords=f;exports.getBlockIndexForParagraph=tt;exports.getBodyCharacterCount=Ne;exports.getBodyText=Me;exports.getBodyWordCount=We;exports.getFormattingAtPosition=Je;exports.getHyperlinkAtPosition=Ge;exports.getHyperlinkText=g;exports.getParagraphAtIndex=et;exports.getParagraphText=p;exports.getParagraphs=x;exports.getRunText=c;exports.getTableText=m;exports.getTextAfter=_e;exports.getTextBefore=Ze;exports.hasHyperlinks=Ye;exports.hasImages=Xe;exports.hasTables=$e;exports.isHeadingStyle=Ke;exports.isPositionInHyperlink=Ue;exports.parseHeadingLevel=Qe;//# sourceMappingURL=headless-reexport.cjs.map
|
|
2
5
|
//# sourceMappingURL=headless-reexport.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"headless-reexport.cjs","sourcesContent":[]}
|
|
1
|
+
{"version":3,"sources":["../../core/src/agent/text-utils.ts","../../core/src/headless.ts"],"names":["getParagraphText","paragraph","texts","item","getRunText","getHyperlinkText","run","c","hyperlink","child","getTableText","table","row","cell","block","getBodyText","body","countWords","text","w","countCharacters","includeSpaces","getBodyWordCount","count","getTableWordCount","getBodyCharacterCount","getTableCharacterCount","getTextBefore","paragraphs","position","maxChars","totalChars","currentPara","beforeText","i","para","combined","getTextAfter","afterText","getFormattingAtPosition","offset","currentOffset","runEnd","linkEnd","isPositionInHyperlink","linkStart","getHyperlinkAtPosition","isHeadingStyle","styleId","parseHeadingLevel","match","hasImages","content","hasHyperlinks","hasTables","getParagraphs","getParagraphAtIndex","index","getBlockIndexForParagraph","paragraphIndex","currentParagraphIndex","VERSION"],"mappings":"mfA2BO,SAASA,CAAAA,CAAiBC,CAAAA,CAA8B,CAC7D,IAAMC,EAAkB,EAAC,CAEzB,IAAA,IAAWC,CAAAA,IAAQF,EAAU,OAAA,CACvBE,CAAAA,CAAK,IAAA,GAAS,KAAA,CAChBD,EAAM,IAAA,CAAKE,CAAAA,CAAWD,CAAI,CAAC,CAAA,CAClBA,CAAAA,CAAK,IAAA,GAAS,WAAA,EACvBD,EAAM,IAAA,CAAKG,CAAAA,CAAiBF,CAAI,CAAC,EAIrC,OAAOD,CAAAA,CAAM,IAAA,CAAK,EAAE,CACtB,CAKO,SAASE,CAAAA,CAAWE,CAAAA,CAAkB,CAC3C,OAAOA,CAAAA,CAAI,OAAA,CACR,OAAQC,CAAAA,EAAMA,CAAAA,CAAE,IAAA,GAAS,MAAM,EAC/B,GAAA,CAAKA,CAAAA,EAAOA,CAAAA,CAAqC,IAAI,EACrD,IAAA,CAAK,EAAE,CACZ,CAKO,SAASF,CAAAA,CAAiBG,CAAAA,CAA8B,CAC7D,IAAMN,EAAkB,EAAC,CACzB,IAAA,IAAWO,CAAAA,IAASD,EAAU,QAAA,CACxBC,CAAAA,CAAM,IAAA,GAAS,KAAA,EACjBP,EAAM,IAAA,CAAKE,CAAAA,CAAWK,CAAK,CAAC,CAAA,CAGhC,OAAOP,CAAAA,CAAM,IAAA,CAAK,EAAE,CACtB,CAKO,SAASQ,CAAAA,CAAaC,EAAsB,CACjD,IAAM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CAAAA,CAAoB2C,CAAAA,CAAgC,CAC5F,IAAIC,CAAAA,CAAwB,EAC5B,IAAA,IAAS1B,CAAAA,CAAI,EAAGA,CAAAA,CAAIlB,CAAAA,CAAK,QAAQ,MAAA,CAAQkB,CAAAA,EAAAA,CACvC,GAAIlB,CAAAA,CAAK,OAAA,CAAQkB,CAAC,CAAA,CAAE,IAAA,GAAS,YAAa,CACxC,GAAI0B,IAA0BD,CAAAA,CAC5B,OAAOzB,EAET0B,CAAAA,GACF,CAEF,OAAO,GACT,KCrdaC,EAAAA,CAAU","file":"headless-reexport.cjs","sourcesContent":["/**\n * Shared Text Utilities for Agent Module\n *\n * Common text extraction and manipulation utilities used by\n * context.ts, selectionContext.ts, and other agent-related code.\n *\n * Consolidates duplicated helper functions into a single location.\n */\n\nimport type {\n DocumentBody,\n Paragraph,\n Run,\n Hyperlink,\n Table,\n TextFormatting,\n} from '../types/document';\n\nimport type { Position } from '../types/agentApi';\n\n// ============================================================================\n// TEXT EXTRACTION\n// ============================================================================\n\n/**\n * Get plain text from a paragraph\n */\nexport function getParagraphText(paragraph: Paragraph): string {\n const texts: string[] = [];\n\n for (const item of paragraph.content) {\n if (item.type === 'run') {\n texts.push(getRunText(item));\n } else if (item.type === 'hyperlink') {\n texts.push(getHyperlinkText(item));\n }\n }\n\n return texts.join('');\n}\n\n/**\n * Get plain text from a run\n */\nexport function getRunText(run: Run): string {\n return run.content\n .filter((c) => c.type === 'text')\n .map((c) => (c as { type: 'text'; text: string }).text)\n .join('');\n}\n\n/**\n * Get plain text from a hyperlink\n */\nexport function getHyperlinkText(hyperlink: Hyperlink): string {\n const texts: string[] = [];\n for (const child of hyperlink.children) {\n if (child.type === 'run') {\n texts.push(getRunText(child));\n }\n }\n return texts.join('');\n}\n\n/**\n * Get plain text from a table\n */\nexport function getTableText(table: Table): string {\n const texts: string[] = [];\n\n for (const row of table.rows) {\n for (const cell of row.cells) {\n for (const block of cell.content) {\n if (block.type === 'paragraph') {\n texts.push(getParagraphText(block));\n }\n }\n }\n }\n\n return texts.join('\\t');\n}\n\n/**\n * Get plain text from document body\n */\nexport function getBodyText(body: DocumentBody): string {\n const texts: string[] = [];\n\n for (const block of body.content) {\n if (block.type === 'paragraph') {\n texts.push(getParagraphText(block));\n } else if (block.type === 'table') {\n texts.push(getTableText(block));\n }\n }\n\n return texts.join('\\n');\n}\n\n// ============================================================================\n// WORD COUNTING\n// ============================================================================\n\n/**\n * Count words in text\n */\nexport function countWords(text: string): number {\n const words = text.split(/\\s+/).filter((w) => w.length > 0);\n return words.length;\n}\n\n/**\n * Count characters in text\n */\nexport function countCharacters(text: string, includeSpaces = true): number {\n if (includeSpaces) {\n return text.length;\n }\n return text.replace(/\\s/g, '').length;\n}\n\n/**\n * Get word count from document body\n */\nexport function getBodyWordCount(body: DocumentBody): number {\n let count = 0;\n for (const block of body.content) {\n if (block.type === 'paragraph') {\n count += countWords(getParagraphText(block));\n } else if (block.type === 'table') {\n count += getTableWordCount(block);\n }\n }\n return count;\n}\n\n/**\n * Get word count from table\n */\nexport function getTableWordCount(table: Table): number {\n let count = 0;\n for (const row of table.rows) {\n for (const cell of row.cells) {\n for (const block of cell.content) {\n if (block.type === 'paragraph') {\n count += countWords(getParagraphText(block));\n }\n }\n }\n }\n return count;\n}\n\n/**\n * Get character count from document body\n */\nexport function getBodyCharacterCount(body: DocumentBody): number {\n let count = 0;\n for (const block of body.content) {\n if (block.type === 'paragraph') {\n count += getParagraphText(block).length;\n } else if (block.type === 'table') {\n count += getTableCharacterCount(block);\n }\n }\n return count;\n}\n\n/**\n * Get character count from table\n */\nexport function getTableCharacterCount(table: Table): number {\n let count = 0;\n for (const row of table.rows) {\n for (const cell of row.cells) {\n for (const block of cell.content) {\n if (block.type === 'paragraph') {\n count += getParagraphText(block).length;\n }\n }\n }\n }\n return count;\n}\n\n// ============================================================================\n// CONTEXT EXTRACTION\n// ============================================================================\n\n/**\n * Get text before a position\n *\n * @param paragraphs - Array of paragraphs\n * @param position - Position to get text before\n * @param maxChars - Maximum characters to return\n * @returns Text before the position\n */\nexport function getTextBefore(\n paragraphs: Paragraph[],\n position: Position,\n maxChars: number\n): string {\n const texts: string[] = [];\n let totalChars = 0;\n\n // Text before offset in current paragraph\n const currentPara = paragraphs[position.paragraphIndex];\n if (currentPara) {\n const text = getParagraphText(currentPara);\n const beforeText = text.slice(0, position.offset);\n texts.unshift(beforeText);\n totalChars += beforeText.length;\n }\n\n // Text from previous paragraphs\n for (let i = position.paragraphIndex - 1; i >= 0 && totalChars < maxChars; i--) {\n const para = paragraphs[i];\n if (!para) continue;\n const text = getParagraphText(para);\n texts.unshift(text);\n totalChars += text.length;\n }\n\n const combined = texts.join('\\n');\n if (combined.length > maxChars) {\n return '...' + combined.slice(-maxChars);\n }\n return combined;\n}\n\n/**\n * Get text after a position\n *\n * @param paragraphs - Array of paragraphs\n * @param position - Position to get text after\n * @param maxChars - Maximum characters to return\n * @returns Text after the position\n */\nexport function getTextAfter(\n paragraphs: Paragraph[],\n position: Position,\n maxChars: number\n): string {\n const texts: string[] = [];\n let totalChars = 0;\n\n // Text after offset in current paragraph\n const currentPara = paragraphs[position.paragraphIndex];\n if (currentPara) {\n const text = getParagraphText(currentPara);\n const afterText = text.slice(position.offset);\n texts.push(afterText);\n totalChars += afterText.length;\n }\n\n // Text from following paragraphs\n for (let i = position.paragraphIndex + 1; i < paragraphs.length && totalChars < maxChars; i++) {\n const para = paragraphs[i];\n if (!para) continue;\n const text = getParagraphText(para);\n texts.push(text);\n totalChars += text.length;\n }\n\n const combined = texts.join('\\n');\n if (combined.length > maxChars) {\n return combined.slice(0, maxChars) + '...';\n }\n return combined;\n}\n\n// ============================================================================\n// FORMATTING QUERIES\n// ============================================================================\n\n/**\n * Get formatting at a specific position in a paragraph\n *\n * @param paragraph - The paragraph to check\n * @param offset - Character offset in the paragraph\n * @returns Formatting at that position\n */\nexport function getFormattingAtPosition(\n paragraph: Paragraph,\n offset: number\n): Partial<TextFormatting> {\n let currentOffset = 0;\n\n for (const item of paragraph.content) {\n if (item.type === 'run') {\n const text = getRunText(item);\n const runEnd = currentOffset + text.length;\n\n if (offset >= currentOffset && offset < runEnd) {\n return item.formatting || {};\n }\n\n currentOffset = runEnd;\n } else if (item.type === 'hyperlink') {\n const text = getHyperlinkText(item);\n const linkEnd = currentOffset + text.length;\n\n if (offset >= currentOffset && offset < linkEnd) {\n // Return formatting from first child run\n for (const child of item.children) {\n if (child.type === 'run') {\n return child.formatting || {};\n }\n }\n }\n\n currentOffset = linkEnd;\n }\n }\n\n return {};\n}\n\n/**\n * Check if position is within a hyperlink\n *\n * @param paragraph - The paragraph to check\n * @param offset - Character offset in the paragraph\n * @returns True if position is in a hyperlink\n */\nexport function isPositionInHyperlink(paragraph: Paragraph, offset: number): boolean {\n let currentOffset = 0;\n\n for (const item of paragraph.content) {\n if (item.type === 'run') {\n const text = getRunText(item);\n currentOffset += text.length;\n } else if (item.type === 'hyperlink') {\n const text = getHyperlinkText(item);\n const linkStart = currentOffset;\n const linkEnd = currentOffset + text.length;\n\n if (offset >= linkStart && offset < linkEnd) {\n return true;\n }\n\n currentOffset = linkEnd;\n }\n }\n\n return false;\n}\n\n/**\n * Get hyperlink at position\n *\n * @param paragraph - The paragraph to check\n * @param offset - Character offset in the paragraph\n * @returns The hyperlink at that position, or undefined\n */\nexport function getHyperlinkAtPosition(\n paragraph: Paragraph,\n offset: number\n): Hyperlink | undefined {\n let currentOffset = 0;\n\n for (const item of paragraph.content) {\n if (item.type === 'run') {\n const text = getRunText(item);\n currentOffset += text.length;\n } else if (item.type === 'hyperlink') {\n const text = getHyperlinkText(item);\n const linkStart = currentOffset;\n const linkEnd = currentOffset + text.length;\n\n if (offset >= linkStart && offset < linkEnd) {\n return item;\n }\n\n currentOffset = linkEnd;\n }\n }\n\n return undefined;\n}\n\n// ============================================================================\n// STYLE HELPERS\n// ============================================================================\n\n/**\n * Check if style ID represents a heading\n *\n * @param styleId - Style ID to check\n * @returns True if it's a heading style\n */\nexport function isHeadingStyle(styleId?: string): boolean {\n if (!styleId) return false;\n return styleId.toLowerCase().includes('heading');\n}\n\n/**\n * Parse heading level from style ID\n *\n * @param styleId - Style ID to parse\n * @returns Heading level (1-9) or undefined\n */\nexport function parseHeadingLevel(styleId?: string): number | undefined {\n if (!styleId) return undefined;\n const match = styleId.match(/heading\\s*(\\d)/i);\n if (match) {\n return parseInt(match[1], 10);\n }\n return undefined;\n}\n\n// ============================================================================\n// DOCUMENT QUERIES\n// ============================================================================\n\n/**\n * Check if document body has images\n *\n * @param body - Document body to check\n * @returns True if contains images\n */\nexport function hasImages(body: DocumentBody): boolean {\n for (const block of body.content) {\n if (block.type === 'paragraph') {\n for (const item of block.content) {\n if (item.type === 'run') {\n for (const content of item.content) {\n if (content.type === 'drawing') {\n return true;\n }\n }\n }\n }\n }\n }\n return false;\n}\n\n/**\n * Check if document body has hyperlinks\n *\n * @param body - Document body to check\n * @returns True if contains hyperlinks\n */\nexport function hasHyperlinks(body: DocumentBody): boolean {\n for (const block of body.content) {\n if (block.type === 'paragraph') {\n for (const item of block.content) {\n if (item.type === 'hyperlink') {\n return true;\n }\n }\n }\n }\n return false;\n}\n\n/**\n * Check if document body has tables\n *\n * @param body - Document body to check\n * @returns True if contains tables\n */\nexport function hasTables(body: DocumentBody): boolean {\n return body.content.some((block) => block.type === 'table');\n}\n\n// ============================================================================\n// PARAGRAPH HELPERS\n// ============================================================================\n\n/**\n * Get all paragraphs from document body\n *\n * @param body - Document body\n * @returns Array of paragraphs\n */\nexport function getParagraphs(body: DocumentBody): Paragraph[] {\n return body.content.filter((block): block is Paragraph => block.type === 'paragraph');\n}\n\n/**\n * Get paragraph at index from document body\n *\n * @param body - Document body\n * @param index - Paragraph index (0-indexed)\n * @returns Paragraph or undefined\n */\nexport function getParagraphAtIndex(body: DocumentBody, index: number): Paragraph | undefined {\n const paragraphs = getParagraphs(body);\n return paragraphs[index];\n}\n\n/**\n * Get block index for a paragraph index\n *\n * @param body - Document body\n * @param paragraphIndex - Paragraph index\n * @returns Block index or -1 if not found\n */\nexport function getBlockIndexForParagraph(body: DocumentBody, paragraphIndex: number): number {\n let currentParagraphIndex = 0;\n for (let i = 0; i < body.content.length; i++) {\n if (body.content[i].type === 'paragraph') {\n if (currentParagraphIndex === paragraphIndex) {\n return i;\n }\n currentParagraphIndex++;\n }\n }\n return -1;\n}\n\n// ============================================================================\n// EXPORTS\n// ============================================================================\n\nexport default {\n getParagraphText,\n getRunText,\n getHyperlinkText,\n getTableText,\n getBodyText,\n countWords,\n countCharacters,\n getBodyWordCount,\n getBodyCharacterCount,\n getTextBefore,\n getTextAfter,\n getFormattingAtPosition,\n isPositionInHyperlink,\n getHyperlinkAtPosition,\n isHeadingStyle,\n parseHeadingLevel,\n hasImages,\n hasHyperlinks,\n hasTables,\n getParagraphs,\n getParagraphAtIndex,\n getBlockIndexForParagraph,\n};\n","/**\n * Headless API Entry Point\n *\n * Provides document manipulation functionality without React/DOM dependencies.\n * Suitable for Node.js scripts, CLI tools, and server-side processing.\n *\n * @example\n * ```ts\n * import { DocumentAgent, parseDocx, pluginRegistry } from '@eigenpal/docx-editor/headless';\n * import { docxtemplaterPlugin } from '@eigenpal/docx-editor/core-plugins';\n *\n * // Register plugins\n * pluginRegistry.register(docxtemplaterPlugin);\n *\n * // Load and manipulate document\n * const buffer = fs.readFileSync('template.docx');\n * const agent = await DocumentAgent.fromBuffer(buffer);\n *\n * // Get document info\n * console.log('Word count:', agent.getWordCount());\n * console.log('Variables:', agent.getVariables());\n *\n * // Edit document\n * const newAgent = agent\n * .insertText({ paragraphIndex: 0, offset: 0 }, 'Hello ')\n * .applyStyle(0, 'Heading1');\n *\n * // Apply template variables\n * const finalAgent = await newAgent.applyVariables({\n * customer_name: 'Jane Doe',\n * date: '2024-02-15',\n * });\n *\n * // Export\n * const output = await finalAgent.toBuffer();\n * fs.writeFileSync('output.docx', Buffer.from(output));\n * ```\n */\n\n// ============================================================================\n// VERSION\n// ============================================================================\n\nexport const VERSION = '0.0.2';\n\n// ============================================================================\n// DOCUMENT AGENT\n// ============================================================================\n\nexport { DocumentAgent, createAgent, createAgentFromDocument } from './agent/DocumentAgent';\nexport type {\n InsertTextOptions,\n InsertTableOptions,\n InsertImageOptions,\n InsertHyperlinkOptions,\n FormattedTextSegment,\n} from './agent/DocumentAgent';\n\n// ============================================================================\n// COMMAND EXECUTION\n// ============================================================================\n\nexport { executeCommand, executeCommands } from './agent/executor';\n\n// ============================================================================\n// CONTEXT BUILDERS\n// ============================================================================\n\nexport {\n getAgentContext,\n getDocumentSummary,\n buildSelectionContext as buildSelectionContextFromContext,\n type AgentContextOptions,\n type SelectionContextOptions as ContextSelectionOptions,\n} from './agent/context';\n\nexport {\n buildSelectionContext,\n buildExtendedSelectionContext,\n getSelectionFormattingSummary,\n type SelectionContextOptions,\n type ExtendedSelectionContext,\n type FormattingSummary,\n} from './agent/selectionContext';\n\n// ============================================================================\n// TEXT UTILITIES\n// ============================================================================\n\nexport {\n getParagraphText,\n getRunText,\n getHyperlinkText,\n getTableText,\n getBodyText,\n countWords,\n countCharacters,\n getBodyWordCount,\n getBodyCharacterCount,\n getTextBefore,\n getTextAfter,\n getFormattingAtPosition,\n isPositionInHyperlink,\n getHyperlinkAtPosition,\n isHeadingStyle,\n parseHeadingLevel,\n hasImages,\n hasHyperlinks,\n hasTables,\n getParagraphs,\n getParagraphAtIndex,\n getBlockIndexForParagraph,\n} from './agent/text-utils';\n\n// ============================================================================\n// PARSER / SERIALIZER\n// ============================================================================\n\nexport { parseDocx } from './docx/parser';\nexport {\n serializeDocument as serializeDocx,\n serializeDocumentBody,\n serializeSectionProperties,\n} from './docx/serializer/documentSerializer';\nexport { repackDocx, createDocx } from './docx/rezip';\n\n// ============================================================================\n// TEMPLATE PROCESSING\n// ============================================================================\n\nexport {\n processTemplate,\n processTemplateDetailed,\n processTemplateAsBlob,\n processTemplateAdvanced,\n getTemplateTags,\n validateTemplate,\n getMissingVariables,\n previewTemplate,\n createTemplateProcessor,\n type ProcessTemplateOptions,\n type ProcessTemplateResult,\n type TemplateError,\n} from './utils/processTemplate';\n\n// ============================================================================\n// VARIABLE DETECTION\n// ============================================================================\n\nexport {\n detectVariables,\n detectVariablesDetailed,\n detectVariablesInBody,\n detectVariablesInParagraph,\n extractVariablesFromText,\n hasTemplateVariables,\n isValidVariableName,\n sanitizeVariableName,\n formatVariable,\n parseVariable,\n replaceVariables,\n removeVariables,\n documentHasVariables,\n type VariableDetectionResult,\n type VariableOccurrence,\n} from './utils/variableDetector';\n\n// ============================================================================\n// DOCUMENT CREATION\n// ============================================================================\n\nexport {\n createEmptyDocument,\n createDocumentWithText,\n type CreateEmptyDocumentOptions,\n} from './utils/createDocument';\n\n// ============================================================================\n// UTILITIES\n// ============================================================================\n\nexport {\n twipsToPixels,\n pixelsToTwips,\n formatPx,\n emuToPixels,\n pointsToPixels,\n halfPointsToPixels,\n pixelsToEmu,\n emuToTwips,\n twipsToEmu,\n} from './utils/units';\n\nexport {\n resolveColor,\n resolveHighlightColor,\n resolveShadingColor,\n parseColorString,\n createThemeColor,\n createRgbColor,\n darkenColor,\n lightenColor,\n blendColors,\n getContrastingColor,\n isBlack,\n isWhite,\n colorsEqual,\n} from './utils/colorResolver';\n\n// ============================================================================\n// PLUGIN SYSTEM\n// ============================================================================\n\nexport {\n pluginRegistry,\n PluginRegistry,\n registerPlugins,\n createPluginRegistrar,\n isZodSchema,\n type CorePlugin,\n type Plugin,\n type PluginCommand,\n type CommandHandler,\n type PluginCommandHandler,\n type CommandResult,\n type PluginOptions,\n type PluginRegistrationResult,\n type McpToolDefinition,\n type ToolDefinition,\n type McpToolHandler,\n type ToolHandler,\n type McpToolResult,\n type ToolResult,\n type McpToolContent,\n type McpToolContext,\n type McpToolAnnotations,\n type McpSession,\n type LoadedDocument,\n type JsonSchema,\n type ZodSchemaLike,\n type PluginEvent,\n type PluginEventListener,\n} from './core-plugins';\n\n// ============================================================================\n// TYPES\n// ============================================================================\n\n// Document types\nexport type {\n Document,\n DocxPackage,\n DocumentBody,\n BlockContent,\n Paragraph,\n Run,\n RunContent,\n TextContent,\n Table,\n TableRow,\n TableCell,\n Image,\n Hyperlink,\n Theme,\n Style,\n StyleDefinitions,\n TextFormatting,\n ParagraphFormatting,\n SectionProperties,\n Footnote,\n Endnote,\n ListLevel,\n NumberingDefinitions,\n Relationship,\n} from './types/document';\n\n// Agent API types\nexport type {\n AIAction,\n AIActionRequest,\n AgentResponse,\n AgentContext,\n SelectionContext,\n Range,\n Position,\n ParagraphContext,\n ParagraphOutline,\n SectionInfo,\n StyleInfo,\n SuggestedAction,\n AgentCommand,\n InsertTextCommand,\n ReplaceTextCommand,\n DeleteTextCommand,\n FormatTextCommand,\n FormatParagraphCommand,\n InsertTableCommand,\n InsertImageCommand,\n InsertHyperlinkCommand,\n SetVariableCommand,\n ApplyStyleCommand,\n ApplyVariablesCommand,\n} from './types/agentApi';\n\n// API functions\nexport {\n createCollapsedRange,\n createRange,\n isPositionInRange,\n comparePositions,\n getActionLabel,\n getActionDescription,\n createCommand,\n DEFAULT_AI_ACTIONS,\n} from './types/agentApi';\n"]}
|
|
@@ -1 +1,195 @@
|
|
|
1
|
-
|
|
1
|
+
import { d as DocumentBody, a as Paragraph, T as TextFormatting, H as Hyperlink, b as Run, e as Table, P as Position } from './agentApi-BFVyKagE.cjs';
|
|
2
|
+
export { f as AIAction, g as AIActionRequest, A as AgentCommand, h as AgentContext, i as AgentResponse, j as ApplyStyleCommand, k as ApplyVariablesCommand, l as BlockContent, m as DEFAULT_AI_ACTIONS, n as DeleteTextCommand, D as Document, o as DocxPackage, E as Endnote, F as Footnote, p as FormatParagraphCommand, q as FormatTextCommand, I as Image, r as InsertHyperlinkCommand, s as InsertImageCommand, t as InsertTableCommand, u as InsertTextCommand, L as ListLevel, N as NumberingDefinitions, v as ParagraphContext, w as ParagraphFormatting, x as ParagraphOutline, R as Range, y as Relationship, z as ReplaceTextCommand, c as RunContent, S as SectionInfo, C as SectionProperties, G as SelectionContext, J as SetVariableCommand, K as Style, M as StyleDefinitions, O as StyleInfo, Q as SuggestedAction, U as TableCell, V as TableRow, W as TextContent, X as Theme, Y as comparePositions, Z as createCollapsedRange, _ as createCommand, $ as createRange, a0 as getActionDescription, a1 as getActionLabel, a2 as isPositionInRange } from './agentApi-BFVyKagE.cjs';
|
|
3
|
+
export { A as AgentContextOptions, S as ContextSelectionOptions, C as CreateEmptyDocumentOptions, E as ExtendedSelectionContext, F as FormattingSummary, P as ProcessTemplateOptions, a as ProcessTemplateResult, b as SelectionContextOptions, T as TemplateError, c as blendColors, d as buildExtendedSelectionContext, e as buildSelectionContext, f as buildSelectionContextFromContext, g as colorsEqual, h as createDocumentWithText, i as createEmptyDocument, j as createRgbColor, k as createTemplateProcessor, l as createThemeColor, m as darkenColor, n as emuToPixels, o as emuToTwips, p as executeCommand, q as executeCommands, r as formatPx, s as getAgentContext, t as getContrastingColor, u as getDocumentSummary, v as getMissingVariables, w as getSelectionFormattingSummary, x as getTemplateTags, y as halfPointsToPixels, z as isBlack, B as isWhite, D as lightenColor, G as parseColorString, H as parseDocx, I as pixelsToEmu, J as pixelsToTwips, K as pointsToPixels, L as previewTemplate, M as processTemplate, N as processTemplateAdvanced, O as processTemplateAsBlob, Q as processTemplateDetailed, R as resolveColor, U as resolveHighlightColor, V as resolveShadingColor, W as serializeDocumentBody, X as serializeDocx, Y as serializeSectionProperties, Z as twipsToEmu, _ as twipsToPixels, $ as validateTemplate } from './colorResolver-Cu46bSKr.cjs';
|
|
4
|
+
export { b as CommandHandler, d as CommandResult, C as CorePlugin, J as JsonSchema, L as LoadedDocument, e as McpSession, f as McpToolAnnotations, g as McpToolContent, h as McpToolContext, M as McpToolDefinition, i as McpToolHandler, j as McpToolResult, C as Plugin, k as PluginCommand, b as PluginCommandHandler, l as PluginEvent, c as PluginEventListener, P as PluginOptions, a as PluginRegistrationResult, M as ToolDefinition, i as ToolHandler, j as ToolResult, Z as ZodSchemaLike, m as isZodSchema } from './types-Bnp8rvJn.cjs';
|
|
5
|
+
export { D as DocumentAgent, F as FormattedTextSegment, I as InsertHyperlinkOptions, a as InsertImageOptions, b as InsertTableOptions, c as InsertTextOptions, d as createAgent, e as createAgentFromDocument } from './DocumentAgent-B0EC8lPC.cjs';
|
|
6
|
+
export { P as PluginRegistry, c as createPluginRegistrar, p as pluginRegistry, r as registerPlugins } from './registry-DjacfR6Q.cjs';
|
|
7
|
+
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-CMhJtM96.cjs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Shared Text Utilities for Agent Module
|
|
11
|
+
*
|
|
12
|
+
* Common text extraction and manipulation utilities used by
|
|
13
|
+
* context.ts, selectionContext.ts, and other agent-related code.
|
|
14
|
+
*
|
|
15
|
+
* Consolidates duplicated helper functions into a single location.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Get plain text from a paragraph
|
|
20
|
+
*/
|
|
21
|
+
declare function getParagraphText(paragraph: Paragraph): string;
|
|
22
|
+
/**
|
|
23
|
+
* Get plain text from a run
|
|
24
|
+
*/
|
|
25
|
+
declare function getRunText(run: Run): string;
|
|
26
|
+
/**
|
|
27
|
+
* Get plain text from a hyperlink
|
|
28
|
+
*/
|
|
29
|
+
declare function getHyperlinkText(hyperlink: Hyperlink): string;
|
|
30
|
+
/**
|
|
31
|
+
* Get plain text from a table
|
|
32
|
+
*/
|
|
33
|
+
declare function getTableText(table: Table): string;
|
|
34
|
+
/**
|
|
35
|
+
* Get plain text from document body
|
|
36
|
+
*/
|
|
37
|
+
declare function getBodyText(body: DocumentBody): string;
|
|
38
|
+
/**
|
|
39
|
+
* Count words in text
|
|
40
|
+
*/
|
|
41
|
+
declare function countWords(text: string): number;
|
|
42
|
+
/**
|
|
43
|
+
* Count characters in text
|
|
44
|
+
*/
|
|
45
|
+
declare function countCharacters(text: string, includeSpaces?: boolean): number;
|
|
46
|
+
/**
|
|
47
|
+
* Get word count from document body
|
|
48
|
+
*/
|
|
49
|
+
declare function getBodyWordCount(body: DocumentBody): number;
|
|
50
|
+
/**
|
|
51
|
+
* Get character count from document body
|
|
52
|
+
*/
|
|
53
|
+
declare function getBodyCharacterCount(body: DocumentBody): number;
|
|
54
|
+
/**
|
|
55
|
+
* Get text before a position
|
|
56
|
+
*
|
|
57
|
+
* @param paragraphs - Array of paragraphs
|
|
58
|
+
* @param position - Position to get text before
|
|
59
|
+
* @param maxChars - Maximum characters to return
|
|
60
|
+
* @returns Text before the position
|
|
61
|
+
*/
|
|
62
|
+
declare function getTextBefore(paragraphs: Paragraph[], position: Position, maxChars: number): string;
|
|
63
|
+
/**
|
|
64
|
+
* Get text after a position
|
|
65
|
+
*
|
|
66
|
+
* @param paragraphs - Array of paragraphs
|
|
67
|
+
* @param position - Position to get text after
|
|
68
|
+
* @param maxChars - Maximum characters to return
|
|
69
|
+
* @returns Text after the position
|
|
70
|
+
*/
|
|
71
|
+
declare function getTextAfter(paragraphs: Paragraph[], position: Position, maxChars: number): string;
|
|
72
|
+
/**
|
|
73
|
+
* Get formatting at a specific position in a paragraph
|
|
74
|
+
*
|
|
75
|
+
* @param paragraph - The paragraph to check
|
|
76
|
+
* @param offset - Character offset in the paragraph
|
|
77
|
+
* @returns Formatting at that position
|
|
78
|
+
*/
|
|
79
|
+
declare function getFormattingAtPosition(paragraph: Paragraph, offset: number): Partial<TextFormatting>;
|
|
80
|
+
/**
|
|
81
|
+
* Check if position is within a hyperlink
|
|
82
|
+
*
|
|
83
|
+
* @param paragraph - The paragraph to check
|
|
84
|
+
* @param offset - Character offset in the paragraph
|
|
85
|
+
* @returns True if position is in a hyperlink
|
|
86
|
+
*/
|
|
87
|
+
declare function isPositionInHyperlink(paragraph: Paragraph, offset: number): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Get hyperlink at position
|
|
90
|
+
*
|
|
91
|
+
* @param paragraph - The paragraph to check
|
|
92
|
+
* @param offset - Character offset in the paragraph
|
|
93
|
+
* @returns The hyperlink at that position, or undefined
|
|
94
|
+
*/
|
|
95
|
+
declare function getHyperlinkAtPosition(paragraph: Paragraph, offset: number): Hyperlink | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Check if style ID represents a heading
|
|
98
|
+
*
|
|
99
|
+
* @param styleId - Style ID to check
|
|
100
|
+
* @returns True if it's a heading style
|
|
101
|
+
*/
|
|
102
|
+
declare function isHeadingStyle(styleId?: string): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Parse heading level from style ID
|
|
105
|
+
*
|
|
106
|
+
* @param styleId - Style ID to parse
|
|
107
|
+
* @returns Heading level (1-9) or undefined
|
|
108
|
+
*/
|
|
109
|
+
declare function parseHeadingLevel(styleId?: string): number | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Check if document body has images
|
|
112
|
+
*
|
|
113
|
+
* @param body - Document body to check
|
|
114
|
+
* @returns True if contains images
|
|
115
|
+
*/
|
|
116
|
+
declare function hasImages(body: DocumentBody): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Check if document body has hyperlinks
|
|
119
|
+
*
|
|
120
|
+
* @param body - Document body to check
|
|
121
|
+
* @returns True if contains hyperlinks
|
|
122
|
+
*/
|
|
123
|
+
declare function hasHyperlinks(body: DocumentBody): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Check if document body has tables
|
|
126
|
+
*
|
|
127
|
+
* @param body - Document body to check
|
|
128
|
+
* @returns True if contains tables
|
|
129
|
+
*/
|
|
130
|
+
declare function hasTables(body: DocumentBody): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Get all paragraphs from document body
|
|
133
|
+
*
|
|
134
|
+
* @param body - Document body
|
|
135
|
+
* @returns Array of paragraphs
|
|
136
|
+
*/
|
|
137
|
+
declare function getParagraphs(body: DocumentBody): Paragraph[];
|
|
138
|
+
/**
|
|
139
|
+
* Get paragraph at index from document body
|
|
140
|
+
*
|
|
141
|
+
* @param body - Document body
|
|
142
|
+
* @param index - Paragraph index (0-indexed)
|
|
143
|
+
* @returns Paragraph or undefined
|
|
144
|
+
*/
|
|
145
|
+
declare function getParagraphAtIndex(body: DocumentBody, index: number): Paragraph | undefined;
|
|
146
|
+
/**
|
|
147
|
+
* Get block index for a paragraph index
|
|
148
|
+
*
|
|
149
|
+
* @param body - Document body
|
|
150
|
+
* @param paragraphIndex - Paragraph index
|
|
151
|
+
* @returns Block index or -1 if not found
|
|
152
|
+
*/
|
|
153
|
+
declare function getBlockIndexForParagraph(body: DocumentBody, paragraphIndex: number): number;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Headless API Entry Point
|
|
157
|
+
*
|
|
158
|
+
* Provides document manipulation functionality without React/DOM dependencies.
|
|
159
|
+
* Suitable for Node.js scripts, CLI tools, and server-side processing.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* import { DocumentAgent, parseDocx, pluginRegistry } from '@eigenpal/docx-editor/headless';
|
|
164
|
+
* import { docxtemplaterPlugin } from '@eigenpal/docx-editor/core-plugins';
|
|
165
|
+
*
|
|
166
|
+
* // Register plugins
|
|
167
|
+
* pluginRegistry.register(docxtemplaterPlugin);
|
|
168
|
+
*
|
|
169
|
+
* // Load and manipulate document
|
|
170
|
+
* const buffer = fs.readFileSync('template.docx');
|
|
171
|
+
* const agent = await DocumentAgent.fromBuffer(buffer);
|
|
172
|
+
*
|
|
173
|
+
* // Get document info
|
|
174
|
+
* console.log('Word count:', agent.getWordCount());
|
|
175
|
+
* console.log('Variables:', agent.getVariables());
|
|
176
|
+
*
|
|
177
|
+
* // Edit document
|
|
178
|
+
* const newAgent = agent
|
|
179
|
+
* .insertText({ paragraphIndex: 0, offset: 0 }, 'Hello ')
|
|
180
|
+
* .applyStyle(0, 'Heading1');
|
|
181
|
+
*
|
|
182
|
+
* // Apply template variables
|
|
183
|
+
* const finalAgent = await newAgent.applyVariables({
|
|
184
|
+
* customer_name: 'Jane Doe',
|
|
185
|
+
* date: '2024-02-15',
|
|
186
|
+
* });
|
|
187
|
+
*
|
|
188
|
+
* // Export
|
|
189
|
+
* const output = await finalAgent.toBuffer();
|
|
190
|
+
* fs.writeFileSync('output.docx', Buffer.from(output));
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
declare const VERSION = "0.0.2";
|
|
194
|
+
|
|
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 };
|