Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a477705c7f | ||
|
|
6a14f900df | ||
|
|
e10ccee8ad |
No files matched your search
@@ -234,6 +234,80 @@ P 下双击 = 结束当前路径(`commitPenPath`),不再进节点编辑。
|
|||||||
- 文字 / 形状 / 钢笔会被直接栅格化进结果层(PS 合并矢量层也是这个结果)。
|
- 文字 / 形状 / 钢笔会被直接栅格化进结果层(PS 合并矢量层也是这个结果)。
|
||||||
- 结果层落回「原最低参与层」的位置,`assignLayerZ` 重新连续编号,不产生重复 z。
|
- 结果层落回「原最低参与层」的位置,`assignLayerZ` 重新连续编号,不产生重复 z。
|
||||||
|
|
||||||
|
## v1.16.0:右栏常驻调色面板 + 可拖宽度 + 整体字号提升
|
||||||
|
|
||||||
|
用户三句话拆成四件事:面板文字偏小、右栏要能拖宽、把调色面板(含常用色)搬进右栏、
|
||||||
|
顶部能切换当前元素要调的颜色。
|
||||||
|
|
||||||
|
### 调色面板进右栏(弹层保留)
|
||||||
|
|
||||||
|
调色面板不再是「只能弹出来」:右栏顶部常驻一份,工具栏色块点击仍然弹一份。
|
||||||
|
两处**是同一份 DOM**(`dom.js#colorSurfaceHtml()`),靠 `data-color-surface` 区分:
|
||||||
|
|
||||||
|
- `bindColorSurface(surface)` 每块面板各绑一次交互(tab / 无 / 常用色 / 最近色 / HEX / 吸管 / SV 拖动);
|
||||||
|
- `updateColorUI()` 里原本单点的 `querySelector` 全改成 `querySelectorAll` 遍历——
|
||||||
|
HEX 回填、SV 背景与指示点、色相指示点、「无」按钮显隐,两处一起刷。
|
||||||
|
|
||||||
|
复制两段 HTML 的方案被否掉:这套控件有 4 组联动,复制就等于以后每个改动都要改两遍,
|
||||||
|
漏一处就是「一边变了另一边没变」——这个项目已经因为「同一概念两处各写一份」栽过几次。
|
||||||
|
|
||||||
|
顶部三格就是**当前元素可调的颜色项**,跟随选中对象变化:形状 = 描边/填充、
|
||||||
|
文字 = 文字/描边/底色、箭头与画笔 = 只有主色。
|
||||||
|
|
||||||
|
布局差异全在 CSS:弹层横排一行(SV 180×104 + HEX + 常用色 6×2 + 最近 4×2),
|
||||||
|
右栏窄所以改竖排(SV 全宽 118 高 → HEX 一行 → 常用色 → 最近)。
|
||||||
|
右栏色块用 `repeat(auto-fill, minmax(24px, 1fr))`,拖宽后一行自动多放几个。
|
||||||
|
|
||||||
|
### 右栏可拖宽度
|
||||||
|
|
||||||
|
- `.iwb-editor-side-resizer` 贴在右栏左边缘(9px 热区,悬停才亮橙线,避免和面板分隔线打架);
|
||||||
|
- 宽度统一写 CSS 变量 `--iwb-side-w`,原来三处硬编码的 240/240/220 全部改成读它;
|
||||||
|
- 范围 220–520,且不超过窗口 45%(窄窗口不把画布挤没);默认 280(220 时「温度/色调」会被压成两字);
|
||||||
|
- 双击手柄复位;松手写宿主 `settings.sideWidth`,下次打开恢复。
|
||||||
|
|
||||||
|
### 字号 +1 档
|
||||||
|
|
||||||
|
旧值大量是 10–11.5px(按 1440 宽屏定的),2K/4K 与系统缩放 125% 下发虚。
|
||||||
|
不逐条改原规则,改为在 CSS 末尾用 `#iwb-editor-overlay` 前缀集中覆盖一档:
|
||||||
|
面板行名 10 → 12.5、标题 11.5 → 13、状态栏 11 → 12、选项栏 12 → 13、
|
||||||
|
图层名 12 → 13、色板 tab 11.5 → 12.5。宿主画布外的节点浮条不在遮罩内,不受影响。
|
||||||
|
|
||||||
|
同时把「图片调节」的名称列 46 → 50px、数值框 36 → 40px,字号变大后不会挤成省略号。
|
||||||
|
|
||||||
|
### 回归
|
||||||
|
|
||||||
|
harness 新增 5 条:右栏面板结构、右栏选色后弹层同步高亮、拖宽生效、双击复位、字号计算值。
|
||||||
|
色板相关旧用例的选择器全部限定到 `.iwb-editor-color-pop`(否则右栏那份会命中 strict mode 冲突)。
|
||||||
|
|
||||||
|
## v1.15.1:修「换一张图调节,画面还原成上一张」
|
||||||
|
|
||||||
|
### 病灶
|
||||||
|
|
||||||
|
原图图层的 id 是**写死的 `'base'`**,而 `adjust.js` 里「调节前基准像素」的缓存
|
||||||
|
`sourceCache` 以 `layer.id` 为 key。退出编辑器走 `releaseEditorMemory()`,
|
||||||
|
它释放了图层画布与 `S.fx`,却**漏了 `sourceCache` 和 `S.adjust`** ——
|
||||||
|
于是第二张图打开后 `captureFor('base')` 直接命中上一张图的像素,
|
||||||
|
一拖滑杆就把旧图重算到新图上。id 固定 ⇒ 100% 复现,不是偶发。
|
||||||
|
|
||||||
|
同一个疏漏还有第二层:`S.adjust.layerId` 残留 `'base'` 且 `source` 非空时,
|
||||||
|
`ensureAdjustTarget()` 认为「目标没变,不用重拍基准」,连 `switchTarget()` 都跳过。
|
||||||
|
|
||||||
|
### 修法
|
||||||
|
|
||||||
|
新增 `adjust.js#resetAdjustCache()`:清空 `sourceCache` + 把 `S.adjust` 归零。
|
||||||
|
两处调用,**开与关都兜住**:
|
||||||
|
|
||||||
|
- `resetState()`(每次 `open()`)—— 防住「关闭路径没走到/提前抛错」的边缘;
|
||||||
|
- `releaseEditorMemory()`(`close()`)—— 立即释放两份全幅位图,不等下次打开。
|
||||||
|
|
||||||
|
`__debug()` 增加 `adjustCacheSize` 观测口,回归用例如实断言「退出后为 0」。
|
||||||
|
|
||||||
|
### 回归
|
||||||
|
|
||||||
|
harness 新增 Round 3:退出前确认 `adjustCacheSize > 0`(前置)→ 退出 → 重开 →
|
||||||
|
断言 `cache === 0 && layerId === null && hasSource === false` → 重开后曝光 +100
|
||||||
|
仍正常提亮(亮度 177 → 241),证明用的是新图基准。
|
||||||
|
|
||||||
## v1.15.0:右侧栏「图片调节」11 项 + 快速效果强度修正
|
## v1.15.0:右侧栏「图片调节」11 项 + 快速效果强度修正
|
||||||
|
|
||||||
需求:在右侧栏加基本的图片调节能力(曝光/明度/对比度/阴影/高光/色相/饱和度/白平衡/锐度/清晰度),
|
需求:在右侧栏加基本的图片调节能力(曝光/明度/对比度/阴影/高光/色相/饱和度/白平衡/锐度/清晰度),
|
||||||
|
|||||||
@@ -311,6 +311,8 @@ getCompositeCanvas() // 当前这一张
|
|||||||
| 工具参数解耦与选项栏 | ✅ v1.2.0:`S.shapeLineWidth` / `S.textSize` 独立于 `S.brushSize`;选项栏按工具出参数(画笔三参、形状线宽+填充、文字字号、选区形状/羽化),与右侧面板双向同步 |
|
| 工具参数解耦与选项栏 | ✅ v1.2.0:`S.shapeLineWidth` / `S.textSize` 独立于 `S.brushSize`;选项栏按工具出参数(画笔三参、形状线宽+填充、文字字号、选区形状/羽化),与右侧面板双向同步 |
|
||||||
| P3 图层增强 | 🟡 v1.7:缩略图 / 重命名 / 多选 / 不透明度滑杆已补;混合模式 / 图层蒙版 / 编组未做 |
|
| P3 图层增强 | 🟡 v1.7:缩略图 / 重命名 / 多选 / 不透明度滑杆已补;混合模式 / 图层蒙版 / 编组未做 |
|
||||||
| P4 单张输出 | ✅ PNG/JPG/WebP、透明/白底、800×800(长边 80%)、≤500KB 迭代降质、下载、设置记忆;无队列 |
|
| P4 单张输出 | ✅ PNG/JPG/WebP、透明/白底、800×800(长边 80%)、≤500KB 迭代降质、下载、设置记忆;无队列 |
|
||||||
|
| 右栏调色面板 / 可拖宽度 / 字号(v1.16.0) | ✅ 调色面板从「只弹层」变成「右栏常驻 + 弹层保留」,两处共用同一份 DOM(`dom.js#colorSurfaceHtml`),按 `[data-color-surface]` 各绑一次交互、`updateColorUI` 改遍历同步(HEX / SV / 色相 / 「无」显隐 / 常用色与最近色高亮);右栏宽度统一到 CSS 变量 `--iwb-side-w`(原三处硬编码 240/240/220),手柄 9px 热区、范围 220–520 且 ≤ 窗口 45%、默认 280、双击复位、写 `settings.sideWidth` 记忆;字号在 CSS 末尾用 `#iwb-editor-overlay` 前缀集中 +1 档(面板行名 12.5 / 标题 13 / 状态栏 12 / 选项栏 13 / 颜色 tab 12.5),调节名称列 46→50、数值框 36→40 |
|
||||||
|
| 调节基准跨图串用修复(v1.15.1) | ✅ 退出编辑器后 `sourceCache`(key = `layer.id`,原图恒为 `'base'`)与 `S.adjust` 未清 ⇒ 第二张图一拖滑杆就把上一张图的像素重算上来,且 `ensureAdjustTarget()` 因 `layerId` 相同而跳过重拍基准。新增 `resetAdjustCache()`,在 `resetState()` 与 `releaseEditorMemory()` 双路径清空;`__debug()` 增 `adjustCacheSize` 观测口,harness 补「退出→重开」三条断言 |
|
||||||
| 图片调节(v1.15.0) | ✅ 右侧栏新增 11 项连续调色:曝光(±2EV)/明度/对比度/阴影/高光/色相/饱和度/温度/色调/锐度/清晰度。走 `getImageData` 逐像素(CSS filter 做不到阴影高光的分区蒙版、白平衡的通道增益、锐化的卷积);拖动用长边 ≤900 的降采样预览(6.7ms),松手才全量(4000² 144ms)。`source` + 每层 `sourceCache` 保证永远从基准重算不叠加;撤销后滑块归零并重拍基准。顺带修强度:增强 brightness 1.12→1.4、高对比 contrast 1.4→1.6 |
|
| 图片调节(v1.15.0) | ✅ 右侧栏新增 11 项连续调色:曝光(±2EV)/明度/对比度/阴影/高光/色相/饱和度/温度/色调/锐度/清晰度。走 `getImageData` 逐像素(CSS filter 做不到阴影高光的分区蒙版、白平衡的通道增益、锐化的卷积);拖动用长边 ≤900 的降采样预览(6.7ms),松手才全量(4000² 144ms)。`source` + 每层 `sourceCache` 保证永远从基准重算不叠加;撤销后滑块归零并重拍基准。顺带修强度:增强 brightness 1.12→1.4、高对比 contrast 1.4→1.6 |
|
||||||
| 文字字体下拉修复(v1.14.1) | ✅ 选项栏 click 委托原用 `closest([data-opt-text])` 判断文字样式按钮,`<select data-opt-text="fontFamily">` 自带该属性 → 被当按钮 → 取 `dataset.value`(select 上没有)= undefined → `fontKeyOf` 脏值收敛成 `sans`,症状是「点开下拉看一眼字体就被打回黑体」。改为只认 `button[data-opt-text]` + select 早退;`syncOptionBar` 的 active 遍历同步收紧;change 后不再整体重绘(否则换掉刚操作的下拉节点、焦点丢失)。补 2 条真实 click 用例 —— 原用例用 `selectOption` 绕过 click 才漏掉 |
|
| 文字字体下拉修复(v1.14.1) | ✅ 选项栏 click 委托原用 `closest([data-opt-text])` 判断文字样式按钮,`<select data-opt-text="fontFamily">` 自带该属性 → 被当按钮 → 取 `dataset.value`(select 上没有)= undefined → `fontKeyOf` 脏值收敛成 `sans`,症状是「点开下拉看一眼字体就被打回黑体」。改为只认 `button[data-opt-text]` + select 早退;`syncOptionBar` 的 active 遍历同步收紧;change 后不再整体重绘(否则换掉刚操作的下拉节点、焦点丢失)。补 2 条真实 click 用例 —— 原用例用 `selectOption` 绕过 click 才漏掉 |
|
||||||
| 文字字体选择 | ✅ v1.14.0:文字对象新增 `fontFamily`(预设 key:`sans` 黑体 / `serif` 宋体 / `kai` 楷体 / `round` 圆体),`fontOf()` 从硬编码 `sans-serif` 改为读 `TEXT_FONTS[key].stack` 的跨平台字体栈;选项栏加「字体」下拉(`select[data-opt-text]`,走 `change` 委托,其余文字样式仍走 `click`),复用 `TEXT_STYLE_STATE_KEY` 一条写回路径;输入框同步字体族与字重;`fontKeyOf()` 把脏值收敛回默认。**明确不做内置字体**:宿主 CSP `default-src 'self'` 拦第三方字体、CJK 字体 2–64MB 无法内联、异步字体有 measureText 时序坑。实测换字体仅首次多 13–42ms 字形光栅化,热重绘 0.1–0.2ms;中文全角等宽,换字体不改字宽(1000²/30 对象内存 114MB 属既有架构,与字体无关) |
|
| 文字字体选择 | ✅ v1.14.0:文字对象新增 `fontFamily`(预设 key:`sans` 黑体 / `serif` 宋体 / `kai` 楷体 / `round` 圆体),`fontOf()` 从硬编码 `sans-serif` 改为读 `TEXT_FONTS[key].stack` 的跨平台字体栈;选项栏加「字体」下拉(`select[data-opt-text]`,走 `change` 委托,其余文字样式仍走 `click`),复用 `TEXT_STYLE_STATE_KEY` 一条写回路径;输入框同步字体族与字重;`fontKeyOf()` 把脏值收敛回默认。**明确不做内置字体**:宿主 CSP `default-src 'self'` 拦第三方字体、CJK 字体 2–64MB 无法内联、异步字体有 measureText 时序坑。实测换字体仅首次多 13–42ms 字形光栅化,热重绘 0.1–0.2ms;中文全角等宽,换字体不改字宽(1000²/30 对象内存 114MB 属既有架构,与字体无关) |
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@iwb-plugin/image-annotate",
|
"name": "@iwb-plugin/image-annotate",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.15.0",
|
"version": "1.16.0",
|
||||||
"description": "IWB 插件:图片标注 / 修图(编辑器移植自 iwb-plaus 扩展,纯 Canvas 2D)",
|
"description": "IWB 插件:图片标注 / 修图(编辑器移植自 iwb-plaus 扩展,纯 Canvas 2D)",
|
||||||
"ibwPlugin": {
|
"ibwPlugin": {
|
||||||
"id": "image-annotate",
|
"id": "image-annotate",
|
||||||
|
|||||||
@@ -1218,7 +1218,9 @@
|
|||||||
|
|
||||||
/* 左栏:调色板在上,参数竖排,导出按钮底部 */
|
/* 左栏:调色板在上,参数竖排,导出按钮底部 */
|
||||||
.iwb-editor-left {
|
.iwb-editor-left {
|
||||||
width: 240px; min-width: 240px; flex: 0 0 240px;
|
/* v1.16:宽度唯一出处。拖拽手柄写 --iwb-side-w,下面两条历史规则也都读它,
|
||||||
|
不再各写一个 240/220 的魔数(以前三处硬编码,改一次要搜三次)。 */
|
||||||
|
width: var(--iwb-side-w, 280px); min-width: var(--iwb-side-w, 280px); flex: 0 0 var(--iwb-side-w, 280px);
|
||||||
display: flex; flex-direction: column; gap: 14px;
|
display: flex; flex-direction: column; gap: 14px;
|
||||||
padding: 12px; background: #181825; border-right: 1px solid #313244; overflow-y: auto;
|
padding: 12px; background: #181825; border-right: 1px solid #313244; overflow-y: auto;
|
||||||
}
|
}
|
||||||
@@ -1322,7 +1324,7 @@
|
|||||||
.iwb-editor-main { display: flex; flex-direction: row; align-items: stretch; }
|
.iwb-editor-main { display: flex; flex-direction: row; align-items: stretch; }
|
||||||
.iwb-editor-main > .iwb-editor-layer-panel { flex: 0 0 290px; min-width: 290px; width: 290px; }
|
.iwb-editor-main > .iwb-editor-layer-panel { flex: 0 0 290px; min-width: 290px; width: 290px; }
|
||||||
.iwb-editor-main > .iwb-editor-canvas-wrap { flex: 1 1 auto; min-width: 0; }
|
.iwb-editor-main > .iwb-editor-canvas-wrap { flex: 1 1 auto; min-width: 0; }
|
||||||
.iwb-editor-left { flex: 0 0 240px; min-width: 240px; width: 240px; }
|
.iwb-editor-left { flex: 0 0 var(--iwb-side-w, 280px); min-width: var(--iwb-side-w, 280px); width: var(--iwb-side-w, 280px); }
|
||||||
.iwb-editor-layer-panel .iwb-editor-layer-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
|
.iwb-editor-layer-panel .iwb-editor-layer-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
|
||||||
|
|
||||||
/* ======== 顶部布局 v5:左侧重置类 / 中间工具 / 右侧保存类 ======== */
|
/* ======== 顶部布局 v5:左侧重置类 / 中间工具 / 右侧保存类 ======== */
|
||||||
@@ -1529,7 +1531,7 @@
|
|||||||
}
|
}
|
||||||
.iwb-editor-main { padding-left: 0; }
|
.iwb-editor-main { padding-left: 0; }
|
||||||
.iwb-editor-main > .iwb-editor-layer-panel { flex: 0 0 260px !important; min-width: 260px !important; width: 260px !important; }
|
.iwb-editor-main > .iwb-editor-layer-panel { flex: 0 0 260px !important; min-width: 260px !important; width: 260px !important; }
|
||||||
.iwb-editor-left { flex: 0 0 220px !important; min-width: 220px !important; width: 220px !important; }
|
.iwb-editor-left { flex: 0 0 var(--iwb-side-w, 280px) !important; min-width: var(--iwb-side-w, 280px) !important; width: var(--iwb-side-w, 280px) !important; }
|
||||||
.iwb-editor-overlay.panels-collapsed .iwb-editor-layer-panel,
|
.iwb-editor-overlay.panels-collapsed .iwb-editor-layer-panel,
|
||||||
.iwb-editor-overlay.panels-collapsed .iwb-editor-left { display: none !important; }
|
.iwb-editor-overlay.panels-collapsed .iwb-editor-left { display: none !important; }
|
||||||
.iwb-editor-zoom-hint { display: none !important; }
|
.iwb-editor-zoom-hint { display: none !important; }
|
||||||
@@ -2096,3 +2098,135 @@
|
|||||||
|
|
||||||
/* 选项栏按钮里是中文双字标签(常规/特粗/底色),不给 nowrap 会被挤成竖排 */
|
/* 选项栏按钮里是中文双字标签(常规/特粗/底色),不给 nowrap 会被挤成竖排 */
|
||||||
.iwb-editor-optionbar-body .iwb-opt-btn { white-space: nowrap; }
|
.iwb-editor-optionbar-body .iwb-opt-btn { white-space: nowrap; }
|
||||||
|
|
||||||
|
/* ================================================================
|
||||||
|
v1.16:右栏常驻调色面板 + 可拖宽度 + 整体字号提升一档
|
||||||
|
需求(用户 2026-11-09):① 面板文字偏小 ② 右栏要能拖宽
|
||||||
|
③ 把调色面板(含常用色)搬进右栏 ④ 顶部切换当前元素可调的颜色项
|
||||||
|
================================================================ */
|
||||||
|
|
||||||
|
/* ---- 1) 右栏宽度手柄:贴在侧栏左边缘(侧栏在画布右侧) ----
|
||||||
|
必须放在 left:0 而不是负值:侧栏本身 overflow-x:hidden,探出去的部分会被裁掉。 */
|
||||||
|
.iwb-editor-side-resizer {
|
||||||
|
position: absolute; left: 0; top: 0; bottom: 0; width: 9px;
|
||||||
|
z-index: 46; cursor: col-resize; touch-action: none;
|
||||||
|
}
|
||||||
|
/* 平时完全隐形,悬停/拖动时才亮一条橙线:
|
||||||
|
常驻一条竖线会和「画布/面板」的分隔线打架,看起来像两条边界。 */
|
||||||
|
.iwb-editor-side-resizer::after {
|
||||||
|
content: ''; position: absolute; left: 3px; top: 0; bottom: 0; width: 2px;
|
||||||
|
border-radius: 1px; background: transparent; transition: background 0.12s ease;
|
||||||
|
}
|
||||||
|
.iwb-editor-side-resizer:hover::after,
|
||||||
|
.iwb-editor-side-resizer.is-dragging::after { background: #e8a735; }
|
||||||
|
|
||||||
|
/* ---- 2) 右栏调色面板 ---- */
|
||||||
|
.iwb-editor-colors {
|
||||||
|
display: flex; flex-direction: column; gap: 9px;
|
||||||
|
padding: 9px 10px 10px; border-radius: 10px;
|
||||||
|
background: #1e1e2c; border: 1px solid #2f2f42;
|
||||||
|
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 档 ----
|
||||||
|
旧值大量是 10–11.5px(按 1440 宽屏定的),在 2K/4K 与系统缩放 125% 下发虚。
|
||||||
|
集中用 #iwb-editor-overlay 前缀覆盖而不是逐条改原规则:字号以后只在这块调。
|
||||||
|
宿主画布外的节点浮条(.iwb-node-floatbar 等)不在遮罩内,不受影响。 */
|
||||||
|
#iwb-editor-overlay { font-size: 13px; }
|
||||||
|
#iwb-editor-overlay .iwb-editor-title em.iwb-editor-doc-size { font-size: 12px; }
|
||||||
|
#iwb-editor-overlay .iwb-editor-header > .iwb-editor-session .iwb-editor-btn,
|
||||||
|
#iwb-editor-overlay .iwb-editor-header .iwb-editor-export-actions .iwb-editor-btn { font-size: 12.5px; }
|
||||||
|
#iwb-editor-overlay .iwb-editor-export-settings-btn { font-size: 12.5px; }
|
||||||
|
#iwb-editor-overlay .iwb-editor-export-row > span,
|
||||||
|
#iwb-editor-overlay .iwb-editor-export-note,
|
||||||
|
#iwb-editor-overlay .iwb-editor-more-menu kbd { font-size: 12px; }
|
||||||
|
|
||||||
|
/* 选项栏 */
|
||||||
|
#iwb-editor-overlay .iwb-editor-optionbar { font-size: 13px; }
|
||||||
|
#iwb-editor-overlay .iwb-opt-label,
|
||||||
|
#iwb-editor-overlay .iwb-opt-current,
|
||||||
|
#iwb-editor-overlay .iwb-opt-btn,
|
||||||
|
#iwb-editor-overlay .iwb-opt-num,
|
||||||
|
#iwb-editor-overlay .iwb-opt-select { font-size: 13px; }
|
||||||
|
#iwb-editor-overlay .iwb-opt-num { width: 50px; }
|
||||||
|
#iwb-editor-overlay .iwb-opt-hint,
|
||||||
|
#iwb-editor-overlay .iwb-editor-optionbar-tip,
|
||||||
|
#iwb-editor-overlay .iwb-opt-unit,
|
||||||
|
#iwb-editor-overlay .iwb-opt-swatch-label { font-size: 12px; }
|
||||||
|
|
||||||
|
/* 状态栏 */
|
||||||
|
#iwb-editor-overlay .iwb-editor-statusbar { font-size: 12px; height: 28px; min-height: 28px; }
|
||||||
|
|
||||||
|
/* 图层面板 */
|
||||||
|
#iwb-editor-overlay .iwb-layer-name { font-size: 13px; }
|
||||||
|
#iwb-editor-overlay .iwb-layer-name-input { font-size: 13px; }
|
||||||
|
#iwb-editor-overlay .iwb-layer-paint { font-size: 12px; }
|
||||||
|
#iwb-editor-overlay .iwb-layer-op,
|
||||||
|
#iwb-editor-overlay .iwb-layer-op-val { font-size: 11.5px; }
|
||||||
|
#iwb-editor-overlay .iwb-layer-op-val { width: 36px; }
|
||||||
|
|
||||||
|
/* 右栏:图片调节 */
|
||||||
|
#iwb-editor-overlay .iwb-editor-adj-title { font-size: 13px; }
|
||||||
|
#iwb-editor-overlay .iwb-editor-adj-target { font-size: 11.5px; }
|
||||||
|
#iwb-editor-overlay .iwb-editor-adj-reset { font: 500 12px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; padding: 3px 8px; }
|
||||||
|
#iwb-editor-overlay .iwb-editor-adj-row { grid-template-columns: 50px 1fr 40px; }
|
||||||
|
#iwb-editor-overlay .iwb-editor-adj-name { font-size: 12.5px; }
|
||||||
|
#iwb-editor-overlay .iwb-editor-adj-val { width: 40px; font: 500 12px/1.4 -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; }
|
||||||
|
#iwb-editor-overlay .iwb-editor-adj-tip { font-size: 11.5px; }
|
||||||
|
|
||||||
|
/* 右栏:快速效果 */
|
||||||
|
#iwb-editor-overlay .iwb-editor-fx-title { font-size: 13px; }
|
||||||
|
#iwb-editor-overlay .iwb-editor-fx-target { font-size: 11.5px; max-width: 150px; }
|
||||||
|
#iwb-editor-overlay .iwb-editor-fx-btn { font: 500 12px/1 -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; padding: 8px 2px 7px; }
|
||||||
|
#iwb-editor-overlay .iwb-editor-fx-tip { font-size: 11.5px; }
|
||||||
|
#iwb-editor-overlay .iwb-editor-fx-adj-name,
|
||||||
|
#iwb-editor-overlay .iwb-editor-fx-adj-val { font-size: 12px; }
|
||||||
|
|
||||||
|
/* 右栏:缩放 */
|
||||||
|
#iwb-editor-overlay .iwb-editor-left .iwb-editor-zoom .iwb-editor-zoom-val,
|
||||||
|
#iwb-editor-overlay .iwb-editor-left .iwb-editor-zoom .iwb-editor-zoom-fit { font-size: 12px; }
|
||||||
|
|
||||||
|
/* 调色面板本体 */
|
||||||
|
#iwb-editor-overlay .iwb-color-pop-tab,
|
||||||
|
#iwb-editor-overlay .iwb-color-pop-none { font-size: 12.5px; height: 26px; }
|
||||||
|
#iwb-editor-overlay .iwb-editor-color-pop .iwb-editor-color-hex-input { font-size: 13px; }
|
||||||
@@ -289,6 +289,27 @@ import { toast } from './commands.js'
|
|||||||
return rec
|
return rec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退出编辑器 / 重新打开时清空基准缓存(v1.15.1 修)。
|
||||||
|
*
|
||||||
|
* 必须清的原因:缓存的 key 是 layer.id,而原图层的 id 是写死的 'base'。
|
||||||
|
* 退出编辑器时 releaseEditorMemory() 释放了图层画布,却没清这张 Map,
|
||||||
|
* 于是下一张图打开后 captureFor() 直接命中上一张图的像素,
|
||||||
|
* 表现为「调第二张图,画面变回第一张」。id 固定 ⇒ 100% 复现,不是偶发。
|
||||||
|
*
|
||||||
|
* 顺带把 S.adjust 也归零:残留的 params 会让新图的滑杆一进来就显示 +80,
|
||||||
|
* 而画面是未调状态,参数与画面对不上。
|
||||||
|
*/
|
||||||
|
export function resetAdjustCache() {
|
||||||
|
sourceCache.clear()
|
||||||
|
S.adjust = { layerId: null, source: null, previewCanvas: null, params: zeroAdjust() }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 观测口:回归用例用它断言「退出后缓存确实清空了」 */
|
||||||
|
export function adjustCacheSize() {
|
||||||
|
return sourceCache.size
|
||||||
|
}
|
||||||
|
|
||||||
/** 切换调节目标:旧层基准入缓存,新层取缓存或现拍,参数按层恢复 */
|
/** 切换调节目标:旧层基准入缓存,新层取缓存或现拍,参数按层恢复 */
|
||||||
function switchTarget(layer) {
|
function switchTarget(layer) {
|
||||||
const st = S.adjust
|
const st = S.adjust
|
||||||
|
|||||||
@@ -10,6 +10,55 @@ import { S, runtime } from './state.js'
|
|||||||
import { bindEvents } from './events.js'
|
import { bindEvents } from './events.js'
|
||||||
|
|
||||||
|
|
||||||
|
// ============ 调色面板(两处共用) ============
|
||||||
|
/**
|
||||||
|
* v1.16:调色面板从「只能弹层」变成「右栏常驻 + 弹层保留」,两处用同一份 DOM。
|
||||||
|
*
|
||||||
|
* 为什么抽成函数而不是复制两段 HTML:这套控件有 4 组联动(tab 高亮、SV/色相指示点、
|
||||||
|
* HEX 回填、常用色/最近色的 active 圈),复制两段 = 以后每加一种颜色语义都要改两遍,
|
||||||
|
* 漏一处就是「一边改了另一边不变」。同一份结构 + 按 `[data-color-surface]` 遍历,
|
||||||
|
* 才可能保证一致(events.js#updateColorUI 就是按 surface 逐个刷的)。
|
||||||
|
*
|
||||||
|
* 布局差异全部交给 CSS:弹层是横排一行,右栏窄,改成竖排(picker 全宽、色块自动换行)。
|
||||||
|
*/
|
||||||
|
const COMMON_COLORS = [
|
||||||
|
'#ff4444', '#ff8a00', '#ffd400', '#4cd964', '#00bfa5', '#4488ff',
|
||||||
|
'#aa44ff', '#ff66aa', '#ffffff', '#d0d0d0', '#808080', '#000000'
|
||||||
|
]
|
||||||
|
|
||||||
|
function colorSurfaceHtml() {
|
||||||
|
return `
|
||||||
|
<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" data-color-slot="fill" title="正在调填充色(形状内部颜色 / 文字描边色)"><i></i><span class="iwb-color-pop-tab-label">填充</span></button>
|
||||||
|
<button type="button" class="iwb-color-pop-tab" data-color-slot="bg" hidden title="正在调文本框底色(垫在文字下面)"><i></i><span class="iwb-color-pop-tab-label">底色</span></button>
|
||||||
|
<button type="button" class="iwb-color-pop-none" data-color-none="1" title="无填充:形状内部透明,只留描边"><span></span>无</button>
|
||||||
|
</div>
|
||||||
|
<div class="iwb-color-pop-body">
|
||||||
|
<div class="iwb-color-pop-picker">
|
||||||
|
<div class="iwb-color-sv"><span></span></div>
|
||||||
|
<div class="iwb-color-hue"><span></span></div>
|
||||||
|
</div>
|
||||||
|
<span class="iwb-color-pop-sep"></span>
|
||||||
|
<div class="iwb-color-pop-fields">
|
||||||
|
<button type="button" class="iwb-editor-color-eye" data-action="palettePick" title="吸色:切到吸管工具,在画布上点一下取色"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m2 22 1-1h3l9-9"/><path d="M3 21v-3l9-9"/><path d="m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3Z"/></svg></button>
|
||||||
|
<input class="iwb-editor-color-hex-input" value="#ff4444" maxlength="7" spellcheck="false" autocomplete="off" title="十六进制颜色,回车生效">
|
||||||
|
</div>
|
||||||
|
<span class="iwb-color-pop-sep"></span>
|
||||||
|
<div class="iwb-color-group">
|
||||||
|
<span class="iwb-color-group-label">常用色</span>
|
||||||
|
<div class="iwb-editor-color-swatches">
|
||||||
|
${COMMON_COLORS.map(c => `<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="${c}" style="background:${c}" title="${c}"></button>`).join('')}
|
||||||
|
</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>`
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ============ DOM 创建 ============
|
// ============ DOM 创建 ============
|
||||||
export function createEl() {
|
export function createEl() {
|
||||||
if (runtime.el) return
|
if (runtime.el) return
|
||||||
@@ -169,6 +218,20 @@ import { bindEvents } from './events.js'
|
|||||||
<div class="iwb-editor-zoom-hint">滚轮缩放 · 抓手/空格/中键拖拽自由移动画布</div>
|
<div class="iwb-editor-zoom-hint">滚轮缩放 · 抓手/空格/中键拖拽自由移动画布</div>
|
||||||
|
|
||||||
<aside class="iwb-editor-left">
|
<aside class="iwb-editor-left">
|
||||||
|
<!-- v1.16:侧栏宽度拖拽手柄。贴在侧栏左边缘(它在画布右侧),
|
||||||
|
双击复位。宽度写进 CSS 变量 --iwb-side-w,由 --iwb-side-w 统一裁各条 width 规则。 -->
|
||||||
|
<div class="iwb-editor-side-resizer" data-side-resizer="1" title="拖动调整侧栏宽度,双击复位"></div>
|
||||||
|
<!-- 调色面板(v1.16):从弹层搬进来常驻一份,弹层保留。
|
||||||
|
两处是同一份 DOM(dom.js#colorSurfaceHtml),靠 data-color-surface 区分与遍历,
|
||||||
|
不存在「一边改了另一边不变」。顶部色格 = 当前元素可调的颜色项,
|
||||||
|
跟随选中对象变化:形状=描边/填充,文字=文字/描边/底色,箭头=只要描边。 -->
|
||||||
|
<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):
|
<!-- 调色板已迁到工具栏弹层(v1.3,用户裁定 2026-11-05):
|
||||||
侧栏只留快速效果 + 缩放;色板 DOM 在 modal 末尾的 .iwb-editor-color-pop -->
|
侧栏只留快速效果 + 缩放;色板 DOM 在 modal 末尾的 .iwb-editor-color-pop -->
|
||||||
<!-- 图片调节(v1.15):连续调色,作用于当前位图图层(默认原图)。
|
<!-- 图片调节(v1.15):连续调色,作用于当前位图图层(默认原图)。
|
||||||
@@ -242,47 +305,12 @@ import { bindEvents } from './events.js'
|
|||||||
<span class="iwb-editor-status-layer">当前层:原图</span>
|
<span class="iwb-editor-status-layer">当前层:原图</span>
|
||||||
<span class="iwb-editor-status-tool">画笔</span>
|
<span class="iwb-editor-status-tool">画笔</span>
|
||||||
</div>
|
</div>
|
||||||
<!-- 色板弹层(v1.3):工具栏色点点击展开。
|
<!-- 色板弹层(v1.3;v1.16 起与右栏常驻面板共用同一份 DOM):
|
||||||
必须挂在 modal 下、不能塞进 .iwb-editor-tools —— 工具栏是 overflow-x:auto,
|
工具栏色块点击展开。必须挂在 modal 下、不能塞进 .iwb-editor-tools ——
|
||||||
canvas-wrap 是 overflow:clip,塞进去弹层会被直接裁掉;定位由 events.js 计算。 -->
|
工具栏是 overflow-x:auto,canvas-wrap 是 overflow:clip,塞进去弹层会被直接裁掉;
|
||||||
<div class="iwb-editor-color-pop" hidden>
|
定位由 events.js 计算。 -->
|
||||||
<!-- 弹层头部(v1.11 两格 → v1.12 文字三格):标明「现在调的是哪个颜色」,
|
<div class="iwb-editor-color-pop" data-color-surface="pop" hidden>
|
||||||
并可直接切换。与工具栏那几个色块是同一组槽位,两边高亮完全一致。
|
${colorSurfaceHtml()}
|
||||||
「无」只对「可以没有」的颜色有意义:文字色没有无,描边/底色/填充才有。 -->
|
|
||||||
<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" data-color-slot="fill" title="正在调填充色(形状内部颜色 / 文字描边色)"><i></i><span class="iwb-color-pop-tab-label">填充</span></button>
|
|
||||||
<button type="button" class="iwb-color-pop-tab" data-color-slot="bg" hidden title="正在调文本框底色(垫在文字下面)"><i></i><span class="iwb-color-pop-tab-label">底色</span></button>
|
|
||||||
<button type="button" class="iwb-color-pop-none" data-color-none="1" title="无填充:形状内部透明,只留描边"><span></span>无</button>
|
|
||||||
</div>
|
|
||||||
<div class="iwb-color-pop-body">
|
|
||||||
<div class="iwb-color-pop-picker">
|
|
||||||
<div class="iwb-color-sv"><span></span></div>
|
|
||||||
<div class="iwb-color-hue"><span></span></div>
|
|
||||||
</div>
|
|
||||||
<span class="iwb-color-pop-sep"></span>
|
|
||||||
<div class="iwb-color-pop-fields">
|
|
||||||
<button type="button" class="iwb-editor-color-eye" data-action="palettePick" title="吸色:切到吸管工具,在画布上点一下取色"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m2 22 1-1h3l9-9"/><path d="M3 21v-3l9-9"/><path d="m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3Z"/></svg></button>
|
|
||||||
<input class="iwb-editor-color-hex-input" value="#ff4444" maxlength="7" spellcheck="false" autocomplete="off" title="十六进制颜色,回车生效">
|
|
||||||
</div>
|
|
||||||
<span class="iwb-color-pop-sep"></span>
|
|
||||||
<!-- 最近使用(v1.9):由 recent-colors.js 动态填充,空的时候整行隐藏 -->
|
|
||||||
<div class="iwb-editor-recent-colors" hidden title="最近使用"></div>
|
|
||||||
<div class="iwb-editor-color-swatches">
|
|
||||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#ff4444" style="background:#ff4444" title="#ff4444"></button>
|
|
||||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#ff8a00" style="background:#ff8a00" title="#ff8a00"></button>
|
|
||||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#ffd400" style="background:#ffd400" title="#ffd400"></button>
|
|
||||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#4cd964" style="background:#4cd964" title="#4cd964"></button>
|
|
||||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#00bfa5" style="background:#00bfa5" title="#00bfa5"></button>
|
|
||||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#4488ff" style="background:#4488ff" title="#4488ff"></button>
|
|
||||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#aa44ff" style="background:#aa44ff" title="#aa44ff"></button>
|
|
||||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#ff66aa" style="background:#ff66aa" title="#ff66aa"></button>
|
|
||||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#ffffff" style="background:#ffffff" title="#ffffff"></button>
|
|
||||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#d0d0d0" style="background:#d0d0d0" title="#d0d0d0"></button>
|
|
||||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#808080" style="background:#808080" title="#808080"></button>
|
|
||||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#000000" style="background:#000000" title="#000000"></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="iwb-editor-toast" role="status" aria-live="polite"></div>
|
<div class="iwb-editor-toast" role="status" aria-live="polite"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -27,6 +27,12 @@ import { applyQuickEffect, setEffectValue } from './effects.js'
|
|||||||
import { applyAdjust, ensureAdjustTarget, mountAdjustPanel, resetAdjust, setAdjustValue, syncAdjustControls } from './adjust.js'
|
import { applyAdjust, ensureAdjustTarget, mountAdjustPanel, resetAdjust, setAdjustValue, syncAdjustControls } from './adjust.js'
|
||||||
import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||||
|
|
||||||
|
/* 右栏宽度(v1.16):默认 280 —— 220 放 11 项调节时「温度/色调」会被压成两字,
|
||||||
|
而这是用户最常拖的滑杆区。上限还要跟窗口宽度取小,窄窗口不把画布挤没。 */
|
||||||
|
export const SIDE_DEFAULT = 280
|
||||||
|
export const SIDE_MIN = 220
|
||||||
|
export const SIDE_MAX = 520
|
||||||
|
|
||||||
|
|
||||||
// ============ 鼠标事件 ============
|
// ============ 鼠标事件 ============
|
||||||
/**
|
/**
|
||||||
@@ -1027,17 +1033,17 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
|||||||
})
|
})
|
||||||
// 「无」:形状 = 无填充;文字描边 = 描边宽度 0;文字底色 = 关掉底色块
|
// 「无」:形状 = 无填充;文字描边 = 描边宽度 0;文字底色 = 关掉底色块
|
||||||
// (文字色没有「无」—— 字没有颜色就等于把字删了,不该给这个按钮)
|
// (文字色没有「无」—— 字没有颜色就等于把字删了,不该给这个按钮)
|
||||||
const noneBtn = runtime.el.querySelector('[data-color-none]')
|
// v1.16:右栏与弹层各有一个「无」,必须按集合刷,否则只有先出现的那个对
|
||||||
if (noneBtn) {
|
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 showNone = onBg || onFill
|
||||||
const show = onBg || onFill
|
runtime.el.querySelectorAll('[data-color-none]').forEach(noneBtn => {
|
||||||
noneBtn.hidden = !show
|
noneBtn.hidden = !showNone
|
||||||
noneBtn.classList.toggle('active', show && (onBg ? !sl.bgOn : !sl.fillOn))
|
noneBtn.classList.toggle('active', showNone && (onBg ? !sl.bgOn : !sl.fillOn))
|
||||||
noneBtn.title = onBg
|
noneBtn.title = onBg
|
||||||
? '无底色:文字后面完全透明'
|
? '无底色:文字后面完全透明'
|
||||||
: (isText ? '无描边:把描边宽度置 0,只留文字本身' : '无填充:形状内部透明,只留描边')
|
: (isText ? '无描边:把描边宽度置 0,只留文字本身' : '无填充:形状内部透明,只留描边')
|
||||||
}
|
})
|
||||||
|
|
||||||
const cur = activeColor()
|
const cur = activeColor()
|
||||||
let matchPreset = false
|
let matchPreset = false
|
||||||
@@ -1046,28 +1052,34 @@ 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)
|
||||||
})
|
})
|
||||||
const panelHex = runtime.el.querySelector('.iwb-editor-color-hex')
|
// v1.16:hex / 调色器在两处面板各有一份 → 一律按集合刷
|
||||||
const hexInput = runtime.el.querySelector('.iwb-editor-color-hex-input')
|
runtime.el.querySelectorAll('.iwb-editor-color-hex').forEach(el => { el.textContent = cur.toUpperCase() })
|
||||||
if (hexInput && document.activeElement !== hexInput) hexInput.value = cur.toUpperCase()
|
runtime.el.querySelectorAll('.iwb-editor-color-hex-input').forEach(inp => {
|
||||||
|
if (document.activeElement !== inp) inp.value = cur.toUpperCase()
|
||||||
|
})
|
||||||
runtime.el.querySelectorAll('.iwb-editor-color-panel-swatch').forEach(sw => sw.classList.toggle('active', (sw.dataset.panelColor || '').toLowerCase() === cur.toLowerCase()))
|
runtime.el.querySelectorAll('.iwb-editor-color-panel-swatch').forEach(sw => sw.classList.toggle('active', (sw.dataset.panelColor || '').toLowerCase() === cur.toLowerCase()))
|
||||||
if (panelHex) panelHex.textContent = cur.toUpperCase()
|
|
||||||
const rgb = hexToRgb(cur)
|
const rgb = hexToRgb(cur)
|
||||||
const max = Math.max(rgb.r, rgb.g, rgb.b) / 255, min = Math.min(rgb.r, rgb.g, rgb.b) / 255
|
const max = Math.max(rgb.r, rgb.g, rgb.b) / 255, min = Math.min(rgb.r, rgb.g, rgb.b) / 255
|
||||||
const d = max - min
|
const d = max - min
|
||||||
let h = 0
|
let h = 0
|
||||||
if (d) { if (max === rgb.r / 255) h = 60 * (((rgb.g - rgb.b) / 255 / d) % 6); else if (max === rgb.g / 255) h = 60 * ((rgb.b - rgb.r) / 255 / d + 2); else h = 60 * ((rgb.r - rgb.g) / 255 / d + 4) }
|
if (d) { if (max === rgb.r / 255) h = 60 * (((rgb.g - rgb.b) / 255 / d) % 6); else if (max === rgb.g / 255) h = 60 * ((rgb.b - rgb.r) / 255 / d + 2); else h = 60 * ((rgb.r - rgb.g) / 255 / d + 4) }
|
||||||
if (h < 0) h += 360
|
if (h < 0) h += 360
|
||||||
const sv = runtime.el.querySelector('.iwb-color-sv'), hue = runtime.el.querySelector('.iwb-color-hue')
|
const sat = max ? d / max : 0
|
||||||
if (sv) sv.style.backgroundColor = `hsl(${h} 100% 50%)`
|
runtime.el.querySelectorAll('.iwb-color-sv').forEach(sv => {
|
||||||
if (hue) hue.dataset.hue = h
|
sv.style.backgroundColor = `hsl(${h} 100% 50%)`
|
||||||
const hueMarker = hue && hue.querySelector('span'); if (hueMarker) hueMarker.style.top = (h / 360 * 100) + '%'
|
const m = sv.querySelector('span')
|
||||||
const svMarker = sv && sv.querySelector('span'); if (svMarker) { const sat = max ? d / max : 0; svMarker.style.left = (sat * 100) + '%'; svMarker.style.top = ((1 - max) * 100) + '%' }
|
if (m) { m.style.left = (sat * 100) + '%'; m.style.top = ((1 - max) * 100) + '%' }
|
||||||
const custom = runtime.el.querySelector('.iwb-editor-color-custom')
|
})
|
||||||
if (custom) {
|
runtime.el.querySelectorAll('.iwb-color-hue').forEach(hue => {
|
||||||
|
hue.dataset.hue = h
|
||||||
|
const m = hue.querySelector('span')
|
||||||
|
if (m) m.style.top = (h / 360 * 100) + '%'
|
||||||
|
})
|
||||||
|
runtime.el.querySelectorAll('.iwb-editor-color-custom').forEach(custom => {
|
||||||
custom.classList.toggle('active', !matchPreset)
|
custom.classList.toggle('active', !matchPreset)
|
||||||
const inp = custom.querySelector('input')
|
const inp = custom.querySelector('input')
|
||||||
if (inp) inp.value = cur
|
if (inp) inp.value = cur
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 画笔大小/硬度/透明曾经在侧栏也有一份,2026-11-04 起只保留工具选项栏一处,
|
/** 画笔大小/硬度/透明曾经在侧栏也有一份,2026-11-04 起只保留工具选项栏一处,
|
||||||
@@ -2060,9 +2072,81 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
|||||||
bindExportActions()
|
bindExportActions()
|
||||||
bindWheelZoom()
|
bindWheelZoom()
|
||||||
bindTextInput()
|
bindTextInput()
|
||||||
|
bindSideResize()
|
||||||
bindGlobalListeners()
|
bindGlobalListeners()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ============ 右栏宽度(v1.16) ============ */
|
||||||
|
|
||||||
|
/** 应用宽度:夹在 [SIDE_MIN, min(SIDE_MAX, 窗口 45%)],写 CSS 变量 */
|
||||||
|
export function applySideWidth(w) {
|
||||||
|
if (!runtime.el) return S.sideWidth || SIDE_DEFAULT
|
||||||
|
const cap = Math.min(SIDE_MAX, Math.max(SIDE_MIN, Math.floor((window.innerWidth || 1440) * 0.45)))
|
||||||
|
const v = Math.round(Math.min(cap, Math.max(SIDE_MIN, Number(w) || SIDE_DEFAULT)))
|
||||||
|
runtime.el.style.setProperty('--iwb-side-w', v + 'px')
|
||||||
|
S.sideWidth = v
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 打开编辑器时恢复上次宽度(没存过就用默认值) */
|
||||||
|
export function loadSideWidth() {
|
||||||
|
const st = S.callbacks && S.callbacks.settings
|
||||||
|
let w = 0
|
||||||
|
if (st && typeof st.get === 'function') { try { w = Number(st.get('sideWidth')) || 0 } catch (e) { /* ignore */ } }
|
||||||
|
return applySideWidth(w > 0 ? w : SIDE_DEFAULT)
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveSideWidth() {
|
||||||
|
const st = S.callbacks && S.callbacks.settings
|
||||||
|
if (st && typeof st.set === 'function') { try { st.set('sideWidth', S.sideWidth) } catch (e) { /* ignore */ } }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拖拽右栏宽度。
|
||||||
|
* 侧栏在画布右侧,所以指针左移 = 变宽(startW - dx),别写反。
|
||||||
|
* 用 pointer capture:指针拖出 7px 宽的手柄后事件仍然回到手柄上,
|
||||||
|
* 否则鼠标一快就跟丢、宽度卡住。
|
||||||
|
*/
|
||||||
|
function bindSideResize() {
|
||||||
|
const handle = runtime.el && runtime.el.querySelector('[data-side-resizer]')
|
||||||
|
if (!handle) return
|
||||||
|
let dragging = false
|
||||||
|
let startX = 0
|
||||||
|
let startW = 0
|
||||||
|
const endDrag = () => {
|
||||||
|
if (!dragging) return
|
||||||
|
dragging = false
|
||||||
|
handle.classList.remove('is-dragging')
|
||||||
|
document.body.style.cursor = ''
|
||||||
|
document.body.style.userSelect = ''
|
||||||
|
saveSideWidth()
|
||||||
|
}
|
||||||
|
handle.addEventListener('pointerdown', (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
e.stopPropagation()
|
||||||
|
dragging = true
|
||||||
|
startX = e.clientX
|
||||||
|
startW = S.sideWidth || SIDE_DEFAULT
|
||||||
|
handle.classList.add('is-dragging')
|
||||||
|
document.body.style.cursor = 'col-resize'
|
||||||
|
document.body.style.userSelect = 'none'
|
||||||
|
try { handle.setPointerCapture(e.pointerId) } catch (err) { /* 老浏览器退回普通事件 */ }
|
||||||
|
})
|
||||||
|
handle.addEventListener('pointermove', (e) => {
|
||||||
|
if (!dragging) return
|
||||||
|
applySideWidth(startW - (e.clientX - startX))
|
||||||
|
})
|
||||||
|
handle.addEventListener('pointerup', endDrag)
|
||||||
|
handle.addEventListener('pointercancel', endDrag)
|
||||||
|
handle.addEventListener('lostpointercapture', endDrag)
|
||||||
|
// 双击复位:拖窄了想回去,不用精确拖回 280
|
||||||
|
handle.addEventListener('dblclick', (e) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
applySideWidth(SIDE_DEFAULT)
|
||||||
|
saveSideWidth()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/** 工具条按钮:点击切换当前工具(选区命令按钮也借用 .iwb-editor-tool 样式,靠 data-tool 过滤掉) */
|
/** 工具条按钮:点击切换当前工具(选区命令按钮也借用 .iwb-editor-tool 样式,靠 data-tool 过滤掉) */
|
||||||
function bindToolButtons() {
|
function bindToolButtons() {
|
||||||
// 工具
|
// 工具
|
||||||
@@ -2122,8 +2206,10 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 色板弹层(v1.3;v1.11 起同时服务描边与填充两个槽):
|
/** 调色面板(v1.3 弹层 → v1.16 弹层 + 右栏常驻):
|
||||||
* 工具栏两个色块开关;tab / hex / 吸管 / 推荐色 / 调色器 / 无填充都在这一个弹层里 */
|
* 两处是同一份 DOM(dom.js#colorSurfaceHtml),按 [data-color-surface] 逐个绑定。
|
||||||
|
* 每个 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"]')]
|
||||||
@@ -2132,37 +2218,50 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
|||||||
btn.addEventListener('click', (e) => { e.stopPropagation(); toggleColorPop(btn.dataset.colorSlot) })
|
btn.addEventListener('click', (e) => { e.stopPropagation(); toggleColorPop(btn.dataset.colorSlot) })
|
||||||
})
|
})
|
||||||
if (pop) {
|
if (pop) {
|
||||||
pop.addEventListener('mousedown', (e) => e.stopPropagation())
|
|
||||||
// 点外面关闭:必须用捕获阶段 —— 画布的 mousedown 会 preventDefault,
|
// 点外面关闭:必须用捕获阶段 —— 画布的 mousedown 会 preventDefault,
|
||||||
// 冒泡阶段拿不到「点了外面」这件事。
|
// 冒泡阶段拿不到「点了外面」这件事。右栏面板常驻,不参与关闭。
|
||||||
document.addEventListener('mousedown', (e) => {
|
document.addEventListener('mousedown', (e) => {
|
||||||
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)
|
||||||
window.addEventListener('resize', positionColorPop)
|
window.addEventListener('resize', positionColorPop)
|
||||||
}
|
}
|
||||||
|
runtime.el.querySelectorAll('[data-color-surface]').forEach(surface => bindColorSurface(surface))
|
||||||
|
}
|
||||||
|
|
||||||
// 弹层头部:切描边/填充,或直接置为「无填充」
|
/** 一块调色面板的全部交互:弹层与右栏各一份,代码只有这一处 */
|
||||||
if (pop) {
|
function bindColorSurface(surface) {
|
||||||
pop.addEventListener('click', (e) => {
|
const isPop = surface.classList.contains('iwb-editor-color-pop')
|
||||||
const tab = e.target.closest('[data-color-slot]')
|
surface.addEventListener('mousedown', (e) => e.stopPropagation())
|
||||||
if (tab && tab.classList.contains('iwb-color-pop-tab')) {
|
// tab 切换目标槽 / 「无」 / 常用色与最近色,统一委托:
|
||||||
e.stopPropagation()
|
// 静态 12 色 + 动态插入的「最近使用」都要能点,一次性 querySelectorAll 会漏掉后者
|
||||||
setColorTarget(tab.dataset.colorSlot)
|
surface.addEventListener('click', (e) => {
|
||||||
positionColorPop()
|
const tab = e.target.closest('.iwb-color-pop-tab[data-color-slot]')
|
||||||
return
|
if (tab) {
|
||||||
}
|
e.stopPropagation()
|
||||||
const none = e.target.closest('[data-color-none]')
|
setColorTarget(tab.dataset.colorSlot)
|
||||||
if (none) {
|
if (isPop) positionColorPop() // 换 tab 后弹层宽度会变,重新贴一次
|
||||||
e.stopPropagation()
|
return
|
||||||
applyColorNone()
|
}
|
||||||
return
|
const none = e.target.closest('[data-color-none]')
|
||||||
}
|
if (none) { e.stopPropagation(); applyColorNone(); return }
|
||||||
|
const sw = e.target.closest('[data-panel-color]')
|
||||||
|
if (sw) { e.stopPropagation(); applyPanelColor(sw.dataset.panelColor) }
|
||||||
|
})
|
||||||
|
|
||||||
|
const hexInput = surface.querySelector('.iwb-editor-color-hex-input')
|
||||||
|
if (hexInput) {
|
||||||
|
hexInput.addEventListener('change', () => {
|
||||||
|
if (/^#[0-9a-f]{6}$/i.test(hexInput.value)) applyPanelColor(hexInput.value)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
const palettePick = surface.querySelector('[data-action="palettePick"]')
|
||||||
|
if (palettePick) {
|
||||||
|
palettePick.addEventListener('mousedown', (e) => e.stopPropagation())
|
||||||
|
// 取色要回画布点,弹层必须先收起,否则它会挡住取样点(右栏面板在画布外,不挡)
|
||||||
|
palettePick.addEventListener('click', () => { closeColorPop(); setTool('picker') })
|
||||||
|
}
|
||||||
|
|
||||||
// 独立颜色面板:按当前目标槽写色(描边 → 主色,填充 → 形状 fillColor)
|
|
||||||
const setPanelColor = (color) => applyPanelColor(color)
|
|
||||||
// 拖动取色期间只拍一次快照:applyColorChange 每改一次颜色都会 saveSnapshot,
|
// 拖动取色期间只拍一次快照:applyColorChange 每改一次颜色都会 saveSnapshot,
|
||||||
// 在 SV 里拖一下会连拍几百张全画质 ImageData(4K 图直接吃掉几百 MB)。
|
// 在 SV 里拖一下会连拍几百张全画质 ImageData(4K 图直接吃掉几百 MB)。
|
||||||
// pointerdown 先拍(此时颜色还没变,快照是「改之前」),之后每步只改对象。
|
// pointerdown 先拍(此时颜色还没变,快照是「改之前」),之后每步只改对象。
|
||||||
@@ -2177,26 +2276,10 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
|||||||
}
|
}
|
||||||
applyPanelColor(color, { skipHistory: true })
|
applyPanelColor(color, { skipHistory: true })
|
||||||
}
|
}
|
||||||
const panelHexInput = runtime.el.querySelector('.iwb-editor-color-hex-input')
|
|
||||||
if (panelHexInput) panelHexInput.addEventListener('change', () => { if (/^#[0-9a-f]{6}$/i.test(panelHexInput.value)) setPanelColor(panelHexInput.value) })
|
const sv = surface.querySelector('.iwb-color-sv')
|
||||||
// 色块统一走委托:静态 12 色 + 动态插入的「最近使用」都要能点,
|
const hue = surface.querySelector('.iwb-color-hue')
|
||||||
// 一次性 querySelectorAll 绑定会漏掉后来插进来的按钮
|
if (!sv || !hue) return
|
||||||
if (pop) {
|
|
||||||
pop.addEventListener('click', (e) => {
|
|
||||||
const btn = e.target.closest('[data-panel-color]')
|
|
||||||
if (!btn) return
|
|
||||||
e.stopPropagation()
|
|
||||||
setPanelColor(btn.dataset.panelColor)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const palettePick = runtime.el.querySelector('[data-action="palettePick"]')
|
|
||||||
if (palettePick) {
|
|
||||||
palettePick.addEventListener('mousedown', (e) => e.stopPropagation())
|
|
||||||
// 取色要回画布点,弹层必须先收起,否则它会挡住取样点
|
|
||||||
palettePick.addEventListener('click', () => { closeColorPop(); setTool('picker') })
|
|
||||||
}
|
|
||||||
const sv = runtime.el.querySelector('.iwb-color-sv')
|
|
||||||
const hue = runtime.el.querySelector('.iwb-color-hue')
|
|
||||||
const initHsv = (() => {
|
const initHsv = (() => {
|
||||||
const { r, g, b } = hexToRgb(activeColor())
|
const { r, g, b } = hexToRgb(activeColor())
|
||||||
const rr = r / 255, gg = g / 255, bb = b / 255
|
const rr = r / 255, gg = g / 255, bb = b / 255
|
||||||
|
|||||||
@@ -33,11 +33,11 @@ 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 } from './events.js'
|
import { updateAllUI, bindLiteUI, renderOptionBar, updateStatusbar, loadSideWidth } 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'
|
||||||
import { onHistoryRestore as onAdjustHistoryRestore, renderAdjustPanel } from './adjust.js'
|
import { adjustCacheSize, onHistoryRestore as onAdjustHistoryRestore, renderAdjustPanel, resetAdjustCache } from './adjust.js'
|
||||||
import { loadExportOptions, prepareOutput, downloadBlob, copyBlobToClipboard, bindExportUI, renderExportUI } from './export.js'
|
import { loadExportOptions, prepareOutput, downloadBlob, copyBlobToClipboard, bindExportUI, renderExportUI } from './export.js'
|
||||||
import { loadRecentColors } from './recent-colors.js'
|
import { loadRecentColors } from './recent-colors.js'
|
||||||
import { toast } from './commands.js'
|
import { toast } from './commands.js'
|
||||||
@@ -73,6 +73,9 @@ import { toast } from './commands.js'
|
|||||||
bindFloating()
|
bindFloating()
|
||||||
bindExportUI()
|
bindExportUI()
|
||||||
initPanels()
|
initPanels()
|
||||||
|
// 右栏宽度跟着用户上次拖的位置(v1.16);必须在 initPanels 之后——
|
||||||
|
// 侧栏收起时元素虽 display:none,写 CSS 变量仍然有效,下次展开直接生效
|
||||||
|
loadSideWidth()
|
||||||
renderAll()
|
renderAll()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[IWB编辑器] 打开失败:', e)
|
console.error('[IWB编辑器] 打开失败:', e)
|
||||||
@@ -130,6 +133,9 @@ import { toast } from './commands.js'
|
|||||||
S.altPicker = false
|
S.altPicker = false
|
||||||
// 快速效果的基准像素属于上一张图,重开必须清掉(否则滑杆会往新图上写旧像素)
|
// 快速效果的基准像素属于上一张图,重开必须清掉(否则滑杆会往新图上写旧像素)
|
||||||
S.fx = { key: null, value: 0, layerId: null, source: null }
|
S.fx = { key: null, value: 0, layerId: null, source: null }
|
||||||
|
// 图片调节的基准像素同理,而且更致命:缓存 key 是图层 id,原图恒为 'base',
|
||||||
|
// 不清就一定命中上一张图的像素(v1.15.1 修「调新图变回旧图」)
|
||||||
|
resetAdjustCache()
|
||||||
S.zCounter = Math.max(S.layers.length - 1, 0)
|
S.zCounter = Math.max(S.layers.length - 1, 0)
|
||||||
S.placingImage = null
|
S.placingImage = null
|
||||||
S.placingHandle = null
|
S.placingHandle = null
|
||||||
@@ -224,6 +230,9 @@ import { toast } from './commands.js'
|
|||||||
S.pickerComposite = null
|
S.pickerComposite = null
|
||||||
// 2b) 快速效果的基准像素:又一张全幅位图,不释放就白占一份图大小的内存
|
// 2b) 快速效果的基准像素:又一张全幅位图,不释放就白占一份图大小的内存
|
||||||
S.fx = { key: null, value: 0, layerId: null, source: null }
|
S.fx = { key: null, value: 0, layerId: null, source: null }
|
||||||
|
// 2c) 图片调节的基准像素与预览副本(两张全幅位图)+ 按 layer.id 的缓存 Map。
|
||||||
|
// 缓存必须清,否则下次打开新图时 'base' 会命中这份旧像素(v1.15.1)
|
||||||
|
resetAdjustCache()
|
||||||
// 3) 交互态复位:关闭后 window mouseup 等全局监听仍活着,靠标志位保证不落到绘制路径
|
// 3) 交互态复位:关闭后 window mouseup 等全局监听仍活着,靠标志位保证不落到绘制路径
|
||||||
S.isDrawing = false
|
S.isDrawing = false
|
||||||
S.panning = false
|
S.panning = false
|
||||||
@@ -385,6 +394,8 @@ import { toast } from './commands.js'
|
|||||||
hasSource: Boolean(S.adjust && S.adjust.source),
|
hasSource: Boolean(S.adjust && S.adjust.source),
|
||||||
params: S.adjust && S.adjust.params ? { ...S.adjust.params } : null
|
params: S.adjust && S.adjust.params ? { ...S.adjust.params } : null
|
||||||
},
|
},
|
||||||
|
// 调节基准缓存条数:退出编辑器后必须是 0(否则下一张图会拿到上一张的像素)
|
||||||
|
adjustCacheSize: adjustCacheSize(),
|
||||||
interaction: S.interaction,
|
interaction: S.interaction,
|
||||||
ants: !!S._antFrame,
|
ants: !!S._antFrame,
|
||||||
view: S.viewX !== null ? [Math.round(S.viewX), Math.round(S.viewY)] : null,
|
view: S.viewX !== null ? [Math.round(S.viewX), Math.round(S.viewY)] : null,
|
||||||
|
|||||||
@@ -43,12 +43,21 @@ import { S, runtime } from './state.js'
|
|||||||
renderRecentColors()
|
renderRecentColors()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function renderRecentColors() {
|
export function renderRecentColors() {
|
||||||
const wrap = runtime.el && runtime.el.querySelector('.iwb-editor-recent-colors')
|
if (!runtime.el) return
|
||||||
if (!wrap) return
|
// v1.16:右栏常驻面板与工具栏弹层各有一份,按集合刷
|
||||||
const list = S.recentColors || []
|
const wraps = runtime.el.querySelectorAll('.iwb-editor-recent-colors')
|
||||||
wrap.innerHTML = list.map(c =>
|
if (!wraps.length) return
|
||||||
`<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="${c}" style="background:${c}" title="最近使用 ${c}"></button>`
|
const list = S.recentColors || []
|
||||||
).join('')
|
const html = list.map(c =>
|
||||||
|
`<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="${c}" style="background:${c}" title="最近使用 ${c}"></button>`
|
||||||
|
).join('')
|
||||||
|
wraps.forEach(wrap => {
|
||||||
|
wrap.innerHTML = html
|
||||||
wrap.hidden = !list.length
|
wrap.hidden = !list.length
|
||||||
}
|
// v1.16:右栏给了一组加了「最近」小标题,没有最近色时整组一起藏,
|
||||||
|
// 否则标题下面留一块空白,看起来像没加载出来。
|
||||||
|
const group = wrap.closest('.iwb-color-group')
|
||||||
|
if (group) group.hidden = !list.length
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -53,6 +53,9 @@
|
|||||||
// 色板(调色器 / 吸管 / 推荐色 / hex)按这个值决定写 S.color 还是 shapeFillColor,
|
// 色板(调色器 / 吸管 / 推荐色 / hex)按这个值决定写 S.color 还是 shapeFillColor,
|
||||||
// 否则「三个地方各调各的颜色」会一直存在。
|
// 否则「三个地方各调各的颜色」会一直存在。
|
||||||
colorTarget: 'stroke', // stroke | fill
|
colorTarget: 'stroke', // stroke | fill
|
||||||
|
// v1.16:右侧栏宽度(px)。0 = 按默认值走,打开编辑器时从宿主 KV 恢复。
|
||||||
|
// 宽度统一落在 CSS 变量 --iwb-side-w 上,不再各条规则各写一个魔数。
|
||||||
|
sideWidth: 0,
|
||||||
textSize: 32, // 新建文字的字号 px
|
textSize: 32, // 新建文字的字号 px
|
||||||
// ---- v1.9 文字样式:这套是「新建文字」的默认值,每段文字自己存一份 ----
|
// ---- v1.9 文字样式:这套是「新建文字」的默认值,每段文字自己存一份 ----
|
||||||
textWeight: 'bold', // bold | normal | 900
|
textWeight: 'bold', // bold | normal | 900
|
||||||
|
|||||||
+2466
-112
File diff suppressed because it is too large.
Load diff
@@ -206,6 +206,46 @@ if (!SKIP_PASTE) {
|
|||||||
check('Ctrl+Shift+] 置顶生效', (await panelSeq()) !== afterBottom, await panelSeq())
|
check('Ctrl+Shift+] 置顶生效', (await panelSeq()) !== afterBottom, await panelSeq())
|
||||||
check('排序后仍只有一个选中项', (await activeCount()) === 1, 'active=' + await activeCount())
|
check('排序后仍只有一个选中项', (await activeCount()) === 1, 'active=' + await activeCount())
|
||||||
|
|
||||||
|
// v1.15 图片调节:真站确认面板存在、11 项按参数表生成(DOM 由 adjust.js 生成,
|
||||||
|
// 构建时漏带就会是 0 行 —— 这类「打包产物缺模块」只有真站能发现)
|
||||||
|
const adjRowCount = await page.locator('.iwb-editor-adj-row').count()
|
||||||
|
const adjNames = await page.locator('.iwb-editor-adj-name').allTextContents()
|
||||||
|
check('右侧栏「图片调节」11 项齐全',
|
||||||
|
adjRowCount === 11 && adjNames.join('/') === '曝光/明度/对比度/阴影/高光/色相/饱和度/温度/色调/锐度/清晰度',
|
||||||
|
'rows=' + adjRowCount + ' ' + adjNames.join('/'))
|
||||||
|
check('调节面板认到了作用层(不是「无图层」)',
|
||||||
|
(await page.locator('.iwb-editor-adj-target').textContent()) !== '无图层',
|
||||||
|
await page.locator('.iwb-editor-adj-target').textContent())
|
||||||
|
|
||||||
|
// v1.16:右栏常驻调色面板 + 可拖宽度。真站里 DOM 与 CSS 是分别打包的,
|
||||||
|
// 只验面板在不在、拖宽后宽度有没有真的变 —— 样式漏打包时这里会直接露出来。
|
||||||
|
const sideColor = await page.evaluate(() => {
|
||||||
|
const side = document.querySelector('.iwb-editor-left [data-color-surface="side"]')
|
||||||
|
if (!side) return null
|
||||||
|
return {
|
||||||
|
tabs: side.querySelectorAll('.iwb-color-pop-tab').length,
|
||||||
|
swatches: side.querySelectorAll('.iwb-editor-color-swatches [data-panel-color]').length,
|
||||||
|
sv: !!side.querySelector('.iwb-color-sv')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
check('右栏常驻调色面板(色格切换 + 调色器 + 12 个常用色)',
|
||||||
|
Boolean(sideColor) && sideColor.tabs === 3 && sideColor.swatches === 12 && sideColor.sv,
|
||||||
|
JSON.stringify(sideColor))
|
||||||
|
|
||||||
|
const sideBefore = await page.evaluate(() => Math.round(document.querySelector('.iwb-editor-left').getBoundingClientRect().width))
|
||||||
|
const sideGrip = await page.locator('.iwb-editor-side-resizer').boundingBox()
|
||||||
|
if (sideGrip) {
|
||||||
|
await page.mouse.move(sideGrip.x + 3, sideGrip.y + 120)
|
||||||
|
await page.mouse.down()
|
||||||
|
await page.mouse.move(sideGrip.x + 3 - 70, sideGrip.y + 120, { steps: 6 })
|
||||||
|
await page.mouse.up()
|
||||||
|
await page.waitForTimeout(180)
|
||||||
|
}
|
||||||
|
const sideAfter = await page.evaluate(() => Math.round(document.querySelector('.iwb-editor-left').getBoundingClientRect().width))
|
||||||
|
check('右栏可以拖宽(不再固定 220)', sideAfter >= sideBefore + 60, sideBefore + ' → ' + sideAfter)
|
||||||
|
await page.locator('.iwb-editor-side-resizer').dblclick()
|
||||||
|
await page.waitForTimeout(150)
|
||||||
|
|
||||||
// v1.14 字体选择:真站是带 CSP 的环境,这里确认下拉可用、字体切换真的落到了对象上。
|
// v1.14 字体选择:真站是带 CSP 的环境,这里确认下拉可用、字体切换真的落到了对象上。
|
||||||
// 系统字体不受 CSP 约束(CSP 管的是网络字体),所以只要 canvas 能画就没问题。
|
// 系统字体不受 CSP 约束(CSP 管的是网络字体),所以只要 canvas 能画就没问题。
|
||||||
const famDbg = () => page.evaluate(() => window.__iwbEditor.__debug())
|
const famDbg = () => page.evaluate(() => window.__iwbEditor.__debug())
|
||||||
|
|||||||
@@ -1001,7 +1001,7 @@ check('拖调色器改选中形状颜色:历史只增加 1 条', await (async
|
|||||||
if (!(await dbg()).selectedShapeId) return 'pre: 没选中形状'
|
if (!(await dbg()).selectedShapeId) return 'pre: 没选中形状'
|
||||||
const h0 = (await dbg()).history
|
const h0 = (await dbg()).history
|
||||||
await page.locator('.iwb-editor-tools [data-action="toggleColorPop"][data-color-slot="stroke"]').click()
|
await page.locator('.iwb-editor-tools [data-action="toggleColorPop"][data-color-slot="stroke"]').click()
|
||||||
const sv = await page.locator('.iwb-color-sv').boundingBox()
|
const sv = await page.locator('.iwb-editor-color-pop .iwb-color-sv').boundingBox()
|
||||||
await page.mouse.move(sv.x + sv.width * 0.2, sv.y + sv.height * 0.2)
|
await page.mouse.move(sv.x + sv.width * 0.2, sv.y + sv.height * 0.2)
|
||||||
await page.mouse.down()
|
await page.mouse.down()
|
||||||
await page.mouse.move(sv.x + sv.width * 0.9, sv.y + sv.height * 0.85, { steps: 20 })
|
await page.mouse.move(sv.x + sv.width * 0.9, sv.y + sv.height * 0.85, { steps: 20 })
|
||||||
@@ -1983,7 +1983,7 @@ check('点文字的「描边」格:色板目标是描边(tab 写「描边」
|
|||||||
popTextTarget.bgVisible && popTextTarget.noneVisible, JSON.stringify(popTextTarget))
|
popTextTarget.bgVisible && popTextTarget.noneVisible, JSON.stringify(popTextTarget))
|
||||||
|
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
const el = document.querySelector('.iwb-editor-color-hex-input')
|
const el = document.querySelector('.iwb-editor-color-pop .iwb-editor-color-hex-input')
|
||||||
el.value = '#00a3ff'
|
el.value = '#00a3ff'
|
||||||
el.dispatchEvent(new Event('change', { bubbles: true }))
|
el.dispatchEvent(new Event('change', { bubbles: true }))
|
||||||
})
|
})
|
||||||
@@ -2019,7 +2019,7 @@ const popBgTarget = await page.evaluate(() => {
|
|||||||
check('点文字的「底色」格:色板切到底色', popBgTarget.bgActive && popBgTarget.label === '底色', JSON.stringify(popBgTarget))
|
check('点文字的「底色」格:色板切到底色', popBgTarget.bgActive && popBgTarget.label === '底色', JSON.stringify(popBgTarget))
|
||||||
|
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
const el = document.querySelector('.iwb-editor-color-hex-input')
|
const el = document.querySelector('.iwb-editor-color-pop .iwb-editor-color-hex-input')
|
||||||
el.value = '#123456'
|
el.value = '#123456'
|
||||||
el.dispatchEvent(new Event('change', { bubbles: true }))
|
el.dispatchEvent(new Event('change', { bubbles: true }))
|
||||||
})
|
})
|
||||||
@@ -2045,7 +2045,7 @@ check('底色格显示真实颜色(半透明显示,不是实心块)',
|
|||||||
await page.locator('.iwb-editor-color-btn[data-color-slot="stroke"]').click()
|
await page.locator('.iwb-editor-color-btn[data-color-slot="stroke"]').click()
|
||||||
await page.waitForTimeout(200)
|
await page.waitForTimeout(200)
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
const el = document.querySelector('.iwb-editor-color-hex-input')
|
const el = document.querySelector('.iwb-editor-color-pop .iwb-editor-color-hex-input')
|
||||||
el.value = '#ff00aa'
|
el.value = '#ff00aa'
|
||||||
el.dispatchEvent(new Event('change', { bubbles: true }))
|
el.dispatchEvent(new Event('change', { bubbles: true }))
|
||||||
})
|
})
|
||||||
@@ -2062,12 +2062,12 @@ check('文字色 / 描边色 / 底色三格互不串(改一格不动另外两
|
|||||||
// 「无」在底色格 = 关掉底色块,颜色留着
|
// 「无」在底色格 = 关掉底色块,颜色留着
|
||||||
await page.locator('.iwb-editor-color-btn[data-color-slot="bg"]').click()
|
await page.locator('.iwb-editor-color-btn[data-color-slot="bg"]').click()
|
||||||
await page.waitForTimeout(200)
|
await page.waitForTimeout(200)
|
||||||
await page.evaluate(() => document.querySelector('[data-color-none]').click())
|
await page.evaluate(() => document.querySelector('.iwb-editor-color-pop [data-color-none]').click())
|
||||||
await page.waitForTimeout(260)
|
await page.waitForTimeout(260)
|
||||||
const bgNone = await page.evaluate(() => {
|
const bgNone = await page.evaluate(() => {
|
||||||
const t = window.__iwbEditor.__debug().texts[0]
|
const t = window.__iwbEditor.__debug().texts[0]
|
||||||
const chip = document.querySelector('.iwb-editor-color-pair [data-color-slot="bg"]')
|
const chip = document.querySelector('.iwb-editor-color-pair [data-color-slot="bg"]')
|
||||||
return { bgFill: t.bgFill, bgColor: t.bgColor, cls: chip.className, noneActive: document.querySelector('[data-color-none]').classList.contains('active') }
|
return { bgFill: t.bgFill, bgColor: t.bgColor, cls: chip.className, noneActive: document.querySelector('.iwb-editor-color-pop [data-color-none]').classList.contains('active') }
|
||||||
})
|
})
|
||||||
check('底色格点「无」:关掉底色块、颜色留着,格子回到斜杠态',
|
check('底色格点「无」:关掉底色块、颜色留着,格子回到斜杠态',
|
||||||
bgNone.bgFill === false && bgNone.bgColor === '#123456' && /is-none/.test(bgNone.cls) && bgNone.noneActive,
|
bgNone.bgFill === false && bgNone.bgColor === '#123456' && /is-none/.test(bgNone.cls) && bgNone.noneActive,
|
||||||
@@ -2264,7 +2264,7 @@ await page.waitForTimeout(150)
|
|||||||
await page.locator('.iwb-editor-color-pop [data-panel-color="#ffd400"]').first().click()
|
await page.locator('.iwb-editor-color-pop [data-panel-color="#ffd400"]').first().click()
|
||||||
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-recent-colors [data-panel-color]').count()
|
const recentsInPop = await page.locator('.iwb-editor-color-pop .iwb-editor-recent-colors [data-panel-color]').count()
|
||||||
await page.keyboard.press('Escape')
|
await page.keyboard.press('Escape')
|
||||||
await page.waitForTimeout(120)
|
await page.waitForTimeout(120)
|
||||||
check('选过的颜色进入「最近使用」并出现在色板弹层',
|
check('选过的颜色进入「最近使用」并出现在色板弹层',
|
||||||
@@ -2415,7 +2415,7 @@ check('点填充槽打开色板:目标是填充,并出现「无」按钮',
|
|||||||
// 拿黄色/绿色统计会数到别的图形,永远清不到 0。
|
// 拿黄色/绿色统计会数到别的图形,永远清不到 0。
|
||||||
const mainBefore = await page.evaluate(() => window.__iwbEditor.__debug().color)
|
const mainBefore = await page.evaluate(() => window.__iwbEditor.__debug().color)
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
const el = document.querySelector('.iwb-editor-color-hex-input')
|
const el = document.querySelector('.iwb-editor-color-pop .iwb-editor-color-hex-input')
|
||||||
el.value = '#a014b2'
|
el.value = '#a014b2'
|
||||||
el.dispatchEvent(new Event('change', { bubbles: true }))
|
el.dispatchEvent(new Event('change', { bubbles: true }))
|
||||||
})
|
})
|
||||||
@@ -2432,13 +2432,13 @@ check('色板里选色写进填充、主色(描边)不动,工具栏填充
|
|||||||
|
|
||||||
// 「无」:关填充,画面清空,但颜色留着
|
// 「无」:关填充,画面清空,但颜色留着
|
||||||
const purpleBefore = await countColorInVec([160, 20, 178], 10)
|
const purpleBefore = await countColorInVec([160, 20, 178], 10)
|
||||||
await page.evaluate(() => document.querySelector('[data-color-none]').click())
|
await page.evaluate(() => document.querySelector('.iwb-editor-color-pop [data-color-none]').click())
|
||||||
await page.waitForTimeout(320)
|
await page.waitForTimeout(320)
|
||||||
const afterNone = await page.evaluate(() => {
|
const afterNone = await page.evaluate(() => {
|
||||||
const d = window.__iwbEditor.__debug()
|
const d = window.__iwbEditor.__debug()
|
||||||
const s = d.shapes[d.shapes.length - 1]
|
const s = d.shapes[d.shapes.length - 1]
|
||||||
const fillBtn = document.querySelector('.iwb-editor-color-pair [data-color-slot="fill"]')
|
const fillBtn = document.querySelector('.iwb-editor-color-pair [data-color-slot="fill"]')
|
||||||
return { fill: s.fill, fillColor: s.fillColor, btnCls: fillBtn.className, noneActive: document.querySelector('[data-color-none]').classList.contains('active') }
|
return { fill: s.fill, fillColor: s.fillColor, btnCls: fillBtn.className, noneActive: document.querySelector('.iwb-editor-color-pop [data-color-none]').classList.contains('active') }
|
||||||
})
|
})
|
||||||
const purpleAfter = await countColorInVec([160, 20, 178], 10)
|
const purpleAfter = await countColorInVec([160, 20, 178], 10)
|
||||||
check('「无」把填充关掉:画面清空、颜色留着(下次点颜色还是它)',
|
check('「无」把填充关掉:画面清空、颜色留着(下次点颜色还是它)',
|
||||||
@@ -2553,6 +2553,73 @@ check('右侧栏出现「图片调节」,11 项齐全且顺序固定',
|
|||||||
adjRowCount === 11 && adjNames.join('/') === '曝光/明度/对比度/阴影/高光/色相/饱和度/温度/色调/锐度/清晰度',
|
adjRowCount === 11 && adjNames.join('/') === '曝光/明度/对比度/阴影/高光/色相/饱和度/温度/色调/锐度/清晰度',
|
||||||
'rows=' + adjRowCount + ' ' + adjNames.join('/'))
|
'rows=' + adjRowCount + ' ' + adjNames.join('/'))
|
||||||
|
|
||||||
|
// ---------- v1.16:右栏常驻调色面板 / 两处同步 / 可拖宽度 / 字号 ----------
|
||||||
|
const sideSurface = await page.evaluate(() => {
|
||||||
|
const side = document.querySelector('.iwb-editor-left [data-color-surface="side"]')
|
||||||
|
if (!side) return null
|
||||||
|
const tabs = [...side.querySelectorAll('.iwb-color-pop-tab')]
|
||||||
|
return {
|
||||||
|
tabs: tabs.length,
|
||||||
|
visibleTabs: tabs.filter(t => !t.hidden).length,
|
||||||
|
swatches: side.querySelectorAll('.iwb-editor-color-swatches [data-panel-color]').length,
|
||||||
|
sv: !!side.querySelector('.iwb-color-sv'),
|
||||||
|
hue: !!side.querySelector('.iwb-color-hue'),
|
||||||
|
hex: !!side.querySelector('.iwb-editor-color-hex-input')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
check('右栏有常驻调色面板:可调颜色项 + 调色器 + 12 个常用色',
|
||||||
|
Boolean(sideSurface) && sideSurface.tabs === 3 && sideSurface.visibleTabs >= 1 &&
|
||||||
|
sideSurface.swatches === 12 && sideSurface.sv && sideSurface.hue && sideSurface.hex,
|
||||||
|
JSON.stringify(sideSurface))
|
||||||
|
|
||||||
|
// 在右栏点常用色 → 弹层里同一色块也必须高亮(两处共用一份颜色状态)
|
||||||
|
await page.locator('.iwb-editor-left [data-color-surface="side"] [data-panel-color="#00bfa5"]').click()
|
||||||
|
await page.waitForTimeout(220)
|
||||||
|
const colorSync = await page.evaluate(() => {
|
||||||
|
// 只看「常用色」网格:最近使用里同色也会高亮,那是正常的两处提示,不该算进断言
|
||||||
|
const activeIn = (root) => [...root.querySelectorAll('.iwb-editor-color-swatches [data-panel-color]')]
|
||||||
|
.filter(b => b.classList.contains('active')).map(b => b.dataset.panelColor)
|
||||||
|
const side = document.querySelector('.iwb-editor-left [data-color-surface="side"]')
|
||||||
|
const pop = document.querySelector('.iwb-editor-color-pop')
|
||||||
|
return { side: activeIn(side), pop: activeIn(pop), color: window.__iwbEditor.__debug().color }
|
||||||
|
})
|
||||||
|
check('右栏选色后弹层同一色块同步高亮(不是两套各管各的)',
|
||||||
|
colorSync.side.length === 1 && colorSync.side[0] === '#00bfa5' &&
|
||||||
|
colorSync.pop.length === 1 && colorSync.pop[0] === '#00bfa5' && colorSync.color === '#00bfa5',
|
||||||
|
JSON.stringify(colorSync))
|
||||||
|
|
||||||
|
// 拖右栏宽度:侧栏在画布右侧,指针左移 80px ⇒ 宽 80px
|
||||||
|
const sideW0 = await page.evaluate(() => Math.round(document.querySelector('.iwb-editor-left').getBoundingClientRect().width))
|
||||||
|
const grip = await page.locator('.iwb-editor-side-resizer').boundingBox()
|
||||||
|
await page.mouse.move(grip.x + grip.width / 2, grip.y + grip.height / 2)
|
||||||
|
await page.mouse.down()
|
||||||
|
await page.mouse.move(grip.x + grip.width / 2 - 80, grip.y + grip.height / 2, { steps: 8 })
|
||||||
|
await page.mouse.up()
|
||||||
|
await page.waitForTimeout(180)
|
||||||
|
const sideW1 = await page.evaluate(() => Math.round(document.querySelector('.iwb-editor-left').getBoundingClientRect().width))
|
||||||
|
check('拖右栏手柄:宽度随拖动变大(不是固定 220)',
|
||||||
|
sideW1 >= sideW0 + 70 && sideW1 <= 520, sideW0 + ' → ' + sideW1)
|
||||||
|
|
||||||
|
await page.locator('.iwb-editor-side-resizer').dblclick()
|
||||||
|
await page.waitForTimeout(180)
|
||||||
|
const sideW2 = await page.evaluate(() => Math.round(document.querySelector('.iwb-editor-left').getBoundingClientRect().width))
|
||||||
|
// 注意:aside 是 content-box,width 280 + 左右 padding 24 ⇒ rect 约 304/305。
|
||||||
|
// 这里跟「拖之前」比才对,写死 280 会误判。
|
||||||
|
check('双击手柄复位到默认宽度(回到拖动前)', Math.abs(sideW2 - sideW0) <= 2, sideW0 + ' ← ' + sideW2)
|
||||||
|
|
||||||
|
const fontSizes = await page.evaluate(() => ({
|
||||||
|
adjName: getComputedStyle(document.querySelector('.iwb-editor-adj-name')).fontSize,
|
||||||
|
adjTitle: getComputedStyle(document.querySelector('.iwb-editor-adj-title')).fontSize,
|
||||||
|
statusbar: getComputedStyle(document.querySelector('.iwb-editor-statusbar')).fontSize,
|
||||||
|
optionbar: getComputedStyle(document.querySelector('.iwb-editor-optionbar')).fontSize,
|
||||||
|
layerName: document.querySelector('.iwb-layer-name') ? getComputedStyle(document.querySelector('.iwb-layer-name')).fontSize : null
|
||||||
|
}))
|
||||||
|
check('整体字号提升一档(面板行名 12.5 / 标题 13 / 状态栏 12 / 选项栏 13)',
|
||||||
|
fontSizes.adjName === '12.5px' && fontSizes.adjTitle === '13px' &&
|
||||||
|
fontSizes.statusbar === '12px' && fontSizes.optionbar === '13px' &&
|
||||||
|
(!fontSizes.layerName || fontSizes.layerName === '13px'),
|
||||||
|
JSON.stringify(fontSizes))
|
||||||
|
|
||||||
/** 合成整幅可见像素后统计:平均亮度 / 灰像素占比 / R、B 均值 */
|
/** 合成整幅可见像素后统计:平均亮度 / 灰像素占比 / R、B 均值 */
|
||||||
const adjStat = () => page.evaluate(() => {
|
const adjStat = () => page.evaluate(() => {
|
||||||
const list = [...document.querySelectorAll('.iwb-editor-layer-canvas')]
|
const list = [...document.querySelectorAll('.iwb-editor-layer-canvas')]
|
||||||
@@ -2668,6 +2735,11 @@ check('切图层时调节面板跟随新层,切回原层参数恢复',
|
|||||||
|
|
||||||
await adjReset()
|
await adjReset()
|
||||||
|
|
||||||
|
// 退出前先记一笔:此时调过曝光/温度,缓存里必然有 'base' 条目,
|
||||||
|
// 下面 Round 3 用它证明「退出确实把缓存清掉了」,而不是本来就没缓存。
|
||||||
|
const adjCacheBefore = (await dbg()).adjustCacheSize
|
||||||
|
check('前置:调过之后基准缓存里有条目', adjCacheBefore > 0, 'cache=' + adjCacheBefore)
|
||||||
|
|
||||||
await page.locator('[data-action="cancel"]').click()
|
await page.locator('[data-action="cancel"]').click()
|
||||||
const openState = await poll(async () => page.evaluate(() => window.__openState))
|
const openState = await poll(async () => page.evaluate(() => window.__openState))
|
||||||
check('点「退出」:宿主 Promise 结算为 cancel 且编辑器关闭',
|
check('点「退出」:宿主 Promise 结算为 cancel 且编辑器关闭',
|
||||||
@@ -2675,6 +2747,35 @@ check('点「退出」:宿主 Promise 结算为 cancel 且编辑器关闭',
|
|||||||
(await page.locator('#iwb-editor-overlay').isVisible().catch(() => false)) === false,
|
(await page.locator('#iwb-editor-overlay').isVisible().catch(() => false)) === false,
|
||||||
JSON.stringify(openState))
|
JSON.stringify(openState))
|
||||||
|
|
||||||
|
// ---------- Round 3:退出再打开,调节基准必须重建 ----------
|
||||||
|
// 原图图层的 id 是写死的 'base',而 adjust.js 的基准缓存以 layer.id 为 key。
|
||||||
|
// 退出时不清缓存 ⇒ 第二张图 captureFor('base') 命中上一张图的像素,
|
||||||
|
// 表现为「编辑另一张图时一调节,画面还原成上一张」—— 100% 复现,不是偶发。
|
||||||
|
await page.evaluate(() => {
|
||||||
|
window.__openState = null
|
||||||
|
window.__commands['annotate-selected'].run().then(
|
||||||
|
(mode) => { window.__openState = { mode: String(mode) } },
|
||||||
|
(err) => { window.__openState = { error: String((err && err.message) || err) } }
|
||||||
|
)
|
||||||
|
})
|
||||||
|
await page.locator('#iwb-editor-overlay').waitFor({ state: 'visible', timeout: 15000 })
|
||||||
|
await page.waitForFunction(() => window.__iwbEditor.__debug().open === true)
|
||||||
|
|
||||||
|
const adjFresh = await dbg()
|
||||||
|
check('退出重开:调节基准缓存清空、无残留 source 与 layerId(否则第二张图会串上一张的像素)',
|
||||||
|
adjFresh.adjustCacheSize === 0 && adjFresh.adjust.hasSource === false && adjFresh.adjust.layerId === null,
|
||||||
|
'cache=' + adjFresh.adjustCacheSize + ' layerId=' + adjFresh.adjust.layerId + ' hasSource=' + adjFresh.adjust.hasSource)
|
||||||
|
|
||||||
|
const adjBase2 = await adjStat()
|
||||||
|
await adjSet('exposure', 100)
|
||||||
|
const adjBright2 = await adjStat()
|
||||||
|
check('重开后调节以新图像素为基准:曝光 +100 正常提亮(不是把旧图重算上来)',
|
||||||
|
adjBase2 && adjBright2 && adjBright2.lum > adjBase2.lum + 25,
|
||||||
|
'亮度 ' + (adjBase2 && adjBase2.lum) + ' → ' + (adjBright2 && adjBright2.lum))
|
||||||
|
await adjReset()
|
||||||
|
|
||||||
|
await page.locator('[data-action="cancel"]').click()
|
||||||
|
|
||||||
check('无运行时错误 / 无弹窗', errors.length === 0, errors.slice(0, 3).join(' | '))
|
check('无运行时错误 / 无弹窗', errors.length === 0, errors.slice(0, 3).join(' | '))
|
||||||
|
|
||||||
await browser.close()
|
await browser.close()
|
||||||
|
|||||||
Reference in new issue
Block a user