fix(promptlib): 1.6.17 拖拽屏蔽文本选择 + 落点居中 + 详情插入居中
This commit is contained in:
1 parent
ca1764b2c4
commit
d151df3512
3 files changed
+20
-5
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@iwb-plugin/promptlib",
|
||||
"private": true,
|
||||
"version": "1.6.16",
|
||||
"version": "1.6.17",
|
||||
"description": "提示词库:右栏提示词列表(搜索/分组/收藏/新建编辑/插入画布/复制/删除),数据由宿主 promptlib 能力提供",
|
||||
"ibwPlugin": {
|
||||
"id": "promptlib",
|
||||
|
||||
+18
-4
@@ -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 },
|
||||
|
||||
@@ -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