feat(plugin): 同步 promptlib 1.0.1(分组胶囊自适应换行)

- plugins/promptlib:转为目录形态(manifest.json + main.js + styles.css),旧单文件产物清理
  (源仓带 styles.css 即自动目录化,样式才能随包分发)
- tests/plugin-promptlib-render-test.js:钉住「无滚动容器 + 全部胶囊为换行容器直接子节点」
- 市场已发布 promptlib 1.0.1(客户端仍 3.25.57,无需重装)
This commit is contained in:
qiqi committed 2026-11-20 17:37:40 +08:00
1 parent 1738027da6
commit 411a7c9572
5 files changed
+61 -15

No files matched your search

+8 -3
View File
@@ -41,9 +41,14 @@
},
{
"id": "promptlib",
"file": "plugin-promptlib.a9e3cfbab06f.js",
"version": "1.0.0",
"integrity": "sha256-qePPurBvP7xuj3Oq10hg2WiLt0LqT81rygl5exb6/gg="
"dir": "promptlib",
"main": "main.js",
"style": "styles.css",
"version": "1.0.1",
"files": {
"main.js": "ce2d1347b8b61a75f16a54a96f16861066c6ca70add314216c33ba95b2eb2d60",
"styles.css": "2bce24d4fde9014b674397d94bbf5cdc6825ca600e3e942c057efa6b47f350ad"
}
},
{
"id": "image-annotate",
@@ -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 },
+19
View File
@@ -0,0 +1,19 @@
{
"id": "promptlib",
"name": "提示词库",
"version": "1.0.1",
"apiVersion": 1,
"main": "main.js",
"style": "styles.css",
"description": "右栏提示词列表:搜索/分组/收藏/新建编辑/插入画布/复制(数据由客户端提供)",
"author": "official",
"icon": "📖",
"tags": [
"资源",
"提示词"
],
"files": {
"main.js": "ce2d1347b8b61a75f16a54a96f16861066c6ca70add314216c33ba95b2eb2d60",
"styles.css": "2bce24d4fde9014b674397d94bbf5cdc6825ca600e3e942c057efa6b47f350ad"
}
}
+16
View File
@@ -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;
}
+8 -2
View File
@@ -56,8 +56,14 @@ const wait = (ms) => new Promise((r) => setTimeout(r, ms))
const cards = () => Array.from(host.querySelectorAll('.iwb-pcard'))
assert.strictEqual(cards().length, 3, '应渲染 3 条提示词,实际 ' + cards().length)
// 胶囊在横向滚动容器内
assert.ok(host.querySelector('.iwb-lib-chips-scroll .iwb-chip'), '胶囊应在 .iwb-lib-chips-scroll 内')
// 胶囊行:v1.0.1 改为适应面板宽度自动换行(宿主 nowrap + 滚动容器会让靠后的分组看不见也点不到)
const chipsWrap = host.querySelector('.iwb-plp-chips')
assert.ok(chipsWrap, '胶囊行应带 .iwb-plp-chips(自带换行样式的作用域类)')
assert.ok(/(^|\s)iwb-lib-chips(\s|$)/.test(chipsWrap.className), '应沿用宿主 .iwb-lib-chips')
assert.ok(!chipsWrap.querySelector('.iwb-lib-chips-scroll'), '不应再有单行滚动容器(改为换行)')
const chipEls = Array.from(chipsWrap.querySelectorAll('.iwb-chip'))
assert.ok(chipEls.every((c) => c.parentElement === chipsWrap), '全部胶囊(含分组名与 +/⚙)都应是换行容器的直接子节点')
assert.ok(chipEls.length >= 4, '胶囊应至少 全部/未分组/分组/+/⚙,实际 ' + chipEls.length)
// 搜索跨分组:停在「小红书」时搜「收藏」也能命中 q2
const chipXhs = Array.from(host.querySelectorAll('.iwb-chip')).find((c) => c.textContent.indexOf('小红书') === 0)