vscode-colaview 0.4.0 → 0.4.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.
@@ -0,0 +1,29 @@
1
+ # ColaView MD v0.4.1
2
+
3
+ ## 🎬 Slides Preview: Mermaid & Math Now Render
4
+
5
+ In the slides deck, ```mermaid fences and `$$…$$` block math were drawn as raw source lines — the slides render layer is a standalone renderer and had no widget support. Worse, the deck paginator splits oversized code blocks by line budget, so a long mermaid fence was chopped into invalid partial sources that failed parsing with "Syntax error in text".
6
+
7
+ - **Mermaid fences are never split** — `splitBlock` keeps a mermaid block whole (an oversized diagram occupies a page on its own).
8
+ - **Hydration** — the renderer emits placeholder containers (source kept in a hidden node), and the WebView hydrates them after each deck render. When rendering fails, the source stays visible as a fallback.
9
+
10
+ ## 🎯 Slide Rendering Aligned with ColaMD-extend
11
+
12
+ Slides mermaid now renders through **pele** (the same renderer ColaMD-extend uses via `pele/lazy`): the SVG references `var(--pele-*)` tokens that DECK_CSS injects on the holder — the same mapping as the document preview — so diagrams inherit the active theme exactly instead of looking like pasted-in neutral-theme pictures. The standalone present/PDF document loads the pele global build from CDN and renders synchronously.
13
+
14
+ - **Per-page fit via font-size shrink** (from ColaMD-themes `fitPaper`) — replaces the previous `zoom` approach, which distorts the pages' cqw/cqh container-query sizing in presenting and printing. Exposed as `window.__colaviewFitSlides`.
15
+ - **Refit after hydration** — mermaid and KaTeX change each page's content height, so hydration re-runs the fit.
16
+ - **Blank directive-only pages filtered** (from ColaMD-extend `deckPages`) — no more empty paper sheets in presenting and printing.
17
+
18
+ ## 🐛 Present (Fullscreen): Browser Opens Reliably on Windows
19
+
20
+ Presenting failed with "系统找不到指定的文件": `vscode.env.openExternal` with a `file:` URI goes through Windows ShellExecute and frequently fails. Presenting now opens the file through the platform shell — `start` on Windows, `open` on macOS, `xdg-open` on Linux — with `openExternal` as a fallback.
21
+
22
+ ## ⌨️ Keybindings & Localization
23
+
24
+ - `Ctrl+Alt+V` opens the preview, `Ctrl+Alt+S` the slides preview (Markdown files only, conflict-free with Save).
25
+ - Command titles are localized via `package.nls.json` / `package.nls.zh-cn.json`, following the VS Code display language.
26
+
27
+ ---
28
+
29
+ **Download**: `vscode-colaview-0.4.1.vsix` — install via `Extensions → Install from VSIX`, or `code --install-extension vscode-colaview-0.4.1.vsix`.
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "colaview.autoPreview": false,
3
- "colaview.theme": "notion"
3
+ "colaview.theme": "pink-script-dark"
4
4
  }
package/CHANGELOG.md CHANGED
@@ -2,36 +2,49 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
- ## [0.4.0] - 2026-12-01
6
-
7
- ### Added
8
- - **Menu optimization** — the editor context menu now only offers "Show Preview" and "Show Slides Preview". The preview context menu keeps Present (Fullscreen) pinned first and scopes exports to the current mode: documents get PDF / HTML / Word, slides get PDF / PPTX. Command titles are localized via `package.nls.json` / `package.nls.zh-cn.json` (following the VS Code display language), and the preview commands ship keybindings `Ctrl+Alt+V` (preview) / `Ctrl+Alt+S` (slides preview), active only in Markdown files.
9
- - **Grouped theme submenu** — theme groups are Built-in · Light / Built-in · Dark / Custom, and the submenu is capped at 70vh with scrolling, so long custom-theme lists no longer overflow the page.
10
- - **DSH rendering alignment** — the 12 built-in themes are upgraded to the ColaMD 2.8 contract (seed palette, `--font-body`/`--font-mono`/`--editor-font-size`/`--editor-column-width` typography tokens, JetBrains Mono / Fira Code webfont mirroring with `fonts.gstatic.com` allowed by CSP), and the WebView injects a DSH BASE_CSS alignment layer via zero-specificity `:where()` rules: 820px column + 2.2rem gutters, 1.78 body line-height (per-theme values win), 0.01em letter-spacing, token-driven heading metrics with h1/h2 underlines removed. Cascade: engine defaults < alignment layer < theme identity rules.
11
- - **Slide preview, presenting & exports** (merged from the 0.2.x line, released as v0.3.4 on main) — dedicated slide render layer at 1920×1080, fullscreen presenting via the system browser, slide exports to PDF / standalone `.slides.html` / PPTX, and bilingual preview menus.
12
-
13
- ### Changed
14
- - **Engine upgrade: ColaMD 2.8.2** — `@bytechain.cn/colamd` bumped from 2.7.11 to 2.8.2. The engine now ships the CM6 whole-line `block: true` replace-decoration fix natively (mermaid always, block math / HTML blocks when covering full lines, tables always), and its own `.cm-md-mermaid` palette is page-based. The `patch-package` patch is retired — no more node_modules patching.
15
- - **All 12 built-in theme files synced with ColaMD-extend** (the 2.7.12+ theme contract): refined border colors in every theme, Elegant drops the dead `--table-border` variable, Dark/Midnight/Writer add strong and inline-code accent colors, Notion replaces the link-underline rules with strong/URL colors, Dracula/Gruvbox/Nord/Midnight drop blockquote text overrides, Elegant/Sepia drop blockquote horizontal padding.
16
- - **Mermaid diagrams now render on the page, not on the code block** — preview and HTML/PDF exports derive the `--pele-*` tokens from `--bg-color`/`--text-color` (18%/28%/45% mixes, same ratios as the engine) instead of `--code-block-bg`/`--code-block-text`, and no longer paint a code-block background behind the diagram. This matches ColaMD-extend: diagrams are dark-lines-on-paper in light themes and light-lines-on-dark in dark themes. Most visible with Elegant/Bear, which previously drew pale lines on the dark code-block background.
17
- - **Word export color rules hardened** (mirroring ColaMD-extend `docx-style.ts`) — dark themes fall back entirely to the light palette (Word is white paper; light-on-dark text would be invisible), and light themes with a dark code block (Elegant/Bear) render diagrams on a white background with the body text color instead of pale code-block text on white.
18
-
19
- ### Fixed
20
- - **Slides mode reverted to the original theme after switching** — `switchTheme` wrote `colaview.theme` to user settings while a workspace value (e.g. `.vscode/settings.json`) shadowed it, so `pushSlides` recomposed the deck CSS from the stale `getCurrentTheme()`. Theme writes now target the workspace when one is open, and theme switches pass the theme name explicitly to `pushSlides`.
21
- - **Theme-file variables were inert in the preview** — the engine writes the same variables on `body.theme-x` (specificity 0,1,1), which always beat the injected `:root` block (0,1,0), so the built-in and custom theme files' variable values never took effect in the preview (while their element rules did, producing mixed rendering). Theme CSS is now injected as `:root, body.theme-x` so it wins, and HTML exports apply the same scoping — preview and export stay identical.
22
-
23
- ### Removed
24
- - `patches/` — the CM6 `block: true` patch is no longer needed with engine 2.8.2 (`patch-package` stays wired through `postinstall` and simply finds nothing to apply).
25
-
26
- ## [0.3.4] - 2026-12-01
27
-
28
- ### Added
29
- - **幻灯片预览与放映(合入 0.2.x 分支的能力,适配 0.4.0 的 CodeMirror 6 预览层)** — 复用上游 `slides.css` 行级契约的独立渲染层(`src/slides/`),按 `<!-- slide: cover -->` 等指令分页,每页固定 1920×1080;预览面板内可在文档/幻灯片两种模式间切换。
30
- - **全屏放映** — 文档与幻灯片都交给系统浏览器放映(`src/present/`):幻灯片 ←/→ 翻页、`F` 切换全屏、点击左右半屏翻页。
31
- - **幻灯片导出** — PDF(每页 1920×1080)、独立 HTML(`.slides.html`,自带翻页与全屏)、PPTX(16:9,零依赖 OOXML)。
32
- - **中英双语的预览菜单** — 右键菜单文案由扩展宿主按 `vscode.env.language` 下发;「全屏显示」固定置顶,导出项按文档/幻灯片模式区分(文档给 Word,幻灯片给 PPTX)。
33
-
34
-
5
+ ## [0.4.1] - 2026-12-03
6
+
7
+ ### Added
8
+ - **Slide hydration for mermaid & math** — the slides render layer now emits placeholder containers for ```mermaid fences and `$$…$$` blocks, and the WebView hydrates them with mermaid SVG / KaTeX HTML (the source stays as fallback when rendering fails). The WebView bundle grows to ~11MB (mermaid + KaTeX inlined).
9
+
10
+ ### Changed
11
+ - **Slide rendering aligned with ColaMD-themes / ColaMD-extend** — slides mermaid now renders through **pele** (the same renderer ColaMD-extend uses): the SVG references `var(--pele-*)` tokens injected on the holder by DECK_CSS (same mapping as the document preview), so theme colors apply without re-rendering and the diagram stops looking like a pasted-in neutral-theme picture. The per-page fit is rewritten from `zoom` to font-size shrink (room/need × 0.98, 50% floor, 8 passes — `zoom` distorts the pages' cqw/cqh container-query sizing in presenting and printing, ported from ColaMD-themes `fitPaper`); the fit re-runs on `fonts.ready`, `load` and after mermaid/math hydration (`window.__colaviewFitSlides`), and the slides PDF exporter fits under print media before printing; blank directive-only pages are filtered during pagination (ported from ColaMD-extend `deckPages`).
12
+
13
+ ### Fixed
14
+ - **Slides preview showed mermaid blocks as source code / "Syntax error in text"** — two causes: the deck paginator split oversized ```mermaid fences by line budget, producing invalid partial sources that failed mermaid parsing (mermaid blocks are now kept whole, occupying a page on their own when oversized); and the placeholder containers were invisible until hydration (fixed by the hydration above). `$$…$$` block math is likewise rendered instead of shown raw.
15
+ - **Fullscreen presenting failed with "系统找不到指定的文件"** — `vscode.env.openExternal` with a `file:` URI goes through ShellExecute and fails on Windows. Presenting now opens the default browser via the platform shell (`start` on Windows, `open` on macOS, `xdg-open` on Linux), with `openExternal` kept as fallback.
16
+ - **Present mode / slides PDF export had no mermaid content at all** — the standalone documents now carry a CDN hydration script (mermaid + KaTeX); the PDF exporter waits for hydration (`window.__colaviewSlidesHydrated`) before printing. Offline, the source stays visible as fallback.
17
+
18
+ ## [0.4.0] - 2026-12-01
19
+
20
+ ### Added
21
+ - **Menu optimization** — the editor context menu now only offers "Show Preview" and "Show Slides Preview". The preview context menu keeps Present (Fullscreen) pinned first and scopes exports to the current mode: documents get PDF / HTML / Word, slides get PDF / PPTX. Command titles are localized via `package.nls.json` / `package.nls.zh-cn.json` (following the VS Code display language), and the preview commands ship keybindings `Ctrl+Alt+V` (preview) / `Ctrl+Alt+S` (slides preview), active only in Markdown files.
22
+ - **Grouped theme submenu** — theme groups are Built-in · Light / Built-in · Dark / Custom, and the submenu is capped at 70vh with scrolling, so long custom-theme lists no longer overflow the page.
23
+ - **DSH rendering alignment** — the 12 built-in themes are upgraded to the ColaMD 2.8 contract (seed palette, `--font-body`/`--font-mono`/`--editor-font-size`/`--editor-column-width` typography tokens, JetBrains Mono / Fira Code webfont mirroring with `fonts.gstatic.com` allowed by CSP), and the WebView injects a DSH BASE_CSS alignment layer via zero-specificity `:where()` rules: 820px column + 2.2rem gutters, 1.78 body line-height (per-theme values win), 0.01em letter-spacing, token-driven heading metrics with h1/h2 underlines removed. Cascade: engine defaults < alignment layer < theme identity rules.
24
+ - **Slide preview, presenting & exports** (merged from the 0.2.x line, released as v0.3.4 on main) — dedicated slide render layer at 1920×1080, fullscreen presenting via the system browser, slide exports to PDF / standalone `.slides.html` / PPTX, and bilingual preview menus.
25
+
26
+ ### Changed
27
+ - **Engine upgrade: ColaMD 2.8.2** — `@bytechain.cn/colamd` bumped from 2.7.11 to 2.8.2. The engine now ships the CM6 whole-line `block: true` replace-decoration fix natively (mermaid always, block math / HTML blocks when covering full lines, tables always), and its own `.cm-md-mermaid` palette is page-based. The `patch-package` patch is retired — no more node_modules patching.
28
+ - **All 12 built-in theme files synced with ColaMD-extend** (the 2.7.12+ theme contract): refined border colors in every theme, Elegant drops the dead `--table-border` variable, Dark/Midnight/Writer add strong and inline-code accent colors, Notion replaces the link-underline rules with strong/URL colors, Dracula/Gruvbox/Nord/Midnight drop blockquote text overrides, Elegant/Sepia drop blockquote horizontal padding.
29
+ - **Mermaid diagrams now render on the page, not on the code block** — preview and HTML/PDF exports derive the `--pele-*` tokens from `--bg-color`/`--text-color` (18%/28%/45% mixes, same ratios as the engine) instead of `--code-block-bg`/`--code-block-text`, and no longer paint a code-block background behind the diagram. This matches ColaMD-extend: diagrams are dark-lines-on-paper in light themes and light-lines-on-dark in dark themes. Most visible with Elegant/Bear, which previously drew pale lines on the dark code-block background.
30
+ - **Word export color rules hardened** (mirroring ColaMD-extend `docx-style.ts`) — dark themes fall back entirely to the light palette (Word is white paper; light-on-dark text would be invisible), and light themes with a dark code block (Elegant/Bear) render diagrams on a white background with the body text color instead of pale code-block text on white.
31
+
32
+ ### Fixed
33
+ - **Slides mode reverted to the original theme after switching** — `switchTheme` wrote `colaview.theme` to user settings while a workspace value (e.g. `.vscode/settings.json`) shadowed it, so `pushSlides` recomposed the deck CSS from the stale `getCurrentTheme()`. Theme writes now target the workspace when one is open, and theme switches pass the theme name explicitly to `pushSlides`.
34
+ - **Theme-file variables were inert in the preview** — the engine writes the same variables on `body.theme-x` (specificity 0,1,1), which always beat the injected `:root` block (0,1,0), so the built-in and custom theme files' variable values never took effect in the preview (while their element rules did, producing mixed rendering). Theme CSS is now injected as `:root, body.theme-x` so it wins, and HTML exports apply the same scoping — preview and export stay identical.
35
+
36
+ ### Removed
37
+ - `patches/` — the CM6 `block: true` patch is no longer needed with engine 2.8.2 (`patch-package` stays wired through `postinstall` and simply finds nothing to apply).
38
+
39
+ ## [0.3.4] - 2026-12-01
40
+
41
+ ### Added
42
+ - **幻灯片预览与放映(合入 0.2.x 分支的能力,适配 0.4.0 的 CodeMirror 6 预览层)** — 复用上游 `slides.css` 行级契约的独立渲染层(`src/slides/`),按 `<!-- slide: cover -->` 等指令分页,每页固定 1920×1080;预览面板内可在文档/幻灯片两种模式间切换。
43
+ - **全屏放映** — 文档与幻灯片都交给系统浏览器放映(`src/present/`):幻灯片 ←/→ 翻页、`F` 切换全屏、点击左右半屏翻页。
44
+ - **幻灯片导出** — PDF(每页 1920×1080)、独立 HTML(`.slides.html`,自带翻页与全屏)、PPTX(16:9,零依赖 OOXML)。
45
+ - **中英双语的预览菜单** — 右键菜单文案由扩展宿主按 `vscode.env.language` 下发;「全屏显示」固定置顶,导出项按文档/幻灯片模式区分(文档给 Word,幻灯片给 PPTX)。
46
+
47
+
35
48
  ## [0.3.2] - 2026-11-07
36
49
 
37
50
  ### Fixed
@@ -69,7 +82,7 @@ All notable changes to this project will be documented in this file.
69
82
  - Added `src/export/render-export-images.ts` — headless-Chrome (puppeteer-core) rasterizes KaTeX and Mermaid to PNG, rewriting the source Markdown to image placeholders.
70
83
  - Added direct dependencies: `docx`, `katex`, `remark-parse`, `remark-gfm`, `unified`.
71
84
  - Added **9 new built-in themes**: Sepia, Notion, Bear, Writer, Solarized Dark, Nord, Gruvbox, Dracula, Midnight — expanding from 4 to 12 total built-in themes
72
- - Added local **TypeScript type declarations** (`src/types/colamd-renderer.d.ts`) for `@bytechain.cn/colamd@2.7.9`, since the npm package does not publish `.d.ts` files
85
+ - Added local **TypeScript type declarations** (`src/types/colamd-renderer.d.ts`) for `@bytechain.cn/colamd@2.7.9`, since the npm package does not publish `.d.ts` files
73
86
  - Added `src/export/theme-style.ts` — **theme-faithful export**. Converts editor-specific theme selectors (`#editor .cm-content .cm-md-*`) into semantic HTML selectors (`h1`/`strong`/`em`/`code`/`table`/`blockquote`...) and extracts `:root` tokens plus `.cm-content` font/line-height, then injects the converted styles into PDF, HTML and Word exports so exported documents inherit the current preview theme's fonts, accent colors, table styling, blockquote padding, etc.
74
87
 
75
88
  ### Changed
@@ -93,7 +106,7 @@ All notable changes to this project will be documented in this file.
93
106
  ### Files Changed
94
107
  - `package.json` — Bump `@bytechain.cn/colamd` from `^1.5.2` to `^2.7.9`, update theme enum, change default theme; add `docx`, `katex`, `remark-parse`, `remark-gfm`, `unified`
95
108
  - `src/export/docx-exporter.ts` — New Word export converter
96
- - `src/export/render-export-images.ts` — New KaTeX/Mermaid → PNG renderer for Word export
109
+ - `src/export/render-export-images.ts` — New KaTeX/Mermaid → PNG renderer for Word export
97
110
  - `src/export/theme-style.ts` — New theme CSS → semantic HTML style converter for exports
98
111
  - `src/preview/preview-manager.ts` — Strip Electron print rule from inlined CSS, add Word export message handler
99
112
  - `src/types/colamd-renderer.d.ts` — New local type declarations
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # ColaView MD
1
+ # ColaView MD
2
2
 
3
3
  [![VS Code](https://img.shields.io/badge/VS_Code-1.85%2B-007ACC?logo=visual-studio-code)](https://code.visualstudio.com/)
4
4
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-3178C6?logo=typescript)](https://www.typescriptlang.org/)
5
5
  [![License](https://img.shields.io/badge/License-MIT-green)](LICENSE)
6
- [![Version](https://img.shields.io/badge/Version-0.4.0-orange)](package.json)
6
+ [![Version](https://img.shields.io/badge/Version-0.4.1-orange)](package.json)
7
7
 
8
8
  Rich Markdown preview & PDF/HTML/Word export for VS Code — powered by [ColaMD](https://github.com/byteuser1977/ColaMD-extend) rendering engine (CodeMirror 6 based).
9
9
 
@@ -224,15 +224,22 @@ The project uses **esbuild** for bundling — the extension side (`out/extension
224
224
 
225
225
  ## Changelog
226
226
 
227
- ### v0.4.0 (Current)
227
+ ### v0.4.1 (Current)
228
+
229
+ - **🎬 Slide Mermaid & Math Rendered** — mermaid fences are no longer split into invalid chunks ("Syntax error in text") and, together with `$$…$$` blocks, are hydrated with mermaid SVG / KaTeX in the preview (source shown as fallback); WebView bundle grows to ~11MB.
230
+ - **🐛 Present (Fullscreen) Opens the Browser Reliably** — Windows `file:` URI via `openExternal` failed ("系统找不到指定的文件"); presenting now uses the platform shell (`start` / `open` / `xdg-open`) with `openExternal` as fallback.
231
+ - **🖼️ Present Window & Slides PDF Include Mermaid** — standalone slide documents embed a CDN hydration script (mermaid + KaTeX); the slides PDF exporter waits for hydration before printing. Offline, the source stays as fallback.
232
+ - **🎯 Slide Rendering Aligned with DSH / ColaMD-extend** — slides mermaid renders through **pele** (the same renderer as ColaMD-extend) with `--pele-*` theme tokens instead of mermaid themes; per-page fit switched from `zoom` to font-size shrink (DSH `fitPaper`), re-run after hydration and before slides-PDF printing; blank directive-only pages are filtered during pagination.
233
+
234
+ ### v0.4.0
228
235
 
229
236
  - **🔧 Engine Upgrade — ColaMD 2.8.2, No More Patches** — the CM6 whole-line replace-decoration fix (`block: true`, previously a `patch-package` patch) is now native to the engine and extended to tables and HTML blocks; the `patches/` directory is gone. The engine's mermaid palette is page-based as well.
230
237
  - **🎨 Mermaid Diagrams Drawn on the Page** — preview and HTML/PDF exports derive the `--pele-*` tokens from page colors (`--bg-color`/`--text-color`, 18%/28%/45% mixes) instead of code-block colors, and no longer paint a code-block background behind diagrams — matching ColaMD-extend. Most visible with Elegant/Bear, which previously drew pale lines on the dark code block.
231
238
  - **🐛 Theme Variables Actually Apply Now** — the engine's `body.theme-x` variables (specificity 0,1,1) always beat the injected `:root` (0,1,0), so theme-file variable values were ignored in the preview. Theme CSS is now injected as `:root, body.theme-x`; exports apply the same scoping.
232
239
  - **🎨 All 12 Built-in Themes Synced with ColaMD-extend** — border colors refined in every theme; Dark/Midnight/Writer add strong/inline-code accents; Notion swaps link underlines for strong/URL colors; blockquote overrides trimmed; Elegant drops the dead `--table-border` variable.
233
- - **🎨 Word Export: Readable Colors on White Paper** — dark themes fall back entirely to the light palette; light themes with a dark code block (Elegant/Bear) draw diagrams on white with body-text color.
234
- - **🧭 Menus Simplified, Theme Submenu Grouped** — editor context menu reduced to Show Preview / Show Slides Preview; the preview menu keeps Present (fullscreen) first and scopes exports by mode (documents: PDF/HTML/Word, slides: PDF/PPTX); the theme submenu groups into Built-in · Light / Dark / Custom with a scrollable max-height.
235
- - **🎯 Rendering Aligned with the DSH Plugin** — 12 themes upgraded to the ColaMD 2.8 contract (seed palette, typography tokens, JetBrains Mono/Fira Code webfont mirroring); the WebView injects the DSH BASE_CSS layer (820px column, 1.78 line-height, 0.01em letter-spacing, token heading metrics) beneath theme identity rules.
240
+ - **🎨 Word Export: Readable Colors on White Paper** — dark themes fall back entirely to the light palette; light themes with a dark code block (Elegant/Bear) draw diagrams on white with body-text color.
241
+ - **🧭 Menus Simplified, Theme Submenu Grouped** — editor context menu reduced to Show Preview / Show Slides Preview; the preview menu keeps Present (fullscreen) first and scopes exports by mode (documents: PDF/HTML/Word, slides: PDF/PPTX); the theme submenu groups into Built-in · Light / Dark / Custom with a scrollable max-height.
242
+ - **🎯 Rendering Aligned with the DSH Plugin** — 12 themes upgraded to the ColaMD 2.8 contract (seed palette, typography tokens, JetBrains Mono/Fira Code webfont mirroring); the WebView injects the DSH BASE_CSS layer (820px column, 1.78 line-height, 0.01em letter-spacing, token heading metrics) beneath theme identity rules.
236
243
  - **🐛 Slides Theme Switch Fixed** — a workspace `colaview.theme` value shadowed the user setting, so slides decks recomposed from the stale theme after switching; theme writes now target the active settings scope and switches pass the theme name explicitly.
237
244
 
238
245
  ### v0.3.4
package/README_CN.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![VS Code](https://img.shields.io/badge/VS_Code-1.85%2B-007ACC?logo=visual-studio-code)](https://code.visualstudio.com/)
4
4
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-3178C6?logo=typescript)](https://www.typescriptlang.org/)
5
5
  [![License](https://img.shields.io/badge/License-MIT-green)](LICENSE)
6
- [![Version](https://img.shields.io/badge/Version-0.4.0-orange)](package.json)
6
+ [![Version](https://img.shields.io/badge/Version-0.4.1-orange)](package.json)
7
7
 
8
8
  VS Code 富文本 Markdown 预览与 PDF/HTML/Word 导出扩展 — 基于 [ColaMD](https://github.com/byteuser1977/ColaMD-extend) 渲染引擎(CodeMirror 6 内核)。
9
9
 
@@ -224,15 +224,22 @@ npm run package
224
224
 
225
225
  ## 更新日志
226
226
 
227
- ### v0.4.0(当前版本)
227
+ ### v0.4.1(当前版本)
228
+
229
+ - **🎬 幻灯片渲染 mermaid 与公式** — mermaid 围栏不再被切成非法分段(修复「Syntax error in text」),与 `$$…$$` 公式块一起由 WebView 水合为 mermaid SVG / KaTeX HTML(渲染失败保留源码兜底);WebView 体积增至约 11MB。
230
+ - **🐛 全屏放映可稳定打开浏览器** — Windows 上 `openExternal` 打开 `file:` URI 失败(「系统找不到指定的文件」);放映改走平台 shell(`start` / `open` / `xdg-open`),`openExternal` 作为兜底。
231
+ - **🖼️ 放映窗口与幻灯片 PDF 包含 mermaid** — 独立幻灯片文档内嵌 CDN 水合脚本(mermaid + KaTeX);幻灯片 PDF 导出等待水合完成再打印。离线时保留源码兜底。
232
+ - **🎯 幻灯片渲染对齐 DSH / ColaMD-extend** — 幻灯片 mermaid 改用 **pele** 渲染(与 ColaMD-extend 同一实现),配色走 `--pele-*` 主题令牌;逐页 fit 由 `zoom` 改为字号收缩(移植 DSH `fitPaper`),水合后与幻灯片 PDF 打印前重新 fit;分页过滤纯指令空页。
233
+
234
+ ### v0.4.0
228
235
 
229
236
  - **🔧 引擎升级 — ColaMD 2.8.2,告别补丁** — CM6 整行 replace 装饰的 `block: true` 修复(此前靠 `patch-package` 固化)已随引擎原生发布,并扩展到表格与 HTML 块;`patches/` 目录已移除。引擎自身的 mermaid 配色也已页面化。
230
237
  - **🎨 Mermaid 图画在页面上** — 预览与 HTML/PDF 导出的 `--pele-*` 令牌改由页面颜色(`--bg-color`/`--text-color`,18%/28%/45% 混合)推导,不再按代码块配色、不再给图铺代码块底色,与 ColaMD-extend 一致。Elegant/Bear 此前把浅色线条画在深色代码块上,差异最明显。
231
238
  - **🐛 主题变量真正生效** — 引擎把同一批变量写在 `body.theme-x`(特异性 0,1,1)上,永远压过注入的 `:root`(0,1,0),主题文件里的变量值在预览中一直被忽略。主题 CSS 现以 `:root, body.theme-x` 注入;导出端同样处理。
232
239
  - **🎨 12 套内置主题与 ColaMD-extend 同步** — 全部主题边框色微调;Dark/Midnight/Writer 新增加粗/行内代码强调色;Notion 以 strong/URL 颜色替代链接下划线;引用块覆盖规则精简;Elegant 移除失效的 `--table-border` 变量。
233
- - **🎨 Word 导出:白纸上的可读配色** — 深色主题整体回落浅色板;浅色主题配深色代码块(Elegant/Bear)时图表以白底 + 正文色绘制。
234
- - **🧭 菜单精简,主题子菜单分组** — 代码页右键菜单只保留 Show Preview / Show Slides Preview;预览菜单「全屏显示」置顶,导出项按模式区分(文档:PDF/HTML/Word,幻灯片:PDF/PPTX);主题子菜单按「内置亮色 / 内置暗色 / 自定义」分组并限高滚动。
235
- - **🎯 对齐 DSH 插件渲染** — 12 套主题升级到 ColaMD 2.8 契约(seed 色板、排版令牌、JetBrains Mono/Fira Code webfont 镜像);WebView 注入 DSH BASE_CSS 对齐层(820px 列宽、1.78 行高、0.01em 字距、令牌化标题度量),层级位于主题个性规则之下。
240
+ - **🎨 Word 导出:白纸上的可读配色** — 深色主题整体回落浅色板;浅色主题配深色代码块(Elegant/Bear)时图表以白底 + 正文色绘制。
241
+ - **🧭 菜单精简,主题子菜单分组** — 代码页右键菜单只保留 Show Preview / Show Slides Preview;预览菜单「全屏显示」置顶,导出项按模式区分(文档:PDF/HTML/Word,幻灯片:PDF/PPTX);主题子菜单按「内置亮色 / 内置暗色 / 自定义」分组并限高滚动。
242
+ - **🎯 对齐 DSH 插件渲染** — 12 套主题升级到 ColaMD 2.8 契约(seed 色板、排版令牌、JetBrains Mono/Fira Code webfont 镜像);WebView 注入 DSH BASE_CSS 对齐层(820px 列宽、1.78 行高、0.01em 字距、令牌化标题度量),层级位于主题个性规则之下。
236
243
  - **🐛 修复幻灯片模式切主题回退** — 工作区设置遮蔽了用户级 `colaview.theme`,切换后 deck 仍按旧主题合成;主题写入现在落到当前生效的设置层级,切换时显式传递主题名。
237
244
 
238
245
  ### v0.3.4
package/RELEASE_NOTES.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # Release Notes
2
2
 
3
+ ## v0.4.1 (2026-12-03)
4
+
5
+ ### 🎬 Slides Preview: Mermaid & Math Now Render
6
+
7
+ In the slides deck, ` ```mermaid ` fences and `$$…$$` block math were drawn as raw source lines — the slides render layer is a standalone renderer and had no widget support. Worse, the deck paginator splits oversized code blocks by line budget, so a long mermaid fence was chopped into invalid partial sources that failed mermaid parsing with "Syntax error in text".
8
+
9
+ Two fixes:
10
+
11
+ - **Mermaid fences are never split** — `splitBlock` keeps a mermaid block whole (an oversized diagram occupies a page on its own).
12
+ - **Hydration** — the renderer emits placeholder containers (source kept in a hidden node), and the WebView hydrates them after each deck render: mermaid diagrams become inline SVG (upstream `slides.css` `.mermaid-svg` contract), block math becomes KaTeX HTML. When rendering fails, the source stays visible as a fallback. The WebView bundle grows from 3.6MB to ~11MB because mermaid and KaTeX are now inlined alongside the engine.
13
+
14
+ ### 🐛 Present (Fullscreen): Browser Opens Reliably + Mermaid Included
15
+
16
+ Two presenting problems fixed:
17
+
18
+ - **"系统找不到指定的文件"** — `vscode.env.openExternal` with a `file:` URI goes through Windows ShellExecute, which frequently cannot resolve file associations for that call. Presenting now opens the file through the platform shell — `start "" "<file>"` on Windows, `open` on macOS, `xdg-open` on Linux — with `openExternal` as a fallback and the file path in the error message if both fail.
19
+ - **No mermaid content in the present window / slides PDF** — the standalone documents now embed a CDN hydration script (mermaid + KaTeX) that fills the same placeholder containers, and the slides PDF exporter waits for hydration (`window.__colaviewSlidesHydrated`) before printing. Offline, the source stays visible as a fallback.
20
+
21
+ ### 🎯 Slide Rendering Aligned with ColaMD-themes / ColaMD-extend
22
+
23
+ Three mechanisms ported from the two upstream implementations:
24
+
25
+ - **Mermaid renders through pele** (the same renderer ColaMD-extend uses via `pele/lazy`) — instead of configuring mermaid themes, the SVG references `var(--pele-*)` tokens that DECK_CSS injects on the holder (the same mapping as the document preview), so diagrams inherit the active theme exactly and stop looking like pasted-in neutral-theme pictures. The WebView hydrates with `pele/lazy` (bundled); the standalone present/PDF document loads the pele global build from CDN and renders synchronously.
26
+ - **Per-page fit via font-size shrink** (from ColaMD-themes `fitPaper`, `dsh-preview.ts`) — replaces the previous `zoom` approach: `zoom` changes the pages' cqw/cqh container-query size and is unreliable in presenting and printing. The fit shrinks the page content font by `room/need × 0.98` per pass (8 passes, 50% floor), re-runs on `fonts.ready` / `load` and is exposed as `window.__colaviewFitSlides`.
27
+ - **Refit after hydration** — mermaid and KaTeX change each page's content height, so the hydration script re-runs the fit when it finishes.
28
+ - **Blank directive-only pages filtered** (from ColaMD-extend `deckPages`, `slideshow.ts`) — slides carrying no title, lead, kicker or blocks no longer produce empty paper sheets in presenting and printing. The slides PDF exporter additionally fits under print media before printing.
29
+
3
30
  ## v0.4.0 (2026-12-01)
4
31
 
5
32
  ### 🔧 Engine Upgrade — ColaMD 2.8.2, No More Patches
@@ -28,8 +55,8 @@ Two rules mirrored from ColaMD-extend's `docx-style.ts`: dark themes fall back e
28
55
 
29
56
  The editor context menu now offers just "Show Preview" and "Show Slides Preview" — exports and presenting live in the preview panel and the Command Palette. The preview context menu keeps **Present (Fullscreen)** pinned first and scopes exports to the current mode: documents get PDF / HTML / Word, slides get PDF / PPTX.
30
57
 
31
- The theme submenu is grouped into Built-in · Light / Built-in · Dark / Custom with a scrollable max-height (70vh), so a long list of custom `.themes/` files no longer runs off the page.
32
-
58
+ The theme submenu is grouped into Built-in · Light / Built-in · Dark / Custom with a scrollable max-height (70vh), so a long list of custom `.themes/` files no longer runs off the page.
59
+
33
60
  Command titles are localized through `package.nls.json` / `package.nls.zh-cn.json` — menus and the Command Palette follow the VS Code display language. The preview commands also gain conflict-free keybindings: `Ctrl+Alt+V` opens the preview and `Ctrl+Alt+S` the slides preview, both scoped to Markdown files so Save (`Ctrl+S`) keeps working.
34
61
 
35
62
  ### 🎯 Rendering Aligned with the DSH Plugin
@@ -78,23 +105,23 @@ Mermaid diagrams looked centered in the preview but sat flush against the left e
78
105
 
79
106
  Diagram colors are derived from the theme's code-block background (`--code-block-bg`), and in ColaMD the diagram is drawn on that block background. ColaView's preview and exports instead floated the diagram on the plain page background — most visible with Elegant and Bear, whose light pages pair with dark code blocks, so the dark diagram stood on white instead of on the dark block.
80
107
 
81
- The preview (`index.html`) now paints `.cm-md-mermaid` with the code-block background (6px radius, `0.8em 1em` padding), and the export CSS (`preview-manager.ts`) applies the same block to the serialized mermaid wrapper, so preview, PDF and HTML exports match ColaMD.
82
-
83
- ### 🎨 Mermaid Colors Now Match the Preview in Every Theme
84
-
85
- With non-Elegant themes, diagrams in exported PDF/HTML used a different color set than the preview — nodes, edges and labels drifted toward pele's built-in light palette instead of the theme's own tones.
86
-
87
- **Root cause:** the export stylesheet re-declared the `--pele-*` color tokens on `div:has(> svg.pele)`, a selector that never matches the serialized `<p><svg class="pele">…</svg></p>` markup. The declarations were dead, and diagrams fell back to pele's defaults.
88
-
89
- **Fix:** exports now use the tokens that `buildExportHTML` already collects from the preview's `.cm-md-mermaid` into `:root` — those are the exact colors the preview renders with, including any explicit overrides from custom themes. The derived token block is injected only when the runtime values are missing (e.g. no rendered mermaid node at export time), so no theme-aware value is ever overwritten.
90
-
91
- ### 🧹 Removed Ineffective Settings
92
-
93
- Four entries in the settings page did nothing, and they are now gone:
94
-
95
- - `colaview.plugins.math` / `colaview.plugins.mermaid` — no-ops since v0.3.0, because math and Mermaid are built into the engine and cannot be toggled.
96
- - `colaview.pdfMethod` / `colaview.customThemesPath` — never read by the extension (PDF always uses the local Chrome pipeline, themes always come from the workspace `.themes` directory).
97
-
108
+ The preview (`index.html`) now paints `.cm-md-mermaid` with the code-block background (6px radius, `0.8em 1em` padding), and the export CSS (`preview-manager.ts`) applies the same block to the serialized mermaid wrapper, so preview, PDF and HTML exports match ColaMD.
109
+
110
+ ### 🎨 Mermaid Colors Now Match the Preview in Every Theme
111
+
112
+ With non-Elegant themes, diagrams in exported PDF/HTML used a different color set than the preview — nodes, edges and labels drifted toward pele's built-in light palette instead of the theme's own tones.
113
+
114
+ **Root cause:** the export stylesheet re-declared the `--pele-*` color tokens on `div:has(> svg.pele)`, a selector that never matches the serialized `<p><svg class="pele">…</svg></p>` markup. The declarations were dead, and diagrams fell back to pele's defaults.
115
+
116
+ **Fix:** exports now use the tokens that `buildExportHTML` already collects from the preview's `.cm-md-mermaid` into `:root` — those are the exact colors the preview renders with, including any explicit overrides from custom themes. The derived token block is injected only when the runtime values are missing (e.g. no rendered mermaid node at export time), so no theme-aware value is ever overwritten.
117
+
118
+ ### 🧹 Removed Ineffective Settings
119
+
120
+ Four entries in the settings page did nothing, and they are now gone:
121
+
122
+ - `colaview.plugins.math` / `colaview.plugins.mermaid` — no-ops since v0.3.0, because math and Mermaid are built into the engine and cannot be toggled.
123
+ - `colaview.pdfMethod` / `colaview.customThemesPath` — never read by the extension (PDF always uses the local Chrome pipeline, themes always come from the workspace `.themes` directory).
124
+
98
125
  The dead `togglePlugin` message plumbing and no-op configuration listeners were removed with them. The settings page now shows only `colaview.theme`, `colaview.autoPreview` and `colaview.scrollSync`.
99
126
 
100
127
  ### 🐛 Preview: Blocks No Longer Vanish After Viewing Their Source