feat(image-annotate): v1.19.0 右栏调色模块删除 + 头部一行(吸管/色值/去色/图钉)+ 16 常用色 8 列 + 最近两排
This commit is contained in:
1 parent
929b7ec2a1
commit
fdfb4ed603
9 files changed
+386
-2506
No files matched your search
@@ -277,7 +277,6 @@
|
||||
.iwb-editor-params .iwb-editor-zoom { margin-left: auto; order: 20; }
|
||||
.iwb-editor-top-colors { display: none; }
|
||||
|
||||
.iwb-editor-colors { display: flex; gap: 4px; }
|
||||
.iwb-editor-color {
|
||||
width: 20px; height: 20px;
|
||||
border-radius: 50%;
|
||||
@@ -1788,16 +1787,35 @@
|
||||
|
||||
.iwb-editor-color-pop {
|
||||
position: absolute; z-index: 60; display: flex; flex-direction: column; align-items: stretch; gap: 7px;
|
||||
/* 固定宽度(不是让内容撑):绝对定位元素是 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;
|
||||
box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
|
||||
-webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
|
||||
}
|
||||
.iwb-editor-color-pop[hidden] { display: none; }
|
||||
/* 弹层头部:说明现在调的是描边还是填充,并可直接换;右侧是「无」(仅填充) */
|
||||
/* 弹层头部(v1.19 一行装完):
|
||||
调哪个槽(描边/填充/底色)│ 吸管 + 色值 │ 去色 │ 图钉
|
||||
原来「吸管 + 色值」在右列占一整块,现在提到头部,body 的整块高度都留给色块。 */
|
||||
.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 {
|
||||
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;
|
||||
color: #a6adc8; font: 500 11.5px/1 -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
|
||||
cursor: pointer;
|
||||
@@ -1814,47 +1832,57 @@
|
||||
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; }
|
||||
/* 去色(v1.19):原来的「无」改名挪位。虚线框 + 红斜圈,和「实心色块」区分开;
|
||||
它是开关不是色块,所以不用填充色表达状态,只换边框/文字色。 */
|
||||
.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;
|
||||
font: 500 11.5px/1 -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; cursor: pointer;
|
||||
}
|
||||
.iwb-color-pop-none span {
|
||||
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 svg { flex: 0 0 auto; }
|
||||
.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[hidden] { display: none; }
|
||||
.iwb-color-pop-body { display: flex; align-items: stretch; gap: 10px; }
|
||||
.iwb-color-pop-picker { display: flex; gap: 8px; flex: 0 0 auto; }
|
||||
.iwb-editor-color-pop .iwb-color-sv { width: 176px; height: 102px; flex: 0 0 176px; }
|
||||
.iwb-editor-color-pop .iwb-color-hue { width: 16px; height: 102px; flex: 0 0 16px; }
|
||||
.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-color-pop-sep { width: 1px; align-self: stretch; background: #313244; flex: 0 0 auto; }
|
||||
|
||||
/* ==== 右列(v1.18,用户 2026-11-10)====
|
||||
设置 / 常用色 / 最近 三块竖着叠,块之间 1px 细线,不写小标题:
|
||||
原来「常用色」「最近」各占一行标题 + 横向铺开,整块面板又宽又高。
|
||||
现宽 133px(6 列 × 18px),三块高度加起来刚好填满左侧取色器的高度。 */
|
||||
/* ==== 色块区(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: space-between;
|
||||
width: 133px; flex: 0 0 133px; gap: 0;
|
||||
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 #313244; margin-top: 5px; padding-top: 5px;
|
||||
border-top: 1px solid #3b3b4e; margin-top: 5px; padding-top: 5px;
|
||||
}
|
||||
.iwb-color-pop-fields { display: flex; align-items: center; gap: 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 {
|
||||
flex: 1 1 auto; width: 0; height: 26px; padding: 0 5px; 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;
|
||||
}
|
||||
.iwb-editor-color-pop .iwb-editor-color-swatches {
|
||||
display: grid; grid-template-columns: repeat(6, 18px); grid-auto-rows: 18px;
|
||||
display: grid; grid-template-columns: repeat(8, 20px); grid-auto-rows: 20px;
|
||||
gap: 5px; flex: 0 0 auto; align-content: center;
|
||||
}
|
||||
.iwb-editor-color-pop .iwb-editor-color-panel-swatch {
|
||||
width: 18px; height: 18px; 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;
|
||||
}
|
||||
.iwb-editor-color-pop .iwb-editor-color-panel-swatch:hover { transform: scale(1.14); }
|
||||
@@ -1863,13 +1891,12 @@
|
||||
}
|
||||
.iwb-editor-color-pop .iwb-editor-color-eye { width: 26px; height: 26px; border-radius: 6px; flex: 0 0 auto; }
|
||||
|
||||
/* ==== 钉住(v1.18)====
|
||||
绝对定位到头部右上角:这样「无」按钮显隐都不会把图钉挤来挤去,
|
||||
头部加 padding-right 让出位置,两者不会叠在一起。 */
|
||||
.iwb-color-pop-head { position: relative; padding-right: 26px; }
|
||||
/* ==== 钉住(v1.18 / v1.19 改为流式)====
|
||||
v1.18 是绝对定位贴右上角(躲开「无」按钮显隐带来的位移);
|
||||
v1.19「吸管 + 色值」也进了头部,头部本来就是一排可变宽控件,
|
||||
图钉跟着流走反而更稳 —— 竖线已经把「去色 | 图钉」和左边隔开,位置不会再被误读。 */
|
||||
.iwb-color-pop-pin {
|
||||
position: absolute; right: 0; top: 50%; transform: translateY(-50%);
|
||||
width: 22px; height: 22px; padding: 0;
|
||||
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;
|
||||
@@ -2107,20 +2134,20 @@
|
||||
/* 选项栏里色块旁边的分组标签,和「描边 / 底色」这类双字按钮区分开 */
|
||||
.iwb-opt-swatch-label { color: #7f849c; font-size: 11px; flex: 0 0 auto; }
|
||||
|
||||
/* 「最近使用」:色板弹层里与常用色同一套 6 列 18px 网格(v1.18 起上限 6 个,正好一行),
|
||||
/* 「最近使用」:与常用色同一套 8 列 20px 网格(v1.19 起最多 16 个 = 铺满两排),
|
||||
空的时候整块隐藏(不占位)。 */
|
||||
.iwb-editor-color-pop .iwb-editor-recent-colors {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, 18px);
|
||||
grid-auto-rows: 18px;
|
||||
grid-template-columns: repeat(8, 20px);
|
||||
grid-auto-rows: 20px;
|
||||
gap: 5px;
|
||||
flex: 0 0 auto;
|
||||
align-content: center;
|
||||
}
|
||||
.iwb-editor-recent-colors[hidden] { display: none; }
|
||||
.iwb-editor-color-pop .iwb-editor-recent-colors .iwb-editor-color-panel-swatch {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 50%;
|
||||
@@ -2156,57 +2183,12 @@
|
||||
.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; }
|
||||
/* ---- 2) 右栏调色面板:已删(v1.19,用户 2026-11-10) ----
|
||||
颜色只剩工具栏弹层一处。弹层钉住后本来就常开,右栏那份只是重复占位。
|
||||
原来这里的 .iwb-editor-colors / .iwb-editor-colors-head / 以及一批
|
||||
`.iwb-editor-colors .iwb-color-pop-*` 覆盖规则(弹层横排、右栏竖排)全部移除 ——
|
||||
少一层「同一份 DOM 两套布局」的分支,改色板不会再出现「改了一处另一处没跟上」。 */
|
||||
|
||||
/* 弹层是横排一行;右栏窄,改成竖排:调色器全宽 → HEX 一行 → 常用色 → 最近。
|
||||
结构完全一样(同一份 DOM),差异全在这里用容器选择器覆盖。 */
|
||||
.iwb-editor-colors .iwb-color-pop-head { flex-wrap: wrap; gap: 5px; padding-right: 0; }
|
||||
/* 右栏不需要「钉住」(它本来就常驻),也不需要 v1.18 那层 side 容器:
|
||||
display:contents 把它拆掉,子元素直接参与 body 的竖排 flex,和改版前一样。 */
|
||||
.iwb-editor-colors .iwb-color-pop-pin { display: none; }
|
||||
.iwb-editor-colors .iwb-color-pop-side { display: contents; }
|
||||
.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% 下发虚。
|
||||
|
||||
@@ -10,33 +10,51 @@ import { S, runtime } from './state.js'
|
||||
import { bindEvents } from './events.js'
|
||||
|
||||
|
||||
// ============ 调色面板(两处共用) ============
|
||||
// ============ 调色面板(工具栏弹层) ============
|
||||
/**
|
||||
* v1.16:调色面板从「只能弹层」变成「右栏常驻 + 弹层保留」,两处用同一份 DOM。
|
||||
*
|
||||
* 为什么抽成函数而不是复制两段 HTML:这套控件有 4 组联动(tab 高亮、SV/色相指示点、
|
||||
* HEX 回填、常用色/最近色的 active 圈),复制两段 = 以后每加一种颜色语义都要改两遍,
|
||||
* 漏一处就是「一边改了另一边不变」。同一份结构 + 按 `[data-color-surface]` 遍历,
|
||||
* 才可能保证一致(events.js#updateColorUI 就是按 surface 逐个刷的)。
|
||||
*
|
||||
* 布局差异全部交给 CSS:弹层是横排一行,右栏窄,改成竖排(picker 全宽、色块自动换行)。
|
||||
* v1.19:右栏常驻面板删掉,只剩工具栏弹层这一份(钉住后它本来就是常开的)。
|
||||
* 仍抽成函数而不是写在模板里:这套控件有 4 组联动(tab 高亮、SV/色相指示点、
|
||||
* HEX 回填、常用色/最近色的 active 圈),events.js#updateColorUI 按
|
||||
* `[data-color-surface]` 逐个刷 —— 留着这层抽象,将来若再加一处面板不用重写联动。
|
||||
*/
|
||||
/* 16 个常用色 = 色板里 8 列 × 2 行(v1.19)。
|
||||
排布刻意成对:第一行是 8 个饱和亮色(红橙黄绿青蓝紫粉),
|
||||
第二行是 4 个中性色(白/浅灰/中灰/黑)+ 4 个同色系「深一档」,
|
||||
深红/深绿/深蓝/深紫 在浅色底图上比亮色稳,做描边不刺眼。 */
|
||||
const COMMON_COLORS = [
|
||||
'#ff4444', '#ff8a00', '#ffd400', '#4cd964', '#00bfa5', '#4488ff',
|
||||
'#aa44ff', '#ff66aa', '#ffffff', '#d0d0d0', '#808080', '#000000'
|
||||
'#ff4444', '#ff8a00', '#ffd400', '#4cd964', '#00bfa5', '#4488ff', '#aa44ff', '#ff66aa',
|
||||
'#ffffff', '#d0d0d0', '#808080', '#000000', '#c0392b', '#0f9d58', '#1677ff', '#6b4fbb'
|
||||
]
|
||||
|
||||
/** 色板面板(v1.19 起只有工具栏弹层一份,右栏常驻面板已删)
|
||||
*
|
||||
* 头部一行:调哪个槽(描边/填充/底色)│ 吸管 + 色值 │ 去色 │ 图钉
|
||||
* 把「吸管 + 色值」提到头部,是为了让下面整块高度都留给色块:
|
||||
* 常用色 2 排 + 最近色 2 排,一屏就能点到,不用滚动、也不用二次点开。
|
||||
*/
|
||||
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>
|
||||
<!-- 钉住(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 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 class="iwb-color-pop-body">
|
||||
<div class="iwb-color-pop-picker">
|
||||
@@ -44,14 +62,10 @@ import { bindEvents } from './events.js'
|
||||
<div class="iwb-color-hue"><span></span></div>
|
||||
</div>
|
||||
<span class="iwb-color-pop-sep"></span>
|
||||
<!-- 右侧竖列(v1.18):设置 → 常用色 → 最近,三块上下叠,块间用 1px 细线分隔,
|
||||
不再写「常用色 / 最近」小标题 —— 标题各占一行,是这块面板最浪费的高度。
|
||||
右栏常驻面板复用同一份 DOM,那边用 display:contents 拆掉这一层,走自己的竖排。 -->
|
||||
<!-- 色块区(v1.19):常用色 8×2 在上、最近色 8×2 在下,中间 1px 细线分隔。
|
||||
不写「常用色 / 最近」小标题 —— 每个色块的 title 已经写明是哪一个,
|
||||
而标题要各占一行,是这块面板最浪费的高度(v1.18 已这么定,v1.19 沿用)。 -->
|
||||
<div class="iwb-color-pop-side">
|
||||
<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>
|
||||
<div class="iwb-color-group">
|
||||
<span class="iwb-color-group-label">常用色</span>
|
||||
<div class="iwb-editor-color-swatches">
|
||||
@@ -236,19 +250,11 @@ import { bindEvents } from './events.js'
|
||||
<!-- 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):
|
||||
侧栏只留快速效果 + 缩放;色板 DOM 在 modal 末尾的 .iwb-editor-color-pop -->
|
||||
<!-- 右栏常驻调色面板已删(v1.19,用户 2026-11-10:「右边栏的调色模块就可以去掉了」)。
|
||||
理由:弹层钉住之后它一直是开着的,右栏那份同样内容只是在跟弹层抢注意力,
|
||||
还白占一块最显眼的位置。颜色只剩弹层一处(modal 末尾 .iwb-editor-color-pop),
|
||||
右栏现在从「图片调节」直接开始。 -->
|
||||
|
||||
<!-- 图片调节(v1.15):连续调色,作用于当前位图图层(默认原图)。
|
||||
行由 adjust.js#mountAdjustPanel() 按 ADJUST_DEFS 生成 —— 参数表只维护一份,
|
||||
不在 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)
|
||||
})
|
||||
// 「无」:形状/钢笔 = 无描边或无填充;文字描边 = 描边宽度 0;文字底色 = 关掉底色块
|
||||
// (文字色与箭头单槽没有「无」—— 去掉就等于把对象删了,不该给这个按钮)
|
||||
// v1.16:右栏与弹层各有一个「无」,必须按集合刷,否则只有先出现的那个对
|
||||
// 「去色」(v1.19 前叫「无」):形状/钢笔 = 无描边或无填充;文字描边 = 描边宽度 0;文字底色 = 关掉底色块
|
||||
// (文字色与箭头单槽没有「去色」—— 去掉就等于把对象删了,不该给这个按钮)
|
||||
// 按集合刷(原来是右栏 + 弹层各一个,现在只剩弹层一个,写法保持不变以免将来再加面板时漏刷)
|
||||
const onBg = S.colorTarget === 'bg' && isText
|
||||
const onFill = S.colorTarget === 'fill' && second
|
||||
const onStroke = S.colorTarget === 'stroke' && !isText && strokeSlotCanBeNone()
|
||||
@@ -1066,10 +1066,10 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
noneBtn.hidden = !showNone
|
||||
noneBtn.classList.toggle('active', showNone && (onBg ? !sl.bgOn : (onFill ? !sl.fillOn : !sl.strokeOn)))
|
||||
noneBtn.title = onBg
|
||||
? '无底色:文字后面完全透明'
|
||||
? '去色:文字后面完全透明(无底色)'
|
||||
: (onStroke
|
||||
? (sl.strokeOn === false ? '当前已是无描边;点选颜色可恢复描边' : '无描边:去掉形状外框,只留内部填充')
|
||||
: (isText ? '无描边:把描边宽度置 0,只留文字本身' : '无填充:形状内部透明,只留描边'))
|
||||
? (sl.strokeOn === false ? '当前已是无描边;点选颜色可恢复描边' : '去色:去掉形状外框,只留内部填充')
|
||||
: (isText ? '去色:把描边宽度置 0,只留文字本身' : '去色:形状内部透明,只留描边'))
|
||||
})
|
||||
|
||||
const cur = activeColor()
|
||||
@@ -1079,7 +1079,7 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
if (on) matchPreset = true
|
||||
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-input').forEach(inp => {
|
||||
if (document.activeElement !== inp) inp.value = cur.toUpperCase()
|
||||
@@ -2320,10 +2320,9 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
}
|
||||
}
|
||||
|
||||
/** 调色面板(v1.3 弹层 → v1.16 弹层 + 右栏常驻):
|
||||
* 两处是同一份 DOM(dom.js#colorSurfaceHtml),按 [data-color-surface] 逐个绑定。
|
||||
* 每个 surface 各自持有一份 HSV 拖拽状态,但取值一律从 activeColor() 现算,
|
||||
* 所以「在右栏取色、再去弹层拖 SV」不会跳色。 */
|
||||
/** 调色面板(v1.3 弹层 → v1.16 弹层 + 右栏常驻 → v1.19 只剩弹层):
|
||||
* 结构来自 dom.js#colorSurfaceHtml,按 [data-color-surface] 逐个绑定。
|
||||
* 每个 surface 各自持有一份 HSV 拖拽状态,但取值一律从 activeColor() 现算。 */
|
||||
function bindColorPanel() {
|
||||
const pop = runtime.el.querySelector('.iwb-editor-color-pop')
|
||||
const colorBtns = [...runtime.el.querySelectorAll('[data-action="toggleColorPop"]')]
|
||||
@@ -2333,7 +2332,7 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
})
|
||||
if (pop) {
|
||||
// 点外面关闭:必须用捕获阶段 —— 画布的 mousedown 会 preventDefault,
|
||||
// 冒泡阶段拿不到「点了外面」这件事。右栏面板常驻,不参与关闭。
|
||||
// 冒泡阶段拿不到「点了外面」这件事。
|
||||
// 钉住时一律不关:这就是「钉住」的全部意义(要收就再点一次图钉,或按 Esc)。
|
||||
document.addEventListener('mousedown', (e) => {
|
||||
if (S.colorPopPinned) return
|
||||
@@ -2376,7 +2375,7 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
const palettePick = surface.querySelector('[data-action="palettePick"]')
|
||||
if (palettePick) {
|
||||
palettePick.addEventListener('mousedown', (e) => e.stopPropagation())
|
||||
// 取色要回画布点,弹层必须先收起,否则它会挡住取样点(右栏面板在画布外,不挡)
|
||||
// 取色要回画布点,弹层必须先收起,否则它会挡住取样点
|
||||
palettePick.addEventListener('click', () => { closeColorPop(); setTool('picker') })
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* recent-colors.js - 最近使用颜色(v1.9)
|
||||
*
|
||||
* 只依赖 state.js(叶子模块):tools.js 在改色时调用 rememberColor(),
|
||||
* color pop 打开时 renderRecentColors() 把最近 6 个色块铺出来。
|
||||
* color pop 打开时 renderRecentColors() 把最近的色块铺出来。
|
||||
* 持久化走宿主 ctx.settings(小 KV,不放像素,符合宿主存储约定)。
|
||||
*/
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
import { S, runtime } from './state.js'
|
||||
|
||||
// v1.18:上限从 8 收到 6 —— 色板弹层右列改成 6 列网格(和「常用色」同一套),
|
||||
// 6 个正好一行;8 个会折成第二行,把整块面板撑高 23px,和「更紧凑」的目标相反。
|
||||
const MAX = 6
|
||||
// v1.19:上限 6 → 16。色板弹层改成 8 列网格,16 个正好铺满两排
|
||||
// (v1.18 为「更紧凑」收到 6,是因为当时只有一排的空间;吸管+色值移到头部后省出这一排)。
|
||||
const MAX = 16
|
||||
const KEY = 'recentColors'
|
||||
|
||||
function valid(hex) {
|
||||
@@ -47,7 +47,6 @@ import { S, runtime } from './state.js'
|
||||
|
||||
export function renderRecentColors() {
|
||||
if (!runtime.el) return
|
||||
// v1.16:右栏常驻面板与工具栏弹层各有一份,按集合刷
|
||||
const wraps = runtime.el.querySelectorAll('.iwb-editor-recent-colors')
|
||||
if (!wraps.length) return
|
||||
const list = S.recentColors || []
|
||||
@@ -57,8 +56,7 @@ export function renderRecentColors() {
|
||||
wraps.forEach(wrap => {
|
||||
wrap.innerHTML = html
|
||||
wrap.hidden = !list.length
|
||||
// v1.16:右栏给了一组加了「最近」小标题,没有最近色时整组一起藏,
|
||||
// 否则标题下面留一块空白,看起来像没加载出来。
|
||||
// 没有最近色时整组一起藏,否则下面留一块空白,看起来像没加载出来
|
||||
const group = wrap.closest('.iwb-color-group')
|
||||
if (group) group.hidden = !list.length
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user