vscode-colaview 0.3.3 → 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.
Files changed (43) hide show
  1. package/.release-notes-v0.4.1.md +29 -0
  2. package/.vscode/settings.json +1 -1
  3. package/CHANGELOG.md +45 -16
  4. package/README.md +318 -287
  5. package/README_CN.md +318 -287
  6. package/RELEASE_NOTES.md +80 -21
  7. package/esbuild.js +2 -0
  8. package/package.json +204 -164
  9. package/package.nls.json +14 -0
  10. package/package.nls.zh-cn.json +14 -0
  11. package/src/commands/commands.ts +48 -0
  12. package/src/docx/docx-builder.ts +241 -0
  13. package/src/export/docx-exporter.ts +961 -961
  14. package/src/export/html-exporter.ts +8 -2
  15. package/src/export/pdf-exporter.ts +69 -0
  16. package/src/export/pptx-exporter.ts +63 -0
  17. package/src/export/render-export-images.ts +386 -386
  18. package/src/export/theme-style.ts +195 -195
  19. package/src/pptx/pptx-builder.ts +249 -0
  20. package/src/pptx/zip.ts +158 -0
  21. package/src/present/presenter.ts +89 -0
  22. package/src/preview/preview-manager.ts +783 -541
  23. package/src/preview/webview/app.ts +695 -370
  24. package/src/preview/webview/index.html +167 -146
  25. package/src/slides/deck.ts +408 -0
  26. package/src/slides/markdown.ts +420 -0
  27. package/src/slides/render.ts +580 -0
  28. package/src/slides/slides.css +1082 -0
  29. package/src/themes/built-in/bear.css +64 -13
  30. package/src/themes/built-in/dark.css +64 -5
  31. package/src/themes/built-in/dracula.css +64 -5
  32. package/src/themes/built-in/elegant.css +75 -11
  33. package/src/themes/built-in/gruvbox.css +65 -6
  34. package/src/themes/built-in/light.css +62 -2
  35. package/src/themes/built-in/midnight.css +64 -6
  36. package/src/themes/built-in/nord.css +64 -5
  37. package/src/themes/built-in/notion.css +63 -11
  38. package/src/themes/built-in/sepia.css +65 -10
  39. package/src/themes/built-in/solarized-dark.css +64 -5
  40. package/src/themes/built-in/writer.css +66 -19
  41. package/src/themes/theme-manager.ts +207 -180
  42. package/src/types/colamd-renderer.d.ts +47 -47
  43. package/src/types/pele-lazy.d.ts +21 -0
@@ -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": "elegant"
3
+ "colaview.theme": "pink-script-dark"
4
4
  }
package/CHANGELOG.md CHANGED
@@ -2,20 +2,49 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
- ## [0.3.3] - 2026-11-14
6
-
7
- ### Changed
8
- - **Engine upgrade: ColaMD 2.7.13-rc.1** — `@bytechain.cn/colamd` bumped from 2.7.12 to 2.7.13-rc.1. 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.
9
- - **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.
10
- - **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 2.7.13-rc.1: 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.
11
- - **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.
12
-
13
- ### Fixed
14
- - **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.
15
-
16
- ### Removed
17
- - `patches/` — the CM6 `block: true` patch is no longer needed with engine 2.7.13-rc.1 (`patch-package` stays wired through `postinstall` and simply finds nothing to apply).
18
-
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
+
19
48
  ## [0.3.2] - 2026-11-07
20
49
 
21
50
  ### Fixed
@@ -53,7 +82,7 @@ All notable changes to this project will be documented in this file.
53
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.
54
83
  - Added direct dependencies: `docx`, `katex`, `remark-parse`, `remark-gfm`, `unified`.
55
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
56
- - 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
57
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.
58
87
 
59
88
  ### Changed
@@ -77,7 +106,7 @@ All notable changes to this project will be documented in this file.
77
106
  ### Files Changed
78
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`
79
108
  - `src/export/docx-exporter.ts` — New Word export converter
80
- - `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
81
110
  - `src/export/theme-style.ts` — New theme CSS → semantic HTML style converter for exports
82
111
  - `src/preview/preview-manager.ts` — Strip Electron print rule from inlined CSS, add Word export message handler
83
112
  - `src/types/colamd-renderer.d.ts` — New local type declarations