From e699c22fa037b78142f5e1743e677fc711131243 Mon Sep 17 00:00:00 2001 From: qiqi Date: Sun, 8 Nov 2026 20:27:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(image-annotate):=20v1.9.0=20=E6=96=87?= =?UTF-8?q?=E5=AD=97=E6=A0=B7=E5=BC=8F=E5=8C=85=E3=80=81=E5=90=B8=E9=99=84?= =?UTF-8?q?=E5=8F=82=E8=80=83=E7=BA=BF=E3=80=81=E5=9C=86=E8=A7=92=E4=B8=8E?= =?UTF-8?q?=E6=9C=80=E8=BF=91=E8=89=B2=E3=80=81=E5=A4=8D=E5=88=B6=E5=88=B0?= =?UTF-8?q?=E5=89=AA=E8=B4=B4=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 文字从「字号 + 颜色」扩到完整样式:字重(常规/粗/特粗)、对齐(左/中/右)、 行距、描边、底色块、多行(textarea + Shift+Enter)。新增叶子模块 text.js, fontOf / textMetrics / textBox / drawTextObject 成为唯一事实来源, objects.js(预览/命中/包围盒)与 layers.js(栅格化)共用,避免量一套画一套; 描边与底色撑大包围盒,手柄、吸附、缩略图随之变化。单行无描边无底色的老文字 包围盒与旧实现逐像素一致,老作业打开不变形。 吸附参考线:snap.js 只做纯计算。目标线为画布 0/中/满 + 其他可见元素的左中右、 上中下;阈值 6 屏幕像素按 viewScale() 折回图片像素,磁力不随缩放变大; 命中画洋红参考线(区别于选中框的橙),松手清空;Alt 全程禁用。 位图/文字/形状三条拖动路径都接,文字需补 b.x - t.x 原点偏移。 矩形圆角:shapeRadius 进 drawShape,半径夹到 min(w,h)/2,路径手写 arcTo (不用 ctx.roundRect,老内核没有)。最近使用颜色最多 8 个,存 ctx.settings 跨会话保留,只有落定的改色才记录;色板改用事件委托以覆盖动态插入的色块。 导出「复制」:结果编成 PNG 写 ClipboardItem,可直接粘进聊天窗口/后台上传框 且不关闭编辑器。优先 createImageBitmap 绕开宿主 CSP 的 img-src 限制; 非安全上下文无 navigator.clipboard 时明确提示改用「导出」而非静默失败。 顺带修:选项栏中文双字标签加 white-space:nowrap(否则 36px 一行内竖排成 「常/规」);.iwb-editor-optionbar-tip 补基础样式(原来只有 display:none, 裸 span 参与 flex 收缩被挤成两行贴边);文字工具的 hint 移到按钮之后, 放不下时让说明滚出视野而不是把操作按钮顶没。 harness 140 → 158 条,全部通过;validate 9/9。 --- image-annotate/README.md | 65 ++ image-annotate/docs/PS_LITE_ROADMAP.md | 3 +- image-annotate/package.json | 2 +- image-annotate/plugin/editor.css | 63 +- image-annotate/plugin/editor/dom.js | 8 +- image-annotate/plugin/editor/events.js | 213 +++++- image-annotate/plugin/editor/export.js | 61 ++ image-annotate/plugin/editor/index.js | 45 +- image-annotate/plugin/editor/layers.js | 37 +- image-annotate/plugin/editor/objects.js | 40 +- image-annotate/plugin/editor/recent-colors.js | 54 ++ image-annotate/plugin/editor/snap.js | 94 +++ image-annotate/plugin/editor/state.js | 12 + image-annotate/plugin/editor/text.js | 155 +++++ image-annotate/plugin/editor/tools.js | 34 +- image-annotate/src/index.js | 656 ++++++++++++++++-- image-annotate/tools/harness.mjs | 235 +++++++ 17 files changed, 1678 insertions(+), 99 deletions(-) create mode 100644 image-annotate/plugin/editor/recent-colors.js create mode 100644 image-annotate/plugin/editor/snap.js create mode 100644 image-annotate/plugin/editor/text.js diff --git a/image-annotate/README.md b/image-annotate/README.md index c4efa30..1e05523 100644 --- a/image-annotate/README.md +++ b/image-annotate/README.md @@ -234,6 +234,71 @@ P 下双击 = 结束当前路径(`commitPenPath`),不再进节点编辑。 - 文字 / 形状 / 钢笔会被直接栅格化进结果层(PS 合并矢量层也是这个结果)。 - 结果层落回「原最低参与层」的位置,`assignLayerZ` 重新连续编号,不产生重复 z。 +## v1.9.0:文字样式包 / 吸附参考线 / 圆角与最近色 / 复制到剪贴板 + +一次补齐四个高频缺口,都属于「没有它就得切回 PS」的那类。 + +### 1. 文字从「字号 + 颜色」扩到完整样式 + +`字号 / 字重(常规·粗·特粗)/ 对齐(左·中·右)/ 行距 / 描边 / 底色块 / 多行`。 + +关键是把「量出来的框」和「画出来的字」合成一处:新增叶子模块 `text.js`, +`fontOf / textMetrics / textBox / drawTextObject` 是唯一事实来源, +`objects.js`(预览、命中、包围盒)与 `layers.js`(栅格化进矢量层)都调它。 +此前量 `measureText` 一套、画 `fillText` 一套,一旦加描边和底色必然错位。 + +- 描边与底色会**撑大包围盒**(`textBox()` 计入 `strokeWidth/2` 与 padding), + 选择框、吸附、缩放手柄随之变化,不会出现「字比框大」。 +- 输入框从 `` 换成 `
#ffffff
@@ -239,6 +241,8 @@ import { bindEvents } from './events.js'
+ +
diff --git a/image-annotate/plugin/editor/events.js b/image-annotate/plugin/editor/events.js index fcd1f2d..6f1f152 100644 --- a/image-annotate/plugin/editor/events.js +++ b/image-annotate/plugin/editor/events.js @@ -15,9 +15,10 @@ import { beginMarquee, updateMarquee, endMarquee, beginLasso, updateLasso, endLa import { runCommand, toast } from './commands.js' import { showSelectionContext, hideSelectionContext } from './floating.js' import { applyConstraintDrag, cancelCrop, clearOverlay, confirmCrop, drawCropPreview, hideCropBar, hitCropHandle, insideRect, resizeCropRect, setConstraint, showCropBar, updateCropInfo } from './crop.js' -import { applyShapeHandle, beginPenEdit, beginShapeHandleDrag, beginTextRotate, beginTextScaleDrag, commitTextInput, deleteSelectedShape, deleteSelectedText, exitPenEdit, getPenEditingShape, getSelectedShape, getSelectedText, hideTextInput, hitAnyObject, hitPenEdgeInsert, hitPenPoint, hitShapeHandle, hitShapeLayer, hitTextHandle, hitTextLayer, hitTopmost, moveLayer, renderObjects, selectNeighborLayer, selectUnit, shapeBounds, showTextInput } from './objects.js' +import { applyShapeHandle, beginPenEdit, beginShapeHandleDrag, beginTextRotate, beginTextScaleDrag, commitTextInput, deleteSelectedShape, deleteSelectedText, exitPenEdit, getPenEditingShape, getSelectedShape, getSelectedText, hideTextInput, hitAnyObject, hitPenEdgeInsert, hitPenPoint, hitShapeHandle, hitShapeLayer, hitTextHandle, hitTextLayer, hitTopmost, moveLayer, otherObjectBoxes, renderObjects, selectNeighborLayer, selectUnit, shapeBounds, showTextInput, textBounds } from './objects.js' +import { snapMove } from './snap.js' import { cancelImagePlacement, confirmImagePlacement, drawPlacementPreview, hitPlacementHandle, insidePlacementRect, resizePlacement } from './placement.js' -import { close, exportResult } from './index.js' +import { close, copyResult, exportResult } from './index.js' import { loadImage } from './dom.js' import { pushHistory, redo, resetDraw, restoreOriginal, restoreAll, saveSnapshot, snapshotState, undo } from './history.js' import { applyQuickEffect, setEffectValue } from './effects.js' @@ -344,6 +345,8 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' } function onMouseMove(e) { + // 记下修饰键:拖动按 Alt 时临时关掉吸附(想停在「差一点点」的位置时用) + S._altDown = !!e.altKey // 图片放置拖拽 if (S.placingImage && S.placingHandle && S.placingStart) { onPlacementDragMove(e); return @@ -416,8 +419,24 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' if (S.textDrag.mode === 'move') { const dx = pos0.x - S.textDrag.start.x const dy = pos0.y - S.textDrag.start.y - t.x = clamp(S.textDrag.layer.x + dx, 0, Math.max(0, S.imgW - 4)) - t.y = clamp(S.textDrag.layer.y + dy, 0, Math.max(0, S.imgH - 4)) + let nx = clamp(S.textDrag.layer.x + dx, 0, Math.max(0, S.imgW - 4)) + let ny = clamp(S.textDrag.layer.y + dy, 0, Math.max(0, S.imgH - 4)) + // 吸附:按住 Alt 临时关掉(要对齐到「差一点点」的位置时用) + if (!S._altDown) { + const b = textBounds(t) + // b 是「含描边/底色的包围盒」,t.x/t.y 是文字原点:两者差一个固定偏移, + // 用原点当包围盒左上会把吸附中心算偏 strokeWidth/2,边线永远差几像素吸不上 + const offX = b.x - t.x + const offY = b.y - t.y + const s = snapMove({ x: nx + offX, y: ny + offY, w: b.w, h: b.h }, otherObjectBoxes(t)) + nx += s.dx + ny += s.dy + S.guides = s.guides.length ? s.guides : null + } else { + S.guides = null + } + t.x = nx + t.y = ny } else if (S.textDrag.mode === 'rotate') { const st = S.textDrag const a1 = Math.atan2(pos0.y - st.cy, pos0.x - st.cx) @@ -457,8 +476,17 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' const dx = pos0.x - S.shapeDrag.start.x const dy = pos0.y - S.shapeDrag.start.y const b = shapeBounds(S.shapeDrag.shape) - const cdx = clamp(dx, -b.x, Math.max(-b.x, S.imgW - (b.x + b.w))) - const cdy = clamp(dy, -b.y, Math.max(-b.y, S.imgH - (b.y + b.h))) + let cdx = clamp(dx, -b.x, Math.max(-b.x, S.imgW - (b.x + b.w))) + let cdy = clamp(dy, -b.y, Math.max(-b.y, S.imgH - (b.y + b.h))) + if (!S._altDown) { + const box = { x: b.x + cdx, y: b.y + cdy, w: b.w, h: b.h } + const s = snapMove(box, otherObjectBoxes(sh)) + cdx += s.dx + cdy += s.dy + S.guides = s.guides.length ? s.guides : null + } else { + S.guides = null + } if (sh.type === 'pen') { sh.pts = (S.shapeDrag.shape.pts || []).map(p => ({ x: p.x + cdx, y: p.y + cdy })) } else { @@ -510,6 +538,7 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' lw: Math.max(1, S.shapeLineWidth), lineWidth: Math.max(1, S.shapeLineWidth), fill: S.tool === 'rect' || S.tool === 'circle' ? !!S.rectFill : false, + radius: S.tool === 'rect' ? Math.max(0, S.shapeRadius) : 0, opacity: 1, visible: true } @@ -622,6 +651,8 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' } } S.textDrag = null + S.guides = null // 松手即撤掉吸附参考线(重绘 overlay 才能真的擦掉) + renderObjects() renderLayerPanel() return } @@ -639,6 +670,7 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' } } S.bitmapDrag = null + S.guides = null renderObjects() renderLayerPanel() return @@ -656,6 +688,8 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' } } S.shapeDrag = null + S.guides = null + renderObjects() renderLayerPanel() return } @@ -708,6 +742,7 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' color: S.color, lw: Math.max(1, S.shapeLineWidth), fill: S.tool === 'rect' || S.tool === 'circle' ? !!S.rectFill : false, + radius: S.tool === 'rect' ? Math.max(0, S.shapeRadius) : 0, opacity: 1, visible: true, locked: false, @@ -946,6 +981,51 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' const SHAPE_NAMES = { rect: '矩形', circle: '圆形', arrow: '箭头', pen: '钢笔路径' } + // ---- 文字样式(v1.9):字重 / 对齐 / 行距 / 描边 / 底色 ---- + // 控件既作用于「当前选中的文字」,也写回「新建文字的默认值」: + // 没选中时光调参数就是调下一次输入的样子,选中后调则立刻改这一段。 + const TEXT_STYLE_STATE_KEY = { + fontWeight: 'textWeight', align: 'textAlign', lineHeight: 'textLineHeight', + strokeWidth: 'textStrokeWidth', strokeColor: 'textStrokeColor', + bgFill: 'textBgFill', bgColor: 'textBgColor' + } + + /** 读样式:t 有值读对象自己的(老对象缺字段时回退到默认),否则读新建默认值 */ + function textStyleValues(t) { + const pick = (objKey, stateKey, dflt) => { + const raw = t ? t[objKey] : S[stateKey] + return raw == null ? dflt : raw + } + return { + fontWeight: String(pick('fontWeight', 'textWeight', 'bold')), + align: pick('align', 'textAlign', 'left'), + lineHeight: Number(pick('lineHeight', 'textLineHeight', 1.25)) || 1.25, + strokeWidth: Math.max(0, Number(pick('strokeWidth', 'textStrokeWidth', 0)) || 0), + strokeColor: pick('strokeColor', 'textStrokeColor', '#ffffff'), + bgFill: !!pick('bgFill', 'textBgFill', false), + bgColor: pick('bgColor', 'textBgColor', '#000000') + } + } + + function textStyleHTML(t) { + const v = textStyleValues(t) + const wBtn = (val, label, title) => + `` + const aBtn = (val, label, title) => + `` + return ` + 字重${wBtn('normal', '常规', '常规字重')}${wBtn('bold', '粗', '粗体(默认)')}${wBtn('900', '特粗', '特粗,封面标题用')} + 对齐${aBtn('left', '左', '多行时按左缘对齐')}${aBtn('center', '中', '多行时居中')}${aBtn('right', '右', '多行时按右缘对齐')} + 行距 + % + + 描边 + px + + + ` + } + /** 选择工具:只有选中了元素才出该元素的参数。 * 用户裁定 2026-11-04:选中矩形/钢笔后要能就地切描边/实心、改描边粗细, * 不必再切回绘制工具 —— 所以这里复用绘制工具同一套控件与写回路径。 */ @@ -972,6 +1052,8 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' return `已选中:${SHAPE_NAMES[t] || t}` + rangeOpt('shapeLineWidth', '线宽', 1, 60, lw, '') + presetDots('shapeLineWidth', [1, 2, 3, 6, 10, 16, 24]) + // 圆角只对矩形有意义(圆形本来就是圆的,箭头/钢笔没有这个概念) + + (t === 'rect' ? rangeOpt('shapeRadius', '圆角', 0, 200, Math.round(sh.radius || 0), 'px') : '') + (t === 'arrow' ? '' : fillStyleHTML(owner)) + (t === 'pen' && !sh.closed ? '这条钢笔路径未闭合,实心不生效;点回起点闭合后即可填充' @@ -983,8 +1065,11 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' if (text) { return `已选中:文字` + rangeOpt('textSize', '字号', 8, 400, Math.round(text.fontSize || S.textSize), 'px') - + '双击文字改内容,拖动移动,手柄缩放' + + textStyleHTML(text) + // 控件齐全时这一行很挤,说明文字必须排在按钮之后: + // 真放不下时宁可把 hint 滚出视野,也不能把「复制/取消选区」这些按钮顶没了 + selCmdHTML() + + '双击改内容 · 拖动手柄缩放' } return `当前工具:选择 / 移动 点中矩形/圆形/钢笔/文字后,这里会出现它的描边、实心与粗细` @@ -1009,6 +1094,7 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' if (tool === 'rect' || tool === 'circle') { return rangeOpt('shapeLineWidth', '线宽', 1, 60, S.shapeLineWidth, '') + presetDots('shapeLineWidth', [1, 2, 3, 6, 10, 16, 24]) + + (tool === 'rect' ? rangeOpt('shapeRadius', '圆角', 0, 200, S.shapeRadius, 'px') : '') + fillStyleHTML('rect') } if (tool === 'arrow') { @@ -1024,7 +1110,8 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' } if (tool === 'text') { return rangeOpt('textSize', '字号', 8, 400, S.textSize, 'px') - + '点画布输入文字,Enter 确认' + + textStyleHTML(null) + + '点画布输入文字,Enter 确认,Shift+Enter 换行' } if (tool === 'marquee') { return `形状 @@ -1068,7 +1155,10 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' if (key === 'brushHardness') return S.brushHardness if (key === 'brushOpacity') return Math.round(S.brushOpacity * 100) if (key === 'shapeLineWidth') return selShape ? Math.max(1, Math.round(selShape.lw || S.shapeLineWidth)) : S.shapeLineWidth + if (key === 'shapeRadius') return selShape && selShape.type === 'rect' ? Math.round(selShape.radius || 0) : S.shapeRadius if (key === 'textSize') return selText ? Math.round(selText.fontSize || S.textSize) : S.textSize + if (key === 'textLineHeight') return Math.round((selText ? (Number(selText.lineHeight) || S.textLineHeight) : S.textLineHeight) * 100) + if (key === 'textStrokeWidth') return Math.round(selText ? (Number(selText.strokeWidth) || 0) : S.textStrokeWidth) if (key === 'feather') return S.selectionFeather return '' } @@ -1093,6 +1183,18 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' } btn.classList.toggle('active', !!cur === (btn.dataset.value === 'fill')) }) + // 文字样式按钮组与两个颜色框:选中对象的值优先,没选中就显示新建默认值 + const sv = textStyleValues(selText) + body.querySelectorAll('[data-opt-text]').forEach(btn => { + const k = btn.dataset.optText + const cur = k === 'bgFill' ? (sv.bgFill ? '1' : '0') : String(sv[k]) + btn.classList.toggle('active', cur === btn.dataset.value) + }) + body.querySelectorAll('[data-opt-color]').forEach(inp => { + if (document.activeElement === inp) return + const v = sv[inp.dataset.optColor] + if (v && String(inp.value).toLowerCase() !== String(v).toLowerCase()) inp.value = v + }) } /** 状态栏:缩放 / 尺寸 / 光标 / 选区 / 当前层 / 工具 */ @@ -1140,6 +1242,45 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' if (committed) textSnapDone = false } + let textStyleSnapDone = false + + /** + * 应用一条文字样式。 + * 两件事一起做:写回「新建默认值」S.*,以及改当前选中的那段文字。 + * 拖动滑杆/连续点按钮时只在第一次拍快照(一次调整 = 一次撤销)。 + */ + function applyTextStyle(key, raw, committed) { + const stateKey = TEXT_STYLE_STATE_KEY[key] + if (!stateKey) return + let value = raw + // data-value 是字符串:'0' 也是真值,必须显式判,不能直接 !!raw + if (key === 'bgFill') value = raw === true || raw === 1 || raw === '1' || raw === 'true' + else if (key === 'lineHeight') value = clamp(Number(raw) || 125, 80, 300) / 100 + else if (key === 'strokeWidth') value = clamp(Number(raw) || 0, 0, 40) + else if (key === 'strokeColor' || key === 'bgColor') value = String(raw || '#000000').toLowerCase() + else value = String(raw) + + S[stateKey] = value + const t = getSelectedText() + if (!t || t.locked) { textStyleSnapDone = false; return } + if (committed || !textStyleSnapDone) { saveSnapshot('文字样式'); textStyleSnapDone = true } + t[key] = value + renderObjects() + if (committed) textStyleSnapDone = false + } + + let radiusSnapDone = false + + /** 圆角只对矩形有意义:改默认值 + 改选中的那个矩形 */ + function applyShapeRadius(committed) { + const sh = getSelectedShape() + if (!sh || sh.locked || sh.type !== 'rect') { radiusSnapDone = false; return } + if (committed || !radiusSnapDone) { saveSnapshot('圆角'); radiusSnapDone = true } + sh.radius = S.shapeRadius + renderObjects() + if (committed) radiusSnapDone = false + } + /** 形状描边/实心:既改下次新建的默认值,也改当前选中的那个。 * owner='rect' 作用于矩形/圆,owner='pen' 作用于钢笔闭合路径。 */ function setShapeFill(fill, owner) { @@ -1183,6 +1324,13 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' } else if (key === 'textSize') { S.textSize = clamp(safe || 32, 8, 400) applyTextSize(committed) + } else if (key === 'textLineHeight') { + applyTextStyle('lineHeight', safe || 125, committed) + } else if (key === 'textStrokeWidth') { + applyTextStyle('strokeWidth', safe, committed) + } else if (key === 'shapeRadius') { + S.shapeRadius = clamp(safe, 0, 400) + applyShapeRadius(committed) } else if (key === 'feather') { S.selectionFeather = clamp(safe, 0, 20) if (S.selection && S.selection.active) S.selection.feather = S.selectionFeather @@ -1268,8 +1416,28 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' // 滑杆拖动中(input)与松手/失焦(change)走同一条写回路径, // committed 只决定「要不要顺手记一步历史」,不影响参数生效。 body.addEventListener('input', (e) => setOptionFromControl(e.target, false)) - body.addEventListener('change', (e) => setOptionFromControl(e.target, true)) + body.addEventListener('change', (e) => { + // 原生颜色框:拖动时只派发 input、关闭取色器才派发 change。 + // 只认 change,保证「改一次颜色 = 一步撤销」,不在拖动途中连拍快照。 + const colorEl = e.target.closest ? e.target.closest('[data-opt-color]') : null + if (colorEl) { + e.stopPropagation() + applyTextStyle(colorEl.dataset.optColor, colorEl.value, true) + syncOptionBar() + return + } + setOptionFromControl(e.target, true) + }) body.addEventListener('click', (e) => { + // 文字样式按钮(字重 / 对齐 / 底色开关) + const textBtn = e.target.closest('[data-opt-text]') + if (textBtn) { + e.stopPropagation() + const k = textBtn.dataset.optText + applyTextStyle(k, textBtn.dataset.value, true) + syncOptionBar() + return + } const shapeBtn = e.target.closest('[data-opt="shape"]') if (shapeBtn) { e.stopPropagation() @@ -1467,7 +1635,16 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' } 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) })) + // 色块统一走委托:静态 12 色 + 动态插入的「最近使用」都要能点, + // 一次性 querySelectorAll 绑定会漏掉后来插进来的按钮 + if (pop) { + pop.addEventListener('click', (e) => { + const btn = e.target.closest('[data-panel-color]') + if (!btn) return + e.stopPropagation() + setPanelColor(btn.dataset.panelColor) + }) + } const palettePick = runtime.el.querySelector('[data-action="palettePick"]') if (palettePick) { palettePick.addEventListener('mousedown', (e) => e.stopPropagation()) @@ -1658,6 +1835,7 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' // 底部 bindIf('[data-action="cancel"]', 'click', close) bindIf('[data-action="download"]', 'click', () => exportResult('download')) + bindIf('[data-action="copyClipboard"]', 'click', () => copyResult()) bindIf('[data-action="newNode"]', 'click', () => exportResult('newNode')) bindIf('[data-action="replace"]', 'click', () => exportResult('replace')) } @@ -1670,14 +1848,21 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js' S.canvasWrap.addEventListener('wheel', onWheel, { passive: false }) } - /** 文字输入框:Enter 提交、Esc 取消 */ + /** 文字输入框:Enter 提交、Shift+Enter 换行、Esc 取消(v1.9 换成 textarea 支持多行) */ function bindTextInput() { // 文字输入 const textInput = runtime.el.querySelector('.iwb-editor-text-input') - textInput && textInput.addEventListener('mousedown', (e) => e.stopPropagation()) - textInput && textInput.addEventListener('keydown', (e) => { + if (!textInput) return + textInput.addEventListener('mousedown', (e) => e.stopPropagation()) + // 边打边按内容撑高:textarea 不自动长高,多行标题会被压在两行里看不清 + const autosize = () => { + textInput.style.height = 'auto' + textInput.style.height = (textInput.scrollHeight + 4) + 'px' + } + textInput.addEventListener('input', autosize) + textInput.addEventListener('keydown', (e) => { e.stopPropagation() - if (e.key === 'Enter') { e.preventDefault(); commitTextInput() } + if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); commitTextInput() } else if (e.key === 'Escape') { e.preventDefault(); hideTextInput() } }) } diff --git a/image-annotate/plugin/editor/export.js b/image-annotate/plugin/editor/export.js index 8c0360a..8eeacb8 100644 --- a/image-annotate/plugin/editor/export.js +++ b/image-annotate/plugin/editor/export.js @@ -294,3 +294,64 @@ import { toast } from './commands.js' setTimeout(() => { try { URL.revokeObjectURL(url) } catch (e) { /* ignore */ } }, 2000) toast('已下载 ' + name + '(' + Math.round(blob.size / 1024) + 'KB)', 'success') } + + /** 任意图片 blob → PNG blob(剪贴板对 image/png 支持最稳,体积在剪贴板里无所谓) */ + async function toPngBlob(blob) { + // 优先 createImageBitmap:不经过 URL,绕开宿主 CSP 对 img-src 的限制 + try { + if (typeof createImageBitmap === 'function') { + const bmp = await createImageBitmap(blob) + const c = document.createElement('canvas') + c.width = bmp.width + c.height = bmp.height + c.getContext('2d').drawImage(bmp, 0, 0) + if (typeof bmp.close === 'function') bmp.close() + const out = await new Promise(res => c.toBlob(b => res(b), 'image/png')) + c.width = 0 + c.height = 0 + if (out) return out + } + } catch (e) { /* 走 img 回退 */ } + return await new Promise((resolve) => { + const url = URL.createObjectURL(blob) + const img = new Image() + img.onload = () => { + const c = document.createElement('canvas') + c.width = img.naturalWidth + c.height = img.naturalHeight + c.getContext('2d').drawImage(img, 0, 0) + try { URL.revokeObjectURL(url) } catch (e) { /* ignore */ } + c.toBlob(b => resolve(b || blob), 'image/png') + } + img.onerror = () => { + try { URL.revokeObjectURL(url) } catch (e) { /* ignore */ } + resolve(blob) + } + img.src = url + }) + } + + /** + * 复制到系统剪贴板:运营场景最常用的一条路 —— 复制后直接粘进聊天窗口/小红书后台, + * 省掉「下载 → 再上传」。必须在用户手势里调用(浏览器要求),失败给可操作提示。 + */ + export async function copyBlobToClipboard(blob) { + const nav = typeof navigator !== 'undefined' ? navigator : null + const CI = typeof window !== 'undefined' ? window.ClipboardItem : null + if (!nav || !nav.clipboard || typeof nav.clipboard.write !== 'function' || typeof CI !== 'function') { + toast('当前浏览器不支持复制图片,请用「导出」下载', 'warn') + return false + } + let png = blob + if (blob.type !== 'image/png') { + try { png = await toPngBlob(blob) } catch (e) { png = blob } + } + try { + await nav.clipboard.write([new CI({ 'image/png': png })]) + toast('已复制到剪贴板(' + Math.round(png.size / 1024) + 'KB),可直接粘贴', 'success') + return true + } catch (e) { + toast('复制失败:' + ((e && e.message) || '浏览器拒绝了剪贴板写入') + ';可用「导出」下载', 'error') + return false + } + } diff --git a/image-annotate/plugin/editor/index.js b/image-annotate/plugin/editor/index.js index 1a57040..0c8750f 100644 --- a/image-annotate/plugin/editor/index.js +++ b/image-annotate/plugin/editor/index.js @@ -30,14 +30,15 @@ import { HISTORY_MAX_BYTES, HISTORY_MAX_ENTRIES, historyBudgetBytes, snapshotSta import { cancelImagePlacement } from './placement.js' import { clearSelection, purgeVectorCanvases, renderLayerPanel } from './layers.js' import { createEl, loadImage } from './dom.js' -import { renderObjects, hideTextInput } from './objects.js' +import { renderObjects, hideTextInput, textBounds } from './objects.js' import { setupCanvas } from './viewport.js' import { resetOverlayTransform } from './scale.js' import { updateAllUI, bindLiteUI, renderOptionBar, updateStatusbar } from './events.js' import { disposeSelection, renderSelection, selectionInfo, syncAnts, registerSelectionCommands } from './selection.js' import { bindFloating, positionFloating, hideSelectionContext } from './floating.js' import { renderFxPanel } from './effects.js' -import { loadExportOptions, prepareOutput, downloadBlob, bindExportUI, renderExportUI } from './export.js' +import { loadExportOptions, prepareOutput, downloadBlob, copyBlobToClipboard, bindExportUI, renderExportUI } from './export.js' +import { loadRecentColors } from './recent-colors.js' import { toast } from './commands.js' // ============ 打开编辑器 ============ @@ -63,6 +64,7 @@ import { toast } from './commands.js' updateAllUI() registerSelectionCommands() loadExportOptions() + loadRecentColors() bindLiteUI() bindFloating() bindExportUI() @@ -274,6 +276,19 @@ import { toast } from './commands.js' } } + /** 复制当前结果为图片到系统剪贴板:不关编辑器、不写宿主节点 */ + export async function copyResult() { + if (S.placingImage) cancelImagePlacement() + try { + const { blob } = await prepareOutput() + await copyBlobToClipboard(blob) + if (S.renderAll) S.renderAll() // 摘要里的「上次输出 …KB」要跟上 + } catch (e) { + console.error('[IWB编辑器] 复制失败:', e) + toast('复制失败:' + ((e && e.message) || '图片可能跨域'), 'error') + } + } + // ============ 暴露接口 ============ /** * 快照/历史开销观测口(性能回归与手测用): @@ -308,9 +323,29 @@ import { toast } from './commands.js' opacity: l.opacity == null ? 1 : l.opacity, cssOpacity: l.canvas ? parseFloat(l.canvas.style.opacity || '1') : null })), - shapes: S.shapeLayers.map(s => ({ id: s.id, type: s.type, lw: s.lw, fill: !!s.fill, closed: !!s.closed, z: s.z, color: s.color })), - texts: S.textLayers.map(t => ({ id: t.id, text: t.text })), - selectedShapeId: S.selectedShapeId, + shapes: S.shapeLayers.map(s => ({ id: s.id, type: s.type, lw: s.lw, fill: !!s.fill, closed: !!s.closed, z: s.z, color: s.color, radius: s.radius || 0, x1: Math.round(s.x1 || 0), y1: Math.round(s.y1 || 0), x2: Math.round(s.x2 || 0), y2: Math.round(s.y2 || 0) })), + texts: S.textLayers.map(t => ({ + id: t.id, text: t.text, x: t.x, y: t.y, fontSize: t.fontSize, color: t.color, + fontWeight: t.fontWeight, align: t.align, lineHeight: t.lineHeight, + strokeWidth: t.strokeWidth, strokeColor: t.strokeColor, bgFill: !!t.bgFill, bgColor: t.bgColor, + // 包围盒:吸附/多行/底色/描边的断言都靠它,和绘制共用同一套度量 + box: (() => { const b = textBounds(t); return { x: Math.round(b.x), y: Math.round(b.y), w: Math.round(b.w), h: Math.round(b.h) } })() + })), + // 吸附参考线(拖动中才有)与最近使用颜色:交互回归用 + guides: S.guides ? S.guides.map(g => ({ axis: g.axis, at: Math.round(g.at * 10) / 10 })) : [], + recentColors: (S.recentColors || []).slice(), + textDefaults: { + weight: S.textWeight, align: S.textAlign, lineHeight: S.textLineHeight, + strokeWidth: S.textStrokeWidth, strokeColor: S.textStrokeColor, + bgFill: S.textBgFill, bgColor: S.textBgColor + }, selectedShapeId: S.selectedShapeId, + // 光标所在的图片坐标(状态栏同源):换算问题的第一现场证据 + lastPos: S.lastPos ? { x: Math.round(S.lastPos.x), y: Math.round(S.lastPos.y) } : null, + // 当前正在进行的拖拽类型:move 才是拖动本体,handle/rotate 说明点到了控制点 + drag: S.shapeDrag ? ('shape:' + S.shapeDrag.mode + (S.shapeDrag.handle ? ':' + S.shapeDrag.handle : '')) + : S.textDrag ? ('text:' + S.textDrag.mode) + : S.bitmapDrag ? ('bitmap:' + S.bitmapDrag.mode + (S.bitmapDrag.handle ? ':' + S.bitmapDrag.handle : '')) + : null, selectedTextId: S.selectedTextId, penEditId: S.penEditId, activeLayerId: S.activeLayerId, diff --git a/image-annotate/plugin/editor/layers.js b/image-annotate/plugin/editor/layers.js index af79ed1..8395e7c 100644 --- a/image-annotate/plugin/editor/layers.js +++ b/image-annotate/plugin/editor/layers.js @@ -8,7 +8,9 @@ 'use strict' import { S, runtime } from './state.js' -import { TEXT_FONT, allObjects, assignLayerZ, deleteSelectedShape, deleteSelectedText, layerUnits, layerUnitsDesc, renderObjects, selectUnit, sortLayersByZ, textBounds } from './objects.js' +import { allObjects, assignLayerZ, deleteSelectedShape, deleteSelectedText, layerUnits, layerUnitsDesc, otherObjectBoxes, renderObjects, selectUnit, sortLayersByZ } from './objects.js' +import { drawTextObject } from './text.js' +import { snapMove } from './snap.js' import { boxCorners, clamp, drawRotationHandles, hitRotationHandle, rotPt, unrotPt } from './viewport.js' import { viewScale } from './scale.js' import { drawShape } from './tools.js' @@ -276,8 +278,19 @@ import { isDrawableLayer } from '../vendor/layer-logic.js' if (!drag || !layer) return const base = drag.layer if (drag.mode === 'move') { - layer.x = base.x + pos.x - drag.start.x - layer.y = base.y + pos.y - drag.start.y + let nx = base.x + pos.x - drag.start.x + let ny = base.y + pos.y - drag.start.y + // 吸附到画布中线/边界与其它元素(按住 Alt 临时关掉) + if (!S._altDown && base.w > 0 && base.h > 0) { + const s = snapMove({ x: nx, y: ny, w: base.w, h: base.h }, otherObjectBoxes(layer)) + nx += s.dx + ny += s.dy + S.guides = s.guides.length ? s.guides : null + } else { + S.guides = null + } + layer.x = nx + layer.y = ny if (isDrawableLayer(layer)) layer._bounds = undefined } else if (drag.mode === 'rotate') { const rcx = base.x + base.w / 2, rcy = base.y + base.h / 2 @@ -454,21 +467,9 @@ export function setActiveLayer(id) { if (kind === 'shape') { drawShape(ctx, obj) } else { - ctx.save() - ctx.textBaseline = 'top' - ctx.globalAlpha = obj.opacity != null ? obj.opacity : 1 - const rot = obj.rotation || 0 - if (rot) { - const b = textBounds(obj) - const cx = b.x + b.w / 2, cy = b.y + b.h / 2 - ctx.translate(cx, cy) - ctx.rotate(rot * Math.PI / 180) - ctx.translate(-cx, -cy) - } - ctx.font = TEXT_FONT(obj.fontSize) - ctx.fillStyle = obj.color - ctx.fillText(obj.text, obj.x, obj.y) - ctx.restore() + // 文字绘制统一走 text.js:预览、落层、缩略图必须是同一套度量与画法, + // 否则「量出来的选中框」和「画出来的字」会各说各话(多行/描边/底色尤其明显) + drawTextObject(ctx, obj) } } diff --git a/image-annotate/plugin/editor/objects.js b/image-annotate/plugin/editor/objects.js index ea0e3ed..516a435 100644 --- a/image-annotate/plugin/editor/objects.js +++ b/image-annotate/plugin/editor/objects.js @@ -16,19 +16,19 @@ import { drawShape, setTool } from './tools.js' import { saveSnapshot, snapshotState } from './history.js' import { toast } from './commands.js' import { renderOptionBar, updateLayerUI } from './events.js' +import { fontOf, newTextStyle, textBox } from './text.js' +import { drawGuides } from './snap.js' import { isDrawableLayer } from '../vendor/layer-logic.js' // ============ 文字图层 ============ - export const TEXT_FONT = (size) => 'bold ' + size + 'px sans-serif' + /** 兼容旧调用点:TEXT_FONT(size) 返回粗体字体串;带样式的字体请用 text.js 的 fontOf(obj) */ + export const TEXT_FONT = (size) => fontOf({ fontSize: size, fontWeight: 'bold' }) + /** 文字包围盒:含多行、底色 padding 与描边外扩(单行时与旧实现完全一致) */ export function textBounds(t) { - const ctx = S.textCtx - ctx.font = TEXT_FONT(t.fontSize) - const w = ctx.measureText(t.text).width - const h = t.fontSize * 1.25 - return { x: t.x, y: t.y, w, h } + return textBox(t) } export function getSelectedText() { @@ -204,6 +204,23 @@ import { isDrawableLayer } from '../vendor/layer-logic.js' return null } + /** 其它可见元素的包围盒(拖动吸附用):排除自己与原图底图(底图边界=画布边界,重复) */ + export function otherObjectBoxes(exclude) { + const out = [] + for (const unit of layerUnits()) { + const o = unit.obj + if (!o || o === exclude || o.id === 'base' || o.visible === false) continue + if (unit.kind === 'bitmap') { + if (isFinite(o.x) && isFinite(o.y) && o.w > 0 && o.h > 0) out.push({ x: o.x, y: o.y, w: o.w, h: o.h }) + } else if (unit.kind === 'text') { + out.push(textBox(o)) + } else { + out.push(shapeBounds(o)) + } + } + return out + } + export function hitAnyObject(pos) { for (const unit of layerUnitsDesc()) { if (unit.kind === 'bitmap') continue @@ -439,6 +456,8 @@ import { isDrawableLayer } from '../vendor/layer-logic.js' for (const { kind, obj } of allObjects()) drawVectorToCanvas(kind, obj) reorderLayerCanvas() clearOverlay() + // 吸附参考线:拖动中才有值,松手清空。画在 overlay 层,不参与合成与导出 + drawGuides(S.overlayCtx, S.guides) if (tempShape) drawShape(S.overlayCtx, tempShape) if (S.tool === 'pen' && S.penPath && S.penPath.pts.length) drawPenPathPreview() // 图片放置模式优先显示放置预览 @@ -588,6 +607,9 @@ import { isDrawableLayer } from '../vendor/layer-logic.js' input.select() input.dataset.x = x input.dataset.y = y + // textarea 不会自己长高:先按内容撑开,否则多行文本会挤在一行里 + input.style.height = 'auto' + input.style.height = Math.max(30, input.scrollHeight + 4) + 'px' } export function hideTextInput() { @@ -632,6 +654,12 @@ import { isDrawableLayer } from '../vendor/layer-logic.js' x, y, text, color: S.color, fontSize: Math.max(8, S.textSize), + // 样式一次性随默认值落进对象:老对象没有这些字段,text.js 会各自回退到等价默认值 + ...newTextStyle({ + fontWeight: S.textWeight, align: S.textAlign, lineHeight: S.textLineHeight, + strokeWidth: S.textStrokeWidth, strokeColor: S.textStrokeColor, + bgFill: S.textBgFill, bgColor: S.textBgColor + }), opacity: 1, visible: true, locked: false, diff --git a/image-annotate/plugin/editor/recent-colors.js b/image-annotate/plugin/editor/recent-colors.js new file mode 100644 index 0000000..136d62e --- /dev/null +++ b/image-annotate/plugin/editor/recent-colors.js @@ -0,0 +1,54 @@ +/* recent-colors.js - 最近使用颜色(v1.9) + * + * 只依赖 state.js(叶子模块):tools.js 在改色时调用 rememberColor(), + * color pop 打开时 renderRecentColors() 把最近 8 个色块铺出来。 + * 持久化走宿主 ctx.settings(小 KV,不放像素,符合宿主存储约定)。 + */ + +'use strict' + +import { S, runtime } from './state.js' + + const MAX = 8 + const KEY = 'recentColors' + + function valid(hex) { + return /^#[0-9a-f]{6}$/i.test(String(hex || '')) + } + + export function loadRecentColors() { + const st = S.callbacks && S.callbacks.settings + let list = [] + if (st && typeof st.get === 'function') { + try { + const got = st.get(KEY) + if (Array.isArray(got)) list = got + } catch (e) { /* 宿主 KV 不可用就当没有 */ } + } + S.recentColors = list.filter(valid).map(c => String(c).toLowerCase()).slice(0, MAX) + renderRecentColors() + } + + /** 记一个颜色:去重后置顶,最多 8 个 */ + export function rememberColor(hex) { + if (!valid(hex)) return + const c = String(hex).toLowerCase() + if (S.recentColors && S.recentColors[0] === c) return // 已经是最新,别每次重排 + const list = [c].concat((S.recentColors || []).filter(x => x !== c)) + S.recentColors = list.slice(0, MAX) + const st = S.callbacks && S.callbacks.settings + if (st && typeof st.set === 'function') { + try { st.set(KEY, S.recentColors) } catch (e) { /* 存不下就只在本次会话用 */ } + } + renderRecentColors() + } + + export function renderRecentColors() { + const wrap = runtime.el && runtime.el.querySelector('.iwb-editor-recent-colors') + if (!wrap) return + const list = S.recentColors || [] + wrap.innerHTML = list.map(c => + `` + ).join('') + wrap.hidden = !list.length + } diff --git a/image-annotate/plugin/editor/snap.js b/image-annotate/plugin/editor/snap.js new file mode 100644 index 0000000..b022098 --- /dev/null +++ b/image-annotate/plugin/editor/snap.js @@ -0,0 +1,94 @@ +/* snap.js - 拖动吸附与参考线(v1.9) + * + * 只做两件事:算「要不要吸、吸多少」,以及把参考线画出来。 + * 不碰对象的写入 —— 调用方拿到 dx/dy 自己应用到 x/y,再在 render 里画线。 + * 这样位图、文字、形状三种拖动可以共用同一套吸附,不会各写一遍阈值。 + * + * 吸附目标:画布中线/四边 + 其它可见元素的左/中/右与上/中/下。 + * 阈值按屏幕像素给(6px),换算成图片像素后再比较 —— 否则放大图片时 + * 吸附范围会跟着放大到几十像素,鼠标还没靠近就被拽走。 + */ + +'use strict' + +import { S } from './state.js' +import { viewScale } from './scale.js' + + /** 吸附触发距离(屏幕像素) */ + export const SNAP_SCREEN_PX = 6 + + /** 参考线颜色:洋红,和选中框的橙色区分开 */ + const GUIDE_COLOR = '#ff2d95' + + function pushBox(targets, box) { + const x2 = box.x + box.w + const y2 = box.y + box.h + targets.x.push(box.x, box.x + box.w / 2, x2) + targets.y.push(box.y, box.y + box.h / 2, y2) + } + + /** 在候选线里找「离得最近且不超过阈值」的那条,返回需要平移的量 */ + function nearest(targets, sources, tol, axis) { + let best = null + for (let i = 0; i < targets.length; i++) { + for (let j = 0; j < sources.length; j++) { + const delta = targets[i] - sources[j] + const abs = Math.abs(delta) + if (abs > tol) continue + if (!best || abs < Math.abs(best.delta)) best = { delta: delta, at: targets[i], axis: axis } + } + } + return best + } + + /** + * 计算吸附位移。 + * @param {{x:number,y:number,w:number,h:number}} box 被拖元素的包围盒(已按指针位移算好,未吸附) + * @param {Array<{x:number,y:number,w:number,h:number}>} others 其它元素的包围盒 + * @returns {{dx:number, dy:number, guides:Array}} + */ + export function snapMove(box, others) { + const tol = SNAP_SCREEN_PX / Math.max(0.02, viewScale()) + const targets = { x: [0, S.imgW / 2, S.imgW], y: [0, S.imgH / 2, S.imgH] } + for (const o of others || []) { + if (!o || !isFinite(o.x) || !isFinite(o.y)) continue + pushBox(targets, o) + } + const sourcesX = [box.x, box.x + box.w / 2, box.x + box.w] + const sourcesY = [box.y, box.y + box.h / 2, box.y + box.h] + const gx = nearest(targets.x, sourcesX, tol, 'x') + const gy = nearest(targets.y, sourcesY, tol, 'y') + const guides = [] + if (gx) guides.push(gx) + if (gy) guides.push(gy) + return { dx: gx ? gx.delta : 0, dy: gy ? gy.delta : 0, guides: guides } + } + + /** 画参考线(贯穿整个画布 + overlay 外扩区,拖动时一眼看到对齐到哪) */ + export function drawGuides(ctx, guides) { + if (!guides || !guides.length || !ctx) return + const scale = viewScale() + const pad = S.overlayPad || 0 + ctx.save() + ctx.strokeStyle = GUIDE_COLOR + ctx.lineWidth = 1 / Math.max(0.02, scale) + ctx.setLineDash([6 / Math.max(0.02, scale), 4 / Math.max(0.02, scale)]) + for (const g of guides) { + ctx.beginPath() + if (g.axis === 'x') { + ctx.moveTo(g.at, -pad) + ctx.lineTo(g.at, S.imgH + pad) + } else { + ctx.moveTo(-pad, g.at) + ctx.lineTo(S.imgW + pad, g.at) + } + ctx.stroke() + } + ctx.setLineDash([]) + ctx.restore() + } + + export function clearGuides() { + if (!S.guides) return + S.guides = null + } diff --git a/image-annotate/plugin/editor/state.js b/image-annotate/plugin/editor/state.js index 517adef..e973a28 100644 --- a/image-annotate/plugin/editor/state.js +++ b/image-annotate/plugin/editor/state.js @@ -38,7 +38,18 @@ // v1.2 工具参数解耦:形状线宽与文字字号不再借用画笔粗细, // 否则「调细画笔」会顺手把所有形状的描边一起改掉。 shapeLineWidth: 3, // 矩形/圆形/箭头/钢笔的描边粗细 + shapeRadius: 0, // 矩形圆角半径 px(v1.9,仅 rect 有意义) textSize: 32, // 新建文字的字号 px + // ---- v1.9 文字样式:这套是「新建文字」的默认值,每段文字自己存一份 ---- + textWeight: 'bold', // bold | normal | 900 + textAlign: 'left', // left | center | right(多行时各行按块宽对齐) + textLineHeight: 1.25, // 行高倍数(1.25 = 老版单行高度,勿随意改) + textStrokeWidth: 0, // 描边宽度 px,0 = 无描边 + textStrokeColor: '#ffffff', + textBgFill: false, // 底色块 + textBgColor: '#000000', + // 最近使用颜色(最多 8 个,存 ctx.settings,跨会话保留) + recentColors: [], // 图层系统 layers: [], // 位图图层数组 [{ id, name, canvas, ctx, opacity, visible, z }] activeLayerId: null, // 当前活跃位图图层 ID(画笔/橡皮操作目标) @@ -113,6 +124,7 @@ exportOptions: null, // { preset, format, bg, maxKB, size },来自 ctx.settings interaction: 'idle', // 轻量交互状态机:idle | marquee | lasso | placing | cropping renderAll: null, // 由 index.js 注入的统一重绘出口 + guides: null, // 拖动吸附参考线(图片坐标,松手清空):[{axis:'x'|'y', at, from, to}] lastExport: null // 观测口:{ bytes, width, height, format, preset } } diff --git a/image-annotate/plugin/editor/text.js b/image-annotate/plugin/editor/text.js new file mode 100644 index 0000000..87a25f5 --- /dev/null +++ b/image-annotate/plugin/editor/text.js @@ -0,0 +1,155 @@ +/* text.js - 文字的字体串、度量与绘制(v1.9) + * + * 为什么单独一个模块:文字要在两处画 —— 落层(layers.js#drawVectorToCanvas)与 + * 预览/度量(objects.js)。两边各写一遍必然出现「量出来的框和画出来的字不一样」。 + * 这里做成零依赖叶子模块(不 import 任何编辑器模块),objects.js 与 layers.js + * 都只往下依赖它,不会形成循环 import(esbuild 打成 IIFE 时循环 import 会拿到 undefined)。 + * + * 坐标语义(与 v1.8 之前保持一致,勿随意改动): + * t.x / t.y 是「文字块」左上角;底色 padding 与描边从这一点向内/外扩展。 + * 单行 + 无底色 + 无描边时,textBox() 与老版 textBounds() 完全相等(w=文字宽,h=fontSize×1.25)。 + */ + +'use strict' + + /** 默认行高倍数:必须等于老版的 fontSize×1.25,否则单行文字的选中框会变高 */ + export const TEXT_LINE_HEIGHT = 1.25 + + /** 底色块相对字号的 padding 系数 */ + const BG_PAD_RATIO = 0.3 + + let _measureCtx = null + + /** 度量用的离屏 ctx:不依赖编辑器 DOM 是否已建好,避免 textBounds 在早期调用时抛错 */ + function measureCtx() { + if (!_measureCtx) { + const c = document.createElement('canvas') + c.width = 8 + c.height = 8 + _measureCtx = c.getContext('2d') + } + return _measureCtx + } + + /** 字重:'bold' | 'normal' | '900' …(默认粗体,与老版一致) */ + export function weightOf(t) { + const w = t && t.fontWeight + return w == null || w === '' ? 'bold' : String(w) + } + + export function fontOf(t) { + const size = Math.max(4, Number(t && t.fontSize) || 32) + return weightOf(t) + ' ' + size + 'px sans-serif' + } + + /** 文字的排布度量:分行、每行宽度、行高、底色 padding、描边宽度 */ + export function textMetrics(t) { + const ctx = measureCtx() + const font = fontOf(t) + ctx.font = font + const raw = (t && t.text) == null ? '' : String(t.text) + const lines = raw.split('\n') + const widths = lines.map(line => ctx.measureText(line).width) + const size = Math.max(4, Number(t && t.fontSize) || 32) + const lh = size * (Number(t && t.lineHeight) || TEXT_LINE_HEIGHT) + const w = lines.length ? Math.max.apply(null, widths) : 0 + const pad = t && t.bgFill ? Math.round(size * BG_PAD_RATIO) : 0 + const sw = Math.max(0, Number(t && t.strokeWidth) || 0) + return { lines, widths, w, h: lh * lines.length, lh, pad, sw, font, size } + } + + /** 包围盒(图片坐标):含底色 padding 与描边向外扩出的一半 */ + export function textBox(t) { + const m = textMetrics(t) + const half = m.sw / 2 + return { + x: t.x - half, + y: t.y - half, + w: Math.max(m.w, 2) + m.pad * 2 + m.sw, + h: Math.max(m.h, 1) + m.pad * 2 + m.sw + } + } + + function alignOf(t) { + const a = t && t.align + return a === 'center' || a === 'right' ? a : 'left' + } + + /** + * 画一段文字(含底色块、描边、多行、旋转)。 + * 底色块与描边都按「块」来画:底色覆盖整块,描边沿字形外沿。 + */ + export function drawTextObject(ctx, t) { + const m = textMetrics(t) + ctx.save() + ctx.textBaseline = 'top' + ctx.globalAlpha = t.opacity != null ? t.opacity : 1 + const b = textBox(t) + const rot = t.rotation || 0 + if (rot) { + const cx = b.x + b.w / 2 + const cy = b.y + b.h / 2 + ctx.translate(cx, cy) + ctx.rotate(rot * Math.PI / 180) + ctx.translate(-cx, -cy) + } + ctx.font = m.font + const align = alignOf(t) + const boxW = m.w + m.pad * 2 + + // 底色块:先于文字画,圆角按字号比例给一点(纯直角贴小字会很硬) + if (t.bgFill) { + const r = Math.min(m.pad + 2, Math.min(boxW, m.h + m.pad * 2) / 2) + ctx.globalAlpha = (t.opacity != null ? t.opacity : 1) * (t.bgAlpha == null ? 0.55 : t.bgAlpha) + ctx.fillStyle = t.bgColor || '#000000' + const bx = t.x, by = t.y + const bw = boxW, bh = m.h + m.pad * 2 + ctx.beginPath() + if (typeof ctx.roundRect === 'function') { + ctx.roundRect(bx, by, bw, bh, r) + } else { + ctx.moveTo(bx + r, by) + ctx.arcTo(bx + bw, by, bx + bw, by + bh, r) + ctx.arcTo(bx + bw, by + bh, bx, by + bh, r) + ctx.arcTo(bx, by + bh, bx, by, r) + ctx.arcTo(bx, by, bx + bw, by, r) + ctx.closePath() + } + ctx.fill() + ctx.globalAlpha = (t.opacity != null ? t.opacity : 1) + } + + // 对齐以「块内可用宽度(不含 padding)」为基准:多行时各行按这个宽度对齐 + ctx.textAlign = align + const left = t.x + m.pad + const ox = align === 'center' ? left + m.w / 2 : align === 'right' ? left + m.w : left + + ctx.lineJoin = 'round' + ctx.miterLimit = 2 + for (let i = 0; i < m.lines.length; i++) { + const y = t.y + m.pad + i * m.lh + if (m.sw > 0) { + ctx.lineWidth = m.sw + ctx.strokeStyle = t.strokeColor || '#ffffff' + ctx.strokeText(m.lines[i], ox, y) + } + ctx.fillStyle = t.color || '#ff4444' + ctx.fillText(m.lines[i], ox, y) + } + ctx.restore() + } + + /** 从默认样式造一段文字的字段(新建文字 / 老对象补默认值共用) */ + export function newTextStyle(src) { + const s = src || {} + return { + fontWeight: weightOf(s), + align: alignOf(s), + lineHeight: Number(s.lineHeight) || TEXT_LINE_HEIGHT, + strokeWidth: Math.max(0, Number(s.strokeWidth) || 0), + strokeColor: s.strokeColor || '#ffffff', + bgFill: !!s.bgFill, + bgColor: s.bgColor || '#000000', + bgAlpha: s.bgAlpha == null ? 0.55 : Number(s.bgAlpha) + } + } diff --git a/image-annotate/plugin/editor/tools.js b/image-annotate/plugin/editor/tools.js index cb7e1d9..8aa8430 100644 --- a/image-annotate/plugin/editor/tools.js +++ b/image-annotate/plugin/editor/tools.js @@ -18,6 +18,7 @@ import { saveSnapshot } from './history.js' import { updateBrushParamUI, updateColorUI, updateToolUI } from './events.js' import { isDrawableLayer } from '../vendor/layer-logic.js' import { hexToRgb, rgbToHex } from '../vendor/image-math.js' +import { rememberColor } from './recent-colors.js' // ============ 绘制工具 ============ @@ -160,6 +161,24 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js' S.pickerComposite = null } + /** 圆角半径:夹在短边一半以内,避免圆角把矩形吃掉变胶囊/消失 */ + function roundedRadius(s, w, h) { + const r = Number(s && s.radius) || 0 + if (r <= 0) return 0 + return Math.min(r, Math.min(w, h) / 2) + } + + /** 圆角矩形路径:不用 ctx.roundRect(老浏览器没有),手写 arcs,行为可控 */ + function roundRectPath(ctx, x, y, w, h, r) { + const rr = Math.min(r, Math.min(w, h) / 2) + ctx.moveTo(x + rr, y) + ctx.arcTo(x + w, y, x + w, y + h, rr) + ctx.arcTo(x + w, y + h, x, y + h, rr) + ctx.arcTo(x, y + h, x, y, rr) + ctx.arcTo(x, y, x + w, y, rr) + ctx.closePath() + } + /** 按形状对象绘制(矩形/箭头),预览与最终渲染共用 */ export function drawShape(ctx, s) { ctx.save() @@ -181,8 +200,16 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js' if (pts.length > 1) { ctx.beginPath(); ctx.moveTo(pts[0].x, pts[0].y); for (let i = 1; i < pts.length; i++) ctx.lineTo(pts[i].x, pts[i].y); if (s.closed) ctx.closePath(); if (s.closed && s.fill) { ctx.fillStyle = s.color; ctx.fill() } ctx.stroke() } } else if (s.type === 'rect') { const rx = Math.min(s.x1, s.x2), ry = Math.min(s.y1, s.y2), rw = Math.abs(s.x2 - s.x1), rh = Math.abs(s.y2 - s.y1) - if (s.fill) { ctx.fillStyle = s.color; ctx.fillRect(rx, ry, rw, rh) } - ctx.strokeRect(rx, ry, rw, rh) + const radius = roundedRadius(s, rw, rh) + if (radius > 0) { + ctx.beginPath() + roundRectPath(ctx, rx, ry, rw, rh, radius) + if (s.fill) { ctx.fillStyle = s.color; ctx.fill() } + ctx.stroke() + } else { + if (s.fill) { ctx.fillStyle = s.color; ctx.fillRect(rx, ry, rw, rh) } + ctx.strokeRect(rx, ry, rw, rh) + } } else if (s.type === 'circle') { const rx = Math.min(s.x1, s.x2), ry = Math.min(s.y1, s.y2) const rw = Math.abs(s.x2 - s.x1), rh = Math.abs(s.y2 - s.y1) @@ -380,6 +407,9 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js' export function applyColorChange(color, opts) { const skipHistory = !!(opts && opts.skipHistory) S.color = color + // 只有「确认型」改色才进最近使用:拖 SV 时 skipHistory=true 每帧都调, + // 全记进去会把最近色刷成一串相邻色,毫无用处。 + if (!skipHistory) rememberColor(color) updateColorUI() const t = getSelectedText() if (t && !t.locked && t.color !== S.color) { diff --git a/image-annotate/src/index.js b/image-annotate/src/index.js index 2687dac..767a1ae 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.8.3', + version: '1.9.0', apiVersion: 1, capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'], settings: { @@ -63,8 +63,25 @@ var __IWB_ANNOTATE_MANIFEST__ = { // 否则「调细画笔」会顺手把所有形状的描边一起改掉。 shapeLineWidth: 3, // 矩形/圆形/箭头/钢笔的描边粗细 + shapeRadius: 0, + // 矩形圆角半径 px(v1.9,仅 rect 有意义) textSize: 32, // 新建文字的字号 px + // ---- v1.9 文字样式:这套是「新建文字」的默认值,每段文字自己存一份 ---- + textWeight: "bold", + // bold | normal | 900 + textAlign: "left", + // left | center | right(多行时各行按块宽对齐) + textLineHeight: 1.25, + // 行高倍数(1.25 = 老版单行高度,勿随意改) + textStrokeWidth: 0, + // 描边宽度 px,0 = 无描边 + textStrokeColor: "#ffffff", + textBgFill: false, + // 底色块 + textBgColor: "#000000", + // 最近使用颜色(最多 8 个,存 ctx.settings,跨会话保留) + recentColors: [], // 图层系统 layers: [], // 位图图层数组 [{ id, name, canvas, ctx, opacity, visible, z }] @@ -171,6 +188,8 @@ var __IWB_ANNOTATE_MANIFEST__ = { // 轻量交互状态机:idle | marquee | lasso | placing | cropping renderAll: null, // 由 index.js 注入的统一重绘出口 + guides: null, + // 拖动吸附参考线(图片坐标,松手清空):[{axis:'x'|'y', at, from, to}] lastExport: null // 观测口:{ bytes, width, height, format, preset } }; @@ -461,6 +480,50 @@ var __IWB_ANNOTATE_MANIFEST__ = { return 0; } + // image-annotate/plugin/editor/recent-colors.js + var MAX = 8; + var KEY = "recentColors"; + function valid(hex) { + return /^#[0-9a-f]{6}$/i.test(String(hex || "")); + } + function loadRecentColors() { + const st = S.callbacks && S.callbacks.settings; + let list = []; + if (st && typeof st.get === "function") { + try { + const got = st.get(KEY); + if (Array.isArray(got)) list = got; + } catch (e) { + } + } + S.recentColors = list.filter(valid).map((c) => String(c).toLowerCase()).slice(0, MAX); + renderRecentColors(); + } + function rememberColor(hex) { + if (!valid(hex)) return; + const c = String(hex).toLowerCase(); + if (S.recentColors && S.recentColors[0] === c) return; + const list = [c].concat((S.recentColors || []).filter((x) => x !== c)); + S.recentColors = list.slice(0, MAX); + const st = S.callbacks && S.callbacks.settings; + if (st && typeof st.set === "function") { + try { + st.set(KEY, S.recentColors); + } catch (e) { + } + } + renderRecentColors(); + } + function renderRecentColors() { + const wrap = runtime.el && runtime.el.querySelector(".iwb-editor-recent-colors"); + if (!wrap) return; + const list = S.recentColors || []; + wrap.innerHTML = list.map( + (c) => `` + ).join(""); + wrap.hidden = !list.length; + } + // image-annotate/plugin/editor/tools.js var brushStampCache = { key: "", canvas: null }; function getBrushStamp(size, color, hardness) { @@ -585,6 +648,20 @@ var __IWB_ANNOTATE_MANIFEST__ = { S.strokeCtx.clearRect(0, 0, S.imgW, S.imgH); S.pickerComposite = null; } + function roundedRadius(s, w, h) { + const r = Number(s && s.radius) || 0; + if (r <= 0) return 0; + return Math.min(r, Math.min(w, h) / 2); + } + function roundRectPath(ctx, x, y, w, h, r) { + const rr = Math.min(r, Math.min(w, h) / 2); + ctx.moveTo(x + rr, y); + ctx.arcTo(x + w, y, x + w, y + h, rr); + ctx.arcTo(x + w, y + h, x, y + h, rr); + ctx.arcTo(x, y + h, x, y, rr); + ctx.arcTo(x, y, x + w, y, rr); + ctx.closePath(); + } function drawShape(ctx, s) { ctx.save(); ctx.globalAlpha = s.opacity != null ? s.opacity : 1; @@ -615,11 +692,22 @@ var __IWB_ANNOTATE_MANIFEST__ = { } } else if (s.type === "rect") { const rx = Math.min(s.x1, s.x2), ry = Math.min(s.y1, s.y2), rw = Math.abs(s.x2 - s.x1), rh = Math.abs(s.y2 - s.y1); - if (s.fill) { - ctx.fillStyle = s.color; - ctx.fillRect(rx, ry, rw, rh); + const radius = roundedRadius(s, rw, rh); + if (radius > 0) { + ctx.beginPath(); + roundRectPath(ctx, rx, ry, rw, rh, radius); + if (s.fill) { + ctx.fillStyle = s.color; + ctx.fill(); + } + ctx.stroke(); + } else { + if (s.fill) { + ctx.fillStyle = s.color; + ctx.fillRect(rx, ry, rw, rh); + } + ctx.strokeRect(rx, ry, rw, rh); } - ctx.strokeRect(rx, ry, rw, rh); } else if (s.type === "circle") { const rx = Math.min(s.x1, s.x2), ry = Math.min(s.y1, s.y2); const rw = Math.abs(s.x2 - s.x1), rh = Math.abs(s.y2 - s.y1); @@ -780,6 +868,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { function applyColorChange(color, opts) { const skipHistory = !!(opts && opts.skipHistory); S.color = color; + if (!skipHistory) rememberColor(color); updateColorUI(); const t = getSelectedText(); if (t && !t.locked && t.color !== S.color) { @@ -901,14 +990,186 @@ var __IWB_ANNOTATE_MANIFEST__ = { }, 2600); } + // image-annotate/plugin/editor/text.js + var TEXT_LINE_HEIGHT = 1.25; + var BG_PAD_RATIO = 0.3; + var _measureCtx = null; + function measureCtx() { + if (!_measureCtx) { + const c = document.createElement("canvas"); + c.width = 8; + c.height = 8; + _measureCtx = c.getContext("2d"); + } + return _measureCtx; + } + function weightOf(t) { + const w = t && t.fontWeight; + return w == null || w === "" ? "bold" : String(w); + } + function fontOf(t) { + const size = Math.max(4, Number(t && t.fontSize) || 32); + return weightOf(t) + " " + size + "px sans-serif"; + } + function textMetrics(t) { + const ctx = measureCtx(); + const font = fontOf(t); + ctx.font = font; + const raw = (t && t.text) == null ? "" : String(t.text); + const lines = raw.split("\n"); + const widths = lines.map((line) => ctx.measureText(line).width); + const size = Math.max(4, Number(t && t.fontSize) || 32); + const lh = size * (Number(t && t.lineHeight) || TEXT_LINE_HEIGHT); + const w = lines.length ? Math.max.apply(null, widths) : 0; + const pad = t && t.bgFill ? Math.round(size * BG_PAD_RATIO) : 0; + const sw = Math.max(0, Number(t && t.strokeWidth) || 0); + return { lines, widths, w, h: lh * lines.length, lh, pad, sw, font, size }; + } + function textBox(t) { + const m = textMetrics(t); + const half = m.sw / 2; + return { + x: t.x - half, + y: t.y - half, + w: Math.max(m.w, 2) + m.pad * 2 + m.sw, + h: Math.max(m.h, 1) + m.pad * 2 + m.sw + }; + } + function alignOf(t) { + const a = t && t.align; + return a === "center" || a === "right" ? a : "left"; + } + function drawTextObject(ctx, t) { + const m = textMetrics(t); + ctx.save(); + ctx.textBaseline = "top"; + ctx.globalAlpha = t.opacity != null ? t.opacity : 1; + const b = textBox(t); + const rot = t.rotation || 0; + if (rot) { + const cx = b.x + b.w / 2; + const cy = b.y + b.h / 2; + ctx.translate(cx, cy); + ctx.rotate(rot * Math.PI / 180); + ctx.translate(-cx, -cy); + } + ctx.font = m.font; + const align = alignOf(t); + const boxW = m.w + m.pad * 2; + if (t.bgFill) { + const r = Math.min(m.pad + 2, Math.min(boxW, m.h + m.pad * 2) / 2); + ctx.globalAlpha = (t.opacity != null ? t.opacity : 1) * (t.bgAlpha == null ? 0.55 : t.bgAlpha); + ctx.fillStyle = t.bgColor || "#000000"; + const bx = t.x, by = t.y; + const bw = boxW, bh = m.h + m.pad * 2; + ctx.beginPath(); + if (typeof ctx.roundRect === "function") { + ctx.roundRect(bx, by, bw, bh, r); + } else { + ctx.moveTo(bx + r, by); + ctx.arcTo(bx + bw, by, bx + bw, by + bh, r); + ctx.arcTo(bx + bw, by + bh, bx, by + bh, r); + ctx.arcTo(bx, by + bh, bx, by, r); + ctx.arcTo(bx, by, bx + bw, by, r); + ctx.closePath(); + } + ctx.fill(); + ctx.globalAlpha = t.opacity != null ? t.opacity : 1; + } + ctx.textAlign = align; + const left = t.x + m.pad; + const ox = align === "center" ? left + m.w / 2 : align === "right" ? left + m.w : left; + ctx.lineJoin = "round"; + ctx.miterLimit = 2; + for (let i = 0; i < m.lines.length; i++) { + const y = t.y + m.pad + i * m.lh; + if (m.sw > 0) { + ctx.lineWidth = m.sw; + ctx.strokeStyle = t.strokeColor || "#ffffff"; + ctx.strokeText(m.lines[i], ox, y); + } + ctx.fillStyle = t.color || "#ff4444"; + ctx.fillText(m.lines[i], ox, y); + } + ctx.restore(); + } + function newTextStyle(src) { + const s = src || {}; + return { + fontWeight: weightOf(s), + align: alignOf(s), + lineHeight: Number(s.lineHeight) || TEXT_LINE_HEIGHT, + strokeWidth: Math.max(0, Number(s.strokeWidth) || 0), + strokeColor: s.strokeColor || "#ffffff", + bgFill: !!s.bgFill, + bgColor: s.bgColor || "#000000", + bgAlpha: s.bgAlpha == null ? 0.55 : Number(s.bgAlpha) + }; + } + + // image-annotate/plugin/editor/snap.js + var SNAP_SCREEN_PX = 6; + var GUIDE_COLOR = "#ff2d95"; + function pushBox(targets, box) { + const x2 = box.x + box.w; + const y2 = box.y + box.h; + targets.x.push(box.x, box.x + box.w / 2, x2); + targets.y.push(box.y, box.y + box.h / 2, y2); + } + function nearest(targets, sources, tol, axis) { + let best = null; + for (let i = 0; i < targets.length; i++) { + for (let j = 0; j < sources.length; j++) { + const delta = targets[i] - sources[j]; + const abs = Math.abs(delta); + if (abs > tol) continue; + if (!best || abs < Math.abs(best.delta)) best = { delta, at: targets[i], axis }; + } + } + return best; + } + function snapMove(box, others) { + const tol = SNAP_SCREEN_PX / Math.max(0.02, viewScale()); + const targets = { x: [0, S.imgW / 2, S.imgW], y: [0, S.imgH / 2, S.imgH] }; + for (const o of others || []) { + if (!o || !isFinite(o.x) || !isFinite(o.y)) continue; + pushBox(targets, o); + } + const sourcesX = [box.x, box.x + box.w / 2, box.x + box.w]; + const sourcesY = [box.y, box.y + box.h / 2, box.y + box.h]; + const gx = nearest(targets.x, sourcesX, tol, "x"); + const gy = nearest(targets.y, sourcesY, tol, "y"); + const guides = []; + if (gx) guides.push(gx); + if (gy) guides.push(gy); + return { dx: gx ? gx.delta : 0, dy: gy ? gy.delta : 0, guides }; + } + function drawGuides(ctx, guides) { + if (!guides || !guides.length || !ctx) return; + const scale = viewScale(); + const pad = S.overlayPad || 0; + ctx.save(); + ctx.strokeStyle = GUIDE_COLOR; + ctx.lineWidth = 1 / Math.max(0.02, scale); + ctx.setLineDash([6 / Math.max(0.02, scale), 4 / Math.max(0.02, scale)]); + for (const g of guides) { + ctx.beginPath(); + if (g.axis === "x") { + ctx.moveTo(g.at, -pad); + ctx.lineTo(g.at, S.imgH + pad); + } else { + ctx.moveTo(-pad, g.at); + ctx.lineTo(S.imgW + pad, g.at); + } + ctx.stroke(); + } + ctx.setLineDash([]); + ctx.restore(); + } + // image-annotate/plugin/editor/objects.js - var TEXT_FONT = (size) => "bold " + size + "px sans-serif"; function textBounds(t) { - const ctx = S.textCtx; - ctx.font = TEXT_FONT(t.fontSize); - const w = ctx.measureText(t.text).width; - const h = t.fontSize * 1.25; - return { x: t.x, y: t.y, w, h }; + return textBox(t); } function getSelectedText() { return S.textLayers.find((t) => t.id === S.selectedTextId) || null; @@ -1066,6 +1327,21 @@ var __IWB_ANNOTATE_MANIFEST__ = { for (const unit of layerUnitsDesc()) if (hitUnit(unit, pos)) return unit; return null; } + function otherObjectBoxes(exclude) { + const out = []; + for (const unit of layerUnits()) { + const o = unit.obj; + if (!o || o === exclude || o.id === "base" || o.visible === false) continue; + if (unit.kind === "bitmap") { + if (isFinite(o.x) && isFinite(o.y) && o.w > 0 && o.h > 0) out.push({ x: o.x, y: o.y, w: o.w, h: o.h }); + } else if (unit.kind === "text") { + out.push(textBox(o)); + } else { + out.push(shapeBounds(o)); + } + } + return out; + } function hitAnyObject(pos) { for (const unit of layerUnitsDesc()) { if (unit.kind === "bitmap") continue; @@ -1307,6 +1583,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { for (const { kind, obj } of allObjects()) drawVectorToCanvas(kind, obj); reorderLayerCanvas(); clearOverlay(); + drawGuides(S.overlayCtx, S.guides); if (tempShape) drawShape(S.overlayCtx, tempShape); if (S.tool === "pen" && S.penPath && S.penPath.pts.length) drawPenPathPreview(); if (S.placingImage) { @@ -1449,6 +1726,8 @@ var __IWB_ANNOTATE_MANIFEST__ = { input.select(); input.dataset.x = x; input.dataset.y = y; + input.style.height = "auto"; + input.style.height = Math.max(30, input.scrollHeight + 4) + "px"; } function hideTextInput() { const input = runtime.el.querySelector(".iwb-editor-text-input"); @@ -1493,6 +1772,16 @@ var __IWB_ANNOTATE_MANIFEST__ = { text, color: S.color, fontSize: Math.max(8, S.textSize), + // 样式一次性随默认值落进对象:老对象没有这些字段,text.js 会各自回退到等价默认值 + ...newTextStyle({ + fontWeight: S.textWeight, + align: S.textAlign, + lineHeight: S.textLineHeight, + strokeWidth: S.textStrokeWidth, + strokeColor: S.textStrokeColor, + bgFill: S.textBgFill, + bgColor: S.textBgColor + }), opacity: 1, visible: true, locked: false, @@ -1815,8 +2104,18 @@ var __IWB_ANNOTATE_MANIFEST__ = { if (!drag || !layer) return; const base = drag.layer; if (drag.mode === "move") { - layer.x = base.x + pos.x - drag.start.x; - layer.y = base.y + pos.y - drag.start.y; + let nx = base.x + pos.x - drag.start.x; + let ny = base.y + pos.y - drag.start.y; + if (!S._altDown && base.w > 0 && base.h > 0) { + const s = snapMove({ x: nx, y: ny, w: base.w, h: base.h }, otherObjectBoxes(layer)); + nx += s.dx; + ny += s.dy; + S.guides = s.guides.length ? s.guides : null; + } else { + S.guides = null; + } + layer.x = nx; + layer.y = ny; if (isDrawableLayer(layer)) layer._bounds = void 0; } else if (drag.mode === "rotate") { const rcx = base.x + base.w / 2, rcy = base.y + base.h / 2; @@ -1983,21 +2282,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { if (kind === "shape") { drawShape(ctx, obj); } else { - ctx.save(); - ctx.textBaseline = "top"; - ctx.globalAlpha = obj.opacity != null ? obj.opacity : 1; - const rot = obj.rotation || 0; - if (rot) { - const b = textBounds(obj); - const cx = b.x + b.w / 2, cy = b.y + b.h / 2; - ctx.translate(cx, cy); - ctx.rotate(rot * Math.PI / 180); - ctx.translate(-cx, -cy); - } - ctx.font = TEXT_FONT(obj.fontSize); - ctx.fillStyle = obj.color; - ctx.fillText(obj.text, obj.x, obj.y); - ctx.restore(); + drawTextObject(ctx, obj); } } function toggleLayerVisibility(id) { @@ -3207,13 +3492,14 @@ var __IWB_ANNOTATE_MANIFEST__ = {
一次只输出一个结果;设置会记住
+
工具选项
- 选区也可右键;Ctrl+J 复制 · Delete 清除 · Ctrl+D 取消 + Ctrl+J 复制 · Delete 清除
@@ -3242,7 +3528,8 @@ var __IWB_ANNOTATE_MANIFEST__ = {
- + +
#ffffff
@@ -3367,6 +3654,8 @@ var __IWB_ANNOTATE_MANIFEST__ = {
+ +
@@ -4027,6 +4316,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { crop: onCropDrawMove }; function onMouseMove(e) { + S._altDown = !!e.altKey; if (S.placingImage && S.placingHandle && S.placingStart) { onPlacementDragMove(e); return; @@ -4100,8 +4390,21 @@ var __IWB_ANNOTATE_MANIFEST__ = { if (S.textDrag.mode === "move") { const dx = pos0.x - S.textDrag.start.x; const dy = pos0.y - S.textDrag.start.y; - t.x = clamp(S.textDrag.layer.x + dx, 0, Math.max(0, S.imgW - 4)); - t.y = clamp(S.textDrag.layer.y + dy, 0, Math.max(0, S.imgH - 4)); + let nx = clamp(S.textDrag.layer.x + dx, 0, Math.max(0, S.imgW - 4)); + let ny = clamp(S.textDrag.layer.y + dy, 0, Math.max(0, S.imgH - 4)); + if (!S._altDown) { + const b = textBounds(t); + const offX = b.x - t.x; + const offY = b.y - t.y; + const s = snapMove({ x: nx + offX, y: ny + offY, w: b.w, h: b.h }, otherObjectBoxes(t)); + nx += s.dx; + ny += s.dy; + S.guides = s.guides.length ? s.guides : null; + } else { + S.guides = null; + } + t.x = nx; + t.y = ny; } else if (S.textDrag.mode === "rotate") { const st = S.textDrag; const a1 = Math.atan2(pos0.y - st.cy, pos0.x - st.cx); @@ -4137,8 +4440,17 @@ var __IWB_ANNOTATE_MANIFEST__ = { const dx = pos0.x - S.shapeDrag.start.x; const dy = pos0.y - S.shapeDrag.start.y; const b = shapeBounds(S.shapeDrag.shape); - const cdx = clamp(dx, -b.x, Math.max(-b.x, S.imgW - (b.x + b.w))); - const cdy = clamp(dy, -b.y, Math.max(-b.y, S.imgH - (b.y + b.h))); + let cdx = clamp(dx, -b.x, Math.max(-b.x, S.imgW - (b.x + b.w))); + let cdy = clamp(dy, -b.y, Math.max(-b.y, S.imgH - (b.y + b.h))); + if (!S._altDown) { + const box = { x: b.x + cdx, y: b.y + cdy, w: b.w, h: b.h }; + const s = snapMove(box, otherObjectBoxes(sh)); + cdx += s.dx; + cdy += s.dy; + S.guides = s.guides.length ? s.guides : null; + } else { + S.guides = null; + } if (sh.type === "pen") { sh.pts = (S.shapeDrag.shape.pts || []).map((p) => ({ x: p.x + cdx, y: p.y + cdy })); } else { @@ -4187,6 +4499,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { lw: Math.max(1, S.shapeLineWidth), lineWidth: Math.max(1, S.shapeLineWidth), fill: S.tool === "rect" || S.tool === "circle" ? !!S.rectFill : false, + radius: S.tool === "rect" ? Math.max(0, S.shapeRadius) : 0, opacity: 1, visible: true }; @@ -4295,6 +4608,8 @@ var __IWB_ANNOTATE_MANIFEST__ = { } } S.textDrag = null; + S.guides = null; + renderObjects(); renderLayerPanel(); return; } @@ -4310,6 +4625,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { } } S.bitmapDrag = null; + S.guides = null; renderObjects(); renderLayerPanel(); return; @@ -4324,6 +4640,8 @@ var __IWB_ANNOTATE_MANIFEST__ = { } } S.shapeDrag = null; + S.guides = null; + renderObjects(); renderLayerPanel(); return; } @@ -4370,6 +4688,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { color: S.color, lw: Math.max(1, S.shapeLineWidth), fill: S.tool === "rect" || S.tool === "circle" ? !!S.rectFill : false, + radius: S.tool === "rect" ? Math.max(0, S.shapeRadius) : 0, opacity: 1, visible: true, locked: false, @@ -4588,6 +4907,46 @@ var __IWB_ANNOTATE_MANIFEST__ = { `; } var SHAPE_NAMES = { rect: "矩形", circle: "圆形", arrow: "箭头", pen: "钢笔路径" }; + var TEXT_STYLE_STATE_KEY = { + fontWeight: "textWeight", + align: "textAlign", + lineHeight: "textLineHeight", + strokeWidth: "textStrokeWidth", + strokeColor: "textStrokeColor", + bgFill: "textBgFill", + bgColor: "textBgColor" + }; + function textStyleValues(t) { + const pick = (objKey, stateKey, dflt) => { + const raw = t ? t[objKey] : S[stateKey]; + return raw == null ? dflt : raw; + }; + return { + fontWeight: String(pick("fontWeight", "textWeight", "bold")), + align: pick("align", "textAlign", "left"), + lineHeight: Number(pick("lineHeight", "textLineHeight", 1.25)) || 1.25, + strokeWidth: Math.max(0, Number(pick("strokeWidth", "textStrokeWidth", 0)) || 0), + strokeColor: pick("strokeColor", "textStrokeColor", "#ffffff"), + bgFill: !!pick("bgFill", "textBgFill", false), + bgColor: pick("bgColor", "textBgColor", "#000000") + }; + } + function textStyleHTML(t) { + const v = textStyleValues(t); + const wBtn = (val, label, title) => ``; + const aBtn = (val, label, title) => ``; + return ` + 字重${wBtn("normal", "常规", "常规字重")}${wBtn("bold", "粗", "粗体(默认)")}${wBtn("900", "特粗", "特粗,封面标题用")} + 对齐${aBtn("left", "左", "多行时按左缘对齐")}${aBtn("center", "中", "多行时居中")}${aBtn("right", "右", "多行时按右缘对齐")} + 行距 + % + + 描边 + px + + + `; + } var SELCMD_SVGS = { all: '', invert: '', @@ -4604,12 +4963,12 @@ var __IWB_ANNOTATE_MANIFEST__ = { if (t === "rect" || t === "circle" || t === "pen" || t === "arrow") { const owner = t === "pen" ? "pen" : "rect"; const lw = Math.max(1, Math.round(sh.lw || S.shapeLineWidth)); - return `已选中:${SHAPE_NAMES[t] || t}` + rangeOpt("shapeLineWidth", "线宽", 1, 60, lw, "") + presetDots("shapeLineWidth", [1, 2, 3, 6, 10, 16, 24]) + (t === "arrow" ? "" : fillStyleHTML(owner)) + (t === "pen" && !sh.closed ? '这条钢笔路径未闭合,实心不生效;点回起点闭合后即可填充' : "") + selCmdHTML(); + return `已选中:${SHAPE_NAMES[t] || t}` + rangeOpt("shapeLineWidth", "线宽", 1, 60, lw, "") + presetDots("shapeLineWidth", [1, 2, 3, 6, 10, 16, 24]) + (t === "rect" ? rangeOpt("shapeRadius", "圆角", 0, 200, Math.round(sh.radius || 0), "px") : "") + (t === "arrow" ? "" : fillStyleHTML(owner)) + (t === "pen" && !sh.closed ? '这条钢笔路径未闭合,实心不生效;点回起点闭合后即可填充' : "") + selCmdHTML(); } } const text = getSelectedText(); if (text) { - return `已选中:文字` + rangeOpt("textSize", "字号", 8, 400, Math.round(text.fontSize || S.textSize), "px") + '双击文字改内容,拖动移动,手柄缩放' + selCmdHTML(); + return `已选中:文字` + rangeOpt("textSize", "字号", 8, 400, Math.round(text.fontSize || S.textSize), "px") + textStyleHTML(text) + selCmdHTML() + '双击改内容 · 拖动手柄缩放'; } return `当前工具:选择 / 移动 点中矩形/圆形/钢笔/文字后,这里会出现它的描边、实心与粗细` + selCmdHTML(); @@ -4626,7 +4985,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { ${Math.round(S.brushOpacity * 100)}%` + presetDots("brushHardness", [0, 25, 50, 75, 100]); } if (tool === "rect" || tool === "circle") { - return rangeOpt("shapeLineWidth", "线宽", 1, 60, S.shapeLineWidth, "") + presetDots("shapeLineWidth", [1, 2, 3, 6, 10, 16, 24]) + fillStyleHTML("rect"); + return rangeOpt("shapeLineWidth", "线宽", 1, 60, S.shapeLineWidth, "") + presetDots("shapeLineWidth", [1, 2, 3, 6, 10, 16, 24]) + (tool === "rect" ? rangeOpt("shapeRadius", "圆角", 0, 200, S.shapeRadius, "px") : "") + fillStyleHTML("rect"); } if (tool === "arrow") { return rangeOpt("shapeLineWidth", "线宽", 1, 60, S.shapeLineWidth, "") + presetDots("shapeLineWidth", [1, 2, 3, 6, 10, 16, 24]) + '拖出箭头,松手完成'; @@ -4635,7 +4994,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { return rangeOpt("shapeLineWidth", "线宽", 1, 60, S.shapeLineWidth, "") + presetDots("shapeLineWidth", [1, 2, 3, 6, 10, 16, 24]) + fillStyleHTML("pen") + '逐点点击,点回起点闭合;闭合后可切换描边/实心'; } if (tool === "text") { - return rangeOpt("textSize", "字号", 8, 400, S.textSize, "px") + '点画布输入文字,Enter 确认'; + return rangeOpt("textSize", "字号", 8, 400, S.textSize, "px") + textStyleHTML(null) + '点画布输入文字,Enter 确认,Shift+Enter 换行'; } if (tool === "marquee") { return `形状 @@ -4675,7 +5034,10 @@ var __IWB_ANNOTATE_MANIFEST__ = { if (key === "brushHardness") return S.brushHardness; if (key === "brushOpacity") return Math.round(S.brushOpacity * 100); if (key === "shapeLineWidth") return selShape ? Math.max(1, Math.round(selShape.lw || S.shapeLineWidth)) : S.shapeLineWidth; + if (key === "shapeRadius") return selShape && selShape.type === "rect" ? Math.round(selShape.radius || 0) : S.shapeRadius; if (key === "textSize") return selText ? Math.round(selText.fontSize || S.textSize) : S.textSize; + if (key === "textLineHeight") return Math.round((selText ? Number(selText.lineHeight) || S.textLineHeight : S.textLineHeight) * 100); + if (key === "textStrokeWidth") return Math.round(selText ? Number(selText.strokeWidth) || 0 : S.textStrokeWidth); if (key === "feather") return S.selectionFeather; return ""; }; @@ -4699,6 +5061,17 @@ var __IWB_ANNOTATE_MANIFEST__ = { } btn.classList.toggle("active", !!cur === (btn.dataset.value === "fill")); }); + const sv = textStyleValues(selText); + body.querySelectorAll("[data-opt-text]").forEach((btn) => { + const k = btn.dataset.optText; + const cur = k === "bgFill" ? sv.bgFill ? "1" : "0" : String(sv[k]); + btn.classList.toggle("active", cur === btn.dataset.value); + }); + body.querySelectorAll("[data-opt-color]").forEach((inp) => { + if (document.activeElement === inp) return; + const v = sv[inp.dataset.optColor]; + if (v && String(inp.value).toLowerCase() !== String(v).toLowerCase()) inp.value = v; + }); } function updateStatusbar() { if (!runtime.el) return; @@ -4746,6 +5119,45 @@ var __IWB_ANNOTATE_MANIFEST__ = { renderObjects(); if (committed) textSnapDone = false; } + var textStyleSnapDone = false; + function applyTextStyle(key, raw, committed) { + const stateKey = TEXT_STYLE_STATE_KEY[key]; + if (!stateKey) return; + let value = raw; + if (key === "bgFill") value = raw === true || raw === 1 || raw === "1" || raw === "true"; + else if (key === "lineHeight") value = clamp(Number(raw) || 125, 80, 300) / 100; + else if (key === "strokeWidth") value = clamp(Number(raw) || 0, 0, 40); + else if (key === "strokeColor" || key === "bgColor") value = String(raw || "#000000").toLowerCase(); + else value = String(raw); + S[stateKey] = value; + const t = getSelectedText(); + if (!t || t.locked) { + textStyleSnapDone = false; + return; + } + if (committed || !textStyleSnapDone) { + saveSnapshot("文字样式"); + textStyleSnapDone = true; + } + t[key] = value; + renderObjects(); + if (committed) textStyleSnapDone = false; + } + var radiusSnapDone = false; + function applyShapeRadius(committed) { + const sh = getSelectedShape(); + if (!sh || sh.locked || sh.type !== "rect") { + radiusSnapDone = false; + return; + } + if (committed || !radiusSnapDone) { + saveSnapshot("圆角"); + radiusSnapDone = true; + } + sh.radius = S.shapeRadius; + renderObjects(); + if (committed) radiusSnapDone = false; + } function setShapeFill(fill, owner) { const isPen = owner === "pen"; if (isPen) S.penFill = !!fill; @@ -4784,6 +5196,13 @@ var __IWB_ANNOTATE_MANIFEST__ = { } else if (key === "textSize") { S.textSize = clamp(safe || 32, 8, 400); applyTextSize(committed); + } else if (key === "textLineHeight") { + applyTextStyle("lineHeight", safe || 125, committed); + } else if (key === "textStrokeWidth") { + applyTextStyle("strokeWidth", safe, committed); + } else if (key === "shapeRadius") { + S.shapeRadius = clamp(safe, 0, 400); + applyShapeRadius(committed); } else if (key === "feather") { S.selectionFeather = clamp(safe, 0, 20); if (S.selection && S.selection.active) S.selection.feather = S.selectionFeather; @@ -4856,8 +5275,25 @@ var __IWB_ANNOTATE_MANIFEST__ = { if (body) { body.addEventListener("mousedown", (e) => e.stopPropagation()); body.addEventListener("input", (e) => setOptionFromControl(e.target, false)); - body.addEventListener("change", (e) => setOptionFromControl(e.target, true)); + body.addEventListener("change", (e) => { + const colorEl = e.target.closest ? e.target.closest("[data-opt-color]") : null; + if (colorEl) { + e.stopPropagation(); + applyTextStyle(colorEl.dataset.optColor, colorEl.value, true); + syncOptionBar(); + return; + } + setOptionFromControl(e.target, true); + }); body.addEventListener("click", (e) => { + const textBtn = e.target.closest("[data-opt-text]"); + if (textBtn) { + e.stopPropagation(); + const k = textBtn.dataset.optText; + applyTextStyle(k, textBtn.dataset.value, true); + syncOptionBar(); + return; + } const shapeBtn = e.target.closest('[data-opt="shape"]'); if (shapeBtn) { e.stopPropagation(); @@ -5041,10 +5477,14 @@ var __IWB_ANNOTATE_MANIFEST__ = { 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); - })); + if (pop) { + pop.addEventListener("click", (e) => { + const btn = e.target.closest("[data-panel-color]"); + if (!btn) return; + e.stopPropagation(); + setPanelColor(btn.dataset.panelColor); + }); + } const palettePick = runtime.el.querySelector('[data-action="palettePick"]'); if (palettePick) { palettePick.addEventListener("mousedown", (e) => e.stopPropagation()); @@ -5243,6 +5683,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { function bindExportActions() { bindIf('[data-action="cancel"]', "click", close); bindIf('[data-action="download"]', "click", () => exportResult("download")); + bindIf('[data-action="copyClipboard"]', "click", () => copyResult()); bindIf('[data-action="newNode"]', "click", () => exportResult("newNode")); bindIf('[data-action="replace"]', "click", () => exportResult("replace")); } @@ -5251,10 +5692,16 @@ var __IWB_ANNOTATE_MANIFEST__ = { } function bindTextInput() { const textInput = runtime.el.querySelector(".iwb-editor-text-input"); - textInput && textInput.addEventListener("mousedown", (e) => e.stopPropagation()); - textInput && textInput.addEventListener("keydown", (e) => { + if (!textInput) return; + textInput.addEventListener("mousedown", (e) => e.stopPropagation()); + const autosize = () => { + textInput.style.height = "auto"; + textInput.style.height = textInput.scrollHeight + 4 + "px"; + }; + textInput.addEventListener("input", autosize); + textInput.addEventListener("keydown", (e) => { e.stopPropagation(); - if (e.key === "Enter") { + if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); commitTextInput(); } else if (e.key === "Escape") { @@ -6947,6 +7394,70 @@ var __IWB_ANNOTATE_MANIFEST__ = { }, 2e3); toast("已下载 " + name + "(" + Math.round(blob.size / 1024) + "KB)", "success"); } + async function toPngBlob(blob) { + try { + if (typeof createImageBitmap === "function") { + const bmp = await createImageBitmap(blob); + const c = document.createElement("canvas"); + c.width = bmp.width; + c.height = bmp.height; + c.getContext("2d").drawImage(bmp, 0, 0); + if (typeof bmp.close === "function") bmp.close(); + const out = await new Promise((res) => c.toBlob((b) => res(b), "image/png")); + c.width = 0; + c.height = 0; + if (out) return out; + } + } catch (e) { + } + return await new Promise((resolve) => { + const url = URL.createObjectURL(blob); + const img = new Image(); + img.onload = () => { + const c = document.createElement("canvas"); + c.width = img.naturalWidth; + c.height = img.naturalHeight; + c.getContext("2d").drawImage(img, 0, 0); + try { + URL.revokeObjectURL(url); + } catch (e) { + } + c.toBlob((b) => resolve(b || blob), "image/png"); + }; + img.onerror = () => { + try { + URL.revokeObjectURL(url); + } catch (e) { + } + resolve(blob); + }; + img.src = url; + }); + } + async function copyBlobToClipboard(blob) { + const nav = typeof navigator !== "undefined" ? navigator : null; + const CI = typeof window !== "undefined" ? window.ClipboardItem : null; + if (!nav || !nav.clipboard || typeof nav.clipboard.write !== "function" || typeof CI !== "function") { + toast("当前浏览器不支持复制图片,请用「导出」下载", "warn"); + return false; + } + let png = blob; + if (blob.type !== "image/png") { + try { + png = await toPngBlob(blob); + } catch (e) { + png = blob; + } + } + try { + await nav.clipboard.write([new CI({ "image/png": png })]); + toast("已复制到剪贴板(" + Math.round(png.size / 1024) + "KB),可直接粘贴", "success"); + return true; + } catch (e) { + toast("复制失败:" + (e && e.message || "浏览器拒绝了剪贴板写入") + ";可用「导出」下载", "error"); + return false; + } + } // image-annotate/plugin/editor/index.js async function open(options) { @@ -6969,6 +7480,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { updateAllUI(); registerSelectionCommands(); loadExportOptions(); + loadRecentColors(); bindLiteUI(); bindFloating(); bindExportUI(); @@ -7154,6 +7666,17 @@ var __IWB_ANNOTATE_MANIFEST__ = { if (S.callbacks && S.callbacks.onError) S.callbacks.onError("导出失败:" + (e && e.message || "图片跨域")); } } + async function copyResult() { + if (S.placingImage) cancelImagePlacement(); + try { + const { blob } = await prepareOutput(); + await copyBlobToClipboard(blob); + if (S.renderAll) S.renderAll(); + } catch (e) { + console.error("[IWB编辑器] 复制失败:", e); + toast("复制失败:" + (e && e.message || "图片可能跨域"), "error"); + } + } var __stats = () => ({ history: S.history.length, historyBytes: S.history.reduce((n, s) => n + (s.__bytes || 0), 0), @@ -7182,9 +7705,44 @@ var __IWB_ANNOTATE_MANIFEST__ = { opacity: l.opacity == null ? 1 : l.opacity, cssOpacity: l.canvas ? parseFloat(l.canvas.style.opacity || "1") : null })), - shapes: S.shapeLayers.map((s) => ({ id: s.id, type: s.type, lw: s.lw, fill: !!s.fill, closed: !!s.closed, z: s.z, color: s.color })), - texts: S.textLayers.map((t) => ({ id: t.id, text: t.text })), + shapes: S.shapeLayers.map((s) => ({ id: s.id, type: s.type, lw: s.lw, fill: !!s.fill, closed: !!s.closed, z: s.z, color: s.color, radius: s.radius || 0, x1: Math.round(s.x1 || 0), y1: Math.round(s.y1 || 0), x2: Math.round(s.x2 || 0), y2: Math.round(s.y2 || 0) })), + texts: S.textLayers.map((t) => ({ + id: t.id, + text: t.text, + x: t.x, + y: t.y, + fontSize: t.fontSize, + color: t.color, + fontWeight: t.fontWeight, + align: t.align, + lineHeight: t.lineHeight, + strokeWidth: t.strokeWidth, + strokeColor: t.strokeColor, + bgFill: !!t.bgFill, + bgColor: t.bgColor, + // 包围盒:吸附/多行/底色/描边的断言都靠它,和绘制共用同一套度量 + box: (() => { + const b = textBounds(t); + return { x: Math.round(b.x), y: Math.round(b.y), w: Math.round(b.w), h: Math.round(b.h) }; + })() + })), + // 吸附参考线(拖动中才有)与最近使用颜色:交互回归用 + guides: S.guides ? S.guides.map((g) => ({ axis: g.axis, at: Math.round(g.at * 10) / 10 })) : [], + recentColors: (S.recentColors || []).slice(), + textDefaults: { + weight: S.textWeight, + align: S.textAlign, + lineHeight: S.textLineHeight, + strokeWidth: S.textStrokeWidth, + strokeColor: S.textStrokeColor, + bgFill: S.textBgFill, + bgColor: S.textBgColor + }, selectedShapeId: S.selectedShapeId, + // 光标所在的图片坐标(状态栏同源):换算问题的第一现场证据 + lastPos: S.lastPos ? { x: Math.round(S.lastPos.x), y: Math.round(S.lastPos.y) } : null, + // 当前正在进行的拖拽类型:move 才是拖动本体,handle/rotate 说明点到了控制点 + drag: S.shapeDrag ? "shape:" + S.shapeDrag.mode + (S.shapeDrag.handle ? ":" + S.shapeDrag.handle : "") : S.textDrag ? "text:" + S.textDrag.mode : S.bitmapDrag ? "bitmap:" + S.bitmapDrag.mode + (S.bitmapDrag.handle ? ":" + S.bitmapDrag.handle : "") : null, selectedTextId: S.selectedTextId, penEditId: S.penEditId, activeLayerId: S.activeLayerId, @@ -7279,7 +7837,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 position: relative;\n}\n\n/* 图层项:整项改成「行 + 可选的不透明度行」,两行都靠 .iwb-layer-row 保持原来的横向排布 */\n.iwb-layer-item {\n display: block;\n padding: 5px 8px;\n border-radius: 6px;\n cursor: grab;\n user-select: none;\n transition: background 0.12s;\n margin-bottom: 2px;\n}\n.iwb-layer-row {\n display: flex;\n align-items: center;\n gap: 6px;\n min-width: 0;\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/* 拖动中:整行跟着指针浮起,压住相邻行;其余行由 JS 实时让位(落点反馈) */\n.iwb-layer-item.dragging {\n position: relative;\n z-index: 3;\n opacity: 1;\n background: #3a3d55;\n box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5), inset 0 0 0 1px #e8a735;\n transition: none;\n cursor: grabbing;\n}\n.iwb-editor-layer-list.sorting,\n.iwb-editor-layer-list.sorting .iwb-layer-item { cursor: grabbing; }\n/* 画笔/橡皮作用目标:与「选中」分离,避免出现两个图层同时高亮 */\n.iwb-layer-paint { flex: 0 0 auto; color: #a6adc8; font-size: 11px; opacity: 0.85; }\n/* 不透明度角标:只有非 100% 才出现,一眼看出哪层被调淡了 */\n.iwb-layer-op { flex: 0 0 auto; font-size: 10px; color: #a6adc8; font-variant-numeric: tabular-nums; }\n\n/* 缩略图:canvas 画内容,类型图标垫在下面当兜底(空图层的缩略图是全透明的) */\n.iwb-layer-thumb {\n position: relative;\n flex: 0 0 auto;\n width: 22px;\n height: 22px;\n border-radius: 3px;\n overflow: hidden;\n background-color: #1e1e2e;\n background-image: linear-gradient(45deg, #33334a 25%, transparent 25%), linear-gradient(-45deg, #33334a 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #33334a 75%), linear-gradient(-45deg, transparent 75%, #33334a 75%);\n background-size: 8px 8px;\n background-position: 0 0, 0 4px, 4px -4px, -4px 0;\n box-shadow: inset 0 0 0 1px #45475a;\n}\n.iwb-layer-thumb canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }\n.iwb-layer-thumb .iwb-layer-icon {\n position: absolute;\n inset: 0;\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #7f849c;\n}\n\n/* 不透明度行:只出现在选中项下,拖动时不能被重绘打断 */\n.iwb-layer-op-row {\n display: flex;\n align-items: center;\n gap: 6px;\n margin: 4px 0 1px 26px;\n}\n.iwb-layer-opacity {\n flex: 1 1 auto;\n min-width: 0;\n height: 14px;\n accent-color: #e8a735;\n cursor: pointer;\n}\n.iwb-layer-op-val {\n flex: 0 0 auto;\n width: 32px;\n text-align: right;\n font-size: 10px;\n color: #a6adc8;\n font-variant-numeric: tabular-nums;\n}\n\n/* 可重命名的图层名:悬停给个提示,进入编辑时换成输入框 */\n.iwb-layer-name.renamable:hover { color: #e8a735; }\n.iwb-layer-name-input {\n flex: 1 1 auto;\n min-width: 0;\n padding: 1px 4px;\n border: 1px solid #e8a735;\n border-radius: 3px;\n background: #1e1e2e;\n color: #cdd6f4;\n font-size: 12px;\n font-family: inherit;\n outline: none;\n}\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\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\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\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/* v1.8:当前生效的效果。必须与 hover 一眼区分 —— 拖动强度滑杆时要能看出在调哪个效果 */\n.iwb-editor-fx-btn.is-active {\n background: #2c2735; border-color: #e8a735; color: #f3dcb0;\n}\n.iwb-editor-fx-btn.is-active .iwb-editor-fx-ico {\n box-shadow: inset 0 0 0 1px rgba(232, 167, 53, 0.75);\n}\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/* v1.8:效果参数滑杆。范围与单位随效果切换(马赛克=块大小 px、柔化=半径 px、其余=强度 %)。\n 未点效果 / 目标层被切走时加 .iwb-editor-fx-adj-off 整条置灰。 */\n.iwb-editor-fx-adj {\n display: flex; flex-direction: column; gap: 4px;\n padding: 6px 8px 5px; border-radius: 7px;\n background: #1e1e2c; border: 1px solid #2f2f42;\n transition: opacity 0.12s ease;\n}\n.iwb-editor-fx-adj-head {\n display: flex; align-items: center; justify-content: space-between; gap: 6px;\n}\n.iwb-editor-fx-adj-name {\n font-size: 10.5px; font-weight: 500; color: #b9c0d8;\n overflow: hidden; text-overflow: ellipsis; white-space: nowrap;\n}\n.iwb-editor-fx-adj-val {\n font-size: 10.5px; color: #e8a735; font-variant-numeric: tabular-nums; flex: 0 0 auto;\n}\n.iwb-editor-fx-adj-off { opacity: 0.5; }\n.iwb-editor-fx-range {\n -webkit-appearance: none; appearance: none;\n width: 100%; height: 14px; margin: 0; background: transparent; cursor: pointer;\n}\n.iwb-editor-fx-range::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: #313244; }\n.iwb-editor-fx-range::-webkit-slider-thumb {\n -webkit-appearance: none; appearance: none;\n width: 12px; height: 12px; margin-top: -4px; border-radius: 50%;\n background: #e8a735; border: 1px solid #1e1e2c;\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);\n}\n.iwb-editor-fx-range::-moz-range-track { height: 4px; border-radius: 2px; background: #313244; }\n.iwb-editor-fx-range::-moz-range-thumb {\n width: 12px; height: 12px; border-radius: 50%; background: #e8a735; border: 1px solid #1e1e2c;\n}\n.iwb-editor-fx-range:disabled { cursor: default; }\n.iwb-editor-fx-range:disabled::-webkit-slider-thumb { background: #585b70; }\n.iwb-editor-fx-range:disabled::-moz-range-thumb { background: #585b70; }\n.iwb-editor-fx-range:focus-visible { outline: 2px solid #89b4fa; outline-offset: 2px; }\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'; + 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 line-height: 1.35;\n /* textarea:默认会显示右下角拖拽柄与滚动条,画布上的就地输入框都不要 */\n resize: none;\n overflow: hidden;\n white-space: pre;\n background: rgba(255, 255, 255, 0.95);\n color: #1e1e2e;\n z-index: 10;\n min-width: 120px;\n min-height: 30px;\n font-family: inherit;\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 position: relative;\n}\n\n/* 图层项:整项改成「行 + 可选的不透明度行」,两行都靠 .iwb-layer-row 保持原来的横向排布 */\n.iwb-layer-item {\n display: block;\n padding: 5px 8px;\n border-radius: 6px;\n cursor: grab;\n user-select: none;\n transition: background 0.12s;\n margin-bottom: 2px;\n}\n.iwb-layer-row {\n display: flex;\n align-items: center;\n gap: 6px;\n min-width: 0;\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/* 拖动中:整行跟着指针浮起,压住相邻行;其余行由 JS 实时让位(落点反馈) */\n.iwb-layer-item.dragging {\n position: relative;\n z-index: 3;\n opacity: 1;\n background: #3a3d55;\n box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5), inset 0 0 0 1px #e8a735;\n transition: none;\n cursor: grabbing;\n}\n.iwb-editor-layer-list.sorting,\n.iwb-editor-layer-list.sorting .iwb-layer-item { cursor: grabbing; }\n/* 画笔/橡皮作用目标:与「选中」分离,避免出现两个图层同时高亮 */\n.iwb-layer-paint { flex: 0 0 auto; color: #a6adc8; font-size: 11px; opacity: 0.85; }\n/* 不透明度角标:只有非 100% 才出现,一眼看出哪层被调淡了 */\n.iwb-layer-op { flex: 0 0 auto; font-size: 10px; color: #a6adc8; font-variant-numeric: tabular-nums; }\n\n/* 缩略图:canvas 画内容,类型图标垫在下面当兜底(空图层的缩略图是全透明的) */\n.iwb-layer-thumb {\n position: relative;\n flex: 0 0 auto;\n width: 22px;\n height: 22px;\n border-radius: 3px;\n overflow: hidden;\n background-color: #1e1e2e;\n background-image: linear-gradient(45deg, #33334a 25%, transparent 25%), linear-gradient(-45deg, #33334a 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #33334a 75%), linear-gradient(-45deg, transparent 75%, #33334a 75%);\n background-size: 8px 8px;\n background-position: 0 0, 0 4px, 4px -4px, -4px 0;\n box-shadow: inset 0 0 0 1px #45475a;\n}\n.iwb-layer-thumb canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }\n.iwb-layer-thumb .iwb-layer-icon {\n position: absolute;\n inset: 0;\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #7f849c;\n}\n\n/* 不透明度行:只出现在选中项下,拖动时不能被重绘打断 */\n.iwb-layer-op-row {\n display: flex;\n align-items: center;\n gap: 6px;\n margin: 4px 0 1px 26px;\n}\n.iwb-layer-opacity {\n flex: 1 1 auto;\n min-width: 0;\n height: 14px;\n accent-color: #e8a735;\n cursor: pointer;\n}\n.iwb-layer-op-val {\n flex: 0 0 auto;\n width: 32px;\n text-align: right;\n font-size: 10px;\n color: #a6adc8;\n font-variant-numeric: tabular-nums;\n}\n\n/* 可重命名的图层名:悬停给个提示,进入编辑时换成输入框 */\n.iwb-layer-name.renamable:hover { color: #e8a735; }\n.iwb-layer-name-input {\n flex: 1 1 auto;\n min-width: 0;\n padding: 1px 4px;\n border: 1px solid #e8a735;\n border-radius: 3px;\n background: #1e1e2e;\n color: #cdd6f4;\n font-size: 12px;\n font-family: inherit;\n outline: none;\n}\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\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\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\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/* 右端通用快捷键提示。原来只有 @media 里的 display:none,没有任何基础样式,\n 于是它作为裸 span 参与 flex 收缩,被挤成两行还贴到右边缘外。 */\n.iwb-editor-optionbar-tip {\n flex: 0 0 auto; white-space: nowrap;\n color: #6c7086; font-size: 11px; padding-left: 4px;\n}\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/* hint 是「说明」不是「控件」:不许被压缩。\n 早先带 text-overflow:ellipsis,在 36px 高的选项栏里会被压成「双击改…」这种半截文案,\n 比不显示更误导人;现在由父级 overflow-x 决定是完整显示还是整体滚出视野。 */\n.iwb-opt-hint { color: #7f849c; font-size: 11px; margin-left: auto; white-space: nowrap; flex: 0 0 auto; }\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/* v1.8:当前生效的效果。必须与 hover 一眼区分 —— 拖动强度滑杆时要能看出在调哪个效果 */\n.iwb-editor-fx-btn.is-active {\n background: #2c2735; border-color: #e8a735; color: #f3dcb0;\n}\n.iwb-editor-fx-btn.is-active .iwb-editor-fx-ico {\n box-shadow: inset 0 0 0 1px rgba(232, 167, 53, 0.75);\n}\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/* v1.8:效果参数滑杆。范围与单位随效果切换(马赛克=块大小 px、柔化=半径 px、其余=强度 %)。\n 未点效果 / 目标层被切走时加 .iwb-editor-fx-adj-off 整条置灰。 */\n.iwb-editor-fx-adj {\n display: flex; flex-direction: column; gap: 4px;\n padding: 6px 8px 5px; border-radius: 7px;\n background: #1e1e2c; border: 1px solid #2f2f42;\n transition: opacity 0.12s ease;\n}\n.iwb-editor-fx-adj-head {\n display: flex; align-items: center; justify-content: space-between; gap: 6px;\n}\n.iwb-editor-fx-adj-name {\n font-size: 10.5px; font-weight: 500; color: #b9c0d8;\n overflow: hidden; text-overflow: ellipsis; white-space: nowrap;\n}\n.iwb-editor-fx-adj-val {\n font-size: 10.5px; color: #e8a735; font-variant-numeric: tabular-nums; flex: 0 0 auto;\n}\n.iwb-editor-fx-adj-off { opacity: 0.5; }\n.iwb-editor-fx-range {\n -webkit-appearance: none; appearance: none;\n width: 100%; height: 14px; margin: 0; background: transparent; cursor: pointer;\n}\n.iwb-editor-fx-range::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: #313244; }\n.iwb-editor-fx-range::-webkit-slider-thumb {\n -webkit-appearance: none; appearance: none;\n width: 12px; height: 12px; margin-top: -4px; border-radius: 50%;\n background: #e8a735; border: 1px solid #1e1e2c;\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);\n}\n.iwb-editor-fx-range::-moz-range-track { height: 4px; border-radius: 2px; background: #313244; }\n.iwb-editor-fx-range::-moz-range-thumb {\n width: 12px; height: 12px; border-radius: 50%; background: #e8a735; border: 1px solid #1e1e2c;\n}\n.iwb-editor-fx-range:disabled { cursor: default; }\n.iwb-editor-fx-range:disabled::-webkit-slider-thumb { background: #585b70; }\n.iwb-editor-fx-range:disabled::-moz-range-thumb { background: #585b70; }\n.iwb-editor-fx-range:focus-visible { outline: 2px solid #89b4fa; outline-offset: 2px; }\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\n/* ================================================================\n v1.9:文字样式控件 / 圆角 / 最近使用颜色 / 复制按钮\n ================================================================ */\n\n/* 选项栏里的原生颜色框(描边色 / 底色):压成和数字框同高的小方块 */\n.iwb-opt-color {\n width: 22px;\n height: 20px;\n padding: 0;\n flex: 0 0 auto;\n border: 1px solid #45475a;\n border-radius: 4px;\n background: transparent;\n cursor: pointer;\n}\n.iwb-opt-color::-webkit-color-swatch-wrapper { padding: 2px; }\n.iwb-opt-color::-webkit-color-swatch { border: 0; border-radius: 3px; }\n\n/* 「最近使用」:色板弹层里 4 列 × 2 行,空的时候整块隐藏(不占位) */\n.iwb-editor-color-pop .iwb-editor-recent-colors {\n display: grid;\n grid-template-columns: repeat(4, 18px);\n grid-auto-rows: 18px;\n gap: 5px;\n flex: 0 0 auto;\n align-content: center;\n}\n.iwb-editor-recent-colors[hidden] { display: none; }\n.iwb-editor-color-pop .iwb-editor-recent-colors .iwb-editor-color-panel-swatch {\n width: 18px;\n height: 18px;\n padding: 0;\n border: 0;\n border-radius: 50%;\n cursor: pointer;\n}\n.iwb-editor-color-pop .iwb-editor-recent-colors .iwb-editor-color-panel-swatch:hover { transform: scale(1.12); }\n\n/* 复制到剪贴板:与「导出」同尺寸但用低饱和色,避免两个绿色按钮抢眼 */\n.iwb-editor-btn-copy { background: #313244 !important; color: #cdd6f4 !important; }\n.iwb-editor-btn-copy:hover { background: #3b3d52 !important; }\n\n/* 选项栏按钮里是中文双字标签(常规/特粗/底色),不给 nowrap 会被挤成竖排 */\n.iwb-editor-optionbar-body .iwb-opt-btn { white-space: nowrap; }\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 1133499..397ff7c 100644 --- a/image-annotate/tools/harness.mjs +++ b/image-annotate/tools/harness.mjs @@ -1659,6 +1659,241 @@ check('图层拖动排序:位图与矢量混排也能拖(面板顺序、z、 return geo.vecIdx >= 1 ? true : '矢量画布在 DOM 里排到了最底 vecIdx=' + geo.vecIdx })()) +// ---------- v1.9 文字样式 / 吸附参考线 / 圆角 / 最近色 / 复制 ---------- + +/** 图片坐标 → 屏幕坐标(用位图图层 canvas 的实际显示尺寸换算,别用 zoom 猜) */ +async function imgToScreen(ix, iy) { + const b = await page.locator('.iwb-editor-layer-canvas').first().boundingBox() + const d = await dbg() + return { x: b.x + ix * (b.width / d.doc.w), y: b.y + iy * (b.height / d.doc.h), box: b, doc: d.doc } +} + +/** 吸附阈值(图片像素):与 snap.js 的 6 屏幕像素保持同一口径 */ +async function snapTol() { + const d = await dbg() + const b = await page.locator('.iwb-editor-layer-canvas').first().boundingBox() + return 6 / (b.width / d.doc.w) +} + +// 多行文字:Shift+Enter 换行(textarea)→ 落成两行,包围盒高度约为单行两倍 +await page.locator('.iwb-editor-tool[data-tool="text"]').click() +let p0 = await imgToScreen(8, 8) +await page.mouse.click(p0.x, p0.y) +await page.waitForTimeout(150) +await page.evaluate(() => { + const el = document.querySelector('.iwb-editor-text-input') + el.focus() + el.value = 'AB\nCD' + el.dispatchEvent(new Event('input', { bubbles: true })) +}) +await page.keyboard.press('Enter') +await page.waitForTimeout(220) +let vdbg = await dbg() +const multiLine = vdbg.texts.length === 1 && vdbg.texts[0].text.indexOf('\n') > 0 +const singleH = vdbg.texts.length ? vdbg.texts[0].fontSize * 1.25 : 0 +check('文字支持多行(Shift+Enter 换行,包围盒高 ≈ 两行)', + multiLine && vdbg.texts[0].box.h >= singleH * 2 - 2, + multiLine ? 'h=' + vdbg.texts[0].box.h + ' 单行=' + Math.round(singleH) : JSON.stringify(vdbg.texts)) + +await page.locator('.iwb-editor-tool[data-tool="select"]').click() +p0 = await imgToScreen(10, 12) +await page.mouse.click(p0.x, p0.y) +await page.waitForTimeout(200) +vdbg = await dbg() +check('选中文字后选项栏出整套文字样式控件(字重/对齐/行距/描边/底色)', + Boolean(vdbg.selectedTextId) && + (await page.locator('.iwb-editor-optionbar-body [data-opt-text="fontWeight"]').count()) === 3 && + (await page.locator('.iwb-editor-optionbar-body [data-opt-text="align"]').count()) === 3 && + (await page.locator('.iwb-editor-optionbar-body [data-opt-text="bgFill"]').count()) === 1 && + (await page.locator('.iwb-editor-optionbar-body [data-opt="textLineHeight"]').count()) >= 1 && + (await page.locator('.iwb-editor-optionbar-body [data-opt-color]').count()) === 2) + +await page.locator('.iwb-editor-optionbar-body [data-opt-text="fontWeight"][data-value="900"]').click() +await page.waitForTimeout(150) +vdbg = await dbg() +const boldBefore = vdbg.texts[0].fontWeight +check('点「特粗」改选中文字的字重', boldBefore === '900', 'fontWeight=' + boldBefore) +await page.keyboard.press('Control+z') +await page.waitForTimeout(200) +vdbg = await dbg() +check('字重改动可撤销', vdbg.texts[0].fontWeight !== '900', 'fontWeight=' + vdbg.texts[0].fontWeight) + +// 撤销会清掉选中态(历史恢复后不再高亮),要继续改样式得重新选中 +await page.locator('.iwb-editor-tool[data-tool="select"]').click() +p0 = await imgToScreen(10, 12) +await page.mouse.click(p0.x, p0.y) +await page.waitForTimeout(200) +vdbg = await dbg() +const hBefore = vdbg.texts[0].box.h +await page.evaluate(() => { + const el = document.querySelector('.iwb-editor-optionbar-body input[data-opt="textStrokeWidth"]') + el.value = '6' + el.dispatchEvent(new Event('input', { bubbles: true })) + el.dispatchEvent(new Event('change', { bubbles: true })) +}) +await page.waitForTimeout(200) +vdbg = await dbg() +check('描边走选项栏生效且包围盒随之变大(含描边外扩)', + vdbg.texts[0].strokeWidth === 6 && vdbg.texts[0].box.h > hBefore, + 'sw=' + vdbg.texts[0].strokeWidth + ' h ' + hBefore + '→' + vdbg.texts[0].box.h) + +// 底色块 +await page.locator('.iwb-editor-optionbar-body [data-opt-text="bgFill"]').click() +await page.waitForTimeout(200) +vdbg = await dbg() +const hBg = vdbg.texts[0].box.h +check('底色块开关生效(padding 让包围盒继续变大)', + vdbg.texts[0].bgFill === true && hBg > vdbg.texts[0].box.h - 1 && hBg > 0, + 'bgFill=' + vdbg.texts[0].bgFill + ' h=' + hBg) + +// 吸附:画一个实心矩形,拖到画布中心附近应被精确吸到中心并出现参考线 +await page.locator('.iwb-editor-tool[data-tool="rect"]').click() +await page.waitForTimeout(100) +if (await page.locator('.iwb-editor-optionbar-body [data-opt-toggle="fill"][data-fill-owner="rect"]').getAttribute('class').then(c => c.indexOf('active') < 0)) { + await page.locator('.iwb-editor-optionbar-body [data-opt-toggle="fill"][data-fill-owner="rect"]').click() +} +let pa = await imgToScreen(6, 6) +let pb = await imgToScreen(26, 26) +await page.mouse.move(pa.x, pa.y) +await page.mouse.down() +await page.mouse.move(pb.x, pb.y, { steps: 6 }) +await page.mouse.up() +await page.waitForTimeout(200) + +await page.locator('.iwb-editor-tool[data-tool="select"]').click() +pa = await imgToScreen(16, 16) +await page.mouse.click(pa.x, pa.y) +// 等过 380ms 的双击窗口:同一个点连点会被判成双击(双击属于「进对象编辑」, +// 不该接管拖动),这里要测的是单击选中后的拖动 +await page.waitForTimeout(420) +const rectGeo = await page.evaluate(() => { + const d = window.__iwbEditor.__debug() + const s = d.shapes[d.shapes.length - 1] + return s ? { id: s.id } : null +}) +const tol = await snapTol() +const sBox = await page.evaluate(() => { + const d = window.__iwbEditor.__debug() + const cv = [...document.querySelectorAll('.iwb-editor-canvas-stack > canvas.iwb-editor-vec-canvas')] + return { doc: d.doc, shapes: d.shapes.length } +}) +// 抓矩形中心,拖到「画布中心 + tol/2」:若吸附生效,中心会精确回到画布中心 +const rectInfo = await page.evaluate(() => { + const d = window.__iwbEditor.__debug() + const sel = d.selectedShapeId + return sel ? { sel, doc: d.doc } : { doc: d.doc } +}) +const center = { x: sBox.doc.w / 2, y: sBox.doc.h / 2 } +// 用轴对齐假设取矩形中心:从墨迹范围读更稳(矩形是自己画的 6..26) +const inkBox = await page.evaluate(() => { + const cv = [...document.querySelectorAll('.iwb-editor-canvas-stack > canvas.iwb-editor-vec-canvas')] + let best = null + for (const c of cv) { + const cx = c.getContext('2d') + const d = cx.getImageData(0, 0, c.width, c.height).data + let minX = 1e9, minY = 1e9, maxX = -1, maxY = -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] > 20) { if (x < minX) minX = x; if (x > maxX) maxX = x; if (y < minY) minY = y; if (y > maxY) maxY = y } + } + if (maxX >= 0) best = { minX, minY, maxX, maxY, w: maxX - minX + 1, h: maxY - minY + 1 } + } + return best +}) +const rc = { x: (inkBox.minX + inkBox.maxX + 1) / 2, y: (inkBox.minY + inkBox.maxY + 1) / 2 } +const grab = await imgToScreen(rc.x, rc.y) +const destImg = { x: center.x + tol / 2, y: center.y + tol / 2 } +const dest = await imgToScreen(destImg.x, destImg.y) +await page.mouse.move(grab.x, grab.y) +await page.mouse.down() +await page.mouse.move(grab.x + 3, grab.y + 3, { steps: 3 }) +await page.mouse.move(dest.x, dest.y, { steps: 8 }) +await page.waitForTimeout(160) +const gMid = (await dbg()).guides +await page.mouse.up() +await page.waitForTimeout(220) +const gEnd = (await dbg()).guides + +// 松手后按墨迹中心核对:应该正好落在画布中心 +const inkAfter = await page.evaluate(() => { + const cv = [...document.querySelectorAll('.iwb-editor-canvas-stack > canvas.iwb-editor-vec-canvas')] + let best = null + for (const c of cv) { + const cx = c.getContext('2d') + const d = cx.getImageData(0, 0, c.width, c.height).data + let minX = 1e9, minY = 1e9, maxX = -1, maxY = -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] > 20) { if (x < minX) minX = x; if (x > maxX) maxX = x; if (y < minY) minY = y; if (y > maxY) maxY = y } + } + if (maxX >= 0) best = { minX, minY, maxX, maxY } + } + return best +}) +const cAfter = { x: (inkAfter.minX + inkAfter.maxX + 1) / 2, y: (inkAfter.minY + inkAfter.maxY + 1) / 2 } +check('拖到画布中心附近会被精确吸附(中心误差 < 1px)', + gMid.length >= 1 && Math.abs(cAfter.x - center.x) < 1 && Math.abs(cAfter.y - center.y) < 1, + 'guides=' + JSON.stringify(gMid) + ' 中心=' + Math.round(cAfter.x) + ',' + Math.round(cAfter.y) + ' 期望=' + center.x + ',' + center.y) +check('松手后参考线清除', gEnd.length === 0, JSON.stringify(gEnd)) + +// Alt 拖动不吸附 +const grab2 = await imgToScreen(cAfter.x, cAfter.y) +await page.keyboard.down('Alt') +await page.mouse.move(grab2.x, grab2.y) +await page.mouse.down() +await page.mouse.move(grab2.x + 4, grab2.y + 4, { steps: 4 }) +await page.waitForTimeout(140) +const gAlt = (await dbg()).guides +await page.mouse.up() +await page.keyboard.up('Alt') +check('按住 Alt 拖动时不吸附(无参考线)', gAlt.length === 0, JSON.stringify(gAlt)) + +// 圆角:设半径后角落被切掉,墨迹变少 +// 所有矢量层墨迹的总和:前面用例画过别的矩形,只取「最大那层」会量错对象 +const inkCount = () => page.evaluate(() => { + const cv = [...document.querySelectorAll('.iwb-editor-canvas-stack > canvas.iwb-editor-vec-canvas')] + let total = 0 + for (const c of cv) { + const d = c.getContext('2d').getImageData(0, 0, c.width, c.height).data + for (let i = 3; i < d.length; i += 4) if (d[i] > 20) total++ + } + return total +}) +const inkSharp = await inkCount() +await page.evaluate(() => { + const el = document.querySelector('.iwb-editor-optionbar-body input[data-opt="shapeRadius"]') + el.value = '6' + el.dispatchEvent(new Event('input', { bubbles: true })) + el.dispatchEvent(new Event('change', { bubbles: true })) +}) +await page.waitForTimeout(220) +const inkRound = await inkCount() +const radiusVal = (await dbg()).shapes.map(s => s.radius).filter(r => r > 0) +check('矩形圆角生效(角落被切,墨迹减少)', + radiusVal.length === 1 && inkRound < inkSharp, + 'radius=' + JSON.stringify(radiusVal) + ' ink ' + inkSharp + '→' + inkRound) + +// 最近使用颜色 +await page.locator('[data-action="toggleColorPop"]').click() +await page.waitForTimeout(150) +await page.locator('.iwb-editor-color-pop [data-panel-color="#ffd400"]').first().click() +await page.waitForTimeout(200) +const recents = (await dbg()).recentColors +const recentsInPop = await page.locator('.iwb-editor-recent-colors [data-panel-color]').count() +await page.keyboard.press('Escape') +await page.waitForTimeout(120) +check('选过的颜色进入「最近使用」并出现在色板弹层', + recents[0] === '#ffd400' && recentsInPop >= 1, + JSON.stringify(recents) + ' 弹层色块=' + recentsInPop) + +// 复制到剪贴板:harness 跑在 about:blank(非安全上下文), +// 这里只验「按钮存在 + 点击有明确反馈 + 不抛错」,真安全上下文由本地 http 探针覆盖 +const copyExists = await page.locator('[data-action="copyClipboard"]').count() +await page.locator('[data-action="copyClipboard"]').click() +await page.waitForTimeout(400) +const copyToast = await page.locator('.iwb-editor-toast').textContent() +check('顶栏有「复制」且点击给出明确反馈(非静默失败)', + copyExists === 1 && /复制/.test(copyToast || ''), + 'toast=' + JSON.stringify(copyToast)) + check('无选中时 Ctrl+] 有 toast 提示(不再无声失败)', await (async () => { await page.keyboard.press('Escape') // 清掉可能残留的选中态 await page.keyboard.press('Control+]')