revert+fix(promptlib): 1.8.16 回退到 1.8.9 样式基线,插入变量改用原生 insertText 精确落点
validate / validate (push) Canceled after 0s

This commit is contained in:
qiqi committed 2026-11-23 09:51:20 +08:00
1 parent 89d3cfc619
commit 385a73c111
3 files changed
+73 -83

No files matched your search

+15 -7
View File
@@ -1556,15 +1556,23 @@
insVarBtn.addEventListener('pointerdown', function (e) { e.preventDefault(); rememberSel() })
insVarBtn.addEventListener('click', function () {
var v = textIn.value
var s = Math.min(Math.max(lastSel.s || 0, 0), v.length)
var e = Math.min(Math.max(lastSel.e == null ? s : lastSel.e, s), v.length)
textIn.focus()
// 先把选区恢复到用户最后的光标位置,再交给浏览器原生插入
try { textIn.setSelectionRange(Math.min(lastSel.s, v.length), Math.min(lastSel.e, v.length)) } catch (e) { /* ignore */ }
var s = textIn.selectionStart, e = textIn.selectionEnd
var name = s !== e ? String(v.slice(s, e)).replace(/\s+/g, '').slice(0, 24) : '新变量'
if (!name) name = '新变量'
var ins = '{' + name + '}'
textIn.focus()
textIn.value = v.slice(0, s) + ins + v.slice(e)
textIn.setSelectionRange(s + 1, s + 1 + name.length)
lastSel = { s: s + 1, e: s + 1 + name.length }
var ok = false
try { ok = document.execCommand('insertText', false, ins) } catch (err) { ok = false }
if (!ok) {
textIn.value = v.slice(0, s) + ins + v.slice(e)
textIn.setSelectionRange(s + 1, s + 1 + name.length)
} else {
var pos = textIn.selectionStart
textIn.setSelectionRange(pos - ins.length + 1, pos - 1)
}
lastSel = { s: textIn.selectionStart, e: textIn.selectionEnd }
dirty = true
paintHl()
varEd.sync(textIn.value)
@@ -1763,7 +1771,7 @@
global.IWBPluginHost.register({
id: 'promptlib',
name: '提示词库',
version: '1.8.15',
version: '1.8.16',
apiVersion: 1,
capabilities: ['panels', 'promptlib', 'nodeTypes', 'canvas', 'canvasWrite'],
data: { schemaVersion: 3, maxBytes: 4 * 1024 * 1024 },