@quillmark/svelte 0.39.1 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -231,7 +231,7 @@ The verbs complete it. `answerReview(ids | 'all' | { group }, 'accept' | 'dismis
231
231
 
232
232
  The **answer card** floats on the current item, below the paragraph or block it stands in, beside that paragraph's last line where the line ends short of it, centred on the line of a one-line field so it stands inside the field rather than over the next field's label, or above it where there is no room, so it covers none of the item's own paragraph, with **Dismiss** and **Accept** and their keys, and the item's `note` above them on one line. It scrolls with the item and is clipped at the pane's edge as the text is. It keeps clear of `reviewInset`, the px the host's chrome takes at the foot of the pane, while the item shows, steps aside while the reader types, and never takes the focus: a press on it leaves the focus where it was, and Alt+F10 puts the keyboard on it, Escape handing the focus back. Under a finger, or on a screen with no hover, it drops the key hints and its buttons are tap-sized.
233
233
 
234
- While a review is open, `REVIEW_KEYS` answer the current item from anywhere on the page but another editor or a text box outside this one: ⌘/Ctrl+Enter accepts it, ⌘/Ctrl+Backspace dismisses it, and ⌘/Ctrl+⌥/Alt+↓ and ↑ step to the next and previous item, moving the caret along when pressed in the editor. The two answer keys are the card's, so they answer an item the card stands on in view: with the item scrolled out of the pane the first press brings it back and the next answers it, and while the reader types in the editor, where the card steps aside, both stay the leaf's own keys. A proposal that only adds blocks is current from anywhere in the paragraph it adds after; where a proposal also rewrites that paragraph, the caret names the rewrite, and `revealReview(id, { focus: true })` puts it in the one asked for. Every word the review draws is a `strings` key, and its one hue is `--qm-review` ([THEMING.md](THEMING.md)).
234
+ While a review is open, `REVIEW_KEYS` answer the current item from anywhere on the page but another editor or a text box outside this one: ⌘/Ctrl+Enter accepts it, ⌘/Ctrl+⌥/Alt+Backspace dismisses it, and ⌘/Ctrl+⌥/Alt+↓ and ↑ step to the next and previous item, moving the caret along when pressed in the editor. The two answer keys are the card's, so they answer an item the card stands on in view: with the item scrolled out of the pane, or the card aside while the reader types, the first press brings it back and the next answers it. No leaf binds a review key: ⌘/Ctrl+Enter is the review's alone, and Alt+Enter ticks a task item, takes a sibling from a list element of several lines and leaves a code block. A proposal that only adds blocks is current from anywhere in the paragraph it adds after; where a proposal also rewrites that paragraph, the caret names the rewrite, and `revealReview(id, { focus: true })` puts it in the one asked for. Every word the review draws is a `strings` key, and its one hue is `--qm-review` ([THEMING.md](THEMING.md)).
235
235
 
236
236
  ### Wording
237
237
 
@@ -8,7 +8,6 @@
8
8
  // A throw keeps the optimistic PM state and reports through `onError`.
9
9
  // An external change re-hydrates through `applyExternal`, gated by `reconcile` except where the
10
10
  // hold it re-evaluates flips.
11
- import { baseKeymap } from 'prosemirror-commands';
12
11
  import { gapCursor } from 'prosemirror-gapcursor';
13
12
  import { history, isHistoryTransaction, redo, undo } from 'prosemirror-history';
14
13
  import { keymap } from 'prosemirror-keymap';
@@ -30,7 +29,7 @@ import { inputRulesPlugin, undoRuleKeymap } from './inputrules.js';
30
29
  import { linebreakPlugin } from './breaks.js';
31
30
  import { bodyKeymap, holdsTab } from './keymap.js';
32
31
  import { DEFAULT_LEAVE_STRINGS, leavePlugin } from './leave.js';
33
- import { FIELD_KEYS, markKeymap } from './shortcuts.js';
32
+ import { FIELD_KEYS, leafBaseKeymap, markKeymap } from './shortcuts.js';
34
33
  import { remoteKey } from './remote.js';
35
34
  import { renameBlocks, reviewLayer } from './review.js';
36
35
  import { valueDiffPlugin, valueSpans } from './value-diff.js';
@@ -911,7 +910,7 @@ export function proseLeafPlugins(schema, opts) {
911
910
  if (!opts.noInputRules)
912
911
  list.push(inputRulesPlugin(schema), undoRuleKeymap());
913
912
  list.push(keymap(editorKeymap(schema, opts.inline, !!opts.slash)));
914
- list.push(keymap(baseKeymap));
913
+ list.push(keymap(leafBaseKeymap));
915
914
  if (schema.marks.link)
916
915
  list.push(linkPastePlugin(schema.marks.link));
917
916
  list.push(dragMovePlugin());
@@ -8,11 +8,11 @@ import type { Command } from 'prosemirror-state';
8
8
  * prepend a link in `keymap.ts` (INVARIANTS §Chrome). `Tab` sinks an unnumbered
9
9
  * line alone into a sub-list, any other line its whole item, and a block right after a list into
10
10
  * the list's last item. `Mod-Shift-7` / `Mod-Shift-8` are the list toggle (`list-toggle.ts`).
11
- * `Mod-Enter` ticks the task item around the caret (`toggleTask`).
11
+ * `LIST_KEYS.task` ticks the task item around the caret (`toggleTask`).
12
12
  *
13
13
  * `Enter` is a chain in precedence order: the empty line above an unnumbered one, an empty top-level
14
14
  * middle item out of the list, the marker back on an empty continuation line, `splitListItem` (`splitTaskItem` for
15
- * tasks), then `liftListItem`. The split link splits a non-empty item, and on an empty last item
15
+ * tasks, `paragraphAbove` over a heading), then `liftListItem`. The split link splits a non-empty item, and on an empty last item
16
16
  * either splits the wrapping item (a nested one, so Enter lifts one level) or bails so the last
17
17
  * link lifts a top-level one to a paragraph.
18
18
  *
@@ -72,6 +72,35 @@ function lineAbove(itemType, paragraph) {
72
72
  return true;
73
73
  };
74
74
  }
75
+ /**
76
+ * Enter at the head of an item's first line that holds text and is no paragraph, a heading → the
77
+ * item `split` opens above it holds an empty paragraph, as `splitBlock` leaves one above a heading
78
+ * outside a list. `splitListItem` gives the new item the line's own type.
79
+ */
80
+ function paragraphAbove(itemType, paragraph, split) {
81
+ return (state, dispatch, view) => {
82
+ const { $from, empty } = state.selection;
83
+ const line = $from.parent;
84
+ if (!dispatch ||
85
+ !empty ||
86
+ $from.parentOffset !== 0 ||
87
+ $from.depth < 2 ||
88
+ line.type === paragraph ||
89
+ line.type.spec.code ||
90
+ line.content.size === 0 ||
91
+ $from.node(-1).type !== itemType ||
92
+ $from.index(-1) !== 0)
93
+ return split(state, dispatch, view);
94
+ return split(state, (tr) => {
95
+ const $at = tr.selection.$from;
96
+ const below = $at.before($at.depth - 1);
97
+ const above = tr.doc.resolve(below).nodeBefore;
98
+ if (above?.type === itemType)
99
+ tr.setBlockType(below - above.nodeSize, below, paragraph);
100
+ dispatch(tr);
101
+ }, view);
102
+ };
103
+ }
75
104
  /** Whether `item` holds nothing but one empty textblock. */
76
105
  function emptyItem(item) {
77
106
  return (item.childCount === 1 && !!item.firstChild?.isTextblock && item.firstChild.content.size === 0);
@@ -477,11 +506,11 @@ function sinkIntoList(itemType) {
477
506
  * prepend a link in `keymap.ts` (INVARIANTS §Chrome). `Tab` sinks an unnumbered
478
507
  * line alone into a sub-list, any other line its whole item, and a block right after a list into
479
508
  * the list's last item. `Mod-Shift-7` / `Mod-Shift-8` are the list toggle (`list-toggle.ts`).
480
- * `Mod-Enter` ticks the task item around the caret (`toggleTask`).
509
+ * `LIST_KEYS.task` ticks the task item around the caret (`toggleTask`).
481
510
  *
482
511
  * `Enter` is a chain in precedence order: the empty line above an unnumbered one, an empty top-level
483
512
  * middle item out of the list, the marker back on an empty continuation line, `splitListItem` (`splitTaskItem` for
484
- * tasks), then `liftListItem`. The split link splits a non-empty item, and on an empty last item
513
+ * tasks, `paragraphAbove` over a heading), then `liftListItem`. The split link splits a non-empty item, and on an empty last item
485
514
  * either splits the wrapping item (a nested one, so Enter lifts one level) or bails so the last
486
515
  * link lifts a top-level one to a paragraph.
487
516
  *
@@ -503,7 +532,7 @@ export function listKeymap(schema) {
503
532
  [LIST_KEYS.indent]: chainCommands(sinkLine(itemType), sinkWithin(itemType), sinkIntoList(itemType)),
504
533
  [LIST_KEYS.outdent]: outdent(itemType),
505
534
  [LIST_KEYS.task]: toggleTask(itemType),
506
- Enter: chainCommands(lineAbove(itemType, paragraph), lineOutOfMiddle(itemType), markerOn(itemType), splitTaskItem(itemType), liftListItem(itemType)),
535
+ Enter: chainCommands(lineAbove(itemType, paragraph), lineOutOfMiddle(itemType), markerOn(itemType), paragraphAbove(itemType, paragraph, splitTaskItem(itemType)), liftListItem(itemType)),
507
536
  Backspace: chainCommands(deleteAcross, markerOff(itemType), lineOut(itemType), joinOntoList(itemType)),
508
537
  Delete: chainCommands(deleteAcross, deleteBelow(itemType, backspace))
509
538
  };
@@ -18,6 +18,7 @@ export declare const FIELD_KEYS: {
18
18
  export declare const BODY_KEYS: {
19
19
  readonly lineBreak: "Shift-Enter";
20
20
  readonly leave: "Escape";
21
+ readonly exitCode: "Alt-Enter";
21
22
  };
22
23
  /** A list item (`lists.ts`, `list-move.ts`). */
23
24
  export declare const LIST_KEYS: {
@@ -25,7 +26,7 @@ export declare const LIST_KEYS: {
25
26
  readonly bulleted: "Mod-Shift-8";
26
27
  readonly indent: "Tab";
27
28
  readonly outdent: "Shift-Tab";
28
- readonly task: "Mod-Enter";
29
+ readonly task: "Alt-Enter";
29
30
  readonly moveUp: "Alt-ArrowUp";
30
31
  readonly moveDown: "Alt-ArrowDown";
31
32
  };
@@ -45,16 +46,19 @@ export declare const TABLE_KEYS: {
45
46
  readonly erase: "Backspace";
46
47
  readonly eraseAlt: "Delete";
47
48
  };
48
- /** The review's keys, the editor's wherever the focus is while a review is open and ahead of
49
- * every other binding of them, so `accept` takes the current change over a task item's
50
- * `LIST_KEYS.task` and `dismiss` over a text leaf's own delete; `next` and `previous` step
51
- * through the changes. */
49
+ /** The review's keys, the editor's wherever the focus is while a review is open. No leaf binds
50
+ * one of them, `accept` included, so each answers alike in every field; `acceptAlt` is `accept`
51
+ * under the modifiers `dismiss` and the steps share. */
52
52
  export declare const REVIEW_KEYS: {
53
53
  readonly accept: "Mod-Enter";
54
- readonly dismiss: "Mod-Backspace";
54
+ readonly acceptAlt: "Mod-Alt-Enter";
55
+ readonly dismiss: "Mod-Alt-Backspace";
55
56
  readonly next: "Mod-Alt-ArrowDown";
56
57
  readonly previous: "Mod-Alt-ArrowUp";
57
58
  };
59
+ /** A leaf's last keymap: `baseKeymap` with a fence left by `BODY_KEYS.exitCode`. The review's
60
+ * accept is held inside a fence, so it does nothing there with no review open either. */
61
+ export declare const leafBaseKeymap: Record<string, Command>;
58
62
  /** The mark toggles, each bound only where the schema declares its mark. */
59
63
  export declare function markKeymap(schema: Schema): Record<string, Command>;
60
64
  /** Where a shortcut answers: any prose field, a multi-block body, a list item, a table cell, an
@@ -81,6 +85,7 @@ export interface ShortcutStrings {
81
85
  shortcutFormatBar: string;
82
86
  shortcutLineBreak: string;
83
87
  shortcutLeave: string;
88
+ shortcutExitCode: string;
84
89
  shortcutNumberedList: string;
85
90
  shortcutBulletedList: string;
86
91
  shortcutIndent: string;
@@ -5,7 +5,7 @@
5
5
  // A key a surface takes only to decline, hold or pass on (Backspace at a block edge, the
6
6
  // body's Tab hold, a code fence's Tab) is not a shortcut a writer looks up, and stays a
7
7
  // literal in its keymap.
8
- import { toggleMark } from 'prosemirror-commands';
8
+ import { baseKeymap, exitCode, toggleMark } from 'prosemirror-commands';
9
9
  /** Every prose leaf, a table cell included: history and the marks. `link` and `formatBar`
10
10
  * bind in the formatting popover, the surface one prompts from and the other enters. */
11
11
  export const FIELD_KEYS = {
@@ -23,7 +23,8 @@ export const FIELD_KEYS = {
23
23
  /** A multi-block body, outside any surface nested in it. */
24
24
  export const BODY_KEYS = {
25
25
  lineBreak: 'Shift-Enter',
26
- leave: 'Escape'
26
+ leave: 'Escape',
27
+ exitCode: 'Alt-Enter'
27
28
  };
28
29
  /** A list item (`lists.ts`, `list-move.ts`). */
29
30
  export const LIST_KEYS = {
@@ -31,7 +32,7 @@ export const LIST_KEYS = {
31
32
  bulleted: 'Mod-Shift-8',
32
33
  indent: 'Tab',
33
34
  outdent: 'Shift-Tab',
34
- task: 'Mod-Enter',
35
+ task: 'Alt-Enter',
35
36
  moveUp: 'Alt-ArrowUp',
36
37
  moveDown: 'Alt-ArrowDown'
37
38
  };
@@ -51,16 +52,23 @@ export const TABLE_KEYS = {
51
52
  erase: 'Backspace',
52
53
  eraseAlt: 'Delete'
53
54
  };
54
- /** The review's keys, the editor's wherever the focus is while a review is open and ahead of
55
- * every other binding of them, so `accept` takes the current change over a task item's
56
- * `LIST_KEYS.task` and `dismiss` over a text leaf's own delete; `next` and `previous` step
57
- * through the changes. */
55
+ /** The review's keys, the editor's wherever the focus is while a review is open. No leaf binds
56
+ * one of them, `accept` included, so each answers alike in every field; `acceptAlt` is `accept`
57
+ * under the modifiers `dismiss` and the steps share. */
58
58
  export const REVIEW_KEYS = {
59
59
  accept: 'Mod-Enter',
60
- dismiss: 'Mod-Backspace',
60
+ acceptAlt: 'Mod-Alt-Enter',
61
+ dismiss: 'Mod-Alt-Backspace',
61
62
  next: 'Mod-Alt-ArrowDown',
62
63
  previous: 'Mod-Alt-ArrowUp'
63
64
  };
65
+ /** A leaf's last keymap: `baseKeymap` with a fence left by `BODY_KEYS.exitCode`. The review's
66
+ * accept is held inside a fence, so it does nothing there with no review open either. */
67
+ export const leafBaseKeymap = {
68
+ ...baseKeymap,
69
+ [REVIEW_KEYS.accept]: (state) => !!state.selection.$from.parent.type.spec.code,
70
+ [BODY_KEYS.exitCode]: exitCode
71
+ };
64
72
  /** The mark toggles, each bound only where the schema declares its mark. */
65
73
  export function markKeymap(schema) {
66
74
  const map = {};
@@ -88,11 +96,12 @@ export const DEFAULT_SHORTCUT_STRINGS = {
88
96
  shortcutFormatBar: 'Move to the format bar over a selection',
89
97
  shortcutLineBreak: 'Line break within a paragraph',
90
98
  shortcutLeave: 'Let Tab leave the editor',
99
+ shortcutExitCode: 'Leave a code block',
91
100
  shortcutNumberedList: 'Numbered list',
92
101
  shortcutBulletedList: 'Bulleted list',
93
102
  shortcutIndent: 'Nest under the item above',
94
103
  shortcutOutdent: 'Move back up a level',
95
- shortcutTask: 'Check or uncheck a task, outside a review',
104
+ shortcutTask: 'Check or uncheck a task',
96
105
  shortcutMoveItem: 'Move the item up or down',
97
106
  shortcutNextCell: 'Next cell, adding a row past the last',
98
107
  shortcutPreviousCell: 'Previous cell',
@@ -123,6 +132,7 @@ const SHORTCUTS = [
123
132
  { scope: 'field', label: 'shortcutFormatBar', keys: [F.formatBar] },
124
133
  { scope: 'body', label: 'shortcutLineBreak', keys: [BODY_KEYS.lineBreak] },
125
134
  { scope: 'body', label: 'shortcutLeave', keys: [BODY_KEYS.leave] },
135
+ { scope: 'body', label: 'shortcutExitCode', keys: [BODY_KEYS.exitCode] },
126
136
  { scope: 'list', label: 'shortcutNumberedList', keys: [L.numbered] },
127
137
  { scope: 'list', label: 'shortcutBulletedList', keys: [L.bulleted] },
128
138
  { scope: 'list', label: 'shortcutIndent', keys: [L.indent] },
@@ -141,7 +151,11 @@ const SHORTCUTS = [
141
151
  },
142
152
  { scope: 'table', label: 'shortcutAlignColumn', keys: [T.alignLeft, T.alignRight] },
143
153
  { scope: 'table', label: 'shortcutDeleteCells', keys: [T.erase, T.eraseAlt] },
144
- { scope: 'review', label: 'shortcutReviewAccept', keys: [REVIEW_KEYS.accept] },
154
+ {
155
+ scope: 'review',
156
+ label: 'shortcutReviewAccept',
157
+ keys: [REVIEW_KEYS.accept, REVIEW_KEYS.acceptAlt]
158
+ },
145
159
  { scope: 'review', label: 'shortcutReviewDismiss', keys: [REVIEW_KEYS.dismiss] },
146
160
  { scope: 'review', label: 'shortcutReviewNext', keys: [REVIEW_KEYS.next] },
147
161
  { scope: 'review', label: 'shortcutReviewPrevious', keys: [REVIEW_KEYS.previous] }
@@ -9,13 +9,13 @@
9
9
  //
10
10
  // Every control is absolutely positioned out of the grid; `codec/prose.css` draws the band, the
11
11
  // clusters and the selection wash.
12
- import { baseKeymap, chainCommands, selectAll } from 'prosemirror-commands';
12
+ import { chainCommands, selectAll } from 'prosemirror-commands';
13
13
  import { redo, undo } from 'prosemirror-history';
14
14
  import { keymap } from 'prosemirror-keymap';
15
15
  import { EditorState, NodeSelection, Selection, TextSelection } from 'prosemirror-state';
16
16
  import { EditorView } from 'prosemirror-view';
17
17
  import { decode } from './decode.js';
18
- import { FIELD_KEYS, markKeymap, TABLE_KEYS as T } from './shortcuts.js';
18
+ import { FIELD_KEYS, leafBaseKeymap, markKeymap, TABLE_KEYS as T } from './shortcuts.js';
19
19
  import { inputRulesPlugin, undoRuleKeymap } from './inputrules.js';
20
20
  import { linkPastePlugin } from './link-paste.js';
21
21
  import { dragMovePlugin } from './drag-move.js';
@@ -137,7 +137,7 @@ function cellPlugins(keys, outer) {
137
137
  linkPastePlugin(cellSchema.marks.link),
138
138
  dragMovePlugin(outer),
139
139
  keymap(keys),
140
- keymap(baseKeymap)
140
+ keymap(leafBaseKeymap)
141
141
  ];
142
142
  }
143
143
  /**
@@ -19,7 +19,7 @@ export declare function taskPlugin(): Plugin;
19
19
  export declare function splitTaskItem(itemType: NodeType): Command;
20
20
  /**
21
21
  * `checked` flipped on the nearest task item around the caret, or on a selected task item,
22
- * as one transaction. It declines outside a task item and inside a fence, where `baseKeymap`'s `exitCode` is the
23
- * nearer answer to `Mod-Enter`.
22
+ * as one transaction. It declines outside a task item and inside a fence, where leaving the fence is the
23
+ * nearer answer to the key the two share.
24
24
  */
25
25
  export declare function toggleTask(itemType: NodeType): Command;
@@ -1,7 +1,7 @@
1
1
  // A task item is a `list_item` whose `checked` is a boolean (INVARIANTS §"Task items"). Its
2
2
  // `toDOM` draws a checkbox ahead of the item's blocks, disabled, which is the drawing a
3
3
  // held leaf, a copy and `renderContent` take; a leaf that edits mounts the item through
4
- // `taskItemView`, whose checkbox toggles, as `Mod-Enter` does (`toggleTask`). A task item
4
+ // `taskItemView`, whose checkbox toggles, as `LIST_KEYS.task` does (`toggleTask`). A task item
5
5
  // is minted by source mode and by a paste alone: no shorthand, command or key makes one.
6
6
  import { DOMSerializer } from 'prosemirror-model';
7
7
  import { NodeSelection, Plugin } from 'prosemirror-state';
@@ -140,8 +140,8 @@ export function splitTaskItem(itemType) {
140
140
  }
141
141
  /**
142
142
  * `checked` flipped on the nearest task item around the caret, or on a selected task item,
143
- * as one transaction. It declines outside a task item and inside a fence, where `baseKeymap`'s `exitCode` is the
144
- * nearer answer to `Mod-Enter`.
143
+ * as one transaction. It declines outside a task item and inside a fence, where leaving the fence is the
144
+ * nearer answer to the key the two share.
145
145
  */
146
146
  export function toggleTask(itemType) {
147
147
  return (state, dispatch) => {
@@ -9,6 +9,9 @@ export interface FrameOptions {
9
9
  /** Room held clear at the band's foot, where it is more than the scroller's own `scroll-padding`. */
10
10
  foot?: number;
11
11
  behavior?: ScrollBehavior;
12
+ /** The extent framed in place of the target's own box, in viewport px, where more than the
13
+ * target has to show with it. */
14
+ extent?: Band;
12
15
  }
13
16
  /**
14
17
  * The scroll, in px down, that frames `target` in `band` with `gap` clear of each edge. `top` is
@@ -82,9 +82,10 @@ function frameInline(target, stop, behavior) {
82
82
  * where it is.
83
83
  */
84
84
  export function frame(target, opts) {
85
- const box = target.getBoundingClientRect();
86
- if (!box.width && !box.height)
85
+ const own = target.getBoundingClientRect();
86
+ if (!own.width && !own.height)
87
87
  return;
88
+ const box = opts.extent ?? own;
88
89
  const field = target.closest('.qm-field');
89
90
  const top = Math.min(field?.getBoundingClientRect().top ?? box.top, box.top);
90
91
  const scroller = scrollerOf(target);
@@ -51,7 +51,7 @@
51
51
  caret there, and short of a prose line's end splits the line there, as a bulleted list
52
52
  does; a paste of several lines into a prose row opens a row per line; Backspace at a
53
53
  prose line's start joins it onto the line above and Delete at its end joins the next
54
- onto it, each one commit. A prose element whose `items` declares a `shape` holds lines of its own, so Enter breaks a line inside it and ⌘/Ctrl+Enter inserts the sibling, and a paste stays in the element. Backspace on an empty element removes it and hands focus back up the list, Alt+↑/↓
54
+ onto it, each one commit. A prose element whose `items` declares a `shape` holds lines of its own, so Enter breaks a line inside it and Alt+Enter inserts the sibling, and a paste stays in the element. Backspace on an empty element removes it and hands focus back up the list, Alt+↑/↓
55
55
  anywhere in a row of the list moves it, the nearest row answering and never
56
56
  the record around a nested one: the twin of the handle's drag. A move is one splice of the ids
57
57
  and of the values together, the mechanism insert and remove use, so an element keeps
@@ -223,7 +223,7 @@
223
223
  // has text elements.
224
224
  const control = $derived(items ? controlKind(items) : 'text');
225
225
  /** A prose element whose `items` declares a `shape`: its own lines, which Enter breaks and
226
- * ⌘/Ctrl+Enter leaves for a sibling. */
226
+ * Alt+Enter leaves for a sibling. */
227
227
  const multiline = $derived(control === 'prose' && !leafFlags(items).inline);
228
228
  const table = $derived(layout === 'table' && control === 'object');
229
229
  const columns = $derived(Object.entries(items?.properties ?? {}));
@@ -922,7 +922,8 @@
922
922
  return;
923
923
  }
924
924
  if (e.key === 'Enter') {
925
- if (multiline && !(e.ctrlKey || e.metaKey)) return;
925
+ if (e.ctrlKey || e.metaKey) return;
926
+ if (multiline && (!e.altKey || e.defaultPrevented)) return;
926
927
  e.preventDefault();
927
928
  insertAfter(k, column);
928
929
  } else if (e.key === 'Backspace' && !e.repeat && elementEmpty(k, e.target, column)) {
@@ -1315,7 +1316,7 @@
1315
1316
  <!-- svelte-ignore a11y_no_static_element_interactions -->
1316
1317
  <div
1317
1318
  class={[
1318
- 'qm-array-row qm-review-added',
1319
+ 'qm-array-row qm-review-added qm-focus-ring',
1319
1320
  {
1320
1321
  'qm-array-table-row': table,
1321
1322
  'qm-element': control === 'object' && !table,
@@ -1324,6 +1325,7 @@
1324
1325
  ]}
1325
1326
  style:order
1326
1327
  data-qm-review={item.id}
1328
+ tabindex="-1"
1327
1329
  role="group"
1328
1330
  aria-label={t.strings.reviewNewItem}
1329
1331
  >
@@ -462,7 +462,7 @@
462
462
 
463
463
  {#snippet kindOptions()}
464
464
  {#each kinds as k (k)}
465
- <option value={k}>{kindTitle(quill.schema.card_kinds?.[k], k)}</option>
465
+ <option value={k}>{kindTitle(quill.schema[k], k)}</option>
466
466
  {/each}
467
467
  {/snippet}
468
468
 
@@ -12,8 +12,11 @@
12
12
  change stands in, and never above it: a card that turns over the text as a scroll runs short
13
13
  of room moves under the pointer about to answer. Its room under the change is what a step
14
14
  scrolls for, and the host's chrome at the pane's foot (`inset`) is kept clear. The column is
15
- the card's body or its form whole, never the one field, so Accept stands at one edge from
16
- change to change and a pointer answering a run of them does not hunt for it. A field or a
15
+ the card's body or its form whole, so Accept stands at one edge from change to change and a
16
+ pointer answering a run of them does not hunt for it. A field or a property sharing its row
17
+ takes its own right edge instead, reaching past it only as far as the card is wide and never
18
+ past the column's: a card at the column's edge stands under the row's last field, which reads
19
+ as the change it answers whatever field the change is in. A field or a
17
20
  property sharing its row with others takes the card beside its line only where the card
18
21
  stands within its own slot, and under the row otherwise: beside the line of one that ends
19
22
  short of the column's edge the card covers the value of the next. Over a change too tall for
@@ -27,7 +30,9 @@
27
30
  anywhere, a resize of the editor.
28
31
 
29
32
  It never takes the focus. A press on it keeps the focus where it is, and the keyboard reaches
30
- it only by `enter`, from which Escape and every answer hand the focus back.
33
+ it only by `enter`. There its keys are bare: Enter on a button, Backspace or Delete to dismiss,
34
+ the arrows up and down to step. The focus rides the card from change to change, and Escape or
35
+ the last answer hands it back.
31
36
  -->
32
37
  <script lang="ts">
33
38
  import { tick } from 'svelte';
@@ -48,9 +53,13 @@
48
53
  outdated: boolean;
49
54
  /** Why, as the proposal's writer says it. */
50
55
  note?: string;
56
+ /** The answer key whose press only brought the card, whose hint says to press it again. */
57
+ asked?: 'accept' | 'dismiss';
51
58
  onAnswer(action: 'accept' | 'dismiss'): void;
59
+ /** Go to the next change, or the previous. */
60
+ onStep(dir: 1 | -1): void;
52
61
  }
53
- let { id, root, inset, hidden, outdated, note, onAnswer }: Props = $props();
62
+ let { id, root, inset, hidden, outdated, note, asked, onAnswer, onStep }: Props = $props();
54
63
  const noteId = $props.id();
55
64
 
56
65
  const t = wording();
@@ -64,8 +73,14 @@
64
73
  let stands = false;
65
74
  /** The change is drawn, so the card has somewhere to stand. */
66
75
  let placed = $state(false);
76
+ /** The span, in viewport px, of the change's blocks and the card where it stands unpinned. */
77
+ let reach: { top: number; bottom: number } = { top: 0, bottom: 0 };
67
78
  /** Where the focus was when the keyboard entered the card, to hand it back. */
68
79
  let from: HTMLElement | undefined;
80
+ /** The keyboard is on the card, from `enter` until the reader takes the focus off it. The
81
+ * card is inert between two changes, which drops the focus to the body: that is no move of
82
+ * the reader's, and the focus is put back as the card shows again. */
83
+ let riding = $state(false);
69
84
 
70
85
  const shown = $derived(placed && !hidden && id !== undefined);
71
86
 
@@ -120,13 +135,18 @@
120
135
  const column = (els[0].closest(
121
136
  '.qm-fields, .qm-card, .qm-review-card-add, .qm-review-card-remove'
122
137
  ) ?? root)!;
123
- left = Math.max(view.left + gap, column.getBoundingClientRect().right - w);
138
+ const edge = column.getBoundingClientRect().right;
139
+ const home = els[0].closest('.qm-object-prop, .qm-field')?.getBoundingClientRect();
140
+ const right =
141
+ home && home.right < edge ? Math.min(edge, Math.max(home.right, home.left + w)) : edge;
142
+ left = Math.max(view.left + gap, right - w);
124
143
  const at = (root ?? el).getBoundingClientRect();
125
144
  const last = blocks.find((b, i) => b !== els[i] && b.getBoundingClientRect().bottom === lower);
126
145
  const tuck = last && lastLine(last, h);
127
146
  const slot = last?.closest('.qm-object-prop, .qm-field')?.getBoundingClientRect();
128
147
  const beside = tuck && tuck.right + gap <= left && (!slot || left + w <= slot.right + 1);
129
148
  const below = beside ? tuck.top : lower + gap;
149
+ reach = { top: upper, bottom: Math.max(lower, below + h) };
130
150
  const tall = lower - upper + gap + h > floor - ceil;
131
151
  pinned = shows && tall && below + h > floor;
132
152
  const y = pinned ? Math.max(ceil, floor - h) : below;
@@ -223,11 +243,19 @@
223
243
  return !placed || stands;
224
244
  }
225
245
 
246
+ /** What a reveal frames for the change: its blocks and the card under or beside them, as
247
+ * the card stands where nothing pins it. `undefined` while the change draws nothing. */
248
+ export function extent(): { top: number; bottom: number } | undefined {
249
+ place();
250
+ return placed ? reach : undefined;
251
+ }
252
+
226
253
  /** Put the focus on Accept, handing it back to where it was on Escape or an answer. False
227
254
  * with no card on show. */
228
255
  export async function enter(): Promise<boolean> {
229
256
  if (!shown || !el || !inView(el)) return false;
230
257
  from = document.activeElement instanceof HTMLElement ? document.activeElement : undefined;
258
+ riding = true;
231
259
  await tick();
232
260
  el.querySelector<HTMLElement>('.qm-review-card-accept')?.focus({ preventScroll: true });
233
261
  return true;
@@ -236,21 +264,50 @@
236
264
  function leave(): void {
237
265
  const back = from;
238
266
  from = undefined;
267
+ riding = false;
239
268
  if (back?.isConnected) back.focus({ preventScroll: true });
240
269
  }
241
270
 
242
271
  function answer(action: 'accept' | 'dismiss'): void {
243
- const held = !!el?.contains(document.activeElement);
244
272
  onAnswer(action);
245
- if (held) leave();
273
+ }
274
+
275
+ $effect(() => {
276
+ if (!riding) return;
277
+ if (id === undefined) leave();
278
+ else if (shown && document.activeElement === document.body)
279
+ el?.querySelector<HTMLElement>('.qm-review-card-accept')?.focus({ preventScroll: true });
280
+ });
281
+
282
+ /** The reader took the focus off the card: to `to`, or by a press outside it. */
283
+ function tookOff(to: EventTarget | null): void {
284
+ if (to instanceof Node && el?.contains(to)) return;
285
+ riding = false;
286
+ from = undefined;
246
287
  }
247
288
 
248
289
  function onkeydown(e: KeyboardEvent): void {
290
+ if (e.ctrlKey || e.metaKey || e.altKey) return;
249
291
  if (e.key === 'Escape') {
250
292
  e.preventDefault();
251
293
  leave();
252
294
  return;
253
295
  }
296
+ if (e.key === 'Backspace' || e.key === 'Delete') {
297
+ e.preventDefault();
298
+ if (!e.repeat) answer('dismiss');
299
+ return;
300
+ }
301
+ if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
302
+ e.preventDefault();
303
+ onStep(e.key === 'ArrowUp' ? -1 : 1);
304
+ return;
305
+ }
306
+ // A held Enter clicks its button on every repeat, and a held key answers once.
307
+ if (e.key === 'Enter' && e.repeat) {
308
+ e.preventDefault();
309
+ return;
310
+ }
254
311
  if (e.key !== 'Tab' && e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') return;
255
312
  const buttons = [...(el?.querySelectorAll<HTMLElement>('button') ?? [])];
256
313
  const at = buttons.indexOf(document.activeElement as HTMLElement);
@@ -261,7 +318,11 @@
261
318
  }
262
319
  </script>
263
320
 
264
- <svelte:window onscrollcapture={schedule} onresize={schedule} />
321
+ <svelte:window
322
+ onscrollcapture={schedule}
323
+ onresize={schedule}
324
+ onpointerdowncapture={(e) => tookOff(e.target)}
325
+ />
265
326
 
266
327
  <!-- svelte-ignore a11y_no_static_element_interactions -->
267
328
  <!-- The press keeps the focus where it is: the answer is about the text, not a move off it. -->
@@ -281,7 +342,8 @@
281
342
  onmousedown={(e) => e.preventDefault()}
282
343
  {onkeydown}
283
344
  onfocusout={(e) => {
284
- if (!el?.contains(e.relatedTarget as Node | null)) from = undefined;
345
+ if (e.relatedTarget) tookOff(e.relatedTarget);
346
+ else if (!riding) from = undefined;
285
347
  }}
286
348
  >
287
349
  {#if note}<p id={noteId} class="qm-review-card-reason" title={note}>{note}</p>{/if}
@@ -293,7 +355,9 @@
293
355
  tabindex="-1"
294
356
  aria-keyshortcuts={keyshortcut(REVIEW_KEYS.dismiss)}
295
357
  onclick={() => answer('dismiss')}
296
- >{t.strings.reviewDismiss}<kbd>{keycap(REVIEW_KEYS.dismiss)}</kbd></button
358
+ >{t.strings.reviewDismiss}<kbd class={{ 'qm-review-card-asked': asked === 'dismiss' }}
359
+ >{keycap(REVIEW_KEYS.dismiss)}</kbd
360
+ ></button
297
361
  >
298
362
  <button
299
363
  type="button"
@@ -301,7 +365,9 @@
301
365
  tabindex="-1"
302
366
  aria-keyshortcuts={keyshortcut(REVIEW_KEYS.accept)}
303
367
  onclick={() => answer('accept')}
304
- >{t.strings.reviewAccept}<kbd>{keycap(REVIEW_KEYS.accept)}</kbd></button
368
+ >{t.strings.reviewAccept}<kbd class={{ 'qm-review-card-asked': asked === 'accept' }}
369
+ >{keycap(REVIEW_KEYS.accept)}</kbd
370
+ ></button
305
371
  >
306
372
  </div>
307
373
  </div>
@@ -372,6 +438,22 @@
372
438
  }
373
439
  kbd {
374
440
  font: inherit;
441
+ border-radius: var(--_qm-radius-inner);
442
+ }
443
+ /* The press that brought the card asks for another: its key's hint rings once. */
444
+ .qm-review-card-asked {
445
+ outline: var(--_qm-border-width) solid currentColor;
446
+ outline-offset: 2px;
447
+ }
448
+ @media (prefers-reduced-motion: no-preference) {
449
+ .qm-review-card-asked {
450
+ animation: qm-review-card-ask var(--_qm-duration-slow) var(--_qm-ease-reverse) 2;
451
+ }
452
+ }
453
+ @keyframes qm-review-card-ask {
454
+ 50% {
455
+ outline-offset: 4px;
456
+ }
375
457
  }
376
458
  .qm-review-card-answers {
377
459
  display: flex;
@@ -11,10 +11,18 @@ interface Props {
11
11
  outdated: boolean;
12
12
  /** Why, as the proposal's writer says it. */
13
13
  note?: string;
14
+ /** The answer key whose press only brought the card, whose hint says to press it again. */
15
+ asked?: 'accept' | 'dismiss';
14
16
  onAnswer(action: 'accept' | 'dismiss'): void;
17
+ /** Go to the next change, or the previous. */
18
+ onStep(dir: 1 | -1): void;
15
19
  }
16
20
  declare const ReviewCard: import("svelte").Component<Props, {
17
21
  standsInView: () => boolean;
22
+ extent: () => {
23
+ top: number;
24
+ bottom: number;
25
+ } | undefined;
18
26
  enter: () => Promise<boolean>;
19
27
  }, "">;
20
28
  type ReviewCard = ReturnType<typeof ReviewCard>;