dsh-md-plus 0.4.1 → 0.4.2
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/CHANGELOG.md +10 -1
- package/README.md +2 -2
- package/lib/client.js +35 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
-
## 0.4.
|
|
3
|
+
## 0.4.2 —— 未发布
|
|
4
|
+
|
|
5
|
+
- 修复鼠标悬浮表格或折叠内容时吞掉页面滚轮:移除表格容器的 `overscroll-behavior` containment,折叠态改为保留横向滚动、纵向 `overflow-y: clip`,并覆盖 DSH 宿主 `.tableScroll` 自带的横向 containment。
|
|
6
|
+
- 修复宽表横向滚动条出现 / 消失时鼠标移入移出表格造成的上下跳动:取消 hover 阶段的 padding 切换,固定底部留白。
|
|
7
|
+
- 修复宽表横向滚动时「展开 / 收起」按钮跟着表格内容移动:按钮中心固定跟随表格可视区域。
|
|
8
|
+
- 修复宽表横向滚动时右上角 CSV / Markdown 操作按钮跟表格内容移动:操作组固定在表格可视区域右上角。
|
|
9
|
+
- 新增 `docs/table-wheel-demo.html`:可直接检查短表、默认折叠长表(含横向滚动)和展开长表三种滚轮行为。
|
|
10
|
+
- 测试补到 73 条,新增表格和折叠内容不建立吞滚轮滚动容器的回归用例。
|
|
11
|
+
|
|
12
|
+
## 0.4.1 —— 2026-10-30
|
|
4
13
|
|
|
5
14
|
- 修复 DSH 代码块头部只显示占位文案时读不到真实围栏语言、补高亮失效的问题:现在会从宿主的 React fiber 读取真实 `lang`,读不到再退回正文嗅探,并把头部语言名显示成真实语言。
|
|
6
15
|
- 修复 `graph = nx.Graph()`、`pie = 3.14`、`timeline = []` 等普通代码被误判成 mermaid 图的问题:只嗅探第一行有效内容,并排除赋值和调用形态。
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
- **代码块**:统一成完整卡片,头部显示 `</>` 图标和语言名(无语言显示 `Plain text`),保留宿主原生的换行与复制按钮,顶栏与卡片同色。
|
|
10
10
|
- **Mermaid**:围栏渲染成 SVG,可在「图形 / 代码」间切换;支持全屏查看(滚轮缩放、拖拽、双击适应、Esc 关闭)、四套配色,以及下载 SVG / PNG。
|
|
11
11
|
- **长内容折叠**:代码块、表格、图表超过阈值自动折叠,底部出现「展开 / 收起」,长日志和长表格不会撑满聊天。
|
|
12
|
-
- **表格**:浅色 /
|
|
12
|
+
- **表格**:浅色 / 深色两套样式,表头吸顶,宽表支持表内横向滚动;每张表上方右侧有「CSV / Markdown」复制按钮。
|
|
13
13
|
- **图片放大**:只在旧宿主没有原生预览按钮时兜底,点击图片打开暗色预览,Esc 或点遮罩关闭;新版 DSH 的原生预览、头像、图标、代码块和链接里的图片都不接管。
|
|
14
14
|
- **设置面板**:右下角齿轮可调 Mermaid 配色、代码字号、图表默认视图和三类折叠阈值,阈值下方会注明按高度判断。设置存在 `localStorage`,界面文案跟随页面 `<html lang>` 切换中英文。
|
|
15
15
|
|
|
@@ -27,7 +27,7 @@ dsh plugin --profile desktop remove dsh-md-plus
|
|
|
27
27
|
```powershell
|
|
28
28
|
npm install # 顺带跑 prepare → build
|
|
29
29
|
npm run build # 产出 lib/ 下四个文件
|
|
30
|
-
npm run check # 语法检查 +
|
|
30
|
+
npm run check # 语法检查 + 73 条测试(先 build 再跑,check 不含 build)
|
|
31
31
|
npm run preview # 生成 preview.html(含真渲出来的 mermaid 图)
|
|
32
32
|
npm run shot # 用 headless Chrome 把 preview.html 截成 docs/preview.png
|
|
33
33
|
```
|
package/lib/client.js
CHANGED
|
@@ -443,8 +443,9 @@ window.__ModuleLoader__.load({
|
|
|
443
443
|
"." + MODAL_CLASS + " svg{display:block}",
|
|
444
444
|
// ── 长内容折叠:代码块、表格、图表卡共用一套按钮 ───────────────
|
|
445
445
|
"." + FOLD_CLASS + "{position:relative}",
|
|
446
|
-
|
|
447
|
-
"." +
|
|
446
|
+
// 用 clip 而不是 hidden:hidden 会建立隐形滚动容器,鼠标在折叠内容上滚轮会被它吞掉。
|
|
447
|
+
"." + FOLD_CLASS + "[" + FOLD_ATTR + '="on"]{max-height:var(--md-plus-fold-max-height);overflow:clip}',
|
|
448
|
+
"." + FOLD_BTN_CLASS + "{display:block;white-space:nowrap;margin:8px auto 0;padding:4px 12px;border:1px solid var(--dsw-alias-border-secondary,rgb(127 127 127 / 22%));border-radius:999px;background:var(--dsw-alias-bg-base,#fff);color:var(--dsw-alias-label-primary);font:12px/18px var(--dsw-font-family-sans,system-ui,sans-serif);cursor:pointer;box-shadow:0 2px 8px rgb(0 0 0 / 12%);z-index:2}",
|
|
448
449
|
"." + FOLD_CLASS + "[" + FOLD_ATTR + '="on"] .' + FOLD_BTN_CLASS + "{position:absolute;left:50%;bottom:8px;transform:translateX(-50%);margin:0}",
|
|
449
450
|
// ── 图片点击放大 ────────────────────────────────────────────────
|
|
450
451
|
'[class*="_markdown_"] img{cursor:zoom-in}',
|
|
@@ -480,7 +481,10 @@ window.__ModuleLoader__.load({
|
|
|
480
481
|
// 抓手用结构选择器而不是 DSH 的哈希类名:外层是「唯一子元素是 table 的 div」。
|
|
481
482
|
// 前面挂 [class*="_markdown_"] 有两个作用——只认 markdown 渲染出来的表格,
|
|
482
483
|
// 同时把特异性顶到 (0,1,4),压过 DSH 自己的 .tableScroll th (0,1,1)。
|
|
483
|
-
|
|
484
|
+
// 不要加 overscroll-behavior-y:contain:宿主给表格的外层是 overflow-x:auto,
|
|
485
|
+
// 两轴滚动容器上加 contain 会让没有纵向滚动的短表也吞掉页面滚轮;宿主的
|
|
486
|
+
// overscroll-behavior-x:contain 同样要清掉,Chrome 下它也会连带吞掉纵向滚轮。
|
|
487
|
+
TABLE + "{position:relative;margin-block:16px;max-height:min(70vh,720px);overflow-y:auto;overscroll-behavior:auto;" + TABLE_VARS + "}",
|
|
484
488
|
"body[data-ds-dark-theme] " + TABLE + "{" + TABLE_VARS_DARK + "}",
|
|
485
489
|
// 整张表一个 1px 边框 + 小圆角。
|
|
486
490
|
// 注意必须是 separate:collapse 模式下 Chrome 会忽略单元格的圆角,
|
|
@@ -507,23 +511,24 @@ window.__ModuleLoader__.load({
|
|
|
507
511
|
// 长表往下滚时表头留在视口顶部;底色不透明才不会透出下面的行
|
|
508
512
|
TABLE + " > table thead th{position:sticky;top:0;z-index:1}",
|
|
509
513
|
// 复制按钮放在表尾右侧:不压住表头文字,表格折叠时也能随展开一起出现
|
|
510
|
-
TABLE + " > table > caption." + TABLE_TOOLS_CLASS + "{caption-side:top;text-align:right;
|
|
514
|
+
TABLE + " > table > caption." + TABLE_TOOLS_CLASS + "{caption-side:top;position:sticky;right:0;width:0;height:30px;margin-left:auto;padding:0;text-align:right;z-index:2}",
|
|
515
|
+
TABLE + " > table > caption." + TABLE_TOOLS_CLASS + " > span{position:absolute;right:0;top:0;display:flex;gap:0;white-space:nowrap}",
|
|
511
516
|
TABLE + " > table > caption." + TABLE_TOOLS_CLASS + " button{appearance:none;border:1px solid var(--md-plus-tbl-line);border-radius:5px;padding:2px 8px;margin-left:4px;background:transparent;color:var(--dsw-alias-label-secondary);font:11px/16px var(--dsw-font-family-sans,system-ui,sans-serif);cursor:pointer}",
|
|
512
517
|
TABLE + " > table > caption." + TABLE_TOOLS_CLASS + " button:hover{color:var(--dsw-alias-label-primary);background:var(--md-plus-tbl-hover)}",
|
|
513
518
|
// 宽表(≥4 列)不收着不行。宿主给这类表加了 .md-table-wide,并让它「出血」:
|
|
514
519
|
// 包裹层撑到面板宽,再用 padding-left 把表推到正文栏左侧。那个 padding 会吃掉
|
|
515
|
-
//
|
|
516
|
-
// 才出现——文字表落进这个区间就很难读。这里按回正文栏宽,超出改为表内横滚。
|
|
520
|
+
// 可用宽度,结果是表格比正文宽出一截、右边还被裁掉;这里按回正文栏宽,超出改为表内横滚。
|
|
517
521
|
// 特异性 (0,2,2),压得住宿主的 .Pg4CGa_body .md-table-wide (0,2,0)。
|
|
518
|
-
TABLE + ".md-table-wide{width:100%;max-width:100%;margin-inline:0;padding-inline:0;overflow-x:auto}",
|
|
522
|
+
TABLE + ".md-table-wide{width:100%;max-width:100%;margin-inline:0;padding-inline:0;padding-bottom:0;overflow-x:auto}",
|
|
519
523
|
// 塞得下就撑满正文栏,塞不下保持自然宽度让外面滚,不把列挤成一列一个字
|
|
520
524
|
TABLE + ".md-table-wide > table{width:100%;max-width:none;min-width:max-content}",
|
|
521
|
-
//
|
|
522
|
-
//
|
|
523
|
-
TABLE + ".
|
|
525
|
+
// 折叠态保留横向滚动,但纵向必须 clip;横向滚动容器只有在
|
|
526
|
+
// overscroll-behavior:auto 时才会把纵向滚轮交还给页面。
|
|
527
|
+
TABLE + "." + FOLD_CLASS + "[" + FOLD_ATTR + '="on"]{overflow-x:auto;overflow-y:clip}'
|
|
524
528
|
].join("\n");
|
|
525
529
|
var scripts = /* @__PURE__ */ new Map();
|
|
526
530
|
var pending = /* @__PURE__ */ new Set();
|
|
531
|
+
var foldSyncs = /* @__PURE__ */ new WeakMap();
|
|
527
532
|
var timer = null;
|
|
528
533
|
var rescanQueued = false;
|
|
529
534
|
var injected = /* @__PURE__ */ new Set();
|
|
@@ -1045,6 +1050,12 @@ window.__ModuleLoader__.load({
|
|
|
1045
1050
|
}
|
|
1046
1051
|
function resetFold(target) {
|
|
1047
1052
|
if (target === null) return;
|
|
1053
|
+
var sync = foldSyncs.get(target);
|
|
1054
|
+
if (sync !== void 0) {
|
|
1055
|
+
target.removeEventListener("scroll", sync);
|
|
1056
|
+
window.removeEventListener("resize", sync);
|
|
1057
|
+
foldSyncs.delete(target);
|
|
1058
|
+
}
|
|
1048
1059
|
target.removeAttribute(FOLD_ATTR);
|
|
1049
1060
|
target.classList.remove(FOLD_CLASS);
|
|
1050
1061
|
target.style.removeProperty("--md-plus-fold-max-height");
|
|
@@ -1077,13 +1088,23 @@ window.__ModuleLoader__.load({
|
|
|
1077
1088
|
button.className = FOLD_BTN_CLASS;
|
|
1078
1089
|
button.textContent = t("foldOpen");
|
|
1079
1090
|
button.setAttribute("aria-expanded", "false");
|
|
1091
|
+
var sync = target.hasAttribute(TABLE_DONE_ATTR) ? () => {
|
|
1092
|
+
button.style.left = target.scrollLeft + target.clientWidth / 2 + "px";
|
|
1093
|
+
} : null;
|
|
1094
|
+
if (sync !== null) {
|
|
1095
|
+
foldSyncs.set(target, sync);
|
|
1096
|
+
target.addEventListener("scroll", sync, { passive: true });
|
|
1097
|
+
window.addEventListener("resize", sync);
|
|
1098
|
+
}
|
|
1080
1099
|
button.addEventListener("click", () => {
|
|
1081
1100
|
var folded = target.getAttribute(FOLD_ATTR) === "on";
|
|
1082
1101
|
target.setAttribute(FOLD_ATTR, folded ? "off" : "on");
|
|
1083
1102
|
button.textContent = folded ? t("foldClose") : t("foldOpen");
|
|
1084
1103
|
button.setAttribute("aria-expanded", folded ? "true" : "false");
|
|
1104
|
+
sync?.();
|
|
1085
1105
|
});
|
|
1086
1106
|
target.appendChild(button);
|
|
1107
|
+
sync?.();
|
|
1087
1108
|
});
|
|
1088
1109
|
}
|
|
1089
1110
|
function scanFolds() {
|
|
@@ -1153,6 +1174,8 @@ window.__ModuleLoader__.load({
|
|
|
1153
1174
|
table.setAttribute(TABLE_DONE_ATTR, "1");
|
|
1154
1175
|
var tools = document.createElement("caption");
|
|
1155
1176
|
tools.className = TABLE_TOOLS_CLASS;
|
|
1177
|
+
var group = document.createElement("span");
|
|
1178
|
+
group.className = TABLE_TOOLS_CLASS + "-group";
|
|
1156
1179
|
for (const [kind, label, titleKey, convert] of [
|
|
1157
1180
|
["csv", t("tableCsv"), "copyCsvTitle", tableToCsv],
|
|
1158
1181
|
["md", t("tableMd"), "copyMdTitle", tableToMarkdown]
|
|
@@ -1171,8 +1194,9 @@ window.__ModuleLoader__.load({
|
|
|
1171
1194
|
}
|
|
1172
1195
|
flashButton(button, ok ? t("copied") : t("copyFailed"));
|
|
1173
1196
|
});
|
|
1174
|
-
|
|
1197
|
+
group.appendChild(button);
|
|
1175
1198
|
}
|
|
1199
|
+
tools.appendChild(group);
|
|
1176
1200
|
dataTable.insertBefore(tools, dataTable.firstChild);
|
|
1177
1201
|
}
|
|
1178
1202
|
function openImage(source, alt) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-md-plus",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Markdown display enhancements for DeepSeek Harness Web: code block restyle, syntax highlighting for languages DSH does not ship, and built-in mermaid diagrams.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|