@bytechain.cn/colamd 1.5.0 → 1.5.1-beta.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 (193) hide show
  1. package/.trae/specs/optimize-theme-loading/checklist.md +20 -0
  2. package/.trae/specs/optimize-theme-loading/spec.md +103 -0
  3. package/.trae/specs/optimize-theme-loading/tasks.md +40 -0
  4. package/CHANGELOG.md +323 -0
  5. package/CLAUDE.md +56 -0
  6. package/README.md +422 -26
  7. package/README_CN.md +480 -28
  8. package/android/app/build/.npmkeep +0 -0
  9. package/android/app/build.gradle +76 -0
  10. package/android/app/capacitor.build.gradle +24 -0
  11. package/android/app/proguard-rules.pro +21 -0
  12. package/android/app/release.keystore +0 -0
  13. package/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java +26 -0
  14. package/android/app/src/main/AndroidManifest.xml +64 -0
  15. package/android/app/src/main/java/cn/bytechain/colamd/MainActivity.java +180 -0
  16. package/android/app/src/main/res/drawable/ic_launcher_background.xml +170 -0
  17. package/android/app/src/main/res/drawable/splash.png +0 -0
  18. package/android/app/src/main/res/drawable-land-hdpi/splash.png +0 -0
  19. package/android/app/src/main/res/drawable-land-mdpi/splash.png +0 -0
  20. package/android/app/src/main/res/drawable-land-xhdpi/splash.png +0 -0
  21. package/android/app/src/main/res/drawable-land-xxhdpi/splash.png +0 -0
  22. package/android/app/src/main/res/drawable-land-xxxhdpi/splash.png +0 -0
  23. package/android/app/src/main/res/drawable-port-hdpi/splash.png +0 -0
  24. package/android/app/src/main/res/drawable-port-mdpi/splash.png +0 -0
  25. package/android/app/src/main/res/drawable-port-xhdpi/splash.png +0 -0
  26. package/android/app/src/main/res/drawable-port-xxhdpi/splash.png +0 -0
  27. package/android/app/src/main/res/drawable-port-xxxhdpi/splash.png +0 -0
  28. package/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +34 -0
  29. package/android/app/src/main/res/layout/activity_main.xml +12 -0
  30. package/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
  31. package/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
  32. package/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  33. package/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png +0 -0
  34. package/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  35. package/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  36. package/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png +0 -0
  37. package/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  38. package/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  39. package/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png +0 -0
  40. package/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  41. package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  42. package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png +0 -0
  43. package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  44. package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  45. package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png +0 -0
  46. package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  47. package/android/app/src/main/res/values/ic_launcher_background.xml +4 -0
  48. package/android/app/src/main/res/values/strings.xml +7 -0
  49. package/android/app/src/main/res/values/styles.xml +22 -0
  50. package/android/app/src/main/res/xml/file_paths.xml +5 -0
  51. package/android/app/src/main/res/xml/network_security_config.xml +8 -0
  52. package/android/app/src/test/java/com/getcapacitor/myapp/ExampleUnitTest.java +18 -0
  53. package/android/build.gradle +29 -0
  54. package/android/capacitor.settings.gradle +21 -0
  55. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  56. package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  57. package/android/gradle.properties +22 -0
  58. package/android/gradlew +248 -0
  59. package/android/gradlew.bat +92 -0
  60. package/android/settings.gradle +5 -0
  61. package/android/variables.gradle +16 -0
  62. package/bytechain.cn-colamd-1.5.1-beta.2.tgz +0 -0
  63. package/capacitor.config.js +29 -0
  64. package/capacitor.config.ts +30 -0
  65. package/demo.md +191 -484
  66. package/dist/main/index.js +77 -46
  67. package/dist/renderer/assets/{arc-tTbbM8LO.js → arc-CPdeInCG.js} +1 -1
  68. package/dist/renderer/assets/{architectureDiagram-3BPJPVTR-CEgYow6c.js → architectureDiagram-3BPJPVTR-BAbnaR9G.js} +4 -3
  69. package/dist/renderer/assets/{blockDiagram-GPEHLZMM-LHyVtPwW.js → blockDiagram-GPEHLZMM-CYSWjnJg.js} +5 -4
  70. package/dist/renderer/assets/{c4Diagram-AAUBKEIU-C1P1eJrf.js → c4Diagram-AAUBKEIU-Rb1tstnr.js} +3 -2
  71. package/dist/renderer/assets/{channel-upve91Tq.js → channel-DpG2A6fE.js} +1 -1
  72. package/dist/renderer/assets/{chunk-2J33WTMH-lag2vhq9.js → chunk-2J33WTMH-DFc0Jxy_.js} +1 -1
  73. package/dist/renderer/assets/{chunk-4BX2VUAB-BXJ8Ggh-.js → chunk-4BX2VUAB-BhRxDTNn.js} +1 -1
  74. package/dist/renderer/assets/{chunk-55IACEB6-CiBpxRa1.js → chunk-55IACEB6-DEgMVBk8.js} +1 -1
  75. package/dist/renderer/assets/{chunk-727SXJPM-ODeKQFXC.js → chunk-727SXJPM-bjBIfiz8.js} +5 -5
  76. package/dist/renderer/assets/{chunk-AQP2D5EJ-BK7xJolB.js → chunk-AQP2D5EJ-DwQMzTzD.js} +3 -3
  77. package/dist/renderer/assets/{chunk-FMBD7UC4-BxpCZPtz.js → chunk-FMBD7UC4-CkphwJzs.js} +1 -1
  78. package/dist/renderer/assets/{chunk-ND2GUHAM-CqqaU9Ue.js → chunk-ND2GUHAM-oU09z4y4.js} +1 -1
  79. package/dist/renderer/assets/{chunk-QZHKN3VN-Biq_K124.js → chunk-QZHKN3VN-rCbVuPBn.js} +1 -1
  80. package/dist/renderer/assets/{classDiagram-v2-Q7XG4LA2-Cq95X99o.js → classDiagram-4FO5ZUOK-DGS2faoM.js} +7 -6
  81. package/dist/renderer/assets/{classDiagram-4FO5ZUOK-Cq95X99o.js → classDiagram-v2-Q7XG4LA2-DGS2faoM.js} +7 -6
  82. package/dist/renderer/assets/{cose-bilkent-S5V4N54A-XasiD0bu.js → cose-bilkent-S5V4N54A-iqY6-EwA.js} +2 -1
  83. package/dist/renderer/assets/{dagre-BM42HDAG-Nq84Gfx4.js → dagre-BM42HDAG-5t3X5sDa.js} +4 -3
  84. package/dist/renderer/assets/{diagram-2AECGRRQ-DwuB1GWt.js → diagram-2AECGRRQ-DzHiYDPh.js} +4 -3
  85. package/dist/renderer/assets/{diagram-5GNKFQAL-C2tgeI1h.js → diagram-5GNKFQAL-BiNv6Keq.js} +5 -4
  86. package/dist/renderer/assets/{diagram-KO2AKTUF-D5KzjNBc.js → diagram-KO2AKTUF-ClzeDG6f.js} +4 -3
  87. package/dist/renderer/assets/{diagram-LMA3HP47-C12xHS1c.js → diagram-LMA3HP47-CGkw7wII.js} +4 -3
  88. package/dist/renderer/assets/{diagram-OG6HWLK6-CnxI9oEa.js → diagram-OG6HWLK6-Dl-Hyk1_.js} +5 -4
  89. package/dist/renderer/assets/{erDiagram-TEJ5UH35-D_uPaKwn.js → erDiagram-TEJ5UH35-BxUN79Qb.js} +5 -4
  90. package/dist/renderer/assets/{flowDiagram-I6XJVG4X-B6q_1-tE.js → flowDiagram-I6XJVG4X-CzFk-KNI.js} +7 -6
  91. package/dist/renderer/assets/{ganttDiagram-6RSMTGT7-CFo7ifF9.js → ganttDiagram-6RSMTGT7-C2xl6Igx.js} +3 -2
  92. package/dist/renderer/assets/{gitGraphDiagram-PVQCEYII-WSexHTnq.js → gitGraphDiagram-PVQCEYII-_fn7XCa7.js} +5 -4
  93. package/dist/renderer/assets/{graph-DyX_9f6d.js → graph-CDoHYrHm.js} +1 -1
  94. package/dist/renderer/assets/index-B4uDgADr.js +530 -0
  95. package/dist/renderer/assets/index-CBcVpA3d.js +30 -0
  96. package/dist/renderer/assets/index-CGj1spkU.js +27 -0
  97. package/dist/renderer/assets/{index-dyHEFYvY.css → index-CeFpoCKV.css} +443 -400
  98. package/dist/renderer/assets/index-D4CPFkph.js +9 -0
  99. package/dist/renderer/assets/{index-DW7LS8C1.js → index-DAlXyxzt.js} +1183 -346
  100. package/dist/renderer/assets/index-DxOzbfR-.js +110 -0
  101. package/dist/renderer/assets/index-Y89U1ptl.js +9 -0
  102. package/dist/renderer/assets/{infoDiagram-5YYISTIA-DaeJdLRq.js → infoDiagram-5YYISTIA-DL6XIxLz.js} +3 -2
  103. package/dist/renderer/assets/{ishikawaDiagram-YF4QCWOH-DDCZc35f.js → ishikawaDiagram-YF4QCWOH-BUZLjRo-.js} +2 -1
  104. package/dist/renderer/assets/{journeyDiagram-JHISSGLW-BEdmpAgl.js → journeyDiagram-JHISSGLW-C4rH_mQM.js} +5 -4
  105. package/dist/renderer/assets/{kanban-definition-UN3LZRKU-BEFtQcFb.js → kanban-definition-UN3LZRKU-DRbrBcWV.js} +3 -2
  106. package/dist/renderer/assets/{layout-CAJgQHdw.js → layout-DZl4n4qu.js} +2 -2
  107. package/dist/renderer/assets/{linear-B2ggJ8Am.js → linear-B0Krxg21.js} +1 -1
  108. package/dist/renderer/assets/{mindmap-definition-RKZ34NQL-DSxVgHB5.js → mindmap-definition-RKZ34NQL-DdmPsWrn.js} +4 -3
  109. package/dist/renderer/assets/{pieDiagram-4H26LBE5-CwYoJBuL.js → pieDiagram-4H26LBE5-BPZLqwG0.js} +5 -4
  110. package/dist/renderer/assets/preload-helper-tXtZnHb0.js +88 -0
  111. package/dist/renderer/assets/{quadrantDiagram-W4KKPZXB-CST9Fvg9.js → quadrantDiagram-W4KKPZXB-Dr-oWRk9.js} +3 -2
  112. package/dist/renderer/assets/{requirementDiagram-4Y6WPE33-DtrH52jS.js → requirementDiagram-4Y6WPE33-B6QZd0lo.js} +4 -3
  113. package/dist/renderer/assets/{sankeyDiagram-5OEKKPKP-ca1tPzJ_.js → sankeyDiagram-5OEKKPKP-Cyl9ojEt.js} +2 -1
  114. package/dist/renderer/assets/{sequenceDiagram-3UESZ5HK-Dfp1EJZ7.js → sequenceDiagram-3UESZ5HK-D48Yr9T6.js} +4 -3
  115. package/dist/renderer/assets/{stateDiagram-AJRCARHV-Bha2QoNB.js → stateDiagram-AJRCARHV-qyb8ETsa.js} +7 -6
  116. package/dist/renderer/assets/{stateDiagram-v2-BHNVJYJU-DWgFUYu1.js → stateDiagram-v2-BHNVJYJU-DmDOyyrJ.js} +5 -4
  117. package/dist/renderer/assets/{timeline-definition-PNZ67QCA-C3h_-OTj.js → timeline-definition-PNZ67QCA-C-KQxTi1.js} +3 -2
  118. package/dist/renderer/assets/{vennDiagram-CIIHVFJN-DFzjSrZi.js → vennDiagram-CIIHVFJN-BdaZlnH-.js} +2 -1
  119. package/dist/renderer/assets/{wardley-L42UT6IY-Cx-VbqoS.js → wardley-L42UT6IY-b-_GPpqL.js} +1 -1
  120. package/dist/renderer/assets/{wardleyDiagram-YWT4CUSO-S2D9XqX6.js → wardleyDiagram-YWT4CUSO-B2hBE-EE.js} +4 -3
  121. package/dist/renderer/assets/web-BKE0SH0E.js +36 -0
  122. package/dist/renderer/assets/web-CBsFp24u.js +564 -0
  123. package/dist/renderer/assets/web-Dc8YgoHP.js +24 -0
  124. package/dist/renderer/assets/web-TfDzToU7.js +58 -0
  125. package/dist/renderer/assets/{xychartDiagram-2RQKCTM6-Cfxigbts.js → xychartDiagram-2RQKCTM6-CSvswDTY.js} +3 -2
  126. package/dist/renderer/index.html +62 -3
  127. package/docs/academic-demo.md +566 -0
  128. package/docs/demo.html +748 -0
  129. package/docs/demo.md +546 -0
  130. package/docs/demo.pdf +0 -0
  131. package/docs/theme-paradigm.md +658 -0
  132. package/electron-builder.yml +7 -0
  133. package/electron.vite.config.js +31 -0
  134. package/electron.vite.config.ts +1 -1
  135. package/ios/App/App/AppDelegate.swift +49 -0
  136. package/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png +0 -0
  137. package/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json +14 -0
  138. package/ios/App/App/Assets.xcassets/Contents.json +6 -0
  139. package/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json +23 -0
  140. package/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png +0 -0
  141. package/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png +0 -0
  142. package/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png +0 -0
  143. package/ios/App/App/Base.lproj/LaunchScreen.storyboard +32 -0
  144. package/ios/App/App/Base.lproj/Main.storyboard +19 -0
  145. package/ios/App/App/Info.plist +49 -0
  146. package/ios/App/App.xcodeproj/project.pbxproj +408 -0
  147. package/ios/App/App.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  148. package/ios/App/Podfile +28 -0
  149. package/package.json +23 -3
  150. package/resources/templates/slides/template-forest-ink.html +540 -0
  151. package/scripts/generate-icons.js +102 -0
  152. package/src/main/index.ts +87 -63
  153. package/src/preload/index.d.ts +51 -0
  154. package/src/preload/index.js +70 -0
  155. package/src/renderer/capacitor-api.ts +713 -0
  156. package/src/renderer/editor/editor.ts +87 -4
  157. package/src/renderer/editor/plugins/index.ts +24 -32
  158. package/src/renderer/editor/plugins/math-plugin.ts +1 -1
  159. package/src/renderer/editor/plugins/mermaid-plugin-custom.css +13 -398
  160. package/src/renderer/editor/plugins/mermaid-plugin.ts +62 -71
  161. package/src/renderer/editor/plugins/themes/base/dark.css +23 -0
  162. package/src/renderer/editor/plugins/themes/base/elegant.css +32 -0
  163. package/src/renderer/editor/plugins/themes/base/light.css +20 -0
  164. package/src/renderer/editor/plugins/themes/base/newsprint.css +27 -0
  165. package/src/renderer/editor/plugins/themes/components/mermaid/academic.css +43 -0
  166. package/src/renderer/editor/plugins/themes/components/mermaid/dark.css +20 -0
  167. package/src/renderer/editor/plugins/themes/components/mermaid/elegant.css +24 -0
  168. package/src/renderer/editor/plugins/themes/components/mermaid/light.css +21 -0
  169. package/src/renderer/editor/plugins/themes/components/mermaid/newsprint.css +26 -0
  170. package/src/renderer/editor/plugins/themes/components/mermaid/variables.css +592 -0
  171. package/src/renderer/editor/plugins/themes/foundation.css +143 -0
  172. package/src/renderer/editor/plugins/themes/theme-manager.ts +92 -0
  173. package/src/renderer/env.d.ts +4 -1
  174. package/src/renderer/index.html +59 -1
  175. package/src/renderer/main.ts +432 -57
  176. package/src/renderer/mobile.css +429 -0
  177. package/themes/README.md +3 -0
  178. package/themes/academic-paper.css +1321 -0
  179. package/themes/elegant.css +14 -7
  180. package/themes/forest-ink.css +664 -0
  181. package/themes/pixso-design.css +1261 -0
  182. package/themes/swiss-design.css +596 -0
  183. package/themes/template.css +498 -0
  184. package/tsconfig.main.json +1 -0
  185. package/tsconfig.main.tsbuildinfo +1 -0
  186. package/tsconfig.preload.json +1 -0
  187. package/tsconfig.preload.tsbuildinfo +1 -0
  188. package/tsconfig.renderer.json +1 -0
  189. package/tsconfig.renderer.tsbuildinfo +1 -0
  190. package/tsconfig.tsbuildinfo +1 -0
  191. package/.trae/documents/fix-mermaid-colors-and-sankey.md +0 -50
  192. package/src/renderer/themes/theme-manager.ts +0 -40
  193. /package/src/renderer/{themes → editor/plugins/themes}/base.css +0 -0
@@ -0,0 +1,20 @@
1
+ # Checklist
2
+
3
+ - [x] themes 目录已从 `src/renderer/themes/` 迁移到 `src/renderer/editor/plugins/themes/`
4
+ - [x] main.ts 中 `./themes/theme-manager` import 路径已更新为 `./editor/plugins/themes/theme-manager`
5
+ - [x] main.ts 中 `./themes/base.css` import 路径已更新为 `./editor/plugins/themes/base.css`
6
+ - [x] `parseTemplateDirective()` 可正确解析 `/* @template: light */` 注释
7
+ - [x] `setCachedCustomTheme()` 在导入自定义主题时正确缓存 CSS 内容和模版引用
8
+ - [x] `customThemeCache` 维护已导入的自定义主题数据
9
+ - [x] `applyTheme('custom:name')` 从缓存恢复 CSS 并正确应用(含模版变量层叠)
10
+ - [x] 自定义 → 预制 → 自定义 切换后样式完全恢复,无残留污染
11
+ - [x] 应用重启后通过 `setCachedCustomTheme` + `applyTheme` 恢复已保存的自定义主题
12
+ - [x] mermaid-plugin-custom.css 已移除与 variables.css 重复的基础选择器(从432行精简至46行)
13
+ - [x] mermaid-plugin-custom.css 变量命名与 `--mermaid-node-stroke` 等 foundation.css 体系对齐
14
+ - [x] mermaid-plugin.ts 中 `getCustomMermaidThemeVariables()` 变量名对齐(8处)
15
+ - [x] mermaid-plugin.ts 中 `getCustomMermaidC4Config()` 变量名对齐(20处)
16
+ - [x] mermaid-plugin.ts 中 custom 的 dark mode 从 `--mermaid-dark-mode` CSS 变量读取
17
+ - [x] 导入引用模版的自定义主题,模版 class 与 theme-custom class 同时生效
18
+ - [x] 导入不引用模版的自定义主题,行为与当前一致(向后兼容)
19
+ - [x] 所有内建主题无需修改,功能不变
20
+ - [x] TypeScript 编译无本次修改引入的新错误
@@ -0,0 +1,103 @@
1
+ # 优化外部主题载入设定 Spec
2
+
3
+ ## Why
4
+ 当前外部导入主题存在两个问题:
5
+ 1. **复杂度高**:用户需要编写完整的 CSS 文件(包含大量选择器和变量定义),没有模版继承机制
6
+ 2. **Bug**:自定义主题 → 预制主题 → 自定义主题 的切换过程中,自定义 CSS 样式丢失,导致预制主题的样式残留污染
7
+
8
+ 项目已有完整的 CSS 变量抽象体系(`themes/foundation.css` + `themes/base/*.css` + `themes/components/mermaid/*.css`),外部主题应能通过引用基础模版 + 少量变量覆写的方式完成定义,大幅降低配置代码量。
9
+
10
+ ## What Changes
11
+ - 将 `src/renderer/themes/` 目录迁移到 `src/renderer/editor/plugins/themes/` 下
12
+ - `theme-manager.ts`:新增模版引用机制,支持解析 `/* @template: light */` 指令;新增自定义 CSS 持久化缓存,修复切回自定义主题时样式丢失的 Bug
13
+ - `mermaid-plugin-custom.css`:精简优化,利用 CSS 变量体系减少冗余选择器
14
+ - `mermaid-plugin.ts`:优化 custom 主题路径的变量读取逻辑,适配模版引用机制
15
+ - `main.ts`:更新 import 路径;修复 `applyThemeChange` 不传 customCSS 的 Bug
16
+
17
+ ## Impact
18
+ - Affected specs: 主题系统
19
+ - Affected code:
20
+ - `src/renderer/themes/` → `src/renderer/editor/plugins/themes/` (目录迁移)
21
+ - `src/renderer/themes/theme-manager.ts` → 新增模版引用 + CSS 缓存
22
+ - `src/renderer/editor/plugins/mermaid-plugin-custom.css` (精简)
23
+ - `src/renderer/editor/plugins/mermaid-plugin.ts` (优化 custom 主题路径)
24
+ - `src/renderer/main.ts` (import 路径 + Bug 修复)
25
+
26
+ ## ADDED Requirements
27
+
28
+ ### Requirement: 外部主题模版引用机制
29
+ The system SHALL 支持外部导入的 CSS 文件通过 `/* @template: <name> */` 注释声明所引用的基础模版。
30
+ 对于没有标注引用的以 light 模版作为引入基础。
31
+
32
+ 支持的模版名称:`light`、`dark`、`elegant`、`newsprint`。
33
+
34
+ 当外部主题声明了模版引用,系统应先加载模版的 CSS 变量(来自 `themes/base/<name>.css` 和 `themes/components/mermaid/<name>.css`),再将导入的 CSS 作为覆写层叠加。导入的 CSS 只需定义与模版有差异的变量。
35
+
36
+ 对现有已经定义的复杂定义的主题模版要做到向下兼容。
37
+
38
+ #### Scenario: 引用 light 模版
39
+ - **WHEN** 用户导入以下 CSS:
40
+ ```css
41
+ /* @template: light */
42
+ :root {
43
+ --color-link: #ff6600;
44
+ --color-accent: #ff6600;
45
+ --mermaid-node-stroke: #ff6600;
46
+ --mermaid-highlight: #ff6600;
47
+ }
48
+ ```
49
+ - **THEN** 系统先加载 `themes/base/light.css` 的变量,再叠加以上覆写
50
+ - **THEN** 主样式使用 light 模版的字体/颜色/间距,仅链接色和强调色被覆写
51
+ - **THEN** Mermaid 图表使用 light 模版的 mermaid 变量作为基础,节点边框色被覆写为 `#ff6600`
52
+
53
+ #### Scenario: 不声明模版引用
54
+ - **WHEN** 用户导入的 CSS 不包含 `/* @template: */` 注释
55
+ - **THEN** 行为与当前一致:仅注入自定义 CSS,其他变量使用 `:root` / `foundation.css` 默认值
56
+
57
+ ### Requirement: 自定义主题 CSS 持久化缓存
58
+ The system SHALL 在 `theme-manager.ts` 中缓存最后导入的自定义 CSS 内容和模版引用信息,确保任何时候切换回自定义主题都能正确恢复样式。
59
+
60
+ #### Scenario: 自定义 → 预制 → 自定义 切换
61
+ - **WHEN** 用户先导入自定义主题,再切换到 dark 主题,再切换回自定义主题
62
+ - **THEN** 自定义主题的 CSS 样式完全恢复,不残留 dark 主题的样式
63
+ - **THEN** Mermaid 图表以自定义主题配色正确渲染
64
+
65
+ #### Scenario: 应用重启后恢复
66
+ - **WHEN** 应用重启后加载保存的自定义主题(localStorage 中存有 `custom:<name>`)
67
+ - **THEN** 系统通过 API 重新加载该主题的 CSS 文件并恢复样式
68
+ - **THEN** 模版引用信息随主题一起持久化恢复
69
+
70
+ ### Requirement: themes 目录迁移到 editor/plugins 下
71
+ The system SHALL 将 `src/renderer/themes/` 目录整体迁移到 `src/renderer/editor/plugins/themes/`,所有相关 import 路径同步更新。
72
+
73
+ #### Scenario: main.ts 引用路径
74
+ - **WHEN** main.ts 导入 theme-manager 和 base.css
75
+ - **THEN** import 路径从 `./themes/theme-manager` 更新为 `./editor/plugins/themes/theme-manager`
76
+ - **THEN** CSS import 路径从 `./themes/base.css` 更新为 `./editor/plugins/themes/base.css`
77
+
78
+ ## MODIFIED Requirements
79
+
80
+ ### Requirement: mermaid-plugin-custom.css 精简
81
+ **Before**: 包含大量与 `themes/components/mermaid/variables.css` 功能重叠的选择器(节点样式、连线样式、标签样式等),使用旧的变量命名(`--mermaid-node-border` 而非 `--mermaid-node-stroke`)。
82
+ **After**:
83
+ - 移除与 `variables.css` 重复的通用选择器(节点/连线/标签/聚类等基础样式)
84
+ - 仅保留 `custom` 主题特有的差异化样式(如 `person-man` 强制白色文字、`foreignObject` span 颜色等)
85
+ - 变量命名与 `foundation.css` 中的 `--mermaid-*` 体系对齐
86
+
87
+ ### Requirement: mermaid-plugin.ts custom 主题变量读取优化
88
+ **Before**: `getCustomMermaidThemeVariables()` 和 `getCustomMermaidC4Config()` 使用旧的变量命名(`--mermaid-node-border`、`--mermaid-line-color` 等),fallback 链混乱。
89
+ **After**:
90
+ - 变量名与 `foundation.css` 的 `--mermaid-*` 命名体系对齐
91
+ - fallback 逻辑清晰,优先读 `--mermaid-*` 专用变量,fallback 到通用 CSS 变量
92
+ - `getMermaidTheme()` 中 custom 主题的 dark mode 判断从 `--mermaid-dark-mode` CSS 变量读取
93
+
94
+ ### Requirement: theme-manager.ts applyTheme 函数
95
+ **Before**: `applyTheme(name, customCSS?)` 仅注入传入的 `customCSS`,不维护缓存;切回自定义主题时无 CSS 可注入。
96
+ **After**:
97
+ - 内部缓存自定义 CSS 内容和模版引用
98
+ - `applyTheme` 在检测到 `custom:` 前缀时自动应用缓存(含模版变量层叠)
99
+ - 导出 `setCachedCustomTheme(name, css)` 供外部在导入时调用
100
+ - 导出 `getCachedCustomTheme(name)` 支持查询已缓存的主题
101
+
102
+ ## REMOVED Requirements
103
+ 无。所有现有功能保持不变,仅做增强和修复。
@@ -0,0 +1,40 @@
1
+ # Tasks
2
+
3
+ - [x] Task 1: 迁移 themes 目录到 editor/plugins 下
4
+ - [x] 将 `src/renderer/themes/` 完整移动到 `src/renderer/editor/plugins/themes/`
5
+ - [x] 更新 `src/renderer/main.ts` 中的 import 路径:`./themes/theme-manager` → `./editor/plugins/themes/theme-manager`
6
+ - [x] 更新 `src/renderer/main.ts` 中的 CSS import:`./themes/base.css` → `./editor/plugins/themes/base.css`
7
+
8
+ - [x] Task 2: 重构 theme-manager.ts — 模版引用 + CSS 缓存 + Bug 修复
9
+ - [x] 新增 `parseTemplateDirective(css: string): string | null` 函数,解析 `/* @template: <name> */`
10
+ - [x] 新增自定义 CSS 缓存(`customThemeCache: Map<string, { css: string; template: string | null }>`)
11
+ - [x] 导出 `setCachedCustomTheme(name, css)` 用于导入时缓存
12
+ - [x] 导出 `getCachedCustomTheme(name)` 用于查询已缓存的主题
13
+ - [x] 修改 `applyTheme(name, customCSS?)`:当 `name` 以 `custom:` 开头时从缓存恢复 CSS,并根据模版引用叠加模版 class
14
+
15
+ - [x] Task 3: 优化 mermaid-plugin-custom.css — 精简与 variables.css 去重
16
+ - [x] 移除与 `themes/components/mermaid/variables.css` 重复的基础选择器(节点/连线/标签/聚类等)
17
+ - [x] 保留 custom 主题特有的差异化样式(person-man 强制白色、文字偏移等)
18
+ - [x] 文件从 432 行精简至 46 行
19
+
20
+ - [x] Task 4: 优化 mermaid-plugin.ts — custom 主题变量读取对齐
21
+ - [x] 更新 `getCustomMermaidThemeVariables()` 中的变量名(8处对齐)
22
+ - [x] 更新 `getCustomMermaidC4Config()` 中的变量名(20处对齐)
23
+ - [x] `getMermaidTheme()` 中 custom 的 dark mode 判断已从 `--mermaid-dark-mode` CSS 变量读取(无需修改,已正确实现)
24
+
25
+ - [x] Task 5: 更新 main.ts — import 路径 + 调用来适配新 API
26
+ - [x] 导入 `setCachedCustomTheme` 函数
27
+ - [x] 修改 `onMenuImportTheme` 回调:先 `setCachedCustomTheme` 再 `applyTheme`
28
+ - [x] 修改移动端菜单 `import-theme` 回调,同上
29
+ - [x] 修改应用重启恢复逻辑:先 `setCachedCustomTheme` 再 `applyTheme`
30
+
31
+ - [x] Task 6: 验证
32
+ - [x] TypeScript renderer 编译无本次修改引入的新错误
33
+ - [x] 14 项 checklist 全部通过
34
+
35
+ # Task Dependencies
36
+ - Task 2 依赖 Task 1(迁移后路径才正确)
37
+ - Task 3 依赖 Task 1(CSS 文件引用 themes 目录)
38
+ - Task 4 可与 Task 3 并行
39
+ - Task 5 依赖 Task 1 和 Task 2
40
+ - Task 6 依赖 Task 1-5 全部完成
package/CHANGELOG.md ADDED
@@ -0,0 +1,323 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.5.1-beta.2] - 2026-05-22
9
+
10
+ ### Fixed
11
+
12
+ #### TypeScript Type Errors
13
+ - Fixed 15 TypeScript type errors across the codebase:
14
+ - `capacitor-api.ts`: Fixed `string | null` type assignment error
15
+ - `editor.ts`: Fixed `remarkPluginsCtx` type mismatch and `rootEl` null check
16
+ - `math-plugin.ts`: Fixed `$NodeSchema` type compatibility with `$view` function
17
+ - `mermaid-plugin.ts`: Fixed Mermaid theme type and `$NodeSchema` type issues
18
+ - `main.ts`: Added Vite client types reference for `import.meta.glob`
19
+ - `main/index.ts`: Removed invalid `createServer` import from `fs` and `marginType` from `PrintToPDFOptions`
20
+
21
+ #### TypeScript Project Configuration
22
+ - Added `"composite": true` to all TypeScript project configurations for proper project references:
23
+ - `tsconfig.main.json`
24
+ - `tsconfig.preload.json`
25
+ - `tsconfig.renderer.json`
26
+
27
+ ### Changed
28
+
29
+ #### Mermaid Theme System Refactor
30
+ - **Restructured Mermaid styles to warm color palette**:
31
+ - Changed Mermaid color scheme to Guizang warm tones (cream background + brown tones)
32
+ - Adjusted font size to 10.5pt for academic printing compatibility
33
+ - Added Typora compatible selectors (`.md-diagram-panel`)
34
+ - Added mobile responsive adaptation
35
+ - Unified text color and border styles
36
+
37
+ #### Theme System Architecture
38
+ - **New modular theme architecture**:
39
+ - `src/renderer/editor/plugins/themes/` — New theme manager and base styles
40
+ - `themes/base/` — Base theme CSS files (light, dark, elegant, newsprint)
41
+ - `themes/components/mermaid/` — Mermaid-specific theme CSS files
42
+ - `foundation.css` — Shared foundation styles
43
+ - `variables.css` — CSS variables for Mermaid theming
44
+
45
+ ### Added
46
+
47
+ #### New Themes
48
+ - **Academic Paper theme**: [`academic-paper.css`](themes/academic-paper.css)
49
+ - Mermaid color scheme in Guizang warm tones (cream background + brown tones)
50
+ - Font size optimized for academic printing (10.5pt)
51
+ - Typora compatible selectors (`.md-diagram-panel`)
52
+ - Mobile responsive adaptation
53
+ - **Pixso Design theme**: [`pixso-design.css`](themes/pixso-design.css)
54
+ - **Swiss Design theme**: [`swiss-design.css`](themes/swiss-design.css) 🇨🇭
55
+ - Pure black-white-red color system inspired by Swiss International Typographic Style
56
+ - Geometric sans-serif fonts (Helvetica / Inter), grid-based layout with generous whitespace
57
+ - Form follows function design philosophy, minimal and restrained aesthetic
58
+ - Complete Mermaid diagram integration with monochrome + accent red styling
59
+
60
+ #### Theme Development Framework
61
+ - **Theme paradigm document**: [`docs/theme-paradigm.md`](docs/theme-paradigm.md)
62
+ - Comprehensive CSS theme development specification (v3.0)
63
+ - Design principles: variable-based, modular, semantic naming, AI-agent derivable
64
+ - Mandatory design constraints with validation methods (MUST / MUST NOT / SHOULD levels)
65
+ - Color space specification: 5 seed colors + 3 font stacks auto-derivation system
66
+ - Print fidelity requirements: `@media print` as screen style mirror enhancement
67
+
68
+ - **Standardized theme template**: [`themes/template.css`](themes/template.css)
69
+ - Reference implementation following the v3.0 paradigm
70
+ - All required sections: design tokens, editor styles, code blocks, blockquotes, tables, Mermaid variables, print styles
71
+ - Ready-to-use template for creating new custom themes
72
+
73
+ #### Documentation Updates
74
+ - Updated [README.md](README.md) and [README_CN.md](README_CN.md) to include Swiss Design theme in the downloadable themes table
75
+ - Added comprehensive theme descriptions for all 7 external themes (elegant, guizang, forest-ink, academic-paper, pixso-design, swiss-design, template)
76
+
77
+ ---
78
+
79
+ ## [1.5.1-beta.1] - 2026-05-22
80
+
81
+ ### Added
82
+
83
+ #### Android Platform Support
84
+ - **Full Android platform support**: Integrated Capacitor 6 for native Android app builds
85
+ - **File picker functionality**: Integrated `@capawesome/capacitor-file-picker` plugin for file selection on Android devices
86
+ - **Mobile responsive styles**: Added [`mobile.css`](src/renderer/mobile.css) for optimized mobile display and interaction
87
+ - **Auto-generated app icons**: Added [`generate-icons.js`](scripts/generate-icons.js) script to auto-generate Android/iOS icons at various sizes
88
+ - Android mipmap icons (48px-192px)
89
+ - Android adaptive icon foreground layer (108px-432px)
90
+ - iOS AppIcon (1024x1024)
91
+
92
+ #### New Themes & Styles
93
+ - **Forest Ink slide theme**: Added forest ink color scheme slide template with full presentation logic and responsive layout
94
+ - **Academic Paper theme**: Added [`academic-paper.css`](src/renderer/styles/themes/academic-paper.css) theme
95
+ - Mermaid color scheme in Guizang warm tones (cream background + brown tones)
96
+ - Font size optimized for academic printing (10.5pt)
97
+ - Typora compatible selectors (`.md-diagram-panel`)
98
+ - Mobile responsive adaptation
99
+ - **Pixso Design theme**: Added [`pixso-design.css`](src/renderer/styles/themes/pixso-design.css) theme
100
+
101
+ ### Fixed
102
+
103
+ #### Android Platform Fixes
104
+ - **Chinese IME (Input Method Editor) fix**:
105
+ - Removed `e.preventDefault()` in `beforeinput` event to resolve CJK input method issues
106
+ - Enhanced ProseMirror editor IME composition event handling
107
+ - Used `-webkit-user-modify: read-write-plaintext-only` to improve input experience
108
+ - **Intent file open fix**:
109
+ - Added `Intent.ACTION_VIEW` handling in `MainActivity`
110
+ - Supported `onNewIntent` for opening new files when app is already running
111
+ - Passed file content to WebView via JavaScript events
112
+ - **PDF export fix**:
113
+ - Replaced Capacitor Plugin bridge with `JavascriptInterface`
114
+ - Added `ColaMDNativeBridge` class to call Android native `PrintManager`
115
+ - Added "Save as PDF" option
116
+ - Fixed pagination, save button, mermaid version, and layer residue issues
117
+
118
+ #### Export Functionality Improvements
119
+ - **PDF/HTML export**:
120
+ - Refactored Mermaid rendering logic with export sync wait mechanism
121
+ - Supported real-time rendered content export
122
+ - Fixed default filename logic
123
+ - **File manager open**:
124
+ - Adopted pull model: JS actively calls Java `checkPendingFile()` to query
125
+ - Eliminated JS event injection timing issues
126
+ - Added init detection + setInterval polling for dual guarantee
127
+
128
+ ### Changed
129
+
130
+ - **Mobile IME handling refactor**:
131
+ - Simplified mobile CSS styles, removed outdated Android IME patches
132
+ - Refactored Android file open event listener, using new `colamd-open-event` instead of old `intent-file-opened`
133
+ - **Close button style optimization**: Replaced rectangle rotation icon with standard cross line icon for more consistent visual effect
134
+ - **Theme style updates**:
135
+ - `mermaid-plugin.css`: Minor adjustments
136
+ - `forest-ink.css`: Updated forest ink theme
137
+
138
+ ### Documentation
139
+
140
+ - Added [`demo.md`](docs/demo.md) and [`demo.pdf`](docs/demo.pdf) demo documents
141
+ - Updated README and README_CN.md with export documentation and new doc paths
142
+ - Added mobile support documentation with tech stack, build/release workflow, and troubleshooting
143
+ - Added Forest Ink theme documentation
144
+
145
+ ### Dependencies
146
+
147
+ | Package | Version | Purpose |
148
+ |---------|---------|---------|
149
+ | @capawesome/capacitor-file-picker | ^6.2.0 | Android file picker plugin |
150
+ | sharp | ^0.34.5 | Icon generation tool |
151
+
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
+ ## [1.5.0] - 2026-05-18
236
+
237
+ ### Added
238
+
239
+ #### Renderer Plugin System (Core Feature)
240
+ - Introduce declarative plugin architecture with independent registration, enable/disable toggle, and dynamic module management
241
+ - Unified plugin design pattern: Schema Definition → NodeView Interaction → Remark Parsing → Markdown Serialization → PNG Export → Rendered/Source Dual Mode
242
+ - **Plug** menu in menu bar for unified plugin render control
243
+
244
+ #### 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
package/CLAUDE.md CHANGED
@@ -85,3 +85,59 @@ src/
85
85
  - 主题 CSS 与编辑器逻辑完全分离
86
86
  - 代码简洁,不过度设计
87
87
  - 每个新功能先问:这是必要的吗?
88
+
89
+ ### 插件系统规范
90
+
91
+ 插件与主程序通过 `RendererPlugin` 接口通信,遵循**弱耦合**原则:
92
+
93
+ **1. 插件注册**
94
+
95
+ 插件通过 `registerPluginModule()` 自注册(副作用导入):
96
+
97
+ ```typescript
98
+ // ✅ 正确:副作用导入,仅触发 registerPluginModule
99
+ import './editor/plugins/math-plugin'
100
+ import './editor/plugins/mermaid-plugin'
101
+
102
+ // ✅ 兜底:glob 加载可能遗漏的插件
103
+ const _pluginRegistry = import.meta.glob('./editor/plugins/*-plugin.ts', { eager: true })
104
+
105
+ // ❌ 禁止:导入插件专用函数/类型
106
+ import { awaitAllMermaidRenders } from './editor/plugins/mermaid-plugin'
107
+ ```
108
+
109
+ **2. 接口驱动**
110
+
111
+ `main.ts` 只通过 `RendererPlugin` 接口方法与插件交互,**禁止**直接导入插件专用函数或硬编码插件 ID:
112
+
113
+ ```typescript
114
+ // ✅ 正确:遍历插件,调用通用接口
115
+ for (const p of getAllPlugins()) p.ensureRendered?.()
116
+
117
+ // ❌ 禁止:直接导入插件专用函数
118
+ import { awaitAllMermaidRenders } from './editor/plugins/mermaid-plugin'
119
+ await awaitAllMermaidRenders()
120
+
121
+ // ❌ 禁止:硬编码插件 ID 做特殊处理
122
+ getAllPlugins().filter(p => p.id === 'mermaid')
123
+ ```
124
+
125
+ **3. 功能归属**
126
+
127
+ | 逻辑类型 | 归属 |
128
+ |----------|------|
129
+ | 插件注册、schema、视图、导出能力 | 插件文件 (`*-plugin.ts`) |
130
+ | 通用插件查询、切换、导出能力发现 | `plugins/index.ts` |
131
+ | 编辑器创建、markdown 读写 | `editor/editor.ts` |
132
+ | IPC 事件路由、UI 协调 | `main.ts` |
133
+
134
+ **4. 减少 main.ts 修改**
135
+
136
+ 新增插件功能时,优先在插件文件和 `plugins/index.ts` 中实现。`main.ts` 仅在需要新的 IPC 事件路由或 UI 协调时才修改。
137
+
138
+ **5. `RendererPlugin` 接口约定**
139
+
140
+ - `ensureRendered?: () => Promise<void>` — 导出前等待渲染完成
141
+ - `onThemeChange?: (theme: string) => void` — 主题切换时重新配置
142
+ - `exportCapabilities?: ExportCapability[]` — 右键导出菜单
143
+ - `nodeTypes?: string[]` — 声明插件管理的 ProseMirror 节点类型