diff --git a/README.md b/README.md index e211556..9a2c626 100644 --- a/README.md +++ b/README.md @@ -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 a grey button is the whole refusal: 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 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. **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. diff --git a/README.zh-CN.md b/README.zh-CN.md index 72b0cf1..e71a2b9 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -72,7 +72,7 @@ Shift 常驻菜单栏(macOS)与通知区域(Windows),同时也有普 **使用工具(`Option + Shift`,Windows 为 `Alt + Shift`)** 操作相同,扇区会从格式换成该类型文件可用的工具。圆环打开时,保持按住 `Shift`,再按下或松开 `Option`/`Alt`,即可在格式环与工具环之间来回切换。 -**不想拖动?** 主窗口中的「文件转换」与「文件工具」会先让你挑选文件,然后对选中的文件弹出同一个圆环;「文字识别」则选取图片并识别。拖放文件必须**对准按钮**:三个按钮是唯一的落点,松开在哪个按钮上就执行那个按钮的动作——「文件转换」打开格式环,「文件工具」打开工具环,「文字识别」直接识别图片。拖拽进行中三个按钮会同时显示为候选落点,并且只有按钮会响应,周围的面板保持静止;松开在其他位置什么都不会发生。**处理不了的按钮会在这次拖拽期间变灰**:不是图片的文件会让「文字识别」变灰,没有任何可转换目标的格式会让「文件转换」变灰,而变灰本身就是全部答复——松手时什么都不执行,安静地不做,既不会弹出一个空圆环,也不会转交给别的圆环。「文件工具」永远不变灰,因为它的环里总有打开、在文件夹中显示与发送。同一条规则在所有平台上、无论文件来自访达/资源管理器还是「最近使用」,判定结果都一致。右侧「最近使用」里的条目同样可以拖到这三个按钮上,用同一次拖拽复用已经处理过的文件。 +**不想拖动?** 主窗口中的「文件转换」与「文件工具」会先让你挑选文件,然后对选中的文件弹出同一个圆环;「文字识别」则选取图片并识别。拖放文件必须**对准按钮**:三个按钮是唯一的落点,松开在哪个按钮上就执行那个按钮的动作——「文件转换」打开格式环,「文件工具」打开工具环,「文字识别」直接识别图片。拖拽进行中三个按钮会同时显示为候选落点,并且只有按钮会响应,周围的面板保持静止;松开在其他位置什么都不会发生。**处理不了的按钮会在这次拖拽期间变灰**:不是图片的文件会让「文字识别」变灰,没有任何可转换目标的格式会让「文件转换」变灰;指针移到这个按钮上时,光标与按钮边缘都会显示禁止。拒绝在松手前就可见——松手时什么都不执行,安静地不做,既不会弹出一个空圆环,也不会转交给别的圆环。「文件工具」永远不变灰,因为它的环里总有打开、在文件夹中显示与发送。同一条规则在所有平台上、无论文件来自访达/资源管理器还是「最近使用」,判定结果都一致。右侧「最近使用」里的条目同样可以拖到这三个按钮上,用同一次拖拽复用已经处理过的文件。 **一次处理多个文件。** 用 `⌘`/`Ctrl` 点选多个文件后一起拖动,每个文件都会被处理。选中 2 张以上图片或 2 个以上 PDF 时,会出现「合并」扇区,把它们合成一个 PDF。 diff --git a/docs/ENGINEERING-NOTES.md b/docs/ENGINEERING-NOTES.md index 1b5db54..69287cf 100644 --- a/docs/ENGINEERING-NOTES.md +++ b/docs/ENGINEERING-NOTES.md @@ -424,10 +424,10 @@ N 个组件」,行内的单个安装按钮保持原样,两种入口调用同 「文字识别」的拒绝方式在同一步收紧里改成了**事前可见**:0.1.10 用提示说明"这个格式识别不了", 但那仍是让用户先做错、再由浮层告知。现在拖拽一开始就按携带的文件判定,识别不了的按钮直接进入 -不可用态(`is-drop-unavailable`,`aria-disabled`,与全应用统一的 `--dimmed` 一致),松手时 -什么都不发生,也不再有任何提示。`dragPaths` 是判定唯一依据:原生路径在 `enter` 拿到 `paths`, -内部路径在 `dragstart` 写入这一行——`over` 事件不带路径,`dataTransfer` 在 `dragover` 里也读不到, -所以两条路都必须在开始时登记。 +不可用态(`is-drop-unavailable`,`aria-disabled`,与全应用统一的 `--dimmed` 一致);指针落在 +这个按钮上时再加 `is-drop-forbidden` 与系统的禁止光标,松手时什么都不发生,也不再有任何提示。 +`dragPaths` 是判定唯一依据:原生路径在 `enter` 拿到 `paths`,内部路径在 `dragstart` 写入这一行 +——`over` 事件不带路径,`dataTransfer` 在 `dragover` 里也读不到,所以两条路都必须在开始时登记。 外部拖入和内部拖拽始终遵循同一条规则,`dropFiles` 因此接受 `DropAction | null`,`null` 直接 原样返回——它不是"未知动作",而是"没有动作",两条投递路径共用这一个判断。 @@ -457,7 +457,8 @@ N 个组件」,行内的单个安装按钮保持原样,两种入口调用同 | 点亮候选按钮的开关有两个来源 | 外部拖拽靠原生 `enter` 设置的 `dragging`,内部拖拽原生事件不一定到,必须另有 `rowDragging`,否则从列表拖起时按钮毫无反应。 | | 面板不要用 `is-dragging` 自己做拖放反馈 | 内部拖拽拿不到原生事件,只有外部拖拽会点亮面板,两种拖法观感不同;把反馈收在按钮上,两条路径共用同一套 `has-drop-target`。 | | 三个按钮共用 `src/lib/dropCapabilities.ts` 一条规则 | 判定原先只写在「文字识别」上,另外两个按钮照旧执行,于是"能处理就处理、不能处理就禁止"在同一个面板里有两种口径。视觉状态(`spent()`)、`dropFiles` 的实际执行、`aimedAction` 的点亮,三处必须问同一个函数,否则会出现"看着能按、按下去什么都不做"或者反过来。 | -| 「处理不了」不接受兜底,也不解释拒绝 | 按钮说做什么就做什么:既不能转交别的圆环,也不能弹一条"为什么不行"——那等于让用户先做错再被纠正。变灰就是全部答复。 | +| 「处理不了」不接受兜底,也不解释拒绝 | 按钮说做什么就做什么:既不能转交别的圆环,也不能弹一条"为什么不行"——那等于让用户先做错再被纠正。变灰、禁止光标与红边就是全部答复。 | +| `dragover` 必须按同一个能力判断设置 `dropEffect` | 只把按钮变灰、却始终返回 `copy`,系统光标会继续显示"可投放";用户看到能放、松手却没有动作。`dropEffectFor()` 让 `none` 与 `actionCanServe()` 共用一条规则:PDF 悬停到「文字识别」时是禁止,悬停到另外两个按钮时仍是可投放。 | | `actionCanServe` 在"文件未知"时必须返回 true | Windows 的拖拽在载荷可读之前可能报告 0 个文件;按空列表判定会把三个按钮全部禁掉,一次本来能用的手势就废了。只有"知道文件、且知道处理不了"才禁止。 | | 「文件工具」永不禁止 | 它的环以打开 / 在文件夹中显示 / 发送收尾,任何存在的文件都能执行;把"其他"类型判成处理不了会让面板出现三个灰按钮。 | | 拖出的行落在窗口之外时不能命中按钮 | `dragend` 的坐标也要经过 `actionAtPoint`,而命中判定四周有 `SLACK_X/SLACK_Y` 余量;不先判窗口边界,拖去资源管理器的一行会被当成落在按钮上。 | @@ -513,7 +514,7 @@ N 个组件」,行内的单个安装按钮保持原样,两种入口调用同 1. 「最近使用」某行 → 拖到「文件转换」→ 只弹出一个格式环,且文件是这一行。 2. 同一行 → 拖到「文件工具」→ 只弹出工具环。 -3. 图片行 → 拖到「文字识别」→ 按钮正常点亮,打开编辑器并自动开始识别;非图片行 → 「文字识别」拖拽全程为不可用态且不会点亮,松手后不打开编辑器、不开环、**不出现任何提示**,另外两个按钮仍可正常落点。 +3. 图片行 → 拖到「文字识别」→ 按钮正常点亮,打开编辑器并自动开始识别;非图片行 → 「文字识别」拖拽全程为不可用态且不会点亮,悬停时按钮出现禁止红边、系统光标显示禁止,松手后不打开编辑器、不开环、**不出现任何提示**,另外两个按钮仍可正常落点。 3b. `.key` / `.zip` 这类没有可转换目标的行 → 「文件转换」同样拖拽全程变灰、松手不执行;「文件工具」始终可用并正常弹出工具环。 3c. **Windows 必须单独跑一遍 1–3**:这一平台两条投递路径都可能不上报,兜底只在 `dragEnd` 里,macOS 通过不代表 Windows 通过。 3d. 先用「文件转换」弹出一个圆环、再拖一行到按钮上 → 圆环不能吃掉这次拖放(Windows 尤其要看这一条)。 diff --git a/src/components/MainWindow.tsx b/src/components/MainWindow.tsx index 737034a..dce70ed 100644 --- a/src/components/MainWindow.tsx +++ b/src/components/MainWindow.tsx @@ -52,6 +52,7 @@ import { FEEDBACK } from "../lib/feedback"; import { hitTestDropTarget, releasePoint, toWindowPoint } from "../lib/dropTargets"; import { actionCanServe, + dropEffectFor, OCR_IMAGE_EXTENSIONS, type DropAction, } from "../lib/dropCapabilities"; @@ -392,12 +393,15 @@ export function MainWindow() { * differs by engine, so both are listening and `landRecentRow` decides who was first. */ function rowDragOver(event: DragEvent) { - if (!recentDrag.current) return; + const drag = recentDrag.current; + if (!drag) return; event.preventDefault(); - event.dataTransfer.dropEffect = "copy"; const point = { x: event.clientX, y: event.clientY }; dragPointer.current = point; const next = actionAtPoint(point); + // A spent button must show the same refusal before release that it shows on + // release: `none` turns the operating system's cursor into a prohibition. + event.dataTransfer.dropEffect = dropEffectFor(next, [drag.path]); if (dropAction !== next) setDropAction(next); } @@ -767,12 +771,14 @@ export function MainWindow() { }, [recent, historyQuery]); // 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. Being spent is the - // whole notice - there is no message to explain a refusal the user can already see. + // 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. 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; const outputLabel = (kind: WriteCheck["kind"]) => kind === "screenshot" ? t("screenshots") : kind === "recording" ? t("recordings") : t("fileResults"); @@ -914,7 +920,8 @@ export function MainWindow() {