feat(image-annotate): 1.2.4 选择态就地改形状参数(描边/实心/线宽) + 顶栏命令带(更多菜单图标化: 新建/导入图层、置顶/上/下/置底、适应窗口、收起侧栏) + 选区命令入竖工具条
This commit is contained in:
1 parent
b83b8f3755
commit
77b4f7d5fe
8 files changed
+307
-147
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@iwb-plugin/image-annotate",
|
||||
"private": true,
|
||||
"version": "1.2.3",
|
||||
"version": "1.2.4",
|
||||
"description": "IWB 插件:图片标注 / 修图(编辑器移植自 iwb-plaus 扩展,纯 Canvas 2D)",
|
||||
"ibwPlugin": {
|
||||
"id": "image-annotate",
|
||||
|
||||
@@ -1546,3 +1546,26 @@
|
||||
/* ---- v1.2.3:侧栏只留调色板 + 缩放 ---- */
|
||||
/* 笔刷粗细/快捷点从侧栏移除后,缩放条直接挂在 aside 下:贴底,与调色板拉开距离 */
|
||||
.iwb-editor-left > .iwb-editor-zoom { margin-top: auto; border-top: 1px solid #313244; padding-top: 10px; }
|
||||
|
||||
/* ================================================================
|
||||
v1.2.4:顶栏命令带(原「更多 ▾」图标化)
|
||||
布局:标题 | 撤销·重做·还原 | ⟨图层 新建/导入⟩ ⟨顺序 置顶/上移/下移/置底⟩ ⟨视图 适应/侧栏⟩ | …… | 输出·下载·新建·覆盖·退出
|
||||
================================================================ */
|
||||
.iwb-editor-header > .iwb-editor-history { order: 1; }
|
||||
.iwb-editor-header > .iwb-editor-commands { order: 3; display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
|
||||
.iwb-editor-header > .iwb-editor-commands .iwb-editor-divider { width: 1px; height: 20px; background: #313244; flex: 0 0 auto; }
|
||||
.iwb-editor-cmdgroup { display: flex; align-items: center; gap: 4px; }
|
||||
.iwb-editor-cmdgroup[data-group="order"] { gap: 2px; }
|
||||
/* 顶栏里的命令按钮统一 30×30 方角,和撤销/重做同款 */
|
||||
.iwb-editor-header > .iwb-editor-commands .iwb-editor-action,
|
||||
.iwb-editor-header > .iwb-editor-commands .iwb-editor-layer-btn {
|
||||
width: 30px; height: 30px; min-width: 30px; padding: 0; border: 0; border-radius: 8px;
|
||||
background: #313244; color: #cdd6f4;
|
||||
display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
|
||||
}
|
||||
.iwb-editor-header > .iwb-editor-commands .iwb-editor-action:hover:not(:disabled),
|
||||
.iwb-editor-header > .iwb-editor-commands .iwb-editor-layer-btn:hover:not(:disabled) { background: #45475a; }
|
||||
.iwb-editor-header > .iwb-editor-commands .iwb-editor-layer-btn:disabled { opacity: 0.35; cursor: not-allowed; }
|
||||
/* 竖工具条里的选区命令(全选/反选/取消)与工具按钮区分一点点:命令用中性色底 */
|
||||
.iwb-editor-header > .iwb-editor-tools .iwb-editor-selcmd { background: #26263a; }
|
||||
.iwb-editor-header > .iwb-editor-tools .iwb-editor-selcmd:hover { background: #45475a; }
|
||||
@@ -25,25 +25,35 @@ import { bindEvents } from './events.js'
|
||||
<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"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg></button>
|
||||
</div>
|
||||
<div class="iwb-editor-more-wrap">
|
||||
<button class="iwb-editor-more-btn" data-action="toggleMore" aria-expanded="false">更多 ▾</button>
|
||||
<div class="iwb-editor-more-menu">
|
||||
<button data-more="sel.all">全选 <kbd>Ctrl+A</kbd></button>
|
||||
<button data-more="sel.invert">反选 <kbd>Ctrl+Shift+I</kbd></button>
|
||||
<button data-more="sel.none">取消选区 <kbd>Esc</kbd></button>
|
||||
<span class="iwb-editor-more-sep"></span>
|
||||
<button data-more="addBlankLayer">新建空白图层</button>
|
||||
<button data-more="addBitmapLayer">导入图片为图层</button>
|
||||
<button data-more="zoomFit">适应窗口</button>
|
||||
<button data-more="reset">还原原图</button>
|
||||
<span class="iwb-editor-more-sep"></span>
|
||||
<button data-action="togglePanels">收起 / 展开侧栏</button>
|
||||
<!-- 顶栏命令带(v1.2.4):原「更多 ▾」菜单全部铺开成图标,按 图层 / 顺序 / 视图 分三组 -->
|
||||
<div class="iwb-editor-commands">
|
||||
<div class="iwb-editor-cmdgroup" data-group="layers">
|
||||
<button class="iwb-editor-action" data-action="addBlankLayer" title="新建空白图层"><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"/><line x1="12" y1="8" x2="12" y2="16"/><line x1="8" y1="12" x2="16" y2="12"/></svg></button>
|
||||
<button class="iwb-editor-action" data-action="addBitmapLayer" title="导入图片为图层(也可直接 ⌘/Ctrl+V 粘贴剪贴板图片)"><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"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.1-3.1a2 2 0 0 0-2.8 0L6 21"/><line x1="19" y1="8" x2="19" y2="14"/><line x1="22" y1="11" x2="16" y2="11"/></svg></button>
|
||||
</div>
|
||||
<span class="iwb-editor-divider"></span>
|
||||
<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="适应窗口"><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="收起 / 展开侧栏(画布优先)"><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>
|
||||
<button class="iwb-editor-panel-toggle" data-action="togglePanels" title="收起 / 展开侧栏(画布优先)">⇥</button>
|
||||
<div class="iwb-editor-tools">
|
||||
<button class="iwb-editor-tool" data-tool="select" 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="M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z"/></svg></button>
|
||||
|
||||
<!-- 选区命令紧跟「选择」工具(用户裁定 2026-11-04:从「更多」里拿出来,不再藏二级) -->
|
||||
<button class="iwb-editor-tool iwb-editor-selcmd" data-more="sel.all" title="全选 (Ctrl+A)"><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="3 2"><rect x="3.5" y="3.5" width="17" height="17" rx="1"/></svg></button>
|
||||
<button class="iwb-editor-tool iwb-editor-selcmd" data-more="sel.invert" title="反选 (Ctrl+Shift+I)"><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.5" y="3.5" width="17" height="17" rx="1" stroke-dasharray="3 2"/><rect x="8" y="8" width="8" height="8" rx="1" fill="currentColor" stroke="none"/></svg></button>
|
||||
<button class="iwb-editor-tool iwb-editor-selcmd" data-more="sel.none" title="取消选区 (Esc / Ctrl+D)"><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.5" y="3.5" width="17" height="17" rx="1" stroke-dasharray="3 2"/><line x1="4" y1="20" x2="20" y2="4"/></svg></button>
|
||||
|
||||
<span class="iwb-editor-divider"></span>
|
||||
|
||||
<button class="iwb-editor-tool" data-tool="marquee" title="框选:拖出矩形/椭圆选区,松手后旁边出现操作条(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>
|
||||
|
||||
@@ -71,7 +81,6 @@ import { bindEvents } from './events.js'
|
||||
|
||||
<span class="iwb-editor-divider"></span>
|
||||
</div>
|
||||
<span class="iwb-editor-divider"></span>
|
||||
|
||||
<div class="iwb-editor-export-actions">
|
||||
<div class="iwb-editor-export-settings-wrap">
|
||||
@@ -121,19 +130,10 @@ import { bindEvents } from './events.js'
|
||||
<div class="iwb-editor-layer-panel">
|
||||
<div class="iwb-editor-layer-panel-header">
|
||||
<span class="iwb-editor-layer-panel-title">图层</span>
|
||||
<div class="iwb-editor-layer-add-group">
|
||||
<button class="iwb-editor-layer-add-btn" data-action="addBitmapLayer" title="导入图片为新图层(也可直接 ⌘/Ctrl+V 粘贴剪贴板图片)"><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="3" y="3" width="18" height="18" rx="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.1-3.1a2 2 0 0 0-2.8 0L6 21"/><line x1="19" y1="8" x2="19" y2="14"/><line x1="22" y1="11" x2="16" y2="11"/></svg></button>
|
||||
<button class="iwb-editor-layer-add-btn" data-action="addBlankLayer" title="新建空白图层"><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="3" y="3" width="18" height="18" rx="2"/><line x1="12" y1="8" x2="12" y2="16"/><line x1="8" y1="12" x2="16" y2="12"/></svg></button>
|
||||
</div>
|
||||
<!-- 新建图层 / 导入图片已上移到顶栏命令带(v1.2.4),面板只留标题,避免同一功能两个入口 -->
|
||||
</div>
|
||||
|
||||
<div class="iwb-editor-layer-group" title="调整选中元素的图层顺序">
|
||||
<span class="iwb-editor-constraint-label">图层</span>
|
||||
<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>
|
||||
<!-- 图层顺序(置顶/上移/下移/置底)已移到顶栏命令带(v1.2.4) -->
|
||||
<div class="iwb-editor-layer-list"></div>
|
||||
</div>
|
||||
<div class="iwb-editor-canvas-wrap">
|
||||
|
||||
@@ -859,9 +859,41 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
<button class="iwb-opt-btn${fill ? ' active' : ''}" data-opt-toggle="fill" data-fill-owner="${owner}" data-value="fill">实心</button>`
|
||||
}
|
||||
|
||||
const SHAPE_NAMES = { rect: '矩形', circle: '圆形', arrow: '箭头', pen: '钢笔路径' }
|
||||
|
||||
/** 选择工具:只有选中了元素才出该元素的参数。
|
||||
* 用户裁定 2026-11-04:选中矩形/钢笔后要能就地切描边/实心、改描边粗细,
|
||||
* 不必再切回绘制工具 —— 所以这里复用绘制工具同一套控件与写回路径。 */
|
||||
function selectOptionHTML() {
|
||||
const sh = getSelectedShape()
|
||||
if (sh) {
|
||||
const t = sh.type
|
||||
if (t === 'rect' || t === 'circle' || t === 'pen' || t === 'arrow') {
|
||||
const owner = t === 'pen' ? 'pen' : 'rect'
|
||||
const lw = Math.max(1, Math.round(sh.lw || S.shapeLineWidth))
|
||||
return `<span class="iwb-opt-current">已选中:${SHAPE_NAMES[t] || t}</span>`
|
||||
+ rangeOpt('shapeLineWidth', '线宽', 1, 60, lw, '')
|
||||
+ presetDots('shapeLineWidth', [1, 2, 3, 6, 10, 16, 24])
|
||||
+ (t === 'arrow' ? '' : fillStyleHTML(owner))
|
||||
+ (t === 'pen' && !sh.closed
|
||||
? '<span class="iwb-opt-hint">这条钢笔路径未闭合,实心不生效;点回起点闭合后即可填充</span>'
|
||||
: '')
|
||||
}
|
||||
}
|
||||
const text = getSelectedText()
|
||||
if (text) {
|
||||
return `<span class="iwb-opt-current">已选中:文字</span>`
|
||||
+ rangeOpt('textSize', '字号', 8, 400, Math.round(text.fontSize || S.textSize), 'px')
|
||||
+ '<span class="iwb-opt-hint">双击文字改内容,拖动移动,手柄缩放</span>'
|
||||
}
|
||||
return `<span class="iwb-opt-current">当前工具:选择 / 移动</span>
|
||||
<span class="iwb-opt-hint">点中矩形/圆形/钢笔/文字后,这里会出现它的描边、实心与粗细</span>`
|
||||
}
|
||||
|
||||
/** 每个工具只露最常用的 2–4 个参数,全部直接写回 S(右侧参数面板同步) */
|
||||
function optionBarHTML(tool) {
|
||||
if (tool === 'crop') return cropOptionHTML()
|
||||
if (tool === 'select') return selectOptionHTML()
|
||||
if (tool === 'brush' || tool === 'eraser') {
|
||||
return rangeOpt('brushSize', '大小', 1, 300, S.brushSize, '')
|
||||
+ presetDots('brushSize', [2, 4, 8, 12, 16, 24, 32])
|
||||
@@ -912,7 +944,10 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
if (!body) return
|
||||
// 工具没变就只同步数值:renderAll 每次操作都会走到这里,全量重建 innerHTML
|
||||
// 会打断正在拖的滑杆和正在输入的数字框(静态审查 P2-11)。
|
||||
if (!force && body.dataset.tool === S.tool) { syncOptionBar(); return }
|
||||
// 签名里带上选中对象 id:选择工具下换选一个形状,参数区必须整体重建。
|
||||
const sig = S.tool + '|' + (S.selectedShapeId || '') + '|' + (S.selectedTextId || '')
|
||||
if (!force && body.dataset.sig === sig) { syncOptionBar(); return }
|
||||
body.dataset.sig = sig
|
||||
body.dataset.tool = S.tool
|
||||
body.innerHTML = optionBarHTML(S.tool)
|
||||
if (S.tool === 'crop') updateCropInfo() // 重渲染后裁剪尺寸摘要要立即就位
|
||||
@@ -923,12 +958,15 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
export function syncOptionBar() {
|
||||
const body = runtime.el && runtime.el.querySelector('.iwb-editor-optionbar-body')
|
||||
if (!body) return
|
||||
// 选择工具下参数显示的是「选中对象自己的值」,不是新建默认值
|
||||
const selShape = S.tool === 'select' ? getSelectedShape() : null
|
||||
const selText = S.tool === 'select' ? getSelectedText() : null
|
||||
const val = (key) => {
|
||||
if (key === 'brushSize') return S.brushSize
|
||||
if (key === 'brushHardness') return S.brushHardness
|
||||
if (key === 'brushOpacity') return Math.round(S.brushOpacity * 100)
|
||||
if (key === 'shapeLineWidth') return S.shapeLineWidth
|
||||
if (key === 'textSize') return S.textSize
|
||||
if (key === 'shapeLineWidth') return selShape ? Math.max(1, Math.round(selShape.lw || S.shapeLineWidth)) : S.shapeLineWidth
|
||||
if (key === 'textSize') return selText ? Math.round(selText.fontSize || S.textSize) : S.textSize
|
||||
if (key === 'feather') return S.selectionFeather
|
||||
return ''
|
||||
}
|
||||
@@ -945,7 +983,12 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
btn.classList.toggle('active', S.selectionKind === btn.dataset.value)
|
||||
})
|
||||
body.querySelectorAll('[data-opt-toggle]').forEach(btn => {
|
||||
const cur = btn.dataset.fillOwner === 'pen' ? S.penFill : S.rectFill
|
||||
const owner = btn.dataset.fillOwner === 'pen' ? 'pen' : 'rect'
|
||||
let cur = owner === 'pen' ? S.penFill : S.rectFill
|
||||
// 选中态以对象自身的 fill 为准,否则按钮显示会和画面相反
|
||||
if (selShape && (owner === 'pen' ? selShape.type === 'pen' : (selShape.type === 'rect' || selShape.type === 'circle'))) {
|
||||
cur = !!selShape.fill
|
||||
}
|
||||
btn.classList.toggle('active', !!cur === (btn.dataset.value === 'fill'))
|
||||
})
|
||||
}
|
||||
@@ -1010,6 +1053,8 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
// 未闭合的钢笔路径没有可填区域:保持描边,不动视觉结果
|
||||
sh.fill = isPen ? (!!S.penFill && !!sh.closed) : !!S.rectFill
|
||||
renderObjects()
|
||||
// 对象的 fill 更新在 sync 之后,选择工具下按钮的激活态要再刷一次
|
||||
syncOptionBar()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1043,47 +1088,31 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
syncOptionBar()
|
||||
}
|
||||
|
||||
/** 更多菜单 / 面板收起 / 选项栏控件:只绑定一次,DOM 重绘不丢事件(委托) */
|
||||
/** 顶栏命令带 / 面板收起 / 选项栏控件:只绑定一次,DOM 重绘不丢事件(委托) */
|
||||
export function bindLiteUI() {
|
||||
const root = runtime.el
|
||||
if (!root || root.dataset.liteBound === '1') return
|
||||
root.dataset.liteBound = '1'
|
||||
|
||||
const moreBtn = root.querySelector('[data-action="toggleMore"]')
|
||||
const moreMenu = root.querySelector('.iwb-editor-more-menu')
|
||||
const closeMenus = () => {
|
||||
if (moreMenu) moreMenu.classList.remove('open')
|
||||
if (moreBtn) moreBtn.setAttribute('aria-expanded', 'false')
|
||||
const panel = root.querySelector('.iwb-editor-export-settings')
|
||||
if (panel) panel.classList.remove('open')
|
||||
const toggle = root.querySelector('[data-action="toggleExportSettings"]')
|
||||
if (toggle) toggle.setAttribute('aria-expanded', 'false')
|
||||
}
|
||||
if (moreBtn && moreMenu) {
|
||||
moreBtn.addEventListener('mousedown', (e) => e.stopPropagation())
|
||||
moreBtn.addEventListener('click', (e) => {
|
||||
e.stopPropagation()
|
||||
const open = moreMenu.classList.toggle('open')
|
||||
moreBtn.setAttribute('aria-expanded', String(open))
|
||||
})
|
||||
}
|
||||
if (moreMenu) {
|
||||
moreMenu.addEventListener('mousedown', (e) => e.stopPropagation())
|
||||
moreMenu.addEventListener('click', (e) => {
|
||||
const btn = e.target.closest('button')
|
||||
if (!btn) return
|
||||
e.stopPropagation()
|
||||
const key = btn.dataset.more
|
||||
if (key && key.indexOf('sel.') === 0) runCommand(key)
|
||||
else if (key === 'addBlankLayer') addBlankLayer()
|
||||
else if (key === 'addBitmapLayer') {
|
||||
const b = root.querySelector('.iwb-editor-layer-add-btn[data-action="addBitmapLayer"]')
|
||||
if (b) b.click()
|
||||
} else if (key === 'zoomFit') setZoomFit()
|
||||
else if (key === 'reset') restoreAll()
|
||||
closeMenus()
|
||||
})
|
||||
}
|
||||
|
||||
// 选区命令(全选/反选/取消)已从「更多 ▾」搬到竖工具条「选择」后面,改走事件委托:
|
||||
// 三个按钮不切换工具,只调命令层(与快捷键、右键菜单同一条路径)。
|
||||
root.addEventListener('click', (e) => {
|
||||
const btn = e.target.closest('[data-more]')
|
||||
if (!btn) return
|
||||
e.stopPropagation()
|
||||
const key = btn.dataset.more
|
||||
if (key && key.indexOf('sel.') === 0) runCommand(key)
|
||||
else if (key === 'addBlankLayer') addBlankLayer()
|
||||
else if (key === 'zoomFit') setZoomFit()
|
||||
else if (key === 'reset') restoreAll()
|
||||
})
|
||||
|
||||
root.querySelectorAll('[data-action="togglePanels"]').forEach(btn => {
|
||||
btn.addEventListener('mousedown', (e) => e.stopPropagation())
|
||||
@@ -1166,11 +1195,11 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
})
|
||||
}
|
||||
|
||||
// 点画布 / 面板其它地方收起下拉。必须用捕获阶段:modal 自身有个
|
||||
// 点画布 / 面板其它地方收起输出设置下拉。必须用捕获阶段:modal 自身有个
|
||||
// mousedown stopPropagation(阻止宿主抢事件),冒泡阶段收不到。
|
||||
const modal = root.querySelector('.iwb-editor-modal') || root
|
||||
modal.addEventListener('mousedown', (e) => {
|
||||
if (!e.target.closest('.iwb-editor-more-wrap') && !e.target.closest('.iwb-editor-export-settings-wrap')) closeMenus()
|
||||
if (!e.target.closest('.iwb-editor-export-settings-wrap')) closeMenus()
|
||||
}, true)
|
||||
}
|
||||
|
||||
@@ -1194,6 +1223,13 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
return el
|
||||
}
|
||||
|
||||
/** 同一个动作在顶栏/侧栏/面板都可能出现一个按钮(如「适应窗口」),全部绑上 */
|
||||
function bindAll(selector, type, handler) {
|
||||
const list = runtime.el.querySelectorAll(selector)
|
||||
list.forEach(el => el.addEventListener(type, handler))
|
||||
return list.length
|
||||
}
|
||||
|
||||
export function bindEvents() {
|
||||
bindToolButtons()
|
||||
bindColorPanel()
|
||||
@@ -1209,10 +1245,11 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
bindGlobalListeners()
|
||||
}
|
||||
|
||||
/** 工具条按钮:点击切换当前工具 */
|
||||
/** 工具条按钮:点击切换当前工具(选区命令按钮也借用 .iwb-editor-tool 样式,靠 data-tool 过滤掉) */
|
||||
function bindToolButtons() {
|
||||
// 工具
|
||||
runtime.el.querySelectorAll('.iwb-editor-tool').forEach(btn => {
|
||||
if (!btn.dataset.tool) return
|
||||
btn.addEventListener('mousedown', (e) => e.stopPropagation())
|
||||
btn.addEventListener('click', () => setTool(btn.dataset.tool))
|
||||
})
|
||||
@@ -1313,7 +1350,7 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
e.stopPropagation()
|
||||
zoomStep(ZOOM_STEP, S.canvasWrap.clientWidth / 2, S.canvasWrap.clientHeight / 2)
|
||||
})
|
||||
bindIf('[data-action="zoomFit"]', 'click', (e) => {
|
||||
bindAll('[data-action="zoomFit"]', 'click', (e) => {
|
||||
e.stopPropagation()
|
||||
setZoomFit()
|
||||
})
|
||||
@@ -1338,11 +1375,11 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
|
||||
/** 裁剪确认/取消已迁入选项栏(bindLiteUI 委托),旧直连绑定移除。 */
|
||||
|
||||
/** 添加位图图层(导入图片)与新建空白图层 */
|
||||
/** 添加位图图层(导入图片)与新建空白图层:顶栏与其它入口统一绑,取第一个会漏按钮 */
|
||||
function bindLayerAddActions() {
|
||||
// 添加位图图层(导入图片)
|
||||
bindIf('[data-action="addBitmapLayer"]', 'mousedown', (e) => e.stopPropagation())
|
||||
bindIf('[data-action="addBitmapLayer"]', 'click', () => {
|
||||
bindAll('[data-action="addBitmapLayer"]', 'mousedown', (e) => e.stopPropagation())
|
||||
bindAll('[data-action="addBitmapLayer"]', 'click', () => {
|
||||
const fileInput = document.createElement('input')
|
||||
fileInput.type = 'file'
|
||||
fileInput.accept = 'image/*'
|
||||
@@ -1364,8 +1401,8 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
})
|
||||
|
||||
// 新建空白图层
|
||||
bindIf('[data-action="addBlankLayer"]', 'mousedown', (e) => e.stopPropagation())
|
||||
bindIf('[data-action="addBlankLayer"]', 'click', () => {
|
||||
bindAll('[data-action="addBlankLayer"]', 'mousedown', (e) => e.stopPropagation())
|
||||
bindAll('[data-action="addBlankLayer"]', 'click', () => {
|
||||
addBlankLayer()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ import { toast } from './commands.js'
|
||||
tool: S.tool,
|
||||
doc: { w: S.imgW, h: S.imgH },
|
||||
layers: S.layers.map(l => ({ id: l.id, name: l.name, z: l.z, locked: !!l.locked, visible: l.visible !== false })),
|
||||
shapes: S.shapeLayers.map(s => ({ id: s.id, type: s.type, lw: s.lw, fill: !!s.fill })),
|
||||
shapes: S.shapeLayers.map(s => ({ id: s.id, type: s.type, lw: s.lw, fill: !!s.fill, closed: !!s.closed })),
|
||||
texts: S.textLayers.map(t => ({ id: t.id, text: t.text })),
|
||||
selectedShapeId: S.selectedShapeId,
|
||||
selectedTextId: S.selectedTextId,
|
||||
|
||||
@@ -13,7 +13,7 @@ import { drawBitmapSelection, drawVectorToCanvas, hitBitmapAt, removeVecCanvas,
|
||||
import { drawPlacementPreview } from './placement.js'
|
||||
import { drawShape } from './tools.js'
|
||||
import { saveSnapshot, snapshotState } from './history.js'
|
||||
import { updateLayerUI } from './events.js'
|
||||
import { renderOptionBar, updateLayerUI } from './events.js'
|
||||
import { isDrawableLayer } from '../vendor/layer-logic.js'
|
||||
|
||||
|
||||
@@ -175,6 +175,8 @@ import { isDrawableLayer } from '../vendor/layer-logic.js'
|
||||
S.textDrag = null
|
||||
S.shapeDrag = null
|
||||
S.bitmapDrag = null
|
||||
// 选中态变了,选项栏要跟着换成该对象的参数(选择工具下改描边/实心/线宽/字号)
|
||||
renderOptionBar()
|
||||
}
|
||||
|
||||
/** 判定一个图层单元是否命中该点(位图用矩形/像素,矢量用包围盒/形状) */
|
||||
|
||||
+84
-68
@@ -9,7 +9,7 @@
|
||||
var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
id: 'image-annotate',
|
||||
name: '标注 / 修图',
|
||||
version: '1.2.3',
|
||||
version: '1.2.4',
|
||||
apiVersion: 1,
|
||||
capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'],
|
||||
settings: {
|
||||
@@ -932,6 +932,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
S.textDrag = null;
|
||||
S.shapeDrag = null;
|
||||
S.bitmapDrag = null;
|
||||
renderOptionBar();
|
||||
}
|
||||
function hitUnit(unit, pos) {
|
||||
const { kind, obj } = unit;
|
||||
@@ -2655,25 +2656,35 @@ 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"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg></button>
|
||||
</div>
|
||||
<div class="iwb-editor-more-wrap">
|
||||
<button class="iwb-editor-more-btn" data-action="toggleMore" aria-expanded="false">更多 ▾</button>
|
||||
<div class="iwb-editor-more-menu">
|
||||
<button data-more="sel.all">全选 <kbd>Ctrl+A</kbd></button>
|
||||
<button data-more="sel.invert">反选 <kbd>Ctrl+Shift+I</kbd></button>
|
||||
<button data-more="sel.none">取消选区 <kbd>Esc</kbd></button>
|
||||
<span class="iwb-editor-more-sep"></span>
|
||||
<button data-more="addBlankLayer">新建空白图层</button>
|
||||
<button data-more="addBitmapLayer">导入图片为图层</button>
|
||||
<button data-more="zoomFit">适应窗口</button>
|
||||
<button data-more="reset">还原原图</button>
|
||||
<span class="iwb-editor-more-sep"></span>
|
||||
<button data-action="togglePanels">收起 / 展开侧栏</button>
|
||||
<!-- 顶栏命令带(v1.2.4):原「更多 ▾」菜单全部铺开成图标,按 图层 / 顺序 / 视图 分三组 -->
|
||||
<div class="iwb-editor-commands">
|
||||
<div class="iwb-editor-cmdgroup" data-group="layers">
|
||||
<button class="iwb-editor-action" data-action="addBlankLayer" title="新建空白图层"><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"/><line x1="12" y1="8" x2="12" y2="16"/><line x1="8" y1="12" x2="16" y2="12"/></svg></button>
|
||||
<button class="iwb-editor-action" data-action="addBitmapLayer" title="导入图片为图层(也可直接 ⌘/Ctrl+V 粘贴剪贴板图片)"><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"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.1-3.1a2 2 0 0 0-2.8 0L6 21"/><line x1="19" y1="8" x2="19" y2="14"/><line x1="22" y1="11" x2="16" y2="11"/></svg></button>
|
||||
</div>
|
||||
<span class="iwb-editor-divider"></span>
|
||||
<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="适应窗口"><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="收起 / 展开侧栏(画布优先)"><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>
|
||||
<button class="iwb-editor-panel-toggle" data-action="togglePanels" title="收起 / 展开侧栏(画布优先)">⇥</button>
|
||||
<div class="iwb-editor-tools">
|
||||
<button class="iwb-editor-tool" data-tool="select" 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="M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z"/></svg></button>
|
||||
|
||||
<!-- 选区命令紧跟「选择」工具(用户裁定 2026-11-04:从「更多」里拿出来,不再藏二级) -->
|
||||
<button class="iwb-editor-tool iwb-editor-selcmd" data-more="sel.all" title="全选 (Ctrl+A)"><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="3 2"><rect x="3.5" y="3.5" width="17" height="17" rx="1"/></svg></button>
|
||||
<button class="iwb-editor-tool iwb-editor-selcmd" data-more="sel.invert" title="反选 (Ctrl+Shift+I)"><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.5" y="3.5" width="17" height="17" rx="1" stroke-dasharray="3 2"/><rect x="8" y="8" width="8" height="8" rx="1" fill="currentColor" stroke="none"/></svg></button>
|
||||
<button class="iwb-editor-tool iwb-editor-selcmd" data-more="sel.none" title="取消选区 (Esc / Ctrl+D)"><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.5" y="3.5" width="17" height="17" rx="1" stroke-dasharray="3 2"/><line x1="4" y1="20" x2="20" y2="4"/></svg></button>
|
||||
|
||||
<span class="iwb-editor-divider"></span>
|
||||
|
||||
<button class="iwb-editor-tool" data-tool="marquee" title="框选:拖出矩形/椭圆选区,松手后旁边出现操作条(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>
|
||||
|
||||
@@ -2701,7 +2712,6 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
|
||||
<span class="iwb-editor-divider"></span>
|
||||
</div>
|
||||
<span class="iwb-editor-divider"></span>
|
||||
|
||||
<div class="iwb-editor-export-actions">
|
||||
<div class="iwb-editor-export-settings-wrap">
|
||||
@@ -2751,19 +2761,10 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
<div class="iwb-editor-layer-panel">
|
||||
<div class="iwb-editor-layer-panel-header">
|
||||
<span class="iwb-editor-layer-panel-title">图层</span>
|
||||
<div class="iwb-editor-layer-add-group">
|
||||
<button class="iwb-editor-layer-add-btn" data-action="addBitmapLayer" title="导入图片为新图层(也可直接 ⌘/Ctrl+V 粘贴剪贴板图片)"><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="3" y="3" width="18" height="18" rx="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.1-3.1a2 2 0 0 0-2.8 0L6 21"/><line x1="19" y1="8" x2="19" y2="14"/><line x1="22" y1="11" x2="16" y2="11"/></svg></button>
|
||||
<button class="iwb-editor-layer-add-btn" data-action="addBlankLayer" title="新建空白图层"><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="3" y="3" width="18" height="18" rx="2"/><line x1="12" y1="8" x2="12" y2="16"/><line x1="8" y1="12" x2="16" y2="12"/></svg></button>
|
||||
</div>
|
||||
<!-- 新建图层 / 导入图片已上移到顶栏命令带(v1.2.4),面板只留标题,避免同一功能两个入口 -->
|
||||
</div>
|
||||
|
||||
<div class="iwb-editor-layer-group" title="调整选中元素的图层顺序">
|
||||
<span class="iwb-editor-constraint-label">图层</span>
|
||||
<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>
|
||||
<!-- 图层顺序(置顶/上移/下移/置底)已移到顶栏命令带(v1.2.4) -->
|
||||
<div class="iwb-editor-layer-list"></div>
|
||||
</div>
|
||||
<div class="iwb-editor-canvas-wrap">
|
||||
@@ -3687,8 +3688,27 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
<button class="iwb-opt-btn${fill ? "" : " active"}" data-opt-toggle="stroke" data-fill-owner="${owner}" data-value="stroke">描边</button>
|
||||
<button class="iwb-opt-btn${fill ? " active" : ""}" data-opt-toggle="fill" data-fill-owner="${owner}" data-value="fill">实心</button>`;
|
||||
}
|
||||
var SHAPE_NAMES = { rect: "矩形", circle: "圆形", arrow: "箭头", pen: "钢笔路径" };
|
||||
function selectOptionHTML() {
|
||||
const sh = getSelectedShape();
|
||||
if (sh) {
|
||||
const t = sh.type;
|
||||
if (t === "rect" || t === "circle" || t === "pen" || t === "arrow") {
|
||||
const owner = t === "pen" ? "pen" : "rect";
|
||||
const lw = Math.max(1, Math.round(sh.lw || S.shapeLineWidth));
|
||||
return `<span class="iwb-opt-current">已选中:${SHAPE_NAMES[t] || t}</span>` + rangeOpt("shapeLineWidth", "线宽", 1, 60, lw, "") + presetDots("shapeLineWidth", [1, 2, 3, 6, 10, 16, 24]) + (t === "arrow" ? "" : fillStyleHTML(owner)) + (t === "pen" && !sh.closed ? '<span class="iwb-opt-hint">这条钢笔路径未闭合,实心不生效;点回起点闭合后即可填充</span>' : "");
|
||||
}
|
||||
}
|
||||
const text = getSelectedText();
|
||||
if (text) {
|
||||
return `<span class="iwb-opt-current">已选中:文字</span>` + rangeOpt("textSize", "字号", 8, 400, Math.round(text.fontSize || S.textSize), "px") + '<span class="iwb-opt-hint">双击文字改内容,拖动移动,手柄缩放</span>';
|
||||
}
|
||||
return `<span class="iwb-opt-current">当前工具:选择 / 移动</span>
|
||||
<span class="iwb-opt-hint">点中矩形/圆形/钢笔/文字后,这里会出现它的描边、实心与粗细</span>`;
|
||||
}
|
||||
function optionBarHTML(tool) {
|
||||
if (tool === "crop") return cropOptionHTML();
|
||||
if (tool === "select") return selectOptionHTML();
|
||||
if (tool === "brush" || tool === "eraser") {
|
||||
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}">
|
||||
@@ -3726,10 +3746,12 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
function renderOptionBar(force) {
|
||||
const body = runtime.el && runtime.el.querySelector(".iwb-editor-optionbar-body");
|
||||
if (!body) return;
|
||||
if (!force && body.dataset.tool === S.tool) {
|
||||
const sig = S.tool + "|" + (S.selectedShapeId || "") + "|" + (S.selectedTextId || "");
|
||||
if (!force && body.dataset.sig === sig) {
|
||||
syncOptionBar();
|
||||
return;
|
||||
}
|
||||
body.dataset.sig = sig;
|
||||
body.dataset.tool = S.tool;
|
||||
body.innerHTML = optionBarHTML(S.tool);
|
||||
if (S.tool === "crop") updateCropInfo();
|
||||
@@ -3738,12 +3760,14 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
function syncOptionBar() {
|
||||
const body = runtime.el && runtime.el.querySelector(".iwb-editor-optionbar-body");
|
||||
if (!body) return;
|
||||
const selShape = S.tool === "select" ? getSelectedShape() : null;
|
||||
const selText = S.tool === "select" ? getSelectedText() : null;
|
||||
const val = (key) => {
|
||||
if (key === "brushSize") return S.brushSize;
|
||||
if (key === "brushHardness") return S.brushHardness;
|
||||
if (key === "brushOpacity") return Math.round(S.brushOpacity * 100);
|
||||
if (key === "shapeLineWidth") return S.shapeLineWidth;
|
||||
if (key === "textSize") return S.textSize;
|
||||
if (key === "shapeLineWidth") return selShape ? Math.max(1, Math.round(selShape.lw || S.shapeLineWidth)) : S.shapeLineWidth;
|
||||
if (key === "textSize") return selText ? Math.round(selText.fontSize || S.textSize) : S.textSize;
|
||||
if (key === "feather") return S.selectionFeather;
|
||||
return "";
|
||||
};
|
||||
@@ -3760,7 +3784,11 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
btn.classList.toggle("active", S.selectionKind === btn.dataset.value);
|
||||
});
|
||||
body.querySelectorAll("[data-opt-toggle]").forEach((btn) => {
|
||||
const cur = btn.dataset.fillOwner === "pen" ? S.penFill : S.rectFill;
|
||||
const owner = btn.dataset.fillOwner === "pen" ? "pen" : "rect";
|
||||
let cur = owner === "pen" ? S.penFill : S.rectFill;
|
||||
if (selShape && (owner === "pen" ? selShape.type === "pen" : selShape.type === "rect" || selShape.type === "circle")) {
|
||||
cur = !!selShape.fill;
|
||||
}
|
||||
btn.classList.toggle("active", !!cur === (btn.dataset.value === "fill"));
|
||||
});
|
||||
}
|
||||
@@ -3822,6 +3850,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
saveSnapshot("填充");
|
||||
sh.fill = isPen ? !!S.penFill && !!sh.closed : !!S.rectFill;
|
||||
renderObjects();
|
||||
syncOptionBar();
|
||||
}
|
||||
}
|
||||
function setOptionFromControl(el, committed) {
|
||||
@@ -3857,41 +3886,22 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
const root = runtime.el;
|
||||
if (!root || root.dataset.liteBound === "1") return;
|
||||
root.dataset.liteBound = "1";
|
||||
const moreBtn = root.querySelector('[data-action="toggleMore"]');
|
||||
const moreMenu = root.querySelector(".iwb-editor-more-menu");
|
||||
const closeMenus = () => {
|
||||
if (moreMenu) moreMenu.classList.remove("open");
|
||||
if (moreBtn) moreBtn.setAttribute("aria-expanded", "false");
|
||||
const panel = root.querySelector(".iwb-editor-export-settings");
|
||||
if (panel) panel.classList.remove("open");
|
||||
const toggle = root.querySelector('[data-action="toggleExportSettings"]');
|
||||
if (toggle) toggle.setAttribute("aria-expanded", "false");
|
||||
};
|
||||
if (moreBtn && moreMenu) {
|
||||
moreBtn.addEventListener("mousedown", (e) => e.stopPropagation());
|
||||
moreBtn.addEventListener("click", (e) => {
|
||||
e.stopPropagation();
|
||||
const open2 = moreMenu.classList.toggle("open");
|
||||
moreBtn.setAttribute("aria-expanded", String(open2));
|
||||
});
|
||||
}
|
||||
if (moreMenu) {
|
||||
moreMenu.addEventListener("mousedown", (e) => e.stopPropagation());
|
||||
moreMenu.addEventListener("click", (e) => {
|
||||
const btn = e.target.closest("button");
|
||||
if (!btn) return;
|
||||
e.stopPropagation();
|
||||
const key = btn.dataset.more;
|
||||
if (key && key.indexOf("sel.") === 0) runCommand(key);
|
||||
else if (key === "addBlankLayer") addBlankLayer();
|
||||
else if (key === "addBitmapLayer") {
|
||||
const b = root.querySelector('.iwb-editor-layer-add-btn[data-action="addBitmapLayer"]');
|
||||
if (b) b.click();
|
||||
} else if (key === "zoomFit") setZoomFit();
|
||||
else if (key === "reset") restoreAll();
|
||||
closeMenus();
|
||||
});
|
||||
}
|
||||
root.addEventListener("click", (e) => {
|
||||
const btn = e.target.closest("[data-more]");
|
||||
if (!btn) return;
|
||||
e.stopPropagation();
|
||||
const key = btn.dataset.more;
|
||||
if (key && key.indexOf("sel.") === 0) runCommand(key);
|
||||
else if (key === "addBlankLayer") addBlankLayer();
|
||||
else if (key === "zoomFit") setZoomFit();
|
||||
else if (key === "reset") restoreAll();
|
||||
});
|
||||
root.querySelectorAll('[data-action="togglePanels"]').forEach((btn) => {
|
||||
btn.addEventListener("mousedown", (e) => e.stopPropagation());
|
||||
btn.addEventListener("click", (e) => {
|
||||
@@ -3981,7 +3991,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
}
|
||||
const modal = root.querySelector(".iwb-editor-modal") || root;
|
||||
modal.addEventListener("mousedown", (e) => {
|
||||
if (!e.target.closest(".iwb-editor-more-wrap") && !e.target.closest(".iwb-editor-export-settings-wrap")) closeMenus();
|
||||
if (!e.target.closest(".iwb-editor-export-settings-wrap")) closeMenus();
|
||||
}, true);
|
||||
}
|
||||
var warnedMissing = /* @__PURE__ */ new Set();
|
||||
@@ -3997,6 +4007,11 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
el.addEventListener(type, handler);
|
||||
return el;
|
||||
}
|
||||
function bindAll(selector, type, handler) {
|
||||
const list = runtime.el.querySelectorAll(selector);
|
||||
list.forEach((el) => el.addEventListener(type, handler));
|
||||
return list.length;
|
||||
}
|
||||
function bindEvents() {
|
||||
bindToolButtons();
|
||||
bindColorPanel();
|
||||
@@ -4013,6 +4028,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
}
|
||||
function bindToolButtons() {
|
||||
runtime.el.querySelectorAll(".iwb-editor-tool").forEach((btn) => {
|
||||
if (!btn.dataset.tool) return;
|
||||
btn.addEventListener("mousedown", (e) => e.stopPropagation());
|
||||
btn.addEventListener("click", () => setTool(btn.dataset.tool));
|
||||
});
|
||||
@@ -4143,7 +4159,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
e.stopPropagation();
|
||||
zoomStep(ZOOM_STEP, S.canvasWrap.clientWidth / 2, S.canvasWrap.clientHeight / 2);
|
||||
});
|
||||
bindIf('[data-action="zoomFit"]', "click", (e) => {
|
||||
bindAll('[data-action="zoomFit"]', "click", (e) => {
|
||||
e.stopPropagation();
|
||||
setZoomFit();
|
||||
});
|
||||
@@ -4163,8 +4179,8 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
restoreBtn && restoreBtn.addEventListener("click", restoreOriginal);
|
||||
}
|
||||
function bindLayerAddActions() {
|
||||
bindIf('[data-action="addBitmapLayer"]', "mousedown", (e) => e.stopPropagation());
|
||||
bindIf('[data-action="addBitmapLayer"]', "click", () => {
|
||||
bindAll('[data-action="addBitmapLayer"]', "mousedown", (e) => e.stopPropagation());
|
||||
bindAll('[data-action="addBitmapLayer"]', "click", () => {
|
||||
const fileInput = document.createElement("input");
|
||||
fileInput.type = "file";
|
||||
fileInput.accept = "image/*";
|
||||
@@ -4184,8 +4200,8 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
});
|
||||
fileInput.click();
|
||||
});
|
||||
bindIf('[data-action="addBlankLayer"]', "mousedown", (e) => e.stopPropagation());
|
||||
bindIf('[data-action="addBlankLayer"]', "click", () => {
|
||||
bindAll('[data-action="addBlankLayer"]', "mousedown", (e) => e.stopPropagation());
|
||||
bindAll('[data-action="addBlankLayer"]', "click", () => {
|
||||
addBlankLayer();
|
||||
});
|
||||
}
|
||||
@@ -6016,7 +6032,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
tool: S.tool,
|
||||
doc: { w: S.imgW, h: S.imgH },
|
||||
layers: S.layers.map((l) => ({ id: l.id, name: l.name, z: l.z, locked: !!l.locked, visible: l.visible !== false })),
|
||||
shapes: S.shapeLayers.map((s) => ({ id: s.id, type: s.type, lw: s.lw, fill: !!s.fill })),
|
||||
shapes: S.shapeLayers.map((s) => ({ id: s.id, type: s.type, lw: s.lw, fill: !!s.fill, closed: !!s.closed })),
|
||||
texts: S.textLayers.map((t) => ({ id: t.id, text: t.text })),
|
||||
selectedShapeId: S.selectedShapeId,
|
||||
selectedTextId: S.selectedTextId,
|
||||
@@ -6057,7 +6073,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) {
|
||||
|
||||
@@ -96,7 +96,7 @@ const boot = await page.evaluate((png) => {
|
||||
window.__commands['annotate-selected'].run().catch(() => {})
|
||||
return { version: window.__manifest.version, settingsSchema: Object.keys(window.__manifest.settings || {}) }
|
||||
}, PNG)
|
||||
check('产物可执行(循环打包未炸)', boot.version === '1.2.3', 'version=' + boot.version)
|
||||
check('产物可执行(循环打包未炸)', boot.version === '1.2.4', 'version=' + boot.version)
|
||||
check('manifest 声明输出预设设置项', boot.settingsSchema.includes('exportPreset') && boot.settingsSchema.includes('panelsCollapsed'), boot.settingsSchema.join(','))
|
||||
|
||||
await page.locator('#iwb-editor-overlay').waitFor({ state: 'visible', timeout: 15000 })
|
||||
@@ -106,11 +106,11 @@ const pixel = (cx, cy) => page.evaluate(({ x, y }) => {
|
||||
return { base: d.pixel('base', x, y), draw: d.pixel('draw', x, y), layers: d.layers.map(l => ({ id: l.id, a: d.pixel(l.id, x, y) })) }
|
||||
}, { x: cx, y: cy })
|
||||
|
||||
check('编辑器打开 + 便利 UI 五区齐全', await page.evaluate(() => {
|
||||
check('编辑器打开 + 便利 UI 五区齐全(v1.2.4 起命令带取代「更多」菜单)', await page.evaluate(() => {
|
||||
const q = (s) => Boolean(document.querySelector(s))
|
||||
return q('.iwb-editor-optionbar') && q('.iwb-editor-statusbar') && q('.iwb-editor-sel-bar') &&
|
||||
q('.iwb-editor-toast') && q('.iwb-editor-selection-overlay') && q('.iwb-editor-cursor-overlay') &&
|
||||
q('[data-action="download"]') && q('[data-action="toggleMore"]')
|
||||
q('[data-action="download"]') && q('.iwb-editor-commands')
|
||||
}))
|
||||
check('新增选区工具按钮', (await page.locator('.iwb-editor-tool[data-tool="marquee"]').count()) === 1 &&
|
||||
(await page.locator('.iwb-editor-tool[data-tool="lasso"]').count()) === 1)
|
||||
@@ -430,7 +430,7 @@ check('选中形状 → Ctrl+A → Delete ⇒ 形状仍在、当前层像素被
|
||||
await page.keyboard.press('Control+z')
|
||||
await page.keyboard.press('Control+d')
|
||||
|
||||
// ---- Fix2:裁剪与选区互斥(快捷键 / 更多菜单 / 右键菜单三入口) + confirmCrop 清残留 ----
|
||||
// ---- Fix2:裁剪与选区互斥(快捷键 / 顶栏全选图标 / 右键菜单三入口) + confirmCrop 清残留 ----
|
||||
await page.locator('.iwb-editor-tool[data-tool="crop"]').click()
|
||||
const cropStart = await dbg()
|
||||
check('切到裁剪:旧选区被清、蚂蚁线停止', cropStart.selection === null && cropStart.ants === false)
|
||||
@@ -439,10 +439,9 @@ const cropAfterA = await dbg()
|
||||
check('裁剪中 Ctrl+A:不建选区、不启动蚂蚁线、浮动条不出现',
|
||||
cropAfterA.selection === null && cropAfterA.ants === false &&
|
||||
(await page.locator('.iwb-editor-sel-bar').isVisible()) === false)
|
||||
await page.locator('[data-action="toggleMore"]').click()
|
||||
await page.locator('[data-more="sel.all"]').click()
|
||||
await page.locator('.iwb-editor-selcmd[data-more="sel.all"]').click()
|
||||
const cropAfterMenu = await dbg()
|
||||
check('裁剪中「更多 → 全选」同样被拦', cropAfterMenu.selection === null && cropAfterMenu.ants === false)
|
||||
check('裁剪中「全选」图标同样被拦', cropAfterMenu.selection === null && cropAfterMenu.ants === false)
|
||||
await page.mouse.click(box2.x + box2.width * 0.5, box2.y + box2.height * 0.5, { button: 'right' })
|
||||
const menuShown = await page.locator('.iwb-editor-sel-bar.as-menu').count()
|
||||
await page.locator('.iwb-editor-sel-bar button[data-sel-cmd="sel.all"]').click()
|
||||
@@ -656,6 +655,89 @@ check('原图锁定且无标注层时用橡皮:提示「先画再擦」且不
|
||||
'layers=' + layersAfterReset + ' toast=' + toastText)
|
||||
await page.keyboard.press('Control+z') // 撤销还原,恢复图层结构
|
||||
|
||||
// ---- v1.2.4:顶栏命令带(「更多」图标化)/ 选择工具就地改形状参数 ----
|
||||
|
||||
check('「更多」菜单已移除,新建/导入/顺序/视图图标进顶栏命令带', await page.evaluate(() => {
|
||||
const q = (s) => Boolean(document.querySelector(s))
|
||||
const hdrCmds = document.querySelectorAll('.iwb-editor-header .iwb-editor-commands .iwb-editor-layer-btn').length
|
||||
return !q('.iwb-editor-more-wrap') && !q('[data-action="toggleMore"]') && hdrCmds === 4 &&
|
||||
q('.iwb-editor-header [data-action="addBitmapLayer"]') &&
|
||||
q('.iwb-editor-header [data-action="addBlankLayer"]') &&
|
||||
q('.iwb-editor-header [data-action="zoomFit"]') &&
|
||||
q('.iwb-editor-header [data-action="togglePanels"]')
|
||||
}))
|
||||
|
||||
check('全选/反选/取消选区三个图标紧跟「选择」工具', await page.evaluate(() => {
|
||||
const tools = Array.from(document.querySelectorAll('.iwb-editor-header > .iwb-editor-tools .iwb-editor-tool'))
|
||||
const idx = tools.findIndex(b => b.dataset.tool === 'select')
|
||||
const cmds = tools.slice(idx + 1, idx + 4)
|
||||
return idx >= 0 && cmds.length === 3 && cmds.every(b => /^sel\./.test(b.dataset.more || ''))
|
||||
}))
|
||||
|
||||
await page.locator('.iwb-editor-selcmd[data-more="sel.all"]').click()
|
||||
const selAllDbg = await dbg()
|
||||
check('点「全选」图标 = Ctrl+A(选区生成)', Boolean(selAllDbg.selection && selAllDbg.selection.w === selAllDbg.doc.w),
|
||||
JSON.stringify(selAllDbg.selection))
|
||||
await page.locator('.iwb-editor-selcmd[data-more="sel.none"]').click()
|
||||
check('点「取消选区」图标清掉选区', !(await dbg()).selection)
|
||||
|
||||
// 画一个矩形 → 切选择工具点中它 → 选项栏就地改 描边/实心 + 线宽
|
||||
await page.locator('.iwb-editor-tool[data-tool="rect"]').click()
|
||||
await drag2(liveBox.x + liveBox.width * 0.2, liveBox.y + liveBox.height * 0.2,
|
||||
liveBox.x + liveBox.width * 0.45, liveBox.y + liveBox.height * 0.45)
|
||||
await page.locator('.iwb-editor-tool[data-tool="select"]').click()
|
||||
await page.mouse.click(liveBox.x + liveBox.width * 0.3, liveBox.y + liveBox.height * 0.3)
|
||||
await page.waitForTimeout(150)
|
||||
let selShapeDbg = await dbg()
|
||||
check('选择工具选中矩形后选项栏出该形状的参数',
|
||||
selShapeDbg.selectedShapeId &&
|
||||
(await page.locator('.iwb-editor-optionbar-body [data-opt-toggle][data-fill-owner="rect"]').count()) === 2 &&
|
||||
(await page.locator('.iwb-editor-optionbar-body [data-opt="shapeLineWidth"]').count()) >= 2,
|
||||
'selected=' + selShapeDbg.selectedShapeId)
|
||||
await page.locator('.iwb-editor-optionbar-body [data-opt-toggle="fill"][data-fill-owner="rect"]').click()
|
||||
selShapeDbg = await dbg()
|
||||
check('选中矩形就地切「实心」(对象与按钮激活态一致)',
|
||||
selShapeDbg.shapes[selShapeDbg.shapes.length - 1].fill === true &&
|
||||
await page.evaluate(() => document.querySelector('.iwb-editor-optionbar-body [data-opt-toggle="fill"][data-fill-owner="rect"]').classList.contains('active')),
|
||||
JSON.stringify(selShapeDbg.shapes.slice(-1)))
|
||||
await page.locator('.iwb-editor-optionbar-body [data-opt-toggle="stroke"][data-fill-owner="rect"]').click()
|
||||
selShapeDbg = await dbg()
|
||||
check('再切回「描边」(按钮激活态跟随)',
|
||||
selShapeDbg.shapes[selShapeDbg.shapes.length - 1].fill === false &&
|
||||
await page.evaluate(() => document.querySelector('.iwb-editor-optionbar-body [data-opt-toggle="stroke"][data-fill-owner="rect"]').classList.contains('active')))
|
||||
await page.locator('.iwb-editor-optionbar-body input[type="number"][data-opt="shapeLineWidth"]').fill('9')
|
||||
await page.waitForTimeout(120)
|
||||
selShapeDbg = await dbg()
|
||||
check('选中矩形就地改线宽 9', selShapeDbg.shapes[selShapeDbg.shapes.length - 1].lw === 9,
|
||||
JSON.stringify(selShapeDbg.shapes.slice(-1)))
|
||||
|
||||
// 钢笔:闭合路径选中后同样可切描边/实心
|
||||
await page.locator('.iwb-editor-tool[data-tool="pen"]').click()
|
||||
const pA = [liveBox.x + liveBox.width * 0.55, liveBox.y + liveBox.height * 0.25]
|
||||
const pB = [liveBox.x + liveBox.width * 0.75, liveBox.y + liveBox.height * 0.25]
|
||||
const pC = [liveBox.x + liveBox.width * 0.75, liveBox.y + liveBox.height * 0.45]
|
||||
const pD = [liveBox.x + liveBox.width * 0.55, liveBox.y + liveBox.height * 0.45]
|
||||
for (const [x, y] of [pA, pB, pC, pD]) await page.mouse.click(x, y)
|
||||
await page.mouse.click(pA[0], pA[1]) // 点回起点闭合
|
||||
await page.waitForTimeout(120)
|
||||
const penShapeDbg = await dbg()
|
||||
check('钢笔闭合路径落成并自动选中', penShapeDbg.selectedShapeId &&
|
||||
penShapeDbg.shapes[penShapeDbg.shapes.length - 1].type === 'pen' &&
|
||||
penShapeDbg.shapes[penShapeDbg.shapes.length - 1].closed === true,
|
||||
JSON.stringify(penShapeDbg.shapes.slice(-1)))
|
||||
check('选中钢笔路径的选项栏有 描边/实心(pen 归属)',
|
||||
(await page.locator('.iwb-editor-optionbar-body [data-opt-toggle][data-fill-owner="pen"]').count()) === 2)
|
||||
await page.locator('.iwb-editor-tool[data-tool="select"]').click()
|
||||
await page.locator('.iwb-editor-optionbar-body [data-opt-toggle="stroke"][data-fill-owner="pen"]').click()
|
||||
let penSelDbg = await dbg()
|
||||
check('选中钢笔路径就地切「描边」', penSelDbg.shapes[penSelDbg.shapes.length - 1].fill === false)
|
||||
await page.locator('.iwb-editor-optionbar-body [data-opt-toggle="fill"][data-fill-owner="pen"]').click()
|
||||
penSelDbg = await dbg()
|
||||
check('再切回「实心」', penSelDbg.shapes[penSelDbg.shapes.length - 1].fill === true)
|
||||
await page.keyboard.press('Control+z') // 撤销最后一次填充
|
||||
await page.keyboard.press('Control+z') // 撤销钢笔路径
|
||||
await page.keyboard.press('Control+z') // 撤销矩形线宽
|
||||
|
||||
|
||||
await page.locator('[data-action="cancel"]').click()
|
||||
const openState = await poll(async () => page.evaluate(() => window.__openState))
|
||||
|
||||
Reference in new issue
Block a user