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.
- package/.eslintrc.json +43 -0
- package/.github/workflows/build.yml +64 -0
- package/.github/workflows/ci.yml +39 -0
- package/.vscode/extensions.json +3 -0
- package/Current.md +97 -0
- package/DocHub_Image.png +0 -0
- package/README.md +666 -0
- package/USER_GUIDE.md +1173 -0
- package/Updater.md +311 -0
- package/build/256x256.png +0 -0
- package/build/512x512.png +0 -0
- package/build/app-update.yml +4 -0
- package/build/create-icon.js +208 -0
- package/build/icon.ico +0 -0
- package/build/icon.png +0 -0
- package/build/icon_1024x1024.png +0 -0
- package/dist/assets/Analytics-BpsG9895.js +1 -0
- package/dist/assets/Card-IAZin8kp.js +1 -0
- package/dist/assets/CurrentSession-B-rFkHvf.js +12 -0
- package/dist/assets/Dashboard-C_5gMb0q.js +1 -0
- package/dist/assets/Documents-CqZ25axS.js +1 -0
- package/dist/assets/Input-l89xwXBi.js +1 -0
- package/dist/assets/Reporting-DqdHJY_a.js +1 -0
- package/dist/assets/Search-XNbu5z_3.js +1 -0
- package/dist/assets/SessionManager-lH9hZfzH.js +1 -0
- package/dist/assets/Sessions-ClZOPYNc.js +1 -0
- package/dist/assets/Settings-DUEHGURa.js +11 -0
- package/dist/assets/index-8xUe8ptc.js +24 -0
- package/dist/assets/index-RYyJqF7O.css +1 -0
- package/dist/assets/path-BkOl0AGO.js +1 -0
- package/dist/assets/promises-ID_B9S-h.js +1 -0
- package/dist/assets/urlHelpers-TvgahX0r.js +1 -0
- package/dist/assets/useToast-yRSO1dkm.js +1 -0
- package/dist/assets/vendor-charts-RkGK5ROP.js +36 -0
- package/dist/assets/vendor-db-l0sNRNKZ.js +1 -0
- package/dist/assets/vendor-react-BVZ_anCF.js +4 -0
- package/dist/assets/vendor-search-Dw8P0qyA.js +1 -0
- package/dist/assets/vendor-ui-BU7NfluV.js +53 -0
- package/dist/electron/PowerAutomateApiService-LfW09ZGr.js +147 -0
- package/dist/electron/main-CXkNtyv-.js +19789 -0
- package/dist/electron/main.js +5 -0
- package/dist/electron/preload.js +1 -0
- package/dist/icon.png +0 -0
- package/dist/index.html +27 -0
- package/docs/CODEBASE_ANALYSIS_REPORT.md +309 -0
- package/docs/DEBUG_LOGGING_GUIDE.md +244 -0
- package/docs/README.md +115 -0
- package/docs/TOC_WIRING_GUIDE.md +344 -0
- package/docs/analysis/Bullet_Symbol_Bug_Analysis.md +136 -0
- package/docs/analysis/DOCXMLATER_ANALYSIS_SUMMARY.txt +169 -0
- package/docs/analysis/Document_Processing_Issues_Analysis.md +704 -0
- package/docs/analysis/FIELD_PRESERVATION_ANALYSIS.md +1200 -0
- package/docs/analysis/INDENTATION_PRESERVE_ANALYSIS.md +181 -0
- package/docs/analysis/INDENTATION_PRESERVE_IMPLEMENTATION.md +207 -0
- package/docs/analysis/List_Implementation.md +206 -0
- package/docs/analysis/List_Implementation_Accuracy_Report.md +366 -0
- package/docs/analysis/PROCESSING_OPTIONS_UI_UPDATES.md +220 -0
- package/docs/analysis/RefactorStyles.md +852 -0
- package/docs/analysis/STYLE_PARAMETER_ENHANCEMENT.md +143 -0
- package/docs/analysis/docxmlater-comparison-todo-2025-11-13.md +636 -0
- package/docs/analysis/docxmlater-implementation-analysis-2025-11-13.md +340 -0
- package/docs/analysis/docxmlater-template_ui-integration-analysis.md +263 -0
- package/docs/analysis/github-issues-to-create.md +237 -0
- package/docs/api/API_README.md +538 -0
- package/docs/api/API_REFERENCE.md +751 -0
- package/docs/api/TYPE_DEFINITIONS.md +869 -0
- package/docs/architecture/FONT_EMBEDDING_GUIDE.md +318 -0
- package/docs/architecture/docxmlater-functions-and-structure.md +726 -0
- package/docs/docxmlater-readme.md +1341 -0
- package/docs/fixes/EXECUTION_LOG_TEST_BASE.md +573 -0
- package/docs/fixes/HYPERLINK_TEXT_SANITIZATION.md +253 -0
- package/docs/fixes/README.md +37 -0
- package/docs/github-issues/issue-1-body.md +125 -0
- package/docs/github-issues/issue-10-body.md +850 -0
- package/docs/github-issues/issue-2-body.md +200 -0
- package/docs/github-issues/issue-3-body.md +270 -0
- package/docs/github-issues/issue-4-body.md +169 -0
- package/docs/github-issues/issue-5-body.md +173 -0
- package/docs/github-issues/issue-6-body.md +158 -0
- package/docs/github-issues/issue-7-body.md +171 -0
- package/docs/github-issues/issue-8-body.md +407 -0
- package/docs/github-issues/issue-9-body.md +515 -0
- package/docs/github-issues/issue-tracker.md +274 -0
- package/docs/github-issues/predictive-analysis-2025-10-18.md +2131 -0
- package/docs/implementation/List_Framework_Refactor_Plan.md +336 -0
- package/docs/implementation/PRIMARY_TEXT_COLOR_FEATURE.md +217 -0
- package/docs/implementation/RELEASE_PLAN_v2.1.0.md +362 -0
- package/docs/implementation/RefactorStyles.md +588 -0
- package/docs/implementation/implement-plan.md +489 -0
- package/docs/implementation/missing-helpers-implementation.md +391 -0
- package/docs/implementation/refactor-plan.md +520 -0
- package/docs/implementation/session-implementation-complete.md +233 -0
- package/docs/implementation/session-management-plan.md +250 -0
- package/docs/setup-checklist.md +77 -0
- package/docs/versions/changelog.md +345 -0
- package/electron/customUpdater.ts +656 -0
- package/electron/main.ts +2441 -0
- package/electron/memoryConfig.ts +187 -0
- package/electron/preload.ts +394 -0
- package/electron/proxyConfig.ts +340 -0
- package/electron/services/BackupService.ts +452 -0
- package/electron/services/DictionaryService.ts +402 -0
- package/electron/services/LocalDictionaryLookupService.ts +147 -0
- package/electron/services/PowerAutomateApiService.ts +231 -0
- package/electron/services/SharePointSyncService.ts +474 -0
- package/electron/windowsCertStore.ts +427 -0
- package/electron/zscalerConfig.ts +381 -0
- package/eslint.config.js +92 -0
- package/jest.config.js +52 -0
- package/package.json +214 -0
- package/postcss.config.mjs +6 -0
- package/public/icon.png +0 -0
- package/publish-release.ps1 +5 -0
- package/renovate.json +30 -0
- package/src/App.tsx +216 -0
- package/src/__mocks__/p-limit.js +12 -0
- package/src/__mocks__/styleMock.js +1 -0
- package/src/components/common/BugReportButton.tsx +44 -0
- package/src/components/common/BugReportDialog.tsx +193 -0
- package/src/components/common/Button.tsx +153 -0
- package/src/components/common/Card.tsx +86 -0
- package/src/components/common/ColorPickerDialog.tsx +177 -0
- package/src/components/common/ConfirmDialog.tsx +96 -0
- package/src/components/common/DebugConsole.tsx +275 -0
- package/src/components/common/EmptyState.tsx +183 -0
- package/src/components/common/ErrorBoundary.tsx +98 -0
- package/src/components/common/ErrorDetailsDialog.tsx +153 -0
- package/src/components/common/ErrorFallback.tsx +218 -0
- package/src/components/common/Input.tsx +109 -0
- package/src/components/common/Skeleton.tsx +184 -0
- package/src/components/common/SplashScreen.tsx +81 -0
- package/src/components/common/Toast.tsx +155 -0
- package/src/components/common/Tooltip.tsx +79 -0
- package/src/components/common/UpdateNotification.tsx +320 -0
- package/src/components/comparison/ComparisonWindow.tsx +374 -0
- package/src/components/comparison/SideBySideDiff.tsx +486 -0
- package/src/components/comparison/index.ts +8 -0
- package/src/components/document/DocumentUploader.tsx +288 -0
- package/src/components/document/HyperlinkPreview.tsx +430 -0
- package/src/components/document/HyperlinkService.md +1484 -0
- package/src/components/document/Hyperlink_Technical_Documentation.md +496 -0
- package/src/components/document/InlineChangesView.tsx +707 -0
- package/src/components/document/ProcessingProgress.tsx +303 -0
- package/src/components/document/ProcessingResults.tsx +256 -0
- package/src/components/document/TrackedChangesDetail.tsx +530 -0
- package/src/components/document/TrackedChangesPanel.tsx +546 -0
- package/src/components/document/VirtualDocumentList.tsx +240 -0
- package/src/components/editor/DocumentEditor.tsx +723 -0
- package/src/components/editor/DocumentEditorModal.tsx +640 -0
- package/src/components/editor/EditorQuickActions.tsx +502 -0
- package/src/components/editor/EditorToolbar.tsx +312 -0
- package/src/components/editor/TableEditor.tsx +926 -0
- package/src/components/editor/index.ts +18 -0
- package/src/components/layout/Header.tsx +190 -0
- package/src/components/layout/Sidebar.tsx +313 -0
- package/src/components/layout/TitleBar.tsx +190 -0
- package/src/components/navigation/CommandPalette.tsx +233 -0
- package/src/components/navigation/KeyboardShortcutsModal.tsx +173 -0
- package/src/components/sessions/ChangeItem.tsx +408 -0
- package/src/components/sessions/ChangeViewer.tsx +1155 -0
- package/src/components/sessions/DocumentComparisonModal.tsx +314 -0
- package/src/components/sessions/ProcessingOptions.tsx +297 -0
- package/src/components/sessions/ReplacementsTab.tsx +438 -0
- package/src/components/sessions/RevisionHandlingOptions.tsx +87 -0
- package/src/components/sessions/SessionManager.tsx +188 -0
- package/src/components/sessions/StylesEditor.tsx +1335 -0
- package/src/components/sessions/TabContainer.tsx +151 -0
- package/src/components/sessions/VirtualSessionList.tsx +157 -0
- package/src/components/sessions/sessionToProcessorManager.tsx +420 -0
- package/src/components/settings/CertificateManager.tsx +410 -0
- package/src/components/settings/SegmentedControl.tsx +88 -0
- package/src/components/settings/SettingRow.tsx +52 -0
- package/src/contexts/GlobalStatsContext.tsx +396 -0
- package/src/contexts/SessionContext.tsx +2129 -0
- package/src/contexts/ThemeContext.tsx +428 -0
- package/src/contexts/UserSettingsContext.tsx +290 -0
- package/src/contexts/__tests__/GlobalStatsContext.test.tsx +390 -0
- package/src/global.d.ts +273 -0
- package/src/hooks/useDocumentQueue.tsx +210 -0
- package/src/hooks/useToast.tsx +55 -0
- package/src/main.tsx +10 -0
- package/src/pages/Analytics.tsx +386 -0
- package/src/pages/CurrentSession.tsx +1174 -0
- package/src/pages/Dashboard.tsx +319 -0
- package/src/pages/Documents.tsx +317 -0
- package/src/pages/Projects.tsx +250 -0
- package/src/pages/Reporting.tsx +386 -0
- package/src/pages/Search.tsx +349 -0
- package/src/pages/Sessions.tsx +285 -0
- package/src/pages/Settings.tsx +2662 -0
- package/src/services/HyperlinkService.ts +1085 -0
- package/src/services/document/DocXMLaterProcessor.ts +617 -0
- package/src/services/document/DocumentProcessingComparison.ts +856 -0
- package/src/services/document/DocumentSnapshotService.ts +575 -0
- package/src/services/document/WordDocumentProcessor.ts +10509 -0
- package/src/services/document/__tests__/DocXMLaterProcessor.hyperlinks.test.md +311 -0
- package/src/services/document/__tests__/WordDocumentProcessor.integration.test.ts +515 -0
- package/src/services/document/__tests__/WordDocumentProcessor.test.ts +812 -0
- package/src/services/document/blanklines/BlankLineManager.ts +658 -0
- package/src/services/document/blanklines/__tests__/paragraphChecks.test.ts +281 -0
- package/src/services/document/blanklines/helpers/blankLineInsertion.ts +87 -0
- package/src/services/document/blanklines/helpers/blankLineSnapshot.ts +251 -0
- package/src/services/document/blanklines/helpers/clearCustom.ts +121 -0
- package/src/services/document/blanklines/helpers/contextChecks.ts +117 -0
- package/src/services/document/blanklines/helpers/imageChecks.ts +51 -0
- package/src/services/document/blanklines/helpers/paragraphChecks.ts +236 -0
- package/src/services/document/blanklines/helpers/removeBlanksBetweenListItems.ts +91 -0
- package/src/services/document/blanklines/helpers/removeTrailingBlanks.ts +35 -0
- package/src/services/document/blanklines/helpers/tableGuards.ts +21 -0
- package/src/services/document/blanklines/index.ts +67 -0
- package/src/services/document/blanklines/rules/additionRules.ts +337 -0
- package/src/services/document/blanklines/rules/indentationRules.ts +317 -0
- package/src/services/document/blanklines/rules/removalRules.ts +362 -0
- package/src/services/document/blanklines/rules/ruleTypes.ts +92 -0
- package/src/services/document/blanklines/types.ts +29 -0
- package/src/services/document/helpers/ImageBorderCropper.ts +377 -0
- package/src/services/document/helpers/__tests__/whitespace.test.ts +272 -0
- package/src/services/document/helpers/whitespace.ts +117 -0
- package/src/services/document/list/ListNormalizer.ts +947 -0
- package/src/services/document/list/index.ts +45 -0
- package/src/services/document/list/list-detection.ts +275 -0
- package/src/services/document/list/list-types.ts +162 -0
- package/src/services/document/processors/HyperlinkProcessor.ts +370 -0
- package/src/services/document/processors/ListProcessor.ts +257 -0
- package/src/services/document/processors/StructureProcessor.ts +176 -0
- package/src/services/document/processors/StyleProcessor.ts +389 -0
- package/src/services/document/processors/TableProcessor.ts +2238 -0
- package/src/services/document/processors/__tests__/HyperlinkProcessor.test.ts +314 -0
- package/src/services/document/processors/__tests__/ListProcessor.test.ts +291 -0
- package/src/services/document/processors/__tests__/StructureProcessor.test.ts +257 -0
- package/src/services/document/processors/__tests__/TableProcessor.hlp-tips-bullets.test.ts +459 -0
- package/src/services/document/processors/__tests__/TableProcessor.test.ts +1604 -0
- package/src/services/document/processors/index.ts +28 -0
- package/src/services/document/types/docx-processing.ts +310 -0
- package/src/services/editor/EditorActionHandlers.ts +901 -0
- package/src/services/editor/index.ts +13 -0
- package/src/setupTests.ts +47 -0
- package/src/styles/global.css +782 -0
- package/src/types/backup.ts +132 -0
- package/src/types/dictionary.ts +125 -0
- package/src/types/document-processing.ts +331 -0
- package/src/types/docxmlater-augments.d.ts +142 -0
- package/src/types/editor.ts +280 -0
- package/src/types/electron.ts +340 -0
- package/src/types/globalStats.ts +155 -0
- package/src/types/hyperlink.ts +471 -0
- package/src/types/operations.ts +354 -0
- package/src/types/session.ts +427 -0
- package/src/types/settings.ts +112 -0
- package/src/utils/MemoryMonitor.ts +248 -0
- package/src/utils/cn.ts +6 -0
- package/src/utils/colorConvert.ts +306 -0
- package/src/utils/diffUtils.ts +347 -0
- package/src/utils/documentUtils.ts +202 -0
- package/src/utils/electronGuard.ts +62 -0
- package/src/utils/indexedDB.ts +915 -0
- package/src/utils/logger.ts +717 -0
- package/src/utils/pathSecurity.ts +232 -0
- package/src/utils/pathValidator.ts +236 -0
- package/src/utils/processingTimeEstimator.ts +153 -0
- package/src/utils/safeJsonParse.ts +62 -0
- package/src/utils/textSanitizer.ts +162 -0
- package/src/utils/urlHelpers.ts +304 -0
- package/src/utils/urlPatterns.ts +198 -0
- package/src/utils/urlSanitizer.ts +152 -0
- package/src/vite-env.d.ts +11 -0
- package/tsconfig.electron.json +19 -0
- package/tsconfig.json +36 -0
- package/tsconfig.node.json +12 -0
- package/typedoc.json +45 -0
- 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
|