dsh-composer-live 0.2.13 → 0.2.15

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 CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  > 更新日志以中文记录。Changelog entries are written in Chinese.
4
4
 
5
+ ## 0.2.15(2026-10-18)
6
+
7
+ **输入 `/` 命令/技能名时文字无颜色、hover 被色块遮挡(用户 0.2.1 实测反馈)。**
8
+
9
+ - **根因**:0.2.x 官方把 `/anatomy` 这类技能命令识别为「文本引用装饰」`[data-composer-text-ref]`——span 带 `color: var(--dsw-alias-state-business-primary)`(主题引用色)与 `:hover { background: var(--dsw-alias-state-business-tertiary) }`。插件把编辑器文字 `-webkit-text-fill-color: transparent` 后由 overlay 重绘,装饰的 `color` 因此不可见(文字显示为普通正文色);而 hover 背景留在编辑器层(`z-index: 1`,画在 overlay 之上),会整块盖住渲染文字。
10
+ - **修法**:`buildAnchors` 记录 `[data-composer-text-ref]` 的投影区间(挂在 `anchors.refs`),`renderCharOverlay` 按绝对 offset 给对应字符加 `dsh-cl-ref` class,颜色取同一主题变量 `--dsw-alias-state-business-primary`(明暗主题自动跟随,取不到时回退 `#3b82f6`);同时注入 `[data-composer-text-ref]:hover { background: transparent !important }` 禁掉编辑器层 hover 背景,杜绝遮挡。
11
+ - 单测 188 项通过。
12
+
13
+ ## 0.2.14(2026-10-06)
14
+
15
+ **工具栏迁出输入卡:放卡外正上方,不再占输入框内部空间(用户反馈「工具栏阻碍输入框空间」)。**
16
+
17
+ - **DOM 位置**:`.dsh-cl-toolbar` 从「输入卡内、编辑器滚动容器顶部(v0.2.8 sticky)」迁到「card 的父容器内、card 前一格」——输入卡外、正上方,视觉为与卡等宽的独立细条(36px 高、圆角 12px、明暗两套底色阴影、与卡 6px 间距)。编辑器 padding-top 让位(v0.2.8 的 BAR_RESERVE 6px)随 sticky 体系整体退役,输入框恢复官方原始内距。
18
+ - **宽度同步**:父容器(`uV2eYG_root`,flex column + align-items:flex-start)内容宽 ≠ card 宽,CSS `width:100%` 会比卡突出——搬正逻辑每次从 `card.offsetWidth` 同步(有差异才写,避免每次 run 触发样式失效)。
19
+ - **card 重建防双份**:工具栏跨 card 重建存活(hero 切换/会话切换后旧工具栏仍留在父容器),setupCard 先查父容器复用(接管 `__dshClToolbar`/`__dshClBtns` 引用)再谈新建;expand 按钮闭包改 `findCard()` 现查(格式键本就现查)。卸载清理改引用直取 + `document.querySelectorAll` 全局兜底(card 已消失时父容器查找清不到)。
20
+ - **React 重排自愈**:官方重建父容器 children 时不认识外来节点,工具栏可能被挤错位——搬正逻辑(每次 setupCard/run 跑)持续拉回 card 前一格。
21
+ - **代价说明**:工具栏卡外后占文档流 36px,消息区可视高度相应少 36px(消息区自身可滚动,内容无损)。
22
+ - E2E:`scrollToolbar` op 重写为「卡外位置 + 与卡等宽 + 长文滚动时输入区(工具栏+输入框)整体固定」断言(旧 sticky 钉顶语义退役);`toolbarClear` 查找范围从 card 内改 document 级。场景 R8 更名 `R8-toolbar-outside-card`。
23
+ - 单测 188 项通过;8124(0.1.5-rc.2)E2E 全绿后发布。
24
+
5
25
  ## 0.2.13(2026-10-01)
6
26
 
7
27
  **发布仓库隐私整改 + E2E 工具通用化(插件本体零改动)。**
package/README.md CHANGED
@@ -55,7 +55,7 @@ It is a **pure browser-side plugin**: zero runtime dependencies, no service inje
55
55
 
56
56
  ### Toolbars and shortcuts
57
57
 
58
- - **Sticky top toolbar**: B / italic / code / link / list / code block / expand. Wraps the selection, or inserts empty markers at the caret; B lights up when the caret sits inside `**…**`. The bar is pinned to the top of the scroll area, so it never overlaps content or image attachments.
58
+ - **Format toolbar (outside the composer card since v0.2.14)**: B / italic / code / link / list / code block / expand. Wraps the selection, or inserts empty markers at the caret; B lights up when the caret sits inside `**…**`. The bar is a standalone strip directly above the composer card, card-aligned width, taking no space inside the input area — it never overlaps content or image attachments.
59
59
  - **Selection floating format bar** (Open WebUI style): select text and B/italic/code/link appear above the selection.
60
60
  - **Ctrl+B / Ctrl+I / Ctrl+E** for bold / italic / inline code — which also blocks the browser's native contenteditable bold that would silently insert real `<b>` tags into the draft.
61
61
 
@@ -68,7 +68,7 @@ It is a **pure browser-side plugin**: zero runtime dependencies, no service inje
68
68
  - **Esc** does the right thing in context: open candidate menus → official handler; expanded composer → collapse; generation in progress → stop generating.
69
69
  - One-key **70vh expand** for long-form writing.
70
70
  - Light/dark theme aware; IME-safe (composition input never flashes); rendering is rAF-batched and incremental.
71
- - **@ mention chips** stay official and editable. Paragraphs containing chips gracefully degrade to official rendering (chip widths cannot be replicated; zero misalignment wins). Text decorations are unaffected.
71
+ - **@ mention chips** stay official and editable. Paragraphs containing chips gracefully degrade to official rendering (chip widths cannot be replicated; zero misalignment wins). Text decorations are unaffected — `/` commands and skill-name references are painted in the official reference colour, and the official hover background is disabled (it paints above the render layer and would cover the text).
72
72
  - Also fixes two official positioning glitches when image attachments are present: the trigger menu floating far above the composer, and toolbars overlapping thumbnails.
73
73
 
74
74
  ### Not duplicated from DSH 0.1.5
package/README.zh-CN.md CHANGED
@@ -55,7 +55,7 @@ dsh-composer-live 把 DSH Web 的输入框变成 Open WebUI 风格的实时编
55
55
 
56
56
  ### 工具栏与快捷键
57
57
 
58
- - **常驻顶部工具栏**:加粗 / 斜体 / 行内代码 / 链接 / 列表 / 代码块 / 展开。选中文字时包裹、未选中插入空标记;光标落在 `**…**` 内时加粗键自动点亮。工具栏钉在滚动区顶部,永不与正文或图片附件重叠。
58
+ - **常驻格式工具栏(v0.2.14 起在输入卡外正上方)**:加粗 / 斜体 / 行内代码 / 链接 / 列表 / 代码块 / 展开。选中文字时包裹、未选中插入空标记;光标落在 `**…**` 内时加粗键自动点亮。工具栏是与输入卡等宽的独立细条,不占输入框内部高度,也永不与正文或图片附件重叠。
59
59
  - **选区浮动格式条**(Open WebUI 形态):选中一段文字,加粗/斜体/代码/链接四键浮现在选区上方。
60
60
  - **Ctrl+B / Ctrl+I / Ctrl+E** 快捷加粗 / 斜体 / 行内代码——同时拦掉浏览器对 contenteditable 的原生加粗(那会悄悄往草稿里插入真正的 `<b>` 标签)。
61
61
 
@@ -68,7 +68,7 @@ dsh-composer-live 把 DSH Web 的输入框变成 Open WebUI 风格的实时编
68
68
  - **Esc** 按语境做对的事:官方候选菜单开着 → 归官方处理;展开态 → 收起;AI 生成中 → 停止生成。
69
69
  - 一键**展开 70vh** 长文写作模式。
70
70
  - 明暗主题自适应;输入法安全(拼音组字不闪烁);渲染按 rAF 合帧、增量进行。
71
- - **@ 引用胶囊**保持官方原样、可编辑。含胶囊的段落优雅降级为官方显示(胶囊宽度无法复刻,零错位优先)。热词文本装饰不受影响。
71
+ - **@ 引用胶囊**保持官方原样、可编辑。含胶囊的段落优雅降级为官方显示(胶囊宽度无法复刻,零错位优先)。热词文本装饰不受影响——`/` 命令与技能名的引用装饰在渲染层沿用官方引用色,官方 hover 背景已禁用(它画在渲染层之上,会盖住文字)。
72
72
  - 顺带修复官方在图片附件在场时的两个定位问题:候选菜单悬空浮出输入框、工具栏盖住缩略图。
73
73
 
74
74
  ### 不与 DSH 0.1.5 重复
package/client.js CHANGED
@@ -85,7 +85,7 @@ window.__ModuleLoader__.load({
85
85
  /** 「停止生成」按钮 aria-label(i18n 双语;实测校正清单见 README)。 */
86
86
  const STOP_BTN_HINTS = ["停止生成", "Stop generating", "停止"];
87
87
  /** 工具栏高度 + 呼吸(占位同步值)。 */
88
- const BAR_RESERVE = "6px"; // v0.2.8:sticky 工具栏在流内占 38px,编辑器 padding 只留呼吸(原 absolute 方案的 44px 占位退役)
88
+ const TB_HEIGHT = "36px"; // v0.2.14:卡外独立条高度(原卡内 sticky 的 38px + BAR_RESERVE 让位整体退役)
89
89
  //#endregion
90
90
 
91
91
  //#region dsh-composer-live: 安全工具
@@ -434,7 +434,7 @@ window.__ModuleLoader__.load({
434
434
  }
435
435
 
436
436
  /** 字符锚定渲染主入口:清空 overlay,按测量坐标输出「整块背景 + 定位字符段」。 */
437
- function renderCharOverlay(ov, input, anchors, lines, states) {
437
+ function renderCharOverlay(ov, input, anchors, lines, states, refs) {
438
438
  const ovRect = ov.getBoundingClientRect();
439
439
  const ox = ovRect.left, oy = ovRect.top;
440
440
  const segLineHeight = getComputedStyle(ov).lineHeight; // 段定位的 half-leading 修正用
@@ -446,6 +446,10 @@ window.__ModuleLoader__.load({
446
446
  const contentLeft = inpRect.left + pl - 12;
447
447
  const contentW = inpRect.width - pl - pr + 24;
448
448
  let out = "";
449
+ // 每行在投影文本中的起始 offset(refs 区间按绝对 offset 匹配字符)
450
+ const lineStarts = [];
451
+ let lineAcc = 0;
452
+ for (const l of lines) { lineStarts.push(lineAcc); lineAcc += l.length + 1; }
449
453
  // ===== 块级背景(代码块整块一个矩形:垂直无缝;引用段同理) =====
450
454
  // 逐行画背景会按行内容宽度锯齿 + 行间露缝——聚合到块级:从块首行首字符顶
451
455
  // 到块末行末字符底 ±2.5px,水平取容器内容宽。块内空行天然被矩形覆盖。
@@ -503,6 +507,20 @@ window.__ModuleLoader__.load({
503
507
  const tl = tk.text.length;
504
508
  for (let k = 0; k < tl && ci < chars.length; k++, ci++) charCls[ci] = tk.cls;
505
509
  }
510
+ // 官方文本引用装饰(/ 命令、技能名)→ 引用色。编辑器文字透明,官方给
511
+ // 装饰 span 的 color 看不见;按投影区间在渲染层补上同一主题色。
512
+ if (refs.length) {
513
+ const base = lineStarts[li] || 0;
514
+ for (let k = 0; k < chars.length; k++) {
515
+ const abs = base + chars[k].off;
516
+ for (const r of refs) {
517
+ if (abs >= r.start && abs < r.end) {
518
+ charCls[k] = (charCls[k] ? charCls[k] + " " : "") + "dsh-cl-ref";
519
+ break;
520
+ }
521
+ }
522
+ }
523
+ }
506
524
  // 合并「同样式 + 同视觉行 + 横向连续」的字符成段(段内浏览器排版同字体零差)。
507
525
  // 等宽整框语义:文档含代码块时全部段用等宽合成栈(与编辑器 MONO_ALL 同源变量)。
508
526
  const anyCode = states.some((st) => st.inCode);
@@ -822,18 +840,13 @@ window.__ModuleLoader__.load({
822
840
  function styleText() {
823
841
  return (
824
842
  "#" + STYLE_ID + "{}" +
825
- // 常驻工具栏(absolute 横贯输入卡顶部):占位由 input/placeholder 的
826
- // padding-top 同步让出(overlay 的 padding 每次渲染从 input 复制)。
827
- "." + TOOLBAR + "{position:sticky;top:0;left:0;right:0;z-index:60;display:flex;align-items:center;box-sizing:border-box;height:38px;padding:0 10px;gap:2px;background:rgba(28,30,36,.95);border-bottom:1px solid rgba(127,127,127,.16);}" +
828
- // sticky 工具栏钉滚动视口顶(v0.2.8):内容从其下方滚过永不重叠;附件栏在
829
- // 滚动容器外,scroll 顶=附件栏底,天然让位(v0.2.7 的让位变量退役)。背景色
830
- // 必须不透明——滚动内容从下方经过(实测反馈「工具栏透明」问题的根治)。
831
- "body.dsh-cl-light ." + TOOLBAR + "{background:rgba(250,251,253,.97);border-bottom-color:rgba(0,0,0,.08);}" +
843
+ // 常驻工具栏(v0.2.14:输入卡外、卡正上方的独立条):不再占输入框内部
844
+ // 高度——编辑器 padding 让位(v0.2.8 的 BAR_RESERVE)随 sticky 体系整体
845
+ // 退役;宽度由搬正逻辑从 card 同步(父容器内容宽 ≠ card 宽,width:100%
846
+ // 会比卡突出)。背景不透明(沿用 v0.2.8 教训:透底会与后方内容混色)。
847
+ "." + TOOLBAR + "{display:flex;align-items:center;box-sizing:border-box;height:" + TB_HEIGHT + ";padding:0 12px;gap:2px;margin:0 0 6px;border-radius:12px;background:rgba(28,30,36,.95);box-shadow:rgba(0,0,0,.25) 0px 1px 8px 0px;}" +
848
+ "body.dsh-cl-light ." + TOOLBAR + "{background:rgba(250,251,253,.97);box-shadow:rgba(61,55,48,.125) 0px 0px 0px 0.5px,rgba(0,0,0,.04) 0px 1px 8px 0px;}" +
832
849
  "." + TOOLBAR + " [data-cl=\"expand\"]{margin-left:auto;}" +
833
-
834
- // 编辑层与占位层让出工具栏一行(38px 工具栏 + 6px 呼吸)
835
- CARD_SEL + " " + INPUT_SEL + "{padding-top:" + BAR_RESERVE + " !important;}" +
836
- CARD_SEL + " " + PLACEHOLDER_SEL + "{padding-top:" + BAR_RESERVE + " !important;box-sizing:border-box;}" +
837
850
  // 透明化:只隐藏文字「绘制」(-webkit-text-fill-color),color 属性保留
838
851
  // ——caret 颜色、官方 hint ::after、chip 恢复全靠 color 不动。
839
852
  // 提层:编辑器自身 z-index:1 画在 overlay(z:0)之上——caret/选区是编辑器
@@ -905,6 +918,12 @@ window.__ModuleLoader__.load({
905
918
  // 字符段:绝对定位画在编辑器字符 rect 上;字体继承 overlay(syncMetrics
906
919
  // 复制官方度量);样式类只改 paint(伪粗/染色/胶囊背景外扩),零 advance 变化。
907
920
  ".dsh-cl-c{position:absolute;white-space:pre;pointer-events:none;color:inherit;font-family:inherit;}" +
921
+ // 官方文本引用装饰(/ 命令、技能名):渲染层用同一主题引用色。
922
+ // 编辑器层文字已透明,官方给装饰 span 的 color 看不见(此前显示为
923
+ // 普通正文色);hover 背景同样在编辑器层(z-index:1,画在 overlay
924
+ // 之上),会整块盖住渲染文字——禁掉,常驻引用色已足够辨识。
925
+ ".dsh-cl-c.dsh-cl-ref{color:var(--dsw-alias-state-business-primary,#3b82f6);}" +
926
+ INPUT_SEL + "." + HOST + " " + TEXT_REF_SEL + ":hover{background:transparent !important;}" +
908
927
  ".dsh-cl-c.dsh-cl-codefont{font-family:var(--dsh-cl-code-font,var(--ds-font-family-code,monospace));}" +
909
928
  ".dsh-cl-c.dsh-cl-strong,.dsh-cl-c.dsh-cl-heading{font-weight:inherit;-webkit-text-stroke:.45px currentColor;}" +
910
929
  ".dsh-cl-c.dsh-cl-em{font-style:italic;}" +
@@ -1025,6 +1044,9 @@ window.__ModuleLoader__.load({
1025
1044
  */
1026
1045
  function buildAnchors(input) {
1027
1046
  const anchors = [];
1047
+ // 官方文本引用装饰([data-composer-text-ref],0.2.x 用于 / 命令与技能名)的
1048
+ // 投影区间:渲染层据此给字符上引用色(编辑器文字已透明,官方 color 不可见)。
1049
+ const refs = [];
1028
1050
  if (!input) return anchors;
1029
1051
  let firstPara = true;
1030
1052
  const visit = (node) => {
@@ -1046,6 +1068,15 @@ window.__ModuleLoader__.load({
1046
1068
  continue;
1047
1069
  }
1048
1070
  if (c.matches && c.matches(CHIP_HOST_SEL)) { anchors.push({ kind: "chip", el: c, len: 1 }); continue; }
1071
+ if (c.matches && c.matches(TEXT_REF_SEL)) {
1072
+ // 引用/命令装饰:内容仍是普通文本(非原子 chip),记录投影区间
1073
+ // 供渲染层染色;文本照常下钻进锚表。
1074
+ const start = anchorsText(anchors).length;
1075
+ visit(c);
1076
+ const end = anchorsText(anchors).length;
1077
+ if (end > start) refs.push({ start, end });
1078
+ continue;
1079
+ }
1049
1080
  // 其余元素(B/I/STRONG/DIV 等富文本粘贴产物、装饰壳)一律继续
1050
1081
  // 下钻收集文字——「忽略内容」会把粘贴的富文本结构整个漏掉:锚表
1051
1082
  // 空转 → 渲染层空白 + 透明化已生效 = 大段粘贴「一片空白」(文字
@@ -1055,6 +1086,7 @@ window.__ModuleLoader__.load({
1055
1086
  }
1056
1087
  };
1057
1088
  visit(input);
1089
+ anchors.refs = refs;
1058
1090
  return anchors;
1059
1091
  }
1060
1092
 
@@ -1253,7 +1285,7 @@ window.__ModuleLoader__.load({
1253
1285
  fallbackToOfficial();
1254
1286
  } else {
1255
1287
  try {
1256
- renderCharOverlay(ov, input, anchors, lines, states);
1288
+ renderCharOverlay(ov, input, anchors, lines, states, anchors.refs || []);
1257
1289
  if (hasContent && ov.querySelectorAll(".dsh-cl-c").length === 0) fallbackToOfficial();
1258
1290
  } catch (err) {
1259
1291
  fallbackToOfficial();
@@ -1429,13 +1461,25 @@ window.__ModuleLoader__.load({
1429
1461
  const input = card.querySelector(INPUT_SEL);
1430
1462
  if (!input) return;
1431
1463
 
1432
- if (card.getAttribute(READY_KEY) !== "1" && !card.querySelector("." + TOOLBAR)) {
1464
+ if (card.getAttribute(READY_KEY) !== "1") {
1433
1465
  card.setAttribute(READY_KEY, "1");
1434
1466
  const scroll = card.querySelector(SCROLL_SEL);
1435
1467
  if (scroll) scroll.classList.add("dsh-cl-anchor");
1436
1468
 
1469
+ // 卡外工具栏复用(v0.2.14):card 重建(hero 切换/会话切换/官方重挂)后,
1470
+ // 旧工具栏仍留在 card 的父容器里——不能建第二份,找到即接管,
1471
+ // __dshClToolbar/__dshClBtns 指向既有节点(按钮闭包一律 findCard() 现查,
1472
+ // 无需重绑监听)。
1473
+ let toolbar = card.parentElement ? card.parentElement.querySelector("." + TOOLBAR) : null;
1474
+ if (toolbar) {
1475
+ card.__dshClToolbar = toolbar;
1476
+ card.__dshClBtns = {};
1477
+ for (const b of toolbar.querySelectorAll(".dsh-cl-btn")) {
1478
+ if (b.dataset.cl) card.__dshClBtns[b.dataset.cl] = b;
1479
+ }
1480
+ } else {
1437
1481
  // 常驻格式工具栏(6 格式键 + 展开键)
1438
- const toolbar = document.createElement("div");
1482
+ toolbar = document.createElement("div");
1439
1483
  toolbar.className = TOOLBAR;
1440
1484
  toolbar.setAttribute("role", "toolbar");
1441
1485
  toolbar.setAttribute("aria-label", "格式工具栏");
@@ -1474,7 +1518,9 @@ window.__ModuleLoader__.load({
1474
1518
  expandBtn.innerHTML = iconSvg("expand");
1475
1519
  expandBtn.addEventListener("mousedown", (ev) => ev.preventDefault());
1476
1520
  expandBtn.addEventListener("click", () => {
1477
- const s = card.querySelector(SCROLL_SEL);
1521
+ // 现查 card:工具栏跨 card 重建存活(复用),闭包里的 card 可能已换实例
1522
+ const c = findCard();
1523
+ const s = c && c.querySelector(SCROLL_SEL);
1478
1524
  if (!s) return;
1479
1525
  const on = s.classList.toggle(EXPANDED);
1480
1526
  expandBtn.classList.toggle("dsh-cl-active", on);
@@ -1482,8 +1528,8 @@ window.__ModuleLoader__.load({
1482
1528
  expandBtn.innerHTML = iconSvg(on ? "collapse" : "expand");
1483
1529
  });
1484
1530
  toolbar.appendChild(expandBtn);
1485
- card.__dshClToolbar = toolbar; // 只创建不挂载——sticky 需挂进滚动容器,见下方 grow 块
1486
- // 挂载延后到 grow(sticky 需在滚动容器内,与 overlay 同一安全位置)
1531
+ card.__dshClToolbar = toolbar; // 只创建不挂载——卡外挂载见下方搬正逻辑
1532
+ } // else(新建工具栏)结束
1487
1533
 
1488
1534
  // 选区浮动格式条(body 级 fixed)
1489
1535
  const floatBar = document.createElement("div");
@@ -1684,6 +1730,19 @@ window.__ModuleLoader__.load({
1684
1730
  }, true);
1685
1731
  }
1686
1732
 
1733
+ // 卡外工具栏搬正(v0.2.14):挂 card 的父容器、card 前一格——输入卡外正上方。
1734
+ // 未挂载/被 React 重排挤错位(官方重建 children 时不认识外来节点)都拉回;
1735
+ // 宽度从 card 同步(父容器内容宽 ≠ card 宽,CSS width:100% 会比卡突出),
1736
+ // 有差异才写 style,避免每次 run 都触发样式失效。
1737
+ const tb = card.__dshClToolbar || (card.parentElement && card.parentElement.querySelector("." + TOOLBAR));
1738
+ if (tb && card.parentElement && (tb.parentElement !== card.parentElement || tb.nextElementSibling !== card)) {
1739
+ card.parentElement.insertBefore(tb, card);
1740
+ }
1741
+ if (tb) {
1742
+ const w = card.offsetWidth + "px";
1743
+ if (tb.style.width !== w) tb.style.width = w;
1744
+ }
1745
+
1687
1746
  // 确保 overlay 与哨兵在位(插在编辑层之前,画在其下不挡光标)
1688
1747
  const grow = input.parentElement;
1689
1748
  if (grow) {
@@ -1694,9 +1753,6 @@ window.__ModuleLoader__.load({
1694
1753
  ov.setAttribute("aria-hidden", "true");
1695
1754
  grow.insertBefore(ov, input);
1696
1755
  }
1697
- // sticky 工具栏进滚动容器(在 overlay 前):未挂载或挂错位置都搬正
1698
- const tb = card.__dshClToolbar || card.querySelector("." + TOOLBAR);
1699
- if (tb && (tb.parentElement !== grow || tb.nextElementSibling !== ov)) grow.insertBefore(tb, ov);
1700
1756
  if (!card.__dshClSentinel || !card.__dshClSentinel.isConnected) {
1701
1757
  const s = document.createElement("div");
1702
1758
  s.className = SENTINEL;
@@ -1802,8 +1858,10 @@ window.__ModuleLoader__.load({
1802
1858
  }
1803
1859
  if (card.__dshClFloat) { card.__dshClFloat.remove(); card.__dshClFloat = null; }
1804
1860
  card.removeAttribute(READY_KEY);
1805
- const tb = card.querySelector("." + TOOLBAR);
1861
+ // v0.2.14:工具栏在 card 外(父容器内),先引用/父容器找,找不到再全局兜底
1862
+ const tb = card.__dshClToolbar || (card.parentElement && card.parentElement.querySelector("." + TOOLBAR));
1806
1863
  if (tb) tb.remove();
1864
+ card.__dshClToolbar = null;
1807
1865
  const input = card.querySelector(INPUT_SEL);
1808
1866
  if (input) {
1809
1867
  input.classList.remove(HOST, MONO_ALL);
@@ -1820,6 +1878,8 @@ window.__ModuleLoader__.load({
1820
1878
  }
1821
1879
  const s = document.getElementById(STYLE_ID);
1822
1880
  if (s) s.remove();
1881
+ // 卡外工具栏全局兜底:card 已随会话切换消失时上面的引用清不到
1882
+ document.querySelectorAll("." + TOOLBAR).forEach((el) => el.remove());
1823
1883
  };
1824
1884
  });
1825
1885
  }
@@ -27,13 +27,15 @@
27
27
  浏览器半的组成:
28
28
 
29
29
  ```
30
+ ┌─ 格式工具栏 .dsh-cl-toolbar(v0.2.14 起挂在输入卡外、卡正上方——
31
+ │ card 父容器内 card 前一格,宽度从 card 同步,不占输入框内部高度)
32
+ │
30
33
  ┌─ 官方输入卡 [data-composer-card]
31
34
  │ ┌─ 官方 Lexical 编辑器 [data-composer-input](contenteditable)
32
35
  │ │ 真实文字:-webkit-text-fill-color:transparent(透明但仍在排版)
33
36
  │ │ position:relative; z-index:1(caret/选区盖在渲染层之上)
34
37
  │ ├─ 渲染层 .dsh-cl-live(自建,pointer-events:none,z-index:0)
35
38
  │ │ 逐字符定位在编辑器文字的真实坐标上
36
- │ └─ 格式工具栏(sticky,挂在滚动容器内)
37
39
  │
38
40
  ├─ 键盘捕获层:[data-composer-card] capture 阶段,先于官方 Lexical keymap
39
41
  └─ 数据源:直接读编辑器 DOM → 投影文本(零服务注入)
@@ -161,7 +163,7 @@ dsh 0.1.5 前端是 CSS Modules——类名全带随机 hash(每次构建变
161
163
 
162
164
  同理,对官方**布局**的适配也用几何法而非类名:图片附件在场时的工具栏让位靠「检测编辑器外的 img → 向上找全宽祖先取底边」,官方 DOM 怎么改都不失效。
163
165
 
164
- 顺带兜底的两个官方定位问题(均为几何法):图片附件在场时候选菜单悬空(官方菜单 absolute + `bottom:4px` 锚定不感知附件栏——bottom 锚定下 margin 零位移、top 与 bottom 同设会拉伸,只有 `transform: translateY` 与官方零冲突且天然幂等收敛);工具栏盖附件缩略图(根治 = 工具栏挂进滚动容器 + `position:sticky; top:0`,附件栏在滚动容器外,sticky 天然让位)。
166
+ 顺带兜底的两个官方定位问题(均为几何法):图片附件在场时候选菜单悬空(官方菜单 absolute + `bottom:4px` 锚定不感知附件栏——bottom 锚定下 margin 零位移、top 与 bottom 同设会拉伸,只有 `transform: translateY` 与官方零冲突且天然幂等收敛);工具栏盖附件缩略图(v0.2.8 曾用「挂进滚动容器 + sticky」根治,**v0.2.14 起工具栏整体迁到输入卡外正上方,与卡内附件栏物理分层,天然无重叠**;宽度从 `card.offsetWidth` 同步而非 CSS `width:100%`——父容器内容宽 ≠ card 宽)。
165
167
 
166
168
  ## 8. 等宽字体体系
167
169
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-composer-live",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "description": "DSH Web 0.1.5+ 输入框增强(Lexical contenteditable 架构版):markdown 实时渲染 + 代码块语法高亮/段落级等宽 + 格式工具栏(常驻顶条 + 选区浮动条)+ 70vh 展开 + 大段粘贴包代码块 + Esc 分发。纯浏览器端插件,零依赖,不改官方源码。仿 Open WebUI 输入体验。",
5
5
  "type": "module",
6
6
  "main": "index.js",