fix(style-source): 手动拉高提示词节点时文字不再卡在 240px (1.0.2)
上一版注入的 `.iwb-node .iwb-textarea-plain{max-height:240px}` 把宿主
`.iwb-node-fixed .iwb-textarea{max-height:none;height:auto!important}` 盖掉了:
两者特异性同为 (0,2,0),插件样式注在 style.css 之后 ⇒ 上限赢。用户拉高节点
后文字仍停在 240px,下面一大片空白。
- 上限改为只作用于 `.iwb-node:not(.iwb-node-fixed)`(node.h 有值 = 手动拉过尺寸),
并补 `.iwb-node.iwb-node-fixed .iwb-textarea-plain{max-height:none}` 兜底
- harness:合成宿主补抄 style.css 的 fixed 规则;新增 2 条断言(文本域随节点撑满 / maxH=none)
- 实测 273px 默认节点仍限 240 内滚动;拉高到 522 时 textarea 撑到 492,无裁切
This commit is contained in:
1 parent
99717eb5e8
commit
4f7bed96c6
4 files changed
+56
-9
No files matched your search
+10
-4
@@ -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`,效果一致)。
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -54,7 +54,14 @@ const PNG_1PX = Buffer.from(
|
||||
|
||||
const PAGE_HTML = `<!doctype html><html><head><meta charset="utf-8">
|
||||
<style>html,body{margin:0;height:100%;font-family:system-ui,sans-serif}
|
||||
#stage{display:flex;align-items:stretch;height:100vh;padding:0}</style></head>
|
||||
#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}
|
||||
</style></head>
|
||||
<body><div id="stage"></div></body></html>`
|
||||
|
||||
async function main() {
|
||||
@@ -126,7 +133,7 @@ async function main() {
|
||||
const m = window.__manifest
|
||||
return { id: m.id, name: m.name, version: m.version, apiVersion: m.apiVersion, caps: m.capabilities, hasDataUrl: Boolean(m.settings && m.settings.dataUrl) }
|
||||
})
|
||||
check('manifest id/version 正确', manifest.id === 'style-source' && manifest.version === '1.0.1', JSON.stringify({ id: manifest.id, version: manifest.version }))
|
||||
check('manifest id/version 正确', manifest.id === 'style-source' && manifest.version === '1.0.2', JSON.stringify({ id: manifest.id, version: manifest.version }))
|
||||
check('capabilities 含 panels+canvas+canvasWrite',
|
||||
['panels', 'canvas', 'canvasWrite'].every((c) => manifest.caps.includes(c)), manifest.caps.join(','))
|
||||
check('settings 暴露 dataUrl', manifest.hasDataUrl)
|
||||
@@ -182,6 +189,33 @@ async function main() {
|
||||
check('内联 height=1200 的文本域被压到 240(节点不再被拉长)', cap.cappedH > 0 && cap.cappedH <= 260, 'h=' + cap.cappedH + '(240 内容 + 边框)')
|
||||
check('超出部分在文本域内滚动', cap.overflowY === 'auto', cap.overflowY)
|
||||
|
||||
// 回归守门:默认只压「自动高」的节点;用户手动拉过尺寸(node.h → .iwb-node-fixed)时不能压,
|
||||
// 否则节点被拉高一米,文字还卡在 240px,下面留一大片空白
|
||||
const stretched = await page.evaluate(() => {
|
||||
const wrap = document.createElement('div')
|
||||
wrap.className = 'iwb-node iwb-node-fixed' // node.h 有值 → 宿主加这个 class
|
||||
wrap.style.cssText = 'width:280px;min-height:520px'
|
||||
const body = document.createElement('div')
|
||||
body.className = 'iwb-node-body'
|
||||
const ta = document.createElement('textarea')
|
||||
ta.className = 'iwb-textarea iwb-textarea-plain'
|
||||
ta.style.height = '1200px'
|
||||
ta.value = 'x'.repeat(4000)
|
||||
body.appendChild(ta)
|
||||
wrap.appendChild(body)
|
||||
document.getElementById('stage').appendChild(wrap)
|
||||
const r = {
|
||||
nodeH: Math.round(wrap.getBoundingClientRect().height),
|
||||
taH: Math.round(ta.getBoundingClientRect().height),
|
||||
cap: getComputedStyle(ta).maxHeight,
|
||||
}
|
||||
wrap.remove()
|
||||
return r
|
||||
})
|
||||
check('手动拉高节点后文本域跟着撑满(不再卡在 240)',
|
||||
stretched.taH > stretched.nodeH * 0.6, 'node=' + stretched.nodeH + ' textarea=' + stretched.taH + ' maxH=' + stretched.cap)
|
||||
check('手动拉高节点时上限被让开', stretched.cap === 'none', stretched.cap)
|
||||
|
||||
// ---- 数据加载 ----
|
||||
const loaded = await poll(async () => {
|
||||
const txt = await page.locator('.iwb-ss-status').innerText().catch(() => '')
|
||||
|
||||
Reference in new issue
Block a user