feat(image-annotate): v1.18.0 色板可钉住 + 右列竖向收窄 + 撤销组搬进工具条最右

This commit is contained in:
qiqi committed 2026-11-10 06:59:04 +08:00
1 parent b6d10339f6
commit a94e5be954
10 files changed
+408 -86

No files matched your search

+39
View File
@@ -234,6 +234,45 @@ P 下双击 = 结束当前路径(`commitPenPath`),不再进节点编辑。
- 文字 / 形状 / 钢笔会被直接栅格化进结果层(PS 合并矢量层也是这个结果)。
- 结果层落回「原最低参与层」的位置,`assignLayerZ` 重新连续编号,不产生重复 z。
## v1.18.0:色板可以「钉住」+ 右列竖向收窄 + 撤销组搬进工具条
用户两句话:「这个弹出的调色气泡,加一个功能就是让他能够钉住,在需要调色的时候不用每次都要点开」
「右边的数值、常用色、最近色你看下能不能竖向排…顺序改为设置、常用色、最近,这三项不用标题,
用细横线分割」;另加「这几个图标移动到工具栏的最右边」(撤销 / 重做 / 还原)。
**钉住**:色板弹层右上角一颗图钉(`data-action="pinColorPop"`)。
- 钉住时点画布、点别处都不收起 —— 这就是它存在的全部意义(要收就再点一次图钉或按 Esc)。
- 状态写 `ctx.settings.colorPopPinned`,跨会话记住:钉过一次就一直钉着,下次打开仍是钉住的。
- 图钉用**绝对定位**钉在头部右上角(头部留 `padding-right: 26px` 让位),
这样「无」按钮的显隐不会把它挤来挤去。
- 激活态用琥珀色描边 + 淡底,不旋转角度:45° 的图钉在 13px 下看着像歪掉的问号。
**右列竖向**:原来「吸管+HEX | 常用色 | 最近」是横向并排、靠小标题分组,
弹层宽 630px 且「常用色 / 最近」各占一行标题。现在三块竖着叠、块间 1px 细线、**不要标题**:
```
[ 取色器 ] │ [吸管 #FF4444] ← 设置
│ ─────────────
│ ●●●●●● ●●●●●● ← 常用色(6 列 × 2 行)
│ ─────────────
│ ●●●●●● ← 最近(6 列,上限收到 6 个正好一行)
```
弹层从 **630×157 → 380×153**:宽度砍掉 40%,高度基本不变(标题行省下来的高度被 6 列更窄的网格吃掉)。
色块 22px → 18px;「最近」上限 8 → 6,否则 8 个会折成第二行,把面板顶高 23px,和「更紧凑」相反。
同一份 DOM 右栏常驻面板也在用,那边靠 `.iwb-editor-colors .iwb-color-pop-side { display: contents }`
把新加的 `.iwb-color-pop-side` 这层拆掉,走自己原来的竖排,pin 按钮在右栏 `display: none`。
**撤销组搬位**:撤销 / 重做 / 还原从顶栏 `.iwb-editor-history` 移到画布底部工具栏最右(视图快捷之后)。
理由是这三个是画画时会连着按的操作,手在画布上,不该抬头去顶栏找。顶栏只剩会话组(新建/覆盖/退出)与输出。
三个按钮本来就和工具按钮同为 32×32 `.iwb-editor-action` 样式,搬过去不用改尺寸。
**验证**:harness 228 项(新增 5 项:右列竖排几何 + 1px 分隔线 + 无标题、弹层尺寸 ≤ 460×175、
钉住后点画布不收起且写进 settings、取消钉住后点画布立即收起、撤销组是 tools 最后子元素且与工具同轴)。
改了两条老断言:顶栏不再有 `.iwb-editor-history`;`[data-action="reset"]` 的查询范围从 header 改成 tools。
## v1.17.0:描边也能是「无色」+ 一边无色时 Shift+X 照样交换
用户两句话:「让矢量图形与钢笔的描边色也可以去掉」「描边与填充有一个是无色的时候可以交换,
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@iwb-plugin/image-annotate",
"private": true,
"version": "1.17.1",
"version": "1.18.0",
"description": "IWB 插件:图片标注 / 修图(编辑器移植自 iwb-plaus 扩展,纯 Canvas 2D)",
"ibwPlugin": {
"id": "image-annotate",
+55 -15
View File
@@ -232,6 +232,10 @@
gap: 4px;
}
/* 撤销 / 重做 / 还原(v1.18):搬进工具条末端后需要一个 flex 容器,
否则三个 button 之间是 inline-block 的空隙,和左边 4px gap 的工具按钮对不齐。 */
.iwb-editor-history { display: flex; align-items: center; gap: 4px; }
.iwb-editor-tool, .iwb-editor-action {
background: #313244;
border: none;
@@ -1783,8 +1787,8 @@
.iwb-editor-color-pop {
position: absolute; z-index: 60; display: flex; flex-direction: column; align-items: stretch; gap: 9px;
padding: 10px 12px; border-radius: 12px;
position: absolute; z-index: 60; display: flex; flex-direction: column; align-items: stretch; gap: 7px;
padding: 9px 11px; border-radius: 12px;
background: rgba(24, 24, 37, 0.97); border: 1px solid #313244;
box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
-webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
@@ -1822,29 +1826,60 @@
.iwb-color-pop-none:hover { border-color: #f38ba8; color: #f38ba8; }
.iwb-color-pop-none.active { border-style: solid; border-color: #f38ba8; color: #f38ba8; background: rgba(243, 139, 168, 0.12); }
.iwb-color-pop-none[hidden] { display: none; }
.iwb-color-pop-body { display: flex; align-items: center; gap: 10px; }
.iwb-color-pop-body { display: flex; align-items: stretch; gap: 10px; }
.iwb-color-pop-picker { display: flex; gap: 8px; flex: 0 0 auto; }
.iwb-editor-color-pop .iwb-color-sv { width: 180px; height: 104px; flex: 0 0 180px; }
.iwb-editor-color-pop .iwb-color-hue { width: 16px; height: 104px; flex: 0 0 16px; }
.iwb-editor-color-pop .iwb-color-sv { width: 176px; height: 102px; flex: 0 0 176px; }
.iwb-editor-color-pop .iwb-color-hue { width: 16px; height: 102px; flex: 0 0 16px; }
.iwb-color-pop-sep { width: 1px; align-self: stretch; background: #313244; flex: 0 0 auto; }
.iwb-color-pop-fields { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
/* ==== 右列(v1.18,用户 2026-11-10)====
设置 / 常用色 / 最近 三块竖着叠,块之间 1px 细线,不写小标题:
原来「常用色」「最近」各占一行标题 + 横向铺开,整块面板又宽又高。
现宽 133px(6 列 × 18px),三块高度加起来刚好填满左侧取色器的高度。 */
.iwb-color-pop-side {
display: flex; flex-direction: column; justify-content: space-between;
width: 133px; flex: 0 0 133px; gap: 0;
}
/* 细线分隔:只加在「块与块之间」,第一块前面不加,否则顶部多一条悬空的线 */
.iwb-color-pop-side > * + * {
border-top: 1px solid #313244; margin-top: 5px; padding-top: 5px;
}
.iwb-color-pop-fields { display: flex; align-items: center; gap: 5px; }
.iwb-editor-color-pop .iwb-editor-color-hex-input {
width: 86px; height: 28px; padding: 0 6px; text-align: center;
flex: 1 1 auto; width: 0; height: 26px; padding: 0 5px; text-align: center;
font: 600 12px monospace; border-radius: 6px; box-sizing: border-box;
}
.iwb-editor-color-pop .iwb-editor-color-swatches {
display: grid; grid-template-columns: repeat(6, 22px); grid-auto-rows: 22px;
gap: 7px; flex: 0 0 auto; align-content: center;
display: grid; grid-template-columns: repeat(6, 18px); grid-auto-rows: 18px;
gap: 5px; flex: 0 0 auto; align-content: center;
}
.iwb-editor-color-pop .iwb-editor-color-panel-swatch {
width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
transition: transform 0.08s ease;
}
.iwb-editor-color-pop .iwb-editor-color-panel-swatch:hover { transform: scale(1.12); }
.iwb-editor-color-pop .iwb-editor-color-panel-swatch:hover { transform: scale(1.14); }
.iwb-editor-color-pop .iwb-editor-color-panel-swatch.active {
outline: 2px solid #fff; outline-offset: 2px;
}
.iwb-editor-color-pop .iwb-editor-color-eye { width: 28px; height: 28px; border-radius: 6px; }
.iwb-editor-color-pop .iwb-editor-color-eye { width: 26px; height: 26px; border-radius: 6px; flex: 0 0 auto; }
/* ==== 钉住(v1.18)====
绝对定位到头部右上角:这样「无」按钮显隐都不会把图钉挤来挤去,
头部加 padding-right 让出位置,两者不会叠在一起。 */
.iwb-color-pop-head { position: relative; padding-right: 26px; }
.iwb-color-pop-pin {
position: absolute; right: 0; top: 50%; transform: translateY(-50%);
width: 22px; height: 22px; padding: 0;
display: inline-flex; align-items: center; justify-content: center;
border: 1px solid transparent; border-radius: 6px; background: transparent;
color: #9aa0b4; cursor: pointer;
}
.iwb-color-pop-pin:hover { background: #313244; color: #cdd6f4; }
/* 钉住态:琥珀色描边 + 淡底。用颜色而不是旋转表达「已钉住」,
旋转 45° 的图钉在 13px 下看起来像歪掉的问号。 */
.iwb-color-pop-pin.active {
background: rgba(232, 167, 53, 0.16); border-color: #e8a735; color: #f0b752;
}
/* ================================================================
v1.4:侧栏「快速效果」
@@ -2072,10 +2107,11 @@
/* 选项栏里色块旁边的分组标签,和「描边 / 底色」这类双字按钮区分开 */
.iwb-opt-swatch-label { color: #7f849c; font-size: 11px; flex: 0 0 auto; }
/* 「最近使用」:色板弹层里 4 列 × 2 行,空的时候整块隐藏(不占位) */
/* 「最近使用」:色板弹层里与常用色同一套 6 列 18px 网格(v1.18 起上限 6 个,正好一行),
空的时候整块隐藏(不占位)。 */
.iwb-editor-color-pop .iwb-editor-recent-colors {
display: grid;
grid-template-columns: repeat(4, 18px);
grid-template-columns: repeat(6, 18px);
grid-auto-rows: 18px;
gap: 5px;
flex: 0 0 auto;
@@ -2133,7 +2169,11 @@
/* 弹层是横排一行;右栏窄,改成竖排:调色器全宽 → HEX 一行 → 常用色 → 最近。
结构完全一样(同一份 DOM),差异全在这里用容器选择器覆盖。 */
.iwb-editor-colors .iwb-color-pop-head { flex-wrap: wrap; gap: 5px; }
.iwb-editor-colors .iwb-color-pop-head { flex-wrap: wrap; gap: 5px; padding-right: 0; }
/* 右栏不需要「钉住」(它本来就常驻),也不需要 v1.18 那层 side 容器:
display:contents 把它拆掉,子元素直接参与 body 的竖排 flex,和改版前一样。 */
.iwb-editor-colors .iwb-color-pop-pin { display: none; }
.iwb-editor-colors .iwb-color-pop-side { display: contents; }
.iwb-editor-colors .iwb-color-pop-tab { padding: 0 8px; }
.iwb-editor-colors .iwb-color-pop-body { flex-direction: column; align-items: stretch; gap: 8px; }
.iwb-editor-colors .iwb-color-pop-sep { display: none; }
+33 -18
View File
@@ -33,6 +33,10 @@ import { bindEvents } from './events.js'
<button type="button" class="iwb-color-pop-tab" data-color-slot="fill" title="正在调填充色(形状内部颜色 / 文字描边色)"><i></i><span class="iwb-color-pop-tab-label">填充</span></button>
<button type="button" class="iwb-color-pop-tab" data-color-slot="bg" hidden title="正在调文本框底色(垫在文字下面)"><i></i><span class="iwb-color-pop-tab-label">底色</span></button>
<button type="button" class="iwb-color-pop-none" data-color-none="1" title="无填充:形状内部透明,只留描边"><span></span>无</button>
<!-- 钉住(v1.18,用户 2026-11-10):调色常常要连着改好几处,每次点开色板太碎。
钉住后点画布 / 点别处都不收起,只有再点一次图钉、按 Esc、或点吸管才收。
图标是竖向图钉(头朝上),激活态整颗变琥珀色。 -->
<button type="button" class="iwb-color-pop-pin" data-action="pinColorPop" aria-pressed="false" title="钉住色板:一直开着,点画布也不收起(再点一次取消)"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 17v5"/><path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"/></svg></button>
</div>
<div class="iwb-color-pop-body">
<div class="iwb-color-pop-picker">
@@ -40,20 +44,24 @@ import { bindEvents } from './events.js'
<div class="iwb-color-hue"><span></span></div>
</div>
<span class="iwb-color-pop-sep"></span>
<div class="iwb-color-pop-fields">
<button type="button" class="iwb-editor-color-eye" data-action="palettePick" title="吸色:切到吸管工具,在画布上点一下取色"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m2 22 1-1h3l9-9"/><path d="M3 21v-3l9-9"/><path d="m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3Z"/></svg></button>
<input class="iwb-editor-color-hex-input" value="#ff4444" maxlength="7" spellcheck="false" autocomplete="off" title="十六进制颜色,回车生效">
</div>
<span class="iwb-color-pop-sep"></span>
<div class="iwb-color-group">
<span class="iwb-color-group-label">常用色</span>
<div class="iwb-editor-color-swatches">
${COMMON_COLORS.map(c => `<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="${c}" style="background:${c}" title="${c}"></button>`).join('')}
<!-- 右侧竖列(v1.18):设置 → 常用色 → 最近,三块上下叠,块间用 1px 细线分隔,
不再写「常用色 / 最近」小标题 —— 标题各占一行,是这块面板最浪费的高度。
右栏常驻面板复用同一份 DOM,那边用 display:contents 拆掉这一层,走自己的竖排。 -->
<div class="iwb-color-pop-side">
<div class="iwb-color-pop-fields">
<button type="button" class="iwb-editor-color-eye" data-action="palettePick" title="吸色:切到吸管工具,在画布上点一下取色"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m2 22 1-1h3l9-9"/><path d="M3 21v-3l9-9"/><path d="m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3Z"/></svg></button>
<input class="iwb-editor-color-hex-input" value="#ff4444" maxlength="7" spellcheck="false" autocomplete="off" title="十六进制颜色,回车生效">
</div>
<div class="iwb-color-group">
<span class="iwb-color-group-label">常用色</span>
<div class="iwb-editor-color-swatches">
${COMMON_COLORS.map(c => `<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="${c}" style="background:${c}" title="${c}"></button>`).join('')}
</div>
</div>
<div class="iwb-color-group">
<span class="iwb-color-group-label">最近</span>
<div class="iwb-editor-recent-colors" hidden title="最近使用"></div>
</div>
</div>
<div class="iwb-color-group">
<span class="iwb-color-group-label">最近</span>
<div class="iwb-editor-recent-colors" hidden title="最近使用"></div>
</div>
</div>`
}
@@ -75,11 +83,9 @@ import { bindEvents } from './events.js'
<button class="iwb-editor-btn iwb-editor-btn-replace" data-action="replace" title="用当前编辑结果覆盖原图">覆盖</button>
<button class="iwb-editor-btn iwb-editor-btn-cancel" data-action="cancel" title="放弃修改并退出">退出</button>
</div>
<div class="iwb-editor-history">
<button class="iwb-editor-action" data-action="undo" 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="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/></svg></button>
<button class="iwb-editor-action" data-action="redo" title="重做 (Ctrl+Shift+Z)"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/></svg></button>
<button class="iwb-editor-action iwb-editor-action-reset" data-action="reset" title="还原原图:删掉所有标注/图层,回到打开时的样子(Ctrl+Z 可撤销)"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 2v6h-6"/><path d="M3 12a9 9 0 0 1 15-6.7L21 8"/><path d="M3 22v-6h6"/><path d="M21 12a9 9 0 0 1-15 6.7L3 16"/></svg></button>
</div>
<!-- 撤销/重做/还原(v1.18,用户 2026-11-10):从顶栏搬到画布底部工具栏最右侧。
理由:这三个是「画画时会连着按」的操作,手在画布上,不该抬头去顶栏找。
顶栏只留会话组(新建/覆盖/退出)与输出。 -->
<!-- 顶栏命令带已清空(v1.13):
四个「置顶/上移/下移/置底」按钮删除(图层面板可拖动 + Ctrl+]/[ 已覆盖);
「适应窗口 / 收起侧栏」搬到画布底部工具栏最右侧,离画布更近。
@@ -213,6 +219,15 @@ import { bindEvents } from './events.js'
<span class="iwb-editor-divider"></span>
<button class="iwb-editor-tool iwb-editor-view-btn" data-action="zoomFit" title="适应窗口 (Ctrl+0):整张图缩放到刚好放得下"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 3 3 3 3 9"/><polyline points="15 3 21 3 21 9"/><polyline points="3 15 3 21 9 21"/><polyline points="21 15 21 21 15 21"/></svg></button>
<button class="iwb-editor-tool iwb-editor-view-btn" data-action="togglePanels" title="收起 / 展开侧栏 (Tab)"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="16" rx="2"/><line x1="9" y1="4" x2="9" y2="20"/></svg></button>
<!-- 撤销 / 重做 / 还原(v1.18):从顶栏移到工具条最右。
放在视图快捷之后,是整条工具栏真正的末端 —— 手在画布区时离得最近。 -->
<span class="iwb-editor-divider"></span>
<div class="iwb-editor-history">
<button class="iwb-editor-action" data-action="undo" 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="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/></svg></button>
<button class="iwb-editor-action" data-action="redo" title="重做 (Ctrl+Shift+Z)"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/></svg></button>
<button class="iwb-editor-action iwb-editor-action-reset" data-action="reset" title="还原原图:删掉所有标注/图层,回到打开时的样子(Ctrl+Z 可撤销)"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 2v6h-6"/><path d="M3 12a9 9 0 0 1 15-6.7L21 8"/><path d="M3 22v-6h6"/><path d="M21 12a9 9 0 0 1-15 6.7L3 16"/></svg></button>
</div>
</div>
</div>
<div class="iwb-editor-zoom-hint">滚轮缩放 · 抓手/空格/中键拖拽自由移动画布</div>
+35
View File
@@ -2240,6 +2240,37 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
})
}
/** v1.18 钉住(用户 2026-11-10):色板弹层常开,点画布 / 点别处都不收起。
* 状态存宿主 KV —— 钉住是一种「这段时间我要连着调色」的使用习惯,
* 不该每次开编辑器都重新钉一遍。 */
export function loadColorPopPinned() {
const st = S.callbacks && S.callbacks.settings
let on = false
if (st && typeof st.get === 'function') { try { on = !!st.get('colorPopPinned') } catch (e) { /* 宿主 KV 不可用就当没钉 */ } }
S.colorPopPinned = on
syncPinUI()
}
function setColorPopPinned(on) {
S.colorPopPinned = !!on
const st = S.callbacks && S.callbacks.settings
if (st && typeof st.set === 'function') {
try { st.set('colorPopPinned', S.colorPopPinned) } catch (e) { /* 存不下就只管本次会话 */ }
}
syncPinUI()
}
function syncPinUI() {
if (!runtime.el) return
runtime.el.querySelectorAll('[data-action="pinColorPop"]').forEach(btn => {
btn.classList.toggle('active', !!S.colorPopPinned)
btn.setAttribute('aria-pressed', String(!!S.colorPopPinned))
btn.title = S.colorPopPinned
? '已钉住:点画布不会收起色板(再点一次取消钉住)'
: '钉住色板:一直开着,点画布也不收起(再点一次取消)'
})
}
/** 关闭色板弹层;返回「关之前是开着的」,供 Esc 决定要不要吞掉这次按键 */
export function closeColorPop() {
const pop = runtime.el && runtime.el.querySelector('.iwb-editor-color-pop')
@@ -2303,7 +2334,9 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
if (pop) {
// 点外面关闭:必须用捕获阶段 —— 画布的 mousedown 会 preventDefault,
// 冒泡阶段拿不到「点了外面」这件事。右栏面板常驻,不参与关闭。
// 钉住时一律不关:这就是「钉住」的全部意义(要收就再点一次图钉,或按 Esc)。
document.addEventListener('mousedown', (e) => {
if (S.colorPopPinned) return
const onBtn = colorBtns.some(b => b.contains(e.target))
if (!pop.hidden && !pop.contains(e.target) && !onBtn) closeColorPop()
}, true)
@@ -2319,6 +2352,8 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
// tab 切换目标槽 / 「无」 / 常用色与最近色,统一委托:
// 静态 12 色 + 动态插入的「最近使用」都要能点,一次性 querySelectorAll 会漏掉后者
surface.addEventListener('click', (e) => {
const pin = e.target.closest('[data-action="pinColorPop"]')
if (pin) { e.stopPropagation(); setColorPopPinned(!S.colorPopPinned); return }
const tab = e.target.closest('.iwb-color-pop-tab[data-color-slot]')
if (tab) {
e.stopPropagation()
+3 -1
View File
@@ -33,7 +33,7 @@ import { createEl, loadImage } from './dom.js'
import { renderObjects, hideTextInput, textBounds } from './objects.js'
import { setupCanvas } from './viewport.js'
import { resetOverlayTransform } from './scale.js'
import { updateAllUI, bindLiteUI, renderOptionBar, updateStatusbar, loadSideWidth } from './events.js'
import { updateAllUI, bindLiteUI, renderOptionBar, updateStatusbar, loadSideWidth, loadColorPopPinned } from './events.js'
import { disposeSelection, renderSelection, selectionInfo, syncAnts, registerSelectionCommands } from './selection.js'
import { bindFloating, positionFloating, hideSelectionContext } from './floating.js'
import { renderFxPanel } from './effects.js'
@@ -69,6 +69,8 @@ import { toast } from './commands.js'
registerSelectionCommands()
loadExportOptions()
loadRecentColors()
// v1.18:色板「钉住」状态也来自宿主 KV,和常用色/最近色一起恢复
loadColorPopPinned()
bindLiteUI()
bindFloating()
bindExportUI()
@@ -1,7 +1,7 @@
/* recent-colors.js - 最近使用颜色(v1.9)
*
* 只依赖 state.js(叶子模块):tools.js 在改色时调用 rememberColor(),
* color pop 打开时 renderRecentColors() 把最近 8 个色块铺出来。
* color pop 打开时 renderRecentColors() 把最近 6 个色块铺出来。
* 持久化走宿主 ctx.settings(小 KV,不放像素,符合宿主存储约定)。
*/
@@ -9,7 +9,9 @@
import { S, runtime } from './state.js'
const MAX = 8
// v1.18:上限从 8 收到 6 —— 色板弹层右列改成 6 列网格(和「常用色」同一套),
// 6 个正好一行;8 个会折成第二行,把整块面板撑高 23px,和「更紧凑」的目标相反。
const MAX = 6
const KEY = 'recentColors'
function valid(hex) {
@@ -29,7 +31,7 @@ import { S, runtime } from './state.js'
renderRecentColors()
}
/** 记一个颜色:去重后置顶,最多 8 个 */
/** 记一个颜色:去重后置顶,最多 MAX 个 */
export function rememberColor(hex) {
if (!valid(hex)) return
const c = String(hex).toLowerCase()
+4 -1
View File
@@ -56,6 +56,9 @@
// 色板(调色器 / 吸管 / 推荐色 / hex)按这个值决定写 S.color 还是 shapeFillColor,
// 否则「三个地方各调各的颜色」会一直存在。
colorTarget: 'stroke', // stroke | fill
// v1.18:色板弹层是否「钉住」。钉住后点画布/点别处都不收起,方便连着调几处颜色。
// 存宿主 KV(跨会话记住):钉过一次就一直钉着,下次打开仍生效。
colorPopPinned: false,
// v1.16:右侧栏宽度(px)。0 = 按默认值走,打开编辑器时从宿主 KV 恢复。
// 宽度统一落在 CSS 变量 --iwb-side-w 上,不再各条规则各写一个魔数。
sideWidth: 0,
@@ -70,7 +73,7 @@
textBgFill: TEXT_DEFAULTS.bgFill, // 底色块
textBgColor: TEXT_DEFAULTS.bgColor, // 中性近黑,不再是纯黑 #000000
textBgAlpha: TEXT_DEFAULTS.bgAlpha, // 底色透明度(色块按这个不透明度显示,所见即所得)
// 最近使用颜色(最多 8 个,存 ctx.settings,跨会话保留)
// 最近使用颜色(最多 6 个,存 ctx.settings,跨会话保留)
recentColors: [],
// 图层系统
layers: [], // 位图图层数组 [{ id, name, canvas, ctx, opacity, visible, z }]
+133 -36
View File
@@ -9,7 +9,7 @@
var __IWB_ANNOTATE_MANIFEST__ = {
id: 'image-annotate',
name: '标注 / 修图',
version: '1.17.1',
version: '1.18.0',
apiVersion: 1,
capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'],
settings: {
@@ -235,6 +235,9 @@ var __IWB_ANNOTATE_MANIFEST__ = {
// 否则「三个地方各调各的颜色」会一直存在。
colorTarget: "stroke",
// stroke | fill
// v1.18:色板弹层是否「钉住」。钉住后点画布/点别处都不收起,方便连着调几处颜色。
// 存宿主 KV(跨会话记住):钉过一次就一直钉着,下次打开仍生效。
colorPopPinned: false,
// v1.16:右侧栏宽度(px)。0 = 按默认值走,打开编辑器时从宿主 KV 恢复。
// 宽度统一落在 CSS 变量 --iwb-side-w 上,不再各条规则各写一个魔数。
sideWidth: 0,
@@ -258,7 +261,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
// 中性近黑,不再是纯黑 #000000
textBgAlpha: TEXT_DEFAULTS.bgAlpha,
// 底色透明度(色块按这个不透明度显示,所见即所得)
// 最近使用颜色(最多 8 个,存 ctx.settings,跨会话保留)
// 最近使用颜色(最多 6 个,存 ctx.settings,跨会话保留)
recentColors: [],
// 图层系统
layers: [],
@@ -663,7 +666,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
}
// image-annotate/plugin/editor/recent-colors.js
var MAX = 8;
var MAX = 6;
var KEY = "recentColors";
function valid(hex) {
return /^#[0-9a-f]{6}$/i.test(String(hex || ""));
@@ -3517,6 +3520,10 @@ var __IWB_ANNOTATE_MANIFEST__ = {
<button type="button" class="iwb-color-pop-tab" data-color-slot="fill" title="正在调填充色(形状内部颜色 / 文字描边色)"><i></i><span class="iwb-color-pop-tab-label">填充</span></button>
<button type="button" class="iwb-color-pop-tab" data-color-slot="bg" hidden title="正在调文本框底色(垫在文字下面)"><i></i><span class="iwb-color-pop-tab-label">底色</span></button>
<button type="button" class="iwb-color-pop-none" data-color-none="1" title="无填充:形状内部透明,只留描边"><span></span>无</button>
<!-- 钉住(v1.18,用户 2026-11-10):调色常常要连着改好几处,每次点开色板太碎。
钉住后点画布 / 点别处都不收起,只有再点一次图钉、按 Esc、或点吸管才收。
图标是竖向图钉(头朝上),激活态整颗变琥珀色。 -->
<button type="button" class="iwb-color-pop-pin" data-action="pinColorPop" aria-pressed="false" title="钉住色板:一直开着,点画布也不收起(再点一次取消)"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 17v5"/><path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"/></svg></button>
</div>
<div class="iwb-color-pop-body">
<div class="iwb-color-pop-picker">
@@ -3524,20 +3531,24 @@ var __IWB_ANNOTATE_MANIFEST__ = {
<div class="iwb-color-hue"><span></span></div>
</div>
<span class="iwb-color-pop-sep"></span>
<div class="iwb-color-pop-fields">
<button type="button" class="iwb-editor-color-eye" data-action="palettePick" title="吸色:切到吸管工具,在画布上点一下取色"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m2 22 1-1h3l9-9"/><path d="M3 21v-3l9-9"/><path d="m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3Z"/></svg></button>
<input class="iwb-editor-color-hex-input" value="#ff4444" maxlength="7" spellcheck="false" autocomplete="off" title="十六进制颜色,回车生效">
</div>
<span class="iwb-color-pop-sep"></span>
<div class="iwb-color-group">
<span class="iwb-color-group-label">常用色</span>
<div class="iwb-editor-color-swatches">
${COMMON_COLORS.map((c) => `<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="${c}" style="background:${c}" title="${c}"></button>`).join("")}
<!-- 右侧竖列(v1.18):设置 → 常用色 → 最近,三块上下叠,块间用 1px 细线分隔,
不再写「常用色 / 最近」小标题 —— 标题各占一行,是这块面板最浪费的高度。
右栏常驻面板复用同一份 DOM,那边用 display:contents 拆掉这一层,走自己的竖排。 -->
<div class="iwb-color-pop-side">
<div class="iwb-color-pop-fields">
<button type="button" class="iwb-editor-color-eye" data-action="palettePick" title="吸色:切到吸管工具,在画布上点一下取色"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m2 22 1-1h3l9-9"/><path d="M3 21v-3l9-9"/><path d="m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3Z"/></svg></button>
<input class="iwb-editor-color-hex-input" value="#ff4444" maxlength="7" spellcheck="false" autocomplete="off" title="十六进制颜色,回车生效">
</div>
<div class="iwb-color-group">
<span class="iwb-color-group-label">常用色</span>
<div class="iwb-editor-color-swatches">
${COMMON_COLORS.map((c) => `<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="${c}" style="background:${c}" title="${c}"></button>`).join("")}
</div>
</div>
<div class="iwb-color-group">
<span class="iwb-color-group-label">最近</span>
<div class="iwb-editor-recent-colors" hidden title="最近使用"></div>
</div>
</div>
<div class="iwb-color-group">
<span class="iwb-color-group-label">最近</span>
<div class="iwb-editor-recent-colors" hidden title="最近使用"></div>
</div>
</div>`;
}
@@ -3556,11 +3567,9 @@ var __IWB_ANNOTATE_MANIFEST__ = {
<button class="iwb-editor-btn iwb-editor-btn-replace" data-action="replace" title="用当前编辑结果覆盖原图">覆盖</button>
<button class="iwb-editor-btn iwb-editor-btn-cancel" data-action="cancel" title="放弃修改并退出">退出</button>
</div>
<div class="iwb-editor-history">
<button class="iwb-editor-action" data-action="undo" 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="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/></svg></button>
<button class="iwb-editor-action" data-action="redo" title="重做 (Ctrl+Shift+Z)"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/></svg></button>
<button class="iwb-editor-action iwb-editor-action-reset" data-action="reset" title="还原原图:删掉所有标注/图层,回到打开时的样子(Ctrl+Z 可撤销)"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 2v6h-6"/><path d="M3 12a9 9 0 0 1 15-6.7L21 8"/><path d="M3 22v-6h6"/><path d="M21 12a9 9 0 0 1-15 6.7L3 16"/></svg></button>
</div>
<!-- 撤销/重做/还原(v1.18,用户 2026-11-10):从顶栏搬到画布底部工具栏最右侧。
理由:这三个是「画画时会连着按」的操作,手在画布上,不该抬头去顶栏找。
顶栏只留会话组(新建/覆盖/退出)与输出。 -->
<!-- 顶栏命令带已清空(v1.13):
四个「置顶/上移/下移/置底」按钮删除(图层面板可拖动 + Ctrl+]/[ 已覆盖);
「适应窗口 / 收起侧栏」搬到画布底部工具栏最右侧,离画布更近。
@@ -3694,6 +3703,15 @@ var __IWB_ANNOTATE_MANIFEST__ = {
<span class="iwb-editor-divider"></span>
<button class="iwb-editor-tool iwb-editor-view-btn" data-action="zoomFit" title="适应窗口 (Ctrl+0):整张图缩放到刚好放得下"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 3 3 3 3 9"/><polyline points="15 3 21 3 21 9"/><polyline points="3 15 3 21 9 21"/><polyline points="21 15 21 21 15 21"/></svg></button>
<button class="iwb-editor-tool iwb-editor-view-btn" data-action="togglePanels" title="收起 / 展开侧栏 (Tab)"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="16" rx="2"/><line x1="9" y1="4" x2="9" y2="20"/></svg></button>
<!-- 撤销 / 重做 / 还原(v1.18):从顶栏移到工具条最右。
放在视图快捷之后,是整条工具栏真正的末端 —— 手在画布区时离得最近。 -->
<span class="iwb-editor-divider"></span>
<div class="iwb-editor-history">
<button class="iwb-editor-action" data-action="undo" 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="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/></svg></button>
<button class="iwb-editor-action" data-action="redo" title="重做 (Ctrl+Shift+Z)"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/></svg></button>
<button class="iwb-editor-action iwb-editor-action-reset" data-action="reset" title="还原原图:删掉所有标注/图层,回到打开时的样子(Ctrl+Z 可撤销)"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 2v6h-6"/><path d="M3 12a9 9 0 0 1 15-6.7L21 8"/><path d="M3 22v-6h6"/><path d="M21 12a9 9 0 0 1-15 6.7L3 16"/></svg></button>
</div>
</div>
</div>
<div class="iwb-editor-zoom-hint">滚轮缩放 · 抓手/空格/中键拖拽自由移动画布</div>
@@ -6453,6 +6471,37 @@ var __IWB_ANNOTATE_MANIFEST__ = {
btn.addEventListener("click", () => setTool(btn.dataset.tool));
});
}
function loadColorPopPinned() {
const st = S.callbacks && S.callbacks.settings;
let on = false;
if (st && typeof st.get === "function") {
try {
on = !!st.get("colorPopPinned");
} catch (e) {
}
}
S.colorPopPinned = on;
syncPinUI();
}
function setColorPopPinned(on) {
S.colorPopPinned = !!on;
const st = S.callbacks && S.callbacks.settings;
if (st && typeof st.set === "function") {
try {
st.set("colorPopPinned", S.colorPopPinned);
} catch (e) {
}
}
syncPinUI();
}
function syncPinUI() {
if (!runtime.el) return;
runtime.el.querySelectorAll('[data-action="pinColorPop"]').forEach((btn) => {
btn.classList.toggle("active", !!S.colorPopPinned);
btn.setAttribute("aria-pressed", String(!!S.colorPopPinned));
btn.title = S.colorPopPinned ? "已钉住:点画布不会收起色板(再点一次取消钉住)" : "钉住色板:一直开着,点画布也不收起(再点一次取消)";
});
}
function closeColorPop() {
const pop = runtime.el && runtime.el.querySelector(".iwb-editor-color-pop");
if (!pop || pop.hidden) return false;
@@ -6508,6 +6557,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
});
if (pop) {
document.addEventListener("mousedown", (e) => {
if (S.colorPopPinned) return;
const onBtn = colorBtns.some((b) => b.contains(e.target));
if (!pop.hidden && !pop.contains(e.target) && !onBtn) closeColorPop();
}, true);
@@ -6519,6 +6569,12 @@ var __IWB_ANNOTATE_MANIFEST__ = {
const isPop = surface.classList.contains("iwb-editor-color-pop");
surface.addEventListener("mousedown", (e) => e.stopPropagation());
surface.addEventListener("click", (e) => {
const pin = e.target.closest('[data-action="pinColorPop"]');
if (pin) {
e.stopPropagation();
setColorPopPinned(!S.colorPopPinned);
return;
}
const tab = e.target.closest(".iwb-color-pop-tab[data-color-slot]");
if (tab) {
e.stopPropagation();
@@ -8548,6 +8604,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
registerSelectionCommands();
loadExportOptions();
loadRecentColors();
loadColorPopPinned();
bindLiteUI();
bindFloating();
bindExportUI();
@@ -9157,6 +9214,10 @@ var __IWB_ANNOTATE_MANIFEST__ = {
gap: 4px;
}
/* 撤销 / 重做 / 还原(v1.18):搬进工具条末端后需要一个 flex 容器,
否则三个 button 之间是 inline-block 的空隙,和左边 4px gap 的工具按钮对不齐。 */
.iwb-editor-history { display: flex; align-items: center; gap: 4px; }
.iwb-editor-tool, .iwb-editor-action {
background: #313244;
border: none;
@@ -10708,8 +10769,8 @@ var __IWB_ANNOTATE_MANIFEST__ = {
.iwb-editor-color-pop {
position: absolute; z-index: 60; display: flex; flex-direction: column; align-items: stretch; gap: 9px;
padding: 10px 12px; border-radius: 12px;
position: absolute; z-index: 60; display: flex; flex-direction: column; align-items: stretch; gap: 7px;
padding: 9px 11px; border-radius: 12px;
background: rgba(24, 24, 37, 0.97); border: 1px solid #313244;
box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
-webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
@@ -10747,29 +10808,60 @@ var __IWB_ANNOTATE_MANIFEST__ = {
.iwb-color-pop-none:hover { border-color: #f38ba8; color: #f38ba8; }
.iwb-color-pop-none.active { border-style: solid; border-color: #f38ba8; color: #f38ba8; background: rgba(243, 139, 168, 0.12); }
.iwb-color-pop-none[hidden] { display: none; }
.iwb-color-pop-body { display: flex; align-items: center; gap: 10px; }
.iwb-color-pop-body { display: flex; align-items: stretch; gap: 10px; }
.iwb-color-pop-picker { display: flex; gap: 8px; flex: 0 0 auto; }
.iwb-editor-color-pop .iwb-color-sv { width: 180px; height: 104px; flex: 0 0 180px; }
.iwb-editor-color-pop .iwb-color-hue { width: 16px; height: 104px; flex: 0 0 16px; }
.iwb-editor-color-pop .iwb-color-sv { width: 176px; height: 102px; flex: 0 0 176px; }
.iwb-editor-color-pop .iwb-color-hue { width: 16px; height: 102px; flex: 0 0 16px; }
.iwb-color-pop-sep { width: 1px; align-self: stretch; background: #313244; flex: 0 0 auto; }
.iwb-color-pop-fields { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
/* ==== 右列(v1.18,用户 2026-11-10)====
设置 / 常用色 / 最近 三块竖着叠,块之间 1px 细线,不写小标题:
原来「常用色」「最近」各占一行标题 + 横向铺开,整块面板又宽又高。
现宽 133px(6 列 × 18px),三块高度加起来刚好填满左侧取色器的高度。 */
.iwb-color-pop-side {
display: flex; flex-direction: column; justify-content: space-between;
width: 133px; flex: 0 0 133px; gap: 0;
}
/* 细线分隔:只加在「块与块之间」,第一块前面不加,否则顶部多一条悬空的线 */
.iwb-color-pop-side > * + * {
border-top: 1px solid #313244; margin-top: 5px; padding-top: 5px;
}
.iwb-color-pop-fields { display: flex; align-items: center; gap: 5px; }
.iwb-editor-color-pop .iwb-editor-color-hex-input {
width: 86px; height: 28px; padding: 0 6px; text-align: center;
flex: 1 1 auto; width: 0; height: 26px; padding: 0 5px; text-align: center;
font: 600 12px monospace; border-radius: 6px; box-sizing: border-box;
}
.iwb-editor-color-pop .iwb-editor-color-swatches {
display: grid; grid-template-columns: repeat(6, 22px); grid-auto-rows: 22px;
gap: 7px; flex: 0 0 auto; align-content: center;
display: grid; grid-template-columns: repeat(6, 18px); grid-auto-rows: 18px;
gap: 5px; flex: 0 0 auto; align-content: center;
}
.iwb-editor-color-pop .iwb-editor-color-panel-swatch {
width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
transition: transform 0.08s ease;
}
.iwb-editor-color-pop .iwb-editor-color-panel-swatch:hover { transform: scale(1.12); }
.iwb-editor-color-pop .iwb-editor-color-panel-swatch:hover { transform: scale(1.14); }
.iwb-editor-color-pop .iwb-editor-color-panel-swatch.active {
outline: 2px solid #fff; outline-offset: 2px;
}
.iwb-editor-color-pop .iwb-editor-color-eye { width: 28px; height: 28px; border-radius: 6px; }
.iwb-editor-color-pop .iwb-editor-color-eye { width: 26px; height: 26px; border-radius: 6px; flex: 0 0 auto; }
/* ==== 钉住(v1.18)====
绝对定位到头部右上角:这样「无」按钮显隐都不会把图钉挤来挤去,
头部加 padding-right 让出位置,两者不会叠在一起。 */
.iwb-color-pop-head { position: relative; padding-right: 26px; }
.iwb-color-pop-pin {
position: absolute; right: 0; top: 50%; transform: translateY(-50%);
width: 22px; height: 22px; padding: 0;
display: inline-flex; align-items: center; justify-content: center;
border: 1px solid transparent; border-radius: 6px; background: transparent;
color: #9aa0b4; cursor: pointer;
}
.iwb-color-pop-pin:hover { background: #313244; color: #cdd6f4; }
/* 钉住态:琥珀色描边 + 淡底。用颜色而不是旋转表达「已钉住」,
旋转 45° 的图钉在 13px 下看起来像歪掉的问号。 */
.iwb-color-pop-pin.active {
background: rgba(232, 167, 53, 0.16); border-color: #e8a735; color: #f0b752;
}
/* ================================================================
v1.4:侧栏「快速效果」
@@ -10997,10 +11089,11 @@ var __IWB_ANNOTATE_MANIFEST__ = {
/* 选项栏里色块旁边的分组标签,和「描边 / 底色」这类双字按钮区分开 */
.iwb-opt-swatch-label { color: #7f849c; font-size: 11px; flex: 0 0 auto; }
/* 「最近使用」:色板弹层里 4 列 × 2 行,空的时候整块隐藏(不占位) */
/* 「最近使用」:色板弹层里与常用色同一套 6 列 18px 网格(v1.18 起上限 6 个,正好一行),
空的时候整块隐藏(不占位)。 */
.iwb-editor-color-pop .iwb-editor-recent-colors {
display: grid;
grid-template-columns: repeat(4, 18px);
grid-template-columns: repeat(6, 18px);
grid-auto-rows: 18px;
gap: 5px;
flex: 0 0 auto;
@@ -11058,7 +11151,11 @@ var __IWB_ANNOTATE_MANIFEST__ = {
/* 弹层是横排一行;右栏窄,改成竖排:调色器全宽 → HEX 一行 → 常用色 → 最近。
结构完全一样(同一份 DOM),差异全在这里用容器选择器覆盖。 */
.iwb-editor-colors .iwb-color-pop-head { flex-wrap: wrap; gap: 5px; }
.iwb-editor-colors .iwb-color-pop-head { flex-wrap: wrap; gap: 5px; padding-right: 0; }
/* 右栏不需要「钉住」(它本来就常驻),也不需要 v1.18 那层 side 容器:
display:contents 把它拆掉,子元素直接参与 body 的竖排 flex,和改版前一样。 */
.iwb-editor-colors .iwb-color-pop-pin { display: none; }
.iwb-editor-colors .iwb-color-pop-side { display: contents; }
.iwb-editor-colors .iwb-color-pop-tab { padding: 0 8px; }
.iwb-editor-colors .iwb-color-pop-body { flex-direction: column; align-items: stretch; gap: 8px; }
.iwb-editor-colors .iwb-color-pop-sep { display: none; }
+100 -11
View File
@@ -193,6 +193,71 @@ check('色板弹层默认收起;点工具栏色点弹出、且整块在视口
return inView && !(await pop.isVisible()) ? true : 'box=' + JSON.stringify(box)
})())
// ---------- v1.18 色板弹层:钉住 + 右列竖排(用户 2026-11-10) ----------
// 需求原话:「加一个钉住,在需要调色的时候不用每次都要点开」「右边的数值、常用色、最近色
// 竖向排」「顺序改为设置、常用色、最近,这三项不用标题,用细横线分割」。
await page.locator('.iwb-editor-tool[data-tool="marquee"]').click() // 用选择工具点画布,不落像素
await page.locator('.iwb-editor-tools [data-action="toggleColorPop"][data-color-slot="stroke"]').click()
await page.waitForTimeout(140)
const popLayout = await page.evaluate(() => {
const pop = document.querySelector('.iwb-editor-color-pop')
const picker = pop.querySelector('.iwb-color-pop-picker')
const side = pop.querySelector('.iwb-color-pop-side')
const fields = pop.querySelector('.iwb-color-pop-fields')
const groups = [...side.querySelectorAll('.iwb-color-group')]
const r = (el) => el.getBoundingClientRect()
const pr = r(picker)
const sr = r(side)
const fr = r(fields)
const g0 = r(groups[0])
// 「最近」组在没有历史色时整块 hidden,rect 全是 0 —— 不能拿它参与几何比较
const g1el = groups[1]
const g1 = g1el && !g1el.hidden ? r(g1el) : null
return {
w: Math.round(r(pop).width),
h: Math.round(r(pop).height),
sideInRight: Math.round(sr.left) >= Math.round(pr.right), // 右列在取色器右边
threeStacked: fr.bottom <= g0.top + 1 && (!g1 || g0.bottom <= g1.top + 1), // 设置→常用→最近 自上而下
sameColumn: Math.abs(fr.left - g0.left) < 2 && (!g1 || Math.abs(g0.left - g1.left) < 2),
dividers: groups.map((g) => getComputedStyle(g).borderTopWidth),
labelsVisible: [...pop.querySelectorAll('.iwb-color-group-label')].filter((l) => l.offsetParent !== null).length,
swatch: Math.round(r(pop.querySelector('.iwb-editor-color-panel-swatch')).width),
}
})
check('色板右列竖排:设置 → 常用色 → 最近 同一列,1px 细线分隔且没有小标题',
popLayout.sideInRight && popLayout.threeStacked && popLayout.sameColumn &&
popLayout.labelsVisible === 0 && popLayout.dividers.every((d) => d === '1px'),
JSON.stringify(popLayout))
check('竖排后弹层比横排版更紧凑(宽度收窄、总高不超过 175px)',
popLayout.w < 460 && popLayout.h <= 175, 'w=' + popLayout.w + ' h=' + popLayout.h)
// 开发用:ANNOT_SHOT=/tmp/pop.png 出一张色板弹层截图(验证 v1.18 布局)
if (process.env.ANNOT_SHOT) await page.locator('.iwb-editor-color-pop').screenshot({ path: process.env.ANNOT_SHOT })
const pinBtn = page.locator('.iwb-editor-color-pop [data-action="pinColorPop"]')
await pinBtn.click()
await page.waitForTimeout(90)
await page.mouse.click(imgBox.x + imgBox.width * 0.5, imgBox.y + imgBox.height * 0.5)
await page.waitForTimeout(140)
const pinned = await page.evaluate(() => ({
open: !document.querySelector('.iwb-editor-color-pop').hidden,
active: document.querySelector('.iwb-editor-color-pop [data-action="pinColorPop"]').classList.contains('active'),
saved: window.__settings.colorPopPinned === true,
}))
check('钉住后点画布不收起,状态写进宿主 settings(下次打开仍钉着)',
pinned.open && pinned.active && pinned.saved, JSON.stringify(pinned))
await pinBtn.click()
await page.waitForTimeout(70)
await page.mouse.click(imgBox.x + imgBox.width * 0.35, imgBox.y + imgBox.height * 0.4)
await page.waitForTimeout(140)
const unpinned = await page.evaluate(() => ({
open: !document.querySelector('.iwb-editor-color-pop').hidden,
saved: window.__settings.colorPopPinned,
active: document.querySelector('.iwb-editor-color-pop [data-action="pinColorPop"]').classList.contains('active'),
}))
check('取消钉住后点画布立即收起(状态回到 false)',
!unpinned.open && unpinned.saved === false && !unpinned.active, JSON.stringify(unpinned))
const drag = async (x1, y1, x2, y2) => {
await page.mouse.move(x1, y1)
await page.mouse.down()
@@ -672,10 +737,9 @@ check('适应窗口后图片底边不被工具条遮挡', await page.evaluate(()
check('顶栏输出/导出按钮组贴最右侧(用户裁定 2026-11-04)', await page.evaluate(() => {
const hdr = document.querySelector('.iwb-editor-header')
const ex = document.querySelector('.iwb-editor-header > .iwb-editor-export-actions')
const hist = document.querySelector('.iwb-editor-header > .iwb-editor-history')
if (!hdr || !ex || !hist) return false
if (!hdr || !ex) return false
const h = hdr.getBoundingClientRect(), e = ex.getBoundingClientRect()
return h.right - e.right <= 14 && e.left > hist.getBoundingClientRect().right
return h.right - e.right <= 14
}))
// 橡皮:1.2.2 回归 —— events.js 少 import getActiveLayer,一按下就 ReferenceError,表现为「橡皮不能擦」
@@ -743,11 +807,15 @@ check('顶栏不再有图层层级按钮;视图快捷搬到画布工具栏最
const hdrAdd = document.querySelector('.iwb-editor-header [data-action="addBlankLayer"], .iwb-editor-header [data-action="addBitmapLayer"]')
const tools = document.querySelector('.iwb-editor-canvas-wrap > .iwb-editor-tools')
const kids = tools ? [...tools.children] : []
const lastTwo = kids.slice(-2).map(el => el.dataset && el.dataset.action)
// v1.18:撤销组搬进来后是 tools 的最后一个子元素,视图快捷退到它前面两位
// (中间还夹了一条分隔线 span,没有 data-action,过滤掉)
const histEl = kids.find(el => el.classList && el.classList.contains('iwb-editor-history')) || null
const lastTwo = kids.filter(el => el !== histEl && el.dataset && el.dataset.action)
.slice(-2).map(el => el.dataset.action)
return !q('.iwb-editor-more-wrap') && !q('[data-action="toggleMore"]') &&
hdrLayerBtns === 0 && !hdrAdd && addBtns === 4 &&
!q('.iwb-editor-header [data-action="zoomFit"]') && !q('.iwb-editor-header [data-action="togglePanels"]') &&
lastTwo.join(',') === 'zoomFit,togglePanels' &&
lastTwo.join(',') === 'zoomFit,togglePanels' && kids[kids.length - 1] === histEl &&
q('.iwb-editor-layer-panel-header [data-action="addBlankLayer"]') &&
q('.iwb-editor-layer-panel-header [data-action="addBitmapLayer"]') &&
q('.iwb-editor-layer-panel-header [data-action="mergeLayers"]') &&
@@ -755,7 +823,7 @@ check('顶栏不再有图层层级按钮;视图快捷搬到画布工具栏最
}))
check('「还原原图」图标是循环重置(refresh)而不是垃圾桶', await page.evaluate(() => {
const svg = document.querySelector('.iwb-editor-header [data-action="reset"] svg')
const svg = document.querySelector('.iwb-editor-tools [data-action="reset"] svg')
if (!svg) return false
const paths = svg.querySelectorAll('path').length
const polys = Array.from(svg.querySelectorAll('polyline')).map(p => p.getAttribute('points')).join('|')
@@ -1018,24 +1086,45 @@ await page.keyboard.press('Control+z') // 撤销上一步新建的矩形,恢
// ---- v1.2.9:会话组(新建/覆盖/退出)移到顶栏最左 + 图层 PS 快捷键 ----
check('顶栏:标题最前 → 新建/覆盖/退出(统一中性色)→ 竖分隔 → 撤销组,右侧只剩 输出+导出', await page.evaluate(() => {
check('顶栏:标题 → 新建/覆盖/退出(统一中性色),撤销组已搬去工具条,右侧只剩 输出+导出', await page.evaluate(() => {
const q = (s) => document.querySelector(s)
const session = q('.iwb-editor-header > .iwb-editor-session')
const title = q('.iwb-editor-header > .iwb-editor-title')
const hist = q('.iwb-editor-header > .iwb-editor-history')
const dl = q('.iwb-editor-header [data-action="download"]')
if (!session || !title || !hist || !dl) return false
const t = title.getBoundingClientRect(), s = session.getBoundingClientRect(), h = hist.getBoundingClientRect()
if (!session || !title || !dl) return false
const t = title.getBoundingClientRect(), s = session.getBoundingClientRect()
const btns = Array.from(session.querySelectorAll('.iwb-editor-btn')).map(b => b.dataset.action).join(',')
const bg = (sel) => getComputedStyle(q(sel)).backgroundColor
const unified = bg('.iwb-editor-header .iwb-editor-btn-new') === bg('.iwb-editor-header .iwb-editor-btn-replace') &&
bg('.iwb-editor-header .iwb-editor-btn-replace') === bg('.iwb-editor-header .iwb-editor-btn-cancel')
return btns === 'newNode,replace,cancel' &&
t.left < s.left && s.right < h.left &&
t.left < s.left &&
!q('.iwb-editor-header > .iwb-editor-history') && // v1.18 搬去工具条最右
!q('.iwb-editor-header > .iwb-editor-commands') &&
unified && dl.textContent.trim() === '导出' &&
!q('.iwb-editor-export-actions [data-action="newNode"]')
}))
// v1.18(用户 2026-11-10):撤销 / 重做 / 还原从顶栏搬到画布底部工具栏最右 —— 手在画布上时够得到
check('撤销 / 重做 / 还原 在工具条最右(视图快捷之后,是 tools 的最后一个子元素)', await page.evaluate(() => {
const tools = document.querySelector('.iwb-editor-tools')
const hist = tools && tools.querySelector('.iwb-editor-history')
const fit = tools && tools.querySelector('[data-action="zoomFit"]')
const panels = tools && tools.querySelector('[data-action="togglePanels"]')
const crop = tools && tools.querySelector('[data-tool="crop"]')
if (!hist || !fit || !panels || !crop) return false
const acts = [...hist.querySelectorAll('[data-action]')].map((b) => b.dataset.action).join(',')
const c = crop.getBoundingClientRect()
const f = fit.getBoundingClientRect()
const p = panels.getBoundingClientRect()
const h = hist.getBoundingClientRect()
return acts === 'undo,redo,reset' &&
tools.lastElementChild === hist &&
c.right <= f.left && f.right <= p.left && p.right <= h.left &&
Math.abs(h.top - c.top) < 2 // 与工具按钮同一条水平线,没有掉到第二行
}))
// 开发用:ANNOT_SHOT_BAR=/tmp/bar.png 出一张工具条截图(验证撤销组落在最右、没有换行)
if (process.env.ANNOT_SHOT_BAR) await page.locator('.iwb-editor-tools').screenshot({ path: process.env.ANNOT_SHOT_BAR })
check('画笔选项栏:推荐大小只留 4 个快捷点,硬度补 5 个快捷点且滑杆加宽', await (async () => {
await page.locator('.iwb-editor-tool[data-tool="brush"]').click()
const ok = await page.evaluate(() => {