@betteroffice/docx 0.0.1
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/LICENSE +201 -0
- package/README.md +41 -0
- package/dist/Subscribable-DOz6Ohoo.d.mts +33 -0
- package/dist/agent/index.d.mts +531 -0
- package/dist/agent/index.mjs +1 -0
- package/dist/chunk-34K66SY4.mjs +1 -0
- package/dist/chunk-3UBMCDME.mjs +1 -0
- package/dist/chunk-4RCISPPE.mjs +1 -0
- package/dist/chunk-4UD54UM5.mjs +1 -0
- package/dist/chunk-52GB3Y42.mjs +1 -0
- package/dist/chunk-6NEKRDXF.mjs +1 -0
- package/dist/chunk-6PW4CWUG.mjs +1 -0
- package/dist/chunk-7DEIW7FL.mjs +1 -0
- package/dist/chunk-7PCO5I2O.mjs +1 -0
- package/dist/chunk-BI3B33LI.mjs +1 -0
- package/dist/chunk-BIQWVK5P.mjs +2 -0
- package/dist/chunk-CIRN3LZA.mjs +1 -0
- package/dist/chunk-DXKG3HQ5.mjs +16 -0
- package/dist/chunk-EUUIJVM6.mjs +0 -0
- package/dist/chunk-FPZBTOD6.mjs +1 -0
- package/dist/chunk-FZIA7OFY.mjs +1 -0
- package/dist/chunk-GWKJ2Y4Y.mjs +1 -0
- package/dist/chunk-H3JCIGWK.mjs +1 -0
- package/dist/chunk-HJGAQIU7.mjs +2 -0
- package/dist/chunk-I6KKMUUC.mjs +1 -0
- package/dist/chunk-IL5JZJT7.mjs +1 -0
- package/dist/chunk-JY6ILTNS.mjs +1 -0
- package/dist/chunk-KEE52TT5.mjs +1 -0
- package/dist/chunk-KVKLLTDP.mjs +58 -0
- package/dist/chunk-KXNZFTTK.mjs +1 -0
- package/dist/chunk-L5ISVQ3W.mjs +1 -0
- package/dist/chunk-LDUWIM7M.mjs +1 -0
- package/dist/chunk-N5Q3YN64.mjs +1 -0
- package/dist/chunk-NEWOMDTX.mjs +1 -0
- package/dist/chunk-O2QSE2I7.mjs +1 -0
- package/dist/chunk-OBQGPMPQ.mjs +1 -0
- package/dist/chunk-OJOHXQNQ.mjs +1 -0
- package/dist/chunk-OMR3TWCD.mjs +2 -0
- package/dist/chunk-P3KDV4M2.mjs +1 -0
- package/dist/chunk-Q7PO7V73.mjs +1 -0
- package/dist/chunk-QOUFE3VX.mjs +1 -0
- package/dist/chunk-SINEY6ZF.mjs +1 -0
- package/dist/chunk-T4EZMUXM.mjs +1 -0
- package/dist/chunk-TTRUPDAB.mjs +1 -0
- package/dist/chunk-TYHI7RAD.mjs +1 -0
- package/dist/chunk-UIEJWORW.mjs +1 -0
- package/dist/chunk-VAOUFAUH.mjs +1 -0
- package/dist/chunk-VBOTMRXV.mjs +1 -0
- package/dist/chunk-VCER63GQ.mjs +1 -0
- package/dist/chunk-WAUF2UC7.mjs +2 -0
- package/dist/chunk-WRWRCBLK.mjs +1 -0
- package/dist/chunk-X4XDO3LZ.mjs +1 -0
- package/dist/chunk-XQBCCJBO.mjs +9 -0
- package/dist/chunk-XWUOLYRQ.mjs +2 -0
- package/dist/chunk-XYH6XWP3.mjs +10 -0
- package/dist/chunk-YBIM6UJV.mjs +8 -0
- package/dist/chunk-YCIH2Q3E.mjs +1 -0
- package/dist/chunk-YUOKI2HB.mjs +1 -0
- package/dist/chunk-ZOV5KL7C.mjs +1 -0
- package/dist/colorResolver-n0o7H7ep.d.mts +290 -0
- package/dist/content-sSHuWw49.d.mts +2202 -0
- package/dist/core-plugins.d.mts +37 -0
- package/dist/core-plugins.mjs +1 -0
- package/dist/core.d.mts +451 -0
- package/dist/core.mjs +1 -0
- package/dist/displayListQueries-p-ijSzdh.d.mts +222 -0
- package/dist/docx/index.d.mts +618 -0
- package/dist/docx/index.mjs +2 -0
- package/dist/docx/parser.d.mts +41 -0
- package/dist/docx/parser.mjs +1 -0
- package/dist/docx/rezip.d.mts +148 -0
- package/dist/docx/rezip.mjs +1 -0
- package/dist/docx/serializer/index.d.mts +42 -0
- package/dist/docx/serializer/index.mjs +1 -0
- package/dist/docx/wrapTypes.d.mts +19 -0
- package/dist/docx/wrapTypes.mjs +1 -0
- package/dist/docxInput-DTbCa48g.d.mts +21 -0
- package/dist/editor/index.d.mts +170 -0
- package/dist/editor/index.mjs +1 -0
- package/dist/editorTree-DO5PyDK8.d.mts +37 -0
- package/dist/executor-7O2RBJ2B.mjs +1 -0
- package/dist/fontLoader-Bx6DK6-2.d.mts +327 -0
- package/dist/formatting-DoL7KBSL.d.mts +823 -0
- package/dist/generated/edit/docx_edit_bg.wasm +0 -0
- package/dist/generated/layout/docx_layout_bg.wasm +0 -0
- package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
- package/dist/generated/parse/docx_parse_bg.wasm +0 -0
- package/dist/headerFooterLayout-0zPT64Qc.d.mts +316 -0
- package/dist/headless.d.mts +69 -0
- package/dist/headless.mjs +1 -0
- package/dist/layout/flow/index.d.mts +149 -0
- package/dist/layout/flow/index.mjs +1 -0
- package/dist/layout/index.d.mts +307 -0
- package/dist/layout/index.mjs +1 -0
- package/dist/layout/measure/index.d.mts +324 -0
- package/dist/layout/measure/index.mjs +1 -0
- package/dist/layout/pagination/index.d.mts +60 -0
- package/dist/layout/pagination/index.mjs +1 -0
- package/dist/layout/pagination/types.d.mts +4 -0
- package/dist/layout/pagination/types.mjs +1 -0
- package/dist/layout/render/index.d.mts +733 -0
- package/dist/layout/render/index.mjs +1 -0
- package/dist/loadWasmAsset-CMvnVkfA.d.mts +3 -0
- package/dist/managers/AutoSaveManager.d.mts +81 -0
- package/dist/managers/AutoSaveManager.mjs +1 -0
- package/dist/managers/TableSelectionManager.d.mts +74 -0
- package/dist/managers/TableSelectionManager.mjs +1 -0
- package/dist/managers/types.d.mts +113 -0
- package/dist/managers/types.mjs +0 -0
- package/dist/mcp-cli.mjs +142 -0
- package/dist/mcp.d.mts +162 -0
- package/dist/mcp.mjs +16 -0
- package/dist/measureBlocksPipeline-Df0Bbrwy.d.mts +109 -0
- package/dist/measuredBlock-DZwz8zhD.d.mts +26 -0
- package/dist/plugin-api/RenderedDomContext.d.mts +114 -0
- package/dist/plugin-api/RenderedDomContext.mjs +1 -0
- package/dist/plugin-api/index.d.mts +7 -0
- package/dist/plugin-api/index.mjs +0 -0
- package/dist/plugin-api/resolveItemPositions.d.mts +39 -0
- package/dist/plugin-api/resolveItemPositions.mjs +1 -0
- package/dist/plugin-api/types.d.mts +193 -0
- package/dist/plugin-api/types.mjs +0 -0
- package/dist/processTemplate-HDUIZFJ5.mjs +1 -0
- package/dist/registry-DMM5VTdT.d.mts +165 -0
- package/dist/rustDisplayList-dqunvwxH.d.mts +1036 -0
- package/dist/rustPagination-Bj2hq013.d.mts +106 -0
- package/dist/sectionConfigs-DW3J8q0X.d.mts +55 -0
- package/dist/selectionContext-Buc9BCU1.d.mts +570 -0
- package/dist/selectiveSave-oFBJ1n71.d.mts +16 -0
- package/dist/selectiveXmlPatch-ypkxlTD_.d.mts +23 -0
- package/dist/settingsParser-CcGvtmCK.d.mts +33 -0
- package/dist/styles/index.d.mts +162 -0
- package/dist/styles/index.mjs +1 -0
- package/dist/styles-VxNcXLdi.d.mts +189 -0
- package/dist/types/agentApi.d.mts +456 -0
- package/dist/types/agentApi.mjs +1 -0
- package/dist/types/content.d.mts +3 -0
- package/dist/types/content.mjs +1 -0
- package/dist/types/document.d.mts +117 -0
- package/dist/types/document.mjs +1 -0
- package/dist/types-DNrYr6yQ.d.mts +1754 -0
- package/dist/types-dYdjUZMo.d.mts +311 -0
- package/dist/units-O5Y02RKQ.d.mts +34 -0
- package/dist/utils/autoScroll.d.mts +24 -0
- package/dist/utils/autoScroll.mjs +1 -0
- package/dist/utils/cardStyles.d.mts +22 -0
- package/dist/utils/cardStyles.mjs +1 -0
- package/dist/utils/comments.d.mts +120 -0
- package/dist/utils/comments.mjs +4 -0
- package/dist/utils/findReplace.d.mts +114 -0
- package/dist/utils/findReplace.mjs +2 -0
- package/dist/utils/findVerticalScrollParent.d.mts +25 -0
- package/dist/utils/findVerticalScrollParent.mjs +1 -0
- package/dist/utils/fontOptions.d.mts +21 -0
- package/dist/utils/fontOptions.mjs +1 -0
- package/dist/utils/headingCollector.d.mts +28 -0
- package/dist/utils/headingCollector.mjs +1 -0
- package/dist/utils/highlightColors.d.mts +14 -0
- package/dist/utils/highlightColors.mjs +1 -0
- package/dist/utils/index.d.mts +956 -0
- package/dist/utils/index.mjs +84 -0
- package/dist/utils/listState.d.mts +27 -0
- package/dist/utils/listState.mjs +1 -0
- package/dist/utils/reportIssue.d.mts +23 -0
- package/dist/utils/reportIssue.mjs +2 -0
- package/dist/utils/sidebarConstants.d.mts +10 -0
- package/dist/utils/sidebarConstants.mjs +1 -0
- package/dist/utils/stylePreview.d.mts +70 -0
- package/dist/utils/stylePreview.mjs +1 -0
- package/dist/utils/textSelection.d.mts +92 -0
- package/dist/utils/textSelection.mjs +1 -0
- package/dist/utils/units.d.mts +78 -0
- package/dist/utils/units.mjs +1 -0
- package/dist/variableDetector-Borj29SF.d.mts +115 -0
- package/dist/wasm-FZQ5XB2Y.mjs +1 -0
- package/dist/wasm-SA237OSP.mjs +1 -0
- package/dist/wasm-edit.d.mts +473 -0
- package/dist/wasm-edit.mjs +1 -0
- package/dist/wasm-layout.d.mts +112 -0
- package/dist/wasm-layout.mjs +1 -0
- package/dist/wasm-opc.d.mts +16 -0
- package/dist/wasm-opc.mjs +1 -0
- package/dist/wasm-parse.d.mts +18 -0
- package/dist/wasm-parse.mjs +1 -0
- package/dist/watermarkApi-DCxjutkg.d.mts +38 -0
- package/dist/yrs/index.d.mts +882 -0
- package/dist/yrs/index.mjs +1 -0
- package/dist/yrs/residentEngineWorker.d.mts +2 -0
- package/dist/yrs/residentEngineWorker.mjs +1 -0
- package/package.json +365 -0
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
export { A as AgentContextOptions, S as ContextSelectionOptions, D as DocumentAgent, E as ExtendedSelectionContext, F as FormattedTextSegment, a as FormattingSummary, I as InsertHyperlinkOptions, b as InsertImageOptions, c as InsertTableOptions, d as InsertTextOptions, e as SelectionContextOptions, f as buildExtendedSelectionContext, g as buildSelectionContext, h as buildSelectionContextFromContext, i as createAgent, j as createAgentFromDocument, k as executeCommand, l as executeCommands, m as getAgentContext, n as getDocumentSummary, o as getSelectionFormattingSummary } from '../selectionContext-Buc9BCU1.mjs';
|
|
2
|
+
import { c as DocumentBody, P as Paragraph, H as Hyperlink, R as Run, T as Table, aQ as SdtType, aP as SdtProperties, aM as SdtDataBinding, p as BlockSdt, am as InlineSdt, B as BlockContent } from '../content-sSHuWw49.mjs';
|
|
3
|
+
import { T as TextFormatting } from '../formatting-DoL7KBSL.mjs';
|
|
4
|
+
import { Position } from '../types/agentApi.mjs';
|
|
5
|
+
export { AIAction, AIActionRequest, AgentCommand, AgentContext, AgentResponse, SelectionContext as AgentSelectionContext, ApplyStyleCommand, ApplyVariablesCommand, DEFAULT_AI_ACTIONS, DeleteTextCommand, FormatParagraphCommand, FormatTextCommand, InsertHyperlinkCommand, InsertImageCommand, InsertParagraphBreakCommand, InsertTableCommand, InsertTextCommand, MergeParagraphsCommand, ParagraphContext, ParagraphOutline, Range, RemoveHyperlinkCommand, ReplaceTextCommand, SectionInfo, SetVariableCommand, SplitParagraphCommand, StyleInfo, SuggestedAction, comparePositions, createCollapsedRange, createCommand, createRange, getActionDescription, getActionLabel, isPositionInRange } from '../types/agentApi.mjs';
|
|
6
|
+
import { Document } from '../types/document.mjs';
|
|
7
|
+
import '../selectiveSave-oFBJ1n71.mjs';
|
|
8
|
+
import '../docxInput-DTbCa48g.mjs';
|
|
9
|
+
import '../docx/wrapTypes.mjs';
|
|
10
|
+
import '../styles-VxNcXLdi.mjs';
|
|
11
|
+
import '../settingsParser-CcGvtmCK.mjs';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Shared Text Utilities for Agent Module
|
|
15
|
+
*
|
|
16
|
+
* Common text extraction and manipulation utilities used by
|
|
17
|
+
* context.ts, selectionContext.ts, and other agent-related code.
|
|
18
|
+
*
|
|
19
|
+
* Consolidates duplicated helper functions into a single location.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Get plain text from a paragraph
|
|
24
|
+
*/
|
|
25
|
+
declare function getParagraphText(paragraph: Paragraph): string;
|
|
26
|
+
/**
|
|
27
|
+
* Get plain text from a run
|
|
28
|
+
*/
|
|
29
|
+
declare function getRunText(run: Run): string;
|
|
30
|
+
/**
|
|
31
|
+
* Get plain text from a hyperlink
|
|
32
|
+
*/
|
|
33
|
+
declare function getHyperlinkText(hyperlink: Hyperlink): string;
|
|
34
|
+
/**
|
|
35
|
+
* Get plain text from a table
|
|
36
|
+
*/
|
|
37
|
+
declare function getTableText(table: Table): string;
|
|
38
|
+
/**
|
|
39
|
+
* Get plain text from document body
|
|
40
|
+
*/
|
|
41
|
+
declare function getBodyText(body: DocumentBody): string;
|
|
42
|
+
/**
|
|
43
|
+
* Count words in text
|
|
44
|
+
*/
|
|
45
|
+
declare function countWords(text: string): number;
|
|
46
|
+
/**
|
|
47
|
+
* Count characters in text
|
|
48
|
+
*/
|
|
49
|
+
declare function countCharacters(text: string, includeSpaces?: boolean): number;
|
|
50
|
+
/**
|
|
51
|
+
* Get word count from document body
|
|
52
|
+
*/
|
|
53
|
+
declare function getBodyWordCount(body: DocumentBody): number;
|
|
54
|
+
/**
|
|
55
|
+
* Get character count from document body
|
|
56
|
+
*/
|
|
57
|
+
declare function getBodyCharacterCount(body: DocumentBody): number;
|
|
58
|
+
/**
|
|
59
|
+
* Get text before a position
|
|
60
|
+
*
|
|
61
|
+
* @param paragraphs - Array of paragraphs
|
|
62
|
+
* @param position - Position to get text before
|
|
63
|
+
* @param maxChars - Maximum characters to return
|
|
64
|
+
* @returns Text before the position
|
|
65
|
+
*/
|
|
66
|
+
declare function getTextBefore(paragraphs: Paragraph[], position: Position, maxChars: number): string;
|
|
67
|
+
/**
|
|
68
|
+
* Get text after a position
|
|
69
|
+
*
|
|
70
|
+
* @param paragraphs - Array of paragraphs
|
|
71
|
+
* @param position - Position to get text after
|
|
72
|
+
* @param maxChars - Maximum characters to return
|
|
73
|
+
* @returns Text after the position
|
|
74
|
+
*/
|
|
75
|
+
declare function getTextAfter(paragraphs: Paragraph[], position: Position, maxChars: number): string;
|
|
76
|
+
/**
|
|
77
|
+
* Get formatting at a specific position in a paragraph
|
|
78
|
+
*
|
|
79
|
+
* @param paragraph - The paragraph to check
|
|
80
|
+
* @param offset - Character offset in the paragraph
|
|
81
|
+
* @returns Formatting at that position
|
|
82
|
+
*/
|
|
83
|
+
declare function getFormattingAtPosition(paragraph: Paragraph, offset: number): Partial<TextFormatting>;
|
|
84
|
+
/**
|
|
85
|
+
* Check if position is within a hyperlink
|
|
86
|
+
*
|
|
87
|
+
* @param paragraph - The paragraph to check
|
|
88
|
+
* @param offset - Character offset in the paragraph
|
|
89
|
+
* @returns True if position is in a hyperlink
|
|
90
|
+
*/
|
|
91
|
+
declare function isPositionInHyperlink(paragraph: Paragraph, offset: number): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Get hyperlink at position
|
|
94
|
+
*
|
|
95
|
+
* @param paragraph - The paragraph to check
|
|
96
|
+
* @param offset - Character offset in the paragraph
|
|
97
|
+
* @returns The hyperlink at that position, or undefined
|
|
98
|
+
*/
|
|
99
|
+
declare function getHyperlinkAtPosition(paragraph: Paragraph, offset: number): Hyperlink | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Check if style ID represents a heading
|
|
102
|
+
*
|
|
103
|
+
* @param styleId - Style ID to check
|
|
104
|
+
* @returns True if it's a heading style
|
|
105
|
+
*/
|
|
106
|
+
declare function isHeadingStyle(styleId?: string): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Parse heading level from style ID
|
|
109
|
+
*
|
|
110
|
+
* @param styleId - Style ID to parse
|
|
111
|
+
* @returns Heading level (1-9) or undefined
|
|
112
|
+
*/
|
|
113
|
+
declare function parseHeadingLevel(styleId?: string): number | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Check if document body has images
|
|
116
|
+
*
|
|
117
|
+
* @param body - Document body to check
|
|
118
|
+
* @returns True if contains images
|
|
119
|
+
*/
|
|
120
|
+
declare function hasImages(body: DocumentBody): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Check if document body has hyperlinks
|
|
123
|
+
*
|
|
124
|
+
* @param body - Document body to check
|
|
125
|
+
* @returns True if contains hyperlinks
|
|
126
|
+
*/
|
|
127
|
+
declare function hasHyperlinks(body: DocumentBody): boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Check if document body has tables
|
|
130
|
+
*
|
|
131
|
+
* @param body - Document body to check
|
|
132
|
+
* @returns True if contains tables
|
|
133
|
+
*/
|
|
134
|
+
declare function hasTables(body: DocumentBody): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Get all paragraphs from document body
|
|
137
|
+
*
|
|
138
|
+
* @param body - Document body
|
|
139
|
+
* @returns Array of paragraphs
|
|
140
|
+
*/
|
|
141
|
+
declare function getParagraphs(body: DocumentBody): Paragraph[];
|
|
142
|
+
/**
|
|
143
|
+
* Get paragraph at index from document body
|
|
144
|
+
*
|
|
145
|
+
* @param body - Document body
|
|
146
|
+
* @param index - Paragraph index (0-indexed)
|
|
147
|
+
* @returns Paragraph or undefined
|
|
148
|
+
*/
|
|
149
|
+
declare function getParagraphAtIndex(body: DocumentBody, index: number): Paragraph | undefined;
|
|
150
|
+
/**
|
|
151
|
+
* Get block index for a paragraph index
|
|
152
|
+
*
|
|
153
|
+
* @param body - Document body
|
|
154
|
+
* @param paragraphIndex - Paragraph index
|
|
155
|
+
* @returns Block index or -1 if not found
|
|
156
|
+
*/
|
|
157
|
+
declare function getBlockIndexForParagraph(body: DocumentBody, paragraphIndex: number): number;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Content-control (SDT) addressing for the document model.
|
|
161
|
+
*
|
|
162
|
+
* Content controls (`w:sdt`) are the natural anchor for template logic and
|
|
163
|
+
* agent edits: they survive the round trip (see the parser + serializer) and
|
|
164
|
+
* carry a stable `tag`/`alias`/`id`. This module discovers and edits them
|
|
165
|
+
* without a DOM or an editor instance, so server-side pipelines and AI agents
|
|
166
|
+
* can find an anchor by tag and act on it.
|
|
167
|
+
*
|
|
168
|
+
* Both **block-level** (`w:sdt` wrapping paragraphs/tables) and **inline**
|
|
169
|
+
* (`w:sdt` inside a paragraph) controls are addressed, including inline
|
|
170
|
+
* controls inside table cells (and nested tables). With
|
|
171
|
+
* `{ includeHeadersFooters: true }` the walk also covers header/footer parts.
|
|
172
|
+
*
|
|
173
|
+
* Not surfaced (model limitations): a block SDT placed directly inside a table
|
|
174
|
+
* cell (`TableCell.content` cannot hold one), an inline SDT inside a hyperlink
|
|
175
|
+
* (`Hyperlink.children` excludes it), and controls inside tracked-change
|
|
176
|
+
* wrappers.
|
|
177
|
+
*/
|
|
178
|
+
|
|
179
|
+
/** Filter for {@link findContentControls}. All provided fields must match (AND). */
|
|
180
|
+
interface ContentControlFilter {
|
|
181
|
+
/** Developer identifier (`w:tag`), exact match. */
|
|
182
|
+
tag?: string;
|
|
183
|
+
/** Friendly name (`w:alias`), exact match. */
|
|
184
|
+
alias?: string;
|
|
185
|
+
/** Numeric id (`w:id`), exact match. */
|
|
186
|
+
id?: number;
|
|
187
|
+
/** Control type projection (`richText`, `dropDownList`, …). */
|
|
188
|
+
type?: SdtType;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Where a control lives. `body` = the main document story; `header`/`footer`
|
|
192
|
+
* = a page-furniture part addressed by its relationship id (the key into
|
|
193
|
+
* `package.headers`/`package.footers`).
|
|
194
|
+
*/
|
|
195
|
+
type ContentControlLocation = {
|
|
196
|
+
part: 'body';
|
|
197
|
+
} | {
|
|
198
|
+
part: 'header' | 'footer';
|
|
199
|
+
rId: string;
|
|
200
|
+
};
|
|
201
|
+
/** A discovered content control plus enough context to address and edit it. */
|
|
202
|
+
interface ContentControlInfo {
|
|
203
|
+
/** Developer identifier (`w:tag`). */
|
|
204
|
+
tag?: string;
|
|
205
|
+
/** Friendly name (`w:alias`). */
|
|
206
|
+
alias?: string;
|
|
207
|
+
/** Numeric id (`w:id`). */
|
|
208
|
+
id?: number;
|
|
209
|
+
/** Control type projection. */
|
|
210
|
+
sdtType: SdtType;
|
|
211
|
+
/** Lock setting, if any. A locked control should refuse content edits. */
|
|
212
|
+
lock?: SdtProperties['lock'];
|
|
213
|
+
/** Dropdown/combobox list items, if modeled. */
|
|
214
|
+
listItems?: {
|
|
215
|
+
displayText: string;
|
|
216
|
+
value: string;
|
|
217
|
+
}[];
|
|
218
|
+
/** Placeholder docPart reference, if any. */
|
|
219
|
+
placeholder?: string;
|
|
220
|
+
/** Whether the control is currently showing placeholder text (`w:showingPlcHdr`). */
|
|
221
|
+
showingPlaceholder?: boolean;
|
|
222
|
+
/** Checkbox state, for checkbox controls. */
|
|
223
|
+
checked?: boolean;
|
|
224
|
+
/** Date format string, for date controls. */
|
|
225
|
+
dateFormat?: string;
|
|
226
|
+
/** XML data binding (`w:dataBinding`), if the control is bound. */
|
|
227
|
+
dataBinding?: SdtDataBinding;
|
|
228
|
+
/** Plain text of the control's content (paragraphs/tables/nested controls flattened). */
|
|
229
|
+
text: string;
|
|
230
|
+
/**
|
|
231
|
+
* Block-index path to this control: top-level `[i]`, a control nested in the
|
|
232
|
+
* i-th block's content `[i, j]`, and so on. For inline / cell controls it is
|
|
233
|
+
* the block indices of the nearest enclosing blocks.
|
|
234
|
+
*/
|
|
235
|
+
path: number[];
|
|
236
|
+
/** Nesting depth = number of enclosing content controls (0 = not inside another control). */
|
|
237
|
+
depth: number;
|
|
238
|
+
/** Block-level (`w:sdt` at block level) or inline (`w:sdt` inside a paragraph). */
|
|
239
|
+
kind: 'block' | 'inline';
|
|
240
|
+
/** Where the control lives (body vs a header/footer part). */
|
|
241
|
+
location: ContentControlLocation;
|
|
242
|
+
}
|
|
243
|
+
/** Plain text of a control's content, descending into tables and nested SDTs. */
|
|
244
|
+
declare function getContentControlText(control: BlockSdt | InlineSdt): string;
|
|
245
|
+
/** Options for {@link findContentControls}. */
|
|
246
|
+
interface FindContentControlsOptions {
|
|
247
|
+
/**
|
|
248
|
+
* When `true`, also search header/footer parts — but only when a full
|
|
249
|
+
* {@link Document} is passed (a bare `DocumentBody` carries no parts, so this
|
|
250
|
+
* then searches the body only and never throws). Defaults to `false` (the main
|
|
251
|
+
* document story only).
|
|
252
|
+
*/
|
|
253
|
+
includeHeadersFooters?: boolean;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Find every content control in the document — block-level AND inline —
|
|
257
|
+
* optionally filtered by tag/alias/id/type. Results are in strict document
|
|
258
|
+
* order; nested controls follow their parent.
|
|
259
|
+
*
|
|
260
|
+
* The walk descends body blocks, block SDTs, tables (row-major, including
|
|
261
|
+
* nested tables) into cell content, and paragraph inline content (inline
|
|
262
|
+
* SDTs, recursing into nested inline SDTs). With `{ includeHeadersFooters: true }`
|
|
263
|
+
* and a full {@link Document}, header then footer parts are searched after the
|
|
264
|
+
* body, each sorted by relationship id for deterministic order.
|
|
265
|
+
*
|
|
266
|
+
* Not surfaced (model limitations, documented): a block SDT placed directly
|
|
267
|
+
* inside a table cell (`TableCell.content` is `(Paragraph | Table)[]`), an
|
|
268
|
+
* inline SDT inside a hyperlink (`Hyperlink.children` excludes it), and
|
|
269
|
+
* controls buried inside tracked-change wrappers.
|
|
270
|
+
*/
|
|
271
|
+
declare function findContentControls(input: Document | DocumentBody, filter?: ContentControlFilter, options?: FindContentControlsOptions): ContentControlInfo[];
|
|
272
|
+
/** Convenience: the first control matching `filter`, or `undefined`. */
|
|
273
|
+
declare function findContentControl(input: Document | DocumentBody, filter: ContentControlFilter, options?: FindContentControlsOptions): ContentControlInfo | undefined;
|
|
274
|
+
/** No control matched the filter. */
|
|
275
|
+
declare class ContentControlNotFoundError extends Error {
|
|
276
|
+
constructor(filter: ContentControlFilter);
|
|
277
|
+
}
|
|
278
|
+
/** The matched control's lock forbids the attempted edit (pass `force` to override). */
|
|
279
|
+
declare class ContentControlLockedError extends Error {
|
|
280
|
+
constructor(lock: SdtProperties['lock'], op: 'edit' | 'remove');
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* The control's type doesn't support free text/block replacement (e.g. a
|
|
284
|
+
* dropdown, date, checkbox, or picture control), so writing arbitrary content
|
|
285
|
+
* would desync the type marker from its value. Use a type-specific setter, or
|
|
286
|
+
* pass `{ force: true }` to override.
|
|
287
|
+
*/
|
|
288
|
+
declare class ContentControlTypeError extends Error {
|
|
289
|
+
constructor(sdtType: SdtType);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* The control is bound to a Custom XML data store (`w:dataBinding`). Writing its
|
|
293
|
+
* content won't stick — Word re-renders the control from the bound XML node — so
|
|
294
|
+
* the write is refused. Update the data store instead, or pass `{ force: true }`.
|
|
295
|
+
*/
|
|
296
|
+
declare class ContentControlBoundError extends Error {
|
|
297
|
+
constructor();
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* A `BlockContent[]` replacement was targeted at an inline control, which can
|
|
301
|
+
* only hold inline content (runs, hyperlinks, fields, nested inline SDTs, math).
|
|
302
|
+
* Splicing a paragraph into a paragraph would be invalid OOXML — pass a string,
|
|
303
|
+
* or a single paragraph whose content is entirely inline.
|
|
304
|
+
*/
|
|
305
|
+
declare class ContentControlKindError extends Error {
|
|
306
|
+
constructor(detail: string);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Replace the content of the first control matching `filter` — block-level OR
|
|
310
|
+
* inline (including inside table cells and, with `includeHeadersFooters: true`,
|
|
311
|
+
* headers and footers). `replacement` may be a string or block content.
|
|
312
|
+
*
|
|
313
|
+
* - For a **block** control the string is split into paragraphs on newlines
|
|
314
|
+
* (a `plainText` control collapses to one paragraph); block content is used
|
|
315
|
+
* as-is (cloned).
|
|
316
|
+
* - For an **inline** control the string becomes a single run that inherits the
|
|
317
|
+
* placeholder's formatting (so the value matches the field it replaces). A
|
|
318
|
+
* richText control turns `\n` into a line break; a plainText control never
|
|
319
|
+
* gets one. Passing `BlockContent[]` to an inline control throws
|
|
320
|
+
* {@link ContentControlKindError} unless it is a single all-inline paragraph.
|
|
321
|
+
*
|
|
322
|
+
* Pass `{ all: true }` to fill **every** control matching `filter` (one logical
|
|
323
|
+
* value that recurs under a shared tag — e.g. a name in the body, a running
|
|
324
|
+
* header, and several table cells) instead of just the first.
|
|
325
|
+
*
|
|
326
|
+
* The control's properties, tag/alias, and lossless raw `w:sdtPr` are preserved.
|
|
327
|
+
* When the control was showing its placeholder (`w:showingPlcHdr`), that flag is
|
|
328
|
+
* cleared so Word doesn't render the new content as placeholder text.
|
|
329
|
+
*
|
|
330
|
+
* Throws {@link ContentControlNotFoundError} if nothing matches,
|
|
331
|
+
* {@link ContentControlLockedError} if the lock forbids editing,
|
|
332
|
+
* {@link ContentControlTypeError} for a typed (dropdown/date/…) control, and
|
|
333
|
+
* {@link ContentControlBoundError} for a data-bound control. Pass
|
|
334
|
+
* `{ force: true }` to override the guards.
|
|
335
|
+
*/
|
|
336
|
+
declare function setContentControlContent(doc: Document, filter: ContentControlFilter, replacement: string | BlockContent[], options?: {
|
|
337
|
+
force?: boolean;
|
|
338
|
+
includeHeadersFooters?: boolean;
|
|
339
|
+
all?: boolean;
|
|
340
|
+
}): Document;
|
|
341
|
+
/**
|
|
342
|
+
* Remove the first control matching `filter` — block-level OR inline (incl.
|
|
343
|
+
* inside table cells and, with `includeHeadersFooters: true`, headers/footers).
|
|
344
|
+
* With `keepContent: true` the control's content is unwrapped in place (the box goes
|
|
345
|
+
* away, the content stays) — block content lifts to its block siblings, inline
|
|
346
|
+
* content stays inline in the enclosing paragraph. Otherwise the control and
|
|
347
|
+
* its content are deleted.
|
|
348
|
+
*
|
|
349
|
+
* Pass `{ all: true }` to remove **every** control matching `filter` (e.g. to
|
|
350
|
+
* flatten a finished template by unwrapping all controls) instead of the first.
|
|
351
|
+
*
|
|
352
|
+
* Unwrapping a repeating-section (item) is refused unless `force`, since lifting
|
|
353
|
+
* its blocks out would orphan the (w15) repeating structure.
|
|
354
|
+
*
|
|
355
|
+
* Throws {@link ContentControlNotFoundError} / {@link ContentControlLockedError}
|
|
356
|
+
* as {@link setContentControlContent} does.
|
|
357
|
+
*/
|
|
358
|
+
declare function removeContentControl(doc: Document, filter: ContentControlFilter, options?: {
|
|
359
|
+
force?: boolean;
|
|
360
|
+
keepContent?: boolean;
|
|
361
|
+
includeHeadersFooters?: boolean;
|
|
362
|
+
all?: boolean;
|
|
363
|
+
}): Document;
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Create a new inline content control (`w:sdt`) by wrapping a text span.
|
|
367
|
+
*
|
|
368
|
+
* Complements the discovery/edit functions in {@link ./contentControls}: where
|
|
369
|
+
* those find and mutate existing controls, this wraps an exact run of text
|
|
370
|
+
* inside a paragraph in a new control with a synthesized, Word-correct
|
|
371
|
+
* `w:sdtPr`. Pure — the input {@link Document} is not mutated.
|
|
372
|
+
*/
|
|
373
|
+
|
|
374
|
+
/** A create request failed: the target couldn't be resolved, or the wrap is invalid. */
|
|
375
|
+
declare class ContentControlCreateError extends Error {
|
|
376
|
+
constructor(message: string);
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Where to create a control: an exact text span inside a paragraph. The
|
|
380
|
+
* paragraph is located by Word `w14:paraId`, and the chosen `occurrence` of
|
|
381
|
+
* `text` is wrapped in an inline control — including inside a table cell, where
|
|
382
|
+
* block-level controls aren't allowed.
|
|
383
|
+
*/
|
|
384
|
+
interface CreateContentControlTarget {
|
|
385
|
+
/** Word `w14:paraId` of the paragraph containing the text. */
|
|
386
|
+
paraId: string;
|
|
387
|
+
/** Exact substring to wrap. */
|
|
388
|
+
text: string;
|
|
389
|
+
/** Which occurrence of `text` to wrap when it repeats (1-based; default 1). */
|
|
390
|
+
occurrence?: number;
|
|
391
|
+
}
|
|
392
|
+
/** Modeled properties for a control created by {@link createContentControl}. */
|
|
393
|
+
interface NewContentControlProps {
|
|
394
|
+
/** Control type (default `richText`). */
|
|
395
|
+
sdtType?: SdtType;
|
|
396
|
+
/** Developer identifier (`w:tag`). */
|
|
397
|
+
tag?: string;
|
|
398
|
+
/** Friendly name (`w:alias`). */
|
|
399
|
+
alias?: string;
|
|
400
|
+
/** Numeric id (`w:id`). Default: auto-assigned, unique across the document. */
|
|
401
|
+
id?: number;
|
|
402
|
+
/** Lock setting (`w:lock`). */
|
|
403
|
+
lock?: SdtProperties['lock'];
|
|
404
|
+
/** Dropdown/combobox list items. */
|
|
405
|
+
listItems?: {
|
|
406
|
+
displayText: string;
|
|
407
|
+
value: string;
|
|
408
|
+
}[];
|
|
409
|
+
/** Date display format (`w:date/w:dateFormat`), for `date` controls. */
|
|
410
|
+
dateFormat?: string;
|
|
411
|
+
/** Initial checkbox state, for `checkbox` controls. */
|
|
412
|
+
checked?: boolean;
|
|
413
|
+
/** Whether the control starts in placeholder state (`w:showingPlcHdr`). */
|
|
414
|
+
showingPlaceholder?: boolean;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Wrap an exact text span inside a paragraph in a new inline content control
|
|
418
|
+
* (`w:sdt`), returning a new {@link Document} and the created control's
|
|
419
|
+
* {@link ContentControlInfo}. Pure — the input is not mutated. This is the form
|
|
420
|
+
* needed inside table cells and mid-sentence, where block controls aren't
|
|
421
|
+
* allowed: runs are split at the span boundaries (formatting preserved) and
|
|
422
|
+
* interior fields/tabs/breaks are kept wholesale.
|
|
423
|
+
*
|
|
424
|
+
* The control's `w:sdtPr` is synthesized from `props`, and its `w:id` is
|
|
425
|
+
* auto-assigned (unique across the document) when `props.id` is omitted, so the
|
|
426
|
+
* control round-trips and `findContentControl(doc, { tag })` resolves it after a
|
|
427
|
+
* save/reload.
|
|
428
|
+
*
|
|
429
|
+
* **Body only:** the search covers body paragraphs and block/table content —
|
|
430
|
+
* paragraphs inside headers or footers are not reachable. Passing a `paraId`
|
|
431
|
+
* from a header/footer part throws {@link ContentControlCreateError} with a
|
|
432
|
+
* "No paragraph found" message.
|
|
433
|
+
*
|
|
434
|
+
* @throws {@link ContentControlCreateError} when the paragraph or text isn't
|
|
435
|
+
* found, the span overlaps an existing control or crosses a non-run boundary,
|
|
436
|
+
* the `sdtType` can't be synthesized, or a supplied `id` already exists.
|
|
437
|
+
*/
|
|
438
|
+
declare function createContentControl(doc: Document, target: CreateContentControlTarget, props?: NewContentControlProps): {
|
|
439
|
+
doc: Document;
|
|
440
|
+
control: ContentControlInfo;
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Typed value setters for block-level content controls — set a dropdown
|
|
445
|
+
* selection, toggle a checkbox, or set a date. These produce both the visible
|
|
446
|
+
* content (the run text Word shows) and the structured state inside the
|
|
447
|
+
* captured raw `w:sdtPr` (dropdown `w:lastValue`, `w14:checked`, `w:date`'s
|
|
448
|
+
* `w:fullDate`), patched in place so the rest of the control round-trips
|
|
449
|
+
* verbatim. Use these instead of {@link setContentControlContent} for typed
|
|
450
|
+
* controls, which that function refuses by design.
|
|
451
|
+
*
|
|
452
|
+
* Raw `w:sdtPr` is patched with targeted string edits (not a full re-serialize)
|
|
453
|
+
* to preserve the `CT_SdtPr` element order and any unmodeled properties — the
|
|
454
|
+
* same capture-and-replay contract used everywhere else for SDTs.
|
|
455
|
+
*/
|
|
456
|
+
|
|
457
|
+
/** A typed value to apply to a content control. */
|
|
458
|
+
type ContentControlValue = {
|
|
459
|
+
kind: 'dropdown';
|
|
460
|
+
value: string;
|
|
461
|
+
} | {
|
|
462
|
+
kind: 'checkbox';
|
|
463
|
+
checked: boolean;
|
|
464
|
+
} | {
|
|
465
|
+
kind: 'date';
|
|
466
|
+
date: string;
|
|
467
|
+
};
|
|
468
|
+
/** The control doesn't support the requested value kind, or the value is invalid. */
|
|
469
|
+
declare class ContentControlValueError extends Error {
|
|
470
|
+
constructor(message: string);
|
|
471
|
+
}
|
|
472
|
+
/** Format an ISO date (yyyy-mm-dd) with a subset of OOXML date tokens. */
|
|
473
|
+
declare function formatSdtDate(iso: string, pattern?: string, language?: string): string;
|
|
474
|
+
/**
|
|
475
|
+
* Set a typed value (dropdown selection / checkbox / date) on the first control
|
|
476
|
+
* matching `filter` — **block-level OR inline** (inline includes controls inside
|
|
477
|
+
* table cells, and with `includeHeadersFooters: true`, headers/footers) — returning a new
|
|
478
|
+
* {@link Document}. Updates both the visible content and the structured raw
|
|
479
|
+
* state (dropdown `w:lastValue`, `w14:checked`, `w:date/@w:fullDate`), so the
|
|
480
|
+
* result round-trips and Word shows the new value.
|
|
481
|
+
*
|
|
482
|
+
* Pass `{ all: true }` to set the value on **every** control matching `filter`
|
|
483
|
+
* (a value shared across duplicated controls) instead of just the first.
|
|
484
|
+
*
|
|
485
|
+
* Throws `ContentControlNotFoundError` if nothing matches,
|
|
486
|
+
* {@link ContentControlLockedError} if content-locked,
|
|
487
|
+
* {@link ContentControlBoundError} if data-bound (the store would override the
|
|
488
|
+
* write), and {@link ContentControlValueError} if the value doesn't fit the
|
|
489
|
+
* control type. The lock/bound guards are overridable with `{ force: true }`.
|
|
490
|
+
*/
|
|
491
|
+
declare function setContentControlValue(doc: Document, filter: ContentControlFilter, value: ContentControlValue, options?: {
|
|
492
|
+
force?: boolean;
|
|
493
|
+
includeHeadersFooters?: boolean;
|
|
494
|
+
all?: boolean;
|
|
495
|
+
}): Document;
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Repeating-section (w15:repeatingSection) support — add and remove repeated
|
|
499
|
+
* items, the way Word's "+" affordance does. A repeating section is a block
|
|
500
|
+
* content control whose `w:sdtPr` carries `<w15:repeatingSection>`; its direct
|
|
501
|
+
* children are item controls each carrying `<w15:repeatingSectionItem>`.
|
|
502
|
+
*
|
|
503
|
+
* Adding clones an existing item (with a fresh, unique `w:id`) and inserts it
|
|
504
|
+
* after; removing drops one item but keeps at least one. The w15 elements ride
|
|
505
|
+
* in the captured raw `w:sdtPr` (they're unmodeled), so we detect and patch the
|
|
506
|
+
* raw string rather than re-serializing.
|
|
507
|
+
*/
|
|
508
|
+
|
|
509
|
+
/** The control's raw `w:sdtPr` declares it a repeating section (the container). */
|
|
510
|
+
declare function isRepeatingSection(props: SdtProperties): boolean;
|
|
511
|
+
/** The control's raw `w:sdtPr` declares it a repeating-section item. */
|
|
512
|
+
declare function isRepeatingSectionItem(props: SdtProperties): boolean;
|
|
513
|
+
/** Raised when an operation targets something that isn't a repeating section/item. */
|
|
514
|
+
declare class RepeatingSectionError extends Error {
|
|
515
|
+
constructor(message: string);
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Add a new repeating-section item, cloned from an existing one and inserted
|
|
519
|
+
* after it. `afterIndex` is the item ordinal to clone/insert after (default:
|
|
520
|
+
* the last item). Returns a new {@link Document}.
|
|
521
|
+
*/
|
|
522
|
+
declare function addRepeatingSectionItem(doc: Document, filter: ContentControlFilter, options?: {
|
|
523
|
+
afterIndex?: number;
|
|
524
|
+
}): Document;
|
|
525
|
+
/**
|
|
526
|
+
* Remove the repeating-section item at ordinal `index`. Keeps at least one item
|
|
527
|
+
* (Word does not allow removing the last). Returns a new {@link Document}.
|
|
528
|
+
*/
|
|
529
|
+
declare function removeRepeatingSectionItem(doc: Document, filter: ContentControlFilter, index: number): Document;
|
|
530
|
+
|
|
531
|
+
export { ContentControlBoundError, ContentControlCreateError, type ContentControlFilter, type ContentControlInfo, ContentControlKindError, type ContentControlLocation, ContentControlLockedError, ContentControlNotFoundError, ContentControlTypeError, type ContentControlValue, ContentControlValueError, type CreateContentControlTarget, type FindContentControlsOptions, type NewContentControlProps, Position, RepeatingSectionError, addRepeatingSectionItem, countCharacters, countWords, createContentControl, findContentControl, findContentControls, formatSdtDate, getBlockIndexForParagraph, getBodyCharacterCount, getBodyText, getBodyWordCount, getContentControlText, getFormattingAtPosition, getHyperlinkAtPosition, getHyperlinkText, getParagraphAtIndex, getParagraphText, getParagraphs, getRunText, getTableText, getTextAfter, getTextBefore, hasHyperlinks, hasImages, hasTables, isHeadingStyle, isPositionInHyperlink, isRepeatingSection, isRepeatingSectionItem, parseHeadingLevel, removeContentControl, removeRepeatingSectionItem, setContentControlContent, setContentControlValue };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as ContentControlCreateError,e as RepeatingSectionError,f as addRepeatingSectionItem,b as createContentControl,c as isRepeatingSection,d as isRepeatingSectionItem,g as removeRepeatingSectionItem}from'../chunk-QOUFE3VX.mjs';export{C as ContentControlBoundError,F as ContentControlKindError,A as ContentControlLockedError,z as ContentControlNotFoundError,B as ContentControlTypeError,J as ContentControlValueError,g as countCharacters,f as countWords,y as findContentControl,x as findContentControls,K as formatSdtDate,v as getBlockIndexForParagraph,i as getBodyCharacterCount,e as getBodyText,h as getBodyWordCount,w as getContentControlText,l as getFormattingAtPosition,n as getHyperlinkAtPosition,c as getHyperlinkText,u as getParagraphAtIndex,a as getParagraphText,t as getParagraphs,b as getRunText,d as getTableText,k as getTextAfter,j as getTextBefore,r as hasHyperlinks,q as hasImages,s as hasTables,o as isHeadingStyle,m as isPositionInHyperlink,p as parseHeadingLevel,I as removeContentControl,H as setContentControlContent,M as setContentControlValue}from'../chunk-YBIM6UJV.mjs';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-Q7PO7V73.mjs';export{a as DocumentAgent,h as buildExtendedSelectionContext,g as buildSelectionContext,e as buildSelectionContextFromContext,b as createAgent,c as createAgentFromDocument,d as getAgentContext,f as getDocumentSummary,i as getSelectionFormattingSummary}from'../chunk-XQBCCJBO.mjs';import'../chunk-UIEJWORW.mjs';export{a as executeCommand,b as executeCommands}from'../chunk-6PW4CWUG.mjs';import'../chunk-KXNZFTTK.mjs';import'../chunk-VBOTMRXV.mjs';import'../chunk-OJOHXQNQ.mjs';import'../chunk-KVKLLTDP.mjs';import'../chunk-BIQWVK5P.mjs';import'../chunk-3UBMCDME.mjs';import'../chunk-LDUWIM7M.mjs';import'../chunk-DXKG3HQ5.mjs';import'../chunk-FPZBTOD6.mjs';import'../chunk-H3JCIGWK.mjs';import'../chunk-N5Q3YN64.mjs';import'../chunk-SINEY6ZF.mjs';import'../chunk-T4EZMUXM.mjs';import'../chunk-TTRUPDAB.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function h(){return {type:"break",breakType:"page"}}function b(){return {type:"break",breakType:"column"}}function y(e){return {type:"break",breakType:"textWrapping",clear:e}}function C(){return {type:"run",content:[h()]}}function l(){return {type:"paragraph",content:[],formatting:{pageBreakBefore:true}}}function k(e){return e.content.filter(t=>t.type==="run")}function d(e,t){let{paragraphIndex:a}=t,n=[...e.package.document.content||[]],r=l();return n.splice(a+1,0,r),{...e,package:{...e.package,document:{...e.package.document,content:n}}}}function B(){return {type:"paragraph",content:[],formatting:{borders:{bottom:{style:"single",color:{rgb:"000000"},size:12,space:1}},spaceBefore:120,spaceAfter:120}}}function R(e,t){let{paragraphIndex:a}=t,n=[...e.package.document.content||[]],r=B();return n.splice(a+1,0,r),{...e,package:{...e.package,document:{...e.package.document,content:n}}}}function i(e){return e.type==="break"&&e.breakType==="page"}function I(e){return e.type==="break"&&e.breakType==="column"}function D(e){return e.type==="break"&&e.breakType==="textWrapping"}function T(e){return e.type==="break"}function g(e){return e.formatting?.pageBreakBefore===true}function z(e){let t=0;for(let a of e.package.document.content||[])if(a.type==="paragraph"){let n=a;g(n)&&t++;let r=k(n);for(let u of r)for(let o of u.content)i(o)&&t++;}return t}function w(e){let t=[],a=e.package.document.content||[];for(let n=0;n<a.length;n++){let r=a[n];if(r.type==="paragraph"){let u=r;g(u)&&t.push({paragraphIndex:n});let o=k(u);for(let p=0;p<o.length;p++){let s=o[p];for(let c of s.content)i(c)&&t.push({paragraphIndex:n,runIndex:p});}}}return t}function H(e,t){let{paragraphIndex:a,runIndex:n}=t,r=[...e.package.document.content||[]],u=r[a];if(u.type!=="paragraph")return e;let o=u;if(g(o)&&n===void 0)return r[a]={...o,formatting:{...o.formatting,pageBreakBefore:false}},{...e,package:{...e.package,document:{...e.package.document,content:r}}};if(n!==void 0){let p=[],s=0;for(let c of o.content)if(c.type==="run"){if(s===n){let f=c.content.filter(m=>!i(m));f.length>0&&p.push({...c,content:f});}else p.push(c);s++;}else p.push(c);return r[a]={...o,content:p},{...e,package:{...e.package,document:{...e.package.document,content:r}}}}return e}export{h as a,b,y as c,C as d,l as e,d as f,B as g,R as h,i,I as j,D as k,T as l,g as m,z as n,w as o,H as p};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r=96;function i(n){return n==null||isNaN(n)?0:Math.round(n*96/914400)}function m(n){return Math.round(n/96*914400)}function _(n){return n/72*96}var t=1440,s=144,x=576,c=14;function T(n){return n/t*96}function f(n){return n/96*t}function N(n){return Math.round(n/914400*t)}function H(n){return Math.round(n/t*914400)}function l(n){return n/s*96}function R(n){return n/2}function S(n){return n*2}function a(n){return n/x*96}function b(n,o=2){let e=Math.pow(10,o);return Math.round(n*e)/e}function C(n,o,e){return Math.min(Math.max(n,o),e)}function h(n){return `${b(n)}px`}export{r as a,i as b,m as c,_ as d,t as e,c as f,T as g,f as h,N as i,H as j,l as k,R as l,S as m,a as n,b as o,C as p,h as q};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var R=/[\p{L}\p{N}\p{M}_''\-]/u,S=/\s/;function f(e){return !e||e.length===0?false:R.test(e)}function g(e){return !e||e.length===0?false:S.test(e)}function c(e,t){if(!e||e.length===0)return [0,0];t=Math.max(0,Math.min(t,e.length-1));let r=e[t];if(g(r)){let n=t,o=t;for(;n>0&&g(e[n-1]);)n--;for(;o<e.length&&g(e[o]);)o++;return [n,o]}if(f(r)){let n=t,o=t;for(;n>0&&f(e[n-1]);)n--;for(;o<e.length&&f(e[o]);)o++;return [n,o]}return [t,t+1]}function b(e,t){let[r,n]=c(e,t);return e.slice(r,n)}function O(e,t){let[r,n]=c(e,t);return {word:e.slice(r,n),startIndex:r,endIndex:n}}function p(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let t=e.getRangeAt(0),r=t.startContainer;if(r.nodeType===Node.TEXT_NODE){let n=r.textContent||"",o=t.startOffset,[s,l]=c(n,o);if(l>s)return t.setStart(r,s),t.setEnd(r,l),e.removeAllRanges(),e.addRange(t),true}if(r.nodeType===Node.ELEMENT_NODE){let n=r,o=x(n);if(o.length>0){let s=t.startOffset,l=null,a=s;if(s<n.childNodes.length){let i=n.childNodes[s];if(i.nodeType===Node.TEXT_NODE)l=i,a=0;else if(i instanceof Element){let d=x(i);d.length>0&&(l=d[0],a=0);}}if(!l&&o.length>0&&(l=o[0],a=0),l){let i=l.textContent||"",[d,h]=c(i,a);if(h>d){let E=document.createRange();return E.setStart(l,d),E.setEnd(l,h),e.removeAllRanges(),e.addRange(E),true}}}}return false}function A(e,t){let r=window.getSelection();if(!r)return false;let n=e.textContent||"",[o,s]=c(n,t);if(s>o){let l=document.createRange();return l.setStart(e,o),l.setEnd(e,s),r.removeAllRanges(),r.addRange(l),true}return false}function y(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let t=e.getRangeAt(0);if(t.collapsed)return p();let r=t.startContainer,n=t.endContainer,o=t.startOffset,s=t.endOffset;if(r.nodeType===Node.TEXT_NODE){let l=r.textContent||"",[a]=c(l,t.startOffset);o=a;}if(n.nodeType===Node.TEXT_NODE){let l=n.textContent||"",a=Math.max(0,t.endOffset-1),[,i]=c(l,a);s=i;}try{return t.setStart(r,o),t.setEnd(n,s),e.removeAllRanges(),e.addRange(t),!0}catch(l){return console.warn("Could not expand selection to word boundaries:",l),false}}function C(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let r=e.getRangeAt(0).commonAncestorContainer,n=W(r);if(n){let o=document.createRange();return o.selectNodeContents(n),e.removeAllRanges(),e.addRange(o),true}return false}function W(e){if(!e)return null;let t=e;for(;t;){if(t instanceof Element&&t.hasAttribute("data-paragraph-index"))return t;t=t.parentNode;}return null}function x(e){let t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),n;for(;n=r.nextNode();)n.nodeType===Node.TEXT_NODE&&t.push(n);return t}var T=0,u=null,m=null,M=500;function w(){T=0,m=null,u&&(clearTimeout(u),u=null);}function N(e){return e.target!==m&&w(),T++,m=e.target,u&&clearTimeout(u),u=setTimeout(w,M),Math.min(T,3)}function _(){return e=>{e.ctrlKey||e.metaKey||e.altKey||p();}}function k(){return e=>{if(N(e)===3){if(e.ctrlKey||e.metaKey||e.altKey)return;C();}}}var D={isWordCharacter:f,isWhitespace:g,findWordBoundaries:c,getWordAt:b,findWordAt:O,selectWordAtCursor:p,selectWordInTextNode:A,expandSelectionToWordBoundaries:y,selectParagraphAtCursor:C,handleClickForMultiClick:N,createDoubleClickWordSelector:_,createTripleClickParagraphSelector:k};export{f as a,g as b,c,b as d,O as e,p as f,A as g,y as h,C as i,N as j,_ as k,k as l,D as m};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=["CONFIDENTIAL","DRAFT","DO NOT COPY","SAMPLE","URGENT","ASAP"];function i(t,n){if(!(t>0)||!(n>0))return;let e=t/n;return e>=1?{widthEmu:3954780,heightEmu:Math.round(3954780/e)}:{widthEmu:Math.round(3954780*e),heightEmu:3954780}}export{a,i as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {g}from'./chunk-3UBMCDME.mjs';function F(e,n,t){if(!(!e||e<=0)){if(n==="pct")return t*e/5e3;if(!n||n==="dxa"||n==="auto")return g(e)}}function p(e){let n=new Map,t=[];for(let r=0;r<e.rows.length;r++){let i=e.rows[r]?.cells??[],o=n.get(r)??new Set,a=Math.max(0,Math.min(16384,Math.trunc(e.rows[r]?.gridBefore??0)));for(;o.has(a);)a++;for(let m=0;m<i.length;m++){let u=i[m];if(!u)continue;u.gridStart!=null&&(a=Math.max(a,Math.min(16384,Math.trunc(u.gridStart))));let s=Math.max(1,Math.min(16384,Math.trunc(u.colSpan??1))),f=Math.max(1,Math.min(32768,Math.trunc(u.rowSpan??1)));if(t.push({rowIndex:r,cellIndex:m,columnIndex:a,colSpan:s,rowSpan:f}),f>1)for(let c=r+1;c<r+f;c++){n.has(c)||n.set(c,new Set);let d=n.get(c);for(let l=0;l<s;l++)d.add(a+l);}for(a+=s;o.has(a);)a++;}}return t}function Z(e){let n=p(e),t=1;for(let r of n)t=Math.max(t,r.columnIndex+r.colSpan);for(let r=0;r<e.rows.length;r++){let i=e.rows[r],a=n.filter(m=>m.rowIndex===r).reduce((m,u)=>Math.max(m,u.columnIndex+u.colSpan),Math.max(0,Math.trunc(i.gridBefore??0)));t=Math.max(t,a+Math.max(0,Math.trunc(i.gridAfter??0)));}return Math.min(16384,t)}function b(e,n,t,r,i){return F(e?.value,e?.type,r)??F(n,t,r)??(i!=null&&i>0?i:void 0)}function h(e,n,t,r){if(!(r>0)||n>=e.length)return;let i=Math.min(e.length,n+Math.max(1,t)),o=e.slice(n,i).reduce((u,s)=>u+s,0),a=r-o;if(a<=0)return;let m=a/Math.max(1,i-n);for(let u=n;u<i;u++)e[u]+=m;}function x(e,n){let t=e.reduce((i,o)=>i+o,0);if(!(n>t)||e.length===0)return e;let r=(n-t)/e.length;return e.map(i=>i+r)}function Y(e,n,t,r){let i=e.gridWidths??e.columnWidths??[],o=w(i,t,r??n),a=p(e).filter(m=>m.rowIndex===0);for(let m of a){let u=e.rows[0]?.cells[m.cellIndex];if(!u)continue;let s=b(u.preferredWidth,u.widthValue,u.widthType,r??n,u.width);s&&h(o,m.columnIndex,m.colSpan,s);}return r&&(o=x(o,r)),o}function A(e,n,t,r){let i=w(e.gridWidths??e.columnWidths??[],t,r??n),o=Array(t).fill(0),a=Array(t).fill(0);for(let l of p(e)){let g=e.rows[l.rowIndex]?.cells[l.cellIndex];if(!g)continue;let M=b(g.preferredWidth,g.widthValue,g.widthType,r??n,g.width),W=Math.max(0,g.minContentWidth??0,g.noWrap?g.maxContentWidth??0:0),v=Math.max(W,g.maxContentWidth??M??0);h(o,l.columnIndex,l.colSpan,W),h(a,l.columnIndex,l.colSpan,v),M&&h(a,l.columnIndex,l.colSpan,M);}for(let l=0;l<t;l++)o[l]<=0&&(o[l]=Math.min(i[l],a[l]||i[l])),a[l]=Math.max(o[l],a[l]||i[l]);let m=o.reduce((l,g)=>l+g,0),u=a.reduce((l,g)=>l+g,0),s=Math.max(m,Math.min(n,r??(u>0?u:n)));if(s>=u)return x(a,s);let f=a.map((l,g)=>Math.max(0,l-o[g])),c=f.reduce((l,g)=>l+g,0),d=Math.max(0,s-m);return c<=0?x(o,s):o.map((l,g)=>l+d*f[g]/c)}function w(e,n,t){if(n<=0)return [];let r=t>0?t/n:0;if(e.length===0)return Array(n).fill(r);let i=e.slice(0,n),o=n-i.length;if(o>0){let f=i.filter(d=>d>0),c=f.length>0?f.reduce((d,l)=>d+l,0)/f.length:r;i=i.concat(Array(o).fill(c));}let a=i.reduce((f,c)=>f+(c>0?c:0),0),m=i.filter(f=>f<=0).length;if(a<=0)return Array(n).fill(r);if(m===0)return i;let u=Math.max(0,t-a),s=u>0?u/m:a/Math.max(1,n-m);return i.map(f=>f>0?f:s)}function C(e,n){let t=e.columnWidths??[],r=b(e.preferredWidth,e.width,e.widthType,n),i=Z(e),o=r??n,a=e.widthAlgorithm??e.layoutMode??"legacy";if(e.rows.length>0&&a==="fixed")return Y(e,n,i,r);if(e.rows.length>0&&a==="autofit")return A(e,n,i,r);if(e.rows.length>0&&(t=w(t,i,o)),t.length>0&&r){let m=t.reduce((u,s)=>u+s,0);if(m>0&&Math.abs(m-r)>1){let u=r/m;t=t.map(s=>s*u);}}return t}function D(e,n){let t=C(e,n),r=b(e.preferredWidth,e.width,e.widthType,n);return t.reduce((i,o)=>i+o,0)||r||n}function O(e,n,t){let r=Math.max(1,t),i=Math.max(0,e),o=Math.max(0,n);return i>=r||o>=r||i+o>=r?{leftMargin:0,rightMargin:0}:{leftMargin:i,rightMargin:o}}function H(e,n){return e.map(t=>{let r=t.x-t.distLeft,i=t.x+t.width+t.distRight,o=t.y-t.distTop,a=t.y+t.height+t.distBottom;if(t.wrapType==="topAndBottom")return {leftMargin:0,rightMargin:0,topY:o,bottomY:a,fullWidthBlock:true};let m=0,u=0,s,f=t.wrapText??"bothSides";f==="right"?m=T(i):f==="left"?u=S(r,n):f==="largest"?{leftMargin:m,rightMargin:u}=G(r,i,n):E(r,i,n)?s=_(r,i,n):t.side==="left"?m=T(i):u=S(r,n);let c=O(m,u,n);return {leftMargin:c.leftMargin,rightMargin:c.rightMargin,topY:o,bottomY:a,segments:s}})}function V(e,n,t,r){if(!t||t.length===0)return {leftMargin:0,rightMargin:0};let i=0,o=0,a,m=r+e,u=m+n;for(let s of t)if(!(u<=s.topY||m>=s.bottomY)){if(s.fullWidthBlock)return {leftMargin:0,rightMargin:0,segments:[{leftOffset:0,availableWidth:0}]};if(s.segments?.length){a=a?R(a,s.segments):s.segments;continue}i=Math.max(i,s.leftMargin),o=Math.max(o,s.rightMargin);}return {leftMargin:i,rightMargin:o,segments:a}}function R(e,n){let t=[];for(let r of e)for(let i of n){let o=Math.max(r.leftOffset,i.leftOffset),a=Math.min(r.leftOffset+r.availableWidth,i.leftOffset+i.availableWidth);a>o&&t.push({leftOffset:o,availableWidth:a-o});}return t}function E(e,n,t){return e>24&&n+24<t}function _(e,n,t){return [{leftOffset:0,availableWidth:Math.max(0,e)},{leftOffset:Math.max(0,n),availableWidth:Math.max(0,t-n)}].filter(r=>r.availableWidth>1)}function G(e,n,t){let r=Math.max(0,e);return Math.max(0,t-n)>=r?{leftMargin:T(n),rightMargin:0}:{leftMargin:0,rightMargin:S(e,t)}}function T(e){return Math.max(0,e)}function S(e,n){return Math.max(0,n-e)}export{F as a,p as b,Z as c,w as d,C as e,D as f,O as g,H as h,V as i};
|