From 18dad1b9afedde95a23d8ae3bb384e8e5cc290f4 Mon Sep 17 00:00:00 2001 From: qiqi Date: Tue, 24 Nov 2026 11:52:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(plugins):=20=E5=90=8C=E6=AD=A5=E4=BE=BF?= =?UTF-8?q?=E5=88=A9=E8=B4=B4=20sticky=20v1.0.6=EF=BC=88=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E5=9B=9E=E7=BC=A9=E5=A4=96=E6=A1=86=E8=87=AA=E5=8A=A8=E9=99=8D?= =?UTF-8?q?=E9=AB=98=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/index.json | 6 ++-- ...21fe4.js => plugin-sticky.11daf5129b91.js} | 28 +++++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) rename plugins/runtime/{plugin-sticky.ec6ffaa21fe4.js => plugin-sticky.11daf5129b91.js} (95%) diff --git a/plugins/index.json b/plugins/index.json index 69fe24d..709ca23 100644 --- a/plugins/index.json +++ b/plugins/index.json @@ -64,9 +64,9 @@ }, { "id": "sticky", - "file": "plugin-sticky.ec6ffaa21fe4.js", - "version": "1.0.5", - "integrity": "sha256-7G/6oh/kod4qe0Zvt25O/5OFbO1hWJdk36mHcYEH218=" + "file": "plugin-sticky.11daf5129b91.js", + "version": "1.0.6", + "integrity": "sha256-Edr1EpuRGNLA4VpHjXgZ7voREYyjTtnmMtwFvTFxOMQ=" }, { "id": "style-source", diff --git a/plugins/runtime/plugin-sticky.ec6ffaa21fe4.js b/plugins/runtime/plugin-sticky.11daf5129b91.js similarity index 95% rename from plugins/runtime/plugin-sticky.ec6ffaa21fe4.js rename to plugins/runtime/plugin-sticky.11daf5129b91.js index 0b1de23..fbba3fe 100644 --- a/plugins/runtime/plugin-sticky.ec6ffaa21fe4.js +++ b/plugins/runtime/plugin-sticky.11daf5129b91.js @@ -299,7 +299,10 @@ // 读出来还是旧高度,会自我锁死); // 2. 首次遇到「旧 h 明显大于内容」时把 node.h 校正到内容高度,顺手把外框 minHeight // 覆盖成同一个值——resize 起点 (onResizeStart 读 n0.h) 才和实际视觉一致,拖小立刻生效。 - // 用户之后手动拖大的 h 不会再次被校正(只针对首次记录的 stale h),所以仍然可以拖大拖小。 + // 区分两种 h: + // - 插件自动跟随内容写出的 h:内容长高就涨、缩回就降(v1.0.6 修的「两行退回一行不缩」); + // - 用户拖手柄改出的 h:h 相对上一帧变了 ⇒ 尊重手动尺寸,只在内容超过它时顶一下。 + // 首次遇到的旧大 h 校正一次(staleH),之后进入自动跟随。 function fitOuterBox(st, node) { if (!st || !st.root || !node) return var toolsH = st.tools.offsetHeight || 30 @@ -308,9 +311,24 @@ var content = Math.round(toolsH + bodyH + 2) // +2 = 宿主节点上下各 1px 边框 var h = Number(node.h) || 0 if (st.staleH == null) st.staleH = h - // 文字变大后内容超过旧 h:同步把 h 顶上去,resize 起点才不会滞后一大截。 - // 首次遇到的旧大 h 也校正到内容高度;用户之后拖出来的其它更大 h 原样保留。 - if (h < content - 2 || (h > content + 2 && st.staleH === h)) node.h = content + + if (st.lastBoxH != null && h !== st.lastBoxH) { + // 外部(用户拖手柄)改了 h:退出自动跟随,保留手动尺寸 + st.autoFollow = false + } else if (st.autoFollow == null) { + // 首帧:旧 h 若明显大于内容,先校正一次,然后进入自动跟随 + if (h > content + 2 && st.staleH === h) { node.h = content; h = content } + st.autoFollow = true + } + + if (st.autoFollow) { + // 自动跟随:文本/字号增减都双向贴合(这是两行退回一行能缩回去的关键) + if (Math.abs(h - content) > 1) { node.h = content; h = content } + } else if (h < content - 2) { + // 手动尺寸只在内容超出时才顶高,不覆盖用户主动拖大的高度 + node.h = content; h = content + } + st.lastBoxH = h var floor = Math.max(content, Number(node.h) || 0) // root → host(.iwb-plugin-node-body) → card(.iwb-node) var card = st.root.parentNode && st.root.parentNode.parentNode @@ -418,7 +436,7 @@ global.IWBPluginHost.register({ id: 'sticky', name: '便利贴', - version: '1.0.5', + version: '1.0.6', apiVersion: 1, capabilities: ['panels', 'nodeTypes', 'canvas'], }, function (ctx) {