feat(image-annotate): v1.6.0 色板入工具栏 + 快速效果 + 画完回 V + 图层合并(补齐 1.3.0–1.6.0)

上一次提交停在 1.2.12,本次把 1.3.0 → 1.6.0 四个版本的源码一并归档。

v1.3.0 色板进工具栏 + 矢量/文字工具只负责创建
- 工具栏最左色点 → 弹层(前调色器、后颜色设置 + 推荐颜色)
  - 弹层必须挂 .iwb-editor-modal 下:工具栏是 overflow-x:auto、画布 wrap 是 overflow:clip,塞进去会被裁
  - applyColorChange 改 pointerdown 拍一次快照,修「拖调色器爆撤销栈」
  - 每次按下前从 S.color 重同步 hsv,修「点推荐色后再拖 SV 跳回红」
  - 外部点击改 document 捕获阶段监听(画布 mousedown preventDefault,冒泡收不到)
- onShapeMouseDown / onTextMouseDown 不再命中已有对象;setTool 的 keepSel 只剩 select|picker

v1.4.0 侧栏快速效果
- 6 个:反白(反相,非排版意义的黑底白字)/ 灰度 / 提亮 / 压暗 / 高对比 / 马赛克
- 目标是当前位图图层,标题右侧实时显示层名;不碰图层几何也不改 image
- 导入图片层先克隆栅格化成「xxx · 效果」层、原层 visible=false(直接改像素会被 redraw 冲掉)
- 撤销走快照,base 与画笔层走像素路径

v1.5.0 画完自动回 V,编辑统一走 V
- 图形/文字落笔完成即退出当前工具并切 V
- 钢笔改为只用 V 双击进节点编辑
- 双击判定改成自算 380ms 窗口:单击选中会重绘矢量画布,浏览器不再派发 dblclick

v1.6.0 笔刷环 + 图层合并
- 画笔用 [ / ] 调粗细时立刻刷新笔刷环(原来只在 mousemove 里 drawToolRing,键改后不动)
- 图层合并:⌘/Ctrl 点击多选后合并、⌘E 向下合并、⌘⇧E 合并可见(PS 语义)
  - 统一用 composeUnitsInto 合成并按结果重排 z,避免合并后像素为空
  - 隐藏层不参与且保留;矢量(文字/形状/钢笔)直接栅格化
  - 有 base 参与时写回 base(像素快照可逐像素撤销),否则新建位图层承载

harness 129 项全通。1.6.0 已发布到线上:
plugin-image-annotate.198a20e4d722.js / sha256-GYog5NcinRDM67in67JxJUtBhUPB2lfttM/kw9UHwFo=
This commit is contained in:
qiqi committed 2026-11-05 11:27:37 +08:00
1 parent 577a891e73
commit 5f11e40f43
14 files changed
+2034 -233

No files matched your search

+129
View File
@@ -1608,3 +1608,132 @@
/* 标题与会话组之间、撤销组与命令带之间的竖分隔 */
.iwb-editor-header > .iwb-editor-session { margin-right: 4px; }
.iwb-editor-header > .iwb-editor-divider { width: 1px; height: 20px; background: #313244; flex: 0 0 auto; margin: 0 4px; }
/* ================================================================
v1.3:色板搬进工具栏(用户裁定 2026-11-05)
工具栏最左一个「当前色圆点」,点开在工具栏上方弹出色板:
[SV + 色相] | [吸管 + hex] | [6×2 推荐色]
弹层挂在 modal 下(不是工具栏里):工具栏 overflow-x:auto、
canvas-wrap overflow:clip,放里面必被裁;位置由 events.js 按按钮矩形算。
================================================================ */
.iwb-editor-modal { position: relative; }
.iwb-editor-canvas-wrap > .iwb-editor-tools .iwb-editor-color-btn {
width: 32px; height: 32px; min-width: 32px; flex: 0 0 auto; padding: 0;
border: 0; border-radius: 9px; background: #313244; cursor: pointer;
display: inline-flex; align-items: center; justify-content: center;
}
.iwb-editor-canvas-wrap > .iwb-editor-tools .iwb-editor-color-btn:hover,
.iwb-editor-canvas-wrap > .iwb-editor-tools .iwb-editor-color-btn.active { background: #45475a; }
.iwb-editor-color-btn i {
width: 18px; height: 18px; border-radius: 50%; display: block; background: #ff4444;
box-shadow: 0 0 0 2px #181825, 0 0 0 3px #585b70;
}
.iwb-editor-color-pop {
position: absolute; z-index: 60; display: flex; align-items: center; gap: 10px;
padding: 10px 12px; 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);
}
.iwb-editor-color-pop[hidden] { display: none; }
.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-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; }
.iwb-editor-color-pop .iwb-editor-color-hex-input {
width: 86px; height: 28px; padding: 0 6px; 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;
}
.iwb-editor-color-pop .iwb-editor-color-panel-swatch {
width: 22px; height: 22px; 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.active {
outline: 2px solid #fff; outline-offset: 2px;
}
.iwb-editor-color-pop .iwb-editor-color-eye { width: 28px; height: 28px; border-radius: 6px; }
/* ================================================================
v1.4:侧栏「快速效果」
3×2 网格,作用于当前位图图层。只做颜色/采样变换,不改几何。
图标全部用 CSS 渐变画(不引第三方库,也不加 SVG 体积)。
================================================================ */
.iwb-editor-fx {
display: flex; flex-direction: column; gap: 8px;
flex: 0 0 auto;
}
.iwb-editor-fx-head {
display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.iwb-editor-fx-title {
font-size: 11px; font-weight: 600; letter-spacing: 0.4px; color: #a6adc8;
}
.iwb-editor-fx-target {
max-width: 116px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
padding: 2px 6px; border-radius: 5px; background: #313244; color: #cdd6f4;
font-size: 10px; line-height: 1.4;
}
.iwb-editor-fx-grid {
display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.iwb-editor-fx-btn {
display: flex; flex-direction: column; align-items: center; gap: 5px;
padding: 7px 2px 6px; border: 1px solid transparent; border-radius: 9px;
background: #232334; color: #cdd6f4;
font: 500 10.5px/1 -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
cursor: pointer; transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
.iwb-editor-fx-btn:hover { background: #313244; border-color: #45475a; }
.iwb-editor-fx-btn:active { transform: scale(0.96); }
.iwb-editor-fx-btn:focus-visible { outline: 2px solid #89b4fa; outline-offset: 1px; }
.iwb-editor-fx-ico {
width: 22px; height: 22px; border-radius: 5px; display: block;
background-color: #d9d9e3;
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}
/* 图标统一垫浅色底:纯黑部分若直接压在深色按钮上会「消失」,看着像缺了个角 */
.ico-invert { background-image: linear-gradient(135deg, transparent 0 50%, #14141f 50% 100%); }
.ico-gray { background-image: linear-gradient(90deg, #12121c 0, #8a8a99 50%, #f4f4f8 100%); }
.ico-boost {
background-image: radial-gradient(circle at 50% 52%, #ffffff 0 24%, #cfcfdd 42%, #6e6e85 100%);
}
.ico-contrast { background-image: linear-gradient(90deg, #000000 0 46%, #ffffff 54% 100%); }
.ico-soft {
background-image: radial-gradient(circle at 50% 50%, #23233a 0 16%, rgba(35, 35, 58, 0.5) 34%, rgba(35, 35, 58, 0.16) 50%, rgba(35, 35, 58, 0) 68%);
}
.ico-mosaic {
background-image: repeating-conic-gradient(#6b6b80 0% 25%, #d9d9e3 0% 50%);
background-size: 10px 10px;
}
.iwb-editor-fx-tip {
margin: 0; font-size: 10px; line-height: 1.55; color: #6c7086;
}
/* ================================================================
v1.6:图层面板多选(⌘/Ctrl 点击)+ 合并按钮
多选用青色侧条与单选(橙色 #e8a735)区分:一个图层可以「被选中但不在合并集合里」,
两套状态不能长得一样。
================================================================ */
.iwb-layer-item.multi {
background: rgba(137, 180, 250, 0.14);
box-shadow: inset 2px 0 0 #89b4fa;
}
.iwb-layer-item.multi.active {
background: rgba(137, 180, 250, 0.2);
box-shadow: inset 2px 0 0 #89b4fa, inset 0 0 0 1px rgba(137, 180, 250, 0.45);
}
.iwb-editor-layer-add-group { flex: 0 0 auto; flex-wrap: nowrap; }
.iwb-editor-layer-add-btn[data-action="mergeLayers"]:hover,
.iwb-editor-layer-add-btn[data-action="mergeVisible"]:hover {
background: #45475a;
border-color: #89b4fa;
color: #cdd6f4;
}