fix(promptlib): 插入提示词/封面落到画布中心 + 1.6.17 同步
This commit is contained in:
1 parent
3483cc4174
commit
9739764d2f
5 files changed
+38
-12
No files matched your search
+3
-3
@@ -44,10 +44,10 @@
|
||||
"dir": "promptlib",
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
"version": "1.6.16",
|
||||
"version": "1.6.17",
|
||||
"files": {
|
||||
"main.js": "cc303530f758e54a185710e8c47620b7e588693adeb86a421b0833aed114a445",
|
||||
"styles.css": "1d3d84220118ed97490314d2aa122126d505c9eabcf1f8bd53a627983e7d5942"
|
||||
"main.js": "029d6adb976c5e41428ffbb3b5e8f3698dde2532597fcc55cc75e774b25b284e",
|
||||
"styles.css": "1fdad04e2ffe1c8ba2a991a88072f780b65238096f9ccd1b5adba671ff2c9cb3"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -755,6 +755,7 @@
|
||||
global.removeEventListener('pointercancel', st.onCancel, true)
|
||||
} catch (e) { /* ignore */ }
|
||||
if (st.ghost && st.ghost.parentNode) st.ghost.parentNode.removeChild(st.ghost)
|
||||
try { document.body.classList.remove('iwb-plp-dragging') } catch (e) { /* ignore */ }
|
||||
try { st.card.classList.remove('is-dragging'); st.card.classList.remove('is-pressed') } catch (e) { /* ignore */ }
|
||||
if (!commit || !st.active) return
|
||||
try {
|
||||
@@ -770,18 +771,30 @@
|
||||
if (!w) return
|
||||
var vd = varsOf(st.p)
|
||||
if (vd.length) {
|
||||
api2.createNode('ptpl', w.x, w.y, { promptId: '', name: st.p.name || '提示词模板', tpl: st.p.text || '', vdefs: vd, vars: {}, cover: st.p.cover || '', refOn: false, text: st.p.text || '', outKind: 'prompt' })
|
||||
api2.createNode('ptpl', w.x - 210, w.y - 20, { promptId: '', name: st.p.name || '提示词模板', tpl: st.p.text || '', vdefs: vd, vars: {}, cover: st.p.cover || '', refOn: false, text: st.p.text || '', outKind: 'prompt' })
|
||||
notify('已插入模板节点:' + (st.p.name || ''))
|
||||
} else {
|
||||
api2.createNode('prompt', w.x, w.y, { text: st.p.text || '', title: st.p.name || '' })
|
||||
api2.createNode('prompt', w.x - 132, w.y - 20, { text: st.p.text || '', title: st.p.name || '' })
|
||||
notify('已插入提示词:' + (st.p.name || ''))
|
||||
}
|
||||
} catch (err) { notify('拖拽插入失败:' + ((err && err.message) || err), 'err') }
|
||||
}
|
||||
// 详情里插入节点:落到画布可视区域中心,而不是被 findSpot 丢到左侧面板下面
|
||||
function canvasCenter (w, h) {
|
||||
try {
|
||||
var c = document.querySelector('.iwb-canvas')
|
||||
var sw = ctx.canvas && typeof ctx.canvas.screenToWorld === 'function' ? ctx.canvas.screenToWorld : null
|
||||
if (!c || !sw) return null
|
||||
var r = c.getBoundingClientRect()
|
||||
var pt = sw(r.left + r.width / 2, r.top + r.height / 2)
|
||||
return pt ? { x: pt.x - (w || 0) / 2, y: pt.y - (h || 0) / 2 } : null
|
||||
} catch (e) { return null }
|
||||
}
|
||||
function startCardDrag (e, p, card) {
|
||||
if (e.button !== 0) return
|
||||
// 不用 preventDefault:否则 WebKit 可能吞掉 click/dblclick(双击详情失效)
|
||||
card.classList.add('is-pressed')
|
||||
try { document.body.classList.add('iwb-plp-dragging') } catch (err) { /* ignore */ }
|
||||
var st = { card: card, p: p, sx: e.clientX, sy: e.clientY, active: false, ghost: null }
|
||||
st.onMove = function (ev) {
|
||||
var dx = ev.clientX - st.sx, dy = ev.clientY - st.sy
|
||||
@@ -1284,7 +1297,8 @@
|
||||
if (ctx.nodes && cw && typeof cw.createNode === 'function') {
|
||||
insTpl = el('button', { class: 'iwb-btn iwb-btn-sm iwb-btn-primary', title: '插入可填变量的模板节点', text: '插入模板节点' })
|
||||
insTpl.addEventListener('click', function () {
|
||||
var id = cw.createNode('ptpl', null, null, {
|
||||
var ctr = canvasCenter(420, 260)
|
||||
var id = cw.createNode('ptpl', ctr ? ctr.x : null, ctr ? ctr.y : null, {
|
||||
promptId: p.id, name: p.name || '提示词模板', tpl: p.text || '', vdefs: vlist, vars: vals, outKind: 'prompt',
|
||||
cover: p.cover || coverNameOf(p), refOn: false, text: filled(),
|
||||
})
|
||||
@@ -1580,7 +1594,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'promptlib',
|
||||
name: '提示词库',
|
||||
version: '1.6.16',
|
||||
version: '1.6.17',
|
||||
apiVersion: 1,
|
||||
capabilities: ['panels', 'promptlib', 'nodeTypes', 'canvas', 'canvasWrite'],
|
||||
data: { schemaVersion: 3, maxBytes: 4 * 1024 * 1024 },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "promptlib",
|
||||
"name": "提示词库",
|
||||
"version": "1.6.16",
|
||||
"version": "1.6.17",
|
||||
"apiVersion": 1,
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
@@ -13,7 +13,7 @@
|
||||
"提示词"
|
||||
],
|
||||
"files": {
|
||||
"main.js": "cc303530f758e54a185710e8c47620b7e588693adeb86a421b0833aed114a445",
|
||||
"styles.css": "1d3d84220118ed97490314d2aa122126d505c9eabcf1f8bd53a627983e7d5942"
|
||||
"main.js": "029d6adb976c5e41428ffbb3b5e8f3698dde2532597fcc55cc75e774b25b284e",
|
||||
"styles.css": "1fdad04e2ffe1c8ba2a991a88072f780b65238096f9ccd1b5adba671ff2c9cb3"
|
||||
}
|
||||
}
|
||||
@@ -388,3 +388,4 @@ box-shadow: 0 24px 60px rgba(0,0,0,.32);
|
||||
/* v1.6.13:未选中时变量输入框不拦截指针 —— 单击节点=选中/可拖动;选中后再点输入框编辑 */
|
||||
.iwb-plp-node:not(.is-selected) input{pointer-events:none}
|
||||
.iwb-plp-card{user-select:none}
|
||||
body.iwb-plp-dragging, body.iwb-plp-dragging *{user-select:none!important;-webkit-user-select:none!important}
|
||||
Reference in new issue
Block a user