Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fdfb4ed603 | ||
|
|
929b7ec2a1 | ||
|
|
a94e5be954 | ||
|
|
b6d10339f6 | ||
|
|
89c8e0a1d8 | ||
|
|
9bbb94b789 | ||
|
|
6284f84d29 | ||
|
|
b299895730 |
No files matched your search
@@ -234,6 +234,94 @@ P 下双击 = 结束当前路径(`commitPenPath`),不再进节点编辑。
|
|||||||
- 文字 / 形状 / 钢笔会被直接栅格化进结果层(PS 合并矢量层也是这个结果)。
|
- 文字 / 形状 / 钢笔会被直接栅格化进结果层(PS 合并矢量层也是这个结果)。
|
||||||
- 结果层落回「原最低参与层」的位置,`assignLayerZ` 重新连续编号,不产生重复 z。
|
- 结果层落回「原最低参与层」的位置,`assignLayerZ` 重新连续编号,不产生重复 z。
|
||||||
|
|
||||||
|
## v1.19.0:右栏调色模块退场 / 头部一行装完 / 常用色 16 个 + 最近两排
|
||||||
|
|
||||||
|
用户一段话:「右边栏的调色模块就可以去掉了,然后还去一个去色按钮,可以放在钉住按钮的左边,
|
||||||
|
用竖线分割,然后我希望最近色多几个…把吸色与色值数放在钉住按钮的一排,那下面的最近色就可以放两排了。
|
||||||
|
后宽度可以再多一点点,就是让颜色按钮一排可以放 8 个,那你就需要多加 4 个常用色」。
|
||||||
|
|
||||||
|
**1) 右栏常驻调色面板删除。**
|
||||||
|
色板现在只有工具栏弹层一处。v1.16 加它是因为「不想每次点开弹层」,但 v1.18 的钉住已经解决了同一件事——
|
||||||
|
弹层钉住后本来就是一个常开的浮层,右栏那份是同样内容的第二个副本,还占着最显眼的位置。
|
||||||
|
顺带少了一层「同一份 DOM 两套 CSS 布局」的分支,改色板不用再担心改了这头没那头。
|
||||||
|
|
||||||
|
**2) 头部一行装完**:调色槽 │ 吸管 + 色值 │ 去色 │ 图钉
|
||||||
|
|
||||||
|
```
|
||||||
|
[描边●][填充●] │ ⌖ [ #FFD400 ] │ [⊘ 去色] │ 📌
|
||||||
|
```
|
||||||
|
|
||||||
|
- 吸管与色值从右列搬到头部,body 的整块高度都留给色块 —— 这是「最近色能放两排」的前提。
|
||||||
|
- 「无」改名**去色**,挪到图钉左边、用 1px 竖线隔开:调色时「这一项不上色」和「钉住」都是随手要按的开关。
|
||||||
|
对描边/填充/底色都生效,title 随当前槽变。
|
||||||
|
- 没有可去色的上下文(没选中对象、文字色这种单槽)时它本来就隐藏,**它前面那条竖线跟着一起藏**
|
||||||
|
(`:has(> .iwb-color-pop-none[hidden])`),否则头部右侧会留一截悬空的「||」。
|
||||||
|
- 「去色 | 图钉」整组用 `margin-left: auto` 贴最右,色值框固定 150px 不被拉成长条
|
||||||
|
(拉长后视觉重心全跑到输入框上,色块反倒成了配角)。tab 加 `flex: 0 0 auto; white-space: nowrap`——
|
||||||
|
宽度不够时该缩的是色值框,不是把「描边」压成竖排两个字。
|
||||||
|
|
||||||
|
**3) 色块 8 列 × 2 行,常用色 12 → 16,最近色 6 → 16。**
|
||||||
|
|
||||||
|
第一行是 8 个饱和亮色,第二行是 4 个中性色 + 4 个同色系「深一档」:
|
||||||
|
|
||||||
|
```
|
||||||
|
亮:#ff4444 #ff8a00 #ffd400 #4cd964 #00bfa5 #4488ff #aa44ff #ff66aa
|
||||||
|
常:#ffffff #d0d0d0 #808080 #000000 #c0392b #0f9d58 #1677ff #6b4fbb
|
||||||
|
```
|
||||||
|
|
||||||
|
加的那 4 个(深红/深绿/深蓝/深紫)在浅色底图上比亮色稳,做描边不刺眼。色块 18 → 20px。
|
||||||
|
弹层 **380×153 → 440×157**(宽度 +16%,高度只 +4px —— 多出来的一排被「吸管+色值上移」抵掉了)。
|
||||||
|
|
||||||
|
两个刻意的决定:
|
||||||
|
|
||||||
|
- **弹层宽度写死 440px**。绝对定位元素是 shrink-to-fit,宽度会跟着最长内容走:
|
||||||
|
文字工具多出「底色」tab 时头部变宽,弹层当场变宽 17px 再跳回来,定位还得重算。
|
||||||
|
- **分隔线从 `#313244` 提到 `#3b3b4e`**。没有小标题时,这条线是唯一能看出「常用 / 最近」分界的东西,
|
||||||
|
按原色画在深底上几乎看不见。
|
||||||
|
|
||||||
|
**验证**:harness 229 项、真站 e2e 见下。新增 harness 断言:头部四个控件同一水平线 + 去色在图钉左边 +
|
||||||
|
两者之间有竖线 + 三 tab(文字工具)时头部不横向溢出、常用色 16 个严格 8 列 2 行、最近色网格 8 列 2 排、
|
||||||
|
弹层宽高区间、右栏第一个模块是「图片调节」且无 `[data-color-surface]`。
|
||||||
|
|
||||||
|
## 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 照样交换
|
## v1.17.0:描边也能是「无色」+ 一边无色时 Shift+X 照样交换
|
||||||
|
|
||||||
用户两句话:「让矢量图形与钢笔的描边色也可以去掉」「描边与填充有一个是无色的时候可以交换,
|
用户两句话:「让矢量图形与钢笔的描边色也可以去掉」「描边与填充有一个是无色的时候可以交换,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@iwb-plugin/image-annotate",
|
"name": "@iwb-plugin/image-annotate",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.17.1",
|
"version": "1.19.0",
|
||||||
"description": "IWB 插件:图片标注 / 修图(编辑器移植自 iwb-plaus 扩展,纯 Canvas 2D)",
|
"description": "IWB 插件:图片标注 / 修图(编辑器移植自 iwb-plaus 扩展,纯 Canvas 2D)",
|
||||||
"ibwPlugin": {
|
"ibwPlugin": {
|
||||||
"id": "image-annotate",
|
"id": "image-annotate",
|
||||||
|
|||||||
@@ -232,6 +232,10 @@
|
|||||||
gap: 4px;
|
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 {
|
.iwb-editor-tool, .iwb-editor-action {
|
||||||
background: #313244;
|
background: #313244;
|
||||||
border: none;
|
border: none;
|
||||||
@@ -273,7 +277,6 @@
|
|||||||
.iwb-editor-params .iwb-editor-zoom { margin-left: auto; order: 20; }
|
.iwb-editor-params .iwb-editor-zoom { margin-left: auto; order: 20; }
|
||||||
.iwb-editor-top-colors { display: none; }
|
.iwb-editor-top-colors { display: none; }
|
||||||
|
|
||||||
.iwb-editor-colors { display: flex; gap: 4px; }
|
|
||||||
.iwb-editor-color {
|
.iwb-editor-color {
|
||||||
width: 20px; height: 20px;
|
width: 20px; height: 20px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
@@ -1783,17 +1786,36 @@
|
|||||||
|
|
||||||
|
|
||||||
.iwb-editor-color-pop {
|
.iwb-editor-color-pop {
|
||||||
position: absolute; z-index: 60; display: flex; flex-direction: column; align-items: stretch; gap: 9px;
|
position: absolute; z-index: 60; display: flex; flex-direction: column; align-items: stretch; gap: 7px;
|
||||||
padding: 10px 12px; border-radius: 12px;
|
/* 固定宽度(不是让内容撑):绝对定位元素是 shrink-to-fit,宽度会跟着最长内容走 ——
|
||||||
|
文字工具多出「底色」tab 时头部变宽,弹层当场变宽 17px 再跳回来,定位也要重算。
|
||||||
|
440 = 内容 416(SV 176 + 8 + 色相 16 + 10 + 1 + 10 + 色块 195)+ 左右 padding 22 + 边框 2。 */
|
||||||
|
box-sizing: border-box; width: 440px;
|
||||||
|
padding: 9px 11px; border-radius: 12px;
|
||||||
background: rgba(24, 24, 37, 0.97); border: 1px solid #313244;
|
background: rgba(24, 24, 37, 0.97); border: 1px solid #313244;
|
||||||
box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
|
box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
|
||||||
-webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
|
-webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
|
||||||
}
|
}
|
||||||
.iwb-editor-color-pop[hidden] { display: none; }
|
.iwb-editor-color-pop[hidden] { display: none; }
|
||||||
/* 弹层头部:说明现在调的是描边还是填充,并可直接换;右侧是「无」(仅填充) */
|
/* 弹层头部(v1.19 一行装完):
|
||||||
|
调哪个槽(描边/填充/底色)│ 吸管 + 色值 │ 去色 │ 图钉
|
||||||
|
原来「吸管 + 色值」在右列占一整块,现在提到头部,body 的整块高度都留给色块。 */
|
||||||
.iwb-color-pop-head { display: flex; align-items: center; gap: 6px; }
|
.iwb-color-pop-head { display: flex; align-items: center; gap: 6px; }
|
||||||
|
/* 竖线:分隔「调哪个槽 / 取色工具 / 去色·钉住」三组,比空白更清楚,又不加边框重量 */
|
||||||
|
.iwb-color-pop-bar { width: 1px; height: 16px; background: #313244; flex: 0 0 auto; }
|
||||||
|
/* 「去色 | 图钉」整组贴最右(margin-left:auto)。这样色值框不用拉成一条长条去填空,
|
||||||
|
头部是「左边调色槽与工具 / 右边两个开关」两段式,扫视时不会把 HEX 当成主角。 */
|
||||||
|
.iwb-color-pop-tools { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
|
||||||
|
/* 没有可去色的上下文(未选中对象 / 文字色这种单槽)时「去色」是隐藏的,
|
||||||
|
它前面那条竖线要一起藏掉,否则头部右侧会留下一截悬空的「||」;
|
||||||
|
两条都藏掉后整组只剩图钉,竖线也不再夹在「色值 | 图钉」之间显得多余 */
|
||||||
|
.iwb-color-pop-tools:has(> .iwb-color-pop-none[hidden]) > .iwb-color-pop-bar { display: none; }
|
||||||
|
|
||||||
.iwb-color-pop-tab {
|
.iwb-color-pop-tab {
|
||||||
display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px;
|
display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px;
|
||||||
|
/* 不许被压缩、不许折行:头部一行要同时装下 tab + 吸管 + 色值 + 去色 + 图钉,
|
||||||
|
宽度不够时该缩的是色值框(flex:0 1),不是把「描边」压成竖排两个字 */
|
||||||
|
flex: 0 0 auto; white-space: nowrap;
|
||||||
border: 1px solid transparent; border-radius: 7px; background: #232334;
|
border: 1px solid transparent; border-radius: 7px; background: #232334;
|
||||||
color: #a6adc8; font: 500 11.5px/1 -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
|
color: #a6adc8; font: 500 11.5px/1 -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@@ -1810,41 +1832,81 @@
|
|||||||
background-image: linear-gradient(135deg, transparent calc(50% - 1px), #f38ba8 calc(50% - 1px), #f38ba8 calc(50% + 1px), transparent calc(50% + 1px));
|
background-image: linear-gradient(135deg, transparent calc(50% - 1px), #f38ba8 calc(50% - 1px), #f38ba8 calc(50% + 1px), transparent calc(50% + 1px));
|
||||||
}
|
}
|
||||||
.iwb-color-pop-tab[hidden] { display: none; }
|
.iwb-color-pop-tab[hidden] { display: none; }
|
||||||
|
/* 去色(v1.19):原来的「无」改名挪位。虚线框 + 红斜圈,和「实心色块」区分开;
|
||||||
|
它是开关不是色块,所以不用填充色表达状态,只换边框/文字色。 */
|
||||||
.iwb-color-pop-none {
|
.iwb-color-pop-none {
|
||||||
margin-left: auto; display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px;
|
flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px;
|
||||||
border: 1px dashed #585b70; border-radius: 7px; background: transparent; color: #a6adc8;
|
border: 1px dashed #585b70; border-radius: 7px; background: transparent; color: #a6adc8;
|
||||||
font: 500 11.5px/1 -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; cursor: pointer;
|
font: 500 11.5px/1 -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; cursor: pointer;
|
||||||
}
|
}
|
||||||
.iwb-color-pop-none span {
|
.iwb-color-pop-none svg { flex: 0 0 auto; }
|
||||||
width: 11px; height: 11px; border-radius: 3px; display: block; background-color: #45475a;
|
|
||||||
background-image: linear-gradient(135deg, transparent calc(50% - 1px), #f38ba8 calc(50% - 1px), #f38ba8 calc(50% + 1px), transparent calc(50% + 1px));
|
|
||||||
}
|
|
||||||
.iwb-color-pop-none:hover { border-color: #f38ba8; color: #f38ba8; }
|
.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.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-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-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-sv { width: 176px; height: 104px; flex: 0 0 176px; }
|
||||||
.iwb-editor-color-pop .iwb-color-hue { width: 16px; height: 104px; flex: 0 0 16px; }
|
.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-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.19,用户 2026-11-10)====
|
||||||
|
常用色 8×2 在上、最近色 8×2 在下,块间 1px 细线,不写小标题。
|
||||||
|
8 列 20px = 195px;两排色块(45 + 11 + 45 = 101)刚好填满左侧取色器 104 的高度,
|
||||||
|
所以整个弹层只有头部 + 取色器两层,没有多余留白。 */
|
||||||
|
.iwb-color-pop-side {
|
||||||
|
display: flex; flex-direction: column; justify-content: center;
|
||||||
|
width: 195px; flex: 0 0 195px; gap: 0;
|
||||||
|
}
|
||||||
|
/* 细线分隔:只加在「块与块之间」,第一块前面不加,否则顶部多一条悬空的线。
|
||||||
|
色号比背景亮两档(#3b3b4e):没有小标题时,这条线是唯一能看出「常用 / 最近」分界的东西,
|
||||||
|
按 #313244 画在深底上几乎看不见。 */
|
||||||
|
.iwb-color-pop-side > * + * {
|
||||||
|
border-top: 1px solid #3b3b4e; margin-top: 5px; padding-top: 5px;
|
||||||
|
}
|
||||||
|
.iwb-color-group { display: flex; flex-direction: column; gap: 0; min-width: 0; flex: 0 0 auto; }
|
||||||
|
/* 标题不显示:「常用色 / 最近」各占一行是这块面板最浪费的高度,
|
||||||
|
色块自己的 title 已经写明是哪一个、哪一个最近用过 */
|
||||||
|
.iwb-editor-color-pop .iwb-color-group-label { display: none; }
|
||||||
|
/* display:flex 会盖掉 [hidden] 的默认 display:none,必须显式写一条 */
|
||||||
|
.iwb-color-group[hidden] { display: none; }
|
||||||
|
|
||||||
|
/* 色值输入固定 150px:够显示 #RRGGBB 还有余量,又不会被 flex-grow 拉成一条长条
|
||||||
|
(拉长后视觉重心全跑到输入框上,色块反倒成了配角)。
|
||||||
|
文字工具多出「底色」tab 时按 0 1 150 自动收缩,min-width 保证七个字符看得全。 */
|
||||||
.iwb-editor-color-pop .iwb-editor-color-hex-input {
|
.iwb-editor-color-pop .iwb-editor-color-hex-input {
|
||||||
width: 86px; height: 28px; padding: 0 6px; text-align: center;
|
flex: 0 1 150px; width: 150px; min-width: 58px; height: 26px; padding: 0 5px; text-align: center;
|
||||||
font: 600 12px monospace; border-radius: 6px; box-sizing: border-box;
|
font: 600 12px monospace; border-radius: 6px; box-sizing: border-box;
|
||||||
}
|
}
|
||||||
.iwb-editor-color-pop .iwb-editor-color-swatches {
|
.iwb-editor-color-pop .iwb-editor-color-swatches {
|
||||||
display: grid; grid-template-columns: repeat(6, 22px); grid-auto-rows: 22px;
|
display: grid; grid-template-columns: repeat(8, 20px); grid-auto-rows: 20px;
|
||||||
gap: 7px; flex: 0 0 auto; align-content: center;
|
gap: 5px; flex: 0 0 auto; align-content: center;
|
||||||
}
|
}
|
||||||
.iwb-editor-color-pop .iwb-editor-color-panel-swatch {
|
.iwb-editor-color-pop .iwb-editor-color-panel-swatch {
|
||||||
width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
|
width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
|
||||||
transition: transform 0.08s ease;
|
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 {
|
.iwb-editor-color-pop .iwb-editor-color-panel-swatch.active {
|
||||||
outline: 2px solid #fff; outline-offset: 2px;
|
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 / v1.19 改为流式)====
|
||||||
|
v1.18 是绝对定位贴右上角(躲开「无」按钮显隐带来的位移);
|
||||||
|
v1.19「吸管 + 色值」也进了头部,头部本来就是一排可变宽控件,
|
||||||
|
图钉跟着流走反而更稳 —— 竖线已经把「去色 | 图钉」和左边隔开,位置不会再被误读。 */
|
||||||
|
.iwb-color-pop-pin {
|
||||||
|
flex: 0 0 auto; width: 24px; height: 24px; 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:侧栏「快速效果」
|
v1.4:侧栏「快速效果」
|
||||||
@@ -2072,19 +2134,20 @@
|
|||||||
/* 选项栏里色块旁边的分组标签,和「描边 / 底色」这类双字按钮区分开 */
|
/* 选项栏里色块旁边的分组标签,和「描边 / 底色」这类双字按钮区分开 */
|
||||||
.iwb-opt-swatch-label { color: #7f849c; font-size: 11px; flex: 0 0 auto; }
|
.iwb-opt-swatch-label { color: #7f849c; font-size: 11px; flex: 0 0 auto; }
|
||||||
|
|
||||||
/* 「最近使用」:色板弹层里 4 列 × 2 行,空的时候整块隐藏(不占位) */
|
/* 「最近使用」:与常用色同一套 8 列 20px 网格(v1.19 起最多 16 个 = 铺满两排),
|
||||||
|
空的时候整块隐藏(不占位)。 */
|
||||||
.iwb-editor-color-pop .iwb-editor-recent-colors {
|
.iwb-editor-color-pop .iwb-editor-recent-colors {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(4, 18px);
|
grid-template-columns: repeat(8, 20px);
|
||||||
grid-auto-rows: 18px;
|
grid-auto-rows: 20px;
|
||||||
gap: 5px;
|
gap: 5px;
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
align-content: center;
|
align-content: center;
|
||||||
}
|
}
|
||||||
.iwb-editor-recent-colors[hidden] { display: none; }
|
.iwb-editor-recent-colors[hidden] { display: none; }
|
||||||
.iwb-editor-color-pop .iwb-editor-recent-colors .iwb-editor-color-panel-swatch {
|
.iwb-editor-color-pop .iwb-editor-recent-colors .iwb-editor-color-panel-swatch {
|
||||||
width: 18px;
|
width: 20px;
|
||||||
height: 18px;
|
height: 20px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border: 0;
|
border: 0;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
@@ -2120,53 +2183,12 @@
|
|||||||
.iwb-editor-side-resizer:hover::after,
|
.iwb-editor-side-resizer:hover::after,
|
||||||
.iwb-editor-side-resizer.is-dragging::after { background: #e8a735; }
|
.iwb-editor-side-resizer.is-dragging::after { background: #e8a735; }
|
||||||
|
|
||||||
/* ---- 2) 右栏调色面板 ---- */
|
/* ---- 2) 右栏调色面板:已删(v1.19,用户 2026-11-10) ----
|
||||||
.iwb-editor-colors {
|
颜色只剩工具栏弹层一处。弹层钉住后本来就常开,右栏那份只是重复占位。
|
||||||
display: flex; flex-direction: column; gap: 9px;
|
原来这里的 .iwb-editor-colors / .iwb-editor-colors-head / 以及一批
|
||||||
padding: 9px 10px 10px; border-radius: 10px;
|
`.iwb-editor-colors .iwb-color-pop-*` 覆盖规则(弹层横排、右栏竖排)全部移除 ——
|
||||||
background: #1e1e2c; border: 1px solid #2f2f42;
|
少一层「同一份 DOM 两套布局」的分支,改色板不会再出现「改了一处另一处没跟上」。 */
|
||||||
flex: 0 0 auto;
|
|
||||||
}
|
|
||||||
.iwb-editor-colors-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
|
|
||||||
.iwb-editor-colors-title { font-size: 13px; font-weight: 600; color: #cdd6f4; }
|
|
||||||
.iwb-editor-colors-hint { font-size: 11.5px; color: #7f87a3; }
|
|
||||||
|
|
||||||
/* 弹层是横排一行;右栏窄,改成竖排:调色器全宽 → HEX 一行 → 常用色 → 最近。
|
|
||||||
结构完全一样(同一份 DOM),差异全在这里用容器选择器覆盖。 */
|
|
||||||
.iwb-editor-colors .iwb-color-pop-head { flex-wrap: wrap; gap: 5px; }
|
|
||||||
.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; }
|
|
||||||
.iwb-editor-colors .iwb-color-pop-picker { width: 100%; gap: 6px; }
|
|
||||||
.iwb-editor-colors .iwb-color-sv { flex: 1 1 auto; width: auto; height: 118px; }
|
|
||||||
.iwb-editor-colors .iwb-color-hue { width: 16px; height: 118px; flex: 0 0 16px; }
|
|
||||||
.iwb-editor-colors .iwb-color-pop-fields { width: 100%; gap: 6px; }
|
|
||||||
.iwb-editor-colors .iwb-editor-color-hex-input { flex: 1 1 auto; width: auto; height: 28px; }
|
|
||||||
.iwb-editor-colors .iwb-editor-color-eye { width: 30px; height: 28px; border-radius: 6px; flex: 0 0 auto; }
|
|
||||||
|
|
||||||
/* 分组:右栏显示「常用色 / 最近」小标题,弹层里隐藏(那里横向排得下,加标题反而占高) */
|
|
||||||
.iwb-color-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 0 0 auto; }
|
|
||||||
.iwb-color-group-label { font-size: 11.5px; color: #7f87a3; letter-spacing: 0.3px; }
|
|
||||||
.iwb-editor-color-pop .iwb-color-group { gap: 0; }
|
|
||||||
.iwb-editor-color-pop .iwb-color-group-label { display: none; }
|
|
||||||
/* display:flex 会盖掉 [hidden] 的默认 display:none,必须显式写一条 */
|
|
||||||
.iwb-color-group[hidden] { display: none; }
|
|
||||||
|
|
||||||
/* 右栏色块:网格按容器宽度自适应,拖宽后一行能多放几个 */
|
|
||||||
.iwb-editor-colors .iwb-editor-color-swatches {
|
|
||||||
display: grid; grid-template-columns: repeat(auto-fill, minmax(24px, 1fr));
|
|
||||||
gap: 6px; width: 100%;
|
|
||||||
}
|
|
||||||
.iwb-editor-colors .iwb-editor-recent-colors {
|
|
||||||
display: grid; grid-template-columns: repeat(auto-fill, minmax(22px, 1fr));
|
|
||||||
gap: 6px; width: 100%;
|
|
||||||
}
|
|
||||||
.iwb-editor-colors .iwb-editor-color-panel-swatch {
|
|
||||||
width: 100%; aspect-ratio: 1 / 1; min-height: 22px; padding: 0; border: 0;
|
|
||||||
border-radius: 50%; cursor: pointer; transition: transform 0.08s ease;
|
|
||||||
}
|
|
||||||
.iwb-editor-colors .iwb-editor-color-panel-swatch:hover { transform: scale(1.1); }
|
|
||||||
.iwb-editor-colors .iwb-editor-color-panel-swatch.active { outline: 2px solid #fff; outline-offset: 2px; }
|
|
||||||
|
|
||||||
/* ---- 3) 字号 +1 档 ----
|
/* ---- 3) 字号 +1 档 ----
|
||||||
旧值大量是 10–11.5px(按 1440 宽屏定的),在 2K/4K 与系统缩放 125% 下发虚。
|
旧值大量是 10–11.5px(按 1440 宽屏定的),在 2K/4K 与系统缩放 125% 下发虚。
|
||||||
|
|||||||
@@ -10,29 +10,51 @@ import { S, runtime } from './state.js'
|
|||||||
import { bindEvents } from './events.js'
|
import { bindEvents } from './events.js'
|
||||||
|
|
||||||
|
|
||||||
// ============ 调色面板(两处共用) ============
|
// ============ 调色面板(工具栏弹层) ============
|
||||||
/**
|
/**
|
||||||
* v1.16:调色面板从「只能弹层」变成「右栏常驻 + 弹层保留」,两处用同一份 DOM。
|
* v1.19:右栏常驻面板删掉,只剩工具栏弹层这一份(钉住后它本来就是常开的)。
|
||||||
*
|
* 仍抽成函数而不是写在模板里:这套控件有 4 组联动(tab 高亮、SV/色相指示点、
|
||||||
* 为什么抽成函数而不是复制两段 HTML:这套控件有 4 组联动(tab 高亮、SV/色相指示点、
|
* HEX 回填、常用色/最近色的 active 圈),events.js#updateColorUI 按
|
||||||
* HEX 回填、常用色/最近色的 active 圈),复制两段 = 以后每加一种颜色语义都要改两遍,
|
* `[data-color-surface]` 逐个刷 —— 留着这层抽象,将来若再加一处面板不用重写联动。
|
||||||
* 漏一处就是「一边改了另一边不变」。同一份结构 + 按 `[data-color-surface]` 遍历,
|
|
||||||
* 才可能保证一致(events.js#updateColorUI 就是按 surface 逐个刷的)。
|
|
||||||
*
|
|
||||||
* 布局差异全部交给 CSS:弹层是横排一行,右栏窄,改成竖排(picker 全宽、色块自动换行)。
|
|
||||||
*/
|
*/
|
||||||
|
/* 16 个常用色 = 色板里 8 列 × 2 行(v1.19)。
|
||||||
|
排布刻意成对:第一行是 8 个饱和亮色(红橙黄绿青蓝紫粉),
|
||||||
|
第二行是 4 个中性色(白/浅灰/中灰/黑)+ 4 个同色系「深一档」,
|
||||||
|
深红/深绿/深蓝/深紫 在浅色底图上比亮色稳,做描边不刺眼。 */
|
||||||
const COMMON_COLORS = [
|
const COMMON_COLORS = [
|
||||||
'#ff4444', '#ff8a00', '#ffd400', '#4cd964', '#00bfa5', '#4488ff',
|
'#ff4444', '#ff8a00', '#ffd400', '#4cd964', '#00bfa5', '#4488ff', '#aa44ff', '#ff66aa',
|
||||||
'#aa44ff', '#ff66aa', '#ffffff', '#d0d0d0', '#808080', '#000000'
|
'#ffffff', '#d0d0d0', '#808080', '#000000', '#c0392b', '#0f9d58', '#1677ff', '#6b4fbb'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
/** 色板面板(v1.19 起只有工具栏弹层一份,右栏常驻面板已删)
|
||||||
|
*
|
||||||
|
* 头部一行:调哪个槽(描边/填充/底色)│ 吸管 + 色值 │ 去色 │ 图钉
|
||||||
|
* 把「吸管 + 色值」提到头部,是为了让下面整块高度都留给色块:
|
||||||
|
* 常用色 2 排 + 最近色 2 排,一屏就能点到,不用滚动、也不用二次点开。
|
||||||
|
*/
|
||||||
function colorSurfaceHtml() {
|
function colorSurfaceHtml() {
|
||||||
return `
|
return `
|
||||||
<div class="iwb-color-pop-head">
|
<div class="iwb-color-pop-head">
|
||||||
<button type="button" class="iwb-color-pop-tab active" data-color-slot="stroke" title="正在调描边色(形状描边 / 画笔 / 文字色)"><i></i><span class="iwb-color-pop-tab-label">描边</span></button>
|
<button type="button" class="iwb-color-pop-tab active" data-color-slot="stroke" title="正在调描边色(形状描边 / 画笔 / 文字色)"><i></i><span class="iwb-color-pop-tab-label">描边</span></button>
|
||||||
<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="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-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>
|
<span class="iwb-color-pop-bar"></span>
|
||||||
|
<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="十六进制颜色,回车生效">
|
||||||
|
<!-- 去色(v1.19,用户 2026-11-10):就是原来的「无」,挪到图钉左边并用竖线隔开。
|
||||||
|
调色时「这一项我不上色」和「钉住」都是随手要按的开关,放在同一侧最顺。
|
||||||
|
对描边 / 填充 / 底色都生效,具体含义随当前槽变(见 updateColorUI 的 title)。
|
||||||
|
外面这层 .iwb-color-pop-tools 用 margin-left:auto 把整组推到最右:
|
||||||
|
色值框因此不会被拉成一整条(见 CSS 的 max-width)。 -->
|
||||||
|
<span class="iwb-color-pop-tools">
|
||||||
|
<span class="iwb-color-pop-bar"></span>
|
||||||
|
<button type="button" class="iwb-color-pop-none" data-color-none="1" title="去色:当前这一项不上色(描边/填充/底色按上下文透明)"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="m5.6 5.6 12.8 12.8"/></svg>去色</button>
|
||||||
|
<span class="iwb-color-pop-bar"></span>
|
||||||
|
<!-- 钉住(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>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="iwb-color-pop-body">
|
<div class="iwb-color-pop-body">
|
||||||
<div class="iwb-color-pop-picker">
|
<div class="iwb-color-pop-picker">
|
||||||
@@ -40,20 +62,20 @@ import { bindEvents } from './events.js'
|
|||||||
<div class="iwb-color-hue"><span></span></div>
|
<div class="iwb-color-hue"><span></span></div>
|
||||||
</div>
|
</div>
|
||||||
<span class="iwb-color-pop-sep"></span>
|
<span class="iwb-color-pop-sep"></span>
|
||||||
<div class="iwb-color-pop-fields">
|
<!-- 色块区(v1.19):常用色 8×2 在上、最近色 8×2 在下,中间 1px 细线分隔。
|
||||||
<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>
|
不写「常用色 / 最近」小标题 —— 每个色块的 title 已经写明是哪一个,
|
||||||
<input class="iwb-editor-color-hex-input" value="#ff4444" maxlength="7" spellcheck="false" autocomplete="off" title="十六进制颜色,回车生效">
|
而标题要各占一行,是这块面板最浪费的高度(v1.18 已这么定,v1.19 沿用)。 -->
|
||||||
</div>
|
<div class="iwb-color-pop-side">
|
||||||
<span class="iwb-color-pop-sep"></span>
|
<div class="iwb-color-group">
|
||||||
<div class="iwb-color-group">
|
<span class="iwb-color-group-label">常用色</span>
|
||||||
<span class="iwb-color-group-label">常用色</span>
|
<div class="iwb-editor-color-swatches">
|
||||||
<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('')}
|
||||||
${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>
|
|
||||||
<div class="iwb-color-group">
|
|
||||||
<span class="iwb-color-group-label">最近</span>
|
|
||||||
<div class="iwb-editor-recent-colors" hidden title="最近使用"></div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>`
|
</div>`
|
||||||
}
|
}
|
||||||
@@ -75,11 +97,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-replace" data-action="replace" title="用当前编辑结果覆盖原图">覆盖</button>
|
||||||
<button class="iwb-editor-btn iwb-editor-btn-cancel" data-action="cancel" title="放弃修改并退出">退出</button>
|
<button class="iwb-editor-btn iwb-editor-btn-cancel" data-action="cancel" title="放弃修改并退出">退出</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="iwb-editor-history">
|
<!-- 撤销/重做/还原(v1.18,用户 2026-11-10):从顶栏搬到画布底部工具栏最右侧。
|
||||||
<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.13):
|
<!-- 顶栏命令带已清空(v1.13):
|
||||||
四个「置顶/上移/下移/置底」按钮删除(图层面板可拖动 + Ctrl+]/[ 已覆盖);
|
四个「置顶/上移/下移/置底」按钮删除(图层面板可拖动 + Ctrl+]/[ 已覆盖);
|
||||||
「适应窗口 / 收起侧栏」搬到画布底部工具栏最右侧,离画布更近。
|
「适应窗口 / 收起侧栏」搬到画布底部工具栏最右侧,离画布更近。
|
||||||
@@ -213,6 +233,15 @@ import { bindEvents } from './events.js'
|
|||||||
<span class="iwb-editor-divider"></span>
|
<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="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>
|
<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>
|
</div>
|
||||||
<div class="iwb-editor-zoom-hint">滚轮缩放 · 抓手/空格/中键拖拽自由移动画布</div>
|
<div class="iwb-editor-zoom-hint">滚轮缩放 · 抓手/空格/中键拖拽自由移动画布</div>
|
||||||
@@ -221,19 +250,11 @@ import { bindEvents } from './events.js'
|
|||||||
<!-- v1.16:侧栏宽度拖拽手柄。贴在侧栏左边缘(它在画布右侧),
|
<!-- v1.16:侧栏宽度拖拽手柄。贴在侧栏左边缘(它在画布右侧),
|
||||||
双击复位。宽度写进 CSS 变量 --iwb-side-w,由 --iwb-side-w 统一裁各条 width 规则。 -->
|
双击复位。宽度写进 CSS 变量 --iwb-side-w,由 --iwb-side-w 统一裁各条 width 规则。 -->
|
||||||
<div class="iwb-editor-side-resizer" data-side-resizer="1" title="拖动调整侧栏宽度,双击复位"></div>
|
<div class="iwb-editor-side-resizer" data-side-resizer="1" title="拖动调整侧栏宽度,双击复位"></div>
|
||||||
<!-- 调色面板(v1.16):从弹层搬进来常驻一份,弹层保留。
|
<!-- 右栏常驻调色面板已删(v1.19,用户 2026-11-10:「右边栏的调色模块就可以去掉了」)。
|
||||||
两处是同一份 DOM(dom.js#colorSurfaceHtml),靠 data-color-surface 区分与遍历,
|
理由:弹层钉住之后它一直是开着的,右栏那份同样内容只是在跟弹层抢注意力,
|
||||||
不存在「一边改了另一边不变」。顶部色格 = 当前元素可调的颜色项,
|
还白占一块最显眼的位置。颜色只剩弹层一处(modal 末尾 .iwb-editor-color-pop),
|
||||||
跟随选中对象变化:形状=描边/填充,文字=文字/描边/底色,箭头=只要描边。 -->
|
右栏现在从「图片调节」直接开始。 -->
|
||||||
<section class="iwb-editor-colors" data-color-surface="side">
|
|
||||||
<div class="iwb-editor-colors-head">
|
|
||||||
<span class="iwb-editor-colors-title">颜色</span>
|
|
||||||
<span class="iwb-editor-colors-hint" title="点上面的色格选择要调哪个颜色">点色格切换</span>
|
|
||||||
</div>
|
|
||||||
${colorSurfaceHtml()}
|
|
||||||
</section>
|
|
||||||
<!-- 调色板已迁到工具栏弹层(v1.3,用户裁定 2026-11-05):
|
|
||||||
侧栏只留快速效果 + 缩放;色板 DOM 在 modal 末尾的 .iwb-editor-color-pop -->
|
|
||||||
<!-- 图片调节(v1.15):连续调色,作用于当前位图图层(默认原图)。
|
<!-- 图片调节(v1.15):连续调色,作用于当前位图图层(默认原图)。
|
||||||
行由 adjust.js#mountAdjustPanel() 按 ADJUST_DEFS 生成 —— 参数表只维护一份,
|
行由 adjust.js#mountAdjustPanel() 按 ADJUST_DEFS 生成 —— 参数表只维护一份,
|
||||||
不在 DOM 里再抄一遍(这个项目已经因为「同一个概念两处各写一份」栽过几次)。
|
不在 DOM 里再抄一遍(这个项目已经因为「同一个概念两处各写一份」栽过几次)。
|
||||||
|
|||||||
@@ -1055,9 +1055,9 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
|||||||
// 描边格:文字的「描边」是第二格(上面已处理),文字色/单槽上下文不允许「无」
|
// 描边格:文字的「描边」是第二格(上面已处理),文字色/单槽上下文不允许「无」
|
||||||
if (!isFill && !isBg) tab.classList.toggle('is-none', !isText && sl.strokeOn === false)
|
if (!isFill && !isBg) tab.classList.toggle('is-none', !isText && sl.strokeOn === false)
|
||||||
})
|
})
|
||||||
// 「无」:形状/钢笔 = 无描边或无填充;文字描边 = 描边宽度 0;文字底色 = 关掉底色块
|
// 「去色」(v1.19 前叫「无」):形状/钢笔 = 无描边或无填充;文字描边 = 描边宽度 0;文字底色 = 关掉底色块
|
||||||
// (文字色与箭头单槽没有「无」—— 去掉就等于把对象删了,不该给这个按钮)
|
// (文字色与箭头单槽没有「去色」—— 去掉就等于把对象删了,不该给这个按钮)
|
||||||
// v1.16:右栏与弹层各有一个「无」,必须按集合刷,否则只有先出现的那个对
|
// 按集合刷(原来是右栏 + 弹层各一个,现在只剩弹层一个,写法保持不变以免将来再加面板时漏刷)
|
||||||
const onBg = S.colorTarget === 'bg' && isText
|
const onBg = S.colorTarget === 'bg' && isText
|
||||||
const onFill = S.colorTarget === 'fill' && second
|
const onFill = S.colorTarget === 'fill' && second
|
||||||
const onStroke = S.colorTarget === 'stroke' && !isText && strokeSlotCanBeNone()
|
const onStroke = S.colorTarget === 'stroke' && !isText && strokeSlotCanBeNone()
|
||||||
@@ -1066,10 +1066,10 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
|||||||
noneBtn.hidden = !showNone
|
noneBtn.hidden = !showNone
|
||||||
noneBtn.classList.toggle('active', showNone && (onBg ? !sl.bgOn : (onFill ? !sl.fillOn : !sl.strokeOn)))
|
noneBtn.classList.toggle('active', showNone && (onBg ? !sl.bgOn : (onFill ? !sl.fillOn : !sl.strokeOn)))
|
||||||
noneBtn.title = onBg
|
noneBtn.title = onBg
|
||||||
? '无底色:文字后面完全透明'
|
? '去色:文字后面完全透明(无底色)'
|
||||||
: (onStroke
|
: (onStroke
|
||||||
? (sl.strokeOn === false ? '当前已是无描边;点选颜色可恢复描边' : '无描边:去掉形状外框,只留内部填充')
|
? (sl.strokeOn === false ? '当前已是无描边;点选颜色可恢复描边' : '去色:去掉形状外框,只留内部填充')
|
||||||
: (isText ? '无描边:把描边宽度置 0,只留文字本身' : '无填充:形状内部透明,只留描边'))
|
: (isText ? '去色:把描边宽度置 0,只留文字本身' : '去色:形状内部透明,只留描边'))
|
||||||
})
|
})
|
||||||
|
|
||||||
const cur = activeColor()
|
const cur = activeColor()
|
||||||
@@ -1079,7 +1079,7 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
|||||||
if (on) matchPreset = true
|
if (on) matchPreset = true
|
||||||
s.classList.toggle('active', on)
|
s.classList.toggle('active', on)
|
||||||
})
|
})
|
||||||
// v1.16:hex / 调色器在两处面板各有一份 → 一律按集合刷
|
// hex / 调色器按集合刷(现在只有弹层一处,写法保持不变以免将来加面板时漏刷)
|
||||||
runtime.el.querySelectorAll('.iwb-editor-color-hex').forEach(el => { el.textContent = cur.toUpperCase() })
|
runtime.el.querySelectorAll('.iwb-editor-color-hex').forEach(el => { el.textContent = cur.toUpperCase() })
|
||||||
runtime.el.querySelectorAll('.iwb-editor-color-hex-input').forEach(inp => {
|
runtime.el.querySelectorAll('.iwb-editor-color-hex-input').forEach(inp => {
|
||||||
if (document.activeElement !== inp) inp.value = cur.toUpperCase()
|
if (document.activeElement !== inp) inp.value = cur.toUpperCase()
|
||||||
@@ -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 决定要不要吞掉这次按键 */
|
/** 关闭色板弹层;返回「关之前是开着的」,供 Esc 决定要不要吞掉这次按键 */
|
||||||
export function closeColorPop() {
|
export function closeColorPop() {
|
||||||
const pop = runtime.el && runtime.el.querySelector('.iwb-editor-color-pop')
|
const pop = runtime.el && runtime.el.querySelector('.iwb-editor-color-pop')
|
||||||
@@ -2289,10 +2320,9 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 调色面板(v1.3 弹层 → v1.16 弹层 + 右栏常驻):
|
/** 调色面板(v1.3 弹层 → v1.16 弹层 + 右栏常驻 → v1.19 只剩弹层):
|
||||||
* 两处是同一份 DOM(dom.js#colorSurfaceHtml),按 [data-color-surface] 逐个绑定。
|
* 结构来自 dom.js#colorSurfaceHtml,按 [data-color-surface] 逐个绑定。
|
||||||
* 每个 surface 各自持有一份 HSV 拖拽状态,但取值一律从 activeColor() 现算,
|
* 每个 surface 各自持有一份 HSV 拖拽状态,但取值一律从 activeColor() 现算。 */
|
||||||
* 所以「在右栏取色、再去弹层拖 SV」不会跳色。 */
|
|
||||||
function bindColorPanel() {
|
function bindColorPanel() {
|
||||||
const pop = runtime.el.querySelector('.iwb-editor-color-pop')
|
const pop = runtime.el.querySelector('.iwb-editor-color-pop')
|
||||||
const colorBtns = [...runtime.el.querySelectorAll('[data-action="toggleColorPop"]')]
|
const colorBtns = [...runtime.el.querySelectorAll('[data-action="toggleColorPop"]')]
|
||||||
@@ -2302,8 +2332,10 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
|||||||
})
|
})
|
||||||
if (pop) {
|
if (pop) {
|
||||||
// 点外面关闭:必须用捕获阶段 —— 画布的 mousedown 会 preventDefault,
|
// 点外面关闭:必须用捕获阶段 —— 画布的 mousedown 会 preventDefault,
|
||||||
// 冒泡阶段拿不到「点了外面」这件事。右栏面板常驻,不参与关闭。
|
// 冒泡阶段拿不到「点了外面」这件事。
|
||||||
|
// 钉住时一律不关:这就是「钉住」的全部意义(要收就再点一次图钉,或按 Esc)。
|
||||||
document.addEventListener('mousedown', (e) => {
|
document.addEventListener('mousedown', (e) => {
|
||||||
|
if (S.colorPopPinned) return
|
||||||
const onBtn = colorBtns.some(b => b.contains(e.target))
|
const onBtn = colorBtns.some(b => b.contains(e.target))
|
||||||
if (!pop.hidden && !pop.contains(e.target) && !onBtn) closeColorPop()
|
if (!pop.hidden && !pop.contains(e.target) && !onBtn) closeColorPop()
|
||||||
}, true)
|
}, true)
|
||||||
@@ -2319,6 +2351,8 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
|||||||
// tab 切换目标槽 / 「无」 / 常用色与最近色,统一委托:
|
// tab 切换目标槽 / 「无」 / 常用色与最近色,统一委托:
|
||||||
// 静态 12 色 + 动态插入的「最近使用」都要能点,一次性 querySelectorAll 会漏掉后者
|
// 静态 12 色 + 动态插入的「最近使用」都要能点,一次性 querySelectorAll 会漏掉后者
|
||||||
surface.addEventListener('click', (e) => {
|
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]')
|
const tab = e.target.closest('.iwb-color-pop-tab[data-color-slot]')
|
||||||
if (tab) {
|
if (tab) {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
@@ -2341,7 +2375,7 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
|||||||
const palettePick = surface.querySelector('[data-action="palettePick"]')
|
const palettePick = surface.querySelector('[data-action="palettePick"]')
|
||||||
if (palettePick) {
|
if (palettePick) {
|
||||||
palettePick.addEventListener('mousedown', (e) => e.stopPropagation())
|
palettePick.addEventListener('mousedown', (e) => e.stopPropagation())
|
||||||
// 取色要回画布点,弹层必须先收起,否则它会挡住取样点(右栏面板在画布外,不挡)
|
// 取色要回画布点,弹层必须先收起,否则它会挡住取样点
|
||||||
palettePick.addEventListener('click', () => { closeColorPop(); setTool('picker') })
|
palettePick.addEventListener('click', () => { closeColorPop(); setTool('picker') })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import { createEl, loadImage } from './dom.js'
|
|||||||
import { renderObjects, hideTextInput, textBounds } from './objects.js'
|
import { renderObjects, hideTextInput, textBounds } from './objects.js'
|
||||||
import { setupCanvas } from './viewport.js'
|
import { setupCanvas } from './viewport.js'
|
||||||
import { resetOverlayTransform } from './scale.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 { disposeSelection, renderSelection, selectionInfo, syncAnts, registerSelectionCommands } from './selection.js'
|
||||||
import { bindFloating, positionFloating, hideSelectionContext } from './floating.js'
|
import { bindFloating, positionFloating, hideSelectionContext } from './floating.js'
|
||||||
import { renderFxPanel } from './effects.js'
|
import { renderFxPanel } from './effects.js'
|
||||||
@@ -69,6 +69,8 @@ import { toast } from './commands.js'
|
|||||||
registerSelectionCommands()
|
registerSelectionCommands()
|
||||||
loadExportOptions()
|
loadExportOptions()
|
||||||
loadRecentColors()
|
loadRecentColors()
|
||||||
|
// v1.18:色板「钉住」状态也来自宿主 KV,和常用色/最近色一起恢复
|
||||||
|
loadColorPopPinned()
|
||||||
bindLiteUI()
|
bindLiteUI()
|
||||||
bindFloating()
|
bindFloating()
|
||||||
bindExportUI()
|
bindExportUI()
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* recent-colors.js - 最近使用颜色(v1.9)
|
/* recent-colors.js - 最近使用颜色(v1.9)
|
||||||
*
|
*
|
||||||
* 只依赖 state.js(叶子模块):tools.js 在改色时调用 rememberColor(),
|
* 只依赖 state.js(叶子模块):tools.js 在改色时调用 rememberColor(),
|
||||||
* color pop 打开时 renderRecentColors() 把最近 8 个色块铺出来。
|
* color pop 打开时 renderRecentColors() 把最近的色块铺出来。
|
||||||
* 持久化走宿主 ctx.settings(小 KV,不放像素,符合宿主存储约定)。
|
* 持久化走宿主 ctx.settings(小 KV,不放像素,符合宿主存储约定)。
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -9,7 +9,9 @@
|
|||||||
|
|
||||||
import { S, runtime } from './state.js'
|
import { S, runtime } from './state.js'
|
||||||
|
|
||||||
const MAX = 8
|
// v1.19:上限 6 → 16。色板弹层改成 8 列网格,16 个正好铺满两排
|
||||||
|
// (v1.18 为「更紧凑」收到 6,是因为当时只有一排的空间;吸管+色值移到头部后省出这一排)。
|
||||||
|
const MAX = 16
|
||||||
const KEY = 'recentColors'
|
const KEY = 'recentColors'
|
||||||
|
|
||||||
function valid(hex) {
|
function valid(hex) {
|
||||||
@@ -29,7 +31,7 @@ import { S, runtime } from './state.js'
|
|||||||
renderRecentColors()
|
renderRecentColors()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 记一个颜色:去重后置顶,最多 8 个 */
|
/** 记一个颜色:去重后置顶,最多 MAX 个 */
|
||||||
export function rememberColor(hex) {
|
export function rememberColor(hex) {
|
||||||
if (!valid(hex)) return
|
if (!valid(hex)) return
|
||||||
const c = String(hex).toLowerCase()
|
const c = String(hex).toLowerCase()
|
||||||
@@ -45,7 +47,6 @@ import { S, runtime } from './state.js'
|
|||||||
|
|
||||||
export function renderRecentColors() {
|
export function renderRecentColors() {
|
||||||
if (!runtime.el) return
|
if (!runtime.el) return
|
||||||
// v1.16:右栏常驻面板与工具栏弹层各有一份,按集合刷
|
|
||||||
const wraps = runtime.el.querySelectorAll('.iwb-editor-recent-colors')
|
const wraps = runtime.el.querySelectorAll('.iwb-editor-recent-colors')
|
||||||
if (!wraps.length) return
|
if (!wraps.length) return
|
||||||
const list = S.recentColors || []
|
const list = S.recentColors || []
|
||||||
@@ -55,8 +56,7 @@ export function renderRecentColors() {
|
|||||||
wraps.forEach(wrap => {
|
wraps.forEach(wrap => {
|
||||||
wrap.innerHTML = html
|
wrap.innerHTML = html
|
||||||
wrap.hidden = !list.length
|
wrap.hidden = !list.length
|
||||||
// v1.16:右栏给了一组加了「最近」小标题,没有最近色时整组一起藏,
|
// 没有最近色时整组一起藏,否则下面留一块空白,看起来像没加载出来
|
||||||
// 否则标题下面留一块空白,看起来像没加载出来。
|
|
||||||
const group = wrap.closest('.iwb-color-group')
|
const group = wrap.closest('.iwb-color-group')
|
||||||
if (group) group.hidden = !list.length
|
if (group) group.hidden = !list.length
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -56,6 +56,9 @@
|
|||||||
// 色板(调色器 / 吸管 / 推荐色 / hex)按这个值决定写 S.color 还是 shapeFillColor,
|
// 色板(调色器 / 吸管 / 推荐色 / hex)按这个值决定写 S.color 还是 shapeFillColor,
|
||||||
// 否则「三个地方各调各的颜色」会一直存在。
|
// 否则「三个地方各调各的颜色」会一直存在。
|
||||||
colorTarget: 'stroke', // stroke | fill
|
colorTarget: 'stroke', // stroke | fill
|
||||||
|
// v1.18:色板弹层是否「钉住」。钉住后点画布/点别处都不收起,方便连着调几处颜色。
|
||||||
|
// 存宿主 KV(跨会话记住):钉过一次就一直钉着,下次打开仍生效。
|
||||||
|
colorPopPinned: false,
|
||||||
// v1.16:右侧栏宽度(px)。0 = 按默认值走,打开编辑器时从宿主 KV 恢复。
|
// v1.16:右侧栏宽度(px)。0 = 按默认值走,打开编辑器时从宿主 KV 恢复。
|
||||||
// 宽度统一落在 CSS 变量 --iwb-side-w 上,不再各条规则各写一个魔数。
|
// 宽度统一落在 CSS 变量 --iwb-side-w 上,不再各条规则各写一个魔数。
|
||||||
sideWidth: 0,
|
sideWidth: 0,
|
||||||
@@ -70,7 +73,7 @@
|
|||||||
textBgFill: TEXT_DEFAULTS.bgFill, // 底色块
|
textBgFill: TEXT_DEFAULTS.bgFill, // 底色块
|
||||||
textBgColor: TEXT_DEFAULTS.bgColor, // 中性近黑,不再是纯黑 #000000
|
textBgColor: TEXT_DEFAULTS.bgColor, // 中性近黑,不再是纯黑 #000000
|
||||||
textBgAlpha: TEXT_DEFAULTS.bgAlpha, // 底色透明度(色块按这个不透明度显示,所见即所得)
|
textBgAlpha: TEXT_DEFAULTS.bgAlpha, // 底色透明度(色块按这个不透明度显示,所见即所得)
|
||||||
// 最近使用颜色(最多 8 个,存 ctx.settings,跨会话保留)
|
// 最近使用颜色(最多 6 个,存 ctx.settings,跨会话保留)
|
||||||
recentColors: [],
|
recentColors: [],
|
||||||
// 图层系统
|
// 图层系统
|
||||||
layers: [], // 位图图层数组 [{ id, name, canvas, ctx, opacity, visible, z }]
|
layers: [], // 位图图层数组 [{ id, name, canvas, ctx, opacity, visible, z }]
|
||||||
|
|||||||
+99
-2270
File diff suppressed because it is too large.
Load diff
@@ -183,10 +183,24 @@ if (!SKIP_PASTE) {
|
|||||||
(await page.locator('.iwb-editor-header .iwb-editor-commands').count()) === 0,
|
(await page.locator('.iwb-editor-header .iwb-editor-commands').count()) === 0,
|
||||||
'layerBtn=' + await page.locator('.iwb-editor-layer-btn').count())
|
'layerBtn=' + await page.locator('.iwb-editor-layer-btn').count())
|
||||||
|
|
||||||
const toolsTail = await page.evaluate(() => Array.from(document.querySelectorAll('.iwb-editor-tools > *'))
|
// v1.18(用户 2026-11-10):撤销 / 重做 / 还原 从顶栏搬到工具条最右,
|
||||||
.slice(-2).map((n) => n.dataset.action || n.className))
|
// 「适应窗口 / 收起侧栏」退到它前面两位。这里断言「末尾是撤销组、视图按钮在其前」
|
||||||
check('工具栏最右两个按钮是「适应窗口 / 收起侧栏」',
|
// —— 光看版本号挡不住产物没重建。
|
||||||
JSON.stringify(toolsTail) === JSON.stringify(['zoomFit', 'togglePanels']), JSON.stringify(toolsTail))
|
const toolsOrder = await page.evaluate(() => {
|
||||||
|
const kids = Array.from(document.querySelectorAll('.iwb-editor-tools > *'))
|
||||||
|
const acts = kids.filter((n) => n.dataset && n.dataset.action).map((n) => n.dataset.action)
|
||||||
|
const hist = kids[kids.length - 1]
|
||||||
|
return {
|
||||||
|
tail: acts.slice(-2),
|
||||||
|
lastIsHistory: Boolean(hist && hist.classList.contains('iwb-editor-history')),
|
||||||
|
histActs: [...(hist ? hist.querySelectorAll('[data-action]') : [])].map((b) => b.dataset.action),
|
||||||
|
headerHasHistory: Boolean(document.querySelector('.iwb-editor-header .iwb-editor-history')),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
check('工具栏最右是「撤销/重做/还原」组(视图按钮在其前)',
|
||||||
|
JSON.stringify(toolsOrder.tail) === JSON.stringify(['zoomFit', 'togglePanels']) &&
|
||||||
|
toolsOrder.lastIsHistory && toolsOrder.histActs.join(',') === 'undo,redo,reset' &&
|
||||||
|
!toolsOrder.headerHasHistory, JSON.stringify(toolsOrder))
|
||||||
|
|
||||||
const before = await panelSeq()
|
const before = await panelSeq()
|
||||||
const activeName = await page.evaluate(() => document.querySelector('.iwb-editor-layer-list .iwb-layer-item.active .iwb-layer-name')?.textContent)
|
const activeName = await page.evaluate(() => document.querySelector('.iwb-editor-layer-list .iwb-layer-item.active .iwb-layer-name')?.textContent)
|
||||||
@@ -217,20 +231,46 @@ if (!SKIP_PASTE) {
|
|||||||
(await page.locator('.iwb-editor-adj-target').textContent()) !== '无图层',
|
(await page.locator('.iwb-editor-adj-target').textContent()) !== '无图层',
|
||||||
await page.locator('.iwb-editor-adj-target').textContent())
|
await page.locator('.iwb-editor-adj-target').textContent())
|
||||||
|
|
||||||
// v1.16:右栏常驻调色面板 + 可拖宽度。真站里 DOM 与 CSS 是分别打包的,
|
// v1.19:右栏常驻调色面板已删(用户 2026-11-10),颜色只剩工具栏弹层一处。
|
||||||
// 只验面板在不在、拖宽后宽度有没有真的变 —— 样式漏打包时这里会直接露出来。
|
// 真站里 DOM 与 CSS 分别打包,这里同时验「右栏干净」和「弹层头部一行 / 16 色 8 列」——
|
||||||
const sideColor = await page.evaluate(() => {
|
// 样式漏打包时,头部会退回竖排或色块掉成 6 列,这条会直接露出来。
|
||||||
const side = document.querySelector('.iwb-editor-left [data-color-surface="side"]')
|
const sideColor = await page.evaluate(() => ({
|
||||||
if (!side) return null
|
hasSide: Boolean(document.querySelector('.iwb-editor-left [data-color-surface]')),
|
||||||
|
firstSection: (document.querySelector('.iwb-editor-left > section') || {}).className || '',
|
||||||
|
}))
|
||||||
|
check('右栏调色模块已删(第一个模块是图片调节)',
|
||||||
|
sideColor.hasSide === false && /iwb-editor-adj/.test(sideColor.firstSection),
|
||||||
|
JSON.stringify(sideColor))
|
||||||
|
|
||||||
|
await page.locator('.iwb-editor-tools [data-action="toggleColorPop"][data-color-slot="stroke"]').click()
|
||||||
|
await page.waitForTimeout(240)
|
||||||
|
const popShape = await page.evaluate(() => {
|
||||||
|
const pop = document.querySelector('.iwb-editor-color-pop')
|
||||||
|
if (!pop) return null
|
||||||
|
const r = (el) => el.getBoundingClientRect()
|
||||||
|
const head = r(pop.querySelector('.iwb-color-pop-head'))
|
||||||
|
const items = [pop.querySelector('[data-action="palettePick"]'),
|
||||||
|
pop.querySelector('.iwb-editor-color-hex-input'),
|
||||||
|
pop.querySelector('[data-action="pinColorPop"]')].map((el) => {
|
||||||
|
const b = r(el)
|
||||||
|
return { c: b.top + b.height / 2, l: b.left, r: b.right }
|
||||||
|
})
|
||||||
|
const sw = [...pop.querySelectorAll('.iwb-editor-color-swatches [data-panel-color]')]
|
||||||
return {
|
return {
|
||||||
tabs: side.querySelectorAll('.iwb-color-pop-tab').length,
|
w: Math.round(r(pop).width),
|
||||||
swatches: side.querySelectorAll('.iwb-editor-color-swatches [data-panel-color]').length,
|
sameRow: items.every((it) =>
|
||||||
sv: !!side.querySelector('.iwb-color-sv')
|
Math.abs(it.c - (head.top + head.height / 2)) < 3 && it.l >= head.left - 1 && it.r <= head.right + 1),
|
||||||
|
common: sw.length,
|
||||||
|
cols: new Set(sw.map((b) => Math.round(r(b).left))).size,
|
||||||
|
swatch: sw.length ? Math.round(r(sw[0]).width) : 0,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
check('右栏常驻调色面板(色格切换 + 调色器 + 12 个常用色)',
|
check('色板弹层:头部一行(吸管 / 色值 / 图钉同排)+ 常用色 16 个 8 列',
|
||||||
Boolean(sideColor) && sideColor.tabs === 3 && sideColor.swatches === 12 && sideColor.sv,
|
Boolean(popShape) && popShape.sameRow && popShape.common === 16 &&
|
||||||
JSON.stringify(sideColor))
|
popShape.cols === 8 && popShape.swatch === 20 && popShape.w === 440,
|
||||||
|
JSON.stringify(popShape))
|
||||||
|
await page.keyboard.press('Escape')
|
||||||
|
await page.waitForTimeout(140)
|
||||||
|
|
||||||
const sideBefore = await page.evaluate(() => Math.round(document.querySelector('.iwb-editor-left').getBoundingClientRect().width))
|
const sideBefore = await page.evaluate(() => Math.round(document.querySelector('.iwb-editor-left').getBoundingClientRect().width))
|
||||||
const sideGrip = await page.locator('.iwb-editor-side-resizer').boundingBox()
|
const sideGrip = await page.locator('.iwb-editor-side-resizer').boundingBox()
|
||||||
|
|||||||
@@ -139,13 +139,14 @@ check('打开编辑器默认只有「原图」1 层,且状态栏不再写「
|
|||||||
JSON.stringify((await dbg()).layers.map(l => l.name)))
|
JSON.stringify((await dbg()).layers.map(l => l.name)))
|
||||||
|
|
||||||
// v1.3(用户裁定 2026-11-05):调色板从侧栏搬进工具栏弹层,侧栏只剩缩放
|
// v1.3(用户裁定 2026-11-05):调色板从侧栏搬进工具栏弹层,侧栏只剩缩放
|
||||||
check('调色板已搬进工具栏:侧栏只剩缩放,SV/色相/推荐色都在弹层里',
|
// v1.19(用户 2026-11-10):右栏那份常驻调色面板删掉,颜色只剩弹层一处
|
||||||
|
check('调色板只在工具栏弹层:右栏没有调色模块,SV/色相/16 个常用色都在弹层里',
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
const q = (s) => Boolean(document.querySelector(s))
|
const q = (s) => Boolean(document.querySelector(s))
|
||||||
return !q('.iwb-editor-left .iwb-editor-color-panel') &&
|
return !q('.iwb-editor-left [data-color-surface]') && !q('.iwb-editor-left .iwb-editor-colors') &&
|
||||||
q('.iwb-editor-tools [data-action="toggleColorPop"][data-color-slot="stroke"]') &&
|
q('.iwb-editor-tools [data-action="toggleColorPop"][data-color-slot="stroke"]') &&
|
||||||
q('.iwb-editor-color-pop .iwb-color-sv') && q('.iwb-editor-color-pop .iwb-color-hue') &&
|
q('.iwb-editor-color-pop .iwb-color-sv') && q('.iwb-editor-color-pop .iwb-color-hue') &&
|
||||||
document.querySelectorAll('.iwb-editor-color-pop .iwb-editor-color-panel-swatch').length === 12 &&
|
document.querySelectorAll('.iwb-editor-color-pop .iwb-editor-color-swatches [data-panel-color]').length === 16 &&
|
||||||
q('.iwb-editor-zoom') &&
|
q('.iwb-editor-zoom') &&
|
||||||
!q('.iwb-editor-brush-size') && !q('.iwb-editor-brush-num') &&
|
!q('.iwb-editor-brush-size') && !q('.iwb-editor-brush-num') &&
|
||||||
document.querySelectorAll('.iwb-editor-brush-preset').length === 0
|
document.querySelectorAll('.iwb-editor-brush-preset').length === 0
|
||||||
@@ -193,6 +194,141 @@ check('色板弹层默认收起;点工具栏色点弹出、且整块在视口
|
|||||||
return inView && !(await pop.isVisible()) ? true : 'box=' + JSON.stringify(box)
|
return inView && !(await pop.isVisible()) ? true : 'box=' + JSON.stringify(box)
|
||||||
})())
|
})())
|
||||||
|
|
||||||
|
// ---------- v1.18 / v1.19 色板弹层布局(用户 2026-11-10) ----------
|
||||||
|
// v1.18:「加钉住」「三项不写标题、用细横线分割」
|
||||||
|
// v1.19:「去色放钉住左边、竖线分割」「吸色与色值放在钉住那一排」「宽度再多一点,
|
||||||
|
// 颜色一排 8 个,常用色多加 4 个」「最近色放两排」
|
||||||
|
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 r = (el) => el.getBoundingClientRect()
|
||||||
|
const none = pop.querySelector('[data-color-none]')
|
||||||
|
// 空画布(没选中对象)时「去色」是隐藏的(只有可去色的上下文才给这个按钮),
|
||||||
|
// 这里临时显出来量几何,量完还原 —— 否则 rect 全是 0,位置断言恒假。
|
||||||
|
const noneWasHidden = none.hidden
|
||||||
|
if (noneWasHidden) none.hidden = false
|
||||||
|
const picker = r(pop.querySelector('.iwb-color-pop-picker'))
|
||||||
|
const side = r(pop.querySelector('.iwb-color-pop-side'))
|
||||||
|
const head = r(pop.querySelector('.iwb-color-pop-head'))
|
||||||
|
const eye = pop.querySelector('[data-action="palettePick"]')
|
||||||
|
const hex = pop.querySelector('.iwb-editor-color-hex-input')
|
||||||
|
const pin = pop.querySelector('[data-action="pinColorPop"]')
|
||||||
|
// 头部一行:吸管 / 色值 / 去色 / 图钉 的竖直中心都必须落在头部这条线上
|
||||||
|
const cy = (el) => r(el).top + r(el).height / 2
|
||||||
|
const headOneRow = [eye, hex, none, pin].every((el) =>
|
||||||
|
Math.abs(cy(el) - (head.top + head.height / 2)) < 3 &&
|
||||||
|
r(el).left >= head.left - 1 && r(el).right <= head.right + 1)
|
||||||
|
const bars = [...pop.querySelectorAll('.iwb-color-pop-bar')].map(r)
|
||||||
|
const noneLeftOfPin = r(none).right <= r(pin).left
|
||||||
|
const barBetweenNonePin = bars.some((b) =>
|
||||||
|
b.left >= r(none).right - 1 && b.right <= r(pin).left + 1 && b.height > 8)
|
||||||
|
// 文字工具会多出「底色」tab(三格同显):临时显出来验头部不横扫溢出,
|
||||||
|
// 否则「吸管 + 色值 + 去色 + 图钉」在窄面板里会把图钉挤出弹层。
|
||||||
|
const bgTab = pop.querySelector('.iwb-color-pop-tab[data-color-slot="bg"]')
|
||||||
|
const bgWasHidden = bgTab.hidden
|
||||||
|
const headEl = pop.querySelector('.iwb-color-pop-head')
|
||||||
|
if (bgWasHidden) bgTab.hidden = false
|
||||||
|
// 注意用元素本身读 scrollWidth/clientWidth —— DOMRect 上没有这两个属性,写 head.scrollWidth
|
||||||
|
// 会拿到 undefined,比较恒为 false(本次就是这样白跑了两轮)
|
||||||
|
const headFitsThreeTabs = headEl.scrollWidth <= headEl.clientWidth + 1 &&
|
||||||
|
[none, pin].every((el) => r(el).right <= head.right + 1)
|
||||||
|
const headThreeTabsWidth = headEl.scrollWidth
|
||||||
|
const headDbg = {
|
||||||
|
client: pop.querySelector('.iwb-color-pop-head').clientWidth,
|
||||||
|
scroll: pop.querySelector('.iwb-color-pop-head').scrollWidth,
|
||||||
|
tabs: [...pop.querySelectorAll('.iwb-color-pop-tab')].map((t) => Math.round(r(t).width)),
|
||||||
|
hex: Math.round(r(hex).width),
|
||||||
|
popW: Math.round(r(pop).width),
|
||||||
|
headRight: Math.round(head.right), noneR: Math.round(r(none).right), pinR: Math.round(r(pin).right),
|
||||||
|
}
|
||||||
|
if (bgWasHidden) bgTab.hidden = true
|
||||||
|
const sw = [...pop.querySelectorAll('.iwb-editor-color-swatches [data-panel-color]')]
|
||||||
|
const row1 = sw.slice(0, 8).map((b) => Math.round(r(b).top))
|
||||||
|
const row2 = sw.slice(8).map((b) => Math.round(r(b).top))
|
||||||
|
// 「最近」没有历史色时整组(含外层 group)都是 hidden,量不出网格;
|
||||||
|
// 这里临时铺满 16 个量完再还原 —— 只解 wrap 的 hidden 不够,外层还压着一层
|
||||||
|
const rec = pop.querySelector('.iwb-editor-recent-colors')
|
||||||
|
const recGroup = rec.closest('.iwb-color-group')
|
||||||
|
const recWasHidden = rec.hidden
|
||||||
|
const grpWasHidden = Boolean(recGroup && recGroup.hidden)
|
||||||
|
if (recWasHidden) {
|
||||||
|
rec.hidden = false
|
||||||
|
if (recGroup) recGroup.hidden = false
|
||||||
|
rec.innerHTML = '<button class="iwb-editor-color-panel-swatch"></button>'.repeat(16)
|
||||||
|
}
|
||||||
|
const recRows = new Set([...rec.querySelectorAll('.iwb-editor-color-panel-swatch')]
|
||||||
|
.map((b) => Math.round(r(b).top))).size
|
||||||
|
const recCols = new Set([...rec.querySelectorAll('.iwb-editor-color-panel-swatch')]
|
||||||
|
.map((b) => Math.round(r(b).left))).size
|
||||||
|
if (recWasHidden) {
|
||||||
|
rec.innerHTML = ''
|
||||||
|
rec.hidden = true
|
||||||
|
if (grpWasHidden && recGroup) recGroup.hidden = true
|
||||||
|
}
|
||||||
|
const out = {
|
||||||
|
w: Math.round(r(pop).width),
|
||||||
|
h: Math.round(r(pop).height),
|
||||||
|
headOneRow,
|
||||||
|
headRows: [head.top, head.bottom, head.left, head.right].map(Math.round),
|
||||||
|
items: [eye, hex, none, pin].map((el) => [r(el).top, r(el).bottom, r(el).left, r(el).right].map(Math.round)),
|
||||||
|
sideInRight: Math.round(side.left) >= Math.round(picker.right),
|
||||||
|
noneLeftOfPin,
|
||||||
|
barBetweenNonePin,
|
||||||
|
headFitsThreeTabs, headThreeTabsWidth, headDbg,
|
||||||
|
common: sw.length,
|
||||||
|
twoRows: row1.length === 8 && row2.length === 8 &&
|
||||||
|
new Set(row1).size === 1 && new Set(row2).size === 1 && row1[0] < row2[0],
|
||||||
|
cols: new Set(sw.map((b) => Math.round(r(b).left))).size,
|
||||||
|
recRows, recCols,
|
||||||
|
dividers: [...pop.querySelectorAll('.iwb-color-pop-side > * + *')].map((g) => getComputedStyle(g).borderTopWidth),
|
||||||
|
labelsVisible: [...pop.querySelectorAll('.iwb-color-group-label')].filter((l) => l.offsetParent !== null).length,
|
||||||
|
swatch: Math.round(r(sw[0]).width),
|
||||||
|
}
|
||||||
|
if (noneWasHidden) none.hidden = true
|
||||||
|
return out
|
||||||
|
})
|
||||||
|
check('色板头部一行装完:吸管 + 色值 + 去色 + 图钉同一排,「去色」在图钉左边且有竖线隔开',
|
||||||
|
popLayout.headOneRow && popLayout.noneLeftOfPin && popLayout.barBetweenNonePin && popLayout.headFitsThreeTabs,
|
||||||
|
JSON.stringify(popLayout))
|
||||||
|
check('常用色 8 列 × 2 行(16 个),最近色也是 8 列两排,块间 1px 细线且无小标题',
|
||||||
|
popLayout.common === 16 && popLayout.twoRows && popLayout.cols === 8 &&
|
||||||
|
popLayout.recCols === 8 && popLayout.recRows === 2 &&
|
||||||
|
popLayout.labelsVisible === 0 && popLayout.dividers.every((d) => d === '1px'),
|
||||||
|
JSON.stringify(popLayout))
|
||||||
|
check('色块区在取色器右侧,弹层宽高在预期区间(比 v1.18 的 380×153 宽一档)',
|
||||||
|
popLayout.sideInRight && popLayout.w >= 410 && popLayout.w <= 470 && popLayout.h <= 178 &&
|
||||||
|
popLayout.swatch === 20,
|
||||||
|
'w=' + popLayout.w + ' h=' + popLayout.h + ' swatch=' + popLayout.swatch)
|
||||||
|
// 开发用:ANNOT_SHOT=/tmp/pop.png 出一张色板弹层截图(验证布局)
|
||||||
|
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) => {
|
const drag = async (x1, y1, x2, y2) => {
|
||||||
await page.mouse.move(x1, y1)
|
await page.mouse.move(x1, y1)
|
||||||
await page.mouse.down()
|
await page.mouse.down()
|
||||||
@@ -672,10 +808,9 @@ check('适应窗口后图片底边不被工具条遮挡', await page.evaluate(()
|
|||||||
check('顶栏输出/导出按钮组贴最右侧(用户裁定 2026-11-04)', await page.evaluate(() => {
|
check('顶栏输出/导出按钮组贴最右侧(用户裁定 2026-11-04)', await page.evaluate(() => {
|
||||||
const hdr = document.querySelector('.iwb-editor-header')
|
const hdr = document.querySelector('.iwb-editor-header')
|
||||||
const ex = document.querySelector('.iwb-editor-header > .iwb-editor-export-actions')
|
const ex = document.querySelector('.iwb-editor-header > .iwb-editor-export-actions')
|
||||||
const hist = document.querySelector('.iwb-editor-header > .iwb-editor-history')
|
if (!hdr || !ex) return false
|
||||||
if (!hdr || !ex || !hist) return false
|
|
||||||
const h = hdr.getBoundingClientRect(), e = ex.getBoundingClientRect()
|
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,表现为「橡皮不能擦」
|
// 橡皮:1.2.2 回归 —— events.js 少 import getActiveLayer,一按下就 ReferenceError,表现为「橡皮不能擦」
|
||||||
@@ -743,11 +878,15 @@ check('顶栏不再有图层层级按钮;视图快捷搬到画布工具栏最
|
|||||||
const hdrAdd = document.querySelector('.iwb-editor-header [data-action="addBlankLayer"], .iwb-editor-header [data-action="addBitmapLayer"]')
|
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 tools = document.querySelector('.iwb-editor-canvas-wrap > .iwb-editor-tools')
|
||||||
const kids = tools ? [...tools.children] : []
|
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"]') &&
|
return !q('.iwb-editor-more-wrap') && !q('[data-action="toggleMore"]') &&
|
||||||
hdrLayerBtns === 0 && !hdrAdd && addBtns === 4 &&
|
hdrLayerBtns === 0 && !hdrAdd && addBtns === 4 &&
|
||||||
!q('.iwb-editor-header [data-action="zoomFit"]') && !q('.iwb-editor-header [data-action="togglePanels"]') &&
|
!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="addBlankLayer"]') &&
|
||||||
q('.iwb-editor-layer-panel-header [data-action="addBitmapLayer"]') &&
|
q('.iwb-editor-layer-panel-header [data-action="addBitmapLayer"]') &&
|
||||||
q('.iwb-editor-layer-panel-header [data-action="mergeLayers"]') &&
|
q('.iwb-editor-layer-panel-header [data-action="mergeLayers"]') &&
|
||||||
@@ -755,7 +894,7 @@ check('顶栏不再有图层层级按钮;视图快捷搬到画布工具栏最
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
check('「还原原图」图标是循环重置(refresh)而不是垃圾桶', await page.evaluate(() => {
|
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
|
if (!svg) return false
|
||||||
const paths = svg.querySelectorAll('path').length
|
const paths = svg.querySelectorAll('path').length
|
||||||
const polys = Array.from(svg.querySelectorAll('polyline')).map(p => p.getAttribute('points')).join('|')
|
const polys = Array.from(svg.querySelectorAll('polyline')).map(p => p.getAttribute('points')).join('|')
|
||||||
@@ -1018,24 +1157,45 @@ await page.keyboard.press('Control+z') // 撤销上一步新建的矩形,恢
|
|||||||
|
|
||||||
// ---- v1.2.9:会话组(新建/覆盖/退出)移到顶栏最左 + 图层 PS 快捷键 ----
|
// ---- v1.2.9:会话组(新建/覆盖/退出)移到顶栏最左 + 图层 PS 快捷键 ----
|
||||||
|
|
||||||
check('顶栏:标题最前 → 新建/覆盖/退出(统一中性色)→ 竖分隔 → 撤销组,右侧只剩 输出+导出', await page.evaluate(() => {
|
check('顶栏:标题 → 新建/覆盖/退出(统一中性色),撤销组已搬去工具条,右侧只剩 输出+导出', await page.evaluate(() => {
|
||||||
const q = (s) => document.querySelector(s)
|
const q = (s) => document.querySelector(s)
|
||||||
const session = q('.iwb-editor-header > .iwb-editor-session')
|
const session = q('.iwb-editor-header > .iwb-editor-session')
|
||||||
const title = q('.iwb-editor-header > .iwb-editor-title')
|
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"]')
|
const dl = q('.iwb-editor-header [data-action="download"]')
|
||||||
if (!session || !title || !hist || !dl) return false
|
if (!session || !title || !dl) return false
|
||||||
const t = title.getBoundingClientRect(), s = session.getBoundingClientRect(), h = hist.getBoundingClientRect()
|
const t = title.getBoundingClientRect(), s = session.getBoundingClientRect()
|
||||||
const btns = Array.from(session.querySelectorAll('.iwb-editor-btn')).map(b => b.dataset.action).join(',')
|
const btns = Array.from(session.querySelectorAll('.iwb-editor-btn')).map(b => b.dataset.action).join(',')
|
||||||
const bg = (sel) => getComputedStyle(q(sel)).backgroundColor
|
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') &&
|
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')
|
bg('.iwb-editor-header .iwb-editor-btn-replace') === bg('.iwb-editor-header .iwb-editor-btn-cancel')
|
||||||
return btns === 'newNode,replace,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') &&
|
!q('.iwb-editor-header > .iwb-editor-commands') &&
|
||||||
unified && dl.textContent.trim() === '导出' &&
|
unified && dl.textContent.trim() === '导出' &&
|
||||||
!q('.iwb-editor-export-actions [data-action="newNode"]')
|
!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 () => {
|
check('画笔选项栏:推荐大小只留 4 个快捷点,硬度补 5 个快捷点且滑杆加宽', await (async () => {
|
||||||
await page.locator('.iwb-editor-tool[data-tool="brush"]').click()
|
await page.locator('.iwb-editor-tool[data-tool="brush"]').click()
|
||||||
const ok = await page.evaluate(() => {
|
const ok = await page.evaluate(() => {
|
||||||
@@ -2265,6 +2425,23 @@ await page.locator('.iwb-editor-color-pop [data-panel-color="#ffd400"]').first()
|
|||||||
await page.waitForTimeout(200)
|
await page.waitForTimeout(200)
|
||||||
const recents = (await dbg()).recentColors
|
const recents = (await dbg()).recentColors
|
||||||
const recentsInPop = await page.locator('.iwb-editor-color-pop .iwb-editor-recent-colors [data-panel-color]').count()
|
const recentsInPop = await page.locator('.iwb-editor-color-pop .iwb-editor-recent-colors [data-panel-color]').count()
|
||||||
|
// 开发用:ANNOT_SHOT2=/tmp/pop-full.png 出一张「去色可见 + 最近色铺满两排」的完整效果图。
|
||||||
|
// 最近色要长期用才攒得满,这里临时补到 16 个纯为出图,不改 S.recentColors / settings。
|
||||||
|
if (process.env.ANNOT_SHOT2) {
|
||||||
|
await page.evaluate(() => {
|
||||||
|
const rec = document.querySelector('.iwb-editor-color-pop .iwb-editor-recent-colors')
|
||||||
|
const group = rec.closest('.iwb-color-group')
|
||||||
|
const list = ['#ffd400', '#e34d59', '#1677ff', '#0f9d58', '#6b4fbb', '#c0392b',
|
||||||
|
'#ff8a00', '#4cd964', '#00bfa5', '#4488ff', '#aa44ff', '#ff66aa',
|
||||||
|
'#d0d0d0', '#808080', '#ffffff', '#000000']
|
||||||
|
rec.innerHTML = list.map((c) =>
|
||||||
|
`<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="${c}" style="background:${c}" title="最近使用 ${c}"></button>`).join('')
|
||||||
|
rec.hidden = false
|
||||||
|
if (group) group.hidden = false
|
||||||
|
})
|
||||||
|
await page.waitForTimeout(120)
|
||||||
|
await page.locator('.iwb-editor-color-pop').screenshot({ path: process.env.ANNOT_SHOT2 })
|
||||||
|
}
|
||||||
await page.keyboard.press('Escape')
|
await page.keyboard.press('Escape')
|
||||||
await page.waitForTimeout(120)
|
await page.waitForTimeout(120)
|
||||||
check('选过的颜色进入「最近使用」并出现在色板弹层',
|
check('选过的颜色进入「最近使用」并出现在色板弹层',
|
||||||
@@ -2721,40 +2898,40 @@ check('右侧栏出现「图片调节」,11 项齐全且顺序固定',
|
|||||||
adjRowCount === 11 && adjNames.join('/') === '曝光/明度/对比度/阴影/高光/色相/饱和度/温度/色调/锐度/清晰度',
|
adjRowCount === 11 && adjNames.join('/') === '曝光/明度/对比度/阴影/高光/色相/饱和度/温度/色调/锐度/清晰度',
|
||||||
'rows=' + adjRowCount + ' ' + adjNames.join('/'))
|
'rows=' + adjRowCount + ' ' + adjNames.join('/'))
|
||||||
|
|
||||||
// ---------- v1.16:右栏常驻调色面板 / 两处同步 / 可拖宽度 / 字号 ----------
|
// ---------- v1.19:右栏调色模块删除(用户 2026-11-10)/ 可拖宽度 / 字号 ----------
|
||||||
const sideSurface = await page.evaluate(() => {
|
const sideFirst = await page.evaluate(() => {
|
||||||
const side = document.querySelector('.iwb-editor-left [data-color-surface="side"]')
|
const aside = document.querySelector('.iwb-editor-left')
|
||||||
if (!side) return null
|
const firstSection = aside && aside.querySelector(':scope > section')
|
||||||
const tabs = [...side.querySelectorAll('.iwb-color-pop-tab')]
|
|
||||||
return {
|
return {
|
||||||
tabs: tabs.length,
|
hasColor: Boolean(aside && aside.querySelector('[data-color-surface]')),
|
||||||
visibleTabs: tabs.filter(t => !t.hidden).length,
|
first: firstSection ? firstSection.className : '',
|
||||||
swatches: side.querySelectorAll('.iwb-editor-color-swatches [data-panel-color]').length,
|
popCount: document.querySelectorAll('.iwb-editor-color-pop').length,
|
||||||
sv: !!side.querySelector('.iwb-color-sv'),
|
|
||||||
hue: !!side.querySelector('.iwb-color-hue'),
|
|
||||||
hex: !!side.querySelector('.iwb-editor-color-hex-input')
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
check('右栏有常驻调色面板:可调颜色项 + 调色器 + 12 个常用色',
|
check('右栏调色模块已删:侧栏第一个模块是「图片调节」,颜色只剩弹层一处',
|
||||||
Boolean(sideSurface) && sideSurface.tabs === 3 && sideSurface.visibleTabs >= 1 &&
|
sideFirst.hasColor === false && /iwb-editor-adj/.test(sideFirst.first) && sideFirst.popCount === 1,
|
||||||
sideSurface.swatches === 12 && sideSurface.sv && sideSurface.hue && sideSurface.hex,
|
JSON.stringify(sideFirst))
|
||||||
JSON.stringify(sideSurface))
|
|
||||||
|
|
||||||
// 在右栏点常用色 → 弹层里同一色块也必须高亮(两处共用一份颜色状态)
|
// 弹层里选常用色:色块 active 圈 / HEX 输入 / 工具栏色点三处必须同时变
|
||||||
await page.locator('.iwb-editor-left [data-color-surface="side"] [data-panel-color="#00bfa5"]').click()
|
await page.locator('.iwb-editor-tools [data-action="toggleColorPop"][data-color-slot="stroke"]').click()
|
||||||
await page.waitForTimeout(220)
|
await page.waitForTimeout(120)
|
||||||
|
await page.locator('.iwb-editor-color-pop .iwb-editor-color-swatches [data-panel-color="#00bfa5"]').click()
|
||||||
|
await page.waitForTimeout(200)
|
||||||
const colorSync = await page.evaluate(() => {
|
const colorSync = await page.evaluate(() => {
|
||||||
// 只看「常用色」网格:最近使用里同色也会高亮,那是正常的两处提示,不该算进断言
|
const active = [...document.querySelectorAll('.iwb-editor-color-pop .iwb-editor-color-swatches [data-panel-color]')]
|
||||||
const activeIn = (root) => [...root.querySelectorAll('.iwb-editor-color-swatches [data-panel-color]')]
|
|
||||||
.filter(b => b.classList.contains('active')).map(b => b.dataset.panelColor)
|
.filter(b => b.classList.contains('active')).map(b => b.dataset.panelColor)
|
||||||
const side = document.querySelector('.iwb-editor-left [data-color-surface="side"]')
|
return {
|
||||||
const pop = document.querySelector('.iwb-editor-color-pop')
|
active,
|
||||||
return { side: activeIn(side), pop: activeIn(pop), color: window.__iwbEditor.__debug().color }
|
hex: document.querySelector('.iwb-editor-color-pop .iwb-editor-color-hex-input').value,
|
||||||
|
color: window.__iwbEditor.__debug().color,
|
||||||
|
}
|
||||||
})
|
})
|
||||||
check('右栏选色后弹层同一色块同步高亮(不是两套各管各的)',
|
check('弹层选色:常用色高亮 + HEX 回填 + 主色统一(三处不是各说各话)',
|
||||||
colorSync.side.length === 1 && colorSync.side[0] === '#00bfa5' &&
|
colorSync.active.length === 1 && colorSync.active[0] === '#00bfa5' &&
|
||||||
colorSync.pop.length === 1 && colorSync.pop[0] === '#00bfa5' && colorSync.color === '#00bfa5',
|
colorSync.hex.toLowerCase() === '#00bfa5' && colorSync.color === '#00bfa5',
|
||||||
JSON.stringify(colorSync))
|
JSON.stringify(colorSync))
|
||||||
|
await page.keyboard.press('Escape')
|
||||||
|
await page.waitForTimeout(90)
|
||||||
|
|
||||||
// 拖右栏宽度:侧栏在画布右侧,指针左移 80px ⇒ 宽 80px
|
// 拖右栏宽度:侧栏在画布右侧,指针左移 80px ⇒ 宽 80px
|
||||||
const sideW0 = await page.evaluate(() => Math.round(document.querySelector('.iwb-editor-left').getBoundingClientRect().width))
|
const sideW0 = await page.evaluate(() => Math.round(document.querySelector('.iwb-editor-left').getBoundingClientRect().width))
|
||||||
|
|||||||
@@ -28,9 +28,12 @@ v0.2 换 potrace,并且按用户要求**只做单色 / 灰度**(不做彩色
|
|||||||
背景默认白)+「带底」勾选(决定背景色是否写进导出)
|
背景默认白)+「带底」勾选(决定背景色是否写进导出)
|
||||||
- **按孤岛拆分**(默认开):每个连通块输出为一个独立 `<path>` 元素,粘到 Figma 就是多个
|
- **按孤岛拆分**(默认开):每个连通块输出为一个独立 `<path>` 元素,粘到 Figma 就是多个
|
||||||
可单独选中的图层;关掉则整图合并成一个 path(便于整体缩放/移动)
|
可单独选中的图层;关掉则整图合并成一个 path(便于整体缩放/移动)
|
||||||
- 预览:按住空格对比原图;**滚轮/捏合缩放、拖动平移、双击复位**(0.2×–8×);面板显示元素数 / 层数 / 体积 / 耗时
|
- 预览:按住空格对比原图;**滚轮/捏合缩放、左键拖动平移、双击复位**(0.2×–8×);面板显示元素数 / 层数 / 体积 / 耗时
|
||||||
- 输出:**复制 SVG**(写 `image/svg+xml` + `text/html` + `text/plain` 三种剪贴板口味,
|
- 顶栏按钮(左 → 右):**保存为节点** · **复制 SVG** · **下载 SVG** · 取消(四颗统一描边配色,不用绿色主按钮)
|
||||||
Figma / Illustrator 粘进去就是真矢量)· **下载 SVG** · **保存为节点**(PNG,按输出倍率 1–4× 从矢量重绘)
|
- **保存为节点**:PNG,按输出倍率 1–4× 从矢量重绘后写回画布
|
||||||
|
- **复制 SVG**:写 `image/svg+xml` + `text/html` + `text/plain` 三种剪贴板口味,
|
||||||
|
Figma / Illustrator 粘进去就是真矢量
|
||||||
|
- **下载 SVG**:存成文件
|
||||||
|
|
||||||
## 按孤岛拆分(v0.3)
|
## 按孤岛拆分(v0.3)
|
||||||
|
|
||||||
@@ -91,7 +94,8 @@ potrace 出厂把**整张图所有轮廓**塞进同一个 `<path>` 的 d 里(8
|
|||||||
| 操作 | 行为 |
|
| 操作 | 行为 |
|
||||||
|---|---|
|
|---|---|
|
||||||
| 鼠标滚轮 / 触控板捏合 | 以**光标位置为锚点**缩放(0.2×–8×) |
|
| 鼠标滚轮 / 触控板捏合 | 以**光标位置为锚点**缩放(0.2×–8×) |
|
||||||
| 拖住左键 / 触控板双指滑动 | 平移画布 |
|
| 按住左键拖动 / 按住中键拖动 | 平移画布(100% 时也能拖) |
|
||||||
|
| 水平滚动(`Shift` + 滚轮也是这种) | 只平移,不改倍率 |
|
||||||
| 双击 / 点右下角「172% 复位」/ 按 `0` | 回到 100% 等比铺满 |
|
| 双击 / 点右下角「172% 复位」/ 按 `0` | 回到 100% 等比铺满 |
|
||||||
| `+` / `-` | 以画面中心缩放 |
|
| `+` / `-` | 以画面中心缩放 |
|
||||||
|
|
||||||
@@ -102,9 +106,11 @@ potrace 出厂把**整张图所有轮廓**塞进同一个 `<path>` 的 d 里(8
|
|||||||
要是每张图各存一份状态,切过去那一刻画面就会跳。harness 有断言锁这个行为。
|
要是每张图各存一份状态,切过去那一刻画面就会跳。harness 有断言锁这个行为。
|
||||||
- **锚点缩放**才有「指哪放大哪」的感觉。推导:图片中心恒在「预览区中心 + pan」,屏幕点 P 的图上偏移
|
- **锚点缩放**才有「指哪放大哪」的感觉。推导:图片中心恒在「预览区中心 + pan」,屏幕点 P 的图上偏移
|
||||||
`d = (P − C − pan) / zoom`,要让 P 不动需 `pan′ = pan + d·(zoom − zoom′)`。
|
`d = (P − C − pan) / zoom`,要让 P 不动需 `pan′ = pan + d·(zoom − zoom′)`。
|
||||||
- **触控板双指滑动 ≠ 捏合**。浏览器里捏合是 `ctrlKey + wheel`,普通双指滑动是 `wheel` 小步长。
|
- **滚轮一律缩放,不猜设备**。第一版想区分「鼠标滚轮 vs 触控板双指滑动」,判定条件写成
|
||||||
前者缩放、后者平移;把双指滑动硬拗成缩放是 macOS 上最招人烦的一种「自作聪明」。
|
「`deltaY` 是 ±100 这类整数且 ≥48」—— 结果鼠标开着平滑滚动、或高精度滚轮给小数步长时,
|
||||||
鼠标滚轮靠「deltaY ≥ 48 且是整数」区分。
|
滚轮被当成双指滑动,表现成**拖图不放大**(用户实测踩到)。现在只按主导轴分:
|
||||||
|
垂直 → 缩放,水平 → 平移。步长按幅度分两档(≥40 用 0.0018,细碎小数用 0.012),
|
||||||
|
让鼠标一格约 1.2×、触控板小步也跟手。
|
||||||
|
|
||||||
布局上 `.vz-stage` 从 flex 居中改成 `position: absolute` + `translate(-50%, -50%)`:
|
布局上 `.vz-stage` 从 flex 居中改成 `position: absolute` + `translate(-50%, -50%)`:
|
||||||
缩放锚点要求元素的变换中心稳稳落在预览区正中,flex 居中下图片尺寸一变中心就会漂。
|
缩放锚点要求元素的变换中心稳稳落在预览区正中,flex 居中下图片尺寸一变中心就会漂。
|
||||||
@@ -130,7 +136,7 @@ potrace 与其 JS 移植都是 **GPL-2.0**(见 `plugin/vendor/potrace/LICENSE`
|
|||||||
```bash
|
```bash
|
||||||
npm run build -- image-vectorize # plugin/ → src/index.js(esbuild IIFE)
|
npm run build -- image-vectorize # plugin/ → src/index.js(esbuild IIFE)
|
||||||
npm run validate # 契约校验
|
npm run validate # 契约校验
|
||||||
node image-vectorize/tools/harness.mjs # 本地端到端(合成宿主 + 真 Chromium,47 项)
|
node image-vectorize/tools/harness.mjs # 本地端到端(合成宿主 + 真 Chromium,64 项)
|
||||||
node image-vectorize/tools/e2e-site.mjs # 真站(KV / SRI / CSP / 真实画布桥)
|
node image-vectorize/tools/e2e-site.mjs # 真站(KV / SRI / CSP / 真实画布桥)
|
||||||
|
|
||||||
# 拿真实素材调参数(不进 CI,最快看到效果):
|
# 拿真实素材调参数(不进 CI,最快看到效果):
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@iwb-plugin/image-vectorize",
|
"name": "@iwb-plugin/image-vectorize",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.4.0",
|
"version": "0.4.2",
|
||||||
"description": "位图转矢量:potrace(纯 JS)单色/灰度描摹,输出 SVG 与 PNG 节点;对文字、logo、线稿保形好,不需要 wasm",
|
"description": "位图转矢量:potrace(纯 JS)单色/灰度描摹,输出 SVG 与 PNG 节点;对文字、logo、线稿保形好,不需要 wasm",
|
||||||
"ibwPlugin": {
|
"ibwPlugin": {
|
||||||
"id": "image-vectorize",
|
"id": "image-vectorize",
|
||||||
|
|||||||
@@ -75,14 +75,8 @@
|
|||||||
.vz-btn:hover { background: #34343f; border-color: #4a4a5c; }
|
.vz-btn:hover { background: #34343f; border-color: #4a4a5c; }
|
||||||
.vz-btn:active { background: #2f2f3a; }
|
.vz-btn:active { background: #2f2f3a; }
|
||||||
.vz-btn:disabled { opacity: 0.45; cursor: default; }
|
.vz-btn:disabled { opacity: 0.45; cursor: default; }
|
||||||
|
/* 顶栏四颗按钮统一走上面这套描边配色(曾经有一颗 .vz-btn-primary 绿色主按钮,
|
||||||
.vz-btn-primary {
|
2026-11-09 用户要求「颜色都用取消按钮的配色」,已去掉)。 */
|
||||||
background: #1f7a52;
|
|
||||||
border-color: #27875c;
|
|
||||||
color: #eafff5;
|
|
||||||
}
|
|
||||||
.vz-btn-primary:hover { background: #248a5d; border-color: #2f9c69; }
|
|
||||||
.vz-btn-primary:disabled { background: #24503e; border-color: #2a5c47; }
|
|
||||||
|
|
||||||
/* ---------- 主体 ---------- */
|
/* ---------- 主体 ---------- */
|
||||||
.vz-body {
|
.vz-body {
|
||||||
|
|||||||
@@ -128,10 +128,12 @@ function viewHTML(name) {
|
|||||||
'<header class="vz-header">' +
|
'<header class="vz-header">' +
|
||||||
'<span class="vz-title">位图转矢量<em data-meta>' + esc(name) + '</em></span>' +
|
'<span class="vz-title">位图转矢量<em data-meta>' + esc(name) + '</em></span>' +
|
||||||
'<div class="vz-spacer"></div>' +
|
'<div class="vz-spacer"></div>' +
|
||||||
'<button type="button" class="vz-btn" data-act="cancel">取消</button>' +
|
// 顺序:主操作在左,取消在最右(用户 2026-11-09 要求与原先互换)。
|
||||||
|
// 四颗按钮同一套描边配色,不再给主操作上绿色填充 —— 用户口径「颜色都用取消按钮的配色」。
|
||||||
|
'<button type="button" class="vz-btn" data-act="save">保存为节点</button>' +
|
||||||
'<button type="button" class="vz-btn" data-act="copy">复制 SVG</button>' +
|
'<button type="button" class="vz-btn" data-act="copy">复制 SVG</button>' +
|
||||||
'<button type="button" class="vz-btn" data-act="svg">下载 SVG</button>' +
|
'<button type="button" class="vz-btn" data-act="svg">下载 SVG</button>' +
|
||||||
'<button type="button" class="vz-btn vz-btn-primary" data-act="save">保存为节点</button>' +
|
'<button type="button" class="vz-btn" data-act="cancel">取消</button>' +
|
||||||
'</header>' +
|
'</header>' +
|
||||||
'<div class="vz-body">' +
|
'<div class="vz-body">' +
|
||||||
'<div class="vz-preview" data-preview>' +
|
'<div class="vz-preview" data-preview>' +
|
||||||
@@ -386,36 +388,43 @@ export function createVectorizer(options) {
|
|||||||
|
|
||||||
function onPreviewWheel(event) {
|
function onPreviewWheel(event) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
// 触控板「捏合」在浏览器里就是 ctrlKey + wheel;鼠标滚轮是 ±100 这类整数大步。
|
// 滚轮 = 缩放,无条件(用户口径:中键滚轮就是放大缩小)。
|
||||||
// 触控板双指滑动(小步 / 小数)留给平移 —— macOS 上把它硬拗成缩放是最招人烦的自作聪明。
|
// 早先靠「deltaY 是 ±100 整数」猜设备来区分鼠标滚轮与触控板双指滑动,结果鼠标驱动
|
||||||
const wheelLike = !event.shiftKey && Math.abs(event.deltaY) >= 48 && Number.isInteger(event.deltaY)
|
// 一旦给小数步长(平滑滚动 / 高精度滚轮)就落进平移分支,表现成「滚轮拖图不放大」。
|
||||||
if (event.ctrlKey || wheelLike) {
|
// 现在只按主导轴分:水平滚动(含 Shift+滚轮,Chrome 会转成 deltaX)才平移。
|
||||||
const step = event.ctrlKey ? 0.01 : 0.0018
|
if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
|
||||||
zoomAt(event.clientX, event.clientY, Math.exp(-event.deltaY * step))
|
panX += event.deltaX
|
||||||
|
applyView()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
panX += event.deltaX
|
if (!event.deltaY) return
|
||||||
panY += event.deltaY
|
// 步长分两档:鼠标滚轮一格 ±100,触控板是细碎小数步 —— 后者要给更大增益才跟得上手
|
||||||
applyView()
|
const step = event.ctrlKey ? 0.01 : Math.abs(event.deltaY) >= 40 ? 0.0018 : 0.012
|
||||||
|
zoomAt(event.clientX, event.clientY, Math.exp(-event.deltaY * step))
|
||||||
}
|
}
|
||||||
|
|
||||||
function onPreviewPointerDown(event) {
|
function onPreviewPointerDown(event) {
|
||||||
if (!els || !els.preview || event.button !== 0) return
|
if (!els || !els.preview) return
|
||||||
|
// 左键拖动 = 平移;中键拖动也平移(设计软件的肌肉记忆,顺手)
|
||||||
|
if (event.button !== 0 && event.button !== 1) return
|
||||||
if (event.target.closest('.vz-zoom')) return
|
if (event.target.closest('.vz-zoom')) return
|
||||||
|
// 挡掉 img 原生拖拽与中键自动滚动(Windows 上会弹四向圆盘,手势直接断掉)
|
||||||
|
event.preventDefault()
|
||||||
drag = { x: event.clientX, y: event.clientY, panX: panX, panY: panY, id: event.pointerId }
|
drag = { x: event.clientX, y: event.clientY, panX: panX, panY: panY, id: event.pointerId }
|
||||||
els.preview.classList.add('is-panning')
|
els.preview.classList.add('is-panning')
|
||||||
try { els.preview.setPointerCapture(event.pointerId) } catch (e) { /* 没有 capture 也能拖,只是移出元素会断 */ }
|
try { els.preview.setPointerCapture(event.pointerId) } catch (e) { /* 没有 capture 也能拖,只是移出元素会断 */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
function onPreviewPointerMove(event) {
|
function onPreviewPointerMove(event) {
|
||||||
if (!drag || !els || !els.preview) return
|
if (!drag || !els || !els.preview || event.pointerId !== drag.id) return
|
||||||
panX = drag.panX + (event.clientX - drag.x)
|
panX = drag.panX + (event.clientX - drag.x)
|
||||||
panY = drag.panY + (event.clientY - drag.y)
|
panY = drag.panY + (event.clientY - drag.y)
|
||||||
applyView()
|
applyView()
|
||||||
}
|
}
|
||||||
|
|
||||||
function onPreviewPointerUp() {
|
function onPreviewPointerUp(event) {
|
||||||
if (!drag) return
|
if (!drag) return
|
||||||
|
if (event && event.pointerId !== undefined && event.pointerId !== drag.id) return
|
||||||
if (els && els.preview) {
|
if (els && els.preview) {
|
||||||
els.preview.classList.remove('is-panning')
|
els.preview.classList.remove('is-panning')
|
||||||
try { els.preview.releasePointerCapture(drag.id) } catch (e) { /* 已经释放过 */ }
|
try { els.preview.releasePointerCapture(drag.id) } catch (e) { /* 已经释放过 */ }
|
||||||
@@ -797,6 +806,8 @@ export function createVectorizer(options) {
|
|||||||
els.preview.addEventListener('pointermove', onPreviewPointerMove)
|
els.preview.addEventListener('pointermove', onPreviewPointerMove)
|
||||||
els.preview.addEventListener('pointerup', onPreviewPointerUp)
|
els.preview.addEventListener('pointerup', onPreviewPointerUp)
|
||||||
els.preview.addEventListener('pointercancel', onPreviewPointerUp)
|
els.preview.addEventListener('pointercancel', onPreviewPointerUp)
|
||||||
|
// capture 被系统抢走(切窗口、拖出屏幕)时也要收尾,否则光标会一直卡在 grabbing
|
||||||
|
els.preview.addEventListener('lostpointercapture', onPreviewPointerUp)
|
||||||
els.preview.addEventListener('dblclick', onPreviewDblClick)
|
els.preview.addEventListener('dblclick', onPreviewDblClick)
|
||||||
els.preview.addEventListener('click', function (event) {
|
els.preview.addEventListener('click', function (event) {
|
||||||
if (event.target.closest('.vz-zoom')) resetView()
|
if (event.target.closest('.vz-zoom')) resetView()
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
var __IWB_VECTORIZE_MANIFEST__ = {
|
var __IWB_VECTORIZE_MANIFEST__ = {
|
||||||
id: 'image-vectorize',
|
id: 'image-vectorize',
|
||||||
name: '位图转矢量',
|
name: '位图转矢量',
|
||||||
version: '0.4.0',
|
version: '0.4.2',
|
||||||
apiVersion: 1,
|
apiVersion: 1,
|
||||||
capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'],
|
capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'],
|
||||||
settings: {
|
settings: {
|
||||||
@@ -2082,14 +2082,8 @@ var __IWB_VECTORIZE_MANIFEST__ = {
|
|||||||
.vz-btn:hover { background: #34343f; border-color: #4a4a5c; }
|
.vz-btn:hover { background: #34343f; border-color: #4a4a5c; }
|
||||||
.vz-btn:active { background: #2f2f3a; }
|
.vz-btn:active { background: #2f2f3a; }
|
||||||
.vz-btn:disabled { opacity: 0.45; cursor: default; }
|
.vz-btn:disabled { opacity: 0.45; cursor: default; }
|
||||||
|
/* 顶栏四颗按钮统一走上面这套描边配色(曾经有一颗 .vz-btn-primary 绿色主按钮,
|
||||||
.vz-btn-primary {
|
2026-11-09 用户要求「颜色都用取消按钮的配色」,已去掉)。 */
|
||||||
background: #1f7a52;
|
|
||||||
border-color: #27875c;
|
|
||||||
color: #eafff5;
|
|
||||||
}
|
|
||||||
.vz-btn-primary:hover { background: #248a5d; border-color: #2f9c69; }
|
|
||||||
.vz-btn-primary:disabled { background: #24503e; border-color: #2a5c47; }
|
|
||||||
|
|
||||||
/* ---------- 主体 ---------- */
|
/* ---------- 主体 ---------- */
|
||||||
.vz-body {
|
.vz-body {
|
||||||
@@ -3022,7 +3016,7 @@ var __IWB_VECTORIZE_MANIFEST__ = {
|
|||||||
}).join("") + '</div></div><div class="vz-row vz-row-switch"><div class="vz-row-text">按孤岛拆分<span>每个连通块一个图层,粘到 Figma 可单独选中;笔画不连的汉字会分成几块</span></div><label class="vz-switch"><input type="checkbox" data-check="splitIslands"' + (params.splitIslands ? " checked" : "") + '><i></i></label></div></div><div class="vz-group"><div class="vz-stats"><span><b data-stat="elements">–</b> 元素</span><span><b data-stat="levels">–</b> 层</span><span><b data-stat="bytes">–</b></span><span><b data-stat="ms">–</b></span></div></div><div class="vz-group"><button type="button" class="vz-adv-toggle" data-act="adv" aria-expanded="' + (advOpen ? "true" : "false") + '">高级参数<span data-adv-caret>' + (advOpen ? "▴" : "▾") + '</span></button><div class="vz-adv" data-adv' + (advOpen ? "" : " hidden") + '><div class="vz-row"><div class="vz-row-label">阈值<span>自动按直方图取,手动可救极端图</span></div><div class="vz-seg" data-seg-group="thrMode"><button type="button" data-seg="thrMode" data-value="auto">自动</button><button type="button" data-seg="thrMode" data-value="manual">手动</button></div></div><div data-thr-row hidden>' + rangeHTML("threshold", "阈值取值", 0, 255, 1, params.threshold >= 0 ? params.threshold : 128, "") + '</div><div class="vz-row"><div class="vz-row-label">反相<span>黑底白字时打开</span></div><div class="vz-seg" data-seg-group="invert">' + segHTML("invert", [["0", "正片"], ["1", "负片"]], params.invert ? 1 : 0) + '</div></div><div class="vz-row"><div class="vz-row-label">填充 / 背景<span>填充仅「纯单色」生效 · 背景作预览底</span></div><div class="vz-swatches"><input type="color" class="vz-color" data-color="color" value="' + esc(params.color) + '" title="填充色(纯单色生效)"><input type="color" class="vz-color" data-color="bg" value="' + esc(params.bg) + '" title="背景色(预览底;勾「带底」写入导出)"><label class="vz-mini" title="导出 / 复制时把背景色一起写进 SVG(默认不带,粘到 Figma 是透明底)"><input type="checkbox" data-check="bgExport"' + (params.bgExport ? " checked" : "") + "><span>带底</span></label></div></div></div></div>";
|
}).join("") + '</div></div><div class="vz-row vz-row-switch"><div class="vz-row-text">按孤岛拆分<span>每个连通块一个图层,粘到 Figma 可单独选中;笔画不连的汉字会分成几块</span></div><label class="vz-switch"><input type="checkbox" data-check="splitIslands"' + (params.splitIslands ? " checked" : "") + '><i></i></label></div></div><div class="vz-group"><div class="vz-stats"><span><b data-stat="elements">–</b> 元素</span><span><b data-stat="levels">–</b> 层</span><span><b data-stat="bytes">–</b></span><span><b data-stat="ms">–</b></span></div></div><div class="vz-group"><button type="button" class="vz-adv-toggle" data-act="adv" aria-expanded="' + (advOpen ? "true" : "false") + '">高级参数<span data-adv-caret>' + (advOpen ? "▴" : "▾") + '</span></button><div class="vz-adv" data-adv' + (advOpen ? "" : " hidden") + '><div class="vz-row"><div class="vz-row-label">阈值<span>自动按直方图取,手动可救极端图</span></div><div class="vz-seg" data-seg-group="thrMode"><button type="button" data-seg="thrMode" data-value="auto">自动</button><button type="button" data-seg="thrMode" data-value="manual">手动</button></div></div><div data-thr-row hidden>' + rangeHTML("threshold", "阈值取值", 0, 255, 1, params.threshold >= 0 ? params.threshold : 128, "") + '</div><div class="vz-row"><div class="vz-row-label">反相<span>黑底白字时打开</span></div><div class="vz-seg" data-seg-group="invert">' + segHTML("invert", [["0", "正片"], ["1", "负片"]], params.invert ? 1 : 0) + '</div></div><div class="vz-row"><div class="vz-row-label">填充 / 背景<span>填充仅「纯单色」生效 · 背景作预览底</span></div><div class="vz-swatches"><input type="color" class="vz-color" data-color="color" value="' + esc(params.color) + '" title="填充色(纯单色生效)"><input type="color" class="vz-color" data-color="bg" value="' + esc(params.bg) + '" title="背景色(预览底;勾「带底」写入导出)"><label class="vz-mini" title="导出 / 复制时把背景色一起写进 SVG(默认不带,粘到 Figma 是透明底)"><input type="checkbox" data-check="bgExport"' + (params.bgExport ? " checked" : "") + "><span>带底</span></label></div></div></div></div>";
|
||||||
}
|
}
|
||||||
function viewHTML(name) {
|
function viewHTML(name) {
|
||||||
return '<div class="vz-root"><div class="vz-modal" role="dialog" aria-modal="true" aria-label="位图转矢量"><header class="vz-header"><span class="vz-title">位图转矢量<em data-meta>' + esc(name) + '</em></span><div class="vz-spacer"></div><button type="button" class="vz-btn" data-act="cancel">取消</button><button type="button" class="vz-btn" data-act="copy">复制 SVG</button><button type="button" class="vz-btn" data-act="svg">下载 SVG</button><button type="button" class="vz-btn vz-btn-primary" data-act="save">保存为节点</button></header><div class="vz-body"><div class="vz-preview" data-preview><img class="vz-stage" data-stage="vector" alt="矢量预览" draggable="false"><img class="vz-stage" data-stage="original" alt="原图" draggable="false" hidden><div class="vz-badge" data-badge>矢量预览</div><div class="vz-status" data-status hidden><i class="vz-dot"></i><span data-status-text></span></div><div class="vz-hint">空格 对比原图 · 滚轮缩放 · 拖动平移 · 双击复位</div><div class="vz-zoom" data-zoom-chip hidden title="点击回到 100%"><b data-zoom-val>100%</b><span>复位</span></div></div><aside class="vz-panel" data-panel></aside></div></div></div>';
|
return '<div class="vz-root"><div class="vz-modal" role="dialog" aria-modal="true" aria-label="位图转矢量"><header class="vz-header"><span class="vz-title">位图转矢量<em data-meta>' + esc(name) + '</em></span><div class="vz-spacer"></div><button type="button" class="vz-btn" data-act="save">保存为节点</button><button type="button" class="vz-btn" data-act="copy">复制 SVG</button><button type="button" class="vz-btn" data-act="svg">下载 SVG</button><button type="button" class="vz-btn" data-act="cancel">取消</button></header><div class="vz-body"><div class="vz-preview" data-preview><img class="vz-stage" data-stage="vector" alt="矢量预览" draggable="false"><img class="vz-stage" data-stage="original" alt="原图" draggable="false" hidden><div class="vz-badge" data-badge>矢量预览</div><div class="vz-status" data-status hidden><i class="vz-dot"></i><span data-status-text></span></div><div class="vz-hint">空格 对比原图 · 滚轮缩放 · 拖动平移 · 双击复位</div><div class="vz-zoom" data-zoom-chip hidden title="点击回到 100%"><b data-zoom-val>100%</b><span>复位</span></div></div><aside class="vz-panel" data-panel></aside></div></div></div>';
|
||||||
}
|
}
|
||||||
var ALPHA_TONE = { hard: 0.4, normal: 1, round: 1.2 };
|
var ALPHA_TONE = { hard: 0.4, normal: 1, round: 1.2 };
|
||||||
var toneOf = (alphaMax) => alphaMax <= 0.6 ? "hard" : alphaMax >= 1.1 ? "round" : "normal";
|
var toneOf = (alphaMax) => alphaMax <= 0.6 ? "hard" : alphaMax >= 1.1 ? "round" : "normal";
|
||||||
@@ -3232,19 +3226,20 @@ var __IWB_VECTORIZE_MANIFEST__ = {
|
|||||||
}
|
}
|
||||||
function onPreviewWheel(event) {
|
function onPreviewWheel(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const wheelLike = !event.shiftKey && Math.abs(event.deltaY) >= 48 && Number.isInteger(event.deltaY);
|
if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
|
||||||
if (event.ctrlKey || wheelLike) {
|
panX += event.deltaX;
|
||||||
const step = event.ctrlKey ? 0.01 : 18e-4;
|
applyView();
|
||||||
zoomAt(event.clientX, event.clientY, Math.exp(-event.deltaY * step));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
panX += event.deltaX;
|
if (!event.deltaY) return;
|
||||||
panY += event.deltaY;
|
const step = event.ctrlKey ? 0.01 : Math.abs(event.deltaY) >= 40 ? 18e-4 : 0.012;
|
||||||
applyView();
|
zoomAt(event.clientX, event.clientY, Math.exp(-event.deltaY * step));
|
||||||
}
|
}
|
||||||
function onPreviewPointerDown(event) {
|
function onPreviewPointerDown(event) {
|
||||||
if (!els || !els.preview || event.button !== 0) return;
|
if (!els || !els.preview) return;
|
||||||
|
if (event.button !== 0 && event.button !== 1) return;
|
||||||
if (event.target.closest(".vz-zoom")) return;
|
if (event.target.closest(".vz-zoom")) return;
|
||||||
|
event.preventDefault();
|
||||||
drag = { x: event.clientX, y: event.clientY, panX, panY, id: event.pointerId };
|
drag = { x: event.clientX, y: event.clientY, panX, panY, id: event.pointerId };
|
||||||
els.preview.classList.add("is-panning");
|
els.preview.classList.add("is-panning");
|
||||||
try {
|
try {
|
||||||
@@ -3253,13 +3248,14 @@ var __IWB_VECTORIZE_MANIFEST__ = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function onPreviewPointerMove(event) {
|
function onPreviewPointerMove(event) {
|
||||||
if (!drag || !els || !els.preview) return;
|
if (!drag || !els || !els.preview || event.pointerId !== drag.id) return;
|
||||||
panX = drag.panX + (event.clientX - drag.x);
|
panX = drag.panX + (event.clientX - drag.x);
|
||||||
panY = drag.panY + (event.clientY - drag.y);
|
panY = drag.panY + (event.clientY - drag.y);
|
||||||
applyView();
|
applyView();
|
||||||
}
|
}
|
||||||
function onPreviewPointerUp() {
|
function onPreviewPointerUp(event) {
|
||||||
if (!drag) return;
|
if (!drag) return;
|
||||||
|
if (event && event.pointerId !== void 0 && event.pointerId !== drag.id) return;
|
||||||
if (els && els.preview) {
|
if (els && els.preview) {
|
||||||
els.preview.classList.remove("is-panning");
|
els.preview.classList.remove("is-panning");
|
||||||
try {
|
try {
|
||||||
@@ -3637,6 +3633,7 @@ var __IWB_VECTORIZE_MANIFEST__ = {
|
|||||||
els.preview.addEventListener("pointermove", onPreviewPointerMove);
|
els.preview.addEventListener("pointermove", onPreviewPointerMove);
|
||||||
els.preview.addEventListener("pointerup", onPreviewPointerUp);
|
els.preview.addEventListener("pointerup", onPreviewPointerUp);
|
||||||
els.preview.addEventListener("pointercancel", onPreviewPointerUp);
|
els.preview.addEventListener("pointercancel", onPreviewPointerUp);
|
||||||
|
els.preview.addEventListener("lostpointercapture", onPreviewPointerUp);
|
||||||
els.preview.addEventListener("dblclick", onPreviewDblClick);
|
els.preview.addEventListener("dblclick", onPreviewDblClick);
|
||||||
els.preview.addEventListener("click", function(event) {
|
els.preview.addEventListener("click", function(event) {
|
||||||
if (event.target.closest(".vz-zoom")) resetView();
|
if (event.target.closest(".vz-zoom")) resetView();
|
||||||
|
|||||||
@@ -139,6 +139,15 @@ check('样式注入生效(CSP unsafe-inline)', await page.evaluate(() => {
|
|||||||
return Boolean(s && s.textContent.indexOf('.vz-') >= 0)
|
return Boolean(s && s.textContent.indexOf('.vz-') >= 0)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
// 用户 2026-11-09:取消与保存为节点互换,四颗按钮同一套描边配色(绿色主按钮已去掉)。
|
||||||
|
// 这条同时是「线上真的是新版」的活体证据 —— 光看版本号挡不住产物没重建。
|
||||||
|
check('顶栏顺序 保存为节点→复制→下载→取消,四颗同色', await page.evaluate(() => {
|
||||||
|
const btns = [...document.querySelectorAll('.vz-header .vz-btn')]
|
||||||
|
if (btns.map((b) => b.dataset.act).join(',') !== 'save,copy,svg,cancel') return false
|
||||||
|
const colors = new Set(btns.map((b) => getComputedStyle(b).backgroundColor + '|' + getComputedStyle(b).color))
|
||||||
|
return colors.size === 1
|
||||||
|
}))
|
||||||
|
|
||||||
// ---------- 5) 真站 CSP 下引擎能跑 ----------
|
// ---------- 5) 真站 CSP 下引擎能跑 ----------
|
||||||
const paths = await poll(async () => {
|
const paths = await poll(async () => {
|
||||||
// 统计项是「元素」,合并模式下会带后缀「(N 孤岛合并)」,只取前面的数字
|
// 统计项是「元素」,合并模式下会带后缀「(N 孤岛合并)」,只取前面的数字
|
||||||
@@ -189,12 +198,15 @@ const pvBox = await page.locator('.vz-preview').boundingBox()
|
|||||||
await page.mouse.move(pvBox.x + pvBox.width / 2 + 40, pvBox.y + pvBox.height / 2 - 20)
|
await page.mouse.move(pvBox.x + pvBox.width / 2 + 40, pvBox.y + pvBox.height / 2 - 20)
|
||||||
await page.mouse.wheel(0, -300)
|
await page.mouse.wheel(0, -300)
|
||||||
await sleep(220)
|
await sleep(220)
|
||||||
|
// 断言「换算比例」而不是「比容器大」:正方形图 fit 进宽屏预览后本来就比容器窄,
|
||||||
|
// 拿 rect.width > clientWidth 会比较,放大了也可能不成立(实测真站 549 vs 1011)
|
||||||
check('滚轮放大预览、倍率胶囊出现', await page.evaluate(() => {
|
check('滚轮放大预览、倍率胶囊出现', await page.evaluate(() => {
|
||||||
const p = document.querySelector('.vz-preview')
|
const p = document.querySelector('.vz-preview')
|
||||||
|
const v = document.querySelector('[data-stage="vector"]')
|
||||||
const z = Number(p.style.getPropertyValue('--vz-zoom') || 1)
|
const z = Number(p.style.getPropertyValue('--vz-zoom') || 1)
|
||||||
const chip = document.querySelector('[data-zoom-chip]')
|
const chip = document.querySelector('[data-zoom-chip]')
|
||||||
const rect = document.querySelector('[data-stage="vector"]').getBoundingClientRect()
|
const ratio = v.getBoundingClientRect().width / v.clientWidth
|
||||||
return z > 1.1 && Boolean(chip) && !chip.hidden && rect.width > p.clientWidth
|
return z > 1.1 && Boolean(chip) && !chip.hidden && Math.abs(ratio - z) < 0.02
|
||||||
}))
|
}))
|
||||||
await page.mouse.dblclick(pvBox.x + pvBox.width / 2, pvBox.y + pvBox.height / 2)
|
await page.mouse.dblclick(pvBox.x + pvBox.width / 2, pvBox.y + pvBox.height / 2)
|
||||||
await sleep(220)
|
await sleep(220)
|
||||||
@@ -203,6 +215,23 @@ check('双击复位回 100%', await page.evaluate(() => {
|
|||||||
return Number(p.style.getPropertyValue('--vz-zoom') || 1) === 1
|
return Number(p.style.getPropertyValue('--vz-zoom') || 1) === 1
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
// 回归:平滑滚轮(小数 deltaY)在真站也必须缩放。旧逻辑靠整数步长识别鼠标,会把这类滚轮当平移。
|
||||||
|
await page.evaluate(() => {
|
||||||
|
const p = document.querySelector('.vz-preview')
|
||||||
|
const r = p.getBoundingClientRect()
|
||||||
|
p.dispatchEvent(new WheelEvent('wheel', {
|
||||||
|
deltaY: -12.5, deltaMode: 0, bubbles: true, cancelable: true,
|
||||||
|
clientX: r.left + r.width / 2, clientY: r.top + r.height / 2,
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
await sleep(160)
|
||||||
|
check('真站:小数步长滚轮照样放大', await page.evaluate(() => {
|
||||||
|
const p = document.querySelector('.vz-preview')
|
||||||
|
return Number(p.style.getPropertyValue('--vz-zoom') || 1) > 1.001
|
||||||
|
}))
|
||||||
|
await page.mouse.dblclick(pvBox.x + pvBox.width / 2, pvBox.y + pvBox.height / 2)
|
||||||
|
await sleep(160)
|
||||||
|
|
||||||
// ---------- 5.6) 复制到剪贴板(真写,读回校验口味) ----------
|
// ---------- 5.6) 复制到剪贴板(真写,读回校验口味) ----------
|
||||||
await page.locator('[data-act="copy"]').click()
|
await page.locator('[data-act="copy"]').click()
|
||||||
await sleep(400)
|
await sleep(400)
|
||||||
|
|||||||
@@ -153,6 +153,15 @@ check('模态打开:预览区 + 参数面板 + 四个动作按钮齐全', awai
|
|||||||
document.querySelector('[data-act="save"]') && document.querySelector('[data-act="svg"]') &&
|
document.querySelector('[data-act="save"]') && document.querySelector('[data-act="svg"]') &&
|
||||||
document.querySelector('[data-act="copy"]') && document.querySelector('[data-act="cancel"]'))))
|
document.querySelector('[data-act="copy"]') && document.querySelector('[data-act="cancel"]'))))
|
||||||
|
|
||||||
|
// 用户 2026-11-09:顶栏「取消」与「保存为节点」互换(主操作在左、取消在最右),
|
||||||
|
// 且不再给主操作上绿色 —— 四颗按钮用同一套描边配色。
|
||||||
|
check('顶栏顺序:保存为节点 → 复制 → 下载 → 取消,且四颗同色', await page.evaluate(() => {
|
||||||
|
const btns = [...document.querySelectorAll('.vz-header .vz-btn')]
|
||||||
|
if (btns.map((b) => b.dataset.act).join(',') !== 'save,copy,svg,cancel') return false
|
||||||
|
const colors = new Set(btns.map((b) => getComputedStyle(b).backgroundColor + '|' + getComputedStyle(b).color))
|
||||||
|
return colors.size === 1
|
||||||
|
}))
|
||||||
|
|
||||||
// 高级参数默认展开:用户 2026-11-05 明确要求「不用隐藏」(低频项也一眼能看到)
|
// 高级参数默认展开:用户 2026-11-05 明确要求「不用隐藏」(低频项也一眼能看到)
|
||||||
check('高级参数默认展开', await page.evaluate(() => {
|
check('高级参数默认展开', await page.evaluate(() => {
|
||||||
const box = document.querySelector('[data-adv]')
|
const box = document.querySelector('[data-adv]')
|
||||||
@@ -232,6 +241,41 @@ const reset = await viewState()
|
|||||||
check('双击复位回 100% 且胶囊消失',
|
check('双击复位回 100% 且胶囊消失',
|
||||||
reset.zoom === 1 && reset.panX === 0 && reset.panY === 0 && !reset.chip)
|
reset.zoom === 1 && reset.panX === 0 && reset.panY === 0 && !reset.chip)
|
||||||
|
|
||||||
|
// 回归:滚轮必须无条件缩放。早先靠「deltaY 是 ±100 整数」识别鼠标滚轮,
|
||||||
|
// 平滑滚动/高精度滚轮给小数步长时会被判成触控板滑动 → 退化成平移,用户看到「滚轮不放大」。
|
||||||
|
const wheelBy = (deltaY, deltaX) => page.evaluate(([dy, dx]) => {
|
||||||
|
const p = document.querySelector('[data-preview]')
|
||||||
|
const r = p.getBoundingClientRect()
|
||||||
|
p.dispatchEvent(new WheelEvent('wheel', {
|
||||||
|
deltaY: dy, deltaX: dx, deltaMode: 0, bubbles: true, cancelable: true,
|
||||||
|
clientX: r.left + r.width / 2, clientY: r.top + r.height / 2,
|
||||||
|
}))
|
||||||
|
}, [deltaY, deltaX])
|
||||||
|
await wheelBy(-12.5, 0) // 小数步长 = 平滑滚轮 / 触控板
|
||||||
|
await sleep(90)
|
||||||
|
const smooth = await viewState()
|
||||||
|
check('滚轮给小数步长也缩放(不被误判成触控板滑动)', smooth.zoom > 1.001, 'zoom=' + smooth.zoom)
|
||||||
|
await wheelBy(0, -60) // 纯水平滚动(Shift+滚轮在 Chrome 里就是这种)
|
||||||
|
await sleep(90)
|
||||||
|
const horiz = await viewState()
|
||||||
|
check('水平滚动只平移、不改倍率', horiz.zoom === smooth.zoom && Math.abs(horiz.panX - smooth.panX) > 20,
|
||||||
|
'panX=' + horiz.panX.toFixed(1))
|
||||||
|
|
||||||
|
await page.mouse.dblclick(cx, cy)
|
||||||
|
await sleep(120)
|
||||||
|
await page.mouse.move(cx, cy)
|
||||||
|
await page.mouse.down()
|
||||||
|
await page.mouse.move(cx + 40, cy + 20, { steps: 5 })
|
||||||
|
await page.mouse.up()
|
||||||
|
await sleep(90)
|
||||||
|
const dragAt1x = await viewState()
|
||||||
|
check('100% 状态左键也能拖图(不要求先放大)',
|
||||||
|
dragAt1x.zoom === 1 && Math.abs(dragAt1x.panX - 40) < 3 && Math.abs(dragAt1x.panY - 20) < 3,
|
||||||
|
'pan=' + dragAt1x.panX.toFixed(1) + ',' + dragAt1x.panY.toFixed(1))
|
||||||
|
|
||||||
|
await page.mouse.dblclick(cx, cy)
|
||||||
|
await sleep(120)
|
||||||
|
|
||||||
const monoPaths = Number(await pathsNow(page))
|
const monoPaths = Number(await pathsNow(page))
|
||||||
const monoMs = Number((await page.locator('[data-stat="ms"]').textContent()).replace(/[^\d]/g, ''))
|
const monoMs = Number((await page.locator('[data-stat="ms"]').textContent()).replace(/[^\d]/g, ''))
|
||||||
check('单色描摹产出元素(文字图形都在)', monoPaths >= 1 && monoPaths <= 80, 'elements=' + monoPaths)
|
check('单色描摹产出元素(文字图形都在)', monoPaths >= 1 && monoPaths <= 80, 'elements=' + monoPaths)
|
||||||
|
|||||||
Reference in new issue
Block a user