@bytechain.cn/colamd-themes 0.3.2 → 0.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 (99) hide show
  1. package/.claude/skills/colamd-themes-preview.skill.md +333 -0
  2. package/.claude/skills/colamd-themes.skill.md +10 -0
  3. package/.dsh/skills/colamd-themes/SKILL.md +14 -0
  4. package/.github/supported-topics.yml +17 -0
  5. package/.hermes/skills/tools/colamd-themes/SKILL.md +14 -0
  6. package/.openclaw/skills/colamd-themes/SKILL.md +1 -37
  7. package/.opencode/skills/colamd-themes/SKILL.md +17 -0
  8. package/.trae/rules/colamd-themes.md +0 -36
  9. package/CHANGELOG.md +331 -241
  10. package/DSH_SUPPORT_SUMMARY.md +87 -0
  11. package/README.md +414 -384
  12. package/README_CN.md +412 -384
  13. package/RELEASENOTE.md +541 -389
  14. package/dist/cli.js +36 -55
  15. package/dist/cli.js.map +1 -1
  16. package/dist/color-utils.d.ts +1 -0
  17. package/dist/color-utils.js +25 -6
  18. package/dist/color-utils.js.map +1 -1
  19. package/dist/extractors/pdf-extractor.js +6 -1
  20. package/dist/extractors/pdf-extractor.js.map +1 -1
  21. package/dist/extractors/url-extractor.d.ts +0 -4
  22. package/dist/extractors/url-extractor.js +13 -126
  23. package/dist/extractors/url-extractor.js.map +1 -1
  24. package/dist/generator.d.ts +1 -1
  25. package/dist/generator.js +32 -11
  26. package/dist/generator.js.map +1 -1
  27. package/dist/models.d.ts +5 -4
  28. package/dist/models.js +2 -3
  29. package/dist/models.js.map +1 -1
  30. package/dist/renderer.d.ts +6 -3
  31. package/dist/renderer.js +54 -93
  32. package/dist/renderer.js.map +1 -1
  33. package/dist/templates/template.css +220 -498
  34. package/dist/templates/theme-paradigm.md +530 -658
  35. package/dist/templates/theme-template.hbs +256 -370
  36. package/dist/theme-store.js +19 -3
  37. package/dist/theme-store.js.map +1 -1
  38. package/dist/utils/document-paradigm.d.ts +12 -0
  39. package/dist/utils/document-paradigm.js +109 -0
  40. package/dist/utils/document-paradigm.js.map +1 -0
  41. package/dist/validators.d.ts +4 -1
  42. package/dist/validators.js +115 -1
  43. package/dist/validators.js.map +1 -1
  44. package/mcp-server/dist/index.d.ts +13 -0
  45. package/mcp-server/dist/index.d.ts.map +1 -0
  46. package/mcp-server/dist/index.js +0 -0
  47. package/mcp-server/dist/index.js.map +1 -0
  48. package/mcp-server/package-lock.json +1759 -0
  49. package/mcp-server/package.json +24 -0
  50. package/mcp-server/src/index.ts +0 -0
  51. package/mcp-server/tsconfig.json +19 -0
  52. package/package.json +54 -36
  53. package/skills/build-skills.sh +30 -5
  54. package/skills/colamd-themes/SKILL.md +180 -178
  55. package/src/cli.ts +474 -487
  56. package/src/color-systems.ts +289 -289
  57. package/src/color-utils.ts +137 -120
  58. package/src/contrast.ts +66 -66
  59. package/src/docx-style-paradigm.ts +811 -811
  60. package/src/export-cli.ts +356 -356
  61. package/src/extractors/base.ts +8 -8
  62. package/src/extractors/docx-extractor.ts +417 -417
  63. package/src/extractors/pdf-extractor.ts +533 -527
  64. package/src/extractors/url-extractor.ts +846 -981
  65. package/src/generator.ts +197 -169
  66. package/src/index.ts +29 -29
  67. package/src/models.ts +212 -212
  68. package/src/renderer.ts +310 -359
  69. package/src/templates/template.css +220 -498
  70. package/src/templates/theme-paradigm.md +530 -658
  71. package/src/templates/theme-template.hbs +256 -370
  72. package/src/theme-store.ts +185 -170
  73. package/src/types/pdf-parse.d.ts +12 -12
  74. package/src/utils/cli-utils.ts +84 -84
  75. package/src/utils/document-paradigm.ts +118 -0
  76. package/src/validators.ts +298 -176
  77. package/themes/academic-paper-pt.css +353 -1805
  78. package/themes/academic-paper.css +350 -1099
  79. package/themes/academic-style.css +342 -2430
  80. package/themes/colly.css +256 -370
  81. package/themes/elegant.css +288 -671
  82. package/themes/forest-ink.css +240 -664
  83. package/themes/guizang.css +250 -732
  84. package/themes/hermes-security.css +279 -0
  85. package/themes/meeting-minutes.css +256 -370
  86. package/themes/pixso-design.css +278 -1261
  87. package/themes/salvator-blog.css +256 -370
  88. package/themes/shimo-theme.css +256 -0
  89. package/themes/swiss-design.css +285 -746
  90. package/themes/template.css +220 -498
  91. package/themes/trae-blue.css +280 -737
  92. package/themes/word-contract.css +249 -0
  93. package/themes-preview/demo-content.md +187 -187
  94. package/tsconfig.json +18 -18
  95. package/src/mermaid-presets.ts +0 -142
  96. package/themes/swiss-design copy.css +0 -746
  97. package/themes-preview/colly-preview.html +0 -623
  98. package/themes-preview/meeting-minutes-preview.html +0 -625
  99. package/themes-preview/salvator-blog-preview.html +0 -623
@@ -1,498 +1,220 @@
1
- /*
2
- * ColaMD 主题模板:{你的主题名称}
3
- * 版本:v3.0(模块化 + 变量驱动范式)
4
- *
5
- * ═══════════════════════════════════════════════════════════
6
- * 使用说明(面向用户 & AI Agent)
7
- * ═══════════════════════════════════════════════════════════
8
- *
9
- * 【快速上手】
10
- * 1. 修改 SECTION 1 的种子色板 (5 个种子色)
11
- * 2. 修改 SECTION 1 的字体选择 (3 组字体栈)
12
- * 3. 保存,导入 ColaMD:Theme > Import Theme
13
- * → 其余变量自动推导,无需手动调整
14
- *
15
- * 【变量命名规则】
16
- * --seed-* = 用户定义的原始设计令牌 (SECTION 1)
17
- * --color-* = 自动推导的色阶变量 (SECTION 2)
18
- * --font-* = 字体栈变量
19
- * --mermaid-* = Mermaid 图表变量 (被内置 variables.css 消费)
20
- *
21
- * 【架构原理】
22
- * 本文件只定义变量 + 极小量微调选择器。
23
- * 所有 Mermaid SVG 样式由 src/.../mermaid/variables.css 自动映射。
24
- * 所有编辑器排版由 src/.../base.css 自动承继。
25
- * → 主题作者只需关注「变量值」,无需写重复的选择器。
26
- *
27
- * 【配色方法论】
28
- * 浅色主题:seed-surface 最浅 → seed-panel 稍深 → seed-ink 最深
29
- * 深色主题:反转以上关系
30
- * 点缀色 (seed-accent):占页面 5-10% 面积,用于链接/强调/边框
31
- *
32
- * ═══════════════════════════════════════════════════════════
33
- * SECTION 1 — 设计令牌 (Design Tokens)
34
- * 用户只需修改此区域的数值
35
- * ═══════════════════════════════════════════════════════════ */
36
-
37
- body.theme-custom {
38
-
39
- /* ═══════════════════════════════════════════════════════════
40
- 1.1 种子色板 (Seed Palette)
41
- 修改这 5 个种子色即可改变整个主题的视觉基调
42
- ═══════════════════════════════════════════════════════════ */
43
-
44
- /* 点缀色:用于链接、强调、Mermaid 高亮、引用边框(占页面 ≤10%) */
45
- --seed-accent: #6366f1; /* 主色 (Indigo) */
46
- --seed-accent-light: #eef2ff; /* 浅变体 (bg 用途) */
47
- --seed-accent-dark: #4f46e5; /* 深变体 (hover/text) */
48
-
49
- /* 表面色:页面底色层次(从浅到深,3 级) */
50
- --seed-surface: #ffffff; /* L0 页面背景 (最浅) */
51
- --seed-panel: #f8f9fb; /* L1 卡片/代码区背景 */
52
- --seed-panel-alt: #f1f3f5; /* L2 表头/引用块背景 */
53
-
54
- /* 文字色:前景色层次(从深到浅,3 级) */
55
- --seed-ink: #1a1d26; /* T0 正文/标题 (最深) */
56
- --seed-ink-muted: #6b7280; /* T1 次要文字 */
57
- --seed-ink-dim: #9ca3af; /* T2 弱化/禁用文字 */
58
-
59
- /* 边框色 */
60
- --seed-border: #e5e7eb; /* 分割线/表格边框 */
61
- --seed-border-strong: #d1d5db; /* 强调边框 */
62
-
63
- /* ═══════════════════════════════════════════════════════════
64
- 1.2 字体系统 (Typography)
65
- ═══════════════════════════════════════════════════════════ */
66
-
67
- /* 正文字体栈:优先西文 → 中文衬线 → 通用衬线 */
68
- --font-body: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont,
69
- "Noto Serif SC", "Source Han Serif SC", "Songti SC",
70
- Georgia, "Times New Roman", serif;
71
-
72
- /* 标题字体栈:无衬线优先,与正文形成对比 */
73
- --font-heading: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont,
74
- "Noto Sans SC", "Source Han Sans SC", "PingFang SC",
75
- "Microsoft YaHei", sans-serif;
76
-
77
- /* 等宽字体栈:代码/公式 */
78
- --font-code: "JetBrains Mono", "SF Mono", "Fira Code", Menlo, Consolas, monospace;
79
-
80
- /* Mermaid 图表字体(与标题保持一致,字号独立控制) */
81
- --font-mermaid: var(--font-heading);
82
-
83
- /* ═══════════════════════════════════════════════════════════
84
- 1.3 字号 & 间距
85
- ═══════════════════════════════════════════════════════════ */
86
-
87
- /* 基准字号 (1rem = 该值) */
88
- --font-size-root: 16px;
89
-
90
- /* 标题倍率(相对于根字号) */
91
- --font-scale-h1: 2.0; /* 32px */
92
- --font-scale-h2: 1.5; /* 24px */
93
- --font-scale-h3: 1.25; /* 20px */
94
- --font-scale-h4: 1.1; /* 17.6px */
95
- --font-scale-h5: 1.0; /* 16px */
96
- --font-scale-h6: 0.95; /* 15.2px */
97
-
98
- /* Mermaid 独立字号 */
99
- --font-size-mermaid: 13px;
100
-
101
- /* 行高 */
102
- --line-height-body: 1.75;
103
- --line-height-heading: 1.35;
104
- --line-height-code: 1.6;
105
-
106
- /* ═══════════════════════════════════════════════════════════
107
- 1.4 圆角 & 间距 (可选)
108
- ═══════════════════════════════════════════════════════════ */
109
- --radius-sm: 3px;
110
- --radius-md: 6px;
111
- --radius-lg: 10px;
112
- --content-width: 820px;
113
-
114
- /* ═══════════════════════════════════════════════════════════
115
- SECTION 2 — 语义映射 (Semantic Mapping)
116
- 将 SECTION 1 的令牌自动映射到 ColaMD 内置系统消费的变量
117
- 通常无需修改,除非需要特殊微调某个语义角色
118
- ═══════════════════════════════════════════════════════════ */
119
-
120
- /* ── 2.1 编辑区表面色 ── */
121
- --bg-color: var(--seed-surface);
122
- --surface-color: var(--seed-panel);
123
- --surface-alt: var(--seed-panel-alt);
124
-
125
- /* ── 2.2 编辑区文字色 ── */
126
- --text-color: var(--seed-ink);
127
- --heading-color: var(--seed-ink);
128
- --text-muted: var(--seed-ink-muted);
129
- --text-dim: var(--seed-ink-dim);
130
-
131
- /* ── 2.3 链接 & 强调 ── */
132
- --link-color: var(--seed-accent);
133
- --accent-color: var(--seed-accent);
134
- --accent-dark: var(--seed-accent-dark);
135
- --accent-light: var(--seed-accent-light);
136
- --selection-bg: rgba(99, 102, 241, 0.15); /* 手动匹配 accent */
137
-
138
- /* ── 2.4 边框 & 分割线 ── */
139
- --border-color: var(--seed-border);
140
- --blockquote-border: var(--seed-accent);
141
- --hr-color: var(--seed-border);
142
-
143
- /* ── 2.5 内联代码 ── */
144
- --code-bg: var(--seed-panel);
145
- --code-color: var(--seed-accent-dark);
146
-
147
- /* ── 2.6 代码块 ── */
148
- --code-block-bg: var(--seed-panel-alt);
149
- --code-block-text: var(--seed-ink);
150
- --code-block-color: var(--seed-ink);
151
-
152
- /* ── 2.7 引用块 ── */
153
- --blockquote-bg: var(--seed-panel);
154
-
155
- /* ── 2.8 表格 ── */
156
- --table-header-bg: var(--seed-panel);
157
- --table-border: var(--seed-border);
158
-
159
- /* ── 2.9 滚动条 ── */
160
- --scrollbar-thumb: var(--seed-border-strong);
161
- --scrollbar-thumb-hover: var(--seed-ink-muted);
162
-
163
- /* ═══════════════════════════════════════════════════════════
164
- SECTION 3 — Mermaid 图表变量 (20 核心变量)
165
- 由内置 src/.../mermaid/variables.css 自动消费
166
- 变量说明注释标注了每个变量的视觉作用
167
- ═══════════════════════════════════════════════════════════ */
168
-
169
- /* ── 3.1 容器 ── */
170
- --mermaid-background: var(--seed-panel); /* 图表容器背景 */
171
- --mermaid-border-color: var(--seed-border); /* 图表容器边框 */
172
- --mermaid-border-radius: var(--radius-md); /* 图表容器圆角 */
173
- --mermaid-padding: 20px; /* 图表容器内边距 */
174
-
175
- /* ── 3.2 字体 ── */
176
- --mermaid-font-family: var(--font-mermaid); /* 图表内字体 */
177
- --mermaid-font-size: var(--font-size-mermaid); /* 图表内字号 */
178
-
179
- /* ── 3.3 节点 (所有图表类型的矩形/圆形/菱形等) ── */
180
- --mermaid-node-fill: var(--seed-panel); /* 节点填充色 */
181
- --mermaid-node-stroke: var(--seed-accent); /* 节点描边色 */
182
- --mermaid-node-stroke-width: 1.5px; /* 节点描边宽度 */
183
- --mermaid-node-text: var(--seed-ink); /* 节点内文字色 */
184
-
185
- /* ── 3.4 连线 (边/箭头) ── */
186
- --mermaid-edge-stroke: var(--seed-ink-muted); /* 连线颜色 */
187
- --mermaid-edge-stroke-width: 1.5px; /* 连线宽度 */
188
-
189
- /* ── 3.5 聚类 (Subgraph / 子图容器) ── */
190
- --mermaid-cluster-fill: rgba(99, 102, 241, 0.06); /* 聚类填充 */
191
- --mermaid-cluster-stroke: var(--seed-accent); /* 聚类边框 */
192
-
193
- /* ── 3.6 标签 (节点内文本 / 边标签文本) ── */
194
- --mermaid-label-text: var(--seed-ink); /* 标签文字色 */
195
- --mermaid-edge-label-text: var(--seed-ink-muted); /* 边标签文字色 */
196
- --mermaid-edge-label-bg: var(--seed-surface); /* 边标签背景色 */
197
-
198
- /* ── 3.7 标题 & 坐标轴 (Pie/Gantt/XYChart 等) ── */
199
- --mermaid-title-text: var(--seed-ink); /* 图表标题色 */
200
- --mermaid-axis-text: var(--seed-ink-muted); /* 坐标轴文字色 */
201
- --mermaid-highlight: var(--seed-accent); /* 高亮/标记色 */
202
-
203
- /* ── 3.8 人物节点 (Sequence / C4 等) ── */
204
- --mermaid-person-stroke: var(--seed-ink); /* 人物描边色 */
205
- --mermaid-person-fill: var(--seed-panel); /* 人物填充色 */
206
-
207
- /* ── 3.9 标签 Y 偏移 (微调文字垂直对齐,通常 0 或 -3px) ── */
208
- --mermaid-label-offset-y: 0px;
209
-
210
- /* ═══════════════════════════════════════════════════════════
211
- SECTION 4 — 排版微调 (Fine Tuning)
212
- 仅覆盖 base.css 未通过变量处理的样式
213
- 所有值继续引用变量,禁止硬编码
214
- ═══════════════════════════════════════════════════════════ */
215
-
216
-
217
- /* ── 4.1 中文字体适应:适当增大行高 ── */
218
- --line-height-base: var(--line-height-body);
219
-
220
- /* ── 4.2 深色代码块需要文字变亮 (可选,若代码块背景很深则启用) ── */
221
- /* --code-block-text: #e4e7ed; */ /* 默认注释,按需取消 */
222
- }
223
-
224
- /* ═════════════════════════════════════════════════════════════
225
- SECTION 5 — 选择器级微调 (Selector Fine-Tuning)
226
- 仅用于 base.css 不提供的个性化样式
227
- 所有值严格引用变量,禁止出现裸色值/裸字号
228
- ═════════════════════════════════════════════════════════════ */
229
-
230
- /* ── 5.1 全局:字体 + 底色 + 字号 ── */
231
- html { font-size: var(--font-size-root); }
232
- body.theme-custom, html, body {
233
- background-color: var(--bg-color);
234
- color: var(--text-color);
235
- font-family: var(--font-body);
236
- line-height: var(--line-height-body);
237
- }
238
-
239
- /* ── 5.2 编辑区 ── */
240
- #write {
241
- max-width: var(--content-width);
242
- margin: 0 auto;
243
- padding: 30px 60px 100px;
244
- }
245
-
246
- /* ── 5.3 标题:字体 + 倍率 ── */
247
- body.theme-custom h1, body.theme-custom h2, body.theme-custom h3,
248
- body.theme-custom h4, body.theme-custom h5, body.theme-custom h6 {
249
- font-family: var(--font-heading);
250
- color: var(--heading-color);
251
- font-weight: 700;
252
- line-height: var(--line-height-heading);
253
- }
254
-
255
- body.theme-custom h1 { font-size: calc(var(--font-size-root) * var(--font-scale-h1)); }
256
- body.theme-custom h2 { font-size: calc(var(--font-size-root) * var(--font-scale-h2)); }
257
- body.theme-custom h3 { font-size: calc(var(--font-size-root) * var(--font-scale-h3)); }
258
- body.theme-custom h4 { font-size: calc(var(--font-size-root) * var(--font-scale-h4)); }
259
- body.theme-custom h5 { font-size: calc(var(--font-size-root) * var(--font-scale-h5)); }
260
- body.theme-custom h6 { font-size: calc(var(--font-size-root) * var(--font-scale-h6)); }
261
-
262
- /* ── 5.4 内联强调:使用点缀色 ── */
263
- body.theme-custom strong { color: var(--accent-color); }
264
-
265
- /* ── 5.5 内联代码 ── */
266
- body.theme-custom code {
267
- font-family: var(--font-code);
268
- background: var(--code-bg);
269
- color: var(--code-color);
270
- }
271
-
272
- /* ── 5.6 代码块 ── */
273
- body.theme-custom pre {
274
- background: var(--code-block-bg);
275
- font-family: var(--font-code);
276
- line-height: var(--line-height-code);
277
- }
278
- body.theme-custom pre code {
279
- color: var(--code-block-text);
280
- background: transparent;
281
- }
282
-
283
- /* ── 5.7 引用块 ── */
284
- body.theme-custom blockquote {
285
- background: var(--blockquote-bg);
286
- border-left: 4px solid var(--blockquote-border);
287
- }
288
-
289
- /* ── 5.8 表格表头 ── */
290
- body.theme-custom table th {
291
- background: var(--table-header-bg);
292
- font-weight: 700;
293
- border-bottom: 2px solid var(--accent-color);
294
- }
295
-
296
- /* ── 5.9 分割线 ── */
297
- body.theme-custom hr {
298
- border: none;
299
- border-top: 1px solid var(--hr-color);
300
- }
301
-
302
- /* ── 5.10 图片居中 ── */
303
- body.theme-custom img { max-width: 100%; }
304
-
305
- /* ── 5.11 Mermaid 图表标题(跟随图表的 p) ── */
306
- /* 用于 **图X ...** 这类 Markdown 标题自动居中 */
307
- body.theme-custom .mermaid-block + p {
308
- text-align: center;
309
- font-family: var(--font-heading);
310
- font-size: calc(var(--font-size-mermaid) + 2px);
311
- color: var(--text-muted);
312
- }
313
-
314
- /* ── 5.12 响应式 ── */
315
- @media only screen and (max-width: 768px) {
316
- #write { padding: 20px; }
317
- body.theme-custom .mermaid-block { padding: 12px; }
318
- body.theme-custom .mermaid-preview svg { max-width: 100% !important; height: auto !important; }
319
- }
320
-
321
- /* ═════════════════════════════════════════════════════════════
322
- SECTION 6 — 打印 / 导出 (Print / Export)
323
- 原则:屏幕样式的完整镜像。每个屏幕属性都必须在 print 中显式声明。
324
- 禁止在 print 中引入新色值,禁止遗漏任何有色/有尺寸的元素。
325
- ═════════════════════════════════════════════════════════════ */
326
- @media print {
327
- @page { margin: 20mm; }
328
-
329
- /* ── 6.0 变量重声明(Chromium 打印引擎会丢失 CSS 变量,需重新注入) ── */
330
- body.theme-custom {
331
- --seed-accent: #6366f1; /* ⬅ 与 SECTION 1.1 保持完全一致 */
332
- --seed-accent-dark: #4f46e5;
333
- --seed-surface: #ffffff;
334
- --seed-ink: #1a1d26;
335
- --seed-ink-muted: #6b7280;
336
- --seed-panel: #f8f9fb;
337
- --seed-panel-alt: #f1f3f5;
338
- --seed-border: #e5e7eb;
339
- --font-size-root: 16px;
340
- --line-height-body: 1.75;
341
- --line-height-heading: 1.35;
342
- --line-height-code: 1.6;
343
- --font-scale-h1: 2.0;
344
- --font-scale-h2: 1.5;
345
- --font-scale-h3: 1.25;
346
- --font-scale-h4: 1.1;
347
- --font-scale-h5: 1.0;
348
- --font-scale-h6: 0.95;
349
- --content-width: 820px;
350
- --font-size-mermaid: 13px;
351
- --accent-color: var(--seed-accent);
352
- --accent-dark: var(--seed-accent-dark);
353
- --code-bg: var(--seed-panel);
354
- --code-color: var(--seed-accent-dark);
355
- --code-block-bg: var(--seed-panel-alt);
356
- --code-block-text: var(--seed-ink);
357
- --blockquote-bg: var(--seed-panel);
358
- --table-header-bg: var(--seed-panel);
359
- --border-color: var(--seed-border);
360
- --hr-color: var(--seed-border);
361
- --font-body: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont,
362
- "Noto Serif SC", "Source Han Serif SC", "Songti SC",
363
- Georgia, "Times New Roman", serif;
364
- --font-heading: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont,
365
- "Noto Sans SC", "Source Han Sans SC", "PingFang SC",
366
- "Microsoft YaHei", sans-serif;
367
- --font-code: "JetBrains Mono", "SF Mono", "Fira Code", Menlo, Consolas, monospace;
368
- }
369
-
370
- /* ── 6.1 根元素:字号 + 字体 + 行高 + 底色 ── */
371
- html {
372
- font-size: var(--font-size-root) !important;
373
- }
374
- html, body, body.theme-custom {
375
- background: var(--seed-surface) !important;
376
- color: var(--seed-ink) !important;
377
- font-family: var(--font-body) !important;
378
- line-height: var(--line-height-body) !important;
379
- -webkit-print-color-adjust: exact !important;
380
- print-color-adjust: exact !important;
381
- }
382
-
383
- /* ── 6.2 编辑区 ── */
384
- #write {
385
- max-width: var(--content-width) !important;
386
- margin: 0 auto !important;
387
- padding: 30px 60px 100px !important;
388
- }
389
-
390
- /* ── 6.3 标题:字号 + 字体 + 字重 + 行高 ── */
391
- body.theme-custom h1, body.theme-custom h2, body.theme-custom h3,
392
- body.theme-custom h4, body.theme-custom h5, body.theme-custom h6 {
393
- font-family: var(--font-heading) !important;
394
- color: var(--seed-ink) !important;
395
- font-weight: 700 !important;
396
- line-height: var(--line-height-heading) !important;
397
- -webkit-print-color-adjust: exact !important;
398
- print-color-adjust: exact !important;
399
- }
400
- body.theme-custom h1 { font-size: calc(var(--font-size-root) * var(--font-scale-h1)) !important; }
401
- body.theme-custom h2 { font-size: calc(var(--font-size-root) * var(--font-scale-h2)) !important; }
402
- body.theme-custom h3 { font-size: calc(var(--font-size-root) * var(--font-scale-h3)) !important; }
403
- body.theme-custom h4 { font-size: calc(var(--font-size-root) * var(--font-scale-h4)) !important; }
404
- body.theme-custom h5 { font-size: calc(var(--font-size-root) * var(--font-scale-h5)) !important; }
405
- body.theme-custom h6 { font-size: calc(var(--font-size-root) * var(--font-scale-h6)) !important; }
406
-
407
- /* ── 6.4 内联强调 ── */
408
- body.theme-custom strong {
409
- color: var(--accent-color) !important;
410
- font-weight: 700 !important;
411
- -webkit-print-color-adjust: exact !important;
412
- print-color-adjust: exact !important;
413
- }
414
-
415
- /* ── 6.5 内联代码:字体 + 背景 + 颜色 ── */
416
- body.theme-custom code {
417
- font-family: var(--font-code) !important;
418
- background: var(--code-bg) !important;
419
- color: var(--code-color) !important;
420
- -webkit-print-color-adjust: exact !important;
421
- print-color-adjust: exact !important;
422
- }
423
-
424
- /* ── 6.6 代码块:背景 + 字体 + 行高 ── */
425
- body.theme-custom pre {
426
- background: var(--code-block-bg) !important;
427
- font-family: var(--font-code) !important;
428
- line-height: var(--line-height-code) !important;
429
- -webkit-print-color-adjust: exact !important;
430
- print-color-adjust: exact !important;
431
- }
432
- body.theme-custom pre code {
433
- color: var(--code-block-text) !important;
434
- background: transparent !important;
435
- }
436
-
437
- /* ── 6.7 引用块:背景 + 左侧竖线(色值与屏幕一致:accent) ── */
438
- body.theme-custom blockquote {
439
- background: var(--blockquote-bg) !important;
440
- border-left: 4px solid var(--seed-accent) !important;
441
- -webkit-print-color-adjust: exact !important;
442
- print-color-adjust: exact !important;
443
- }
444
-
445
- /* ── 6.8 表格:边框合并 + 表头 ── */
446
- body.theme-custom table {
447
- border-collapse: collapse !important;
448
- }
449
- body.theme-custom table th {
450
- background: var(--table-header-bg) !important;
451
- color: var(--seed-ink) !important;
452
- font-weight: 700 !important;
453
- border-bottom: 2px solid var(--accent-color) !important;
454
- -webkit-print-color-adjust: exact !important;
455
- print-color-adjust: exact !important;
456
- }
457
- body.theme-custom table td {
458
- border-color: var(--seed-border) !important;
459
- }
460
-
461
- /* ── 6.9 链接 ── */
462
- body.theme-custom a {
463
- color: var(--seed-accent) !important;
464
- -webkit-print-color-adjust: exact !important;
465
- print-color-adjust: exact !important;
466
- }
467
-
468
- /* ── 6.10 分割线 ── */
469
- body.theme-custom hr {
470
- border: none !important;
471
- border-top: 1px solid var(--hr-color) !important;
472
- }
473
-
474
- /* ── 6.11 图片 ── */
475
- body.theme-custom img {
476
- max-width: 100% !important;
477
- }
478
-
479
- /* ── 6.12 Mermaid 图表容器 ── */
480
- body.theme-custom .mermaid-block {
481
- background: var(--seed-surface) !important;
482
- border-color: var(--seed-border) !important;
483
- -webkit-print-color-adjust: exact !important;
484
- print-color-adjust: exact !important;
485
- }
486
- body.theme-custom .mermaid-preview svg * {
487
- -webkit-print-color-adjust: exact !important;
488
- print-color-adjust: exact !important;
489
- }
490
-
491
- /* ── 6.13 图表标题 ── */
492
- body.theme-custom .mermaid-block + p {
493
- color: var(--seed-ink-muted) !important;
494
- text-align: center !important;
495
- font-family: var(--font-heading) !important;
496
- font-size: calc(var(--font-size-mermaid) + 2px) !important;
497
- }
498
- }
1
+ /* ===== ColaMD 自定义主题模板(2.7 契约)=====
2
+
3
+ 复制这一份改就是了:改配色、改字体、改文件名,然后 Theme > Import Theme,
4
+ 或者放进 ~/.colamd/themes/。
5
+
6
+ 三件事先说清楚:
7
+
8
+ 1. 变量写在 :root 里。没写的活变量继承 Light 主题的默认值,所以只想改配色的话,
9
+ 下面第一段往往就够了,选择器那一段可以整段删掉。
10
+ 2. 编辑器里没有 <h1>、<blockquote> 这种元素:标题是一「行」带一个类,引用与代码块
11
+ 是每一行一个 div,加粗是一个 span。所以只能选 .cm-md-* 这些钩子。
12
+ 3. 引用块与代码块**不能加纵向 padding**:一行一个 div,纵向 padding 会按行累加。
13
+ 要留呼吸感只给 padding-left / padding-right。
14
+
15
+ 这份故意不是一套好看的配色,它是照着改的起点。 */
16
+
17
+ :root {
18
+ /* ---- 语义色(活变量)---- */
19
+ --bg-color: #ffffff; /* 正文底色 */
20
+ --text-color: #24292f; /* 正文字色 */
21
+ --text-secondary: #57606a; /* 次级文字:引用、标签 */
22
+ --text-muted: #6e7781; /* 压淡文字:行号、链接地址、列表圆点 */
23
+ --border-color: #d0d7de; /* 分隔线、表格边框、面板描边 */
24
+ --link-color: #0969da; /* 链接、搜索高亮 */
25
+
26
+ --code-bg: rgba(175, 184, 193, 0.2); /* 行内代码底色 */
27
+ --code-block-bg: #f6f8fa; /* 代码块底色:明暗决定 Pele 图表配色 */
28
+ --code-block-text: #24292f; /* 代码块文字 */
29
+
30
+ --blockquote-border: #d0d7de; /* 引用块左竖线 */
31
+ --blockquote-bg: transparent; /* 引用块底色,transparent 就是不要底 */
32
+ --table-header-bg: #f6f8fa; /* 表头底色 */
33
+ --selection-bg: rgba(9, 105, 218, 0.15);/* 选中背景 */
34
+ --highlight-bg: #fff3bf; /* ==高亮== 底色 */
35
+
36
+ /* ---- 字体与度量(活变量)---- */
37
+ --font-body: Georgia, 'Songti SC', 'Noto Serif SC', serif;
38
+ --font-mono: 'SF Mono', 'Fira Code', Menlo, Consolas, monospace;
39
+ --editor-font-size: 16px;
40
+ --editor-column-width: 780px;
41
+
42
+ /* ---- Pele 图表(可选,9 个)----
43
+ 图直接画在 --code-block-bg 上,缺省会由代码块底色与字色推导。 */
44
+ --pele-bg: var(--code-block-bg);
45
+ --pele-fg: var(--code-block-text);
46
+ --pele-muted: color-mix(in srgb, var(--code-block-text) 70%, var(--code-block-bg));
47
+ --pele-line: var(--code-block-text);
48
+ --pele-surface: color-mix(in srgb, var(--code-block-text) 18%, var(--code-block-bg));
49
+ --pele-surface-alt: color-mix(in srgb, var(--code-block-text) 28%, var(--code-block-bg));
50
+ --pele-border: color-mix(in srgb, var(--code-block-text) 45%, var(--code-block-bg));
51
+ --pele-accent: var(--link-color);
52
+ --pele-radius: 6px;
53
+ }
54
+
55
+ /* ===== 编辑器 DOM =====
56
+ CodeMirror 6 的选择器优先级:行级规则写成「两个类」才压得住它运行时注入的
57
+ baseTheme,所以下面一律用 #editor .cm-content .cm-md-*。 */
58
+
59
+ #editor .cm-content {
60
+ font-family: var(--font-body);
61
+ line-height: 1.75;
62
+ }
63
+
64
+ /* 标题。只要一级二级就这样写,三级往下照抄类名即可。 */
65
+ #editor .cm-content .cm-md-atxheading1,
66
+ #editor .cm-content .cm-md-atxheading2 {
67
+ color: #1b4f72;
68
+ padding-bottom: 0.25em;
69
+ border-bottom: 1px solid var(--border-color);
70
+ }
71
+ #editor .cm-content .cm-md-atxheading3,
72
+ #editor .cm-content .cm-md-atxheading4,
73
+ #editor .cm-content .cm-md-atxheading5,
74
+ #editor .cm-content .cm-md-atxheading6 {
75
+ color: #1b4f72;
76
+ }
77
+
78
+ /* 行内格式。 */
79
+ #editor .cm-content .cm-md-strong { color: var(--link-color); }
80
+ #editor .cm-content .cm-md-em { font-style: italic; }
81
+ #editor .cm-content .cm-md-strike { text-decoration: line-through; }
82
+ #editor .cm-content .cm-md-highlight { background: var(--highlight-bg); }
83
+ #editor .cm-content .cm-md-link { color: var(--link-color); }
84
+ #editor .cm-content .cm-md-url { color: var(--text-muted); }
85
+
86
+ #editor .cm-content .cm-md-inlinecode {
87
+ font-family: var(--font-mono);
88
+ background: var(--code-bg);
89
+ color: var(--text-color);
90
+ border-radius: 3px;
91
+ }
92
+
93
+ /* 标记字符(#、>、-、围栏):光标不在这一行时压淡。 */
94
+ #editor .cm-content .cm-md-marker,
95
+ #editor .cm-content .cm-md-quotemark,
96
+ #editor .cm-content .cm-md-listmark {
97
+ color: var(--text-muted);
98
+ }
99
+
100
+ /* 引用块:一行一个 div,所以只给左右内边距。 */
101
+ #editor .cm-content .cm-md-blockquote {
102
+ background: var(--blockquote-bg);
103
+ color: var(--text-secondary);
104
+ border-left: 3px solid var(--blockquote-border);
105
+ padding-left: 16px;
106
+ padding-right: 16px;
107
+ }
108
+
109
+ /* 代码块:同样一行一个 div;圆角放在首行/末行。 */
110
+ #editor .cm-content .cm-md-codeblock {
111
+ background: var(--code-block-bg);
112
+ color: var(--code-block-text);
113
+ padding-left: 16px;
114
+ padding-right: 16px;
115
+ }
116
+ #editor .cm-content .cm-md-codeblock-first {
117
+ border-top-left-radius: 6px;
118
+ border-top-right-radius: 6px;
119
+ }
120
+ #editor .cm-content .cm-md-codeblock-last {
121
+ border-bottom-left-radius: 6px;
122
+ border-bottom-right-radius: 6px;
123
+ }
124
+
125
+ /* 表格:单元格是 .cm-md-table-widget 里的 th / td。 */
126
+ #editor .cm-content .cm-md-table-widget th,
127
+ #editor .cm-content .cm-md-table-widget td {
128
+ border-color: var(--border-color);
129
+ }
130
+ #editor .cm-content .cm-md-table-widget th {
131
+ background: var(--table-header-bg);
132
+ color: var(--text-color);
133
+ border-bottom: 2px solid var(--link-color);
134
+ }
135
+
136
+ /* 分隔线。 */
137
+ #editor .cm-content .cm-md-hr { border-top-color: var(--border-color); }
138
+
139
+ /* 中文正文首行缩进:一行就是一个 div,标题/引用/代码/列表行归零。 */
140
+ #editor .cm-content .cm-line { text-indent: 2em; }
141
+
142
+ #editor .cm-content .cm-md-atxheading1,
143
+ #editor .cm-content .cm-md-atxheading2,
144
+ #editor .cm-content .cm-md-atxheading3,
145
+ #editor .cm-content .cm-md-atxheading4,
146
+ #editor .cm-content .cm-md-atxheading5,
147
+ #editor .cm-content .cm-md-atxheading6,
148
+ #editor .cm-content .cm-md-blockquote,
149
+ #editor .cm-content .cm-md-codeblock,
150
+ #editor .cm-content .cm-md-hr,
151
+ #editor .cm-content .cm-md-mermaid,
152
+ #editor .cm-content .cm-md-li-0,
153
+ #editor .cm-content .cm-md-li-1,
154
+ #editor .cm-content .cm-md-li-2,
155
+ #editor .cm-content .cm-md-li-3,
156
+ #editor .cm-content .cm-md-li-4,
157
+ #editor .cm-content .cm-md-li-5,
158
+ #editor .cm-content .cm-md-li-6 {
159
+ text-indent: 0;
160
+ }
161
+
162
+ /* ===== 导出的 HTML =====
163
+ 导出件是语义标签(h1/p/pre/table…),挂在 .colamd-document 上,
164
+ 编辑器里不存在这个类。document.css 已给结构,这里只补配色。 */
165
+
166
+ .colamd-document {
167
+ font-family: var(--font-body);
168
+ font-size: var(--editor-font-size);
169
+ line-height: 1.75;
170
+ }
171
+
172
+ .colamd-document h1,
173
+ .colamd-document h2,
174
+ .colamd-document h3,
175
+ .colamd-document h4,
176
+ .colamd-document h5,
177
+ .colamd-document h6 {
178
+ color: #1b4f72;
179
+ }
180
+
181
+ .colamd-document strong { color: var(--link-color); }
182
+ .colamd-document code {
183
+ background: var(--code-bg);
184
+ color: var(--text-color);
185
+ font-family: var(--font-mono);
186
+ }
187
+ .colamd-document pre { background: var(--code-block-bg); }
188
+ .colamd-document pre code { color: var(--code-block-text); }
189
+ .colamd-document blockquote {
190
+ background: var(--blockquote-bg);
191
+ color: var(--text-secondary);
192
+ border-left-color: var(--blockquote-border);
193
+ }
194
+ .colamd-document mark { background: var(--highlight-bg); }
195
+ .colamd-document th {
196
+ background: var(--table-header-bg);
197
+ border-bottom: 2px solid var(--link-color);
198
+ }
199
+ .colamd-document hr { border-top-color: var(--border-color); }
200
+
201
+ .colamd-document p { text-indent: 2em; }
202
+ .colamd-document li p,
203
+ .colamd-document td p,
204
+ .colamd-document th p,
205
+ .colamd-document blockquote p {
206
+ text-indent: 0;
207
+ }
208
+
209
+ /* ===== 打印 =====
210
+ 应用直接对当前窗口 printToPDF,上面所有规则原样生效。 */
211
+
212
+ @media print {
213
+ html,
214
+ body {
215
+ background: var(--bg-color);
216
+ color: var(--text-color);
217
+ -webkit-print-color-adjust: exact;
218
+ print-color-adjust: exact;
219
+ }
220
+ }