fix(drop): disable a spent button and mark it, so both drag paths agree
A file from the file manager arrives through the native drag channel, where wry fixes the macOS drag operation to Copy, so the cursor could never carry the refusal. The answer now lives on the button: it is disabled for the length of the gesture, shows a prohibition sign over its own label, and takes no hover feedback. A Recent row also stops being reported as 'no files' by the native enter, which had lit all three buttons for a file two of them could not serve.main
parent
f625832856
commit
cb758c6a03
|
|
@ -72,7 +72,7 @@ Shift lives in the menu bar (macOS) and the notification area (Windows), and it
|
|||
|
||||
**Use a tool (`Option + Shift`, or `Alt + Shift` on Windows).** Same gesture, and the wedges become tools for that file type instead of formats. While the ring is open, keep `Shift` held and press or release `Option`/`Alt` to flip between the format ring and the tool ring.
|
||||
|
||||
**Prefer not to drag?** In the main window, **Convert files** and **File tools** open a picker and then show the same ring for what you chose; **OCR** picks an image and reads it. Dropping a file is **aimed**: the three buttons are the only drop targets, and the button you release on is the action it runs - **Convert files** opens the format ring, **File tools** the tool ring, **OCR** reads the image. All three light up as candidates while a drag is in flight, and only they react: the panel around them stays still. Release anywhere else and nothing happens at all. A button that cannot serve the file you are dragging goes grey for the length of the gesture - **OCR** for anything that is not an image, **Convert files** for a format with nothing to convert it into - and hovering it shows a forbidden cursor and edge. That refusal is visible before release: the drop does nothing, silently, instead of opening an empty ring or handing the file to another ring. **File tools** never greys out, because its ring ends in Open, Reveal and Send. The same rule decides a drop in every case, whichever platform you are on and whether the file came from the file manager or from the Recent list.
|
||||
**Prefer not to drag?** In the main window, **Convert files** and **File tools** open a picker and then show the same ring for what you chose; **OCR** picks an image and reads it. Dropping a file is **aimed**: the three buttons are the only drop targets, and the button you release on is the action it runs - **Convert files** opens the format ring, **File tools** the tool ring, **OCR** reads the image. All three light up as candidates while a drag is in flight, and only they react: the panel around them stays still. Release anywhere else and nothing happens at all. A button that cannot serve the file you are dragging is **switched off for the length of the gesture** and carries a prohibition sign over its own label - **OCR** for anything that is not an image, **Convert files** for a format with nothing to convert it into. A switched-off button takes no hover feedback at all, and releasing on it does nothing, silently: no empty ring, no handover to another ring, no message. **File tools** never switches off, because its ring ends in Open, Reveal and Send. The same rule, and the same look, decide a drop in every case - whichever platform you are on, and whether the file came from the file manager or from the Recent list.
|
||||
|
||||
**Several files at once.** Multi-select with `⌘`/`Ctrl`-click, then drag. Every file is processed. With 2+ images or 2+ PDFs selected, a **Merge** wedge appears that combines them into a single PDF.
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ Shift 常驻菜单栏(macOS)与通知区域(Windows),同时也有普
|
|||
|
||||
**使用工具(`Option + Shift`,Windows 为 `Alt + Shift`)** 操作相同,扇区会从格式换成该类型文件可用的工具。圆环打开时,保持按住 `Shift`,再按下或松开 `Option`/`Alt`,即可在格式环与工具环之间来回切换。
|
||||
|
||||
**不想拖动?** 主窗口中的「文件转换」与「文件工具」会先让你挑选文件,然后对选中的文件弹出同一个圆环;「文字识别」则选取图片并识别。拖放文件必须**对准按钮**:三个按钮是唯一的落点,松开在哪个按钮上就执行那个按钮的动作——「文件转换」打开格式环,「文件工具」打开工具环,「文字识别」直接识别图片。拖拽进行中三个按钮会同时显示为候选落点,并且只有按钮会响应,周围的面板保持静止;松开在其他位置什么都不会发生。**处理不了的按钮会在这次拖拽期间变灰**:不是图片的文件会让「文字识别」变灰,没有任何可转换目标的格式会让「文件转换」变灰;指针移到这个按钮上时,光标与按钮边缘都会显示禁止。拒绝在松手前就可见——松手时什么都不执行,安静地不做,既不会弹出一个空圆环,也不会转交给别的圆环。「文件工具」永远不变灰,因为它的环里总有打开、在文件夹中显示与发送。同一条规则在所有平台上、无论文件来自访达/资源管理器还是「最近使用」,判定结果都一致。右侧「最近使用」里的条目同样可以拖到这三个按钮上,用同一次拖拽复用已经处理过的文件。
|
||||
**不想拖动?** 主窗口中的「文件转换」与「文件工具」会先让你挑选文件,然后对选中的文件弹出同一个圆环;「文字识别」则选取图片并识别。拖放文件必须**对准按钮**:三个按钮是唯一的落点,松开在哪个按钮上就执行那个按钮的动作——「文件转换」打开格式环,「文件工具」打开工具环,「文字识别」直接识别图片。拖拽进行中三个按钮会同时显示为候选落点,并且只有按钮会响应,周围的面板保持静止;松开在其他位置什么都不会发生。**处理不了的按钮会在这次拖拽期间被直接禁用,并在按钮上层显示禁止符号**:不是图片的文件会禁用「文字识别」,没有任何可转换目标的格式会禁用「文件转换」。被禁用的按钮没有任何 hover 反馈,松手时什么都不执行、安静地不做,既不会弹出一个空圆环,也不会转交给别的圆环,也不会弹提示。「文件工具」永远不会被禁用,因为它的环里总有打开、在文件夹中显示与发送。同一条规则、同一种观感,在所有平台上、无论文件来自访达/资源管理器还是「最近使用」,判定结果都一致。右侧「最近使用」里的条目同样可以拖到这三个按钮上,用同一次拖拽复用已经处理过的文件。
|
||||
|
||||
**一次处理多个文件。** 用 `⌘`/`Ctrl` 点选多个文件后一起拖动,每个文件都会被处理。选中 2 张以上图片或 2 个以上 PDF 时,会出现「合并」扇区,把它们合成一个 PDF。
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
| 0.1.8 | 最近文件改为收藏并移除拖回主操作按钮的交互;Windows 增加单实例保护;macOS DOCX→PDF 改用 Quick Look 源,保留页眉、页脚与装订版式。 |
|
||||
| 0.1.9 | 重新支持把「最近使用」拖回三个主操作按钮,并且**按钮是唯一落点**——松开在面板其他位置不执行任何操作(见「『最近使用』拖回主面板的三个按钮」);设置面板字号统一到 `--text-*` 阶梯;取消「截图后」行为选项,固定为结果卡片;修复 macOS「运行组件」把 AppKit 文档渲染器报成 Pandoc 缺失且没有安装入口的回归。 |
|
||||
| 0.1.10 | 拖放反馈收束到按钮:面板自身不再做拖拽动画,松开在非按钮处彻底静默(去掉 0.1.9 的提示浮层);「文字识别」对非图片直接拒绝,不再退回格式环;托盘「识别图片文字…」改为「文字识别」。 |
|
||||
| 0.1.11 | Windows 实测「最近使用」拖到三个按钮全部完不成:页内文件拖拽在 WebView2 上 DOM 与原生两条投递路径都可能不上报,改由 `dragEnd` 兜底;开始拖动时先让闲置圆环让开,它无边框且始终置顶,正压在按钮上(两节都在「『最近使用』拖回主面板的三个按钮」里)。三个按钮的可用性判定收进 `src/lib/dropCapabilities.ts`,两种语言、两条投递路径共用一条"能处理就处理,不能处理就禁止"的规则。局域网接收的文件从此也受「完成后在访达中显示」控制,一批只在最后一个落地时显示一次;「运行组件」缺失多项时可以一次装完。 |
|
||||
| 0.1.11 | Windows 实测「最近使用」拖到三个按钮全部完不成:页内文件拖拽在 WebView2 上 DOM 与原生两条投递路径都可能不上报,改由 `dragEnd` 兜底;开始拖动时先让闲置圆环让开,它无边框且始终置顶,正压在按钮上(两节都在「『最近使用』拖回主面板的三个按钮」里)。三个按钮的可用性判定收进 `src/lib/dropCapabilities.ts`,两种语言、两条投递路径共用一条"能处理就处理,不能处理就禁止"的规则。同一节里另有两处:内部拖拽被原生 `enter` 报成"没有文件"、从而三个按钮全部点亮(`dragPathsKnown()` 改为合并),以及禁止态从"变灰+系统光标"改成**按钮禁用加上层禁止符号**(原生通道的光标由 wry 固定成 Copy,页面改不动)。局域网接收的文件从此也受「完成后在访达中显示」控制,一批只在最后一个落地时显示一次;「运行组件」缺失多项时可以一次装完。 |
|
||||
|
||||
历史提交可以这样定位:
|
||||
|
||||
|
|
@ -424,11 +424,43 @@ N 个组件」,行内的单个安装按钮保持原样,两种入口调用同
|
|||
|
||||
「文字识别」的拒绝方式在同一步收紧里改成了**事前可见**:0.1.10 用提示说明"这个格式识别不了",
|
||||
但那仍是让用户先做错、再由浮层告知。现在拖拽一开始就按携带的文件判定,识别不了的按钮直接进入
|
||||
不可用态(`is-drop-unavailable`,`aria-disabled`,与全应用统一的 `--dimmed` 一致);指针落在
|
||||
这个按钮上时再加 `is-drop-forbidden` 与系统的禁止光标,松手时什么都不发生,也不再有任何提示。
|
||||
不可用态,松手时什么都不发生,也不再有任何提示。
|
||||
|
||||
**不可用态必须写成"禁用 + 按钮上层的禁止符号",不能只靠光标。** 0.1.11 第一次实现时把拒绝交给
|
||||
了系统光标(`dropEffect: "none"`)与一圈红边,实测两条投递路径的观感并不一致:页内拖拽能改
|
||||
`dropEffect`,而外部文件走的是原生拖放通道,**macOS 下 wry 的 `draggingUpdated` 固定回报
|
||||
`NSDragOperation::Copy`**(`wry/src/wkwebview/drag_drop.rs`),页面根本没有机会把光标改成禁止。
|
||||
于是同一个 PDF,从列表拖过去是禁止光标、从访达拖过去是"可复制",用户读到的仍是"看着能放、
|
||||
松手没反应"。结论:**拒绝必须画在按钮自己身上**,因为按钮的渲染不受拖放通道影响。现在
|
||||
`is-drop-unavailable` 直接把按钮 `disabled`,并用 `.drop-ban` 在按钮上层画禁止符号(圆+斜杠用
|
||||
CSS 画,不用图标字体,保证任何缩放下都锐利)。
|
||||
|
||||
**按钮变暗用自身配色,不用 `opacity`。** 全应用统一的禁用样式是 `opacity: var(--dimmed)`,但
|
||||
禁止符号是画在按钮之上的,连按钮一起调暗会把符号一起调淡——而符号才是必须被看清的那一层。
|
||||
所以 `is-drop-unavailable` 改用 `color` / `background` 弱化,符号保持满不透明度。
|
||||
|
||||
**`is-drop-unavailable` 必须 `pointer-events: none`。** 落点由坐标命中(`actionAtPoint`)而不是
|
||||
由"哪个元素回答了事件"决定;禁用按钮若仍占住命中区,`disabled` 后的按钮不再回应拖拽事件,
|
||||
手势会停在最后一个应答过的按钮上。把它让开,命中判定与视觉状态才可能一致,顺带让 hover 反馈
|
||||
彻底无从发生。
|
||||
|
||||
`dragPaths` 是判定唯一依据:原生路径在 `enter` 拿到 `paths`,内部路径在 `dragstart` 写入这一行
|
||||
——`over` 事件不带路径,`dataTransfer` 在 `dragover` 里也读不到,所以两条路都必须在开始时登记。
|
||||
|
||||
### 内部拖拽会被原生 `enter` 报成"没有文件"
|
||||
|
||||
0.1.11 实测最隐蔽的一个 bug:把「最近使用」的一行拖到按钮上,**三个按钮全部点亮为可处理**,
|
||||
松手却什么都不做——正是用户描述的"反馈为可处理文件,但又不给出操作"。原因是 macOS 上一次内部
|
||||
拖拽会被**两条通道同时上报**,而原生 `enter` 的载荷里没有文件名:wry 的 `collect_paths` 只读
|
||||
`NSFilenamesPboardType`,页内拖拽携带的是 `text/uri-list`,于是回报 `paths: []`。这个空数组把
|
||||
`dragstart` 已经登记的 `[行路径]` 覆盖掉,而 `actionCanServe` 按既定规则必须把"文件未知"当作
|
||||
不禁止,三个按钮就全成了候选落点。
|
||||
|
||||
修法是合并而不是覆盖:`dragPathsKnown(known, reported)`(`src/lib/dropCapabilities.ts`)——
|
||||
报告非空时以报告为准,报告为空时保留已知的那一份。**不能反过来"信任最新一条"**:两条通道谁先到
|
||||
因平台与 WebView 版本而异,覆盖语义必然在其中一种顺序下失效。也**不能把空数组直接判成"全禁用"**:
|
||||
那是 0.1.10 之前 Windows 拖拽整片灰掉的成因(见下条 `actionCanServe`)。
|
||||
|
||||
外部拖入和内部拖拽始终遵循同一条规则,`dropFiles` 因此接受 `DropAction | null`,`null` 直接
|
||||
原样返回——它不是"未知动作",而是"没有动作",两条投递路径共用这一个判断。
|
||||
|
||||
|
|
@ -457,8 +489,10 @@ N 个组件」,行内的单个安装按钮保持原样,两种入口调用同
|
|||
| 点亮候选按钮的开关有两个来源 | 外部拖拽靠原生 `enter` 设置的 `dragging`,内部拖拽原生事件不一定到,必须另有 `rowDragging`,否则从列表拖起时按钮毫无反应。 |
|
||||
| 面板不要用 `is-dragging` 自己做拖放反馈 | 内部拖拽拿不到原生事件,只有外部拖拽会点亮面板,两种拖法观感不同;把反馈收在按钮上,两条路径共用同一套 `has-drop-target`。 |
|
||||
| 三个按钮共用 `src/lib/dropCapabilities.ts` 一条规则 | 判定原先只写在「文字识别」上,另外两个按钮照旧执行,于是"能处理就处理、不能处理就禁止"在同一个面板里有两种口径。视觉状态(`spent()`)、`dropFiles` 的实际执行、`aimedAction` 的点亮,三处必须问同一个函数,否则会出现"看着能按、按下去什么都不做"或者反过来。 |
|
||||
| 「处理不了」不接受兜底,也不解释拒绝 | 按钮说做什么就做什么:既不能转交别的圆环,也不能弹一条"为什么不行"——那等于让用户先做错再被纠正。变灰、禁止光标与红边就是全部答复。 |
|
||||
| `dragover` 必须按同一个能力判断设置 `dropEffect` | 只把按钮变灰、却始终返回 `copy`,系统光标会继续显示"可投放";用户看到能放、松手却没有动作。`dropEffectFor()` 让 `none` 与 `actionCanServe()` 共用一条规则:PDF 悬停到「文字识别」时是禁止,悬停到另外两个按钮时仍是可投放。 |
|
||||
| 「处理不了」不接受兜底,也不解释拒绝 | 按钮说做什么就做什么:既不能转交别的圆环,也不能弹一条"为什么不行"——那等于让用户先做错再被纠正。按钮禁用加上层禁止符号就是全部答复。 |
|
||||
| 拒绝信号只能画在按钮上,不能交给系统光标 | 外部文件走原生拖放通道,macOS 下 wry 固定回报 `NSDragOperation::Copy`,页面改不动那条通道的光标;只有按钮的渲染两条通道共用。`dropEffectFor()` 仍然服务页内拖拽(Chromium 会真的显示禁止光标),但它只是加分项,不是唯一答复。 |
|
||||
| 禁用按钮要 `pointer-events: none` | 落点靠坐标命中,不靠元素应答;禁用后按钮若仍占命中区,拖拽事件不再回到它身上,`dropAction` 会停在上一个应答的按钮上。 |
|
||||
| 内部拖拽的原生 `enter` 不带文件名,要合并不要覆盖 | `collect_paths` 只读文件列表,页内拖拽带的是 `text/uri-list`,于是回报空数组;直接写入会把 `dragstart` 登记的行路径冲掉,三个按钮全点亮、松手又静默。`dragPathsKnown()` 保留已知的那一份。 |
|
||||
| `actionCanServe` 在"文件未知"时必须返回 true | Windows 的拖拽在载荷可读之前可能报告 0 个文件;按空列表判定会把三个按钮全部禁掉,一次本来能用的手势就废了。只有"知道文件、且知道处理不了"才禁止。 |
|
||||
| 「文件工具」永不禁止 | 它的环以打开 / 在文件夹中显示 / 发送收尾,任何存在的文件都能执行;把"其他"类型判成处理不了会让面板出现三个灰按钮。 |
|
||||
| 拖出的行落在窗口之外时不能命中按钮 | `dragend` 的坐标也要经过 `actionAtPoint`,而命中判定四周有 `SLACK_X/SLACK_Y` 余量;不先判窗口边界,拖去资源管理器的一行会被当成落在按钮上。 |
|
||||
|
|
@ -514,8 +548,8 @@ N 个组件」,行内的单个安装按钮保持原样,两种入口调用同
|
|||
|
||||
1. 「最近使用」某行 → 拖到「文件转换」→ 只弹出一个格式环,且文件是这一行。
|
||||
2. 同一行 → 拖到「文件工具」→ 只弹出工具环。
|
||||
3. 图片行 → 拖到「文字识别」→ 按钮正常点亮,打开编辑器并自动开始识别;非图片行 → 「文字识别」拖拽全程为不可用态且不会点亮,悬停时按钮出现禁止红边、系统光标显示禁止,松手后不打开编辑器、不开环、**不出现任何提示**,另外两个按钮仍可正常落点。
|
||||
3b. `.key` / `.zip` 这类没有可转换目标的行 → 「文件转换」同样拖拽全程变灰、松手不执行;「文件工具」始终可用并正常弹出工具环。
|
||||
3. 图片行 → 拖到「文字识别」→ 按钮正常点亮,打开编辑器并自动开始识别;非图片行 → 「文字识别」拖拽全程为禁用态、按钮上层显示禁止符号且不会点亮,**hover 完全无反馈**,松手后不打开编辑器、不开环、**不出现任何提示**,另外两个按钮仍可正常落点。**同一条非图片行还要从访达再拖一次**:两条通道的观感必须一致(这是 0.1.11 的主要回归点)。
|
||||
3b. `.key` / `.zip` 这类没有可转换目标的行 → 「文件转换」同样全程禁用+禁止符号、松手不执行;「文件工具」始终可用并正常弹出工具环。
|
||||
3c. **Windows 必须单独跑一遍 1–3**:这一平台两条投递路径都可能不上报,兜底只在 `dragEnd` 里,macOS 通过不代表 Windows 通过。
|
||||
3d. 先用「文件转换」弹出一个圆环、再拖一行到按钮上 → 圆环不能吃掉这次拖放(Windows 尤其要看这一条)。
|
||||
4. 同一行 → 拖到面板空白处 / 标题栏 / 列表本身 → 不开环、不执行、**不出现任何提示浮层**。
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ import { FEEDBACK } from "../lib/feedback";
|
|||
import { hitTestDropTarget, releasePoint, toWindowPoint } from "../lib/dropTargets";
|
||||
import {
|
||||
actionCanServe,
|
||||
dragPathsKnown,
|
||||
dropEffectFor,
|
||||
OCR_IMAGE_EXTENSIONS,
|
||||
type DropAction,
|
||||
|
|
@ -693,7 +694,8 @@ export function MainWindow() {
|
|||
setDragging(true);
|
||||
// `enter` is the first moment the carried files are known, which is
|
||||
// early enough to mark a button that cannot serve them.
|
||||
setDragPaths(event.payload.paths);
|
||||
const carried = event.payload.paths;
|
||||
setDragPaths((current) => dragPathsKnown(current, carried));
|
||||
setDropAction(actionAt(event.payload.position));
|
||||
return;
|
||||
}
|
||||
|
|
@ -704,7 +706,7 @@ export function MainWindow() {
|
|||
if (event.payload.type === "leave") {
|
||||
setDragging(false);
|
||||
setDropAction(null);
|
||||
setDragPaths(null);
|
||||
if (!drag) setDragPaths(null);
|
||||
return;
|
||||
}
|
||||
if (event.payload.type === "drop") {
|
||||
|
|
@ -772,13 +774,19 @@ export function MainWindow() {
|
|||
|
||||
// One rule for all three buttons and both platforms: a button that cannot serve the
|
||||
// files in flight shows spent, and a release on it does nothing. The button under the
|
||||
// pointer also gets a forbidden edge and the engine's no-drop cursor, so the refusal
|
||||
// is visible before the user lets go.
|
||||
// pointer keeps its cursor, and the refusal itself is drawn on the button: a file
|
||||
// from the file manager arrives through the native drag channel, where macOS fixes the
|
||||
// drag operation to `copy`, so the cursor cannot carry the answer. The button must.
|
||||
const spent = (action: DropAction) =>
|
||||
dragPaths !== null && !actionCanServe(action, dragPaths);
|
||||
// A button that cannot serve the drag is not a candidate, so it never lights up.
|
||||
const aimedAction = dropAction && actionCanServe(dropAction, dragPaths) ? dropAction : null;
|
||||
const forbiddenAction = dropAction && spent(dropAction) ? dropAction : null;
|
||||
// The prohibition mark reads the same whichever way the file was picked up, and it
|
||||
// stays for the length of the gesture rather than only while hovered.
|
||||
const banMark = (action: DropAction) =>
|
||||
spent(action) ? (
|
||||
<span className="drop-ban" aria-hidden="true" />
|
||||
) : null;
|
||||
|
||||
const outputLabel = (kind: WriteCheck["kind"]) =>
|
||||
kind === "screenshot" ? t("screenshots") : kind === "recording" ? t("recordings") : t("fileResults");
|
||||
|
|
@ -920,8 +928,8 @@ export function MainWindow() {
|
|||
<button
|
||||
className={`home-primary ${aimedAction === "formats" ? "is-drop-target" : ""} ${
|
||||
spent("formats") ? "is-drop-unavailable" : ""
|
||||
} ${forbiddenAction === "formats" ? "is-drop-forbidden" : ""}`}
|
||||
aria-disabled={spent("formats") ? "true" : undefined}
|
||||
}`}
|
||||
disabled={spent("formats")}
|
||||
ref={(node) => {
|
||||
dropTargets.current.formats = node;
|
||||
}}
|
||||
|
|
@ -935,12 +943,13 @@ export function MainWindow() {
|
|||
<FileOutput size={18} />
|
||||
)}
|
||||
{t("convertFiles")}
|
||||
{banMark("formats")}
|
||||
</button>
|
||||
<button
|
||||
className={`home-secondary ${aimedAction === "tools" ? "is-drop-target" : ""} ${
|
||||
spent("tools") ? "is-drop-unavailable" : ""
|
||||
} ${forbiddenAction === "tools" ? "is-drop-forbidden" : ""}`}
|
||||
aria-disabled={spent("tools") ? "true" : undefined}
|
||||
}`}
|
||||
disabled={spent("tools")}
|
||||
ref={(node) => {
|
||||
dropTargets.current.tools = node;
|
||||
}}
|
||||
|
|
@ -952,12 +961,13 @@ export function MainWindow() {
|
|||
<Wrench size={18} />
|
||||
)}
|
||||
{t("fileTools")}
|
||||
{banMark("tools")}
|
||||
</button>
|
||||
<button
|
||||
className={`home-secondary ${aimedAction === "ocr" ? "is-drop-target" : ""} ${
|
||||
spent("ocr") ? "is-drop-unavailable" : ""
|
||||
} ${forbiddenAction === "ocr" ? "is-drop-forbidden" : ""}`}
|
||||
aria-disabled={spent("ocr") ? "true" : undefined}
|
||||
}`}
|
||||
disabled={spent("ocr")}
|
||||
ref={(node) => {
|
||||
dropTargets.current.ocr = node;
|
||||
}}
|
||||
|
|
@ -965,6 +975,7 @@ export function MainWindow() {
|
|||
>
|
||||
{busy === "ocr" ? <LoaderCircle size={18} className="spin" /> : <ScanText size={18} />}
|
||||
{t("ocr")}
|
||||
{banMark("ocr")}
|
||||
</button>
|
||||
</div>
|
||||
<p className="home-drop-hint">
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { test } from "node:test";
|
|||
|
||||
import {
|
||||
actionCanServe,
|
||||
dragPathsKnown,
|
||||
convertible,
|
||||
dropEffectFor,
|
||||
kindFromPath,
|
||||
|
|
@ -69,3 +70,16 @@ test("the drag cursor refuses a button that cannot serve the files", () => {
|
|||
// A payload that is not known yet is not a refusal.
|
||||
assert.equal(dropEffectFor("ocr", null), "copy");
|
||||
});
|
||||
|
||||
test("a Recent row keeps its own path when the native channel reports none", () => {
|
||||
// macOS reports the page's own drag through the native channel too, with an empty
|
||||
// file list: overwriting the row with `[]` spent nothing and lit all three buttons.
|
||||
const row = ["/Users/me/files/report.pdf"];
|
||||
assert.deepEqual(dragPathsKnown(row, []), row);
|
||||
assert.ok(!actionCanServe("ocr", dragPathsKnown(row, [])));
|
||||
assert.ok(actionCanServe("formats", dragPathsKnown(row, [])));
|
||||
// A file from the file manager is the authority, in whichever order it arrives.
|
||||
assert.deepEqual(dragPathsKnown(row, ["/tmp/photo.png"]), ["/tmp/photo.png"]);
|
||||
// Nothing known and nothing reported stays unknown, which spends nothing.
|
||||
assert.equal(dragPathsKnown(null, []), null);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -102,5 +102,20 @@ export function dropEffectFor(
|
|||
return action && actionCanServe(action, paths) ? "copy" : "none";
|
||||
}
|
||||
|
||||
/**
|
||||
* What the drag in flight carries, kept across the two channels that report it.
|
||||
*
|
||||
* A Recent row registers its own path at `dragstart`, and the native channel can
|
||||
* report the same gesture with no file names at all: a drag the page started carries a
|
||||
* URI list, not the file list the native event reads. An empty report therefore means
|
||||
* "nothing new", not "nothing carried" — writing `[]` over the row's path makes every
|
||||
* button a candidate again, which is the mismatch of a processable cursor that hands
|
||||
* back no action. Nothing known and nothing reported stays unknown, the one case where
|
||||
* a button must not be spent.
|
||||
*/
|
||||
export function dragPathsKnown(known: string[] | null, reported: string[]): string[] | null {
|
||||
return reported.length > 0 ? reported : known;
|
||||
}
|
||||
|
||||
/** The extensions the image picker offers when OCR is started by hand. */
|
||||
export const OCR_IMAGE_EXTENSIONS = IMAGE_EXTENSIONS;
|
||||
|
|
|
|||
|
|
@ -1974,33 +1974,73 @@ kbd {
|
|||
background: #fff1e7;
|
||||
}
|
||||
|
||||
/* The drag carries a file this button cannot serve: spent, so it is read as a
|
||||
candidate no more than a control that is switched off elsewhere in the app. */
|
||||
/* The drag carries a file this button cannot serve, so the button is switched off for
|
||||
the length of the gesture and the prohibition sign is drawn over it. The answer has to
|
||||
live on the button rather than in the cursor: a file from the file manager arrives
|
||||
through the native drag channel, where macOS fixes the drag operation to `copy`, and
|
||||
only the button says the same thing on both paths and both platforms.
|
||||
Muted through its own colours rather than `opacity`, because a dimmed button would
|
||||
dim the sign sitting on it, and the sign is the part that has to read. */
|
||||
.home-primary.is-drop-unavailable,
|
||||
.home-secondary.is-drop-unavailable {
|
||||
opacity: var(--dimmed);
|
||||
cursor: default;
|
||||
position: relative;
|
||||
border: 1px solid rgba(101, 64, 43, 0.14);
|
||||
color: #b5a399;
|
||||
background: rgba(255, 255, 255, 0.44);
|
||||
box-shadow: none;
|
||||
transform: none;
|
||||
cursor: not-allowed;
|
||||
/* The aim is measured by coordinates, not by which element answers the event, so a
|
||||
switched-off button must stay out of the way: taking the hit area would stop the
|
||||
drag events on it and leave the gesture pointing at the last button that answered.
|
||||
It also means no hover feedback is even possible. */
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* A disabled control takes no hover feedback, and the sign makes that final: nothing
|
||||
may make a spent button look reachable while the file is still in the air. */
|
||||
.home-primary.is-drop-unavailable:hover,
|
||||
.home-secondary.is-drop-unavailable:hover {
|
||||
border: 1px solid rgba(101, 64, 43, 0.14);
|
||||
color: #b5a399;
|
||||
background: rgba(255, 255, 255, 0.44);
|
||||
transform: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
/* The pointer is over a button that cannot serve this drag. The engine shows the
|
||||
no-drop cursor because `rowDragOver` asks for `dropEffect: none`; the solid red
|
||||
edge makes that same answer visible on the button itself. */
|
||||
.home-primary.is-drop-forbidden,
|
||||
.home-secondary.is-drop-forbidden {
|
||||
cursor: not-allowed;
|
||||
/* A candidate button is dashed while a file is in the air; a spent one keeps a plain
|
||||
edge so the two states cannot be confused. */
|
||||
.home-primary-actions.has-drop-target .home-primary.is-drop-unavailable,
|
||||
.home-primary-actions.has-drop-target .home-secondary.is-drop-unavailable {
|
||||
border: 1px solid rgba(101, 64, 43, 0.14);
|
||||
}
|
||||
|
||||
.home-primary-actions.has-drop-target .home-primary.is-drop-forbidden,
|
||||
.home-primary-actions.has-drop-target .home-secondary.is-drop-forbidden {
|
||||
border-style: solid;
|
||||
border-color: rgba(178, 64, 43, 0.48);
|
||||
box-shadow: 0 0 0 3px rgba(178, 64, 43, 0.08);
|
||||
/* The prohibition sign, drawn over the button's own label rather than beside it, and
|
||||
belonging to no hit area of its own. Circle and bar are drawn here instead of through
|
||||
an icon so the sign keeps the button's corner radius and stays crisp at any scale. */
|
||||
.drop-ban {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
border: 2.5px solid #c33a22;
|
||||
border-radius: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
opacity: 1;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.drop-ban::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 26px;
|
||||
height: 2.5px;
|
||||
border-radius: 2px;
|
||||
background: #c33a22;
|
||||
transform: translate(-50%, -50%) rotate(-45deg);
|
||||
}
|
||||
|
||||
.home-side {
|
||||
|
|
|
|||
Loading…
Reference in New Issue