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,588 @@
1
+ # Style Refactoring Reference Guide
2
+
3
+ **Version:** 2.2.0
4
+ **Date:** November 2025
5
+ **Status:** In Progress
6
+
7
+ ---
8
+
9
+ ## Overview
10
+
11
+ This document tracks the refactored style application API, providing a comprehensive reference for all new functions, helpers, and types added to support flexible style application with custom formatting.
12
+
13
+ ---
14
+
15
+ ## New Types and Interfaces
16
+
17
+ ### Location: `src/types/formatting.ts`
18
+
19
+ #### `EmphasisType`
20
+
21
+ ```typescript
22
+ type EmphasisType = "bold" | "italic" | "underline";
23
+ ```
24
+
25
+ Text emphasis options for formatting.
26
+
27
+ #### `ListPrefix`
28
+
29
+ ```typescript
30
+ interface ListPrefix {
31
+ format: "bullet" | "number";
32
+ style: string; // e.g., '•', '1.', 'a)'
33
+ }
34
+ ```
35
+
36
+ Configuration for list prefix styling.
37
+
38
+ #### `FormatOptions`
39
+
40
+ ```typescript
41
+ interface FormatOptions {
42
+ // Text formatting
43
+ font?: string; // Font family (e.g., 'Arial', 'Verdana')
44
+ size?: number; // Font size in points
45
+ color?: string; // Text color as 6-digit hex (e.g., 'FF0000')
46
+ emphasis?: EmphasisType[]; // Array of emphasis types
47
+
48
+ // Alignment
49
+ alignment?: "left" | "right" | "center" | "justify";
50
+
51
+ // Spacing (in points)
52
+ spaceAbove?: number; // Space before paragraph
53
+ spaceBelow?: number; // Space after paragraph
54
+ lineSpacing?: number; // Line spacing
55
+
56
+ // Indentation (in inches)
57
+ indentLeft?: number;
58
+ indentRight?: number;
59
+ indentFirst?: number;
60
+ indentHanging?: number;
61
+
62
+ // Padding (in points) - for table cells
63
+ paddingTop?: number;
64
+ paddingBottom?: number;
65
+ paddingLeft?: number;
66
+ paddingRight?: number;
67
+
68
+ // List formatting
69
+ prefixList?: string | ListPrefix;
70
+
71
+ // Advanced options
72
+ borderColor?: string; // 6-digit hex
73
+ borderWidth?: number; // In points
74
+ shading?: string; // Background color as 6-digit hex
75
+ keepWithNext?: boolean; // Only set if true
76
+ keepLines?: boolean; // Only set if true
77
+ }
78
+ ```
79
+
80
+ Complete formatting configuration for style application.
81
+
82
+ **Unit Conversions:**
83
+
84
+ - Points to twips: `points * 20` (1 point = 20 twips)
85
+ - Inches to twips: `inches * 1440` (1 inch = 1440 twips)
86
+
87
+ #### `StyleApplyOptions`
88
+
89
+ ```typescript
90
+ interface StyleApplyOptions {
91
+ paragraphs?: Paragraph[]; // Specific paragraphs to apply style to
92
+ keepProperties?: string[]; // Properties to preserve from existing formatting
93
+ format?: FormatOptions; // Custom formatting to apply
94
+ }
95
+ ```
96
+
97
+ Options for applying styles to paragraphs.
98
+
99
+ ---
100
+
101
+ ## Updated Public Methods
102
+
103
+ ### Location: `src/core/Document.ts`
104
+
105
+ All style application methods now accept optional `StyleApplyOptions` parameter.
106
+
107
+ #### `applyH1(options?: StyleApplyOptions): number`
108
+
109
+ **Line:** 3794
110
+ Applies Heading 1 style to paragraphs with H1-like style names.
111
+
112
+ **Example:**
113
+
114
+ ```typescript
115
+ // Simple usage
116
+ doc.applyH1();
117
+
118
+ // With custom formatting
119
+ doc.applyH1({
120
+ format: { font: "Arial", size: 18, emphasis: ["bold"] },
121
+ });
122
+
123
+ // Preserve specific properties
124
+ doc.applyH1({
125
+ keepProperties: ["bold", "color"],
126
+ format: { font: "Verdana" },
127
+ });
128
+ ```
129
+
130
+ #### `applyH2(options?: StyleApplyOptions): number`
131
+
132
+ **Line:** 3811
133
+ Applies Heading 2 style to paragraphs with H2-like style names.
134
+
135
+ **Example:**
136
+
137
+ ```typescript
138
+ doc.applyH2({
139
+ format: { font: "Verdana", size: 14, color: "000000" },
140
+ });
141
+ ```
142
+
143
+ #### `applyH3(options?: StyleApplyOptions): number`
144
+
145
+ **Line:** 3828
146
+ Applies Heading 3 style to paragraphs with H3-like style names.
147
+
148
+ **Example:**
149
+
150
+ ```typescript
151
+ doc.applyH3({
152
+ format: { font: "Verdana", size: 12, emphasis: ["bold"] },
153
+ });
154
+ ```
155
+
156
+ #### `applyNormal(options?: StyleApplyOptions): number`
157
+
158
+ **Line:** 3839
159
+ Applies Normal style to paragraphs without recognized styles.
160
+
161
+ **Example:**
162
+
163
+ ```typescript
164
+ doc.applyNormal({
165
+ format: {
166
+ font: "Verdana",
167
+ size: 12,
168
+ alignment: "justify",
169
+ spaceBelow: 3,
170
+ },
171
+ });
172
+ ```
173
+
174
+ #### `applyNumList(options?: StyleApplyOptions): number`
175
+
176
+ **Line:** 3870
177
+ Applies list style to numbered lists.
178
+
179
+ #### `applyBulletList(options?: StyleApplyOptions): number`
180
+
181
+ **Line:** 3881
182
+ Applies list style to bullet lists.
183
+
184
+ #### `applyTOC(options?: StyleApplyOptions): number`
185
+
186
+ **Line:** 3892
187
+ Applies Table of Contents style.
188
+
189
+ #### `applyTOD(options?: StyleApplyOptions): number`
190
+
191
+ **Line:** 3903
192
+ Applies Top of Document style.
193
+
194
+ #### `applyCaution(options?: StyleApplyOptions): number`
195
+
196
+ **Line:** 3914
197
+ Applies Caution/Warning style.
198
+
199
+ #### `applyCellHeader(options?: StyleApplyOptions): number`
200
+
201
+ **Line:** 3925
202
+ Applies header style to table cell paragraphs (typically first row).
203
+
204
+ **Example:**
205
+
206
+ ```typescript
207
+ doc.applyCellHeader({
208
+ format: {
209
+ font: "Arial",
210
+ size: 12,
211
+ emphasis: ["bold"],
212
+ alignment: "center",
213
+ },
214
+ });
215
+ ```
216
+
217
+ ---
218
+
219
+ ## New Helper Methods (Private)
220
+
221
+ ### Heading Options: `src/core/Document.ts`
222
+
223
+ #### `applyFormatOptions(para: Paragraph, options: FormatOptions): void`
224
+
225
+ **Line:** 3928
226
+ **Purpose:** Applies formatting options to a paragraph.
227
+
228
+ **Functionality:**
229
+
230
+ - Text formatting (font, size, color, emphasis) applied to all runs
231
+ - Alignment applied to paragraph
232
+ - Spacing converted from points to twips (1pt = 20 twips)
233
+ - Indentation converted from inches to twips (1in = 1440 twips)
234
+ - Advanced options (keepWithNext, keepLines) only set if true
235
+
236
+ **Unit Conversions:**
237
+
238
+ ```typescript
239
+ // Spacing: points → twips
240
+ spaceAbove * 20;
241
+ spaceBelow * 20;
242
+ lineSpacing * 20;
243
+
244
+ // Indentation: inches → twips
245
+ indentLeft * 1440;
246
+ indentRight * 1440;
247
+ indentFirst * 1440;
248
+ indentHanging * 1440;
249
+ ```
250
+
251
+ #### `clearFormattingExcept(para: Paragraph, keepProperties: string[]): void`
252
+
253
+ **Line:** 3038
254
+ **Purpose:** Selectively clears formatting while preserving specific properties.
255
+
256
+ **Functionality:**
257
+
258
+ - Saves specified properties from paragraph formatting
259
+ - Clears all paragraph formatting
260
+ - Restores saved properties
261
+ - Handles run-level properties using appropriate setters
262
+
263
+ **Supported Properties to Keep:**
264
+
265
+ - `bold`, `italic`, `underline`
266
+ - `color`, `font`, `size`
267
+ - `highlight`, `strike`
268
+ - `subscript`, `superscript`
269
+
270
+ #### `applyStyleToMatching(targetStyle: string, options: StyleApplyOptions | undefined, matcher: (style: string) => boolean): number`
271
+
272
+ **Line:** 4032
273
+ **Purpose:** Helper to apply style to matching paragraphs.
274
+
275
+ **Functionality:**
276
+
277
+ - Filters paragraphs by style name using matcher function
278
+ - Skips preserved paragraphs
279
+ - Applies target style
280
+ - Handles selective property preservation if `keepProperties` specified
281
+ - Applies custom formatting if `format` option provided
282
+ - Returns count of paragraphs updated
283
+
284
+ ---
285
+
286
+ ## New Element Methods
287
+
288
+ ### Location: `src/elements/Run.ts`
289
+
290
+ #### `clearFormatting(): this`
291
+
292
+ **Line:** 1280
293
+ **Purpose:** Clears all formatting from a run.
294
+
295
+ **Example:**
296
+
297
+ ```typescript
298
+ run.clearFormatting();
299
+ ```
300
+
301
+ ### Location: `src/elements/Paragraph.ts`
302
+
303
+ #### `clearDirectFormatting(): this`
304
+
305
+ **Line:** 2343
306
+ **Purpose:** Clears all direct formatting from paragraph and its runs.
307
+
308
+ **Functionality:**
309
+
310
+ - Clears paragraph-level formatting
311
+ - Preserves style reference and numbering
312
+ - Clears formatting from all runs
313
+
314
+ **Example:**
315
+
316
+ ```typescript
317
+ paragraph.clearDirectFormatting();
318
+ ```
319
+
320
+ ---
321
+
322
+ ## Existing Methods (Updated Signatures)
323
+
324
+ ### Multiple headings: `src/core/Document.ts`
325
+
326
+ #### `cleanFormatting(styleNames?: string[]): number`
327
+
328
+ **Line:** 3749
329
+ **Purpose:** Cleans direct formatting from paragraphs that have a style applied.
330
+
331
+ **Parameters:**
332
+
333
+ - `styleNames` (optional): Array of specific style names to clean
334
+
335
+ **Returns:** Number of paragraphs cleaned
336
+
337
+ **Example:**
338
+
339
+ ```typescript
340
+ // Clean all styled paragraphs
341
+ doc.cleanFormatting();
342
+
343
+ // Clean specific styles only
344
+ doc.cleanFormatting(["Heading1", "Heading2", "Normal"]);
345
+ ```
346
+
347
+ ---
348
+
349
+ ## Style Matchers
350
+
351
+ Regular expressions used to match style names:
352
+
353
+ | Method | Regex Pattern | Matches |
354
+ | ----------------- | ------------------------------------------------------------ | ------------------------------------------- |
355
+ | `applyH1` | `/^(heading\s*1\|header\s*1\|h1)$/i` | Heading1, Heading 1, Header1, H1 |
356
+ | `applyH2` | `/^(heading\s*2\|header\s*2\|h2)$/i` | Heading2, Heading 2, Header2, H2 |
357
+ | `applyH3` | `/^(heading\s*3\|header\s*3\|h3)$/i` | Heading3, Heading 3, Header3, H3 |
358
+ | `applyNumList` | `/^(list\s*number\|numbered\s*list\|list\s*paragraph)$/i` | List Number, Numbered List, List Paragraph |
359
+ | `applyBulletList` | `/^(list\s*bullet\|bullet\s*list\|list\s*paragraph)$/i` | List Bullet, Bullet List, List Paragraph |
360
+ | `applyTOC` | `/^(toc\|table\s*of\s*contents\|toc\s*heading)$/i` | TOC, Table Of Contents, TOC Heading |
361
+ | `applyTOD` | `/^(tod\|top\s*of\s*document\|document\s*top)$/i` | TOD, Top Of Document, Document Top |
362
+ | `applyCaution` | `/^(caution\|warning\|important\|alert)$/i` | Caution, Warning, Important, Alert |
363
+ | `applyNormal` | `/^(heading\|header\|h\d\|list\|toc\|tod\|caution\|table)/i` | Applies to styles NOT matching this pattern |
364
+
365
+ All patterns are case-insensitive (`i` flag).
366
+
367
+ ---
368
+
369
+ ## Usage Patterns
370
+
371
+ ### Pattern 1: Simple Style Application
372
+
373
+ ```typescript
374
+ // Apply default style, clear all formatting
375
+ doc.applyH1();
376
+ doc.applyH2();
377
+ doc.applyNormal();
378
+ ```
379
+
380
+ ### Pattern 2: Custom Formatting
381
+
382
+ ```typescript
383
+ // Apply style with custom formatting
384
+ doc.applyH2({
385
+ format: {
386
+ font: "Verdana",
387
+ size: 14,
388
+ color: "000000",
389
+ emphasis: ["bold"],
390
+ alignment: "left",
391
+ spaceBelow: 6,
392
+ indentLeft: 0.25,
393
+ },
394
+ });
395
+ ```
396
+
397
+ ### Pattern 3: Selective Preservation
398
+
399
+ ```typescript
400
+ // Keep existing bold and color, apply new formatting
401
+ doc.applyH1({
402
+ keepProperties: ["bold", "color"],
403
+ format: {
404
+ font: "Arial",
405
+ size: 18,
406
+ alignment: "center",
407
+ },
408
+ });
409
+ ```
410
+
411
+ ### Pattern 4: Specific Paragraphs
412
+
413
+ ```typescript
414
+ // Apply to specific paragraphs only
415
+ const someParagraphs = doc.getAllParagraphs().slice(0, 10);
416
+ doc.applyH1({
417
+ paragraphs: someParagraphs,
418
+ format: { font: "Verdana", size: 18 },
419
+ });
420
+ ```
421
+
422
+ ### Pattern 5: Complex Formatting
423
+
424
+ ```typescript
425
+ // Full-featured example
426
+ doc.applyNormal({
427
+ keepProperties: ["bold", "italic"],
428
+ format: {
429
+ font: "Verdana",
430
+ size: 12,
431
+ color: "000000",
432
+ alignment: "justify",
433
+ spaceAbove: 0,
434
+ spaceBelow: 3,
435
+ lineSpacing: 1.15,
436
+ indentLeft: 0,
437
+ indentRight: 0,
438
+ indentFirst: 0.5,
439
+ keepWithNext: true,
440
+ shading: "F0F0F0",
441
+ },
442
+ });
443
+ ```
444
+
445
+ ---
446
+
447
+ ## Migration Guide
448
+
449
+ ### Before (v2.1.0 and earlier)
450
+
451
+ ```typescript
452
+ // Simple, no options
453
+ doc.applyH1(); // Returns number
454
+ ```
455
+
456
+ ### After (v2.2.0+)
457
+
458
+ ```typescript
459
+ // Still backwards compatible
460
+ doc.applyH1(); // Works exactly the same
461
+
462
+ // New: With options
463
+ doc.applyH1({
464
+ format: { font: "Arial", size: 18 },
465
+ });
466
+
467
+ // New: Preserve properties
468
+ doc.applyH1({
469
+ keepProperties: ["bold", "color"],
470
+ });
471
+ ```
472
+
473
+ **No breaking changes** - All existing code continues to work.
474
+
475
+ ---
476
+
477
+ ## Template_UI Integration
478
+
479
+ ### Location: `src/services/document/WordDocumentProcessor.ts`
480
+
481
+ **Lines:** 653-673
482
+
483
+ Currently calls all style methods with default parameters (no options):
484
+
485
+ ```typescript
486
+ const h1Count = doc.applyH1();
487
+ const h2Count = doc.applyH2();
488
+ const h3Count = doc.applyH3();
489
+ const numListCount = doc.applyNumList();
490
+ const bulletListCount = doc.applyBulletList();
491
+ const tocCount = doc.applyTOC();
492
+ const todCount = doc.applyTOD();
493
+ const cautionCount = doc.applyCaution();
494
+ const cellHeaderCount = doc.applyCellHeader();
495
+ const hyperlinkCount = doc.applyHyperlink();
496
+ const normalCount = doc.applyNormal();
497
+ const cleanedCount = doc.cleanFormatting();
498
+ ```
499
+
500
+ **Future Enhancement:** Add UI to configure custom formatting per style.
501
+
502
+ ---
503
+
504
+ ## Testing Notes
505
+
506
+ ### Test Cases to Add
507
+
508
+ 1. **Format Options Application**
509
+
510
+ - Font, size, color application
511
+ - Emphasis (bold, italic, underline)
512
+ - Alignment
513
+ - Spacing conversions (points → twips)
514
+ - Indentation conversions (inches → twips)
515
+
516
+ 2. **Property Preservation**
517
+
518
+ - Keep specified properties
519
+ - Clear non-specified properties
520
+ - Preserve paragraph-level properties
521
+ - Preserve run-level properties
522
+
523
+ 3. **Style Matching**
524
+
525
+ - Case-insensitive matching
526
+ - Multiple style name variants
527
+ - Normal style fallback logic
528
+
529
+ 4. **Edge Cases**
530
+ - Empty paragraphs
531
+ - Preserved paragraphs (should skip)
532
+ - Paragraphs without style names
533
+ - Tables with no first row
534
+
535
+ ---
536
+
537
+ ## Known Limitations
538
+
539
+ 1. **Padding Properties:** `paddingTop/Bottom/Left/Right` are defined but not yet fully implemented for table cells (TODO).
540
+
541
+ 2. **List Prefix:** `prefixList` option is defined but custom list styling not yet implemented (TODO).
542
+
543
+ 3. **Border Properties:** `borderColor` and `borderWidth` are defined but not yet applied (TODO).
544
+
545
+ 4. **Hanging Indent:** Set directly through `para.formatting.indentation.hanging` rather than dedicated setter method.
546
+
547
+ ---
548
+
549
+ ## Files Modified
550
+
551
+ ### docXMLater
552
+
553
+ 1. `src/types/formatting.ts` - New types and interfaces
554
+ 2. `src/core/Document.ts` - Updated methods and new helpers
555
+ 3. `src/elements/Paragraph.ts` - Added `clearDirectFormatting()`
556
+ 4. `src/elements/Run.ts` - Added `clearFormatting()`
557
+ 5. `src/index.ts` - Exported new types
558
+ 6. `package.json` - Version bump to 2.2.0
559
+
560
+ ### Template_UI
561
+
562
+ 1. `src/services/document/WordDocumentProcessor.ts` - Integration (lines 653-673)
563
+ 2. `package.json` - Updated docXMLater dependency
564
+
565
+ ---
566
+
567
+ ## Next Steps
568
+
569
+ 1. Add unit tests for new functionality
570
+ 2. Add UI in Template_UI to configure custom formatting per style
571
+ 3. Implement remaining TODO items (padding, borders, list prefix)
572
+ 4. Consider adding preset style configurations (e.g., "Corporate", "Academic", "Minimal")
573
+ 5. Document performance implications of complex formatting operations
574
+
575
+ ---
576
+
577
+ ## Notes
578
+
579
+ - All style application methods are backwards compatible
580
+ - Options parameter is optional - default behavior unchanged
581
+ - Boolean properties simplified: only set if true (no undefined checks needed)
582
+ - Unit conversions handled automatically (points/inches → twips)
583
+ - Property preservation uses getters/setters (no direct formatting access)
584
+
585
+ ---
586
+
587
+ **Last Updated:** November 13, 2025
588
+ **Next Review:** After user testing and feedback