diff --git a/plugins/index.json b/plugins/index.json index 30b08a6..c07f437 100644 --- a/plugins/index.json +++ b/plugins/index.json @@ -64,9 +64,9 @@ }, { "id": "sticky", - "file": "plugin-sticky.d2b0bb7022e2.js", - "version": "1.0.2", - "integrity": "sha256-0rC7cCLiv15UN8vkk1O75JAfspbolXNN4nMsBH+K084=" + "file": "plugin-sticky.d56d16b30743.js", + "version": "1.0.3", + "integrity": "sha256-1W0WswdDfppndPhoc4ODRKzLLhSq6fc6J3MLNC/o3Lw=" }, { "id": "style-source", diff --git a/plugins/runtime/plugin-sticky.d2b0bb7022e2.js b/plugins/runtime/plugin-sticky.d56d16b30743.js similarity index 90% rename from plugins/runtime/plugin-sticky.d2b0bb7022e2.js rename to plugins/runtime/plugin-sticky.d56d16b30743.js index 21abc80..5d2fc83 100644 --- a/plugins/runtime/plugin-sticky.d2b0bb7022e2.js +++ b/plugins/runtime/plugin-sticky.d56d16b30743.js @@ -40,7 +40,8 @@ '.iwb-sticky-btn{cursor:pointer;border:1px solid rgba(0,0,0,.2);border-radius:6px;background:transparent;color:inherit;font-size:11px;padding:2px 6px;font-family:inherit;line-height:1.4;user-select:none}' + '.iwb-sticky-btn:hover{background:rgba(0,0,0,.07)}' + '.iwb-sticky-btn-on{font-weight:600;background:rgba(0,0,0,.1)}' + - '.iwb-sticky-dot{display:inline-block;width:14px;height:14px;border-radius:50%;border:1px solid rgba(0,0,0,.25);cursor:pointer;vertical-align:middle;padding:0}' + + // 调色圆点推到工具条最右端(右上),色板 right:8px 与圆点右缘对齐,落在其正下方。 + '.iwb-sticky-dot{display:inline-block;width:14px;height:14px;border-radius:50%;border:1px solid rgba(0,0,0,.25);cursor:pointer;vertical-align:middle;padding:0;margin-left:auto}' + '.iwb-sticky-dot-on{box-shadow:0 0 0 2px rgba(0,0,0,.55)}' + '.iwb-sticky-pal{position:absolute;top:100%;right:8px;z-index:20;display:grid;grid-template-columns:repeat(4,18px);gap:8px 6px;padding:10px;border-radius:10px;border:1px solid var(--iwb-border,#d5d9e0);background:var(--iwb-layer2,#fff);box-shadow:0 4px 16px rgba(0,0,0,.18)}' + '.iwb-sticky-pal-sw{width:18px;height:18px;border-radius:50%;border:1px solid rgba(0,0,0,.2);cursor:pointer;padding:0}' + @@ -137,7 +138,7 @@ } st.node = node st.props = props - syncSkeleton(st, data) + syncSkeleton(st, data, node) } function buildSkeleton(host, props) { @@ -286,7 +287,32 @@ if (!b.style.height && prev) b.style.height = prev } - function syncSkeleton(st, data) { + // 宿主 NodeCard 把 node.h 当作 minHeight 写在外框上(style.minHeight = node.h, height:auto)。 + // 这就是 v1.0.2「内容贴字了但外框还有一截空白、手柄拖不下去」的真正原因:插件只改了 + // textarea 高度,外框仍被 node.h 撑住。这里做两件事: + // 1. 内容高度 = 工具条 + 正文(不用 root.offsetHeight:root 会被旧的 minHeight 拉高, + // 读出来还是旧高度,会自我锁死); + // 2. 首次遇到「旧 h 明显大于内容」时把 node.h 校正到内容高度,顺手把外框 minHeight + // 覆盖成同一个值——resize 起点 (onResizeStart 读 n0.h) 才和实际视觉一致,拖小立刻生效。 + // 用户之后手动拖大的 h 不会再次被校正(只针对首次记录的 stale h),所以仍然可以拖大拖小。 + function fitOuterBox(st, node) { + if (!st || !st.root || !node) return + var toolsH = st.tools.offsetHeight || 30 + var bodyH = parseFloat(st.body.style.height) || 0 + if (!bodyH) return + 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 + 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 + if (card && card.style && card.style.minHeight !== floor + 'px') card.style.minHeight = floor + 'px' + } + + function syncSkeleton(st, data, node) { var bg = data.bgColor || DEFAULT_BG var size = normSize(data.fontSize == null ? DEFAULT_SIZE : data.fontSize) var weight = data.fontWeight === 600 ? 600 : 400 @@ -300,6 +326,7 @@ if (st.body.style.fontSize !== size + 'px') st.body.style.fontSize = size + 'px' if (st.body.style.fontWeight !== String(weight)) st.body.style.fontWeight = String(weight) fitBody(st, text, size) + fitOuterBox(st, node) if (st.bold.className !== 'iwb-sticky-btn' + (weight === 600 ? ' iwb-sticky-btn-on' : '')) { st.bold.className = 'iwb-sticky-btn' + (weight === 600 ? ' iwb-sticky-btn-on' : '') } @@ -386,7 +413,7 @@ global.IWBPluginHost.register({ id: 'sticky', name: '便利贴', - version: '1.0.2', + version: '1.0.3', apiVersion: 1, capabilities: ['panels', 'nodeTypes', 'canvas'], }, function (ctx) {