From 5da8f6d3f123e36f4c532125324d1af5082321c9 Mon Sep 17 00:00:00 2001 From: qiqi Date: Fri, 20 Nov 2026 17:37:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(promptlib):=20=E5=88=86=E7=BB=84=E8=83=B6?= =?UTF-8?q?=E5=9B=8A=E6=94=B9=E4=B8=BA=E9=80=82=E5=BA=94=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E5=AE=BD=E5=BA=A6=E8=87=AA=E5=8A=A8=E6=8D=A2=E8=A1=8C=20v1.0.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 与节点组同一问题:宿主 .iwb-lib-chips 是 nowrap + .iwb-lib-chips-scroll 单行滚动(右侧渐隐), 分组多时靠后的分类看不见也点不到。 - 去掉滚动容器,胶囊行加 .iwb-plp-chips,自带 styles.css 用双类选择器改 flex-wrap: wrap - +/⚙ 由「钉在滚动区右侧」改为随胶囊一起换行(与 grouplib 一致),归到 .iwb-plp-add --- promptlib/package.json | 2 +- promptlib/src/index.js | 20 ++++++++++---------- promptlib/styles.css | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 promptlib/styles.css diff --git a/promptlib/package.json b/promptlib/package.json index 08fad7d..a66bdef 100644 --- a/promptlib/package.json +++ b/promptlib/package.json @@ -1,7 +1,7 @@ { "name": "@iwb-plugin/promptlib", "private": true, - "version": "1.0.0", + "version": "1.0.1", "description": "提示词库:右栏提示词列表(搜索/分组/收藏/新建编辑/插入画布/复制/删除),数据由宿主 promptlib 能力提供", "ibwPlugin": { "id": "promptlib", diff --git a/promptlib/src/index.js b/promptlib/src/index.js index cdc624b..5580cc8 100644 --- a/promptlib/src/index.js +++ b/promptlib/src/index.js @@ -410,9 +410,10 @@ fixed.appendChild(scope) } - // 分组胶囊:滚动区 + 右侧固定 + / ⚙ - var chips = el('div', { class: 'iwb-lib-chips' }) - var chipsScroll = el('div', { class: 'iwb-lib-chips-scroll' }) + // 分组胶囊:与节点组一致 —— 适应面板宽度自动换行。 + // 宿主 .iwb-lib-chips 是 nowrap + .iwb-lib-chips-scroll 单行滚动(右侧渐隐), + // 分组多时靠后的分类看不见也点不到;换行规则在插件自带 styles.css 的 .iwb-plp-chips 里。 + var chips = el('div', { class: 'iwb-lib-chips iwb-plp-chips' }) var chip = function (label, value, count, drop) { var active = (value === 'all' && (filter === 'all' || words().length)) || filter === value var b = el('button', { class: 'iwb-chip' + (active ? ' iwb-chip-active' : '') + (drop ? ' iwb-chip-drop' : ''), title: drop ? '拖拽提示词卡片到此 = 移动到该分组' : '' }) @@ -431,11 +432,10 @@ } return b } - chipsScroll.appendChild(chip('全部', 'all', prompts.length)) - chipsScroll.appendChild(chip('未分组', '__none__', countOf('__none__'), true)) - gs.forEach(function (g) { chipsScroll.appendChild(chip(g.name, g.name, countOf(g.name), true)) }) - chips.appendChild(chipsScroll) - var addChip = el('button', { class: 'iwb-chip iwb-chip-add', title: '新建分组', text: '+' }) + chips.appendChild(chip('全部', 'all', prompts.length)) + chips.appendChild(chip('未分组', '__none__', countOf('__none__'), true)) + gs.forEach(function (g) { chips.appendChild(chip(g.name, g.name, countOf(g.name), true)) }) + var addChip = el('button', { class: 'iwb-chip iwb-plp-add iwb-chip-add', title: '新建分组', text: '+' }) addChip.addEventListener('click', function () { var input = el('input', { class: 'iwb-input', placeholder: '新分组名称' }) var mask = el('div', { class: 'iwb-modal-mask' }) @@ -462,7 +462,7 @@ setTimeout(function () { try { input.focus() } catch (e) { /* ignore */ } }, 0) }) chips.appendChild(addChip) - var mgChip = el('button', { class: 'iwb-chip iwb-chip-add', title: '管理分组(重命名 / 排序 / 删除)', text: '⚙' }) + var mgChip = el('button', { class: 'iwb-chip iwb-plp-add iwb-chip-add', title: '管理分组(重命名 / 排序 / 删除)', text: '⚙' }) mgChip.addEventListener('click', openManager) chips.appendChild(mgChip) fixed.appendChild(chips) @@ -573,7 +573,7 @@ global.IWBPluginHost.register({ id: 'promptlib', name: '提示词库', - version: '1.0.0', + version: '1.0.1', apiVersion: 1, capabilities: ['panels', 'promptlib'], data: { schemaVersion: 1, maxBytes: 65536 }, diff --git a/promptlib/styles.css b/promptlib/styles.css new file mode 100644 index 0000000..4179f16 --- /dev/null +++ b/promptlib/styles.css @@ -0,0 +1,16 @@ +/* promptlib(提示词库)自带样式 + 作用域全部带 .iwb-plp-*,不影响宿主与其他插件;样式随插件发布,不必等客户端发版。 */ + +/* 分组胶囊「适应面板宽度」自动换行。 + 宿主的 .iwb-lib-chips 是 flex-wrap: nowrap(配 .iwb-lib-chips-scroll 做单行横向滚动 + 右侧渐隐), + 分组多时靠后的分类看不见也点不到。双类选择器提高优先级(不依赖样式注入顺序)。 */ +.iwb-lib-chips.iwb-plp-chips { + flex-wrap: wrap; + row-gap: 6px; +} + +/* + / ⚙ 是动作按钮,不是分组名:不参与压缩,并与最后一个分组稍作分隔 */ +.iwb-plp-chips .iwb-plp-add { + flex: 0 0 auto; + margin-left: 2px; +}