feat(image-annotate): 1.2.2 手柄仅选择工具/高亮跟随绘制目标/选项栏快捷点与裁剪参数/Enter-Esc 裁剪

This commit is contained in:
qiqi committed 2026-11-04 20:30:49 +08:00
1 parent 1bf8220c05
commit f50b734fd7
11 files changed
+340 -164

No files matched your search

+4 -2
View File
@@ -205,7 +205,9 @@ check('v1.1 框选 + 浮动操作条出现', Boolean(v11sel && v11sel.w > 5 && v
await page.locator('.iwb-editor-sel-bar').isVisible(), JSON.stringify(v11sel))
const v11px = (x, y) => page.evaluate(({ px, py }) => {
const d = window.__iwbEditor.__debug()
return { base: d.pixel('base', px, py), draw: d.pixel('draw', px, py) }
// 1.2.1 起默认没有 id='draw' 的预建层:填充落进「当前活动层」,
// 所以这里读活动层像素而不是写死 'draw'
return { base: d.pixel('base', px, py), draw: d.pixel(d.activeLayerId, px, py), activeId: d.activeLayerId }
}, { px: x, py: y })
const vcX = Math.round(v11sel.x + v11sel.w / 2)
const vcY = Math.round(v11sel.y + v11sel.h / 2)
@@ -219,7 +221,7 @@ check('v1.1 Delete 只清当前层(base 像素原样)',
await page.keyboard.press('Control+z')
const v11layersBeforeReset = (await dbg()).layers.length
await page.locator('[data-action="reset"]').click()
check('v1.1 还原原图=只剩原图+画笔层,不留下空白层', (await dbg()).layers.length === 2, JSON.stringify((await dbg()).layers))
check('v1.1 还原原图=只剩原图单层(1.2.1 起不预建画笔层)', (await dbg()).layers.length === 1, JSON.stringify((await dbg()).layers))
await page.keyboard.press('Control+z')
check('v1.1 还原原图可 Ctrl+Z 撤销', (await dbg()).layers.length === v11layersBeforeReset,
'层数 ' + v11layersBeforeReset + ' → 2 → ' + (await dbg()).layers.length)
+74 -6
View File
@@ -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.1', 'version=' + boot.version)
check('产物可执行(循环打包未炸)', boot.version === '1.2.2', '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 })
@@ -286,12 +286,14 @@ await page.locator('[data-action="toggleExportSettings"]').click() // 收起,
// ---------- 选区与裁剪互斥 ----------
await page.locator('.iwb-editor-tool[data-tool="crop"]').click()
check('切到裁剪会清掉选区', !(await dbg()).selection)
check('切到裁剪会清掉选区,裁剪参数出现在选项栏(不再有画布下方浮窗)',
!(await dbg()).selection &&
(await page.locator('.iwb-editor-optionbar-body [data-action="confirmCrop"]').count()) === 1 &&
(await page.locator('.iwb-editor-optionbar-body [data-ratio="1:1"]').count()) === 1 &&
(await page.locator('.iwb-editor-crop-bar').count()) === 0)
await page.locator('.iwb-editor-tool[data-tool="marquee"]').click()
check('切回选区会取消裁剪框', await page.evaluate(() => {
const bar = document.querySelector('.iwb-editor-crop-bar')
return bar && getComputedStyle(bar).display === 'none'
}))
check('切回选区:裁剪控件从选项栏消失、裁剪框取消',
await page.evaluate(() => !document.querySelector('[data-action="confirmCrop"]')))
// ---------- 回归:矢量对象经撤销/重做后仍可渲染(快照不得把 DOM 画布序列化成 {}) ----------
await page.locator('.iwb-editor-tool[data-tool="rect"]').click()
@@ -530,6 +532,72 @@ check('参数数字框里按 Ctrl+A 仍能全选(不再被当打字吞掉)',
JSON.stringify(selAfterCtrlA.selection))
await page.keyboard.press('Control+d')
// ---- v1.2.2:手柄只在选择工具出现 / 高亮跟随绘制目标 / 选项栏快捷点 / 侧栏实心移除 ----
// 侧栏「实心」按钮移除(选项栏 rect 工具已有描边/实心切换)
check('侧栏「实心」按钮已移除(选项栏承担该功能)',
(await page.locator('[data-action="toggleFill"]').count()) === 0)
// 快捷点:画笔大小
await page.locator('.iwb-editor-tool[data-tool="brush"]').click()
check('画笔选项栏有 7 个大小快捷点',
(await page.locator('.iwb-editor-optionbar-body [data-opt-preset="brushSize"]').count()) === 7)
await page.locator('.iwb-editor-optionbar-body [data-opt-preset="brushSize"][data-value="12"]').click()
check('点快捷点 12:笔刷大小即时生效且侧栏滑杆同步',
(await dbg()).toolOptions.brushSize === 12 &&
await page.evaluate(() => Number(document.querySelector('.iwb-editor-brush-size').value) === 12))
// 快捷点:矢量描边
await page.locator('.iwb-editor-tool[data-tool="arrow"]').click()
check('箭头选项栏有 7 个线宽快捷点',
(await page.locator('.iwb-editor-optionbar-body [data-opt-preset="shapeLineWidth"]').count()) === 7)
await page.locator('.iwb-editor-optionbar-body [data-opt-preset="shapeLineWidth"][data-value="6"]').click()
check('点线宽快捷点 6:shapeLineWidth 即时生效',
(await dbg()).toolOptions.shapeLineWidth === 6)
// 高亮跟随绘制目标:画一笔后面板选中层 == 画笔目标层
await page.locator('.iwb-editor-tool[data-tool="brush"]').click()
await drag2(liveBox.x + liveBox.width * 0.55, liveBox.y + liveBox.height * 0.75,
liveBox.x + liveBox.width * 0.65, liveBox.y + liveBox.height * 0.85)
const syncDbg = await dbg()
check('画笔落笔后面板高亮层 == 绘制目标层(不再「没选中却能画」)',
syncDbg.selectedLayerId === syncDbg.activeLayerId,
'selected=' + syncDbg.selectedLayerId + ' active=' + syncDbg.activeLayerId)
// 变换手柄只在 select 工具出现:画笔态 overlay 无手柄像素,切到选择工具后出现
const overlayAlpha = () => page.evaluate(() => {
const c = document.querySelector('.iwb-editor-crop-overlay')
if (!c) return -1
const cx = c.getContext('2d')
const d = cx.getImageData(0, 0, c.width, c.height).data
let n = 0
for (let i = 3; i < d.length; i += 4) if (d[i] > 0) n++
return n
})
check('画笔工具下选中层不画变换手柄(overlay 干净)', (await overlayAlpha()) === 0)
await page.locator('.iwb-editor-tool[data-tool="select"]').click()
check('切到选择工具后变换框/手柄出现(overlay 有像素)', (await overlayAlpha()) > 0)
await page.keyboard.press('Escape') // 清选中,避免影响后续
// 裁剪:Esc 取消 / Enter 确认
await page.locator('.iwb-editor-tool[data-tool="crop"]').click()
await drag2(liveBox.x + liveBox.width * 0.15, liveBox.y + liveBox.height * 0.15,
liveBox.x + liveBox.width * 0.6, liveBox.y + liveBox.height * 0.6)
check('拉出裁剪框后选项栏显示尺寸摘要',
(await page.locator('.iwb-editor-optionbar-body .iwb-editor-crop-info').textContent()) !== '--')
await page.keyboard.press('Escape')
check('Esc 取消裁剪(摘要复位为 --)',
(await page.locator('.iwb-editor-optionbar-body .iwb-editor-crop-info').textContent()) === '--')
await drag2(liveBox.x + liveBox.width * 0.15, liveBox.y + liveBox.height * 0.15,
liveBox.x + liveBox.width * 0.6, liveBox.y + liveBox.height * 0.6)
const docBeforeEnter = (await dbg()).doc
await page.keyboard.press('Enter')
const docAfterEnter = (await dbg()).doc
check('Enter 确认裁剪(画布尺寸变小、与按钮确认等效)',
docAfterEnter.w < docBeforeEnter.w && docAfterEnter.h < docBeforeEnter.h,
JSON.stringify(docBeforeEnter) + ' → ' + JSON.stringify(docAfterEnter))
await page.keyboard.press('Control+z')
// ---- Fix4:点「退出」必须结算宿主 Promise(glue.openEditor → onClose) ----
await page.locator('[data-action="cancel"]').click()
const openState = await poll(async () => page.evaluate(() => window.__openState))