feat(image-annotate): v1.20.0 去色下移为常用色第一格 + 头部控件全部定宽(不再被 flex 抵掉)

- 去色:头部按钮 → 常用色网格第一格(20px 同尺寸、虚线圆 + 斜圈)
- 不可用上下文(文字色 / 未闭合钢笔)不再 hidden,改 disabled + 42% 不透明度,title 说明原因
- 头部定宽:色值框 flex 0 0 124px(原 0 1 150)、加「底色」tab 后色值框与图钉位置不动
- 常用色 16 → 15(亮紫让位,深紫保留),去色 + 15 = 8 列 2 行
- 删掉 :has(...[hidden]) 隐藏竖线的规则,头部结构变纯静态
- harness 231 项 / 真站 e2e 40 项
This commit is contained in:
qiqi committed 2026-11-10 07:54:32 +08:00
1 parent 00a2699e89
commit d16e68bfa9
8 files changed
+209 -111

No files matched your search

+9 -4
View File
@@ -256,6 +256,7 @@ if (!SKIP_PASTE) {
return { c: b.top + b.height / 2, l: b.left, r: b.right }
})
const sw = [...pop.querySelectorAll('.iwb-editor-color-swatches [data-panel-color]')]
const grid = pop.querySelector('.iwb-editor-color-swatches')
return {
w: Math.round(r(pop).width),
sameRow: items.every((it) =>
@@ -263,11 +264,14 @@ if (!SKIP_PASTE) {
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,
// v1.20:去色占常用色第一格(20px 同尺寸、第一排最左)
noneFirst: grid.children[0] === pop.querySelector('[data-color-none]'),
cells: grid.children.length,
}
})
check('色板弹层:头部一行(吸管 / 色值 / 图钉同排)+ 常用色 16 个 8 列',
Boolean(popShape) && popShape.sameRow && popShape.common === 16 &&
popShape.cols === 8 && popShape.swatch === 20 && popShape.w === 440,
check('色板弹层:头部一行(吸管 / 色值 / 图钉同排)+ 去色占常用色第一格 + 15 色 8 列',
Boolean(popShape) && popShape.sameRow && popShape.noneFirst && popShape.cells === 16 &&
popShape.common === 15 && popShape.cols === 8 && popShape.swatch === 20 && popShape.w === 440,
JSON.stringify(popShape))
await page.keyboard.press('Escape')
await page.waitForTimeout(140)
@@ -301,7 +305,8 @@ if (!SKIP_PASTE) {
await page.waitForTimeout(250)
const noneOnStroke = await page.evaluate(() => {
const n = document.querySelector('.iwb-editor-color-pop [data-color-none]')
return Boolean(n) && !n.hidden
// v1.20:去色不再 hidden,改用 disabled 表达「这个上下文不能去色」
return Boolean(n) && Boolean(n.offsetParent) && !n.disabled
})
await page.evaluate(() => document.querySelector('.iwb-editor-color-pop [data-color-none]').click())
await page.waitForTimeout(300)
+85 -49
View File
@@ -140,13 +140,15 @@ check('打开编辑器默认只有「原图」1 层,且状态栏不再写「
// v1.3(用户裁定 2026-11-05):调色板从侧栏搬进工具栏弹层,侧栏只剩缩放
// v1.19(用户 2026-11-10):右栏那份常驻调色面板删掉,颜色只剩弹层一处
check('调色板只在工具栏弹层:右栏没有调色模块,SV/色相/16 个常用色都在弹层里',
check('调色板只在工具栏弹层:右栏没有调色模块,SV/色相/去色 + 15 个常用色都在弹层里',
await page.evaluate(() => {
const q = (s) => Boolean(document.querySelector(s))
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-color-pop .iwb-color-sv') && q('.iwb-editor-color-pop .iwb-color-hue') &&
document.querySelectorAll('.iwb-editor-color-pop .iwb-editor-color-swatches [data-panel-color]').length === 16 &&
// v1.20:去色进网格占第一格,所以 data-panel-color 只剩 15 个(+ 去色 = 16 格)
document.querySelectorAll('.iwb-editor-color-pop .iwb-editor-color-swatches [data-panel-color]').length === 15 &&
q('.iwb-editor-color-pop .iwb-editor-color-swatches [data-color-none]') &&
q('.iwb-editor-zoom') &&
!q('.iwb-editor-brush-size') && !q('.iwb-editor-brush-num') &&
document.querySelectorAll('.iwb-editor-brush-preset').length === 0
@@ -194,10 +196,12 @@ check('色板弹层默认收起;点工具栏色点弹出、且整块在视口
return inView && !(await pop.isVisible()) ? true : 'box=' + JSON.stringify(box)
})())
// ---------- v1.18 / v1.19 色板弹层布局(用户 2026-11-10) ----------
// ---------- v1.18 / v1.19 / v1.20 色板弹层布局(用户 2026-11-10) ----------
// v1.18:「加钉住」「三项不写标题、用细横线分割」
// v1.19:「去色放钉住左边、竖线分割」「吸色与色值放在钉住那一排」「宽度再多一点,
// 颜色一排 8 个,常用色多加 4 个」「最近色放两排」
// v1.20:文字工具多出「底色」tab 时头部挤爆,把「去色」整颗抵没了 ——
// 改成去色占常用色第一格(永远在,不可用只置灰),头部元素全部定宽。
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)
@@ -205,48 +209,48 @@ 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 grid = pop.querySelector('.iwb-editor-color-swatches')
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 headEl = pop.querySelector('.iwb-color-pop-head')
const head = r(headEl)
const eye = pop.querySelector('[data-action="palettePick"]')
const hex = pop.querySelector('.iwb-editor-color-hex-input')
const pin = pop.querySelector('[data-action="pinColorPop"]')
// 头部一行:吸管 / 色值 / 去色 / 图钉 的竖直中心都必须落在头部这条线上
const sw = [...pop.querySelectorAll('.iwb-editor-color-swatches [data-panel-color]')]
// 去色现在是常用色网格的第一格:位置固定、尺寸和其它色块一致
const noneFirstCell = grid.children[0] === none
const noneSameSize = Math.abs(r(none).width - r(sw[0]).width) < 1 &&
Math.abs(r(none).height - r(sw[0]).height) < 1
const noneRow1 = Math.round(r(none).top) === Math.round(r(sw[0]).top) &&
Math.round(r(none).left) < Math.round(r(sw[0]).left)
// 头部一行:吸管 / 色值 / 图钉 的竖直中心都必须落在头部这条线上
const cy = (el) => r(el).top + r(el).height / 2
const headOneRow = [eye, hex, none, pin].every((el) =>
const headOneRow = [eye, hex, 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(三格同显):临时显出来验头部不横扫溢出,
// 否则「吸管 + 色值 + 去色 + 图钉」在窄面板里会把图钉挤出弹层。
// 定宽验收:文字工具会多出「底色」tab,头部宽度必须不变形 ——
// 色值框宽度与图钉右边缘在「两 tab / 三 tab」两种上下文下要完全一致,
// 这条就是用户截图那次 bug 的回归断言(当时去色被 flex 抵掉、色值框从 150 缩到 147)。
const hexW2 = Math.round(r(hex).width)
const pinR2 = Math.round(r(pin).right)
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
const hexW3 = Math.round(r(hex).width)
const pinR3 = Math.round(r(pin).right)
// 注意用元素本身读 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 headFitsThreeTabs = headEl.scrollWidth <= headEl.clientWidth + 1 && r(pin).right <= head.right + 1
const headDbg = {
client: pop.querySelector('.iwb-color-pop-head').clientWidth,
scroll: pop.querySelector('.iwb-color-pop-head').scrollWidth,
client: headEl.clientWidth, scroll: headEl.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),
hex: hexW3, popW: Math.round(r(pop).width),
headRight: Math.round(head.right), pinR: pinR3,
}
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))
const row1 = sw.slice(0, 7).map((b) => Math.round(r(b).top))
const row2 = sw.slice(7).map((b) => Math.round(r(b).top))
// 「最近」没有历史色时整组(含外层 group)都是 hidden,量不出网格;
// 这里临时铺满 16 个量完再还原 —— 只解 wrap 的 hidden 不够,外层还压着一层
const rec = pop.querySelector('.iwb-editor-recent-colors')
@@ -272,28 +276,32 @@ const popLayout = await page.evaluate(() => {
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)),
items: [eye, hex, 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,
noneFirstCell, noneSameSize, noneRow1,
headFitsThreeTabs, headFixed: hexW2 === hexW3 && pinR2 === pinR3,
hexW: [hexW2, hexW3], pinR: [pinR2, pinR3], 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],
// 8 列 × 2 行:13 个常用色 + 第一格去色 = 16 格,两排各 8
twoRows: row1.length === 7 && row2.length === 8 &&
new Set(row1).size === 1 && new Set(row2).size === 1 && row1[0] < row2[0] &&
grid.children.length === 16,
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,
check('色板头部一行装完:吸管 + 色值 + 图钉同一排,且加「底色」tab 后色值框与图钉位置纹丝不动',
popLayout.headOneRow && popLayout.headFitsThreeTabs && popLayout.headFixed,
JSON.stringify(popLayout))
check('常用色 8 列 × 2 行(16 个),最近色也是 8 列两排,块间 1px 细线且无小标题',
popLayout.common === 16 && popLayout.twoRows && popLayout.cols === 8 &&
check('「去色」是常用色的第一格(20px 同尺寸、第一排最左),不再挂在头部',
popLayout.noneFirstCell && popLayout.noneSameSize && popLayout.noneRow1,
JSON.stringify({ first: popLayout.noneFirstCell, size: popLayout.noneSameSize, row: popLayout.noneRow1, sw: popLayout.swatch }))
check('常用色 8 列 × 2 行(去色 + 15 色 = 16 格),最近色也是 8 列两排,块间 1px 细线且无小标题',
popLayout.common === 15 && popLayout.twoRows && popLayout.cols === 8 &&
popLayout.recCols === 8 && popLayout.recRows === 2 &&
popLayout.labelsVisible === 0 && popLayout.dividers.every((d) => d === '1px'),
JSON.stringify(popLayout))
@@ -2135,12 +2143,35 @@ const popTextTarget = await page.evaluate(() => {
fillActive: tab.classList.contains('active'),
fillLabel: tab.querySelector('.iwb-color-pop-tab-label').textContent,
bgVisible: !bgTab.hidden,
noneVisible: !pop.querySelector('[data-color-none]').hidden
// v1.20:去色不再 hidden,改成「在不在 + 能不能用」
noneVisible: !!pop.querySelector('[data-color-none]').offsetParent,
noneUsable: !pop.querySelector('[data-color-none]').disabled
}
})
check('点文字的「描边」格:色板目标是描边(tab 写「描边」),底色 tab 同时可选',
check('点文字的「描边」格:色板目标是描边(tab 写「描边」),底色 tab 同时可选,去色可用',
popTextTarget.open && popTextTarget.fillActive && popTextTarget.fillLabel === '描边' &&
popTextTarget.bgVisible && popTextTarget.noneVisible, JSON.stringify(popTextTarget))
popTextTarget.bgVisible && popTextTarget.noneVisible && popTextTarget.noneUsable,
JSON.stringify(popTextTarget))
// v1.20(用户 2026-11-10 截图):文字色这一格去不掉色,但按钮必须**留在原位变灰**,
// 不能整颗消失 —— 消失会让色板每切一次工具就重排,位置记不住。
await page.locator('.iwb-editor-color-btn[data-color-slot="stroke"]').click()
await page.waitForTimeout(200)
const noneDisabledOnTextColor = await page.evaluate(() => {
const n = document.querySelector('.iwb-editor-color-pop [data-color-none]')
return {
visible: !!n.offsetParent, disabled: n.disabled, dim: Number(getComputedStyle(n).opacity),
title: n.title, bgTabStillHidden: document.querySelector('.iwb-color-pop-tab[data-color-slot="bg"]').hidden
}
})
check('文字色上下文:去色仍在第一格、只是置灰 disabled(说明原因),不整颗消失',
noneDisabledOnTextColor.visible && noneDisabledOnTextColor.disabled &&
noneDisabledOnTextColor.dim < 0.6 && /去色不可用/.test(noneDisabledOnTextColor.title),
JSON.stringify(noneDisabledOnTextColor))
// 开发用:ANNOT_SHOT3=/tmp/pop-text.png 出「文字工具三 tab + 去色置灰」的效果图(用户截图那个场景)
if (process.env.ANNOT_SHOT3) await page.locator('.iwb-editor-color-pop').screenshot({ path: process.env.ANNOT_SHOT3 })
await page.locator('.iwb-editor-color-btn[data-color-slot="fill"]').click()
await page.waitForTimeout(200)
await page.evaluate(() => {
const el = document.querySelector('.iwb-editor-color-pop .iwb-editor-color-hex-input')
@@ -2582,11 +2613,13 @@ const popTarget = await page.evaluate(() => {
return {
open: !pop.hidden,
fillActive: pop.querySelector('.iwb-color-pop-tab[data-color-slot="fill"]').classList.contains('active'),
noneVisible: !pop.querySelector('[data-color-none]').hidden
noneVisible: !!pop.querySelector('[data-color-none]').offsetParent,
noneUsable: !pop.querySelector('[data-color-none]').disabled
}
})
check('点填充槽打开色板:目标是填充,并出现「无」按钮',
popTarget.open && popTarget.fillActive && popTarget.noneVisible, JSON.stringify(popTarget))
check('点填充槽打开色板:目标是填充,去色在第一格且可用',
popTarget.open && popTarget.fillActive && popTarget.noneVisible && popTarget.noneUsable,
JSON.stringify(popTarget))
// 用一个画布上不会出现的怪色(#a014b2)验收:12 个推荐色在前面用例里都用过,
// 拿黄色/绿色统计会数到别的图形,永远清不到 0。
@@ -2746,7 +2779,8 @@ const selectedShapeState = () => page.evaluate(() => {
color: s && s.color, fillColor: s && s.fillColor,
strokeBtnNone: !!btn && btn.classList.contains('is-none'),
optOff: !!opt && opt.classList.contains('is-off'),
noneHidden: !none || none.hidden,
// v1.20:去色永远在,只是不可用时 disabled(灰色),所以断言的是「能不能用」不是「在不在」
noneDisabled: !none || none.disabled,
noneActive: !!none && none.classList.contains('active')
}
})
@@ -2772,7 +2806,9 @@ const magentaBefore = await magentaPerCanvas()
await page.locator('.iwb-editor-color-btn[data-color-slot="stroke"]').click()
await page.waitForTimeout(220)
const noneShownOnStroke = await page.evaluate(() =>
!document.querySelector('.iwb-editor-color-pop [data-color-none]').hidden)
!document.querySelector('.iwb-editor-color-pop [data-color-none]').disabled)
// 开发用:ANNOT_SHOT4=/tmp/pop-none.png 出「去色可用态」的效果图(形状描边上下文)
if (process.env.ANNOT_SHOT4) await page.locator('.iwb-editor-color-pop').screenshot({ path: process.env.ANNOT_SHOT4 })
await page.evaluate(() => document.querySelector('.iwb-editor-color-pop [data-color-none]').click())
await page.waitForTimeout(320)
const noStroke = await selectedShapeState()
@@ -2849,8 +2885,8 @@ await page.waitForTimeout(280)
await page.locator('.iwb-editor-color-btn[data-color-slot="stroke"]').click()
await page.waitForTimeout(220)
const openPen = await selectedShapeState()
check('未闭合钢笔不给「无描边」(去掉等于把这条线删了)',
openPen.type === 'pen' && openPen.closed === false && openPen.noneHidden === true,
check('未闭合钢笔不给「无描边」(去掉等于把这条线删了):去色留在原位但置灰',
openPen.type === 'pen' && openPen.closed === false && openPen.noneDisabled === true,
JSON.stringify(openPen))
// ---- 一边无色也能交换(用户反馈的第二个问题)----