feat(image-annotate): v1.13.0 顶栏瘦身 / 视图按钮归位 / R·O·L 快捷键 / 填充色实时 / 图层解封

1. 顶栏删掉置顶/上移/下移/置底四个层级按钮(图层拖动 + Ctrl+]/[ 已覆盖),
   `.iwb-editor-commands` 整块移除,`updateLayerUI()` / `bindLayerOrderButtons()` 一并清除。
2. 「适应窗口 / 收起侧栏」移到工具栏 DOM 末尾 —— 工具栏是 shrink-to-fit 的
   absolute 居中容器,放最后天然就在最右,无需额外定位。
3. 快捷键:R 矩形、O 圆形、L 箭头;套索从 L 迁到 A(能力不丢),U 与 Shift+U 保留。
   键盘处理改为优先匹配 e.code,修掉中文输入法下 [ ] 变【】导致的失灵。
4. 原生 <input type="color"> 补接 input 事件做实时预览(skipHistory +
   nativeColorSnapped),change 才落一次可撤销提交 —— 拖一整轮色谱只记 1 步。
5. 原图不再钉底:planPanelOrder / updateSortTarget / onSortEnd / moveLayer /
   mergeUnits 五处解封,其他图层可拖到原图下方,面板提示同步更新。

回归:tools/harness.mjs 140 → 192 条全通;npm run validate 9/9。
This commit is contained in:
qiqi committed 2026-11-08 22:26:47 +08:00
1 parent 9c938887c1
commit 31866a2407
11 files changed
+847 -242

No files matched your search

+228 -98
View File
@@ -9,7 +9,7 @@
var __IWB_ANNOTATE_MANIFEST__ = {
id: 'image-annotate',
name: '标注 / 修图',
version: '1.11.0',
version: '1.13.0',
apiVersion: 1,
capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'],
settings: {
@@ -1395,14 +1395,9 @@ var __IWB_ANNOTATE_MANIFEST__ = {
}
if (sel.obj.locked || sel.obj.id === "base") return;
const units = layerUnits();
const baseIdx = units.findIndex((u) => u.obj.id === "base");
if (baseIdx > 0) {
const [b] = units.splice(baseIdx, 1);
units.unshift(b);
}
const from = units.findIndex((u) => u.obj === sel.obj);
if (from < 0) return;
const min = baseIdx >= 0 ? 1 : 0;
const min = 0;
let to;
if (dir === "up") to = Math.min(from + 1, units.length - 1);
else if (dir === "down") to = Math.max(from - 1, min);
@@ -1647,7 +1642,6 @@ var __IWB_ANNOTATE_MANIFEST__ = {
const penShape = getPenEditingShape();
if (penShape) drawPenEditOverlay(penShape);
if (S.cropRect) drawCropPreview();
updateLayerUI();
}
function getPenEditingShape() {
if (!S.penEditId) return null;
@@ -2422,7 +2416,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
const delSvg = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>';
const pct = opacityPct(item.opacity);
const canRename = item.type === "bitmap";
const sortHint = item.id === "base" ? "原图(固定在最底层)" : "拖动调整叠放顺序";
const sortHint = item.id === "base" ? "原图(其他图层可以拖到它下面)" : "拖动调整叠放顺序";
html += `<div class="iwb-layer-item${activeClass}${multiClass}${visClass}" data-layer-id="${item.id}" data-layer-type="${item.type}">
<div class="iwb-layer-row">
<button class="iwb-layer-vis" data-vis-id="${item.id}" data-vis-type="${item.type}" title="${item.visible ? "隐藏" : "显示"}">${visSvg}</button>
@@ -2460,11 +2454,6 @@ var __IWB_ANNOTATE_MANIFEST__ = {
ordered.push(u);
}
if (!ordered.length || byKey.size) return null;
const baseIdx = ordered.findIndex((u) => u.obj.id === "base");
if (baseIdx > 0) {
const [b] = ordered.splice(baseIdx, 1);
ordered.unshift(b);
}
const before = units.map((u) => u.obj.id).join("|");
return { ordered, changed: before !== ordered.map((u) => u.obj.id).join("|") };
}
@@ -2531,9 +2520,8 @@ var __IWB_ANNOTATE_MANIFEST__ = {
if (d.y < lr.top + 18) list.scrollTop -= 8;
else if (d.y > lr.bottom - 18) list.scrollTop += 8;
const rows = Array.from(list.querySelectorAll(".iwb-layer-item"));
const baseEl = rows.find((el) => el.dataset.layerId === "base") || null;
const movable = rows.filter((el) => el !== baseEl && el !== d.item);
let anchor = baseEl || null;
const movable = rows.filter((el) => el !== d.item);
let anchor = null;
for (const el of movable) {
const r2 = el.getBoundingClientRect();
if (d.y < r2.top + r2.height / 2) {
@@ -2558,9 +2546,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
if (!d.active) return;
const rows = Array.from(d.list.querySelectorAll(".iwb-layer-item"));
const keyOf = (el) => el.dataset.layerType + ":" + el.dataset.layerId;
const baseEl = rows.find((el) => el.dataset.layerId === "base") || null;
const desc = rows.filter((el) => el !== baseEl).map(keyOf);
if (baseEl) desc.push(keyOf(baseEl));
const desc = rows.map(keyOf);
if (d.type === "bitmap") {
if (S.layers.some((l) => l.id === d.id)) S.selectedLayerId = d.id;
} else if (d.type === "text" || d.type === "shape") {
@@ -2885,6 +2871,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
const chosenSet = new Set(sorted.map((u) => u.obj));
const insertAt = all.slice(0, Math.max(lowIdx, 0)).filter((u) => !chosenSet.has(u.obj)).length;
let carrier;
const baseZ = baseUnit ? baseUnit.obj.z || 0 : 0;
if (baseUnit) {
carrier = baseUnit.obj;
carrier.image = null;
@@ -2902,7 +2889,8 @@ var __IWB_ANNOTATE_MANIFEST__ = {
composeUnitsInto(carrier, sorted);
for (const u of sorted) if (u.obj !== carrier) dropUnit(u);
const rest = layerUnits().filter((u) => u.obj !== carrier);
rest.unshift({ kind: "bitmap", obj: carrier });
const at = rest.filter((u) => (u.obj.z || 0) < baseZ).length;
rest.splice(Math.min(at, rest.length), 0, { kind: "bitmap", obj: carrier });
assignLayerZ(rest);
} else {
const canvas = createLayerCanvas();
@@ -3465,21 +3453,10 @@ var __IWB_ANNOTATE_MANIFEST__ = {
<button class="iwb-editor-action" data-action="redo" title="重做 (Ctrl+Shift+Z)"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/></svg></button>
<button class="iwb-editor-action iwb-editor-action-reset" data-action="reset" title="还原原图:删掉所有标注/图层,回到打开时的样子(Ctrl+Z 可撤销)"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 2v6h-6"/><path d="M3 12a9 9 0 0 1 15-6.7L21 8"/><path d="M3 22v-6h6"/><path d="M21 12a9 9 0 0 1-15 6.7L3 16"/></svg></button>
</div>
<span class="iwb-editor-divider"></span>
<!-- 顶栏命令带(v1.2.6):撤销/重做/还原 | 顺序 | 视图;图层新建/导入回图层面板标题栏 -->
<div class="iwb-editor-commands">
<div class="iwb-editor-cmdgroup" data-group="order" title="调整选中元素的图层顺序">
<button class="iwb-editor-layer-btn" data-layer="top" title="置顶:选中元素移到最上层 (Ctrl+Shift+])"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="5" x2="20" y2="5"/><line x1="12" y1="19" x2="12" y2="5"/><polyline points="6 11 12 5 18 11"/></svg></button>
<button class="iwb-editor-layer-btn" data-layer="up" title="上移一层 (Ctrl+])"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="19" x2="12" y2="5"/><polyline points="6 11 12 5 18 11"/></svg></button>
<button class="iwb-editor-layer-btn" data-layer="down" title="下移一层 (Ctrl+[)"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"/><polyline points="6 13 12 19 18 13"/></svg></button>
<button class="iwb-editor-layer-btn" data-layer="bottom" title="置底:选中元素移到最下层 (Ctrl+Shift+[)"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"/><polyline points="6 13 12 19 18 13"/><line x1="4" y1="19" x2="20" y2="19"/></svg></button>
</div>
<span class="iwb-editor-divider"></span>
<div class="iwb-editor-cmdgroup" data-group="view">
<button class="iwb-editor-action" data-action="zoomFit" title="适应窗口 (Ctrl+0)"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 3 3 3 3 9"/><polyline points="15 3 21 3 21 9"/><polyline points="3 15 3 21 9 21"/><polyline points="21 15 21 21 15 21"/></svg></button>
<button class="iwb-editor-action" data-action="togglePanels" title="收起 / 展开侧栏 (Tab)"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="16" rx="2"/><line x1="9" y1="4" x2="9" y2="20"/></svg></button>
</div>
</div>
<!-- 顶栏命令带已清空(v1.13):
四个「置顶/上移/下移/置底」按钮删除(图层面板可拖动 + Ctrl+]/[ 已覆盖);
「适应窗口 / 收起侧栏」搬到画布底部工具栏最右侧,离画布更近。
整个 .iwb-editor-commands 容器一并移除,不留一条空分隔线。 -->
<div class="iwb-editor-export-actions">
<div class="iwb-editor-export-settings-wrap">
@@ -3564,20 +3541,23 @@ var __IWB_ANNOTATE_MANIFEST__ = {
<button data-sel-cmd="sel.none" title="取消选区 (Esc / Ctrl+D)">取消</button>
</div>
<div class="iwb-editor-tools">
<!-- 颜色(v1.11):描边 + 填充 两个槽叠放在一个按钮位里(PS 式前/背景色)。
点哪个槽就调哪个:色板只有一套,写谁由 S.colorTarget 决定。
这样全项目只有「描边色 / 填充色」两个颜色概念,不再有第三个主色。
填充块在无填充时画斜杠,跟随描边色时带一个小三角角标。 -->
<!-- 颜色(v1.11 两格 → v1.12 文字三格):
形状下是「描边 + 填充」两格叠放在一个按钮位里(PS 式前/背景色);
文字下是「文字 / 描边 / 底色」三格横排 —— 文字对象天生就有三个颜色,
只给两格必然有一格无处安放(用户反馈「文本不支持描边与字体色切换」)。
点哪格就调哪格:色板只有一套,写谁由 S.colorTarget 决定。
关掉的那格画斜杠,跟随描边色的填充块带一个小三角角标。 -->
<div class="iwb-editor-color-pair" data-color-mode="single">
<button type="button" class="iwb-editor-color-btn" data-color-slot="stroke" data-action="toggleColorPop" aria-expanded="false" title="描边色:形状描边 / 画笔 / 文字都用它。点开色板调色"><i></i></button>
<button type="button" class="iwb-editor-color-btn" data-color-slot="fill" data-action="toggleColorPop" aria-expanded="false" title="填充色:形状内部颜色。点开色板调色,色板里可切换「无填充」"><i></i></button>
<button type="button" class="iwb-editor-color-btn" data-color-slot="bg" data-action="toggleColorPop" aria-expanded="false" title="文本框底色:垫在文字下面的一块半透明色板。点开调色,可选「无」"><i></i></button>
</div>
<span class="iwb-editor-divider"></span>
<button class="iwb-editor-tool" data-tool="select" title="选择/移动 (V):点击元素选中,拖拽移动,手柄调整大小,双击文字改内容"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z"/></svg></button>
<span class="iwb-editor-divider"></span>
<button class="iwb-editor-tool" data-tool="marquee" title="选框 (M):拖出矩形/椭圆选区,松手后旁边出现操作条;Shift+M 切换矩形/椭圆"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="4 3"><rect x="3" y="4" width="18" height="16" rx="1"/></svg></button>
<button class="iwb-editor-tool" data-tool="lasso" title="套索 (L):按住拖动自由圈选,松手闭合"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12c0-4 3.6-7 8-7s8 3 8 7-3.6 7-8 7c-2 0-3.8-.6-5.2-1.6"/><path d="M6.8 17.4 4 20l1.2-3.2"/><circle cx="20" cy="19" r="2"/></svg></button>
<button class="iwb-editor-tool" data-tool="lasso" title="套索 (A):按住拖动自由圈选,松手闭合"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12c0-4 3.6-7 8-7s8 3 8 7-3.6 7-8 7c-2 0-3.8-.6-5.2-1.6"/><path d="M6.8 17.4 4 20l1.2-3.2"/><circle cx="20" cy="19" r="2"/></svg></button>
<button class="iwb-editor-tool active" data-tool="brush" title="画笔 (B):] 增大 / [ 减小笔刷;按住 Alt 临时吸色"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg></button>
@@ -3587,11 +3567,11 @@ var __IWB_ANNOTATE_MANIFEST__ = {
<button class="iwb-editor-tool" data-tool="text" title="文字 (T)"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 7 4 3 20 3 20 7"/><line x1="9" y1="20" x2="15" y2="20"/><line x1="12" y1="3" x2="12" y2="20"/></svg></button>
<button class="iwb-editor-tool" data-tool="rect" title="矩形 (U):Shift+U 在矩形/圆形/箭头间循环"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/></svg></button>
<button class="iwb-editor-tool" data-tool="rect" title="矩形 (R):Shift+U 在矩形/圆形/箭头间循环"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/></svg></button>
<button class="iwb-editor-tool" data-tool="circle" title="圆形 (U):Shift+U 在矩形/圆形/箭头间循环"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="8"/></svg></button>
<button class="iwb-editor-tool" data-tool="circle" title="圆形 (O):Shift+U 在矩形/圆形/箭头间循环"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="8"/></svg></button>
<button class="iwb-editor-tool" data-tool="arrow" title="箭头 (U):Shift+U 在矩形/圆形/箭头间循环"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/></svg></button>
<button class="iwb-editor-tool" data-tool="arrow" title="箭头 (L):Shift+U 在矩形/圆形/箭头间循环"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/></svg></button>
<button class="iwb-editor-tool" data-tool="picker" title="吸管 (I):点击画布取色(悬停预览);选中形状/文字时取色直接改它的颜色,取完切回上一工具"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m2 22 1-1h3l9-9"/><path d="M3 21v-3l9-9"/><path d="m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3Z"/></svg></button>
@@ -3601,7 +3581,11 @@ var __IWB_ANNOTATE_MANIFEST__ = {
<button class="iwb-editor-tool" data-tool="crop" title="裁剪 (C):参数在选项栏;Enter 确认 / Esc 取消"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6.13 1L6 16a2 2 0 0 0 2 2h15"/><path d="M1 6.13L16 6a2 2 0 0 1 2 2v15"/></svg></button>
<!-- 视图快捷(v1.13):从顶栏搬过来,贴在工具条最右侧的「|」之后。
工具条本身是 shrink-to-fit 且居中,所以这一组天然就是「最右边」。 -->
<span class="iwb-editor-divider"></span>
<button class="iwb-editor-tool iwb-editor-view-btn" data-action="zoomFit" title="适应窗口 (Ctrl+0):整张图缩放到刚好放得下"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 3 3 3 3 9"/><polyline points="15 3 21 3 21 9"/><polyline points="3 15 3 21 9 21"/><polyline points="21 15 21 21 15 21"/></svg></button>
<button class="iwb-editor-tool iwb-editor-view-btn" data-action="togglePanels" title="收起 / 展开侧栏 (Tab)"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="16" rx="2"/><line x1="9" y1="4" x2="9" y2="20"/></svg></button>
</div>
</div>
<div class="iwb-editor-zoom-hint">滚轮缩放 · 抓手/空格/中键拖拽自由移动画布</div>
@@ -3671,12 +3655,13 @@ var __IWB_ANNOTATE_MANIFEST__ = {
必须挂在 modal 下、不能塞进 .iwb-editor-tools —— 工具栏是 overflow-x:auto,
canvas-wrap 是 overflow:clip,塞进去弹层会被直接裁掉;定位由 events.js 计算。 -->
<div class="iwb-editor-color-pop" hidden>
<!-- 弹层头部(v1.11):标明「现在调的是哪个颜色」,并可直接切换。
与工具栏那两个色块是同一组槽位,两边高亮完全一致。
「无」只对填充有意义:描边关掉会让形状彻底消失,不是用户要的。 -->
<!-- 弹层头部(v1.11 两格 → v1.12 文字三格):标明「现在调的是哪个颜色」,
并可直接切换。与工具栏那几个色块是同一组槽位,两边高亮完全一致。
「无」只对「可以没有」的颜色有意义:文字色没有无,描边/底色/填充才有。 -->
<div class="iwb-color-pop-head">
<button type="button" class="iwb-color-pop-tab active" data-color-slot="stroke" title="正在调描边色(形状描边 / 画笔 / 文字色)"><i></i><span class="iwb-color-pop-tab-label">描边</span></button>
<button type="button" class="iwb-color-pop-tab" data-color-slot="fill" title="正在调填充色(形状内部颜色)"><i></i><span class="iwb-color-pop-tab-label">填充</span></button>
<button type="button" class="iwb-color-pop-tab" data-color-slot="fill" title="正在调填充色(形状内部颜色 / 文字描边色)"><i></i><span class="iwb-color-pop-tab-label">填充</span></button>
<button type="button" class="iwb-color-pop-tab" data-color-slot="bg" hidden title="正在调文本框底色(垫在文字下面)"><i></i><span class="iwb-color-pop-tab-label">底色</span></button>
<button type="button" class="iwb-color-pop-none" data-color-none="1" title="无填充:形状内部透明,只留描边"><span></span>无</button>
</div>
<div class="iwb-color-pop-body">
@@ -4767,7 +4752,6 @@ var __IWB_ANNOTATE_MANIFEST__ = {
updateBrushUI();
updateBrushParamUI();
updateFillUI();
updateLayerUI();
updateZoomUI();
hidePickerTip();
runtime.el.querySelectorAll(".iwb-editor-constraint-btn[data-ratio]").forEach((b) => b.classList.remove("active"));
@@ -4830,37 +4814,87 @@ var __IWB_ANNOTATE_MANIFEST__ = {
layer.canvas.style.cursor = cur;
}
};
function fillSlotOn() {
function colorContext() {
const t = getSelectedText();
if (t || S.tool === "text") return { kind: "text", text: t || null };
const sh = getSelectedShape();
if (sh) return sh.type === "rect" || sh.type === "circle" || sh.type === "pen" && !!sh.closed;
return S.tool === "rect" || S.tool === "circle" || S.tool === "pen";
if (sh) return { kind: sh.type === "arrow" ? "strokeOnly" : "shape", shape: sh };
if (S.tool === "rect" || S.tool === "circle" || S.tool === "pen") return { kind: "shape", shape: null };
return { kind: "strokeOnly", shape: null };
}
function fillSlotOn() {
const ctx = colorContext();
if (ctx.kind === "text") return true;
if (ctx.kind !== "shape") return false;
const sh = ctx.shape;
if (!sh) return true;
return sh.type === "rect" || sh.type === "circle" || sh.type === "pen" && !!sh.closed;
}
function textColorSlots(t) {
const color = (t ? t.color : S.color) || S.color;
const strokeColor = (t ? t.strokeColor : S.textStrokeColor) || TEXT_DEFAULTS.strokeColor;
const sw = Number(t ? t.strokeWidth : S.textStrokeWidth) || 0;
const bgColor = (t ? t.bgColor : S.textBgColor) || TEXT_DEFAULTS.bgColor;
const bgFill = !!(t ? t.bgFill : S.textBgFill);
const bgAlpha = Number(t ? t.bgAlpha == null ? TEXT_DEFAULTS.bgAlpha : t.bgAlpha : S.textBgAlpha) || TEXT_DEFAULTS.bgAlpha;
return {
mode: "text",
stroke: color,
fill: strokeColor,
fillOn: sw > 0,
follow: false,
bg: bgColor,
bgOn: bgFill,
bgAlpha,
strokeName: "文字",
fillName: "描边",
bgName: "底色"
};
}
function colorSlots() {
const sh = getSelectedShape();
const ctx = colorContext();
if (ctx.kind === "text") return textColorSlots(ctx.text);
const sh = ctx.shape;
const stroke = sh && sh.color || S.color;
const rawFill = sh ? sh.fillColor || null : S.shapeFillColor;
const fillOn = sh ? sh.type === "pen" ? !!sh.fill && !!sh.closed : !!sh.fill : S.tool === "pen" ? !!S.penFill : !!S.rectFill;
return { stroke, fill: rawFill || stroke, fillOn, follow: !rawFill };
return {
mode: ctx.kind === "shape" ? "shape" : "single",
stroke,
fill: rawFill || stroke,
fillOn,
follow: !rawFill,
bg: null,
bgOn: false,
bgAlpha: 1,
strokeName: "描边",
fillName: "填充",
bgName: "底色"
};
}
function activeColor() {
const sl = colorSlots();
return S.colorTarget === "fill" ? sl.fill : sl.stroke;
if (S.colorTarget === "bg") return sl.bg || sl.stroke;
if (S.colorTarget === "fill" && fillSlotOn()) return sl.fill || sl.stroke;
return sl.stroke;
}
function updateColorUI() {
const sl = colorSlots();
const fillable = fillSlotOn();
if (!fillable && S.colorTarget === "fill") S.colorTarget = "stroke";
const isText = sl.mode === "text";
const second = isText ? true : fillSlotOn();
if (S.colorTarget !== "stroke" && !second) S.colorTarget = "stroke";
if (S.colorTarget === "bg" && !isText) S.colorTarget = "stroke";
const pair = runtime.el.querySelector(".iwb-editor-color-pair");
if (pair) pair.dataset.colorMode = fillable ? "pair" : "single";
if (pair) pair.dataset.colorMode = isText ? "triple" : second ? "pair" : "single";
const strokeBtn = runtime.el.querySelector('.iwb-editor-color-btn[data-color-slot="stroke"]');
const fillBtn = runtime.el.querySelector('.iwb-editor-color-btn[data-color-slot="fill"]');
const textCtx = S.tool === "text" || !!S.selectedTextId && S.tool === "select";
const strokeName = textCtx ? "文字" : S.tool === "brush" || S.tool === "eraser" ? "画笔" : "描边";
const bgBtn = runtime.el.querySelector('.iwb-editor-color-btn[data-color-slot="bg"]');
const strokeName = isText ? "文字" : S.tool === "brush" || S.tool === "eraser" ? "画笔" : "描边";
if (strokeBtn) {
const dot = strokeBtn.querySelector("i");
if (dot) dot.style.backgroundColor = sl.stroke;
strokeBtn.classList.toggle("active", S.colorTarget === "stroke");
strokeBtn.title = fillable ? `描边色 ${sl.stroke.toUpperCase()}:形状描边也用这个值。点开色板调色` : `${strokeName}色 ${sl.stroke.toUpperCase()}:点开色板调色`;
strokeBtn.title = isText ? `文字色 ${String(sl.stroke).toUpperCase()}:改文字本身的颜色(右边「描边」是字的外描边)` : second ? `描边色 ${String(sl.stroke).toUpperCase()}:形状描边也用这个值。点开色板调色` : `${strokeName}色 ${String(sl.stroke).toUpperCase()}:点开色板调色`;
const popEl = runtime.el.querySelector(".iwb-editor-color-pop");
strokeBtn.setAttribute("aria-expanded", String(!!(popEl && !popEl.hidden && S.colorTarget === "stroke")));
}
@@ -4870,25 +4904,50 @@ var __IWB_ANNOTATE_MANIFEST__ = {
fillBtn.classList.toggle("is-none", !sl.fillOn);
fillBtn.classList.toggle("is-follow", sl.follow && sl.fillOn);
fillBtn.classList.toggle("active", S.colorTarget === "fill");
fillBtn.title = !sl.fillOn ? "填充:无(形状内部透明)。点开色板选色即可填充" : sl.follow ? "填充色:跟随描边色 " + sl.fill.toUpperCase() + ",点开可单独指定" : "填充色 " + sl.fill.toUpperCase() + ",点开调色";
const fc = String(sl.fill).toUpperCase();
fillBtn.title = isText ? sl.fillOn ? `文字描边色 ${fc}:沿字形外沿描一圈。点开调色,「无」= 去掉描边` : "文字描边:无(描边宽度 0)。点开选色会自动给 6px 描边" : !sl.fillOn ? "填充:无(形状内部透明)。点开色板选色即可填充" : sl.follow ? "填充色:跟随描边色 " + fc + ",点开可单独指定" : "填充色 " + fc + ",点开调色";
}
if (bgBtn) {
const dot = bgBtn.querySelector("i");
if (dot) {
dot.style.backgroundColor = sl.bg || "transparent";
dot.style.opacity = sl.bgOn ? String(sl.bgAlpha) : "";
}
bgBtn.classList.toggle("is-none", !sl.bgOn);
bgBtn.classList.toggle("active", S.colorTarget === "bg");
bgBtn.title = sl.bgOn ? `文本框底色 ${String(sl.bg || "").toUpperCase()}(${Math.round(sl.bgAlpha * 100)}% 不透明):垫在文字下面,「无」= 去掉底色` : "文本框底色:无(透明)。点开选色会自动开启底色";
bgBtn.setAttribute("aria-expanded", String(!!(runtime.el.querySelector(".iwb-editor-color-pop:not([hidden])") && S.colorTarget === "bg")));
}
runtime.el.querySelectorAll(".iwb-color-pop-tab").forEach((tab) => {
const isFill = tab.dataset.colorSlot === "fill";
tab.classList.toggle("active", S.colorTarget === (isFill ? "fill" : "stroke"));
const slot = tab.dataset.colorSlot;
const isFill = slot === "fill";
const isBg = slot === "bg";
tab.classList.toggle("active", S.colorTarget === slot);
const dot = tab.querySelector("i");
if (dot) dot.style.backgroundColor = isFill ? sl.fill : sl.stroke;
if (dot) {
dot.style.backgroundColor = isBg ? sl.bg || "transparent" : isFill ? sl.fill : sl.stroke;
if (isBg) dot.style.opacity = sl.bgOn ? String(sl.bgAlpha) : "";
}
const label = tab.querySelector(".iwb-color-pop-tab-label");
if (label) label.textContent = isFill ? "填充" : fillable ? "描边" : strokeName;
if (label) label.textContent = isBg ? "底色" : isFill ? isText ? "描边" : "填充" : strokeName;
tab.title = isBg ? "正在调文本框底色(垫在文字下面)" : isFill ? isText ? "正在调文字描边色(沿字形外沿)" : "正在调填充色(形状内部颜色)" : isText ? "正在调文字色(文字本身的颜色)" : "正在调描边色";
if (isFill) {
tab.classList.toggle("is-none", !sl.fillOn);
tab.hidden = !fillable;
tab.hidden = !second;
}
if (isBg) {
tab.classList.toggle("is-none", !sl.bgOn);
tab.hidden = !isText;
}
});
const noneBtn = runtime.el.querySelector("[data-color-none]");
if (noneBtn) {
const show = fillable && S.colorTarget === "fill";
const onBg = S.colorTarget === "bg" && isText;
const onFill = S.colorTarget === "fill" && second;
const show = onBg || onFill;
noneBtn.hidden = !show;
noneBtn.classList.toggle("active", show && !sl.fillOn);
noneBtn.classList.toggle("active", show && (onBg ? !sl.bgOn : !sl.fillOn));
noneBtn.title = onBg ? "无底色:文字后面完全透明" : isText ? "无描边:把描边宽度置 0,只留文字本身" : "无填充:形状内部透明,只留描边";
}
const cur = activeColor();
let matchPreset = false;
@@ -4940,12 +4999,6 @@ var __IWB_ANNOTATE_MANIFEST__ = {
const b = runtime.el.querySelector('[data-action="toggleFill"]');
if (b) b.classList.toggle("active", !!S.rectFill);
}
function updateLayerUI() {
const hasSel = !!(S.selectedTextId || S.selectedShapeId || S.layers.some((l) => l.id === S.selectedLayerId && l.id !== "base" && !l.locked));
runtime.el.querySelectorAll(".iwb-editor-layer-btn").forEach((b) => {
b.disabled = !hasSel;
});
}
var TOOL_NAMES = {
select: "选择 / 移动",
marquee: "框选",
@@ -5076,7 +5129,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
}
const text = getSelectedText();
if (text) {
return `<span class="iwb-opt-current">已选中:文字</span>` + rangeOpt("textSize", "字号", 8, 400, Math.round(text.fontSize || S.textSize), "px") + textStyleHTML(text) + '<span class="iwb-opt-hint">双击改内容 · 拖动手柄缩放</span>';
return `<span class="iwb-opt-current">已选中:文字</span>` + rangeOpt("textSize", "字号", 8, 400, Math.round(text.fontSize || S.textSize), "px") + textStyleHTML(text) + '<span class="iwb-opt-hint">双击改内容 · 拖动手柄缩放 · 左上三格 = 文字色 / 描边 / 底色</span>';
}
return `<span class="iwb-opt-current">当前工具:选择 / 移动</span>` + selCmdHTML() + '<span class="iwb-opt-hint">点中矩形/圆形/钢笔/文字后,这里出现它的描边、实心与粗细</span>';
}
@@ -5290,6 +5343,47 @@ var __IWB_ANNOTATE_MANIFEST__ = {
renderObjects();
if (committed) radiusSnapDone = false;
}
var textColorSnapDone = false;
function applyTextColor(key, color, opts) {
const skipHistory = !!(opts && opts.skipHistory);
const stateKey = TEXT_STYLE_STATE_KEY[key];
if (!stateKey) return;
const hex = String(color || "").toLowerCase();
if (!/^#[0-9a-f]{6}$/.test(hex)) return;
if (!skipHistory) rememberColor(hex);
S[stateKey] = hex;
if (key === "strokeColor" && !(Number(S.textStrokeWidth) > 0)) S.textStrokeWidth = 6;
if (key === "bgColor" && !S.textBgFill) S.textBgFill = true;
const t = getSelectedText();
if (t && !t.locked) {
if (!skipHistory && !textColorSnapDone) {
saveSnapshot("文字颜色");
textColorSnapDone = true;
}
t[key] = hex;
if (key === "strokeColor" && !(Number(t.strokeWidth) > 0)) t.strokeWidth = S.textStrokeWidth;
if (key === "bgColor" && !t.bgFill) t.bgFill = true;
renderObjects();
}
updateColorUI();
if (skipHistory) {
syncOptionBarSoon();
return;
}
textColorSnapDone = false;
syncOptionBar();
}
function applyColorNone() {
const sl = colorSlots();
if (sl.mode === "text") {
if (S.colorTarget === "bg") applyTextStyle("bgFill", "0", true);
else if (S.colorTarget === "fill") applyTextStyle("strokeWidth", 0, true);
updateColorUI();
syncOptionBar();
return;
}
applyShapeColor("none");
}
function applyShapeColor(kind, raw, opts) {
const skipHistory = !!(opts && opts.skipHistory);
const sh = getSelectedShape();
@@ -5337,6 +5431,21 @@ var __IWB_ANNOTATE_MANIFEST__ = {
else syncOptionBar();
}
function applyPanelColor(color, opts) {
const sl = colorSlots();
if (sl.mode === "text") {
if (S.colorTarget === "fill") {
applyTextColor("strokeColor", color, opts);
return;
}
if (S.colorTarget === "bg") {
applyTextColor("bgColor", color, opts);
return;
}
applyColorChange(color, opts);
if (opts && opts.skipHistory) syncOptionBarSoon();
else syncOptionBar();
return;
}
if (S.colorTarget === "fill" && fillSlotOn()) {
applyShapeColor("fill", color, opts);
return;
@@ -5347,7 +5456,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
else syncOptionBar();
}
function setColorTarget(slot) {
S.colorTarget = slot === "fill" ? "fill" : "stroke";
S.colorTarget = slot === "fill" ? "fill" : slot === "bg" ? "bg" : "stroke";
updateColorUI();
}
var optionBarSyncRaf = 0;
@@ -5475,19 +5584,42 @@ var __IWB_ANNOTATE_MANIFEST__ = {
const body = root.querySelector(".iwb-editor-optionbar-body");
if (body) {
body.addEventListener("mousedown", (e) => e.stopPropagation());
body.addEventListener("input", (e) => setOptionFromControl(e.target, false));
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();
let nativeColorSnapped = false;
const nativeColorOf = (t) => t && t.closest ? t.closest("[data-shape-color]") || t.closest("[data-opt-color]") : null;
const applyNativeColor = (el, preview) => {
const isShape = el.hasAttribute("data-shape-color");
const key = isShape ? el.dataset.shapeColor : el.dataset.optColor;
if (!nativeColorSnapped) {
const t = getSelectedText(), sh = getSelectedShape();
if (t && !t.locked || sh && !sh.locked) {
saveSnapshot(isShape ? "填充颜色" : "文字颜色");
nativeColorSnapped = true;
}
}
if (isShape) applyShapeColor(key, el.value, { skipHistory: true });
else applyTextColor(key, el.value, { skipHistory: true });
if (preview) {
syncOptionBarSoon();
return;
}
const shapeColorEl = e.target.closest ? e.target.closest("[data-shape-color]") : null;
if (shapeColorEl) {
if (nativeColorSnapped) rememberColor(String(el.value || "").toLowerCase());
nativeColorSnapped = false;
syncOptionBar();
};
body.addEventListener("input", (e) => {
const colorEl = nativeColorOf(e.target);
if (colorEl) {
e.stopPropagation();
applyShapeColor(shapeColorEl.dataset.shapeColor, shapeColorEl.value);
applyNativeColor(colorEl, true);
return;
}
setOptionFromControl(e.target, false);
});
body.addEventListener("change", (e) => {
const colorEl = nativeColorOf(e.target);
if (colorEl) {
e.stopPropagation();
applyNativeColor(colorEl, false);
return;
}
setOptionFromControl(e.target, true);
@@ -5593,7 +5725,6 @@ var __IWB_ANNOTATE_MANIFEST__ = {
bindColorPanel();
bindColorPalette();
bindFillToggle();
bindLayerOrderButtons();
bindZoomButtons();
bindHistoryActions();
bindLayerAddActions();
@@ -5637,7 +5768,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
function toggleColorPop(slot) {
const pop = runtime.el.querySelector(".iwb-editor-color-pop");
if (!pop) return;
const want = slot === "fill" ? "fill" : "stroke";
const want = slot === "fill" ? "fill" : slot === "bg" ? "bg" : "stroke";
if (!pop.hidden && S.colorTarget === want) {
closeColorPop();
return;
@@ -5682,7 +5813,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
const none = e.target.closest("[data-color-none]");
if (none) {
e.stopPropagation();
applyShapeColor("none");
applyColorNone();
return;
}
});
@@ -5838,12 +5969,6 @@ var __IWB_ANNOTATE_MANIFEST__ = {
}
});
}
function bindLayerOrderButtons() {
runtime.el.querySelectorAll(".iwb-editor-layer-btn").forEach((btn) => {
btn.addEventListener("mousedown", (e) => e.stopPropagation());
btn.addEventListener("click", () => moveLayer(btn.dataset.layer));
});
}
function bindZoomButtons() {
bindIf('[data-action="zoomOut"]', "click", (e) => {
e.stopPropagation();
@@ -6179,11 +6304,14 @@ var __IWB_ANNOTATE_MANIFEST__ = {
const letterTools = {
v: "select",
m: "marquee",
l: "lasso",
a: "lasso",
l: "arrow",
b: "brush",
e: "eraser",
p: "pen",
t: "text",
r: "rect",
o: "circle",
u: "rect",
c: "crop",
i: "picker",
@@ -7970,6 +8098,8 @@ var __IWB_ANNOTATE_MANIFEST__ = {
},
// 矢量图形颜色:fillColor=null 表示跟随描边色(回归要能断言这条语义)
shapeColors: { stroke: S.color, fill: S.shapeFillColor || null },
// 色板当前在调哪一格:stroke / fill / bg(文字上下文里 fill=描边、bg=底色)
colorTarget: S.colorTarget,
selectedShapeId: S.selectedShapeId,
// 光标所在的图片坐标(状态栏同源):换算问题的第一现场证据
lastPos: S.lastPos ? { x: Math.round(S.lastPos.x), y: Math.round(S.lastPos.y) } : null,
@@ -8069,7 +8199,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-edLine truncated
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-edLine truncated
// image-annotate/plugin/glue.js
function createGlue(ctx, css) {