fix(plugin): 移除便利贴的停靠栏面板,版本升至 1.0.9
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 49s
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 49s
便利贴是纯画布节点(plugin:sticky:sticky),不需要边栏面板 —— 面板里的「插入便利贴 / 列表 / 定位」与节点本身重复,且此前被误用作 side 偏好的验证对象。 改动: - 删除整段面板实现(registerPanel / mountPanel / refreshList / insertNote / ctxForPanel / noteList,85 行) - capabilities: ['panels','nodeTypes','canvas'] → ['nodeTypes','canvas'] - 版本 1.0.8 → 1.0.9(能力面变更,需高于外部已装副本才会覆盖) - plugins/index.json 同步 version 与 SRI integrity(已校验哈希一致) 节点类型注册不受影响(渲染 / 高度 / 端口配置原样保留)。 验证:npm run verify:ci 全绿(含 e2e 冒烟 31 条)。
This commit is contained in:
1 parent
843dd83910
commit
c313a11f3e
2 files changed
+4
-85
No files matched your search
+2
-2
@@ -76,8 +76,8 @@
|
||||
{
|
||||
"id": "sticky",
|
||||
"file": "plugin-sticky.f5f77ac81467.js",
|
||||
"version": "1.0.8",
|
||||
"integrity": "sha256-9fd6yBRnWxcDNDN1G+KywL9vp5JN9CaTMja4s5pK1As="
|
||||
"version": "1.0.9",
|
||||
"integrity": "sha256-LhTIND2kB+MhL6Z5GQUh30X9m+rkVqSZz40MzysGSvo="
|
||||
},
|
||||
{
|
||||
"id": "style-source",
|
||||
|
||||
@@ -397,89 +397,16 @@
|
||||
if (st.dot.style.background !== bg) st.dot.style.background = bg
|
||||
}
|
||||
|
||||
// ---------------- 面板 ----------------
|
||||
var ctxForPanel = null
|
||||
var noteList = []
|
||||
|
||||
function refreshList() {
|
||||
if (!ctxForPanel) return
|
||||
var host = ctxForPanel.__stickyPanelRoot
|
||||
if (!host || typeof host.innerHTML !== 'undefined' && !host.innerHTML && !host.appendChild) return
|
||||
var list = host.querySelector ? host.querySelector('.iwb-sticky-list') : null
|
||||
if (!list) return
|
||||
// 尽力从画布读回便利贴节点(只读画布能力给了 getNodes)
|
||||
var nodes = []
|
||||
try {
|
||||
var api = ctxRef && ctxRef.canvas
|
||||
if (api && typeof api.getNodes === 'function') nodes = api.getNodes() || []
|
||||
} catch (e) { nodes = [] }
|
||||
var mine = nodes.filter(function (n) { return String(n.type || '').indexOf('plugin:sticky:') === 0 })
|
||||
// 用最近插入的本地记录补足(getNodes 快照不含自定义状态没关系,这里只显示文本)
|
||||
var seen = {}
|
||||
var rows = []
|
||||
mine.concat(noteList).forEach(function (n) {
|
||||
var key = n.id
|
||||
if (!key || seen[key]) return
|
||||
seen[key] = 1
|
||||
var text = String((n.data && n.data.text) || '').replace(/\s+/g, ' ').slice(0, 30) || '(空便利贴)'
|
||||
rows.push({ id: key, text: text })
|
||||
})
|
||||
while (list.firstChild) list.removeChild(list.firstChild)
|
||||
rows.slice(-20).forEach(function (r) {
|
||||
var row = el('div', { className: 'iwb-sticky-row' })
|
||||
row.appendChild(el('span', { className: 'iwb-sticky-row-txt' }, r.text))
|
||||
var go = el('button', { className: 'iwb-sticky-go', type: 'button' }, '定位')
|
||||
go.addEventListener('click', function () {
|
||||
try { if (ctxRef && ctxRef.canvas && typeof ctxRef.canvas.focusNode === 'function') ctxRef.canvas.focusNode(r.id) } catch (e) { /* noop */ }
|
||||
})
|
||||
row.appendChild(go)
|
||||
list.appendChild(row)
|
||||
})
|
||||
}
|
||||
|
||||
function mountPanel(host, ctx) {
|
||||
ensureStyle()
|
||||
ctxForPanel = ctx
|
||||
host.textContent = ''
|
||||
host.style.minWidth = '0'; host.style.minHeight = '0'; host.style.height = '100%'
|
||||
var wrap = el('div', { className: 'iwb-sticky-panel' })
|
||||
wrap.appendChild(el('div', { className: 'iwb-sticky-panel-tip' },
|
||||
'在画布上放一张便利贴:字调大当说明标题,字调小放多行正文。点右下角拖动手柄可改变便签大小。'))
|
||||
var add = el('button', { className: 'iwb-sticky-add', type: 'button' }, '+ 插入便利贴')
|
||||
add.addEventListener('click', function () { insertNote() })
|
||||
wrap.appendChild(add)
|
||||
var list = el('div', { className: 'iwb-sticky-list' })
|
||||
wrap.appendChild(list)
|
||||
host.appendChild(wrap)
|
||||
ctxForPanel.__stickyPanelRoot = host
|
||||
refreshList()
|
||||
}
|
||||
|
||||
function insertNote() {
|
||||
var api = ctxRef && ctxRef.canvas
|
||||
if (!api || typeof api.createNode !== 'function') return null
|
||||
var id = api.createNode('plugin:sticky:sticky', null, null, {
|
||||
text: '', fontSize: DEFAULT_SIZE, fontWeight: 400, bgColor: DEFAULT_BG,
|
||||
})
|
||||
if (id) {
|
||||
noteList.push({ id: id, data: { text: '' } })
|
||||
refreshList()
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
function dispose() {
|
||||
ctxRef = null
|
||||
ctxForPanel = null
|
||||
noteList = []
|
||||
}
|
||||
|
||||
global.IWBPluginHost.register({
|
||||
id: 'sticky',
|
||||
name: '便利贴',
|
||||
version: '1.0.8',
|
||||
version: '1.0.9',
|
||||
apiVersion: 1,
|
||||
capabilities: ['panels', 'nodeTypes', 'canvas'],
|
||||
capabilities: ['nodeTypes', 'canvas'],
|
||||
}, function (ctx) {
|
||||
ctxRef = ctx
|
||||
if (ctx.nodes && typeof ctx.nodes.register === 'function') {
|
||||
@@ -492,14 +419,6 @@
|
||||
render: renderSticky,
|
||||
})
|
||||
}
|
||||
if (ctx.ui && typeof ctx.ui.registerPanel === 'function') {
|
||||
ctx.ui.registerPanel({
|
||||
id: 'sticky',
|
||||
title: '便利贴',
|
||||
icon: 'note',
|
||||
mount: mountPanel,
|
||||
})
|
||||
}
|
||||
return { dispose: dispose }
|
||||
})
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
Reference in new issue
Block a user