diff --git a/image-annotate/package.json b/image-annotate/package.json
index 7a187bc..bb29bf4 100644
--- a/image-annotate/package.json
+++ b/image-annotate/package.json
@@ -1,7 +1,7 @@
{
"name": "@iwb-plugin/image-annotate",
"private": true,
- "version": "1.2.11",
+ "version": "1.2.12",
"description": "IWB 插件:图片标注 / 修图(编辑器移植自 iwb-plaus 扩展,纯 Canvas 2D)",
"ibwPlugin": {
"id": "image-annotate",
diff --git a/image-annotate/plugin/editor/dom.js b/image-annotate/plugin/editor/dom.js
index 4c6ffcb..fb16c69 100644
--- a/image-annotate/plugin/editor/dom.js
+++ b/image-annotate/plugin/editor/dom.js
@@ -132,9 +132,9 @@ import { bindEvents } from './events.js'
-
+
-
+
diff --git a/image-annotate/plugin/editor/events.js b/image-annotate/plugin/editor/events.js
index 86bd130..b89d5f6 100644
--- a/image-annotate/plugin/editor/events.js
+++ b/image-annotate/plugin/editor/events.js
@@ -9,7 +9,7 @@
import { S, ZOOM_STEP, runtime } from './state.js'
import { ROT_CURSOR, clamp, getPos, isOverRotationHandle, setView, setZoomActual, setZoomFit, zoomStep } from './viewport.js'
import { addBitmapLayer, addBlankLayer, applyBitmapDrag, beginBitmapDrag, clearSelection, deleteLayer, ensureWritableLayer, getActiveCtx, getActiveLayer, hitBitmapHandle, removeVecCanvas, renderLayerPanel } from './layers.js'
-import { applyColorChange, beginStroke, clearToolRing, drawToolRing, endStroke, eraseSegment, exitPicker, hidePickerTip, sampleColor, setTool, showPickerTip, strokeSegment } from './tools.js'
+import { applyColorChange, beginAltPicker, beginStroke, clearToolRing, drawToolRing, endAltPicker, endStroke, eraseSegment, exitPicker, hidePickerTip, sampleColor, setTool, showPickerTip, strokeSegment } from './tools.js'
import { beginMarquee, updateMarquee, endMarquee, beginLasso, updateLasso, endLasso, clearMarquee, syncAnts, renderSelection } from './selection.js'
import { runCommand, toast } from './commands.js'
import { showSelectionContext, hideSelectionContext } from './floating.js'
@@ -1475,6 +1475,8 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
if (S.spaceDown) { S.spaceDown = false; updateCursor() }
if (S.panning) { S.panning = false; S.panStart = null; updateCursor() }
S._shiftDown = false
+ // Alt 的 keyup 可能落在窗口外,兜底结束临时吸管,避免工具卡在 picker
+ endAltPicker()
})
// 阻止 modal 内部点击冒泡
@@ -1687,6 +1689,12 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
if (e.key === 'Escape') { e.preventDefault(); cancelImagePlacement(); return }
}
if (e.key === 'Shift') S._shiftDown = true
+ // PS:画笔 / 橡皮下按住 Alt 临时吸管(点击取色,松开 Alt 回到原工具)
+ if (e.key === 'Alt' && !e.ctrlKey && !e.metaKey) {
+ e.preventDefault() // 防 Windows 浏览器把单独 Alt 当作菜单栏激活
+ beginAltPicker()
+ return
+ }
if (e.key === 'Enter' && S.tool === 'pen' && S.penPath) { e.preventDefault(); commitPenPath(); return }
// 裁剪:Enter 确认 / Esc 取消(用户裁定,替代浮窗上的两个按钮 —— 按钮也保留在选项栏)
if (e.key === 'Enter' && S.tool === 'crop' && S.cropRect) { e.preventDefault(); confirmCrop(); return }
@@ -1857,6 +1865,8 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
function onKeyup(e) {
if (e.key === 'Shift') S._shiftDown = false
+ // PS:松开 Alt 结束临时吸管,回到画笔 / 橡皮
+ if (e.key === 'Alt') endAltPicker()
if (e.code === 'Space' && S.spaceDown) {
S.spaceDown = false
updateCursor()
diff --git a/image-annotate/plugin/editor/index.js b/image-annotate/plugin/editor/index.js
index 0c1dfa7..28ee454 100644
--- a/image-annotate/plugin/editor/index.js
+++ b/image-annotate/plugin/editor/index.js
@@ -284,6 +284,8 @@ import { toast } from './commands.js'
const __debug = () => ({
open: S.open,
tool: S.tool,
+ color: S.color,
+ altPicker: !!S.altPicker,
doc: { w: S.imgW, h: S.imgH },
zoom: S.zoom,
fit: { w: Math.round(S.fitW || 0), h: Math.round(S.fitH || 0) },
diff --git a/image-annotate/plugin/editor/state.js b/image-annotate/plugin/editor/state.js
index 8d04c23..45743fc 100644
--- a/image-annotate/plugin/editor/state.js
+++ b/image-annotate/plugin/editor/state.js
@@ -20,6 +20,7 @@
brushHardness: 100, // 画笔硬度 0~100:100=硬边描边,<100=径向渐变软边章
brushOpacity: 1, // 画笔透明度 0.05~1(一笔整体透明度,笔划内不叠加)
prevTool: null, // 吸管工具激活前的工具(取色后切回)
+ altPicker: false, // 按住 Alt 的临时吸管(画笔/橡皮下),松开 Alt 回到原工具
pickerComposite: null, // 吸管取样用的合成画布缓存(切工具/画布变化时失效)
rectFill: false, // 矩形/圆形是否实心填充
penFill: true, // 钢笔闭合路径是否实心填充(只对闭合路径有意义)
diff --git a/image-annotate/plugin/editor/tools.js b/image-annotate/plugin/editor/tools.js
index 94cf6d4..70ef64e 100644
--- a/image-annotate/plugin/editor/tools.js
+++ b/image-annotate/plugin/editor/tools.js
@@ -321,6 +321,13 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js'
/** 取色完成:切回吸管激活前的工具 */
export function exitPicker() {
+ // 按住 Alt 的临时吸管:取色后不退出(PS 手感:Alt 按住期间可连续吸色),
+ // 由 keyup / 窗口失焦时的 endAltPicker() 统一收尾回到原工具
+ if (S.altPicker) {
+ S.pickerComposite = null
+ hidePickerTip()
+ return
+ }
S.tool = (S.prevTool && S.prevTool !== 'picker') ? S.prevTool : 'brush'
S.prevTool = null
// 回到的若不是选择/形状类工具,选中态按 setTool 同一套规则清掉,避免画布残留选中框
@@ -343,8 +350,27 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js'
renderObjects()
}
- /** 统一颜色应用:设置当前色 + 同步选中文字/形状颜色 */
- export function applyColorChange(color) {
+ /**
+ * PS 手感:画笔 / 橡皮下按住 Alt 临时变成吸管,松开 Alt 回到原工具。
+ * 只在这两个绘制工具下生效;正在描笔时(isDrawing)不打断。
+ * 取色后不退出吸管(见 exitPicker 的 altPicker 分支),可以按住 Alt 连续吸色。
+ */
+ export function beginAltPicker() {
+ if (S.altPicker) return
+ if (S.tool !== 'brush' && S.tool !== 'eraser') return
+ if (S.isDrawing) return
+ S.altPicker = true
+ setTool('picker') // setTool 会把原工具存进 prevTool,松开 Alt 时用它还原
+ }
+
+ /** 松开 Alt / 窗口失焦:结束临时吸管并回到原工具 */
+ export function endAltPicker() {
+ if (!S.altPicker) return
+ S.altPicker = false
+ exitPicker()
+ }
+
+ /** 统一颜色应用:设置当前色 + 同步选中文字/形状颜色 */ export function applyColorChange(color) {
S.color = color
updateColorUI()
const t = getSelectedText()
@@ -365,6 +391,8 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js'
export function setTool(tool) {
if (S.placingImage) cancelImagePlacement()
commitTextInput()
+ // 用户主动切到别的工具 = 放弃「按住 Alt 临时吸管」,否则松 Alt 会把工具抢回去
+ if (tool !== 'picker') S.altPicker = false
if (tool !== 'select' && tool !== 'pen') { S.penEditId = null; S.penDragPt = -1; S.penDragPending = null }
if (tool === 'picker' && S.tool !== 'picker') S.prevTool = S.tool
if (tool !== 'pen') S.penPath = null
diff --git a/image-annotate/src/index.js b/image-annotate/src/index.js
index 4899217..30331b3 100644
--- a/image-annotate/src/index.js
+++ b/image-annotate/src/index.js
@@ -9,7 +9,7 @@
var __IWB_ANNOTATE_MANIFEST__ = {
id: 'image-annotate',
name: '标注 / 修图',
- version: '1.2.11',
+ version: '1.2.12',
apiVersion: 1,
capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'],
settings: {
@@ -39,6 +39,8 @@ var __IWB_ANNOTATE_MANIFEST__ = {
// 画笔透明度 0.05~1(一笔整体透明度,笔划内不叠加)
prevTool: null,
// 吸管工具激活前的工具(取色后切回)
+ altPicker: false,
+ // 按住 Alt 的临时吸管(画笔/橡皮下),松开 Alt 回到原工具
pickerComposite: null,
// 吸管取样用的合成画布缓存(切工具/画布变化时失效)
rectFill: false,
@@ -709,6 +711,11 @@ var __IWB_ANNOTATE_MANIFEST__ = {
if (tip) tip.style.display = "none";
}
function exitPicker() {
+ if (S.altPicker) {
+ S.pickerComposite = null;
+ hidePickerTip();
+ return;
+ }
S.tool = S.prevTool && S.prevTool !== "picker" ? S.prevTool : "brush";
S.prevTool = null;
const back = S.tool;
@@ -728,6 +735,18 @@ var __IWB_ANNOTATE_MANIFEST__ = {
}
renderObjects();
}
+ function beginAltPicker() {
+ if (S.altPicker) return;
+ if (S.tool !== "brush" && S.tool !== "eraser") return;
+ if (S.isDrawing) return;
+ S.altPicker = true;
+ setTool("picker");
+ }
+ function endAltPicker() {
+ if (!S.altPicker) return;
+ S.altPicker = false;
+ exitPicker();
+ }
function applyColorChange(color) {
S.color = color;
updateColorUI();
@@ -747,6 +766,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
function setTool(tool) {
if (S.placingImage) cancelImagePlacement();
commitTextInput();
+ if (tool !== "picker") S.altPicker = false;
if (tool !== "select" && tool !== "pen") {
S.penEditId = null;
S.penDragPt = -1;
@@ -2786,9 +2806,9 @@ var __IWB_ANNOTATE_MANIFEST__ = {
-
+
-
+
@@ -4278,6 +4298,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
updateCursor();
}
S._shiftDown = false;
+ endAltPicker();
});
bindIf(".iwb-editor-modal", "mousedown", (e) => e.stopPropagation());
}
@@ -4488,6 +4509,11 @@ var __IWB_ANNOTATE_MANIFEST__ = {
}
}
if (e.key === "Shift") S._shiftDown = true;
+ if (e.key === "Alt" && !e.ctrlKey && !e.metaKey) {
+ e.preventDefault();
+ beginAltPicker();
+ return;
+ }
if (e.key === "Enter" && S.tool === "pen" && S.penPath) {
e.preventDefault();
commitPenPath();
@@ -4711,6 +4737,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
}
function onKeyup(e) {
if (e.key === "Shift") S._shiftDown = false;
+ if (e.key === "Alt") endAltPicker();
if (e.code === "Space" && S.spaceDown) {
S.spaceDown = false;
updateCursor();
@@ -6185,6 +6212,8 @@ var __IWB_ANNOTATE_MANIFEST__ = {
var __debug = () => ({
open: S.open,
tool: S.tool,
+ color: S.color,
+ altPicker: !!S.altPicker,
doc: { w: S.imgW, h: S.imgH },
zoom: S.zoom,
fit: { w: Math.round(S.fitW || 0), h: Math.round(S.fitH || 0) },
diff --git a/image-annotate/tools/harness.mjs b/image-annotate/tools/harness.mjs
index 1edf4a4..af082ae 100644
--- a/image-annotate/tools/harness.mjs
+++ b/image-annotate/tools/harness.mjs
@@ -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.11', 'version=' + boot.version)
+check('产物可执行(循环打包未炸)', boot.version === '1.2.12', '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 })
@@ -904,6 +904,28 @@ check('画笔选项栏:推荐大小只留 4 个快捷点,硬度补 5 个快
return ok
})())
+// 按住 Alt 临时吸色(PS 手感):画笔下按住 Alt → 吸管 → 取色 → 松开回画笔
+check('画笔按住 Alt 临时吸色,松开 Alt 回到画笔(可连续取色)', await (async () => {
+ await page.locator('.iwb-editor-tool[data-tool="brush"]').click()
+ const color0 = (await dbg()).color
+ await page.keyboard.down('Alt')
+ const d1 = await dbg()
+ if (d1.tool !== 'picker' || !d1.altPicker) return 'down: tool=' + d1.tool + ' alt=' + d1.altPicker
+ // 取色:点画面右下角(实色区)
+ await page.mouse.click(liveBox.x + liveBox.width * 0.8, liveBox.y + liveBox.height * 0.85)
+ await page.waitForTimeout(120)
+ const d2 = await dbg()
+ // 取色后仍停在吸管(Alt 还按着),颜色已变
+ if (d2.tool !== 'picker') return 'pick: tool=' + d2.tool
+ if (d2.color === color0) return 'pick: color 未变 ' + d2.color
+ await page.keyboard.up('Alt')
+ await page.waitForTimeout(180)
+ const d3 = await dbg()
+ return d3.tool === 'brush' && !d3.altPicker
+ ? true
+ : 'up: tool=' + d3.tool + ' alt=' + d3.altPicker
+})())
+
// Shift+X:选中形状切 描边/实心(PS 风格,用户裁定 2026-11-04 晚)
// 图层快捷键:Ctrl+]/[ 上/下移、Ctrl+Shift+]/[ 置顶/置底、Alt+]/[ 选层、Delete 删图层
@@ -952,10 +974,12 @@ check('图层 PS 快捷键:Alt+[/] 向下/向上选择图层', await (async ()
})())
check('Delete 删除选中的位图图层(PS 习惯)', await (async () => {
- const before = (await dbg()).layers.length
+ const d0 = await dbg()
+ const before = d0.layers.length
await page.keyboard.press('Delete')
const d = await dbg()
- return d.layers.length === before - 1 && d.selectedLayerId === null
+ if (d.layers.length !== before - 1) return 'layers ' + before + '→' + d.layers.length + ' sel=' + d0.selectedLayerId + ' selShape=' + d0.selectedShapeId + ' tool=' + d0.tool + ' toast=' + await page.locator('.iwb-editor-toast').textContent()
+ return d.selectedLayerId === null ? true : 'sel 未清空: ' + d.selectedLayerId
})())
check('无选中时 Ctrl+] 有 toast 提示(不再无声失败)', await (async () => {