From d151df3512c212997142efbd64f4deb8548eadff Mon Sep 17 00:00:00 2001 From: qiqi Date: Sun, 22 Nov 2026 22:09:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(promptlib):=201.6.17=20=E6=8B=96=E6=8B=BD?= =?UTF-8?q?=E5=B1=8F=E8=94=BD=E6=96=87=E6=9C=AC=E9=80=89=E6=8B=A9=20+=20?= =?UTF-8?q?=E8=90=BD=E7=82=B9=E5=B1=85=E4=B8=AD=20+=20=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E6=8F=92=E5=85=A5=E5=B1=85=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- promptlib/package.json | 2 +- promptlib/src/index.js | 22 ++++++++++++++++++---- promptlib/styles.css | 1 + 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/promptlib/package.json b/promptlib/package.json index 24b4367..812fb7b 100644 --- a/promptlib/package.json +++ b/promptlib/package.json @@ -1,7 +1,7 @@ { "name": "@iwb-plugin/promptlib", "private": true, - "version": "1.6.16", + "version": "1.6.17", "description": "提示词库:右栏提示词列表(搜索/分组/收藏/新建编辑/插入画布/复制/删除),数据由宿主 promptlib 能力提供", "ibwPlugin": { "id": "promptlib", diff --git a/promptlib/src/index.js b/promptlib/src/index.js index b1f583b..88b8de4 100644 --- a/promptlib/src/index.js +++ b/promptlib/src/index.js @@ -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 }, diff --git a/promptlib/styles.css b/promptlib/styles.css index 0028fc0..b56cf70 100644 --- a/promptlib/styles.css +++ b/promptlib/styles.css @@ -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}