vscode-colaview 0.3.0 → 0.3.3
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.
- package/.vscode/settings.json +1 -4
- package/CHANGELOG.md +43 -0
- package/README.md +31 -9
- package/README_CN.md +31 -9
- package/RELEASE_NOTES.md +115 -0
- package/esbuild.js +6 -0
- package/package.json +164 -186
- package/src/export/docx-exporter.ts +43 -4
- package/src/export/render-export-images.ts +186 -5
- package/src/export/theme-style.ts +77 -16
- package/src/extension.ts +0 -11
- package/src/preview/preview-manager.ts +64 -21
- package/src/preview/webview/app.ts +11 -12
- package/src/preview/webview/index.html +19 -0
- package/src/themes/built-in/bear.css +1 -1
- package/src/themes/built-in/dark.css +9 -1
- package/src/themes/built-in/dracula.css +1 -5
- package/src/themes/built-in/elegant.css +5 -12
- package/src/themes/built-in/gruvbox.css +1 -5
- package/src/themes/built-in/light.css +1 -1
- package/src/themes/built-in/midnight.css +7 -3
- package/src/themes/built-in/nord.css +1 -5
- package/src/themes/built-in/notion.css +9 -11
- package/src/themes/built-in/sepia.css +3 -6
- package/src/themes/built-in/solarized-dark.css +1 -1
- package/src/themes/built-in/writer.css +9 -1
package/.vscode/settings.json
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +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
|
+
|
|
19
|
+
## [0.3.2] - 2026-11-07
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
- Fixed **PDF/HTML export failing with `md is not defined`** — the export CSS injected by `patchExportHTML` lives in a JS template literal, and a CSS comment inside it contained unescaped backticks (`` `.cm-md-mermaid` ``). The first backtick closed the template literal early, so the rest of the comment was parsed as JavaScript (`…template.cm - md - mermaid…`), throwing `ReferenceError: md is not defined` at export time — surfacing to the user as "PDF export failed: md is not defined". The backticks are now escaped, so the comment stays a comment. (Only the packaged/minified build hit it in a confusing way; `tsc` flags it as `Cannot find name 'md'`.)
|
|
23
|
+
- Fixed **Mermaid diagrams left-aligned in PDF/HTML exports** — the engine serializes mermaid blocks as class-stripped `<p><svg class="pele pele-…">…</svg></p>`, so the previous export rule (`div:has(> svg.pele)`) never matched and its `text-align: center` never applied: diagrams were centered in the preview but flush-left on paper. Centering now lives on `svg.pele` itself (`display: block; margin: 0 auto`), independent of the wrapper element.
|
|
24
|
+
- Fixed **Mermaid diagram background not matching ColaMD-extend** — diagram colors are derived from the theme's code-block background (`--code-block-bg`), and in ColaMD the diagram sits on that block background. ColaView preview and export rendered it on the plain page background instead. Both now paint the same block behind the diagram (code-block background, 6px radius, `0.8em 1em` padding), so Elegant/Bear (light themes with dark code blocks) match ColaMD's dark diagram block.
|
|
25
|
+
- Fixed **Mermaid diagram colors drifting from the preview in PDF/HTML exports for non-Elegant themes** — exports re-derived the `--pele-*` tokens on a wrapper selector that never matched the serialized `<p><svg class="pele">` markup, so diagrams fell back to pele's built-in light palette (dark nodes/edges on dark themes, light gray surfaces where the theme wanted the code-block tone). Exports now use the runtime `--pele-*` values that `buildExportHTML` collects from the preview's `.cm-md-mermaid` into `:root`; a token block using the engine's own derivation is injected only when those runtime values are absent (e.g. no rendered mermaid node at export time).
|
|
26
|
+
- Fixed **preview blocks vanishing after viewing their source** — the engine (ColaMD 2.7.11) rendered mermaid diagrams and multi-line block math as *inline* replace decorations spanning multiple lines; CodeMirror 6 only honors such decorations on the initial build, so after clicking into a diagram/formula (source revealed) and clicking away, the widget was never recreated and the whole block disappeared. Fixed with `block: true` for whole-line-covering replace decorations (mermaid always, block math when covering full lines). Patched via `patch-package` (`patches/`); the same fix is applied upstream in ColaMD-extend `live-preview.ts`.
|
|
27
|
+
- Fixed **Word export producing broken images** — puppeteer v25's `screenshot()` returns a `Uint8Array`; calling `.toString('base64')` on a TypedArray yields a comma-joined decimal byte string instead of base64, so every formula/diagram image embedded in the `.docx` was corrupt and exported as placeholder text. Screenshots are now converted with `Buffer.from()`.
|
|
28
|
+
- Fixed **Word-exported formulas rendering with wrong glyphs** — the formula screenshot page inlines `katex.min.css`, but its relative `url(fonts/*.woff2)` references can't resolve on a `page.setContent` (about:blank) page, so KaTeX fell back to system fonts. KaTeX fonts are now inlined as base64 data URIs at render time (and the font files are copied to `out/assets/katex-fonts/` by the build).
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
- **Export HTML/PDF now carries the engine's theme-scoped body rules** — the per-theme accent rules (`body.theme-x .cm-content .cm-md-strong`, inline code colors, heading colors, table header styling...) that live in the engine's `colamd.css` are extracted and translated to semantic selectors (`body.theme-x .colamd-document strong` ...) and injected into exports, so exported documents match the preview and ColaMD-extend rendering for all 12 built-in themes.
|
|
32
|
+
- `src/preview/webview/index.html` gives `.cm-md-mermaid` the code-block background in the preview; `src/preview/preview-manager.ts` applies the same block, plus the centering rule, to the serialized mermaid wrapper in HTML/PDF exports, and no longer redeclares `--pele-*` on the exported SVG.
|
|
33
|
+
|
|
34
|
+
### Removed
|
|
35
|
+
- Ineffective settings removed from the extension manifest: `colaview.plugins.math` and `colaview.plugins.mermaid` (no-ops since v0.3.0 — math and Mermaid are built into the engine), `colaview.pdfMethod` and `colaview.customThemesPath` (never read by the extension). The dead `togglePlugin` message plumbing and the no-op `onDidChangeConfiguration` listeners they fed are gone too. Remaining settings: `colaview.theme`, `colaview.autoPreview`, `colaview.scrollSync`.
|
|
36
|
+
|
|
37
|
+
## [0.3.1] - 2026-11-07
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
- **Engine upgrade: ColaMD 2.7.11** — `@bytechain.cn/colamd` bumped from 2.7.9 to 2.7.11, bringing upstream fixes: inline math rendered as formulas inside table cells, list indent handled purely by CSS (source spaces hidden), cursor misalignment with multi-digit ordered lists, block-level widget layout (no margin placeholders, diagram height re-measured after async render), and Enter/Backspace restored to official CodeMirror commands.
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
- Fixed **Word-exported code blocks breaking on Windows** — ported ColaMD-extend #202 fixes: code font now written into all four `w:rFonts` slots with a platform-appropriate mono font (Menlo/Consolas/DejaVu Sans Mono) plus a dedicated CJK `eastAsia` font (so Chinese comments no longer garble); explicit left alignment prevents justify-stretched lines; code blocks get a light border and `noProof` (no spell-check squiggles on identifiers, inline code included).
|
|
44
|
+
- Fixed **Word-exported Mermaid diagrams not following the preview theme** — diagram colors are now derived from the current theme's tokens (surface/border mixes at 18%/28%/45%, same ratios as the editor), with dark themes falling back to the light palette. Previously hardcoded to mermaid's `neutral` theme.
|
|
45
|
+
- Fixed **inline formulas wrapping in Word export** — the measurement viewport was widened to 2000px so wider formulas are not line-wrapped by KaTeX before capture (mirrors ColaMD-extend `MEASURE_WIDTH`).
|
|
46
|
+
- Fixed **exported HTML/PDF diagrams losing theme colors and carrying zoom controls** — injected export CSS now matches serialized `<div><svg class="pele pele-…">` wrappers to restore the `--pele-*` variable mapping (mirrors ColaMD-extend a25b3f8), and hides the editor-only `.pele-zoom` controls that Chromium print cannot remove via scripts (mirrors `print-layout.ts`).
|
|
47
|
+
|
|
5
48
|
## [0.3.0] - 2026-11-06
|
|
6
49
|
|
|
7
50
|
### Added
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://code.visualstudio.com/)
|
|
4
4
|
[](https://www.typescriptlang.org/)
|
|
5
5
|
[](LICENSE)
|
|
6
|
-
[](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
|
|
|
@@ -105,15 +105,9 @@ Import custom CSS: `Ctrl+Shift+P` → "ColaView MD: Import Custom Theme..." or v
|
|
|
105
105
|
| Setting | Type | Default | Description |
|
|
106
106
|
|---------|------|---------|-------------|
|
|
107
107
|
| `colaview.theme` | `string` | `"elegant"` | Preview theme: `light`, `dark`, `elegant`, `sepia`, `notion`, `bear`, `writer`, `solarized-dark`, `nord`, `gruvbox`, `dracula`, `midnight`, or any custom theme name |
|
|
108
|
-
| `colaview.plugins.math` | `boolean` | `true` | *(Deprecated, always-on since v0.3.0)* KaTeX is built into the ColaMD engine and cannot be disabled |
|
|
109
|
-
| `colaview.plugins.mermaid` | `boolean` | `true` | *(Deprecated, always-on since v0.3.0)* Mermaid is built into the ColaMD engine and cannot be disabled |
|
|
110
|
-
| `colaview.pdfMethod` | `string` | `"puppeteer"` | PDF engine: `puppeteer` or `webviewPrint` |
|
|
111
108
|
| `colaview.autoPreview` | `boolean` | `false` | Auto-open preview for `.md` files |
|
|
112
|
-
| `colaview.customThemesPath` | `string` | `""` | Directory for custom theme CSS files |
|
|
113
109
|
| `colaview.scrollSync` | `boolean` | `false` | **Experimental** — Enable scroll sync between editor and preview |
|
|
114
110
|
|
|
115
|
-
> **Note on plugin settings:** Since v0.3.0, math and mermaid rendering are integral parts of the CodeMirror 6 based ColaMD engine and are always enabled. The `colaview.plugins.math` and `colaview.plugins.mermaid` settings are retained for backward compatibility but no longer have any effect.
|
|
116
|
-
|
|
117
111
|
## Supported Syntax
|
|
118
112
|
|
|
119
113
|
**Standard Markdown** — Headings, bold, italic, strikethrough, code blocks, links, images, lists, blockquotes
|
|
@@ -212,11 +206,39 @@ npm run package
|
|
|
212
206
|
|
|
213
207
|
### Build System
|
|
214
208
|
|
|
215
|
-
The project uses **esbuild** for bundling — the extension side (`out/extension.js`) is a small CJS bundle with only VS Code API imports. The WebView side (`out/preview/webview/app.js`) is an IIFE bundle containing the full ColaMD 2.7.
|
|
209
|
+
The project uses **esbuild** for bundling — the extension side (`out/extension.js`) is a small CJS bundle with only VS Code API imports. The WebView side (`out/preview/webview/app.js`) is an IIFE bundle containing the full ColaMD 2.7.13-rc.1 rendering engine (CodeMirror 6 + Mermaid + KaTeX) — approximately 3.5MB unminified, gzip ~400KB. Resource files (CSS, WebView HTML, KaTeX stylesheet, Mermaid script) are copied to `out/` during build so they survive `.vscodeignore` packaging.
|
|
216
210
|
|
|
217
211
|
## Changelog
|
|
218
212
|
|
|
219
|
-
### v0.3.
|
|
213
|
+
### v0.3.3 (Current)
|
|
214
|
+
|
|
215
|
+
- **🔧 Engine Upgrade — ColaMD 2.7.13-rc.1, 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.
|
|
216
|
+
- **🎨 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 2.7.13-rc.1. Most visible with Elegant/Bear, which previously drew pale lines on the dark code block.
|
|
217
|
+
- **🐛 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.
|
|
218
|
+
- **🎨 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.
|
|
219
|
+
- **🎨 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.
|
|
220
|
+
|
|
221
|
+
### v0.3.2
|
|
222
|
+
|
|
223
|
+
- **🐛 PDF/HTML Export Fixed (`md is not defined`)** — exporting failed with "PDF export failed: md is not defined": a CSS comment inside the export stylesheet template literal contained unescaped backticks, which closed the literal early and made the parser treat part of the comment as JavaScript. Backticks are now escaped.
|
|
224
|
+
- **🐛 PDF/HTML Mermaid Diagrams Centered** — the engine serializes mermaid blocks as class-stripped `<p><svg class="pele pele-…">…</svg></p>`, so the previous `div:has(> svg.pele)` export rule never matched and diagrams were left-aligned on paper. Centering now applies to `svg.pele` itself (`display: block; margin: 0 auto`), independent of the wrapper element.
|
|
225
|
+
- **🎨 Mermaid Diagram Background Matches ColaMD-extend** — diagrams are now drawn on the code-block background (`--code-block-bg`, 6px radius, `0.8em 1em` padding) in both the preview and HTML/PDF exports, matching ColaMD instead of floating on the plain page background (most visible with Elegant/Bear, whose dark code blocks sit on light pages).
|
|
226
|
+
- **🎨 Mermaid Colors Match the Preview in Every Theme** — non-Elegant themes exported diagrams with different node/edge/label colors because the export re-declared `--pele-*` on a `div:has(> svg.pele)` selector that never matched the serialized `<p><svg class="pele">` markup, leaving pele's built-in palette in effect. Exports now use the runtime values collected from the preview into `:root`, with the derived token block injected only when those values are absent.
|
|
227
|
+
- **🧹 Removed Ineffective Settings** — `colaview.plugins.math` / `colaview.plugins.mermaid` (no-ops since v0.3.0) and `colaview.pdfMethod` / `colaview.customThemesPath` (never read) are gone; remaining settings: `colaview.theme`, `colaview.autoPreview`, `colaview.scrollSync`.
|
|
228
|
+
- **🐛 Preview Blocks No Longer Vanish After Source View** — Fixed an engine bug (multi-line inline replace decorations are ignored by CodeMirror 6 on incremental updates): clicking a mermaid diagram / multi-line block formula to view its source, then clicking away, no longer makes the whole block disappear. Patched via `patch-package`; fix also applied upstream in ColaMD-extend.
|
|
229
|
+
- **🐛 Word Export Images Fixed** — puppeteer v25 screenshot returns `Uint8Array`; the previous base64 conversion produced corrupt data so formulas/diagrams appeared as placeholder text in the `.docx`. Now converted with `Buffer.from()`.
|
|
230
|
+
- **🐛 Word Formula Glyphs Fixed** — KaTeX fonts are inlined as base64 into the screenshot page (the relative `fonts/*.woff2` URLs could not resolve), so formulas render with proper KaTeX fonts.
|
|
231
|
+
- **🎨 Exports Match Preview Colors** — The engine's theme-scoped body rules (bold/inline-code/heading accent colors per theme) are translated to semantic selectors and injected into HTML/PDF exports for all 12 themes.
|
|
232
|
+
|
|
233
|
+
### v0.3.1
|
|
234
|
+
|
|
235
|
+
- **🔧 Engine Upgrade — ColaMD 2.7.11** — Inline math in table cells, CSS-driven list indent, block widget layout fixes, official CM6 typing commands.
|
|
236
|
+
- **🎨 Word Mermaid Diagrams Follow Theme** — Diagram colors derived from the current preview theme's tokens (dark themes fall back to light), instead of mermaid's hardcoded `neutral`.
|
|
237
|
+
- **🐛 Windows Word Code Blocks Fixed** — Platform mono font in all four `w:rFonts` slots + CJK `eastAsia` font, explicit left alignment, light border, `noProof` (port of ColaMD-extend #202).
|
|
238
|
+
- **🐛 Inline Formulas No Longer Wrap** — Wider (2000px) measurement viewport before capture.
|
|
239
|
+
- **🐛 HTML/PDF Diagrams Follow Theme + No Zoom Controls** — Export CSS matches serialized pele SVG wrappers to restore `--pele-*` variables; editor-only zoom controls hidden on paper.
|
|
240
|
+
|
|
241
|
+
### v0.3.0
|
|
220
242
|
|
|
221
243
|
- **📝 Word Export (`.docx`)** — Ported from ColaMD-extend. High-fidelity Word export with headings, paragraphs, inline styles, code blocks, lists, tables, blockquotes, horizontal rules, images, footnotes, and rasterized KaTeX/Mermaid diagrams.
|
|
222
244
|
- **🎨 Theme-Faithful Export** — New `theme-style.ts` conversion layer maps editor-only theme selectors (`#editor .cm-content .cm-md-*`) to semantic HTML selectors, so PDF/HTML/Word exports inherit the current preview theme's fonts, accent colors, table header styling and blockquote padding.
|
package/README_CN.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://code.visualstudio.com/)
|
|
4
4
|
[](https://www.typescriptlang.org/)
|
|
5
5
|
[](LICENSE)
|
|
6
|
-
[](package.json)
|
|
7
7
|
|
|
8
8
|
VS Code 富文本 Markdown 预览与 PDF/HTML/Word 导出扩展 — 基于 [ColaMD](https://github.com/byteuser1977/ColaMD-extend) 渲染引擎(CodeMirror 6 内核)。
|
|
9
9
|
|
|
@@ -105,15 +105,9 @@ my-project/
|
|
|
105
105
|
| 配置 | 类型 | 默认值 | 说明 |
|
|
106
106
|
|------|------|--------|------|
|
|
107
107
|
| `colaview.theme` | `string` | `"elegant"` | 预览主题:`light`、`dark`、`elegant`、`sepia`、`notion`、`bear`、`writer`、`solarized-dark`、`nord`、`gruvbox`、`dracula`、`midnight` 或任意自定义主题名 |
|
|
108
|
-
| `colaview.plugins.math` | `boolean` | `true` | *(已废弃,v0.3.0 起默认启用)* KaTeX 已内置于 ColaMD 引擎,无法单独关闭 |
|
|
109
|
-
| `colaview.plugins.mermaid` | `boolean` | `true` | *(已废弃,v0.3.0 起默认启用)* Mermaid 已内置于 ColaMD 引擎,无法单独关闭 |
|
|
110
|
-
| `colaview.pdfMethod` | `string` | `"puppeteer"` | PDF 引擎:`puppeteer` 或 `webviewPrint` |
|
|
111
108
|
| `colaview.autoPreview` | `boolean` | `false` | 打开 `.md` 文件时自动显示预览 |
|
|
112
|
-
| `colaview.customThemesPath` | `string` | `""` | 自定义主题 CSS 目录路径 |
|
|
113
109
|
| `colaview.scrollSync` | `boolean` | `false` | **实验性功能** — 启用编辑器与预览面板的滚动同步 |
|
|
114
110
|
|
|
115
|
-
> **关于插件开关:** v0.3.0 起,数学公式和 Mermaid 图表是 CodeMirror 6 版 ColaMD 引擎的内置功能,始终启用。`colaview.plugins.math` 和 `colaview.plugins.mermaid` 配置项为向后兼容保留,但已不再生效。
|
|
116
|
-
|
|
117
111
|
## 支持的语法
|
|
118
112
|
|
|
119
113
|
**标准 Markdown** — 标题、粗体、斜体、删除线、代码块、链接、图片、列表、引用
|
|
@@ -212,11 +206,39 @@ npm run package
|
|
|
212
206
|
|
|
213
207
|
### 构建系统
|
|
214
208
|
|
|
215
|
-
项目使用 **esbuild** 打包 — 扩展端(`out/extension.js`)是一个仅依赖 VS Code API 的小型 CJS bundle。WebView 端(`out/preview/webview/app.js`)是包含完整 ColaMD 2.7.
|
|
209
|
+
项目使用 **esbuild** 打包 — 扩展端(`out/extension.js`)是一个仅依赖 VS Code API 的小型 CJS bundle。WebView 端(`out/preview/webview/app.js`)是包含完整 ColaMD 2.7.13-rc.1 渲染引擎(CodeMirror 6 + Mermaid + KaTeX)的 IIFE bundle — 未压缩约 3.5MB,gzip 后约 400KB。构建时自动复制资源文件(CSS、WebView HTML、KaTeX 样式表、Mermaid 脚本)到 `out/` 目录,确保打包安装后功能正常。
|
|
216
210
|
|
|
217
211
|
## 更新日志
|
|
218
212
|
|
|
219
|
-
### v0.3.
|
|
213
|
+
### v0.3.3(当前版本)
|
|
214
|
+
|
|
215
|
+
- **🔧 引擎升级 — ColaMD 2.7.13-rc.1,告别补丁** — CM6 整行 replace 装饰的 `block: true` 修复(此前靠 `patch-package` 固化)已随引擎原生发布,并扩展到表格与 HTML 块;`patches/` 目录已移除。引擎自身的 mermaid 配色也已页面化。
|
|
216
|
+
- **🎨 Mermaid 图画在页面上** — 预览与 HTML/PDF 导出的 `--pele-*` 令牌改由页面颜色(`--bg-color`/`--text-color`,18%/28%/45% 混合)推导,不再按代码块配色、不再给图铺代码块底色,与 ColaMD-extend 2.7.13-rc.1 一致。Elegant/Bear 此前把浅色线条画在深色代码块上,差异最明显。
|
|
217
|
+
- **🐛 主题变量真正生效** — 引擎把同一批变量写在 `body.theme-x`(特异性 0,1,1)上,永远压过注入的 `:root`(0,1,0),主题文件里的变量值在预览中一直被忽略。主题 CSS 现以 `:root, body.theme-x` 注入;导出端同样处理。
|
|
218
|
+
- **🎨 12 套内置主题与 ColaMD-extend 同步** — 全部主题边框色微调;Dark/Midnight/Writer 新增加粗/行内代码强调色;Notion 以 strong/URL 颜色替代链接下划线;引用块覆盖规则精简;Elegant 移除失效的 `--table-border` 变量。
|
|
219
|
+
- **🎨 Word 导出:白纸上的可读配色** — 深色主题整体回落浅色板;浅色主题配深色代码块(Elegant/Bear)时图表以白底 + 正文色绘制。
|
|
220
|
+
|
|
221
|
+
### v0.3.2
|
|
222
|
+
|
|
223
|
+
- **🐛 修复 PDF/HTML 导出失败(`md is not defined`)** — 导出时报 "PDF export failed: md is not defined":导出样式模板字符串里的一段 CSS 注释含未转义的反引号,提前闭合了模板字面量,剩余注释被当成 JavaScript 解析。现已转义反引号,注释保持为注释。
|
|
224
|
+
- **🐛 修复 PDF/HTML 导出中 Mermaid 图未居中** — 引擎把 mermaid 块序列化成不带类名的 `<p><svg class="pele pele-…">…</svg></p>`,此前的 `div:has(> svg.pele)` 导出规则匹配不到,居中在纸面上失效。现把居中规则落到 `svg.pele` 自身(`display: block; margin: 0 auto`),与父级是 `<p>` 还是 `<div>` 无关。
|
|
225
|
+
- **🎨 Mermaid 图背景色与 ColaMD-extend 一致** — 图表配色按主题的代码块底色(`--code-block-bg`)推导,ColaMD 中图就画在这块底色上。预览与 HTML/PDF 导出现在同样给图加代码块底色(6px 圆角、`0.8em 1em` 内边距),不再浮在浅色页面上;Elegant/Bear(浅色页面配深色代码块)此前差异最明显。
|
|
226
|
+
- **🎨 修复非 Elegant 主题导出后 Mermaid 图内配色与预览不一致** — 导出端此前在 `div:has(> svg.pele)` 上重新声明 `--pele-*`,而引擎序列化出来的是 `<p><svg class="pele">` 结构,选择器从不命中,图只能落回 pele 内置浅色配色(深色主题下节点/连线/文字明显偏色)。现改为直接使用 `buildExportHTML` 从预览 `.cm-md-mermaid` 收集进 `:root` 的运行时令牌;仅在确实缺失时才按引擎同一公式补一份兜底。
|
|
227
|
+
- **🧹 移除无效配置项** — `colaview.plugins.math` / `colaview.plugins.mermaid`(自 v0.3.0 起无实际作用)与 `colaview.pdfMethod` / `colaview.customThemesPath`(从未被读取)已移除;保留 `colaview.theme`、`colaview.autoPreview`、`colaview.scrollSync`。
|
|
228
|
+
- **🐛 修复预览中块级内容「看源码后消失」** — 引擎 bug(跨行 inline replace 装饰在 CM6 增量更新时不会被重建):点击 mermaid 图 / 多行块公式查看源码后再点走,整块内容不再消失。通过 `patch-package` 固化补丁,修复同步提交到 ColaMD-extend 上游。
|
|
229
|
+
- **🐛 修复 Word 导出图片损坏** — puppeteer v25 截图返回 `Uint8Array`,此前的 base64 转换产出的是逗号十进制串,`.docx` 里公式/图表全部变成占位文本。现改用 `Buffer.from()` 转换。
|
|
230
|
+
- **🐛 修复 Word 公式字形错乱** — KaTeX 字体以 base64 内联进截图页(相对 `fonts/*.woff2` 路径无法解析),公式以正确的 KaTeX 字体渲染。
|
|
231
|
+
- **🎨 导出正文颜色与预览一致** — 引擎 colamd.css 中各主题的正文差异化规则(加粗/行内代码/标题配色)被翻译为语义化选择器并注入 HTML/PDF 导出,覆盖全部 12 套主题。
|
|
232
|
+
|
|
233
|
+
### v0.3.1
|
|
234
|
+
|
|
235
|
+
- **🔧 引擎升级 — ColaMD 2.7.11** — 表格单元格内的行内公式成图、列表缩进纯 CSS 分派、块级 widget 布局修复、回车/退格回归 CM6 官方命令。
|
|
236
|
+
- **🎨 Word 导出 Mermaid 配色跟随主题** — 图表配色从当前预览主题令牌推导(深色主题回落浅色),替代原来写死的 mermaid `neutral`。
|
|
237
|
+
- **🐛 修复 Windows 下 Word 代码块乱码** — 等宽字体写入全部四个 `w:rFonts` 槽位 + 单独的 CJK `eastAsia` 中文字体、显式左对齐、浅色边框、`noProof`(移植 ColaMD-extend #202)。
|
|
238
|
+
- **🐛 修复行内公式在 Word 导出中被折行** — 截图前测量视口加宽到 2000px。
|
|
239
|
+
- **🐛 HTML/PDF 导出图表配色跟随主题 + 不再带缩放控件** — 导出 CSS 命中序列化后的 pele SVG 包裹结构恢复 `--pele-*` 变量映射;纸面上隐藏编辑器专属缩放控件。
|
|
240
|
+
|
|
241
|
+
### v0.3.0
|
|
220
242
|
|
|
221
243
|
- **📝 Word 导出(`.docx`)** — 从 ColaMD-extend 移植。高保真 Word 导出,支持标题、段落、行内样式、代码块、列表、表格、引用块、水平线、图片、脚注,以及 KaTeX/Mermaid 转图。
|
|
222
244
|
- **🎨 导出保留主题样式** — 新增 `theme-style.ts` 转换模块,将编辑器专属选择器(`#editor .cm-content .cm-md-*`)映射为语义化 HTML 选择器,PDF/HTML/Word 导出继承当前预览主题的字体、强调色、表格表头样式和引用块内边距。
|
package/RELEASE_NOTES.md
CHANGED
|
@@ -1,5 +1,120 @@
|
|
|
1
1
|
# Release Notes
|
|
2
2
|
|
|
3
|
+
## v0.3.3 (2026-11-14)
|
|
4
|
+
|
|
5
|
+
### 🔧 Engine Upgrade — ColaMD 2.7.13-rc.1, No More Patches
|
|
6
|
+
|
|
7
|
+
`@bytechain.cn/colamd` bumped from 2.7.12 to 2.7.13-rc.1. The CM6 multi-line replace-decoration fix (`block: true` for whole-line replace decorations — previously carried as a `patch-package` patch) is now native to the engine, extended upstream to tables and HTML blocks as well. The `patches/` directory is gone; `patch-package` remains wired through `postinstall` but finds nothing to apply.
|
|
8
|
+
|
|
9
|
+
### 🎨 Mermaid Diagrams Drawn on the Page
|
|
10
|
+
|
|
11
|
+
Diagrams used to sit on the theme's code-block background with colors derived from `--code-block-bg`/`--code-block-text`. But a mermaid fence is a whole-block replacement — there is no code block behind it — so Elegant and Bear (light pages with dark code blocks) rendered pale lines on the dark block, washed out against the page.
|
|
12
|
+
|
|
13
|
+
Preview and HTML/PDF exports now derive the `--pele-*` tokens from the page colors (`--bg-color`/`--text-color`, mixed at 18%/28%/45% — the same ratios as the engine) and no longer paint a background behind the diagram, matching ColaMD-extend 2.7.13-rc.1. Light themes get dark lines on paper; dark themes get light lines on the dark page.
|
|
14
|
+
|
|
15
|
+
### 🐛 Theme Variables Actually Apply Now
|
|
16
|
+
|
|
17
|
+
The built-in and custom theme files declare their variables on `:root`, but the engine writes the same variables on `body.theme-x` — higher specificity — so the theme files' values were silently ignored in the preview (their element rules did apply, giving a mix of old variables and new rules). Theme CSS is now injected as `:root, body.theme-x` so the file wins, and exports apply the same scoping.
|
|
18
|
+
|
|
19
|
+
### 🎨 All 12 Built-in Themes Synced with ColaMD-extend
|
|
20
|
+
|
|
21
|
+
The 12 theme files are byte-identical with ColaMD-extend's (the 2.7.12+ theme contract): refined border colors everywhere, Dark/Midnight/Writer gain strong and inline-code accent colors, Notion swaps link underlines for strong/URL colors, blockquote overrides trimmed (Dracula/Gruvbox/Nord/Midnight), Elegant drops the dead `--table-border` variable and horizontal blockquote padding (as do Sepia).
|
|
22
|
+
|
|
23
|
+
### 🎨 Word Export: Readable Colors on White Paper
|
|
24
|
+
|
|
25
|
+
Two rules mirrored from ColaMD-extend's `docx-style.ts`: dark themes fall back entirely to the light palette (light text on white paper is invisible), and light themes with a dark code block (Elegant/Bear) draw diagrams on white with the body text color instead of pale code-block text.
|
|
26
|
+
|
|
27
|
+
## v0.3.2 (2026-11-07)
|
|
28
|
+
|
|
29
|
+
### 🐛 PDF/HTML Export Fixed: `md is not defined`
|
|
30
|
+
|
|
31
|
+
Exporting to PDF (or HTML) failed with "PDF export failed: md is not defined".
|
|
32
|
+
|
|
33
|
+
**Root cause:** the export CSS injected by `patchExportHTML` is built as a JavaScript template literal, and a CSS comment inside it contained unescaped backticks (`` `.cm-md-mermaid` ``). The first backtick closed the template literal early, so the rest of the comment was parsed as JavaScript (`…template.cm - md - mermaid…`), throwing `ReferenceError: md is not defined` the moment an export ran.
|
|
34
|
+
|
|
35
|
+
**Fix:** the backticks in the comment are escaped. The comment stays a comment and the export CSS is emitted verbatim.
|
|
36
|
+
|
|
37
|
+
### 🐛 PDF/HTML Export: Mermaid Diagrams Centered Again
|
|
38
|
+
|
|
39
|
+
Mermaid diagrams looked centered in the preview but sat flush against the left edge on paper.
|
|
40
|
+
|
|
41
|
+
**Root cause:** the engine serializes a mermaid block as a class-stripped `<p><svg class="pele pele-…">…</svg></p>`. The export CSS added in v0.3.1 targeted `div:has(> svg.pele)`, which can never match a `<p>` wrapper, so its `text-align: center` was inert.
|
|
42
|
+
|
|
43
|
+
**Fix:** centering now lives on `svg.pele` itself (`display: block; margin: 0 auto`), so it works regardless of whether the serializer emits a `<p>` or a `<div>`.
|
|
44
|
+
|
|
45
|
+
### 🎨 Mermaid Diagram Background Matches ColaMD-extend
|
|
46
|
+
|
|
47
|
+
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.
|
|
48
|
+
|
|
49
|
+
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.
|
|
50
|
+
|
|
51
|
+
### 🎨 Mermaid Colors Now Match the Preview in Every Theme
|
|
52
|
+
|
|
53
|
+
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.
|
|
54
|
+
|
|
55
|
+
**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.
|
|
56
|
+
|
|
57
|
+
**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.
|
|
58
|
+
|
|
59
|
+
### 🧹 Removed Ineffective Settings
|
|
60
|
+
|
|
61
|
+
Four entries in the settings page did nothing, and they are now gone:
|
|
62
|
+
|
|
63
|
+
- `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.
|
|
64
|
+
- `colaview.pdfMethod` / `colaview.customThemesPath` — never read by the extension (PDF always uses the local Chrome pipeline, themes always come from the workspace `.themes` directory).
|
|
65
|
+
|
|
66
|
+
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`.
|
|
67
|
+
|
|
68
|
+
### 🐛 Preview: Blocks No Longer Vanish After Viewing Their Source
|
|
69
|
+
|
|
70
|
+
Clicking a rendered mermaid diagram or block formula reveals its source (per ColaMD-extend's block-widget rule); clicking away is supposed to re-render it — but the whole block silently disappeared instead.
|
|
71
|
+
|
|
72
|
+
**Root cause:** the engine rendered mermaid diagrams and multi-line block math as *inline* replace decorations spanning multiple lines. CodeMirror 6 only honors such decorations when the tree is built from scratch (initial load); on incremental updates the widget is never recreated — the decoration comparison even reports the change, but the render layer skips it, leaving an empty block.
|
|
73
|
+
|
|
74
|
+
**Fix:** whole-line-covering replace decorations now use `block: true` (mermaid always; block math when the range covers full lines). Verified in a headless browser: mermaid / multi-line math / tables all reveal source and restore correctly. Applied via `patch-package` (`patches/@bytechain.cn+colamd+2.7.11.patch`, wired through `postinstall`) and committed upstream to ColaMD-extend's `live-preview.ts`.
|
|
75
|
+
|
|
76
|
+
### 🐛 Word Export: Formulas & Diagrams Now Render Correctly
|
|
77
|
+
|
|
78
|
+
Two independent bugs made every formula/diagram image in the exported `.docx` broken:
|
|
79
|
+
|
|
80
|
+
1. **Corrupt image data** — puppeteer v25's `screenshot()` returns a `Uint8Array`; `Uint8Array.toString('base64')` ignores the argument and emits a comma-joined decimal byte string (`137,80,78,…`), which is not base64. The `.docx` image parser rejected it, so formulas/diagrams appeared as `[公式 1]` placeholder text. Screenshots are now converted with `Buffer.from()`.
|
|
81
|
+
2. **Wrong glyph fonts** — the screenshot page inlines `katex.min.css`, but its relative `url(fonts/*.woff2)` references cannot resolve on a `page.setContent` page (about:blank base URL), so KaTeX fell back to system fonts. KaTeX fonts are now inlined as base64 data URIs at render time; the build also copies the font files to `out/assets/katex-fonts/` for packaged installs.
|
|
82
|
+
|
|
83
|
+
### 🎨 Exports Match the Preview's Theme Colors
|
|
84
|
+
|
|
85
|
+
The engine's `colamd.css` carries per-theme body rules (`body.theme-x .cm-content .cm-md-strong`, inline code colors, heading colors, table header styling) that the exported semantic HTML could not match. These rules are now extracted from `colamd.css`, translated to semantic selectors (`body.theme-x .colamd-document strong` …), and injected into HTML/PDF exports — so exports match the preview (and ColaMD-extend) for all 12 built-in themes, including the ones whose accent rules only exist in the engine layer (sepia / dark / notion / midnight / writer).
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## v0.3.1 (2026-11-07)
|
|
90
|
+
|
|
91
|
+
### 🔧 Engine Upgrade — ColaMD 2.7.11
|
|
92
|
+
|
|
93
|
+
`@bytechain.cn/colamd` bumped from 2.7.9 to 2.7.11, bringing upstream fixes: inline math inside table cells rendered as formulas, list indent handled purely by CSS, cursor alignment with multi-digit ordered lists, block-level widget layout (diagram height re-measured after async render), and Enter/Backspace restored to official CodeMirror commands.
|
|
94
|
+
|
|
95
|
+
### 🐛 Windows Word Code Blocks Fixed (ColaMD-extend #202)
|
|
96
|
+
|
|
97
|
+
Three Windows-only symptoms, one module:
|
|
98
|
+
|
|
99
|
+
1. **Garbled code** — the mono font was written into all four `w:rFonts` slots; a macOS-only font made Word substitute the whole run with symbol glyphs. Now uses a platform mono font (Menlo / Consolas / DejaVu Sans Mono) plus a dedicated CJK `eastAsia` font so Chinese comments render properly.
|
|
100
|
+
2. **Explicit left alignment** — code paragraphs inherited justified alignment, stretching every line to full width. Now explicitly left-aligned, single line spacing, with a light border and shading.
|
|
101
|
+
3. **No spell-check squiggles** — `noProof` added to inline code and code block runs.
|
|
102
|
+
|
|
103
|
+
### 🎨 Word Mermaid Diagrams Follow the Preview Theme
|
|
104
|
+
|
|
105
|
+
Exported diagrams were hardcoded to mermaid's `neutral` theme. Diagram colors are now derived from the current theme's tokens — surface/border mixes at 18% / 28% / 45%, the same ratios the editor uses — with dark themes falling back to the light palette (same rule as body text).
|
|
106
|
+
|
|
107
|
+
### 🐛 Inline Formulas No Longer Wrap in Word
|
|
108
|
+
|
|
109
|
+
The rasterization viewport was widened to 2000px before measuring, so slightly-wide formulas are no longer line-wrapped by KaTeX inside the capture (port of ColaMD-extend's `MEASURE_WIDTH` fix).
|
|
110
|
+
|
|
111
|
+
### 🐛 HTML/PDF Diagrams Follow Theme + No Zoom Controls
|
|
112
|
+
|
|
113
|
+
- Export CSS now matches the serialized `<div><svg class="pele pele-…">` wrappers to restore the `--pele-*` variable mapping, so diagrams keep the theme's colors (port of ColaMD-extend a25b3f8).
|
|
114
|
+
- The editor-only diagram zoom controls (`.pele-zoom`) are hidden in exports — Chromium print doesn't run scripts, so pele never gets the chance to remove them and they overlapped diagrams in PDFs (port of `print-layout.ts`).
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
3
118
|
## v0.3.0 (2026-11-06)
|
|
4
119
|
|
|
5
120
|
### 🎨 Theme-Faithful Export
|
package/esbuild.js
CHANGED
|
@@ -70,6 +70,12 @@ function copyResources() {
|
|
|
70
70
|
if (fs.existsSync(katexCss)) {
|
|
71
71
|
copies.push({ src: katexCss, dst: 'out/assets/katex.min.css' });
|
|
72
72
|
}
|
|
73
|
+
// KaTeX 字体:Word 导出的公式截图页会把 katex.min.css 内联进 data: 页面,
|
|
74
|
+
// 相对字体 URL 解析不到,必须带上字体文件(运行时转 base64 内联)。
|
|
75
|
+
const katexFonts = 'node_modules/katex/dist/fonts';
|
|
76
|
+
if (fs.existsSync(katexFonts)) {
|
|
77
|
+
copies.push({ src: katexFonts, dst: 'out/assets/katex-fonts' });
|
|
78
|
+
}
|
|
73
79
|
const mermaidJs = 'node_modules/mermaid/dist/mermaid.min.js';
|
|
74
80
|
if (fs.existsSync(mermaidJs)) {
|
|
75
81
|
copies.push({ src: mermaidJs, dst: 'out/assets/mermaid.min.js' });
|