documentation-hub 5.7.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 (271) hide show
  1. package/.eslintrc.json +43 -0
  2. package/.github/workflows/build.yml +64 -0
  3. package/.github/workflows/ci.yml +39 -0
  4. package/.vscode/extensions.json +3 -0
  5. package/Current.md +97 -0
  6. package/DocHub_Image.png +0 -0
  7. package/README.md +666 -0
  8. package/USER_GUIDE.md +1173 -0
  9. package/Updater.md +311 -0
  10. package/build/256x256.png +0 -0
  11. package/build/512x512.png +0 -0
  12. package/build/app-update.yml +4 -0
  13. package/build/create-icon.js +208 -0
  14. package/build/icon.ico +0 -0
  15. package/build/icon.png +0 -0
  16. package/build/icon_1024x1024.png +0 -0
  17. package/dist/assets/Analytics-BpsG9895.js +1 -0
  18. package/dist/assets/Card-IAZin8kp.js +1 -0
  19. package/dist/assets/CurrentSession-B-rFkHvf.js +12 -0
  20. package/dist/assets/Dashboard-C_5gMb0q.js +1 -0
  21. package/dist/assets/Documents-CqZ25axS.js +1 -0
  22. package/dist/assets/Input-l89xwXBi.js +1 -0
  23. package/dist/assets/Reporting-DqdHJY_a.js +1 -0
  24. package/dist/assets/Search-XNbu5z_3.js +1 -0
  25. package/dist/assets/SessionManager-lH9hZfzH.js +1 -0
  26. package/dist/assets/Sessions-ClZOPYNc.js +1 -0
  27. package/dist/assets/Settings-DUEHGURa.js +11 -0
  28. package/dist/assets/index-8xUe8ptc.js +24 -0
  29. package/dist/assets/index-RYyJqF7O.css +1 -0
  30. package/dist/assets/path-BkOl0AGO.js +1 -0
  31. package/dist/assets/promises-ID_B9S-h.js +1 -0
  32. package/dist/assets/urlHelpers-TvgahX0r.js +1 -0
  33. package/dist/assets/useToast-yRSO1dkm.js +1 -0
  34. package/dist/assets/vendor-charts-RkGK5ROP.js +36 -0
  35. package/dist/assets/vendor-db-l0sNRNKZ.js +1 -0
  36. package/dist/assets/vendor-react-BVZ_anCF.js +4 -0
  37. package/dist/assets/vendor-search-Dw8P0qyA.js +1 -0
  38. package/dist/assets/vendor-ui-BU7NfluV.js +53 -0
  39. package/dist/electron/PowerAutomateApiService-LfW09ZGr.js +147 -0
  40. package/dist/electron/main-CXkNtyv-.js +19789 -0
  41. package/dist/electron/main.js +5 -0
  42. package/dist/electron/preload.js +1 -0
  43. package/dist/icon.png +0 -0
  44. package/dist/index.html +27 -0
  45. package/docs/CODEBASE_ANALYSIS_REPORT.md +309 -0
  46. package/docs/DEBUG_LOGGING_GUIDE.md +244 -0
  47. package/docs/README.md +115 -0
  48. package/docs/TOC_WIRING_GUIDE.md +344 -0
  49. package/docs/analysis/Bullet_Symbol_Bug_Analysis.md +136 -0
  50. package/docs/analysis/DOCXMLATER_ANALYSIS_SUMMARY.txt +169 -0
  51. package/docs/analysis/Document_Processing_Issues_Analysis.md +704 -0
  52. package/docs/analysis/FIELD_PRESERVATION_ANALYSIS.md +1200 -0
  53. package/docs/analysis/INDENTATION_PRESERVE_ANALYSIS.md +181 -0
  54. package/docs/analysis/INDENTATION_PRESERVE_IMPLEMENTATION.md +207 -0
  55. package/docs/analysis/List_Implementation.md +206 -0
  56. package/docs/analysis/List_Implementation_Accuracy_Report.md +366 -0
  57. package/docs/analysis/PROCESSING_OPTIONS_UI_UPDATES.md +220 -0
  58. package/docs/analysis/RefactorStyles.md +852 -0
  59. package/docs/analysis/STYLE_PARAMETER_ENHANCEMENT.md +143 -0
  60. package/docs/analysis/docxmlater-comparison-todo-2025-11-13.md +636 -0
  61. package/docs/analysis/docxmlater-implementation-analysis-2025-11-13.md +340 -0
  62. package/docs/analysis/docxmlater-template_ui-integration-analysis.md +263 -0
  63. package/docs/analysis/github-issues-to-create.md +237 -0
  64. package/docs/api/API_README.md +538 -0
  65. package/docs/api/API_REFERENCE.md +751 -0
  66. package/docs/api/TYPE_DEFINITIONS.md +869 -0
  67. package/docs/architecture/FONT_EMBEDDING_GUIDE.md +318 -0
  68. package/docs/architecture/docxmlater-functions-and-structure.md +726 -0
  69. package/docs/docxmlater-readme.md +1341 -0
  70. package/docs/fixes/EXECUTION_LOG_TEST_BASE.md +573 -0
  71. package/docs/fixes/HYPERLINK_TEXT_SANITIZATION.md +253 -0
  72. package/docs/fixes/README.md +37 -0
  73. package/docs/github-issues/issue-1-body.md +125 -0
  74. package/docs/github-issues/issue-10-body.md +850 -0
  75. package/docs/github-issues/issue-2-body.md +200 -0
  76. package/docs/github-issues/issue-3-body.md +270 -0
  77. package/docs/github-issues/issue-4-body.md +169 -0
  78. package/docs/github-issues/issue-5-body.md +173 -0
  79. package/docs/github-issues/issue-6-body.md +158 -0
  80. package/docs/github-issues/issue-7-body.md +171 -0
  81. package/docs/github-issues/issue-8-body.md +407 -0
  82. package/docs/github-issues/issue-9-body.md +515 -0
  83. package/docs/github-issues/issue-tracker.md +274 -0
  84. package/docs/github-issues/predictive-analysis-2025-10-18.md +2131 -0
  85. package/docs/implementation/List_Framework_Refactor_Plan.md +336 -0
  86. package/docs/implementation/PRIMARY_TEXT_COLOR_FEATURE.md +217 -0
  87. package/docs/implementation/RELEASE_PLAN_v2.1.0.md +362 -0
  88. package/docs/implementation/RefactorStyles.md +588 -0
  89. package/docs/implementation/implement-plan.md +489 -0
  90. package/docs/implementation/missing-helpers-implementation.md +391 -0
  91. package/docs/implementation/refactor-plan.md +520 -0
  92. package/docs/implementation/session-implementation-complete.md +233 -0
  93. package/docs/implementation/session-management-plan.md +250 -0
  94. package/docs/setup-checklist.md +77 -0
  95. package/docs/versions/changelog.md +345 -0
  96. package/electron/customUpdater.ts +656 -0
  97. package/electron/main.ts +2441 -0
  98. package/electron/memoryConfig.ts +187 -0
  99. package/electron/preload.ts +394 -0
  100. package/electron/proxyConfig.ts +340 -0
  101. package/electron/services/BackupService.ts +452 -0
  102. package/electron/services/DictionaryService.ts +402 -0
  103. package/electron/services/LocalDictionaryLookupService.ts +147 -0
  104. package/electron/services/PowerAutomateApiService.ts +231 -0
  105. package/electron/services/SharePointSyncService.ts +474 -0
  106. package/electron/windowsCertStore.ts +427 -0
  107. package/electron/zscalerConfig.ts +381 -0
  108. package/eslint.config.js +92 -0
  109. package/jest.config.js +52 -0
  110. package/package.json +214 -0
  111. package/postcss.config.mjs +6 -0
  112. package/public/icon.png +0 -0
  113. package/publish-release.ps1 +5 -0
  114. package/renovate.json +30 -0
  115. package/src/App.tsx +216 -0
  116. package/src/__mocks__/p-limit.js +12 -0
  117. package/src/__mocks__/styleMock.js +1 -0
  118. package/src/components/common/BugReportButton.tsx +44 -0
  119. package/src/components/common/BugReportDialog.tsx +193 -0
  120. package/src/components/common/Button.tsx +153 -0
  121. package/src/components/common/Card.tsx +86 -0
  122. package/src/components/common/ColorPickerDialog.tsx +177 -0
  123. package/src/components/common/ConfirmDialog.tsx +96 -0
  124. package/src/components/common/DebugConsole.tsx +275 -0
  125. package/src/components/common/EmptyState.tsx +183 -0
  126. package/src/components/common/ErrorBoundary.tsx +98 -0
  127. package/src/components/common/ErrorDetailsDialog.tsx +153 -0
  128. package/src/components/common/ErrorFallback.tsx +218 -0
  129. package/src/components/common/Input.tsx +109 -0
  130. package/src/components/common/Skeleton.tsx +184 -0
  131. package/src/components/common/SplashScreen.tsx +81 -0
  132. package/src/components/common/Toast.tsx +155 -0
  133. package/src/components/common/Tooltip.tsx +79 -0
  134. package/src/components/common/UpdateNotification.tsx +320 -0
  135. package/src/components/comparison/ComparisonWindow.tsx +374 -0
  136. package/src/components/comparison/SideBySideDiff.tsx +486 -0
  137. package/src/components/comparison/index.ts +8 -0
  138. package/src/components/document/DocumentUploader.tsx +288 -0
  139. package/src/components/document/HyperlinkPreview.tsx +430 -0
  140. package/src/components/document/HyperlinkService.md +1484 -0
  141. package/src/components/document/Hyperlink_Technical_Documentation.md +496 -0
  142. package/src/components/document/InlineChangesView.tsx +707 -0
  143. package/src/components/document/ProcessingProgress.tsx +303 -0
  144. package/src/components/document/ProcessingResults.tsx +256 -0
  145. package/src/components/document/TrackedChangesDetail.tsx +530 -0
  146. package/src/components/document/TrackedChangesPanel.tsx +546 -0
  147. package/src/components/document/VirtualDocumentList.tsx +240 -0
  148. package/src/components/editor/DocumentEditor.tsx +723 -0
  149. package/src/components/editor/DocumentEditorModal.tsx +640 -0
  150. package/src/components/editor/EditorQuickActions.tsx +502 -0
  151. package/src/components/editor/EditorToolbar.tsx +312 -0
  152. package/src/components/editor/TableEditor.tsx +926 -0
  153. package/src/components/editor/index.ts +18 -0
  154. package/src/components/layout/Header.tsx +190 -0
  155. package/src/components/layout/Sidebar.tsx +313 -0
  156. package/src/components/layout/TitleBar.tsx +190 -0
  157. package/src/components/navigation/CommandPalette.tsx +233 -0
  158. package/src/components/navigation/KeyboardShortcutsModal.tsx +173 -0
  159. package/src/components/sessions/ChangeItem.tsx +408 -0
  160. package/src/components/sessions/ChangeViewer.tsx +1155 -0
  161. package/src/components/sessions/DocumentComparisonModal.tsx +314 -0
  162. package/src/components/sessions/ProcessingOptions.tsx +297 -0
  163. package/src/components/sessions/ReplacementsTab.tsx +438 -0
  164. package/src/components/sessions/RevisionHandlingOptions.tsx +87 -0
  165. package/src/components/sessions/SessionManager.tsx +188 -0
  166. package/src/components/sessions/StylesEditor.tsx +1335 -0
  167. package/src/components/sessions/TabContainer.tsx +151 -0
  168. package/src/components/sessions/VirtualSessionList.tsx +157 -0
  169. package/src/components/sessions/sessionToProcessorManager.tsx +420 -0
  170. package/src/components/settings/CertificateManager.tsx +410 -0
  171. package/src/components/settings/SegmentedControl.tsx +88 -0
  172. package/src/components/settings/SettingRow.tsx +52 -0
  173. package/src/contexts/GlobalStatsContext.tsx +396 -0
  174. package/src/contexts/SessionContext.tsx +2129 -0
  175. package/src/contexts/ThemeContext.tsx +428 -0
  176. package/src/contexts/UserSettingsContext.tsx +290 -0
  177. package/src/contexts/__tests__/GlobalStatsContext.test.tsx +390 -0
  178. package/src/global.d.ts +273 -0
  179. package/src/hooks/useDocumentQueue.tsx +210 -0
  180. package/src/hooks/useToast.tsx +55 -0
  181. package/src/main.tsx +10 -0
  182. package/src/pages/Analytics.tsx +386 -0
  183. package/src/pages/CurrentSession.tsx +1174 -0
  184. package/src/pages/Dashboard.tsx +319 -0
  185. package/src/pages/Documents.tsx +317 -0
  186. package/src/pages/Projects.tsx +250 -0
  187. package/src/pages/Reporting.tsx +386 -0
  188. package/src/pages/Search.tsx +349 -0
  189. package/src/pages/Sessions.tsx +285 -0
  190. package/src/pages/Settings.tsx +2662 -0
  191. package/src/services/HyperlinkService.ts +1085 -0
  192. package/src/services/document/DocXMLaterProcessor.ts +617 -0
  193. package/src/services/document/DocumentProcessingComparison.ts +856 -0
  194. package/src/services/document/DocumentSnapshotService.ts +575 -0
  195. package/src/services/document/WordDocumentProcessor.ts +10509 -0
  196. package/src/services/document/__tests__/DocXMLaterProcessor.hyperlinks.test.md +311 -0
  197. package/src/services/document/__tests__/WordDocumentProcessor.integration.test.ts +515 -0
  198. package/src/services/document/__tests__/WordDocumentProcessor.test.ts +812 -0
  199. package/src/services/document/blanklines/BlankLineManager.ts +658 -0
  200. package/src/services/document/blanklines/__tests__/paragraphChecks.test.ts +281 -0
  201. package/src/services/document/blanklines/helpers/blankLineInsertion.ts +87 -0
  202. package/src/services/document/blanklines/helpers/blankLineSnapshot.ts +251 -0
  203. package/src/services/document/blanklines/helpers/clearCustom.ts +121 -0
  204. package/src/services/document/blanklines/helpers/contextChecks.ts +117 -0
  205. package/src/services/document/blanklines/helpers/imageChecks.ts +51 -0
  206. package/src/services/document/blanklines/helpers/paragraphChecks.ts +236 -0
  207. package/src/services/document/blanklines/helpers/removeBlanksBetweenListItems.ts +91 -0
  208. package/src/services/document/blanklines/helpers/removeTrailingBlanks.ts +35 -0
  209. package/src/services/document/blanklines/helpers/tableGuards.ts +21 -0
  210. package/src/services/document/blanklines/index.ts +67 -0
  211. package/src/services/document/blanklines/rules/additionRules.ts +337 -0
  212. package/src/services/document/blanklines/rules/indentationRules.ts +317 -0
  213. package/src/services/document/blanklines/rules/removalRules.ts +362 -0
  214. package/src/services/document/blanklines/rules/ruleTypes.ts +92 -0
  215. package/src/services/document/blanklines/types.ts +29 -0
  216. package/src/services/document/helpers/ImageBorderCropper.ts +377 -0
  217. package/src/services/document/helpers/__tests__/whitespace.test.ts +272 -0
  218. package/src/services/document/helpers/whitespace.ts +117 -0
  219. package/src/services/document/list/ListNormalizer.ts +947 -0
  220. package/src/services/document/list/index.ts +45 -0
  221. package/src/services/document/list/list-detection.ts +275 -0
  222. package/src/services/document/list/list-types.ts +162 -0
  223. package/src/services/document/processors/HyperlinkProcessor.ts +370 -0
  224. package/src/services/document/processors/ListProcessor.ts +257 -0
  225. package/src/services/document/processors/StructureProcessor.ts +176 -0
  226. package/src/services/document/processors/StyleProcessor.ts +389 -0
  227. package/src/services/document/processors/TableProcessor.ts +2238 -0
  228. package/src/services/document/processors/__tests__/HyperlinkProcessor.test.ts +314 -0
  229. package/src/services/document/processors/__tests__/ListProcessor.test.ts +291 -0
  230. package/src/services/document/processors/__tests__/StructureProcessor.test.ts +257 -0
  231. package/src/services/document/processors/__tests__/TableProcessor.hlp-tips-bullets.test.ts +459 -0
  232. package/src/services/document/processors/__tests__/TableProcessor.test.ts +1604 -0
  233. package/src/services/document/processors/index.ts +28 -0
  234. package/src/services/document/types/docx-processing.ts +310 -0
  235. package/src/services/editor/EditorActionHandlers.ts +901 -0
  236. package/src/services/editor/index.ts +13 -0
  237. package/src/setupTests.ts +47 -0
  238. package/src/styles/global.css +782 -0
  239. package/src/types/backup.ts +132 -0
  240. package/src/types/dictionary.ts +125 -0
  241. package/src/types/document-processing.ts +331 -0
  242. package/src/types/docxmlater-augments.d.ts +142 -0
  243. package/src/types/editor.ts +280 -0
  244. package/src/types/electron.ts +340 -0
  245. package/src/types/globalStats.ts +155 -0
  246. package/src/types/hyperlink.ts +471 -0
  247. package/src/types/operations.ts +354 -0
  248. package/src/types/session.ts +427 -0
  249. package/src/types/settings.ts +112 -0
  250. package/src/utils/MemoryMonitor.ts +248 -0
  251. package/src/utils/cn.ts +6 -0
  252. package/src/utils/colorConvert.ts +306 -0
  253. package/src/utils/diffUtils.ts +347 -0
  254. package/src/utils/documentUtils.ts +202 -0
  255. package/src/utils/electronGuard.ts +62 -0
  256. package/src/utils/indexedDB.ts +915 -0
  257. package/src/utils/logger.ts +717 -0
  258. package/src/utils/pathSecurity.ts +232 -0
  259. package/src/utils/pathValidator.ts +236 -0
  260. package/src/utils/processingTimeEstimator.ts +153 -0
  261. package/src/utils/safeJsonParse.ts +62 -0
  262. package/src/utils/textSanitizer.ts +162 -0
  263. package/src/utils/urlHelpers.ts +304 -0
  264. package/src/utils/urlPatterns.ts +198 -0
  265. package/src/utils/urlSanitizer.ts +152 -0
  266. package/src/vite-env.d.ts +11 -0
  267. package/tsconfig.electron.json +19 -0
  268. package/tsconfig.json +36 -0
  269. package/tsconfig.node.json +12 -0
  270. package/typedoc.json +45 -0
  271. package/vite.config.ts +152 -0
@@ -0,0 +1,751 @@
1
+ # DocXMLaterProcessor API Reference
2
+
3
+ Complete reference for all public methods in the Documentation Hub's DOCX processing API.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Overview](#overview)
8
+ - [Document I/O Operations](#document-io-operations)
9
+ - [Style Operations](#style-operations)
10
+ - [Table Operations](#table-operations)
11
+ - [Paragraph Formatting](#paragraph-formatting)
12
+ - [High-Level Operations](#high-level-operations)
13
+ - [Hyperlink Operations](#hyperlink-operations)
14
+ - [Search & Replace](#search--replace)
15
+ - [Document Statistics](#document-statistics)
16
+ - [Utility Methods](#utility-methods)
17
+ - [Quick Reference Table](#quick-reference-table)
18
+
19
+ ## Overview
20
+
21
+ The `DocXMLaterProcessor` class provides a comprehensive API for manipulating Microsoft Word (.docx) documents. It wraps the docxmlater library with enterprise-grade features including:
22
+
23
+ - **Type Safety**: Full TypeScript definitions
24
+ - **Error Handling**: Comprehensive error results
25
+ - **Memory Management**: Automatic resource cleanup
26
+ - **Performance**: Batch operations (30-50% faster for hyperlinks)
27
+ - **Data Integrity**: Defensive text sanitization
28
+
29
+ ## Document I/O Operations
30
+
31
+ ### loadFromFile(filePath: string)
32
+
33
+ Load a DOCX document from a file path.
34
+
35
+ **Parameters:**
36
+ - `filePath` (string) - Absolute or relative path to the DOCX file
37
+
38
+ **Returns:** `Promise<ProcessorResult<Document>>`
39
+
40
+ **Example:**
41
+ ```typescript
42
+ const processor = new DocXMLaterProcessor();
43
+ const result = await processor.loadFromFile('./documents/report.docx');
44
+
45
+ if (result.success) {
46
+ const doc = result.data;
47
+ // Work with document...
48
+ doc.dispose();
49
+ }
50
+ ```
51
+
52
+ ---
53
+
54
+ ### loadFromBuffer(buffer: Buffer)
55
+
56
+ Load a DOCX document from a Buffer object.
57
+
58
+ **Parameters:**
59
+ - `buffer` (Buffer) - Buffer containing the DOCX file data
60
+
61
+ **Returns:** `Promise<ProcessorResult<Document>>`
62
+
63
+ **Example:**
64
+ ```typescript
65
+ const response = await fetch('https://example.com/document.docx');
66
+ const arrayBuffer = await response.arrayBuffer();
67
+ const buffer = Buffer.from(arrayBuffer);
68
+
69
+ const result = await processor.loadFromBuffer(buffer);
70
+ ```
71
+
72
+ ---
73
+
74
+ ### saveToFile(doc: Document, filePath: string)
75
+
76
+ Save a Document to a file path with atomic operations.
77
+
78
+ **Parameters:**
79
+ - `doc` (Document) - Document instance to save
80
+ - `filePath` (string) - Path where the DOCX file will be saved
81
+
82
+ **Returns:** `Promise<ProcessorResult<void>>`
83
+
84
+ **Example:**
85
+ ```typescript
86
+ const doc = await processor.loadFromFile('input.docx');
87
+ // Make modifications...
88
+ await processor.saveToFile(doc.data, 'output.docx');
89
+ doc.data.dispose();
90
+ ```
91
+
92
+ ---
93
+
94
+ ### toBuffer(doc: Document)
95
+
96
+ Convert a Document to a Buffer object for in-memory operations or HTTP transmission.
97
+
98
+ **Parameters:**
99
+ - `doc` (Document) - Document instance to convert
100
+
101
+ **Returns:** `Promise<DocumentModifyResult>`
102
+
103
+ **Example:**
104
+ ```typescript
105
+ const result = await processor.toBuffer(doc);
106
+ if (result.success) {
107
+ res.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document');
108
+ res.send(result.data);
109
+ }
110
+ ```
111
+
112
+ ---
113
+
114
+ ## Style Operations
115
+
116
+ ### createDocumentWithStyle(styleId: string, styleName: string, properties: TextStyle & ParagraphStyle)
117
+
118
+ Create a new blank document with a custom paragraph style.
119
+
120
+ **Parameters:**
121
+ - `styleId` (string) - Unique identifier for the style
122
+ - `styleName` (string) - Display name for the style
123
+ - `properties` (TextStyle & ParagraphStyle) - Combined formatting properties
124
+
125
+ **Returns:** `Promise<ProcessorResult<Document>>`
126
+
127
+ **Example:**
128
+ ```typescript
129
+ const result = await processor.createDocumentWithStyle(
130
+ 'CustomHeading',
131
+ 'My Custom Heading',
132
+ {
133
+ fontFamily: 'Arial',
134
+ fontSize: 16,
135
+ bold: true,
136
+ color: '#0066CC',
137
+ alignment: 'left',
138
+ spaceBefore: 240,
139
+ spaceAfter: 120
140
+ }
141
+ );
142
+ ```
143
+
144
+ ---
145
+
146
+ ### applyStyleToParagraphs(doc: Document, styleId: string, application: StyleApplication)
147
+
148
+ Apply a style to paragraphs based on target criteria (all, pattern, or specific indices).
149
+
150
+ **Parameters:**
151
+ - `doc` (Document) - Document containing paragraphs to modify
152
+ - `styleId` (string) - ID of the style to apply
153
+ - `application` (StyleApplication) - Targeting criteria
154
+
155
+ **Returns:** `Promise<ProcessorResult<StyleApplicationResult>>`
156
+
157
+ **Example:**
158
+ ```typescript
159
+ // Apply to paragraphs containing "IMPORTANT"
160
+ const result = await processor.applyStyleToParagraphs(doc, 'Heading1', {
161
+ target: 'pattern',
162
+ pattern: /IMPORTANT/i
163
+ });
164
+
165
+ console.log(`Applied to ${result.data.appliedCount} paragraphs`);
166
+ ```
167
+
168
+ ---
169
+
170
+ ## Table Operations
171
+
172
+ ### createTable(doc: Document, rows: number, columns: number, options?: TableOptions)
173
+
174
+ Create a formatted table in the document.
175
+
176
+ **Parameters:**
177
+ - `doc` (Document) - Document to add the table to
178
+ - `rows` (number) - Number of rows
179
+ - `columns` (number) - Number of columns
180
+ - `options` (object, optional) - Formatting options
181
+ - `borders` (boolean) - Show borders (default: true)
182
+ - `borderColor` (string) - Border color in hex
183
+ - `borderSize` (number) - Border size in points
184
+ - `headerShading` (string) - Header row background color
185
+ - `cellPadding` (number) - Cell padding in twips
186
+
187
+ **Returns:** `Promise<ProcessorResult<Table>>`
188
+
189
+ **Example:**
190
+ ```typescript
191
+ const result = await processor.createTable(doc, 3, 4, {
192
+ borders: true,
193
+ borderColor: '0066CC',
194
+ borderSize: 6,
195
+ headerShading: 'E6F2FF'
196
+ });
197
+ ```
198
+
199
+ ---
200
+
201
+ ### setCellShading(cell: TableCell, color: string)
202
+
203
+ Set background color (shading) for a table cell.
204
+
205
+ **Parameters:**
206
+ - `cell` (TableCell) - Table cell to apply shading to
207
+ - `color` (string) - Background color in hex format
208
+
209
+ **Returns:** `Promise<ProcessorResult<void>>`
210
+
211
+ **Example:**
212
+ ```typescript
213
+ const cell = table.getRow(0).getCell(0);
214
+ await processor.setCellShading(cell, '#E6F2FF');
215
+ ```
216
+
217
+ ---
218
+
219
+ ### addCellContent(cell: TableCell, text: string, formatting?: TextStyle)
220
+
221
+ Add formatted text content to a table cell.
222
+
223
+ **Parameters:**
224
+ - `cell` (TableCell) - Table cell to add content to
225
+ - `text` (string) - Text content to add
226
+ - `formatting` (TextStyle, optional) - Text formatting options
227
+
228
+ **Returns:** `Promise<ProcessorResult<void>>`
229
+
230
+ **Example:**
231
+ ```typescript
232
+ await processor.addCellContent(headerCell, 'Product Name', {
233
+ bold: true,
234
+ fontSize: 12,
235
+ color: '#FFFFFF'
236
+ });
237
+ ```
238
+
239
+ ---
240
+
241
+ ## Paragraph Formatting
242
+
243
+ ### createParagraph(doc: Document, text: string, formatting?: ParagraphStyle & TextStyle)
244
+
245
+ Create a formatted paragraph in the document.
246
+
247
+ **Parameters:**
248
+ - `doc` (Document) - Document to add paragraph to
249
+ - `text` (string) - Text content for the paragraph
250
+ - `formatting` (ParagraphStyle & TextStyle, optional) - Formatting options
251
+
252
+ **Returns:** `Promise<ProcessorResult<Paragraph>>`
253
+
254
+ **Example:**
255
+ ```typescript
256
+ const result = await processor.createParagraph(doc, 'Chapter 1: Introduction', {
257
+ fontFamily: 'Arial',
258
+ fontSize: 16,
259
+ bold: true,
260
+ color: '#0066CC',
261
+ alignment: 'left',
262
+ spaceBefore: 240,
263
+ spaceAfter: 120,
264
+ keepNext: true
265
+ });
266
+ ```
267
+
268
+ ---
269
+
270
+ ### setIndentation(para: Paragraph, options: IndentationOptions)
271
+
272
+ Set indentation on an existing paragraph.
273
+
274
+ **Parameters:**
275
+ - `para` (Paragraph) - Paragraph to modify
276
+ - `options` (object) - Indentation settings
277
+ - `left` (number, optional) - Left indentation in twips
278
+ - `right` (number, optional) - Right indentation in twips
279
+ - `firstLine` (number, optional) - First line indentation in twips
280
+
281
+ **Returns:** `Promise<ProcessorResult<void>>`
282
+
283
+ **Example:**
284
+ ```typescript
285
+ // Set hanging indent for bibliography
286
+ await processor.setIndentation(paragraphs[0], {
287
+ left: processor.inchesToTwips(0.5),
288
+ firstLine: processor.inchesToTwips(-0.25)
289
+ });
290
+ ```
291
+
292
+ ---
293
+
294
+ ## High-Level Operations
295
+
296
+ ### readDocument(filePath: string)
297
+
298
+ Read an existing document and extract its complete structure.
299
+
300
+ **Parameters:**
301
+ - `filePath` (string) - Path to the DOCX file to read
302
+
303
+ **Returns:** `Promise<DocumentReadResult>`
304
+
305
+ **Example:**
306
+ ```typescript
307
+ const result = await processor.readDocument('./report.docx');
308
+
309
+ if (result.success) {
310
+ console.log(`Paragraphs: ${result.data.content.paragraphs.length}`);
311
+ console.log(`Tables: ${result.data.content.tables.length}`);
312
+ }
313
+ ```
314
+
315
+ ---
316
+
317
+ ### modifyDocument(filePath: string, modifications: (doc: Document) => Promise<void> | void)
318
+
319
+ Perform atomic load-modify-save operations on a document.
320
+
321
+ **Parameters:**
322
+ - `filePath` (string) - Path to the DOCX file to modify
323
+ - `modifications` (function) - Function that receives the document and makes modifications
324
+
325
+ **Returns:** `Promise<DocumentModifyResult>`
326
+
327
+ **Example:**
328
+ ```typescript
329
+ await processor.modifyDocument('./contract.docx', async (doc) => {
330
+ doc.replaceText('COMPANY_NAME', 'Acme Corporation');
331
+ doc.replaceText('CURRENT_YEAR', '2025');
332
+ });
333
+ ```
334
+
335
+ ---
336
+
337
+ ### modifyDocumentBuffer(buffer: Buffer, modifications: (doc: Document) => Promise<void> | void)
338
+
339
+ Perform atomic load-modify operations on a document from Buffer.
340
+
341
+ **Parameters:**
342
+ - `buffer` (Buffer) - Buffer containing the DOCX file data
343
+ - `modifications` (function) - Function that receives the document and makes modifications
344
+
345
+ **Returns:** `Promise<DocumentModifyResult>`
346
+
347
+ **Example:**
348
+ ```typescript
349
+ const result = await processor.modifyDocumentBuffer(inputBuffer, async (doc) => {
350
+ const para = doc.createParagraph('CONFIDENTIAL');
351
+ para.setAlignment('center');
352
+ });
353
+ ```
354
+
355
+ ---
356
+
357
+ ## Hyperlink Operations
358
+
359
+ ### extractHyperlinks(doc: Document)
360
+
361
+ Extract all hyperlinks from a document with comprehensive coverage (body, tables, headers, footers).
362
+
363
+ **Performance:** 89% code reduction, 20-30% faster than manual extraction
364
+
365
+ **Parameters:**
366
+ - `doc` (Document) - Document to extract hyperlinks from
367
+
368
+ **Returns:** `Promise<Array<HyperlinkInfo>>`
369
+
370
+ **Example:**
371
+ ```typescript
372
+ const hyperlinks = await processor.extractHyperlinks(doc);
373
+
374
+ hyperlinks.forEach((link, index) => {
375
+ console.log(`${index + 1}. ${link.text}`);
376
+ console.log(` URL: ${link.url}`);
377
+ });
378
+ ```
379
+
380
+ ---
381
+
382
+ ### updateHyperlinkUrls(doc: Document, urlMap: Map<string, string>)
383
+
384
+ Batch update hyperlink URLs using direct mapping.
385
+
386
+ **Performance:** 30-50% faster than modifyHyperlinks for simple replacements
387
+
388
+ **Parameters:**
389
+ - `doc` (Document) - Document to modify
390
+ - `urlMap` (Map<string, string>) - Map of old URLs to new URLs
391
+
392
+ **Returns:** `Promise<ProcessorResult<UpdateStats>>`
393
+
394
+ **Example:**
395
+ ```typescript
396
+ const urlMap = new Map([
397
+ ['http://old-site.com/page1', 'https://new-site.com/page1'],
398
+ ['http://old-site.com/page2', 'https://new-site.com/page2']
399
+ ]);
400
+
401
+ const result = await processor.updateHyperlinkUrls(doc, urlMap);
402
+ console.log(`Updated: ${result.data.modifiedHyperlinks}`);
403
+ ```
404
+
405
+ ---
406
+
407
+ ### modifyHyperlinks(doc: Document, urlTransform: (url: string, displayText: string) => string)
408
+
409
+ Modify hyperlinks using a transformation function.
410
+
411
+ **Parameters:**
412
+ - `doc` (Document) - Document to modify
413
+ - `urlTransform` (function) - Function that receives URL and text, returns new URL
414
+
415
+ **Returns:** `Promise<ProcessorResult<ModifyStats>>`
416
+
417
+ **Example:**
418
+ ```typescript
419
+ // Upgrade HTTP to HTTPS
420
+ await processor.modifyHyperlinks(doc, (url, displayText) => {
421
+ if (url.startsWith('http://') && url.includes('example.com')) {
422
+ return url.replace('http://', 'https://');
423
+ }
424
+ return url;
425
+ });
426
+ ```
427
+
428
+ ---
429
+
430
+ ### appendContentIdToTheSourceUrls(filePath: string, contentId?: string)
431
+
432
+ Append Content ID fragment to theSource URLs (CVS Health specific).
433
+
434
+ **Parameters:**
435
+ - `filePath` (string) - Path to the DOCX file to modify
436
+ - `contentId` (string, optional) - Content fragment to append (default: '#content')
437
+
438
+ **Returns:** `Promise<ProcessorResult<UpdateStats>>`
439
+
440
+ **Example:**
441
+ ```typescript
442
+ const result = await processor.appendContentIdToTheSourceUrls('./document.docx');
443
+ // Transforms: thesource.cvshealth.com/page/docid=abc -> ...#content
444
+ ```
445
+
446
+ ---
447
+
448
+ ### replaceHyperlinkText(doc: Document, pattern: string | RegExp, replacement: string)
449
+
450
+ Replace hyperlink display text based on a pattern.
451
+
452
+ **Parameters:**
453
+ - `doc` (Document) - Document to modify
454
+ - `pattern` (string | RegExp) - Pattern to match in display text
455
+ - `replacement` (string) - Replacement text
456
+
457
+ **Returns:** `Promise<ProcessorResult<ReplaceStats>>`
458
+
459
+ **Example:**
460
+ ```typescript
461
+ // Regex replacement with capture groups
462
+ await processor.replaceHyperlinkText(doc, /Page (\d+)/, 'Section $1');
463
+ ```
464
+
465
+ ---
466
+
467
+ ## Search & Replace
468
+
469
+ ### findText(doc: Document, pattern: string | RegExp, options?: SearchOptions)
470
+
471
+ Find text in document using built-in search.
472
+
473
+ **Parameters:**
474
+ - `doc` (Document) - Document to search
475
+ - `pattern` (string | RegExp) - Text string or regex pattern
476
+ - `options` (object, optional)
477
+ - `caseSensitive` (boolean) - Case-sensitive search
478
+ - `wholeWord` (boolean) - Match whole words only
479
+
480
+ **Returns:** `Promise<ProcessorResult<Array<SearchResult>>>`
481
+
482
+ **Example:**
483
+ ```typescript
484
+ const result = await processor.findText(doc, 'important', {
485
+ caseSensitive: false
486
+ });
487
+
488
+ console.log(`Found ${result.data.length} matches`);
489
+ ```
490
+
491
+ ---
492
+
493
+ ### replaceText(doc: Document, find: string | RegExp, replace: string, options?: ReplaceOptions)
494
+
495
+ Replace text in document using built-in replace.
496
+
497
+ **Parameters:**
498
+ - `doc` (Document) - Document to modify
499
+ - `find` (string | RegExp) - Text or pattern to find
500
+ - `replace` (string) - Replacement text
501
+ - `options` (object, optional)
502
+ - `caseSensitive` (boolean) - Case-sensitive search
503
+ - `wholeWord` (boolean) - Match whole words only
504
+
505
+ **Returns:** `Promise<ProcessorResult<ReplaceStats>>`
506
+
507
+ **Example:**
508
+ ```typescript
509
+ // Simple text replacement
510
+ await processor.replaceText(doc, '{{COMPANY_NAME}}', 'Acme Corporation');
511
+
512
+ // Regex replacement with capture groups
513
+ await processor.replaceText(doc, /(\d{2})\/(\d{2})\/(\d{4})/, '$3-$1-$2');
514
+ ```
515
+
516
+ ---
517
+
518
+ ## Document Statistics
519
+
520
+ ### getWordCount(doc: Document)
521
+
522
+ Get word count from document (includes paragraphs, tables, headers, footers).
523
+
524
+ **Parameters:**
525
+ - `doc` (Document) - Document to analyze
526
+
527
+ **Returns:** `Promise<ProcessorResult<{ wordCount: number }>>`
528
+
529
+ **Example:**
530
+ ```typescript
531
+ const result = await processor.getWordCount(doc);
532
+ console.log(`Document contains ${result.data.wordCount} words`);
533
+
534
+ // Calculate reading time (200 words per minute)
535
+ const readingTime = Math.ceil(result.data.wordCount / 200);
536
+ ```
537
+
538
+ ---
539
+
540
+ ### getCharacterCount(doc: Document, includeSpaces?: boolean)
541
+
542
+ Get character count from document.
543
+
544
+ **Parameters:**
545
+ - `doc` (Document) - Document to analyze
546
+ - `includeSpaces` (boolean, optional) - Include spaces in count (default: true)
547
+
548
+ **Returns:** `Promise<ProcessorResult<{ characterCount: number }>>`
549
+
550
+ **Example:**
551
+ ```typescript
552
+ const withSpaces = await processor.getCharacterCount(doc, true);
553
+ const withoutSpaces = await processor.getCharacterCount(doc, false);
554
+
555
+ console.log(`Characters (with spaces): ${withSpaces.data.characterCount}`);
556
+ console.log(`Characters (no spaces): ${withoutSpaces.data.characterCount}`);
557
+ ```
558
+
559
+ ---
560
+
561
+ ### estimateSize(doc: Document)
562
+
563
+ Estimate document size before saving.
564
+
565
+ **Parameters:**
566
+ - `doc` (Document) - Document to estimate
567
+
568
+ **Returns:** `Promise<ProcessorResult<{ totalEstimatedMB: number, warning?: string }>>`
569
+
570
+ **Example:**
571
+ ```typescript
572
+ const sizeResult = await processor.estimateSize(doc);
573
+ console.log(`Estimated size: ${sizeResult.data.totalEstimatedMB.toFixed(2)} MB`);
574
+
575
+ if (sizeResult.data.totalEstimatedMB < 10) {
576
+ await processor.saveToFile(doc, 'output.docx');
577
+ } else {
578
+ console.error('Document too large');
579
+ }
580
+ ```
581
+
582
+ ---
583
+
584
+ ### getSizeStats(doc: Document)
585
+
586
+ Get detailed document statistics including element counts and size.
587
+
588
+ **Parameters:**
589
+ - `doc` (Document) - Document to analyze
590
+
591
+ **Returns:** `Promise<ProcessorResult<SizeStats>>`
592
+
593
+ **Example:**
594
+ ```typescript
595
+ const stats = await processor.getSizeStats(doc);
596
+
597
+ console.log(`Paragraphs: ${stats.data.elements.paragraphs}`);
598
+ console.log(`Tables: ${stats.data.elements.tables}`);
599
+ console.log(`Images: ${stats.data.elements.images}`);
600
+ console.log(`Hyperlinks: ${stats.data.elements.hyperlinks}`);
601
+ console.log(`Size: ${stats.data.size.totalEstimatedMB.toFixed(2)} MB`);
602
+ ```
603
+
604
+ ---
605
+
606
+ ## Utility Methods
607
+
608
+ ### createNewDocument()
609
+
610
+ Create a new blank document.
611
+
612
+ **Returns:** `Document`
613
+
614
+ **Example:**
615
+ ```typescript
616
+ const doc = processor.createNewDocument();
617
+ await processor.createParagraph(doc, 'Hello World!');
618
+ await processor.saveToFile(doc, 'new-document.docx');
619
+ doc.dispose();
620
+ ```
621
+
622
+ ---
623
+
624
+ ### inchesToTwips(inches: number)
625
+
626
+ Convert inches to twips (1 inch = 1440 twips).
627
+
628
+ **Parameters:**
629
+ - `inches` (number) - Measurement in inches
630
+
631
+ **Returns:** `number`
632
+
633
+ **Example:**
634
+ ```typescript
635
+ const indent = processor.inchesToTwips(0.5); // 720 twips
636
+ await processor.setIndentation(para, { left: indent });
637
+ ```
638
+
639
+ ---
640
+
641
+ ### pointsToTwips(points: number)
642
+
643
+ Convert points to twips (1 point = 20 twips).
644
+
645
+ **Parameters:**
646
+ - `points` (number) - Measurement in points
647
+
648
+ **Returns:** `number`
649
+
650
+ **Example:**
651
+ ```typescript
652
+ const spacing = processor.pointsToTwips(12); // 240 twips
653
+ await processor.createParagraph(doc, 'Text', { spaceBefore: spacing });
654
+ ```
655
+
656
+ ---
657
+
658
+ ### twipsToPoints(twips: number)
659
+
660
+ Convert twips to points (20 twips = 1 point).
661
+
662
+ **Parameters:**
663
+ - `twips` (number) - Measurement in twips
664
+
665
+ **Returns:** `number`
666
+
667
+ **Example:**
668
+ ```typescript
669
+ const formatting = para.getFormatting();
670
+ const points = processor.twipsToPoints(formatting.spaceBefore);
671
+ console.log(`Space before: ${points}pt`);
672
+ ```
673
+
674
+ ---
675
+
676
+ ## Quick Reference Table
677
+
678
+ | Method | Category | Description | Returns |
679
+ |--------|----------|-------------|---------|
680
+ | `loadFromFile` | Document I/O | Load document from file path | `Promise<ProcessorResult<Document>>` |
681
+ | `loadFromBuffer` | Document I/O | Load document from Buffer | `Promise<ProcessorResult<Document>>` |
682
+ | `saveToFile` | Document I/O | Save document to file path | `Promise<ProcessorResult<void>>` |
683
+ | `toBuffer` | Document I/O | Convert document to Buffer | `Promise<DocumentModifyResult>` |
684
+ | `createDocumentWithStyle` | Style Operations | Create document with custom style | `Promise<ProcessorResult<Document>>` |
685
+ | `applyStyleToParagraphs` | Style Operations | Apply style to paragraphs | `Promise<ProcessorResult<StyleApplicationResult>>` |
686
+ | `createTable` | Table Operations | Create formatted table | `Promise<ProcessorResult<Table>>` |
687
+ | `setCellShading` | Table Operations | Set cell background color | `Promise<ProcessorResult<void>>` |
688
+ | `addCellContent` | Table Operations | Add content to table cell | `Promise<ProcessorResult<void>>` |
689
+ | `createParagraph` | Paragraph Formatting | Create formatted paragraph | `Promise<ProcessorResult<Paragraph>>` |
690
+ | `setIndentation` | Paragraph Formatting | Set paragraph indentation | `Promise<ProcessorResult<void>>` |
691
+ | `readDocument` | High-Level Operations | Read document structure | `Promise<DocumentReadResult>` |
692
+ | `modifyDocument` | High-Level Operations | Atomic load-modify-save | `Promise<DocumentModifyResult>` |
693
+ | `modifyDocumentBuffer` | High-Level Operations | Modify document from Buffer | `Promise<DocumentModifyResult>` |
694
+ | `extractHyperlinks` | Hyperlink Operations | Extract all hyperlinks | `Promise<Array<HyperlinkInfo>>` |
695
+ | `updateHyperlinkUrls` | Hyperlink Operations | Batch update hyperlink URLs | `Promise<ProcessorResult<UpdateStats>>` |
696
+ | `modifyHyperlinks` | Hyperlink Operations | Transform hyperlink URLs | `Promise<ProcessorResult<ModifyStats>>` |
697
+ | `appendContentIdToTheSourceUrls` | Hyperlink Operations | Append #content to theSource | `Promise<ProcessorResult<UpdateStats>>` |
698
+ | `replaceHyperlinkText` | Hyperlink Operations | Replace hyperlink display text | `Promise<ProcessorResult<ReplaceStats>>` |
699
+ | `findText` | Search & Replace | Find text in document | `Promise<ProcessorResult<Array<SearchResult>>>` |
700
+ | `replaceText` | Search & Replace | Replace text in document | `Promise<ProcessorResult<ReplaceStats>>` |
701
+ | `getWordCount` | Document Statistics | Get word count | `Promise<ProcessorResult<{ wordCount: number }>>` |
702
+ | `getCharacterCount` | Document Statistics | Get character count | `Promise<ProcessorResult<{ characterCount: number }>>` |
703
+ | `estimateSize` | Document Statistics | Estimate document size | `Promise<ProcessorResult<SizeEstimate>>` |
704
+ | `getSizeStats` | Document Statistics | Get detailed statistics | `Promise<ProcessorResult<SizeStats>>` |
705
+ | `createNewDocument` | Utilities | Create blank document | `Document` |
706
+ | `inchesToTwips` | Utilities | Convert inches to twips | `number` |
707
+ | `pointsToTwips` | Utilities | Convert points to twips | `number` |
708
+ | `twipsToPoints` | Utilities | Convert twips to points | `number` |
709
+
710
+ ---
711
+
712
+ ## Notes
713
+
714
+ ### Memory Management
715
+
716
+ Always call `dispose()` on documents when finished to prevent memory leaks:
717
+
718
+ ```typescript
719
+ const loadResult = await processor.loadFromFile('document.docx');
720
+ if (loadResult.success) {
721
+ const doc = loadResult.data;
722
+ // Work with document...
723
+ doc.dispose(); // Clean up
724
+ }
725
+ ```
726
+
727
+ ### Error Handling
728
+
729
+ All methods return `ProcessorResult<T>` objects with success/error information:
730
+
731
+ ```typescript
732
+ const result = await processor.loadFromFile('file.docx');
733
+ if (!result.success) {
734
+ console.error('Error:', result.error);
735
+ return;
736
+ }
737
+ const doc = result.data;
738
+ ```
739
+
740
+ ### Performance Tips
741
+
742
+ 1. Use `updateHyperlinkUrls()` for direct URL mapping (30-50% faster)
743
+ 2. Use batch operations when possible
744
+ 3. Dispose documents immediately after use
745
+ 4. Use `modifyDocument()` for atomic operations
746
+
747
+ ---
748
+
749
+ **Last Updated:** 2025-11-13
750
+ **Version:** 1.0.40
751
+ **Documentation Hub** | [GitHub](https://github.com/ItMeDiaTech/Documentation_Hub)