feat(image-annotate): 1.2.2 手柄仅选择工具/高亮跟随绘制目标/选项栏快捷点与裁剪参数/Enter-Esc 裁剪

This commit is contained in:
qiqi committed 2026-11-04 20:30:49 +08:00
1 parent 1bf8220c05
commit f50b734fd7
11 files changed
+340 -164

No files matched your search

+107 -81
View File
@@ -9,7 +9,7 @@
var __IWB_ANNOTATE_MANIFEST__ = {
id: 'image-annotate',
name: '标注 / 修图',
version: '1.2.1',
version: '1.2.2',
apiVersion: 1,
capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'],
settings: {
@@ -489,7 +489,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
ctx.lineTo(x2, y2);
ctx.stroke();
ctx.restore();
const active = getActiveLayer();
const active = getActiveLayer2();
if (active && active.id === "draw" && active.sourceCanvas) {
const sourceCtx = active.sourceCanvas.getContext("2d", { willReadFrequently: true });
sourceCtx.save();
@@ -518,7 +518,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
layer._bounds = void 0;
}
function beginStroke() {
bakeDrawableLayer(getActiveLayer());
bakeDrawableLayer(getActiveLayer2());
S.strokeCanvas.width = S.imgW;
S.strokeCanvas.height = S.imgH;
S.strokeCtx.clearRect(0, 0, S.imgW, S.imgH);
@@ -538,7 +538,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
ctx.drawImage(S.strokeCanvas, 0, 0);
ctx.restore();
S.strokeCanvas.style.display = "none";
const active = getActiveLayer();
const active = getActiveLayer2();
if (active && active.id === "draw" && active.sourceCanvas && active.w > 0 && active.h > 0) {
const sourceCtx = active.sourceCanvas.getContext("2d", { willReadFrequently: true });
sourceCtx.save();
@@ -1450,11 +1450,11 @@ var __IWB_ANNOTATE_MANIFEST__ = {
el.style.display = u.obj.visible === false ? "none" : "block";
}
}
function getActiveLayer() {
function getActiveLayer2() {
return S.layers.find((l) => l.id === S.activeLayerId) || null;
}
function getActiveCtx() {
const layer = getActiveLayer();
const layer = getActiveLayer2();
return layer && !layer.locked ? layer.ctx : null;
}
function clearSelection({ keepBitmap = false } = {}) {
@@ -1579,6 +1579,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
}
function drawBitmapSelection(layer) {
if (!layer) return;
if (S.tool !== "select") return;
const drawable = isDrawableLayer(layer);
if (!layer.transformable && !drawable) return;
const box = layerFrame(layer);
@@ -1716,7 +1717,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
placeImageDirectly(img);
}
function ensureWritableLayer() {
const current = getActiveLayer();
const current = getActiveLayer2();
if (current && !current.locked) return current;
const id = S.layers.some((l) => l.id === "draw") ? "L" + Date.now() + Math.floor(Math.random() * 1e3) : "draw";
const canvas = createLayerCanvas();
@@ -2422,7 +2423,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
return { canvas: c, x: e.x - pad, y: e.y - pad, w, h };
}
function writableLayer() {
const layer = getActiveLayer();
const layer = getActiveLayer2();
if (!layer || layer.locked) {
toast(layer && layer.locked ? "当前图层已锁定,请先解锁" : "没有可用的图层", "warn");
return null;
@@ -2694,11 +2695,9 @@ var __IWB_ANNOTATE_MANIFEST__ = {
<span class="iwb-editor-divider"></span>
<button class="iwb-editor-tool" data-tool="crop" title="裁剪"><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>
<button class="iwb-editor-tool" data-tool="crop" title="裁剪(参数在选项栏;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>
<span class="iwb-editor-divider"></span>
<button class="iwb-editor-fill-btn" data-action="toggleFill" title="矩形实心填充开关(选中矩形时切换即时生效)">实心</button>
</div>
<span class="iwb-editor-divider"></span>
@@ -2777,29 +2776,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
</div>
<input class="iwb-editor-text-input" type="text" placeholder="输入文字,Enter确认,Esc取消">
<div class="iwb-editor-picker-tip"><span class="iwb-editor-picker-chip"></span><span class="iwb-editor-picker-hex">#ffffff</span></div>
<div class="iwb-editor-crop-bar">
<div class="iwb-editor-crop-row"><div class="iwb-editor-constraint-group">
<span class="iwb-editor-constraint-label">比例</span>
<button class="iwb-editor-constraint-btn active" data-ratio="free">自由</button>
<button class="iwb-editor-constraint-btn" data-ratio="1:1">1:1</button>
<button class="iwb-editor-constraint-btn" data-ratio="4:3">4:3</button>
<button class="iwb-editor-constraint-btn" data-ratio="3:4">3:4</button>
<button class="iwb-editor-constraint-btn" data-ratio="16:9">16:9</button>
<button class="iwb-editor-constraint-btn" data-ratio="9:16">9:16</button>
</div></div>
<div class="iwb-editor-crop-row"><div class="iwb-editor-constraint-group">
<span class="iwb-editor-constraint-label">尺寸</span>
<input class="iwb-editor-size-input iwb-editor-size-w" type="number" min="1" placeholder="宽" value="800">
<span class="iwb-editor-size-x">×</span>
<input class="iwb-editor-size-input iwb-editor-size-h" type="number" min="1" placeholder="高" value="800">
<button class="iwb-editor-constraint-btn iwb-editor-size-toggle" data-action="toggleSizeConstraint" aria-pressed="false">启用尺寸</button>
<button class="iwb-editor-constraint-btn iwb-editor-size-apply" data-action="applySize">应用</button>
</div></div>
<div class="iwb-editor-crop-row iwb-editor-crop-actions"><span class="iwb-editor-crop-info">--</span>
<button class="iwb-editor-crop-confirm" data-action="confirmCrop">✓ 确认</button>
<button class="iwb-editor-crop-cancel" data-action="cancelCrop">✗ 取消</button>
</div>
</div>
<!-- 裁剪参数已迁入选项栏(v1.2.2),画布下方浮窗删除 -->
<div class="iwb-editor-sel-bar">
<span class="iwb-editor-sel-info">未框选</span>
<button data-sel-cmd="sel.copy" data-needs-sel="1" title="把当前图层选区复制为新图层 (Ctrl+J)">复制</button>
@@ -3104,14 +3081,18 @@ var __IWB_ANNOTATE_MANIFEST__ = {
return;
}
function onBrushMouseDown(pos) {
if (!ensureWritableLayer()) return;
const layer = ensureWritableLayer();
if (!layer) return;
S.selectedLayerId = layer.id;
S.isDrawing = true;
saveSnapshot();
beginStroke();
strokeSegment(pos.x, pos.y, pos.x, pos.y);
}
function onEraserMouseDown(pos) {
if (!getActiveCtx()) return;
const layer = getActiveLayer();
if (!layer || layer.locked) return;
S.selectedLayerId = layer.id;
S.isDrawing = true;
saveSnapshot();
beginStroke();
@@ -3695,9 +3676,34 @@ var __IWB_ANNOTATE_MANIFEST__ = {
<input type="range" class="iwb-opt-range" data-opt="${key}" min="${min}" max="${max}" step="1" value="${value}">
<input type="number" class="iwb-opt-num" data-opt="${key}" min="${min}" max="${max}" step="1" value="${value}">${unit ? `<span class="iwb-opt-unit">${unit}</span>` : ""}`;
}
function presetDots(key, values) {
return `<span class="iwb-opt-dots">${values.map((v) => `<button type="button" class="iwb-opt-dot" data-opt-preset="${key}" data-value="${v}" title="${v}"><i></i></button>`).join("")}</span>`;
}
function cropOptionHTML() {
const c = S.cropConstraint;
const sizeOn = c.type === "size";
return `<span class="iwb-opt-label">比例</span>
<button type="button" class="iwb-editor-constraint-btn${c.type === "free" ? " active" : ""}" data-ratio="free">自由</button>
<button type="button" class="iwb-editor-constraint-btn" data-ratio="1:1">1:1</button>
<button type="button" class="iwb-editor-constraint-btn" data-ratio="4:3">4:3</button>
<button type="button" class="iwb-editor-constraint-btn" data-ratio="3:4">3:4</button>
<button type="button" class="iwb-editor-constraint-btn" data-ratio="16:9">16:9</button>
<button type="button" class="iwb-editor-constraint-btn" data-ratio="9:16">9:16</button>
<span class="iwb-opt-label">尺寸</span>
<input type="number" class="iwb-editor-size-input iwb-editor-size-w" min="1" placeholder="宽" value="800">
<span class="iwb-opt-unit">×</span>
<input type="number" class="iwb-editor-size-input iwb-editor-size-h" min="1" placeholder="高" value="800">
<button type="button" class="iwb-editor-constraint-btn iwb-editor-size-toggle" data-action="toggleSizeConstraint" aria-pressed="${sizeOn}">启用尺寸</button>
<button type="button" class="iwb-editor-constraint-btn iwb-editor-size-apply" data-action="applySize">应用</button>
<span class="iwb-editor-crop-info">--</span>
<button type="button" class="iwb-editor-crop-confirm" data-action="confirmCrop" title="Enter">✓ 确认</button>
<button type="button" class="iwb-editor-crop-cancel" data-action="cancelCrop" title="Esc">✗ 取消</button>
<span class="iwb-opt-hint">拖出裁剪框;Enter 确认 · Esc 取消;裁剪后可 Ctrl+Z</span>`;
}
function optionBarHTML(tool) {
if (tool === "crop") return cropOptionHTML();
if (tool === "brush" || tool === "eraser") {
return rangeOpt("brushSize", "大小", 1, 300, S.brushSize, "") + `<span class="iwb-opt-label">硬度</span>
return rangeOpt("brushSize", "大小", 1, 300, S.brushSize, "") + presetDots("brushSize", [2, 4, 8, 12, 16, 24, 32]) + `<span class="iwb-opt-label">硬度</span>
<input type="range" class="iwb-opt-range" data-opt="brushHardness" min="0" max="100" step="1" value="${S.brushHardness}">
<span class="iwb-opt-val" data-opt-val="brushHardness">${S.brushHardness}</span>
<span class="iwb-opt-label">透明</span>
@@ -3705,12 +3711,12 @@ var __IWB_ANNOTATE_MANIFEST__ = {
<span class="iwb-opt-val" data-opt-val="brushOpacity">${Math.round(S.brushOpacity * 100)}%</span>`;
}
if (tool === "rect" || tool === "circle") {
return rangeOpt("shapeLineWidth", "线宽", 1, 60, S.shapeLineWidth, "") + `<span class="iwb-opt-label">样式</span>
return rangeOpt("shapeLineWidth", "线宽", 1, 60, S.shapeLineWidth, "") + presetDots("shapeLineWidth", [1, 2, 3, 6, 10, 16, 24]) + `<span class="iwb-opt-label">样式</span>
<button class="iwb-opt-btn${S.rectFill ? "" : " active"}" data-opt-toggle="stroke" data-value="stroke">描边</button>
<button class="iwb-opt-btn${S.rectFill ? " active" : ""}" data-opt-toggle="fill" data-value="fill">实心</button>`;
}
if (tool === "arrow" || tool === "pen") {
return rangeOpt("shapeLineWidth", "线宽", 1, 60, S.shapeLineWidth, "") + `<span class="iwb-opt-hint">${tool === "pen" ? "逐点点击,点回起点闭合" : "拖出箭头,松手完成"}</span>`;
return rangeOpt("shapeLineWidth", "线宽", 1, 60, S.shapeLineWidth, "") + presetDots("shapeLineWidth", [1, 2, 3, 6, 10, 16, 24]) + `<span class="iwb-opt-hint">${tool === "pen" ? "逐点点击,点回起点闭合" : "拖出箭头,松手完成"}</span>`;
}
if (tool === "text") {
return rangeOpt("textSize", "字号", 8, 400, S.textSize, "px") + '<span class="iwb-opt-hint">点画布输入文字,Enter 确认</span>';
@@ -3738,6 +3744,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
}
body.dataset.tool = S.tool;
body.innerHTML = optionBarHTML(S.tool);
if (S.tool === "crop") updateCropInfo();
syncOptionBar();
}
function syncOptionBar() {
@@ -3928,6 +3935,55 @@ var __IWB_ANNOTATE_MANIFEST__ = {
if (toggle) {
e.stopPropagation();
setShapeFill(toggle.dataset.value === "fill");
return;
}
const dot = e.target.closest("[data-opt-preset]");
if (dot) {
e.stopPropagation();
setOptionFromControl({ dataset: { opt: dot.dataset.optPreset }, value: dot.dataset.value }, true);
return;
}
const ratioBtn = e.target.closest("[data-ratio]");
if (ratioBtn) {
e.stopPropagation();
const ratio = parseRatio(ratioBtn.dataset.ratio);
body.querySelectorAll(".iwb-editor-constraint-btn[data-ratio]").forEach((b) => b.classList.toggle("active", b === ratioBtn));
setConstraint(ratio > 0 ? "ratio" : "free", ratio > 0 ? ratio : 0, 0, 0);
return;
}
if (e.target.closest('[data-action="toggleSizeConstraint"]')) {
e.stopPropagation();
if (S.cropConstraint.type === "size") {
setConstraint("free", 0, 0, 0);
} else {
const w = parseInt(body.querySelector(".iwb-editor-size-w").value, 10);
const h = parseInt(body.querySelector(".iwb-editor-size-h").value, 10);
if (w > 0 && h > 0) {
body.querySelectorAll(".iwb-editor-constraint-btn[data-ratio]").forEach((b) => b.classList.remove("active"));
setConstraint("size", w / h, w, h);
}
}
return;
}
if (e.target.closest('[data-action="applySize"]')) {
e.stopPropagation();
const w = parseInt(body.querySelector(".iwb-editor-size-w").value, 10);
const h = parseInt(body.querySelector(".iwb-editor-size-h").value, 10);
if (w > 0 && h > 0) {
body.querySelectorAll(".iwb-editor-constraint-btn[data-ratio]").forEach((b) => b.classList.remove("active"));
setConstraint("size", w / h, w, h);
}
return;
}
if (e.target.closest('[data-action="confirmCrop"]')) {
e.stopPropagation();
confirmCrop();
return;
}
if (e.target.closest('[data-action="cancelCrop"]')) {
e.stopPropagation();
cancelCrop();
return;
}
});
}
@@ -3952,7 +4008,6 @@ var __IWB_ANNOTATE_MANIFEST__ = {
function bindEvents() {
bindToolButtons();
bindColorPanel();
bindCropConstraintControls();
bindColorPalette();
bindFillToggle();
bindLayerOrderButtons();
@@ -3960,7 +4015,6 @@ var __IWB_ANNOTATE_MANIFEST__ = {
bindBrushParams();
bindZoomButtons();
bindHistoryActions();
bindCropActions();
bindLayerAddActions();
bindExportActions();
bindWheelZoom();
@@ -4059,39 +4113,6 @@ var __IWB_ANNOTATE_MANIFEST__ = {
});
}
}
function bindCropConstraintControls() {
runtime.el.querySelectorAll(".iwb-editor-constraint-btn[data-ratio]").forEach((btn) => {
btn.addEventListener("mousedown", (e) => e.stopPropagation());
btn.addEventListener("click", () => {
const r = btn.dataset.ratio;
runtime.el.querySelectorAll(".iwb-editor-constraint-btn[data-ratio]").forEach((b) => b.classList.remove("active"));
btn.classList.add("active");
const ratio = parseRatio(r);
if (ratio > 0) {
setConstraint("ratio", ratio, 0, 0);
} else {
setConstraint("free", 0, 0, 0);
}
});
});
const sizeToggle = runtime.el.querySelector('[data-action="toggleSizeConstraint"]');
if (sizeToggle) sizeToggle.addEventListener("click", () => {
if (S.cropConstraint.type === "size") setConstraint("free", 0, 0, 0);
else {
const w = parseInt(runtime.el.querySelector(".iwb-editor-size-w").value, 10), h = parseInt(runtime.el.querySelector(".iwb-editor-size-h").value, 10);
if (w > 0 && h > 0) setConstraint("size", w / h, w, h);
}
});
bindIf('[data-action="applySize"]', "mousedown", (e) => e.stopPropagation());
bindIf('[data-action="applySize"]', "click", () => {
const w = parseInt(runtime.el.querySelector(".iwb-editor-size-w").value, 10);
const h = parseInt(runtime.el.querySelector(".iwb-editor-size-h").value, 10);
if (w > 0 && h > 0) {
runtime.el.querySelectorAll(".iwb-editor-constraint-btn[data-ratio]").forEach((b) => b.classList.remove("active"));
setConstraint("size", w / h, w, h);
}
});
}
function bindColorPalette() {
runtime.el.querySelectorAll(".iwb-editor-color[data-color]").forEach((s) => {
s.addEventListener("mousedown", (e) => e.stopPropagation());
@@ -4203,10 +4224,6 @@ var __IWB_ANNOTATE_MANIFEST__ = {
resetBtn && resetBtn.addEventListener("click", resetDraw);
restoreBtn && restoreBtn.addEventListener("click", restoreOriginal);
}
function bindCropActions() {
bindIf('[data-action="confirmCrop"]', "click", confirmCrop);
bindIf('[data-action="cancelCrop"]', "click", cancelCrop);
}
function bindLayerAddActions() {
bindIf('[data-action="addBitmapLayer"]', "mousedown", (e) => e.stopPropagation());
bindIf('[data-action="addBitmapLayer"]', "click", () => {
@@ -4487,11 +4504,21 @@ var __IWB_ANNOTATE_MANIFEST__ = {
commitPenPath();
return;
}
if (e.key === "Enter" && S.tool === "crop" && S.cropRect) {
e.preventDefault();
confirmCrop();
return;
}
if (e.key === "Escape") {
if (isTyping(e)) {
hideTextInput();
return;
}
if (S.tool === "crop" && S.cropRect) {
e.preventDefault();
cancelCrop();
return;
}
if (S.marquee || S.lassoPts || S.selection && S.selection.active) {
e.preventDefault();
clearMarquee();
@@ -5231,10 +5258,8 @@ var __IWB_ANNOTATE_MANIFEST__ = {
updateCropInfo();
}
function showCropBar() {
runtime.el.querySelector(".iwb-editor-crop-bar").style.display = "flex";
}
function hideCropBar() {
runtime.el.querySelector(".iwb-editor-crop-bar").style.display = "none";
}
// image-annotate/plugin/editor/history.js
@@ -6058,6 +6083,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
selectedShapeId: S.selectedShapeId,
selectedTextId: S.selectedTextId,
activeLayerId: S.activeLayerId,
selectedLayerId: S.selectedLayerId,
selection: selectionInfo(),
toolOptions: {
brushSize: S.brushSize,
@@ -6092,7 +6118,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) {