feat(plugins): 拖拽提示词按变量分流到模板节点 + promptlib 1.5.7 同步

This commit is contained in:
qiqi committed 2026-11-22 17:05:56 +08:00
1 parent 3e28796a15
commit 0c11b45af5
4 files changed
+22 -7

No files matched your search

+1 -1
View File
@@ -46,7 +46,7 @@
"style": "styles.css",
"version": "1.5.0",
"files": {
"main.js": "25f3b26f3727f7378db15ff6ac05cf548e77fdfc1accb8ae738f0187d0e8e71a",
"main.js": "5482e49e99329f368c7e63e30ec64989439ac999b684c7dbafc5916807184c61",
"styles.css": "28a267866d81708fc51aa61a40f922decd917c9ea907c52c8c916fe6398cad68"
}
},
+7 -3
View File
@@ -931,13 +931,17 @@
var card = el('div', { class: 'iwb-plp-card' + (p.cover ? ' has-cover' : ' no-cover'), draggable: 'true', title: '单击查看详情 · 拖到画布插入 · 右键移动到分组' })
card.style.background = coverUrl ? 'var(--iwb-plugin-inset)' : gradOf(p)
if (coverUrl) card.appendChild(el('img', { class: 'iwb-plp-cover', src: coverUrl, alt: '', draggable: 'false' }))
// 紫色小点:表示这条是带变量的模板(不喧宾夺主,鼠标悬停看数量)
if (varsOf(p).length) card.appendChild(el('i', { class: 'iwb-plp-vdot', title: varsOf(p).length + ' 个变量' }))
card.appendChild(el('div', { class: 'iwb-plp-t', text: p.name || '未命名' }))
card.addEventListener('dragstart', function (e) {
try {
e.stopPropagation()
e.dataTransfer.setData('application/x-iwb-prompt', JSON.stringify({ text: p.text || '', name: p.name || '' }))
var vd = varsOf(p)
e.dataTransfer.setData('application/x-iwb-prompt', JSON.stringify({
text: p.text || '', name: p.name || '',
vars: vd.map(function (v) { return v.key }),
vdefs: vd,
cover: p.cover || '',
}))
e.dataTransfer.setData('application/x-iwb-promptid', p.id)
e.dataTransfer.setData('text/plain', (p.text || '').slice(0, 200))
e.dataTransfer.effectAllowed = 'copy'
+1 -1
View File
@@ -13,7 +13,7 @@
"提示词"
],
"files": {
"main.js": "25f3b26f3727f7378db15ff6ac05cf548e77fdfc1accb8ae738f0187d0e8e71a",
"main.js": "5482e49e99329f368c7e63e30ec64989439ac999b684c7dbafc5916807184c61",
"styles.css": "28a267866d81708fc51aa61a40f922decd917c9ea907c52c8c916fe6398cad68"
}
}
+13 -2
View File
@@ -1089,11 +1089,22 @@
try {
const obj = JSON.parse(promptPayload)
const id = uid('n')
const node = { id, type: 'prompt', x: Math.round(wx - 132), y: Math.round(wy - 20), data: { text: obj.text || '', title: obj.name || '' } }
// 有变量 → 模板节点(可填值、可作参考图);没有变量 → 普通文本节点(最轻)
const hasVars = Array.isArray(obj.vars) && obj.vars.length > 0
const node = hasVars
? {
id, type: 'ptpl', x: Math.round(wx - 210), y: Math.round(wy - 20), w: 420,
data: {
promptId: '', name: obj.name || '提示词模板', tpl: obj.text || '',
vdefs: Array.isArray(obj.vdefs) ? obj.vdefs : [],
vars: {}, cover: obj.cover || '', refOn: false, text: obj.text || '',
},
}
: { id, type: 'prompt', x: Math.round(wx - 132), y: Math.round(wy - 20), data: { text: obj.text || '', title: obj.name || '' } }
pushHistory() // 拖拽入画布新增节点:入撤销历史(鼠标落点保留)
commitCanvas(refs.nodes.concat([node]), undefined, undefined)
setSel([id])
setNotice({ type: 'ok', text: '已插入提示词:' + (obj.name || '') })
setNotice({ type: 'ok', text: (hasVars ? '已插入提示词模板:' : '已插入提示词:') + (obj.name || '') })
return
} catch (err) { /* 非本应用拖入 */ }
}