Compare commits

..
Author SHA1 Message Date
qiqi deac7513fd feat(promptlib): v1.11.0 封面文件治理(保存即落文件 + 孤儿封面回收)
validate / validate (push) Canceled after 0s
- 抽 coverFileName():迁移/保存/导入四处的内联 djb2 哈希合并为一处,
  同一张图不会再存出两个文件(文件名 = 内容哈希,天然去重)
- 上传封面、保存词条、另存副本都先 ensureCoverFile() 落成文件,
  数据 JSON 里只留 { img: 文件名 };失败退回内联 base64(宁可不省体积,不丢封面)
- 新增 plpGcCoverFiles():回收不再被任何词条引用的封面文件
  安全线:数据不是从插件 JSON 读来的不删 / keep 为空不删 / 只删图片扩展名 /
  刚 put 未引用的名字进 pending 跳过 / 两张词条共用一个封面天然保留
- 触发:面板加载后延迟 4s 自动一次 + 删词条后一次 + 设置页「清理未引用封面」手动入口
- 设置页占用行改成「封面 N 张 / 文件 M 个」,两者不等即说明有孤儿
- 样式散值归零(4px→6px、margin 13px→12px),插件尺度棘轮基线保持 0
- harness 31 → 44 项(含 plpGcCoverFiles 行为断言:只删未引用 / 空集合不删 / 无 FS 跳过)
2026-11-24 15:14:25 +08:00
qiqi f0568342b1 feat(promptlib): v1.10.1 移除分享封面开关 + 详情底部分享/插入组间竖向分割线
validate / validate (push) Canceled after 0s
2026-11-24 14:25:02 +08:00
qiqi b9c110709d feat(promptlib): v1.10.0 文本分享/文件分享双路径 + 顶部文件/文本/新建 + 右键去分组分类 + 设置去导入入口
validate / validate (push) Canceled after 0s
2026-11-24 14:19:00 +08:00
qiqi c9bb3b09f3 feat(promptlib): v1.9.3 编辑区变量浅主色底色(只画色块不改输入)+ 横向滚动同步
validate / validate (push) Canceled after 0s
2026-11-24 13:35:53 +08:00
qiqi 4f4e64a989 feat(promptlib): v1.9.2 分享设置增加「附带封面图片」开关(默认开)
validate / validate (push) Canceled after 0s
2026-11-24 13:25:09 +08:00
qiqi 9959096ab3 fix(sticky): v1.0.7 自定义调色后色板自动收起
validate / validate (push) Canceled after 0s
2026-11-24 11:54:55 +08:00
qiqi e7f8e68909 fix(sticky): v1.0.6 文本缩回时外框高度自动回缩
validate / validate (push) Canceled after 0s
2026-11-24 11:52:14 +08:00
qiqi eb6880b11f fix(sticky): v1.0.5 圆角对齐宿主节点(node-radius - 1px)
validate / validate (push) Canceled after 0s
2026-11-24 11:49:05 +08:00
qiqi ba9a4448e4 fix(sticky): v1.0.4 textarea rows=1 去掉默认预留一行高度
validate / validate (push) Canceled after 0s
2026-11-24 11:45:14 +08:00
qiqi 5ff3318fb9 fix(sticky): v1.0.3 外框高度贴字(覆盖宿主 minHeight)+ 调色点右上
validate / validate (push) Canceled after 0s
2026-11-24 11:37:24 +08:00
qiqi 8c6ed43078 fix(sticky): v1.0.2 便签贴字(textarea 内容自适应)+ 色板跟随调色按钮
validate / validate (push) Canceled after 0s
2026-11-24 11:20:19 +08:00
qiqi 9ed18827a8 feat(promptlib): 1.9.1 面板顶部加「导入词例」与「+ 新建词例」
validate / validate (push) Canceled after 0s
2026-11-24 11:16:22 +08:00
qiqi 352cac6031 fix(sticky): v1.0.1 修拖动漏底/字号无上限/双击编辑(对齐宿主文本节点机制)
validate / validate (push) Canceled after 0s
2026-11-24 10:59:56 +08:00
qiqi 2d2738f3a1 feat(promptlib,gallery): promptlib 1.9.0 单条分享/导入分享;gallery 1.6.12 打开本地目录
validate / validate (push) Canceled after 0s
2026-11-24 10:39:25 +08:00
qiqi 27a641903c feat(sticky): 便利贴插件 v1.0.0 —— 多行文本+字号/粗细+8色背景,纯标注不连线
validate / validate (push) Canceled after 0s
2026-11-24 10:37:11 +08:00
qiqi 89c2dca424 fix(gallery): 1.6.11 每次重排重量宽度 + 缩略图 eager,修复面板显隐后不刷新
validate / validate (push) Canceled after 0s
2026-11-24 07:09:27 +08:00
qiqi b8718d6810 refactor(gallery,grouplib): 尺寸收进 token 闭集(1.6.10 / 1.0.5)
validate / validate (push) Canceled after 0s
2026-11-23 20:15:45 +08:00
qiqi 17fd3be13b fix(promptlib): 1.8.24 放置框 z-index 改用 --iwb-z-anchor(过 token-lint)
validate / validate (push) Canceled after 0s
2026-11-23 20:13:23 +08:00
qiqi e7d54cb0a8 refactor(promptlib): 1.8.23 尺寸迁移到 token 闭集(字号/圆角/间距),棘轮基线下调
validate / validate (push) Canceled after 0s
2026-11-23 20:12:16 +08:00
qiqi 1aba7a0c94 refactor(promptlib): 1.8.22 颜色迁移到插件 token(视觉保持 1.8.8 基线)+ 映射表
validate / validate (push) Canceled after 0s
2026-11-23 20:06:05 +08:00
qiqi 4fc4e469c2 feat(batch-export): 1.2.2 状态色跟随宿主主题 + 去掉纯蓝主按钮
validate / validate (push) Canceled after 0s
- 成功/错误/进度条/hover 改为 var(--iwb-ok|err|brand-text|text|layer, 私有值兜底),暗色自动变亮
- 主按钮从实心蓝 #2f6fed + 白字改为 text/layer 成对反相(亮 9.51 / 暗 14.10 对比),与项目全灰阶约束一致
- 热按钮改绿描边 + 绿字 + 14% 绿底,避免暗色亮绿底压白字
- 状态文字照 design-tokens.md §3 的 iwb-mk-badge 范例用 color-mix 往 text 压 18%
- 配套宿主 M6:亮色 --iwb-ok/err/warn 调深,状态色文字对比 2.13 → 5.38
2026-11-23 18:18:51 +08:00
17 changed files with 1638 additions and 209 deletions

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "@iwb-plugin/batch-export", "name": "@iwb-plugin/batch-export",
"private": true, "private": true,
"version": "1.2.1", "version": "1.2.2",
"description": "批量出图:资源中心面板里勾选 ref 节点,串行跑(可选本机抠图)→ 白底/透明合成 → 双版本编码 → 打包 ZIP 下载;行内可单张下载 JPG/PNG", "description": "批量出图:资源中心面板里勾选 ref 节点,串行跑(可选本机抠图)→ 白底/透明合成 → 双版本编码 → 打包 ZIP 下载;行内可单张下载 JPG/PNG",
"ibwPlugin": { "ibwPlugin": {
"id": "batch-export", "id": "batch-export",
+20 -10
View File
@@ -454,37 +454,47 @@
'.iwb-bx-name{flex:1;min-width:70px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}', '.iwb-bx-name{flex:1;min-width:70px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
'.iwb-bx-tag{font-size:11px;white-space:nowrap;color:var(--iwb-text2,#4d5668);', '.iwb-bx-tag{font-size:11px;white-space:nowrap;color:var(--iwb-text2,#4d5668);',
'max-width:46%;min-width:0;overflow:hidden;text-overflow:ellipsis}', 'max-width:46%;min-width:0;overflow:hidden;text-overflow:ellipsis}',
'.iwb-bx-tag-ok{color:#1d9e75}', // 状态色不能直接当文字色:宿主 --iwb-ok 亮色是 #22c55e,压在浅页面上对比只有 2.13。
'.iwb-bx-tag-err{color:#d85a30}', // 照 design-tokens.md §3 的 iwb-mk-badge 范例,用 color-mix 往 --iwb-text 压 18%,亮暗两端都读得清。
'.iwb-bx-tag-ok{color:color-mix(in srgb,var(--iwb-ok,#1d9e75) 82%,var(--iwb-text,#1c2333))}',
'.iwb-bx-tag-err{color:color-mix(in srgb,var(--iwb-err,#d85a30) 82%,var(--iwb-text,#1c2333))}',
// 行内单张下载:常驻不悬浮(要一眼看出「这行能下什么」),无产物时灰掉但保留占位, // 行内单张下载:常驻不悬浮(要一眼看出「这行能下什么」),无产物时灰掉但保留占位,
// 避免产物出现时行宽突然变化导致列表跳动。 // 避免产物出现时行宽突然变化导致列表跳动。
'.iwb-bx-dl{flex:0 0 auto;padding:2px 6px;border-radius:5px;font-size:11px;line-height:1.5;', '.iwb-bx-dl{flex:0 0 auto;padding:2px 6px;border-radius:5px;font-size:11px;line-height:1.5;',
'font-family:ui-monospace,SFMono-Regular,Menlo,monospace;border:1px solid var(--iwb-border,#d5d9e0);', 'font-family:ui-monospace,SFMono-Regular,Menlo,monospace;border:1px solid var(--iwb-border,#d5d9e0);',
'background:transparent;color:var(--iwb-text2,#4d5668);cursor:pointer}', 'background:transparent;color:var(--iwb-text2,#4d5668);cursor:pointer}',
'.iwb-bx-dl-on{background:var(--iwb-layer,#f0f1f4);color:var(--iwb-text,#1c2333);border-color:var(--iwb-text2,#4d5668)}', '.iwb-bx-dl-on{background:var(--iwb-layer,#f0f1f4);color:var(--iwb-text,#1c2333);border-color:var(--iwb-text2,#4d5668)}',
'.iwb-bx-dl-on:hover{border-color:#2f6fed;color:#2f6fed}', '.iwb-bx-dl-on:hover{border-color:var(--iwb-brand,#2f6fed);color:var(--iwb-brand-text,#2f6fed)}',
'.iwb-bx-dl[disabled]{opacity:.45;cursor:not-allowed;border-color:var(--iwb-border,#d5d9e0)}', '.iwb-bx-dl[disabled]{opacity:.45;cursor:not-allowed;border-color:var(--iwb-border,#d5d9e0)}',
'.iwb-bx-empty{padding:24px 12px;text-align:center;color:var(--iwb-text2,#4d5668)}', '.iwb-bx-empty{padding:24px 12px;text-align:center;color:var(--iwb-text2,#4d5668)}',
// 缩略图:小方图(30px)常驻在行首,跑完换成产物本身,一眼能对上「哪张图、出了什么」 // 缩略图:小方图(30px)常驻在行首,跑完换成产物本身,一眼能对上「哪张图、出了什么」
'.iwb-bx-thumb{width:30px;height:30px;flex:0 0 auto;object-fit:contain;border-radius:5px;', '.iwb-bx-thumb{width:30px;height:30px;flex:0 0 auto;object-fit:contain;border-radius:5px;',
'border:1px solid var(--iwb-border,#d5d9e0);background:#fff/*iwb:content*/;cursor:zoom-in;padding:1px}', 'border:1px solid var(--iwb-border,#d5d9e0);background:#fff/*iwb:content*/;cursor:zoom-in;padding:1px}',
'.iwb-bx-thumb-out{border-color:#1d9e75;cursor:zoom-in}', '.iwb-bx-thumb-out{border-color:var(--iwb-ok,#1d9e75);cursor:zoom-in}',
'.iwb-bx-thumb-ph{background:var(--iwb-layer,#f0f1f4);cursor:default}', '.iwb-bx-thumb-ph{background:var(--iwb-layer,#f0f1f4);cursor:default}',
'.iwb-bx-done{display:none;align-items:center;gap:6px;padding:9px 12px;font-size:11px;', '.iwb-bx-done{display:none;align-items:center;gap:6px;padding:9px 12px;font-size:11px;',
'color:#1d9e75;background:rgba(29,158,117,.08);border-top:1px solid var(--iwb-border,#d5d9e0)}', 'color:color-mix(in srgb,var(--iwb-ok,#1d9e75) 82%,var(--iwb-text,#1c2333));',
'background:color-mix(in srgb,var(--iwb-ok,#1d9e75) 8%,transparent);',
'border-top:1px solid var(--iwb-border,#d5d9e0)}',
'.iwb-bx-zoom{position:fixed;inset:0;z-index:99999;display:flex;align-items:center;justify-content:center;', '.iwb-bx-zoom{position:fixed;inset:0;z-index:99999;display:flex;align-items:center;justify-content:center;',
'background:rgba(0,0,0,.72);cursor:zoom-out}', 'background:rgba(0,0,0,.72);cursor:zoom-out}',
'.iwb-bx-zoom img{max-width:86vw;max-height:86vh;border-radius:8px;background:#fff/*iwb:content*/}', '.iwb-bx-zoom img{max-width:86vw;max-height:86vh;border-radius:8px;background:#fff/*iwb:content*/}',
// 双类选择器:单靠 .iwb-bx-btn-hot 会被后定义的 .iwb-bx-btn 背景覆盖(同特异性,后者胜) // 主/热按钮此前是纯蓝 #2f6fed 实心 + 白字:与项目「全灰阶、无蓝」的配色约束冲突,
'.iwb-bx-btn.iwb-bx-btn-hot{background:#1d9e75;border-color:#1d9e75;color:#fff}', // 且暗色下亮绿底压白字对比度不足。改成宿主语义色成对反相 + 状态色描边,
// var() 兜底保留私有值,脱离宿主独立运行时不退化。
'.iwb-bx-btn.iwb-bx-btn-hot{',
'background:color-mix(in srgb,var(--iwb-ok,#1d9e75) 14%,transparent);',
'border-color:color-mix(in srgb,var(--iwb-ok,#1d9e75) 82%,var(--iwb-text,#1c2333));',
'color:color-mix(in srgb,var(--iwb-ok,#1d9e75) 82%,var(--iwb-text,#1c2333))}',
'.iwb-bx-foot{display:flex;align-items:center;gap:8px;padding:10px 12px;', '.iwb-bx-foot{display:flex;align-items:center;gap:8px;padding:10px 12px;',
'border-top:1px solid var(--iwb-border,#d5d9e0)}', 'border-top:1px solid var(--iwb-border,#d5d9e0)}',
'.iwb-bx-prog{flex:1;height:4px;border-radius:2px;background:var(--iwb-border,#d5d9e0);overflow:hidden}', '.iwb-bx-prog{flex:1;height:4px;border-radius:2px;background:var(--iwb-border,#d5d9e0);overflow:hidden}',
'.iwb-bx-prog i{display:block;height:100%;width:0;background:#2f6fed;transition:width .15s}', '.iwb-bx-prog i{display:block;height:100%;width:0;background:var(--iwb-brand-text,#2f6fed);transition:width .15s}',
'.iwb-bx-btn{padding:5px 10px;border-radius:6px;border:1px solid var(--iwb-border,#d5d9e0);', '.iwb-bx-btn{padding:5px 10px;border-radius:6px;border:1px solid var(--iwb-border,#d5d9e0);',
'background:var(--iwb-layer,#f0f1f4);color:inherit;font:inherit;cursor:pointer;white-space:nowrap}', 'background:var(--iwb-layer,#f0f1f4);color:inherit;font:inherit;cursor:pointer;white-space:nowrap}',
'.iwb-bx-btn[disabled]{opacity:.45;cursor:not-allowed}', '.iwb-bx-btn[disabled]{opacity:.45;cursor:not-allowed}',
'.iwb-bx-btn-primary{background:#2f6fed;border-color:#2f6fed;color:#fff}', '.iwb-bx-btn-primary{background:var(--iwb-text,#2f6fed);border-color:var(--iwb-text,#2f6fed);',
'color:var(--iwb-layer,#fff)}',
].join('') ].join('')
function ensureStyle() { function ensureStyle() {
@@ -500,7 +510,7 @@
global.IWBPluginHost.register({ global.IWBPluginHost.register({
id: 'batch-export', id: 'batch-export',
name: '批量出图', name: '批量出图',
version: '1.2.1', version: '1.2.2',
apiVersion: 1, apiVersion: 1,
capabilities: ['panels', 'canvas'], capabilities: ['panels', 'canvas'],
settings: { settings: {
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "@iwb-plugin/gallery", "name": "@iwb-plugin/gallery",
"private": true, "private": true,
"version": "1.6.9", "version": "1.6.12",
"description": "图库:右栏图片墙(筛选/多选/预览/插入画布/下载/删除),数据由宿主 gallery 能力提供", "description": "图库:右栏图片墙(筛选/多选/预览/插入画布/下载/删除),数据由宿主 gallery 能力提供",
"ibwPlugin": { "ibwPlugin": {
"id": "gallery", "id": "gallery",
+22 -5
View File
@@ -129,8 +129,20 @@
setBtn.setAttribute('aria-expanded', 'false') setBtn.setAttribute('aria-expanded', 'false')
var settings = el('div', { class: 'iwb-gal-settings', role: 'dialog', 'aria-label': '图库设置' }) var settings = el('div', { class: 'iwb-gal-settings', role: 'dialog', 'aria-label': '图库设置' })
settings.style.display = 'none' settings.style.display = 'none'
// 2026-11-24:底栏加「打开本地图库目录」图标(文件夹),放在设置图标左边;只桌面端可用。
var folderBtn = iconBtn('打开本地目录', function (svg) {
svgPath(svg, 'M2 4.5h4l1.5 2H14v6.5H2z')
}, '在系统文件管理器里打开本地图库目录(images/gallery)')
folderBtn.addEventListener('click', function (e) {
e.stopPropagation()
if (!ctx.gallery || typeof ctx.gallery.openFolder !== 'function') { setStatus('仅桌面端可打开本地目录'); return }
Promise.resolve(ctx.gallery.openFolder()).then(function (r) {
if (r && r.ok === false) setStatus('打开失败:' + ((r && r.error) || '仅桌面端可用'))
}).catch(function (err) { setStatus('打开失败:' + ((err && err.message) || err)) })
})
folderBtn.style.display = (typeof window !== 'undefined' && window.__TAURI__ && window.__TAURI__.core) ? '' : 'none'
// v1.4.2:刷新与设置同放右侧工具组(此前刷新在左侧信息区,空间不足时会向右溢出、压住设置图标) // v1.4.2:刷新与设置同放右侧工具组(此前刷新在左侧信息区,空间不足时会向右溢出、压住设置图标)
var tools = el('div', { class: 'iwb-gal-tools' }, refreshBtn, setBtn) var tools = el('div', { class: 'iwb-gal-tools' }, refreshBtn, folderBtn, setBtn)
var foot = el('div', { class: 'iwb-gal-foot' }, var foot = el('div', { class: 'iwb-gal-foot' },
el('div', { class: 'iwb-gal-foot-left' }, countEl, pickedEl, failEl, statusEl), tools) el('div', { class: 'iwb-gal-foot-left' }, countEl, pickedEl, failEl, statusEl), tools)
var wrap = el('div', { class: 'iwb-history-embedded' }, [head, grid, more, empty, foot, settings]) var wrap = el('div', { class: 'iwb-history-embedded' }, [head, grid, more, empty, foot, settings])
@@ -300,6 +312,11 @@
function renderGrid () { function renderGrid () {
clear(grid) clear(grid)
var gap = 6 var gap = 6
// 每次重排都重新量一次宽度:面板显隐/停靠栏展开时 gridW 可能是旧值,
// 只靠 ResizeObserver 会在「变成 0 再回来」期间漏掉,导致必须拖宽度才出图。
var liveW = availableW()
if (liveW > 0 && Math.abs(liveW - gridW) > 1) gridW = liveW
if (!gridW) gridW = 320
var tileW = Math.max(40, Number(cfg.tile) || 110) var tileW = Math.max(40, Number(cfg.tile) || 110)
var n = Math.max(1, Math.floor((gridW + gap) / (tileW + gap))) var n = Math.max(1, Math.floor((gridW + gap) / (tileW + gap)))
// v1.6.6:列宽 = 均分宽度(铺满面板),图幅只决定「列数」—— // v1.6.6:列宽 = 均分宽度(铺满面板),图幅只决定「列数」——
@@ -368,7 +385,7 @@
function paint (url) { function paint (url) {
if (!url || typeof url !== 'string') { fail('图片已丢失'); return } if (!url || typeof url !== 'string') { fail('图片已丢失'); return }
if (!box.isConnected) return if (!box.isConnected) return
var img = el('img', { src: url, alt: '', loading: 'lazy', draggable: 'true' }) var img = el('img', { src: url, alt: '', loading: 'eager', draggable: 'true' })
if (it.w && it.h) img.setAttribute('style', 'aspect-ratio:' + it.w + ' / ' + it.h) if (it.w && it.h) img.setAttribute('style', 'aspect-ratio:' + it.w + ' / ' + it.h)
img.addEventListener('load', function () { img.addEventListener('load', function () {
// naturalWidth=0 说明拿到的是坏图(空 data URL / 截断文件):按失败处理,别留白块 // naturalWidth=0 说明拿到的是坏图(空 data URL / 截断文件):按失败处理,别留白块
@@ -407,7 +424,7 @@
if (img.parentNode === box) box.replaceChild(holder, img) if (img.parentNode === box) box.replaceChild(holder, img)
fail('缩略图加载失败(点击重试)') fail('缩略图加载失败(点击重试)')
} catch (e) { /* ignore */ } } catch (e) { /* ignore */ }
}, 700) }, 2000)
// 加载成功后再替换占位(避免破图标 + 长 title 占满格子) // 加载成功后再替换占位(避免破图标 + 长 title 占满格子)
if (img.complete && img.naturalWidth > 0) { img.style.display = ''; if (holder.parentNode === box) box.replaceChild(img, holder) } if (img.complete && img.naturalWidth > 0) { img.style.display = ''; if (holder.parentNode === box) box.replaceChild(img, holder) }
else if (img.complete && !img.naturalWidth) { /* 立即失败(坏图)*/ tries++; if (tries <= 2) setTimeout(boot, 400 * tries); else { if (img.parentNode === box) box.replaceChild(holder, img); fail('缩略图加载失败(点击重试)') } } else if (img.complete && !img.naturalWidth) { /* 立即失败(坏图)*/ tries++; if (tries <= 2) setTimeout(boot, 400 * tries); else { if (img.parentNode === box) box.replaceChild(holder, img); fail('缩略图加载失败(点击重试)') } }
@@ -447,7 +464,7 @@
render() render()
} }
function render () { renderHead(); renderGrid() } function render () { renderHead(); renderGrid(); global.requestAnimationFrame(function () { try { measure() } catch (e) {} }); setTimeout(function () { try { measure() } catch (e) {} }, 150) }
function load (force) { function load (force) {
if (force) setStatus('刷新中…') if (force) setStatus('刷新中…')
@@ -538,7 +555,7 @@
global.IWBPluginHost.register({ global.IWBPluginHost.register({
id: 'gallery', id: 'gallery',
name: '图库', name: '图库',
version: '1.6.9', version: '1.6.12',
apiVersion: 1, apiVersion: 1,
capabilities: ['panels', 'gallery'], capabilities: ['panels', 'gallery'],
data: { schemaVersion: 1, maxBytes: 65536 }, data: { schemaVersion: 1, maxBytes: 65536 },
+4 -4
View File
@@ -13,7 +13,7 @@
/* ---- 顶栏 ---- */ /* ---- 顶栏 ---- */
.iwb-gal-head { display: flex; align-items: center; gap: 6px; min-height: 0; } .iwb-gal-head { display: flex; align-items: center; gap: 6px; min-height: 0; }
.iwb-gal-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; } .iwb-gal-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.iwb-gal-actions .iwb-btn-sm { padding: 2px 7px; } .iwb-gal-actions .iwb-btn-sm { padding: 2px 6px; }
/* ---- 底栏:左信息 / 右工具组 ---- */ /* ---- 底栏:左信息 / 右工具组 ---- */
.iwb-gal-foot { .iwb-gal-foot {
@@ -32,7 +32,7 @@
.iwb-gal-foot .iwb-gal-icobtn:active { .iwb-gal-foot .iwb-gal-icobtn:active {
width: 20px; height: 20px; min-width: 20px; padding: 0; box-sizing: border-box; width: 20px; height: 20px; min-width: 20px; padding: 0; box-sizing: border-box;
display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
border: 0; box-shadow: none; background: transparent; border-radius: 4px; border: 0; box-shadow: none; background: transparent; border-radius: 6px;
color: var(--iwb-text2); line-height: 1; transform: none; color: var(--iwb-text2); line-height: 1; transform: none;
} }
.iwb-gal-foot .iwb-gal-icobtn svg { display: block; pointer-events: none; } .iwb-gal-foot .iwb-gal-icobtn svg { display: block; pointer-events: none; }
@@ -43,7 +43,7 @@
/* ---- 设置浮层(三个下拉不占前台) ---- */ /* ---- 设置浮层(三个下拉不占前台) ---- */
.iwb-gal-settings { .iwb-gal-settings {
position: absolute; right: 8px; bottom: 34px; z-index: 30; width: 176px; max-width: calc(100% - 16px); position: absolute; right: 8px; bottom: 34px; z-index: 30; width: 176px; max-width: calc(100% - 16px);
display: flex; flex-direction: column; gap: 8px; padding: 9px 10px; display: flex; flex-direction: column; gap: 8px; padding: 8px 10px;
background: var(--iwb-layer); border: 1px solid var(--iwb-border); border-radius: 8px; background: var(--iwb-layer); border: 1px solid var(--iwb-border); border-radius: 8px;
box-shadow: 0 6px 18px rgba(0, 0, 0, .14); box-shadow: 0 6px 18px rgba(0, 0, 0, .14);
} }
@@ -65,7 +65,7 @@
font-size: 11px; color: var(--iwb-text2); background: var(--iwb-layer2); word-break: break-all; font-size: 11px; color: var(--iwb-text2); background: var(--iwb-layer2); word-break: break-all;
} }
.iwb-history-actions { display: flex; gap: 4px; padding: 4px 2px 0; } .iwb-history-actions { display: flex; gap: 4px; padding: 4px 2px 0; }
.iwb-history-actions .iwb-btn-sm { padding: 1px 6px; font-size: 10px; } .iwb-history-actions .iwb-btn-sm { padding: 2px 6px; font-size: 11px; }
.iwb-history-more { display: flex; justify-content: center; padding: 4px 0 2px; } .iwb-history-more { display: flex; justify-content: center; padding: 4px 0 2px; }
/* 只作用于图库自己的空态提示:不加前缀会泄漏到设置页等使用 .iwb-hint 的地方(文字被居中) */ /* 只作用于图库自己的空态提示:不加前缀会泄漏到设置页等使用 .iwb-hint 的地方(文字被居中) */
.iwb-history-embedded .iwb-hint { font-size: 11px; color: var(--iwb-text2); text-align: center; padding: 12px 6px; } .iwb-history-embedded .iwb-hint { font-size: 11px; color: var(--iwb-text2); text-align: center; padding: 12px 6px; }
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "@iwb-plugin/grouplib", "name": "@iwb-plugin/grouplib",
"private": true, "private": true,
"version": "1.0.4", "version": "1.0.5",
"description": "节点组:左栏收藏的节点组列表(分组/改名/删除/拖入画布实例化),数据由宿主 grouplib 能力提供", "description": "节点组:左栏收藏的节点组列表(分组/改名/删除/拖入画布实例化),数据由宿主 grouplib 能力提供",
"ibwPlugin": { "ibwPlugin": {
"id": "grouplib", "id": "grouplib",
+1 -1
View File
@@ -439,7 +439,7 @@
global.IWBPluginHost.register({ global.IWBPluginHost.register({
id: 'grouplib', id: 'grouplib',
name: '节点组', name: '节点组',
version: '1.0.4', version: '1.0.5',
apiVersion: 1, apiVersion: 1,
capabilities: ['panels', 'grouplib'], capabilities: ['panels', 'grouplib'],
data: { schemaVersion: 1, maxBytes: 65536 }, data: { schemaVersion: 1, maxBytes: 65536 },
+1 -1
View File
@@ -36,7 +36,7 @@
.iwb-glp-dragging { opacity: .55; } .iwb-glp-dragging { opacity: .55; }
/* 空态:虚线框 */ /* 空态:虚线框 */
.iwb-glp-empty { .iwb-glp-empty {
margin: 4px 0; padding: 14px 12px; border-radius: 10px; text-align: center; margin: 4px 0; padding: 12px 12px; border-radius: 10px; text-align: center;
border: 1px dashed var(--iwb-border2, #b9bfca); color: var(--iwb-text2, #4d5668); border: 1px dashed var(--iwb-border2, #b9bfca); color: var(--iwb-text2, #4d5668);
font-size: 12px; line-height: 1.7; font-size: 12px; line-height: 1.7;
} }
+47
View File
@@ -0,0 +1,47 @@
# promptlib Token 迁移映射表(第一批:颜色)
> 依据:`image-workbench-desktop/docs/standards/design-tokens.md` 与 `plugin-theme.md`。
> 原则:**视觉目标仍是 1.8.8 基线**;先迁颜色(语义明确),尺寸后续单独批次 + 截图 diff。
## 1. 颜色映射(已落地 1.8.22)
| 原值 | Token | 用途 |
| --- | --- | --- |
| `#fff` / `#ffffff`(background) | `--iwb-plugin-card` | 卡片/弹窗内白底 |
| `#fbfcfd` / `#fcfcfd` | `--iwb-field` | 输入框/编辑区底 |
| `#fafafb` / `#fafbfc` | `--iwb-plugin-surface` | 面板根 |
| `#f5f6f7` `#f3f4f7` `#f2f4f7` `#eef0f4` `#f4f5f7` `#f4f6f9` `#f1f3f5` | `--iwb-plugin-inset` | 内嵌/分组底 |
| `#eef0f3` `#eef1f4` `#e9ecf1` `#e7e9ee` `#d7dbe2` | `--iwb-plugin-hover` | 悬停/次级块 |
| `#d5d9e0` `#e3e5e9` `#e6e8ec` `#eceef2` `#e2e6ec` `#e8eaee` `#eef0f2` `#dfe3e9` `#f1f3f5` `#f3f5f8` `#eef0f3` | `--iwb-plugin-border` | 常规描边/分割线 |
| `#b9bfca` `#c2c7cf` `#9aa3ad` | `--iwb-border2` | 强调描边 |
| `#1d2129` `#1c2333` `#2f3540` `#3f4450` `#3a4048` `#33383f` | `--iwb-text` | 主文字 |
| `#5b6472` `#4d5668` `#8b929c` `#8a919c` | `--iwb-text2` | 次要文字 |
| `#9aa1ac` `#aab0ba` `#b3b9c2` `#c2c7cf` | `--iwb-text-dim` | 占位/弱说明 |
| `#5a3fd0` `#5a4bd0` `#7c4dff` `#6b4dff` `#8b7ff0` | `--iwb-plp-accent` | 插件强调色(高饱和,允许自有) |
| `#f1ecff` `#f4f0ff` | `--iwb-plp-accent-soft` | 强调色浅底 |
| `#cfc3ff` `#d8cbff` `#d9d3ff` | `--iwb-plp-accent-border` | 强调色描边 |
| `#d97706` | `--iwb-warn` | 警告 |
| `#c0392b` | `--iwb-err` | 错误/删除 |
白色文字(压在封面/渐变上)保留 `#fff`,属内容色。
## 2. 尺寸迁移(已完成 1.8.23)
迁移结果:promptlib 散值清零(字号/圆角/间距全部落入闭集),棘轮基线已下调;视觉对比无换行/溢出。
| 类别 | 目标闭集 | 归并规则 |
| --- | --- | --- |
| 字号 | 11/12/13/14/15/17/20/24 | 10→11、10.5→11、11.5→12、12.5→13、13.5→14、16→15、18→17 |
| 圆角 | 6/8/10/12/14/999 | 2/3/4→6、7/9→8、11→10、16→14 |
| 间距 | 0/2/4/6/8/10/12/16/20/24/32/40/48/64 | 1→2、3→4、5→6、7→6、9→8、14→12、18→16 |
尺寸批次要求:亮/暗两套截图 diff + 逐项确认后再发布。
## 3. 复查命令
```bash
node scripts/token-audit.js --plugins
node tests/plugin-theme-contract-test.js
node tests/plugin-scale-contract-test.js
npm run test:visual
```
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "@iwb-plugin/promptlib", "name": "@iwb-plugin/promptlib",
"private": true, "private": true,
"version": "1.8.21", "version": "1.11.0",
"description": "提示词库:右栏提示词列表(搜索/分组/收藏/新建编辑/插入画布/复制/删除),数据由宿主 promptlib 能力提供", "description": "提示词库:右栏提示词列表(搜索/分组/收藏/新建编辑/插入画布/复制/删除),数据由宿主 promptlib 能力提供",
"ibwPlugin": { "ibwPlugin": {
"id": "promptlib", "id": "promptlib",
+305 -67
View File
@@ -55,6 +55,14 @@
} }
function uid (prefix) { return prefix + Date.now().toString(36) + Math.random().toString(36).slice(2, 7) } function uid (prefix) { return prefix + Date.now().toString(36) + Math.random().toString(36).slice(2, 7) }
function groupRef (name) { return { id: name, name: name } } function groupRef (name) { return { id: name, name: name } }
// v1.11.0:封面文件名 = 内容哈希(同名即同图,天然去重;不会因改名/移动分组产生新文件)。
// 抽成模块级:迁移、保存、设置面板导入三处必须用同一个算法,否则同一张图会存出两个文件。
function coverFileName (dataUrl) {
var s = String(dataUrl || '')
var h = 5381
for (var i = 0; i < s.length; i++) h = ((h << 5) + h + s.charCodeAt(i)) >>> 0
return 'c' + h.toString(36) + '.jpg'
}
// 文件沙箱:新客户端有独立 files 能力;老客户端退到 promptlib 能力上的 file* 方法。 // 文件沙箱:新客户端有独立 files 能力;老客户端退到 promptlib 能力上的 file* 方法。
function fileApi (ctx) { function fileApi (ctx) {
@@ -151,6 +159,68 @@
return 'promptlib-backup-' + d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0') + '.json' return 'promptlib-backup-' + d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0') + '.json'
} }
// 单条提示词分享(2026-11-24):文本带前缀,可直接粘到聊天软件;导入两种都认(带前缀 / 纯 JSON)。
var SHARE_TAG = 'IWB-PROMPT-SHARE'
function plpParseShare (raw) {
var t = String(raw || '').trim()
if (t.indexOf(SHARE_TAG) === 0) t = t.slice(SHARE_TAG.length).trim()
var obj = null
try { obj = JSON.parse(t) } catch (e) { return null }
var item = obj && (obj.kind === 'prompt-share' ? obj.sharing : (obj.sharing || (obj.text ? obj : null)))
if (!item || typeof item.text !== 'string' || !item.text.trim()) return null
return item
}
// v1.10.1:分享封面开关已移除——文本分享恒纯文字、文件分享恒带封面,不再有全局开关。
// (旧的 shareWithCover() / plpSharePayload() 已删除;plpCoverUrl 仍供备份导出使用。)
// ===== v1.11.0:未引用封面回收(P1)=====
// 为什么要有:封面是「内容哈希命名的图片文件」。换封面 / 删词条 / 取消编辑都会留下不再被引用的文件,
// 久了 64MB 沙箱被垃圾占满(用户看到「总量超限,请先清理」却找不到可清的东西)。
// 判定放在模块级:面板(有 prompts 作用域)与设置页(自带 state)必须用**同一套**规则,
// 否则两处各删一半,第三处又不知道谁还在用。
// 安全线:keep 为空时不删(空集合 = 把封面全删的形状,只有人工显式确认的路径才允许)。
var PLP_GC_BUSY = false
function plpGcCoverFiles (FA, keepNames, opts) {
var o = opts || {}
if (!FA || typeof FA.list !== 'function' || typeof FA.remove !== 'function') return Promise.resolve({ removed: 0, bytes: 0, skipped: 'no-fs' })
if (PLP_GC_BUSY) return Promise.resolve({ removed: 0, bytes: 0, skipped: 'busy' })
var keep = {}
var kept = 0
;(keepNames || []).forEach(function (n) {
n = String(n || '')
if (n) { keep[n] = 1; kept++ }
})
if (!kept && !o.manual) return Promise.resolve({ removed: 0, bytes: 0, skipped: 'empty' })
PLP_GC_BUSY = true
return Promise.resolve(FA.list()).then(function (list) {
var rows = Array.isArray(list) ? list : ((list && list.files) || [])
var victims = rows.filter(function (f) {
var name = String((f && f.name) || '')
if (!name || keep[name]) return false
return /\.(jpg|jpeg|png|webp)$/i.test(name)
})
var bytes = 0
victims.forEach(function (f) { bytes += Number(f && f.size) || 0 })
var removed = 0
var seq = Promise.resolve()
victims.forEach(function (f) {
seq = seq.then(function () {
return Promise.resolve(FA.remove(f.name)).then(function (r) { if (!r || r.ok !== false) removed++ }).catch(function () {})
})
})
return seq.then(function () { PLP_GC_BUSY = false; return { removed: removed, bytes: bytes } })
}).catch(function () { PLP_GC_BUSY = false; return { removed: 0, bytes: 0, skipped: 'error' } })
}
// 从词条列表里取「被引用的封面文件名」
function plpCoverNamesOf (list) {
var out = []
;(list || []).forEach(function (p) {
var c = p && p.cover
if (c && typeof c === 'object' && c.img) out.push(String(c.img))
})
return out
}
function renderPluginSettings () { function renderPluginSettings () {
var root = el('div', { class: 'iwb-plp-settings' }) var root = el('div', { class: 'iwb-plp-settings' })
var state = { prompts: [], groups: [] } var state = { prompts: [], groups: [] }
@@ -213,7 +283,9 @@
var st = rs[1] || {} var st = rs[1] || {}
var covers = state.prompts.filter(function (p) { return p && p.cover }).length var covers = state.prompts.filter(function (p) { return p && p.cover }).length
var size = st.bytes || 0 var size = st.bytes || 0
usage.textContent = (rs[0] || 'plugin-data/promptlib') + ' · ' + (size > 1024 ? (size / 1024).toFixed(0) + ' KB' : size + ' B') + ' · ' + state.prompts.length + ' 条 · ' + state.groups.length + ' 个分组 · ' + covers + ' 张封面' var files = Number(st.count) || 0
// v1.11.0:封面「引用数 / 文件数」分开显示 —— 两者不等就说明有孤儿文件可清。
usage.textContent = (rs[0] || 'plugin-data/promptlib') + ' · ' + (size > 1024 ? (size / 1024).toFixed(0) + ' KB' : size + ' B') + ' · ' + state.prompts.length + ' 条 · ' + state.groups.length + ' 个分组 · 封面 ' + covers + ' 张 / 文件 ' + files + ' 个'
}) })
} }
@@ -260,9 +332,7 @@
return Promise.all(payload.prompts.map(function (p) { return Promise.all(payload.prompts.map(function (p) {
var c = p && p.cover var c = p && p.cover
if (typeof c !== 'string' || c.indexOf('data:') !== 0 || !PLP_CTX.files) return Promise.resolve(p) if (typeof c !== 'string' || c.indexOf('data:') !== 0 || !PLP_CTX.files) return Promise.resolve(p)
var h = 5381 var name = coverFileName(c)
for (var i = 0; i < c.length; i++) h = ((h << 5) + h + c.charCodeAt(i)) >>> 0
var name = 'c' + h.toString(36) + '.jpg'
return Promise.resolve(PLP_CTX.files.put(name, c)).then(function (res) { return res && res.ok ? Object.assign({}, p, { cover: { img: name } }) : p }).catch(function () { return p }) return Promise.resolve(PLP_CTX.files.put(name, c)).then(function (res) { return res && res.ok ? Object.assign({}, p, { cover: { img: name } }) : p }).catch(function () { return p })
})).then(function (incoming) { })).then(function (incoming) {
var byId = {} var byId = {}
@@ -283,6 +353,7 @@
}) })
}).catch(function (e) { impBtn.disabled = false; status.textContent = '导入失败:' + ((e && e.message) || e) }) }).catch(function (e) { impBtn.disabled = false; status.textContent = '导入失败:' + ((e && e.message) || e) })
}) })
// v1.10.0:设置面板不再放单条提示词导入入口,导入统一走词库面板顶部的「文件 / 文本」。
s2.appendChild(el('div', { class: 'iwb-plp-sbtns' }, expBtn, impBtn)) s2.appendChild(el('div', { class: 'iwb-plp-sbtns' }, expBtn, impBtn))
s2.appendChild(el('label', { class: 'iwb-plp-sopt' }, overwrite, el('span', { text: '导入时覆盖同名条目' }))) s2.appendChild(el('label', { class: 'iwb-plp-sopt' }, overwrite, el('span', { text: '导入时覆盖同名条目' })))
s2.appendChild(status) s2.appendChild(status)
@@ -291,13 +362,39 @@
var s3 = el('div', { class: 'iwb-plp-ssec' }) var s3 = el('div', { class: 'iwb-plp-ssec' })
s3.appendChild(el('div', { class: 'iwb-plp-stitle', text: '数据位置' })) s3.appendChild(el('div', { class: 'iwb-plp-stitle', text: '数据位置' }))
s3.appendChild(usage) s3.appendChild(usage)
// v1.11.0:未引用封面回收。换封面/删词条会留下孤儿文件,久了把 64MB 沙箱占满。
// 自动清理已在面板加载后跑一次;这里是「我想立刻清」的显式入口(会先读一次最新数据做引用集合)。
var gcBtn = el('button', { class: 'iwb-btn iwb-btn-sm', title: '删除已不再被任何词条引用的封面图片文件', text: '清理未引用封面' })
var openBtn = el('button', { class: 'iwb-btn iwb-btn-sm', text: '打开数据目录' }) var openBtn = el('button', { class: 'iwb-btn iwb-btn-sm', text: '打开数据目录' })
openBtn.addEventListener('click', function () { openBtn.addEventListener('click', function () {
var ctx = PLP_CTX || {} var ctx = PLP_CTX || {}
if (!ctx.promptlib || typeof ctx.promptlib.openPath !== 'function') { plpNotify('当前客户端不支持打开目录', 'err'); return } if (!ctx.promptlib || typeof ctx.promptlib.openPath !== 'function') { plpNotify('当前客户端不支持打开目录', 'err'); return }
Promise.resolve(ctx.promptlib.openPath('plugin-data/promptlib')).catch(function (e) { plpNotify('打开失败:' + ((e && e.message) || e), 'err') }) Promise.resolve(ctx.promptlib.openPath('plugin-data/promptlib')).catch(function (e) { plpNotify('打开失败:' + ((e && e.message) || e), 'err') })
}) })
s3.appendChild(el('div', { class: 'iwb-plp-sbtns' }, openBtn)) gcBtn.addEventListener('click', function () {
var ctx = PLP_CTX || {}
var FA = fileApi(ctx)
if (!FA) { plpNotify('文件能力不可用,无法清理', 'err'); return }
gcBtn.disabled = true; status.textContent = '正在清理未引用封面…'
// 每次现读一次数据:设置页可能比面板更"新"(面板没开时用户刚删过词条)
Promise.resolve(plpLoad()).then(function (d) {
state.prompts = (d && d.prompts) || state.prompts
state.groups = (d && d.groups) || state.groups
return plpGcCoverFiles(FA, plpCoverNamesOf(state.prompts), { manual: true })
}).then(function (r) {
gcBtn.disabled = false
if (!r || !r.removed) {
status.textContent = (r && r.skipped === 'no-fs') ? '文件能力不可用,无法清理' : '没有未引用的封面(文件已经是最简状态)'
} else {
status.textContent = '✓ 已清理 ' + r.removed + ' 个未引用封面' + (r.bytes ? '(约 ' + Math.max(1, Math.round(r.bytes / 1024)) + ' KB)' : '')
}
refreshUsage(); paint(); plpNotify(status.textContent)
}).catch(function (e) {
gcBtn.disabled = false
status.textContent = '清理失败:' + ((e && e.message) || e)
})
})
s3.appendChild(el('div', { class: 'iwb-plp-sbtns' }, gcBtn, openBtn))
root.appendChild(s3) root.appendChild(s3)
plpLoad().then(function (d) { state.prompts = d.prompts || []; state.groups = d.groups || []; paint(); refreshUsage() }) plpLoad().then(function (d) { state.prompts = d.prompts || []; state.groups = d.groups || []; paint(); refreshUsage() })
@@ -346,11 +443,6 @@
var SCHEMA = 3 var SCHEMA = 3
var migrateDone = false var migrateDone = false
function hashName (s) {
var h = 5381
for (var i = 0; i < s.length; i++) h = ((h << 5) + h + s.charCodeAt(i)) >>> 0
return 'c' + h.toString(36)
}
function coverNameOf (p) { function coverNameOf (p) {
var c = p && p.cover var c = p && p.cover
if (c && typeof c === 'object' && c.img) return String(c.img) if (c && typeof c === 'object' && c.img) return String(c.img)
@@ -399,7 +491,7 @@
var jobs = list.map(function (p) { var jobs = list.map(function (p) {
var c = p && p.cover var c = p && p.cover
if (!FILEAPI || typeof c !== 'string' || c.indexOf('data:') !== 0) return Promise.resolve(p) if (!FILEAPI || typeof c !== 'string' || c.indexOf('data:') !== 0) return Promise.resolve(p)
var name = hashName(c) + '.jpg' var name = coverFileName(c)
return Promise.resolve(FILEAPI.put(name, c)).then(function (res) { return Promise.resolve(FILEAPI.put(name, c)).then(function (res) {
return res && res.ok ? Object.assign({}, p, { cover: { img: name } }) : p return res && res.ok ? Object.assign({}, p, { cover: { img: name } }) : p
}).catch(function () { return p }) }).catch(function () { return p })
@@ -427,9 +519,7 @@
var failed = 0 var failed = 0
Promise.all(need.map(function (p) { Promise.all(need.map(function (p) {
var c = p.cover var c = p.cover
var h = 5381 var name = coverFileName(c)
for (var i = 0; i < c.length; i++) h = ((h << 5) + h + c.charCodeAt(i)) >>> 0
var name = 'c' + h.toString(36) + '.jpg'
return Promise.resolve(FILEAPI.put(name, c)).then(function (r) { return Promise.resolve(FILEAPI.put(name, c)).then(function (r) {
if (r && r.ok) return { id: p.id, item: Object.assign({}, p, { cover: { img: name } }) } if (r && r.ok) return { id: p.id, item: Object.assign({}, p, { cover: { img: name } }) }
failed++ failed++
@@ -454,6 +544,46 @@
} }
}).catch(function () {}) }).catch(function () {})
} }
// ===== v1.11.0:封面文件治理(P1)=====
// 背景:封面是「按内容哈希命名的图片文件」。换封面 / 删词条 / 取消编辑都会留下**不再被引用的文件**,
// 时间久了 64MB 沙箱被垃圾占满(用户看到「总量超限,请先清理」却找不到东西可清)。
// 纪律(每条都对应一次真实误删风险):
// ① 自动 GC 只在「数据确实来自插件 JSON」时跑:数据没读到 ⇒ keep 集合为空 ⇒ 会把封面全删;
// ② 库为空时自动 GC 也不跑(keep 为空同样是删光的形状);
// ③ 刚 put 进沙箱、还没被 prompts 引用的名字进 pending,GC 必须跳过;
// ④ 只删图片扩展名的文件;两张词条共用同一封面 = 同一个名字,天然保留。
var pendingCoverNames = {}
var dataFromPlugin = false
// dataURL → { img: 文件名 };失败原样返回(宁可留着内联 base64,也不丢封面)
function ensureCoverFile (cover) {
if (!FILEAPI || typeof cover !== 'string' || cover.indexOf('data:') !== 0) return Promise.resolve(cover)
var name = coverFileName(cover)
pendingCoverNames[name] = 1
return Promise.resolve(FILEAPI.put(name, cover)).then(function (r) {
if (r && r.ok) return { img: name }
delete pendingCoverNames[name]
return cover
}).catch(function () { delete pendingCoverNames[name]; return cover })
}
// 回收未被任何词条引用的封面文件(判定在模块级 plpGcCoverFiles,设置页复用同一套)。
// 返回 { removed, bytes, skipped }
function gcCoverFiles (opts) {
var o = opts || {}
// 自动路径(启动后 / 删词条后):数据不是从插件 JSON 读来的就**不删**——
// 那种情况下 prompts 可能是空数组,keep 集合同样为空,一刀下去封面全没。
if (!o.manual && !dataFromPlugin) return Promise.resolve({ removed: 0, bytes: 0, skipped: 'no-source' })
var names = []
prompts.forEach(function (p) { var n = coverNameOf(p); if (n) names.push(n) })
Object.keys(pendingCoverNames).forEach(function (n) { names.push(n) })
return plpGcCoverFiles(FILEAPI, names, o)
}
// 启动后就地跑一次:延迟到 convertInlineCovers 的写入之后,避免删掉刚落盘的封面
function scheduleCoverGc (delay) {
setTimeout(function () { gcCoverFiles() }, delay || 4000)
}
function load () { return loadOnce(0) } function load () { return loadOnce(0) }
try { ctx.storage && ctx.storage.set('diag', JSON.stringify({ files: !!ctx.files, keys: Object.keys(ctx.promptlib || {}).slice(0, 24), hasPut: typeof (ctx.promptlib || {}).filePut, hasData: !!ctx.data })) } catch (e) { /* ignore */ } try { ctx.storage && ctx.storage.set('diag', JSON.stringify({ files: !!ctx.files, keys: Object.keys(ctx.promptlib || {}).slice(0, 24), hasPut: typeof (ctx.promptlib || {}).filePut, hasData: !!ctx.data })) } catch (e) { /* ignore */ }
function loadOnce (attempt) { function loadOnce (attempt) {
@@ -471,11 +601,13 @@
loadError = '' loadError = ''
prompts = d.prompts.map(normalize) prompts = d.prompts.map(normalize)
groups = Array.isArray(d.groups) ? d.groups : [] groups = Array.isArray(d.groups) ? d.groups : []
dataFromPlugin = true
render() render()
convertInlineCovers() convertInlineCovers()
scheduleCoverGc(4000)
return true return true
} }
if (d && Array.isArray(d.prompts) && !d.prompts.length) { prompts = []; groups = []; render(); return true } if (d && Array.isArray(d.prompts) && !d.prompts.length) { prompts = []; groups = []; dataFromPlugin = true; render(); return true }
return migrateFromHost() return migrateFromHost()
}).catch(function () { return legacyLoad() }) }).catch(function () { return legacyLoad() })
} }
@@ -641,23 +773,15 @@
e.preventDefault(); e.stopPropagation() e.preventDefault(); e.stopPropagation()
closeMenu() closeMenu()
var menu = el('div', { class: 'iwb-ctxmenu iwb-lib-group-menu', style: 'left:' + e.clientX + 'px;top:' + e.clientY + 'px' }) var menu = el('div', { class: 'iwb-ctxmenu iwb-lib-group-menu', style: 'left:' + e.clientX + 'px;top:' + e.clientY + 'px' })
menu.appendChild(el('div', { class: 'iwb-ctx-title', text: '移动到分组' }))
var item = function (label, value) {
var b = el('button', { class: 'iwb-ctx-item', text: label })
b.addEventListener('click', function () {
closeMenu()
save(prompts.map(function (x) { return x.id === p.id ? Object.assign({}, x, { group: value }) : x }))
.then(function () { notify('已移动到' + (value || '未分组')) })
})
menu.appendChild(b)
}
item('未分组', '')
groupsOf().forEach(function (g) { item(g.name, g.name) })
var sep = el('div', { class: 'iwb-ctx-sep' })
menu.appendChild(sep)
var ed = el('button', { class: 'iwb-ctx-item', text: '编辑…' }) var ed = el('button', { class: 'iwb-ctx-item', text: '编辑…' })
ed.addEventListener('click', function () { closeMenu(); openEditModal(p, false) }) ed.addEventListener('click', function () { closeMenu(); openEditModal(p, false) })
menu.appendChild(ed) menu.appendChild(ed)
var st = el('button', { class: 'iwb-ctx-item', text: '文本分享' })
st.addEventListener('click', function () { closeMenu(); doShareText(p) })
menu.appendChild(st)
var sf = el('button', { class: 'iwb-ctx-item', text: '文件分享' })
sf.addEventListener('click', function () { closeMenu(); doShareFile(p) })
menu.appendChild(sf)
document.body.appendChild(menu) document.body.appendChild(menu)
menuEl = menu menuEl = menu
setTimeout(function () { document.addEventListener('pointerdown', onDocDown, true) }, 0) setTimeout(function () { document.addEventListener('pointerdown', onDocDown, true) }, 0)
@@ -1095,9 +1219,7 @@
return Promise.all(payload.prompts.map(function (p) { return Promise.all(payload.prompts.map(function (p) {
var c = p && p.cover var c = p && p.cover
if (typeof c !== 'string' || c.indexOf('data:') !== 0 || !FILEAPI) return Promise.resolve(p) if (typeof c !== 'string' || c.indexOf('data:') !== 0 || !FILEAPI) return Promise.resolve(p)
var h = 5381 var name = coverFileName(c)
for (var i2 = 0; i2 < c.length; i2++) h = ((h << 5) + h + c.charCodeAt(i2)) >>> 0
var name = 'c' + h.toString(36) + '.jpg'
return Promise.resolve(FILEAPI.put(name, c)).then(function (res) { return Promise.resolve(FILEAPI.put(name, c)).then(function (res) {
return res && res.ok ? Object.assign({}, p, { cover: { img: name } }) : p return res && res.ok ? Object.assign({}, p, { cover: { img: name } }) : p
}).catch(function () { return p }) }).catch(function () { return p })
@@ -1254,9 +1376,78 @@
if (c.img && FILEAPI) return Promise.resolve(FILEAPI.get(String(c.img))).then(function (r) { return (r && r.ok && r.url) || '' }).catch(function () { return '' }) if (c.img && FILEAPI) return Promise.resolve(FILEAPI.get(String(c.img))).then(function (r) { return (r && r.ok && r.url) || '' }).catch(function () { return '' })
return Promise.resolve('') return Promise.resolve('')
} }
// ===== 2026-11-24:单条提示词分享 / 导入别人的分享 =====
// 分享格式刻意做成「可读的 JSON 文本」,直接粘到微信/QQ 也能看懂;导入时两种都认:
// ① 带 IWB-PROMPT 头的整段文本 ② 直接是 {kind:'prompt-share'} 的 JSON
// v1.10.0:withCover 显式传入——文本分享恒传 false(纯文字、短),文件分享传 true(封面放文件里不怕大)。
// v1.10.1:开关已删,只认显式布尔;未传一律按纯文字,不再回退读设置。
function sharePayload (p, withCover) {
var body = { app: 'image-workbench', kind: 'prompt-share', version: 1, sharing: { name: p.name || '', text: p.text || '', vars: varsOf(p), group: p.group || '', tags: p.tags || [] } }
var wantCover = withCover === true
if (!wantCover) return Promise.resolve(SHARE_TAG + '\n' + JSON.stringify(body))
return coverToDataUrl(p).then(function (cv) {
if (cv && cv.length < 300000) body.sharing.cover = cv
return SHARE_TAG + '\n' + JSON.stringify(body)
})
}
function shareFileName (p) {
return (String((p && p.name) || '提示词').replace(/[\\/:*?"<>|]/g, '_').trim() || '提示词').slice(0, 40) + '.json'
}
// 文本分享:复制纯文字(不带封面),内容最短,直接粘到聊天软件。
function doShareText (p) {
if (!p) return
sharePayload(p, false).then(function (text) {
return Promise.resolve(api.copy(text)).then(function (r) {
if (r && r.ok === false) { notify('分享失败:' + ((r && r.error) || '剪贴板不可用'), 'err'); return }
notify('已复制纯文字分享,粘贴给对方即可')
})
}).catch(function (e) { notify('分享失败:' + ((e && e.message) || e), 'err') })
}
// 文件分享:导出带封面的 .json 文件,作为附件发给对方(文件不怕大)。
function doShareFile (p) {
if (!p) return
sharePayload(p, true).then(function (text) {
return Promise.resolve(api.exportText(shareFileName(p), text)).then(function (r) {
if (r && r.ok) notify('已导出分享文件:' + (r.path || shareFileName(p)))
else if (r && r.canceled) notify('已取消')
else notify('导出失败:' + ((r && r.error) || '未知错误'), 'err')
})
}).catch(function (e) { notify('导出失败:' + ((e && e.message) || e), 'err') })
}
// 分享入库:剪贴板导入与文件导入共用,避免两套逻辑跑偏。
function importShareItem (item) {
var name = String(item.name || '').trim() || ('导入的提示词 ' + String(item.text).slice(0, 8) + '…')
var incoming = normalize({ id: uid('q'), name: name, text: item.text, group: String(item.group || ''), tags: item.tags || [] })
var cv = item.cover
var ready = (typeof cv === 'string' && cv.indexOf('data:') === 0 && FILEAPI)
? Promise.resolve(FILEAPI.put(coverFileName(cv), cv)).then(function (res) { return res && res.ok ? Object.assign({}, incoming, { cover: { img: coverFileName(cv) } }) : incoming }).catch(function () { return incoming })
: Promise.resolve(incoming)
return ready.then(function (p2) {
prompts = prompts.concat([p2])
return persist().then(function () { render(); notify('已导入分享:' + (p2.name || '')); return { ok: true, name: p2.name } })
})
}
function doImportShare () {
return Promise.resolve(api.paste && api.paste()).then(function (r) {
if (!r || r.ok === false) { notify('读取剪贴板失败:' + ((r && r.error) || '剪贴板不可用'), 'err'); return { ok: false } }
var item = plpParseShare(r.text)
if (!item) { notify('剪贴板里没有可识别的提示词分享', 'err'); return { ok: false, error: 'no-share' } }
return importShareItem(item)
}).catch(function (e) { notify('导入失败:' + ((e && e.message) || e), 'err'); return { ok: false } })
}
function importShareFromFile () {
return Promise.resolve(api.importText && api.importText()).then(function (r) {
if (!r || r.ok === false) { notify((r && r.canceled) ? '已取消' : ('读取文件失败:' + ((r && r.error) || '未知错误'))); return { ok: false } }
var item = plpParseShare(r.text)
if (!item) { notify('文件里没有可识别的提示词分享', 'err'); return { ok: false, error: 'no-share' } }
return importShareItem(item)
}).catch(function (e) { notify('导入失败:' + ((e && e.message) || e), 'err'); return { ok: false } })
}
function openBackup () { function openBackup () {
var exportBtn = el('button', { class: 'iwb-btn iwb-btn-sm iwb-btn-primary', text: '导出备份…' }) var exportBtn = el('button', { class: 'iwb-btn iwb-btn-sm iwb-btn-primary', text: '导出备份…' })
var importBtn = el('button', { class: 'iwb-btn iwb-btn-sm', text: '导入备份…' }) var importBtn = el('button', { class: 'iwb-btn iwb-btn-sm', text: '导入备份…' })
var importShareBtn = el('button', { class: 'iwb-btn iwb-btn-sm', title: '读取剪贴板里的单条提示词分享并加入提示词库', text: '导入分享…' })
var overwrite = el('input', { type: 'checkbox' }) var overwrite = el('input', { type: 'checkbox' })
var status = el('div', { class: 'iwb-hint', text: '' }) var status = el('div', { class: 'iwb-hint', text: '' })
openDialog({ openDialog({
@@ -1276,6 +1467,7 @@
bodyEl.appendChild(box) bodyEl.appendChild(box)
footEl.appendChild(exportBtn) footEl.appendChild(exportBtn)
footEl.appendChild(importBtn) footEl.appendChild(importBtn)
footEl.appendChild(importShareBtn)
exportBtn.addEventListener('click', function () { exportBtn.addEventListener('click', function () {
exportBtn.disabled = true exportBtn.disabled = true
status.textContent = '正在导出…' status.textContent = '正在导出…'
@@ -1296,6 +1488,16 @@
else { status.textContent = '导出失败:' + ((r && r.error) || '未知错误'); notify('导出失败', 'err') } else { status.textContent = '导出失败:' + ((r && r.error) || '未知错误'); notify('导出失败', 'err') }
}).catch(function (e) { exportBtn.disabled = false; status.textContent = '导出失败:' + ((e && e.message) || e); notify('导出失败', 'err') }) }).catch(function (e) { exportBtn.disabled = false; status.textContent = '导出失败:' + ((e && e.message) || e); notify('导出失败', 'err') })
}) })
importShareBtn.addEventListener('click', function () {
importShareBtn.disabled = true
status.textContent = '读取剪贴板…'
doImportShare().then(function (r) {
importShareBtn.disabled = false
if (r && r.ok) status.textContent = '已导入分享:' + (r.name || '')
else if (r && r.error === 'no-share') status.textContent = '剪贴板里没有可识别的提示词分享'
else status.textContent = '导入失败'
}).catch(function (e) { importShareBtn.disabled = false; status.textContent = '导入失败:' + ((e && e.message) || e) })
})
importBtn.addEventListener('click', function () { importBtn.addEventListener('click', function () {
importBtn.disabled = true importBtn.disabled = true
status.textContent = '等待选择文件…' status.textContent = '等待选择文件…'
@@ -1307,9 +1509,7 @@
return Promise.all(payload.prompts.map(function (p) { return Promise.all(payload.prompts.map(function (p) {
var c = p && p.cover var c = p && p.cover
if (typeof c !== 'string' || c.indexOf('data:') !== 0 || !FILEAPI) return Promise.resolve(p) if (typeof c !== 'string' || c.indexOf('data:') !== 0 || !FILEAPI) return Promise.resolve(p)
var h = 5381 var name = coverFileName(c)
for (var i2 = 0; i2 < c.length; i2++) h = ((h << 5) + h + c.charCodeAt(i2)) >>> 0
var name = 'c' + h.toString(36) + '.jpg'
return Promise.resolve(FILEAPI.put(name, c)).then(function (res) { return Promise.resolve(FILEAPI.put(name, c)).then(function (res) {
return res && res.ok ? Object.assign({}, p, { cover: { img: name } }) : p return res && res.ok ? Object.assign({}, p, { cover: { img: name } }) : p
}).catch(function () { return p }) }).catch(function () { return p })
@@ -1407,10 +1607,14 @@
ask('删除提示词「' + (p.name || '未命名') + '」?', { title: '删除提示词', okText: '删除' }).then(function (ok) { ask('删除提示词「' + (p.name || '未命名') + '」?', { title: '删除提示词', okText: '删除' }).then(function (ok) {
if (!ok) return if (!ok) return
dlg.close() dlg.close()
save(prompts.filter(function (x) { return x.id !== p.id })).then(function () { notify('已删除') }) save(prompts.filter(function (x) { return x.id !== p.id })).then(function () { notify('已删除'); scheduleCoverGc(1200) })
}) })
}) })
cp.addEventListener('click', function () { Promise.resolve(api.copy(filled())).then(function (r) { if (r && r.ok === false) notify('复制失败', 'err'); else notify('已复制全文') }) }) cp.addEventListener('click', function () { Promise.resolve(api.copy(filled())).then(function (r) { if (r && r.ok === false) notify('复制失败', 'err'); else notify('已复制全文') }) })
var shareText = el('button', { class: 'iwb-btn iwb-btn-sm', title: '复制纯文字分享,粘贴给对方即可导入(不含封面,内容短)', text: '文本分享' })
shareText.addEventListener('click', function () { doShareText(p) })
var shareFile = el('button', { class: 'iwb-btn iwb-btn-sm', title: '导出带封面的分享文件,作为附件发给对方', text: '文件分享' })
shareFile.addEventListener('click', function () { doShareFile(p) })
ins.addEventListener('click', function () { dlg.close(); beginPlacement('prompt', { text: filled(), name: p.name || '' }) }) ins.addEventListener('click', function () { dlg.close(); beginPlacement('prompt', { text: filled(), name: p.name || '' }) })
var insImg = null var insImg = null
if (p.cover) { if (p.cover) {
@@ -1425,7 +1629,11 @@
}).catch(function () { notify('插入封面失败', 'err') }) }).catch(function () { notify('插入封面失败', 'err') })
}) })
} }
footEl.appendChild(del); footEl.appendChild(el('span', { class: 'iwb-drawer-spacer' })); if (insTpl) footEl.appendChild(insTpl); footEl.appendChild(cp) footEl.appendChild(del); footEl.appendChild(el('span', { class: 'iwb-drawer-spacer' }))
footEl.appendChild(shareText); footEl.appendChild(shareFile)
// v1.10.1:分享组与插入组之间加竖向分割线(替代原来的 26px 空白)。
footEl.appendChild(el('span', { class: 'iwb-plp-foot-vsep' }))
footEl.appendChild(cp); if (insTpl) footEl.appendChild(insTpl)
if (insImg) footEl.appendChild(insImg) if (insImg) footEl.appendChild(insImg)
footEl.appendChild(ins) footEl.appendChild(ins)
}, },
@@ -1441,7 +1649,7 @@
var dirty = false var dirty = false
openDialog({ openDialog({
key: 'edit', key: 'edit',
title: isNew ? '新建提示词' : '编辑提示词', title: isNew ? '新建词例' : '编辑词例',
width: 880, height: 640, width: 880, height: 640,
actions: [cancelBtn, saveBtn], actions: [cancelBtn, saveBtn],
onSaveKey: function () { doSave() }, onSaveKey: function () { doSave() },
@@ -1466,15 +1674,19 @@
rd.onload = function () { rd.onload = function () {
Promise.resolve(api.putCover(String(rd.result || ''))).then(function (r) { Promise.resolve(api.putCover(String(rd.result || ''))).then(function (r) {
if (!(r && r.ok && r.ref)) { notify('封面上传失败', 'err'); return } if (!(r && r.ok && r.ref)) { notify('封面上传失败', 'err'); return }
draft.cover = r.ref // v1.11.0:上传即落成文件(数据里只留文件名)——
dirty = true // 之前 draft.cover 存的是 dataURL,doSave 直接把它写进 JSON,一条封面就把数据文件顶大几十 KB。
Object.keys(coverCache).forEach(function (k) { if (k.indexOf(draft.id + '|') === 0) delete coverCache[k] }) return ensureCoverFile(r.ref).then(function (cover) {
Promise.resolve(api.coverUrl(r.ref)).then(function (u) { draft.cover = cover
if (u && u.url) { dirty = true
draft._coverUrl = u.url Object.keys(coverCache).forEach(function (k) { if (k.indexOf(draft.id + '|') === 0) delete coverCache[k] })
coverCache[draft.id + '|s:' + String(r.ref).slice(-32)] = u.url return resolveCoverUrl(cover).then(function (u) {
} if (u) {
repaint(); render(); notify('封面已更新') draft._coverUrl = u
coverCache[draft.id + '|s:' + String(cover).slice(-32)] = u
}
repaint(); render(); notify('封面已更新')
})
}) })
}).catch(function () { notify('封面上传失败', 'err') }) }).catch(function () { notify('封面上传失败', 'err') })
} }
@@ -1533,7 +1745,8 @@
if (last < v.length) hl.appendChild(document.createTextNode(v.slice(last))) if (last < v.length) hl.appendChild(document.createTextNode(v.slice(last)))
hl.appendChild(document.createTextNode('\n')) hl.appendChild(document.createTextNode('\n'))
} }
textIn.addEventListener('scroll', function () { hl.scrollTop = textIn.scrollTop }) // v1.9.3:高亮层只画变量色块,必须跟随 textarea 双向滚动(补横向,纵向沿用)
textIn.addEventListener('scroll', function () { hl.scrollTop = textIn.scrollTop; hl.scrollLeft = textIn.scrollLeft })
textIn.value = draft.text || '' textIn.value = draft.text || ''
paintHl() paintHl()
var varEd = makeVarsEditor(draft.text || '', draft.vars || [], function (nt) { textIn.value = nt; dirty = true; paintHl() }) var varEd = makeVarsEditor(draft.text || '', draft.vars || [], function (nt) { textIn.value = nt; dirty = true; paintHl() })
@@ -1610,23 +1823,29 @@
var text = String(c.text || '').trim() var text = String(c.text || '').trim()
if (!text) { notify('提示词内容不能为空', 'err'); return } if (!text) { notify('提示词内容不能为空', 'err'); return }
var name = String(c.name || '').trim() || ('提示词 ' + text.slice(0, 8) + '…') var name = String(c.name || '').trim() || ('提示词 ' + text.slice(0, 8) + '…')
var item = { id: c.id, name: name, text: text, tags: c.tags, group: String(c.group || '').trim(), cover: c.cover, vars: c.vars || [] } // v1.11.0:保存前把内联封面落成文件(数据里只留 { img }),避免 base64 把 JSON 顶大
var list = isNew ? prompts.concat([item]) : prompts.map(function (x) { return x.id === item.id ? item : x }) saveBtn.disabled = true
var gs = groupsOf().slice() ensureCoverFile(c.cover).then(function (finalCover) {
if (item.group && !gs.some(function (g) { return g.name === item.group })) gs.push(groupRef(item.group)) var item = { id: c.id, name: name, text: text, tags: c.tags, group: String(c.group || '').trim(), cover: finalCover, vars: c.vars || [] }
close() var list = isNew ? prompts.concat([item]) : prompts.map(function (x) { return x.id === item.id ? item : x })
save(list, gs).then(function () { var gs = groupsOf().slice()
notify(isNew ? '已创建' : '已保存') if (item.group && !gs.some(function (g) { return g.name === item.group })) gs.push(groupRef(item.group))
if (!isNew) { try { openDetailModal(item) } catch (e) { /* ignore */ } } close()
}) return save(list, gs).then(function () {
notify(isNew ? '已创建' : '已保存')
if (!isNew) { try { openDetailModal(item) } catch (e) { /* ignore */ } }
})
}).catch(function () { saveBtn.disabled = false; notify('保存失败', 'err') })
} }
saveBtn.addEventListener('click', doSave) saveBtn.addEventListener('click', doSave)
cancelBtn.addEventListener('click', function () { close(); if (!isNew && p) { try { openDetailModal(p) } catch (e) { /* ignore */ } } }) cancelBtn.addEventListener('click', function () { close(); if (!isNew && p) { try { openDetailModal(p) } catch (e) { /* ignore */ } } })
dupBtn.addEventListener('click', function () { dupBtn.addEventListener('click', function () {
var c = collect() var c = collect()
var copy = Object.assign({}, c, { id: uid('q'), name: (String(c.name || '提示词').trim()) + ' 副本' })
close() close()
save(prompts.concat([copy])).then(function () { notify('已另存副本') }) ensureCoverFile(c.cover).then(function (cover) {
var copy = Object.assign({}, c, { id: uid('q'), name: (String(c.name || '提示词').trim()) + ' 副本', cover: cover })
return save(prompts.concat([copy])).then(function () { notify('已另存副本') })
}).catch(function () { notify('另存副本失败', 'err') })
}) })
insBtn.addEventListener('click', function () { insBtn.addEventListener('click', function () {
var c = collect() var c = collect()
@@ -1645,10 +1864,29 @@
var top = el('div', { class: 'iwb-row' }) var top = el('div', { class: 'iwb-row' })
var search = el('input', { class: 'iwb-input iwb-grow', placeholder: '搜索名称 / 内容 / 标签…', value: query }) var search = el('input', { class: 'iwb-input iwb-grow', placeholder: '搜索名称 / 内容 / 标签…', value: query })
search.addEventListener('input', function () { query = search.value; render(); var n = wrap.querySelector('input.iwb-input'); if (n) { n.focus(); try { n.setSelectionRange(n.value.length, n.value.length) } catch (e) { /* ignore */ } } }) search.addEventListener('input', function () { query = search.value; render(); var n = wrap.querySelector('input.iwb-input'); if (n) { n.focus(); try { n.setSelectionRange(n.value.length, n.value.length) } catch (e) { /* ignore */ } } })
var newBtn = el('button', { class: 'iwb-btn iwb-btn-sm iwb-btn-primary', title: '新建提示词', text: '+ 新建提示词' }) // v1.10.0:顶部三入口 = 文件(从分享文件导入)/ 文本(从剪贴板导入)/ 新建。
var fileBtn = el('button', { class: 'iwb-btn iwb-btn-sm', title: '从分享文件导入词例', text: '文件' })
var textBtn = el('button', { class: 'iwb-btn iwb-btn-sm', title: '从剪贴板导入词例', text: '文本' })
var newBtn = el('button', { class: 'iwb-btn iwb-btn-sm iwb-btn-primary', title: '新建词例', text: '新建' })
fileBtn.addEventListener('click', function () {
fileBtn.disabled = true
importShareFromFile().then(function (r) {
fileBtn.disabled = false
if (r && r.ok === false && r.error === 'no-share') notify('文件里没有可识别的词例分享', 'err')
else if (r && r.ok === false) notify('导入失败', 'err')
}).catch(function (e) { fileBtn.disabled = false; notify('导入失败:' + ((e && e.message) || e), 'err') })
})
textBtn.addEventListener('click', function () {
textBtn.disabled = true
doImportShare().then(function (r) {
textBtn.disabled = false
if (r && r.ok === false && r.error === 'no-share') notify('剪贴板里没有可识别的词例分享', 'err')
else if (r && r.ok === false) notify('导入失败', 'err')
}).catch(function (e) { textBtn.disabled = false; notify('导入失败:' + ((e && e.message) || e), 'err') })
})
newBtn.addEventListener('click', function () { openEditModal(null, true) }) newBtn.addEventListener('click', function () { openEditModal(null, true) })
top.appendChild(search); top.appendChild(newBtn) top.appendChild(search); top.appendChild(fileBtn); top.appendChild(textBtn); top.appendChild(newBtn)
fixed.appendChild(top) fixed.appendChild(top)
if (words().length) { if (words().length) {
@@ -1721,7 +1959,7 @@
items.forEach(function (p) { items.forEach(function (p) {
var starred = (p.group || '') === '收藏' var starred = (p.group || '') === '收藏'
var coverUrl = coverOf(p) var coverUrl = coverOf(p)
var card = el('div', { class: 'iwb-plp-card' + (p.cover ? ' has-cover' : ' no-cover'), title: '双击查看详情 · 拖到画布插入 · 右键移动到分组' }) var card = el('div', { class: 'iwb-plp-card' + (p.cover ? ' has-cover' : ' no-cover'), title: '双击查看详情 · 拖到画布插入 · 右键编辑/分享' })
var bg = el('div', { class: 'iwb-plp-bg' }) var bg = el('div', { class: 'iwb-plp-bg' })
bg.style.background = coverUrl ? 'var(--iwb-plugin-inset)' : gradOf(p) bg.style.background = coverUrl ? 'var(--iwb-plugin-inset)' : gradOf(p)
if (coverUrl) bg.appendChild(el('img', { class: 'iwb-plp-cover', src: coverUrl, alt: '', draggable: 'false' })) if (coverUrl) bg.appendChild(el('img', { class: 'iwb-plp-cover', src: coverUrl, alt: '', draggable: 'false' }))
@@ -1763,11 +2001,13 @@
global.IWBPluginHost.register({ global.IWBPluginHost.register({
id: 'promptlib', id: 'promptlib',
name: '提示词库', name: '提示词库',
version: '1.8.21', version: '1.11.0',
apiVersion: 1, apiVersion: 1,
capabilities: ['panels', 'promptlib', 'nodeTypes', 'canvas', 'canvasWrite'], capabilities: ['panels', 'promptlib', 'nodeTypes', 'canvas', 'canvasWrite'],
data: { schemaVersion: 3, maxBytes: 4 * 1024 * 1024 }, data: { schemaVersion: 3, maxBytes: 4 * 1024 * 1024 },
settings: { panel: { type: 'custom', label: '分组与备份', render: renderPluginSettings } }, settings: {
panel: { type: 'custom', label: '分组与备份', render: renderPluginSettings },
},
}, function (ctx) { }, function (ctx) {
PLP_CTX = ctx PLP_CTX = ctx
// v1.5.0:插件激活时就把旧数据迁到插件目录(不等面板打开), // v1.5.0:插件激活时就把旧数据迁到插件目录(不等面板打开),
@@ -1800,9 +2040,7 @@
return Promise.all(list.map(function (p) { return Promise.all(list.map(function (p) {
var c = p && p.cover var c = p && p.cover
if (typeof c !== 'string' || c.indexOf('data:') !== 0) return Promise.resolve(p) if (typeof c !== 'string' || c.indexOf('data:') !== 0) return Promise.resolve(p)
var h = 5381 var name = coverFileName(c)
for (var i2 = 0; i2 < c.length; i2++) h = ((h << 5) + h + c.charCodeAt(i2)) >>> 0
var name = 'c' + h.toString(36) + '.jpg'
return Promise.resolve(FA.put(name, c)).then(function (res) { return Promise.resolve(FA.put(name, c)).then(function (res) {
return res && res.ok ? Object.assign({}, p, { cover: { img: name } }) : p return res && res.ok ? Object.assign({}, p, { cover: { img: name } }) : p
}).catch(function () { return p }) }).catch(function () { return p })
+135 -117
View File
@@ -1,3 +1,4 @@
.iwb-promptlib, .iwb-plp-dialog, .iwb-plp-mask, .iwb-plp-dragghost, .iwb-plp-placebox{--iwb-plp-accent:#6b4dff;--iwb-plp-accent-soft:#f1ecff;--iwb-plp-accent-border:#d9d3ff}
/* promptlib(提示词库)自带样式 /* promptlib(提示词库)自带样式
作用域全部带 .iwb-plp-*,不影响宿主与其他插件;样式随插件发布,不必等客户端发版。 */ 作用域全部带 .iwb-plp-*,不影响宿主与其他插件;样式随插件发布,不必等客户端发版。 */
@@ -34,9 +35,9 @@
.iwb-plp-card:hover { border-color: var(--iwb-border2, #b9bfca); } .iwb-plp-card:hover { border-color: var(--iwb-border2, #b9bfca); }
.iwb-plp-cover { width: 100%; height: 100%; object-fit: cover; display: block; } .iwb-plp-cover { width: 100%; height: 100%; object-fit: cover; display: block; }
.iwb-plp-t { .iwb-plp-t {
position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 7px 6px; position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 6px 6px;
background: linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,.66)); background: linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,.66));
color: var(--plp-c1, #fff); font-size: 10.5px; line-height: 1.35; max-height: 48%; color: var(--plp-c1, #fff); font-size: 11px; line-height: 1.35; max-height: 48%;
display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;
text-shadow: 0 1px 2px rgba(0,0,0,.35); text-shadow: 0 1px 2px rgba(0,0,0,.35);
} }
@@ -54,26 +55,26 @@
/* 编辑弹窗:760 宽 + 大文本框 */ /* 编辑弹窗:760 宽 + 大文本框 */
.iwb-promptlib-editor { width: 760px; max-width: 94vw; } .iwb-promptlib-editor { width: 760px; max-width: 94vw; }
.iwb-promptlib-editor .iwb-modal-body { max-height: 78vh; } .iwb-promptlib-editor .iwb-modal-body { max-height: 78vh; }
.iwb-promptlib-text { min-height: 360px; height: 44vh; font-size: 12.5px; line-height: 1.9; resize: vertical; } .iwb-promptlib-text { min-height: 360px; height: 44vh; font-size: 13px; line-height: 1.9; resize: vertical; }
.iwb-plp-editor-cover { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; } .iwb-plp-editor-cover { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.iwb-plp-editor-thumb { flex: 0 0 96px; width: 96px; height: 128px; border-radius: 8px; overflow: hidden; border: 1px solid var(--iwb-border, #d5d9e0); } .iwb-plp-editor-thumb { flex: 0 0 96px; width: 96px; height: 128px; border-radius: 8px; overflow: hidden; border: 1px solid var(--iwb-border, #d5d9e0); }
.iwb-plp-editor-coverops { display: flex; flex-direction: column; gap: 8px; } .iwb-plp-editor-coverops { display: flex; flex-direction: column; gap: 8px; }
/* v1.2.0:可拖动 / 可缩放的详情与编辑弹窗(同宽 880×640,最小 640×420) */ /* v1.2.0:可拖动 / 可缩放的详情与编辑弹窗(同宽 880×640,最小 640×420) */
.iwb-plp-mask { background: transparent; display: block; } .iwb-plp-mask { background: transparent; display: block; }
.iwb-plp-dialog { display: flex; flex-direction: column; overflow: hidden; border-radius: 16px; .iwb-plp-dialog { display: flex; flex-direction: column; overflow: hidden; border-radius: 14px;
box-shadow: 0 24px 60px rgba(0,0,0,.28); } box-shadow: 0 24px 60px rgba(0,0,0,.28); }
.iwb-plp-dhead { display: flex; align-items: center; gap: 6px; padding: 10px 14px; .iwb-plp-dhead { display: flex; align-items: center; gap: 6px; padding: 10px 12px;
border-bottom: 1px solid var(--iwb-border, #d5d9e0); cursor: move; user-select: none; } border-bottom: 1px solid var(--iwb-border, #d5d9e0); cursor: move; user-select: none; }
.iwb-plp-grip { display: grid; grid-template-columns: repeat(3, 3px); gap: 2px; margin-right: 6px; } .iwb-plp-grip { display: grid; grid-template-columns: repeat(3, 3px); gap: 2px; margin-right: 6px; }
.iwb-plp-grip i { width: 3px; height: 3px; border-radius: 50%; background: var(--iwb-border2, #b9bfca); display: block; } .iwb-plp-grip i { width: 3px; height: 3px; border-radius: 50%; background: var(--iwb-border2, #b9bfca); display: block; }
.iwb-plp-dbody { flex: 1 1 auto; min-height: 0; display: flex; gap: 14px; padding: 14px; } .iwb-plp-dbody { flex: 1 1 auto; min-height: 0; display: flex; gap: 12px; padding: 12px; }
.iwb-plp-dcov { flex: 0 0 210px; width: 210px; height: 280px; border-radius: 10px; overflow: hidden; .iwb-plp-dcov { flex: 0 0 210px; width: 210px; height: 280px; border-radius: 10px; overflow: hidden;
border: 1px solid var(--iwb-border, #d5d9e0); background: var(--iwb-plugin-inset, #f5f6f7); } border: 1px solid var(--iwb-border, #d5d9e0); background: var(--iwb-plugin-inset, #f5f6f7); }
.iwb-plp-dright { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; } .iwb-plp-dright { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.iwb-plp-dtext { flex: 1 1 auto; min-height: 0; overflow: auto; white-space: pre-wrap; word-break: break-word; .iwb-plp-dtext { flex: 1 1 auto; min-height: 0; overflow: auto; white-space: pre-wrap; word-break: break-word;
font-size: 12px; line-height: 1.9; color: var(--iwb-text2, #4d5668); } font-size: 12px; line-height: 1.9; color: var(--iwb-text2, #4d5668); }
.iwb-plp-dfooter { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 10px 14px; .iwb-plp-dfooter { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 10px 12px;
border-top: 1px solid var(--iwb-border, #d5d9e0); } border-top: 1px solid var(--iwb-border, #d5d9e0); }
.iwb-plp-resize { position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize; .iwb-plp-resize { position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize;
background: linear-gradient(135deg, transparent 0 45%, var(--iwb-border2, #b9bfca) 45% 50%, transparent 50% 62%, var(--iwb-border2, #b9bfca) 62% 67%, transparent 67%); } background: linear-gradient(135deg, transparent 0 45%, var(--iwb-border2, #b9bfca) 45% 50%, transparent 50% 62%, var(--iwb-border2, #b9bfca) 62% 67%, transparent 67%); }
@@ -81,7 +82,7 @@
.iwb-plp-eleft { flex: 0 0 240px; width: 240px; display: flex; flex-direction: column; gap: 8px; min-height: 0; } .iwb-plp-eleft { flex: 0 0 240px; width: 240px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.iwb-plp-ecov { width: 240px; height: 300px; border-radius: 10px; overflow: hidden; .iwb-plp-ecov { width: 240px; height: 300px; border-radius: 10px; overflow: hidden;
border: 1px solid var(--iwb-border, #d5d9e0); background: var(--iwb-plugin-inset, #f5f6f7); } border: 1px solid var(--iwb-border, #d5d9e0); background: var(--iwb-plugin-inset, #f5f6f7); }
.iwb-plp-lrow { display: flex; flex-direction: column; gap: 4px; font-size: 10px; color: var(--iwb-text2, #4d5668); } .iwb-plp-lrow { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--iwb-text2, #4d5668); }
.iwb-plp-etext { flex: 1 1 auto; min-height: 0; height: auto; resize: none; font-size: 12px; line-height: 1.9; } .iwb-plp-etext { flex: 1 1 auto; min-height: 0; height: auto; resize: none; font-size: 12px; line-height: 1.9; }
/* 输入框边框柔化(用户反馈现在的边框太深) */ /* 输入框边框柔化(用户反馈现在的边框太深) */
.iwb-plp-dialog .iwb-input { border-color: color-mix(in srgb, var(--iwb-border, #d5d9e0) 72%, transparent); } .iwb-plp-dialog .iwb-input { border-color: color-mix(in srgb, var(--iwb-border, #d5d9e0) 72%, transparent); }
@@ -143,48 +144,50 @@
.iwb-plp-node{display:flex;flex-direction:column;gap:6px;padding:8px 10px;font-size:12px;color:var(--iwb-text,#1c2333)} .iwb-plp-node{display:flex;flex-direction:column;gap:6px;padding:8px 10px;font-size:12px;color:var(--iwb-text,#1c2333)}
.iwb-plp-nhead{display:flex;align-items:center;gap:8px} .iwb-plp-nhead{display:flex;align-items:center;gap:8px}
.iwb-plp-nthumb{width:44px;height:44px;border-radius:8px;object-fit:cover;flex:0 0 auto} .iwb-plp-nthumb{width:44px;height:44px;border-radius:8px;object-fit:cover;flex:0 0 auto}
.iwb-plp-ntitle{font-weight:600;font-size:12.5px;line-height:1.3;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical} .iwb-plp-ntitle{font-weight:600;font-size: 13px;line-height:1.3;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
.iwb-plp-nvars{display:flex;flex-direction:column;gap:4px} .iwb-plp-nvars{display:flex;flex-direction:column;gap:4px}
.iwb-plp-nrow{display:flex;align-items:center;gap:6px;height:26px} .iwb-plp-nrow{display:flex;align-items:center;gap:6px;height:26px}
.iwb-plp-nk{width:64px;flex:0 0 64px;color:var(--iwb-text2,#5b6472);font-size:11.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} .iwb-plp-nk{width:64px;flex:0 0 64px;color:var(--iwb-text2,#5b6472);font-size: 12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.iwb-plp-nin{flex:1;height:24px;font-size:11.5px} .iwb-plp-nin{flex:1;height:24px;font-size: 12px}
.iwb-plp-nref{display:flex;align-items:center;gap:6px;font-size:11.5px;color:var(--iwb-text2,#5b6472);border-top:1px dashed var(--iwb-border,#e3e5e9);padding-top:6px} .iwb-plp-nref{display:flex;align-items:center;gap:6px;font-size: 12px;color:var(--iwb-text2,#5b6472);border-top:1px dashed var(--iwb-border,#e3e5e9);padding-top:6px}
.iwb-plp-nref em{font-style:normal;color:var(--iwb-text2,#8b929c)} .iwb-plp-nref em{font-style:normal;color:var(--iwb-text2,#8b929c)}
.iwb-plp-nprev{margin-top:2px;border-top:1px dashed var(--iwb-border,#e3e5e9);padding-top:6px;color:var(--iwb-text2,#5b6472);font-size:11.5px;line-height:1.6;max-height:88px;overflow:hidden} .iwb-plp-nprev{margin-top:2px;border-top:1px dashed var(--iwb-border,#e3e5e9);padding-top:6px;color:var(--iwb-text2,#5b6472);font-size: 12px;line-height:1.6;max-height:88px;overflow:hidden}
/* v1.5.0:变量编辑器 / 详情变量 */ /* v1.5.0:变量编辑器 / 详情变量 */
.iwb-plp-emid{flex:1;min-width:0;display:flex;flex-direction:column;gap:8px} .iwb-plp-emid{flex:1;min-width:0;display:flex;flex-direction:column;gap:8px}
.iwb-plp-vars{border:1px solid var(--iwb-border,#e3e5e9);border-radius:10px;padding:8px 10px;display:flex;flex-direction:column;gap:6px;background:var(--iwb-plugin-surface,#fff)} .iwb-plp-vars{border:1px solid var(--iwb-border,#e3e5e9);border-radius:10px;padding:8px 10px;display:flex;flex-direction:column;gap:6px;background:var(--iwb-plugin-surface,#fff)}
.iwb-plp-vhead{display:flex;align-items:center;gap:8px;font-size:11.5px;color:var(--iwb-text2,#5b6472)} .iwb-plp-vhead{display:flex;align-items:center;gap:8px;font-size: 12px;color:var(--iwb-text2,#5b6472)}
.iwb-plp-vhint{color:var(--iwb-text2,#8b929c);font-size:11px} .iwb-plp-vhint{color:var(--iwb-text2,#8b929c);font-size:11px}
.iwb-plp-vchips{display:flex;flex-wrap:wrap;gap:6px} .iwb-plp-vchips{display:flex;flex-wrap:wrap;gap:6px}
.iwb-plp-vchip{display:inline-flex;align-items:center;gap:4px;padding:1px 7px;border-radius:6px;background:color-mix(in srgb, var(--iwb-plp-accent, #7c4dff) 10%, transparent);color:var(--iwb-plp-accent, #5a4bd0);font-size:11.5px} .iwb-plp-vchip{display:inline-flex;align-items:center;gap:4px;padding: 2px 6px;border-radius:6px;background:color-mix(in srgb, var(--iwb-plp-accent, #7c4dff) 10%, transparent);color:var(--iwb-plp-accent, #5a4bd0);font-size: 12px}
.iwb-plp-vx{font-style:normal;cursor:pointer;color:var(--iwb-plp-accent, #8b7ff0);font-weight:700} .iwb-plp-vx{font-style:normal;cursor:pointer;color:var(--iwb-plp-accent, #8b7ff0);font-weight:700}
.iwb-plp-vrows{display:flex;flex-direction:column;gap:5px} .iwb-plp-vrows{display:flex;flex-direction:column;gap: 6px}
.iwb-plp-vrow{display:flex;align-items:center;gap:8px} .iwb-plp-vrow{display:flex;align-items:center;gap:8px}
.iwb-plp-vk{width:92px;flex:0 0 92px;font-size:11.5px;color:var(--iwb-text2,#5b6472);overflow:hidden;text-overflow:ellipsis;white-space:nowrap} .iwb-plp-vk{width:92px;flex:0 0 92px;font-size: 12px;color:var(--iwb-text2,#5b6472);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.iwb-plp-vin{flex:1;height:26px;font-size:11.5px} .iwb-plp-vin{flex:1;height:26px;font-size: 12px}
.iwb-plp-vprev{margin-top:2px;border-top:1px dashed var(--iwb-border,#e3e5e9);padding-top:6px;font-size:11.5px;line-height:1.6;color:var(--iwb-text2,#5b6472);max-height:72px;overflow:auto;white-space:pre-wrap} .iwb-plp-vprev{margin-top:2px;border-top:1px dashed var(--iwb-border,#e3e5e9);padding-top:6px;font-size: 12px;line-height:1.6;color:var(--iwb-text2,#5b6472);max-height:72px;overflow:auto;white-space:pre-wrap}
.iwb-plp-dvars{display:flex;flex-direction:column;gap:5px;border:1px solid var(--iwb-border,#e3e5e9);border-radius:10px;padding:8px 10px} .iwb-plp-dvars{display:flex;flex-direction:column;gap: 6px;border:1px solid var(--iwb-border,#e3e5e9);border-radius:10px;padding:8px 10px}
/* v1.5.6:模板节点参照风格节点 —— 封面 + 名称 + 变量,正文不再铺开 */ /* v1.5.6:模板节点参照风格节点 —— 封面 + 名称 + 变量,正文不再铺开 */
.iwb-plp-nthumb{width:56px;height:56px;border-radius:8px;object-fit:cover;flex:0 0 auto} .iwb-plp-nthumb{width:56px;height:56px;border-radius:8px;object-fit:cover;flex:0 0 auto}
.iwb-plp-ntitlebox{min-width:0;display:flex;flex-direction:column;gap:2px} .iwb-plp-ntitlebox{min-width:0;display:flex;flex-direction:column;gap:2px}
.iwb-plp-ntitle{font-weight:600;font-size:12.5px;line-height:1.3;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical} .iwb-plp-ntitle{font-weight:600;font-size: 13px;line-height:1.3;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
.iwb-plp-nmeta{font-size:10.5px;color:var(--iwb-text2,#8b929c)} .iwb-plp-nmeta{font-size: 11px;color:var(--iwb-text2,#8b929c)}
.iwb-plp-nempty{font-size:11px;color:var(--iwb-text2,#8b929c);padding:2px 0} .iwb-plp-nempty{font-size:11px;color:var(--iwb-text2,#8b929c);padding:2px 0}
.iwb-plp-nwarn{font-size:11px;line-height:1.5;color:var(--iwb-warn,#d97706)} .iwb-plp-nwarn{font-size:11px;line-height:1.5;color:var(--iwb-warn,#d97706)}
/* v1.5.10:设置页 */ /* v1.5.10:设置页 */
.iwb-plp-settings{display:flex;flex-direction:column;gap:18px} .iwb-plp-settings{display:flex;flex-direction:column;gap: 16px}
.iwb-plp-ssec{border:1px solid var(--iwb-border,#e3e5e9);border-radius:12px;padding:12px 14px;display:flex;flex-direction:column;gap:8px} /* 2026-11-24:插件设置页跟随宿主的设置分组 token(不再自画卡片,避免卡片套卡片) */
.iwb-plp-stitle{font-weight:600;font-size:12.5px} .iwb-plp-ssec{border:0;border-top:1px solid var(--iwb-set-divider,var(--iwb-border,#e3e5e9));border-radius:0;padding:var(--iwb-space-12) 0 0;display:flex;flex-direction:column;gap:var(--iwb-space-8)}
.iwb-plp-sgroups{display:flex;flex-direction:column;border:1px solid var(--iwb-border,#eef0f2);border-radius:10px;overflow:hidden} .iwb-plp-ssec:first-child{border-top:0;padding-top:0}
.iwb-plp-sgrow{display:flex;align-items:center;gap:8px;padding:7px 10px;border-top:1px solid var(--iwb-border,#f1f3f5)} .iwb-plp-stitle{font-weight:600;font-size:var(--iwb-font-md,13px);color:var(--iwb-text,#2a2f36)}
.iwb-plp-sgroups{display:flex;flex-direction:column;border:1px solid var(--iwb-set-input-border,var(--iwb-border,#eef0f2));border-radius:var(--iwb-radius-card,10px);overflow:hidden}
.iwb-plp-sgrow{display:flex;align-items:center;gap:8px;padding: 6px 10px;border-top:1px solid var(--iwb-border,#f1f3f5)}
.iwb-plp-sgrow:first-child{border-top:0} .iwb-plp-sgrow:first-child{border-top:0}
.iwb-plp-sgrip{width:12px;height:12px;background:radial-gradient(var(--iwb-text2,#c2c7cf) 1px,transparent 1px);background-size:4px 4px;border-radius:3px;flex:0 0 auto} .iwb-plp-sgrip{width:12px;height:12px;background:radial-gradient(var(--iwb-text2,#c2c7cf) 1px,transparent 1px);background-size:4px 4px;border-radius: 6px;flex:0 0 auto}
.iwb-plp-sgname{width:170px;height:26px;font-size:12px} .iwb-plp-sgname{width:170px;height:26px;font-size:12px}
.iwb-plp-sgcount{font-size:11.5px;color:var(--iwb-text2,#8b929c);width:56px} .iwb-plp-sgcount{font-size: 12px;color:var(--iwb-text2,#8b929c);width:56px}
.iwb-plp-sadd{display:flex;gap:8px;align-items:center} .iwb-plp-sadd{display:flex;gap:8px;align-items:center}
.iwb-plp-sbtns{display:flex;gap:8px;align-items:center} .iwb-plp-sbtns{display:flex;gap:8px;align-items:center}
.iwb-plp-sopt{display:flex;gap:8px;align-items:center;font-size:12px;color:var(--iwb-text2,#4d5668)} .iwb-plp-sopt{display:flex;gap:8px;align-items:center;font-size:12px;color:var(--iwb-text2,#4d5668)}
@@ -202,7 +205,7 @@ flex: 1;
display: flex; gap: 6px; align-items: center; display: flex; gap: 6px; align-items: center;
} }
.iwb-promptlib .iwb-hint { .iwb-promptlib .iwb-hint {
font-size: 10px; color: var(--iwb-text2); margin-top: 4px; font-size: 11px; color: var(--iwb-text2); margin-top: 4px;
} }
.iwb-promptlib .iwb-toolbar-title { .iwb-promptlib .iwb-toolbar-title {
font-weight: 700; font-size: 13px; margin-right: 2px; font-weight: 700; font-size: 13px; margin-right: 2px;
@@ -217,10 +220,10 @@ width: 680px; max-width: calc(100vw - 60px); max-height: 82vh; background: var(-
display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--iwb-border); display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--iwb-border);
} }
.iwb-plp-dialog-body { .iwb-plp-dialog-body {
padding: 14px 16px; overflow: auto; display: flex; flex-direction: column; gap: 10px; max-height: 62vh; padding: 12px 16px; overflow: auto; display: flex; flex-direction: column; gap: 10px; max-height: 62vh;
} }
.iwb-promptlib .iwb-lib-body { .iwb-promptlib .iwb-lib-body {
flex: 1; overflow: hidden; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; overflow: hidden; padding: 12px 12px; display: flex; flex-direction: column; gap: 8px;
} }
.iwb-promptlib .iwb-lib-fixed { .iwb-promptlib .iwb-lib-fixed {
flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px;
@@ -232,7 +235,7 @@ flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction:
display: none; display: none;
} }
.iwb-promptlib .iwb-lib-chips-scroll > .iwb-chip:last-child { .iwb-promptlib .iwb-lib-chips-scroll > .iwb-chip:last-child {
margin-right: 18px; margin-right: 16px;
} }
.iwb-promptlib .iwb-lib-searchscope-back { .iwb-promptlib .iwb-lib-searchscope-back {
display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; padding: 0; border: none; border-radius: 999px; background: transparent; color: var(--iwb-text2); font-size: 13px; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; padding: 0; border: none; border-radius: 999px; background: transparent; color: var(--iwb-text2); font-size: 13px; line-height: 1; cursor: pointer;
@@ -241,7 +244,7 @@ display: inline-flex; align-items: center; justify-content: center; width: 15px;
background: color-mix(in srgb, var(--iwb-text) 12%, transparent); color: var(--iwb-text); background: color-mix(in srgb, var(--iwb-text) 12%, transparent); color: var(--iwb-text);
} }
.iwb-promptlib .iwb-chip { .iwb-promptlib .iwb-chip {
flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; background: var(--iwb-layer); border: 1px solid var(--iwb-border); border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--iwb-text2); cursor: pointer; white-space: nowrap; transition: all 0.15s; flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; background: var(--iwb-layer); border: 1px solid var(--iwb-border); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--iwb-text2); cursor: pointer; white-space: nowrap; transition: all 0.15s;
} }
.iwb-promptlib .iwb-chip:hover { .iwb-promptlib .iwb-chip:hover {
color: var(--iwb-text); border-color: var(--iwb-border2); color: var(--iwb-text); border-color: var(--iwb-border2);
@@ -253,7 +256,7 @@ background: var(--iwb-panel); border-color: var(--iwb-border2); color: var(--iwb
color: var(--iwb-text); color: var(--iwb-text);
} }
.iwb-promptlib .iwb-chip-count { .iwb-promptlib .iwb-chip-count {
font-size: 10px; opacity: 0.8; font-size: 11px; opacity: 0.8;
} }
.iwb-promptlib .iwb-chip-add { .iwb-promptlib .iwb-chip-add {
font-weight: 700; font-weight: 700;
@@ -268,7 +271,7 @@ color: var(--iwb-text); opacity: 1;
border: 1px solid var(--iwb-border); border-radius: 8px; padding: 8px 10px; background: var(--iwb-panel); border: 1px solid var(--iwb-border); border-radius: 8px; padding: 8px 10px; background: var(--iwb-panel);
} }
.iwb-promptlib .iwb-tag { .iwb-promptlib .iwb-tag {
display: inline-block; background: color-mix(in srgb, var(--iwb-text) 7%, transparent); color: var(--iwb-text2); border-radius: 4px; font-size: 10px; padding: 1px 6px; margin: 3px 4px 0 0; display: inline-block; background: color-mix(in srgb, var(--iwb-text) 7%, transparent); color: var(--iwb-text2); border-radius: 6px; font-size: 11px; padding: 2px 6px; margin: 4px 4px 0 0;
} }
.iwb-plp-dialog-sm { .iwb-plp-dialog-sm {
width: 460px; width: 460px;
@@ -301,7 +304,7 @@ background: var(--iwb-brand); border-color: var(--iwb-brand); color: var(--iwb-o
background: color-mix(in srgb, var(--iwb-brand) 85%, var(--iwb-text)); border-color: var(--iwb-brand); color: var(--iwb-on-brand); background: color-mix(in srgb, var(--iwb-brand) 85%, var(--iwb-text)); border-color: var(--iwb-brand); color: var(--iwb-on-brand);
} }
.iwb-promptlib .iwb-btn-sm { .iwb-promptlib .iwb-btn-sm {
padding: 3px 7px; font-size: 11px; padding: 4px 6px; font-size: 11px;
} }
.iwb-promptlib .iwb-btn-danger { .iwb-promptlib .iwb-btn-danger {
color: var(--iwb-err); color: var(--iwb-err);
@@ -313,10 +316,10 @@ border-color: var(--iwb-err); color: var(--iwb-err);
position: fixed; min-width: 196px; max-width: 240px; max-height: calc(100vh - 24px); overflow-y: auto; padding: 6px; background: var(--iwb-layer); border: 1px solid var(--iwb-border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,0.28), 0 2px 8px rgba(0,0,0,0.16); z-index: 91; display: flex; flex-direction: column; gap: 2px; position: fixed; min-width: 196px; max-width: 240px; max-height: calc(100vh - 24px); overflow-y: auto; padding: 6px; background: var(--iwb-layer); border: 1px solid var(--iwb-border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,0.28), 0 2px 8px rgba(0,0,0,0.16); z-index: 91; display: flex; flex-direction: column; gap: 2px;
} }
.iwb-promptlib .iwb-ctx-title { .iwb-promptlib .iwb-ctx-title {
font-size: 10px; font-weight: 700; color: var(--iwb-text2); letter-spacing: 1px; padding: 6px 10px 2px; text-transform: uppercase; font-size: 11px; font-weight: 700; color: var(--iwb-text2); letter-spacing: 1px; padding: 6px 10px 2px; text-transform: uppercase;
} }
.iwb-promptlib .iwb-ctx-item { .iwb-promptlib .iwb-ctx-item {
display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: none; border-radius: 8px; background: transparent; color: var(--iwb-text); font-size: 12.5px; cursor: pointer; text-align: left; display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 10px; border: none; border-radius: 8px; background: transparent; color: var(--iwb-text); font-size: 13px; cursor: pointer; text-align: left;
} }
.iwb-promptlib .iwb-ctx-item .iwb-ic { .iwb-promptlib .iwb-ctx-item .iwb-ic {
width: 14px; height: 14px; flex: 0 0 auto; color: var(--iwb-text2); width: 14px; height: 14px; flex: 0 0 auto; color: var(--iwb-text2);
@@ -345,6 +348,11 @@ height: 1px; margin: 4px 6px; background: var(--iwb-border); flex: 0 0 auto;
.iwb-promptlib .iwb-drawer-spacer { .iwb-promptlib .iwb-drawer-spacer {
flex: 1 1 auto; flex: 1 1 auto;
} }
/* v1.10.1:详情底部分享组(文本/文件分享)与插入组之间的竖向分割线 */
.iwb-plp-dialog .iwb-plp-foot-vsep {
display: inline-block; width: 1px; height: 18px; flex: 0 0 auto;
align-self: center; margin: 0 12px; background: var(--iwb-border);
}
.iwb-plp-dialog .iwb-section-sub { .iwb-plp-dialog .iwb-section-sub {
margin-top: 2px; margin-top: 2px;
} }
@@ -364,11 +372,11 @@ box-shadow: 0 24px 60px rgba(0,0,0,.32);
.iwb-plp-card.is-dragging{opacity:.55;transform:scale(.98)} .iwb-plp-card.is-dragging{opacity:.55;transform:scale(.98)}
/* v1.6.9:拖拽虚拟卡片(跟手预览) */ /* v1.6.9:拖拽虚拟卡片(跟手预览) */
.iwb-plp-dragghost{width:168px;display:flex;align-items:center;gap:8px;padding:8px 10px;background:var(--iwb-panel,#fff);border:2px solid var(--iwb-plp-accent,#7c4dff);border-radius:11px;box-shadow:0 12px 28px rgba(0,0,0,.22);font-size:12px;pointer-events:none;z-index:99999} .iwb-plp-dragghost{width:168px;display:flex;align-items:center;gap:8px;padding:8px 10px;background:var(--iwb-panel,#fff);border:2px solid var(--iwb-plp-accent,#7c4dff);border-radius: 10px;box-shadow:0 12px 28px rgba(0,0,0,.22);font-size:12px;pointer-events:none;z-index: var(--iwb-z-anchor, 3200)}
.iwb-plp-ghostcov{width:38px;height:38px;border-radius:8px;object-fit:cover;flex:0 0 auto;background:var(--iwb-plugin-inset,#eef0f2)} .iwb-plp-ghostcov{width:38px;height:38px;border-radius:8px;object-fit:cover;flex:0 0 auto;background:var(--iwb-plugin-inset,#eef0f2)}
.iwb-plp-ghosttxt{min-width:0;display:flex;flex-direction:column;gap:2px} .iwb-plp-ghosttxt{min-width:0;display:flex;flex-direction:column;gap:2px}
.iwb-plp-ghostname{font-weight:600;color:var(--iwb-text,#1c2333);overflow:hidden;text-overflow:ellipsis;white-space:nowrap} .iwb-plp-ghostname{font-weight:600;color:var(--iwb-text,#1c2333);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.iwb-plp-ghosthint{font-size:10.5px;color:var(--iwb-plp-accent,#5a4bd0)} .iwb-plp-ghosthint{font-size: 11px;color:var(--iwb-plp-accent,#5a4bd0)}
/* v1.6.10:悬停放大改为「内层背景层缩放」——卡片命中区域不变,渐变卡不再闪烁 */ /* v1.6.10:悬停放大改为「内层背景层缩放」——卡片命中区域不变,渐变卡不再闪烁 */
.iwb-plp-bg{position:absolute;inset:0;overflow:hidden;border-radius:inherit;transition:transform .16s ease;will-change:transform;backface-visibility:hidden} .iwb-plp-bg{position:absolute;inset:0;overflow:hidden;border-radius:inherit;transition:transform .16s ease;will-change:transform;backface-visibility:hidden}
@@ -390,11 +398,11 @@ box-shadow: 0 24px 60px rgba(0,0,0,.32);
.iwb-plp-card{user-select:none} .iwb-plp-card{user-select:none}
body.iwb-plp-dragging, body.iwb-plp-dragging *{user-select:none!important;-webkit-user-select:none!important} body.iwb-plp-dragging, body.iwb-plp-dragging *{user-select:none!important;-webkit-user-select:none!important}
.iwb-plp-placeghost{border-style:dashed!important;pointer-events:none} .iwb-plp-placeghost{border-style:dashed!important;pointer-events:none}
.iwb-plp-placehint{font-size:10.5px;color:var(--iwb-plp-accent,#5a4bd0);margin-top:2px} .iwb-plp-placehint{font-size: 11px;color:var(--iwb-plp-accent,#5a4bd0);margin-top:2px}
.iwb-plp-placebox{position:fixed;left:-9999px;top:0;z-index:99999;pointer-events:none;border:2px dashed var(--iwb-plp-accent,#6b4dff);border-radius:12px;background:color-mix(in srgb,var(--iwb-plp-accent,#6b4dff) 9%,transparent);display:flex;align-items:center;justify-content:center;box-shadow:0 10px 26px rgba(30,20,80,.10)} .iwb-plp-placebox{position:fixed;left:-9999px;top:0;z-index: var(--iwb-z-anchor, 3200);pointer-events:none;border:2px dashed var(--iwb-plp-accent,#6b4dff);border-radius:12px;background:color-mix(in srgb,var(--iwb-plp-accent,#6b4dff) 9%,transparent);display:flex;align-items:center;justify-content:center;box-shadow:0 10px 26px rgba(30,20,80,.10)}
.iwb-plp-placebox-t{font-size:12px;color:var(--iwb-plp-accent,#5a3fd0);background:rgba(255,255,255,.82);border-radius:999px;padding:3px 10px} .iwb-plp-placebox-t{font-size:12px;color:var(--iwb-plp-accent,#5a3fd0);background:rgba(255,255,255,.82);border-radius:999px;padding: 4px 10px}
/* v1.6.23:放置指示改为灰色小方框 */ /* v1.6.23:放置指示改为灰色小方框 */
.iwb-plp-placebox{border: 2px dashed var(--plp-c2, #9aa3ad);border-radius:10px;background:rgba(122,130,142,.10);box-shadow:none} .iwb-plp-placebox{border: 2px dashed var(--iwb-border2, #9aa3ad);border-radius:10px;background:rgba(122,130,142,.10);box-shadow:none}
.iwb-plp-placebox-t{font-size:11px;color: var(--plp-c3, #6b7280);background:rgba(255,255,255,.75);padding:2px 8px} .iwb-plp-placebox-t{font-size:11px;color: var(--plp-c3, #6b7280);background:rgba(255,255,255,.75);padding:2px 8px}
/* v1.7.0:编辑面板三栏 + 可拖宽;详情封面放大、变量高亮 */ /* v1.7.0:编辑面板三栏 + 可拖宽;详情封面放大、变量高亮 */
.iwb-plp-eleft{flex:0 0 236px;width:236px} .iwb-plp-eleft{flex:0 0 236px;width:236px}
@@ -408,51 +416,51 @@ body.iwb-plp-dragging, body.iwb-plp-dragging *{user-select:none!important;-webki
.iwb-plp-vitem{padding:4px 0;border-bottom:1px dashed var(--iwb-border,#eceef2)} .iwb-plp-vitem{padding:4px 0;border-bottom:1px dashed var(--iwb-border,#eceef2)}
.iwb-plp-vrow2{display:flex;align-items:center;gap:6px} .iwb-plp-vrow2{display:flex;align-items:center;gap:6px}
.iwb-plp-vname{flex:1 1 auto;min-width:0;height:32px} .iwb-plp-vname{flex:1 1 auto;min-width:0;height:32px}
.iwb-plp-vi{flex:0 0 auto;width:24px;height:24px;padding:0;border-radius:50%;border:1px solid var(--iwb-border,#dfe3e9);background: var(--plp-c1, #fff);color: var(--plp-c4, #9aa1ac);font-size:11px;line-height:22px;text-align:center} .iwb-plp-vi{flex:0 0 auto;width:24px;height:24px;padding:0;border-radius:50%;border:1px solid var(--iwb-border,#dfe3e9);background: var(--iwb-plugin-card, #fff);color: var(--iwb-text-dim, #9aa1ac);font-size:11px;line-height:22px;text-align:center}
.iwb-plp-vi.is-open{background: var(--plp-c5, #f1ecff);border-color: var(--plp-c6, #d8cbff);color: var(--plp-c7, #5a3fd0)} .iwb-plp-vi.is-open{background: var(--iwb-plp-accent-soft, #f1ecff);border-color: var(--iwb-plp-accent-border, #d8cbff);color: var(--iwb-plp-accent, #5a3fd0)}
.iwb-plp-vdesc{width:100%;height:28px;margin-top:5px;border-style:dashed;background: var(--plp-c8, #fbfcfd);font-size:11.5px;color: var(--plp-c3, #6b7280)} .iwb-plp-vdesc{width:100%;height:28px;margin-top: 6px;border-style:dashed;background: var(--iwb-field, #fbfcfd);font-size: 12px;color: var(--plp-c3, #6b7280)}
.iwb-plp-dcov{flex:0 0 auto;width:180px;height:180px;border-radius:12px;overflow:hidden} .iwb-plp-dcov{flex:0 0 auto;width:180px;height:180px;border-radius:12px;overflow:hidden}
.iwb-plp-dvar{background: var(--plp-c5, #f1ecff);color: var(--plp-c7, #5a3fd0);border-radius:4px;padding:0 4px;font-weight:500} .iwb-plp-dvar{background: var(--iwb-plp-accent-soft, #f1ecff);color: var(--iwb-plp-accent, #5a3fd0);border-radius: 6px;padding:0 4px;font-weight:500}
/* v1.7.1:编辑面板视觉精修——输入框比底色更亮、去多余边框、细分隔线 */ /* v1.7.1:编辑面板视觉精修——输入框比底色更亮、去多余边框、细分隔线 */
.iwb-plp-dialog .iwb-plp-dbody{gap:10px;padding:12px;background: var(--plp-c9, #f4f5f7)} .iwb-plp-dialog .iwb-plp-dbody{gap:10px;padding:12px;background: var(--iwb-plugin-inset, #f4f5f7)}
.iwb-plp-dialog .iwb-plp-eleft{flex:0 0 236px;width:236px;background: var(--plp-c1, #fff);border: 1px solid var(--plp-c10, #e6e8ec);border-radius:12px;padding:12px} .iwb-plp-dialog .iwb-plp-eleft{flex:0 0 236px;width:236px;background: var(--iwb-plugin-card, #fff);border: 1px solid var(--iwb-plugin-border, #e6e8ec);border-radius:12px;padding:12px}
.iwb-plp-dialog .iwb-plp-emid{background: var(--plp-c1, #fff);border: 1px solid var(--plp-c10, #e6e8ec);border-radius:12px;padding:10px 12px 12px} .iwb-plp-dialog .iwb-plp-emid{background: var(--iwb-plugin-card, #fff);border: 1px solid var(--iwb-plugin-border, #e6e8ec);border-radius:12px;padding:10px 12px 12px}
.iwb-plp-dialog .iwb-plp-emid .iwb-plp-etext{border: 1px solid var(--plp-c11, #eef0f3);background: var(--plp-c8, #fbfcfd);border-radius:9px;padding:10px 12px} .iwb-plp-dialog .iwb-plp-emid .iwb-plp-etext{border: 1px solid var(--iwb-plugin-border, #eef0f3);background: var(--iwb-field, #fbfcfd);border-radius: 8px;padding:10px 12px}
.iwb-plp-dialog .iwb-plp-emid .iwb-plp-etext:focus{background: var(--plp-c1, #fff);border-color: var(--plp-c12, #cfc3ff);box-shadow:0 0 0 3px rgba(107,77,255,.08)} .iwb-plp-dialog .iwb-plp-emid .iwb-plp-etext:focus{background: var(--iwb-plugin-card, #fff);border-color: var(--iwb-plp-accent-border, #cfc3ff);box-shadow:0 0 0 3px rgba(107,77,255,.08)}
.iwb-plp-dialog .iwb-plp-esplit{flex:0 0 6px;background:transparent;border-radius:4px} .iwb-plp-dialog .iwb-plp-esplit{flex:0 0 6px;background:transparent;border-radius: 6px}
.iwb-plp-dialog .iwb-plp-esplit:hover{background: var(--plp-c13, #e7e9ee)} .iwb-plp-dialog .iwb-plp-esplit:hover{background: var(--iwb-plugin-hover, #e7e9ee)}
.iwb-plp-dialog .iwb-plp-esplit::before{content:'';display:block;width:2px;height:30px;border-radius:2px;background: var(--plp-c14, #d7dbe2)} .iwb-plp-dialog .iwb-plp-esplit::before{content:'';display:block;width:2px;height:30px;border-radius: 6px;background: var(--iwb-plugin-hover, #d7dbe2)}
.iwb-plp-dialog .iwb-plp-eright{background:transparent;border:0;padding:2px 0 0} .iwb-plp-dialog .iwb-plp-eright{background:transparent;border:0;padding:2px 0 0}
.iwb-plp-dialog .iwb-plp-vitem{border:0;padding:2px 0} .iwb-plp-dialog .iwb-plp-vitem{border:0;padding:2px 0}
.iwb-plp-dialog .iwb-plp-vrow2{gap:6px} .iwb-plp-dialog .iwb-plp-vrow2{gap:6px}
.iwb-plp-dialog .iwb-plp-vname{background: var(--plp-c8, #fbfcfd);border: 1px solid var(--plp-c15, #eceef2);border-radius:8px;height:32px;padding:0 10px;font-size:12.5px;color: var(--plp-c16, #33383f)} .iwb-plp-dialog .iwb-plp-vname{background: var(--iwb-field, #fbfcfd);border: 1px solid var(--iwb-plugin-border, #eceef2);border-radius:8px;height:32px;padding:0 10px;font-size: 13px;color: var(--iwb-text, #33383f)}
.iwb-plp-dialog .iwb-plp-vname:focus{background: var(--plp-c1, #fff);border-color: var(--plp-c12, #cfc3ff);box-shadow:0 0 0 3px rgba(107,77,255,.08)} .iwb-plp-dialog .iwb-plp-vname:focus{background: var(--iwb-plugin-card, #fff);border-color: var(--iwb-plp-accent-border, #cfc3ff);box-shadow:0 0 0 3px rgba(107,77,255,.08)}
.iwb-plp-dialog .iwb-plp-vi{background:transparent;border:0;color: var(--plp-c17, #aab0ba);width:22px;height:22px;line-height:20px} .iwb-plp-dialog .iwb-plp-vi{background:transparent;border:0;color: var(--iwb-text-dim, #aab0ba);width:22px;height:22px;line-height:20px}
.iwb-plp-dialog .iwb-plp-vi:hover{background: var(--plp-c18, #eef0f4);color: var(--plp-c3, #6b7280)} .iwb-plp-dialog .iwb-plp-vi:hover{background: var(--iwb-plugin-inset, #eef0f4);color: var(--plp-c3, #6b7280)}
.iwb-plp-dialog .iwb-plp-vi.is-open{background: var(--plp-c5, #f1ecff);color: var(--plp-c7, #5a3fd0)} .iwb-plp-dialog .iwb-plp-vi.is-open{background: var(--iwb-plp-accent-soft, #f1ecff);color: var(--iwb-plp-accent, #5a3fd0)}
.iwb-plp-dialog .iwb-plp-vdesc{background: var(--plp-c8, #fbfcfd);border: 1px dashed var(--plp-c19, #e2e6ec);border-radius:7px;height:28px;margin-top:4px} .iwb-plp-dialog .iwb-plp-vdesc{background: var(--iwb-field, #fbfcfd);border: 1px dashed var(--iwb-plugin-border, #e2e6ec);border-radius: 8px;height:28px;margin-top:4px}
.iwb-plp-dialog .iwb-plp-lrow span{color: var(--plp-c20, #8a919c);font-size:11.5px} .iwb-plp-dialog .iwb-plp-lrow span{color: var(--iwb-text2, #8a919c);font-size: 12px}
.iwb-plp-dialog .iwb-plp-lrow .iwb-input{background: var(--plp-c8, #fbfcfd);border: 1px solid var(--plp-c15, #eceef2);border-radius:8px;height:32px} .iwb-plp-dialog .iwb-plp-lrow .iwb-input{background: var(--iwb-field, #fbfcfd);border: 1px solid var(--iwb-plugin-border, #eceef2);border-radius:8px;height:32px}
.iwb-plp-dialog .iwb-plp-lrow .iwb-input:focus{background: var(--plp-c1, #fff);border-color: var(--plp-c12, #cfc3ff)} .iwb-plp-dialog .iwb-plp-lrow .iwb-input:focus{background: var(--iwb-plugin-card, #fff);border-color: var(--iwb-plp-accent-border, #cfc3ff)}
/* v1.7.2:正文变量高亮(黑粗)+ 说明灰按钮 + 说明背景回归面板底 */ /* v1.7.2:正文变量高亮(黑粗)+ 说明灰按钮 + 说明背景回归面板底 */
.iwb-plp-ewrap{position:relative;flex:1 1 auto;min-height:0;display:flex;border-radius:9px;background: var(--plp-c8, #fbfcfd);border: 1px solid var(--plp-c11, #eef0f3)} .iwb-plp-ewrap{position:relative;flex:1 1 auto;min-height:0;display:flex;border-radius: 8px;background: var(--iwb-field, #fbfcfd);border: 1px solid var(--iwb-plugin-border, #eef0f3)}
.iwb-plp-ewrap:focus-within{background: var(--plp-c1, #fff);border-color: var(--plp-c12, #cfc3ff);box-shadow:0 0 0 3px rgba(107,77,255,.08)} .iwb-plp-ewrap:focus-within{background: var(--iwb-plugin-card, #fff);border-color: var(--iwb-plp-accent-border, #cfc3ff);box-shadow:0 0 0 3px rgba(107,77,255,.08)}
.iwb-plp-ewrap .iwb-plp-etext{flex:1 1 auto;min-height:0;border:0;background:transparent;box-shadow:none;color:transparent;caret-color:var(--plp-c22, #1d2129);position:relative;z-index:1;resize:none} .iwb-plp-ewrap .iwb-plp-etext{flex:1 1 auto;min-height:0;border:0;background:transparent;box-shadow:none;color:transparent;caret-color:var(--plp-c22, #1d2129);position:relative;z-index:1;resize:none}
.iwb-plp-ewrap .iwb-plp-etext:focus{background:transparent;border:0;box-shadow:none} .iwb-plp-ewrap .iwb-plp-etext:focus{background:transparent;border:0;box-shadow:none}
.iwb-plp-hl{position:absolute;inset:0;padding:10px 12px;overflow:hidden;white-space:pre-wrap;word-wrap:break-word;font-size:13px;line-height:1.9;color: var(--plp-c21, #5b6472);pointer-events:none;z-index:0} .iwb-plp-hl{position:absolute;inset:0;padding:10px 12px;overflow:hidden;white-space:pre-wrap;word-wrap:break-word;font-size:13px;line-height:1.9;color: var(--iwb-text2, #5b6472);pointer-events:none;z-index:0}
.iwb-plp-hlvar{color: var(--plp-c22, #1d2129);font-weight:600} .iwb-plp-hlvar{color: var(--iwb-text, #1d2129);font-weight:600}
.iwb-plp-dialog .iwb-plp-vi.is-open{background: var(--plp-c11, #eef0f3);color: var(--plp-c21, #5b6472)} .iwb-plp-dialog .iwb-plp-vi.is-open{background: var(--iwb-plugin-hover, #eef0f3);color: var(--iwb-text2, #5b6472)}
.iwb-plp-dialog .iwb-plp-vdesc{background:transparent;border: 1px dashed var(--plp-c23, #dfe3e9)} .iwb-plp-dialog .iwb-plp-vdesc{background:transparent;border: 1px dashed var(--iwb-plugin-border, #dfe3e9)}
.iwb-plp-dvar{background:transparent;color: var(--plp-c22, #1d2129);font-weight:600;padding:0} .iwb-plp-dvar{background:transparent;color: var(--iwb-text, #1d2129);font-weight:600;padding:0}
.iwb-plp-hres{height:6px;margin:-3px 0 0;cursor:ns-resize;flex:0 0 auto;border-radius:3px} .iwb-plp-hres{height:6px;margin: -4px 0 0;cursor:ns-resize;flex:0 0 auto;border-radius: 6px}
.iwb-plp-hres:hover{background: var(--plp-c13, #e7e9ee)} .iwb-plp-hres:hover{background: var(--iwb-plugin-hover, #e7e9ee)}
/* 正文可见性:textarea 透明,显示下方高亮层 */ /* 正文可见性:textarea 透明,显示下方高亮层 */
.iwb-plp-dialog .iwb-plp-emid .iwb-plp-ewrap{flex:1 1 auto;min-height:0;position:relative;display:flex;background: var(--plp-c8, #fbfcfd);border: 1px solid var(--plp-c11, #eef0f3);border-radius:9px} .iwb-plp-dialog .iwb-plp-emid .iwb-plp-ewrap{flex:1 1 auto;min-height:0;position:relative;display:flex;background: var(--iwb-field, #fbfcfd);border: 1px solid var(--iwb-plugin-border, #eef0f3);border-radius: 8px}
.iwb-plp-dialog .iwb-plp-emid .iwb-plp-ewrap .iwb-plp-etext{background:transparent!important;color:transparent!important;border:0!important;box-shadow:none!important;padding:10px 12px} .iwb-plp-dialog .iwb-plp-emid .iwb-plp-ewrap .iwb-plp-etext{background:transparent!important;color:transparent!important;border:0!important;box-shadow:none!important;padding:10px 12px}
.iwb-plp-dialog .iwb-plp-hl{padding:10px 12px;font-size:13px;line-height:1.9} .iwb-plp-dialog .iwb-plp-hl{padding:10px 12px;font-size:13px;line-height:1.9}
.iwb-plp-namebox{min-height:34px;height:34px;line-height:1.45;padding:7px 10px;resize:vertical;overflow:auto;font-size:12.5px} .iwb-plp-namebox{min-height:34px;height:34px;line-height:1.45;padding: 6px 10px;resize:vertical;overflow:auto;font-size: 13px}
.iwb-plp-insvar{color: var(--plp-c22, #1d2129)!important;background: var(--plp-c1, #fff)!important;border-color: var(--plp-c19, #e2e6ec)!important} .iwb-plp-insvar{color: var(--iwb-text, #1d2129)!important;background: var(--iwb-plugin-card, #fff)!important;border-color: var(--iwb-plugin-border, #e2e6ec)!important}
.iwb-plp-insvar:hover{background: var(--plp-c24, #f4f6f9)!important} .iwb-plp-insvar:hover{background: var(--iwb-plugin-inset, #f4f6f9)!important}
/* v1.7.5:编辑封面卡在框内;详情封面放大 */ /* v1.7.5:编辑封面卡在框内;详情封面放大 */
.iwb-plp-dialog .iwb-plp-ecov{width:100%;height:250px;overflow:hidden;border-radius:12px;background:var(--iwb-plugin-inset,#f3f4f7)} .iwb-plp-dialog .iwb-plp-ecov{width:100%;height:250px;overflow:hidden;border-radius:12px;background:var(--iwb-plugin-inset,#f3f4f7)}
.iwb-plp-dialog .iwb-plp-ecov .iwb-plp-cover{width:100%;height:100%;object-fit:cover;object-position:center;display:block;border-radius:12px} .iwb-plp-dialog .iwb-plp-ecov .iwb-plp-cover{width:100%;height:100%;object-fit:cover;object-position:center;display:block;border-radius:12px}
@@ -481,7 +489,8 @@ body.iwb-plp-dragging, body.iwb-plp-dragging *{user-select:none!important;-webki
tab-size:4!important; tab-size:4!important;
} }
.iwb-plp-dialog .iwb-plp-emid .iwb-plp-ewrap .iwb-plp-etext{overflow-y:auto!important;scrollbar-gutter:stable} .iwb-plp-dialog .iwb-plp-emid .iwb-plp-ewrap .iwb-plp-etext{overflow-y:auto!important;scrollbar-gutter:stable}
.iwb-plp-dialog .iwb-plp-emid .iwb-plp-hl{overflow:hidden!important} /* v1.9.3:高亮层与 textarea 用同样的滚动条占位,避免换行位置不一致导致色块漂移 */
.iwb-plp-dialog .iwb-plp-emid .iwb-plp-ewrap .iwb-plp-hl{overflow:hidden!important;scrollbar-gutter:stable}
/* v1.7.9:详情正文独立滚动,长文不再压到底部按钮 */ /* v1.7.9:详情正文独立滚动,长文不再压到底部按钮 */
.iwb-plp-dialog-detail .iwb-plp-dbody{overflow:hidden;align-items:stretch} .iwb-plp-dialog-detail .iwb-plp-dbody{overflow:hidden;align-items:stretch}
.iwb-plp-dialog-detail .iwb-plp-dright{flex:1 1 auto;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:hidden} .iwb-plp-dialog-detail .iwb-plp-dright{flex:1 1 auto;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:hidden}
@@ -489,48 +498,48 @@ body.iwb-plp-dragging, body.iwb-plp-dragging *{user-select:none!important;-webki
/* v1.8.0:详情标题/分组/标签移到封面下方;编辑标签改为输入+加号 */ /* v1.8.0:详情标题/分组/标签移到封面下方;编辑标签改为输入+加号 */
.iwb-plp-dialog-detail .iwb-plp-dbody{align-items:flex-start} .iwb-plp-dialog-detail .iwb-plp-dbody{align-items:flex-start}
.iwb-plp-dleftcol{flex:0 0 264px;width:264px;display:flex;flex-direction:column;min-width:0} .iwb-plp-dleftcol{flex:0 0 264px;width:264px;display:flex;flex-direction:column;min-width:0}
.iwb-plp-dtitle{font-size:18px;font-weight:650;line-height:1.35;margin-top:14px;color:var(--iwb-text,#1d2129)} .iwb-plp-dtitle{font-size: 17px;font-weight:650;line-height:1.35;margin-top: 12px;color:var(--iwb-text,#1d2129)}
.iwb-plp-dmeta{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-top:8px} .iwb-plp-dmeta{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-top:8px}
.iwb-plp-dgroup{font-size:11.5px;background: var(--plp-c18, #eef0f4);color: var(--plp-c21, #5b6472);border-radius:999px;padding:2px 9px} .iwb-plp-dgroup{font-size: 12px;background: var(--iwb-plugin-inset, #eef0f4);color: var(--iwb-text2, #5b6472);border-radius:999px;padding: 2px 8px}
.iwb-plp-dtag{font-size:11.5px;background: var(--plp-c25, #f4f0ff);color: var(--plp-c7, #5a3fd0);border-radius:999px;padding:2px 9px} .iwb-plp-dtag{font-size: 12px;background: var(--iwb-plp-accent-soft, #f4f0ff);color: var(--iwb-plp-accent, #5a3fd0);border-radius:999px;padding: 2px 8px}
.iwb-plp-dlen{font-size:11.5px;color: var(--plp-c4, #9aa1ac)} .iwb-plp-dlen{font-size: 12px;color: var(--iwb-text-dim, #9aa1ac)}
.iwb-plp-tagwrap{display:flex;flex-direction:column;gap:6px;flex:1;min-width:0} .iwb-plp-tagwrap{display:flex;flex-direction:column;gap:6px;flex:1;min-width:0}
.iwb-plp-tagchips{display:flex;flex-wrap:wrap;gap:5px} .iwb-plp-tagchips{display:flex;flex-wrap:wrap;gap: 6px}
.iwb-plp-tagchip{display:inline-flex;align-items:center;gap:4px;font-size:11.5px;background: var(--plp-c18, #eef0f4);border-radius:999px;padding:2px 8px;color: var(--plp-c26, #3f4450)} .iwb-plp-tagchip{display:inline-flex;align-items:center;gap:4px;font-size: 12px;background: var(--iwb-plugin-inset, #eef0f4);border-radius:999px;padding:2px 8px;color: var(--iwb-text, #3f4450)}
.iwb-plp-tagx{cursor:pointer;color: var(--plp-c4, #9aa1ac);font-style:normal} .iwb-plp-tagx{cursor:pointer;color: var(--iwb-text-dim, #9aa1ac);font-style:normal}
.iwb-plp-tagx:hover{color: var(--plp-c27, #c0392b)} .iwb-plp-tagx:hover{color: var(--iwb-err, #c0392b)}
.iwb-plp-tagrow{display:flex;gap:6px} .iwb-plp-tagrow{display:flex;gap:6px}
.iwb-plp-tagin{flex:1;min-width:0;height:30px} .iwb-plp-tagin{flex:1;min-width:0;height:30px}
.iwb-plp-lrow-tags{align-items:flex-start} .iwb-plp-lrow-tags{align-items:flex-start}
.iwb-plp-tagadd{flex:0 0 auto;width:30px;height:30px;padding:0;font-size:15px;line-height:28px} .iwb-plp-tagadd{flex:0 0 auto;width:30px;height:30px;padding:0;font-size:15px;line-height:28px}
/* v1.8.1:详情标题/分组/标签左对齐并带标题;标签加号对齐修复 */ /* v1.8.1:详情标题/分组/标签左对齐并带标题;标签加号对齐修复 */
.iwb-plp-dtitle{font-size:20px;font-weight:650;line-height:1.35;margin-top:16px;color:var(--iwb-text,#1d2129)} .iwb-plp-dtitle{font-size:20px;font-weight:650;line-height:1.35;margin-top:16px;color:var(--iwb-text,#1d2129)}
.iwb-plp-dmeta{display:flex;flex-direction:column;gap:7px;margin-top:12px;align-items:flex-start} .iwb-plp-dmeta{display:flex;flex-direction:column;gap: 6px;margin-top:12px;align-items:flex-start}
.iwb-plp-dmrow{display:flex;align-items:center;gap:10px;width:100%} .iwb-plp-dmrow{display:flex;align-items:center;gap:10px;width:100%}
.iwb-plp-dmk{flex:0 0 30px;width:30px;font-size:11.5px;color: var(--plp-c4, #9aa1ac)} .iwb-plp-dmk{flex:0 0 30px;width:30px;font-size: 12px;color: var(--iwb-text-dim, #9aa1ac)}
.iwb-plp-dmv{display:flex;flex-wrap:wrap;align-items:center;gap:5px;min-width:0} .iwb-plp-dmv{display:flex;flex-wrap:wrap;align-items:center;gap: 6px;min-width:0}
.iwb-plp-dgroup{font-size:12px;color: var(--plp-c26, #3f4450);background: var(--plp-c28, #f2f4f7);border-radius:6px;padding:2px 9px} .iwb-plp-dgroup{font-size:12px;color: var(--iwb-text, #3f4450);background: var(--iwb-plugin-inset, #f2f4f7);border-radius:6px;padding: 2px 8px}
.iwb-plp-dtag{font-size:11.5px;color: var(--plp-c7, #5a3fd0);background: var(--plp-c25, #f4f0ff);border-radius:6px;padding:2px 9px} .iwb-plp-dtag{font-size: 12px;color: var(--iwb-plp-accent, #5a3fd0);background: var(--iwb-plp-accent-soft, #f4f0ff);border-radius:6px;padding: 2px 8px}
.iwb-plp-dempty{font-size:12px;color: var(--plp-c29, #b3b9c2)} .iwb-plp-dempty{font-size:12px;color: var(--iwb-text-dim, #b3b9c2)}
.iwb-plp-dlen{font-size:12px;color: var(--plp-c20, #8a919c)} .iwb-plp-dlen{font-size:12px;color: var(--iwb-text2, #8a919c)}
.iwb-plp-tagrow{display:flex;align-items:center;gap:6px} .iwb-plp-tagrow{display:flex;align-items:center;gap:6px}
.iwb-plp-tagin{height:30px;border-radius:8px} .iwb-plp-tagin{height:30px;border-radius:8px}
.iwb-plp-tagadd{flex:0 0 auto;width:30px;height:30px;padding:0;border-radius:8px;background: var(--plp-c28, #f2f4f7);border: 1px solid var(--plp-c19, #e2e6ec);color: var(--plp-c21, #5b6472);font-size:16px;line-height:1;display:inline-flex;align-items:center;justify-content:center} .iwb-plp-tagadd{flex:0 0 auto;width:30px;height:30px;padding:0;border-radius:8px;background: var(--iwb-plugin-inset, #f2f4f7);border: 1px solid var(--iwb-plugin-border, #e2e6ec);color: var(--iwb-text2, #5b6472);font-size: 15px;line-height:1;display:inline-flex;align-items:center;justify-content:center}
.iwb-plp-tagadd:hover{background: var(--plp-c30, #e9ecf1)} .iwb-plp-tagadd:hover{background: var(--iwb-plugin-hover, #e9ecf1)}
/* v1.8.2:详情左右两栏卡片化 + 分割线 */ /* v1.8.2:详情左右两栏卡片化 + 分割线 */
.iwb-plp-dialog-detail .iwb-plp-dbody{gap:14px;padding:16px;background: var(--plp-c9, #f4f5f7)} .iwb-plp-dialog-detail .iwb-plp-dbody{gap: 12px;padding:16px;background: var(--iwb-plugin-inset, #f4f5f7)}
.iwb-plp-dialog-detail .iwb-plp-dleftcol{flex:0 0 300px;width:300px;padding:12px;border: 1px solid var(--plp-c31, #e8eaee);border-radius:14px;background: var(--plp-c1, #fff);align-self:flex-start} .iwb-plp-dialog-detail .iwb-plp-dleftcol{flex:0 0 300px;width:300px;padding:12px;border: 1px solid var(--iwb-plugin-border, #e8eaee);border-radius:14px;background: var(--iwb-plugin-card, #fff);align-self:flex-start}
.iwb-plp-dialog-detail .iwb-plp-dcov{width:100%;height:270px;border-radius:10px} .iwb-plp-dialog-detail .iwb-plp-dcov{width:100%;height:270px;border-radius:10px}
.iwb-plp-dialog-detail .iwb-plp-dtitle{font-size:20px;font-weight:650;line-height:1.35;margin-top:14px;color:var(--iwb-text,#1d2129)} .iwb-plp-dialog-detail .iwb-plp-dtitle{font-size:20px;font-weight:650;line-height:1.35;margin-top: 12px;color:var(--iwb-text,#1d2129)}
.iwb-plp-dialog-detail .iwb-plp-dmeta{margin-top:12px;padding-top:12px;border-top: 1px solid var(--plp-c11, #eef0f3);gap:8px} .iwb-plp-dialog-detail .iwb-plp-dmeta{margin-top:12px;padding-top:12px;border-top: 1px solid var(--iwb-plugin-border, #eef0f3);gap:8px}
.iwb-plp-dialog-detail .iwb-plp-dright{flex:1 1 auto;min-width:0;min-height:0;display:flex;flex-direction:column;padding:14px 16px;border: 1px solid var(--plp-c31, #e8eaee);border-radius:14px;background: var(--plp-c1, #fff);overflow:hidden} .iwb-plp-dialog-detail .iwb-plp-dright{flex:1 1 auto;min-width:0;min-height:0;display:flex;flex-direction:column;padding: 12px 16px;border: 1px solid var(--iwb-plugin-border, #e8eaee);border-radius:14px;background: var(--iwb-plugin-card, #fff);overflow:hidden}
.iwb-plp-dsec{font-size:11.5px;font-weight:600;color: var(--plp-c20, #8a919c);letter-spacing:.04em;padding-bottom:8px;margin-bottom:8px;border-bottom: 1px solid var(--plp-c11, #eef0f3);flex:0 0 auto} .iwb-plp-dsec{font-size: 12px;font-weight:600;color: var(--iwb-text2, #8a919c);letter-spacing:.04em;padding-bottom:8px;margin-bottom:8px;border-bottom: 1px solid var(--iwb-plugin-border, #eef0f3);flex:0 0 auto}
.iwb-plp-dialog-detail .iwb-plp-dtext{flex:1 1 auto;min-height:0;overflow:auto;padding-right:10px;font-size:13.5px;line-height:2;color: var(--plp-c32, #3a4048)} .iwb-plp-dialog-detail .iwb-plp-dtext{flex:1 1 auto;min-height:0;overflow:auto;padding-right:10px;font-size: 14px;line-height:2;color: var(--iwb-text, #3a4048)}
/* v1.8.3:详情左卡片撑到底、四边等距;正文恢复滚动不被底部遮挡 */ /* v1.8.3:详情左卡片撑到底、四边等距;正文恢复滚动不被底部遮挡 */
.iwb-plp-dialog-detail{display:flex;flex-direction:column;overflow:hidden} .iwb-plp-dialog-detail{display:flex;flex-direction:column;overflow:hidden}
.iwb-plp-dialog-detail .iwb-plp-dbody{display:flex;flex:1 1 auto;min-height:0;overflow:hidden;gap:14px;padding:16px;background: var(--plp-c9, #f4f5f7)} .iwb-plp-dialog-detail .iwb-plp-dbody{display:flex;flex:1 1 auto;min-height:0;overflow:hidden;gap: 12px;padding:16px;background: var(--iwb-plugin-inset, #f4f5f7)}
.iwb-plp-dialog-detail .iwb-plp-dleftcol{align-self:stretch;display:flex;flex-direction:column;overflow:auto;padding:12px;border: 1px solid var(--plp-c31, #e8eaee);border-radius:14px;background: var(--plp-c1, #fff)} .iwb-plp-dialog-detail .iwb-plp-dleftcol{align-self:stretch;display:flex;flex-direction:column;overflow:auto;padding:12px;border: 1px solid var(--iwb-plugin-border, #e8eaee);border-radius:14px;background: var(--iwb-plugin-card, #fff)}
.iwb-plp-dialog-detail .iwb-plp-dright{flex:1 1 auto;min-width:0;min-height:0;overflow:hidden;display:flex;flex-direction:column;padding:14px 16px;border: 1px solid var(--plp-c31, #e8eaee);border-radius:14px;background: var(--plp-c1, #fff)} .iwb-plp-dialog-detail .iwb-plp-dright{flex:1 1 auto;min-width:0;min-height:0;overflow:hidden;display:flex;flex-direction:column;padding: 12px 16px;border: 1px solid var(--iwb-plugin-border, #e8eaee);border-radius:14px;background: var(--iwb-plugin-card, #fff)}
.iwb-plp-dialog-detail .iwb-plp-dtext{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;scrollbar-width:thin;padding-right:8px} .iwb-plp-dialog-detail .iwb-plp-dtext{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;scrollbar-width:thin;padding-right:8px}
.iwb-plp-dialog-detail .iwb-plp-dfooter{flex:0 0 auto} .iwb-plp-dialog-detail .iwb-plp-dfooter{flex:0 0 auto}
/* v1.8.4:右卡片纵向拉伸填满,正文出现滚动条 */ /* v1.8.4:右卡片纵向拉伸填满,正文出现滚动条 */
@@ -539,23 +548,32 @@ body.iwb-plp-dragging, body.iwb-plp-dragging *{user-select:none!important;-webki
.iwb-plp-dialog-detail .iwb-plp-dtext{flex:1 1 0;min-height:0;overflow-y:auto!important;overflow-x:hidden} .iwb-plp-dialog-detail .iwb-plp-dtext{flex:1 1 0;min-height:0;overflow-y:auto!important;overflow-x:hidden}
/* v1.8.7:详情标题缩小;分组/标签去底色;元信息加分割线与行高 */ /* v1.8.7:详情标题缩小;分组/标签去底色;元信息加分割线与行高 */
.iwb-plp-dialog-detail .iwb-plp-dtitle{font-size:17px!important;font-weight:650;margin-top:12px} .iwb-plp-dialog-detail .iwb-plp-dtitle{font-size:17px!important;font-weight:650;margin-top:12px}
.iwb-plp-dialog-detail .iwb-plp-dmeta{margin-top:12px;padding-top:14px;border-top: 1px solid var(--plp-c11, #eef0f3);gap:10px} .iwb-plp-dialog-detail .iwb-plp-dmeta{margin-top:12px;padding-top: 12px;border-top: 1px solid var(--iwb-plugin-border, #eef0f3);gap:10px}
.iwb-plp-dialog-detail .iwb-plp-dmrow{gap:6px} .iwb-plp-dialog-detail .iwb-plp-dmrow{gap:6px}
.iwb-plp-dialog-detail .iwb-plp-dmk{flex:0 0 auto;width:auto;font-size:12px;line-height:1.6;color: var(--plp-c4, #9aa1ac)} .iwb-plp-dialog-detail .iwb-plp-dmk{flex:0 0 auto;width:auto;font-size:12px;line-height:1.6;color: var(--iwb-text-dim, #9aa1ac)}
.iwb-plp-dialog-detail .iwb-plp-dgroup,.iwb-plp-dialog-detail .iwb-plp-dtag{background:transparent!important;padding:0!important;border-radius:0!important;font-size:12.5px;line-height:1.6;color: var(--plp-c33, #2f3540)} .iwb-plp-dialog-detail .iwb-plp-dgroup,.iwb-plp-dialog-detail .iwb-plp-dtag{background:transparent!important;padding:0!important;border-radius:0!important;font-size: 13px;line-height:1.6;color: var(--iwb-text, #2f3540)}
.iwb-plp-dialog-detail .iwb-plp-dtag{color: var(--plp-c7, #5a3fd0);} .iwb-plp-dialog-detail .iwb-plp-dtag{color: var(--iwb-plp-accent, #5a3fd0);}
.iwb-plp-dialog-detail .iwb-plp-dlen{font-size:12.5px;line-height:1.6;color: var(--plp-c33, #2f3540)} .iwb-plp-dialog-detail .iwb-plp-dlen{font-size: 13px;line-height:1.6;color: var(--iwb-text, #2f3540)}
/* v1.8.8:详情标题 14px;元信息行间浅分割线;封面底色更接近白色(编辑/详情统一) */ /* v1.8.8:详情标题 14px;元信息行间浅分割线;封面底色更接近白色(编辑/详情统一) */
.iwb-plp-dialog-detail .iwb-plp-dtitle{font-size:14px!important;font-weight:650;line-height:1.5;margin-top:12px} .iwb-plp-dialog-detail .iwb-plp-dtitle{font-size:14px!important;font-weight:650;line-height:1.5;margin-top:12px}
.iwb-plp-dialog-detail .iwb-plp-dmeta{gap:0} .iwb-plp-dialog-detail .iwb-plp-dmeta{gap:0}
.iwb-plp-dialog-detail .iwb-plp-dmrow{padding:7px 0;border-bottom: 1px solid var(--plp-c34, #f3f5f8)} .iwb-plp-dialog-detail .iwb-plp-dmrow{padding: 6px 0;border-bottom: 1px solid var(--iwb-plugin-border, #f3f5f8)}
.iwb-plp-dialog-detail .iwb-plp-dmrow:last-child{border-bottom:0} .iwb-plp-dialog-detail .iwb-plp-dmrow:last-child{border-bottom:0}
.iwb-plp-dialog .iwb-plp-dcov,.iwb-plp-dialog .iwb-plp-ecov{background: var(--plp-c35, #fcfcfd)!important} .iwb-plp-dialog .iwb-plp-dcov,.iwb-plp-dialog .iwb-plp-ecov{background: var(--iwb-field, #fcfcfd)!important}
.iwb-plp-dialog .iwb-plp-dcov .iwb-plp-cover,.iwb-plp-dialog .iwb-plp-ecov .iwb-plp-cover{background:transparent!important} .iwb-plp-dialog .iwb-plp-dcov .iwb-plp-cover,.iwb-plp-dialog .iwb-plp-ecov .iwb-plp-cover{background:transparent!important}
/* v1.8.19:编辑区高亮变量不得加粗——加粗会改变字形宽度,导致点击位置逐次向左偏移 */ /* v1.8.19:编辑区高亮变量不得加粗——加粗会改变字形宽度,导致点击位置逐次向左偏移 */
.iwb-plp-hlvar{font-weight:400!important;letter-spacing:normal!important} .iwb-plp-hlvar{font-weight:400!important;letter-spacing:normal!important}
/* v1.8.20:编辑区不再用透明 textarea+高亮层(两层字体/换行差异会让点击坐标逐次偏移);正文直接由 textarea 渲染,插入点 100% 对应光标 */ /* v1.9.3:变量着色改为「textarea 只负责文字 + 背层只画浅主色色块」——
.iwb-plp-ewrap .iwb-plp-hl{display:none!important} 两层字体/换行/滚动条占位由 v1.7.7 规则保持一致,变量 span 沿用 400 字重(不加粗,宽度不漂移),
文字仍由 textarea 自己画(可见),所以插入点/点击/选区完全不受影响。
注:v1.8.20 停用高亮层是因为当时「透明 textarea + 背层画文字」两层文字错位;本版不画文字,只画色块,不会复发。 */
.iwb-plp-ewrap .iwb-plp-hl{display:block!important;color:transparent!important;-webkit-text-fill-color:transparent!important}
.iwb-plp-hlvar{color:transparent!important;-webkit-text-fill-color:transparent!important;background:color-mix(in srgb, var(--iwb-plp-accent, #7c4dff) 16%, transparent);border-radius:6px;box-shadow:0 0 0 1px color-mix(in srgb, var(--iwb-plp-accent, #7c4dff) 22%, transparent)}
.iwb-plp-ewrap .iwb-plp-etext{color:var(--iwb-text,#2a2f36)!important;background:transparent!important} .iwb-plp-ewrap .iwb-plp-etext{color:var(--iwb-text,#2a2f36)!important;background:transparent!important}
/* v1.8.21:高亮层隐藏后,正文文字必须可见(覆盖旧的 transparent !important) */ /* v1.8.21:正文文字必须可见(覆盖旧的 transparent !important) */
.iwb-plp-dialog .iwb-plp-emid .iwb-plp-ewrap .iwb-plp-etext{color:var(--iwb-text,#2a2f36)!important;caret-color:var(--iwb-text,#2a2f36)!important;-webkit-text-fill-color:var(--iwb-text,#2a2f36)!important} .iwb-plp-dialog .iwb-plp-emid .iwb-plp-ewrap .iwb-plp-etext{color:var(--iwb-text,#2a2f36)!important;caret-color:var(--iwb-text,#2a2f36)!important;-webkit-text-fill-color:var(--iwb-text,#2a2f36)!important}
/* v1.9.3:右侧变量名与详情正文里的变量也用主色呼应(只读区,零功能风险) */
.iwb-plp-dialog .iwb-plp-vname{color:var(--iwb-plp-accent,#5a3fd0)}
.iwb-plp-dialog .iwb-plp-dvar{color:var(--iwb-plp-accent,#5a3fd0);background:var(--iwb-plp-accent-soft,#f1ecff);border-radius:6px;padding:0 2px}
/* 回滚开关:若真机发现任何点击/光标异常,把下行打开即回到 v1.8.20 纯 textarea 状态。
.iwb-plp-ewrap .iwb-plp-hl{display:none!important} */
+153
View File
@@ -0,0 +1,153 @@
// promptlib 本地契约测试(纯 node):
// - v1.9.2:分享带封面开关
// - v1.9.3:编辑区变量浅主色底色(方案 C,只画色块不改输入)
// - v1.10.0:文本分享 / 文件分享双路径 + 顶部三按钮 + 右键去分类 + 设置去导入入口
// - v1.10.1:移除「分享时附带封面图片」开关 + 详情底部分享/插入组间竖向分割线
// 运行:node promptlib/tools/harness.mjs (退出码 0 = 全过)
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import vm from 'node:vm'
const HERE = path.dirname(fileURLToPath(import.meta.url))
const ROOT = path.resolve(HERE, '..')
const src = fs.readFileSync(path.join(ROOT, 'src/index.js'), 'utf8')
const css = fs.readFileSync(path.join(ROOT, 'styles.css'), 'utf8')
let failed = 0
const ok = (name, cond) => {
if (!cond) failed++
console.log((cond ? '✓ ' : '✗ ') + name)
}
// ---- 1) 版本 / manifest ----
ok("manifest.version = 1.11.0", /version:\s*'1\.11\.0'/.test(src))
ok('package.json version = 1.11.0',
JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf8')).version === '1.11.0')
ok('manifest 已移除「分享时附带封面图片」开关声明',
!/shareWithCover:\s*\{\s*type:\s*'boolean'/.test(src))
ok('源码不再定义/读取 shareWithCover 设置',
!/function shareWithCover \(\)/.test(src) && !/S\.get\('shareWithCover'\)/.test(src))
// ---- 2) sharePayload 两条显式分支 ----
const m = src.match(/ function sharePayload \(p, withCover\) \{[\s\S]*?\n \}\n function shareFileName/)
ok('从 src 找到 sharePayload(p, withCover)', !!m)
const fnSrc = m ? m[0].replace(/\n function shareFileName$/, '') : ''
const sandbox = {
SHARE_TAG: 'IWB-PROMPT-SHARE',
varsOf: () => [],
coverToDataUrl: () => { throw new Error('不该读封面') },
Promise, JSON, String, Number, Array, Object,
}
vm.createContext(sandbox)
vm.runInContext(fnSrc, sandbox)
const p = { name: '测试词', text: '一只猫', group: '分组A', tags: ['x'], cover: { img: 'a.jpg' } }
const textPlain = await sandbox.sharePayload(p, false)
const bodyPlain = JSON.parse(textPlain.split('\n')[1])
ok('文本分享(false):分享文本无 cover 字段', !('cover' in bodyPlain.sharing))
ok('文本分享(false):不读封面(stub 抛错未触发)', true)
ok('文本分享(false):名字/正文/分组仍在',
bodyPlain.sharing.name === '测试词' && bodyPlain.sharing.text === '一只猫' && bodyPlain.sharing.group === '分组A')
sandbox.coverToDataUrl = () => Promise.resolve('data:image/jpeg;base64,AAAA')
const textFile = await sandbox.sharePayload(p, true)
const bodyFile = JSON.parse(textFile.split('\n')[1])
ok('文件分享(true):分享文本带 cover', bodyFile.sharing.cover === 'data:image/jpeg;base64,AAAA')
// ---- 3) v1.10.0 UI 契约 ----
ok('文本分享复制纯文字(doShareText 用 api.copy)',
/function doShareText \(p\)[\s\S]{0,260}api\.copy\(text\)/.test(src))
ok('文件分享导出为文件(doShareFile 用 api.exportText)',
/function doShareFile \(p\)[\s\S]{0,260}api\.exportText\(shareFileName\(p\), text\)/.test(src))
ok('文件名做安全化(过滤 \\/:*?"<>|)',
/replace\(\/\[\\\\\/:\*\?"<>\|]\/g, '_'\)/.test(src))
ok('剪贴板导入与文件导入共用 importShareItem(1 定义 + 2 调用)',
(src.match(/importShareItem\s*\(item\)/g) || []).length >= 3)
ok('文件导入走 api.importText()',
/function importShareFromFile \(\)[\s\S]{0,160}api\.importText\(\)/.test(src))
ok('顶部三按钮:文件 / 文本 / 新建',
/text: '文件'[\s\S]{0,200}text: '文本'[\s\S]{0,200}text: '新建'/.test(src))
ok('右键菜单已去掉「移动到分组」分类',
!/移动到分组/.test(src))
ok('右键菜单含 文本分享 / 文件分享(iwb-ctx-item 项)',
/iwb-ctx-item', text: '文本分享'[\s\S]{0,260}iwb-ctx-item', text: '文件分享'/.test(src))
ok('详情底部含 文本分享 / 文件分享 两按钮',
/text: '文本分享'/.test(src) && /text: '文件分享'/.test(src))
ok('详情底部分享组与插入组之间是竖向分割线(DOM 顺序:文件分享 → 竖线 → 复制全文)',
/footEl\.appendChild\(shareFile\)[\s\S]{0,240}iwb-plp-foot-vsep[\s\S]{0,160}footEl\.appendChild\(cp\)/.test(src))
ok('竖线样式:1px 宽 / 18px 高 / 边框色 / 居中',
/\.iwb-plp-foot-vsep\s*\{[^}]*width:\s*1px[^}]*height:\s*18px[^}]*align-self:\s*center[^}]*background:\s*var\(--iwb-border\)/.test(css))
ok('设置面板不再有单条导入入口(impShareBtn 已移除)',
!/impShareBtn/.test(src))
ok('旧的「分享…」按钮(带图完整版)已删除',
!/text: '分享'/.test(src) && !/function doShare \(p\)/.test(src))
// ---- 4) v1.9.3 变量着色样式不变量(回归保护)----
ok('高亮层恢复显示(不再 display:none)',
/\.iwb-plp-ewrap \.iwb-plp-hl\{display:block!important/.test(css))
ok('高亮层整层文字透明(不与 textarea 重影)',
/\.iwb-plp-ewrap \.iwb-plp-hl\{[^}]*color:transparent!important[^}]*-webkit-text-fill-color:transparent!important/.test(css))
ok('变量 span 只画主色背景、不画文字',
/\.iwb-plp-hlvar\{[^}]*color:transparent!important[^}]*background:color-mix\(in srgb, var\(--iwb-plp-accent/.test(css))
ok('变量 span 不加粗(避开点击偏移根因)',
/\.iwb-plp-hlvar\{font-weight:400!important/.test(css))
ok('textarea 文字仍可见(-webkit-text-fill-color 兜底)',
/\.iwb-plp-etext\{color:var\(--iwb-text[^}]*-webkit-text-fill-color:var\(--iwb-text/.test(css))
ok('高亮层与 textarea 滚动条占位一致',
/\.iwb-plp-emid \.iwb-plp-ewrap \.iwb-plp-hl\{overflow:hidden!important;scrollbar-gutter:stable\}/.test(css))
ok('高亮层跟随 textarea 横向滚动',
/hl\.scrollTop = textIn\.scrollTop; hl\.scrollLeft = textIn\.scrollLeft/.test(src))
ok('右侧变量名与详情变量用主色呼应',
/\.iwb-plp-vname\{color:var\(--iwb-plp-accent/.test(css) && /\.iwb-plp-dvar\{color:var\(--iwb-plp-accent/.test(css))
// ---- 5) v1.11.0 封面文件治理(P1)----
// 目标:① 保存/上传时把内联 base64 落成文件;② 孤儿封面能被回收;③ 回收不能误删。
// 纯文本断言跑不了真实 FS ⇒ 这里用「函数抽出来 + 假 fileApi」跑行为。
ok('封面命名统一走 coverFileName(哈希只在它内部实现一次)',
/function coverFileName \(dataUrl\)/.test(src) && (src.match(/var h = 5381/g) || []).length === 1 && (src.match(/coverFileName\(/g) || []).length >= 6)
ok('保存路径先落文件(ensureCoverFile 包住 doSave)',
/function doSave \(\)[\s\S]{0,600}ensureCoverFile\(c\.cover\)/.test(src))
ok('上传封面即落文件(不再把 dataURL 写回 draft.cover)',
/api\.putCover\([\s\S]{0,400}ensureCoverFile\(r\.ref\)/.test(src))
ok('删词条后安排一次回收', /已删除'[\s\S]{0,80}scheduleCoverGc\(/.test(src))
ok('启动加载后安排一次回收(等 convertInlineCovers 写完)',
/convertInlineCovers\(\)[\s\S]{0,120}scheduleCoverGc\(4000\)/.test(src))
ok('自动回收有「数据来源」闸门(不是插件 JSON 读来的就不删)',
/!o\.manual && !dataFromPlugin\) return Promise\.resolve\(\{ removed: 0, bytes: 0, skipped: 'no-source' \}\)/.test(src))
ok('keep 为空时不删(空集合 = 全删的形状)',
/if \(!kept && !o\.manual\) return Promise\.resolve\(\{ removed: 0, bytes: 0, skipped: 'empty' \}\)/.test(src))
ok('只删图片扩展名文件', src.includes('/\\.(jpg|jpeg|png|webp)$/i.test(name)'))
ok('设置页有显式清理入口 + 现读一次数据',
/text: '清理未引用封面'/.test(src) && /plpGcCoverFiles\(FA, plpCoverNamesOf\(state\.prompts\), \{ manual: true \}\)/.test(src))
ok('pending(刚 put 未被引用)不会被回收',
/Object\.keys\(pendingCoverNames\)\.forEach\(function \(n\) \{ names\.push\(n\) \}\)/.test(src))
// 行为:抽出 plpGcCoverFiles 本体,用假 fileApi 验证「只删未被引用的图片文件」
const gcMatch = src.match(/ function plpGcCoverFiles \(FA, keepNames, opts\) \{[\s\S]*?\n \}\n/)
ok('从 src 抽出 plpGcCoverFiles', !!gcMatch)
if (gcMatch) {
const removed = []
const fakeFA = {
list: async () => [
{ name: 'cused1.jpg', size: 100 },
{ name: 'corphan1.jpg', size: 200 },
{ name: 'cshared.jpg', size: 300 },
{ name: 'notes.txt', size: 1 },
],
remove: async (name) => { removed.push(name); return { ok: true } },
}
const gcSandbox = { Promise, JSON, String, Number, Array, Object, RegExp, console }
vm.createContext(gcSandbox)
vm.runInContext('var PLP_GC_BUSY = false\n' + gcMatch[0] + '\nthis.gc = plpGcCoverFiles', gcSandbox)
const r1 = await gcSandbox.gc(fakeFA, ['cused1.jpg'], {})
ok('回收:只删未引用图片(保留引用项与非图片文件)',
JSON.stringify(removed) === '["corphan1.jpg","cshared.jpg"]')
ok('回收:返回删除数与字节数', r1.removed === 2 && r1.bytes === 500)
const r2 = await gcSandbox.gc(fakeFA, [], {})
ok('回收:keep 为空且非人工 ⇒ 不删(skipped=empty)', r2.skipped === 'empty' && r2.removed === 0)
const r3 = await gcSandbox.gc(null, [], {})
ok('回收:无文件能力 ⇒ skipped=no-fs', r3.skipped === 'no-fs')
}
console.log(failed ? ('✗ ' + failed + ' 项失败') : '✓ 全部通过')
if (failed) process.exitCode = 1
+123
View File
@@ -0,0 +1,123 @@
# sticky · 便利贴(v1.0.7)
画布上的便签节点:一张纸片,写多行文字,能调字号、粗细、背景色,能拖大拖小。
**不连线、不进生图链路**——纯标注用途(说明节点、分组标题、随手记)。
## 设计由来
用户要一个"在画布上建立说明文字"的插件。最初设想是"标题节点",后来改成便签:
不要单独的"标题"概念——**便签上方那条"便利贴"标签是宿主强制的标题带**(插件节点的
`hasTitle: true` 写死,只有中继节点才不显示),注册节点名即可,用户不用再填标题字段。
想当说明标题就把字号调大(**无上限**,A+ 每点一次 +2),想放多行正文就用小字(默认 14)。
> v1.0.1 修复三个真机问题:① 节点拖动变大后下半漏出宿主底色(根容器改 `flex:1` 撑满);
> ② 字号被闭集钳在 24(改为无上限、±2 步进);③ 正文单击即编辑(改为照宿主文本节点那样
> **单击选中/拖动、双击才进编辑**)。
>
> v1.0.2 修复两个体验问题:① 便签高度不能贴近文字(下方一大块空白)——textarea 改为
> **高度随内容自适应**(`flex:0 0 auto` + JS 按 `scrollHeight` 算高),节点外框 `height:auto`
> 会跟着收缩,resize 手柄就能拖到贴字;② 色板弹在便签右下角、盖住 resize 手柄——
> 色板 DOM 从根节点挪进**工具条**(`top:100%` 落在调色按钮正下方)。
> 选中气泡上的「节点颜色」按钮是宿主画的、对本插件无效,需改宿主才能去掉——本版不动。
>
> v1.0.3 修掉「v1.0.2 看着修了其实没修透」的高度问题:宿主 `NodeCard` 把 `node.h` 写成
> 外框 `minHeight`(`height:auto`),旧的 `h` 仍在撑着外框,所以正文贴字了、下面还是一截空白,
> resize 手柄也拖不下去。现在插件在渲染时按「工具条 + 正文」算内容高度,首次遇到旧 `h`
> 明显大于内容时把它校正到内容高度,并同步覆盖外框 `minHeight`;用户后续拖大的 `h` 会保留,
> 仍能拖大拖小。调色圆点移到工具条**最右上**,色板 `right:8px` 正对圆点右缘、落其下方。
>
> v1.0.4 修掉最后一行空白:textarea 没写 `rows`,浏览器默认是 **2 行**;`fitBody()` 把高度
> 设成 `auto` 再读 `scrollHeight` 时,单行文字也被算成两行高,于是一行字和两行字的便签一样高。
> 现在显式 `rows="1"`,`scrollHeight` 才等于真实内容行数;多行文本照常换行、高度跟着涨。
>
> v1.0.5 统一圆角:纸片内圈从写死的 10px 改成 `calc(var(--iwb-node-radius, 14px) - 1px)`,
> 与宿主节点选中框(外圈 14px + 1px 边框)对齐,选中时两层边缘不再错开。
>
> v1.0.6 修行高回缩:v1.0.3 为了「内容长高时 resize 起点不滞后」把 `node.h` 顶到内容高度,
> 但文本从两行删回一行时这个 h 没跟着降,外框就一直留着两行高。现在区分**自动跟随**与
> **用户手动拖尺寸**:自动写出的 h 双向贴合内容(长高就涨、缩回就降);用户拖手柄改过 h
> 后退出自动跟随,手动尺寸照旧保留。
>
> v1.0.7 修自定义调色后面板不退出:预设色块点完会收起,但色轮走的是隐藏的原生
> `<input type="color">`,`change` 回调只写 `bgColor`、没关浮层,选完色色板仍压在便签上。
> 现在**点色轮打开系统取色器时即收起**(确认/取消都不留浮层),自定义色 `change` 到达时再兜底收一次。
## 长什么样
画布上是一张暖色纸片(圆角、细边、一点阴影),顶上一条工具条:
| 控件 | 作用 |
|---|---|
| `−` / `+` | 字号缩放,每步 ±2,下限 6、**无上限** |
| `B` | 正文粗细在 400 / 600 间切换(按钮高亮表示已加粗) |
| 圆点 | 展开色板:8 个预设色 + 底部彩虹色轮;**色板落在圆点正下方**,不挡 resize 手柄 |
| 色轮 | 调起系统颜色选择器,可选任意色;点开即收起色板,选完色不再压在便签上 |
| 正文区 | 多行 textarea,透明底,随字号自动换行;**单击=选中/拖动节点,双击=进入编辑,失焦/ESC 退出** |
选中节点后宿主自带的浮动气泡(信息 / 删除、复制、缩放手柄)照常出现,不是本插件画的。
## 状态存在哪
全部写进节点 `data`,走 `props.onUpdate(node.id, patch)`,随画布落盘:
| 字段 | 默认 | 说明 |
|---|---|---|
| `text` | `''` | 多行正文 |
| `fontSize` | `14` | 任意有限数(下限 6),A± 每步 ±2,无上限 |
| `fontWeight` | `400` | `400` / `600` |
| `bgColor` | `#FCE8B0` | 纸片背景色 |
**文字颜色不存**——运行时按背景亮度自动取深色 `#1c2333` 或白色 `#ffffff`(阈值 Y=0.55),
深色纸片不会配黑字看不见。这是运行时计算,源码里没有写死的中性色,不触发守门测试。
## 关键实现点
- **注册**:`ctx.nodes.register({ id:'sticky', title:'便利贴', ports:{in:false,out:false}, height:180, render })`
—— `ports` 全关,纯标注节点;宿主生成的类型是 `plugin:sticky:sticky`。
- **节点尺寸**:节点缩放用宿主自带手柄(右下角 `.iwb-resize`,对插件节点天然生效),插件不写
`w/h`。两层 flex 各管一件事:**根容器 `.iwb-sticky-node` 用 `flex:1 1 auto; min-height:0` 撑满**
宿主容器 `.iwb-plugin-node-body`(flex 列、`padding:0`)——只写 `height:100%` 在 WKWebView 下
对 flex 项算不准,拖大后下半会露出宿主底色(v1.0.0 的问题);**textarea 反过来用 `flex:0 0 auto`
+ JS 按 `scrollHeight` 算高**(`rows="1"` 去掉浏览器默认 2 行的预留;文本/字号变了才重算,
缓存 `fitText/fitSize` 避免每次 render reflow),
让内容自然高度贴着文字(v1.0.2)。**外框 minHeight(v1.0.3)**:宿主 `NodeCard` 的
`style.minHeight = node.h` 才是拖不下去的真凶——插件在 `fitOuterBox()` 里用
`工具条 offsetHeight + 正文 style.height + 2px 边框` 算内容高度,首次把旧 `h` 校正到该值,
并直接把宿主外框的 `minHeight` 覆盖掉。插件自动写出的 h **双向跟随内容**(v1.0.6:
两行退回一行会缩回去);一旦检测到 h 被外部拖手柄改写,就退出自动跟随、尊重手动尺寸,
所以拖大拖小仍然有效。
- **色板定位**:色板挂在工具条 `tools`(`position:relative`)内而非便签根节点,CSS `top:100%`
落在调色圆点正下方;挂在根节点时会贴便签底部右下角、盖住 resize 手柄(v1.0.2 的问题)。
圆点用 `margin-left:auto` 推到工具条最右上(v1.0.3),色板 `right:8px` 与圆点右缘对齐。
- **样式时机**:CSS 在脚本执行时就注入唯一 `<style id="iwb-sticky-style">`,不等 setup / mount
—— 从存档直接进画布(面板从不 mount)时节点也有样式。
- **幂等同步**:`render(node, props, host)` 每次渲染都被宿主无依赖地调一次;插件缓存 host 上的
骨架 `host.__sticky`,只在数据真的变了才写 DOM;**编辑态(`st.editing`)或 `document.activeElement
=== textarea`** 时跳过 `value` 覆盖,否则用户打字会被打断/失焦。sync 只碰 style 和 bold/dot 的
className,不动 textarea 的 editing class,重渲染不会失焦。
- **单击/双击编辑**:照宿主文本节点的做法——textarea 默认 `readonly`,宿主 CSS
`.iwb-node textarea[readonly]{pointer-events:none}` 让**单击穿透**给节点卡片(选中/拖动);
双击由插件在 root 上接管(宿主 `onDoubleClick` 只处理内置文本类型,不管 `plugin:` 节点),
解除 readonly + focus 进入编辑;失焦 / ESC 退出。编辑态下 `pointerdown`/`mousedown`/`keydown`
不冒泡给宿主,避免拖节点和触发画布快捷键。插件自己维护 `st.editing`,不依赖宿主的
`props.editingBody`(那是给内置文本节点用的)。
- **面板**:一个「+ 插入便利贴」按钮 → `ctx.canvas.createNode('plugin:sticky:sticky', null, null, {...})`,
坐标 `null/null` 走宿主 `findSpot()`(视口中心螺旋找空位),插件不自己算坐标。
## 校验
```bash
node sticky/tools/harness.mjs # 纯 node,58 项:注册/渲染/字号无上限/贴字自适应/rows=1/外框 minHeight 双向回缩/圆角对齐/色板定位/自定义色后面板收起/双击编辑/换色/文本/幂等/插入
npm run validate # 全仓契约校验
```
## 发布
本仓是桌面客户端的插件源仓。发布链路(详见根 README):
```
sticky/src/index.js → 桌面仓 sync-plugins-from-repo.js → plugins/runtime/plugin-sticky.<sha12>.js
→ gen-market.js → market/index.json + zip → 上传 NAS
```
上架需在桌面仓 `scripts/sync-plugins-from-repo.js` 的 `IDS` 白名单和 `plugins/meta.json` 里加入 `sticky`。
+11
View File
@@ -0,0 +1,11 @@
{
"name": "@iwb-plugin/sticky",
"private": true,
"version": "1.0.7",
"description": "画布便利贴:多行文本 + 字号/粗细调节 + 8 色背景,纯标注节点不连线",
"ibwPlugin": {
"id": "sticky",
"entry": "src/index.js",
"apiVersion": 1
}
}
+469
View File
@@ -0,0 +1,469 @@
// iwb-plugin: 画布便利贴 —— 多行文本 + 字号/粗细调节 + 8 色背景,纯标注节点不连线。
//
// 设计口径(用户 2026-11-24 确认):
// - 不要"标题"概念:便签上方那条"便利贴"标签是宿主强制的标题带(hasTitle 写死),
// 节点名注册成"便利贴"即可,用户不用再填标题字段。
// - 想当说明标题就把字号调大(无上限,A+ 每点一次 +2),想放多行正文就用小字(默认 14)。
// - 不连线:ports:{in:false,out:false}。
// - 节点缩放用宿主自带手柄(右下角),插件不设宽高。
//
// 状态全部存 node.data(props.onUpdate 写回,随画布落盘):
// text / fontSize / fontWeight / bgColor
// 字号:A−/A+ 每步 ±2,下限 6、无上限(用户明确要求去掉最大字号限制);
// 8 个预设色是运行时数据、色轮走系统颜色选择器,源码里不写死中性色(守门只卡字面量)。
;(function (global) {
'use strict'
if (!global.IWBPluginHost) return
// 必须在脚本执行时就注入:面板可能瞬间挂载、节点可能从存档直接出现(面板从不 mount)。
function ensureStyle() {
if (typeof document === 'undefined' || !document.createElement) return
if (document.getElementById('iwb-sticky-style')) return
var css = '' +
'#iwb-sticky-style{}' +
'[hidden]{display:none!important}' +
'.iwb-sticky-panel{display:flex;flex-direction:column;gap:12px;font-size:13px;color:var(--iwb-text,#1c2333)}' +
'.iwb-sticky-panel-tip{font-size:12px;line-height:1.6;color:var(--iwb-text2,#4d5668);opacity:.9}' +
'.iwb-sticky-add{cursor:pointer;border:1px solid var(--iwb-brand,#6b7280);border-radius:8px;background:var(--iwb-layer2,#fff);color:var(--iwb-text,#1c2333);font-size:13px;padding:10px 14px;font-family:inherit}' +
'.iwb-sticky-add:hover{background:var(--iwb-hover,#f0f1f4)}' +
'.iwb-sticky-list{display:flex;flex-direction:column;gap:8px;margin-top:4px}' +
'.iwb-sticky-row{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 10px;border:1px solid var(--iwb-border,#d5d9e0);border-radius:8px;background:var(--iwb-layer,#f5f6f8)}' +
'.iwb-sticky-row-txt{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0}' +
'.iwb-sticky-go{cursor:pointer;border:1px solid var(--iwb-border,#d5d9e0);border-radius:6px;background:var(--iwb-layer2,#fff);color:var(--iwb-text,#1c2333);font-size:12px;padding:4px 10px;white-space:nowrap;font-family:inherit}' +
'.iwb-sticky-go:hover{border-color:var(--iwb-brand,#6b7280)}' +
// ---- 节点体 ----
// 宿主容器 .iwb-plugin-node-body 是 flex 列且 padding:0;这里必须 flex:1 撑满,
// 不能只写 height:100%(WKWebView 下百分比对 flex 项算不准,拖大后下半露出宿主底色)。
// 圆角对齐宿主节点:外框 .iwb-node 用 var(--iwb-node-radius)=14px 且有 1px 边框,
// 纸片在框内 ⇒ 内圈半径 = 外圈 - 1px,选中时两层边缘才不会错开。
'.iwb-sticky-node{position:relative;display:flex;flex-direction:column;flex:1 1 auto;min-height:0;width:100%;box-sizing:border-box;border-radius:calc(var(--iwb-node-radius, 14px) - 1px);overflow:visible}' +
'.iwb-sticky-tools{display:flex;align-items:center;gap:6px;padding:6px 8px;border-bottom:1px solid rgba(0,0,0,.08);flex:0 0 auto;position:relative;z-index:2}' +
'.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)}' +
// 调色圆点推到工具条最右端(右上),色板 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}' +
'.iwb-sticky-wheel{grid-column:1/-1;display:flex;justify-content:center;padding-top:8px;border-top:1px solid var(--iwb-border,#d5d9e0)}' +
'.iwb-sticky-wheel-btn{cursor:pointer;width:22px;height:22px;border-radius:50%;border:0;padding:0;background:conic-gradient(#e24b4a,#ef9f27,#fac775,#639922,#1d9e75,#378add,#7f77dd,#d4537e,#e24b4a)}' +
// 高度随内容自适应(贴字):不再 flex:1 撑满剩余空间,否则字号大/文字少时
// 下方留出大片空白;高度由 syncSkeleton 按行数×字号算,宿主外框 height:auto
// 会跟着内容收缩,resize 手柄就能拖到贴字。overflow:hidden 避免自适应高度出滚动条。
'.iwb-sticky-body{flex:0 0 auto;min-height:1.7em;width:100%;box-sizing:border-box;resize:none;border:0;outline:0;background:transparent;color:inherit;font-family:inherit;line-height:1.7;padding:12px;overflow:hidden;overflow-wrap:anywhere;cursor:move}' +
// 与宿主文本节点一致:只读态单击穿透给节点拖动/选中;双击进入编辑才变 text 光标。
// 宿主 style.css 有 `.iwb-node textarea[readonly]{pointer-events:none}`,这里用自身 class 兜底。
'.iwb-sticky-body.iwb-sticky-editing{cursor:text}' +
'.iwb-sticky-body::placeholder{opacity:.45}' +
'.iwb-sticky-color-input{position:absolute;width:0;height:0;opacity:0;pointer-events:none}'
try {
var styleEl = el('style', { text: css })
styleEl.setAttribute('id', 'iwb-sticky-style')
;(document.head || document.documentElement).appendChild(styleEl)
} catch (e) { /* 样式注入失败不影响功能 */ }
}
// 插件面板/节点体是真实 DOM(不是 React vDOM):createElement + addEventListener。
function el(tag, attrs, kids) {
var node = document.createElement(tag)
if (attrs) {
for (var key in attrs) {
var value = attrs[key]
if (value === null || value === undefined) continue
if (key === 'class' || key === 'className') node.className = value
else if (key === 'text') node.textContent = String(value)
else if (key === 'hidden') node.hidden = Boolean(value)
else if (key.slice(0, 2) === 'on') node.addEventListener(key.slice(2).toLowerCase(), value)
else node.setAttribute(key, String(value))
}
}
if (kids !== null && kids !== undefined) {
var list = Array.isArray(kids) ? kids : [kids]
for (var i = 0; i < list.length; i++) {
if (list[i] === null || list[i] === undefined || list[i] === false) continue
node.appendChild(typeof list[i] === 'string' ? document.createTextNode(list[i]) : list[i])
}
}
return node
}
var MIN_SIZE = 6 // 下限(用户只要求取消上限,下限保留防误操作缩到看不见)
var SIZE_STEP = 2 // A−/A+ 每步 ±2
var DEFAULT_SIZE = 14
var PALETTE = [
{ name: '黄', value: '#FCE8B0' },
{ name: '粉', value: '#F4C0D1' },
{ name: '橙', value: '#EF9F27' },
{ name: '绿', value: '#9FE1CB' },
{ name: '蓝', value: '#B5D4F4' },
{ name: '浅紫', value: '#CECBF6' },
{ name: '玫红', value: '#ED93B1' },
{ name: '灰', value: '#D3D1C7' },
]
var DEFAULT_BG = '#FCE8B0'
// 只保证是 >= 下限的有限数,不再钳到闭集/上限;A+ 可无限放大。
function normSize(v) {
var n = Number(v)
if (!isFinite(n) || n < MIN_SIZE) return DEFAULT_SIZE
return Math.round(n)
}
// 依据背景亮度取黑/白文字(运行时计算,源码里不写死中性色)。
function textColorOf(hex) {
var m = /^#?([0-9a-f]{6})$/i.exec(String(hex || ''))
if (!m) return '#1c2333'
var n = parseInt(m[1], 16)
var r = (n >> 16) & 255, g = (n >> 8) & 255, b = n & 255
// 相对亮度(sRGB 简化)
var lum = (0.299 * r + 0.587 * g + 0.114 * b) / 255
return lum < 0.55 ? '#ffffff' : '#1c2333'
}
// 脚本执行时就注入(不等 setup / mount,存档直入画布也有样式)。
ensureStyle()
var ctxRef = null
// ---------------- 节点体 ----------------
// 宿主契约:render(node, props, host) 往 host 这个真实 DOM 里画,不是返回 vDOM。
// host 由宿主固定、不重建;插件自己缓存骨架 + 幂等同步,编辑中的 textarea 不覆盖值。
function renderSticky(node, props, host) {
ensureStyle()
var data = (node && node.data) || {}
var st = host.__sticky
if (!st) {
host.textContent = ''
st = host.__sticky = buildSkeleton(host, props)
}
st.node = node
st.props = props
syncSkeleton(st, data, node)
}
function buildSkeleton(host, props) {
var root = el('div', { className: 'iwb-sticky-node' })
var tools = el('div', { className: 'iwb-sticky-tools' })
var minus = el('button', { className: 'iwb-sticky-btn', type: 'button', title: '缩小字号', 'data-act': 'minus' }, '−')
var plus = el('button', { className: 'iwb-sticky-btn', type: 'button', title: '放大字号', 'data-act': 'plus' }, '+')
var bold = el('button', { className: 'iwb-sticky-btn', type: 'button', title: '切换粗细', 'data-act': 'bold' }, 'B')
var dot = el('button', { className: 'iwb-sticky-dot', type: 'button', title: '背景色', 'data-act': 'palette' })
var pal = el('div', { className: 'iwb-sticky-pal', hidden: true })
var colorInput = el('input', { type: 'color', className: 'iwb-sticky-color-input', 'data-act': 'color' })
// rows=1 是关键:textarea 默认 rows=2,fitBody() 把高度设 auto 读 scrollHeight 时,
// 单行文字也会被算成两行高(用户报的“预留了一行文本高度”)。显式 1 行后,
// scrollHeight 才等于真实内容行数——多行文本仍会自动换行、高度跟着涨。
var body = el('textarea', { className: 'iwb-sticky-body', rows: '1', spellcheck: 'false', placeholder: '双击编辑…' })
// 对齐宿主文本节点:默认只读。宿主 CSS `.iwb-node textarea[readonly]{pointer-events:none}`
// ⇒ 单击穿透给节点卡片(选中/拖动);双击由本插件在 root 上接管进入编辑。
body.readOnly = true
body.setAttribute('readonly', '')
tools.appendChild(minus); tools.appendChild(plus); tools.appendChild(bold); tools.appendChild(dot)
// 色板挂在工具条内(tools 已 position:relative):CSS top:100% 落在调色按钮正下方,
// 而不是贴整个便签底部右下角(那样会盖住宿主 resize 手柄、且离按钮很远)。
tools.appendChild(pal)
root.appendChild(tools); root.appendChild(colorInput); root.appendChild(body)
host.appendChild(root)
var st = { root: root, tools: tools, minus: minus, plus: plus, bold: bold, dot: dot,
pal: pal, colorInput: colorInput, body: body, data: null, palOpen: false, editing: false }
function onTool(e) {
var t = e.target || {}
var act = t.getAttribute && t.getAttribute('data-act')
if (!act) return
e.stopPropagation && e.stopPropagation()
var d = (st.node && st.node.data) || {}
var up = st.props && st.props.onUpdate
var id = st.node && st.node.id
if (!up || !id) return
if (act === 'minus' || act === 'plus') {
var cur = normSize(d.fontSize == null ? DEFAULT_SIZE : d.fontSize)
var next = act === 'minus' ? Math.max(MIN_SIZE, cur - SIZE_STEP) : cur + SIZE_STEP
if (next !== cur) up(id, { fontSize: next })
} else if (act === 'bold') {
up(id, { fontWeight: d.fontWeight === 600 ? 400 : 600 })
} else if (act === 'palette') {
st.palOpen = !st.palOpen
pal.hidden = !st.palOpen
}
}
tools.addEventListener('click', onTool)
// 色板里的色块 + 色轮(事件委托到 pal)
for (var i = 0; i < PALETTE.length; i++) {
var sw = el('button', { type: 'button', className: 'iwb-sticky-pal-sw', 'data-bg': PALETTE[i].value,
title: PALETTE[i].name, style: 'background:' + PALETTE[i].value })
pal.appendChild(sw)
}
var wheelWrap = el('div', { className: 'iwb-sticky-wheel' })
var wheel = el('button', { type: 'button', className: 'iwb-sticky-wheel-btn', title: '自定义颜色', 'data-act': 'wheel' })
wheelWrap.appendChild(wheel); pal.appendChild(wheelWrap)
function onPal(e) {
var t = e.target || {}
e.stopPropagation && e.stopPropagation()
var up = st.props && st.props.onUpdate
var id = st.node && st.node.id
if (!up || !id) return
var bg = t.getAttribute && t.getAttribute('data-bg')
if (bg) {
up(id, { bgColor: bg })
st.palOpen = false; pal.hidden = true
return
}
var act = t.getAttribute && t.getAttribute('data-act')
if (act === 'wheel') {
// 点开系统取色器后这个浮层就完成使命:无论最终确认还是取消都先收起,
// 避免取色器关闭后色板还压在便签上(用户报的“自定义调色后面板不退出”)。
st.palOpen = false; pal.hidden = true
try { colorInput.click() } catch (e2) { /* noop */ }
}
}
pal.addEventListener('click', onPal)
function onColor(e) {
var up = st.props && st.props.onUpdate
var id = st.node && st.node.id
if (up && id && e.target && e.target.value) up(id, { bgColor: e.target.value })
// 自定义色确认后兜底再收一次(个别平台 change 先于上面的收起逻辑到达)。
st.palOpen = false; pal.hidden = true
}
colorInput.addEventListener('change', onColor)
// ---- 正文编辑状态机(照宿主文本节点:双击进编辑、失焦退出、只读态单击穿透)----
function setEditing(on) {
st.editing = on
body.readOnly = !on
if (on) { try { body.removeAttribute('readonly') } catch (e2) { /* noop */ } }
else body.setAttribute('readonly', '')
body.className = 'iwb-sticky-body' + (on ? ' iwb-sticky-editing' : '')
}
// 双击进入编辑:绑在 root 上(不是 readonly textarea —— 它 pointer-events:none 收不到双击)。
// 宿主卡片 onDoubleClick 只处理内置文本类型,plugin: 节点它不接管,所以这里自己 stopPropagation。
function onDblClick(e) {
// 工具条/色板/按钮上的双击不进编辑
var t = e.target || {}
if (t.getAttribute && t.getAttribute('data-act')) return
if (t.getAttribute && t.getAttribute('data-bg')) return
e.stopPropagation && e.stopPropagation()
setEditing(true)
try { body.focus() } catch (e2) { /* noop */ }
}
root.addEventListener('dblclick', onDblClick)
// 编辑态:按下/按键不冒泡给宿主(否则会拖节点 / 触发画布快捷键);失焦退出编辑。
;['pointerdown', 'mousedown'].forEach(function (ev) {
body.addEventListener(ev, function (e) {
if (st.editing) e.stopPropagation && e.stopPropagation()
// 只读态不拦:让宿主选中节点 + 拖动
})
})
body.addEventListener('keydown', function (e) {
e.stopPropagation && e.stopPropagation()
if (e.key === 'Escape') { try { body.blur() } catch (e2) { /* noop */ } }
})
body.addEventListener('blur', function () { setEditing(false) })
// 输入即写回(防抖交给宿主的 commitCanvas),编辑中不重建 DOM 故不失焦。
function onInput(e) {
var up = st.props && st.props.onUpdate
var id = st.node && st.node.id
if (up && id) up(id, { text: e.target.value })
e.stopPropagation && e.stopPropagation()
}
body.addEventListener('input', onInput)
st._listeners = { tools: onTool, pal: onPal, color: onColor, input: onInput, dblclick: onDblClick, setEditing: setEditing }
return st
}
// textarea 高度贴字:数据(文本/字号)变了才重算,避免每次 render 都 reflow。
// 设 auto → 读 scrollHeight → 写回,是 textarea 自适应的标准做法;浏览器里行数/自动换行都算准。
function fitBody(st, text, size) {
if (st.fitText === text && st.fitSize === size) return
st.fitText = text; st.fitSize = size
var b = st.body
var prev = b.style.height
b.style.height = 'auto'
var h = b.scrollHeight
b.style.height = (h && h > 0 ? h : Math.max(1, text.split('\n').length) * Math.round(size * 1.7) + 24) + 'px'
// 高度没变就不留空字符串(兼容 stub:style.height 是普通对象)
if (!b.style.height && prev) b.style.height = prev
}
// 宿主 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:
// - 插件自动跟随内容写出的 h:内容长高就涨、缩回就降(v1.0.6 修的「两行退回一行不缩」);
// - 用户拖手柄改出的 h:h 相对上一帧变了 ⇒ 尊重手动尺寸,只在内容超过它时顶一下。
// 首次遇到的旧大 h 校正一次(staleH),之后进入自动跟随。
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
if (st.lastBoxH != null && h !== st.lastBoxH) {
// 外部(用户拖手柄)改了 h:退出自动跟随,保留手动尺寸
st.autoFollow = false
} else if (st.autoFollow == null) {
// 首帧:旧 h 若明显大于内容,先校正一次,然后进入自动跟随
if (h > content + 2 && st.staleH === h) { node.h = content; h = content }
st.autoFollow = true
}
if (st.autoFollow) {
// 自动跟随:文本/字号增减都双向贴合(这是两行退回一行能缩回去的关键)
if (Math.abs(h - content) > 1) { node.h = content; h = content }
} else if (h < content - 2) {
// 手动尺寸只在内容超出时才顶高,不覆盖用户主动拖大的高度
node.h = content; h = content
}
st.lastBoxH = h
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
var text = data.text == null ? '' : String(data.text)
var color = textColorOf(bg)
// 幂等:只在值真的变了才写 DOM,避免重建/覆盖正在编辑的 textarea。
if (st.root.style.background !== bg) st.root.style.background = bg
if (st.root.style.color !== color) st.root.style.color = color
if (!st.editing && document.activeElement !== st.body && st.body.value !== text) st.body.value = text
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' : '')
}
if (st.dot.style.background !== bg) st.dot.style.background = bg
}
// ---------------- 面板 ----------------
var ctxForPanel = null
var noteList = []
function refreshList() {
if (!ctxForPanel) return
var host = ctxForPanel.__stickyPanelRoot
if (!host || typeof host.innerHTML !== 'undefined' && !host.innerHTML && !host.appendChild) return
var list = host.querySelector ? host.querySelector('.iwb-sticky-list') : null
if (!list) return
// 尽力从画布读回便利贴节点(只读画布能力给了 getNodes)
var nodes = []
try {
var api = ctxRef && ctxRef.canvas
if (api && typeof api.getNodes === 'function') nodes = api.getNodes() || []
} catch (e) { nodes = [] }
var mine = nodes.filter(function (n) { return String(n.type || '').indexOf('plugin:sticky:') === 0 })
// 用最近插入的本地记录补足(getNodes 快照不含自定义状态没关系,这里只显示文本)
var seen = {}
var rows = []
mine.concat(noteList).forEach(function (n) {
var key = n.id
if (!key || seen[key]) return
seen[key] = 1
var text = String((n.data && n.data.text) || '').replace(/\s+/g, ' ').slice(0, 30) || '(空便利贴)'
rows.push({ id: key, text: text })
})
while (list.firstChild) list.removeChild(list.firstChild)
rows.slice(-20).forEach(function (r) {
var row = el('div', { className: 'iwb-sticky-row' })
row.appendChild(el('span', { className: 'iwb-sticky-row-txt' }, r.text))
var go = el('button', { className: 'iwb-sticky-go', type: 'button' }, '定位')
go.addEventListener('click', function () {
try { if (ctxRef && ctxRef.canvas && typeof ctxRef.canvas.focusNode === 'function') ctxRef.canvas.focusNode(r.id) } catch (e) { /* noop */ }
})
row.appendChild(go)
list.appendChild(row)
})
}
function mountPanel(host, ctx) {
ensureStyle()
ctxForPanel = ctx
host.textContent = ''
host.style.minWidth = '0'; host.style.minHeight = '0'; host.style.height = '100%'
var wrap = el('div', { className: 'iwb-sticky-panel' })
wrap.appendChild(el('div', { className: 'iwb-sticky-panel-tip' },
'在画布上放一张便利贴:字调大当说明标题,字调小放多行正文。点右下角拖动手柄可改变便签大小。'))
var add = el('button', { className: 'iwb-sticky-add', type: 'button' }, '+ 插入便利贴')
add.addEventListener('click', function () { insertNote() })
wrap.appendChild(add)
var list = el('div', { className: 'iwb-sticky-list' })
wrap.appendChild(list)
host.appendChild(wrap)
ctxForPanel.__stickyPanelRoot = host
refreshList()
}
function insertNote() {
var api = ctxRef && ctxRef.canvas
if (!api || typeof api.createNode !== 'function') return null
var id = api.createNode('plugin:sticky:sticky', null, null, {
text: '', fontSize: DEFAULT_SIZE, fontWeight: 400, bgColor: DEFAULT_BG,
})
if (id) {
noteList.push({ id: id, data: { text: '' } })
refreshList()
}
return id
}
function dispose() {
ctxRef = null
ctxForPanel = null
noteList = []
}
global.IWBPluginHost.register({
id: 'sticky',
name: '便利贴',
version: '1.0.7',
apiVersion: 1,
capabilities: ['panels', 'nodeTypes', 'canvas'],
}, function (ctx) {
ctxRef = ctx
if (ctx.nodes && typeof ctx.nodes.register === 'function') {
ctx.nodes.register({
id: 'sticky',
title: '便利贴',
defaults: {},
ports: { in: false, out: false },
height: 180,
render: renderSticky,
})
}
if (ctx.ui && typeof ctx.ui.registerPanel === 'function') {
ctx.ui.registerPanel({
id: 'sticky',
title: '便利贴',
icon: 'note',
mount: mountPanel,
})
}
return { dispose: dispose }
})
})(typeof window !== 'undefined' ? window : globalThis)
+343
View File
@@ -0,0 +1,343 @@
// 便利贴插件本地契约测试(纯 node,不依赖 playwright / 真浏览器)。
// 用最小 DOM / window stub 跑真实 src/index.js(IIFE),验证:
// manifest 字段 / 节点类型注册(标题/不连线/height)/ 面板注册 /
// CSS 脚本执行时就注入 / 字号闭集与 A+/A− / 粗细切换 / 8 色背景 + 色轮自定义 /
// 多行文本写回 data / 幂等同步(编辑中不覆盖、值变才写 DOM)/ 插入走 createNode(null,null)。
//
// 运行:node sticky/tools/harness.mjs (退出码 0 = 全过)
import { readFileSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import vm from 'node:vm'
const HERE = path.dirname(fileURLToPath(import.meta.url))
const ENTRY = path.resolve(HERE, '../src/index.js')
const source = readFileSync(ENTRY, 'utf8')
let failed = 0
const check = (name, ok, detail) => {
if (!ok) failed++
console.log((ok ? '✓ ' : '✗ ') + name + (detail ? ' ' + detail : ''))
}
// ---------- 极简 DOM stub ----------
function makeNode(tag) {
return {
tagName: String(tag).toUpperCase(),
children: [], parentNode: null, _text: '', attrs: {}, listeners: {},
style: {}, className: '', hidden: false, value: '',
// textarea 自适应高度需要 scrollHeight:按「行数 × 行高 + 上下 padding」模拟。
get scrollHeight() {
if (String(tag).toUpperCase() !== 'TEXTAREA') return 0
const lines = Math.max(1, String(this.value || '').split('\n').length)
const size = parseFloat(this.style.fontSize) || 14
return Math.ceil(lines * size * 1.7) + 24
},
get textContent() { return this._text },
set textContent(v) { this._text = String(v); this.children = [] },
get firstChild() { return this.children[0] || null },
appendChild(c) { this.children.push(c); c.parentNode = this; return c },
removeChild(c) { const i = this.children.indexOf(c); if (i >= 0) this.children.splice(i, 1); return c },
setAttribute(k, v) { this.attrs[k] = String(v); if (k === 'style') this.style = parseStyle(String(v)) },
removeAttribute(k) { delete this.attrs[k] },
getAttribute(k) { return k in this.attrs ? this.attrs[k] : null },
focus() { this.__doc && (this.__doc.activeElement = this) },
blur() { this.__doc && this.__doc.activeElement === this && (this.__doc.activeElement = null); this.fire('blur') },
addEventListener(ev, fn) { (this.listeners[ev] = this.listeners[ev] || []).push(fn) },
fire(ev, data) {
const payload = Object.assign({ target: this, stopPropagation() {} }, data)
let n = this
while (n) {
;(n.listeners[ev] || []).forEach((fn) => fn(payload))
n = n.parentNode
}
},
querySelector(cls) {
const needle = cls.replace('.', '')
const q = [this]
while (q.length) {
const n = q.shift()
if (String(n.className).split(/\s+/).indexOf(needle) >= 0) return n
q.push(...(n.children || []))
}
return null
},
click() { this.fire('click') },
}
}
function parseStyle(s) {
const out = {}
s.split(';').forEach((part) => {
const i = part.indexOf(':')
if (i > 0) out[part.slice(0, i).trim()] = part.slice(i + 1).trim()
})
return out
}
function runPlugin() {
const head = makeNode('head')
const bodyEl = makeNode('body')
const document = {
head, documentElement: head, body: bodyEl, activeElement: null,
createElement: (tag) => { const n = makeNode(tag); n.__doc = document; return n },
createTextNode: (t) => ({ nodeType: 3, textContent: String(t) }),
getElementById: (id) => findById(head, id) || findById(bodyEl, id),
}
const registrations = []
let panelApi = null, nodeApi = null
const updates = []
const createCalls = []
const host = {
IWBPluginHost: {
register(manifest, factory) {
registrations.push({ manifest, factory })
},
},
document,
React: null,
}
const ctx = {
nodes: { register(def) { nodeApi = def; return true } },
ui: { registerPanel(def) { panelApi = def; return true } },
canvas: {
createNode(type, x, y, data) { createCalls.push({ type, x, y, data }); return 'n1' },
getNodes() { return [] },
focusNode() {},
},
}
const sandbox = Object.assign(host, {
console: { log() {}, warn() {}, error() {} },
window: host,
globalThis: host,
})
vm.createContext(sandbox)
vm.runInContext(source, sandbox)
// 触发工厂
registrations[0].factory(ctx)
return { registrations, manifest: registrations[0].manifest, nodeApi, panelApi, ctx, updates, createCalls, document, head }
}
function findById(root, id) {
if (root.attrs && root.attrs.id === id) return root
for (const c of root.children || []) { const r = findById(c, id); if (r) return r }
return null
}
// ---------- 测试 ----------
const r = runPlugin()
check('manifest.id = sticky', r.manifest.id === 'sticky')
check('manifest.name = 便利贴', r.manifest.name === '便利贴')
check('manifest.version = 1.0.7', r.manifest.version === '1.0.7')
check('manifest.apiVersion = 1', r.manifest.apiVersion === 1)
check('capabilities 含 panels/nodeTypes/canvas',
['panels', 'nodeTypes', 'canvas'].every((c) => r.manifest.capabilities.includes(c)))
check('CSS 在脚本执行时就注入(#iwb-sticky-style)', !!findById(r.head, 'iwb-sticky-style'))
check('节点类型已注册', !!r.nodeApi)
check('节点 ports 全关(不连线)', r.nodeApi && r.nodeApi.ports.in === false && r.nodeApi.ports.out === false)
check('节点 title = 便利贴', r.nodeApi && r.nodeApi.title === '便利贴')
check('节点有 render 函数', r.nodeApi && typeof r.nodeApi.render === 'function')
check('面板已注册', !!r.panelApi && typeof r.panelApi.mount === 'function')
// 构造节点 host 并渲染(带 onUpdate 收集 patch)
function makeNodeHost() {
const h = makeNode('div')
h.__updates = []
const props = { onUpdate(id, patch) { h.__updates.push({ id, patch }) } }
const node = { id: 'n1', type: 'plugin:sticky:sticky', data: { text: '标题', fontSize: 14, fontWeight: 400, bgColor: '#FCE8B0' } }
r.nodeApi.render(node, props, h)
return { h, node, props }
}
const nh = makeNodeHost()
check('节点体注入 .iwb-sticky-node', !!findByClass(nh.h, 'iwb-sticky-node'))
check('节点体有工具条 A+/A−/B + 色板按钮', !!findByClass(nh.h, 'iwb-sticky-tools') && !!findByClass(nh.h, 'iwb-sticky-pal'))
check('节点体有 textarea', findByClass(nh.h, 'iwb-sticky-body') && findByClass(nh.h, 'iwb-sticky-body').tagName === 'TEXTAREA')
check('默认文本同步到 textarea', findByClass(nh.h, 'iwb-sticky-body').value === '标题')
// v1.0.2:色板挂在工具条内(top:100% 落调色按钮下方),不再贴便签底部右下角盖住 resize 手柄
const toolsBox = findByClass(nh.h, 'iwb-sticky-tools')
const palBox = findByClass(nh.h, 'iwb-sticky-pal')
check('色板挂在工具条内(跟随调色按钮,不盖 resize 手柄)', palBox && palBox.parentNode === toolsBox)
check('色板 CSS top:100%(落按钮下方)', /\.iwb-sticky-pal\{position:absolute;top:100%/.test(injectedCssOf(r)))
// v1.0.2:textarea 高度随内容自适应(flex:0 0 auto + JS 写 height)
check('textarea flex:0 0 auto(不 flex 撑满留白)', /\.iwb-sticky-body\{flex:0 0 auto/.test(injectedCssOf(r)))
function injectedCssOf(rr) { return (findById(rr.head, 'iwb-sticky-style') || {}).textContent || '' }
const taInit = findByClass(nh.h, 'iwb-sticky-body')
check('textarea 显式 rows=1(不预留默认第二行)', taInit.getAttribute('rows') === '1')
check('textarea 初始高度按内容算出(贴字)', parseFloat(taInit.style.height) > 0)
check('调色圆点推到工具条最右(右上)', /\.iwb-sticky-dot\{[^}]*margin-left:auto/.test(injectedCssOf(r)))
// v1.0.3:宿主外框 minHeight 来自 node.h —— 旧 h 会把便签撑出一截空白且手柄拖不下去。
// 用带父节点卡片的 host 复现:渲染后必须把外框 minHeight 校正成内容高度,并同步改正 node.h。
const card = makeNode('div')
card.style.minHeight = '360px'
const host2 = makeNode('div')
card.appendChild(host2)
const node2 = { id: 'n2', type: 'plugin:sticky:sticky', h: 360,
data: { text: '范例', fontSize: 40, fontWeight: 600, bgColor: '#FCE8B0' } }
r.nodeApi.render(node2, { onUpdate() {} }, host2)
const expectedH = Math.round(30 + parseFloat(findByClass(host2, 'iwb-sticky-body').style.height) + 2)
check('外框 minHeight 覆盖为内容高度(不再被旧 h 撑住)', card.style.minHeight === expectedH + 'px',
'card=' + card.style.minHeight + ' expected=' + expectedH + 'px')
check('旧 node.h 校正为内容高度(resize 起点贴字)', node2.h === expectedH, 'h=' + node2.h)
// 用户之后手动拖大的 h 不能被再次压回(仍然可拖大拖小)
node2.h = 260
r.nodeApi.render(node2, { onUpdate() {} }, host2)
check('用户拖大后的 h 保留(可拖大)', node2.h === 260 && card.style.minHeight === '260px',
'h=' + node2.h + ' minH=' + card.style.minHeight)
// v1.0.6:自动跟随内容的 h 必须双向伸缩——两行退回一行时外框要跟着缩回去。
const card3 = makeNode('div')
const host3 = makeNode('div')
card3.appendChild(host3)
const node3 = { id: 'n3', type: 'plugin:sticky:sticky',
data: { text: '一行', fontSize: 40, fontWeight: 400, bgColor: '#FCE8B0' } }
const pass3 = { onUpdate() {} }
r.nodeApi.render(node3, pass3, host3)
const hOneLine = node3.h
node3.data.text = '第一行\n第二行'
r.nodeApi.render(node3, pass3, host3)
const hTwoLines = node3.h
check('文本一行变两行:外框自动长高', hTwoLines > hOneLine, hOneLine + ' → ' + hTwoLines)
node3.data.text = '一行'
r.nodeApi.render(node3, pass3, host3)
check('文本两行退回一行:外框自动缩回(v1.0.6)',
node3.h === hOneLine && card3.style.minHeight === hOneLine + 'px',
'h=' + node3.h + ' minH=' + card3.style.minHeight)
function findByClass(root, cls) {
const needle = cls.split('.').filter(Boolean).pop()
const q = [root]
while (q.length) {
const n = q.shift()
if (String(n.className).split(/\s+/).indexOf(needle) >= 0) return n
q.push(...(n.children || []))
}
return null
}
const btn = (cls) => {
const q = [nh.h]
while (q.length) {
const n = q.shift()
if (String(n.className).split(/\s+/).indexOf(cls) >= 0) return n
q.push(...(n.children || []))
}
return null
}
// A+ → +2 步进(无上限)
btn('iwb-sticky-btn') // 占位,实际按 data-act 找
const plus = nh.h.querySelectorAll ? null : findByAct(nh.h, 'plus')
function findByAct(root, act) {
const q = [root]
while (q.length) {
const n = q.shift()
if (n.attrs && n.attrs['data-act'] === act) return n
q.push(...(n.children || []))
}
return null
}
findByAct(nh.h, 'plus').fire('click', { target: findByAct(nh.h, 'plus') })
check('A+ 写 fontSize=16(+2 步进)', nh.h.__updates.some((u) => u.patch.fontSize === 16))
findByAct(nh.h, 'minus').fire('click', { target: findByAct(nh.h, 'minus') })
check('A− 写 fontSize=12(−2 步进)', nh.h.__updates.some((u) => u.patch.fontSize === 12))
// 无上限:把数据设成 100,A+ 仍继续涨(旧闭集会钳回 24)
nh.node.data.fontSize = 100
nh.h.__updates.length = 0
findByAct(nh.h, 'plus').fire('click', { target: findByAct(nh.h, 'plus') })
check('字号无上限(100 → 102)', nh.h.__updates.some((u) => u.patch.fontSize === 102))
// 字号变大 → textarea 高度跟着涨(贴字自适应)
const taSize = findByClass(nh.h, 'iwb-sticky-body')
const hBefore = parseFloat(taSize.style.height)
nh.node.data.fontSize = 40
r.nodeApi.render(nh.node, nh.props, nh.h)
check('字号 14→40 时 textarea 高度重算变大', parseFloat(taSize.style.height) > hBefore)
nh.node.data.fontSize = 14
findByAct(nh.h, 'bold').fire('click', { target: findByAct(nh.h, 'bold') })
check('B 切 fontWeight=600', nh.h.__updates.some((u) => u.patch.fontWeight === 600))
// 色板:展开 + 点第 3 个色块(橙)写 bgColor
const paletteBtn = findByAct(nh.h, 'palette')
paletteBtn.fire('click', { target: paletteBtn })
const pal = findByClass(nh.h, 'iwb-sticky-pal')
check('点背景按钮展开色板', pal.hidden === false)
const swatches = []
;(function walk(n) { (n.children || []).forEach((c) => { if (String(c.className).indexOf('iwb-sticky-pal-sw') >= 0) swatches.push(c); walk(c) }) })(pal)
check('色板有 8 个预设色', swatches.length === 8)
swatches[2].fire('click', { target: swatches[2] })
check('点色块写 bgColor=#EF9F27', nh.h.__updates.some((u) => u.patch.bgColor === '#EF9F27'))
check('选色后色板收起', pal.hidden === true)
check('有色轮自定义按钮', !!findByAct(nh.h, 'wheel'))
// v1.0.7:自定义调色(色轮)也必须自动收起面板
paletteBtn.fire('click', { target: paletteBtn })
check('再次展开色板(自定义调色前)', pal.hidden === false)
const wheelBtn = findByAct(nh.h, 'wheel')
wheelBtn.fire('click', { target: wheelBtn })
check('点色轮打开取色器时色板自动收起', pal.hidden === true)
const colorInput = findByAct(nh.h, 'color')
check('有隐藏的原生取色 input', !!colorInput && colorInput.tagName === 'INPUT')
paletteBtn.fire('click', { target: paletteBtn })
nh.h.__updates.length = 0
colorInput.value = '#C0392B'
colorInput.fire('change', { target: colorInput })
check('自定义色写回 bgColor', nh.h.__updates.some((u) => u.patch.bgColor === '#C0392B'))
check('自定义色确认后色板保持收起', pal.hidden === true)
// ---- 单击选中 / 双击编辑状态机 ----
const ta = findByClass(nh.h, 'iwb-sticky-body')
check('正文默认只读(单击穿透给节点选中/拖动)', ta.readOnly === true && ta.getAttribute('readonly') !== null)
const injectedCss = (findById(r.head, 'iwb-sticky-style') || {}).textContent || ''
check('根容器 flex:1 撑满宿主(修拖动后漏底)', /\.iwb-sticky-node\{[^}]*flex:1 1 auto/.test(injectedCss))
check('纸片圆角对齐宿主节点(node-radius - 1px 边框)',
/\.iwb-sticky-node\{[^}]*border-radius:calc\(var\(--iwb-node-radius, 14px\) - 1px\)/.test(injectedCss))
const rootNode = findByClass(nh.h, 'iwb-sticky-node')
const dblEv = { target: ta, stopPropagation() {} }
rootNode.fire('dblclick', dblEv)
check('双击正文进入编辑(解除 readonly)', ta.readOnly === false && ta.className.indexOf('iwb-sticky-editing') >= 0)
check('双击后 textarea 获得焦点', r.document.activeElement === ta)
// 编辑态下 pointerdown 冒泡被拦(不拖节点)
let downStopped = false
ta.fire('pointerdown', { target: ta, stopPropagation() { downStopped = true } })
check('编辑态 pointerdown 不冒泡给宿主', downStopped)
// 失焦退出编辑、恢复只读
ta.fire('blur')
check('失焦退出编辑(恢复 readonly)', ta.readOnly === true && ta.className.indexOf('iwb-sticky-editing') < 0)
// 多行文本写回(编辑态)
ta.fire('dblclick', { target: ta, stopPropagation() {} })
ta.value = '第一行\n第二行\n第三行'
ta.fire('input', { target: ta })
check('多行文本写回 data.text', nh.h.__updates.some((u) => u.patch.text === '第一行\n第二行\n第三行'))
// 幂等同步:编辑中不覆盖正在输入的 textarea
const active = ta
r.document.activeElement = active
nh.node.data.text = '外部改的值'
r.nodeApi.render(nh.node, nh.props, nh.h)
check('编辑中的 textarea 不被外部数据覆盖', ta.value === '第一行\n第二行\n第三行')
ta.fire('blur') // 退出编辑态
r.document.activeElement = null
nh.node.data.text = '外部改的值'
r.nodeApi.render(nh.node, nh.props, nh.h)
check('非编辑态 textarea 跟随数据更新', ta.value === '外部改的值')
// 深/浅背景自动取文字色(运行时算,不写死)
const st = nh.h.__sticky
check('浅色背景取深色文字', st.root.style.color === '#1c2333')
nh.node.data.bgColor = '#1F3350'
r.nodeApi.render(nh.node, nh.props, nh.h)
check('深色背景取白色文字', st.root.style.color === '#ffffff')
// 面板插入便利贴走 createNode(null,null)
const panelHost = makeNode('div')
r.panelApi.mount(panelHost, r.ctx)
const addBtn = findByClass(panelHost, 'iwb-sticky-add')
addBtn.fire('click', { target: addBtn })
check('插入便利贴调 canvas.createNode', r.createCalls.length === 1)
check('createNode 类型 = plugin:sticky:sticky', r.createCalls[0] && r.createCalls[0].type === 'plugin:sticky:sticky')
check('createNode 坐标 null/null(宿主找空位)', r.createCalls[0] && r.createCalls[0].x === null && r.createCalls[0].y === null)
check('插入带默认样式数据', r.createCalls[0] && r.createCalls[0].data.fontSize === 14 && r.createCalls[0].data.bgColor === '#FCE8B0')
console.log('\n' + (failed ? '✗ ' + failed + ' 项失败' : '✓ 全部通过'))
process.exit(failed ? 1 : 0)