dsh-mindmap 0.18.9 → 0.18.12

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 (3) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/client.js +65 -14
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -38,6 +38,8 @@ All notable changes to this project are documented here. Release-specific notes
38
38
 
39
39
  ### Fixed
40
40
 
41
+ - Standalone mindmap panel and dsh-zterm's standalone panel no longer fight over the `#root` layout (issue #6). Both plugins now inject the same layout-push rule, so `#root` width is viewport minus mindmap, zterm and sidebar widths and insertion order no longer decides which reserved width survives. The base rule no longer declares `transition`, so zterm open/close/drag stop re-laying out the whole window at 0.3s per frame; the mindmap keeps its 0.3s open/close animation through a temporary `dsh-layout-animating` class on `<html>` (about 320ms, only on open/close, never while dragging). Each open, close, or width change dispatches `dsh:panel-layout` on `window` with `{ id: 'dsh-mindmap', width }` (pixels, `0` when closed) after the CSS variable is written; unmounting announces width `0` and removes the mindmap's own class, timer and style. The matching dsh-zterm change ships separately, and issue #6 stays open until both sides are released. Better Sidebar mode, panel visuals, the width algorithm, and the issue #4 focus-sync and portal logic are unchanged.
42
+ - Standalone panels that mount already open (for example when the panel comes back from Better Sidebar mode with its open state kept) now play the same 0.3s open animation as a manual open, instead of appearing at their final position (issue #6 follow-up). The layout's previous state starts as closed, so the first layout pass treats an open mount as one open transition; closed mounts stay silent, and dragging or window resizing still never pulses the animation.
41
43
  - PNG export now fits text to its card and stops breaking English words apart. The export lays out its own SVG instead of reusing one fixed box width: every node sizes itself to its content (clamped between 72px and 380px), so a short title such as 阶段三 no longer leaves a mostly empty card while a long work item is squeezed into three cramped lines. Text width is measured with the browser's real font metrics (`canvas.measureText`, using the same font stack as the drawing) rather than a per-character guess, so each line is laid out against the card's content width and keeps its inner padding instead of hugging the card edge; environments without a canvas keep the character estimate as a fallback. Line breaking is word-aware: `Apollo`, `RabbitMQ` and `CICD` stay in one piece, Chinese still breaks per character, explicit newlines are honoured, and overlong tokens (long URLs) are still hard-broken so no text is dropped or truncated. The break decision also counts the gap that precedes it, so a line never spills into the inner padding, and the original whitespace order is preserved — leading and trailing spaces stay where the author wrote them, even when a long token is hard-broken. Nodes on the same level keep a shared left edge, so the tree still reads as aligned columns, and the canvas size/pixel safety limits, full text, tables and multi-line content stay as they were. Both 导出图片 and the node context menu's 复制图片 share this export chain, so both are fixed together.
42
44
 
43
45
  - Standalone panels now portal their fixed host to `document.body` instead of rendering inside the conversation header actions slot, preventing host header overflow from clipping the entire panel on DSH 0.2.2 (issue #5). Closing still keeps the workspace mounted with `display:none`; Better Sidebar tabs, layout-push behavior, resizing, and panel visuals remain unchanged.
package/client.js CHANGED
@@ -4958,17 +4958,31 @@ window.__ModuleLoader__.load({
4958
4958
  // 014 布局让位:面板打开/拖宽时把宽度写进 CSS 变量,挤窄 #root 推走
4959
4959
  // 聊天区(better-sidebar 同款);关闭/卸载时移除变量恢复全宽。
4960
4960
  // 仅独立壳模式启用——BS Tab 模式不渲染本组件,不写此变量。
4961
+ // issue #6(共享契约 L2/L3):写入/移除之后派发 dsh:panel-layout;只有 open
4962
+ // 切换才挂动画临时类——拖宽是逐帧跟随,动画会拖尾。
4963
+ // 上一次布局状态的初值取「关闭」:挂载前 #root 既无宽度变量也无动画类,所以
4964
+ // 首次挂载即打开也按一次开切换处理,播放一次开合动画(挂载即关不播放)。
4965
+ const layoutOpenRef = react.useRef(false);
4961
4966
  react.useLayoutEffect(() => {
4962
4967
  if (typeof document === "undefined") return;
4968
+ const toggled = layoutOpenRef.current !== open;
4969
+ layoutOpenRef.current = open;
4963
4970
  if (open) {
4964
4971
  document.documentElement.style.setProperty("--dsh-mindmap-width", `${panelWidth}px`);
4965
4972
  } else {
4966
4973
  document.documentElement.style.removeProperty("--dsh-mindmap-width");
4967
4974
  }
4975
+ if (toggled) pulseLayoutAnimating();
4976
+ dispatchPanelLayout(open ? panelWidth : 0);
4968
4977
  return () => {
4969
4978
  document.documentElement.style.removeProperty("--dsh-mindmap-width");
4970
4979
  };
4971
4980
  }, [open, panelWidth]);
4981
+ // issue #6 L5:卸载时清掉自己的动画类与计时器,并派发宽度 0(面板已不占位)。
4982
+ react.useLayoutEffect(() => () => {
4983
+ clearLayoutAnimating();
4984
+ dispatchPanelLayout(0);
4985
+ }, []);
4972
4986
 
4973
4987
  // 始终挂载 MindmapWorkspace:收起时用 display:none 隐藏外壳,
4974
4988
  // 但组件实例保留——hooks(auto-open / 焦点同步 / 目录树)照常跑。
@@ -5379,6 +5393,55 @@ window.__ModuleLoader__.load({
5379
5393
  return url.href;
5380
5394
  }
5381
5395
 
5396
+ /**
5397
+ * layout-push 规则(issue #6,共享契约 L1):与 zterm 逐字相同。两个插件都按
5398
+ * 视口 − 脑图 − zterm − sidebar 计算 #root,公式一致,插入顺序不再决定谁的预留
5399
+ * 宽度生效。基础块不得声明 transition;动画只属于「自己改宽度」的一方,由下方
5400
+ * html.dsh-layout-animating 临时类开启(L2)。
5401
+ */
5402
+ const LAYOUT_PUSH_CSS = [
5403
+ "#root{",
5404
+ " margin-right:calc(var(--dsh-mindmap-width,0px) + var(--dsh-zterm-width,0px) + var(--dsh-sidebar-width,0px))!important;",
5405
+ " width:calc(100% - var(--dsh-mindmap-width,0px) - var(--dsh-zterm-width,0px) - var(--dsh-sidebar-width,0px))!important;",
5406
+ "}",
5407
+ "html.dsh-layout-animating #root{transition:margin-right .3s ease-in-out,width .3s ease-in-out}",
5408
+ ].join("\n");
5409
+
5410
+ /**
5411
+ * 布局动画临时类(issue #6,L2):仅面板一键开/关时挂到 <html>,约 320ms 后
5412
+ * 移除,重复触发重置计时。拖宽与窗口 resize 不挂(逐帧跟随时动画会拖尾)。
5413
+ */
5414
+ const LAYOUT_ANIMATING_CLASS = "dsh-layout-animating";
5415
+ const LAYOUT_ANIMATING_MS = 320;
5416
+ let layoutAnimatingTimer = null;
5417
+ function pulseLayoutAnimating() {
5418
+ if (typeof document === "undefined") return;
5419
+ const root = document.documentElement;
5420
+ root.classList.add(LAYOUT_ANIMATING_CLASS);
5421
+ if (layoutAnimatingTimer !== null) clearTimeout(layoutAnimatingTimer);
5422
+ layoutAnimatingTimer = setTimeout(() => {
5423
+ layoutAnimatingTimer = null;
5424
+ root.classList.remove(LAYOUT_ANIMATING_CLASS);
5425
+ }, LAYOUT_ANIMATING_MS);
5426
+ }
5427
+ function clearLayoutAnimating() {
5428
+ if (layoutAnimatingTimer !== null) {
5429
+ clearTimeout(layoutAnimatingTimer);
5430
+ layoutAnimatingTimer = null;
5431
+ }
5432
+ if (typeof document !== "undefined") document.documentElement.classList.remove(LAYOUT_ANIMATING_CLASS);
5433
+ }
5434
+
5435
+ /**
5436
+ * 布局变更事件(issue #6,L3):面板 open/close/resize 后派发到 window,
5437
+ * detail = { id: "dsh-mindmap", width },width 为像素数,关闭为 0。zterm 据此
5438
+ * 收起自己的独立面板,替代其 MutationObserver 轮询。
5439
+ */
5440
+ function dispatchPanelLayout(width) {
5441
+ if (typeof window === "undefined") return;
5442
+ window.dispatchEvent(new CustomEvent("dsh:panel-layout", { detail: { id: "dsh-mindmap", width } }));
5443
+ }
5444
+
5382
5445
  function apply(ctx) {
5383
5446
  const face = {};
5384
5447
 
@@ -5476,13 +5539,7 @@ window.__ModuleLoader__.load({
5476
5539
  if (!layoutStyle) {
5477
5540
  layoutStyle = document.createElement("style");
5478
5541
  layoutStyle.setAttribute("data-dsh-mindmap", "layout-push");
5479
- layoutStyle.textContent = [
5480
- "#root{",
5481
- "margin-right:calc(var(--dsh-mindmap-width,0px) + var(--dsh-sidebar-width,0px))!important;",
5482
- "width:calc(100% - var(--dsh-mindmap-width,0px) - var(--dsh-sidebar-width,0px))!important;",
5483
- "transition:margin-right var(--ds-transition-duration-slow) var(--ds-ease-in-out),width var(--ds-transition-duration-slow) var(--ds-ease-in-out);",
5484
- "}",
5485
- ].join("");
5542
+ layoutStyle.textContent = LAYOUT_PUSH_CSS;
5486
5543
  document.head.appendChild(layoutStyle);
5487
5544
  }
5488
5545
  }
@@ -5498,13 +5555,7 @@ window.__ModuleLoader__.load({
5498
5555
  // ctx.effect 不可用:直接注入(015 原始行为),standalone 模式。
5499
5556
  const style = document.createElement("style");
5500
5557
  style.setAttribute("data-dsh-mindmap", "layout-push");
5501
- style.textContent = [
5502
- "#root{",
5503
- "margin-right:calc(var(--dsh-mindmap-width,0px) + var(--dsh-sidebar-width,0px))!important;",
5504
- "width:calc(100% - var(--dsh-mindmap-width,0px) - var(--dsh-sidebar-width,0px))!important;",
5505
- "transition:margin-right var(--ds-transition-duration-slow) var(--ds-ease-in-out),width var(--ds-transition-duration-slow) var(--ds-ease-in-out);",
5506
- "}",
5507
- ].join("");
5558
+ style.textContent = LAYOUT_PUSH_CSS;
5508
5559
  document.head.appendChild(style);
5509
5560
  }
5510
5561
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mindmap",
3
- "version": "0.18.9",
3
+ "version": "0.18.12",
4
4
  "description": "Mindmap plugin for DeepSeek Harness: a plain markdown file in the working directory IS the mindmap; the chat edits it step by step and the right-side panel follows live.",
5
5
  "repository": {
6
6
  "type": "git",