The mouse and touch: a bar on a clicked sentence, ⋯ and right-click menus, a top bar
- One <Menu>: a popover by the pointer or its button, a sheet from the foot on touch; arrows, Home, End, Enter and Esc, closes on a press outside, and gives the focus back. Its items come from actions.ts and press their keys. - A single click on a sentence selects it (as before) and shows a bar over it: expand e · define d · why y · example x · challenge c · ask : | link w · ⋯, each with its key. A drag or a double click shows it for those words. In an article's text too, without link. On a phone it docks at the foot, with ×. - ⋯ on section rows, a pane's pin and ×, the page's byline and note boxes, shown when pointed at or focused, never moving the text. A stale flag, clicked, opens the node's menu, its remedies first. - Right-click on words, a row, a link, a note or a pane: its menu, Copy first; the copy key copies the app's selection too. Shift+right-click and text boxes keep the browser's menu. - The top bar: undo, redo when there is something to redo, and menu (documents, jump, history, links, layout, settings, command line, help), sticky in the column too. - Key hints in the status line, the history and documents panels and a suggestion's card are buttons. - A first visit is told, once, in the status line, that a click on a sentence offers actions and ? lists the keys. Browser tests: the bar on a click and on a drag, each ⋯ menu, right-click with Copy, Shift+right-click untouched, the menu's keys, the sticky bar, Lock naming, the phone's dock and sheet, and links, Shift-clicks, drags and peeks beside it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
1 parent
9b73cdb15e
commit
32efa17294
9 files changed
+1269
-55
No files matched your search
+31
-1
@@ -1,8 +1,14 @@
|
||||
/** The top bar (where the reader is, and whether it is saved) and the documents menu it opens (m). */
|
||||
import { useLayoutEffect, useRef, useState } from "preact/hooks";
|
||||
import { clip } from "../core/text";
|
||||
import { topEntries } from "./actions";
|
||||
import { Hints, act, showMenu } from "./Mouse";
|
||||
import { press } from "./press";
|
||||
import { store } from "./store";
|
||||
|
||||
/** A press on a tool keeps the focus where it was (the keys stay with the page). */
|
||||
const keep = (e: MouseEvent) => e.preventDefault();
|
||||
|
||||
const SAVE_LABEL = { saved: "saved", saving: "saving…", offline: "offline · kept in this browser", foreign: "not saved · reload the page" };
|
||||
const SAVE_TITLE = {
|
||||
saved: "Every edit is saved as you make it. The server has all of them.",
|
||||
@@ -32,6 +38,30 @@ export function DocBar() {
|
||||
<span class={`save-state ${state}`} title={SAVE_TITLE[state]}>
|
||||
{SAVE_LABEL[state]}
|
||||
</span>
|
||||
<span class="tools">
|
||||
<button type="button" class="tool" title="Undo the last edit made in this tab (u)" onMouseDown={keep} onClick={(e) => (e.stopPropagation(), press("u"))}>
|
||||
undo
|
||||
</button>
|
||||
{store.canRedo() && (
|
||||
<button type="button" class="tool" title="Redo (U)" onMouseDown={keep} onClick={(e) => (e.stopPropagation(), press("U"))}>
|
||||
redo
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
class="tool"
|
||||
aria-haspopup="menu"
|
||||
title="Documents, history, layout and settings"
|
||||
onMouseDown={keep}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
const s = store.settings;
|
||||
showMenu(topEntries({ view: s.view, autolink: s.autolink, auto: s.auto, speculate: s.speculate, curves: s.curves, panes: store.panes, doc: !!store.currentDoc, canRedo: store.canRedo() }, act), e.currentTarget as HTMLElement);
|
||||
}}
|
||||
>
|
||||
menu<span class="chev" />
|
||||
</button>
|
||||
</span>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
@@ -96,7 +126,7 @@ export function DocsPanel() {
|
||||
<div class="panel-head">
|
||||
<span>Documents</span>
|
||||
<span class="keys">
|
||||
{typing ? "type to filter · ↑ ↓ · Enter open · Esc for actions" : "j k · Enter open · n new · r rename · s save as · D delete · x export · i import · / filter · Esc"}
|
||||
<Hints hint={typing ? ["type to filter · ↑ ↓", ["Enter", "open"], ["Escape", "for actions"]] : ["j k", ["Enter", "open"], ["n", "new"], ["r", "rename"], ["s", "save as"], ["D", "delete"], ["x", "export"], ["i", "import"], ["/", "filter"], ["Escape", "close"]]} />
|
||||
</span>
|
||||
</div>
|
||||
<input
|
||||
|
||||
Reference in new issue
Block a user