diff --git a/image-annotate/README.md b/image-annotate/README.md index 684e5f1..2e86a8d 100644 --- a/image-annotate/README.md +++ b/image-annotate/README.md @@ -2,7 +2,7 @@ 在宿主里选中一个带图的节点,打开**全屏单张图片编辑器**:画笔 / 矩形 / 箭头 / 文字 / 橡皮 / 吸管 / 抓手 / 裁剪, 外加 **v1.1 的框选与套索选区**(复制/剪切到新层、清除、填充、反选、羽化、选区旁浮动操作条)、 -图层、撤销重做、缩放平移;一次只处理一张、一次只输出一个结果(覆盖原节点 / 新建节点 / 下载)。 +图层(多选 / 向下合并 / 合并可见 / 排序 / 显隐 / 锁定)、撤销重做、缩放平移;一次只处理一张、一次只输出一个结果(覆盖原节点 / 新建节点 / 下载)。 编辑器**最初移植自** `iwb-plaus` 仓库的 `iwb-cutout-extension`(纯 Canvas 2D、零第三方库): - 源:`/Users/qiqi/open/github/iwb-plaus/iwb-cutout-extension/src/editor/`(11 个模块)+ `src/shared/{image-math,layer-logic}.js` @@ -80,6 +80,160 @@ - **裁剪参数迁入选项栏**:比例/尺寸约束、尺寸摘要、确认/取消按钮全部在裁剪工具的选项栏里, 画布下方浮窗删除;**Enter 确认、Esc 取消**(按钮保留)。旧直连绑定改为选项栏委托,重渲染不丢事件。 +## v1.3:色板进工具栏 + 矢量/文字工具只负责「创建」 + +两条都是用户裁定(2026-11-05):色板要顺手、矢量工具要能叠着画。 + +### 色板搬进工具栏弹层 + +侧栏的 `.iwb-editor-color-panel` 整块删除,工具栏最左新增「当前色圆点」(`data-action="toggleColorPop"`)。 +点开是一个横排弹层:`[SV 180×104 + 色相条] | [吸管 + #hex] | [6×2 推荐色]`。 + +- **弹层必须挂在 `.iwb-editor-modal` 下**,不能塞进 `.iwb-editor-tools`:工具栏是 + `overflow-x: auto; overflow-y: hidden`,`.iwb-editor-canvas-wrap` 是 `overflow: clip`, + 放里面会被直接裁掉(踩过)。定位由 `positionColorPop()` 用「按钮矩形 − modal 矩形」现算, + 上方放不下翻到下方,左右夹在 modal 内 —— 这样宿主页面有 transform 也不会错位。 +- 关闭:再点色点 / 点外面(document 捕获阶段,画布 `preventDefault` 让冒泡收不到)/ Esc + (`closeColorPop()` 排在 Esc 链路最前,是真正的「先收浮层」)。 +- 侧栏此时只剩缩放。**下一步可选**:把缩放搬进状态栏、整个删掉右侧栏,画布能多 220px + (要连带改 `panels-collapsed` 与 `computeFit`,本轮没做)。v1.4 在侧栏补了「快速效果」, + 这条「整个删掉」的选项作废,除非把效果挪到别处。 + +两个连带修的旧 bug(都不是这次才存在,是搬过来后变明显): + +1. **拖调色器会爆撤销栈**:`applyColorChange` 每改一次颜色都 `saveSnapshot()`,SV 拖一下 + 就是几百张全画质 `ImageData`。现在 pointerdown 拍一次(此时颜色还没变),拖动期间走 + `applyColorChange(color, { skipHistory: true })`。测试断言「历史只 +1」。 +2. **色相状态会过期**:取色器的 h/s/v 是 `bindColorPanel` 的闭包变量,而推荐色/hex/吸管 + 只改 `S.color`。以前点绿色再拖 SV 会跳回红色。现在每次 `pointerdown` 从 `S.color` + 重新同步一次;灰阶(`d=0`,如 `#000`)反推不出色相,沿用旧色相。 + +### 矢量/文字工具不再具备选择功能 + +`onShapeMouseDown` 以前先 `hitShapeHandle`(拖手柄)、再 `hitShapeLayer` 并拖动同类型形状, +只有点空白才起笔 —— 于是「在已有矩形上面按住」永远被当成拖旧矩形,没法叠着画。 + +现在规则统一:**选中只属于 V(选择工具)与临时吸管**。 + +- `onShapeMouseDown` / `onTextMouseDown` 只负责起笔,不再命中已有对象; +- `setTool` / `exitPicker` 的 `keepSel` 只剩 `select | picker`,切到 矩形/圆形/箭头/钢笔/文字 + 就清掉三个选中 id; +- `onShapeDrawUp`、`commitPenPath` 不再自动选中新对象(否则矢量工具下会冒出选中框与手柄, + 但手柄点不动,自相矛盾)。 + +连带效果:画完图形不会自动选中,选项栏里的线宽/描边是「下一个图形的默认值」; +要改刚画的就按 V 点它。钢笔的节点编辑入口保留双击(V 或 P 下都能进)。 + +## v1.4:侧栏「快速效果」 + +用户 2026-11-05 提出「侧栏加个快速效果栏,先要反白」,并授权补齐其它常用效果。 +侧栏顶部是一块 3×2 的效果面板(`plugin/editor/effects.js`),底部仍是缩放条。 + +**「反白」= 反相(Invert),不是排版意义的黑底白字标签。** 白底变黑底、黑字变白字, +用于快速出一版深色图。如果要做「文字反白标签」,那是标注样式,属于另一个入口。 + +| 键 | 名称 | 实现 | +| --- | --- | --- | +| `invert` | 反白 | `filter: invert(1)` | +| `gray` | 灰度 | `filter: grayscale(1)` | +| `boost` | 增强 | `brightness(1.12) contrast(1.1) saturate(1.06)` | +| `contrast` | 高对比 | `grayscale(1) contrast(2.4)` | +| `soft` | 柔化 | `blur(半径)`,半径 = 短边/500 并夹在 0.8~8px | +| `mosaic` | 马赛克 | 缩到 1/block 再关平滑放大,block = 短边/60(最小 6px) | + +实现上的三条约束: + +1. **目标只有一个:当前位图图层。** 侧栏标题右侧的标签实时显示层名(`renderLayerPanel` + 顺带刷新)。无活跃层时退回「原图」。矢量层(文字/形状)不参与 —— 反白一张图不应该 + 顺手改掉标注颜色。 +2. **不碰图层几何,也不改 `image`。** 全部在图层自己的 canvas 上做重绘; + `ctx.setTransform(1,0,0,1,0,0)` + `globalCompositeOperation = 'copy'`, + 否则会带上视图变换、或者留下旧内容。 +3. **撤销靠快照。** `applyQuickEffect` 先 `saveSnapshot()`。`base` 与画笔层走 + `restorePath = 'pixels'`,`putImageData` 直接回退;**导入图片层**走 `image/sourceCanvas` + 重绘,原地改像素会被下一次重绘冲掉,所以先按 PS「栅格化」的做法拷一个普通位图副本 + (名字 `xxx · 效果`,z 取「原层 → 上一层」的中点),原层 `visible = false` 而不删除。 + Ctrl+Z 时副本被快照机制移除、原层恢复可见(`layerOrder` 里存了 visible),实测来回都干净。 + +未做的:**有选区时只作用于选区**。当前一律整层处理,弹层提示写的也是「作用于当前层」。 + +## v1.5:画完自动回 V,编辑统一走 V + +用户 2026-11-05 测试后提出:**图形/文字画完应该自动退出当前工具、切到 V**,否则每次画完还要手动按一次 V 才能调。 +同一轮追加裁定:**钢笔的节点编辑也只用 V 双击**,P 下不再给入口。 + +### 画完即回 V 并选中 + +| 工具 | 落成点 | 收尾 | +| --- | --- | --- | +| 矩形 / 圆形 / 箭头 | `onShapeDrawUp` | 切 V + 选中新形状 | +| 钢笔 | `commitPenPath` | 同上 | +| 文字 | `commitTextInput` | 切 V + 选中新文字 | + +统一走 `finishCreateTool()`(events.js):**先 `setTool('select')` 再 `selectUnit`** —— 反过来 +会被 `setTool` 里「非 V/吸管就清选中」的规则立刻清掉。尺寸不达标(点一下没拉出形状)不切, +路径点数不足不切,空文字不切。 + +连带代价:连续画多个同类图形,每次都要重新点工具(用户选择「画完即退出」的必然结果)。 + +文字这条要绕开 `setTool` 第一行的 `commitTextInput()`(同步调用会自我递归),所以用 +`queueMicrotask` 延后一个微任务再切;延后期间若又弹出了新的输入框(在 T 下连续点着输入), +就放弃这次切换,不抢工具。 + +### 双击判定改成自己算 + +`dblclick` 在画布上**不可靠**:单击选中会重绘矢量画布,浏览器有时干脆不派发 `dblclick` +(无头环境 100% 复现,`page.mouse.dblclick` 也拿不到事件),此前的「V 双击钢笔进节点编辑」 +其实一直是坏的,只是没有用例覆盖。 + +现在改为 `isDoubleClick()`:同一位置 **380ms 内两次 mousedown**,命中后清空记录(三连击不重复触发)。 +切工具时清 `S.lastClick`,避免跨工具拿上一次点击配对。 + +双击语义(只属于 V,`onCanvasDoubleClick`): + +1. 正在编辑钢笔 → 双击节点 = 删节点(点数不足则删整个形状); +2. 未编辑 → 双击钢笔形状 = 进节点编辑; +3. 双击文字 = 改内容。 + +P 下双击 = 结束当前路径(`commitPenPath`),不再进节点编辑。 + +另外 `setTool` 里 `penEditId` 的清理条件从「非 select 且非 pen」收紧为「非 select」—— +从 V 带着编辑态切到 P 会留下「钢笔下能拖节点但点不动」的半状态。 + +## v1.6:笔刷环即时反馈 + 图层合并 + +用户 2026-11-05 提出两件事:按 `[` / `]` 调笔刷大小时圆环不跟着变(要动一下鼠标才刷新); +图层需要像 PS 一样支持「选多层合并」和「合并已有图层」。 + +### 笔刷环不再等 mousemove + +`drawToolRing` 原先只在 `mousemove` 里调用,所以键盘改大小后环还是旧尺寸。 +现在把「最后一次悬停点」记进 `S.hoverPos`,并导出 `refreshBrushRing()`:大小变化 +(`[` / `]`、选项栏滑杆 / 数字 / 快捷点、图层面板线宽)与工具切换都按这个点立刻重画。 +鼠标离开画布时清空 `hoverPos`,避免把环画到旧位置。 + +### 图层合并(PS 语义) + +| 操作 | 入口 | 行为 | +| --- | --- | --- | +| 向下合并 | `Ctrl/⌘+E`、标题栏「合并」按钮 | 当前层合进下一层,结果继承下层名字与位置 | +| 合并选中 | ⌘/Ctrl 点击图层多选后同上 | 合并多选集合;隐藏层跳过并保留 | +| 合并可见 | `Ctrl/⌘+Shift+E`、标题栏第二个按钮 | 所有可见层合成一层,隐藏层不动 | + +多选:图层项上 **⌘(macOS)/ Ctrl(Windows)点击** 加入或移出集合,青色高亮与单选的橙色侧条区分; +第一次加选会把当前单选层一起纳入。点击画布、切换单选、撤销都会退出多选。 + +实现要点(`layers.js` 的 `mergeUnits`): + +- **有「原图」参与时写回 base 本身**:base 的快照走 `pixels` 路径,撤销能逐像素恢复, + 且「还原原图」始终有锚点。 +- **否则新建一张普通位图层承载**:导入图片层走 `image` 重绘路径,原地改像素后再清掉 `image`, + 撤销时 `restorePath` 会按「像素」去读一份根本没拍的快照(history.js 注释里记过这个坑)。 +- 合成规则与导出 / 吸管共用(同一套 `layerUnits()` z 序与 `opacity` alpha), + 「合并后看到的」等于「导出得到的」。 +- 文字 / 形状 / 钢笔会被直接栅格化进结果层(PS 合并矢量层也是这个结果)。 +- 结果层落回「原最低参与层」的位置,`assignLayerZ` 重新连续编号,不产生重复 z。 + ## 入口 - **节点漂浮菜单**「标注 / 修图」(**仅 `ref` 图片输入节点**) diff --git a/image-annotate/package.json b/image-annotate/package.json index bb29bf4..a1b59a9 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.12", + "version": "1.6.0", "description": "IWB 插件:图片标注 / 修图(编辑器移植自 iwb-plaus 扩展,纯 Canvas 2D)", "ibwPlugin": { "id": "image-annotate", diff --git a/image-annotate/plugin/editor.css b/image-annotate/plugin/editor.css index 59ef562..ac0b543 100755 --- a/image-annotate/plugin/editor.css +++ b/image-annotate/plugin/editor.css @@ -1608,3 +1608,132 @@ /* 标题与会话组之间、撤销组与命令带之间的竖分隔 */ .iwb-editor-header > .iwb-editor-session { margin-right: 4px; } .iwb-editor-header > .iwb-editor-divider { width: 1px; height: 20px; background: #313244; flex: 0 0 auto; margin: 0 4px; } + +/* ================================================================ + v1.3:色板搬进工具栏(用户裁定 2026-11-05) + 工具栏最左一个「当前色圆点」,点开在工具栏上方弹出色板: + [SV + 色相] | [吸管 + hex] | [6×2 推荐色] + 弹层挂在 modal 下(不是工具栏里):工具栏 overflow-x:auto、 + canvas-wrap overflow:clip,放里面必被裁;位置由 events.js 按按钮矩形算。 + ================================================================ */ +.iwb-editor-modal { position: relative; } + +.iwb-editor-canvas-wrap > .iwb-editor-tools .iwb-editor-color-btn { + width: 32px; height: 32px; min-width: 32px; flex: 0 0 auto; padding: 0; + border: 0; border-radius: 9px; background: #313244; cursor: pointer; + display: inline-flex; align-items: center; justify-content: center; +} +.iwb-editor-canvas-wrap > .iwb-editor-tools .iwb-editor-color-btn:hover, +.iwb-editor-canvas-wrap > .iwb-editor-tools .iwb-editor-color-btn.active { background: #45475a; } +.iwb-editor-color-btn i { + width: 18px; height: 18px; border-radius: 50%; display: block; background: #ff4444; + box-shadow: 0 0 0 2px #181825, 0 0 0 3px #585b70; +} + +.iwb-editor-color-pop { + position: absolute; z-index: 60; display: flex; align-items: center; gap: 10px; + padding: 10px 12px; border-radius: 12px; + background: rgba(24, 24, 37, 0.97); border: 1px solid #313244; + box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55); + -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); +} +.iwb-editor-color-pop[hidden] { display: none; } +.iwb-color-pop-picker { display: flex; gap: 8px; flex: 0 0 auto; } +.iwb-editor-color-pop .iwb-color-sv { width: 180px; height: 104px; flex: 0 0 180px; } +.iwb-editor-color-pop .iwb-color-hue { width: 16px; height: 104px; flex: 0 0 16px; } +.iwb-color-pop-sep { width: 1px; align-self: stretch; background: #313244; flex: 0 0 auto; } +.iwb-color-pop-fields { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; } +.iwb-editor-color-pop .iwb-editor-color-hex-input { + width: 86px; height: 28px; padding: 0 6px; text-align: center; + font: 600 12px monospace; border-radius: 6px; box-sizing: border-box; +} +.iwb-editor-color-pop .iwb-editor-color-swatches { + display: grid; grid-template-columns: repeat(6, 22px); grid-auto-rows: 22px; + gap: 7px; flex: 0 0 auto; align-content: center; +} +.iwb-editor-color-pop .iwb-editor-color-panel-swatch { + width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; + transition: transform 0.08s ease; +} +.iwb-editor-color-pop .iwb-editor-color-panel-swatch:hover { transform: scale(1.12); } +.iwb-editor-color-pop .iwb-editor-color-panel-swatch.active { + outline: 2px solid #fff; outline-offset: 2px; +} +.iwb-editor-color-pop .iwb-editor-color-eye { width: 28px; height: 28px; border-radius: 6px; } + +/* ================================================================ + v1.4:侧栏「快速效果」 + 3×2 网格,作用于当前位图图层。只做颜色/采样变换,不改几何。 + 图标全部用 CSS 渐变画(不引第三方库,也不加 SVG 体积)。 + ================================================================ */ +.iwb-editor-fx { + display: flex; flex-direction: column; gap: 8px; + flex: 0 0 auto; +} +.iwb-editor-fx-head { + display: flex; align-items: center; justify-content: space-between; gap: 6px; +} +.iwb-editor-fx-title { + font-size: 11px; font-weight: 600; letter-spacing: 0.4px; color: #a6adc8; +} +.iwb-editor-fx-target { + max-width: 116px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; + padding: 2px 6px; border-radius: 5px; background: #313244; color: #cdd6f4; + font-size: 10px; line-height: 1.4; +} +.iwb-editor-fx-grid { + display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; +} +.iwb-editor-fx-btn { + display: flex; flex-direction: column; align-items: center; gap: 5px; + padding: 7px 2px 6px; border: 1px solid transparent; border-radius: 9px; + background: #232334; color: #cdd6f4; + font: 500 10.5px/1 -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; + cursor: pointer; transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease; +} +.iwb-editor-fx-btn:hover { background: #313244; border-color: #45475a; } +.iwb-editor-fx-btn:active { transform: scale(0.96); } +.iwb-editor-fx-btn:focus-visible { outline: 2px solid #89b4fa; outline-offset: 1px; } +.iwb-editor-fx-ico { + width: 22px; height: 22px; border-radius: 5px; display: block; + background-color: #d9d9e3; + box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2); +} +/* 图标统一垫浅色底:纯黑部分若直接压在深色按钮上会「消失」,看着像缺了个角 */ +.ico-invert { background-image: linear-gradient(135deg, transparent 0 50%, #14141f 50% 100%); } +.ico-gray { background-image: linear-gradient(90deg, #12121c 0, #8a8a99 50%, #f4f4f8 100%); } +.ico-boost { + background-image: radial-gradient(circle at 50% 52%, #ffffff 0 24%, #cfcfdd 42%, #6e6e85 100%); +} +.ico-contrast { background-image: linear-gradient(90deg, #000000 0 46%, #ffffff 54% 100%); } +.ico-soft { + background-image: radial-gradient(circle at 50% 50%, #23233a 0 16%, rgba(35, 35, 58, 0.5) 34%, rgba(35, 35, 58, 0.16) 50%, rgba(35, 35, 58, 0) 68%); +} +.ico-mosaic { + background-image: repeating-conic-gradient(#6b6b80 0% 25%, #d9d9e3 0% 50%); + background-size: 10px 10px; +} +.iwb-editor-fx-tip { + margin: 0; font-size: 10px; line-height: 1.55; color: #6c7086; +} + +/* ================================================================ + v1.6:图层面板多选(⌘/Ctrl 点击)+ 合并按钮 + 多选用青色侧条与单选(橙色 #e8a735)区分:一个图层可以「被选中但不在合并集合里」, + 两套状态不能长得一样。 + ================================================================ */ +.iwb-layer-item.multi { + background: rgba(137, 180, 250, 0.14); + box-shadow: inset 2px 0 0 #89b4fa; +} +.iwb-layer-item.multi.active { + background: rgba(137, 180, 250, 0.2); + box-shadow: inset 2px 0 0 #89b4fa, inset 0 0 0 1px rgba(137, 180, 250, 0.45); +} +.iwb-editor-layer-add-group { flex: 0 0 auto; flex-wrap: nowrap; } +.iwb-editor-layer-add-btn[data-action="mergeLayers"]:hover, +.iwb-editor-layer-add-btn[data-action="mergeVisible"]:hover { + background: #45475a; + border-color: #89b4fa; + color: #cdd6f4; +} diff --git a/image-annotate/plugin/editor/dom.js b/image-annotate/plugin/editor/dom.js index fb16c69..29078ae 100644 --- a/image-annotate/plugin/editor/dom.js +++ b/image-annotate/plugin/editor/dom.js @@ -94,6 +94,8 @@ import { bindEvents } from './events.js' 图层
+ +
@@ -126,6 +128,9 @@ import { bindEvents } from './events.js'
+ + + @@ -160,10 +165,39 @@ import { bindEvents } from './events.js'
滚轮缩放 · 抓手/空格/中键拖拽自由移动画布
` diff --git a/image-annotate/plugin/editor/effects.js b/image-annotate/plugin/editor/effects.js new file mode 100644 index 0000000..ca4bae8 --- /dev/null +++ b/image-annotate/plugin/editor/effects.js @@ -0,0 +1,161 @@ +/* effects.js - 侧栏「快速效果」(v1.4) + * + * 作用对象只有一个:当前位图图层(侧栏标题后面实时显示层名)。 + * 全部走 canvas 2D 的 ctx.filter / 缩放重采样,不引入依赖、不动矢量层、 + * 不改图层几何,因此对「原图」这种带 locked 标记的层也安全(效果不是画笔)。 + * + * 撤销:应用前 saveSnapshot()。base 与画笔层走像素快照(putImageData), + * 天然可回退;导入图片层走 image/sourceCanvas 重绘,原地改像素会被下一次 + * 重绘冲掉,所以先按 PS「栅格化」的做法落一个普通位图副本(原层隐藏)。 + */ + +'use strict' + +import { S } from './state.js' +import { saveSnapshot } from './history.js' +import { createLayerCanvas, getActiveLayer, renderLayerPanel, reorderLayerCanvas, updateLayerCanvasStyles } from './layers.js' +import { layerUnits } from './objects.js' +import { needsPixelSnapshot } from '../vendor/layer-logic.js' +import { toast } from './commands.js' + + /** 效果表:label 用于按钮与提示,css 可依赖画布尺寸(柔化半径随图缩放) */ + export const QUICK_EFFECTS = { + invert: { label: '反白', hint: '反相:明暗翻转,白底变黑底', css: () => 'invert(1)' }, + gray: { label: '灰度', hint: '去色,保留明暗层次', css: () => 'grayscale(1)' }, + boost: { label: '增强', hint: '提亮并略加对比', css: () => 'brightness(1.12) contrast(1.1) saturate(1.06)' }, + contrast: { label: '高对比', hint: '压成黑白硬调', css: () => 'grayscale(1) contrast(2.4)' }, + soft: { label: '柔化', hint: '轻微模糊,弱化背景', css: (c) => 'blur(' + softRadius(c) + 'px)' }, + mosaic: { label: '马赛克', hint: '像素化,用于打码', pixel: true } + } + + const SOFT_MIN = 0.8 + const SOFT_MAX = 8 + function softRadius(canvas) { + const side = Math.min(canvas.width || 0, canvas.height || 0) + return Math.max(SOFT_MIN, Math.min(SOFT_MAX, Math.round(side / 500 * 10) / 10)) + } + function mosaicBlock(canvas) { + const side = Math.min(canvas.width || 0, canvas.height || 0) + return Math.max(6, Math.round(side / 60)) + } + + /** 效果目标:当前活跃位图图层;没有就退回「原图」 */ + export function effectTarget() { + const active = getActiveLayer() + if (active) return active + return S.layers.find(l => l.id === 'base') || null + } + + /** 用 ctx.filter 把画布自身重绘一遍(临时画布中转,避免自绘自的采样问题) */ + function filterCanvas(canvas, css) { + const w = canvas.width, h = canvas.height + if (!w || !h || !css) return + const tmp = document.createElement('canvas') + tmp.width = w + tmp.height = h + const tctx = tmp.getContext('2d') + tctx.filter = css + tctx.drawImage(canvas, 0, 0) + + const ctx = canvas.getContext('2d') + ctx.save() + // 图层 ctx 平时带着视图变换,重绘必须回到设备像素坐标系 + ctx.setTransform(1, 0, 0, 1, 0, 0) + ctx.globalAlpha = 1 + ctx.globalCompositeOperation = 'copy' // copy:连透明像素一起替换,不留旧内容 + ctx.filter = 'none' + ctx.drawImage(tmp, 0, 0) + ctx.restore() + } + + /** 马赛克:缩到 1/block 再关掉平滑放大,比逐像素 getImageData 快一个量级 */ + function pixelateCanvas(canvas, block) { + const w = canvas.width, h = canvas.height + if (!w || !h) return + const sw = Math.max(1, Math.round(w / block)) + const sh = Math.max(1, Math.round(h / block)) + const tmp = document.createElement('canvas') + tmp.width = sw + tmp.height = sh + const tctx = tmp.getContext('2d') + tctx.imageSmoothingEnabled = true + tctx.drawImage(canvas, 0, 0, sw, sh) + + const ctx = canvas.getContext('2d') + ctx.save() + ctx.setTransform(1, 0, 0, 1, 0, 0) + ctx.globalAlpha = 1 + ctx.globalCompositeOperation = 'copy' + ctx.imageSmoothingEnabled = false + ctx.filter = 'none' + ctx.drawImage(tmp, 0, 0, w, h) + ctx.restore() + } + + /** + * 把「导入图片层」栅格化成普通位图,插在它上面一层。 + * 只拷当前 canvas 的可见结果(已含旋转/缩放),所以视觉不变。 + * 原层隐藏而不删除:撤销时快照里有它的 visible,能原样恢复。 + */ + function rasterizeLayer(layer) { + const canvas = createLayerCanvas() + const ctx = canvas.getContext('2d', { willReadFrequently: true }) + ctx.clearRect(0, 0, S.imgW, S.imgH) + ctx.drawImage(layer.canvas, 0, 0) + + // z 取「原层 → 上一层」的中点,保证副本紧贴在原层上方,不会窜到别的标注之上 + const units = layerUnits() + const i = units.findIndex(u => u.kind === 'bitmap' && u.obj === layer) + const baseZ = layer.z || 0 + const nextZ = (i >= 0 && units[i + 1]) ? (units[i + 1].obj.z || 0) : baseZ + 1 + const z = nextZ > baseZ ? (baseZ + nextZ) / 2 : baseZ + 0.5 + + const clone = { + id: 'fx' + Date.now() + Math.floor(Math.random() * 1000), + name: layer.name + ' · 效果', + canvas, + ctx, + opacity: layer.opacity == null ? 1 : layer.opacity, + visible: true, + locked: false, + x: 0, y: 0, w: S.imgW, h: S.imgH, + rotation: 0, + z + } + S.layers.push(clone) + layer.visible = false + if (S.selectedLayerId === layer.id) S.selectedLayerId = clone.id + S.activeLayerId = clone.id + reorderLayerCanvas() + updateLayerCanvasStyles() + renderLayerPanel() + return clone + } + + /** 唯一入口:应用一个快速效果 */ + export function applyQuickEffect(key) { + const fx = QUICK_EFFECTS[key] + if (!fx) return false + const layer = effectTarget() + if (!layer) { toast('没有可处理的图层'); return false } + if (layer.visible === false) { + toast('「' + layer.name + '」已隐藏,先显示再应用效果') + return false + } + + saveSnapshot('效果:' + fx.label) + + let target = layer + if (!needsPixelSnapshot(layer)) target = rasterizeLayer(layer) + if (!target) { toast('栅格化失败,效果未应用'); return false } + + if (fx.pixel) pixelateCanvas(target.canvas, mosaicBlock(target.canvas)) + else filterCanvas(target.canvas, fx.css(target.canvas)) + + target._bounds = undefined + S.pickerComposite = null + if (S.renderAll) S.renderAll() + renderLayerPanel() + toast('已应用「' + fx.label + '」到 ' + target.name + ' · Ctrl+Z 撤销', 'success') + return true + } diff --git a/image-annotate/plugin/editor/events.js b/image-annotate/plugin/editor/events.js index b89d5f6..82bfee6 100644 --- a/image-annotate/plugin/editor/events.js +++ b/image-annotate/plugin/editor/events.js @@ -8,7 +8,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 { addBitmapLayer, addBlankLayer, applyBitmapDrag, beginBitmapDrag, clearSelection, deleteLayer, ensureWritableLayer, getActiveCtx, getActiveLayer, hitBitmapHandle, mergeLayers, mergeVisibleLayers, removeVecCanvas, renderLayerPanel } from './layers.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' @@ -19,6 +19,7 @@ import { cancelImagePlacement, confirmImagePlacement, drawPlacementPreview, hitP import { close, exportResult } from './index.js' import { loadImage } from './dom.js' import { pushHistory, redo, resetDraw, restoreOriginal, restoreAll, saveSnapshot, snapshotState, undo } from './history.js' +import { applyQuickEffect } from './effects.js' import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' @@ -58,19 +59,86 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' S.startX = pos.x S.startY = pos.y hideSelectionContext() + // 点画布视为离开图层面板:退出「合并多选」,免得下次 Ctrl+E 合到看不见的旧集合上 + if (S.layerMulti.length) { S.layerMulti.length = 0; renderLayerPanel() } // 选区工具:拉框 / 套索期间独占交互,不与选择/绘制/裁剪分支纠缠 if (S.tool === 'marquee') { beginMarquee(pos); return } if (S.tool === 'lasso') { beginLasso(pos); return } - // 钢笔节点编辑优先:点节点/点边直接接管;点空白退出编辑后继续走下方工具逻辑 - if ((S.tool === 'select' || S.tool === 'pen')) { + // 双击:V 下进对象编辑(钢笔节点 / 文字内容),P 下结束当前路径。 + // 自己判而不听 dblclick 事件 —— 画布上选中态重绘会让浏览器换掉命中元素, + // 实测 dblclick 根本不派发(无头环境 100% 复现),而 mousedown 一定有。 + const dbl = isDoubleClick(pos) + if (S.tool === 'select') { + if (dbl && onCanvasDoubleClick(e, pos)) return + // 钢笔节点编辑优先(只属于 V,v1.5):点节点/点边直接接管;点空白退出编辑后继续走下方工具逻辑 const penShape = getPenEditingShape() if (penShape && onPenEditMouseDown(e, pos, penShape)) return } + if (S.tool === 'pen' && dbl) { commitPenPath(); return } const handler = Object.prototype.hasOwnProperty.call(MOUSE_DOWN_HANDLERS, S.tool) ? MOUSE_DOWN_HANDLERS[S.tool] : null - if (handler) handler(pos) + if (handler) handler(pos, e) + } + + /** + * 自算双击:同一位置 380ms 内两次 mousedown。 + * 命中一次后清空记录,三连击不会重复触发。 + */ + const DBL_INTERVAL = 380 + function isDoubleClick(pos) { + const now = (typeof performance !== 'undefined' && performance.now) ? performance.now() : Date.now() + const last = S.lastClick + const hit = !!last && (now - last.t) < DBL_INTERVAL && + Math.hypot(pos.x - last.x, pos.y - last.y) < Math.max(8 / S.zoom, 6) + S.lastClick = hit ? null : { t: now, x: pos.x, y: pos.y } + return hit + } + + /** + * 双击语义(只属于 V,v1.5 用户裁定): + * 编辑中的钢笔删节点 > 未编辑的钢笔进节点编辑 > 文字进内容编辑。 + * 返回 true 表示已接管,不再走单击逻辑。 + */ + function onCanvasDoubleClick(e, pos) { + const penShape = getPenEditingShape() + if (penShape) { + const pi = hitPenPoint(pos, penShape, Math.max(14 / S.zoom, 8)) + if (pi < 0) return false + e.preventDefault() + saveSnapshot() + const pts = penShape.pts + const minPts = penShape.closed ? 3 : 2 + if (pts.length <= minPts) { + removeVecCanvas(penShape) + S.shapeLayers = S.shapeLayers.filter(x => x.id !== penShape.id) + S.penEditId = null + S.selectedShapeId = null + } else { + pts.splice(pi, 1) + if (penShape.closed && pts.length < 3) penShape.closed = false + } + renderObjects() + renderLayerPanel() + return true + } + const hitPen = hitShapeLayer(pos, true) + if (hitPen && hitPen.type === 'pen') { + e.preventDefault() + beginPenEdit(hitPen) + return true + } + const hitText = hitTextLayer(pos) + if (hitText) { + e.preventDefault() + selectUnit('text', hitText.id) + if (hitText.locked) return true + renderObjects() + showTextInput(hitText.x, hitText.y, hitText) + return true + } + return false } /** 图片放置模式的按下:命中手柄/图内开始拖拽,点外部确认放置 */ @@ -175,27 +243,14 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' S.isDrawing = true } - /** 文字工具的按下:手柄 > 命中已有文字 > 在点击处新建文字 */ + /** 文字工具的按下:只负责「在点击处新建文字」。 + * v1.3(用户裁定 2026-11-05):与矢量工具同一套规则 —— 点已有文字不再选中/移动它, + * 否则想在文字上叠一段新文字时会被当成拖旧文字。选中/移动/缩放交给 V; + * 改内容 = V 下双击(T 下双击沿用旧行为,仍可直接改)。 */ function onTextMouseDown(pos) { if (commitTextInput()) return - const handle = hitTextHandle(pos) - if (handle) { if (handle === 'rotate') beginTextRotate(pos); else beginTextScaleDrag(handle, pos); return } - const hit = hitTextLayer(pos) - if (hit) { - selectUnit('text', hit.id) - if (hit.locked) { renderObjects(); renderLayerPanel(); return } - S.textDrag = { - mode: 'move', - start: pos, - layer: { x: hit.x, y: hit.y }, - pending: snapshotState() - } - renderObjects() - renderLayerPanel() - } else { - if (S.selectedTextId) { S.selectedTextId = null; renderObjects(); renderLayerPanel() } - showTextInput(pos.x, pos.y) - } + if (S.selectedTextId) { S.selectedTextId = null; renderObjects(); renderLayerPanel() } + showTextInput(pos.x, pos.y) } /** 吸管工具的按下:取样并应用颜色后退出吸管模式 */ @@ -266,19 +321,11 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' return } - /** 矩形/圆形/箭头的按下:命中同类型形状则拖动,否则开始拉新形状 */ + /** 矩形/圆形/箭头的按下:只负责「起笔新建」。 + * v1.3(用户裁定 2026-11-05):矢量工具不再具备选择功能 —— 以前这里先试手柄、 + * 再命中同类型形状并拖动它,于是在已有矩形上面按下会被当成拖旧矩形, + * 根本没法在它上面继续画。选中/移动/改尺寸统一交给 V(选择工具)。 */ function onShapeMouseDown(pos) { - const handle = hitShapeHandle(pos) - if (handle) { beginShapeHandleDrag(handle, pos); return } - const hitShape = hitShapeLayer(pos, true) - if (hitShape && hitShape.type === S.tool) { - S.selectedShapeId = hitShape.id - if (hitShape.locked) { renderObjects(); renderLayerPanel(); return } - S.shapeDrag = { mode: 'move', start: pos, shape: { ...hitShape }, pending: snapshotState() } - renderObjects() - renderLayerPanel() - return - } if (S.selectedShapeId) { S.selectedShapeId = null; renderObjects(); renderLayerPanel() } S.isDrawing = true } @@ -644,7 +691,7 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' } } - /** 矩形/圆/箭头拉框结束:尺寸达标则落成新形状并选中 */ + /** 矩形/圆/箭头拉框结束:尺寸达标则落成新形状,并回到 V 选中它 */ function onShapeDrawUp(pos) { const len = Math.hypot(pos.x - S.startX, pos.y - S.startY) const ok = S.tool === 'rect' || S.tool === 'circle' @@ -666,12 +713,30 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' z: ++S.zCounter } S.shapeLayers.push(shape) - selectUnit('shape', shape.id) + renderObjects() + renderLayerPanel() + finishCreateTool('shape', shape.id) + return } renderObjects() renderLayerPanel() } + /** + * 创建类工具画完即回 V 并选中新对象(用户 2026-11-05 裁定)。 + * 依据:画完的下一步基本是调位置/颜色/粗细,再手动按一次 V 是多余动作。 + * 顺序必须是「先 setTool('select') 再 selectUnit」—— setTool 里对非选中类工具 + * 会清三个选中 id,反过来选中会被立刻清掉。 + */ + function finishCreateTool(kind, id) { + if (['rect', 'circle', 'arrow', 'pen'].indexOf(S.tool) < 0) return + setTool('select') + if (!id) return + selectUnit(kind, id) + renderObjects() + renderLayerPanel() + } + // ============ 缩放 ============ function onWheel(e) { if (!S.open) return @@ -723,12 +788,26 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' updateStatusbar() } + /** + * 笔刷大小 / 工具变化后立刻按「最后悬停点」重画笔刷环。 + * 不这么做,按 ] / [ 或拖选项栏滑块时只有数值在变,环要等下一次 mousemove 才跟上 + * —— 用户看到的就是「调了大小但光标没变,动一下鼠标才正常」(v1.6 反馈)。 + */ + export function refreshBrushRing() { + if (!S.hoverPos) return + if (S.tool !== 'brush' && S.tool !== 'eraser') return + if (S.isDrawing) return + drawToolRing(S.hoverPos) + } + export function updateCursor() { if (S.panning) { S.drawCanvasCursor('grabbing'); return } if (S.spaceDown) { S.drawCanvasCursor('grab'); return } if (S.tool === 'hand') { S.drawCanvasCursor('grab'); return } if (S.tool === 'brush' || S.tool === 'eraser') { S.drawCanvasCursor('none') + // 切到画笔/橡皮时鼠标可能已经在画布上停着:直接补画一次环,不用等移动 + refreshBrushRing() return } if (S.tool === 'crop' && S.cropRect) { @@ -755,6 +834,9 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' const panelHex = runtime.el.querySelector('.iwb-editor-color-hex') const hexInput = runtime.el.querySelector('.iwb-editor-color-hex-input') if (hexInput && document.activeElement !== hexInput) hexInput.value = S.color.toUpperCase() + // 工具栏色点:色板收起时它就是唯一的颜色指示,必须始终跟随 S.color + const colorDot = runtime.el.querySelector('.iwb-editor-color-btn i') + if (colorDot) colorDot.style.background = S.color runtime.el.querySelectorAll('.iwb-editor-color-panel-swatch').forEach(sw => sw.classList.toggle('active', (sw.dataset.panelColor || '').toLowerCase() === S.color.toLowerCase())) if (panelHex) panelHex.textContent = S.color.toUpperCase() const rgb = hexToRgb(S.color) @@ -1086,6 +1168,7 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' S.brushSize = clamp(safe || 1, 1, 300) updateBrushUI() updateBrushParamUI() + refreshBrushRing() } else if (key === 'brushHardness') { S.brushHardness = clamp(safe, 0, 100) updateBrushParamUI() @@ -1136,6 +1219,13 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' // 选区命令(全选/反选/取消)在「选择」工具的选项栏里,与竖工具条时代一样走根级事件委托: // 三个按钮不切换工具,只调命令层(与快捷键、右键菜单同一条路径)。 root.addEventListener('click', (e) => { + // 快速效果(侧栏):点一下即应用,目标层与撤销由 effects.js 负责 + const fxBtn = e.target.closest('[data-fx]') + if (fxBtn) { + e.stopPropagation() + applyQuickEffect(fxBtn.dataset.fx) + return + } const btn = e.target.closest('[data-more]') if (!btn) return e.stopPropagation() @@ -1281,15 +1371,92 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' }) } - /** 独立颜色面板:hex 输入、面板色块、吸管入口与 SV/HUE 取色区 */ + /** 关闭色板弹层;返回「关之前是开着的」,供 Esc 决定要不要吞掉这次按键 */ + export function closeColorPop() { + const pop = runtime.el && runtime.el.querySelector('.iwb-editor-color-pop') + if (!pop || pop.hidden) return false + pop.hidden = true + const btn = runtime.el.querySelector('[data-action="toggleColorPop"]') + if (btn) { btn.classList.remove('active'); btn.setAttribute('aria-expanded', 'false') } + return true + } + + /** 弹层定位:贴工具栏色点上方、左对齐;上方放不下翻到下方,左右夹在 modal 内。 + * 坐标用「按钮矩形 − modal 矩形」算,弹层是 modal 的绝对定位子节点, + * 这样宿主页面有 transform 时也不会错位。 */ + function positionColorPop() { + const pop = runtime.el && runtime.el.querySelector('.iwb-editor-color-pop') + const btn = runtime.el && runtime.el.querySelector('[data-action="toggleColorPop"]') + const modal = runtime.el && runtime.el.querySelector('.iwb-editor-modal') + if (!pop || !btn || !modal || pop.hidden) return + const mr = modal.getBoundingClientRect() + const br = btn.getBoundingClientRect() + const pr = pop.getBoundingClientRect() + let left = br.left - mr.left - 10 + left = Math.min(Math.max(8, left), Math.max(8, mr.width - pr.width - 8)) + let top = br.top - mr.top - pr.height - 10 + if (top < 8) top = br.bottom - mr.top + 10 + pop.style.left = Math.round(left) + 'px' + pop.style.top = Math.round(top) + 'px' + } + + function toggleColorPop() { + const pop = runtime.el.querySelector('.iwb-editor-color-pop') + const btn = runtime.el.querySelector('[data-action="toggleColorPop"]') + if (!pop || !btn) return + if (pop.hidden) { + pop.hidden = false // 先显示再量:hidden 元素 getBoundingClientRect 全是 0 + btn.classList.add('active') + btn.setAttribute('aria-expanded', 'true') + positionColorPop() + } else { + closeColorPop() + } + } + + /** 色板弹层(v1.3):工具栏色点开关;hex/吸管/推荐色/调色器都在这一个弹层里 */ function bindColorPanel() { + const pop = runtime.el.querySelector('.iwb-editor-color-pop') + const colorBtn = runtime.el.querySelector('[data-action="toggleColorPop"]') + if (colorBtn) { + colorBtn.addEventListener('mousedown', (e) => e.stopPropagation()) + colorBtn.addEventListener('click', (e) => { e.stopPropagation(); toggleColorPop() }) + } + if (pop) { + pop.addEventListener('mousedown', (e) => e.stopPropagation()) + // 点外面关闭:必须用捕获阶段 —— 画布的 mousedown 会 preventDefault, + // 冒泡阶段拿不到「点了外面」这件事。 + document.addEventListener('mousedown', (e) => { + if (!pop.hidden && !pop.contains(e.target) && !(colorBtn && colorBtn.contains(e.target))) closeColorPop() + }, true) + window.addEventListener('resize', positionColorPop) + } + // 独立颜色面板:颜色选择后同步当前工具颜色。 const setPanelColor = (color) => applyColorChange(color) + // 拖动取色期间只拍一次快照:applyColorChange 每改一次颜色都会 saveSnapshot, + // 在 SV 里拖一下会连拍几百张全画质 ImageData(4K 图直接吃掉几百 MB)。 + // pointerdown 先拍(此时颜色还没变,快照是「改之前」),之后每步只改对象。 + let dragSnapped = false + const hasColorTarget = () => { + const t = getSelectedText(), sh = getSelectedShape() + return !!((t && !t.locked) || (sh && !sh.locked)) + } + const setDragColor = (color) => { + if (!dragSnapped) { + if (hasColorTarget()) { saveSnapshot(); dragSnapped = true } + } + applyColorChange(color, { skipHistory: true }) + } const panelHexInput = runtime.el.querySelector('.iwb-editor-color-hex-input') if (panelHexInput) panelHexInput.addEventListener('change', () => { if (/^#[0-9a-f]{6}$/i.test(panelHexInput.value)) setPanelColor(panelHexInput.value) }) runtime.el.querySelectorAll('.iwb-editor-color-panel-swatch').forEach(btn => btn.addEventListener('click', (e) => { e.stopPropagation(); setPanelColor(btn.dataset.panelColor) })) const palettePick = runtime.el.querySelector('[data-action="palettePick"]') - if (palettePick) { palettePick.addEventListener('mousedown', (e) => e.stopPropagation()); palettePick.addEventListener('click', () => setTool('picker')) } + if (palettePick) { + palettePick.addEventListener('mousedown', (e) => e.stopPropagation()) + // 取色要回画布点,弹层必须先收起,否则它会挡住取样点 + palettePick.addEventListener('click', () => { closeColorPop(); setTool('picker') }) + } const sv = runtime.el.querySelector('.iwb-color-sv') const hue = runtime.el.querySelector('.iwb-color-hue') const initHsv = (() => { @@ -1316,10 +1483,34 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' const y = clamp((e.clientY - r.top) / r.height, 0, 1) if (target === hue) hueValue = y * 360 else { satValue = x; valValue = 1 - y } - setPanelColor(hsvToHex(hueValue, satValue, valValue)) + setDragColor(hsvToHex(hueValue, satValue, valValue)) + } + // 推荐色 / hex / 吸管改色时,闭包里的 h/s/v 会过期(v1.3 修:以前点了绿色再拖 SV 会跳回红色)。 + // 每次按下前从 S.color 重新同步;灰阶(d=0,如 #000)反推不出色相,就沿用旧色相。 + const syncFromColor = () => { + const { r, g, b } = hexToRgb(S.color) + const rr = r / 255, gg = g / 255, bb = b / 255 + const max = Math.max(rr, gg, bb), min = Math.min(rr, gg, bb), d = max - min + if (d > 0) { + let h = 0 + if (max === rr) h = 60 * (((gg - bb) / d) % 6) + else if (max === gg) h = 60 * ((bb - rr) / d + 2) + else h = 60 * ((rr - gg) / d + 4) + if (h < 0) h += 360 + hueValue = h + } + satValue = max ? d / max : 0 + valValue = max + } + const beginDrag = (target, e) => { syncFromColor(); dragSnapped = false; pick(target, e) } + if (sv) { + sv.addEventListener('pointerdown', e => { sv.setPointerCapture(e.pointerId); beginDrag(sv, e) }) + sv.addEventListener('pointermove', e => { if (e.buttons) pick(sv, e) }) + } + if (hue) { + hue.addEventListener('pointerdown', e => { beginDrag(hue, e) }) + hue.addEventListener('pointermove', e => { if (e.buttons) pick(hue, e) }) } - if (sv) { sv.addEventListener('pointerdown', e => { sv.setPointerCapture(e.pointerId); pick(sv, e) }); sv.addEventListener('pointermove', e => { if (e.buttons) pick(sv, e) }) } - if (hue) { hue.addEventListener('pointerdown', e => { pick(hue, e) }); hue.addEventListener('pointermove', e => { if (e.buttons) pick(hue, e) }) } } /** 裁剪约束控件已迁入选项栏(bindLiteUI 的点击委托统一处理),旧的直连绑定移除。 */ @@ -1431,6 +1622,18 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' bindAll('[data-action="addBlankLayer"]', 'click', () => { addBlankLayer() }) + + // 图层合并(v1.6):⌘/Ctrl 点击图层多选后可合并;未多选时向下合并 + bindAll('[data-action="mergeLayers"]', 'mousedown', (e) => e.stopPropagation()) + bindAll('[data-action="mergeLayers"]', 'click', () => { + const r = mergeLayers() + toast(r.msg, r.ok ? 'success' : 'warn') + }) + bindAll('[data-action="mergeVisible"]', 'mousedown', (e) => e.stopPropagation()) + bindAll('[data-action="mergeVisible"]', 'click', () => { + const r = mergeVisibleLayers() + toast(r.msg, r.ok ? 'success' : 'warn') + }) } /** 底部动作:关闭 / 作为新节点 / 替换(导出入口) */ @@ -1487,7 +1690,9 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' if (!S.penPath || S.penPath.pts.length < 2) { S.penPath = null; renderObjects(); return } saveSnapshot() const shape = { id: 's' + Date.now() + Math.floor(Math.random() * 1000), type: 'pen', pts: S.penPath.pts.slice(), closed: !!S.penPath.closed, color: S.color, lw: Math.max(1, S.shapeLineWidth), fill: !!S.penFill && !!S.penPath.closed, opacity: 1, visible: true, locked: false, z: ++S.zCounter } - S.shapeLayers.push(shape); selectUnit('shape', shape.id); S.penPath = null; renderObjects(); renderLayerPanel() + // 路径落成即回 V 并选中(v1.5):连续画多条就再按一次 P;节点编辑仍走 V 下双击 + S.shapeLayers.push(shape); S.penPath = null; renderObjects(); renderLayerPanel() + finishCreateTool('shape', shape.id) } /** 将 canvas 鼠标事件绑定到活跃图层 canvas(在 setupCanvas 后调用,仅绑定一次) */ @@ -1506,53 +1711,14 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' }) S.canvasStack.addEventListener('mouseleave', () => { if (S.placingImage) return + // 离开画布:笔刷环清掉,同时忘掉悬停点,免得调大小时把环画到旧位置 + S.hoverPos = null if ((S.tool === 'brush' || S.tool === 'eraser') && !S.isDrawing) clearToolRing() if (S.tool === 'picker') hidePickerTip() }) - // 双击文字 → 重新编辑内容;双击钢笔形状 → 进入节点编辑 - S.canvasStack.addEventListener('dblclick', (e) => { - if (S.placingImage) return - const pos = getPos(e) - if (S.tool === 'pen' && S.penPath) { commitPenPath(); return } - if (S.tool === 'select' || S.tool === 'pen') { - const penShape = getPenEditingShape() - if (penShape) { - // 双击节点 → 删除节点 - const pi = hitPenPoint(pos, penShape, Math.max(14 / S.zoom, 8)) - if (pi >= 0) { - e.preventDefault() - saveSnapshot() - const pts = penShape.pts - const minPts = penShape.closed ? 3 : 2 - if (pts.length <= minPts) { - removeVecCanvas(penShape) - S.shapeLayers = S.shapeLayers.filter(x => x.id !== penShape.id) - S.penEditId = null - S.selectedShapeId = null - } else { - pts.splice(pi, 1) - if (penShape.closed && pts.length < 3) penShape.closed = false - } - renderObjects() - renderLayerPanel() - return - } - return // 正在编辑:避免误触发新建文字 - } - // 未在编辑:双击命中钢笔形状进入编辑 - const hitPen = hitShapeLayer(pos, true) - if (hitPen && hitPen.type === 'pen') { e.preventDefault(); beginPenEdit(hitPen); return } - } - if (S.tool !== 'text' && S.tool !== 'select') return - const hit = hitTextLayer(pos) - if (hit) { - selectUnit('text', hit.id) - if (hit.locked) return - renderObjects() - showTextInput(hit.x, hit.y, hit) - } - }) + // 双击不再挂 dblclick:画布上它不可靠(选中重绘会换掉命中元素,浏览器干脆不派发)。 + // 双击语义统一由 onMouseDown → isDoubleClick / onCanvasDoubleClick 处理,见文件上方。 } // 裁剪手柄 hover 光标 @@ -1590,6 +1756,7 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' S.lastPos = p updateStatusbar() } + S.hoverPos = p if (isOverRotationHandle(p)) { S.drawCanvasCursor(ROT_CURSOR); return } const handler = Object.prototype.hasOwnProperty.call(HOVER_HANDLERS, S.tool) ? HOVER_HANDLERS[S.tool] : null if (handler) handler(p, e) @@ -1700,6 +1867,8 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' if (e.key === 'Enter' && S.tool === 'crop' && S.cropRect) { e.preventDefault(); confirmCrop(); return } if (e.key === 'Escape') { if (isTyping(e)) { hideTextInput(); return } + // 色板弹层先关:它是最上层的浮层,Esc 应该先收它 + if (closeColorPop()) { e.preventDefault(); return } // 裁剪优先:有裁剪框时 Esc 取消裁剪 if (S.tool === 'crop' && S.cropRect) { e.preventDefault(); cancelCrop(); return } // 选区优先:Esc 一步取消,不进菜单 @@ -1769,6 +1938,7 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' S.brushSize = clamp(S.brushSize + (e.key === ']' ? step : -step), 1, 300) syncOptionBar() updateCursor() + refreshBrushRing() return } @@ -1793,6 +1963,14 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' if (mod && key === 'j') { e.preventDefault(); runCommand('sel.copy'); return } if (mod && key === 'x' && S.selection && S.selection.active) { e.preventDefault(); runCommand('sel.cut'); return } + // 图层合并(PS 习惯):Ctrl+E 合并(多选优先,否则向下合并)/ Ctrl+Shift+E 合并可见 + if (mod && key === 'e') { + e.preventDefault() + const r = e.shiftKey ? mergeVisibleLayers() : mergeLayers() + toast(r.msg, r.ok ? 'success' : 'warn') + return + } + // 文件类:Ctrl+Shift+N 新建图层 / Ctrl+O 导入图片 / Ctrl+S 导出下载 if (mod && e.shiftKey && key === 'n') { e.preventDefault() diff --git a/image-annotate/plugin/editor/history.js b/image-annotate/plugin/editor/history.js index e5d8eea..0a6f4e9 100644 --- a/image-annotate/plugin/editor/history.js +++ b/image-annotate/plugin/editor/history.js @@ -251,6 +251,7 @@ import { toast } from './commands.js' S.bitmapDrag = null S.penPath = null S.penEditId = null + S.layerMulti.length = 0 // 撤销不动选区:选区是「视图状态」,不是像素状态,避免 Ctrl+Z 后框消失还要重画 reorderLayerCanvas() updateLayerCanvasStyles() @@ -344,6 +345,7 @@ import { toast } from './commands.js' S.bitmapDrag = null S.penPath = null S.penEditId = null + S.layerMulti.length = 0 S.cropRect = null S.cropHandle = null S.cropMoving = false diff --git a/image-annotate/plugin/editor/index.js b/image-annotate/plugin/editor/index.js index 28ee454..1cb6f48 100644 --- a/image-annotate/plugin/editor/index.js +++ b/image-annotate/plugin/editor/index.js @@ -294,8 +294,10 @@ import { toast } from './commands.js' texts: S.textLayers.map(t => ({ id: t.id, text: t.text })), selectedShapeId: S.selectedShapeId, selectedTextId: S.selectedTextId, + penEditId: S.penEditId, activeLayerId: S.activeLayerId, selectedLayerId: S.selectedLayerId, + layerMulti: S.layerMulti.map(x => x.type + ':' + x.id), selection: selectionInfo(), toolOptions: { brushSize: S.brushSize, @@ -318,6 +320,19 @@ import { toast } from './commands.js' const l = S.layers.find(v => v.id === id) if (!l || !l.ctx) return null try { return Array.from(l.ctx.getImageData(Math.round(x), Math.round(y), 1, 1).data) } catch (e) { return null } + }, + // 区域透明像素统计:断言「合并后两半都有内容」比逐点采样快一个量级 + alphaIn: (id, x0, y0, x1, y1) => { + const l = S.layers.find(v => v.id === id) + if (!l || !l.ctx) return 0 + try { + const w = Math.max(1, Math.round(x1 - x0)) + const h = Math.max(1, Math.round(y1 - y0)) + const d = l.ctx.getImageData(Math.round(x0), Math.round(y0), w, h).data + let n = 0 + for (let i = 3; i < d.length; i += 4) if (d[i] > 0) n++ + return n + } catch (e) { return 0 } } }) diff --git a/image-annotate/plugin/editor/layers.js b/image-annotate/plugin/editor/layers.js index 0c3ef3d..c1a089b 100644 --- a/image-annotate/plugin/editor/layers.js +++ b/image-annotate/plugin/editor/layers.js @@ -13,7 +13,7 @@ import { boxCorners, clamp, drawRotationHandles, hitRotationHandle, rotPt, unrot import { drawShape } from './tools.js' import { saveSnapshot, snapshotState } from './history.js' import { placeImageDirectly } from './placement.js' -import { updateBrushParamUI, updateColorUI } from './events.js' +import { updateBrushParamUI, updateColorUI, refreshBrushRing } from './events.js' import { isDrawableLayer } from '../vendor/layer-logic.js' @@ -505,9 +505,17 @@ export function setActiveLayer(id) { const list = runtime.el.querySelector('.iwb-editor-layer-list') if (!list) return + // 先剔除已不存在的多选项(图层被删 / 已被合并),避免面板留着看不见的选择 + if (S.layerMulti.length) { + const alive = new Set(layerUnits().map(u => u.kind + ':' + u.obj.id)) + S.layerMulti = S.layerMulti.filter(r => alive.has(r.type + ':' + r.id)) + } + // 面板顺序直接取统一 z 序的倒序(与画布叠放完全一致)。 // 旧实现位图用 S.layers 数组序、矢量用 allObjects() 再 sort,z 相同时两者次序相反。 const items = [] + // 多选集合(⌘/Ctrl 点击累积):只影响「合并」目标,不抢单选高亮 + const multiSet = new Set(S.layerMulti.map(x => x.type + ':' + x.id)) for (const { kind, obj } of layerUnitsDesc()) { if (kind === 'bitmap') { items.push({ @@ -516,6 +524,7 @@ export function setActiveLayer(id) { color: obj.color || S.color, lineWidth: obj.lineWidth || S.brushSize, // 高亮只代表「选中」;画笔作用目标独立用 ✎ 标记,避免两个图层同时亮 active: obj.id === S.selectedLayerId, + multi: multiSet.has('bitmap:' + obj.id), paintTarget: obj.id === S.activeLayerId, locked: !!obj.locked, canDelete: S.layers.length > 1 }) @@ -527,6 +536,7 @@ export function setActiveLayer(id) { visible: obj.visible !== false, z: obj.z || 0, color: obj.color || S.color, lineWidth: obj.lw || S.brushSize, active: (kind === 'text' && obj.id === S.selectedTextId) || (kind === 'shape' && obj.id === S.selectedShapeId), + multi: multiSet.has(kind + ':' + obj.id), paintTarget: false, locked: !!obj.locked, canDelete: true }) } @@ -535,6 +545,7 @@ export function setActiveLayer(id) { let html = '' for (const item of items) { const activeClass = item.active ? ' active' : '' + const multiClass = item.multi ? ' multi' : '' const visClass = item.visible ? '' : ' hidden' // SVG 图标 let typeIconSvg = '' @@ -554,7 +565,7 @@ export function setActiveLayer(id) { ? '' : '' const delSvg = '' - html += `
+ html += `
${typeIconSvg} ${item.name}${item.paintTarget ? '✎' : ''} @@ -566,6 +577,17 @@ export function setActiveLayer(id) { } list.innerHTML = html + // 侧栏「快速效果」的目标层名:效果和画笔共用同一个目标层,这里一起刷, + // 免得切层后标签还停在上一个图层名上。 + const fxTarget = runtime.el.querySelector('.iwb-editor-fx-target') + if (fxTarget) { + const active = getActiveLayer() + fxTarget.textContent = active ? active.name : '无图层' + fxTarget.title = active + ? '效果作用于当前位图图层:' + active.name + '(切换图层可改变目标)' + : '当前没有可处理的位图图层' + } + // 绑定图层面板事件 bindLayerPanelEvents() } @@ -615,6 +637,15 @@ export function setActiveLayer(id) { if (e.target.closest('.iwb-layer-vis') || e.target.closest('.iwb-layer-lock') || e.target.closest('.iwb-layer-del')) return const id = item.dataset.layerId const type = item.dataset.layerType + // ⌘/Ctrl 点击:加入/移出合并集合(不改变画笔目标与单选高亮) + if (e.metaKey || e.ctrlKey) { + e.preventDefault() + toggleLayerMulti(type, id) + renderLayerPanel() + return + } + // 普通点击回到单选语义:先把合并集合清掉,避免留下看不见的选择 + if (S.layerMulti.length) S.layerMulti.length = 0 if (type === 'bitmap') { setActiveLayer(id) } else if (type === 'text' || type === 'shape') { @@ -647,7 +678,7 @@ export function setActiveLayer(id) { const type = input.dataset.widthType const value = clamp(parseInt(input.value, 10) || 1, 1, 300) const obj = type === 'bitmap' ? S.layers.find(l => l.id === id) : S.shapeLayers.find(s => s.id === id) - if (obj) { obj.lineWidth = value; if (type === 'shape') obj.lw = value; else S.brushSize = value; renderObjects(); updateBrushParamUI(); renderLayerPanel() } + if (obj) { obj.lineWidth = value; if (type === 'shape') obj.lw = value; else { S.brushSize = value; refreshBrushRing() } renderObjects(); updateBrushParamUI(); renderLayerPanel() } }) }) } @@ -716,3 +747,195 @@ export function setActiveLayer(id) { }) }) } + + // ============ 图层合并(v1.6,用户裁定) ============ + + const multiKey = (type, id) => type + ':' + id + + /** 当前单选的是哪个单元(多选的起点);没有选中返回 null */ + function currentUnitRef() { + if (S.selectedLayerId) return { type: 'bitmap', id: S.selectedLayerId } + if (S.selectedTextId) return { type: 'text', id: S.selectedTextId } + if (S.selectedShapeId) return { type: 'shape', id: S.selectedShapeId } + return null + } + + /** ⌘/Ctrl 点击图层项:加入或移出「合并集合」。 + * 第一次加选时把当前单选层一起纳入,符合「先选一层再按住 ⌘ 加选」的习惯。 */ + export function toggleLayerMulti(type, id) { + const key = multiKey(type, id) + const i = S.layerMulti.findIndex(x => multiKey(x.type, x.id) === key) + if (i >= 0) { S.layerMulti.splice(i, 1); return } + if (!S.layerMulti.length) { + const cur = currentUnitRef() + if (cur && multiKey(cur.type, cur.id) !== key) S.layerMulti.push(cur) + } + S.layerMulti.push({ type, id }) + } + + export function clearLayerMulti() { S.layerMulti.length = 0 } + + /** 把一组单元按 z 从低到高叠进目标位图层的像素。 + * alpha 规则与 getCompositeCanvas(导出/吸管)保持一致,保证「合并后看到的就是导出结果」。 */ + function composeUnitsInto(layer, units) { + const tmp = document.createElement('canvas') + tmp.width = S.imgW + tmp.height = S.imgH + const tctx = tmp.getContext('2d') + for (const u of units) { + const el = u.kind === 'bitmap' ? u.obj.canvas : u.obj._canvas + if (!el || el.nodeType !== 1) continue + tctx.globalAlpha = u.obj.opacity == null ? 1 : u.obj.opacity + tctx.drawImage(el, 0, 0) + } + tctx.globalAlpha = 1 + // 图层 ctx 平时带视图变换,写像素必须回到设备坐标;copy 一并覆盖透明区域 + const ctx = layer.ctx + ctx.save() + ctx.setTransform(1, 0, 0, 1, 0, 0) + ctx.globalAlpha = 1 + ctx.globalCompositeOperation = 'copy' + ctx.filter = 'none' + ctx.drawImage(tmp, 0, 0) + ctx.restore() + } + + /** 删除一个图层单元:位图连 DOM 画布一起释放,矢量移除自己的画布 */ + function dropUnit(u) { + if (u.kind === 'bitmap') { + const i = S.layers.indexOf(u.obj) + if (i >= 0) S.layers.splice(i, 1) + try { + if (u.obj.canvas && u.obj.canvas.parentNode) u.obj.canvas.parentNode.removeChild(u.obj.canvas) + } catch (e) { /* 单个图层释放失败不阻断合并 */ } + } else if (u.kind === 'text') { + S.textLayers = S.textLayers.filter(t => t !== u.obj) + removeVecCanvas(u.obj) + } else if (u.kind === 'shape') { + S.shapeLayers = S.shapeLayers.filter(s => s !== u.obj) + removeVecCanvas(u.obj) + } + } + + /** + * 把若干单元合成一张位图,并删掉参与合并的单元。 + * + * 有「原图(base)」参与时写回 base 本身:base 的快照走 pixels 路径,撤销能原样恢复, + * 而且「还原原图」永远有锚点可回。其余情况新建一张普通位图承载 —— 导入图片层走 + * image 重绘路径,如果原地改像素再清掉 image,撤销时 history 的 restorePath 会按 + * 「像素」去读一份根本没拍的快照(详见 history.js 的注释),像素就丢了。 + */ + function mergeUnits(units) { + const sorted = units.slice().sort((a, b) => (a.obj.z || 0) - (b.obj.z || 0)) + const lowUnit = sorted[0] + const baseUnit = sorted.find(u => u.kind === 'bitmap' && u.obj.id === 'base') + // 结果层要落回「原最低层」的位置:先数清它下面还有几个不参与合并的层 + const all = layerUnits() + const lowIdx = all.findIndex(u => u.obj === lowUnit.obj) + const chosenSet = new Set(sorted.map(u => u.obj)) + const insertAt = all.slice(0, Math.max(lowIdx, 0)).filter(u => !chosenSet.has(u.obj)).length + + let carrier + if (baseUnit) { + carrier = baseUnit.obj + // 合并后它就是纯像素层:断掉 image/sourceCanvas,避免后续按原图重新重绘 + carrier.image = null + carrier.sourceCanvas = null + carrier._srcBox = null + carrier.transformable = false + carrier.x = 0 + carrier.y = 0 + carrier.w = S.imgW + carrier.h = S.imgH + carrier.rotation = 0 + carrier.visible = true + carrier.opacity = 1 + carrier._bounds = undefined + composeUnitsInto(carrier, sorted) + for (const u of sorted) if (u.obj !== carrier) dropUnit(u) + // base 永远压在最底,其余层保持原有相对顺序 + const rest = layerUnits().filter(u => u.obj !== carrier) + rest.unshift({ kind: 'bitmap', obj: carrier }) + assignLayerZ(rest) + } else { + const canvas = createLayerCanvas() + const ctx = canvas.getContext('2d', { willReadFrequently: true }) + carrier = { + id: 'm' + Date.now() + Math.floor(Math.random() * 1000), + name: lowUnit.obj.name || '合并图层', + canvas, + ctx, + opacity: 1, + visible: true, + locked: false, + x: 0, y: 0, w: S.imgW, h: S.imgH, + rotation: 0, + z: lowUnit.obj.z || 0 + } + composeUnitsInto(carrier, sorted) + for (const u of sorted) dropUnit(u) + S.layers.push(carrier) + // carrier 已在 layerUnits() 里,先排掉再按原最低层的位置插回去 —— 否则同一个对象会被计两次 z + const rest = layerUnits().filter(u => u.obj !== carrier) + rest.splice(Math.min(insertAt, rest.length), 0, { kind: 'bitmap', obj: carrier }) + assignLayerZ(rest) + } + + S.activeLayerId = carrier.id + S.selectedLayerId = carrier.id + S.selectedTextId = null + S.selectedShapeId = null + S.textDrag = null + S.shapeDrag = null + S.bitmapDrag = null + S.layerMulti.length = 0 + S.pickerComposite = null + sortLayersByZ() + reorderLayerCanvas() + updateLayerCanvasStyles() + renderObjects() + renderLayerPanel() + if (S.renderAll) S.renderAll() + return carrier + } + + /** + * 合并图层(Ctrl/⌘+E) + * - 图层列表里有 2 个以上多选(⌘/Ctrl 点击)→ 合并这些图层 + * - 否则 → 「向下合并」:当前层合进下面一层,结果继承下层名字与位置 + * 隐藏层不参与合并、原样保留(看不见的内容不该被烘进结果)。 + */ + export function mergeLayers() { + const units = layerUnits() + if (units.length < 2) return { ok: false, msg: '只有一个图层,没有可合并的对象' } + + let chosen + if (S.layerMulti.length >= 2) { + chosen = units.filter(u => S.layerMulti.some(r => r.type === u.kind && r.id === u.obj.id)) + if (chosen.length < 2) return { ok: false, msg: '先选两个以上图层(⌘/Ctrl 点击图层列表)' } + } else { + const cur = currentUnitRef() + const idx = cur ? units.findIndex(u => u.kind === cur.type && u.obj.id === cur.id) : -1 + if (idx < 0) return { ok: false, msg: '先在图层列表里选中一层' } + if (idx === 0) return { ok: false, msg: '已经是最底层,没有可合并的下一层' } + chosen = [units[idx - 1], units[idx]] + if (chosen[1].obj.visible === false) return { ok: false, msg: '当前层已隐藏,先显示再合并' } + if (chosen[0].obj.visible === false) return { ok: false, msg: '下一层已隐藏,先显示再合并' } + } + + const visible = chosen.filter(u => u.obj.visible !== false) + if (visible.length < 2) return { ok: false, msg: '可见图层不足 2 个,没有可合并的内容' } + + saveSnapshot('合并图层') + mergeUnits(visible) + return { ok: true, msg: '已合并 ' + visible.length + ' 个图层 · Ctrl+Z 撤销' } + } + + /** 合并可见图层(Ctrl/⌘+Shift+E):隐藏层保留不动 */ + export function mergeVisibleLayers() { + const visible = layerUnits().filter(u => u.obj.visible !== false) + if (visible.length < 2) return { ok: false, msg: '可见图层不足 2 个,没有可合并的对象' } + saveSnapshot('合并可见图层') + mergeUnits(visible) + return { ok: true, msg: '已合并 ' + visible.length + ' 个可见图层 · Ctrl+Z 撤销' } + } diff --git a/image-annotate/plugin/editor/objects.js b/image-annotate/plugin/editor/objects.js index 19b221a..c1899d1 100644 --- a/image-annotate/plugin/editor/objects.js +++ b/image-annotate/plugin/editor/objects.js @@ -11,7 +11,7 @@ import { boxCorners, clamp, drawRotationHandles, hitRotationHandle, rotPt, unrot import { clearOverlay, drawCropPreview } from './crop.js' import { drawBitmapSelection, drawVectorToCanvas, hitBitmapAt, removeVecCanvas, renderLayerPanel, reorderLayerCanvas } from './layers.js' import { drawPlacementPreview } from './placement.js' -import { drawShape } from './tools.js' +import { drawShape, setTool } from './tools.js' import { saveSnapshot, snapshotState } from './history.js' import { toast } from './commands.js' import { renderOptionBar, updateLayerUI } from './events.js' @@ -170,6 +170,8 @@ import { isDrawableLayer } from '../vendor/layer-logic.js' } /** 选中态唯一入口:四个 id 一起写,杜绝「两个图层同时高亮 / 排序作用错对象」 */ export function selectUnit(kind, id) { + // 单选变了就退出「合并多选」:两套选择同时留着会让面板出现说不清的多个高亮 + S.layerMulti.length = 0 S.selectedLayerId = kind === 'bitmap' ? id : null S.selectedTextId = kind === 'text' ? id : null S.selectedShapeId = kind === 'shape' ? id : null @@ -639,6 +641,22 @@ import { isDrawableLayer } from '../vendor/layer-logic.js' committed = true } hideTextInput() + // 文字落成即回 V 并选中(用户 2026-11-05):输入完下一步通常是挪位置 / 改字号颜色。 + // 必须延后一个微任务 —— setTool 第一行就是 commitTextInput(),同步调用会自我递归。 + // 延后期间若又开了新输入框(在 T 下连续点着输入),就不要把工具抢走。 + if (committed) { + const id = S.selectedTextId + queueMicrotask(() => { + if (S.tool !== 'text') return + const box = runtime.el && runtime.el.querySelector('.iwb-editor-text-input') + if (box && box.style.display !== 'none') return + setTool('select') + if (!id) return + selectUnit('text', id) + renderObjects() + renderLayerPanel() + }) + } return committed } diff --git a/image-annotate/plugin/editor/state.js b/image-annotate/plugin/editor/state.js index 45743fc..8bc30eb 100644 --- a/image-annotate/plugin/editor/state.js +++ b/image-annotate/plugin/editor/state.js @@ -20,6 +20,10 @@ brushHardness: 100, // 画笔硬度 0~100:100=硬边描边,<100=径向渐变软边章 brushOpacity: 1, // 画笔透明度 0.05~1(一笔整体透明度,笔划内不叠加) prevTool: null, // 吸管工具激活前的工具(取色后切回) + // 画布内最后一次悬停点(图片坐标):用 [ ] 调笔刷大小时要按这个点立刻重画笔刷环, + // 否则光标环会停在旧尺寸,直到用户再动一下鼠标才更新(v1.6) + hoverPos: null, + lastClick: null, // 上一次画布按下 {t,x,y}:自算双击用(dblclick 在画布上不可靠) altPicker: false, // 按住 Alt 的临时吸管(画笔/橡皮下),松开 Alt 回到原工具 pickerComposite: null, // 吸管取样用的合成画布缓存(切工具/画布变化时失效) rectFill: false, // 矩形/圆形是否实心填充 @@ -57,6 +61,9 @@ textDrag: null, // { mode:'move'|'scale', start:{x,y}, layer:{x,y}, fontSize, baseX } textEditingId: null, selectedLayerId: null, // 选择工具当前选中的可编辑位图图层 + // 图层多选集合 [{id,type}](v1.6):只为「合并选中图层」服务, + // 不参与单选语义(selectedLayerId / selectedTextId 仍各管各的)。 + layerMulti: [], bitmapDrag: null, // { mode:'move'|'scale', handle, start, layer, pending } // 形状图层(矩形/箭头,独立对象,可选中/移动/调手柄) shapeLayers: [], // [{ id, type:'rect'|'arrow', x1,y1,x2,y2, color, lw, fill, opacity, visible, z }] diff --git a/image-annotate/plugin/editor/tools.js b/image-annotate/plugin/editor/tools.js index 70ef64e..f40c2d4 100644 --- a/image-annotate/plugin/editor/tools.js +++ b/image-annotate/plugin/editor/tools.js @@ -332,9 +332,12 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js' 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 + // 与 setTool 同一套规则(v1.3):只有选择工具保留选中态 + if (back !== 'select') { + S.selectedLayerId = null + S.selectedTextId = null + S.selectedShapeId = null + } S.pickerComposite = null hidePickerTip() updateToolUI() @@ -370,18 +373,22 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js' exitPicker() } - /** 统一颜色应用:设置当前色 + 同步选中文字/形状颜色 */ export function applyColorChange(color) { + /** 统一颜色应用:设置当前色 + 同步选中文字/形状颜色。 + * opts.skipHistory:连续取色(拖 SV/色相条)时由调用方在拖动开始时已拍过快照, + * 这里不再逐步 saveSnapshot —— 否则拖一下就是几百张全画质 ImageData。 */ + export function applyColorChange(color, opts) { + const skipHistory = !!(opts && opts.skipHistory) S.color = color updateColorUI() const t = getSelectedText() if (t && !t.locked && t.color !== S.color) { - saveSnapshot() + if (!skipHistory) saveSnapshot() t.color = S.color renderObjects() } const sh = getSelectedShape() if (sh && !sh.locked && S.tool !== 'text' && sh.color !== S.color) { - saveSnapshot() + if (!skipHistory) saveSnapshot() sh.color = S.color renderObjects() } @@ -393,7 +400,9 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js' commitTextInput() // 用户主动切到别的工具 = 放弃「按住 Alt 临时吸管」,否则松 Alt 会把工具抢回去 if (tool !== 'picker') S.altPicker = false - if (tool !== 'select' && tool !== 'pen') { S.penEditId = null; S.penDragPt = -1; S.penDragPending = null } + // 钢笔节点编辑与文字编辑都只属于 V(v1.5):切到任何创建类工具都退出编辑态, + // 否则从 V 带着 penEditId 切到 P 会出现「钢笔下能拖节点但点不动」的半状态。 + if (tool !== 'select') { 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 // 选区与裁剪互斥:进裁剪必须清掉选区;离开选区工具要丢弃未完成的拉框/套索 @@ -406,14 +415,20 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js' S.tool = tool // 吸管是临时取色工具:必须保留选中态,否则「选中形状 → 按 I 取色」时选中被清掉, // applyColorChange 找不到对象,颜色只写进画笔色、形状不变(用户反馈 2026-11-04) + // 选中态只属于「选择(V)」与临时吸管(v1.3,用户裁定 2026-11-05): + // 矩形/圆形/箭头/钢笔/文字都只负责新建,切过去就清掉选中 —— + // 否则矢量工具下点到已有图形会被当成拖动它,没法在它上面继续画。 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 + if (!keepSel) { + S.selectedLayerId = null + S.selectedTextId = null + S.selectedShapeId = null + } S.bitmapDrag = null S.textDrag = null S.shapeDrag = null S.pickerComposite = null + S.lastClick = null // 切工具即断掉双击序列,避免拿上一个工具的最后一次点击配对 hidePickerTip() updateToolUI() updateBrushParamUI() diff --git a/image-annotate/src/index.js b/image-annotate/src/index.js index 30331b3..4453f4e 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.12', + version: '1.6.0', apiVersion: 1, capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'], settings: { @@ -39,6 +39,11 @@ var __IWB_ANNOTATE_MANIFEST__ = { // 画笔透明度 0.05~1(一笔整体透明度,笔划内不叠加) prevTool: null, // 吸管工具激活前的工具(取色后切回) + // 画布内最后一次悬停点(图片坐标):用 [ ] 调笔刷大小时要按这个点立刻重画笔刷环, + // 否则光标环会停在旧尺寸,直到用户再动一下鼠标才更新(v1.6) + hoverPos: null, + lastClick: null, + // 上一次画布按下 {t,x,y}:自算双击用(dblclick 在画布上不可靠) altPicker: false, // 按住 Alt 的临时吸管(画笔/橡皮下),松开 Alt 回到原工具 pickerComposite: null, @@ -88,6 +93,9 @@ var __IWB_ANNOTATE_MANIFEST__ = { textEditingId: null, selectedLayerId: null, // 选择工具当前选中的可编辑位图图层 + // 图层多选集合 [{id,type}](v1.6):只为「合并选中图层」服务, + // 不参与单选语义(selectedLayerId / selectedTextId 仍各管各的)。 + layerMulti: [], bitmapDrag: null, // { mode:'move'|'scale', handle, start, layer, pending } // 形状图层(矩形/箭头,独立对象,可选中/移动/调手柄) @@ -719,9 +727,11 @@ var __IWB_ANNOTATE_MANIFEST__ = { 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; + if (back !== "select") { + S.selectedLayerId = null; + S.selectedTextId = null; + S.selectedShapeId = null; + } S.pickerComposite = null; hidePickerTip(); updateToolUI(); @@ -747,18 +757,19 @@ var __IWB_ANNOTATE_MANIFEST__ = { S.altPicker = false; exitPicker(); } - function applyColorChange(color) { + function applyColorChange(color, opts) { + const skipHistory = !!(opts && opts.skipHistory); S.color = color; updateColorUI(); const t = getSelectedText(); if (t && !t.locked && t.color !== S.color) { - saveSnapshot(); + if (!skipHistory) saveSnapshot(); t.color = S.color; renderObjects(); } const sh = getSelectedShape(); if (sh && !sh.locked && S.tool !== "text" && sh.color !== S.color) { - saveSnapshot(); + if (!skipHistory) saveSnapshot(); sh.color = S.color; renderObjects(); } @@ -767,7 +778,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { if (S.placingImage) cancelImagePlacement(); commitTextInput(); if (tool !== "picker") S.altPicker = false; - if (tool !== "select" && tool !== "pen") { + if (tool !== "select") { S.penEditId = null; S.penDragPt = -1; S.penDragPending = null; @@ -789,13 +800,16 @@ var __IWB_ANNOTATE_MANIFEST__ = { } S.tool = tool; 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; + if (!keepSel) { + S.selectedLayerId = null; + S.selectedTextId = null; + S.selectedShapeId = null; + } S.bitmapDrag = null; S.textDrag = null; S.shapeDrag = null; S.pickerComposite = null; + S.lastClick = null; hidePickerTip(); updateToolUI(); updateBrushParamUI(); @@ -1007,6 +1021,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { S.zCounter = Math.max(S.zCounter, units.length - 1); } function selectUnit(kind, id) { + S.layerMulti.length = 0; S.selectedLayerId = kind === "bitmap" ? id : null; S.selectedTextId = kind === "text" ? id : null; S.selectedShapeId = kind === "shape" ? id : null; @@ -1469,6 +1484,19 @@ var __IWB_ANNOTATE_MANIFEST__ = { committed = true; } hideTextInput(); + if (committed) { + const id = S.selectedTextId; + queueMicrotask(() => { + if (S.tool !== "text") return; + const box = runtime.el && runtime.el.querySelector(".iwb-editor-text-input"); + if (box && box.style.display !== "none") return; + setTool("select"); + if (!id) return; + selectUnit("text", id); + renderObjects(); + renderLayerPanel(); + }); + } return committed; } function deleteSelectedText() { @@ -1982,7 +2010,12 @@ var __IWB_ANNOTATE_MANIFEST__ = { function renderLayerPanel() { const list = runtime.el.querySelector(".iwb-editor-layer-list"); if (!list) return; + if (S.layerMulti.length) { + const alive = new Set(layerUnits().map((u) => u.kind + ":" + u.obj.id)); + S.layerMulti = S.layerMulti.filter((r) => alive.has(r.type + ":" + r.id)); + } const items = []; + const multiSet = new Set(S.layerMulti.map((x) => x.type + ":" + x.id)); for (const { kind, obj } of layerUnitsDesc()) { if (kind === "bitmap") { items.push({ @@ -1996,6 +2029,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { lineWidth: obj.lineWidth || S.brushSize, // 高亮只代表「选中」;画笔作用目标独立用 ✎ 标记,避免两个图层同时亮 active: obj.id === S.selectedLayerId, + multi: multiSet.has("bitmap:" + obj.id), paintTarget: obj.id === S.activeLayerId, locked: !!obj.locked, canDelete: S.layers.length > 1 @@ -2011,6 +2045,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { color: obj.color || S.color, lineWidth: obj.lw || S.brushSize, active: kind === "text" && obj.id === S.selectedTextId || kind === "shape" && obj.id === S.selectedShapeId, + multi: multiSet.has(kind + ":" + obj.id), paintTarget: false, locked: !!obj.locked, canDelete: true @@ -2020,6 +2055,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { let html = ""; for (const item of items) { const activeClass = item.active ? " active" : ""; + const multiClass = item.multi ? " multi" : ""; const visClass = item.visible ? "" : " hidden"; let typeIconSvg = ""; if (item.type === "bitmap") { @@ -2034,7 +2070,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { const visSvg = item.visible ? '' : ''; const lockSvg = item.locked ? '' : ''; const delSvg = ''; - html += `
+ html += `
${typeIconSvg} ${item.name}${item.paintTarget ? '✎' : ""} @@ -2045,6 +2081,12 @@ var __IWB_ANNOTATE_MANIFEST__ = {
`; } list.innerHTML = html; + const fxTarget = runtime.el.querySelector(".iwb-editor-fx-target"); + if (fxTarget) { + const active = getActiveLayer(); + fxTarget.textContent = active ? active.name : "无图层"; + fxTarget.title = active ? "效果作用于当前位图图层:" + active.name + "(切换图层可改变目标)" : "当前没有可处理的位图图层"; + } bindLayerPanelEvents(); } function reorderPanelItem(dragId, targetId) { @@ -2100,6 +2142,13 @@ var __IWB_ANNOTATE_MANIFEST__ = { if (e.target.closest(".iwb-layer-vis") || e.target.closest(".iwb-layer-lock") || e.target.closest(".iwb-layer-del")) return; const id = item.dataset.layerId; const type = item.dataset.layerType; + if (e.metaKey || e.ctrlKey) { + e.preventDefault(); + toggleLayerMulti(type, id); + renderLayerPanel(); + return; + } + if (S.layerMulti.length) S.layerMulti.length = 0; if (type === "bitmap") { setActiveLayer(id); } else if (type === "text" || type === "shape") { @@ -2139,7 +2188,10 @@ var __IWB_ANNOTATE_MANIFEST__ = { if (obj) { obj.lineWidth = value; if (type === "shape") obj.lw = value; - else S.brushSize = value; + else { + S.brushSize = value; + refreshBrushRing(); + } renderObjects(); updateBrushParamUI(); renderLayerPanel(); @@ -2213,6 +2265,162 @@ var __IWB_ANNOTATE_MANIFEST__ = { }); }); } + var multiKey = (type, id) => type + ":" + id; + function currentUnitRef() { + if (S.selectedLayerId) return { type: "bitmap", id: S.selectedLayerId }; + if (S.selectedTextId) return { type: "text", id: S.selectedTextId }; + if (S.selectedShapeId) return { type: "shape", id: S.selectedShapeId }; + return null; + } + function toggleLayerMulti(type, id) { + const key = multiKey(type, id); + const i = S.layerMulti.findIndex((x) => multiKey(x.type, x.id) === key); + if (i >= 0) { + S.layerMulti.splice(i, 1); + return; + } + if (!S.layerMulti.length) { + const cur = currentUnitRef(); + if (cur && multiKey(cur.type, cur.id) !== key) S.layerMulti.push(cur); + } + S.layerMulti.push({ type, id }); + } + function composeUnitsInto(layer, units) { + const tmp = document.createElement("canvas"); + tmp.width = S.imgW; + tmp.height = S.imgH; + const tctx = tmp.getContext("2d"); + for (const u of units) { + const el = u.kind === "bitmap" ? u.obj.canvas : u.obj._canvas; + if (!el || el.nodeType !== 1) continue; + tctx.globalAlpha = u.obj.opacity == null ? 1 : u.obj.opacity; + tctx.drawImage(el, 0, 0); + } + tctx.globalAlpha = 1; + const ctx = layer.ctx; + ctx.save(); + ctx.setTransform(1, 0, 0, 1, 0, 0); + ctx.globalAlpha = 1; + ctx.globalCompositeOperation = "copy"; + ctx.filter = "none"; + ctx.drawImage(tmp, 0, 0); + ctx.restore(); + } + function dropUnit(u) { + if (u.kind === "bitmap") { + const i = S.layers.indexOf(u.obj); + if (i >= 0) S.layers.splice(i, 1); + try { + if (u.obj.canvas && u.obj.canvas.parentNode) u.obj.canvas.parentNode.removeChild(u.obj.canvas); + } catch (e) { + } + } else if (u.kind === "text") { + S.textLayers = S.textLayers.filter((t) => t !== u.obj); + removeVecCanvas(u.obj); + } else if (u.kind === "shape") { + S.shapeLayers = S.shapeLayers.filter((s) => s !== u.obj); + removeVecCanvas(u.obj); + } + } + function mergeUnits(units) { + const sorted = units.slice().sort((a, b) => (a.obj.z || 0) - (b.obj.z || 0)); + const lowUnit = sorted[0]; + const baseUnit = sorted.find((u) => u.kind === "bitmap" && u.obj.id === "base"); + const all = layerUnits(); + const lowIdx = all.findIndex((u) => u.obj === lowUnit.obj); + const chosenSet = new Set(sorted.map((u) => u.obj)); + const insertAt = all.slice(0, Math.max(lowIdx, 0)).filter((u) => !chosenSet.has(u.obj)).length; + let carrier; + if (baseUnit) { + carrier = baseUnit.obj; + carrier.image = null; + carrier.sourceCanvas = null; + carrier._srcBox = null; + carrier.transformable = false; + carrier.x = 0; + carrier.y = 0; + carrier.w = S.imgW; + carrier.h = S.imgH; + carrier.rotation = 0; + carrier.visible = true; + carrier.opacity = 1; + carrier._bounds = void 0; + composeUnitsInto(carrier, sorted); + for (const u of sorted) if (u.obj !== carrier) dropUnit(u); + const rest = layerUnits().filter((u) => u.obj !== carrier); + rest.unshift({ kind: "bitmap", obj: carrier }); + assignLayerZ(rest); + } else { + const canvas = createLayerCanvas(); + const ctx = canvas.getContext("2d", { willReadFrequently: true }); + carrier = { + id: "m" + Date.now() + Math.floor(Math.random() * 1e3), + name: lowUnit.obj.name || "合并图层", + canvas, + ctx, + opacity: 1, + visible: true, + locked: false, + x: 0, + y: 0, + w: S.imgW, + h: S.imgH, + rotation: 0, + z: lowUnit.obj.z || 0 + }; + composeUnitsInto(carrier, sorted); + for (const u of sorted) dropUnit(u); + S.layers.push(carrier); + const rest = layerUnits().filter((u) => u.obj !== carrier); + rest.splice(Math.min(insertAt, rest.length), 0, { kind: "bitmap", obj: carrier }); + assignLayerZ(rest); + } + S.activeLayerId = carrier.id; + S.selectedLayerId = carrier.id; + S.selectedTextId = null; + S.selectedShapeId = null; + S.textDrag = null; + S.shapeDrag = null; + S.bitmapDrag = null; + S.layerMulti.length = 0; + S.pickerComposite = null; + sortLayersByZ(); + reorderLayerCanvas(); + updateLayerCanvasStyles(); + renderObjects(); + renderLayerPanel(); + if (S.renderAll) S.renderAll(); + return carrier; + } + function mergeLayers() { + const units = layerUnits(); + if (units.length < 2) return { ok: false, msg: "只有一个图层,没有可合并的对象" }; + let chosen; + if (S.layerMulti.length >= 2) { + chosen = units.filter((u) => S.layerMulti.some((r) => r.type === u.kind && r.id === u.obj.id)); + if (chosen.length < 2) return { ok: false, msg: "先选两个以上图层(⌘/Ctrl 点击图层列表)" }; + } else { + const cur = currentUnitRef(); + const idx = cur ? units.findIndex((u) => u.kind === cur.type && u.obj.id === cur.id) : -1; + if (idx < 0) return { ok: false, msg: "先在图层列表里选中一层" }; + if (idx === 0) return { ok: false, msg: "已经是最底层,没有可合并的下一层" }; + chosen = [units[idx - 1], units[idx]]; + if (chosen[1].obj.visible === false) return { ok: false, msg: "当前层已隐藏,先显示再合并" }; + if (chosen[0].obj.visible === false) return { ok: false, msg: "下一层已隐藏,先显示再合并" }; + } + const visible = chosen.filter((u) => u.obj.visible !== false); + if (visible.length < 2) return { ok: false, msg: "可见图层不足 2 个,没有可合并的内容" }; + saveSnapshot("合并图层"); + mergeUnits(visible); + return { ok: true, msg: "已合并 " + visible.length + " 个图层 · Ctrl+Z 撤销" }; + } + function mergeVisibleLayers() { + const visible = layerUnits().filter((u) => u.obj.visible !== false); + if (visible.length < 2) return { ok: false, msg: "可见图层不足 2 个,没有可合并的对象" }; + saveSnapshot("合并可见图层"); + mergeUnits(visible); + return { ok: true, msg: "已合并 " + visible.length + " 个可见图层 · Ctrl+Z 撤销" }; + } // image-annotate/plugin/editor/selection.js function hasSelection() { @@ -2768,6 +2976,8 @@ var __IWB_ANNOTATE_MANIFEST__ = { 图层
+ +
@@ -2800,6 +3010,9 @@ var __IWB_ANNOTATE_MANIFEST__ = {
+ + + @@ -2834,10 +3047,39 @@ var __IWB_ANNOTATE_MANIFEST__ = {
滚轮缩放 · 抓手/空格/中键拖拽自由移动画布
`; @@ -2917,6 +3188,132 @@ var __IWB_ANNOTATE_MANIFEST__ = { } } + // image-annotate/plugin/editor/effects.js + var QUICK_EFFECTS = { + invert: { label: "反白", hint: "反相:明暗翻转,白底变黑底", css: () => "invert(1)" }, + gray: { label: "灰度", hint: "去色,保留明暗层次", css: () => "grayscale(1)" }, + boost: { label: "增强", hint: "提亮并略加对比", css: () => "brightness(1.12) contrast(1.1) saturate(1.06)" }, + contrast: { label: "高对比", hint: "压成黑白硬调", css: () => "grayscale(1) contrast(2.4)" }, + soft: { label: "柔化", hint: "轻微模糊,弱化背景", css: (c) => "blur(" + softRadius(c) + "px)" }, + mosaic: { label: "马赛克", hint: "像素化,用于打码", pixel: true } + }; + var SOFT_MIN = 0.8; + var SOFT_MAX = 8; + function softRadius(canvas) { + const side = Math.min(canvas.width || 0, canvas.height || 0); + return Math.max(SOFT_MIN, Math.min(SOFT_MAX, Math.round(side / 500 * 10) / 10)); + } + function mosaicBlock(canvas) { + const side = Math.min(canvas.width || 0, canvas.height || 0); + return Math.max(6, Math.round(side / 60)); + } + function effectTarget() { + const active = getActiveLayer(); + if (active) return active; + return S.layers.find((l) => l.id === "base") || null; + } + function filterCanvas(canvas, css) { + const w = canvas.width, h = canvas.height; + if (!w || !h || !css) return; + const tmp = document.createElement("canvas"); + tmp.width = w; + tmp.height = h; + const tctx = tmp.getContext("2d"); + tctx.filter = css; + tctx.drawImage(canvas, 0, 0); + const ctx = canvas.getContext("2d"); + ctx.save(); + ctx.setTransform(1, 0, 0, 1, 0, 0); + ctx.globalAlpha = 1; + ctx.globalCompositeOperation = "copy"; + ctx.filter = "none"; + ctx.drawImage(tmp, 0, 0); + ctx.restore(); + } + function pixelateCanvas(canvas, block) { + const w = canvas.width, h = canvas.height; + if (!w || !h) return; + const sw = Math.max(1, Math.round(w / block)); + const sh = Math.max(1, Math.round(h / block)); + const tmp = document.createElement("canvas"); + tmp.width = sw; + tmp.height = sh; + const tctx = tmp.getContext("2d"); + tctx.imageSmoothingEnabled = true; + tctx.drawImage(canvas, 0, 0, sw, sh); + const ctx = canvas.getContext("2d"); + ctx.save(); + ctx.setTransform(1, 0, 0, 1, 0, 0); + ctx.globalAlpha = 1; + ctx.globalCompositeOperation = "copy"; + ctx.imageSmoothingEnabled = false; + ctx.filter = "none"; + ctx.drawImage(tmp, 0, 0, w, h); + ctx.restore(); + } + function rasterizeLayer(layer) { + const canvas = createLayerCanvas(); + const ctx = canvas.getContext("2d", { willReadFrequently: true }); + ctx.clearRect(0, 0, S.imgW, S.imgH); + ctx.drawImage(layer.canvas, 0, 0); + const units = layerUnits(); + const i = units.findIndex((u) => u.kind === "bitmap" && u.obj === layer); + const baseZ = layer.z || 0; + const nextZ = i >= 0 && units[i + 1] ? units[i + 1].obj.z || 0 : baseZ + 1; + const z = nextZ > baseZ ? (baseZ + nextZ) / 2 : baseZ + 0.5; + const clone = { + id: "fx" + Date.now() + Math.floor(Math.random() * 1e3), + name: layer.name + " · 效果", + canvas, + ctx, + opacity: layer.opacity == null ? 1 : layer.opacity, + visible: true, + locked: false, + x: 0, + y: 0, + w: S.imgW, + h: S.imgH, + rotation: 0, + z + }; + S.layers.push(clone); + layer.visible = false; + if (S.selectedLayerId === layer.id) S.selectedLayerId = clone.id; + S.activeLayerId = clone.id; + reorderLayerCanvas(); + updateLayerCanvasStyles(); + renderLayerPanel(); + return clone; + } + function applyQuickEffect(key) { + const fx = QUICK_EFFECTS[key]; + if (!fx) return false; + const layer = effectTarget(); + if (!layer) { + toast("没有可处理的图层"); + return false; + } + if (layer.visible === false) { + toast("「" + layer.name + "」已隐藏,先显示再应用效果"); + return false; + } + saveSnapshot("效果:" + fx.label); + let target = layer; + if (!needsPixelSnapshot(layer)) target = rasterizeLayer(layer); + if (!target) { + toast("栅格化失败,效果未应用"); + return false; + } + if (fx.pixel) pixelateCanvas(target.canvas, mosaicBlock(target.canvas)); + else filterCanvas(target.canvas, fx.css(target.canvas)); + target._bounds = void 0; + S.pickerComposite = null; + if (S.renderAll) S.renderAll(); + renderLayerPanel(); + toast("已应用「" + fx.label + "」到 " + target.name + " · Ctrl+Z 撤销", "success"); + return true; + } + // image-annotate/plugin/editor/events.js var MOUSE_DOWN_HANDLERS = { select: onSelectMouseDown, @@ -2945,6 +3342,10 @@ var __IWB_ANNOTATE_MANIFEST__ = { S.startX = pos.x; S.startY = pos.y; hideSelectionContext(); + if (S.layerMulti.length) { + S.layerMulti.length = 0; + renderLayerPanel(); + } if (S.tool === "marquee") { beginMarquee(pos); return; @@ -2953,12 +3354,65 @@ var __IWB_ANNOTATE_MANIFEST__ = { beginLasso(pos); return; } - if (S.tool === "select" || S.tool === "pen") { + const dbl = isDoubleClick(pos); + if (S.tool === "select") { + if (dbl && onCanvasDoubleClick(e, pos)) return; const penShape = getPenEditingShape(); if (penShape && onPenEditMouseDown(e, pos, penShape)) return; } + if (S.tool === "pen" && dbl) { + commitPenPath(); + return; + } const handler = Object.prototype.hasOwnProperty.call(MOUSE_DOWN_HANDLERS, S.tool) ? MOUSE_DOWN_HANDLERS[S.tool] : null; - if (handler) handler(pos); + if (handler) handler(pos, e); + } + var DBL_INTERVAL = 380; + function isDoubleClick(pos) { + const now = typeof performance !== "undefined" && performance.now ? performance.now() : Date.now(); + const last = S.lastClick; + const hit = !!last && now - last.t < DBL_INTERVAL && Math.hypot(pos.x - last.x, pos.y - last.y) < Math.max(8 / S.zoom, 6); + S.lastClick = hit ? null : { t: now, x: pos.x, y: pos.y }; + return hit; + } + function onCanvasDoubleClick(e, pos) { + const penShape = getPenEditingShape(); + if (penShape) { + const pi = hitPenPoint(pos, penShape, Math.max(14 / S.zoom, 8)); + if (pi < 0) return false; + e.preventDefault(); + saveSnapshot(); + const pts = penShape.pts; + const minPts = penShape.closed ? 3 : 2; + if (pts.length <= minPts) { + removeVecCanvas(penShape); + S.shapeLayers = S.shapeLayers.filter((x) => x.id !== penShape.id); + S.penEditId = null; + S.selectedShapeId = null; + } else { + pts.splice(pi, 1); + if (penShape.closed && pts.length < 3) penShape.closed = false; + } + renderObjects(); + renderLayerPanel(); + return true; + } + const hitPen = hitShapeLayer(pos, true); + if (hitPen && hitPen.type === "pen") { + e.preventDefault(); + beginPenEdit(hitPen); + return true; + } + const hitText = hitTextLayer(pos); + if (hitText) { + e.preventDefault(); + selectUnit("text", hitText.id); + if (hitText.locked) return true; + renderObjects(); + showTextInput(hitText.x, hitText.y, hitText); + return true; + } + return false; } function onPlacementMouseDown(e) { e.preventDefault(); @@ -3068,36 +3522,12 @@ var __IWB_ANNOTATE_MANIFEST__ = { } function onTextMouseDown(pos) { if (commitTextInput()) return; - const handle = hitTextHandle(pos); - if (handle) { - if (handle === "rotate") beginTextRotate(pos); - else beginTextScaleDrag(handle, pos); - return; - } - const hit = hitTextLayer(pos); - if (hit) { - selectUnit("text", hit.id); - if (hit.locked) { - renderObjects(); - renderLayerPanel(); - return; - } - S.textDrag = { - mode: "move", - start: pos, - layer: { x: hit.x, y: hit.y }, - pending: snapshotState() - }; + if (S.selectedTextId) { + S.selectedTextId = null; renderObjects(); renderLayerPanel(); - } else { - if (S.selectedTextId) { - S.selectedTextId = null; - renderObjects(); - renderLayerPanel(); - } - showTextInput(pos.x, pos.y); } + showTextInput(pos.x, pos.y); } function onPickerMouseDown(pos) { const s = sampleColor(pos); @@ -3154,24 +3584,6 @@ var __IWB_ANNOTATE_MANIFEST__ = { return; } function onShapeMouseDown(pos) { - const handle = hitShapeHandle(pos); - if (handle) { - beginShapeHandleDrag(handle, pos); - return; - } - const hitShape = hitShapeLayer(pos, true); - if (hitShape && hitShape.type === S.tool) { - S.selectedShapeId = hitShape.id; - if (hitShape.locked) { - renderObjects(); - renderLayerPanel(); - return; - } - S.shapeDrag = { mode: "move", start: pos, shape: { ...hitShape }, pending: snapshotState() }; - renderObjects(); - renderLayerPanel(); - return; - } if (S.selectedShapeId) { S.selectedShapeId = null; renderObjects(); @@ -3538,11 +3950,22 @@ var __IWB_ANNOTATE_MANIFEST__ = { z: ++S.zCounter }; S.shapeLayers.push(shape); - selectUnit("shape", shape.id); + renderObjects(); + renderLayerPanel(); + finishCreateTool("shape", shape.id); + return; } renderObjects(); renderLayerPanel(); } + function finishCreateTool(kind, id) { + if (["rect", "circle", "arrow", "pen"].indexOf(S.tool) < 0) return; + setTool("select"); + if (!id) return; + selectUnit(kind, id); + renderObjects(); + renderLayerPanel(); + } function onWheel(e) { if (!S.open) return; if (e.target && e.target.closest && e.target.closest(".iwb-editor-tools")) return; @@ -3587,6 +4010,12 @@ var __IWB_ANNOTATE_MANIFEST__ = { renderOptionBar(); updateStatusbar(); } + function refreshBrushRing() { + if (!S.hoverPos) return; + if (S.tool !== "brush" && S.tool !== "eraser") return; + if (S.isDrawing) return; + drawToolRing(S.hoverPos); + } function updateCursor() { if (S.panning) { S.drawCanvasCursor("grabbing"); @@ -3602,6 +4031,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { } if (S.tool === "brush" || S.tool === "eraser") { S.drawCanvasCursor("none"); + refreshBrushRing(); return; } if (S.tool === "crop" && S.cropRect) { @@ -3625,6 +4055,8 @@ var __IWB_ANNOTATE_MANIFEST__ = { const panelHex = runtime.el.querySelector(".iwb-editor-color-hex"); const hexInput = runtime.el.querySelector(".iwb-editor-color-hex-input"); if (hexInput && document.activeElement !== hexInput) hexInput.value = S.color.toUpperCase(); + const colorDot = runtime.el.querySelector(".iwb-editor-color-btn i"); + if (colorDot) colorDot.style.background = S.color; runtime.el.querySelectorAll(".iwb-editor-color-panel-swatch").forEach((sw) => sw.classList.toggle("active", (sw.dataset.panelColor || "").toLowerCase() === S.color.toLowerCase())); if (panelHex) panelHex.textContent = S.color.toUpperCase(); const rgb = hexToRgb(S.color); @@ -3912,6 +4344,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { S.brushSize = clamp(safe || 1, 1, 300); updateBrushUI(); updateBrushParamUI(); + refreshBrushRing(); } else if (key === "brushHardness") { S.brushHardness = clamp(safe, 0, 100); updateBrushParamUI(); @@ -3957,6 +4390,12 @@ var __IWB_ANNOTATE_MANIFEST__ = { if (toggle) toggle.setAttribute("aria-expanded", "false"); }; root.addEventListener("click", (e) => { + const fxBtn = e.target.closest("[data-fx]"); + if (fxBtn) { + e.stopPropagation(); + applyQuickEffect(fxBtn.dataset.fx); + return; + } const btn = e.target.closest("[data-more]"); if (!btn) return; e.stopPropagation(); @@ -4088,8 +4527,77 @@ var __IWB_ANNOTATE_MANIFEST__ = { btn.addEventListener("click", () => setTool(btn.dataset.tool)); }); } + function closeColorPop() { + const pop = runtime.el && runtime.el.querySelector(".iwb-editor-color-pop"); + if (!pop || pop.hidden) return false; + pop.hidden = true; + const btn = runtime.el.querySelector('[data-action="toggleColorPop"]'); + if (btn) { + btn.classList.remove("active"); + btn.setAttribute("aria-expanded", "false"); + } + return true; + } + function positionColorPop() { + const pop = runtime.el && runtime.el.querySelector(".iwb-editor-color-pop"); + const btn = runtime.el && runtime.el.querySelector('[data-action="toggleColorPop"]'); + const modal = runtime.el && runtime.el.querySelector(".iwb-editor-modal"); + if (!pop || !btn || !modal || pop.hidden) return; + const mr = modal.getBoundingClientRect(); + const br = btn.getBoundingClientRect(); + const pr = pop.getBoundingClientRect(); + let left = br.left - mr.left - 10; + left = Math.min(Math.max(8, left), Math.max(8, mr.width - pr.width - 8)); + let top = br.top - mr.top - pr.height - 10; + if (top < 8) top = br.bottom - mr.top + 10; + pop.style.left = Math.round(left) + "px"; + pop.style.top = Math.round(top) + "px"; + } + function toggleColorPop() { + const pop = runtime.el.querySelector(".iwb-editor-color-pop"); + const btn = runtime.el.querySelector('[data-action="toggleColorPop"]'); + if (!pop || !btn) return; + if (pop.hidden) { + pop.hidden = false; + btn.classList.add("active"); + btn.setAttribute("aria-expanded", "true"); + positionColorPop(); + } else { + closeColorPop(); + } + } function bindColorPanel() { + const pop = runtime.el.querySelector(".iwb-editor-color-pop"); + const colorBtn = runtime.el.querySelector('[data-action="toggleColorPop"]'); + if (colorBtn) { + colorBtn.addEventListener("mousedown", (e) => e.stopPropagation()); + colorBtn.addEventListener("click", (e) => { + e.stopPropagation(); + toggleColorPop(); + }); + } + if (pop) { + pop.addEventListener("mousedown", (e) => e.stopPropagation()); + document.addEventListener("mousedown", (e) => { + if (!pop.hidden && !pop.contains(e.target) && !(colorBtn && colorBtn.contains(e.target))) closeColorPop(); + }, true); + window.addEventListener("resize", positionColorPop); + } const setPanelColor = (color) => applyColorChange(color); + let dragSnapped = false; + const hasColorTarget = () => { + const t = getSelectedText(), sh = getSelectedShape(); + return !!(t && !t.locked || sh && !sh.locked); + }; + const setDragColor = (color) => { + if (!dragSnapped) { + if (hasColorTarget()) { + saveSnapshot(); + dragSnapped = true; + } + } + applyColorChange(color, { skipHistory: true }); + }; const panelHexInput = runtime.el.querySelector(".iwb-editor-color-hex-input"); if (panelHexInput) panelHexInput.addEventListener("change", () => { if (/^#[0-9a-f]{6}$/i.test(panelHexInput.value)) setPanelColor(panelHexInput.value); @@ -4101,7 +4609,10 @@ var __IWB_ANNOTATE_MANIFEST__ = { const palettePick = runtime.el.querySelector('[data-action="palettePick"]'); if (palettePick) { palettePick.addEventListener("mousedown", (e) => e.stopPropagation()); - palettePick.addEventListener("click", () => setTool("picker")); + palettePick.addEventListener("click", () => { + closeColorPop(); + setTool("picker"); + }); } const sv = runtime.el.querySelector(".iwb-color-sv"); const hue = runtime.el.querySelector(".iwb-color-hue"); @@ -4154,12 +4665,32 @@ var __IWB_ANNOTATE_MANIFEST__ = { satValue = x; valValue = 1 - y; } - setPanelColor(hsvToHex(hueValue, satValue, valValue)); + setDragColor(hsvToHex(hueValue, satValue, valValue)); + }; + const syncFromColor = () => { + const { r, g, b } = hexToRgb(S.color); + const rr = r / 255, gg = g / 255, bb = b / 255; + const max = Math.max(rr, gg, bb), min = Math.min(rr, gg, bb), d = max - min; + if (d > 0) { + let h = 0; + if (max === rr) h = 60 * ((gg - bb) / d % 6); + else if (max === gg) h = 60 * ((bb - rr) / d + 2); + else h = 60 * ((rr - gg) / d + 4); + if (h < 0) h += 360; + hueValue = h; + } + satValue = max ? d / max : 0; + valValue = max; + }; + const beginDrag = (target, e) => { + syncFromColor(); + dragSnapped = false; + pick(target, e); }; if (sv) { sv.addEventListener("pointerdown", (e) => { sv.setPointerCapture(e.pointerId); - pick(sv, e); + beginDrag(sv, e); }); sv.addEventListener("pointermove", (e) => { if (e.buttons) pick(sv, e); @@ -4167,7 +4698,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { } if (hue) { hue.addEventListener("pointerdown", (e) => { - pick(hue, e); + beginDrag(hue, e); }); hue.addEventListener("pointermove", (e) => { if (e.buttons) pick(hue, e); @@ -4259,6 +4790,16 @@ var __IWB_ANNOTATE_MANIFEST__ = { bindAll('[data-action="addBlankLayer"]', "click", () => { addBlankLayer(); }); + bindAll('[data-action="mergeLayers"]', "mousedown", (e) => e.stopPropagation()); + bindAll('[data-action="mergeLayers"]', "click", () => { + const r = mergeLayers(); + toast(r.msg, r.ok ? "success" : "warn"); + }); + bindAll('[data-action="mergeVisible"]', "mousedown", (e) => e.stopPropagation()); + bindAll('[data-action="mergeVisible"]', "click", () => { + const r = mergeVisibleLayers(); + toast(r.msg, r.ok ? "success" : "warn"); + }); } function bindExportActions() { bindIf('[data-action="cancel"]', "click", close); @@ -4311,10 +4852,10 @@ var __IWB_ANNOTATE_MANIFEST__ = { saveSnapshot(); const shape = { id: "s" + Date.now() + Math.floor(Math.random() * 1e3), type: "pen", pts: S.penPath.pts.slice(), closed: !!S.penPath.closed, color: S.color, lw: Math.max(1, S.shapeLineWidth), fill: !!S.penFill && !!S.penPath.closed, opacity: 1, visible: true, locked: false, z: ++S.zCounter }; S.shapeLayers.push(shape); - selectUnit("shape", shape.id); S.penPath = null; renderObjects(); renderLayerPanel(); + finishCreateTool("shape", shape.id); } function bindCanvasEvents() { if (S._canvasEventsBound) return; @@ -4329,56 +4870,10 @@ var __IWB_ANNOTATE_MANIFEST__ = { }); S.canvasStack.addEventListener("mouseleave", () => { if (S.placingImage) return; + S.hoverPos = null; if ((S.tool === "brush" || S.tool === "eraser") && !S.isDrawing) clearToolRing(); if (S.tool === "picker") hidePickerTip(); }); - S.canvasStack.addEventListener("dblclick", (e) => { - if (S.placingImage) return; - const pos = getPos(e); - if (S.tool === "pen" && S.penPath) { - commitPenPath(); - return; - } - if (S.tool === "select" || S.tool === "pen") { - const penShape = getPenEditingShape(); - if (penShape) { - const pi = hitPenPoint(pos, penShape, Math.max(14 / S.zoom, 8)); - if (pi >= 0) { - e.preventDefault(); - saveSnapshot(); - const pts = penShape.pts; - const minPts = penShape.closed ? 3 : 2; - if (pts.length <= minPts) { - removeVecCanvas(penShape); - S.shapeLayers = S.shapeLayers.filter((x) => x.id !== penShape.id); - S.penEditId = null; - S.selectedShapeId = null; - } else { - pts.splice(pi, 1); - if (penShape.closed && pts.length < 3) penShape.closed = false; - } - renderObjects(); - renderLayerPanel(); - return; - } - return; - } - const hitPen = hitShapeLayer(pos, true); - if (hitPen && hitPen.type === "pen") { - e.preventDefault(); - beginPenEdit(hitPen); - return; - } - } - if (S.tool !== "text" && S.tool !== "select") return; - const hit = hitTextLayer(pos); - if (hit) { - selectUnit("text", hit.id); - if (hit.locked) return; - renderObjects(); - showTextInput(hit.x, hit.y, hit); - } - }); } var CROP_CURSORS = { nw: "nwse-resize", @@ -4414,6 +4909,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { S.lastPos = p; updateStatusbar(); } + S.hoverPos = p; if (isOverRotationHandle(p)) { S.drawCanvasCursor(ROT_CURSOR); return; @@ -4529,6 +5025,10 @@ var __IWB_ANNOTATE_MANIFEST__ = { hideTextInput(); return; } + if (closeColorPop()) { + e.preventDefault(); + return; + } if (S.tool === "crop" && S.cropRect) { e.preventDefault(); cancelCrop(); @@ -4613,6 +5113,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { S.brushSize = clamp(S.brushSize + (e.key === "]" ? step : -step), 1, 300); syncOptionBar(); updateCursor(); + refreshBrushRing(); return; } if (mod && !e.shiftKey && e.key === "0") { @@ -4660,6 +5161,12 @@ var __IWB_ANNOTATE_MANIFEST__ = { runCommand("sel.cut"); return; } + if (mod && key === "e") { + e.preventDefault(); + const r = e.shiftKey ? mergeVisibleLayers() : mergeLayers(); + toast(r.msg, r.ok ? "success" : "warn"); + return; + } if (mod && e.shiftKey && key === "n") { e.preventDefault(); addBlankLayer(); @@ -5609,6 +6116,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { S.bitmapDrag = null; S.penPath = null; S.penEditId = null; + S.layerMulti.length = 0; reorderLayerCanvas(); updateLayerCanvasStyles(); renderObjects(); @@ -5690,6 +6198,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { S.bitmapDrag = null; S.penPath = null; S.penEditId = null; + S.layerMulti.length = 0; S.cropRect = null; S.cropHandle = null; S.cropMoving = false; @@ -6222,8 +6731,10 @@ var __IWB_ANNOTATE_MANIFEST__ = { texts: S.textLayers.map((t) => ({ id: t.id, text: t.text })), selectedShapeId: S.selectedShapeId, selectedTextId: S.selectedTextId, + penEditId: S.penEditId, activeLayerId: S.activeLayerId, selectedLayerId: S.selectedLayerId, + layerMulti: S.layerMulti.map((x) => x.type + ":" + x.id), selection: selectionInfo(), toolOptions: { brushSize: S.brushSize, @@ -6250,6 +6761,21 @@ var __IWB_ANNOTATE_MANIFEST__ = { } catch (e) { return null; } + }, + // 区域透明像素统计:断言「合并后两半都有内容」比逐点采样快一个量级 + alphaIn: (id, x0, y0, x1, y1) => { + const l = S.layers.find((v) => v.id === id); + if (!l || !l.ctx) return 0; + try { + const w = Math.max(1, Math.round(x1 - x0)); + const h = Math.max(1, Math.round(y1 - y0)); + const d = l.ctx.getImageData(Math.round(x0), Math.round(y0), w, h).data; + let n = 0; + for (let i = 3; i < d.length; i += 4) if (d[i] > 0) n++; + return n; + } catch (e) { + return 0; + } } }); window.__iwbEditor = { @@ -6260,7 +6786,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { }; // image-annotate/plugin/editor.css - var editor_default = '/* IWB 鲜艺抠图节点 - 注入样式 */\n\n/* 抠图按钮 */\n.iwb-cutout-btn {\n cursor: pointer;\n opacity: 0.7;\n transition: opacity 0.15s, transform 0.15s;\n}\n\n.iwb-cutout-btn:hover {\n opacity: 1;\n transform: scale(1.15);\n}\n\n.iwb-cutout-btn svg {\n width: 14px;\n height: 14px;\n display: block;\n}\n\n/* 正在处理中的按钮状态 */\n.iwb-cutout-btn.processing {\n animation: iwb-cutout-pulse 1s infinite;\n pointer-events: none;\n}\n\n@keyframes iwb-cutout-pulse {\n 0%, 100% { opacity: 0.4; }\n 50% { opacity: 1; }\n}\n\n/* 全屏遮罩 */\n.iwb-cutout-overlay {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.25);\n display: none;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n gap: 12px;\n z-index: 999999;\n pointer-events: all;\n backdrop-filter: blur(2px);\n}\n\n/* 自定义按钮提示(挂在 body,最高层级,不会被图片遮挡) */\n#iwb-cutout-tip {\n position: fixed;\n z-index: 2147483647;\n background: rgba(30, 30, 46, 0.95);\n color: #fff;\n padding: 5px 10px;\n border-radius: 6px;\n font-size: 12px;\n line-height: 1.5;\n white-space: nowrap;\n pointer-events: none;\n display: none;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);\n border: 1px solid rgba(255, 255, 255, 0.14);\n font-family: system-ui, -apple-system, "Segoe UI", sans-serif;\n max-width: 320px;\n white-space: normal;\n word-break: break-all;\n}\n\n/* 加载动画 */\n.iwb-cutout-spinner {\n width: 48px;\n height: 48px;\n border: 4px solid rgba(255, 255, 255, 0.3);\n border-top-color: #e8a735;\n border-radius: 50%;\n animation: iwb-cutout-spin 0.8s linear infinite;\n}\n\n@keyframes iwb-cutout-spin {\n to { transform: rotate(360deg); }\n}\n\n/* 遮罩文字 */\n.iwb-cutout-text {\n color: #fff;\n font-size: 14px;\n font-weight: 500;\n text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);\n background: rgba(0, 0, 0, 0.6);\n padding: 8px 16px;\n border-radius: 6px;\n}\n\n/* Toast 提示 */\n.iwb-cutout-toast {\n position: fixed;\n bottom: 24px;\n left: 50%;\n transform: translateX(-50%);\n padding: 10px 20px;\n border-radius: 8px;\n font-size: 13px;\n font-weight: 500;\n z-index: 999999;\n transition: opacity 0.3s;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n display: none;\n max-width: 400px;\n}\n\n.iwb-cutout-toast-success {\n background: #1a7f37;\n color: #fff;\n}\n\n.iwb-cutout-toast-error {\n background: #cf222e;\n color: #fff;\n}\n\n.iwb-cutout-toast-info {\n background: #1f6feb;\n color: #fff;\n}\n\n/* 白底按钮 */\n.iwb-whitebg-btn {\n cursor: pointer;\n opacity: 0.7;\n transition: opacity 0.15s, transform 0.15s;\n}\n.iwb-whitebg-btn:hover { opacity: 1; transform: scale(1.15); }\n.iwb-whitebg-btn svg { width: 14px; height: 14px; display: block; }\n.iwb-whitebg-btn.processing { animation: iwb-cutout-pulse 1s infinite; pointer-events: none; }\n\n/* 编辑按钮 */\n.iwb-editor-btn-icon {\n cursor: pointer;\n opacity: 0.7;\n transition: opacity 0.15s, transform 0.15s;\n}\n.iwb-editor-btn-icon:hover { opacity: 1; transform: scale(1.15); }\n.iwb-editor-btn-icon svg { width: 14px; height: 14px; display: block; }\n\n/* ==================== 图片编辑器 ==================== */\n\n.iwb-editor-overlay {\n position: fixed;\n top: 0; left: 0;\n width: 100%; height: 100%;\n background: rgba(0, 0, 0, 0.6);\n display: none;\n align-items: center;\n justify-content: center;\n z-index: 999998;\n backdrop-filter: blur(3px);\n}\n\n.iwb-editor-modal {\n background: #1e1e2e;\n border-radius: 0;\n box-shadow: none;\n display: flex;\n flex-direction: column;\n width: 100vw;\n height: 100vh;\n max-width: none;\n max-height: none;\n overflow: visible;\n}\n\n/* 新增:主区域(画布 + 图层面板)flex 布局 */\n.iwb-editor-main {\n display: flex;\n flex: 1 1 auto;\n min-height: 0;\n overflow: visible;\n}\n\n.iwb-editor-header {\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 10px 16px;\n background: #181825;\n border-bottom: 1px solid #313244;\n flex-wrap: nowrap;\n}\n.iwb-editor-header > .iwb-editor-tools {\n position: absolute;\n left: 12px;\n top: 68px;\n width: 44px;\n flex-direction: column;\n padding: 6px;\n background: #181825;\n border: 1px solid #313244;\n border-radius: 8px;\n z-index: 20;\n}\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action { position: static; }\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="undo"],\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="redo"],\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="reset"],\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="restore"] {\n position: absolute;\n top: -54px;\n left: auto;\n}\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="undo"] { right: 154px; }\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="redo"] { right: 118px; }\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="reset"] { right: 82px; }\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="restore"] { right: 46px; }\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-divider {\n width: 24px;\n height: 1px;\n margin: 4px 0;\n}\n\n.iwb-editor-title {\n color: #cdd6f4;\n font-size: 14px;\n font-weight: 600;\n white-space: nowrap;\n}\n\n.iwb-editor-tools {\n display: flex;\n align-items: center;\n gap: 4px;\n}\n\n.iwb-editor-tool, .iwb-editor-action {\n background: #313244;\n border: none;\n border-radius: 6px;\n color: #cdd6f4;\n width: 32px; height: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n font-size: 15px;\n transition: background 0.15s, transform 0.1s;\n}\n.iwb-editor-tool:hover, .iwb-editor-action:hover { background: #45475a; transform: scale(1.08); }\n.iwb-editor-tool.active { background: #e8a735; color: #1e1e2e; }\n.iwb-editor-tool svg, .iwb-editor-action svg { display: block; }\n.iwb-editor-layer-btn svg { display: block; }\n\n/* 复原按钮:绿色高亮,与撤销/重做/清空区分 */\n.iwb-editor-action-restore { background: #1a7f37; color: #fff; }\n.iwb-editor-action-restore:hover { background: #15803d !important; }\n\n.iwb-editor-divider {\n width: 1px; height: 20px;\n background: #45475a;\n margin: 0 4px;\n}\n\n.iwb-editor-params {\n display: flex;\n align-items: center;\n gap: 10px;\n margin-left: 12px;\n justify-content: flex-start;\n min-width: 0;\n flex: 1 1 auto;\n flex-wrap: wrap;\n}\n.iwb-editor-params .iwb-editor-zoom { margin-left: auto; order: 20; }\n.iwb-editor-top-colors { display: none; }\n\n.iwb-editor-colors { display: flex; gap: 4px; }\n.iwb-editor-color {\n width: 20px; height: 20px;\n border-radius: 50%;\n cursor: pointer;\n border: 2px solid transparent;\n transition: transform 0.1s, border-color 0.15s;\n}\n.iwb-editor-color:hover { transform: scale(1.2); }\n.iwb-editor-color.active { border-color: #fff; transform: scale(1.15); }\n\n.iwb-editor-brush-label {\n display: flex;\n align-items: center;\n gap: 6px;\n color: #a6adc8;\n font-size: 12px;\n}\n.iwb-editor-brush-size { width: 80px; cursor: pointer; }\n.iwb-editor-brush-val { color: #e8a735; font-weight: 600; min-width: 16px; }\n\n/* 笔刷/橡皮大小精确数值输入框 */\n.iwb-editor-brush-num,\n.iwb-editor-eraser-num {\n width: 44px;\n padding: 2px 3px;\n background: #313244;\n border: 1px solid #45475a;\n border-radius: 5px;\n color: #e8a735;\n font-weight: 600;\n font-size: 11px;\n font-family: inherit;\n text-align: center;\n}\n.iwb-editor-brush-num:focus,\n.iwb-editor-eraser-num:focus {\n outline: none;\n border-color: #e8a735;\n background: #1e1e2e;\n}\n.iwb-editor-brush-num::-webkit-outer-spin-button,\n.iwb-editor-brush-num::-webkit-inner-spin-button,\n.iwb-editor-eraser-num::-webkit-outer-spin-button,\n.iwb-editor-eraser-num::-webkit-inner-spin-button {\n -webkit-appearance: none; /* 去掉上下箭头,窄输入框更干净 */\n margin: 0;\n}\n\n/* 实心矩形开关 */\n.iwb-editor-fill-btn {\n background: #313244;\n border: 1px solid #45475a;\n border-radius: 6px;\n color: #a6adc8;\n padding: 4px 10px;\n font-size: 12px;\n cursor: pointer;\n transition: background 0.15s, color 0.15s, border-color 0.15s;\n white-space: nowrap;\n}\n.iwb-editor-fill-btn:hover { background: #45475a; }\n.iwb-editor-fill-btn.active {\n background: #e8a735;\n border-color: #e8a735;\n color: #1e1e2e;\n font-weight: 600;\n}\n\n/* 画笔参数组(硬度/透明度,画笔与橡皮工具共用) */\n.iwb-editor-brush-group {\n display: flex;\n align-items: center;\n gap: 10px;\n}\n.iwb-editor-layer-group {\n display: flex;\n align-items: center;\n gap: 3px;\n}\n.iwb-editor-layer-btn {\n background: #313244;\n border: 1px solid #45475a;\n border-radius: 6px;\n color: #a6adc8;\n width: 26px;\n height: 26px;\n font-size: 14px;\n line-height: 1;\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;\n}\n.iwb-editor-layer-btn:hover:not(:disabled) { background: #45475a; color: #cdd6f4; }\n.iwb-editor-layer-btn:disabled {\n opacity: 0.35;\n cursor: not-allowed;\n}\n\n/* 缩放控件 */\n.iwb-editor-zoom {\n display: flex;\n align-items: center;\n gap: 2px;\n background: #313244;\n border-radius: 6px;\n padding: 2px;\n}\n.iwb-editor-zoom-btn {\n background: transparent;\n border: none;\n color: #cdd6f4;\n width: 26px;\n height: 26px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n line-height: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background 0.15s;\n}\n.iwb-editor-zoom-btn:hover { background: #45475a; }\n.iwb-editor-zoom-btn:active { transform: scale(0.94); }\n.iwb-editor-zoom-fit { font-size: 12px; width: auto; padding: 0 8px; }\n.iwb-editor-zoom-val {\n color: #e8a735;\n font-size: 12px;\n font-weight: 600;\n min-width: 46px;\n text-align: center;\n font-variant-numeric: tabular-nums;\n user-select: none;\n}\n\n/* 底部操作提示 */\n.iwb-editor-zoom-hint {\n position: absolute;\n bottom: 8px;\n right: 14px;\n color: #7f849c;\n font-size: 11px;\n background: rgba(24, 24, 37, 0.85);\n padding: 3px 10px;\n border-radius: 4px;\n pointer-events: none;\n z-index: 5;\n}\n\n.iwb-editor-canvas-wrap {\n position: relative;\n background: #11111b;\n flex: 1 1 auto;\n min-height: 0;\n max-width: 100%;\n max-height: 100%;\n overflow: hidden; /* 裁剪框允许显示在图片边界外;编辑区仍由模态层裁切 */\n overflow: clip; /* v1.2.8:hidden 仍可被编程滚动(点击底部工具栏会触发 scrollIntoView 把画布滚跑),clip 彻底禁止滚动 */\n padding: 12px;\n}\n\n.iwb-editor-canvas-stack {\n position: absolute;\n left: 0;\n top: 0;\n display: block;\n width: 0;\n height: 0;\n /* 仅图片工作区显示透明棋盘格,外围裁剪工作区保持纯色。 */\n background-color: #d6d6d6;\n background-image:\n linear-gradient(45deg, #b8b8b8 25%, transparent 25%),\n linear-gradient(-45deg, #b8b8b8 25%, transparent 25%),\n linear-gradient(45deg, transparent 75%, #b8b8b8 75%),\n linear-gradient(-45deg, transparent 75%, #b8b8b8 75%);\n background-size: 20px 20px;\n background-position: 0 0, 0 10px, 10px -10px, -10px 0;\n}\n\n.iwb-editor-base, .iwb-editor-draw, .iwb-editor-text, .iwb-editor-crop-overlay {\n display: block;\n}\n/* 位图图层 canvas(动态创建) */\n.iwb-editor-layer-canvas {\n display: block;\n position: absolute;\n top: 0; left: 0;\n}\n.iwb-editor-base {\n background: #fff;\n /* 棋盘格透明背景示意 */\n background-image:\n linear-gradient(45deg, #e0e0e0 25%, transparent 25%),\n linear-gradient(-45deg, #e0e0e0 25%, transparent 25%),\n linear-gradient(45deg, transparent 75%, #e0e0e0 75%),\n linear-gradient(-45deg, transparent 75%, #e0e0e0 75%);\n background-size: 20px 20px;\n background-position: 0 0, 0 10px, 10px -10px, -10px 0px;\n}\n.iwb-editor-draw {\n position: absolute;\n top: 0; left: 0;\n cursor: crosshair;\n}\n\n/* 笔划预览层:一笔进行中显示(draw 之上、text 之下),事件穿透 */\n.iwb-editor-stroke {\n position: absolute;\n top: 0; left: 0;\n pointer-events: none;\n display: none;\n}\n\n.iwb-editor-brush-hardness { width: 70px; cursor: pointer; }\n.iwb-editor-brush-hardness-val { color: #e8a735; font-weight: 600; min-width: 20px; display: inline-block; text-align: right; }\n.iwb-editor-brush-opacity { width: 70px; cursor: pointer; }\n.iwb-editor-brush-opacity-val { color: #e8a735; font-weight: 600; min-width: 34px; display: inline-block; text-align: right; }\n\n/* 自定义颜色(原生取色器伪装成圆形色板) */\n.iwb-editor-color-custom {\n position: relative;\n overflow: hidden;\n border: 2px dashed #a6adc8;\n}\n.iwb-editor-color-custom.active { border-color: #fff; border-style: solid; transform: scale(1.15); }\n.iwb-editor-color-custom input[type="color"] {\n position: absolute;\n inset: -6px;\n width: calc(100% + 12px);\n height: calc(100% + 12px);\n padding: 0;\n border: none;\n cursor: pointer;\n background: conic-gradient(#ff4444, #ffaa00, #44dd44, #4488ff, #aa44ff, #ff4444);\n}\n.iwb-editor-color-custom input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }\n.iwb-editor-color-custom input[type="color"]::-webkit-color-swatch { border: none; }\n\n/* 吸管悬停预览浮窗 */\n.iwb-editor-picker-tip {\n position: fixed;\n z-index: 2147483000;\n display: none;\n align-items: center;\n gap: 6px;\n background: rgba(30, 30, 46, 0.95);\n border: 1px solid rgba(255, 255, 255, 0.14);\n border-radius: 6px;\n padding: 4px 8px;\n pointer-events: none;\n font-family: system-ui, -apple-system, "Segoe UI", sans-serif;\n}\n.iwb-editor-picker-chip {\n width: 16px;\n height: 16px;\n border-radius: 4px;\n background: transparent;\n}\n.iwb-editor-picker-hex {\n color: #cdd6f4;\n font-size: 12px;\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n}\n\n/* 文字图层:独立 canvas,事件穿透到下层 drawCanvas */\n.iwb-editor-text {\n position: absolute;\n top: 0; left: 0;\n pointer-events: none;\n}\n\n/* 裁剪覆盖层:遮罩/选区框/手柄画在这层,不污染标注层 */\n.iwb-editor-crop-overlay {\n position: absolute;\n top: 0; left: 0;\n pointer-events: none;\n}\n\n/* 文字输入框 */\n.iwb-editor-text-input {\n position: absolute;\n display: none;\n padding: 4px 8px;\n border: 2px solid #4488ff;\n border-radius: 4px;\n font-size: 14px;\n background: rgba(255, 255, 255, 0.95);\n color: #1e1e2e;\n z-index: 10;\n min-width: 120px;\n}\n.iwb-editor-text-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(68, 136, 255, 0.3); }\n\n/* 裁剪确认栏(含约束控件) */\n.iwb-editor-crop-bar {\n position: absolute;\n bottom: 16px;\n left: 50%;\n transform: translateX(-50%);\n display: none;\n gap: 8px;\n z-index: 10;\n align-items: center;\n background: rgba(24, 24, 37, 0.92);\n border: 1px solid #313244;\n border-radius: 8px;\n padding: 6px 10px;\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);\n flex-wrap: wrap;\n max-width: 90%;\n justify-content: center;\n}\n\n.iwb-editor-constraint-group {\n display: flex;\n align-items: center;\n gap: 4px;\n}\n\n.iwb-editor-constraint-label {\n color: #7f849c;\n font-size: 11px;\n margin-right: 2px;\n white-space: nowrap;\n}\n\n.iwb-editor-constraint-btn {\n background: #313244;\n border: none;\n border-radius: 4px;\n color: #cdd6f4;\n padding: 3px 8px;\n font-size: 12px;\n cursor: pointer;\n transition: background 0.15s, transform 0.1s;\n white-space: nowrap;\n}\n.iwb-editor-constraint-btn:hover { background: #45475a; transform: scale(1.05); }\n.iwb-editor-constraint-btn.active { background: #4488ff; color: #fff; }\n\n.iwb-editor-constraint-sep {\n width: 1px;\n height: 20px;\n background: #45475a;\n}\n\n.iwb-editor-size-input {\n width: 50px;\n background: #313244;\n border: 1px solid #45475a;\n border-radius: 4px;\n color: #cdd6f4;\n padding: 3px 6px;\n font-size: 12px;\n text-align: center;\n}\n.iwb-editor-size-input:focus { outline: none; border-color: #4488ff; }\n.iwb-editor-size-input::-webkit-inner-spin-button { -webkit-appearance: none; }\n\n.iwb-editor-size-x { color: #7f849c; font-size: 12px; }\n\n.iwb-editor-size-apply {\n background: #313244;\n border: 1px solid #4488ff;\n color: #4488ff;\n border-radius: 4px;\n padding: 3px 8px;\n font-size: 12px;\n cursor: pointer;\n transition: background 0.15s;\n}\n.iwb-editor-size-apply:hover { background: #4488ff; color: #fff; }\n\n.iwb-editor-crop-info {\n color: #e8a735;\n font-size: 12px;\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n min-width: 60px;\n text-align: center;\n}\n\n.iwb-editor-crop-confirm, .iwb-editor-crop-cancel {\n padding: 6px 16px;\n border: none;\n border-radius: 6px;\n font-size: 13px;\n font-weight: 500;\n cursor: pointer;\n}\n.iwb-editor-crop-confirm { background: #1a7f37; color: #fff; }\n.iwb-editor-crop-confirm:hover { background: #15803d; }\n.iwb-editor-crop-cancel { background: #cf222e; color: #fff; }\n.iwb-editor-crop-cancel:hover { background: #b91c1c; }\n\n/* 底部 */\n.iwb-editor-footer {\n display: flex;\n justify-content: flex-end;\n gap: 8px;\n padding: 12px 16px;\n background: #181825;\n border-top: 1px solid #313244;\n}\n\n.iwb-editor-btn {\n padding: 8px 20px;\n border: none;\n border-radius: 6px;\n font-size: 13px;\n font-weight: 500;\n cursor: pointer;\n transition: background 0.15s, transform 0.1s;\n}\n.iwb-editor-btn:hover { transform: scale(1.03); }\n.iwb-editor-btn-cancel { background: #45475a; color: #cdd6f4; }\n.iwb-editor-btn-cancel:hover { background: #585b70; }\n.iwb-editor-btn-new { background: #4488ff; color: #fff; }\n.iwb-editor-btn-new:hover { background: #3578f0; }\n.iwb-editor-btn-replace { background: #e8a735; color: #1e1e2e; }\n.iwb-editor-btn-replace:hover { background: #d49628; }\n\n/* ==================== 图层面板 ==================== */\n\n.iwb-editor-layer-panel {\n width: 290px;\n min-width: 290px;\n background: #181825;\n border-left: 1px solid #313244;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n\n.iwb-editor-layer-panel-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 10px 12px;\n border-bottom: 1px solid #313244;\n}\n\n.iwb-editor-layer-panel-title {\n color: #cdd6f4;\n font-size: 13px;\n font-weight: 600;\n}\n\n.iwb-editor-layer-add-group {\n display: flex;\n gap: 4px;\n}\n\n.iwb-editor-layer-add-btn {\n background: #313244;\n border: 1px solid #45475a;\n border-radius: 6px;\n color: #cdd6f4;\n width: 26px;\n height: 26px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background 0.15s;\n}\n.iwb-editor-layer-add-btn:hover { background: #45475a; color: #e8a735; }\n.iwb-editor-layer-add-btn svg { display: block; }\n\n.iwb-editor-layer-list {\n flex: 1 1 auto;\n overflow-y: auto;\n padding: 4px;\n}\n\n/* 图层项 */\n.iwb-layer-item {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 6px 8px;\n border-radius: 6px;\n cursor: pointer;\n transition: background 0.12s;\n margin-bottom: 2px;\n}\n.iwb-layer-item:hover { background: #313244; }\n.iwb-layer-item.active {\n background: #313244;\n box-shadow: inset 2px 0 0 #e8a735;\n}\n.iwb-layer-item.hidden { opacity: 0.5; }\n.iwb-layer-item[draggable="true"] { cursor: grab; }\n.iwb-layer-item.dragging { opacity: 0.45; }\n.iwb-layer-item.drop-target { outline: 1px dashed #e8a735; background: rgba(232, 167, 53, 0.16); }\n/* 画笔/橡皮作用目标:与「选中」分离,避免出现两个图层同时高亮 */\n.iwb-layer-paint { flex: 0 0 auto; color: #a6adc8; font-size: 11px; opacity: 0.85; }\n.iwb-layer-color { width: 22px; height: 22px; padding: 0; border: 1px solid #45475a; border-radius: 50%; background: transparent; cursor: pointer; flex: 0 0 auto; }\n.iwb-layer-width { width: 42px; height: 22px; padding: 2px 3px; border: 1px solid #45475a; border-radius: 4px; background: #1e1e2e; color: #e8a735; font-size: 11px; text-align: center; flex: 0 0 auto; }\n.iwb-layer-width:focus { outline: none; border-color: #e8a735; }\n\n.iwb-layer-vis {\n background: none;\n border: none;\n color: #a6adc8;\n cursor: pointer;\n font-size: 13px;\n width: 20px;\n height: 20px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n transition: background 0.12s;\n}\n.iwb-layer-vis:hover { background: #45475a; }\n\n.iwb-layer-icon {\n font-size: 13px;\n width: 18px;\n text-align: center;\n flex-shrink: 0;\n}\n\n.iwb-layer-name {\n color: #cdd6f4;\n font-size: 12px;\n flex: 1 1 auto;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n min-width: 0;\n}\n\n.iwb-layer-lock {\n background: none;\n border: none;\n color: #7f849c;\n cursor: pointer;\n width: 20px;\n height: 20px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n transition: background 0.12s, color 0.12s;\n flex-shrink: 0;\n}\n.iwb-layer-lock:hover, .iwb-layer-lock.active { background: #45475a; color: #e8a735; }\n\n.iwb-layer-del {\n background: none;\n border: none;\n color: #585b70;\n cursor: pointer;\n font-size: 12px;\n width: 18px;\n height: 18px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n transition: background 0.12s, color 0.12s;\n flex-shrink: 0;\n}\n.iwb-layer-del:hover { background: #cf222e; color: #fff; }\n\n/* SVG 图标尺寸 */\n.iwb-layer-vis svg { display: block; }\n.iwb-layer-icon svg { display: block; }\n.iwb-layer-lock svg { display: block; }\n.iwb-layer-del svg { display: block; }\n\n/* 独立 PS 风格颜色面板 */\n.iwb-editor-color-panel { padding: 12px; border-bottom: 1px solid #313244; background: #202033; }\n.iwb-editor-color-panel-title { color: #cdd6f4; font-size: 12px; font-weight: 600; margin-bottom: 10px; }\n.iwb-editor-color-panel-main { display: flex; align-items: center; gap: 10px; }\n.iwb-editor-color-current { width: 52px; height: 52px; border: 2px solid #cdd6f4; border-radius: 6px; overflow: hidden; display: block; background: #ff4444; }\n.iwb-editor-color-panel-input { width: 100%; height: 100%; padding: 0; border: 0; cursor: pointer; opacity: 0; }\n.iwb-editor-color-panel-values { min-width: 0; flex: 1; }\n.iwb-editor-color-hex { color: #cdd6f4; font: 600 12px monospace; display: block; margin-bottom: 8px; }\n.iwb-editor-color-swatches { display: flex; flex-wrap: wrap; gap: 6px; }\n.iwb-editor-color-panel-swatch { width: 20px; height: 20px; border: 1px solid #585b70; border-radius: 4px; cursor: pointer; }\n.iwb-editor-color-panel-swatch:hover { transform: scale(1.12); border-color: #fff; }\n.iwb-editor-panel-width { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: #a6adc8; font-size: 11px; }\n.iwb-editor-panel-width-range { flex: 1; min-width: 60px; }\n.iwb-editor-panel-width-num { width: 42px; padding: 3px; background: #313244; color: #e8a735; border: 1px solid #45475a; border-radius: 4px; text-align: center; }\n.iwb-layer-color, .iwb-layer-width { display: none !important; }\n\n/* 顶部独立操作区,避免操作按钮被竖向工具栏裁切 */\n.iwb-editor-actions { display: flex; align-items: center; gap: 5px; margin-left: auto; flex: 0 0 auto; }\n.iwb-editor-actions .iwb-editor-action { position: static !important; }\n.iwb-editor-actions .iwb-editor-action-restore { width: auto; padding: 0 9px; font-size: 12px; }\n\n/* 原图 canvas 只负责绘制像素,透明处透出 stack 的棋盘格。 */\n.iwb-editor-base { background: transparent !important; background-image: none !important; }\n\n/* 透明区域使用 Photoshop 风格的灰色棋盘格,覆盖整个实际图片区域。 */\n.iwb-editor-canvas-stack {\n background-color: #d6d6d6 !important;\n background-image:\n linear-gradient(45deg, #b8b8b8 25%, transparent 25%),\n linear-gradient(-45deg, #b8b8b8 25%, transparent 25%),\n linear-gradient(45deg, transparent 75%, #b8b8b8 75%),\n linear-gradient(-45deg, transparent 75%, #b8b8b8 75%) !important;\n background-size: 20px 20px !important;\n background-position: 0 0, 0 10px, 10px -10px, -10px 0 !important;\n}\n.iwb-editor-base { background: transparent !important; background-image: none !important; }\n\n/* 顶部参数区必须保持可见且可交互,避免被侧栏定位层覆盖。 */\n.iwb-editor-header { position: relative; min-height: 56px; overflow: visible; }\n.iwb-editor-params { position: relative; z-index: 30; overflow: visible; pointer-events: auto; }\n.iwb-editor-params input, .iwb-editor-params button, .iwb-editor-params label { pointer-events: auto; }\n.iwb-editor-brush-size, .iwb-editor-brush-hardness, .iwb-editor-brush-opacity { min-width: 70px; accent-color: #e8a735; }\n.iwb-editor-brush-num, .iwb-editor-eraser-num { pointer-events: auto; }\n\n/* canvas 的透明像素必须透出 stack 棋盘格,不能被黑色工作区遮住。 */\n.iwb-editor-canvas-stack { isolation: isolate; }\n.iwb-editor-layer-canvas, .iwb-editor-text, .iwb-editor-stroke, .iwb-editor-crop-overlay { background: transparent !important; }\n\n/* 透明棋盘格只覆盖原图的显示矩形,外围裁剪扩展区保持纯色。 */\n.iwb-editor-canvas-stack { background: #11111b !important; background-image: none !important; }\n.iwb-editor-transparency-grid { position: absolute; z-index: 0; pointer-events: none; background-color: #d6d6d6; background-image: linear-gradient(45deg, #b8b8b8 25%, transparent 25%), linear-gradient(-45deg, #b8b8b8 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #b8b8b8 75%), linear-gradient(-45deg, transparent 75%, #b8b8b8 75%); background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0; }\n.iwb-editor-layer-canvas, .iwb-editor-stroke, .iwb-editor-text { z-index: 1; }\n.iwb-editor-crop-overlay { z-index: 10; }\n\n/* 画布扩展区不得盖过编辑器外围,图片区域由透明层单独标识。 */\n.iwb-editor-canvas-stack { overflow: visible; max-width: 100%; max-height: 100%; background: #11111b !important; background-image: none !important; }\n.iwb-editor-transparency-grid { z-index: 0; overflow: hidden; }\n.iwb-editor-layer-canvas { z-index: 1; }\n.iwb-editor-stroke { z-index: 4; }\n.iwb-editor-text { z-index: 5; }\n.iwb-editor-crop-overlay { z-index: 10; }\n\n/* 导出操作与缩放同处顶栏,缩放独立靠右。 */\n.iwb-editor-export-actions { display: flex; align-items: center; gap: 6px; margin-left: 10px; flex: 0 0 auto; }\n.iwb-editor-export-actions .iwb-editor-btn { padding: 6px 10px; font-size: 11px; }\n.iwb-editor-footer { display: none !important; }\n.iwb-layer-color, .iwb-layer-width { display: none !important; }\n\n.iwb-editor-export-actions { display: flex; align-items: center; gap: 6px; margin-left: 10px; flex: 0 0 auto; }\n.iwb-editor-export-actions .iwb-editor-btn { padding: 6px 10px; font-size: 11px; }\n.iwb-editor-footer { display: none !important; }\n.iwb-layer-color, .iwb-layer-width { display: none !important; }\n\n/* 顶部七个操作按钮统一文本按钮样式,自适应中文宽度。 */\n.iwb-editor-actions { gap: 6px; }\n.iwb-editor-actions .iwb-editor-action { width: auto; min-width: 72px; height: 32px; padding: 0 12px; gap: 5px; font-size: 12px; font-weight: 500; white-space: nowrap; }\n.iwb-editor-actions .iwb-editor-action svg { width: 14px; height: 14px; flex: 0 0 auto; }\n.iwb-editor-export-actions .iwb-editor-btn { min-width: 72px; white-space: nowrap; }\n\n/* 顶部操作按钮统一为纯文本,图标隐藏并保持一致宽度。 */\n.iwb-editor-actions .iwb-editor-action svg { display: none !important; }\n.iwb-editor-actions .iwb-editor-action { min-width: 76px; width: 76px; justify-content: center; background: #3b3d52; color: #cdd6f4; }\n.iwb-editor-actions .iwb-editor-action:hover { background: #50536b; }\n.iwb-editor-actions .iwb-editor-action-restore { background: #3b3d52; color: #cdd6f4; }\n.iwb-editor-actions .iwb-editor-action-restore:hover { background: #50536b !important; }\n\n.iwb-editor-actions .iwb-editor-action svg { display: none !important; }\n.iwb-editor-actions .iwb-editor-action { min-width: 76px; width: 76px; justify-content: center; background: #3b3d52; color: #cdd6f4; }\n.iwb-editor-actions .iwb-editor-action:hover, .iwb-editor-actions .iwb-editor-action-restore:hover { background: #50536b !important; }\n\n.iwb-editor-actions .iwb-editor-action { width: auto; min-width: 76px; padding: 0 12px; gap: 5px; }\n.iwb-editor-actions .iwb-editor-action span { display: inline-block; }\n\n.iwb-editor-actions { margin-left: 12px; }\n.iwb-editor-actions .iwb-editor-btn { width: auto; min-width: 76px; height: 32px; padding: 0 12px; font-size: 12px; white-space: nowrap; }\n.iwb-editor-actions .iwb-editor-action { width: auto; min-width: 76px; }\n\n.iwb-editor-actions .iwb-editor-action { min-width: 52px; width: auto; padding: 0 10px; font-size: 12px; }\n.iwb-editor-brush-presets { display: flex; align-items: center; gap: 7px; margin-left: 4px; }\n.iwb-editor-brush-preset { display: inline-flex; align-items: center; gap: 3px; padding: 2px 3px; border: 0; background: transparent; color: #a6adc8; cursor: pointer; font-size: 11px; }\n.iwb-editor-brush-preset i { display: block; width: 12px; height: 12px; border-radius: 50%; background: #e8a735; border: 1px solid #f6d38a; }\n.iwb-editor-brush-preset:nth-child(2) i { width: 16px; height: 16px; }\n.iwb-editor-brush-preset:nth-child(3) i { width: 20px; height: 20px; }\n.iwb-editor-brush-preset:nth-child(4) i { width: 24px; height: 24px; }\n.iwb-editor-brush-preset:hover, .iwb-editor-brush-preset.active { color: #fff; }\n\n/* 紧凑顶栏:操作按钮与描边快捷点仅保留必要视觉信息。 */\n.iwb-editor-actions .iwb-editor-action { width: 28px; min-width: 28px; height: 28px; padding: 0; }\n.iwb-editor-actions .iwb-editor-action svg { display: block !important; width: 14px; height: 14px; }\n.iwb-editor-brush-presets { gap: 5px; margin-left: 2px; }\n.iwb-editor-brush-preset { width: 24px; height: 24px; padding: 0; justify-content: center; }\n.iwb-editor-brush-preset i { width: 5px; height: 5px; }\n.iwb-editor-brush-preset:nth-child(2) i { width: 8px; height: 8px; }\n.iwb-editor-brush-preset:nth-child(3) i { width: 12px; height: 12px; }\n.iwb-editor-brush-preset:nth-child(4) i { width: 16px; height: 16px; }\n\n/* 图层栏内嵌调色板:颜色直接点击应用,不弹出系统取色器。 */\n.iwb-editor-color-panel { padding: 10px; }\n.iwb-editor-color-current { width: 42px; height: 42px; flex: 0 0 42px; cursor: default; }\n.iwb-editor-color-swatches { display: grid; grid-template-columns: repeat(7, 20px); gap: 5px; }\n.iwb-editor-color-panel-swatch { width: 20px; height: 20px; border-radius: 50%; }\n\n.iwb-editor-color-panel { padding: 10px; }\n.iwb-editor-color-current { width: 42px; height: 42px; flex: 0 0 42px; cursor: default; }\n.iwb-editor-color-swatches { display: grid; grid-template-columns: repeat(7, 20px); gap: 5px; }\n.iwb-editor-color-panel-swatch { width: 20px; height: 20px; border-radius: 50%; }\n\n.iwb-editor-color-panel { padding: 10px; }\n.iwb-editor-palette-current { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }\n.iwb-editor-palette-current .iwb-editor-color-current { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 4px; }\n.iwb-editor-color-panel .iwb-editor-color-hex { margin: 0; }\n.iwb-editor-color-panel .iwb-editor-color-swatches { display: grid; grid-template-columns: repeat(6, 20px); gap: 7px; }\n.iwb-editor-color-panel .iwb-editor-color-panel-swatch { width: 20px; height: 20px; border-radius: 50%; padding: 0; }\n.iwb-editor-color-panel .iwb-editor-color-panel-swatch.active { outline: 2px solid #fff; outline-offset: 2px; }\n\n.iwb-editor-color-panel { padding: 10px; }\n.iwb-editor-palette-current { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }\n.iwb-editor-palette-current .iwb-editor-color-current { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 4px; }\n.iwb-editor-color-panel .iwb-editor-color-hex { margin: 0; }\n.iwb-editor-color-panel .iwb-editor-color-swatches { display: grid; grid-template-columns: repeat(6, 20px); gap: 7px; }\n.iwb-editor-color-panel .iwb-editor-color-panel-swatch { width: 20px; height: 20px; border-radius: 50%; padding: 0; }\n.iwb-editor-color-panel .iwb-editor-color-panel-swatch.active { outline: 2px solid #fff; outline-offset: 2px; }\n\n.iwb-editor-inline-picker { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }\n.iwb-editor-inline-picker .iwb-editor-color-panel-input { width: 42px; height: 28px; padding: 0; opacity: 1; cursor: pointer; border: 1px solid #585b70; border-radius: 4px; }\n.iwb-editor-color-panel .iwb-editor-color-swatches { display: grid; grid-template-columns: repeat(6, 20px); gap: 7px; }\n.iwb-editor-color-panel .iwb-editor-color-panel-swatch { width: 20px; height: 20px; border-radius: 50%; padding: 0; }\n\n.iwb-editor-inline-picker { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }\n.iwb-editor-inline-picker .iwb-editor-color-panel-input { width: 42px; height: 28px; padding: 0; opacity: 1; cursor: pointer; border: 1px solid #585b70; border-radius: 4px; }\n.iwb-editor-color-panel .iwb-editor-color-swatches { display: grid; grid-template-columns: repeat(6, 20px); gap: 7px; }\n.iwb-editor-color-panel .iwb-editor-color-panel-swatch { width: 20px; height: 20px; border-radius: 50%; padding: 0; }\n\n.iwb-editor-inline-picker { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }\n.iwb-editor-inline-picker .iwb-editor-color-panel-input { width: 42px; height: 28px; padding: 0; opacity: 1; cursor: pointer; border: 1px solid #585b70; border-radius: 4px; }\n.iwb-editor-color-panel .iwb-editor-color-swatches { display: grid; grid-template-columns: repeat(6, 20px); gap: 7px; }\n.iwb-editor-color-panel .iwb-editor-color-panel-swatch { width: 20px; height: 20px; border-radius: 50%; padding: 0; }\n\n.iwb-editor-color-panel { padding: 9px; }\n.iwb-editor-inline-picker { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }\n.iwb-editor-inline-picker .iwb-editor-color-panel-input { display: block; width: 44px; height: 30px; padding: 0; opacity: 1; cursor: pointer; border: 1px solid #585b70; border-radius: 4px; }\n.iwb-editor-color-panel .iwb-editor-color-swatches { display: grid; grid-template-columns: repeat(6, 20px); gap: 7px; }\n.iwb-editor-color-panel .iwb-editor-color-panel-swatch { width: 20px; height: 20px; border-radius: 50%; padding: 0; }\n.iwb-editor-color-panel .iwb-editor-color-panel-swatch.active { outline: 2px solid #fff; outline-offset: 2px; }\n\n.iwb-editor-color-picker2 { display: flex; gap: 8px; height: 118px; }\n.iwb-color-sv { position: relative; flex: 1; background: linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,rgba(255,255,255,0)); background-color: #f44; border-radius: 4px; }\n.iwb-color-hue { width: 18px; border-radius: 4px; background: linear-gradient(to bottom,#f00,#ff0,#0f0,#0ff,#00f,#f0f,#f00); }\n.iwb-editor-color-fields { display: flex; gap: 6px; margin: 8px 0; }\n.iwb-editor-color-hex-input { width: 72px; background:#313244; color:#cdd6f4; border:1px solid #585b70; padding:4px; }\n.iwb-editor-color-panel-input { width: 32px; height: 26px; opacity: 1; padding: 0; }\n\n.iwb-color-sv span, .iwb-color-hue span { position: absolute; width: 10px; height: 10px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px #222; transform: translate(-50%, -50%); pointer-events: none; }\n.iwb-color-sv span { left: 100%; top: 0; }\n.iwb-color-hue span { left: 50%; top: 0; }\n\n.iwb-compress-btn { color: #16a34a !important; font-size: 11px; font-weight: 700; }\n\n/* 新版浮动气泡栏内的工具按钮 */\n.iwb-node-floatbar .iwb-compress-btn { font-size: 11px; font-weight: 700; }\n.iwb-node-floatbar .iwb-cutout-btn.processing,\n.iwb-node-floatbar .iwb-whitebg-btn.processing,\n.iwb-node-floatbar .iwb-compress-btn.processing { animation: iwb-cutout-pulse 1s infinite; pointer-events: none; }\n\n\n/* 调色板:吸色按钮(替代原来的弹出式取色器) */\n.iwb-editor-color-eye { width: 26px; height: 26px; border: 1px solid #585b70; border-radius: 4px; background: #313244; color: #cdd6f4; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; }\n.iwb-editor-color-eye:hover { border-color: #e8a735; color: #e8a735; }\n\n/* 矢量对象独立画布:与位图图层统一参与 z 排序 */\n.iwb-editor-vec-canvas { position: absolute; top: 0; left: 0; z-index: 1; background: transparent !important; }\n\n/* 空白画布创建菜单 */\n.iwb-blank-menu { position: fixed; width: 242px; background: #fff; border: 1px solid #d0d7de; border-radius: 12px; box-shadow: 0 12px 32px rgba(15,23,42,.2); padding: 10px; z-index: 2147483000; font-size: 12px; color: #1f2328; }\n.iwb-blank-menu .iwb-blank-title { font-weight: 700; font-size: 12px; margin-bottom: 8px; }\n.iwb-blank-menu .iwb-blank-bg, .iwb-blank-menu .iwb-blank-res { display: flex; align-items: center; gap: 5px; margin-bottom: 7px; }\n.iwb-blank-menu .iwb-blank-bg span, .iwb-blank-menu .iwb-blank-res span { color: #656d76; min-width: 26px; }\n.iwb-blank-menu button { border: 1px solid #d0d7de; background: #f6f8fa; color: #1f2328; border-radius: 6px; padding: 3px 8px; cursor: pointer; font-size: 11px; }\n.iwb-blank-menu button:hover { background: #eff2f4; }\n.iwb-blank-menu button.on { background: #0ea5e9; border-color: #0ea5e9; color: #fff; }\n.iwb-blank-menu .iwb-blank-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 4px; }\n.iwb-blank-menu .iwb-blank-grid button { display: flex; flex-direction: column; gap: 1px; align-items: center; padding: 5px 4px; }\n.iwb-blank-menu .iwb-blank-grid b { font-weight: 600; }\n.iwb-blank-menu .iwb-blank-grid i { font-style: normal; color: #656d76; font-size: 10px; }\n\n/* 空参考图节点:常驻“空白画布”按钮(位于节点顶部中央) */\n.iwb-blank-inline-btn { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 6; display: inline-flex; align-items: center; gap: 5px; background: #fff; border: 1px solid #d0d7de; border-radius: 14px; padding: 4px 11px; color: #0ea5e9; font-size: 11px; font-weight: 600; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }\n.iwb-blank-inline-btn:hover { background: #f0f9ff; border-color: #0ea5e9; }\n.iwb-blank-inline-btn svg { width: 13px; height: 13px; }\n\n/* ============ UI 布局重构(参照 excalidraw) ============ */\n/* 顶部:功能按钮在左,工具栏横排整行、按快捷键排序并带数字角标 */\n.iwb-editor-header { flex-wrap: wrap; }\n.iwb-editor-header > .iwb-editor-title { order: 1; }\n.iwb-editor-header > .iwb-editor-actions { order: 2; }\n.iwb-editor-header > .iwb-editor-tools {\n position: static;\n order: 3;\n flex: 1 1 100%;\n width: auto;\n left: auto;\n top: auto;\n margin-top: 8px;\n flex-direction: row;\n justify-content: center;\n padding: 6px 10px;\n border-radius: 10px;\n}\n.iwb-editor-tool { position: relative; }\n.iwb-tool-key {\n position: absolute;\n right: -3px;\n bottom: -3px;\n font-size: 8px;\n line-height: 1;\n background: #45475a;\n color: #cdd6f4;\n padding: 1px 3px;\n border-radius: 3px;\n pointer-events: none;\n font-style: normal;\n font-weight: 600;\n}\n.iwb-editor-tool.active .iwb-tool-key { background: #1e1e2e; color: #e8a735; }\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-divider { width: 1px; height: 22px; margin: 0 6px; }\n\n/* 左侧:工具参数设定栏(缩放/实心/图层/描边/硬度/透明度) */\n.iwb-editor-params {\n width: 216px;\n min-width: 216px;\n flex: 0 0 216px;\n flex-direction: column;\n align-items: stretch;\n gap: 12px;\n margin-left: 0;\n padding: 14px 12px;\n background: #181825;\n border-right: 1px solid #313244;\n overflow-y: auto;\n}\n.iwb-editor-params .iwb-editor-zoom { margin-left: 0; order: 0; }\n.iwb-editor-params .iwb-editor-zoom .iwb-editor-zoom-val { min-width: 52px; text-align: center; }\n.iwb-editor-params .iwb-editor-layer-group { flex-wrap: wrap; justify-content: flex-start; }\n.iwb-editor-params .iwb-editor-brush-label { width: 100%; }\n.iwb-editor-params .iwb-editor-brush-presets { justify-content: flex-start; }\n.iwb-editor-params .iwb-editor-fill-btn { align-self: stretch; }\n.iwb-editor-main { display: flex; flex-direction: row; }\n\n/* ======== 布局重构 v2(按用户 6 点) ======== */\n.iwb-editor-main { display: flex; flex-direction: row; align-items: stretch; }\n\n/* 顶部一行:标题 + 工具栏(含数字角标) + 撤销重做清空还原 */\n.iwb-editor-header { flex-wrap: nowrap; align-items: center; }\n.iwb-editor-header > .iwb-editor-title { order: 0; }\n.iwb-editor-header > .iwb-editor-tools {\n position: static; order: 1; flex: 1 1 auto; flex-basis: auto;\n margin-top: 0; width: auto; left: auto; top: auto;\n flex-direction: row; justify-content: center;\n padding: 0; background: transparent; border: 0; border-radius: 0;\n}\n.iwb-editor-header > .iwb-editor-divider { order: 2; }\n.iwb-editor-header > .iwb-editor-history { order: 3; display: flex; align-items: center; gap: 4px; }\n\n/* 左栏:调色板在上,参数竖排,导出按钮底部 */\n.iwb-editor-left {\n width: 240px; min-width: 240px; flex: 0 0 240px;\n display: flex; flex-direction: column; gap: 14px;\n padding: 12px; background: #181825; border-right: 1px solid #313244; overflow-y: auto;\n}\n.iwb-editor-left > .iwb-editor-color-panel { padding: 0; background: transparent; border-bottom: 0; }\n.iwb-editor-left > .iwb-editor-params {\n width: auto; min-width: 0; flex: 1 1 auto;\n flex-direction: column; align-items: stretch; gap: 12px; margin-left: 0; padding: 0;\n}\n.iwb-editor-left > .iwb-editor-export-actions {\n display: flex; flex-direction: column; gap: 8px;\n margin-top: auto; padding-top: 12px; border-top: 1px solid #313244;\n}\n.iwb-editor-left > .iwb-editor-export-actions .iwb-editor-btn { width: 100%; }\n\n/* 参数竖排:一行一个设置 */\n.iwb-editor-params .iwb-editor-brush-group { display: flex; flex-direction: column; gap: 10px; }\n.iwb-editor-params .iwb-editor-zoom .iwb-editor-zoom-btn,\n.iwb-editor-params .iwb-editor-zoom .iwb-editor-zoom-val { flex: 1 1 auto; }\n.iwb-editor-params .iwb-editor-layer-group { flex-wrap: wrap; }\n\n/* 颜色值后面的 实心/边线 切换 */\n.iwb-editor-fill-pair { display: inline-flex; margin-left: 6px; }\n.iwb-editor-fill-pair .iwb-editor-fill-btn { align-self: center; }\n\n/* ======== 布局优化 v3 ======== */\n/* 左栏可交互(避免被画布/层级遮挡导致“调节不起作用”) */\n.iwb-editor-left { position: relative; z-index: 40; pointer-events: auto; }\n.iwb-editor-left input, .iwb-editor-left select, .iwb-editor-left button, .iwb-editor-left label { pointer-events: auto; }\n\n/* 顶部工具栏内的 面/边(实心) 切换按钮 */\n.iwb-editor-tools .iwb-editor-fill-btn {\n width: 42px; height: 32px; padding: 0; border: 0; border-radius: 8px;\n background: transparent; color: #cdd6f4; cursor: pointer; font-size: 11px; font-weight: 600;\n}\n.iwb-editor-tools .iwb-editor-fill-btn:hover { background: #45475a; }\n.iwb-editor-tools .iwb-editor-fill-btn.active { background: #e8a735; color: #1e1e2e; }\n\n/* 右侧图层面板内的图层顺序按钮 */\n.iwb-editor-layer-panel .iwb-editor-layer-group {\n display: flex; align-items: center; gap: 6px;\n padding: 10px 12px; border-bottom: 1px solid #313244;\n}\n.iwb-editor-layer-panel .iwb-editor-layer-group .iwb-editor-constraint-label { color: #a6adc8; font-size: 12px; margin-right: 2px; }\n\n/* 缩放(画面调整)移到左栏下方 */\n.iwb-editor-params .iwb-editor-zoom {\n order: 99; margin-top: 10px; padding-top: 10px; border-top: 1px solid #313244;\n}\n.iwb-editor-params .iwb-editor-zoom .iwb-editor-zoom-btn { flex: 0 0 auto; }\n.iwb-editor-params .iwb-editor-zoom .iwb-editor-zoom-val { flex: 0 0 auto; }\n\n/* ======== 布局优化 v4 ======== */\n/* 交换左右栏:图层在左,调色板/参数在右 */\n.iwb-editor-main { flex-direction: row; }\n.iwb-editor-main > .iwb-editor-layer-panel { order: 1; border-left: 0; border-right: 1px solid #313244; }\n.iwb-editor-main > .iwb-editor-canvas-wrap { order: 2; }\n.iwb-editor-left { order: 3; border-right: 0; border-left: 1px solid #313244; }\n\n/* 硬度/透明度 数值与滑块对齐 */\n.iwb-editor-params .iwb-editor-brush-label .iwb-editor-brush-hardness-val,\n.iwb-editor-params .iwb-editor-brush-label .iwb-editor-brush-opacity-val {\n min-width: 40px; text-align: right; color: #cdd6f4; font-size: 12px;\n}\n.iwb-editor-params .iwb-editor-brush-label input[type="range"] { flex: 1 1 auto; }\n\n/* 缩放块放在参数区最底部 */\n.iwb-editor-params .iwb-editor-zoom, .iwb-editor-left .iwb-editor-zoom {\n display: flex; align-items: center; justify-content: center; gap: 8px;\n width: 100%; padding: 8px 4px; border-top: 1px solid #313244; margin-top: 12px;\n}\n.iwb-editor-left .iwb-editor-zoom .iwb-editor-zoom-btn {\n flex: 0 0 auto; min-width: 28px; height: 26px; background: #313244; color: #cdd6f4; border: 0; border-radius: 6px; cursor: pointer; font-size: 14px;\n}\n.iwb-editor-left .iwb-editor-zoom .iwb-editor-zoom-btn:hover { background: #45475a; }\n.iwb-editor-left .iwb-editor-zoom .iwb-editor-zoom-val { min-width: 52px; text-align: center; color: #cdd6f4; font: 600 12px sans-serif; }\n\n/* 调色板与下方参数调节之间的横线分割 */\n.iwb-editor-params { border-top: 1px solid #313244; padding-top: 12px; }\n\n/* 色相条指示器需定位父级相对 */\n.iwb-color-hue { position: relative; }\n\n/* 顶部实心按钮与工具匹配:默认背景 */\n.iwb-editor-tools .iwb-editor-fill-btn { background: #313244; color: #cdd6f4; }\n\n/* 裁剪工具条:三行展示(比例 / 尺寸 / 确认取消),避免被挤压 */\n.iwb-editor-crop-bar {\n display: flex;\n flex-direction: column;\n gap: 8px;\n align-items: center;\n padding: 10px 14px;\n}\n.iwb-editor-crop-row { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; width: 100%; gap: 6px; }\n.iwb-editor-crop-row .iwb-editor-constraint-group { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }\n.iwb-editor-crop-actions { gap: 10px; }\n.iwb-editor-crop-actions .iwb-editor-crop-info { min-width: 88px; text-align: center; }\n.iwb-editor-constraint-sep { display: none; }\n\n/* ======== 修复:左列(图层)占满高度,三列稳定布局 ======== */\n.iwb-editor-main { display: flex; flex-direction: row; align-items: stretch; }\n.iwb-editor-main > .iwb-editor-layer-panel { flex: 0 0 290px; min-width: 290px; width: 290px; }\n.iwb-editor-main > .iwb-editor-canvas-wrap { flex: 1 1 auto; min-width: 0; }\n.iwb-editor-left { flex: 0 0 240px; min-width: 240px; width: 240px; }\n.iwb-editor-layer-panel .iwb-editor-layer-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; }\n\n/* ======== 顶部布局 v5:左侧重置类 / 中间工具 / 右侧保存类 ======== */\n.iwb-editor-header > .iwb-editor-title { order: 0; }\n.iwb-editor-header > .iwb-editor-history { order: 1; display: flex; align-items: center; gap: 4px; }\n.iwb-editor-header > .iwb-editor-tools { order: 2; flex: 1 1 auto; justify-content: center; }\n.iwb-editor-header > .iwb-editor-export-actions { order: 3; display: flex; align-items: center; gap: 6px; margin-left: 4px; }\n\n/* 重置类(撤销/重做/清空/复原)统一小圆角按钮 */\n.iwb-editor-header .iwb-editor-history .iwb-editor-action {\n width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px;\n background: #313244; color: #cdd6f4; display: inline-flex; align-items: center; justify-content: center; cursor: pointer;\n}\n.iwb-editor-header .iwb-editor-history .iwb-editor-action:hover { background: #45475a; }\n.iwb-editor-header .iwb-editor-history .iwb-editor-action-restore { background: #313244; color: #cdd6f4; }\n\n/* 保存类(新建/覆盖/退出)统一样式 */\n.iwb-editor-header .iwb-editor-export-actions .iwb-editor-btn {\n height: 30px; padding: 0 14px; border: 0; border-radius: 8px; font-size: 12px; font-weight: 600;\n background: #313244; color: #cdd6f4; cursor: pointer;\n}\n.iwb-editor-header .iwb-editor-export-actions .iwb-editor-btn:hover { background: #45475a; }\n\n/* 调色板与参数之间的分割线及间距 */\n.iwb-editor-left > .iwb-editor-params { border-top: 1px solid #313244; margin-top: 16px; padding-top: 16px; }\n\n/* 笔刷快捷值 7 档圆点 */\n.iwb-editor-brush-presets { display: flex; align-items: center; gap: 8px; }\n.iwb-editor-brush-preset i { width: 6px; height: 6px; }\n.iwb-editor-brush-preset:nth-child(2) i { width: 8px; height: 8px; }\n.iwb-editor-brush-preset:nth-child(3) i { width: 10px; height: 10px; }\n.iwb-editor-brush-preset:nth-child(4) i { width: 13px; height: 13px; }\n.iwb-editor-brush-preset:nth-child(5) i { width: 16px; height: 16px; }\n.iwb-editor-brush-preset:nth-child(6) i { width: 20px; height: 20px; }\n.iwb-editor-brush-preset:nth-child(7) i { width: 24px; height: 24px; }\n\n/* 缩放:缩小比例、圆角 */\n.iwb-editor-left .iwb-editor-zoom { gap: 6px; padding: 6px 4px; margin-top: 10px; }\n.iwb-editor-left .iwb-editor-zoom .iwb-editor-zoom-btn { min-width: 26px; height: 24px; border-radius: 8px; font-size: 13px; }\n.iwb-editor-left .iwb-editor-zoom .iwb-editor-zoom-val { min-width: 44px; font-size: 11px; }\n.iwb-editor-left .iwb-editor-zoom .iwb-editor-zoom-fit { font-size: 11px; padding: 0 8px; }\n\n/* 笔刷快捷值:压缩横向间距,避免右栏出现横向滚动条 */\n.iwb-editor-left { overflow-x: hidden; }\n.iwb-editor-params { overflow-x: hidden; }\n.iwb-editor-brush-presets { gap: 3px; flex-wrap: wrap; max-width: 100%; justify-content: flex-start; }\n.iwb-editor-brush-preset { padding: 0 1px; min-width: 0; flex: 0 0 auto; }\n.iwb-editor-brush-preset i { width: 5px; height: 5px; }\n.iwb-editor-brush-preset:nth-child(2) i { width: 7px; height: 7px; }\n.iwb-editor-brush-preset:nth-child(3) i { width: 9px; height: 9px; }\n.iwb-editor-brush-preset:nth-child(4) i { width: 11px; height: 11px; }\n.iwb-editor-brush-preset:nth-child(5) i { width: 14px; height: 14px; }\n.iwb-editor-brush-preset:nth-child(6) i { width: 17px; height: 17px; }\n.iwb-editor-brush-preset:nth-child(7) i { width: 20px; height: 20px; }\n\n/* 去掉参数模块右侧的边线(隐藏纵向滚动条与右边框) */\n.iwb-editor-left { border-right: 0 !important; scrollbar-width: none; -ms-overflow-style: none; }\n.iwb-editor-left::-webkit-scrollbar { width: 0; height: 0; display: none; }\n.iwb-editor-left > .iwb-editor-params { border-right: 0; }\n.iwb-editor-brush-presets::-webkit-scrollbar { width: 0; height: 0; display: none; }\n\n/* 独立悬浮工具条(扩展自建,不插入应用 React DOM) */\n.iwb-cutout-toolbar {\n position: fixed; z-index: 2147483000; display: none; align-items: center; gap: 3px;\n padding: 4px 6px; border-radius: 14px; background: #fff;\n border: 1px solid #d0d7de; box-shadow: 0 8px 28px rgba(15, 23, 42, 0.14);\n pointer-events: auto;\n}\n.iwb-cutout-toolbar button {\n width: 30px; height: 28px; padding: 0; border: 0; border-radius: 8px;\n background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;\n}\n.iwb-cutout-toolbar button:hover { background: #eef2f7; }\n.iwb-cutout-toolbar button i { font-style: normal; font-size: 11px; font-weight: 700; }\n.iwb-cutout-toolbar button svg { display: block; }\n\n/* 顶部左右两组工具交换:左=新建/覆盖/退出,右=撤销/重做/清空/复原 */\n.iwb-editor-header > .iwb-editor-title { order: 0; }\n/* 输出设定 + 下载/新建/覆盖/退出 收在顶栏最右侧(用户裁定 2026-11-04):\n order 排最后 + margin-left:auto 兜底,中间工具区 flex:1 会把它顶到右端 */\n.iwb-editor-header > .iwb-editor-export-actions { order: 9; margin-left: auto; margin-right: 0; flex: 0 0 auto; }\n.iwb-editor-header > .iwb-editor-tools { order: 2; flex: 1 1 auto; justify-content: center; }\n.iwb-editor-header > .iwb-editor-history { order: 3; margin-left: 0; }\n\n/* 图层面板:放大锁定 / 删除按钮的点击区域与图标 */\n.iwb-editor-layer-panel .iwb-layer-lock,\n.iwb-editor-layer-panel .iwb-layer-del {\n width: 24px; height: 24px; padding: 0; display: inline-flex; align-items: center; justify-content: center;\n}\n.iwb-editor-layer-panel .iwb-layer-lock svg,\n.iwb-editor-layer-panel .iwb-layer-del svg { width: 16px; height: 16px; }\n\n\n/* 图层按钮图标统一 14px */\n.iwb-editor-layer-panel .iwb-layer-vis svg,\n.iwb-editor-layer-panel .iwb-layer-lock svg,\n.iwb-editor-layer-panel .iwb-layer-del svg { width: 14px; height: 14px; }\n.iwb-editor-layer-panel .iwb-layer-vis,\n.iwb-editor-layer-panel .iwb-layer-lock,\n.iwb-editor-layer-panel .iwb-layer-del { width: 22px; height: 22px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }\n\n/* ================================================================\n v1.1 便利版 UI(单张处理)\n 只追加、不重写历史样式:旧规则里的魔数定位在这里统一覆盖。\n 分区:顶栏 / 就地选项栏 / 竖工具栏 / 画布浮层 / 状态栏 / toast\n ================================================================ */\n\n/* ---- 顶栏:精简、一步可达 ---- */\n.iwb-editor-header { min-height: 44px; padding: 6px 12px; gap: 8px; }\n.iwb-editor-title em.iwb-editor-doc-size { font-style: normal; font-weight: 400; font-size: 11px; color: #7f849c; margin-left: 6px; }\n.iwb-editor-optionbar {\n display: flex; align-items: center; gap: 10px;\n height: 36px; min-height: 36px; padding: 0 12px;\n background: #202033; border-bottom: 1px solid #313244;\n color: #a6adc8; font-size: 12px;\n}\n.iwb-editor-optionbar-label { color: #7f849c; font-weight: 600; white-space: nowrap; }\n.iwb-editor-optionbar-body { display: flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; }\n.iwb-opt-label { color: #a6adc8; white-space: nowrap; }\n.iwb-opt-btn {\n background: #313244; color: #cdd6f4; border: 1px solid transparent; border-radius: 5px;\n padding: 3px 9px; font-size: 12px; cursor: pointer;\n}\n.iwb-opt-btn:hover { background: #45475a; }\n.iwb-opt-btn.active { background: #4488ff; color: #fff; }\n.iwb-opt-num {\n width: 46px; padding: 2px 4px; background: #313244; color: #e8a735;\n border: 1px solid #45475a; border-radius: 5px; text-align: center; font-size: 12px;\n}\n.iwb-opt-current { color: #e8a735; font-weight: 600; white-space: nowrap; }\n.iwb-opt-hint { color: #7f849c; font-size: 11px; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n\n.iwb-editor-more-wrap, .iwb-editor-export-settings-wrap { position: relative; flex: 0 0 auto; z-index: 45; }\n.iwb-editor-more-btn, .iwb-editor-panel-toggle, .iwb-editor-export-settings-btn {\n background: #313244; color: #cdd6f4; border: 1px solid #45475a; border-radius: 6px;\n padding: 5px 10px; font-size: 12px; cursor: pointer; white-space: nowrap;\n}\n.iwb-editor-more-btn:hover, .iwb-editor-panel-toggle:hover, .iwb-editor-export-settings-btn:hover { background: #45475a; }\n.iwb-editor-panel-toggle { padding: 5px 8px; }\n.iwb-editor-export-summary { color: #e8a735; margin: 0 2px; }\n\n.iwb-editor-more-menu, .iwb-editor-export-settings {\n display: none; position: absolute; top: 34px; z-index: 60;\n background: #252537; border: 1px solid #45475a; border-radius: 8px;\n padding: 6px; box-shadow: 0 10px 30px rgba(0,0,0,0.45);\n}\n.iwb-editor-more-menu { left: 0; width: 206px; flex-direction: column; gap: 2px; }\n.iwb-editor-more-menu.open, .iwb-editor-export-settings.open { display: flex; flex-direction: column; gap: 4px; }\n.iwb-editor-export-settings { right: 0; width: 268px; }\n.iwb-editor-more-menu button, .iwb-editor-export-row button {\n background: transparent; color: #cdd6f4; border: 0; border-radius: 5px;\n padding: 6px 8px; font-size: 12px; text-align: left; cursor: pointer; white-space: nowrap;\n}\n.iwb-editor-more-menu button:hover, .iwb-editor-export-row button:hover { background: #3b3d52; }\n.iwb-editor-more-menu kbd { float: right; color: #7f849c; font-size: 10px; }\n.iwb-editor-more-sep { height: 1px; background: #45475a; margin: 4px 0; }\n.iwb-editor-export-row { display: flex; align-items: center; gap: 4px; }\n.iwb-editor-export-row > span { width: 34px; flex: 0 0 34px; color: #7f849c; font-size: 11px; }\n.iwb-editor-export-row button { flex: 1 1 auto; text-align: center; background: #313244; }\n.iwb-editor-export-row button.active { background: #4488ff; color: #fff; }\n.iwb-editor-export-note { color: #7f849c; font-size: 11px; border-top: 1px solid #313244; padding-top: 6px; }\n.iwb-editor-btn-download { background: #1a7f37 !important; color: #fff !important; }\n.iwb-editor-btn-download:hover { background: #15803d !important; }\n\n/* ---- v1.2.8:底部浮动工具栏(Figma 风格,横排悬浮在画布底部居中) ----\n 工具栏已从 header 移进 canvas-wrap,只占画布区域宽度,不挤压左右面板;\n bottom 距容器 14px,配合 computeFit() 预留的底部空间,图片不会被压住。 */\n.iwb-editor-canvas-wrap > .iwb-editor-tools {\n position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);\n display: flex; flex-direction: row; align-items: center; gap: 2px;\n padding: 5px 8px; border-radius: 14px;\n background: rgba(24, 24, 37, 0.94);\n border: 1px solid #313244;\n box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);\n -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);\n z-index: 40;\n max-width: calc(100% - 28px);\n overflow-x: auto; overflow-y: hidden; scrollbar-width: none;\n}\n.iwb-editor-canvas-wrap > .iwb-editor-tools::-webkit-scrollbar { display: none; }\n.iwb-editor-canvas-wrap > .iwb-editor-tools .iwb-editor-tool,\n.iwb-editor-canvas-wrap > .iwb-editor-tools .iwb-editor-action {\n width: 32px !important; height: 32px !important; min-width: 32px; flex: 0 0 auto; border-radius: 9px;\n}\n.iwb-editor-canvas-wrap > .iwb-editor-tools .iwb-editor-divider {\n width: 1px; height: 20px; margin: 0 5px; flex: 0 0 auto; background: #45475a;\n}\n.iwb-editor-main { padding-left: 0; }\n.iwb-editor-main > .iwb-editor-layer-panel { flex: 0 0 260px !important; min-width: 260px !important; width: 260px !important; }\n.iwb-editor-left { flex: 0 0 220px !important; min-width: 220px !important; width: 220px !important; }\n.iwb-editor-overlay.panels-collapsed .iwb-editor-layer-panel,\n.iwb-editor-overlay.panels-collapsed .iwb-editor-left { display: none !important; }\n.iwb-editor-zoom-hint { display: none !important; }\n\n/* ---- 交互层:蚂蚁线 / 笔刷环各自独立,互不擦除 ---- */\n.iwb-editor-selection-overlay, .iwb-editor-cursor-overlay {\n position: absolute; top: 0; left: 0; display: block; pointer-events: none;\n background: transparent !important;\n}\n.iwb-editor-selection-overlay { z-index: 11; }\n.iwb-editor-cursor-overlay { z-index: 12; }\n\n/* ---- 选区浮动操作条(体验后再定去留;纯视图,可随时替换) ---- */\n.iwb-editor-sel-bar {\n display: none; position: absolute; z-index: 30; align-items: center; gap: 4px;\n padding: 5px 6px; background: rgba(24,24,37,0.96);\n border: 1px solid #45475a; border-radius: 8px;\n box-shadow: 0 8px 26px rgba(0,0,0,0.45); white-space: nowrap;\n}\n.iwb-editor-sel-bar.as-menu { border-color: #4488ff; }\n.iwb-editor-sel-bar .iwb-editor-sel-info {\n color: #7f849c; font-size: 11px; padding: 0 6px;\n border-right: 1px solid #45475a; margin-right: 2px; font-variant-numeric: tabular-nums;\n}\n.iwb-editor-sel-bar button {\n background: #313244; color: #cdd6f4; border: 1px solid transparent; border-radius: 5px;\n padding: 4px 8px; font-size: 12px; cursor: pointer;\n}\n.iwb-editor-sel-bar button:hover:not(:disabled) { background: #4488ff; color: #fff; }\n.iwb-editor-sel-bar button[data-sel-cmd="sel.delete"]:hover:not(:disabled) { background: #cf222e; }\n.iwb-editor-sel-bar button:disabled { opacity: 0.35; cursor: not-allowed; }\n\n/* ---- 状态栏 / toast ---- */\n.iwb-editor-statusbar {\n display: flex; align-items: center; gap: 14px;\n height: 26px; min-height: 26px; padding: 0 12px;\n background: #181825; border-top: 1px solid #313244;\n color: #a6adc8; font-size: 11px; font-variant-numeric: tabular-nums;\n}\n.iwb-editor-statusbar span + span { border-left: 1px solid #313244; padding-left: 14px; }\n.iwb-editor-status-tool { margin-left: auto; color: #e8a735; }\n.iwb-editor-toast {\n position: fixed; left: 50%; bottom: 46px; z-index: 1000000;\n transform: translate(-50%, 12px); opacity: 0; pointer-events: none;\n transition: opacity 0.2s, transform 0.2s;\n background: #313244; color: #cdd6f4; padding: 8px 14px; border-radius: 8px;\n font-size: 12px; max-width: 80vw; box-shadow: 0 8px 26px rgba(0,0,0,0.45);\n}\n.iwb-editor-toast.show { opacity: 1; transform: translate(-50%, 0); }\n.iwb-editor-toast-success { background: #1a7f37; color: #fff; }\n.iwb-editor-toast-error { background: #cf222e; color: #fff; }\n.iwb-editor-toast-warn { background: #b06a00; color: #fff; }\n.iwb-editor-toast-info { background: #2f6fed; color: #fff; }\n\n@media (max-width: 900px) {\n .iwb-opt-hint, .iwb-editor-optionbar-tip { display: none; }\n .iwb-editor-session .iwb-editor-btn-cancel,\n .iwb-editor-export-actions .iwb-editor-btn-cancel { display: none; }\n}\n\n\n/* 输出设置:按预设显示的行(尺寸/体积只属于电商方图)\n 注意 `.iwb-editor-export-row` 是 display:flex,会盖掉 UA 的 [hidden]{display:none},\n 必须显式 !important,否则 JS 设 hidden 后行还留在面板里。 */\n.iwb-editor-export-row[hidden] { display: none !important; }\n.iwb-editor-export-settings [data-export-key]:disabled {\n opacity: 0.32; cursor: not-allowed; text-decoration: line-through;\n}\n.iwb-editor-export-settings [data-export-key]:disabled:hover { background: #313244; }\n\n/* 选项栏参数控件(v1.2):滑杆 + 数字框 + 实时读数,一行放得下就该保持一行 */\n.iwb-opt-range {\n width: 84px; height: 4px; flex: 0 0 auto;\n accent-color: #4488ff; cursor: pointer;\n}\n.iwb-opt-val {\n min-width: 32px; flex: 0 0 auto; color: #e8a735; font-size: 11px;\n font-variant-numeric: tabular-nums; text-align: right;\n}\n.iwb-opt-unit { color: #7f849c; font-size: 11px; flex: 0 0 auto; }\n/* 窄屏:参数多到放不下时横向滚动,不换行(换行会把 36px 高的选项栏撑开压画布) */\n.iwb-editor-optionbar-body { overflow-x: auto; scrollbar-width: none; }\n.iwb-editor-optionbar-body::-webkit-scrollbar { display: none; }\n@media (max-width: 1100px) {\n .iwb-opt-range { width: 64px; }\n}\n\n/* ---- v1.2.2 ---- */\n/* 选项栏快捷值圆点(笔刷大小 / 矢量描边推荐值),与侧栏描边快捷点同交互 */\n.iwb-opt-dots { display: inline-flex; align-items: center; gap: 3px; flex: 0 0 auto; }\n.iwb-opt-dot {\n display: inline-flex; align-items: center; justify-content: center;\n width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%;\n background: transparent; cursor: pointer;\n}\n.iwb-opt-dot i { display: block; width: 5px; height: 5px; border-radius: 50%; background: #e8a735; border: 1px solid #f6d38a; }\n.iwb-opt-dot:nth-child(2) i { width: 7px; height: 7px; }\n.iwb-opt-dot:nth-child(3) i { width: 9px; height: 9px; }\n.iwb-opt-dot:nth-child(4) i { width: 11px; height: 11px; }\n.iwb-opt-dot:nth-child(5) i { width: 14px; height: 14px; }\n.iwb-opt-dot:nth-child(6) i { width: 17px; height: 17px; }\n.iwb-opt-dot:nth-child(7) i { width: 20px; height: 20px; }\n.iwb-opt-dot:hover { background: #313244; }\n\n/* 裁剪控件在选项栏内联布局(旧 .iwb-editor-crop-bar 的绝对定位容器已删除) */\n.iwb-editor-optionbar-body .iwb-editor-crop-info {\n min-width: 88px; text-align: center; color: #e8a735;\n font-size: 11px; font-variant-numeric: tabular-nums; flex: 0 0 auto;\n}\n.iwb-editor-optionbar-body .iwb-editor-size-input {\n width: 52px; padding: 2px 5px; font-size: 11px;\n background: #1e2030; color: #e5e9f0;\n border: 1px solid #45475a; border-radius: 4px;\n}\n.iwb-editor-optionbar-body .iwb-editor-size-input:focus { outline: none; border-color: #4488ff; }\n/* 硬度滑杆加宽:参数太密时默认 84px 拉不开,用户反馈「软度调节不明显」(2026-11-04) */\n.iwb-editor-optionbar-body .iwb-opt-range-wide { width: 140px; }\n.iwb-editor-optionbar-body .iwb-opt-dots { margin-left: 2px; }\n.iwb-editor-optionbar-body .iwb-editor-size-input::-webkit-inner-spin-button { -webkit-appearance: none; }\n.iwb-editor-optionbar-body .iwb-editor-crop-confirm,\n.iwb-editor-optionbar-body .iwb-editor-crop-cancel {\n padding: 3px 10px; border: 0; border-radius: 4px; cursor: pointer; font-size: 12px; flex: 0 0 auto;\n}\n.iwb-editor-optionbar-body .iwb-editor-crop-confirm { background: #1a7f37; color: #fff; }\n.iwb-editor-optionbar-body .iwb-editor-crop-confirm:hover { background: #15803d; }\n.iwb-editor-optionbar-body .iwb-editor-crop-cancel { background: #cf222e; color: #fff; }\n.iwb-editor-optionbar-body .iwb-editor-crop-cancel:hover { background: #b91c1c; }\n\n/* ---- v1.2.3:侧栏只留调色板 + 缩放 ---- */\n/* 笔刷粗细/快捷点从侧栏移除后,缩放条直接挂在 aside 下:贴底,与调色板拉开距离 */\n.iwb-editor-left > .iwb-editor-zoom { margin-top: auto; border-top: 1px solid #313244; padding-top: 10px; }\n\n/* ================================================================\n v1.2.4:顶栏命令带(原「更多 ▾」图标化)\n 布局:标题 | 撤销·重做·还原 | ⟨图层 新建/导入⟩ ⟨顺序 置顶/上移/下移/置底⟩ ⟨视图 适应/侧栏⟩ | …… | 输出·下载·新建·覆盖·退出\n ================================================================ */\n.iwb-editor-header > .iwb-editor-history { order: 1; }\n.iwb-editor-header > .iwb-editor-commands { order: 3; display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }\n.iwb-editor-header > .iwb-editor-commands .iwb-editor-divider { width: 1px; height: 20px; background: #313244; flex: 0 0 auto; }\n.iwb-editor-cmdgroup { display: flex; align-items: center; gap: 4px; }\n.iwb-editor-cmdgroup[data-group="order"] { gap: 2px; }\n/* 顶栏里的命令按钮统一 30×30 方角,和撤销/重做同款 */\n.iwb-editor-header > .iwb-editor-commands .iwb-editor-action,\n.iwb-editor-header > .iwb-editor-commands .iwb-editor-layer-btn {\n width: 30px; height: 30px; min-width: 30px; padding: 0; border: 0; border-radius: 8px;\n background: #313244; color: #cdd6f4;\n display: inline-flex; align-items: center; justify-content: center; cursor: pointer;\n}\n.iwb-editor-header > .iwb-editor-commands .iwb-editor-action:hover:not(:disabled),\n.iwb-editor-header > .iwb-editor-commands .iwb-editor-layer-btn:hover:not(:disabled) { background: #45475a; }\n.iwb-editor-header > .iwb-editor-commands .iwb-editor-layer-btn:disabled { opacity: 0.35; cursor: not-allowed; }\n/* 选区命令(全选/反选/取消):v1.2.5 起放在「选择」工具的选项栏里,不再占竖工具条 */\n.iwb-opt-sep { width: 1px; height: 18px; background: #313244; margin: 0 4px 0 auto; flex: 0 0 auto; }\n.iwb-opt-selcmd {\n width: 26px; height: 26px; min-width: 26px; padding: 0; border: 0; border-radius: 7px;\n background: #26263a; color: #cdd6f4; flex: 0 0 auto;\n display: inline-flex; align-items: center; justify-content: center; cursor: pointer;\n}\n.iwb-opt-selcmd:hover { background: #45475a; }\n\n/* ================================================================\n v1.2.11:顶栏次序与配色(用户裁定 2026-11-04 晚)\n 布局:标题 | ⟨新建·覆盖·退出⟩ | 撤销·重做·还原 | 顺序·视图 | …… | 输出·导出\n 标题在前(它是标题,不能跑到按钮后面);会话组三键统一中性色,不再花\n ================================================================ */\n.iwb-editor-header > .iwb-editor-title { order: 0; }\n.iwb-editor-header > .iwb-editor-session { order: 1; display: flex; align-items: center; gap: 6px; flex: 0 0 auto; margin-left: 8px; }\n.iwb-editor-header > .iwb-editor-session .iwb-editor-btn { padding: 6px 10px; font-size: 11px; min-width: 56px; white-space: nowrap; }\n.iwb-editor-header > .iwb-editor-session .iwb-editor-btn-new,\n.iwb-editor-header > .iwb-editor-session .iwb-editor-btn-replace,\n.iwb-editor-header > .iwb-editor-session .iwb-editor-btn-cancel { background: #45475a; color: #cdd6f4; }\n.iwb-editor-header > .iwb-editor-session .iwb-editor-btn-new:hover,\n.iwb-editor-header > .iwb-editor-session .iwb-editor-btn-replace:hover,\n.iwb-editor-header > .iwb-editor-session .iwb-editor-btn-cancel:hover { background: #585b70; }\n/* 标题与会话组之间、撤销组与命令带之间的竖分隔 */\n.iwb-editor-header > .iwb-editor-session { margin-right: 4px; }\n.iwb-editor-header > .iwb-editor-divider { width: 1px; height: 20px; background: #313244; flex: 0 0 auto; margin: 0 4px; }\n'; + var editor_default = '/* IWB 鲜艺抠图节点 - 注入样式 */\n\n/* 抠图按钮 */\n.iwb-cutout-btn {\n cursor: pointer;\n opacity: 0.7;\n transition: opacity 0.15s, transform 0.15s;\n}\n\n.iwb-cutout-btn:hover {\n opacity: 1;\n transform: scale(1.15);\n}\n\n.iwb-cutout-btn svg {\n width: 14px;\n height: 14px;\n display: block;\n}\n\n/* 正在处理中的按钮状态 */\n.iwb-cutout-btn.processing {\n animation: iwb-cutout-pulse 1s infinite;\n pointer-events: none;\n}\n\n@keyframes iwb-cutout-pulse {\n 0%, 100% { opacity: 0.4; }\n 50% { opacity: 1; }\n}\n\n/* 全屏遮罩 */\n.iwb-cutout-overlay {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.25);\n display: none;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n gap: 12px;\n z-index: 999999;\n pointer-events: all;\n backdrop-filter: blur(2px);\n}\n\n/* 自定义按钮提示(挂在 body,最高层级,不会被图片遮挡) */\n#iwb-cutout-tip {\n position: fixed;\n z-index: 2147483647;\n background: rgba(30, 30, 46, 0.95);\n color: #fff;\n padding: 5px 10px;\n border-radius: 6px;\n font-size: 12px;\n line-height: 1.5;\n white-space: nowrap;\n pointer-events: none;\n display: none;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);\n border: 1px solid rgba(255, 255, 255, 0.14);\n font-family: system-ui, -apple-system, "Segoe UI", sans-serif;\n max-width: 320px;\n white-space: normal;\n word-break: break-all;\n}\n\n/* 加载动画 */\n.iwb-cutout-spinner {\n width: 48px;\n height: 48px;\n border: 4px solid rgba(255, 255, 255, 0.3);\n border-top-color: #e8a735;\n border-radius: 50%;\n animation: iwb-cutout-spin 0.8s linear infinite;\n}\n\n@keyframes iwb-cutout-spin {\n to { transform: rotate(360deg); }\n}\n\n/* 遮罩文字 */\n.iwb-cutout-text {\n color: #fff;\n font-size: 14px;\n font-weight: 500;\n text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);\n background: rgba(0, 0, 0, 0.6);\n padding: 8px 16px;\n border-radius: 6px;\n}\n\n/* Toast 提示 */\n.iwb-cutout-toast {\n position: fixed;\n bottom: 24px;\n left: 50%;\n transform: translateX(-50%);\n padding: 10px 20px;\n border-radius: 8px;\n font-size: 13px;\n font-weight: 500;\n z-index: 999999;\n transition: opacity 0.3s;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n display: none;\n max-width: 400px;\n}\n\n.iwb-cutout-toast-success {\n background: #1a7f37;\n color: #fff;\n}\n\n.iwb-cutout-toast-error {\n background: #cf222e;\n color: #fff;\n}\n\n.iwb-cutout-toast-info {\n background: #1f6feb;\n color: #fff;\n}\n\n/* 白底按钮 */\n.iwb-whitebg-btn {\n cursor: pointer;\n opacity: 0.7;\n transition: opacity 0.15s, transform 0.15s;\n}\n.iwb-whitebg-btn:hover { opacity: 1; transform: scale(1.15); }\n.iwb-whitebg-btn svg { width: 14px; height: 14px; display: block; }\n.iwb-whitebg-btn.processing { animation: iwb-cutout-pulse 1s infinite; pointer-events: none; }\n\n/* 编辑按钮 */\n.iwb-editor-btn-icon {\n cursor: pointer;\n opacity: 0.7;\n transition: opacity 0.15s, transform 0.15s;\n}\n.iwb-editor-btn-icon:hover { opacity: 1; transform: scale(1.15); }\n.iwb-editor-btn-icon svg { width: 14px; height: 14px; display: block; }\n\n/* ==================== 图片编辑器 ==================== */\n\n.iwb-editor-overlay {\n position: fixed;\n top: 0; left: 0;\n width: 100%; height: 100%;\n background: rgba(0, 0, 0, 0.6);\n display: none;\n align-items: center;\n justify-content: center;\n z-index: 999998;\n backdrop-filter: blur(3px);\n}\n\n.iwb-editor-modal {\n background: #1e1e2e;\n border-radius: 0;\n box-shadow: none;\n display: flex;\n flex-direction: column;\n width: 100vw;\n height: 100vh;\n max-width: none;\n max-height: none;\n overflow: visible;\n}\n\n/* 新增:主区域(画布 + 图层面板)flex 布局 */\n.iwb-editor-main {\n display: flex;\n flex: 1 1 auto;\n min-height: 0;\n overflow: visible;\n}\n\n.iwb-editor-header {\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 10px 16px;\n background: #181825;\n border-bottom: 1px solid #313244;\n flex-wrap: nowrap;\n}\n.iwb-editor-header > .iwb-editor-tools {\n position: absolute;\n left: 12px;\n top: 68px;\n width: 44px;\n flex-direction: column;\n padding: 6px;\n background: #181825;\n border: 1px solid #313244;\n border-radius: 8px;\n z-index: 20;\n}\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action { position: static; }\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="undo"],\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="redo"],\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="reset"],\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="restore"] {\n position: absolute;\n top: -54px;\n left: auto;\n}\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="undo"] { right: 154px; }\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="redo"] { right: 118px; }\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="reset"] { right: 82px; }\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="restore"] { right: 46px; }\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-divider {\n width: 24px;\n height: 1px;\n margin: 4px 0;\n}\n\n.iwb-editor-title {\n color: #cdd6f4;\n font-size: 14px;\n font-weight: 600;\n white-space: nowrap;\n}\n\n.iwb-editor-tools {\n display: flex;\n align-items: center;\n gap: 4px;\n}\n\n.iwb-editor-tool, .iwb-editor-action {\n background: #313244;\n border: none;\n border-radius: 6px;\n color: #cdd6f4;\n width: 32px; height: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n font-size: 15px;\n transition: background 0.15s, transform 0.1s;\n}\n.iwb-editor-tool:hover, .iwb-editor-action:hover { background: #45475a; transform: scale(1.08); }\n.iwb-editor-tool.active { background: #e8a735; color: #1e1e2e; }\n.iwb-editor-tool svg, .iwb-editor-action svg { display: block; }\n.iwb-editor-layer-btn svg { display: block; }\n\n/* 复原按钮:绿色高亮,与撤销/重做/清空区分 */\n.iwb-editor-action-restore { background: #1a7f37; color: #fff; }\n.iwb-editor-action-restore:hover { background: #15803d !important; }\n\n.iwb-editor-divider {\n width: 1px; height: 20px;\n background: #45475a;\n margin: 0 4px;\n}\n\n.iwb-editor-params {\n display: flex;\n align-items: center;\n gap: 10px;\n margin-left: 12px;\n justify-content: flex-start;\n min-width: 0;\n flex: 1 1 auto;\n flex-wrap: wrap;\n}\n.iwb-editor-params .iwb-editor-zoom { margin-left: auto; order: 20; }\n.iwb-editor-top-colors { display: none; }\n\n.iwb-editor-colors { display: flex; gap: 4px; }\n.iwb-editor-color {\n width: 20px; height: 20px;\n border-radius: 50%;\n cursor: pointer;\n border: 2px solid transparent;\n transition: transform 0.1s, border-color 0.15s;\n}\n.iwb-editor-color:hover { transform: scale(1.2); }\n.iwb-editor-color.active { border-color: #fff; transform: scale(1.15); }\n\n.iwb-editor-brush-label {\n display: flex;\n align-items: center;\n gap: 6px;\n color: #a6adc8;\n font-size: 12px;\n}\n.iwb-editor-brush-size { width: 80px; cursor: pointer; }\n.iwb-editor-brush-val { color: #e8a735; font-weight: 600; min-width: 16px; }\n\n/* 笔刷/橡皮大小精确数值输入框 */\n.iwb-editor-brush-num,\n.iwb-editor-eraser-num {\n width: 44px;\n padding: 2px 3px;\n background: #313244;\n border: 1px solid #45475a;\n border-radius: 5px;\n color: #e8a735;\n font-weight: 600;\n font-size: 11px;\n font-family: inherit;\n text-align: center;\n}\n.iwb-editor-brush-num:focus,\n.iwb-editor-eraser-num:focus {\n outline: none;\n border-color: #e8a735;\n background: #1e1e2e;\n}\n.iwb-editor-brush-num::-webkit-outer-spin-button,\n.iwb-editor-brush-num::-webkit-inner-spin-button,\n.iwb-editor-eraser-num::-webkit-outer-spin-button,\n.iwb-editor-eraser-num::-webkit-inner-spin-button {\n -webkit-appearance: none; /* 去掉上下箭头,窄输入框更干净 */\n margin: 0;\n}\n\n/* 实心矩形开关 */\n.iwb-editor-fill-btn {\n background: #313244;\n border: 1px solid #45475a;\n border-radius: 6px;\n color: #a6adc8;\n padding: 4px 10px;\n font-size: 12px;\n cursor: pointer;\n transition: background 0.15s, color 0.15s, border-color 0.15s;\n white-space: nowrap;\n}\n.iwb-editor-fill-btn:hover { background: #45475a; }\n.iwb-editor-fill-btn.active {\n background: #e8a735;\n border-color: #e8a735;\n color: #1e1e2e;\n font-weight: 600;\n}\n\n/* 画笔参数组(硬度/透明度,画笔与橡皮工具共用) */\n.iwb-editor-brush-group {\n display: flex;\n align-items: center;\n gap: 10px;\n}\n.iwb-editor-layer-group {\n display: flex;\n align-items: center;\n gap: 3px;\n}\n.iwb-editor-layer-btn {\n background: #313244;\n border: 1px solid #45475a;\n border-radius: 6px;\n color: #a6adc8;\n width: 26px;\n height: 26px;\n font-size: 14px;\n line-height: 1;\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;\n}\n.iwb-editor-layer-btn:hover:not(:disabled) { background: #45475a; color: #cdd6f4; }\n.iwb-editor-layer-btn:disabled {\n opacity: 0.35;\n cursor: not-allowed;\n}\n\n/* 缩放控件 */\n.iwb-editor-zoom {\n display: flex;\n align-items: center;\n gap: 2px;\n background: #313244;\n border-radius: 6px;\n padding: 2px;\n}\n.iwb-editor-zoom-btn {\n background: transparent;\n border: none;\n color: #cdd6f4;\n width: 26px;\n height: 26px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n line-height: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background 0.15s;\n}\n.iwb-editor-zoom-btn:hover { background: #45475a; }\n.iwb-editor-zoom-btn:active { transform: scale(0.94); }\n.iwb-editor-zoom-fit { font-size: 12px; width: auto; padding: 0 8px; }\n.iwb-editor-zoom-val {\n color: #e8a735;\n font-size: 12px;\n font-weight: 600;\n min-width: 46px;\n text-align: center;\n font-variant-numeric: tabular-nums;\n user-select: none;\n}\n\n/* 底部操作提示 */\n.iwb-editor-zoom-hint {\n position: absolute;\n bottom: 8px;\n right: 14px;\n color: #7f849c;\n font-size: 11px;\n background: rgba(24, 24, 37, 0.85);\n padding: 3px 10px;\n border-radius: 4px;\n pointer-events: none;\n z-index: 5;\n}\n\n.iwb-editor-canvas-wrap {\n position: relative;\n background: #11111b;\n flex: 1 1 auto;\n min-height: 0;\n max-width: 100%;\n max-height: 100%;\n overflow: hidden; /* 裁剪框允许显示在图片边界外;编辑区仍由模态层裁切 */\n overflow: clip; /* v1.2.8:hidden 仍可被编程滚动(点击底部工具栏会触发 scrollIntoView 把画布滚跑),clip 彻底禁止滚动 */\n padding: 12px;\n}\n\n.iwb-editor-canvas-stack {\n position: absolute;\n left: 0;\n top: 0;\n display: block;\n width: 0;\n height: 0;\n /* 仅图片工作区显示透明棋盘格,外围裁剪工作区保持纯色。 */\n background-color: #d6d6d6;\n background-image:\n linear-gradient(45deg, #b8b8b8 25%, transparent 25%),\n linear-gradient(-45deg, #b8b8b8 25%, transparent 25%),\n linear-gradient(45deg, transparent 75%, #b8b8b8 75%),\n linear-gradient(-45deg, transparent 75%, #b8b8b8 75%);\n background-size: 20px 20px;\n background-position: 0 0, 0 10px, 10px -10px, -10px 0;\n}\n\n.iwb-editor-base, .iwb-editor-draw, .iwb-editor-text, .iwb-editor-crop-overlay {\n display: block;\n}\n/* 位图图层 canvas(动态创建) */\n.iwb-editor-layer-canvas {\n display: block;\n position: absolute;\n top: 0; left: 0;\n}\n.iwb-editor-base {\n background: #fff;\n /* 棋盘格透明背景示意 */\n background-image:\n linear-gradient(45deg, #e0e0e0 25%, transparent 25%),\n linear-gradient(-45deg, #e0e0e0 25%, transparent 25%),\n linear-gradient(45deg, transparent 75%, #e0e0e0 75%),\n linear-gradient(-45deg, transparent 75%, #e0e0e0 75%);\n background-size: 20px 20px;\n background-position: 0 0, 0 10px, 10px -10px, -10px 0px;\n}\n.iwb-editor-draw {\n position: absolute;\n top: 0; left: 0;\n cursor: crosshair;\n}\n\n/* 笔划预览层:一笔进行中显示(draw 之上、text 之下),事件穿透 */\n.iwb-editor-stroke {\n position: absolute;\n top: 0; left: 0;\n pointer-events: none;\n display: none;\n}\n\n.iwb-editor-brush-hardness { width: 70px; cursor: pointer; }\n.iwb-editor-brush-hardness-val { color: #e8a735; font-weight: 600; min-width: 20px; display: inline-block; text-align: right; }\n.iwb-editor-brush-opacity { width: 70px; cursor: pointer; }\n.iwb-editor-brush-opacity-val { color: #e8a735; font-weight: 600; min-width: 34px; display: inline-block; text-align: right; }\n\n/* 自定义颜色(原生取色器伪装成圆形色板) */\n.iwb-editor-color-custom {\n position: relative;\n overflow: hidden;\n border: 2px dashed #a6adc8;\n}\n.iwb-editor-color-custom.active { border-color: #fff; border-style: solid; transform: scale(1.15); }\n.iwb-editor-color-custom input[type="color"] {\n position: absolute;\n inset: -6px;\n width: calc(100% + 12px);\n height: calc(100% + 12px);\n padding: 0;\n border: none;\n cursor: pointer;\n background: conic-gradient(#ff4444, #ffaa00, #44dd44, #4488ff, #aa44ff, #ff4444);\n}\n.iwb-editor-color-custom input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }\n.iwb-editor-color-custom input[type="color"]::-webkit-color-swatch { border: none; }\n\n/* 吸管悬停预览浮窗 */\n.iwb-editor-picker-tip {\n position: fixed;\n z-index: 2147483000;\n display: none;\n align-items: center;\n gap: 6px;\n background: rgba(30, 30, 46, 0.95);\n border: 1px solid rgba(255, 255, 255, 0.14);\n border-radius: 6px;\n padding: 4px 8px;\n pointer-events: none;\n font-family: system-ui, -apple-system, "Segoe UI", sans-serif;\n}\n.iwb-editor-picker-chip {\n width: 16px;\n height: 16px;\n border-radius: 4px;\n background: transparent;\n}\n.iwb-editor-picker-hex {\n color: #cdd6f4;\n font-size: 12px;\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n}\n\n/* 文字图层:独立 canvas,事件穿透到下层 drawCanvas */\n.iwb-editor-text {\n position: absolute;\n top: 0; left: 0;\n pointer-events: none;\n}\n\n/* 裁剪覆盖层:遮罩/选区框/手柄画在这层,不污染标注层 */\n.iwb-editor-crop-overlay {\n position: absolute;\n top: 0; left: 0;\n pointer-events: none;\n}\n\n/* 文字输入框 */\n.iwb-editor-text-input {\n position: absolute;\n display: none;\n padding: 4px 8px;\n border: 2px solid #4488ff;\n border-radius: 4px;\n font-size: 14px;\n background: rgba(255, 255, 255, 0.95);\n color: #1e1e2e;\n z-index: 10;\n min-width: 120px;\n}\n.iwb-editor-text-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(68, 136, 255, 0.3); }\n\n/* 裁剪确认栏(含约束控件) */\n.iwb-editor-crop-bar {\n position: absolute;\n bottom: 16px;\n left: 50%;\n transform: translateX(-50%);\n display: none;\n gap: 8px;\n z-index: 10;\n align-items: center;\n background: rgba(24, 24, 37, 0.92);\n border: 1px solid #313244;\n border-radius: 8px;\n padding: 6px 10px;\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);\n flex-wrap: wrap;\n max-width: 90%;\n justify-content: center;\n}\n\n.iwb-editor-constraint-group {\n display: flex;\n align-items: center;\n gap: 4px;\n}\n\n.iwb-editor-constraint-label {\n color: #7f849c;\n font-size: 11px;\n margin-right: 2px;\n white-space: nowrap;\n}\n\n.iwb-editor-constraint-btn {\n background: #313244;\n border: none;\n border-radius: 4px;\n color: #cdd6f4;\n padding: 3px 8px;\n font-size: 12px;\n cursor: pointer;\n transition: background 0.15s, transform 0.1s;\n white-space: nowrap;\n}\n.iwb-editor-constraint-btn:hover { background: #45475a; transform: scale(1.05); }\n.iwb-editor-constraint-btn.active { background: #4488ff; color: #fff; }\n\n.iwb-editor-constraint-sep {\n width: 1px;\n height: 20px;\n background: #45475a;\n}\n\n.iwb-editor-size-input {\n width: 50px;\n background: #313244;\n border: 1px solid #45475a;\n border-radius: 4px;\n color: #cdd6f4;\n padding: 3px 6px;\n font-size: 12px;\n text-align: center;\n}\n.iwb-editor-size-input:focus { outline: none; border-color: #4488ff; }\n.iwb-editor-size-input::-webkit-inner-spin-button { -webkit-appearance: none; }\n\n.iwb-editor-size-x { color: #7f849c; font-size: 12px; }\n\n.iwb-editor-size-apply {\n background: #313244;\n border: 1px solid #4488ff;\n color: #4488ff;\n border-radius: 4px;\n padding: 3px 8px;\n font-size: 12px;\n cursor: pointer;\n transition: background 0.15s;\n}\n.iwb-editor-size-apply:hover { background: #4488ff; color: #fff; }\n\n.iwb-editor-crop-info {\n color: #e8a735;\n font-size: 12px;\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n min-width: 60px;\n text-align: center;\n}\n\n.iwb-editor-crop-confirm, .iwb-editor-crop-cancel {\n padding: 6px 16px;\n border: none;\n border-radius: 6px;\n font-size: 13px;\n font-weight: 500;\n cursor: pointer;\n}\n.iwb-editor-crop-confirm { background: #1a7f37; color: #fff; }\n.iwb-editor-crop-confirm:hover { background: #15803d; }\n.iwb-editor-crop-cancel { background: #cf222e; color: #fff; }\n.iwb-editor-crop-cancel:hover { background: #b91c1c; }\n\n/* 底部 */\n.iwb-editor-footer {\n display: flex;\n justify-content: flex-end;\n gap: 8px;\n padding: 12px 16px;\n background: #181825;\n border-top: 1px solid #313244;\n}\n\n.iwb-editor-btn {\n padding: 8px 20px;\n border: none;\n border-radius: 6px;\n font-size: 13px;\n font-weight: 500;\n cursor: pointer;\n transition: background 0.15s, transform 0.1s;\n}\n.iwb-editor-btn:hover { transform: scale(1.03); }\n.iwb-editor-btn-cancel { background: #45475a; color: #cdd6f4; }\n.iwb-editor-btn-cancel:hover { background: #585b70; }\n.iwb-editor-btn-new { background: #4488ff; color: #fff; }\n.iwb-editor-btn-new:hover { background: #3578f0; }\n.iwb-editor-btn-replace { background: #e8a735; color: #1e1e2e; }\n.iwb-editor-btn-replace:hover { background: #d49628; }\n\n/* ==================== 图层面板 ==================== */\n\n.iwb-editor-layer-panel {\n width: 290px;\n min-width: 290px;\n background: #181825;\n border-left: 1px solid #313244;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n\n.iwb-editor-layer-panel-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 10px 12px;\n border-bottom: 1px solid #313244;\n}\n\n.iwb-editor-layer-panel-title {\n color: #cdd6f4;\n font-size: 13px;\n font-weight: 600;\n}\n\n.iwb-editor-layer-add-group {\n display: flex;\n gap: 4px;\n}\n\n.iwb-editor-layer-add-btn {\n background: #313244;\n border: 1px solid #45475a;\n border-radius: 6px;\n color: #cdd6f4;\n width: 26px;\n height: 26px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background 0.15s;\n}\n.iwb-editor-layer-add-btn:hover { background: #45475a; color: #e8a735; }\n.iwb-editor-layer-add-btn svg { display: block; }\n\n.iwb-editor-layer-list {\n flex: 1 1 auto;\n overflow-y: auto;\n padding: 4px;\n}\n\n/* 图层项 */\n.iwb-layer-item {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 6px 8px;\n border-radius: 6px;\n cursor: pointer;\n transition: background 0.12s;\n margin-bottom: 2px;\n}\n.iwb-layer-item:hover { background: #313244; }\n.iwb-layer-item.active {\n background: #313244;\n box-shadow: inset 2px 0 0 #e8a735;\n}\n.iwb-layer-item.hidden { opacity: 0.5; }\n.iwb-layer-item[draggable="true"] { cursor: grab; }\n.iwb-layer-item.dragging { opacity: 0.45; }\n.iwb-layer-item.drop-target { outline: 1px dashed #e8a735; background: rgba(232, 167, 53, 0.16); }\n/* 画笔/橡皮作用目标:与「选中」分离,避免出现两个图层同时高亮 */\n.iwb-layer-paint { flex: 0 0 auto; color: #a6adc8; font-size: 11px; opacity: 0.85; }\n.iwb-layer-color { width: 22px; height: 22px; padding: 0; border: 1px solid #45475a; border-radius: 50%; background: transparent; cursor: pointer; flex: 0 0 auto; }\n.iwb-layer-width { width: 42px; height: 22px; padding: 2px 3px; border: 1px solid #45475a; border-radius: 4px; background: #1e1e2e; color: #e8a735; font-size: 11px; text-align: center; flex: 0 0 auto; }\n.iwb-layer-width:focus { outline: none; border-color: #e8a735; }\n\n.iwb-layer-vis {\n background: none;\n border: none;\n color: #a6adc8;\n cursor: pointer;\n font-size: 13px;\n width: 20px;\n height: 20px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n transition: background 0.12s;\n}\n.iwb-layer-vis:hover { background: #45475a; }\n\n.iwb-layer-icon {\n font-size: 13px;\n width: 18px;\n text-align: center;\n flex-shrink: 0;\n}\n\n.iwb-layer-name {\n color: #cdd6f4;\n font-size: 12px;\n flex: 1 1 auto;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n min-width: 0;\n}\n\n.iwb-layer-lock {\n background: none;\n border: none;\n color: #7f849c;\n cursor: pointer;\n width: 20px;\n height: 20px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n transition: background 0.12s, color 0.12s;\n flex-shrink: 0;\n}\n.iwb-layer-lock:hover, .iwb-layer-lock.active { background: #45475a; color: #e8a735; }\n\n.iwb-layer-del {\n background: none;\n border: none;\n color: #585b70;\n cursor: pointer;\n font-size: 12px;\n width: 18px;\n height: 18px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n transition: background 0.12s, color 0.12s;\n flex-shrink: 0;\n}\n.iwb-layer-del:hover { background: #cf222e; color: #fff; }\n\n/* SVG 图标尺寸 */\n.iwb-layer-vis svg { display: block; }\n.iwb-layer-icon svg { display: block; }\n.iwb-layer-lock svg { display: block; }\n.iwb-layer-del svg { display: block; }\n\n/* 独立 PS 风格颜色面板 */\n.iwb-editor-color-panel { padding: 12px; border-bottom: 1px solid #313244; background: #202033; }\n.iwb-editor-color-panel-title { color: #cdd6f4; font-size: 12px; font-weight: 600; margin-bottom: 10px; }\n.iwb-editor-color-panel-main { display: flex; align-items: center; gap: 10px; }\n.iwb-editor-color-current { width: 52px; height: 52px; border: 2px solid #cdd6f4; border-radius: 6px; overflow: hidden; display: block; background: #ff4444; }\n.iwb-editor-color-panel-input { width: 100%; height: 100%; padding: 0; border: 0; cursor: pointer; opacity: 0; }\n.iwb-editor-color-panel-values { min-width: 0; flex: 1; }\n.iwb-editor-color-hex { color: #cdd6f4; font: 600 12px monospace; display: block; margin-bottom: 8px; }\n.iwb-editor-color-swatches { display: flex; flex-wrap: wrap; gap: 6px; }\n.iwb-editor-color-panel-swatch { width: 20px; height: 20px; border: 1px solid #585b70; border-radius: 4px; cursor: pointer; }\n.iwb-editor-color-panel-swatch:hover { transform: scale(1.12); border-color: #fff; }\n.iwb-editor-panel-width { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: #a6adc8; font-size: 11px; }\n.iwb-editor-panel-width-range { flex: 1; min-width: 60px; }\n.iwb-editor-panel-width-num { width: 42px; padding: 3px; background: #313244; color: #e8a735; border: 1px solid #45475a; border-radius: 4px; text-align: center; }\n.iwb-layer-color, .iwb-layer-width { display: none !important; }\n\n/* 顶部独立操作区,避免操作按钮被竖向工具栏裁切 */\n.iwb-editor-actions { display: flex; align-items: center; gap: 5px; margin-left: auto; flex: 0 0 auto; }\n.iwb-editor-actions .iwb-editor-action { position: static !important; }\n.iwb-editor-actions .iwb-editor-action-restore { width: auto; padding: 0 9px; font-size: 12px; }\n\n/* 原图 canvas 只负责绘制像素,透明处透出 stack 的棋盘格。 */\n.iwb-editor-base { background: transparent !important; background-image: none !important; }\n\n/* 透明区域使用 Photoshop 风格的灰色棋盘格,覆盖整个实际图片区域。 */\n.iwb-editor-canvas-stack {\n background-color: #d6d6d6 !important;\n background-image:\n linear-gradient(45deg, #b8b8b8 25%, transparent 25%),\n linear-gradient(-45deg, #b8b8b8 25%, transparent 25%),\n linear-gradient(45deg, transparent 75%, #b8b8b8 75%),\n linear-gradient(-45deg, transparent 75%, #b8b8b8 75%) !important;\n background-size: 20px 20px !important;\n background-position: 0 0, 0 10px, 10px -10px, -10px 0 !important;\n}\n.iwb-editor-base { background: transparent !important; background-image: none !important; }\n\n/* 顶部参数区必须保持可见且可交互,避免被侧栏定位层覆盖。 */\n.iwb-editor-header { position: relative; min-height: 56px; overflow: visible; }\n.iwb-editor-params { position: relative; z-index: 30; overflow: visible; pointer-events: auto; }\n.iwb-editor-params input, .iwb-editor-params button, .iwb-editor-params label { pointer-events: auto; }\n.iwb-editor-brush-size, .iwb-editor-brush-hardness, .iwb-editor-brush-opacity { min-width: 70px; accent-color: #e8a735; }\n.iwb-editor-brush-num, .iwb-editor-eraser-num { pointer-events: auto; }\n\n/* canvas 的透明像素必须透出 stack 棋盘格,不能被黑色工作区遮住。 */\n.iwb-editor-canvas-stack { isolation: isolate; }\n.iwb-editor-layer-canvas, .iwb-editor-text, .iwb-editor-stroke, .iwb-editor-crop-overlay { background: transparent !important; }\n\n/* 透明棋盘格只覆盖原图的显示矩形,外围裁剪扩展区保持纯色。 */\n.iwb-editor-canvas-stack { background: #11111b !important; background-image: none !important; }\n.iwb-editor-transparency-grid { position: absolute; z-index: 0; pointer-events: none; background-color: #d6d6d6; background-image: linear-gradient(45deg, #b8b8b8 25%, transparent 25%), linear-gradient(-45deg, #b8b8b8 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #b8b8b8 75%), linear-gradient(-45deg, transparent 75%, #b8b8b8 75%); background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0; }\n.iwb-editor-layer-canvas, .iwb-editor-stroke, .iwb-editor-text { z-index: 1; }\n.iwb-editor-crop-overlay { z-index: 10; }\n\n/* 画布扩展区不得盖过编辑器外围,图片区域由透明层单独标识。 */\n.iwb-editor-canvas-stack { overflow: visible; max-width: 100%; max-height: 100%; background: #11111b !important; background-image: none !important; }\n.iwb-editor-transparency-grid { z-index: 0; overflow: hidden; }\n.iwb-editor-layer-canvas { z-index: 1; }\n.iwb-editor-stroke { z-index: 4; }\n.iwb-editor-text { z-index: 5; }\n.iwb-editor-crop-overlay { z-index: 10; }\n\n/* 导出操作与缩放同处顶栏,缩放独立靠右。 */\n.iwb-editor-export-actions { display: flex; align-items: center; gap: 6px; margin-left: 10px; flex: 0 0 auto; }\n.iwb-editor-export-actions .iwb-editor-btn { padding: 6px 10px; font-size: 11px; }\n.iwb-editor-footer { display: none !important; }\n.iwb-layer-color, .iwb-layer-width { display: none !important; }\n\n.iwb-editor-export-actions { display: flex; align-items: center; gap: 6px; margin-left: 10px; flex: 0 0 auto; }\n.iwb-editor-export-actions .iwb-editor-btn { padding: 6px 10px; font-size: 11px; }\n.iwb-editor-footer { display: none !important; }\n.iwb-layer-color, .iwb-layer-width { display: none !important; }\n\n/* 顶部七个操作按钮统一文本按钮样式,自适应中文宽度。 */\n.iwb-editor-actions { gap: 6px; }\n.iwb-editor-actions .iwb-editor-action { width: auto; min-width: 72px; height: 32px; padding: 0 12px; gap: 5px; font-size: 12px; font-weight: 500; white-space: nowrap; }\n.iwb-editor-actions .iwb-editor-action svg { width: 14px; height: 14px; flex: 0 0 auto; }\n.iwb-editor-export-actions .iwb-editor-btn { min-width: 72px; white-space: nowrap; }\n\n/* 顶部操作按钮统一为纯文本,图标隐藏并保持一致宽度。 */\n.iwb-editor-actions .iwb-editor-action svg { display: none !important; }\n.iwb-editor-actions .iwb-editor-action { min-width: 76px; width: 76px; justify-content: center; background: #3b3d52; color: #cdd6f4; }\n.iwb-editor-actions .iwb-editor-action:hover { background: #50536b; }\n.iwb-editor-actions .iwb-editor-action-restore { background: #3b3d52; color: #cdd6f4; }\n.iwb-editor-actions .iwb-editor-action-restore:hover { background: #50536b !important; }\n\n.iwb-editor-actions .iwb-editor-action svg { display: none !important; }\n.iwb-editor-actions .iwb-editor-action { min-width: 76px; width: 76px; justify-content: center; background: #3b3d52; color: #cdd6f4; }\n.iwb-editor-actions .iwb-editor-action:hover, .iwb-editor-actions .iwb-editor-action-restore:hover { background: #50536b !important; }\n\n.iwb-editor-actions .iwb-editor-action { width: auto; min-width: 76px; padding: 0 12px; gap: 5px; }\n.iwb-editor-actions .iwb-editor-action span { display: inline-block; }\n\n.iwb-editor-actions { margin-left: 12px; }\n.iwb-editor-actions .iwb-editor-btn { width: auto; min-width: 76px; height: 32px; padding: 0 12px; font-size: 12px; white-space: nowrap; }\n.iwb-editor-actions .iwb-editor-action { width: auto; min-width: 76px; }\n\n.iwb-editor-actions .iwb-editor-action { min-width: 52px; width: auto; padding: 0 10px; font-size: 12px; }\n.iwb-editor-brush-presets { display: flex; align-items: center; gap: 7px; margin-left: 4px; }\n.iwb-editor-brush-preset { display: inline-flex; align-items: center; gap: 3px; padding: 2px 3px; border: 0; background: transparent; color: #a6adc8; cursor: pointer; font-size: 11px; }\n.iwb-editor-brush-preset i { display: block; width: 12px; height: 12px; border-radius: 50%; background: #e8a735; border: 1px solid #f6d38a; }\n.iwb-editor-brush-preset:nth-child(2) i { width: 16px; height: 16px; }\n.iwb-editor-brush-preset:nth-child(3) i { width: 20px; height: 20px; }\n.iwb-editor-brush-preset:nth-child(4) i { width: 24px; height: 24px; }\n.iwb-editor-brush-preset:hover, .iwb-editor-brush-preset.active { color: #fff; }\n\n/* 紧凑顶栏:操作按钮与描边快捷点仅保留必要视觉信息。 */\n.iwb-editor-actions .iwb-editor-action { width: 28px; min-width: 28px; height: 28px; padding: 0; }\n.iwb-editor-actions .iwb-editor-action svg { display: block !important; width: 14px; height: 14px; }\n.iwb-editor-brush-presets { gap: 5px; margin-left: 2px; }\n.iwb-editor-brush-preset { width: 24px; height: 24px; padding: 0; justify-content: center; }\n.iwb-editor-brush-preset i { width: 5px; height: 5px; }\n.iwb-editor-brush-preset:nth-child(2) i { width: 8px; height: 8px; }\n.iwb-editor-brush-preset:nth-child(3) i { width: 12px; height: 12px; }\n.iwb-editor-brush-preset:nth-child(4) i { width: 16px; height: 16px; }\n\n/* 图层栏内嵌调色板:颜色直接点击应用,不弹出系统取色器。 */\n.iwb-editor-color-panel { padding: 10px; }\n.iwb-editor-color-current { width: 42px; height: 42px; flex: 0 0 42px; cursor: default; }\n.iwb-editor-color-swatches { display: grid; grid-template-columns: repeat(7, 20px); gap: 5px; }\n.iwb-editor-color-panel-swatch { width: 20px; height: 20px; border-radius: 50%; }\n\n.iwb-editor-color-panel { padding: 10px; }\n.iwb-editor-color-current { width: 42px; height: 42px; flex: 0 0 42px; cursor: default; }\n.iwb-editor-color-swatches { display: grid; grid-template-columns: repeat(7, 20px); gap: 5px; }\n.iwb-editor-color-panel-swatch { width: 20px; height: 20px; border-radius: 50%; }\n\n.iwb-editor-color-panel { padding: 10px; }\n.iwb-editor-palette-current { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }\n.iwb-editor-palette-current .iwb-editor-color-current { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 4px; }\n.iwb-editor-color-panel .iwb-editor-color-hex { margin: 0; }\n.iwb-editor-color-panel .iwb-editor-color-swatches { display: grid; grid-template-columns: repeat(6, 20px); gap: 7px; }\n.iwb-editor-color-panel .iwb-editor-color-panel-swatch { width: 20px; height: 20px; border-radius: 50%; padding: 0; }\n.iwb-editor-color-panel .iwb-editor-color-panel-swatch.active { outline: 2px solid #fff; outline-offset: 2px; }\n\n.iwb-editor-color-panel { padding: 10px; }\n.iwb-editor-palette-current { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }\n.iwb-editor-palette-current .iwb-editor-color-current { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 4px; }\n.iwb-editor-color-panel .iwb-editor-color-hex { margin: 0; }\n.iwb-editor-color-panel .iwb-editor-color-swatches { display: grid; grid-template-columns: repeat(6, 20px); gap: 7px; }\n.iwb-editor-color-panel .iwb-editor-color-panel-swatch { width: 20px; height: 20px; border-radius: 50%; padding: 0; }\n.iwb-editor-color-panel .iwb-editor-color-panel-swatch.active { outline: 2px solid #fff; outline-offset: 2px; }\n\n.iwb-editor-inline-picker { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }\n.iwb-editor-inline-picker .iwb-editor-color-panel-input { width: 42px; height: 28px; padding: 0; opacity: 1; cursor: pointer; border: 1px solid #585b70; border-radius: 4px; }\n.iwb-editor-color-panel .iwb-editor-color-swatches { display: grid; grid-template-columns: repeat(6, 20px); gap: 7px; }\n.iwb-editor-color-panel .iwb-editor-color-panel-swatch { width: 20px; height: 20px; border-radius: 50%; padding: 0; }\n\n.iwb-editor-inline-picker { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }\n.iwb-editor-inline-picker .iwb-editor-color-panel-input { width: 42px; height: 28px; padding: 0; opacity: 1; cursor: pointer; border: 1px solid #585b70; border-radius: 4px; }\n.iwb-editor-color-panel .iwb-editor-color-swatches { display: grid; grid-template-columns: repeat(6, 20px); gap: 7px; }\n.iwb-editor-color-panel .iwb-editor-color-panel-swatch { width: 20px; height: 20px; border-radius: 50%; padding: 0; }\n\n.iwb-editor-inline-picker { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }\n.iwb-editor-inline-picker .iwb-editor-color-panel-input { width: 42px; height: 28px; padding: 0; opacity: 1; cursor: pointer; border: 1px solid #585b70; border-radius: 4px; }\n.iwb-editor-color-panel .iwb-editor-color-swatches { display: grid; grid-template-columns: repeat(6, 20px); gap: 7px; }\n.iwb-editor-color-panel .iwb-editor-color-panel-swatch { width: 20px; height: 20px; border-radius: 50%; padding: 0; }\n\n.iwb-editor-color-panel { padding: 9px; }\n.iwb-editor-inline-picker { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }\n.iwb-editor-inline-picker .iwb-editor-color-panel-input { display: block; width: 44px; height: 30px; padding: 0; opacity: 1; cursor: pointer; border: 1px solid #585b70; border-radius: 4px; }\n.iwb-editor-color-panel .iwb-editor-color-swatches { display: grid; grid-template-columns: repeat(6, 20px); gap: 7px; }\n.iwb-editor-color-panel .iwb-editor-color-panel-swatch { width: 20px; height: 20px; border-radius: 50%; padding: 0; }\n.iwb-editor-color-panel .iwb-editor-color-panel-swatch.active { outline: 2px solid #fff; outline-offset: 2px; }\n\n.iwb-editor-color-picker2 { display: flex; gap: 8px; height: 118px; }\n.iwb-color-sv { position: relative; flex: 1; background: linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,rgba(255,255,255,0)); background-color: #f44; border-radius: 4px; }\n.iwb-color-hue { width: 18px; border-radius: 4px; background: linear-gradient(to bottom,#f00,#ff0,#0f0,#0ff,#00f,#f0f,#f00); }\n.iwb-editor-color-fields { display: flex; gap: 6px; margin: 8px 0; }\n.iwb-editor-color-hex-input { width: 72px; background:#313244; color:#cdd6f4; border:1px solid #585b70; padding:4px; }\n.iwb-editor-color-panel-input { width: 32px; height: 26px; opacity: 1; padding: 0; }\n\n.iwb-color-sv span, .iwb-color-hue span { position: absolute; width: 10px; height: 10px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px #222; transform: translate(-50%, -50%); pointer-events: none; }\n.iwb-color-sv span { left: 100%; top: 0; }\n.iwb-color-hue span { left: 50%; top: 0; }\n\n.iwb-compress-btn { color: #16a34a !important; font-size: 11px; font-weight: 700; }\n\n/* 新版浮动气泡栏内的工具按钮 */\n.iwb-node-floatbar .iwb-compress-btn { font-size: 11px; font-weight: 700; }\n.iwb-node-floatbar .iwb-cutout-btn.processing,\n.iwb-node-floatbar .iwb-whitebg-btn.processing,\n.iwb-node-floatbar .iwb-compress-btn.processing { animation: iwb-cutout-pulse 1s infinite; pointer-events: none; }\n\n\n/* 调色板:吸色按钮(替代原来的弹出式取色器) */\n.iwb-editor-color-eye { width: 26px; height: 26px; border: 1px solid #585b70; border-radius: 4px; background: #313244; color: #cdd6f4; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; }\n.iwb-editor-color-eye:hover { border-color: #e8a735; color: #e8a735; }\n\n/* 矢量对象独立画布:与位图图层统一参与 z 排序 */\n.iwb-editor-vec-canvas { position: absolute; top: 0; left: 0; z-index: 1; background: transparent !important; }\n\n/* 空白画布创建菜单 */\n.iwb-blank-menu { position: fixed; width: 242px; background: #fff; border: 1px solid #d0d7de; border-radius: 12px; box-shadow: 0 12px 32px rgba(15,23,42,.2); padding: 10px; z-index: 2147483000; font-size: 12px; color: #1f2328; }\n.iwb-blank-menu .iwb-blank-title { font-weight: 700; font-size: 12px; margin-bottom: 8px; }\n.iwb-blank-menu .iwb-blank-bg, .iwb-blank-menu .iwb-blank-res { display: flex; align-items: center; gap: 5px; margin-bottom: 7px; }\n.iwb-blank-menu .iwb-blank-bg span, .iwb-blank-menu .iwb-blank-res span { color: #656d76; min-width: 26px; }\n.iwb-blank-menu button { border: 1px solid #d0d7de; background: #f6f8fa; color: #1f2328; border-radius: 6px; padding: 3px 8px; cursor: pointer; font-size: 11px; }\n.iwb-blank-menu button:hover { background: #eff2f4; }\n.iwb-blank-menu button.on { background: #0ea5e9; border-color: #0ea5e9; color: #fff; }\n.iwb-blank-menu .iwb-blank-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 4px; }\n.iwb-blank-menu .iwb-blank-grid button { display: flex; flex-direction: column; gap: 1px; align-items: center; padding: 5px 4px; }\n.iwb-blank-menu .iwb-blank-grid b { font-weight: 600; }\n.iwb-blank-menu .iwb-blank-grid i { font-style: normal; color: #656d76; font-size: 10px; }\n\n/* 空参考图节点:常驻“空白画布”按钮(位于节点顶部中央) */\n.iwb-blank-inline-btn { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 6; display: inline-flex; align-items: center; gap: 5px; background: #fff; border: 1px solid #d0d7de; border-radius: 14px; padding: 4px 11px; color: #0ea5e9; font-size: 11px; font-weight: 600; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }\n.iwb-blank-inline-btn:hover { background: #f0f9ff; border-color: #0ea5e9; }\n.iwb-blank-inline-btn svg { width: 13px; height: 13px; }\n\n/* ============ UI 布局重构(参照 excalidraw) ============ */\n/* 顶部:功能按钮在左,工具栏横排整行、按快捷键排序并带数字角标 */\n.iwb-editor-header { flex-wrap: wrap; }\n.iwb-editor-header > .iwb-editor-title { order: 1; }\n.iwb-editor-header > .iwb-editor-actions { order: 2; }\n.iwb-editor-header > .iwb-editor-tools {\n position: static;\n order: 3;\n flex: 1 1 100%;\n width: auto;\n left: auto;\n top: auto;\n margin-top: 8px;\n flex-direction: row;\n justify-content: center;\n padding: 6px 10px;\n border-radius: 10px;\n}\n.iwb-editor-tool { position: relative; }\n.iwb-tool-key {\n position: absolute;\n right: -3px;\n bottom: -3px;\n font-size: 8px;\n line-height: 1;\n background: #45475a;\n color: #cdd6f4;\n padding: 1px 3px;\n border-radius: 3px;\n pointer-events: none;\n font-style: normal;\n font-weight: 600;\n}\n.iwb-editor-tool.active .iwb-tool-key { background: #1e1e2e; color: #e8a735; }\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-divider { width: 1px; height: 22px; margin: 0 6px; }\n\n/* 左侧:工具参数设定栏(缩放/实心/图层/描边/硬度/透明度) */\n.iwb-editor-params {\n width: 216px;\n min-width: 216px;\n flex: 0 0 216px;\n flex-direction: column;\n align-items: stretch;\n gap: 12px;\n margin-left: 0;\n padding: 14px 12px;\n background: #181825;\n border-right: 1px solid #313244;\n overflow-y: auto;\n}\n.iwb-editor-params .iwb-editor-zoom { margin-left: 0; order: 0; }\n.iwb-editor-params .iwb-editor-zoom .iwb-editor-zoom-val { min-width: 52px; text-align: center; }\n.iwb-editor-params .iwb-editor-layer-group { flex-wrap: wrap; justify-content: flex-start; }\n.iwb-editor-params .iwb-editor-brush-label { width: 100%; }\n.iwb-editor-params .iwb-editor-brush-presets { justify-content: flex-start; }\n.iwb-editor-params .iwb-editor-fill-btn { align-self: stretch; }\n.iwb-editor-main { display: flex; flex-direction: row; }\n\n/* ======== 布局重构 v2(按用户 6 点) ======== */\n.iwb-editor-main { display: flex; flex-direction: row; align-items: stretch; }\n\n/* 顶部一行:标题 + 工具栏(含数字角标) + 撤销重做清空还原 */\n.iwb-editor-header { flex-wrap: nowrap; align-items: center; }\n.iwb-editor-header > .iwb-editor-title { order: 0; }\n.iwb-editor-header > .iwb-editor-tools {\n position: static; order: 1; flex: 1 1 auto; flex-basis: auto;\n margin-top: 0; width: auto; left: auto; top: auto;\n flex-direction: row; justify-content: center;\n padding: 0; background: transparent; border: 0; border-radius: 0;\n}\n.iwb-editor-header > .iwb-editor-divider { order: 2; }\n.iwb-editor-header > .iwb-editor-history { order: 3; display: flex; align-items: center; gap: 4px; }\n\n/* 左栏:调色板在上,参数竖排,导出按钮底部 */\n.iwb-editor-left {\n width: 240px; min-width: 240px; flex: 0 0 240px;\n display: flex; flex-direction: column; gap: 14px;\n padding: 12px; background: #181825; border-right: 1px solid #313244; overflow-y: auto;\n}\n.iwb-editor-left > .iwb-editor-color-panel { padding: 0; background: transparent; border-bottom: 0; }\n.iwb-editor-left > .iwb-editor-params {\n width: auto; min-width: 0; flex: 1 1 auto;\n flex-direction: column; align-items: stretch; gap: 12px; margin-left: 0; padding: 0;\n}\n.iwb-editor-left > .iwb-editor-export-actions {\n display: flex; flex-direction: column; gap: 8px;\n margin-top: auto; padding-top: 12px; border-top: 1px solid #313244;\n}\n.iwb-editor-left > .iwb-editor-export-actions .iwb-editor-btn { width: 100%; }\n\n/* 参数竖排:一行一个设置 */\n.iwb-editor-params .iwb-editor-brush-group { display: flex; flex-direction: column; gap: 10px; }\n.iwb-editor-params .iwb-editor-zoom .iwb-editor-zoom-btn,\n.iwb-editor-params .iwb-editor-zoom .iwb-editor-zoom-val { flex: 1 1 auto; }\n.iwb-editor-params .iwb-editor-layer-group { flex-wrap: wrap; }\n\n/* 颜色值后面的 实心/边线 切换 */\n.iwb-editor-fill-pair { display: inline-flex; margin-left: 6px; }\n.iwb-editor-fill-pair .iwb-editor-fill-btn { align-self: center; }\n\n/* ======== 布局优化 v3 ======== */\n/* 左栏可交互(避免被画布/层级遮挡导致“调节不起作用”) */\n.iwb-editor-left { position: relative; z-index: 40; pointer-events: auto; }\n.iwb-editor-left input, .iwb-editor-left select, .iwb-editor-left button, .iwb-editor-left label { pointer-events: auto; }\n\n/* 顶部工具栏内的 面/边(实心) 切换按钮 */\n.iwb-editor-tools .iwb-editor-fill-btn {\n width: 42px; height: 32px; padding: 0; border: 0; border-radius: 8px;\n background: transparent; color: #cdd6f4; cursor: pointer; font-size: 11px; font-weight: 600;\n}\n.iwb-editor-tools .iwb-editor-fill-btn:hover { background: #45475a; }\n.iwb-editor-tools .iwb-editor-fill-btn.active { background: #e8a735; color: #1e1e2e; }\n\n/* 右侧图层面板内的图层顺序按钮 */\n.iwb-editor-layer-panel .iwb-editor-layer-group {\n display: flex; align-items: center; gap: 6px;\n padding: 10px 12px; border-bottom: 1px solid #313244;\n}\n.iwb-editor-layer-panel .iwb-editor-layer-group .iwb-editor-constraint-label { color: #a6adc8; font-size: 12px; margin-right: 2px; }\n\n/* 缩放(画面调整)移到左栏下方 */\n.iwb-editor-params .iwb-editor-zoom {\n order: 99; margin-top: 10px; padding-top: 10px; border-top: 1px solid #313244;\n}\n.iwb-editor-params .iwb-editor-zoom .iwb-editor-zoom-btn { flex: 0 0 auto; }\n.iwb-editor-params .iwb-editor-zoom .iwb-editor-zoom-val { flex: 0 0 auto; }\n\n/* ======== 布局优化 v4 ======== */\n/* 交换左右栏:图层在左,调色板/参数在右 */\n.iwb-editor-main { flex-direction: row; }\n.iwb-editor-main > .iwb-editor-layer-panel { order: 1; border-left: 0; border-right: 1px solid #313244; }\n.iwb-editor-main > .iwb-editor-canvas-wrap { order: 2; }\n.iwb-editor-left { order: 3; border-right: 0; border-left: 1px solid #313244; }\n\n/* 硬度/透明度 数值与滑块对齐 */\n.iwb-editor-params .iwb-editor-brush-label .iwb-editor-brush-hardness-val,\n.iwb-editor-params .iwb-editor-brush-label .iwb-editor-brush-opacity-val {\n min-width: 40px; text-align: right; color: #cdd6f4; font-size: 12px;\n}\n.iwb-editor-params .iwb-editor-brush-label input[type="range"] { flex: 1 1 auto; }\n\n/* 缩放块放在参数区最底部 */\n.iwb-editor-params .iwb-editor-zoom, .iwb-editor-left .iwb-editor-zoom {\n display: flex; align-items: center; justify-content: center; gap: 8px;\n width: 100%; padding: 8px 4px; border-top: 1px solid #313244; margin-top: 12px;\n}\n.iwb-editor-left .iwb-editor-zoom .iwb-editor-zoom-btn {\n flex: 0 0 auto; min-width: 28px; height: 26px; background: #313244; color: #cdd6f4; border: 0; border-radius: 6px; cursor: pointer; font-size: 14px;\n}\n.iwb-editor-left .iwb-editor-zoom .iwb-editor-zoom-btn:hover { background: #45475a; }\n.iwb-editor-left .iwb-editor-zoom .iwb-editor-zoom-val { min-width: 52px; text-align: center; color: #cdd6f4; font: 600 12px sans-serif; }\n\n/* 调色板与下方参数调节之间的横线分割 */\n.iwb-editor-params { border-top: 1px solid #313244; padding-top: 12px; }\n\n/* 色相条指示器需定位父级相对 */\n.iwb-color-hue { position: relative; }\n\n/* 顶部实心按钮与工具匹配:默认背景 */\n.iwb-editor-tools .iwb-editor-fill-btn { background: #313244; color: #cdd6f4; }\n\n/* 裁剪工具条:三行展示(比例 / 尺寸 / 确认取消),避免被挤压 */\n.iwb-editor-crop-bar {\n display: flex;\n flex-direction: column;\n gap: 8px;\n align-items: center;\n padding: 10px 14px;\n}\n.iwb-editor-crop-row { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; width: 100%; gap: 6px; }\n.iwb-editor-crop-row .iwb-editor-constraint-group { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }\n.iwb-editor-crop-actions { gap: 10px; }\n.iwb-editor-crop-actions .iwb-editor-crop-info { min-width: 88px; text-align: center; }\n.iwb-editor-constraint-sep { display: none; }\n\n/* ======== 修复:左列(图层)占满高度,三列稳定布局 ======== */\n.iwb-editor-main { display: flex; flex-direction: row; align-items: stretch; }\n.iwb-editor-main > .iwb-editor-layer-panel { flex: 0 0 290px; min-width: 290px; width: 290px; }\n.iwb-editor-main > .iwb-editor-canvas-wrap { flex: 1 1 auto; min-width: 0; }\n.iwb-editor-left { flex: 0 0 240px; min-width: 240px; width: 240px; }\n.iwb-editor-layer-panel .iwb-editor-layer-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; }\n\n/* ======== 顶部布局 v5:左侧重置类 / 中间工具 / 右侧保存类 ======== */\n.iwb-editor-header > .iwb-editor-title { order: 0; }\n.iwb-editor-header > .iwb-editor-history { order: 1; display: flex; align-items: center; gap: 4px; }\n.iwb-editor-header > .iwb-editor-tools { order: 2; flex: 1 1 auto; justify-content: center; }\n.iwb-editor-header > .iwb-editor-export-actions { order: 3; display: flex; align-items: center; gap: 6px; margin-left: 4px; }\n\n/* 重置类(撤销/重做/清空/复原)统一小圆角按钮 */\n.iwb-editor-header .iwb-editor-history .iwb-editor-action {\n width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px;\n background: #313244; color: #cdd6f4; display: inline-flex; align-items: center; justify-content: center; cursor: pointer;\n}\n.iwb-editor-header .iwb-editor-history .iwb-editor-action:hover { background: #45475a; }\n.iwb-editor-header .iwb-editor-history .iwb-editor-action-restore { background: #313244; color: #cdd6f4; }\n\n/* 保存类(新建/覆盖/退出)统一样式 */\n.iwb-editor-header .iwb-editor-export-actions .iwb-editor-btn {\n height: 30px; padding: 0 14px; border: 0; border-radius: 8px; font-size: 12px; font-weight: 600;\n background: #313244; color: #cdd6f4; cursor: pointer;\n}\n.iwb-editor-header .iwb-editor-export-actions .iwb-editor-btn:hover { background: #45475a; }\n\n/* 调色板与参数之间的分割线及间距 */\n.iwb-editor-left > .iwb-editor-params { border-top: 1px solid #313244; margin-top: 16px; padding-top: 16px; }\n\n/* 笔刷快捷值 7 档圆点 */\n.iwb-editor-brush-presets { display: flex; align-items: center; gap: 8px; }\n.iwb-editor-brush-preset i { width: 6px; height: 6px; }\n.iwb-editor-brush-preset:nth-child(2) i { width: 8px; height: 8px; }\n.iwb-editor-brush-preset:nth-child(3) i { width: 10px; height: 10px; }\n.iwb-editor-brush-preset:nth-child(4) i { width: 13px; height: 13px; }\n.iwb-editor-brush-preset:nth-child(5) i { width: 16px; height: 16px; }\n.iwb-editor-brush-preset:nth-child(6) i { width: 20px; height: 20px; }\n.iwb-editor-brush-preset:nth-child(7) i { width: 24px; height: 24px; }\n\n/* 缩放:缩小比例、圆角 */\n.iwb-editor-left .iwb-editor-zoom { gap: 6px; padding: 6px 4px; margin-top: 10px; }\n.iwb-editor-left .iwb-editor-zoom .iwb-editor-zoom-btn { min-width: 26px; height: 24px; border-radius: 8px; font-size: 13px; }\n.iwb-editor-left .iwb-editor-zoom .iwb-editor-zoom-val { min-width: 44px; font-size: 11px; }\n.iwb-editor-left .iwb-editor-zoom .iwb-editor-zoom-fit { font-size: 11px; padding: 0 8px; }\n\n/* 笔刷快捷值:压缩横向间距,避免右栏出现横向滚动条 */\n.iwb-editor-left { overflow-x: hidden; }\n.iwb-editor-params { overflow-x: hidden; }\n.iwb-editor-brush-presets { gap: 3px; flex-wrap: wrap; max-width: 100%; justify-content: flex-start; }\n.iwb-editor-brush-preset { padding: 0 1px; min-width: 0; flex: 0 0 auto; }\n.iwb-editor-brush-preset i { width: 5px; height: 5px; }\n.iwb-editor-brush-preset:nth-child(2) i { width: 7px; height: 7px; }\n.iwb-editor-brush-preset:nth-child(3) i { width: 9px; height: 9px; }\n.iwb-editor-brush-preset:nth-child(4) i { width: 11px; height: 11px; }\n.iwb-editor-brush-preset:nth-child(5) i { width: 14px; height: 14px; }\n.iwb-editor-brush-preset:nth-child(6) i { width: 17px; height: 17px; }\n.iwb-editor-brush-preset:nth-child(7) i { width: 20px; height: 20px; }\n\n/* 去掉参数模块右侧的边线(隐藏纵向滚动条与右边框) */\n.iwb-editor-left { border-right: 0 !important; scrollbar-width: none; -ms-overflow-style: none; }\n.iwb-editor-left::-webkit-scrollbar { width: 0; height: 0; display: none; }\n.iwb-editor-left > .iwb-editor-params { border-right: 0; }\n.iwb-editor-brush-presets::-webkit-scrollbar { width: 0; height: 0; display: none; }\n\n/* 独立悬浮工具条(扩展自建,不插入应用 React DOM) */\n.iwb-cutout-toolbar {\n position: fixed; z-index: 2147483000; display: none; align-items: center; gap: 3px;\n padding: 4px 6px; border-radius: 14px; background: #fff;\n border: 1px solid #d0d7de; box-shadow: 0 8px 28px rgba(15, 23, 42, 0.14);\n pointer-events: auto;\n}\n.iwb-cutout-toolbar button {\n width: 30px; height: 28px; padding: 0; border: 0; border-radius: 8px;\n background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;\n}\n.iwb-cutout-toolbar button:hover { background: #eef2f7; }\n.iwb-cutout-toolbar button i { font-style: normal; font-size: 11px; font-weight: 700; }\n.iwb-cutout-toolbar button svg { display: block; }\n\n/* 顶部左右两组工具交换:左=新建/覆盖/退出,右=撤销/重做/清空/复原 */\n.iwb-editor-header > .iwb-editor-title { order: 0; }\n/* 输出设定 + 下载/新建/覆盖/退出 收在顶栏最右侧(用户裁定 2026-11-04):\n order 排最后 + margin-left:auto 兜底,中间工具区 flex:1 会把它顶到右端 */\n.iwb-editor-header > .iwb-editor-export-actions { order: 9; margin-left: auto; margin-right: 0; flex: 0 0 auto; }\n.iwb-editor-header > .iwb-editor-tools { order: 2; flex: 1 1 auto; justify-content: center; }\n.iwb-editor-header > .iwb-editor-history { order: 3; margin-left: 0; }\n\n/* 图层面板:放大锁定 / 删除按钮的点击区域与图标 */\n.iwb-editor-layer-panel .iwb-layer-lock,\n.iwb-editor-layer-panel .iwb-layer-del {\n width: 24px; height: 24px; padding: 0; display: inline-flex; align-items: center; justify-content: center;\n}\n.iwb-editor-layer-panel .iwb-layer-lock svg,\n.iwb-editor-layer-panel .iwb-layer-del svg { width: 16px; height: 16px; }\n\n\n/* 图层按钮图标统一 14px */\n.iwb-editor-layer-panel .iwb-layer-vis svg,\n.iwb-editor-layer-panel .iwb-layer-lock svg,\n.iwb-editor-layer-panel .iwb-layer-del svg { width: 14px; height: 14px; }\n.iwb-editor-layer-panel .iwb-layer-vis,\n.iwb-editor-layer-panel .iwb-layer-lock,\n.iwb-editor-layer-panel .iwb-layer-del { width: 22px; height: 22px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }\n\n/* ================================================================\n v1.1 便利版 UI(单张处理)\n 只追加、不重写历史样式:旧规则里的魔数定位在这里统一覆盖。\n 分区:顶栏 / 就地选项栏 / 竖工具栏 / 画布浮层 / 状态栏 / toast\n ================================================================ */\n\n/* ---- 顶栏:精简、一步可达 ---- */\n.iwb-editor-header { min-height: 44px; padding: 6px 12px; gap: 8px; }\n.iwb-editor-title em.iwb-editor-doc-size { font-style: normal; font-weight: 400; font-size: 11px; color: #7f849c; margin-left: 6px; }\n.iwb-editor-optionbar {\n display: flex; align-items: center; gap: 10px;\n height: 36px; min-height: 36px; padding: 0 12px;\n background: #202033; border-bottom: 1px solid #313244;\n color: #a6adc8; font-size: 12px;\n}\n.iwb-editor-optionbar-label { color: #7f849c; font-weight: 600; white-space: nowrap; }\n.iwb-editor-optionbar-body { display: flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; }\n.iwb-opt-label { color: #a6adc8; white-space: nowrap; }\n.iwb-opt-btn {\n background: #313244; color: #cdd6f4; border: 1px solid transparent; border-radius: 5px;\n padding: 3px 9px; font-size: 12px; cursor: pointer;\n}\n.iwb-opt-btn:hover { background: #45475a; }\n.iwb-opt-btn.active { background: #4488ff; color: #fff; }\n.iwb-opt-num {\n width: 46px; padding: 2px 4px; background: #313244; color: #e8a735;\n border: 1px solid #45475a; border-radius: 5px; text-align: center; font-size: 12px;\n}\n.iwb-opt-current { color: #e8a735; font-weight: 600; white-space: nowrap; }\n.iwb-opt-hint { color: #7f849c; font-size: 11px; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n\n.iwb-editor-more-wrap, .iwb-editor-export-settings-wrap { position: relative; flex: 0 0 auto; z-index: 45; }\n.iwb-editor-more-btn, .iwb-editor-panel-toggle, .iwb-editor-export-settings-btn {\n background: #313244; color: #cdd6f4; border: 1px solid #45475a; border-radius: 6px;\n padding: 5px 10px; font-size: 12px; cursor: pointer; white-space: nowrap;\n}\n.iwb-editor-more-btn:hover, .iwb-editor-panel-toggle:hover, .iwb-editor-export-settings-btn:hover { background: #45475a; }\n.iwb-editor-panel-toggle { padding: 5px 8px; }\n.iwb-editor-export-summary { color: #e8a735; margin: 0 2px; }\n\n.iwb-editor-more-menu, .iwb-editor-export-settings {\n display: none; position: absolute; top: 34px; z-index: 60;\n background: #252537; border: 1px solid #45475a; border-radius: 8px;\n padding: 6px; box-shadow: 0 10px 30px rgba(0,0,0,0.45);\n}\n.iwb-editor-more-menu { left: 0; width: 206px; flex-direction: column; gap: 2px; }\n.iwb-editor-more-menu.open, .iwb-editor-export-settings.open { display: flex; flex-direction: column; gap: 4px; }\n.iwb-editor-export-settings { right: 0; width: 268px; }\n.iwb-editor-more-menu button, .iwb-editor-export-row button {\n background: transparent; color: #cdd6f4; border: 0; border-radius: 5px;\n padding: 6px 8px; font-size: 12px; text-align: left; cursor: pointer; white-space: nowrap;\n}\n.iwb-editor-more-menu button:hover, .iwb-editor-export-row button:hover { background: #3b3d52; }\n.iwb-editor-more-menu kbd { float: right; color: #7f849c; font-size: 10px; }\n.iwb-editor-more-sep { height: 1px; background: #45475a; margin: 4px 0; }\n.iwb-editor-export-row { display: flex; align-items: center; gap: 4px; }\n.iwb-editor-export-row > span { width: 34px; flex: 0 0 34px; color: #7f849c; font-size: 11px; }\n.iwb-editor-export-row button { flex: 1 1 auto; text-align: center; background: #313244; }\n.iwb-editor-export-row button.active { background: #4488ff; color: #fff; }\n.iwb-editor-export-note { color: #7f849c; font-size: 11px; border-top: 1px solid #313244; padding-top: 6px; }\n.iwb-editor-btn-download { background: #1a7f37 !important; color: #fff !important; }\n.iwb-editor-btn-download:hover { background: #15803d !important; }\n\n/* ---- v1.2.8:底部浮动工具栏(Figma 风格,横排悬浮在画布底部居中) ----\n 工具栏已从 header 移进 canvas-wrap,只占画布区域宽度,不挤压左右面板;\n bottom 距容器 14px,配合 computeFit() 预留的底部空间,图片不会被压住。 */\n.iwb-editor-canvas-wrap > .iwb-editor-tools {\n position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);\n display: flex; flex-direction: row; align-items: center; gap: 2px;\n padding: 5px 8px; border-radius: 14px;\n background: rgba(24, 24, 37, 0.94);\n border: 1px solid #313244;\n box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);\n -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);\n z-index: 40;\n max-width: calc(100% - 28px);\n overflow-x: auto; overflow-y: hidden; scrollbar-width: none;\n}\n.iwb-editor-canvas-wrap > .iwb-editor-tools::-webkit-scrollbar { display: none; }\n.iwb-editor-canvas-wrap > .iwb-editor-tools .iwb-editor-tool,\n.iwb-editor-canvas-wrap > .iwb-editor-tools .iwb-editor-action {\n width: 32px !important; height: 32px !important; min-width: 32px; flex: 0 0 auto; border-radius: 9px;\n}\n.iwb-editor-canvas-wrap > .iwb-editor-tools .iwb-editor-divider {\n width: 1px; height: 20px; margin: 0 5px; flex: 0 0 auto; background: #45475a;\n}\n.iwb-editor-main { padding-left: 0; }\n.iwb-editor-main > .iwb-editor-layer-panel { flex: 0 0 260px !important; min-width: 260px !important; width: 260px !important; }\n.iwb-editor-left { flex: 0 0 220px !important; min-width: 220px !important; width: 220px !important; }\n.iwb-editor-overlay.panels-collapsed .iwb-editor-layer-panel,\n.iwb-editor-overlay.panels-collapsed .iwb-editor-left { display: none !important; }\n.iwb-editor-zoom-hint { display: none !important; }\n\n/* ---- 交互层:蚂蚁线 / 笔刷环各自独立,互不擦除 ---- */\n.iwb-editor-selection-overlay, .iwb-editor-cursor-overlay {\n position: absolute; top: 0; left: 0; display: block; pointer-events: none;\n background: transparent !important;\n}\n.iwb-editor-selection-overlay { z-index: 11; }\n.iwb-editor-cursor-overlay { z-index: 12; }\n\n/* ---- 选区浮动操作条(体验后再定去留;纯视图,可随时替换) ---- */\n.iwb-editor-sel-bar {\n display: none; position: absolute; z-index: 30; align-items: center; gap: 4px;\n padding: 5px 6px; background: rgba(24,24,37,0.96);\n border: 1px solid #45475a; border-radius: 8px;\n box-shadow: 0 8px 26px rgba(0,0,0,0.45); white-space: nowrap;\n}\n.iwb-editor-sel-bar.as-menu { border-color: #4488ff; }\n.iwb-editor-sel-bar .iwb-editor-sel-info {\n color: #7f849c; font-size: 11px; padding: 0 6px;\n border-right: 1px solid #45475a; margin-right: 2px; font-variant-numeric: tabular-nums;\n}\n.iwb-editor-sel-bar button {\n background: #313244; color: #cdd6f4; border: 1px solid transparent; border-radius: 5px;\n padding: 4px 8px; font-size: 12px; cursor: pointer;\n}\n.iwb-editor-sel-bar button:hover:not(:disabled) { background: #4488ff; color: #fff; }\n.iwb-editor-sel-bar button[data-sel-cmd="sel.delete"]:hover:not(:disabled) { background: #cf222e; }\n.iwb-editor-sel-bar button:disabled { opacity: 0.35; cursor: not-allowed; }\n\n/* ---- 状态栏 / toast ---- */\n.iwb-editor-statusbar {\n display: flex; align-items: center; gap: 14px;\n height: 26px; min-height: 26px; padding: 0 12px;\n background: #181825; border-top: 1px solid #313244;\n color: #a6adc8; font-size: 11px; font-variant-numeric: tabular-nums;\n}\n.iwb-editor-statusbar span + span { border-left: 1px solid #313244; padding-left: 14px; }\n.iwb-editor-status-tool { margin-left: auto; color: #e8a735; }\n.iwb-editor-toast {\n position: fixed; left: 50%; bottom: 46px; z-index: 1000000;\n transform: translate(-50%, 12px); opacity: 0; pointer-events: none;\n transition: opacity 0.2s, transform 0.2s;\n background: #313244; color: #cdd6f4; padding: 8px 14px; border-radius: 8px;\n font-size: 12px; max-width: 80vw; box-shadow: 0 8px 26px rgba(0,0,0,0.45);\n}\n.iwb-editor-toast.show { opacity: 1; transform: translate(-50%, 0); }\n.iwb-editor-toast-success { background: #1a7f37; color: #fff; }\n.iwb-editor-toast-error { background: #cf222e; color: #fff; }\n.iwb-editor-toast-warn { background: #b06a00; color: #fff; }\n.iwb-editor-toast-info { background: #2f6fed; color: #fff; }\n\n@media (max-width: 900px) {\n .iwb-opt-hint, .iwb-editor-optionbar-tip { display: none; }\n .iwb-editor-session .iwb-editor-btn-cancel,\n .iwb-editor-export-actions .iwb-editor-btn-cancel { display: none; }\n}\n\n\n/* 输出设置:按预设显示的行(尺寸/体积只属于电商方图)\n 注意 `.iwb-editor-export-row` 是 display:flex,会盖掉 UA 的 [hidden]{display:none},\n 必须显式 !important,否则 JS 设 hidden 后行还留在面板里。 */\n.iwb-editor-export-row[hidden] { display: none !important; }\n.iwb-editor-export-settings [data-export-key]:disabled {\n opacity: 0.32; cursor: not-allowed; text-decoration: line-through;\n}\n.iwb-editor-export-settings [data-export-key]:disabled:hover { background: #313244; }\n\n/* 选项栏参数控件(v1.2):滑杆 + 数字框 + 实时读数,一行放得下就该保持一行 */\n.iwb-opt-range {\n width: 84px; height: 4px; flex: 0 0 auto;\n accent-color: #4488ff; cursor: pointer;\n}\n.iwb-opt-val {\n min-width: 32px; flex: 0 0 auto; color: #e8a735; font-size: 11px;\n font-variant-numeric: tabular-nums; text-align: right;\n}\n.iwb-opt-unit { color: #7f849c; font-size: 11px; flex: 0 0 auto; }\n/* 窄屏:参数多到放不下时横向滚动,不换行(换行会把 36px 高的选项栏撑开压画布) */\n.iwb-editor-optionbar-body { overflow-x: auto; scrollbar-width: none; }\n.iwb-editor-optionbar-body::-webkit-scrollbar { display: none; }\n@media (max-width: 1100px) {\n .iwb-opt-range { width: 64px; }\n}\n\n/* ---- v1.2.2 ---- */\n/* 选项栏快捷值圆点(笔刷大小 / 矢量描边推荐值),与侧栏描边快捷点同交互 */\n.iwb-opt-dots { display: inline-flex; align-items: center; gap: 3px; flex: 0 0 auto; }\n.iwb-opt-dot {\n display: inline-flex; align-items: center; justify-content: center;\n width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%;\n background: transparent; cursor: pointer;\n}\n.iwb-opt-dot i { display: block; width: 5px; height: 5px; border-radius: 50%; background: #e8a735; border: 1px solid #f6d38a; }\n.iwb-opt-dot:nth-child(2) i { width: 7px; height: 7px; }\n.iwb-opt-dot:nth-child(3) i { width: 9px; height: 9px; }\n.iwb-opt-dot:nth-child(4) i { width: 11px; height: 11px; }\n.iwb-opt-dot:nth-child(5) i { width: 14px; height: 14px; }\n.iwb-opt-dot:nth-child(6) i { width: 17px; height: 17px; }\n.iwb-opt-dot:nth-child(7) i { width: 20px; height: 20px; }\n.iwb-opt-dot:hover { background: #313244; }\n\n/* 裁剪控件在选项栏内联布局(旧 .iwb-editor-crop-bar 的绝对定位容器已删除) */\n.iwb-editor-optionbar-body .iwb-editor-crop-info {\n min-width: 88px; text-align: center; color: #e8a735;\n font-size: 11px; font-variant-numeric: tabular-nums; flex: 0 0 auto;\n}\n.iwb-editor-optionbar-body .iwb-editor-size-input {\n width: 52px; padding: 2px 5px; font-size: 11px;\n background: #1e2030; color: #e5e9f0;\n border: 1px solid #45475a; border-radius: 4px;\n}\n.iwb-editor-optionbar-body .iwb-editor-size-input:focus { outline: none; border-color: #4488ff; }\n/* 硬度滑杆加宽:参数太密时默认 84px 拉不开,用户反馈「软度调节不明显」(2026-11-04) */\n.iwb-editor-optionbar-body .iwb-opt-range-wide { width: 140px; }\n.iwb-editor-optionbar-body .iwb-opt-dots { margin-left: 2px; }\n.iwb-editor-optionbar-body .iwb-editor-size-input::-webkit-inner-spin-button { -webkit-appearance: none; }\n.iwb-editor-optionbar-body .iwb-editor-crop-confirm,\n.iwb-editor-optionbar-body .iwb-editor-crop-cancel {\n padding: 3px 10px; border: 0; border-radius: 4px; cursor: pointer; font-size: 12px; flex: 0 0 auto;\n}\n.iwb-editor-optionbar-body .iwb-editor-crop-confirm { background: #1a7f37; color: #fff; }\n.iwb-editor-optionbar-body .iwb-editor-crop-confirm:hover { background: #15803d; }\n.iwb-editor-optionbar-body .iwb-editor-crop-cancel { background: #cf222e; color: #fff; }\n.iwb-editor-optionbar-body .iwb-editor-crop-cancel:hover { background: #b91c1c; }\n\n/* ---- v1.2.3:侧栏只留调色板 + 缩放 ---- */\n/* 笔刷粗细/快捷点从侧栏移除后,缩放条直接挂在 aside 下:贴底,与调色板拉开距离 */\n.iwb-editor-left > .iwb-editor-zoom { margin-top: auto; border-top: 1px solid #313244; padding-top: 10px; }\n\n/* ================================================================\n v1.2.4:顶栏命令带(原「更多 ▾」图标化)\n 布局:标题 | 撤销·重做·还原 | ⟨图层 新建/导入⟩ ⟨顺序 置顶/上移/下移/置底⟩ ⟨视图 适应/侧栏⟩ | …… | 输出·下载·新建·覆盖·退出\n ================================================================ */\n.iwb-editor-header > .iwb-editor-history { order: 1; }\n.iwb-editor-header > .iwb-editor-commands { order: 3; display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }\n.iwb-editor-header > .iwb-editor-commands .iwb-editor-divider { width: 1px; height: 20px; background: #313244; flex: 0 0 auto; }\n.iwb-editor-cmdgroup { display: flex; align-items: center; gap: 4px; }\n.iwb-editor-cmdgroup[data-group="order"] { gap: 2px; }\n/* 顶栏里的命令按钮统一 30×30 方角,和撤销/重做同款 */\n.iwb-editor-header > .iwb-editor-commands .iwb-editor-action,\n.iwb-editor-header > .iwb-editor-commands .iwb-editor-layer-btn {\n width: 30px; height: 30px; min-width: 30px; padding: 0; border: 0; border-radius: 8px;\n background: #313244; color: #cdd6f4;\n display: inline-flex; align-items: center; justify-content: center; cursor: pointer;\n}\n.iwb-editor-header > .iwb-editor-commands .iwb-editor-action:hover:not(:disabled),\n.iwb-editor-header > .iwb-editor-commands .iwb-editor-layer-btn:hover:not(:disabled) { background: #45475a; }\n.iwb-editor-header > .iwb-editor-commands .iwb-editor-layer-btn:disabled { opacity: 0.35; cursor: not-allowed; }\n/* 选区命令(全选/反选/取消):v1.2.5 起放在「选择」工具的选项栏里,不再占竖工具条 */\n.iwb-opt-sep { width: 1px; height: 18px; background: #313244; margin: 0 4px 0 auto; flex: 0 0 auto; }\n.iwb-opt-selcmd {\n width: 26px; height: 26px; min-width: 26px; padding: 0; border: 0; border-radius: 7px;\n background: #26263a; color: #cdd6f4; flex: 0 0 auto;\n display: inline-flex; align-items: center; justify-content: center; cursor: pointer;\n}\n.iwb-opt-selcmd:hover { background: #45475a; }\n\n/* ================================================================\n v1.2.11:顶栏次序与配色(用户裁定 2026-11-04 晚)\n 布局:标题 | ⟨新建·覆盖·退出⟩ | 撤销·重做·还原 | 顺序·视图 | …… | 输出·导出\n 标题在前(它是标题,不能跑到按钮后面);会话组三键统一中性色,不再花\n ================================================================ */\n.iwb-editor-header > .iwb-editor-title { order: 0; }\n.iwb-editor-header > .iwb-editor-session { order: 1; display: flex; align-items: center; gap: 6px; flex: 0 0 auto; margin-left: 8px; }\n.iwb-editor-header > .iwb-editor-session .iwb-editor-btn { padding: 6px 10px; font-size: 11px; min-width: 56px; white-space: nowrap; }\n.iwb-editor-header > .iwb-editor-session .iwb-editor-btn-new,\n.iwb-editor-header > .iwb-editor-session .iwb-editor-btn-replace,\n.iwb-editor-header > .iwb-editor-session .iwb-editor-btn-cancel { background: #45475a; color: #cdd6f4; }\n.iwb-editor-header > .iwb-editor-session .iwb-editor-btn-new:hover,\n.iwb-editor-header > .iwb-editor-session .iwb-editor-btn-replace:hover,\n.iwb-editor-header > .iwb-editor-session .iwb-editor-btn-cancel:hover { background: #585b70; }\n/* 标题与会话组之间、撤销组与命令带之间的竖分隔 */\n.iwb-editor-header > .iwb-editor-session { margin-right: 4px; }\n.iwb-editor-header > .iwb-editor-divider { width: 1px; height: 20px; background: #313244; flex: 0 0 auto; margin: 0 4px; }\n\n/* ================================================================\n v1.3:色板搬进工具栏(用户裁定 2026-11-05)\n 工具栏最左一个「当前色圆点」,点开在工具栏上方弹出色板:\n [SV + 色相] | [吸管 + hex] | [6×2 推荐色]\n 弹层挂在 modal 下(不是工具栏里):工具栏 overflow-x:auto、\n canvas-wrap overflow:clip,放里面必被裁;位置由 events.js 按按钮矩形算。\n ================================================================ */\n.iwb-editor-modal { position: relative; }\n\n.iwb-editor-canvas-wrap > .iwb-editor-tools .iwb-editor-color-btn {\n width: 32px; height: 32px; min-width: 32px; flex: 0 0 auto; padding: 0;\n border: 0; border-radius: 9px; background: #313244; cursor: pointer;\n display: inline-flex; align-items: center; justify-content: center;\n}\n.iwb-editor-canvas-wrap > .iwb-editor-tools .iwb-editor-color-btn:hover,\n.iwb-editor-canvas-wrap > .iwb-editor-tools .iwb-editor-color-btn.active { background: #45475a; }\n.iwb-editor-color-btn i {\n width: 18px; height: 18px; border-radius: 50%; display: block; background: #ff4444;\n box-shadow: 0 0 0 2px #181825, 0 0 0 3px #585b70;\n}\n\n.iwb-editor-color-pop {\n position: absolute; z-index: 60; display: flex; align-items: center; gap: 10px;\n padding: 10px 12px; border-radius: 12px;\n background: rgba(24, 24, 37, 0.97); border: 1px solid #313244;\n box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);\n -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);\n}\n.iwb-editor-color-pop[hidden] { display: none; }\n.iwb-color-pop-picker { display: flex; gap: 8px; flex: 0 0 auto; }\n.iwb-editor-color-pop .iwb-color-sv { width: 180px; height: 104px; flex: 0 0 180px; }\n.iwb-editor-color-pop .iwb-color-hue { width: 16px; height: 104px; flex: 0 0 16px; }\n.iwb-color-pop-sep { width: 1px; align-self: stretch; background: #313244; flex: 0 0 auto; }\n.iwb-color-pop-fields { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }\n.iwb-editor-color-pop .iwb-editor-color-hex-input {\n width: 86px; height: 28px; padding: 0 6px; text-align: center;\n font: 600 12px monospace; border-radius: 6px; box-sizing: border-box;\n}\n.iwb-editor-color-pop .iwb-editor-color-swatches {\n display: grid; grid-template-columns: repeat(6, 22px); grid-auto-rows: 22px;\n gap: 7px; flex: 0 0 auto; align-content: center;\n}\n.iwb-editor-color-pop .iwb-editor-color-panel-swatch {\n width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;\n transition: transform 0.08s ease;\n}\n.iwb-editor-color-pop .iwb-editor-color-panel-swatch:hover { transform: scale(1.12); }\n.iwb-editor-color-pop .iwb-editor-color-panel-swatch.active {\n outline: 2px solid #fff; outline-offset: 2px;\n}\n.iwb-editor-color-pop .iwb-editor-color-eye { width: 28px; height: 28px; border-radius: 6px; }\n\n/* ================================================================\n v1.4:侧栏「快速效果」\n 3×2 网格,作用于当前位图图层。只做颜色/采样变换,不改几何。\n 图标全部用 CSS 渐变画(不引第三方库,也不加 SVG 体积)。\n ================================================================ */\n.iwb-editor-fx {\n display: flex; flex-direction: column; gap: 8px;\n flex: 0 0 auto;\n}\n.iwb-editor-fx-head {\n display: flex; align-items: center; justify-content: space-between; gap: 6px;\n}\n.iwb-editor-fx-title {\n font-size: 11px; font-weight: 600; letter-spacing: 0.4px; color: #a6adc8;\n}\n.iwb-editor-fx-target {\n max-width: 116px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;\n padding: 2px 6px; border-radius: 5px; background: #313244; color: #cdd6f4;\n font-size: 10px; line-height: 1.4;\n}\n.iwb-editor-fx-grid {\n display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;\n}\n.iwb-editor-fx-btn {\n display: flex; flex-direction: column; align-items: center; gap: 5px;\n padding: 7px 2px 6px; border: 1px solid transparent; border-radius: 9px;\n background: #232334; color: #cdd6f4;\n font: 500 10.5px/1 -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;\n cursor: pointer; transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;\n}\n.iwb-editor-fx-btn:hover { background: #313244; border-color: #45475a; }\n.iwb-editor-fx-btn:active { transform: scale(0.96); }\n.iwb-editor-fx-btn:focus-visible { outline: 2px solid #89b4fa; outline-offset: 1px; }\n.iwb-editor-fx-ico {\n width: 22px; height: 22px; border-radius: 5px; display: block;\n background-color: #d9d9e3;\n box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);\n}\n/* 图标统一垫浅色底:纯黑部分若直接压在深色按钮上会「消失」,看着像缺了个角 */\n.ico-invert { background-image: linear-gradient(135deg, transparent 0 50%, #14141f 50% 100%); }\n.ico-gray { background-image: linear-gradient(90deg, #12121c 0, #8a8a99 50%, #f4f4f8 100%); }\n.ico-boost {\n background-image: radial-gradient(circle at 50% 52%, #ffffff 0 24%, #cfcfdd 42%, #6e6e85 100%);\n}\n.ico-contrast { background-image: linear-gradient(90deg, #000000 0 46%, #ffffff 54% 100%); }\n.ico-soft {\n background-image: radial-gradient(circle at 50% 50%, #23233a 0 16%, rgba(35, 35, 58, 0.5) 34%, rgba(35, 35, 58, 0.16) 50%, rgba(35, 35, 58, 0) 68%);\n}\n.ico-mosaic {\n background-image: repeating-conic-gradient(#6b6b80 0% 25%, #d9d9e3 0% 50%);\n background-size: 10px 10px;\n}\n.iwb-editor-fx-tip {\n margin: 0; font-size: 10px; line-height: 1.55; color: #6c7086;\n}\n\n/* ================================================================\n v1.6:图层面板多选(⌘/Ctrl 点击)+ 合并按钮\n 多选用青色侧条与单选(橙色 #e8a735)区分:一个图层可以「被选中但不在合并集合里」,\n 两套状态不能长得一样。\n ================================================================ */\n.iwb-layer-item.multi {\n background: rgba(137, 180, 250, 0.14);\n box-shadow: inset 2px 0 0 #89b4fa;\n}\n.iwb-layer-item.multi.active {\n background: rgba(137, 180, 250, 0.2);\n box-shadow: inset 2px 0 0 #89b4fa, inset 0 0 0 1px rgba(137, 180, 250, 0.45);\n}\n.iwb-editor-layer-add-group { flex: 0 0 auto; flex-wrap: nowrap; }\n.iwb-editor-layer-add-btn[data-action="mergeLayers"]:hover,\n.iwb-editor-layer-add-btn[data-action="mergeVisible"]:hover {\n background: #45475a;\n border-color: #89b4fa;\n color: #cdd6f4;\n}\n'; // image-annotate/plugin/glue.js function createGlue(ctx, css) { diff --git a/image-annotate/tools/harness.mjs b/image-annotate/tools/harness.mjs index af082ae..793e5fc 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.12', 'version=' + boot.version) +check('产物可执行(循环打包未炸)', boot.version === '1.6.0', '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 }) @@ -136,14 +136,61 @@ check('打开编辑器默认只有「原图」1 层,且状态栏不再写「 !(await page.locator('.iwb-editor-status-layer').textContent()).includes('画笔标注'), JSON.stringify((await dbg()).layers.map(l => l.name))) -check('侧栏只剩调色板 + 缩放:笔刷大小/快捷点已移除(都收进工具选项栏,2026-11-04 用户裁定)', +// v1.3(用户裁定 2026-11-05):调色板从侧栏搬进工具栏弹层,侧栏只剩缩放 +check('调色板已搬进工具栏:侧栏只剩缩放,SV/色相/推荐色都在弹层里', await page.evaluate(() => { const q = (s) => Boolean(document.querySelector(s)) - return q('.iwb-editor-color-panel') && q('.iwb-color-sv') && q('.iwb-editor-zoom') && + return !q('.iwb-editor-left .iwb-editor-color-panel') && + q('.iwb-editor-tools [data-action="toggleColorPop"]') && + q('.iwb-editor-color-pop .iwb-color-sv') && q('.iwb-editor-color-pop .iwb-color-hue') && + document.querySelectorAll('.iwb-editor-color-pop .iwb-editor-color-panel-swatch').length === 12 && + q('.iwb-editor-zoom') && !q('.iwb-editor-brush-size') && !q('.iwb-editor-brush-num') && document.querySelectorAll('.iwb-editor-brush-preset').length === 0 })) +// v1.4:侧栏「快速效果」(用户 2026-11-05 提出:反白 + 其它推荐效果) +check('侧栏快速效果:6 个效果按钮齐备,目标层标签指向当前层', + await page.evaluate(() => { + const keys = [...document.querySelectorAll('.iwb-editor-left .iwb-editor-fx-btn')].map(b => b.dataset.fx).join(',') + const label = document.querySelector('.iwb-editor-fx-target') + return keys === 'invert,gray,boost,contrast,soft,mosaic' && !!label && label.textContent.trim() === '原图' + })) + +const fxInvert = await (async () => { + const read = () => page.evaluate(() => { + const c = document.querySelectorAll('.iwb-editor-layer-canvas')[0] + const d = c.getContext('2d').getImageData(2, 2, 1, 1).data + return d[0] + ',' + d[1] + ',' + d[2] + }) + const before = await read() + await page.locator('.iwb-editor-left [data-fx="invert"]').click() + await page.waitForTimeout(180) + const after = await read() + await page.keyboard.press('Control+z') + await page.waitForTimeout(180) + const back = await read() + return { ok: after !== before && back === before, detail: `before=${before} after=${after} undo=${back}` } +})() +check('反白真实反相且 Ctrl+Z 能复原(效果进历史链)', fxInvert.ok, fxInvert.detail) + +check('色板弹层默认收起;点工具栏色点弹出、且整块在视口内(没被工具栏/画布的 overflow 裁掉)', + await (async () => { + const pop = page.locator('.iwb-editor-color-pop') + if (await pop.isVisible()) return 'pre: 弹层一开始就开着' + await page.locator('.iwb-editor-tools [data-action="toggleColorPop"]').click() + await page.waitForTimeout(100) + if (!(await pop.isVisible())) return 'post: 点了没开' + const box = await pop.boundingBox() + const vp = page.viewportSize() + const inView = box && box.x >= 0 && box.y >= 0 && + box.x + box.width <= vp.width + 1 && box.y + box.height <= vp.height + 1 + // Esc 关掉(顺带验证 Esc 优先收弹层),不影响后面的用例 + await page.keyboard.press('Escape') + await page.waitForTimeout(80) + return inView && !(await pop.isVisible()) ? true : 'box=' + JSON.stringify(box) + })()) + const drag = async (x1, y1, x2, y2) => { await page.mouse.move(x1, y1) await page.mouse.down() @@ -684,15 +731,17 @@ await page.keyboard.press('Control+z') // 撤销还原,恢复图层结构 // ---- v1.2.4:顶栏命令带(「更多」图标化)/ 选择工具就地改形状参数 ---- -check('「更多」菜单已移除;顶栏只留顺序/视图命令,图层新建与导入回图层面板标题栏', await page.evaluate(() => { +check('「更多」菜单已移除;顶栏只留顺序/视图命令,图层新建/导入/合并在图层面板标题栏', await page.evaluate(() => { const q = (s) => Boolean(document.querySelector(s)) const hdrCmds = document.querySelectorAll('.iwb-editor-header .iwb-editor-commands .iwb-editor-layer-btn').length const titleBar = document.querySelector('.iwb-editor-layer-panel-header') const addBtns = titleBar ? titleBar.querySelectorAll('.iwb-editor-layer-add-btn').length : 0 const hdrAdd = document.querySelector('.iwb-editor-header [data-action="addBlankLayer"], .iwb-editor-header [data-action="addBitmapLayer"]') return !q('.iwb-editor-more-wrap') && !q('[data-action="toggleMore"]') && hdrCmds === 4 && !hdrAdd && - addBtns === 2 && q('.iwb-editor-layer-panel-header [data-action="addBlankLayer"]') && + addBtns === 4 && q('.iwb-editor-layer-panel-header [data-action="addBlankLayer"]') && q('.iwb-editor-layer-panel-header [data-action="addBitmapLayer"]') && + q('.iwb-editor-layer-panel-header [data-action="mergeLayers"]') && + q('.iwb-editor-layer-panel-header [data-action="mergeVisible"]') && q('.iwb-editor-header [data-action="zoomFit"]') && q('.iwb-editor-header [data-action="togglePanels"]') })) @@ -830,26 +879,72 @@ for (const [x, y] of [pA, pB, pC, pD]) await page.mouse.click(x, y) await page.mouse.click(pA[0], pA[1]) // 点回起点闭合 await page.waitForTimeout(120) const penShapeDbg = await dbg() -check('钢笔闭合路径落成并自动选中', penShapeDbg.selectedShapeId && +check('钢笔闭合路径落成后自动回 V 并选中(v1.5 用户裁定)', Boolean(penShapeDbg.selectedShapeId) && + penShapeDbg.tool === 'select' && penShapeDbg.shapes[penShapeDbg.shapes.length - 1].type === 'pen' && penShapeDbg.shapes[penShapeDbg.shapes.length - 1].closed === true, - JSON.stringify(penShapeDbg.shapes.slice(-1))) -check('选中钢笔路径的选项栏有 描边/实心(pen 归属)', - (await page.locator('.iwb-editor-optionbar-body [data-opt-toggle][data-fill-owner="pen"]').count()) === 2) + JSON.stringify({ sel: penShapeDbg.selectedShapeId, tool: penShapeDbg.tool, last: penShapeDbg.shapes.slice(-1) })) +// 选中改为显式:切 V 再点路径内部 await page.locator('.iwb-editor-tool[data-tool="select"]').click() +await page.mouse.click((pA[0] + pC[0]) / 2, (pA[1] + pC[1]) / 2) +await page.waitForTimeout(150) +check('V 选中钢笔路径后选项栏有 描边/实心(pen 归属)', + (await dbg()).selectedShapeId && + (await page.locator('.iwb-editor-optionbar-body [data-opt-toggle][data-fill-owner="pen"]').count()) === 2, + 'selected=' + (await dbg()).selectedShapeId) await page.locator('.iwb-editor-optionbar-body [data-opt-toggle="stroke"][data-fill-owner="pen"]').click() let penSelDbg = await dbg() check('选中钢笔路径就地切「描边」', penSelDbg.shapes[penSelDbg.shapes.length - 1].fill === false) 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) + +// v1.5:钢笔节点编辑统一走 V 双击(用户裁定 2026-11-05),P 下双击不再进编辑 +check('V 下双击钢笔进入节点编辑,P 下双击不进入', await (async () => { + const dx = (pA[0] + pC[0]) / 2, dy = (pA[1] + pC[1]) / 2 + await page.locator('.iwb-editor-tool[data-tool="select"]').click() + await page.mouse.dblclick(dx, dy) + await page.waitForTimeout(200) + const inEdit = (await dbg()).penEditId + await page.keyboard.press('Escape') + await page.waitForTimeout(120) + await page.locator('.iwb-editor-tool[data-tool="pen"]').click() + await page.mouse.dblclick(dx, dy) + await page.waitForTimeout(200) + const underPen = (await dbg()).penEditId + await page.locator('.iwb-editor-tool[data-tool="select"]').click() + return inEdit && !underPen ? true : 'V=' + inEdit + ' P=' + underPen +})()) + +// v1.5:文字输入完成(Enter)后自动回 V 并选中该文字(用户裁定 2026-11-05) +check('文字输入完成后自动回 V 并选中,输入框已收起', await (async () => { + const before = (await dbg()).texts.length + await page.locator('.iwb-editor-tool[data-tool="text"]').click() + await page.mouse.click(liveBox.x + liveBox.width * 0.14, liveBox.y + liveBox.height * 0.12) + await page.waitForTimeout(150) + const open = await page.evaluate(() => { const el = document.querySelector('.iwb-editor-text-input'); return el && el.style.display !== 'none' }) + if (!open) return 'pre: 输入框没出现' + await page.keyboard.type('V5') + await page.keyboard.press('Enter') + await page.waitForTimeout(260) + const d = await dbg() + const last = d.texts[d.texts.length - 1] + const ok = d.tool === 'select' && d.texts.length === before + 1 && d.selectedTextId === (last && last.id) + await page.keyboard.press('Escape') // 清掉选中 + await page.keyboard.press('Control+z') // 撤掉这段文字,保持后续用例现场 + await page.waitForTimeout(150) + await page.locator('.iwb-editor-tool[data-tool="select"]').click() + return ok ? true : 'tool=' + d.tool + ' texts=' + d.texts.length + ' selText=' + d.selectedTextId +})()) // 吸管:选中矢量形状后按 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() + // 先换成一个可辨识的颜色,便于判断取色真的改了对象(v1.3:推荐色在弹层里,先点开色点) + await page.locator('.iwb-editor-tools [data-action="toggleColorPop"]').click() + await page.locator('.iwb-editor-color-pop .iwb-editor-color-panel-swatch[data-panel-color="#4488ff"]').click() + await page.locator('.iwb-editor-tools [data-action="toggleColorPop"]').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') // 切吸管 @@ -870,6 +965,58 @@ await page.keyboard.press('Control+z') // 撤销最后一次填充 await page.keyboard.press('Control+z') // 撤销钢笔路径 await page.keyboard.press('Control+z') // 撤销矩形线宽 +// ---- v1.3:矢量/文字工具不再具备选择功能(用户裁定 2026-11-05)---- +// 核心回归:在已有矩形范围内再拉一个矩形,必须新增图形,而不是把旧矩形拖走 +check('矩形工具在已有矩形上按下 → 新建第二个矩形,并自动回 V 选中它(v1.5)', await (async () => { + await page.locator('.iwb-editor-tool[data-tool="rect"]').click() + const before = (await dbg()).shapes.length + await drag2(liveBox.x + liveBox.width * 0.22, liveBox.y + liveBox.height * 0.22, + liveBox.x + liveBox.width * 0.42, liveBox.y + liveBox.height * 0.42) + const after = await dbg() + const last = after.shapes[after.shapes.length - 1] + return after.shapes.length === before + 1 && after.selectedShapeId === last.id && after.tool === 'select' + ? true + : 'shapes ' + before + '→' + after.shapes.length + ' sel=' + after.selectedShapeId + ' tool=' + after.tool +})()) + +check('切到 矩形/文字/钢笔 都会清掉选中态(选中只属于 V 与临时吸管)', await (async () => { + await page.locator('.iwb-editor-tool[data-tool="select"]').click() + await page.mouse.click(liveBox.x + liveBox.width * 0.3, liveBox.y + liveBox.height * 0.3) + await page.waitForTimeout(120) + if (!(await dbg()).selectedShapeId) return 'pre: V 没选中形状' + const cleared = [] + for (const t of ['rect', 'text', 'pen']) { + await page.locator(`.iwb-editor-tool[data-tool="${t}"]`).click() + const d = await dbg() + cleared.push(!d.selectedShapeId && !d.selectedTextId) + } + return cleared.every(Boolean) ? true : 'cleared=' + cleared.join(',') +})()) + +// 拖调色器改颜色只记一步历史(以前每移动一步就 saveSnapshot,4K 图直接吃掉几百 MB) +check('拖调色器改选中形状颜色:历史只增加 1 条', await (async () => { + await page.keyboard.press('Escape') + await page.locator('.iwb-editor-tool[data-tool="select"]').click() + await page.mouse.click(liveBox.x + liveBox.width * 0.3, liveBox.y + liveBox.height * 0.3) + await page.waitForTimeout(120) + if (!(await dbg()).selectedShapeId) return 'pre: 没选中形状' + const h0 = (await dbg()).history + await page.locator('.iwb-editor-tools [data-action="toggleColorPop"]').click() + const sv = await page.locator('.iwb-color-sv').boundingBox() + await page.mouse.move(sv.x + sv.width * 0.2, sv.y + sv.height * 0.2) + await page.mouse.down() + await page.mouse.move(sv.x + sv.width * 0.9, sv.y + sv.height * 0.85, { steps: 20 }) + await page.mouse.up() + await page.waitForTimeout(150) + const h1 = (await dbg()).history + await page.locator('.iwb-editor-tools [data-action="toggleColorPop"]').click() // 收起 + return h1 - h0 === 1 ? true : 'history ' + h0 + '→' + h1 +})()) + +await page.keyboard.press('Escape') // 退出钢笔的半成品状态 +await page.keyboard.press('Control+z') // 撤销拖动取色的那一步 +await page.keyboard.press('Control+z') // 撤销上一步新建的矩形,恢复现场 + // ---- v1.2.9:会话组(新建/覆盖/退出)移到顶栏最左 + 图层 PS 快捷键 ---- check('顶栏:标题最前 → 新建/覆盖/退出(统一中性色)→ 竖分隔 → 撤销组,右侧只剩 输出+导出', await page.evaluate(() => { @@ -982,6 +1129,169 @@ check('Delete 删除选中的位图图层(PS 习惯)', await (async () => { return d.selectedLayerId === null ? true : 'sel 未清空: ' + d.selectedLayerId })()) +// ---- v1.6:笔刷环即时反馈(按 ] / [ 不必再动鼠标) ---- +check('笔刷环:按 ] 后鼠标不动,环立刻变大', await (async () => { + await page.locator('.iwb-editor-tool[data-tool="brush"]').click() + await page.mouse.move(liveBox.x + liveBox.width * 0.5, liveBox.y + liveBox.height * 0.5) + await page.waitForTimeout(150) + const ringWidth = () => page.evaluate(() => { + const c = document.querySelector('.iwb-editor-cursor-overlay') + const d = c.getContext('2d').getImageData(0, 0, c.width, c.height).data + let minX = 1e9, maxX = -1 + for (let y = 0; y < c.height; y++) { + for (let x = 0; x < c.width; x++) { + if (d[(y * c.width + x) * 4 + 3] > 8) { if (x < minX) minX = x; if (x > maxX) maxX = x } + } + } + return maxX < 0 ? 0 : maxX - minX + 1 + }) + const w0 = await ringWidth() + const s0 = (await dbg()).toolOptions.brushSize + for (let i = 0; i < 3; i++) await page.keyboard.press(']') + await page.waitForTimeout(140) + const w1 = await ringWidth() + const s1 = (await dbg()).toolOptions.brushSize + for (let i = 0; i < 3; i++) await page.keyboard.press('[') + await page.waitForTimeout(120) + return w0 > 0 && s1 > s0 && w1 > w0 ? true : 'w ' + w0 + '→' + w1 + ' size ' + s0 + '→' + s1 +})()) + +// ---- v1.6:图层合并(向下合并 / 多选合并 / 合并可见) ---- +// 两笔分别落在左右半区,合并后同一层里两半都要有像素,才算真合并 +const strokeHalves = async (id, w, h) => page.evaluate(({ id, w, h }) => { + const d = window.__iwbEditor.__debug() + return { + left: d.alphaIn(id, 0, 0, w / 2, h), + right: d.alphaIn(id, w / 2, 0, w, h) + } +}, { id, w, h }) + +check('图层合并:Ctrl+E 向下合并两层(两笔都在),Ctrl+Z 连像素一起回退', await (async () => { + await page.keyboard.press('Escape') + await page.keyboard.press('Control+d') + await page.locator('.iwb-editor-tool[data-tool="brush"]').click() + const doc = (await dbg()).doc + const n0 = (await dbg()).layers.length + await page.keyboard.press('Control+Shift+n') + await page.waitForTimeout(140) + const lowerId = (await dbg()).activeLayerId + await drag2(liveBox.x + liveBox.width * 0.22, liveBox.y + liveBox.height * 0.62, + liveBox.x + liveBox.width * 0.32, liveBox.y + liveBox.height * 0.72) + await page.keyboard.press('Control+Shift+n') + await page.waitForTimeout(140) + const upperId = (await dbg()).activeLayerId + await drag2(liveBox.x + liveBox.width * 0.66, liveBox.y + liveBox.height * 0.62, + liveBox.x + liveBox.width * 0.76, liveBox.y + liveBox.height * 0.72) + const d1 = await dbg() + if (d1.layers.length !== n0 + 2) return 'pre layers ' + d1.layers.length + ' expect ' + (n0 + 2) + await page.keyboard.press('Control+e') + await page.waitForTimeout(320) + const d2 = await dbg() + if (d2.layers.length !== n0 + 1) return 'merge layers ' + d2.layers.length + ' expect ' + (n0 + 1) + const px = await strokeHalves(d2.activeLayerId, doc.w, doc.h) + if (!(px.left > 0 && px.right > 0)) return 'pixels ' + JSON.stringify(px) + await page.keyboard.press('Control+z') + await page.waitForTimeout(320) + const d3 = await dbg() + if (d3.layers.length !== n0 + 2) return 'undo layers ' + d3.layers.length + ' expect ' + (n0 + 2) + // 撤销必须把两笔还给各自原来的层,而不是留一份空层 + const backLower = await strokeHalves(lowerId, doc.w, doc.h) + const backUpper = await strokeHalves(upperId, doc.w, doc.h) + if (!(backLower.left > 0 && backUpper.right > 0)) { + return 'undo pixels lower=' + JSON.stringify(backLower) + ' upper=' + JSON.stringify(backUpper) + } + return true +})()) + +check('图层多选合并:⌘/Ctrl 点击两项后合并按钮合成一层', await (async () => { + const d0 = await dbg() + const n0 = d0.layers.length + const items = page.locator('.iwb-editor-layer-list .iwb-layer-item') + await items.nth(0).click() + await items.nth(1).click({ modifiers: [process.platform === 'darwin' ? 'Meta' : 'Control'] }) + await page.waitForTimeout(220) + const dm = await dbg() + const marked = await page.locator('.iwb-layer-item.multi').count() + if (dm.layerMulti.length !== 2 || marked !== 2) return 'multi ' + JSON.stringify(dm.layerMulti) + ' dom=' + marked + await page.locator('[data-action="mergeLayers"]').click() + await page.waitForTimeout(320) + const d1 = await dbg() + return d1.layers.length === n0 - 1 && d1.layerMulti.length === 0 + ? true + : 'after ' + d1.layers.length + '/' + n0 + ' multi=' + d1.layerMulti.length +})()) + +check('向下合并到「原图」:笔迹写进 base,Ctrl+Z 复原像素', await (async () => { + // 归一到「只剩原图」:先显示所有隐藏层,再合并可见 + let d = await dbg() + for (const l of d.layers) { + if (!l.visible) { + await page.locator('.iwb-layer-vis[data-vis-id="' + l.id + '"]').click() + await page.waitForTimeout(90) + } + } + d = await dbg() + if (d.layers.length > 1) { + await page.keyboard.press('Control+Shift+e') + await page.waitForTimeout(320) + d = await dbg() + } + if (d.layers.length !== 1 || d.layers[0].id !== 'base') return 'normalize: ' + JSON.stringify(d.layers) + + const doc = d.doc + const cx = Math.round(doc.w * 0.5), cy = Math.round(doc.h * 0.5) + const pxAt = () => page.evaluate(([x, y]) => window.__iwbEditor.__debug().pixel('base', x, y), [cx, cy]) + const p0 = await pxAt() + + await page.locator('.iwb-editor-tool[data-tool="brush"]').click() + await page.locator('.iwb-editor-optionbar-body input.iwb-opt-num[data-opt="brushSize"]').fill('40') + await page.keyboard.press('Control+Shift+n') + await page.waitForTimeout(140) + // 斜穿中心的大笔画,避免采样点落空 + await drag2(liveBox.x + liveBox.width * 0.15, liveBox.y + liveBox.height * 0.35, + liveBox.x + liveBox.width * 0.85, liveBox.y + liveBox.height * 0.65) + const d1 = await dbg() + if (d1.layers.length !== 2) return 'pre layers ' + d1.layers.length + await page.keyboard.press('Control+e') + await page.waitForTimeout(340) + const d2 = await dbg() + if (d2.layers.length !== 1 || d2.layers[0].id !== 'base') return 'merge layers ' + JSON.stringify(d2.layers.map(l => l.id)) + const p1 = await pxAt() + if (!p1 || !p0 || (p1[0] === p0[0] && p1[1] === p0[1] && p1[2] === p0[2])) { + return 'base 像素未变 ' + JSON.stringify([p0, p1]) + } + await page.keyboard.press('Control+z') + await page.waitForTimeout(340) + const p2 = await pxAt() + const same = p2 && p0 && p2[0] === p0[0] && p2[1] === p0[1] && p2[2] === p0[2] + return same ? true : 'undo 像素 ' + JSON.stringify([p0, p2]) +})()) + +check('合并可见图层:隐藏层原样保留,可见层合成一层', await (async () => { + // 保证至少 2 个可见层 + let d = await dbg() + while (d.layers.filter(l => l.visible).length < 2) { + await page.keyboard.press('Control+Shift+n') + await page.waitForTimeout(140) + d = await dbg() + } + // 再新建一层并隐藏它,验证它不参与合并、也不会被删 + await page.keyboard.press('Control+Shift+n') + await page.waitForTimeout(160) + const hiddenId = (await dbg()).activeLayerId + await page.locator('.iwb-layer-vis[data-vis-id="' + hiddenId + '"]').click() + await page.waitForTimeout(180) + const visibleBefore = (await dbg()).layers.filter(l => l.visible).length + await page.keyboard.press('Control+Shift+e') + await page.waitForTimeout(360) + const d1 = await dbg() + const stillHidden = d1.layers.some(l => l.id === hiddenId && l.visible === false) + const visibleAfter = d1.layers.filter(l => l.visible).length + return stillHidden && visibleAfter === 1 && visibleBefore >= 2 + ? true + : 'hidden=' + stillHidden + ' visible ' + visibleBefore + '→' + visibleAfter + ' layers=' + d1.layers.length +})()) + check('无选中时 Ctrl+] 有 toast 提示(不再无声失败)', await (async () => { await page.keyboard.press('Escape') // 清掉可能残留的选中态 await page.keyboard.press('Control+]')