merge #1104: fix(terminal) 底部工作台终端不再自带黑底(:global 选择器 + 特异性 0,3,0)
This commit is contained in:
commit
4b61d6802b
2 files changed
+17
-4
No files matched your search
+1
-1
@@ -3,7 +3,7 @@
|
||||
> 本文档收录 dsh-better-sidebar 的完整发布历史(最新版摘要见 [README](README_ZH.md);同步发布于 [GitHub Releases](https://github.com/omdsh-dev/DSH-better-sidebar/releases))。
|
||||
|
||||
### 未发布
|
||||
|
||||
- 🎨 **底部工作台的终端不再自带黑底**:终端区域一直是一块纯黑矩形,而周围的 tab 条与面板都不是。原因是 xterm 自带样式表里的 `.xterm .xterm-viewport { background-color: #000 }`,而本插件的规则 `.screen .xterm-viewport` 被 CSS Modules 把 xterm 的类名也哈希了(编译成 `.o8IiwG_xterm-viewport`),真实 DOM 里根本不匹配;即便包上 `:global()`,同权重的规则也会因为 xterm 在 `open()` 时才注入样式表而输在源顺序。现在选择器写成 `.screen :global(.xterm .xterm-viewport)`(`:global` 保命、多一级 `.xterm` 把特异性抬到 0,3,0),`.screen` 自身也不再画 `bg-base`。Chromium 实测:0,2,0 → `rgb(0, 0, 0)`,0,3,0 → `rgba(0, 0, 0, 0)`。
|
||||
- ⚡ **大 Markdown 的 Mermaid 预览不再卡死渲染器(chunk 内测量隔离到沙箱 iframe)**:Mermaid 用 `SVGElement.getBBox()` 量文字,测量节点挂在 `document.body` 上 → 每次测量都刷新整个 DSH 文档布局。真机实测一次 `getBBox` **59–75 ms**(15,418 节点),空 iframe 里只要 **1 ms**;31 张图因此阻塞主线程 >20 s,触发桌面壳看门狗杀渲染器,恢复标签页后循环卡死。现在图表改在隐藏的 `sandbox="allow-scripts"` iframe(blob: 自包含 mermaid UMD + 协议)里渲染,父侧只做 postMessage 收发与 SVG 清洗:**单图 1,500–7,300 ms → 30–104 ms,31 图约 5 s 内完成**,客户端 mermaid chunk 同时从 **7.04 MB → 3.69 MB**。另加共享渲染队列(可见/近视口优先,其余 `requestIdleCallback` 逐张补齐,两次之间让出 16 ms 主线程;**所有图最终都会渲染成图,不再退化为代码块**)与按围栏行数预留高度的占位骨架。设计与实测见 [docs/plans/2026-10-23-mermaid-iframe-isolation.md](docs/plans/2026-10-23-mermaid-iframe-isolation.md)。
|
||||
- ⚡ **大文档滚动流畅性:渲染让位于滚动、隐藏页签不空转、摘掉全量 DOM 扫描**:图表渲染队列在滚动期间暂停(停止滚动 350 ms 后恢复),并且只服务当前可见的预览——隐藏页签里的图表保持占位、切回时才渲染;`Markdown` 变更触发的两次全量扫描(内联 HTML pass、标题锚点 pass)由「每次 mutation 跑一遍」(实测 8–15 ms/次)改为 80 ms 合并一次;打开文档时的近视口判断改为先批量读 rect、再统一写入,去掉每张图一次强制布局;`.mermaidWrap` 增加 `content-visibility: auto` + `contain-intrinsic-size` + `contain: layout paint style`,视口外的图表不再参与布局与绘制。滚动时不再有后台渲染、全量扫描与视口外 SVG 重绘抢主线程;图表仍会在滚动停止后或进入视口时补齐,不退化为代码块。
|
||||
- 🐞 **图表渲染失败时直接显示 mermaid 的解析错误**:之前只显示通用「Mermaid 渲染失败」+ 源码块(完整错误只在 hover title 里)。现在错误条下方直接给出 mermaid 报错的首两行(如 `Parse error on line 10 ... Expecting 'SEMI', ... got 'UNICODE_TEXT'`),配合下方源码可快速定位坏围栏;错误信息仍完整保留在 title 中。
|
||||
|
||||
@@ -26,7 +26,10 @@
|
||||
padding: 8px;
|
||||
overflow: hidden;
|
||||
color: var(--dsw-alias-label-primary);
|
||||
background: var(--dsw-alias-bg-base);
|
||||
/* No fill of its own: the terminal sits inside the workbench and must read
|
||||
as part of its surface. Painting a token here drew a second rectangle
|
||||
inside the panel. */
|
||||
background: transparent;
|
||||
font-family: var(--ds-font-family-code, monospace);
|
||||
}
|
||||
|
||||
@@ -34,8 +37,18 @@
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.screen .xterm-viewport {
|
||||
background: var(--dsw-alias-bg-base);
|
||||
/* xterm owns these classes, so they MUST be wrapped in `:global()`: CSS
|
||||
Modules would otherwise hash them into `.o8IiwG_xterm-viewport` and match
|
||||
nothing in the real DOM.
|
||||
|
||||
The extra `.xterm` in the selector is NOT redundant either. xterm.css ships
|
||||
`.xterm .xterm-viewport { background-color: #000 }` at specificity 0,2,0
|
||||
and injects that sheet when `open()` runs — after this module. Matching its
|
||||
specificity would therefore lose on source order every time; reaching 0,3,0
|
||||
is what wins. Measured in Chromium: 0,2,0 → `rgb(0, 0, 0)` (still black),
|
||||
0,3,0 → `rgba(0, 0, 0, 0)` (transparent). */
|
||||
.screen :global(.xterm .xterm-viewport) {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.status {
|
||||
|
||||
Reference in new issue
Block a user