From b9ace636efd8dc54f84f9733910f64d6cac2a989 Mon Sep 17 00:00:00 2001 From: qiqi Date: Wed, 4 Nov 2026 16:14:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(image-annotate):=20=E5=9B=BE=E5=B1=82=20z?= =?UTF-8?q?=20=E5=BA=8F=E7=BB=9F=E4=B8=80=20+=20=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E6=8C=89=E9=92=AE/=E9=80=89=E4=B8=AD=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=EF=BC=881.0.5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 根因:粘贴图片用 S.layers.length 当 z,矢量用 ++S.zCounter ⇒ z 撞车; 面板/DOM/合成/命中四处各自排序,导致排序按钮交换 z 无效、截图选不中、双高亮 - objects.js 新增 layerUnits()/layerUnitsDesc()/assignLayerZ()/selectUnit()/hitTopmost(): 图层顺序唯一真源、连续 z、选中态唯一、统一 z 降序命中 - moveLayer 改为统一列表重排(置顶/上移/下移/置底全部生效,base 固定在最底不吞元素) - placement 改 ++S.zCounter;deleteLayer 不再重置位图 z;面板高亮与画笔目标(✎)分离 - 形状/文字/钢笔创建、裁剪、清空标注、重开编辑器均清旧位图选中 id - e2e 补 9 条回归断言(真站 22/22 通过);README 记录与上游的偏离,防回灌覆盖 --- image-annotate/README.md | 28 +- image-annotate/package.json | 2 +- image-annotate/plugin/editor.css | 2 + image-annotate/plugin/editor/crop.js | 3 + image-annotate/plugin/editor/events.js | 62 ++-- image-annotate/plugin/editor/history.js | 2 + image-annotate/plugin/editor/index.js | 3 + image-annotate/plugin/editor/layers.js | 178 ++++------- image-annotate/plugin/editor/objects.js | 115 ++++--- image-annotate/plugin/editor/placement.js | 4 +- image-annotate/plugin/editor/tools.js | 17 +- image-annotate/src/index.js | 370 ++++++++++------------ image-annotate/tools/e2e-site.mjs | 44 ++- 13 files changed, 432 insertions(+), 398 deletions(-) diff --git a/image-annotate/README.md b/image-annotate/README.md index 9f68dd5..f621ec0 100644 --- a/image-annotate/README.md +++ b/image-annotate/README.md @@ -5,10 +5,12 @@ 编辑器**移植自** `iwb-plaus` 仓库的 `iwb-cutout-extension`(纯 Canvas 2D、零第三方库): - 源:`/Users/qiqi/open/github/iwb-plaus/iwb-cutout-extension/src/editor/`(11 个模块)+ `src/shared/{image-math,layer-logic}.js` -- 差异:只有「宿主胶水」(`plugin/glue.js`、`plugin/entry.js`)是新写的;编辑器模块与样式**逐字移植**,便于日后回灌上游 —— **唯一例外见下**。 +- 差异:只有「宿主胶水」(`plugin/glue.js`、`plugin/entry.js`)是新写的;编辑器模块与样式**逐字移植**,便于日后回灌上游 —— **例外见下两节**(`loadImage` 的 CSP 适配、v1.0.5 的图层顺序修复)。 - 原扩展的 CSS 由 `manifest.json` 的 `content_scripts.css` 注入;插件没有 manifest,改为构建时以字符串内联、运行时注入 `