diff --git a/style-source/README.md b/style-source/README.md index 71a497d..f11cf0b 100644 --- a/style-source/README.md +++ b/style-source/README.md @@ -45,14 +45,20 @@ 风格提示词动辄上千字。宿主 `renderPromptBody` 用 `autoGrow` 把 textarea 高度直接设成 `scrollHeight`(**没有上限**), 所以一条长提示词插进画布会变成一根两米高的柱子,一张卡吃掉整个视口。 -插件在挂载时注入一条(幂等的)样式: +插件在挂载时注入两条(幂等的)样式: ```css -.iwb-node .iwb-textarea-plain { max-height: 240px } /* 高度来自设置项 promptMaxH */ +/* 自动高节点:压住上限,高度来自设置项 promptMaxH */ +.iwb-node:not(.iwb-node-fixed) .iwb-textarea-plain { max-height: 240px } +/* 用户手动拉过尺寸的节点(node.h 有值 → 宿主加 .iwb-node-fixed):让开上限,交给宿主拉伸规则 */ +.iwb-node.iwb-node-fixed .iwb-textarea-plain { max-height: none } ``` -- 节点尺寸从此**固定**(≈ max-height + 内边距),插了几张卡一眼看清; +- **默认**节点尺寸固定(≈ max-height + 内边距),插了几张卡一眼看清; - 宿主 `.iwb-textarea` 本来就是 `overflow-y: auto`,超出的部分在节点内滚动,**内容一个字都不丢**; +- **手动拉过右下角缩放手柄**的节点不受上限约束:宿主 `.iwb-node-fixed .iwb-textarea{flex:1 1 auto;height:auto!important}` + 会把文本域撑满节点,想多高就多高(⚠️ 前提是选择器带 `:not(.iwb-node-fixed)`——两条规则特异性同为 `(0,2,0)`, + 且插件样式注入得更晚,不排除的话会把宿主的拉伸规则压掉,节点被拉高后文字仍卡在 240px,下面留一片空白); - 想看全文照旧用节点气泡的「**放大编辑**」(⌘/Ctrl + E),那是不限高的浮层; - 选择器只碰**节点内**的纯文本域,宿主的弹窗 / 设置面板(`.iwb-modal-lg .iwb-textarea`)不受影响。 @@ -71,7 +77,7 @@ ```bash cp src/index.js /tmp/plugin-style-source.js cd ../image-workbench-web -node scripts/plugins-publish.mjs /tmp/plugin-<其余插件>.js /tmp/plugin-style-source.js --upload --version style-source=1.0.1 +node scripts/plugins-publish.mjs /tmp/plugin-<其余插件>.js /tmp/plugin-style-source.js --upload --version style-source=1.0.2 ``` 图标:宿主 `app.js` 的 `PLUGIN_ICONS` 可加 `'style-source': 'palette'`(不加则用面板 manifest 自带的 `palette`,效果一致)。 diff --git a/style-source/package.json b/style-source/package.json index d1326bf..8873ccd 100644 --- a/style-source/package.json +++ b/style-source/package.json @@ -1,7 +1,7 @@ { "name": "@iwb-plugin/style-source", "private": true, - "version": "1.0.1", + "version": "1.0.2", "description": "风格库:资源库面板里浏览 310 个 AI 绘画风格(12 分类 / 搜索 / 变量替换),一键把预览图插入画布 ref 节点、把提示词插入 prompt 节点", "ibwPlugin": { "id": "style-source", diff --git a/style-source/src/index.js b/style-source/src/index.js index 0975555..0f8e9eb 100644 --- a/style-source/src/index.js +++ b/style-source/src/index.js @@ -289,6 +289,11 @@ // · 宿主 .iwb-textarea 本身是 overflow-y:auto,超出部分在节点内滚动,内容一个字都不丢; // · 想看全文照旧用节点气泡的「放大编辑」(⌘/Ctrl+E),那里是不限高的浮层。 // 选择器只碰节点内的纯文本域,宿主的弹窗/设置面板(.iwb-modal-lg .iwb-textarea)不受影响。 + // + // ⚠️ 必须排除 `.iwb-node-fixed`(节点 h 有值 = 用户手动拉过尺寸): + // 宿主 style.css 里有 `.iwb-node-fixed .iwb-textarea{flex:1 1 auto;max-height:none;height:auto!important}`, + // 手拉节点时靠它把文本域撑满节点。原来不加 :not() 时两条规则特异性同为 (0,2,0), + // 而插件样式注入得更晚 ⇒ 上限赢了 ⇒ 节点被拉高后文字仍卡在 240px、下面一片空白(2026-11-02 反馈)。 const PROMPT_MAX_H = 240 function capHeightOf(ctx) { @@ -308,7 +313,9 @@ node = el('style', { id: id }) ;(document.head || document.documentElement).appendChild(node) } - node.textContent = '.iwb-node .iwb-textarea-plain{max-height:' + maxH + 'px}' + // 默认(自动高)节点压住上限;手动拉过尺寸的节点交给宿主拉伸规则,一个字都不裁 + node.textContent = '.iwb-node:not(.iwb-node-fixed) .iwb-textarea-plain{max-height:' + maxH + 'px}' + + '.iwb-node.iwb-node-fixed .iwb-textarea-plain{max-height:none}' } catch (error) { /* 注入失败只是节点还会被拉长,不影响插入 */ } } @@ -885,7 +892,7 @@ global.IWBPluginHost.register({ id: 'style-source', name: '风格库', - version: '1.0.1', + version: '1.0.2', apiVersion: 1, capabilities: ['panels', 'canvas', 'canvasWrite'], settings: { diff --git a/style-source/tools/harness.mjs b/style-source/tools/harness.mjs index a26086c..4f23a01 100644 --- a/style-source/tools/harness.mjs +++ b/style-source/tools/harness.mjs @@ -54,7 +54,14 @@ const PNG_1PX = Buffer.from( const PAGE_HTML = `
+#stage{display:flex;align-items:stretch;height:100vh;padding:0} +/* 从宿主 style.css 抄的关键几条,否则「手动拉过尺寸的节点」这条测不出来 */ +.iwb-node{display:flex;flex-direction:column;border:1px solid #d5d9e0;border-radius:14px;position:relative} +.iwb-node-body{padding:8px 10px;flex:1 1 auto;min-height:0} +.iwb-textarea{min-height:56px;overflow-y:auto;width:100%;box-sizing:border-box;resize:none} +.iwb-node-fixed .iwb-node-body{display:flex;flex-direction:column;overflow:visible;min-height:0} +.iwb-node-fixed .iwb-textarea{flex:1 1 auto;max-height:none;min-height:56px;height:auto !important} +