feat(image-annotate): v1.7.0 图层面板补齐(缩略图 / 重命名 / 不透明度)
按通读代码后定的顺序处理 P3 剩余项里最有价值的三条。
1) 不透明度真正可调
opacity 字段一直在(合成/合并/导出/快照都读它),但面板没有任何控件能写它,
roadmap 里标的「已有」与事实不符。现在选中层后在该项下方展开滑杆:
- 位图走 canvas 的 CSS opacity(像素不动),导出/合并时乘 globalAlpha,所见即所得
- 文字/形状改完重绘矢量层(不透明度已烘进像素,不能再叠 CSS)
- input 第一次到达才拍快照,一次拖动只产生 1 条历史;双击滑杆复位 100%
- 非 100% 且未选中的层在名字旁挂百分比角标
2) 缩略图 + 双击重命名
- 22px 缩略图(canvas 44 设备像素),等比缩放居中;空图层透出类型图标兜底
- 绘制合批 90ms,避免每次 renderLayerPanel 都重画几十张
- 双击名字改名(Enter 提交 / Esc 放弃),改名期间禁用整项拖动
3) 顺手清理
- 删除 .iwb-layer-color / .iwb-layer-width 两个永远看不见的死控件
(CSS display:none !important 写了三遍),连同绑定与死样式
- pasteImageFromUrl 的 window.alert 改 toast(阻塞弹窗在宿主里会卡整页)
- resetState() 补清 layerMulti / hoverPos / lastClick / lastNameClick / altPicker
关键修正:矢量层不透明度只能乘一次。
drawVectorToCanvas / drawShape 已把 opacity 画进像素,getCompositeCanvas 与
composeUnitsInto 再乘 globalAlpha 就是双倍透明 —— 两处都改为只对位图乘。
验证:harness 133 项全通(新增 4 项)、validate 9/9、产物 331811 B。
harness 的版本断言改为读 package.json,不再硬编码。
This commit is contained in:
1 parent
7c2e23e4e3
commit
3e76f2792e
11 files changed
+593
-105
No files matched your search
+172
-47
@@ -9,7 +9,7 @@
|
||||
var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
id: 'image-annotate',
|
||||
name: '标注 / 修图',
|
||||
version: '1.6.0',
|
||||
version: '1.7.0',
|
||||
apiVersion: 1,
|
||||
capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'],
|
||||
settings: {
|
||||
@@ -44,6 +44,9 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
hoverPos: null,
|
||||
lastClick: null,
|
||||
// 上一次画布按下 {t,x,y}:自算双击用(dblclick 在画布上不可靠)
|
||||
// 上一次点击图层名 {id,t}:图层面板重命名也走自算双击(点一下就会重绘面板,
|
||||
// 浏览器不会在同一个节点上派发 dblclick)
|
||||
lastNameClick: null,
|
||||
altPicker: false,
|
||||
// 按住 Alt 的临时吸管(画笔/橡皮下),松开 Alt 回到原工具
|
||||
pickerComposite: null,
|
||||
@@ -673,7 +676,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
if (u.obj.visible === false) continue;
|
||||
const el = u.kind === "bitmap" ? u.obj.canvas : u.obj._canvas;
|
||||
if (!el) continue;
|
||||
cx.globalAlpha = u.obj.opacity == null ? 1 : u.obj.opacity;
|
||||
cx.globalAlpha = u.kind === "bitmap" ? u.obj.opacity == null ? 1 : u.obj.opacity : 1;
|
||||
cx.drawImage(el, 0, 0);
|
||||
}
|
||||
cx.globalAlpha = 1;
|
||||
@@ -1837,8 +1840,10 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
redrawBitmapLayer(layer);
|
||||
}
|
||||
function setActiveLayer(id) {
|
||||
const changed = S.activeLayerId !== id || S.selectedLayerId !== id;
|
||||
S.activeLayerId = id;
|
||||
selectUnit("bitmap", id);
|
||||
if (!changed) return;
|
||||
renderLayerPanel();
|
||||
renderObjects();
|
||||
}
|
||||
@@ -1995,6 +2000,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
layer.canvas.style.height = h + "px";
|
||||
layer.canvas.style.left = offset + "px";
|
||||
layer.canvas.style.top = offset + "px";
|
||||
layer.canvas.style.opacity = String(layer.opacity == null ? 1 : layer.opacity);
|
||||
}
|
||||
styleVectorViewport(w, h, offset);
|
||||
}
|
||||
@@ -2007,6 +2013,26 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
obj._canvas.style.top = offset + "px";
|
||||
}
|
||||
}
|
||||
function esc(v) {
|
||||
return String(v == null ? "" : v).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
||||
}
|
||||
function opacityPct(v) {
|
||||
const n = v == null ? 1 : v;
|
||||
return Math.max(0, Math.min(100, Math.round(n * 100)));
|
||||
}
|
||||
function findPanelTarget(type, id) {
|
||||
if (type === "bitmap") return S.layers.find((l) => l.id === id) || null;
|
||||
if (type === "text") return S.textLayers.find((t) => t.id === id) || null;
|
||||
if (type === "shape") return S.shapeLayers.find((s) => s.id === id) || null;
|
||||
return null;
|
||||
}
|
||||
function applyOpacityVisual(type, obj) {
|
||||
if (type === "bitmap" && obj && obj.canvas) {
|
||||
obj.canvas.style.opacity = String(obj.opacity == null ? 1 : obj.opacity);
|
||||
return;
|
||||
}
|
||||
if (type === "text" || type === "shape") renderObjects();
|
||||
}
|
||||
function renderLayerPanel() {
|
||||
const list = runtime.el.querySelector(".iwb-editor-layer-list");
|
||||
if (!list) return;
|
||||
@@ -2070,17 +2096,26 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
const visSvg = item.visible ? '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>' : '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" y1="2" x2="22" y2="22"/></svg>';
|
||||
const lockSvg = item.locked ? '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="10" width="14" height="10" rx="2"/><path d="M8 10V7a4 4 0 0 1 8 0v3"/></svg>' : '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="10" width="14" height="10" rx="2"/><path d="M8 10V7a4 4 0 0 1 7-2"/></svg>';
|
||||
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";
|
||||
html += `<div class="iwb-layer-item${activeClass}${multiClass}${visClass}" draggable="${item.id !== "base"}" data-layer-id="${item.id}" data-layer-type="${item.type}">
|
||||
<button class="iwb-layer-vis" data-vis-id="${item.id}" data-vis-type="${item.type}" title="${item.visible ? "隐藏" : "显示"}">${visSvg}</button>
|
||||
<span class="iwb-layer-icon">${typeIconSvg}</span>
|
||||
<span class="iwb-layer-name">${item.name}</span>${item.paintTarget ? '<span class="iwb-layer-paint" title="当前画笔 / 橡皮作用图层">✎</span>' : ""}
|
||||
${item.type === "bitmap" || item.type === "shape" ? `<input class="iwb-layer-color" type="color" value="${item.color}" data-color-id="${item.id}" data-color-type="${item.type}" title="调整颜色">` : ""}
|
||||
${item.type === "bitmap" || item.type === "shape" ? `<input class="iwb-layer-width" type="number" min="1" max="300" value="${Math.round(item.lineWidth)}" data-width-id="${item.id}" data-width-type="${item.type}" title="调整边框粗细">` : ""}
|
||||
<button class="iwb-layer-lock${item.locked ? " active" : ""}" data-lock-id="${item.id}" data-lock-type="${item.type}" title="${item.locked ? "解锁图层" : "锁定图层"}">${lockSvg}</button>
|
||||
${item.canDelete ? `<button class="iwb-layer-del" data-del-id="${item.id}" data-del-type="${item.type}" title="删除图层">${delSvg}</button>` : ""}
|
||||
<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>
|
||||
<span class="iwb-layer-thumb"><canvas width="44" height="44" data-thumb-id="${item.id}" data-thumb-type="${item.type}"></canvas><span class="iwb-layer-icon">${typeIconSvg}</span></span>
|
||||
<span class="iwb-layer-name${canRename ? " renamable" : ""}" data-name-id="${item.id}" data-name-type="${item.type}" title="${esc(item.name)}${canRename ? " · 双击重命名" : ""}">${esc(item.name)}</span>
|
||||
${item.paintTarget ? '<span class="iwb-layer-paint" title="当前画笔 / 橡皮作用图层">✎</span>' : ""}
|
||||
${pct < 100 && !item.active ? `<span class="iwb-layer-op" title="不透明度 ${pct}%(选中该层可调)">${pct}%</span>` : ""}
|
||||
<button class="iwb-layer-lock${item.locked ? " active" : ""}" data-lock-id="${item.id}" data-lock-type="${item.type}" title="${item.locked ? "解锁图层" : "锁定图层"}">${lockSvg}</button>
|
||||
${item.canDelete ? `<button class="iwb-layer-del" data-del-id="${item.id}" data-del-type="${item.type}" title="删除图层">${delSvg}</button>` : ""}
|
||||
</div>
|
||||
${item.active ? `<div class="iwb-layer-op-row">
|
||||
<input class="iwb-layer-opacity" type="range" min="0" max="100" step="1" value="${pct}" data-op-id="${item.id}" data-op-type="${item.type}" title="不透明度:拖动调整,双击复位 100%">
|
||||
<span class="iwb-layer-op-val">${pct}%</span>
|
||||
</div>` : ""}
|
||||
</div>`;
|
||||
}
|
||||
list.innerHTML = html;
|
||||
scheduleThumbs();
|
||||
const fxTarget = runtime.el.querySelector(".iwb-editor-fx-target");
|
||||
if (fxTarget) {
|
||||
const active = getActiveLayer();
|
||||
@@ -2116,7 +2151,8 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
const list = runtime.el.querySelector(".iwb-editor-layer-list");
|
||||
if (!list) return;
|
||||
bindLayerItemEvents(list);
|
||||
bindLayerStyleInputs(list);
|
||||
bindLayerNameRename(list);
|
||||
bindLayerOpacityInputs(list);
|
||||
bindLayerVisButtons(list);
|
||||
bindLayerLockButtons(list);
|
||||
bindLayerDelButtons(list);
|
||||
@@ -2140,6 +2176,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
});
|
||||
item.addEventListener("click", (e) => {
|
||||
if (e.target.closest(".iwb-layer-vis") || e.target.closest(".iwb-layer-lock") || e.target.closest(".iwb-layer-del")) return;
|
||||
if (e.target.closest(".iwb-layer-opacity") || e.target.closest(".iwb-layer-name-input") || e.target.closest(".iwb-layer-op-row")) return;
|
||||
const id = item.dataset.layerId;
|
||||
const type = item.dataset.layerType;
|
||||
if (e.metaKey || e.ctrlKey) {
|
||||
@@ -2159,46 +2196,123 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
});
|
||||
});
|
||||
}
|
||||
function bindLayerStyleInputs(list) {
|
||||
list.querySelectorAll(".iwb-layer-color").forEach((input) => {
|
||||
input.addEventListener("mousedown", (e) => e.stopPropagation());
|
||||
input.addEventListener("input", (e) => {
|
||||
function bindLayerNameRename(list) {
|
||||
list.querySelectorAll(".iwb-layer-name.renamable").forEach((el) => {
|
||||
el.addEventListener("mousedown", (e) => {
|
||||
e.stopPropagation();
|
||||
const id = input.dataset.colorId;
|
||||
const type = input.dataset.colorType;
|
||||
const obj = type === "bitmap" ? S.layers.find((l) => l.id === id) : S.shapeLayers.find((s) => s.id === id);
|
||||
if (obj) {
|
||||
obj.color = input.value;
|
||||
S.color = input.value;
|
||||
updateColorUI();
|
||||
renderObjects();
|
||||
renderLayerPanel();
|
||||
S.pickerComposite = null;
|
||||
const id = el.dataset.nameId;
|
||||
const now = Date.now();
|
||||
const prev = S.lastNameClick;
|
||||
if (prev && prev.id === id && now - prev.t < 400) {
|
||||
S.lastNameClick = null;
|
||||
beginRename(id);
|
||||
return;
|
||||
}
|
||||
S.lastNameClick = { id, t: now };
|
||||
});
|
||||
});
|
||||
list.querySelectorAll(".iwb-layer-width").forEach((input) => {
|
||||
}
|
||||
function beginRename(id) {
|
||||
const list = runtime.el.querySelector(".iwb-editor-layer-list");
|
||||
const layer = S.layers.find((l) => l.id === id);
|
||||
if (!list || !layer) return;
|
||||
const item = list.querySelector('.iwb-layer-item[data-layer-id="' + id + '"]');
|
||||
const span = item && item.querySelector(".iwb-layer-name");
|
||||
if (!span || !span.parentNode) return;
|
||||
const input = document.createElement("input");
|
||||
input.className = "iwb-layer-name-input";
|
||||
input.type = "text";
|
||||
input.value = layer.name;
|
||||
input.maxLength = 40;
|
||||
span.replaceWith(input);
|
||||
item.draggable = false;
|
||||
let done = false;
|
||||
const finish = (commit) => {
|
||||
if (done) return;
|
||||
done = true;
|
||||
const next = input.value.trim();
|
||||
if (commit && next && next !== layer.name) {
|
||||
saveSnapshot("重命名图层");
|
||||
layer.name = next;
|
||||
}
|
||||
renderLayerPanel();
|
||||
};
|
||||
input.addEventListener("mousedown", (e) => e.stopPropagation());
|
||||
input.addEventListener("click", (e) => e.stopPropagation());
|
||||
input.addEventListener("keydown", (e) => {
|
||||
e.stopPropagation();
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
finish(true);
|
||||
} else if (e.key === "Escape") {
|
||||
e.preventDefault();
|
||||
finish(false);
|
||||
}
|
||||
});
|
||||
input.addEventListener("blur", () => finish(true));
|
||||
input.focus();
|
||||
input.select();
|
||||
}
|
||||
function bindLayerOpacityInputs(list) {
|
||||
list.querySelectorAll(".iwb-layer-opacity").forEach((input) => {
|
||||
input.addEventListener("mousedown", (e) => e.stopPropagation());
|
||||
input.addEventListener("click", (e) => e.stopPropagation());
|
||||
input.addEventListener("dblclick", (e) => {
|
||||
e.stopPropagation();
|
||||
input.value = "100";
|
||||
applyOpacityFromInput(input);
|
||||
});
|
||||
input.addEventListener("input", (e) => {
|
||||
e.stopPropagation();
|
||||
const id = input.dataset.widthId;
|
||||
const type = input.dataset.widthType;
|
||||
const value = clamp(parseInt(input.value, 10) || 1, 1, 300);
|
||||
const obj = type === "bitmap" ? S.layers.find((l) => l.id === id) : S.shapeLayers.find((s) => s.id === id);
|
||||
if (obj) {
|
||||
obj.lineWidth = value;
|
||||
if (type === "shape") obj.lw = value;
|
||||
else {
|
||||
S.brushSize = value;
|
||||
refreshBrushRing();
|
||||
}
|
||||
renderObjects();
|
||||
updateBrushParamUI();
|
||||
renderLayerPanel();
|
||||
}
|
||||
applyOpacityFromInput(input);
|
||||
});
|
||||
});
|
||||
}
|
||||
function applyOpacityFromInput(input) {
|
||||
const type = input.dataset.opType;
|
||||
const obj = findPanelTarget(type, input.dataset.opId);
|
||||
if (!obj) return;
|
||||
const pct = clamp(parseInt(input.value, 10) || 0, 0, 100);
|
||||
if (!input._opSnapTaken) {
|
||||
input._opSnapTaken = true;
|
||||
saveSnapshot("调整不透明度");
|
||||
}
|
||||
obj.opacity = pct / 100;
|
||||
applyOpacityVisual(type, obj);
|
||||
S.pickerComposite = null;
|
||||
const val = input.parentNode && input.parentNode.querySelector(".iwb-layer-op-val");
|
||||
if (val) val.textContent = pct + "%";
|
||||
}
|
||||
var _thumbTimer = 0;
|
||||
function scheduleThumbs() {
|
||||
if (_thumbTimer) return;
|
||||
_thumbTimer = setTimeout(() => {
|
||||
_thumbTimer = 0;
|
||||
paintThumbs();
|
||||
}, 90);
|
||||
}
|
||||
function paintThumbs() {
|
||||
if (!runtime.el) return;
|
||||
const list = runtime.el.querySelector(".iwb-editor-layer-list");
|
||||
if (!list) return;
|
||||
list.querySelectorAll(".iwb-layer-thumb canvas").forEach((cv) => {
|
||||
const type = cv.dataset.thumbType;
|
||||
const obj = findPanelTarget(type, cv.dataset.thumbId);
|
||||
const src = obj ? type === "bitmap" ? obj.canvas : obj._canvas : null;
|
||||
const g = cv.getContext("2d");
|
||||
if (!g) return;
|
||||
g.clearRect(0, 0, cv.width, cv.height);
|
||||
if (!src || !src.width || !src.height) return;
|
||||
const k = Math.min(cv.width / src.width, cv.height / src.height);
|
||||
const dw = Math.max(1, Math.round(src.width * k));
|
||||
const dh = Math.max(1, Math.round(src.height * k));
|
||||
try {
|
||||
g.imageSmoothingQuality = "high";
|
||||
g.drawImage(src, Math.round((cv.width - dw) / 2), Math.round((cv.height - dh) / 2), dw, dh);
|
||||
} catch (e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
function bindLayerVisButtons(list) {
|
||||
list.querySelectorAll(".iwb-layer-vis").forEach((btn) => {
|
||||
btn.addEventListener("mousedown", (e) => e.stopPropagation());
|
||||
@@ -2293,7 +2407,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
for (const u of units) {
|
||||
const el = u.kind === "bitmap" ? u.obj.canvas : u.obj._canvas;
|
||||
if (!el || el.nodeType !== 1) continue;
|
||||
tctx.globalAlpha = u.obj.opacity == null ? 1 : u.obj.opacity;
|
||||
tctx.globalAlpha = u.kind === "bitmap" ? u.obj.opacity == null ? 1 : u.obj.opacity : 1;
|
||||
tctx.drawImage(el, 0, 0);
|
||||
}
|
||||
tctx.globalAlpha = 1;
|
||||
@@ -5310,10 +5424,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
addBitmapLayer(await loadImage(dataUrl));
|
||||
} catch (err) {
|
||||
console.error("[IWB编辑器] 粘贴图片链接失败:", err);
|
||||
try {
|
||||
window.alert("粘贴失败:" + (err && err.message || "无法读取剪贴板里的图片链接"));
|
||||
} catch (e) {
|
||||
}
|
||||
toast("粘贴失败:" + (err && err.message || "无法读取剪贴板里的图片链接"), "error");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6578,6 +6689,11 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
S.penDragPending = null;
|
||||
S.selectedLayerId = null;
|
||||
S.bitmapDrag = null;
|
||||
S.layerMulti.length = 0;
|
||||
S.hoverPos = null;
|
||||
S.lastClick = null;
|
||||
S.lastNameClick = null;
|
||||
S.altPicker = false;
|
||||
S.zCounter = Math.max(S.layers.length - 1, 0);
|
||||
S.placingImage = null;
|
||||
S.placingHandle = null;
|
||||
@@ -6726,7 +6842,16 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
doc: { w: S.imgW, h: S.imgH },
|
||||
zoom: S.zoom,
|
||||
fit: { w: Math.round(S.fitW || 0), h: Math.round(S.fitH || 0) },
|
||||
layers: S.layers.map((l) => ({ id: l.id, name: l.name, z: l.z, locked: !!l.locked, visible: l.visible !== false })),
|
||||
layers: S.layers.map((l) => ({
|
||||
id: l.id,
|
||||
name: l.name,
|
||||
z: l.z,
|
||||
locked: !!l.locked,
|
||||
visible: l.visible !== false,
|
||||
// 不透明度有两个面:数据字段(导出/合并用)与 CSS(屏幕上看到的),两者必须一致
|
||||
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,
|
||||
@@ -6786,7 +6911,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) {
|
||||
|
||||
Reference in new issue
Block a user