fix(promptlib): 1.6.16 插入走 canvasWrite + canvas.screenToWorld(宿主 API 拆分)
validate / validate (push) Canceled after 0s

This commit is contained in:
qiqi committed 2026-11-22 21:20:13 +08:00
1 parent c9d06b8388
commit ca1764b2c4
2 files changed
+10 -8

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@iwb-plugin/promptlib",
"private": true,
"version": "1.6.15",
"version": "1.6.16",
"description": "提示词库:右栏提示词列表(搜索/分组/收藏/新建编辑/插入画布/复制/删除),数据由宿主 promptlib 能力提供",
"ibwPlugin": {
"id": "promptlib",
+9 -7
View File
@@ -758,14 +758,15 @@
try { st.card.classList.remove('is-dragging'); st.card.classList.remove('is-pressed') } catch (e) { /* ignore */ }
if (!commit || !st.active) return
try {
var api2 = ctx.canvas
var api2 = ctx.canvasWrite || ctx.canvas
var sw = ctx.canvas && typeof ctx.canvas.screenToWorld === 'function' ? ctx.canvas.screenToWorld : null
var cnv = document.querySelector('.iwb-canvas')
if (cnv) {
var rc = cnv.getBoundingClientRect()
if (x < rc.left || x > rc.right || y < rc.top || y > rc.bottom) return
}
if (!api2 || typeof api2.screenToWorld !== 'function' || typeof api2.createNode !== 'function') { notify('当前宿主不支持拖拽插入', 'err'); return }
var w = api2.screenToWorld(x, y)
if (!api2 || typeof api2.createNode !== 'function' || !sw) { notify('当前宿主不支持拖拽插入', 'err'); return }
var w = sw(x, y)
if (!w) return
var vd = varsOf(st.p)
if (vd.length) {
@@ -1279,10 +1280,11 @@
var del = el('button', { class: 'iwb-btn iwb-btn-sm iwb-btn-danger', text: '删除' })
var cp = el('button', { class: 'iwb-btn iwb-btn-sm', text: '复制全文' })
var insTpl = null
if (ctx.nodes && ctx.canvas && typeof ctx.canvas.createNode === 'function') {
var cw = ctx.canvasWrite || ctx.canvas
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 = ctx.canvas.createNode('ptpl', null, null, {
var id = cw.createNode('ptpl', null, 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(),
})
@@ -1578,9 +1580,9 @@
global.IWBPluginHost.register({
id: 'promptlib',
name: '提示词库',
version: '1.6.15',
version: '1.6.16',
apiVersion: 1,
capabilities: ['panels', 'promptlib', 'nodeTypes', 'canvasWrite'],
capabilities: ['panels', 'promptlib', 'nodeTypes', 'canvas', 'canvasWrite'],
data: { schemaVersion: 3, maxBytes: 4 * 1024 * 1024 },
settings: { panel: { type: 'custom', label: '分组与备份', render: renderPluginSettings } },
}, function (ctx) {