@betteroffice/docx 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/README.md +19 -0
  2. package/dist/chunk-AEQOEQJ7.mjs +57 -0
  3. package/dist/chunk-AZ52IWB6.mjs +16 -0
  4. package/dist/{chunk-SINEY6ZF.mjs → chunk-B4IR6YP4.mjs} +1 -1
  5. package/dist/chunk-IFT6DUJX.mjs +1 -0
  6. package/dist/{chunk-H3JCIGWK.mjs → chunk-NJHOPXZW.mjs} +1 -1
  7. package/dist/chunk-NTQM4EYN.mjs +1 -0
  8. package/dist/{chunk-KXNZFTTK.mjs → chunk-WBH3SXI6.mjs} +1 -1
  9. package/dist/collaboration/index.d.mts +64 -0
  10. package/dist/collaboration/index.mjs +1 -0
  11. package/dist/{content-sSHuWw49.d.mts → content-DLFHRQav.d.mts} +8 -8
  12. package/dist/core.d.mts +148 -341
  13. package/dist/core.mjs +1 -1
  14. package/dist/{displayListQueries-p-ijSzdh.d.mts → displayListQueries-UGc_XBUv.d.mts} +1 -1
  15. package/dist/docx/index.d.mts +40 -520
  16. package/dist/docx/index.mjs +2 -2
  17. package/dist/editor/index.d.mts +35 -151
  18. package/dist/editor/index.mjs +1 -1
  19. package/dist/{fontLoader-Bx6DK6-2.d.mts → fontLoader-aSewHMKF.d.mts} +65 -63
  20. package/dist/{formatting-DoL7KBSL.d.mts → formatting-D1EPSaJP.d.mts} +1 -1
  21. package/dist/generated/edit/docx_edit_bg.wasm +0 -0
  22. package/dist/generated/layout/docx_layout_bg.wasm +0 -0
  23. package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
  24. package/dist/generated/parse/docx_parse_bg.wasm +0 -0
  25. package/dist/index-Bwxm3oiC.d.mts +934 -0
  26. package/dist/layout/index.d.mts +18 -240
  27. package/dist/layout/index.mjs +1 -1
  28. package/dist/layout/pagination/index.d.mts +10 -58
  29. package/dist/layout/pagination/index.mjs +1 -1
  30. package/dist/layout/render/index.d.mts +10 -11
  31. package/dist/layout/render/index.mjs +1 -1
  32. package/dist/plugin-api/RenderedDomContext.d.mts +8 -9
  33. package/dist/plugin-api/index.d.mts +191 -6
  34. package/dist/plugin-api/resolveItemPositions.d.mts +4 -5
  35. package/dist/{rustDisplayList-dqunvwxH.d.mts → rustDisplayList-CX78djsZ.d.mts} +5 -5
  36. package/dist/rustMeasureSource-D1KsQvVC.d.mts +106 -0
  37. package/dist/selectiveSave-CVoajSKE.d.mts +56 -0
  38. package/dist/styles/index.d.mts +4 -39
  39. package/dist/styles/index.mjs +1 -1
  40. package/dist/{styles-VxNcXLdi.d.mts → styles-Dn_o3Vo5.d.mts} +2 -2
  41. package/dist/types/content.d.mts +2 -2
  42. package/dist/types/document.d.mts +40 -14
  43. package/dist/{types-DNrYr6yQ.d.mts → types-DMkDbvEu.d.mts} +3 -71
  44. package/dist/utils/comments.d.mts +2 -2
  45. package/dist/utils/index.d.mts +110 -576
  46. package/dist/utils/index.mjs +1 -84
  47. package/dist/utils/stylePreview.d.mts +2 -2
  48. package/dist/utils/units.d.mts +33 -2
  49. package/dist/wasm-BGQBTR2J.mjs +1 -0
  50. package/dist/wasm-edit.d.mts +13 -5
  51. package/dist/wasm-edit.mjs +1 -1
  52. package/dist/wasm-opc.mjs +1 -1
  53. package/dist/wasm-parse.mjs +1 -1
  54. package/dist/yrs/index.d.mts +5 -881
  55. package/dist/yrs/index.mjs +1 -1
  56. package/dist/yrs/residentEngineWorker.mjs +1 -1
  57. package/package.json +16 -139
  58. package/dist/Subscribable-DOz6Ohoo.d.mts +0 -33
  59. package/dist/agent/index.d.mts +0 -531
  60. package/dist/agent/index.mjs +0 -1
  61. package/dist/chunk-34K66SY4.mjs +0 -1
  62. package/dist/chunk-4RCISPPE.mjs +0 -1
  63. package/dist/chunk-52GB3Y42.mjs +0 -1
  64. package/dist/chunk-6PW4CWUG.mjs +0 -1
  65. package/dist/chunk-7DEIW7FL.mjs +0 -1
  66. package/dist/chunk-7PCO5I2O.mjs +0 -1
  67. package/dist/chunk-BI3B33LI.mjs +0 -1
  68. package/dist/chunk-BIQWVK5P.mjs +0 -2
  69. package/dist/chunk-DXKG3HQ5.mjs +0 -16
  70. package/dist/chunk-FPZBTOD6.mjs +0 -1
  71. package/dist/chunk-FZIA7OFY.mjs +0 -1
  72. package/dist/chunk-GWKJ2Y4Y.mjs +0 -1
  73. package/dist/chunk-HJGAQIU7.mjs +0 -2
  74. package/dist/chunk-I6KKMUUC.mjs +0 -1
  75. package/dist/chunk-IL5JZJT7.mjs +0 -1
  76. package/dist/chunk-JY6ILTNS.mjs +0 -1
  77. package/dist/chunk-KEE52TT5.mjs +0 -1
  78. package/dist/chunk-KVKLLTDP.mjs +0 -58
  79. package/dist/chunk-L5ISVQ3W.mjs +0 -1
  80. package/dist/chunk-LDUWIM7M.mjs +0 -1
  81. package/dist/chunk-N5Q3YN64.mjs +0 -1
  82. package/dist/chunk-NEWOMDTX.mjs +0 -1
  83. package/dist/chunk-O2QSE2I7.mjs +0 -1
  84. package/dist/chunk-OJOHXQNQ.mjs +0 -1
  85. package/dist/chunk-OMR3TWCD.mjs +0 -2
  86. package/dist/chunk-P3KDV4M2.mjs +0 -1
  87. package/dist/chunk-Q7PO7V73.mjs +0 -1
  88. package/dist/chunk-QOUFE3VX.mjs +0 -1
  89. package/dist/chunk-TYHI7RAD.mjs +0 -1
  90. package/dist/chunk-UIEJWORW.mjs +0 -1
  91. package/dist/chunk-VAOUFAUH.mjs +0 -1
  92. package/dist/chunk-VBOTMRXV.mjs +0 -1
  93. package/dist/chunk-VCER63GQ.mjs +0 -1
  94. package/dist/chunk-WAUF2UC7.mjs +0 -2
  95. package/dist/chunk-X4XDO3LZ.mjs +0 -1
  96. package/dist/chunk-XQBCCJBO.mjs +0 -9
  97. package/dist/chunk-XWUOLYRQ.mjs +0 -2
  98. package/dist/chunk-XYH6XWP3.mjs +0 -10
  99. package/dist/chunk-YBIM6UJV.mjs +0 -8
  100. package/dist/chunk-YCIH2Q3E.mjs +0 -1
  101. package/dist/chunk-ZOV5KL7C.mjs +0 -1
  102. package/dist/colorResolver-n0o7H7ep.d.mts +0 -290
  103. package/dist/core-plugins.d.mts +0 -37
  104. package/dist/core-plugins.mjs +0 -1
  105. package/dist/docx/parser.d.mts +0 -41
  106. package/dist/docx/parser.mjs +0 -1
  107. package/dist/docx/rezip.d.mts +0 -148
  108. package/dist/docx/rezip.mjs +0 -1
  109. package/dist/docx/serializer/index.d.mts +0 -42
  110. package/dist/docx/serializer/index.mjs +0 -1
  111. package/dist/editorTree-DO5PyDK8.d.mts +0 -37
  112. package/dist/executor-7O2RBJ2B.mjs +0 -1
  113. package/dist/headerFooterLayout-0zPT64Qc.d.mts +0 -316
  114. package/dist/headless.d.mts +0 -69
  115. package/dist/headless.mjs +0 -1
  116. package/dist/layout/flow/index.d.mts +0 -149
  117. package/dist/layout/flow/index.mjs +0 -1
  118. package/dist/layout/measure/index.d.mts +0 -324
  119. package/dist/layout/measure/index.mjs +0 -1
  120. package/dist/layout/pagination/types.d.mts +0 -4
  121. package/dist/layout/pagination/types.mjs +0 -1
  122. package/dist/managers/AutoSaveManager.d.mts +0 -81
  123. package/dist/managers/AutoSaveManager.mjs +0 -1
  124. package/dist/managers/TableSelectionManager.d.mts +0 -74
  125. package/dist/managers/TableSelectionManager.mjs +0 -1
  126. package/dist/managers/types.d.mts +0 -113
  127. package/dist/managers/types.mjs +0 -0
  128. package/dist/mcp-cli.mjs +0 -142
  129. package/dist/mcp.d.mts +0 -162
  130. package/dist/mcp.mjs +0 -16
  131. package/dist/measureBlocksPipeline-Df0Bbrwy.d.mts +0 -109
  132. package/dist/measuredBlock-DZwz8zhD.d.mts +0 -26
  133. package/dist/plugin-api/types.d.mts +0 -193
  134. package/dist/plugin-api/types.mjs +0 -0
  135. package/dist/processTemplate-HDUIZFJ5.mjs +0 -1
  136. package/dist/registry-DMM5VTdT.d.mts +0 -165
  137. package/dist/rustPagination-Bj2hq013.d.mts +0 -106
  138. package/dist/sectionConfigs-DW3J8q0X.d.mts +0 -55
  139. package/dist/selectionContext-Buc9BCU1.d.mts +0 -570
  140. package/dist/selectiveSave-oFBJ1n71.d.mts +0 -16
  141. package/dist/selectiveXmlPatch-ypkxlTD_.d.mts +0 -23
  142. package/dist/settingsParser-CcGvtmCK.d.mts +0 -33
  143. package/dist/types/agentApi.d.mts +0 -456
  144. package/dist/types/agentApi.mjs +0 -1
  145. package/dist/types-dYdjUZMo.d.mts +0 -311
  146. package/dist/units-O5Y02RKQ.d.mts +0 -34
  147. package/dist/utils/headingCollector.d.mts +0 -28
  148. package/dist/utils/headingCollector.mjs +0 -1
  149. package/dist/utils/highlightColors.d.mts +0 -14
  150. package/dist/utils/highlightColors.mjs +0 -1
  151. package/dist/utils/textSelection.d.mts +0 -92
  152. package/dist/utils/textSelection.mjs +0 -1
  153. package/dist/variableDetector-Borj29SF.d.mts +0 -115
  154. package/dist/wasm-FZQ5XB2Y.mjs +0 -1
  155. package/dist/watermarkApi-DCxjutkg.d.mts +0 -38
@@ -1,148 +0,0 @@
1
- import { Document } from '../types/document.mjs';
2
- import '../content-sSHuWw49.mjs';
3
- import '../formatting-DoL7KBSL.mjs';
4
- import './wrapTypes.mjs';
5
- import '../styles-VxNcXLdi.mjs';
6
- import '../settingsParser-CcGvtmCK.mjs';
7
-
8
- /**
9
- * Zip-container READ facade for the DOCX open path.
10
- *
11
- * Backed by the inlined docx-container wasm (see ./wasm): every non-directory
12
- * entry is inflated in Rust — with the decompression-bomb and path-traversal
13
- * guards enforced there by construction — and exposed as a normalized, eager
14
- * read view. Consumers pull parts by path.
15
- *
16
- * Read path only. The write/rezip builder assembles a parts map and hands it
17
- * to the same wasm container via `rezipContainer` (see ./rezip).
18
- */
19
- /**
20
- * Eager, normalized read view of an OPC (DOCX) container. All entries are
21
- * already materialized; lookups are synchronous.
22
- */
23
- interface ZipContainerReader {
24
- paths(): string[];
25
- file(path: string): Uint8Array | null;
26
- text(path: string): string | null;
27
- }
28
-
29
- /**
30
- * Legacy raw-package shape retained for the public rezip compatibility
31
- * signature. Live parsing no longer constructs it; Rust S9 owns extraction.
32
- */
33
- interface RawDocxContent {
34
- documentXml: string | null;
35
- stylesXml: string | null;
36
- themeXml: string | null;
37
- numberingXml: string | null;
38
- fontTableXml: string | null;
39
- settingsXml: string | null;
40
- webSettingsXml: string | null;
41
- headers: Map<string, string>;
42
- footers: Map<string, string>;
43
- footnotesXml: string | null;
44
- endnotesXml: string | null;
45
- commentsXml: string | null;
46
- commentsExtensibleXml: string | null;
47
- commentsExtendedXml: string | null;
48
- documentRels: string | null;
49
- packageRels: string | null;
50
- contentTypesXml: string | null;
51
- corePropsXml: string | null;
52
- appPropsXml: string | null;
53
- customPropsXml: string | null;
54
- media: Map<string, ArrayBuffer>;
55
- fonts: Map<string, ArrayBuffer>;
56
- allXml: Map<string, string>;
57
- container: ZipContainerReader;
58
- originalBuffer: ArrayBuffer;
59
- }
60
-
61
- /**
62
- * Part Enumeration
63
- *
64
- * Shared helpers for walking the parts of a DOCX package (body, headers,
65
- * footers, footnotes, endnotes) when registering newly inserted images and
66
- * hyperlinks against each part's rels file.
67
- */
68
-
69
- /**
70
- * The assembled DOCX package as a `path -> bytes` map. Both the full-repack and
71
- * selective-save flows build one of these and hand it to the wasm container.
72
- */
73
- type PartsMap = Map<string, Uint8Array>;
74
- /**
75
- * Find the highest rId number in a relationships XML string.
76
- */
77
- declare function findMaxRId(relsXml: string): number;
78
-
79
- /**
80
- * Empty DOCX Template
81
- *
82
- * Produces a minimal valid DOCX package — Content Types, package + document
83
- * rels, an empty body with the standard letter-size section, default
84
- * Calibri 11 styles, and core/app properties. Used as the base for
85
- * `createDocx()` when the caller has no existing buffer.
86
- */
87
- /**
88
- * Create a new empty DOCX file.
89
- *
90
- * @returns Promise resolving to minimal DOCX as ArrayBuffer
91
- */
92
- declare function createEmptyDocx(): Promise<ArrayBuffer>;
93
-
94
- /**
95
- * Public DOCX package I/O wrappers.
96
- *
97
- * Model serialization and selective package writing are Rust-owned. The
98
- * TypeScript kept here is compatibility glue for public ZIP utilities and host
99
- * values; package inflation/deflation continues through `docx-container` wasm.
100
- * @packageDocumentation
101
- * @public
102
- */
103
-
104
- declare const COMMENTS_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml";
105
- declare const COMMENTS_EXTENDED_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml";
106
- declare const COMMENTS_IDS_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml";
107
- declare const COMMENTS_EXTENSIBLE_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml";
108
- interface RepackOptions {
109
- /** Retained for signature compatibility; `docx-container` chooses compression. */
110
- compressionLevel?: number;
111
- updateModifiedDate?: boolean;
112
- modifiedBy?: string;
113
- }
114
- /** Repack a public Document through the live Rust S13 writer. */
115
- declare function repackDocx(doc: Document, options?: RepackOptions): Promise<ArrayBuffer>;
116
- declare function repackDocxFromRaw(doc: Document, rawContent: RawDocxContent, options?: RepackOptions): Promise<ArrayBuffer>;
117
- declare function updateDocumentXml(originalBuffer: ArrayBuffer, newDocumentXml: string, options?: RepackOptions): Promise<ArrayBuffer>;
118
- declare function updateXmlFile(originalBuffer: ArrayBuffer, path: string, content: string, options?: RepackOptions): Promise<ArrayBuffer>;
119
- declare function updateMultipleFiles(originalBuffer: ArrayBuffer, updates: Map<string, string | ArrayBuffer>, options?: RepackOptions): Promise<ArrayBuffer>;
120
- declare function applyUpdatesToZip(pkg: PartsMap, updates: Map<string, string | ArrayBuffer>, _options?: RepackOptions): Promise<ArrayBuffer>;
121
- declare function addRelationship(originalBuffer: ArrayBuffer, relationship: {
122
- type: string;
123
- target: string;
124
- targetMode?: 'External' | 'Internal';
125
- }): Promise<{
126
- buffer: ArrayBuffer;
127
- rId: string;
128
- }>;
129
- declare function addMedia(originalBuffer: ArrayBuffer, filename: string, data: ArrayBuffer, mimeType: string): Promise<{
130
- buffer: ArrayBuffer;
131
- rId: string;
132
- path: string;
133
- }>;
134
- declare function updateCoreProperties(corePropsXml: string, options: {
135
- updateModifiedDate?: boolean;
136
- modifiedBy?: string;
137
- }): string;
138
- declare function validateDocx(buffer: ArrayBuffer): Promise<{
139
- valid: boolean;
140
- errors: string[];
141
- warnings: string[];
142
- }>;
143
- declare function isDocxBuffer(buffer: ArrayBuffer): boolean;
144
- declare function createDocx(doc: Document): Promise<ArrayBuffer>;
145
- /** Compatibility helper for callers that update header/footer parts directly. */
146
- declare function collectHeaderFooterUpdates(doc: Document): Map<string, string>;
147
-
148
- export { COMMENTS_CONTENT_TYPE, COMMENTS_EXTENDED_CONTENT_TYPE, COMMENTS_EXTENSIBLE_CONTENT_TYPE, COMMENTS_IDS_CONTENT_TYPE, type PartsMap, type RepackOptions, addMedia, addRelationship, applyUpdatesToZip, collectHeaderFooterUpdates, createDocx, createEmptyDocx, repackDocx as default, findMaxRId, isDocxBuffer, repackDocx, repackDocxFromRaw, updateCoreProperties, updateDocumentXml, updateMultipleFiles, updateXmlFile, validateDocx };
@@ -1 +0,0 @@
1
- export{d as COMMENTS_CONTENT_TYPE,e as COMMENTS_EXTENDED_CONTENT_TYPE,g as COMMENTS_EXTENSIBLE_CONTENT_TYPE,f as COMMENTS_IDS_CONTENT_TYPE,o as addMedia,n as addRelationship,m as applyUpdatesToZip,t as collectHeaderFooterUpdates,s as createDocx,c as createEmptyDocx,u as default,a as findMaxRId,r as isDocxBuffer,h as repackDocx,i as repackDocxFromRaw,p as updateCoreProperties,j as updateDocumentXml,l as updateMultipleFiles,k as updateXmlFile,q as validateDocx}from'../chunk-KVKLLTDP.mjs';import'../chunk-BIQWVK5P.mjs';import'../chunk-H3JCIGWK.mjs';import'../chunk-N5Q3YN64.mjs';import'../chunk-SINEY6ZF.mjs';import'../chunk-T4EZMUXM.mjs';import'../chunk-TTRUPDAB.mjs';
@@ -1,42 +0,0 @@
1
- import { Document } from '../../types/document.mjs';
2
- import { c as DocumentBody, S as SectionProperties, B as BlockContent, C as Comment, E as Endnote, F as Footnote, m as HeaderFooter, P as Paragraph, R as Run, T as Table } from '../../content-sSHuWw49.mjs';
3
- import '../../formatting-DoL7KBSL.mjs';
4
- import '../../styles-VxNcXLdi.mjs';
5
- import '../../settingsParser-CcGvtmCK.mjs';
6
- import '../wrapTypes.mjs';
7
-
8
- /**
9
- * DOCX XML serializers.
10
- *
11
- * The public synchronous serializer surface is retained for compatibility, but
12
- * all OOXML emission is owned by the Rust writer. The fixed context only
13
- * supplies deterministic IDs to standalone XML calls; package saves use the
14
- * source-package hash and clock through {@link ../rustSaveFacade}.
15
- * @packageDocumentation
16
- * @public
17
- */
18
-
19
- /** Serialize a single block content item. */
20
- declare function serializeBlockContent(block: BlockContent): string;
21
- /** Serialize a complete `word/document.xml` part. */
22
- declare function serializeDocument(doc: Document): string;
23
- /** Serialize the contents of `w:body`, without the body tags. */
24
- declare function serializeDocumentBody(body: DocumentBody): string;
25
- /** Serialize section properties. */
26
- declare function serializeSectionProperties(props: SectionProperties | undefined): string;
27
- /** Serialize one paragraph. */
28
- declare function serializeParagraph(paragraph: Paragraph): string;
29
- /** Serialize one run. */
30
- declare function serializeRun(run: Run): string;
31
- /** Serialize one table. */
32
- declare function serializeTable(table: Table): string;
33
- /** Serialize a header or footer part. */
34
- declare function serializeHeaderFooter(hf: HeaderFooter): string;
35
- /** Serialize the comments part. */
36
- declare function serializeComments(comments: Comment[]): string;
37
- /** Serialize the footnotes part. */
38
- declare function serializeFootnotes(footnotes: Footnote[]): string;
39
- /** Serialize the endnotes part. */
40
- declare function serializeEndnotes(endnotes: Endnote[]): string;
41
-
42
- export { serializeBlockContent, serializeComments, serializeDocument, serializeDocumentBody, serializeEndnotes, serializeFootnotes, serializeHeaderFooter, serializeParagraph, serializeRun, serializeSectionProperties, serializeTable };
@@ -1 +0,0 @@
1
- export{a as serializeBlockContent,i as serializeComments,b as serializeDocument,c as serializeDocumentBody,k as serializeEndnotes,j as serializeFootnotes,h as serializeHeaderFooter,e as serializeParagraph,f as serializeRun,d as serializeSectionProperties,g as serializeTable}from'../../chunk-N5Q3YN64.mjs';import'../../chunk-SINEY6ZF.mjs';import'../../chunk-T4EZMUXM.mjs';import'../../chunk-TTRUPDAB.mjs';
@@ -1,37 +0,0 @@
1
- /**
2
- * Structural mark contract consumed by the legacy tree-to-layout adapter.
3
- * @public
4
- */
5
- interface EditorTreeMark {
6
- readonly type: {
7
- readonly name: string;
8
- };
9
- readonly attrs: Record<string, any>;
10
- }
11
- /**
12
- * Structural node contract consumed by renderer-side tree walkers.
13
- *
14
- * The contract deliberately describes only the immutable tree operations the
15
- * renderer needs, so core does not depend on any editor implementation.
16
- * @public
17
- */
18
- interface EditorTreeNode {
19
- readonly type: {
20
- readonly name: string;
21
- create(...args: any[]): EditorTreeNode;
22
- };
23
- readonly attrs: Record<string, any>;
24
- readonly marks: readonly EditorTreeMark[];
25
- readonly nodeSize: number;
26
- readonly content: {
27
- readonly size: number;
28
- };
29
- readonly isText: boolean;
30
- readonly isTextblock: boolean;
31
- readonly isInline: boolean;
32
- readonly text?: string | null;
33
- forEach(callback: (node: EditorTreeNode, offset: number, index: number) => void): void;
34
- descendants(callback: (node: EditorTreeNode, pos: number) => boolean | void): void;
35
- }
36
-
37
- export type { EditorTreeNode as E };
@@ -1 +0,0 @@
1
- export{a as executeCommand,b as executeCommands}from'./chunk-6PW4CWUG.mjs';import'./chunk-KXNZFTTK.mjs';import'./chunk-VBOTMRXV.mjs';import'./chunk-3UBMCDME.mjs';import'./chunk-TTRUPDAB.mjs';
@@ -1,316 +0,0 @@
1
- import { e as LayoutBlock, B as BlockExtent, f as BlockId, L as LayoutOptions, a as Layout, F as FootnoteContent, g as Page, h as FootnoteRenderItem, P as PageMargins, H as HeaderFooterContent, I as ImageRun } from './types-DNrYr6yQ.mjs';
2
- import { a as Theme } from './formatting-DoL7KBSL.mjs';
3
- import { ax as NoteKind, F as Footnote, E as Endnote, m as HeaderFooter } from './content-sSHuWw49.mjs';
4
- import { a as StyleDefinitions } from './styles-VxNcXLdi.mjs';
5
- import { M as MeasuredBlock } from './measuredBlock-DZwz8zhD.mjs';
6
- import { Document } from './types/document.mjs';
7
- import { a as DisplayListQueries, D as DisplayListRect } from './displayListQueries-p-ijSzdh.mjs';
8
-
9
- /**
10
- * Footnote Layout Utilities
11
- *
12
- * Footnote/endnote rendering pipeline plus page-mapping helpers:
13
- * - scanning FlowBlocks for footnote references and their PM positions
14
- * - mapping references to the page that ends up containing them
15
- * - converting a Footnote → FootnoteContent via the body pipeline
16
- * (footnoteToProseDoc → toLayoutBlocks → caller-supplied measureBlocks)
17
- * - reserving per-page footnote area heights for layout
18
- *
19
- * Everything that's pure OOXML / LayoutBlock semantics lives here so the
20
- * React, Vue, and any future adapters can share the conversion logic
21
- * and just supply their own measurement function (which depends on
22
- * platform-specific Canvas/font metrics).
23
- */
24
-
25
- /** Separator line height + vertical padding in pixels. */
26
- declare const FOOTNOTE_SEPARATOR_HEIGHT = 12;
27
- /**
28
- * Gutter between footnote columns when `w15:footnoteColumns` > 1, in pixels
29
- * (≈ 0.25in). Shared by the reserved-height/measurement path (core) and the
30
- * footnote painter so a footnote measured at column width paints into a column
31
- * of exactly that width. Single-column footnotes never consult it.
32
- */
33
- declare const FOOTNOTE_COLUMN_GAP_PX = 24;
34
- /**
35
- * Hard cap on the multi-pass footnote layout loop. Reserving footnote
36
- * space can move a reference to another page, so adapters keep remapping
37
- * until the page→height contract is stable. Dense layouts converge in
38
- * 2–3 passes in practice; 6 is a safe ceiling.
39
- */
40
- declare const MAX_FOOTNOTE_LAYOUT_PASSES = 6;
41
- /**
42
- * Compare two per-page footnote reservation maps. Used by the React +
43
- * Vue adapters to detect when the multi-pass loop has converged.
44
- */
45
- declare function footnoteReservedHeightsEqual(a: Map<number, number>, b: Map<number, number>): boolean;
46
- /**
47
- * Where a footnote reference lives, as found by {@link collectFootnoteRefs}.
48
- *
49
- * `pmPos` alone is enough to attribute a reference to a page for ordinary
50
- * (paragraph) content, whose fragments carry a per-page pm sub-range. A table
51
- * is different: it splits across pages by ROW, but every `TableFragment` keeps
52
- * the whole table's `pmStart`/`pmEnd` (those drive selection mapping and must
53
- * not be narrowed). So for a reference authored inside a table cell we also
54
- * record the OUTERMOST table's id and the index of the row that contains it,
55
- * letting {@link mapFootnotesToPages} attribute the reference to the page that
56
- * actually laid out that row.
57
- */
58
- type FootnoteRefLocation = {
59
- footnoteId: number;
60
- pmPos: number;
61
- /** Undefined preserves the legacy footnote-only shape. */
62
- noteKind?: NoteKind;
63
- /** Id of the outermost enclosing table block, when the ref is in a table cell. */
64
- tableBlockId?: BlockId;
65
- /** Index (into the outermost table's `rows`) of the row holding the ref. */
66
- rowIndex?: number;
67
- };
68
- /**
69
- * Scan FlowBlocks for runs with footnoteRefId set.
70
- * Returns a list of {@link FootnoteRefLocation} in document order.
71
- *
72
- * Recurses into container blocks (table cells, text boxes) so footnote
73
- * references authored anywhere in the body reach the page-reservation
74
- * pass. Without this, a `footnoteRefId` nested inside a table cell never
75
- * gets mapped to a page and the per-page `.layout-footnote-area` silently
76
- * drops that entry even though the body still renders the in-line ref
77
- * marker.
78
- *
79
- * For refs inside a table, the OUTERMOST table's id and row index are
80
- * recorded (a nested table keeps the outer context, since the outer row is
81
- * what the paginator splits into per-page fragments).
82
- */
83
- declare function collectFootnoteRefs(blocks: LayoutBlock[]): FootnoteRefLocation[];
84
- /**
85
- * After layout, determine which footnotes appear on which pages.
86
- * Checks each page's fragments to see if any footnoteRef PM positions fall within.
87
- *
88
- * Returns Map<pageNumber, footnoteId[]> in document order.
89
- */
90
- declare function mapFootnotesToPages(pages: Page[], footnoteRefs: FootnoteRefLocation[]): Map<number, number[]>;
91
- /**
92
- * Footnote-specific block normalization. Mirrors the spirit of
93
- * `normalizeHeaderFooterMeasureBlocks`: post-process the body-pipeline
94
- * output for a single footnote so it carries the correct visual prefix
95
- * (its display number, rendered as a superscript) and a default 8pt font
96
- * for any run that didn't specify a size.
97
- *
98
- * The displayNumber is prepended onto the FIRST paragraph as a fresh
99
- * superscript text run — visually matches Word's footnote numbering
100
- * without disturbing the authored runs.
101
- *
102
- * Exported for callers that want to compose their own conversion
103
- * pipeline; `convertFootnoteToContent` calls it as part of its flow.
104
- */
105
- declare function applyFootnotePresentation(blocks: LayoutBlock[], displayNumber: number, displayLabel?: string): LayoutBlock[];
106
- /**
107
- * Adapter-supplied block measurement function. The caller (React /
108
- * Vue / etc.) supplies its platform's measure routine — at minimum
109
- * paragraph + table + image + textBox — so this core helper stays
110
- * Canvas-free.
111
- */
112
- type MeasureBlocksFn = (blocks: LayoutBlock[], contentWidth: number) => BlockExtent[];
113
- /**
114
- * Options for {@link convertFootnoteToContent}.
115
- */
116
- type ConvertFootnoteOptions = {
117
- /** The document's parsed style definitions, threaded into the body pipeline. */
118
- styles?: StyleDefinitions | null;
119
- /** Theme for resolving themed fills / fonts inside the footnote. */
120
- theme?: Theme | null;
121
- /** Authoritative yrs story source. */
122
- yrsStoryBlocks?: (storyId: string) => LayoutBlock[] | null;
123
- /** BlockExtent callback supplied by the rendering adapter. */
124
- measureBlocks: MeasureBlocksFn;
125
- /**
126
- * Doc-level `w:defaultTabStop` (twips) from the body so list markers
127
- * inside footnotes honor the same tab grid.
128
- */
129
- defaultTabStopTwips?: number | null;
130
- };
131
- /**
132
- * Convert a Footnote to renderable FootnoteContent via the body pipeline:
133
- * `footnoteToProseDoc → toLayoutBlocks → applyFootnotePresentation →
134
- * measureBlocks`. Pre-PR (#378) this lived in a hand-rolled shadow stack
135
- * that silently dropped non-paragraph content; routing through the body
136
- * pipeline gives footnotes full block-kind support — paragraph + table
137
- * + image + textBox + fields.
138
- */
139
- declare function convertFootnoteToContent(footnote: Footnote | Endnote, displayNumber: number, contentWidth: number, options: ConvertFootnoteOptions, presentation?: {
140
- noteKind?: NoteKind;
141
- displayLabel?: string;
142
- anchor?: FootnoteContent['anchor'];
143
- }): FootnoteContent;
144
- /**
145
- * Build footnote content for all footnotes referenced in the document.
146
- * Display numbers are assigned by first-appearance order (the same way
147
- * Word renders them).
148
- */
149
- declare function buildFootnoteContentMap(footnotes: Footnote[], footnoteRefs: Array<{
150
- footnoteId: number;
151
- }>, contentWidth: number | ((ref: {
152
- footnoteId: number;
153
- }) => number), options: ConvertFootnoteOptions): Map<number, FootnoteContent>;
154
- /**
155
- * Distribute footnote items across `columns` balanced columns, preserving
156
- * document order (footnotes must still read in numeric sequence). Items fill
157
- * the first column until it reaches the balanced target height (≈ total / N),
158
- * then spill into the next column — the same order-preserving balance Word
159
- * applies to its footnote columns, not a greedy shortest-column packing
160
- * (which would scramble the reading order).
161
- *
162
- * `columns <= 1` (the default for ordinary single-column footnotes) returns a
163
- * single column unchanged, so callers that never opt into multi-column
164
- * footnotes are byte-for-byte unaffected.
165
- *
166
- * Pure and shared by the reserved-height calculation (core) and the
167
- * display-list footnote emission so the reserved area and the rendered
168
- * columns are computed from the same partition.
169
- */
170
- declare function distributeFootnotesIntoColumns<T extends {
171
- height: number;
172
- }>(items: T[], columns: number): T[][];
173
- /**
174
- * Calculate per-page footnote reserved heights.
175
- * Returns Map<pageNumber, reservedHeight>.
176
- *
177
- * With `columns > 1` the footnotes are balanced across that many columns and
178
- * the reserved height is the tallest column (plus the separator), since the
179
- * columns sit side by side — not the sum of every footnote height.
180
- */
181
- declare function calculateFootnoteReservedHeights(pageFootnoteMap: Map<number, number[]>, footnoteContentMap: Map<number, {
182
- height: number;
183
- noteKind?: NoteKind;
184
- }>, columns?: number | Map<number, number>): Map<number, number>;
185
- interface StabilizeFootnoteLayoutArgs {
186
- blocks: LayoutBlock[];
187
- measures: BlockExtent[];
188
- layoutOpts: LayoutOptions;
189
- /**
190
- * The pagination kernel each stabilization iteration re-enters — the
191
- * caller binds this to the mandatory Rust pagination source
192
- * (`LayoutPaginationSource.paginate`). Throws on engine failure; the
193
- * pipeline surfaces the error.
194
- */
195
- paginate: (measured: MeasuredBlock[], options: LayoutOptions) => Layout;
196
- footnoteRefs: FootnoteRefLocation[];
197
- footnoteContentMap: Map<number, FootnoteContent>;
198
- /** First-pass layout already computed by the caller without reserved heights. */
199
- initialLayout: Layout;
200
- /**
201
- * Number of columns the footnote area is laid out in (`w15:footnoteColumns`).
202
- * Defaults to 1. When > 1, reserved heights are balanced across the columns
203
- * (tallest column wins) instead of summing every footnote, and the value is
204
- * written onto each footnote-bearing page as `page.footnoteColumns`.
205
- */
206
- footnoteColumns?: number | Map<number, number>;
207
- /** Placement-aware mapper; defaults to legacy reference-page mapping. */
208
- mapReferencesToPages?: (pages: Page[], refs: FootnoteRefLocation[]) => Map<number, number[]>;
209
- }
210
- interface StabilizeFootnoteLayoutResult {
211
- layout: Layout;
212
- pageFootnoteMap: Map<number, number[]>;
213
- /** True if the loop converged before hitting MAX_FOOTNOTE_LAYOUT_PASSES. */
214
- converged: boolean;
215
- }
216
- /**
217
- * Run the multi-pass footnote layout loop. Reserving footnote space on a
218
- * page can move a reference to another page, which changes the reservation,
219
- * which can move references again. Iterate until the page→height contract
220
- * is the same one used by the latest layout, or `MAX_FOOTNOTE_LAYOUT_PASSES`
221
- * passes have run.
222
- *
223
- * Lives in core so the React + Vue adapters call the same loop and stay in
224
- * lockstep on convergence behaviour. Writes `page.footnoteIds` onto each
225
- * page in the returned layout so renderers can paint footnote areas.
226
- */
227
- declare function stabilizeFootnoteLayout(args: StabilizeFootnoteLayoutArgs): StabilizeFootnoteLayoutResult;
228
- /**
229
- * Turn the page→footnote-id map into the per-page render payload that
230
- * `renderPages` consumes via `footnotesByPage`. Skips non-`normal` notes
231
- * (separators, continuation notices), reads the display number out of the
232
- * content map, and pulls plain text via `getFootnoteText`.
233
- *
234
- * Lives in core (not in either adapter) so React + Vue both call the
235
- * same helper — same rule as the rest of this module.
236
- */
237
- declare function buildFootnoteRenderItems(pageFootnoteMap: Map<number, number[]>, footnoteContentMap: Map<number, FootnoteContent>, doc: Document | null): Map<number, FootnoteRenderItem[]>;
238
-
239
- /**
240
- * Header / Footer Layout Utilities
241
- *
242
- * The header/footer rendering pipeline lives here so any rendering adapter
243
- * (React, Vue, etc.) can share the conversion logic and just supply its
244
- * platform-specific {@link MeasureBlocksFn}. Mirrors the footnote pipeline
245
- * in `footnoteLayout.ts`.
246
- *
247
- * Pipeline:
248
- * HF.content → headerFooterToProseDoc → toLayoutBlocks
249
- * → measureBlocks (caller-supplied, Canvas-aware)
250
- * → HeaderFooterContent (blocks, measures, height, visualTop/Bottom)
251
- *
252
- * The render side uses the normalized block list so paint and measurement stay
253
- * in lockstep. Visual-bounds calculation still inspects the original block
254
- * list because floating images can paint above/below the nominal flow box even
255
- * when they do not contribute to flow height.
256
- */
257
-
258
- type HeaderFooterMetrics = {
259
- section: 'header' | 'footer';
260
- pageSize: {
261
- w: number;
262
- h: number;
263
- };
264
- margins: PageMargins;
265
- };
266
- declare function normalizeHeaderFooterMeasureBlocks(blocks: LayoutBlock[]): LayoutBlock[];
267
- declare function resolveHeaderFooterVisualTop(run: ImageRun, paragraphY: number, flowHeight: number, metrics: HeaderFooterMetrics): number;
268
- /**
269
- * Whether a header/footer block participates in the in-flow band height that
270
- * pushes the body margin.
271
- *
272
- * OOXML semantics: Word grows the header/footer band — and shifts body text —
273
- * based only on the story's in-flow content. A floating/anchored object
274
- * (`wp:anchor` DrawingML or an absolutely-positioned VML shape, e.g. a
275
- * full-page letterhead anchored to the page in a header) is removed from the
276
- * text flow and positioned on the page; it does NOT grow the band or push the
277
- * body. So only inline-flow blocks count here. Anchored image *runs* inside a
278
- * paragraph are likewise out of flow, but they don't contribute to the
279
- * paragraph's measured line height, so paragraphs need no special handling.
280
- *
281
- * @public
282
- */
283
- declare function contributesToHeaderFooterFlowHeight(block: LayoutBlock): boolean;
284
- declare function calculateHeaderFooterVisualBounds(blocks: LayoutBlock[], measures: BlockExtent[], flowHeight: number, metrics: HeaderFooterMetrics): {
285
- visualTop: number;
286
- visualBottom: number;
287
- };
288
- type ConvertHeaderFooterOptions = {
289
- styles?: StyleDefinitions | null;
290
- theme?: Theme | null;
291
- measureBlocks: MeasureBlocksFn;
292
- /** Authoritative yrs story source. */
293
- yrsStoryBlocks?: (storyId: string) => LayoutBlock[] | null;
294
- /**
295
- * `w:defaultTabStop` (twips) read from `state.doc.attrs.defaultTabStopTwips`
296
- * on the body doc — HF content doesn't carry its own doc-level setting,
297
- * so pass it through so list markers inside headers/footers honor the
298
- * same tab grid as the body.
299
- */
300
- defaultTabStopTwips?: number | null;
301
- };
302
- /**
303
- * Convert HeaderFooter (document type) to HeaderFooterContent (render type).
304
- *
305
- * Routes through the same pipeline as the body: HF.content →
306
- * headerFooterToProseDoc → toLayoutBlocks → measureBlocks. The inline editor
307
- * uses the same conversion chain, so block support (paragraph, table, image,
308
- * textBox, fields) and the inline editor's content stay in lockstep.
309
- */
310
- declare function convertHeaderFooterToContent(headerFooter: HeaderFooter | null | undefined, contentWidth: number, metrics: HeaderFooterMetrics, options: ConvertHeaderFooterOptions, hfStoryId?: string): HeaderFooterContent | undefined;
311
- /** Query-backed HF caret geometry, optionally narrowed to the edited page. */
312
- declare function computeHfCaretRectsFromDisplayList(queries: DisplayListQueries, section: 'header' | 'footer', rId: string, pos: number, pageIndex?: number): DisplayListRect[];
313
- /** Query-backed HF selection geometry, optionally narrowed to the edited page. */
314
- declare function computeHfSelectionRectsFromDisplayList(queries: DisplayListQueries, section: 'header' | 'footer', rId: string, from: number, to: number, pageIndex?: number): DisplayListRect[];
315
-
316
- export { type ConvertFootnoteOptions as C, FOOTNOTE_COLUMN_GAP_PX as F, type HeaderFooterMetrics as H, MAX_FOOTNOTE_LAYOUT_PASSES as M, type StabilizeFootnoteLayoutArgs as S, type ConvertHeaderFooterOptions as a, FOOTNOTE_SEPARATOR_HEIGHT as b, type FootnoteRefLocation as c, type MeasureBlocksFn as d, type StabilizeFootnoteLayoutResult as e, applyFootnotePresentation as f, buildFootnoteContentMap as g, buildFootnoteRenderItems as h, calculateFootnoteReservedHeights as i, calculateHeaderFooterVisualBounds as j, collectFootnoteRefs as k, computeHfCaretRectsFromDisplayList as l, computeHfSelectionRectsFromDisplayList as m, contributesToHeaderFooterFlowHeight as n, convertFootnoteToContent as o, convertHeaderFooterToContent as p, distributeFootnotesIntoColumns as q, footnoteReservedHeightsEqual as r, mapFootnotesToPages as s, normalizeHeaderFooterMeasureBlocks as t, resolveHeaderFooterVisualTop as u, stabilizeFootnoteLayout as v };
@@ -1,69 +0,0 @@
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
- export { ContentControlBoundError, ContentControlCreateError, ContentControlFilter, ContentControlInfo, ContentControlKindError, ContentControlLocation, ContentControlLockedError, ContentControlNotFoundError, ContentControlTypeError, ContentControlValue, ContentControlValueError, CreateContentControlTarget, FindContentControlsOptions, NewContentControlProps, 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 } from './agent/index.mjs';
3
- export { parseDocx } from './docx/parser.mjs';
4
- export { serializeDocumentBody, serializeDocument as serializeDocx, serializeSectionProperties } from './docx/serializer/index.mjs';
5
- export { createDocx, default as repackDocx, updateMultipleFiles } from './docx/rezip.mjs';
6
- export { g as getDocumentWatermark, s as setDocumentWatermark } from './watermarkApi-DCxjutkg.mjs';
7
- export { a as attemptSelectiveSave } from './selectiveSave-oFBJ1n71.mjs';
8
- export { b as buildPatchedDocumentXml, v as validatePatchSafety } from './selectiveXmlPatch-ypkxlTD_.mjs';
9
- export { C as CreateEmptyDocumentOptions, P as ProcessTemplateOptions, a as ProcessTemplateResult, T as TemplateError, c as colorsEqual, b as createDocumentWithText, d as createEmptyDocument, e as createRgbColor, f as createTemplateProcessor, g as createThemeColor, h as getMissingVariables, i as getTemplateTags, j as isBlack, k as isWhite, p as parseColorString, l as previewTemplate, m as processTemplate, n as processTemplateAdvanced, o as processTemplateAsBlob, q as processTemplateDetailed, r as resolveHighlightColor, s as resolveShadingColor, v as validateTemplate } from './colorResolver-n0o7H7ep.mjs';
10
- export { V as VariableDetectionResult, a as VariableOccurrence, d as detectVariables, b as detectVariablesDetailed, c as detectVariablesInBody, e as detectVariablesInParagraph, f as documentHasVariables, g as extractVariablesFromText, h as formatVariable, i as hasTemplateVariables, j as isValidVariableName, p as parseVariable, r as removeVariables, k as replaceVariables, s as sanitizeVariableName } from './variableDetector-Borj29SF.mjs';
11
- export { emuToTwips, formatPx, halfPointsToPixels, pixelsToTwips, pointsToHalfPoints, twipsToEmu, twipsToPixels } from './utils/units.mjs';
12
- export { mapHexToHighlightName } from './utils/highlightColors.mjs';
13
- export { C as CommandHandler, a as CommandResult, b as CorePlugin, J as JsonSchema, L as LoadedDocument, M as McpSession, c as McpToolAnnotations, d as McpToolContent, e as McpToolContext, f as McpToolDefinition, g as McpToolHandler, h as McpToolResult, b as Plugin, P as PluginCommand, C as PluginCommandHandler, i as PluginEvent, j as PluginEventListener, k as PluginOptions, l as PluginRegistrationResult, f as ToolDefinition, g as ToolHandler, h as ToolResult, Z as ZodSchemaLike, m as isZodSchema } from './types-dYdjUZMo.mjs';
14
- export { P as PluginRegistry, c as createPluginRegistrar, p as pluginRegistry, r as registerPlugins } from './registry-DMM5VTdT.mjs';
15
- export { Document, DocxPackage } from './types/document.mjs';
16
- export { AIAction, AIActionRequest, AgentCommand, AgentContext, AgentResponse, ApplyStyleCommand, ApplyVariablesCommand, DEFAULT_AI_ACTIONS, DeleteTextCommand, FormatParagraphCommand, FormatTextCommand, InsertHyperlinkCommand, InsertImageCommand, InsertTableCommand, InsertTextCommand, ParagraphContext, ParagraphOutline, Position, Range, ReplaceTextCommand, SectionInfo, SelectionContext, SetVariableCommand, StyleInfo, SuggestedAction, comparePositions, createCollapsedRange, createCommand, createRange, getActionDescription, getActionLabel, isPositionInRange } from './types/agentApi.mjs';
17
- export { B as BlockContent, C as Comment, a as CommentRangeEnd, b as CommentRangeStart, D as Deletion, c as DocumentBody, E as Endnote, F as Footnote, H as Hyperlink, I as Image, d as Insertion, L as ListLevel, M as MoveFrom, e as MoveTo, N as NumberingDefinitions, P as Paragraph, f as ParagraphContent, R as Run, g as RunContent, S as SectionProperties, T as Table, h as TableCell, i as TableRow, j as TextContent, k as TrackedChangeInfo, l as TrackedRunChange } from './content-sSHuWw49.mjs';
18
- export { P as ParagraphFormatting, T as TextFormatting, a as Theme, b as blendColors, d as darkenColor, g as getContrastingColor, l as lightenColor, r as resolveColor } from './formatting-DoL7KBSL.mjs';
19
- export { R as Relationship, S as Style, a as StyleDefinitions } from './styles-VxNcXLdi.mjs';
20
- export { e as emuToPixels, p as pixelsToEmu, a as pointsToPixels } from './units-O5Y02RKQ.mjs';
21
- import './docxInput-DTbCa48g.mjs';
22
- import './settingsParser-CcGvtmCK.mjs';
23
- import './docx/wrapTypes.mjs';
24
-
25
- /**
26
- * @betteroffice/docx/headless
27
- *
28
- * Headless aggregate for Node.js scripts, CLI tools, and server-side
29
- * processing. Same surface as the default `.` entry, named to make the
30
- * "no DOM" intent explicit. Prefer the smaller subpaths (`./docx`,
31
- * `./agent`, `./utils`, etc.) for new code — they tree-shake better.
32
- *
33
- * @example
34
- * ```ts
35
- * import { DocumentAgent, parseDocx, pluginRegistry } from '@betteroffice/docx/headless';
36
- * import { docxtemplaterPlugin } from '@betteroffice/docx/core-plugins';
37
- *
38
- * // Register plugins
39
- * pluginRegistry.register(docxtemplaterPlugin);
40
- *
41
- * // Load and manipulate document
42
- * const buffer = fs.readFileSync('template.docx');
43
- * const agent = await DocumentAgent.fromBuffer(buffer);
44
- *
45
- * // Get document info
46
- * console.log('Word count:', agent.getWordCount());
47
- * console.log('Variables:', agent.getVariables());
48
- *
49
- * // Edit document
50
- * const newAgent = agent
51
- * .insertText({ paragraphIndex: 0, offset: 0 }, 'Hello ')
52
- * .applyStyle(0, 'Heading1');
53
- *
54
- * // Apply template variables
55
- * const finalAgent = await newAgent.applyVariables({
56
- * customer_name: 'Jane Doe',
57
- * date: '2024-02-15',
58
- * });
59
- *
60
- * // Export
61
- * const output = await finalAgent.toBuffer();
62
- * fs.writeFileSync('output.docx', Buffer.from(output));
63
- * ```
64
- * @packageDocumentation
65
- * @public
66
- */
67
- declare const VERSION = "0.0.2";
68
-
69
- export { VERSION };
package/dist/headless.mjs DELETED
@@ -1 +0,0 @@
1
- export{b as mapHexToHighlightName}from'./chunk-YCIH2Q3E.mjs';export{b as createDocumentWithText,a as createEmptyDocument}from'./chunk-VAOUFAUH.mjs';export{j as colorsEqual,g as createRgbColor,f as createThemeColor,c as isBlack,d as isWhite,e as parseColorString,a as resolveHighlightColor,b as resolveShadingColor}from'./chunk-L5ISVQ3W.mjs';export{a as isZodSchema}from'./chunk-XYH6XWP3.mjs';export{j as createTemplateProcessor,g as getMissingVariables,e as getTemplateTags,h as previewTemplate,a as processTemplate,i as processTemplateAdvanced,c as processTemplateAsBlob,b as processTemplateDetailed,f as validateTemplate}from'./chunk-O2QSE2I7.mjs';export{a as getDocumentWatermark,b as setDocumentWatermark}from'./chunk-WAUF2UC7.mjs';export{b as buildPatchedDocumentXml,a as validatePatchSafety}from'./chunk-KEE52TT5.mjs';export{i as blendColors,g as darkenColor,f as getContrastingColor,h as lightenColor,d as resolveColor}from'./chunk-FZIA7OFY.mjs';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';export{a as detectVariables,b as detectVariablesDetailed,c as detectVariablesInBody,d as detectVariablesInParagraph,m as documentHasVariables,e as extractVariablesFromText,i as formatVariable,f as hasTemplateVariables,g as isValidVariableName,j as parseVariable,l as removeVariables,k as replaceVariables,h as sanitizeVariableName}from'./chunk-UIEJWORW.mjs';export{a as executeCommand,b as executeCommands}from'./chunk-6PW4CWUG.mjs';import'./chunk-KXNZFTTK.mjs';export{a as PluginRegistry,d as createPluginRegistrar,b as pluginRegistry,c as registerPlugins}from'./chunk-VBOTMRXV.mjs';export{a as attemptSelectiveSave}from'./chunk-OJOHXQNQ.mjs';export{s as createDocx,h as repackDocx,l as updateMultipleFiles}from'./chunk-KVKLLTDP.mjs';import'./chunk-BIQWVK5P.mjs';export{b as emuToPixels,i as emuToTwips,q as formatPx,k as halfPointsToPixels,c as pixelsToEmu,h as pixelsToTwips,m as pointsToHalfPoints,d as pointsToPixels,j as twipsToEmu,g as twipsToPixels}from'./chunk-3UBMCDME.mjs';export{a as parseDocx}from'./chunk-LDUWIM7M.mjs';import'./chunk-DXKG3HQ5.mjs';import'./chunk-FPZBTOD6.mjs';import'./chunk-H3JCIGWK.mjs';export{c as serializeDocumentBody,b as serializeDocx,d as serializeSectionProperties}from'./chunk-N5Q3YN64.mjs';import'./chunk-SINEY6ZF.mjs';import'./chunk-T4EZMUXM.mjs';import'./chunk-TTRUPDAB.mjs';var Pt="0.0.2";export{Pt as VERSION};