@bytechain.cn/colamd 1.5.1-beta.2 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/CHANGELOG.md +159 -162
  2. package/README.md +79 -3
  3. package/README_CN.md +78 -3
  4. package/dist/main/index.js +14 -5
  5. package/dist/preload/index.js +1 -1
  6. package/dist/renderer/assets/{arc-CPdeInCG.js → arc-_lugyDzx.js} +1 -1
  7. package/dist/renderer/assets/{architectureDiagram-3BPJPVTR-BAbnaR9G.js → architectureDiagram-3BPJPVTR-DDfP-F9D.js} +2 -2
  8. package/dist/renderer/assets/{blockDiagram-GPEHLZMM-CYSWjnJg.js → blockDiagram-GPEHLZMM-DOETUKma.js} +4 -4
  9. package/dist/renderer/assets/{c4Diagram-AAUBKEIU-Rb1tstnr.js → c4Diagram-AAUBKEIU-kAmLfVtk.js} +2 -2
  10. package/dist/renderer/assets/{channel-DpG2A6fE.js → channel-CD4vJFwr.js} +1 -1
  11. package/dist/renderer/assets/{chunk-2J33WTMH-DFc0Jxy_.js → chunk-2J33WTMH-DkVrgw4l.js} +1 -1
  12. package/dist/renderer/assets/{chunk-4BX2VUAB-BhRxDTNn.js → chunk-4BX2VUAB-JTZ-VKNX.js} +1 -1
  13. package/dist/renderer/assets/{chunk-55IACEB6-DEgMVBk8.js → chunk-55IACEB6-Di_O5box.js} +1 -1
  14. package/dist/renderer/assets/{chunk-727SXJPM-bjBIfiz8.js → chunk-727SXJPM-BgKvwR8w.js} +5 -5
  15. package/dist/renderer/assets/{chunk-AQP2D5EJ-DwQMzTzD.js → chunk-AQP2D5EJ-DonSXCCQ.js} +3 -3
  16. package/dist/renderer/assets/{chunk-FMBD7UC4-CkphwJzs.js → chunk-FMBD7UC4-CsV8Lmy6.js} +1 -1
  17. package/dist/renderer/assets/{chunk-ND2GUHAM-oU09z4y4.js → chunk-ND2GUHAM-C_-_dlq7.js} +1 -1
  18. package/dist/renderer/assets/{chunk-QZHKN3VN-rCbVuPBn.js → chunk-QZHKN3VN-aCmcDsfu.js} +1 -1
  19. package/dist/renderer/assets/{classDiagram-v2-Q7XG4LA2-DGS2faoM.js → classDiagram-4FO5ZUOK-nuHQLjzM.js} +6 -6
  20. package/dist/renderer/assets/{classDiagram-4FO5ZUOK-DGS2faoM.js → classDiagram-v2-Q7XG4LA2-nuHQLjzM.js} +6 -6
  21. package/dist/renderer/assets/{cose-bilkent-S5V4N54A-iqY6-EwA.js → cose-bilkent-S5V4N54A-Di1_SXt9.js} +1 -1
  22. package/dist/renderer/assets/{dagre-BM42HDAG-5t3X5sDa.js → dagre-BM42HDAG-CqOUIYsL.js} +3 -3
  23. package/dist/renderer/assets/{diagram-2AECGRRQ-DzHiYDPh.js → diagram-2AECGRRQ-F-fP19TC.js} +2 -2
  24. package/dist/renderer/assets/{diagram-5GNKFQAL-BiNv6Keq.js → diagram-5GNKFQAL-BD5XZc8G.js} +3 -3
  25. package/dist/renderer/assets/{diagram-KO2AKTUF-ClzeDG6f.js → diagram-KO2AKTUF-Qa3ZxA67.js} +2 -2
  26. package/dist/renderer/assets/{diagram-LMA3HP47-CGkw7wII.js → diagram-LMA3HP47-DqDnw2RA.js} +2 -2
  27. package/dist/renderer/assets/{diagram-OG6HWLK6-Dl-Hyk1_.js → diagram-OG6HWLK6-BH4Elzby.js} +3 -3
  28. package/dist/renderer/assets/{erDiagram-TEJ5UH35-BxUN79Qb.js → erDiagram-TEJ5UH35-CaKZCewa.js} +4 -4
  29. package/dist/renderer/assets/{flowDiagram-I6XJVG4X-CzFk-KNI.js → flowDiagram-I6XJVG4X-C8znUgyL.js} +6 -6
  30. package/dist/renderer/assets/{ganttDiagram-6RSMTGT7-C2xl6Igx.js → ganttDiagram-6RSMTGT7-DnRvbMnU.js} +2 -2
  31. package/dist/renderer/assets/{gitGraphDiagram-PVQCEYII-_fn7XCa7.js → gitGraphDiagram-PVQCEYII-CZuRZzk4.js} +3 -3
  32. package/dist/renderer/assets/{graph-CDoHYrHm.js → graph-CYiEKt0j.js} +1 -1
  33. package/dist/renderer/assets/{index-DAlXyxzt.js → index-BX6JHKv6.js} +328 -143
  34. package/dist/renderer/assets/{index-CeFpoCKV.css → index-CcwAgVRi.css} +5 -6
  35. package/dist/renderer/assets/{infoDiagram-5YYISTIA-DL6XIxLz.js → infoDiagram-5YYISTIA-BlBUdqMb.js} +1 -1
  36. package/dist/renderer/assets/{ishikawaDiagram-YF4QCWOH-BUZLjRo-.js → ishikawaDiagram-YF4QCWOH-TeVytCrP.js} +1 -1
  37. package/dist/renderer/assets/{journeyDiagram-JHISSGLW-C4rH_mQM.js → journeyDiagram-JHISSGLW-BLZa3jnX.js} +4 -4
  38. package/dist/renderer/assets/{kanban-definition-UN3LZRKU-DRbrBcWV.js → kanban-definition-UN3LZRKU-foVxWrJn.js} +2 -2
  39. package/dist/renderer/assets/{layout-DZl4n4qu.js → layout-DOAlFUVb.js} +2 -2
  40. package/dist/renderer/assets/{linear-B0Krxg21.js → linear-BMBn6kVq.js} +1 -1
  41. package/dist/renderer/assets/{mindmap-definition-RKZ34NQL-DdmPsWrn.js → mindmap-definition-RKZ34NQL-5pGeNCcp.js} +3 -3
  42. package/dist/renderer/assets/{pieDiagram-4H26LBE5-BPZLqwG0.js → pieDiagram-4H26LBE5-N9aAUxfr.js} +3 -3
  43. package/dist/renderer/assets/{quadrantDiagram-W4KKPZXB-Dr-oWRk9.js → quadrantDiagram-W4KKPZXB-BPxbtjga.js} +2 -2
  44. package/dist/renderer/assets/{requirementDiagram-4Y6WPE33-B6QZd0lo.js → requirementDiagram-4Y6WPE33-CK1LrJyG.js} +3 -3
  45. package/dist/renderer/assets/{sankeyDiagram-5OEKKPKP-Cyl9ojEt.js → sankeyDiagram-5OEKKPKP-BNj7Sqii.js} +1 -1
  46. package/dist/renderer/assets/{sequenceDiagram-3UESZ5HK-D48Yr9T6.js → sequenceDiagram-3UESZ5HK-B-r7lNhI.js} +3 -3
  47. package/dist/renderer/assets/{stateDiagram-AJRCARHV-qyb8ETsa.js → stateDiagram-AJRCARHV-wrWE0MRa.js} +6 -6
  48. package/dist/renderer/assets/{stateDiagram-v2-BHNVJYJU-DmDOyyrJ.js → stateDiagram-v2-BHNVJYJU-CE-Lqo2d.js} +4 -4
  49. package/dist/renderer/assets/{timeline-definition-PNZ67QCA-C-KQxTi1.js → timeline-definition-PNZ67QCA-BkeMGH4J.js} +2 -2
  50. package/dist/renderer/assets/{vennDiagram-CIIHVFJN-BdaZlnH-.js → vennDiagram-CIIHVFJN-BTxVzto3.js} +1 -1
  51. package/dist/renderer/assets/{wardleyDiagram-YWT4CUSO-B2hBE-EE.js → wardleyDiagram-YWT4CUSO-D2r5dVGW.js} +2 -2
  52. package/dist/renderer/assets/{xychartDiagram-2RQKCTM6-CSvswDTY.js → xychartDiagram-2RQKCTM6-BHQdINVc.js} +2 -2
  53. package/dist/renderer/index.html +2 -2
  54. package/docs/RELEASE_NOTES_v1.5.1.md +382 -0
  55. package/docs/academic-demo.md +2 -1
  56. package/docs/theme-paradigm.md +141 -2
  57. package/package.json +1 -1
  58. package/src/main/index.ts +19 -5
  59. package/src/preload/index.ts +2 -2
  60. package/src/renderer/editor/editor.ts +40 -40
  61. package/src/renderer/editor/plugins/index.ts +18 -0
  62. package/src/renderer/editor/plugins/math-plugin.ts +8 -0
  63. package/src/renderer/editor/plugins/mermaid-plugin.ts +10 -0
  64. package/src/renderer/editor/plugins/themes/theme-manager.ts +41 -0
  65. package/src/renderer/main.ts +180 -83
  66. package/src/renderer/mobile.css +5 -6
  67. package/themes/README.md +18 -1
  68. package/themes/academic-paper-pt.css +1321 -0
  69. package/themes/academic-paper.css +192 -97
  70. package/tsconfig.renderer.tsbuildinfo +1 -1
  71. package/bytechain.cn-colamd-1.5.1-beta.2.tgz +0 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,164 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ### Changed
11
+
12
+ #### PDF Export & Plugin System
13
+ - **Refactored PDF export pipeline** ([`src/renderer/main.ts`](src/renderer/main.ts), [`src/main/index.ts`](src/main/index.ts)):
14
+ - Support for custom print styles with simplified base print CSS
15
+ - Refactored `buildExportHTML` function to auto-extract current theme styles
16
+ - Added auto-injection of custom theme print styles
17
+ - Streamlined export HTML template, removed hardcoded plugin styles in favor of plugin-injected styles
18
+
19
+ #### Plugin Style Management
20
+ - **Unified plugin style management** ([`src/renderer/editor/plugins/index.ts`](src/renderer/editor/plugins/index.ts), [`src/renderer/editor/plugins/math-plugin.ts`](src/renderer/editor/plugins/math-plugin.ts), [`src/renderer/editor/plugins/mermaid-plugin.ts`](src/renderer/editor/plugins/mermaid-plugin.ts)):
21
+ - Added unified configuration fields (clipboard styles, export styles) for Math and Mermaid plugins
22
+ - Replaced hardcoded style handling logic with dynamic retrieval from plugin configuration
23
+ - Optimized error recovery logic to dynamically skip failing plugins instead of hard-excluding math plugin
24
+
25
+ #### Theme System
26
+ - **Fixed custom theme export issues** ([`src/renderer/editor/plugins/themes/theme-manager.ts`](src/renderer/editor/plugins/themes/theme-manager.ts)):
27
+ - Fixed custom theme print CSS extraction logic to avoid Chromium CSSOM serialization issues
28
+ - **Rendering output optimization** ([`src/renderer/editor/editor.ts`](src/renderer/editor/editor.ts), [`src/renderer/main.ts`](src/renderer/main.ts)):
29
+ - Wrapped `getLiveHTML` return content in a div with id "write"
30
+ - Only render base element styles when not using custom themes
31
+
32
+ #### Mobile Platform
33
+ - **Fixed mobile media query** ([`src/renderer/mobile.css`](src/renderer/mobile.css)):
34
+ - Fixed missing screen type in media queries
35
+
36
+ ### Removed
37
+ - Removed outdated PDF font compensation document ([`docs/PDF_FONT_COMPENSATION.md`](docs/PDF_FONT_COMPENSATION.md))
38
+
39
+ ---
40
+
41
+ ## [1.5.1] - 2026-05-23
42
+
43
+ ### Added
44
+
45
+ #### Themes
46
+ - **Academic Paper theme** ([`themes/academic-paper.css`](themes/academic-paper.css)) — Academic paper theme strictly following GB/T 7713 national standard specifications, including three-line tables, SimHei/SimSun typography, multi-level headings, figure/table caption standards
47
+ - **Swiss Design theme** ([`themes/swiss-design.css`](themes/swiss-design.css)) 🇨🇭 — Swiss International Typographic Style: black-white-red color system, geometric sans-serif fonts, grid-based layout, white-on-black table headers
48
+ - **Pixso Design theme** ([`themes/pixso-design.css`](themes/pixso-design.css)) — Pixso design specification theme
49
+ - **Forest Ink theme** ([`themes/forest-ink.css`](themes/forest-ink.css)) — Forest ink style theme
50
+ - **Standardized template** ([`themes/template.css`](themes/template.css)) — Reference implementation template following v3.0 paradigm: variable-based + modular + print fidelity
51
+
52
+ #### Theme Development Framework
53
+ - **Theme paradigm document** ([`docs/theme-paradigm.md`](docs/theme-paradigm.md)) — Complete CSS theme development specification (v3.2):
54
+ - Design principles: variable-driven, modular, semantic naming, AI-agent derivable
55
+ - Design specifications: 30+ verifiable rules (MUST / MUST NOT / SHOULD) including WCAG contrast formula
56
+ - Print fidelity specifications: variable re-declaration, required element coverage list (12 categories), Chromium print constraints
57
+ - px unit unification standard (9.x): prohibits pt/rem mixing to ensure consistent PDF export font sizes
58
+
59
+ #### Platform Support
60
+ - **Android platform**: Capacitor 6 integration, native APK build, file picker, mobile-adapted styles ([`mobile.css`](src/renderer/mobile.css))
61
+ - **iOS platform**: Capacitor 6 integration, native IPA build
62
+ - **Dual-platform bridge**: Runtime auto-detection of Electron/Capacitor API (`capacitor-api.ts`)
63
+
64
+ #### Documentation & Demo
65
+ - **Academic paper demo document** ([`docs/academic-demo.md`](docs/academic-demo.md)) — Wanhua ecosystem research report with 8 Mermaid diagram groups
66
+ - **Inline SVG guide** ([`docs/demo.html`](docs/demo.html)) — Best practices demonstration for embedding SVG in Markdown
67
+ - **General demo document** ([`docs/demo.md`](docs/demo.md)) — Full feature showcase
68
+
69
+ ### Changed
70
+
71
+ #### Theme System Architecture
72
+ - **Modular refactoring**: Theme system split into `foundation.css` + `base/` built-in themes + `components/mermaid/` Mermaid variable mapping + user theme directory
73
+ - **Mermaid variable system**: 20 core CSS variables (`--mermaid-*`) auto-mapped to 22 chart type SVG selectors
74
+ - **Academic paper theme refactoring**: Section 14 hardcoded color values all refactored to `var()` variable references; all `pt` units replaced with `px` even integers
75
+
76
+ #### PDF Export & Plugin System (Post-release)
77
+ - **Refactored PDF export pipeline** ([`src/renderer/main.ts`](src/renderer/main.ts), [`src/main/index.ts`](src/main/index.ts)):
78
+ - Support for custom print styles with simplified base print CSS
79
+ - Refactored `buildExportHTML` function to auto-extract current theme styles and inject into export HTML
80
+ - Streamlined export HTML template, removed hardcoded plugin styles in favor of plugin-injected styles
81
+ - **Unified plugin style management** ([`src/renderer/editor/plugins/index.ts`](src/renderer/editor/plugins/index.ts), [`src/renderer/editor/plugins/math-plugin.ts`](src/renderer/editor/plugins/math-plugin.ts), [`src/renderer/editor/plugins/mermaid-plugin.ts`](src/renderer/editor/plugins/mermaid-plugin.ts)):
82
+ - Added unified configuration fields (clipboard styles, export styles) for Math and Mermaid plugins
83
+ - Replaced hardcoded style handling logic with dynamic retrieval from plugin configuration
84
+ - Optimized error recovery logic to dynamically skip failing plugins instead of hard-excluding math plugin
85
+
86
+ #### Editor Core & Rendering
87
+ - Removed debug auto-open developer tools code
88
+ - Optimized academic paper theme styles
89
+ - **Rendering output optimization** ([`src/renderer/editor/editor.ts`](src/renderer/editor/editor.ts), [`src/renderer/main.ts`](src/renderer/main.ts)):
90
+ - Wrapped `getLiveHTML` return content in a div with id "write"
91
+ - Only render base element styles when not using custom themes
92
+
93
+ ### Fixed
94
+
95
+ #### TypeScript Type System (beta.2)
96
+ - **Fixed 15 TypeScript type errors**:
97
+ - [`capacitor-api.ts`](src/renderer/capacitor-api.ts): Fixed `string | null` type assignment error
98
+ - [`editor.ts`](src/renderer/editor/editor.ts): Fixed `remarkPluginsCtx` type mismatch and `rootEl` null check
99
+ - [`math-plugin.ts`](src/renderer/editor/plugins/math-plugin.ts): Fixed `$NodeSchema` type compatibility with `$view` function
100
+ - [`mermaid-plugin.ts`](src/renderer/editor/plugins/mermaid-plugin.ts): Fixed Mermaid theme type and `$NodeSchema` type issues
101
+ - [`main.ts`](src/renderer/main.ts): Added Vite client types reference for `import.meta.glob`
102
+ - [`main/index.ts`](src/main/index.ts): Removed invalid `fs.createServer` import and `PrintToPDFOptions.marginType`
103
+ - **TypeScript project configuration update**: Added `"composite": true` to all project configurations for proper project references
104
+ - [`tsconfig.main.json`](tsconfig.main.json)
105
+ - [`tsconfig.preload.json`](tsconfig.preload.json)
106
+ - [`tsconfig.renderer.json`](tsconfig.renderer.json)
107
+
108
+ #### Mermaid Diagram Rendering
109
+ - **Fixed text offset and border issues** (elegant + academic-paper themes):
110
+ - Fixed Mermaid text offset problem
111
+ - Fixed variable name mismatch issue
112
+ - Fixed double border display issue
113
+ - **Mermaid theme system refactoring**:
114
+ - Adjusted to Guizang warm color palette (cream background + brown tones)
115
+ - Font size adjusted to 10.5pt for academic printing compatibility
116
+ - Added Typora compatible selectors (`.md-diagram-panel`)
117
+ - Added mobile responsive adaptation
118
+ - Unified text color and border styles
119
+
120
+ #### Theme Print Fidelity
121
+ - **Fixed missing print style mirrors**: Completed `@media print` screen attribute mirrors for template CSS and Swiss Design CSS
122
+ - Covered attributes include: font size, line height, font family, borders, spacing, letter spacing, etc.
123
+ - Ensured consistency between screen preview and PDF export
124
+ - **Fixed custom theme export issues** ([`theme-manager.ts`](src/renderer/editor/plugins/themes/theme-manager.ts)):
125
+ - Fixed custom theme print CSS extraction logic to avoid Chromium CSSOM serialization issues
126
+ - Added auto-injection of custom theme print styles
127
+
128
+ #### Android Platform (beta.1)
129
+ - **Chinese IME (Input Method Editor) fix**:
130
+ - Removed `e.preventDefault()` in `beforeinput` event to resolve CJK input method issues
131
+ - Enhanced ProseMirror editor IME composition event handling
132
+ - Used `-webkit-user-modify: read-write-plaintext-only` to improve input experience
133
+ - **Intent file open fix**:
134
+ - Added `Intent.ACTION_VIEW` handling in `MainActivity`
135
+ - Supported `onNewIntent` for opening new files when app is already running
136
+ - Passed file content to WebView via JavaScript events
137
+ - **PDF export fix**:
138
+ - Replaced Capacitor Plugin bridge with `JavascriptInterface`
139
+ - Added `ColaMDNativeBridge` class to call Android native `PrintManager`
140
+ - Added "Save as PDF" option
141
+ - Fixed pagination, save button, Mermaid version, and layer residue issues
142
+
143
+ #### Export Functionality Improvements
144
+ - **PDF/HTML export optimization**:
145
+ - Refactored Mermaid rendering logic with export sync wait mechanism
146
+ - Supported real-time rendered content export
147
+ - Fixed default filename logic
148
+ - **File manager open mechanism**:
149
+ - Adopted pull model: JS actively calls Java `checkPendingFile()` to query
150
+ - Eliminated JS event injection timing issues
151
+ - Added init detection + setInterval polling for dual guarantee
152
+
153
+ #### Mobile Adaptation
154
+ - **Fixed missing media query type** ([`mobile.css`](src/renderer/mobile.css)):
155
+ - Fixed missing screen type in media queries
156
+
157
+ #### Plugin System
158
+ - **Plugin import fixes and package version updates**
159
+ - **Decoupled plugin system**: Reduced main.ts dependency on specific plugins
160
+
161
+ ### Removed
162
+ - Removed outdated PDF font compensation document ([`docs/PDF_FONT_COMPENSATION.md`](docs/PDF_FONT_COMPENSATION.md))
163
+
164
+ ---
165
+
8
166
  ## [1.5.1-beta.2] - 2026-05-22
9
167
 
10
168
  ### Fixed
@@ -149,89 +307,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
149
307
  | @capawesome/capacitor-file-picker | ^6.2.0 | Android file picker plugin |
150
308
  | sharp | ^0.34.5 | Icon generation tool |
151
309
 
152
- ---
153
-
154
- ## [1.5.1] - 2026-05-18
155
-
156
- ### Added
157
-
158
- #### Capacitor 6 — Mobile Platform Support (Cross-Platform Extension)
159
- - **Capacitor 6 integration** for building native Android (.apk) and iOS (.ipa) apps
160
- - **Platform bridge layer** ([`capacitor-api.ts`](src/renderer/capacitor-api.ts)): Full replacement of Electron IPC with Capacitor native plugins
161
- - Filesystem plugin for file read/write on mobile devices
162
- - Share plugin for content sharing and export
163
- - App plugin for lifecycle management and deep linking
164
- - Status bar plugin for mobile UI integration
165
- - Haptics plugin for tactile feedback support
166
- - **Auto-detection runtime**: `window.electronAPI || createCapacitorAPI()` — seamless switching between desktop (Electron) and mobile (Capacitor) environments
167
- - **Mobile responsive UI** ([`mobile.css`](src/renderer/mobile.css)):
168
- - Touch-optimized interactions with `-webkit-tap-highlight-color: transparent`
169
- - Safe area insets support (`env(safe-area-inset-*)`) for notched devices
170
- - Responsive breakpoints: 768px (tablet), 480px (phone)
171
- - Optimized font sizes, padding, and scroll behavior for mobile screens
172
- - Context menu adaptation for touch interfaces
173
-
174
- #### Android Platform Configuration
175
- - Android project initialized at [`android/`](android/) with Gradle build system
176
- - **File association**: Registered `.md` / `.markdown` file handlers in `AndroidManifest.xml`
177
- - **Storage permissions**: `READ_EXTERNAL_STORAGE`, `WRITE_EXTERNAL_STORAGE`, `MANAGE_EXTERNAL_STORAGE`
178
- - **Network security config**: Cleartext traffic allowed for local development
179
- - **Soft input mode**: `adjustResize` for proper keyboard handling in editor
180
- - **5 Capacitor plugins auto-detected**: @capacitor/app, filesystem, haptics, share, status-bar
181
-
182
- #### iOS Platform Configuration
183
- - Xcode project initialized at [`ios/`](ios/) with CocoaPods dependency management
184
- - Requires Xcode + CocoaPods for full build (pod install)
185
- - Web assets synced to `ios/App/App/public/`
186
-
187
- #### Build Scripts & Workflow
188
- - New npm scripts for Capacitor development workflow:
189
-
190
- | Script | Purpose |
191
- |--------|---------|
192
- | `npm run cap:sync` | Sync web assets to native platforms |
193
- | `npm run cap:open:android` | Open in Android Studio |
194
- | `npm run cap:open:ios` | Open in Xcode |
195
- | `npm run cap:run:android` | Build → Sync → Run on Android device/emulator |
196
- | `npm run cap:run:ios` | Build → Sync → Run on iOS simulator |
197
- | `npm run cap:build:android` | Build debug APK |
198
- | `npm run cap:build:ios` | Build iOS project |
199
-
200
- #### Dual-Platform Architecture
201
- ```
202
- ┌─────────────────────────────────────┐
203
- │ src/renderer/main.ts │
204
- │ api = electronAPI || capacitorAPI │ ← Auto-detect platform
205
- ├──────────────┬──────────────────────┤
206
- │ Electron │ Capacitor 6 │
207
- │ (Desktop) │ (Mobile) │
208
- │ │ │
209
- │ IPC comm │ Filesystem Plugin │
210
- │ dialog │ Share Plugin │
211
- │ shell.open │ App Plugin │
212
- │ fs module │ localStorage storage │
213
- └──────────────┴──────────────────────┘
214
- ```
215
-
216
- ### Changed
217
- - Updated [`editor.ts`](src/renderer/editor/editor.ts): Added fallback `window.capacitorAPI?.openExternal()` for link handling on mobile
218
- - Updated [`env.d.ts`](src/renderer/env.d.ts): Extended type declarations to include `window.capacitorAPI`
219
- - Package version bumped to **1.5.1**
220
-
221
- ### Dependencies
222
-
223
- | Package | Version | Purpose |
224
- |---------|---------|---------|
225
- | @capacitor/core | ^6.2.1 | Capacitor core runtime |
226
- | @capacitor/cli | ^6.2.1 | Capacitor CLI tools |
227
- | @capacitor/android | ^6.2.1 | Android native bridge |
228
- | @capacitor/ios | ^6.2.1 | iOS native bridge |
229
- | @capacitor/filesystem | ^6.0.4 | Mobile file I/O |
230
- | @capacitor/share | ^6.0.4 | Native sharing |
231
- | @capacitor/app | ^6.0.3 | App lifecycle |
232
- | @capacitor/haptics | ^6.0.3 | Tactile feedback |
233
- | @capacitor/status-bar | ^6.0.3 | Status bar control |
234
-
235
310
  ## [1.5.0] - 2026-05-18
236
311
 
237
312
  ### Added
@@ -242,82 +317,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
242
317
  - **Plug** menu in menu bar for unified plugin render control
243
318
 
244
319
  #### Math Plugin (KaTeX Integration)
245
- - Add KaTeX rendering engine for LaTeX math equation support
246
- - **Inline equations** (`$...$`): embedded within paragraphs, e.g., $E = mc^2$
247
- - **Block equations** (`$$...$$`): centered display with support for complex expressions (equation systems, matrices, physics formulas)
248
- - **Dual-mode toggle**: switch between rendered preview and source editing with one click
249
- - Live editing: edit LaTeX source directly in raw mode; auto-save and re-render on blur
250
- - Graceful fallback: degrade to plain text on KaTeX parse failure without blocking workflow
251
-
252
- #### Mermaid Plugin (Diagram Rendering)
253
- - Add Mermaid.js v11.15 for 17+ diagram type visualization:
254
-
255
- | Category | Supported Diagrams |
256
- |----------|-------------------|
257
- | Flowchart | `graph` (TD/LR/RL/BT), `flowchart` |
258
- | Sequence | `sequenceDiagram` |
259
- | Class | `classDiagram` |
260
- | State | `stateDiagram-v2` |
261
- | ER | `erDiagram` |
262
- | User Journey | `journey` |
263
- | Pie | `pie` |
264
- | Gantt | `gantt` |
265
- | Git Graph | `gitGraph` |
266
- | Mind Map | `mindmap` |
267
- | Timeline | `timeline` |
268
- | Quadrant Chart | `quadrantChart` |
269
- | XY/Line/Bar Chart | `xyChart` |
270
- | C4 Architecture | `C4Context`, `C4Container`, `C4Component`, `C4Dynamic`, `C4Deployment` |
271
- | Sankey | `sankey-beta` |
272
- | Block | `block-beta` |
273
- | Architecture | `architecture-beta` |
274
-
275
- - Input shortcut: typing `` ```mermaid `` + Enter auto-converts to mermaid_block node
276
- - Async-safe rendering: render counter prevents race conditions
277
- - Multi-theme deep adaptation: each built-in theme has corresponding Mermaid color scheme
278
- - C4 architecture-specific semantic colors for persons/systems/containers/components
279
- - Auto node height adjustment after rendering (+6px padding) to prevent content overflow
280
-
281
- #### Theme Support
282
- - **Guizang theme**: new Chinese-style dark theme with traditional aesthetics
283
- - Custom Mermaid theme adaptation for Elegant, Newsprint, Dark, and Guizang themes:
284
- - Light → Default Mermaid theme (clean & bright)
285
- - Dark → GitHub Dark style (`#0d1117` background, `#8b949e` border/text)
286
- - Elegant → Custom warm palette (`#e8e2db` background, LXGW WenKai font)
287
- - Newsprint → Print style (PT Serif font, newsprint texture)
288
-
289
- #### Slides Feature — Markdown as Database
290
- - New concept: Markdown as content layer, HTML templates as view layer
291
- - Supported layouts: `cover` · `statement` · `section` · `video` · `thankyou`
292
- - Optional features: background image (`bg:`), video embed (`src:`), inline image preview (`preview:`)
293
- - Export formats: single-file HTML (Base64-inlined images) or folder (with video resources)
294
- - Tutorial template included at `resources/templates/slides/`
295
-
296
- ### Fixed
297
- - Mermaid diagram color scheme issues in dark themes causing unreadable content
298
- - Mermaid diagram container offset/miscalculation leading to content overflow
299
- - Sankey diagram syntax parsing compatibility
300
- - Slides templates not properly bundled into extraResources during build
301
-
302
- ### Dependencies
303
-
304
- | Package | Version | Purpose |
305
- |---------|---------|---------|
306
- | @milkdown/kit | ^7.19.2 | WYSIWYG editor core |
307
- | katex | ^0.16.46 | Math equation rendering engine |
308
- | mermaid | ^11.15.0 | Diagram rendering library |
309
- | electron | ^34.0.0 | Cross-platform desktop framework |
310
-
311
- ## [1.4.0] - Previous Release
312
-
313
- ### Added
314
- - Slides feature — Markdown as Database concept
315
- - Slide export capabilities (HTML single-file and folder formats)
316
-
317
- ---
318
-
319
- [1.5.1-beta.2]: https://github.com/byteuser1977/ColaMD-extend/releases/tag/v1.5.1-beta.2
320
- [1.5.1-beta.1]: https://github.com/byteuser1977/ColaMD-extend/releases/tag/v1.5.1-beta.1
321
- [1.5.1]: https://github.com/byteuser1977/ColaMD-extend/releases/tag/v1.5.1
322
- [1.5.0]: https://github.com/byteuser1977/ColaMD-extend/releases/tag/v1.5.0
323
- [1.4.0]: https://github.com/byteuser1977/ColaMD-extend/releases/tag/v1.4.0
320
+ - Add KaTeX rendering engine for LaTeX math equation support
package/README.md CHANGED
@@ -8,9 +8,48 @@ Real-time collaboration between humans and AI agents — see your agent's change
8
8
 
9
9
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
10
10
  [![GitHub release](https://img.shields.io/github/release/marswaveai/colamd.svg)](https://github.com/marswaveai/colamd/releases)
11
+ [![Version: 1.5.1](https://img.shields.io/badge/Version-1.5.1-blue.svg)](https://github.com/byteuser1977/ColaMD-extend/releases/tag/v1.5.1)
11
12
 
12
13
  **This Extended Edition**: [git@github.com:byteuser1977/ColaMD-extend.git](https://github.com/byteuser1977/ColaMD-extend)
13
14
 
15
+ ## 🎉 v1.5.1 Release Highlights (2026-05-23)
16
+
17
+ ### ✨ New Features
18
+
19
+ #### 🎨 Enhanced Theme System
20
+ - **Academic Paper Theme** — GB/T 7713 compliant academic paper formatting with three-line tables, SimHei/SimSun typography, and print-optimized Mermaid diagrams
21
+ - **Swiss Design Theme** 🇨🇭 — Swiss International Typographic Style with black-white-red color system, geometric sans-serif fonts, and grid-based layout
22
+ - **Pixso Design Theme** — Modern design system styling
23
+ - **Forest Ink Theme** — Forest ink aesthetic with warm paper base and forest green accents
24
+ - **Standardized Template** — Reference implementation following v3.0 theme paradigm for easy custom theme creation
25
+ - **Theme Development Framework** — Complete CSS theme development specification (v3.2) with 30+ verifiable rules, WCAG contrast formulas, and print fidelity guidelines
26
+
27
+ #### 📱 Mobile Platform Support
28
+ - **Android (.apk)** — Capacitor 6 integration with native file picker, IME optimization, and PDF export
29
+ - **iOS (.ipa)** — Full iOS support with Capacitor 6
30
+ - **Dual-platform bridge** — Runtime auto-detection of Electron/Capacitor APIs
31
+ - **Mobile-adapted styles** — Optimized touch interface and responsive design
32
+
33
+ #### 🔧 Post-release Improvements
34
+ - **Refactored PDF Export Pipeline** — Auto-extraction of current theme styles, custom print style support, plugin-injected styles
35
+ - **Unified Plugin Style Management** — Dynamic configuration for Math/Mermaid plugins (clipboard, export, rendering styles)
36
+ - **Enhanced Error Recovery** — Dynamic plugin skipping instead of hard-coded exclusions
37
+ - **Custom Theme Export Fix** — Resolved Chromium CSSOM serialization issues
38
+ - **Rendering Output Optimization** — Improved HTML structure for better compatibility
39
+
40
+ ### 🐛 Key Fixes
41
+ - Fixed 15 TypeScript type errors across the codebase
42
+ - Fixed Mermaid text offset and border issues (elegant + academic-paper themes)
43
+ - Fixed Chinese IME input on Android platform
44
+ - Fixed Intent file opening and PDF export on Android
45
+ - Fixed media query missing screen type for mobile
46
+ - Fixed theme print fidelity (@media print mirrors)
47
+ - Decoupled plugin system from main.ts dependencies
48
+
49
+ > ⚠️ **Theme Migration Notice**: Starting from v1.5.1, theme updates have been migrated to [ColaMD-themes](https://github.com/byteuser1977/ColaMD-themes) repository for faster iteration and community contributions.
50
+
51
+ ---
52
+
14
53
  [Features](#features) | [Renderer Plugins](#renderer-plugin-system) | [Plug Menu](#plug-menu--plugin-render-control) | [Quick Start](#quick-start) | [Mobile Build](#mobile-build--capacitor-6) | [Themes](#theme-system) | [Architecture](#technical-architecture) | [中文](README_CN.md)
15
54
 
16
55
  ---
@@ -131,10 +170,19 @@ No image? The cover falls back to a clean orange-on-white design — it just wor
131
170
 
132
171
  ### 📤 Export Capabilities
133
172
 
134
- - **PDF / HTML export**
173
+ #### PDF / HTML Export (Enhanced in v1.5.1)
174
+ - **Auto Theme Style Extraction** — Automatically extracts and injects current theme styles into exported documents
175
+ - **Custom Print Style Support** — Supports passing custom print CSS for advanced use cases
176
+ - **Plugin-Injected Styles** — Math and Mermaid plugins dynamically inject their export styles (no more hardcoded style handling)
177
+ - **Smart Error Recovery** — Dynamically skips failing plugins during export instead of hard-coded exclusions
178
+ - **A4 PDF Output** — Proper pagination with 15mm margins, background color preservation, clean output without UI elements
179
+ - **HTML Export** — Standalone HTML with embedded styles, KaTeX CDN for math, inline SVG for Mermaid diagrams, zero-dependency sharing
180
+
135
181
  - **Slide export** — Single HTML file (images Base64-inlined) or folder format (with video resources)
136
182
  - **Equation / Diagram PNG export** — Right-click to export as high-definition PNG images (2x scaling)
137
183
 
184
+ > 💡 **Mobile Export**: On Android/iOS, exported files trigger system share panel for direct sending to WeChat, email, etc.
185
+
138
186
  ### 🎨 Themes & Cross-Platform (Inherited from Original)
139
187
 
140
188
  - **4 built-in themes** + [downloadable themes](themes/) + custom CSS import
@@ -628,12 +676,40 @@ Downloadable external themes (located in [`themes/`](themes/) directory):
628
676
  | [elegant.css](themes/elegant.css) | Warm serif with terracotta accents, LXGW WenKai font |
629
677
  | [guizang.css](themes/guizang.css) | Ancient Guizang style, ochre accents, ink-black code blocks |
630
678
  | [forest-ink.css](themes/forest-ink.css) | 🌲 Forest Ink, warm paper base + forest green ink text + forest green accent |
631
- | [academic-paper.css](themes/academic-paper.css) | 📄 **Academic Paper (Enhanced)** — GB/T 7713 compliant, SimHei headings + SimSun body text, three-line tables, print-optimized Mermaid diagrams, footnotes & references styling. See [`academic-demo.md`](docs/academic-demo.md) for a complete example |
679
+ | [academic-paper.css](themes/academic-paper.css) | 📄 **Academic Paper** — GB/T 7713 compliant, SimHei headings + SimSun body text, three-line tables, print-optimized Mermaid diagrams (10.5pt font). See [`academic-demo.md`](docs/academic-demo.md) for a complete example |
680
+ | [academic-paper-pt.css](themes/academic-paper-pt.css) | 📄 **Academic Paper (PT units)** — Same GB/T 7713 design as academic-paper.css but using pt units for specific print scenarios |
632
681
  | [pixso-design.css](themes/pixso-design.css) | 🎨 Pixso Design, modern design system style |
633
- | [swiss-design.css](themes/swiss-design.css) | 🇨🇭 **Swiss Design (International Typographic Style)** — Pure black-white-red color system, geometric sans-serif fonts (Helvetica/Inter), grid-based layout with generous whitespace, form follows function. Minimalist and restrained aesthetic inspired by Swiss International Typographic Style |
682
+ | [swiss-design.css](themes/swiss-design.css) | 🇨🇭 **Swiss Design (International Typographic Style)** — Pure black-white-red color system, geometric sans-serif fonts (Helvetica/Inter), grid-based layout with generous whitespace, form follows function. Complete Mermaid diagram integration with monochrome + accent red styling |
683
+ | [template.css](themes/template.css) | 📝 **Standardized Template** — Reference implementation following v3.0 paradigm. Includes complete design tokens, editor styles, code blocks, blockquotes, tables, Mermaid variables, and print styles. Ready-to-use template for creating custom themes |
684
+
685
+ > ⚠️ **Theme Migration Notice**
686
+ >
687
+ > Starting from v1.5.1, **theme updates and maintenance have been migrated to the dedicated repository**:
688
+ >
689
+ > 🔗 **[https://github.com/byteuser1977/ColaMD-themes](https://github.com/byteuser1977/ColaMD-themes)**
690
+ >
691
+ > Future theme enhancements, bug fixes, and new theme submissions will be handled in the ColaMD-themes repository. This allows for:
692
+ > - Faster iteration and release cycles for theme-specific changes
693
+ > - Community contributions and theme submissions
694
+ > - Independent versioning from the core ColaMD application
695
+ > - Focused issue tracking for theme-related problems
696
+ >
697
+ > The themes included in this release will remain available for backward compatibility, but we recommend checking the dedicated repository for the latest versions and new themes.
634
698
 
635
699
  Custom theme support: Place CSS files in `~/.colamd/themes/` directory, then import via **Theme > Import Theme**. Imported themes persist across sessions.
636
700
 
701
+ ### Theme Development
702
+
703
+ For developers who want to create custom themes, refer to:
704
+
705
+ - **Theme Paradigm Document**: [`docs/theme-paradigm.md`](docs/theme-paradigm.md) — Complete CSS theme development specification (v3.2)
706
+ - Design principles: variable-driven, modular, semantic naming, AI-agent derivable
707
+ - 30+ verifiable rules (MUST / MUST NOT / SHOULD) including WCAG contrast formulas
708
+ - Print fidelity requirements: variable re-declaration, required element coverage (12 categories)
709
+ - px unit unification standard: prohibits pt/rem mixing for consistent PDF export
710
+ - **Theme Template**: [`themes/template.css`](themes/template.css) — Copy this file as a starting point for your custom theme
711
+ - **Mermaid Variable Reference**: See [`themes/README.md`](themes/README.md) for complete Mermaid CSS variable documentation
712
+
637
713
  ---
638
714
 
639
715
  ## Technical Architecture
package/README_CN.md CHANGED
@@ -8,9 +8,48 @@
8
8
 
9
9
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
10
10
  [![GitHub release](https://img.shields.io/github/release/marswaveai/colamd.svg)](https://github.com/marswaveai/colamd/releases)
11
+ [![Version: 1.5.1](https://img.shields.io/badge/Version-1.5.1-blue.svg)](https://github.com/byteuser1977/ColaMD-extend/releases/tag/v1.5.1)
11
12
 
12
13
  **本扩展版仓库**: [git@github.com:byteuser1977/ColaMD-extend.git](https://github.com/byteuser1977/ColaMD-extend)
13
14
 
15
+ ## 🎉 v1.5.1 正式版发布亮点(2026-05-23)
16
+
17
+ ### ✨ 新功能特性
18
+
19
+ #### 🎨 增强主题系统
20
+ - **学术论文主题** — 符合 GB/T 7713 国标规范,含三线表、宋体/黑体排版、打印优化的 Mermaid 图表
21
+ - **瑞士国际主义风格主题** 🇨🇭 — 黑白红三色体系、几何无衬线字体、网格化排版
22
+ - **Pixso 设计规范主题** — 现代设计系统风格
23
+ - **森林墨水主题** — 宣纸暖白底色、森林绿强调色
24
+ - **标准化模板** — 遵循 v3.0 范式的参考实现,便于快速创建自定义主题
25
+ - **主题开发框架** — 完整的 CSS 主题开发规范 (v3.2),包含 30+ 条可验证规则、WCAG 对比度公式和打印保真指南
26
+
27
+ #### 📱 移动端平台支持
28
+ - **Android (.apk)** — Capacitor 6 集成,原生文件选择器、IME 输入法优化、PDF 导出
29
+ - **iOS (.ipa)** — 完整 iOS 支持,基于 Capacitor 6
30
+ - **双平台桥接** — 运行时自动检测 Electron / Capacitor API
31
+ - **移动端适配样式** — 优化的触控界面和响应式设计
32
+
33
+ #### 🔧 发布后改进
34
+ - **重构 PDF 导出流程** — 自动提取当前主题样式、支持自定义打印样式、插件注入样式
35
+ - **统一插件样式管理** — 数学/Mermaid 插件动态配置(剪贴板、导出、渲染样式)
36
+ - **增强错误恢复机制** — 动态跳过出错插件,替代硬编码排除逻辑
37
+ - **自定义主题导出修复** — 解决 Chromium CSSOM 序列化问题
38
+ - **渲染输出优化** — 改进 HTML 结构以提升兼容性
39
+
40
+ ### 🐛 关键修复
41
+ - 修复全项目 15 处 TypeScript 类型错误
42
+ - 修复 Mermaid 文字偏移和边框问题(elegant + academic-paper 主题)
43
+ - 修复 Android 平台中文输入法问题
44
+ - 修复 Android 平台 Intent 文件打开和 PDF 导出
45
+ - 修复移动端媒体查询缺失 screen 类型
46
+ - 修复主题打印保真(@media print 样式镜像)
47
+ - 解耦插件系统,减少 main.ts 对具体插件的依赖
48
+
49
+ > ⚠️ **主题迁移说明**:从 v1.5.1 开始,主题更新已迁移至 [ColaMD-themes](https://github.com/byteuser1977/ColaMD-themes) 仓库,以实现更快速的迭代和社区贡献。
50
+
51
+ ---
52
+
14
53
  [功能特性](#功能特性) | [显示插件](#显示插件系统) | [Plug 菜单](#plug-菜单--插件渲染控制) | [快速开始](#快速开始) | [移动端构建](#移动端构建--capacitor-6) | [主题系统](#主题系统) | [技术架构](#技术架构) | [English](README.md)
15
54
 
16
55
  ***
@@ -140,7 +179,15 @@ page: YOUR NAME
140
179
 
141
180
  ### 📤 导出能力
142
181
 
143
- ColaMD 提供多种导出方式,满足不同场景需求:
182
+ ColaMD 提供多种导出方式,满足不同场景需求(v1.5.1 增强):
183
+
184
+ #### PDF / HTML 导出(v1.5.1 重构)
185
+ - **自动主题样式提取** — 自动提取并注入当前主题样式到导出文档中
186
+ - **自定义打印样式支持** — 支持传入自定义打印 CSS 以满足高级需求
187
+ - **插件注入样式** — 数学和 Mermaid 插件动态注入导出样式(不再使用硬编码样式处理)
188
+ - **智能错误恢复** — 导出时动态跳过出错插件,替代硬编码排除逻辑
189
+ - **A4 分页输出** — 15mm 边距规范分页,背景色保留,无 UI 元素的干净输出
190
+ - **HTML 导出** — 独立 HTML 文件,内嵌样式,KaTeX CDN 渲染数学公式,Mermaid SVG 内联图表,零依赖分享
144
191
 
145
192
  #### 导出为 HTML
146
193
 
@@ -688,12 +735,40 @@ ColaMD 内置 **4 个主题**,所有显示插件均会跟随主题自动适配
688
735
  | [elegant.css](themes/elegant.css) | 典雅暖调,朱砂红强调色、霞鹜文楷衬线体 |
689
736
  | [guizang.css](themes/guizang.css) | 归藏古风,赭石强调色、松烟墨代码块 |
690
737
  | [forest-ink.css](themes/forest-ink.css) | 🌲 森林墨,宣纸暖白底 + 松烟墨绿文字 + 森林绿强调色 |
691
- | [academic-paper.css](themes/academic-paper.css) | 📄 **学术论文(增强版)** — 符合 GB/T 7713 规范,黑体标题 + 宋体正文,三线表格式,打印优化的 Mermaid 图表,脚注与参考文献样式。完整示例见 [`academic-demo.md`](docs/academic-demo.md) |
738
+ | [academic-paper.css](themes/academic-paper.css) | 📄 **学术论文** — 符合 GB/T 7713 规范,黑体标题 + 宋体正文,三线表格式,打印优化的 Mermaid 图表(10.5pt 字号)。完整示例见 [`academic-demo.md`](docs/academic-demo.md) |
739
+ | [academic-paper-pt.css](themes/academic-paper-pt.css) | 📄 **学术论文(PT 单位版)** — 与 academic-paper.css 相同的 GB/T 7713 规范设计,但使用 pt 单位以适配特定打印场景需求 |
692
740
  | [pixso-design.css](themes/pixso-design.css) | 🎨 Pixso 设计,现代设计系统风格 |
693
- | [swiss-design.css](themes/swiss-design.css) | 🇨🇭 **瑞士国际主义平面设计风格** — 纯粹的黑白红三色体系,几何无衬线字体(Helvetica/Inter),网格化排版与大量留白,形式服从功能。极简克制的审美,灵感源自 Swiss International Typographic Style |
741
+ | [swiss-design.css](themes/swiss-design.css) | 🇨🇭 **瑞士国际主义平面设计风格** — 纯粹的黑白红三色体系,几何无衬线字体(Helvetica/Inter),网格化排版与大量留白,形式服从功能。完整的 Mermaid 图表集成(单色调 + 强调红) |
742
+ | [template.css](themes/template.css) | 📝 **标准化模板** — 遵循 v3.0 范式的参考实现,包含完整的设计令牌、编辑器样式、代码块、引用块、表格、Mermaid 变量和打印样式。可作为创建自定义主题的起点 |
743
+
744
+ > ⚠️ **主题迁移说明**
745
+ >
746
+ > 从 v1.5.1 开始,**主题更新和维护已迁移至专用仓库**:
747
+ >
748
+ > 🔗 **[https://github.com/byteuser1977/ColaMD-themes](https://github.com/byteuser1977/ColaMD-themes)**
749
+ >
750
+ > 未来的主题增强、错误修复和新主题提交将在 ColaMD-themes 仓库中进行。这样做的好处包括:
751
+ > - 更快的主题特定变更迭代和发布周期
752
+ > - 社区贡献和主题提交
753
+ > - 与核心 ColaMD 应用独立的版本控制
754
+ > - 专注的主题问题追踪
755
+ >
756
+ > 本版本中包含的主题将保持可用以确保向后兼容性,但我们建议查看专用仓库以获取最新版本和新主题。
694
757
 
695
758
  自定义主题支持:将 CSS 文件放入 `~/.colamd/themes/` 目录,通过 **Theme > Import Theme** 导入。导入的主题会持久化保存,重启后仍然可用。
696
759
 
760
+ ### 主题开发
761
+
762
+ 对于希望创建自定义主题的开发者,请参考:
763
+
764
+ - **主题范式文档**:[`docs/theme-paradigm.md`](docs/theme-paradigm.md) — 完整的 CSS 主题开发规范 (v3.2)
765
+ - 设计原则:变量驱动、模块化、语义命名、AI Agent 可推导
766
+ - 30+ 条可验证规则(MUST / MUST NOT / SHOULD),包含 WCAG 对比度公式
767
+ - 打印保真要求:变量重声明、必覆盖元素清单(12 类)
768
+ - px 单位统一规范:禁止 pt/rem 混用以确保 PDF 导出字号一致
769
+ - **主题模板**:[`themes/template.css`](themes/template.css) — 复制此文件作为自定义主题的起点
770
+ - **Mermaid 变量参考**:参见 [`themes/README.md`](themes/README.md) 获取完整的 Mermaid CSS 变量文档
771
+
697
772
  ---
698
773
 
699
774
  ## 技术架构
@@ -5,6 +5,15 @@ const promises = require("fs/promises");
5
5
  const fs = require("fs");
6
6
  const http = require("http");
7
7
  const themesDir = path.join(electron.app.getPath("home"), ".colamd", "themes");
8
+ const BASE_PRINT_CSS = [
9
+ "html, body { height:auto !important; overflow:visible !important; -webkit-print-color-adjust:exact !important; print-color-adjust:exact !important; }",
10
+ "#titlebar, #slides-btn, #agent-dot { display:none !important; }",
11
+ "#editor { height:auto !important; overflow:visible !important; }",
12
+ "#editor .ProseMirror { min-height:auto !important; }",
13
+ ".mermaid-error, .mermaid-loading { display:none !important; }",
14
+ "svg .error-icon, svg .error-text { display:none !important; }",
15
+ ".math-inline-raw, .math-block-raw, textarea.mermaid-source { display:none !important; }"
16
+ ].join("\n");
8
17
  function ensureThemesDir() {
9
18
  if (!fs.existsSync(themesDir)) {
10
19
  promises.mkdir(themesDir, { recursive: true }).catch(() => {
@@ -316,7 +325,7 @@ electron.ipcMain.handle("save-export-file", async (event, dataUrl, defaultName)
316
325
  return false;
317
326
  }
318
327
  });
319
- electron.ipcMain.handle("export-pdf", async (event) => {
328
+ electron.ipcMain.handle("export-pdf", async (event, printCSS) => {
320
329
  const win = getWinFromEvent(event);
321
330
  if (!win) return false;
322
331
  const defaultName = (suggestFileName(win) || "colamd-print") + ".pdf";
@@ -326,9 +335,8 @@ electron.ipcMain.handle("export-pdf", async (event) => {
326
335
  });
327
336
  if (result.canceled || !result.filePath) return false;
328
337
  try {
329
- const cssKey = await win.webContents.insertCSS(
330
- "html, body { height: auto !important; overflow: visible !important; } #titlebar { display: none !important; } #editor { height: auto !important; overflow: visible !important; } #editor .ProseMirror { min-height: auto !important; } .mermaid-error { display: none !important; } .mermaid-loading { display: none !important; } svg .error-icon, svg .error-text { display: none !important; } .math-inline-raw, .math-block-raw, textarea.mermaid-source { display: none !important; }"
331
- );
338
+ const cssKey = await win.webContents.insertCSS(BASE_PRINT_CSS + "\n" + (printCSS || ""));
339
+ await new Promise((r) => setTimeout(r, 200));
332
340
  const pdfData = await Promise.race([
333
341
  win.webContents.printToPDF({
334
342
  printBackground: true,
@@ -339,7 +347,8 @@ electron.ipcMain.handle("export-pdf", async (event) => {
339
347
  await win.webContents.removeInsertedCSS(cssKey);
340
348
  await promises.writeFile(result.filePath, pdfData);
341
349
  return true;
342
- } catch {
350
+ } catch (e) {
351
+ console.error("[export-pdf] PDF export failed:", e);
343
352
  return false;
344
353
  }
345
354
  });
@@ -5,7 +5,7 @@ electron.contextBridge.exposeInMainWorld("electronAPI", {
5
5
  openFilePath: (path) => electron.ipcRenderer.invoke("open-file-path", path),
6
6
  saveFile: (content) => electron.ipcRenderer.invoke("save-file", content),
7
7
  saveFileAs: (content) => electron.ipcRenderer.invoke("save-file-as", content),
8
- exportPDF: () => electron.ipcRenderer.invoke("export-pdf"),
8
+ exportPDF: (printCSS) => electron.ipcRenderer.invoke("export-pdf", printCSS),
9
9
  exportHTML: (html) => electron.ipcRenderer.invoke("export-html", html),
10
10
  exportSlides: (content) => electron.ipcRenderer.invoke("export-slides", content),
11
11
  newSlides: () => electron.ipcRenderer.invoke("new-slides"),
@@ -1,4 +1,4 @@
1
- import { a0 as withPath, a1 as halfPi, a2 as epsilon, a3 as tau, a4 as cos, a5 as sin, a6 as min, a7 as abs, a8 as pi, a9 as sqrt, aa as atan2, ab as constant, ac as asin, ad as acos, ae as max } from "./index-DAlXyxzt.js";
1
+ import { a0 as withPath, a1 as halfPi, a2 as epsilon, a3 as tau, a4 as cos, a5 as sin, a6 as min, a7 as abs, a8 as pi, a9 as sqrt, aa as atan2, ab as constant, ac as asin, ad as acos, ae as max } from "./index-BX6JHKv6.js";
2
2
  function arcInnerRadius(d) {
3
3
  return d.innerRadius;
4
4
  }
@@ -1,5 +1,5 @@
1
- import { b4 as getDefaultExportFromCjs, _ as __name, I as selectSvgElement, Y as setupGraphViewbox, l as log, b as setAccTitle, a as getAccTitle, p as setDiagramTitle, q as getDiagramTitle, g as getAccDescription, s as setAccDescription, z as clear, F as cleanAndMerge, D as getConfig, G as defaultConfig_default, c as getConfig2, aO as createText, b5 as getIconSVG, i as sanitizeText, d as select, x as getEdgeId, b6 as registerIconPacks, b7 as unknownIcon } from "./index-DAlXyxzt.js";
2
- import { p as populateCommonDb } from "./chunk-4BX2VUAB-BhRxDTNn.js";
1
+ import { b4 as getDefaultExportFromCjs, _ as __name, I as selectSvgElement, Y as setupGraphViewbox, l as log, b as setAccTitle, a as getAccTitle, p as setDiagramTitle, q as getDiagramTitle, g as getAccDescription, s as setAccDescription, z as clear, F as cleanAndMerge, D as getConfig, G as defaultConfig_default, c as getConfig2, aO as createText, b5 as getIconSVG, i as sanitizeText, d as select, x as getEdgeId, b6 as registerIconPacks, b7 as unknownIcon } from "./index-BX6JHKv6.js";
2
+ import { p as populateCommonDb } from "./chunk-4BX2VUAB-JTZ-VKNX.js";
3
3
  import { p as parse } from "./wardley-L42UT6IY-b-_GPpqL.js";
4
4
  import { c as cytoscape$1 } from "./cytoscape.esm-CpHeHM5e.js";
5
5
  import "./preload-helper-tXtZnHb0.js";