fix(image-annotate): v1.2.10 选中形状/文字后切吸管取色能改对象颜色
- 根因:setTool() 切工具时无差别清掉 selectedShapeId/selectedTextId/selectedLayerId, 选中形状按 I 切吸管时选中态当场丢失,applyColorChange 找不到对象,颜色只写进画笔色 - 修复:picker 作为临时工具保留选中态(与 select 同级白名单);exitPicker 按落回的工具用 同一套规则清理,避免画笔工具下残留选中框 - 吸管提示文案补充「选中形状/文字时取色直接改它的颜色」 - __debug().shapes 补 color 字段;harness 新增 1 项回归断言(114 项全绿)
This commit is contained in:
1 parent
9d923aed26
commit
0d161d6ded
7 files changed
+52
-15
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@iwb-plugin/image-annotate",
|
||||
"private": true,
|
||||
"version": "1.2.9",
|
||||
"version": "1.2.10",
|
||||
"description": "IWB 插件:图片标注 / 修图(编辑器移植自 iwb-plaus 扩展,纯 Canvas 2D)",
|
||||
"ibwPlugin": {
|
||||
"id": "image-annotate",
|
||||
|
||||
@@ -145,7 +145,7 @@ import { bindEvents } from './events.js'
|
||||
|
||||
<button class="iwb-editor-tool" data-tool="arrow" title="箭头 (U):Shift+U 在矩形/圆形/箭头间循环"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/></svg></button>
|
||||
|
||||
<button class="iwb-editor-tool" data-tool="picker" title="吸管 (I):点击画布取色(悬停预览),取色后自动切回上一工具"><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="m2 22 1-1h3l9-9"/><path d="M3 21v-3l9-9"/><path d="m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3Z"/></svg></button>
|
||||
<button class="iwb-editor-tool" data-tool="picker" title="吸管 (I):点击画布取色(悬停预览);选中形状/文字时取色直接改它的颜色,取完切回上一工具"><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="m2 22 1-1h3l9-9"/><path d="M3 21v-3l9-9"/><path d="m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3Z"/></svg></button>
|
||||
|
||||
<button class="iwb-editor-tool" data-tool="hand" title="抓手 (H):拖拽自由移动画布(任意工具下按住空格或鼠标中键也可平移)"><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="M18 11V6a2 2 0 0 0-2-2v0a2 2 0 0 0-2 2v0"/><path d="M14 10V4a2 2 0 0 0-2-2v0a2 2 0 0 0-2 2v2"/><path d="M10 10.5V6a2 2 0 0 0-2-2v0a2 2 0 0 0-2 2v8"/><path d="M18 10a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15"/></svg></button>
|
||||
|
||||
|
||||
@@ -810,7 +810,7 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
const OPT_HINTS = {
|
||||
crop: '裁剪栏在画布下方;裁剪与选区互斥,确认后可 Ctrl+Z 撤销',
|
||||
select: '点击选中元素,拖拽移动,手柄缩放',
|
||||
picker: '点击画布取色,取完自动切回上一个工具',
|
||||
picker: '点击画布取色;选中形状/文字时取色直接改它的颜色,取完自动切回上一个工具',
|
||||
hand: '拖拽平移画布;任意工具下按住空格也可以',
|
||||
marquee: '拖出选区 → 操作条就在选区旁边',
|
||||
lasso: '按住拖动画圈,松手闭合'
|
||||
|
||||
@@ -288,7 +288,7 @@ import { toast } from './commands.js'
|
||||
zoom: S.zoom,
|
||||
fit: { w: Math.round(S.fitW || 0), h: Math.round(S.fitH || 0) },
|
||||
layers: S.layers.map(l => ({ id: l.id, name: l.name, z: l.z, locked: !!l.locked, visible: l.visible !== false })),
|
||||
shapes: S.shapeLayers.map(s => ({ id: s.id, type: s.type, lw: s.lw, fill: !!s.fill, closed: !!s.closed, z: s.z })),
|
||||
shapes: S.shapeLayers.map(s => ({ id: s.id, type: s.type, lw: s.lw, fill: !!s.fill, closed: !!s.closed, z: s.z, color: s.color })),
|
||||
texts: S.textLayers.map(t => ({ id: t.id, text: t.text })),
|
||||
selectedShapeId: S.selectedShapeId,
|
||||
selectedTextId: S.selectedTextId,
|
||||
|
||||
@@ -323,6 +323,11 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js'
|
||||
export function exitPicker() {
|
||||
S.tool = (S.prevTool && S.prevTool !== 'picker') ? S.prevTool : 'brush'
|
||||
S.prevTool = null
|
||||
// 回到的若不是选择/形状类工具,选中态按 setTool 同一套规则清掉,避免画布残留选中框
|
||||
const back = S.tool
|
||||
if (back !== 'select') S.selectedLayerId = null
|
||||
if (back !== 'text' && back !== 'select') S.selectedTextId = null
|
||||
if (back !== 'rect' && back !== 'circle' && back !== 'arrow' && back !== 'pen' && back !== 'select') S.selectedShapeId = null
|
||||
S.pickerComposite = null
|
||||
hidePickerTip()
|
||||
updateToolUI()
|
||||
@@ -334,6 +339,7 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js'
|
||||
cancelCrop()
|
||||
hideCropBar()
|
||||
}
|
||||
// 回到上一个工具后选项栏由 updateToolUI() → renderOptionBar() 按新工具重建
|
||||
renderObjects()
|
||||
}
|
||||
|
||||
@@ -370,9 +376,12 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js'
|
||||
S.lassoPts = null
|
||||
}
|
||||
S.tool = tool
|
||||
if (tool !== 'select') S.selectedLayerId = null
|
||||
if (tool !== 'text' && tool !== 'select') S.selectedTextId = null
|
||||
if (tool !== 'rect' && tool !== 'circle' && tool !== 'arrow' && tool !== 'pen' && tool !== 'select') S.selectedShapeId = null
|
||||
// 吸管是临时取色工具:必须保留选中态,否则「选中形状 → 按 I 取色」时选中被清掉,
|
||||
// applyColorChange 找不到对象,颜色只写进画笔色、形状不变(用户反馈 2026-11-04)
|
||||
const keepSel = tool === 'select' || tool === 'picker'
|
||||
if (!keepSel) S.selectedLayerId = null
|
||||
if (tool !== 'text' && !keepSel) S.selectedTextId = null
|
||||
if (tool !== 'rect' && tool !== 'circle' && tool !== 'arrow' && tool !== 'pen' && !keepSel) S.selectedShapeId = null
|
||||
S.bitmapDrag = null
|
||||
S.textDrag = null
|
||||
S.shapeDrag = null
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
id: 'image-annotate',
|
||||
name: '标注 / 修图',
|
||||
version: '1.2.9',
|
||||
version: '1.2.10',
|
||||
apiVersion: 1,
|
||||
capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'],
|
||||
settings: {
|
||||
@@ -711,6 +711,10 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
function exitPicker() {
|
||||
S.tool = S.prevTool && S.prevTool !== "picker" ? S.prevTool : "brush";
|
||||
S.prevTool = null;
|
||||
const back = S.tool;
|
||||
if (back !== "select") S.selectedLayerId = null;
|
||||
if (back !== "text" && back !== "select") S.selectedTextId = null;
|
||||
if (back !== "rect" && back !== "circle" && back !== "arrow" && back !== "pen" && back !== "select") S.selectedShapeId = null;
|
||||
S.pickerComposite = null;
|
||||
hidePickerTip();
|
||||
updateToolUI();
|
||||
@@ -764,9 +768,10 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
S.lassoPts = null;
|
||||
}
|
||||
S.tool = tool;
|
||||
if (tool !== "select") S.selectedLayerId = null;
|
||||
if (tool !== "text" && tool !== "select") S.selectedTextId = null;
|
||||
if (tool !== "rect" && tool !== "circle" && tool !== "arrow" && tool !== "pen" && tool !== "select") S.selectedShapeId = null;
|
||||
const keepSel = tool === "select" || tool === "picker";
|
||||
if (!keepSel) S.selectedLayerId = null;
|
||||
if (tool !== "text" && !keepSel) S.selectedTextId = null;
|
||||
if (tool !== "rect" && tool !== "circle" && tool !== "arrow" && tool !== "pen" && !keepSel) S.selectedShapeId = null;
|
||||
S.bitmapDrag = null;
|
||||
S.textDrag = null;
|
||||
S.shapeDrag = null;
|
||||
@@ -2794,7 +2799,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
|
||||
<button class="iwb-editor-tool" data-tool="arrow" title="箭头 (U):Shift+U 在矩形/圆形/箭头间循环"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/></svg></button>
|
||||
|
||||
<button class="iwb-editor-tool" data-tool="picker" title="吸管 (I):点击画布取色(悬停预览),取色后自动切回上一工具"><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="m2 22 1-1h3l9-9"/><path d="M3 21v-3l9-9"/><path d="m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3Z"/></svg></button>
|
||||
<button class="iwb-editor-tool" data-tool="picker" title="吸管 (I):点击画布取色(悬停预览);选中形状/文字时取色直接改它的颜色,取完切回上一工具"><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="m2 22 1-1h3l9-9"/><path d="M3 21v-3l9-9"/><path d="m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3Z"/></svg></button>
|
||||
|
||||
<button class="iwb-editor-tool" data-tool="hand" title="抓手 (H):拖拽自由移动画布(任意工具下按住空格或鼠标中键也可平移)"><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="M18 11V6a2 2 0 0 0-2-2v0a2 2 0 0 0-2 2v0"/><path d="M14 10V4a2 2 0 0 0-2-2v0a2 2 0 0 0-2 2v2"/><path d="M10 10.5V6a2 2 0 0 0-2-2v0a2 2 0 0 0-2 2v8"/><path d="M18 10a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15"/></svg></button>
|
||||
|
||||
@@ -3663,7 +3668,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
var OPT_HINTS = {
|
||||
crop: "裁剪栏在画布下方;裁剪与选区互斥,确认后可 Ctrl+Z 撤销",
|
||||
select: "点击选中元素,拖拽移动,手柄缩放",
|
||||
picker: "点击画布取色,取完自动切回上一个工具",
|
||||
picker: "点击画布取色;选中形状/文字时取色直接改它的颜色,取完自动切回上一个工具",
|
||||
hand: "拖拽平移画布;任意工具下按住空格也可以",
|
||||
marquee: "拖出选区 → 操作条就在选区旁边",
|
||||
lasso: "按住拖动画圈,松手闭合"
|
||||
@@ -6157,7 +6162,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
zoom: S.zoom,
|
||||
fit: { w: Math.round(S.fitW || 0), h: Math.round(S.fitH || 0) },
|
||||
layers: S.layers.map((l) => ({ id: l.id, name: l.name, z: l.z, locked: !!l.locked, visible: l.visible !== false })),
|
||||
shapes: S.shapeLayers.map((s) => ({ id: s.id, type: s.type, lw: s.lw, fill: !!s.fill, closed: !!s.closed, z: s.z })),
|
||||
shapes: S.shapeLayers.map((s) => ({ id: s.id, type: s.type, lw: s.lw, fill: !!s.fill, closed: !!s.closed, z: s.z, color: s.color })),
|
||||
texts: S.textLayers.map((t) => ({ id: t.id, text: t.text })),
|
||||
selectedShapeId: S.selectedShapeId,
|
||||
selectedTextId: S.selectedTextId,
|
||||
|
||||
@@ -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.9', 'version=' + boot.version)
|
||||
check('产物可执行(循环打包未炸)', boot.version === '1.2.10', '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 })
|
||||
@@ -830,6 +830,29 @@ check('选中钢笔路径就地切「描边」', penSelDbg.shapes[penSelDbg.shap
|
||||
await page.locator('.iwb-editor-optionbar-body [data-opt-toggle="fill"][data-fill-owner="pen"]').click()
|
||||
penSelDbg = await dbg()
|
||||
check('再切回「实心」', penSelDbg.shapes[penSelDbg.shapes.length - 1].fill === true)
|
||||
// 吸管:选中矢量形状后按 I 取色,颜色必须写回对象(2026-11-04 用户反馈:切吸管后颜色只进画笔、形状不变)
|
||||
check('选中矢量形状后切吸管:选中态保留、取色写回形状、取完回到原工具', await (async () => {
|
||||
await page.locator('.iwb-editor-tool[data-tool="select"]').click()
|
||||
const selId = (await dbg()).selectedShapeId
|
||||
if (!selId) return 'pre: 没有选中形状'
|
||||
// 先换成一个可辨识的颜色,便于判断取色真的改了对象
|
||||
await page.locator('.iwb-editor-color-panel-swatch[data-panel-color="#4488ff"]').click()
|
||||
const before = (await dbg()).shapes.find(s => s.id === selId)
|
||||
if (!before || before.color !== '#4488ff') return 'pre: color=' + (before && before.color)
|
||||
await page.keyboard.press('i') // 切吸管
|
||||
const d1 = await dbg()
|
||||
if (d1.tool !== 'picker' || d1.selectedShapeId !== selId) return 'picker: tool=' + d1.tool + ' sel=' + d1.selectedShapeId
|
||||
// 点画面左下角(原图实色区,避开形状本身)
|
||||
await page.mouse.click(liveBox.x + liveBox.width * 0.15, liveBox.y + liveBox.height * 0.85)
|
||||
await page.waitForTimeout(150)
|
||||
const d2 = await dbg()
|
||||
const after = d2.shapes.find(s => s.id === selId)
|
||||
const shapeBar = await page.locator('.iwb-editor-optionbar-body [data-opt-toggle][data-fill-owner="pen"], .iwb-editor-optionbar-body [data-opt-toggle][data-fill-owner="rect"]').count()
|
||||
return d2.tool === 'select' && after && after.color !== '#4488ff' && shapeBar > 0
|
||||
? true
|
||||
: 'post: tool=' + d2.tool + ' color=' + (after && after.color) + ' shapeBar=' + shapeBar
|
||||
})())
|
||||
|
||||
await page.keyboard.press('Control+z') // 撤销最后一次填充
|
||||
await page.keyboard.press('Control+z') // 撤销钢笔路径
|
||||
await page.keyboard.press('Control+z') // 撤销矩形线宽
|
||||
|
||||
Reference in new issue
Block a user