From 0e80c55adffbd917828415febf9c5b26211c4b36 Mon Sep 17 00:00:00 2001 From: qiqi Date: Sun, 22 Nov 2026 23:08:34 +0800 Subject: [PATCH] =?UTF-8?q?chore(plugins):=20promptlib=201.7.2=20=E5=B8=82?= =?UTF-8?q?=E5=9C=BA=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/index.json | 6 +++--- plugins/promptlib/main.js | 24 +++++++++++++++++++++--- plugins/promptlib/manifest.json | 6 +++--- plugins/promptlib/styles.css | 10 ++++++++++ 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/plugins/index.json b/plugins/index.json index 33f5ab6..ffca98a 100644 --- a/plugins/index.json +++ b/plugins/index.json @@ -44,10 +44,10 @@ "dir": "promptlib", "main": "main.js", "style": "styles.css", - "version": "1.7.1", + "version": "1.7.2", "files": { - "main.js": "2451ffb4d5097332e6478f30161c7a60f00e6f65ed9a0134cabc80db3d7a9f2c", - "styles.css": "152ea047caf7ea4cbbf7157cacd94a5e24c40f0c07e27bf8f73b33e369aec15a" + "main.js": "e9e9e63d55068c306030d278721d8d88f2f2c8e65ec64641242ddb8acc37b813", + "styles.css": "e88a2ff725cf1f8ca8abaa7cca35ffb3ffb5a4bbad946e457e5ed7853e4c61e5" } }, { diff --git a/plugins/promptlib/main.js b/plugins/promptlib/main.js index 812b2f3..61f2f10 100644 --- a/plugins/promptlib/main.js +++ b/plugins/promptlib/main.js @@ -1466,11 +1466,29 @@ left.appendChild(el('label', { class: 'iwb-plp-lrow' }, el('span', { text: '分组' }), groupIn)) left.appendChild(el('label', { class: 'iwb-plp-lrow' }, el('span', { text: '标签' }), tagsIn)) var textIn = el('textarea', { class: 'iwb-input iwb-plp-etext', placeholder: '提示词正文' }) + var hl = el('div', { class: 'iwb-plp-hl' }) + var textWrap = el('div', { class: 'iwb-plp-ewrap' }) + textWrap.appendChild(hl); textWrap.appendChild(textIn) + function paintHl () { + var v = textIn.value || '' + hl.textContent = '' + var re = /[{]([^{}]{1,24})[}]/g, last = 0, m + while ((m = re.exec(v))) { + if (m.index > last) hl.appendChild(document.createTextNode(v.slice(last, m.index))) + hl.appendChild(el('span', { class: 'iwb-plp-hlvar', text: m[0] })) + last = m.index + m[0].length + } + if (last < v.length) hl.appendChild(document.createTextNode(v.slice(last))) + hl.appendChild(document.createTextNode('\n')) + } + textIn.addEventListener('scroll', function () { hl.scrollTop = textIn.scrollTop }) textIn.value = draft.text || '' - var varEd = makeVarsEditor(draft.text || '', draft.vars || [], function (nt) { textIn.value = nt; dirty = true }) + paintHl() + var varEd = makeVarsEditor(draft.text || '', draft.vars || [], function (nt) { textIn.value = nt; dirty = true; paintHl() }) var syncTimer = 0 textIn.addEventListener('input', function () { dirty = true + paintHl() if (syncTimer) clearTimeout(syncTimer) syncTimer = setTimeout(function () { varEd.sync(textIn.value) }, 200) }) @@ -1492,7 +1510,7 @@ }) var mid = el('div', { class: 'iwb-plp-emid' }) mid.appendChild(el('div', { class: 'iwb-plp-etool' }, insVarBtn, el('span', { class: 'iwb-hint', text: '在光标处插入 {变量},并自动聚焦变量名' }))) - mid.appendChild(textIn) + mid.appendChild(textWrap) var split = el('div', { class: 'iwb-plp-esplit', title: '拖动调整变量列宽度' }) var right = el('div', { class: 'iwb-plp-eright' }) right.appendChild(varEd.node) @@ -1684,7 +1702,7 @@ global.IWBPluginHost.register({ id: 'promptlib', name: '提示词库', - version: '1.7.1', + version: '1.7.2', apiVersion: 1, capabilities: ['panels', 'promptlib', 'nodeTypes', 'canvas', 'canvasWrite'], data: { schemaVersion: 3, maxBytes: 4 * 1024 * 1024 }, diff --git a/plugins/promptlib/manifest.json b/plugins/promptlib/manifest.json index 97587cf..426f522 100644 --- a/plugins/promptlib/manifest.json +++ b/plugins/promptlib/manifest.json @@ -1,7 +1,7 @@ { "id": "promptlib", "name": "提示词库", - "version": "1.7.1", + "version": "1.7.2", "apiVersion": 1, "main": "main.js", "style": "styles.css", @@ -13,7 +13,7 @@ "提示词" ], "files": { - "main.js": "2451ffb4d5097332e6478f30161c7a60f00e6f65ed9a0134cabc80db3d7a9f2c", - "styles.css": "152ea047caf7ea4cbbf7157cacd94a5e24c40f0c07e27bf8f73b33e369aec15a" + "main.js": "e9e9e63d55068c306030d278721d8d88f2f2c8e65ec64641242ddb8acc37b813", + "styles.css": "e88a2ff725cf1f8ca8abaa7cca35ffb3ffb5a4bbad946e457e5ed7853e4c61e5" } } diff --git a/plugins/promptlib/styles.css b/plugins/promptlib/styles.css index 4a234e9..9970a6d 100644 --- a/plugins/promptlib/styles.css +++ b/plugins/promptlib/styles.css @@ -434,3 +434,13 @@ body.iwb-plp-dragging, body.iwb-plp-dragging *{user-select:none!important;-webki .iwb-plp-dialog .iwb-plp-lrow span{color:#8a919c;font-size:11.5px} .iwb-plp-dialog .iwb-plp-lrow .iwb-input{background:#fbfcfd;border:1px solid #eceef2;border-radius:8px;height:32px} .iwb-plp-dialog .iwb-plp-lrow .iwb-input:focus{background:#fff;border-color:#cfc3ff} +/* v1.7.2:正文变量高亮(黑粗)+ 说明灰按钮 + 说明背景回归面板底 */ +.iwb-plp-ewrap{position:relative;flex:1 1 auto;min-height:0;display:flex;border-radius:9px;background:#fbfcfd;border:1px solid #eef0f3} +.iwb-plp-ewrap:focus-within{background:#fff;border-color:#cfc3ff;box-shadow:0 0 0 3px rgba(107,77,255,.08)} +.iwb-plp-ewrap .iwb-plp-etext{flex:1 1 auto;min-height:0;border:0;background:transparent;box-shadow:none;color:transparent;caret-color:#1d2129;position:relative;z-index:1;resize:none} +.iwb-plp-ewrap .iwb-plp-etext:focus{background:transparent;border:0;box-shadow:none} +.iwb-plp-hl{position:absolute;inset:0;padding:10px 12px;overflow:hidden;white-space:pre-wrap;word-wrap:break-word;font-size:13px;line-height:1.9;color:#5b6472;pointer-events:none;z-index:0} +.iwb-plp-hlvar{color:#1d2129;font-weight:600} +.iwb-plp-dialog .iwb-plp-vi.is-open{background:#eef0f3;color:#5b6472} +.iwb-plp-dialog .iwb-plp-vdesc{background:transparent;border:1px dashed #dfe3e9} +.iwb-plp-dvar{background:transparent;color:#1d2129;font-weight:600;padding:0}