fix(image-annotate): 1.2.7 首笔自动建层缺视图样式导致第一笔错位(补 updateLayerCanvasStyles) + PS 画笔大小快捷键 [/]
This commit is contained in:
1 parent
9e50697dd6
commit
a1c3a40f17
6 files changed
+48
-7
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@iwb-plugin/image-annotate",
|
||||
"private": true,
|
||||
"version": "1.2.6",
|
||||
"version": "1.2.7",
|
||||
"description": "IWB 插件:图片标注 / 修图(编辑器移植自 iwb-plaus 扩展,纯 Canvas 2D)",
|
||||
"ibwPlugin": {
|
||||
"id": "image-annotate",
|
||||
|
||||
@@ -46,9 +46,9 @@ import { bindEvents } from './events.js'
|
||||
<button class="iwb-editor-tool" data-tool="marquee" title="选框 (M):拖出矩形/椭圆选区,松手后旁边出现操作条;Shift+M 切换矩形/椭圆"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="4 3"><rect x="3" y="4" width="18" height="16" rx="1"/></svg></button>
|
||||
<button class="iwb-editor-tool" data-tool="lasso" title="套索 (L):按住拖动自由圈选,松手闭合"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12c0-4 3.6-7 8-7s8 3 8 7-3.6 7-8 7c-2 0-3.8-.6-5.2-1.6"/><path d="M6.8 17.4 4 20l1.2-3.2"/><circle cx="20" cy="19" r="2"/></svg></button>
|
||||
|
||||
<button class="iwb-editor-tool active" data-tool="brush" title="画笔 (B)"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg></button>
|
||||
<button class="iwb-editor-tool active" data-tool="brush" title="画笔 (B):] 增大 / [ 减小笔刷"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg></button>
|
||||
|
||||
<button class="iwb-editor-tool" data-tool="eraser" title="橡皮 (E):擦除当前活跃图层的内容,与画笔共用大小/硬度/透明度"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg></button>
|
||||
<button class="iwb-editor-tool" data-tool="eraser" title="橡皮 (E):] 增大 / [ 减小笔刷;擦除当前活跃图层,与画笔共用大小/硬度/透明度"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg></button>
|
||||
|
||||
<button class="iwb-editor-tool" data-tool="pen" title="钢笔 (P):点击添加节点,双击或 Enter 完成自定义形状"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m12 19 7-7 3 3-7 7-3-3z"/><path d="m18 13-1.5-7.5L2 2l3.5 14.5L13 18l5-5z"/><path d="m2 2 7.586 7.586"/><circle cx="11" cy="11" r="2"/></svg></button>
|
||||
|
||||
|
||||
@@ -1738,6 +1738,16 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
return
|
||||
}
|
||||
|
||||
// PS:] 增大 / [ 减小画笔大小(画笔与橡皮共用,光标环即时反馈)
|
||||
if (!mod && !e.altKey && (e.key === '[' || e.key === ']')) {
|
||||
e.preventDefault()
|
||||
const step = S.brushSize >= 64 ? 8 : S.brushSize >= 24 ? 4 : S.brushSize >= 8 ? 2 : 1
|
||||
S.brushSize = clamp(S.brushSize + (e.key === ']' ? step : -step), 1, 300)
|
||||
syncOptionBar()
|
||||
updateCursor()
|
||||
return
|
||||
}
|
||||
|
||||
// 视图:Ctrl+0 适应窗口 / Ctrl+1 100% / Ctrl+± 缩放(PS 习惯)
|
||||
if (mod && !e.shiftKey && e.key === '0') { e.preventDefault(); setZoomFit(); return }
|
||||
if (mod && !e.shiftKey && e.key === '1') { e.preventDefault(); setZoomActual(); return }
|
||||
|
||||
@@ -347,6 +347,10 @@ export function setActiveLayer(id) {
|
||||
}
|
||||
S.layers.push(layer)
|
||||
reorderLayerCanvas()
|
||||
// 新 canvas 必须立刻套上当前视图的显示尺寸/偏移,否则它会以原始像素尺寸
|
||||
// 贴在 stack 原点 —— 表现就是「第一笔画在错误的位置,滚轮缩放后才正常」
|
||||
// (addBlankLayer 一直有这步,这里漏了。2026-11-04 用户反馈)
|
||||
updateLayerCanvasStyles()
|
||||
setActiveLayer(id)
|
||||
renderLayerPanel()
|
||||
return layer
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
id: 'image-annotate',
|
||||
name: '标注 / 修图',
|
||||
version: '1.2.6',
|
||||
version: '1.2.7',
|
||||
apiVersion: 1,
|
||||
capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'],
|
||||
settings: {
|
||||
@@ -1743,6 +1743,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
};
|
||||
S.layers.push(layer);
|
||||
reorderLayerCanvas();
|
||||
updateLayerCanvasStyles();
|
||||
setActiveLayer(id);
|
||||
renderLayerPanel();
|
||||
return layer;
|
||||
@@ -2677,9 +2678,9 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
<button class="iwb-editor-tool" data-tool="marquee" title="选框 (M):拖出矩形/椭圆选区,松手后旁边出现操作条;Shift+M 切换矩形/椭圆"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="4 3"><rect x="3" y="4" width="18" height="16" rx="1"/></svg></button>
|
||||
<button class="iwb-editor-tool" data-tool="lasso" title="套索 (L):按住拖动自由圈选,松手闭合"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12c0-4 3.6-7 8-7s8 3 8 7-3.6 7-8 7c-2 0-3.8-.6-5.2-1.6"/><path d="M6.8 17.4 4 20l1.2-3.2"/><circle cx="20" cy="19" r="2"/></svg></button>
|
||||
|
||||
<button class="iwb-editor-tool active" data-tool="brush" title="画笔 (B)"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg></button>
|
||||
<button class="iwb-editor-tool active" data-tool="brush" title="画笔 (B):] 增大 / [ 减小笔刷"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg></button>
|
||||
|
||||
<button class="iwb-editor-tool" data-tool="eraser" title="橡皮 (E):擦除当前活跃图层的内容,与画笔共用大小/硬度/透明度"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg></button>
|
||||
<button class="iwb-editor-tool" data-tool="eraser" title="橡皮 (E):] 增大 / [ 减小笔刷;擦除当前活跃图层,与画笔共用大小/硬度/透明度"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg></button>
|
||||
|
||||
<button class="iwb-editor-tool" data-tool="pen" title="钢笔 (P):点击添加节点,双击或 Enter 完成自定义形状"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m12 19 7-7 3 3-7 7-3-3z"/><path d="m18 13-1.5-7.5L2 2l3.5 14.5L13 18l5-5z"/><path d="m2 2 7.586 7.586"/><circle cx="11" cy="11" r="2"/></svg></button>
|
||||
|
||||
@@ -4540,6 +4541,14 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
togglePanelsCollapsed();
|
||||
return;
|
||||
}
|
||||
if (!mod && !e.altKey && (e.key === "[" || e.key === "]")) {
|
||||
e.preventDefault();
|
||||
const step = S.brushSize >= 64 ? 8 : S.brushSize >= 24 ? 4 : S.brushSize >= 8 ? 2 : 1;
|
||||
S.brushSize = clamp(S.brushSize + (e.key === "]" ? step : -step), 1, 300);
|
||||
syncOptionBar();
|
||||
updateCursor();
|
||||
return;
|
||||
}
|
||||
if (mod && !e.shiftKey && e.key === "0") {
|
||||
e.preventDefault();
|
||||
setZoomFit();
|
||||
|
||||
@@ -96,7 +96,7 @@ const boot = await page.evaluate((png) => {
|
||||
window.__commands['annotate-selected'].run().catch(() => {})
|
||||
return { version: window.__manifest.version, settingsSchema: Object.keys(window.__manifest.settings || {}) }
|
||||
}, PNG)
|
||||
check('产物可执行(循环打包未炸)', boot.version === '1.2.6', 'version=' + boot.version)
|
||||
check('产物可执行(循环打包未炸)', boot.version === '1.2.7', 'version=' + boot.version)
|
||||
check('manifest 声明输出预设设置项', boot.settingsSchema.includes('exportPreset') && boot.settingsSchema.includes('panelsCollapsed'), boot.settingsSchema.join(','))
|
||||
|
||||
await page.locator('#iwb-editor-overlay').waitFor({ state: 'visible', timeout: 15000 })
|
||||
@@ -622,6 +622,15 @@ const stampPx = await probe(stampLayerId)
|
||||
const stampBasePx = await probe('base')
|
||||
check('画笔落笔自动落「标注」层且该点有像素', stampPx && stampPx[3] > 0,
|
||||
'layer=' + stampLayerId + ' px=' + JSON.stringify(stampPx))
|
||||
// 回归(2026-11-04 用户反馈):首笔自动建层时新 canvas 没套视图样式,
|
||||
// 以原始像素尺寸贴在 stack 原点 → 第一笔显示错位,滚轮缩放后才正常
|
||||
check('首笔自动建的层立刻获得视图样式(尺寸/偏移与原图层一致,不再裸贴原点)', await page.evaluate((baseId) => {
|
||||
const cs = Array.from(document.querySelectorAll('.iwb-editor-layer-canvas'))
|
||||
const base = cs.find(c => c.style.width && parseFloat(c.style.left) > 0)
|
||||
const fresh = cs[cs.length - 1]
|
||||
return base && fresh && fresh.style.width === base.style.width &&
|
||||
fresh.style.left === base.style.left && fresh.style.top === base.style.top
|
||||
}, stampLayerId))
|
||||
await page.locator('.iwb-editor-tool[data-tool="eraser"]').click()
|
||||
await drag2(liveBox.x + liveBox.width * 0.3, liveBox.y + liveBox.height * 0.5,
|
||||
liveBox.x + liveBox.width * 0.55, liveBox.y + liveBox.height * 0.5)
|
||||
@@ -715,6 +724,15 @@ check('Tab 收起 / 展开侧栏(PS 习惯)', await (async () => {
|
||||
return collapsed === true && restored === false
|
||||
})())
|
||||
|
||||
check('[ / ] 增减画笔大小(PS 习惯,画笔橡皮共用)', await (async () => {
|
||||
await page.keyboard.press(']') // 3 → 5? 起始值不定,只验方向与 clamp
|
||||
const up = (await dbg()).toolOptions.brushSize
|
||||
await page.keyboard.press('[')
|
||||
await page.keyboard.press('[')
|
||||
const down = (await dbg()).toolOptions.brushSize
|
||||
return up > down && down >= 1 && up <= 300
|
||||
})())
|
||||
|
||||
check('Ctrl+1 = 100% 实际像素 / Ctrl+0 = 适应窗口', await (async () => {
|
||||
await page.keyboard.press('Control+1')
|
||||
const d1 = await dbg()
|
||||
|
||||
Reference in new issue
Block a user