@quillmark/svelte 0.39.0 → 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 +1 -1
- package/dist/core/codec/encode.d.ts +10 -0
- package/dist/core/codec/encode.js +101 -0
- package/dist/core/codec/field.js +38 -10
- package/dist/core/codec/index.d.ts +2 -1
- package/dist/core/codec/index.js +2 -1
- package/dist/core/codec/lists.d.ts +2 -2
- package/dist/core/codec/lists.js +32 -3
- package/dist/core/codec/shortcuts.d.ts +11 -6
- package/dist/core/codec/shortcuts.js +24 -10
- package/dist/core/codec/table-view.js +3 -3
- package/dist/core/codec/tasks.d.ts +2 -2
- package/dist/core/codec/tasks.js +3 -3
- package/dist/core/frame.d.ts +3 -0
- package/dist/core/frame.js +3 -2
- package/dist/visual/ArrayField.svelte +6 -4
- package/dist/visual/Card.svelte +1 -1
- package/dist/visual/ProseValue.svelte +11 -1
- package/dist/visual/ReviewCard.svelte +116 -32
- package/dist/visual/ReviewCard.svelte.d.ts +9 -0
- package/dist/visual/VisualEditorInner.svelte +241 -76
- package/dist/visual/hears.d.ts +14 -0
- package/dist/visual/hears.js +58 -0
- package/dist/visual/index.d.ts +2 -0
- package/dist/visual/index.js +1 -0
- package/dist/visual/proposals.js +1 -1
- package/dist/visual/review.svelte.d.ts +2 -0
- package/dist/visual/review.svelte.js +9 -2
- package/dist/visual/structure.d.ts +2 -2
- package/dist/visual/undo.svelte.js +6 -3
- package/package.json +2 -2
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
|
|
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
|
|
|
@@ -41,3 +41,13 @@ export declare function pmToContent(doc: PMNode, anchors?: ContentAnchor[]): Con
|
|
|
41
41
|
* not hold for placeholders (`field.ts`).
|
|
42
42
|
*/
|
|
43
43
|
export declare function lower(oldRt: Content, newRt: Content): Change | null;
|
|
44
|
+
/**
|
|
45
|
+
* The one splice taking `oldRt` to `newRt` where the two differ only in the text of one block
|
|
46
|
+
* and the formatting of what it inserts, or `null`: built here rather than by the store's `diff`,
|
|
47
|
+
* which reads both values whole across the boundary. Exact or absent, never a guess: the value the
|
|
48
|
+
* splice leaves, the store's marks cut at the edit and the insert's own merged back, is checked
|
|
49
|
+
* equal to `newRt`, so a caller that holds `newRt` as the stored value after the write holds it.
|
|
50
|
+
*/
|
|
51
|
+
export declare function spliceOf(oldRt: Content, newRt: Content): Change | null;
|
|
52
|
+
/** Whether `receipt`'s normalized change is `change`, a {@link spliceOf}, as it was sent. */
|
|
53
|
+
export declare function landedAsSent(applied: Change, change: Change): boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { core } from '../lifecycle.js';
|
|
2
2
|
import { HARD_BREAK, ISLAND_SLOT, islandEntryFromNode } from './islands.js';
|
|
3
3
|
import { contentDescriptorFromPM, markKey } from './marks.js';
|
|
4
|
+
import { valueEqual } from './reconcile.js';
|
|
4
5
|
function idsOf(doc) {
|
|
5
6
|
const next = new Map();
|
|
6
7
|
doc.descendants((node) => {
|
|
@@ -244,3 +245,103 @@ export function lower(oldRt, newRt) {
|
|
|
244
245
|
const change = core().diff(oldRt, newRt);
|
|
245
246
|
return change.steps.length ? change : null;
|
|
246
247
|
}
|
|
248
|
+
/**
|
|
249
|
+
* The one splice taking `oldRt` to `newRt` where the two differ only in the text of one block
|
|
250
|
+
* and the formatting of what it inserts, or `null`: built here rather than by the store's `diff`,
|
|
251
|
+
* which reads both values whole across the boundary. Exact or absent, never a guess: the value the
|
|
252
|
+
* splice leaves, the store's marks cut at the edit and the insert's own merged back, is checked
|
|
253
|
+
* equal to `newRt`, so a caller that holds `newRt` as the stored value after the write holds it.
|
|
254
|
+
*/
|
|
255
|
+
export function spliceOf(oldRt, newRt) {
|
|
256
|
+
const a = oldRt.text;
|
|
257
|
+
const b = newRt.text;
|
|
258
|
+
if (a === b)
|
|
259
|
+
return null;
|
|
260
|
+
if (oldRt.codec !== newRt.codec ||
|
|
261
|
+
!valueEqual(oldRt.blocks, newRt.blocks) ||
|
|
262
|
+
!valueEqual(oldRt.containers ?? [], newRt.containers ?? []) ||
|
|
263
|
+
!valueEqual(oldRt.islands ?? [], newRt.islands ?? []))
|
|
264
|
+
return null;
|
|
265
|
+
const short = Math.min(a.length, b.length);
|
|
266
|
+
let at = 0;
|
|
267
|
+
while (at < short && a.charCodeAt(at) === b.charCodeAt(at))
|
|
268
|
+
at++;
|
|
269
|
+
let tail = 0;
|
|
270
|
+
while (tail < short - at &&
|
|
271
|
+
a.charCodeAt(a.length - 1 - tail) === b.charCodeAt(b.length - 1 - tail))
|
|
272
|
+
tail++;
|
|
273
|
+
if (splitsPair(a, at) || splitsPair(a, a.length - tail))
|
|
274
|
+
return null;
|
|
275
|
+
const del = a.slice(at, a.length - tail);
|
|
276
|
+
const insert = b.slice(at, b.length - tail);
|
|
277
|
+
if (breaksText(del) || breaksText(insert))
|
|
278
|
+
return null;
|
|
279
|
+
const end = at + del.length;
|
|
280
|
+
const shift = insert.length - del.length;
|
|
281
|
+
const before = oldRt.marks ?? [];
|
|
282
|
+
const after = newRt.marks ?? [];
|
|
283
|
+
if (before.some(isExtMark) || after.some(isExtMark))
|
|
284
|
+
return null;
|
|
285
|
+
const carried = [];
|
|
286
|
+
for (const m of before) {
|
|
287
|
+
if (m.start < at)
|
|
288
|
+
carried.push({ ...m, end: Math.min(m.end, at) });
|
|
289
|
+
if (m.end > end)
|
|
290
|
+
carried.push({ ...m, start: Math.max(m.start, end) + shift, end: m.end + shift });
|
|
291
|
+
}
|
|
292
|
+
const own = [];
|
|
293
|
+
for (const m of after) {
|
|
294
|
+
const lo = Math.max(m.start, at);
|
|
295
|
+
const hi = Math.min(m.end, at + insert.length);
|
|
296
|
+
if (lo < hi)
|
|
297
|
+
own.push({ ...m, start: lo, end: hi });
|
|
298
|
+
}
|
|
299
|
+
if (!valueEqual(mergeMarks([...carried, ...own]), after))
|
|
300
|
+
return null;
|
|
301
|
+
const anchors = [];
|
|
302
|
+
for (const x of oldRt.anchors ?? []) {
|
|
303
|
+
if ((x.start >= at && x.start <= end) || (x.end >= at && x.end <= end))
|
|
304
|
+
return null;
|
|
305
|
+
anchors.push(x.start > end
|
|
306
|
+
? { ...x, start: x.start + shift, end: x.end + shift }
|
|
307
|
+
: x.end > end
|
|
308
|
+
? { ...x, end: x.end + shift }
|
|
309
|
+
: x);
|
|
310
|
+
}
|
|
311
|
+
if (!valueEqual(anchors, newRt.anchors ?? []))
|
|
312
|
+
return null;
|
|
313
|
+
const marks = own.map((m) => ({ ...m, start: m.start - at, end: m.end - at }));
|
|
314
|
+
const step = { at, insert };
|
|
315
|
+
if (del)
|
|
316
|
+
step.delete = del;
|
|
317
|
+
if (marks.length)
|
|
318
|
+
step.marks = marks;
|
|
319
|
+
return { steps: [{ splice: step }] };
|
|
320
|
+
}
|
|
321
|
+
/** Whether `receipt`'s normalized change is `change`, a {@link spliceOf}, as it was sent. */
|
|
322
|
+
export function landedAsSent(applied, change) {
|
|
323
|
+
const [sent] = change.steps;
|
|
324
|
+
const [got] = applied.steps;
|
|
325
|
+
if (applied.steps.length !== 1 || !('splice' in got) || !('splice' in sent))
|
|
326
|
+
return false;
|
|
327
|
+
const s = sent.splice;
|
|
328
|
+
const g = got.splice;
|
|
329
|
+
return (g.at === s.at &&
|
|
330
|
+
(g.delete ?? '') === (s.delete ?? '') &&
|
|
331
|
+
g.insert === s.insert &&
|
|
332
|
+
valueEqual(g.marks ?? [], s.marks ?? []));
|
|
333
|
+
}
|
|
334
|
+
/** Whether offset `i` of `s` falls between the halves of a surrogate pair. */
|
|
335
|
+
function splitsPair(s, i) {
|
|
336
|
+
if (i <= 0 || i >= s.length)
|
|
337
|
+
return false;
|
|
338
|
+
const lo = s.charCodeAt(i);
|
|
339
|
+
return lo >= 0xdc00 && lo <= 0xdfff;
|
|
340
|
+
}
|
|
341
|
+
/** Whether `s` holds a character that ends a block or a line, or stands for an island. */
|
|
342
|
+
function breaksText(s) {
|
|
343
|
+
return s.includes('\n') || s.includes(HARD_BREAK) || s.includes(ISLAND_SLOT);
|
|
344
|
+
}
|
|
345
|
+
function isExtMark(m) {
|
|
346
|
+
return m.type.startsWith('x-');
|
|
347
|
+
}
|
package/dist/core/codec/field.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// The prose leaf: `createField` (INVARIANTS §Surface). One content field, one PM view wired to
|
|
2
2
|
// the WASM edit surface.
|
|
3
3
|
//
|
|
4
|
-
// `dispatchTransaction` applies the transaction optimistically, lowers it to a `Change` (
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
4
|
+
// `dispatchTransaction` applies the transaction optimistically, lowers it to a `Change` (one
|
|
5
|
+
// splice against the last write's hash for a text edit inside one block, or `replace` for a field
|
|
6
|
+
// not yet at content rest, which has nothing to change), commits via `doc.apply` (a `text` leaf's
|
|
7
|
+
// whole text through the typed writer), then fires `onChange` if it committed and `onCaretMove`.
|
|
8
|
+
// A throw keeps the optimistic PM state and reports through `onError`.
|
|
8
9
|
// An external change re-hydrates through `applyExternal`, gated by `reconcile` except where the
|
|
9
10
|
// hold it re-evaluates flips.
|
|
10
|
-
import { baseKeymap } from 'prosemirror-commands';
|
|
11
11
|
import { gapCursor } from 'prosemirror-gapcursor';
|
|
12
12
|
import { history, isHistoryTransaction, redo, undo } from 'prosemirror-history';
|
|
13
13
|
import { keymap } from 'prosemirror-keymap';
|
|
@@ -20,7 +20,7 @@ import { tooltips } from '../tooltip.js';
|
|
|
20
20
|
import { reportError, errorMessage } from '../errors.js';
|
|
21
21
|
import { decode, fitsLeaf } from './decode.js';
|
|
22
22
|
import { offsetToPM, pmToOffset, buildLineIndex, lineIndexOf, mapThroughDelta } from './positions.js';
|
|
23
|
-
import { lower, pmToContent, scanContent, scanDoc } from './encode.js';
|
|
23
|
+
import { landedAsSent, lower, pmToContent, scanContent, scanDoc, spliceOf } from './encode.js';
|
|
24
24
|
import { capPlugin } from './cap.js';
|
|
25
25
|
import { islandPastePlugin } from './islands.js';
|
|
26
26
|
import { anchorsFromContent } from './marks.js';
|
|
@@ -29,7 +29,7 @@ import { inputRulesPlugin, undoRuleKeymap } from './inputrules.js';
|
|
|
29
29
|
import { linebreakPlugin } from './breaks.js';
|
|
30
30
|
import { bodyKeymap, holdsTab } from './keymap.js';
|
|
31
31
|
import { DEFAULT_LEAVE_STRINGS, leavePlugin } from './leave.js';
|
|
32
|
-
import { FIELD_KEYS, markKeymap } from './shortcuts.js';
|
|
32
|
+
import { FIELD_KEYS, leafBaseKeymap, markKeymap } from './shortcuts.js';
|
|
33
33
|
import { remoteKey } from './remote.js';
|
|
34
34
|
import { renameBlocks, reviewLayer } from './review.js';
|
|
35
35
|
import { valueDiffPlugin, valueSpans } from './value-diff.js';
|
|
@@ -252,6 +252,9 @@ export function createField(opts) {
|
|
|
252
252
|
// `known` is the codec's view of what the leaf holds: kept in sync after every
|
|
253
253
|
// own-edit so `reconcile` can tell an external change from the field's own.
|
|
254
254
|
const reconciler = createReconciler(shown());
|
|
255
|
+
/** The hash the leaf's own last write left on the field, while `reconciler.last` is that value:
|
|
256
|
+
* the base a splice commits against. */
|
|
257
|
+
let base;
|
|
255
258
|
let index; // rebuilt on every structural change
|
|
256
259
|
let view;
|
|
257
260
|
// The ghost's live cell: the ghost plugin reads it per pass, so moving it is an
|
|
@@ -472,16 +475,19 @@ export function createField(opts) {
|
|
|
472
475
|
return commitUnset();
|
|
473
476
|
if (plaintext)
|
|
474
477
|
return commitPlain(literalOf(newRt));
|
|
478
|
+
if (commitSplice(at, oldRt, newRt))
|
|
479
|
+
return true;
|
|
480
|
+
base = undefined;
|
|
475
481
|
try {
|
|
476
482
|
// Only a field not yet at content rest replaces by choice: neither an absent declared
|
|
477
483
|
// field nor an authored string has anchors to lose (`changeCommittable`).
|
|
478
484
|
if (!changeCommittable(doc, addr))
|
|
479
|
-
doc.replace(at, newRt);
|
|
485
|
+
base = doc.replace(at, newRt).hash;
|
|
480
486
|
else {
|
|
481
487
|
const change = lower(oldRt, newRt);
|
|
482
488
|
if (change) {
|
|
483
489
|
const asked = askCore(oldRt, change);
|
|
484
|
-
doc.apply(at, change);
|
|
490
|
+
base = doc.apply(at, change).hash;
|
|
485
491
|
if (asked.size || change.steps.some((step) => 'setBlock' in step))
|
|
486
492
|
adopt();
|
|
487
493
|
}
|
|
@@ -516,6 +522,28 @@ export function createField(opts) {
|
|
|
516
522
|
}
|
|
517
523
|
}
|
|
518
524
|
}
|
|
525
|
+
/**
|
|
526
|
+
* A text edit inside one block, committed as the one splice it is and against the hash of the
|
|
527
|
+
* value the reconciler holds, so neither side is read or sent whole. A store written since that
|
|
528
|
+
* hash refuses the base, and the commit takes the diff path. Whether it landed.
|
|
529
|
+
*/
|
|
530
|
+
function commitSplice(at, oldRt, newRt) {
|
|
531
|
+
if (base === undefined)
|
|
532
|
+
return false;
|
|
533
|
+
const change = spliceOf(oldRt, newRt);
|
|
534
|
+
if (!change)
|
|
535
|
+
return false;
|
|
536
|
+
let receipt;
|
|
537
|
+
try {
|
|
538
|
+
receipt = doc.apply(at, change, { base });
|
|
539
|
+
}
|
|
540
|
+
catch {
|
|
541
|
+
return false;
|
|
542
|
+
}
|
|
543
|
+
base = receipt.hash;
|
|
544
|
+
reconciler.commit(landedAsSent(receipt.applied, change) ? newRt : readLeaf(reader, addr));
|
|
545
|
+
return true;
|
|
546
|
+
}
|
|
519
547
|
/**
|
|
520
548
|
* Each block id the projection minted for a block the store does not hold, swapped in
|
|
521
549
|
* `change` for a placeholder the write fills, so the store is the one minter of block ids:
|
|
@@ -882,7 +910,7 @@ export function proseLeafPlugins(schema, opts) {
|
|
|
882
910
|
if (!opts.noInputRules)
|
|
883
911
|
list.push(inputRulesPlugin(schema), undoRuleKeymap());
|
|
884
912
|
list.push(keymap(editorKeymap(schema, opts.inline, !!opts.slash)));
|
|
885
|
-
list.push(keymap(
|
|
913
|
+
list.push(keymap(leafBaseKeymap));
|
|
886
914
|
if (schema.marks.link)
|
|
887
915
|
list.push(linkPastePlugin(schema.marks.link));
|
|
888
916
|
list.push(dragMovePlugin());
|
|
@@ -13,7 +13,8 @@ export { DEFAULT_LEAVE_STRINGS } from './leave.js';
|
|
|
13
13
|
export type { LeaveStrings } from './leave.js';
|
|
14
14
|
export type { BlockPlace, LeafUndrawn, ReviewAction, ReviewReport, TextReview } from './review.js';
|
|
15
15
|
export { wordDiff } from './review-diff.js';
|
|
16
|
-
export { valueDiffPlugin } from './value-diff.js';
|
|
16
|
+
export { valueDiffPlugin, valueSpans } from './value-diff.js';
|
|
17
|
+
export { reviewCaretPlugin } from './review-caret.js';
|
|
17
18
|
export type { ValueProposal, ValueState } from './value-diff.js';
|
|
18
19
|
export { asContent, planValue, valueChanges } from './value-plan.js';
|
|
19
20
|
export type { ValuePlan, ValueChange } from './value-plan.js';
|
package/dist/core/codec/index.js
CHANGED
|
@@ -26,7 +26,8 @@ export { DEFAULT_SLASH_STRINGS } from './slash.js';
|
|
|
26
26
|
// the visual tier's `strings` set its wording.
|
|
27
27
|
export { DEFAULT_LEAVE_STRINGS } from './leave.js';
|
|
28
28
|
export { wordDiff } from './review-diff.js';
|
|
29
|
-
export { valueDiffPlugin } from './value-diff.js';
|
|
29
|
+
export { valueDiffPlugin, valueSpans } from './value-diff.js';
|
|
30
|
+
export { reviewCaretPlugin } from './review-caret.js';
|
|
30
31
|
export { asContent, planValue, valueChanges } from './value-plan.js';
|
|
31
32
|
// The rich editor's shortcuts as a host lists them, read off the tables the keymaps bind from;
|
|
32
33
|
// the visual tier's `strings` set extends their wording, and the formatting popover binds its
|
|
@@ -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
|
-
* `
|
|
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
|
*
|
package/dist/core/codec/lists.js
CHANGED
|
@@ -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
|
-
* `
|
|
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: "
|
|
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
|
|
49
|
-
*
|
|
50
|
-
*
|
|
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
|
|
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: '
|
|
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
|
|
55
|
-
*
|
|
56
|
-
*
|
|
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
|
-
|
|
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
|
|
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
|
-
{
|
|
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 {
|
|
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(
|
|
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
|
|
23
|
-
* nearer answer to
|
|
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;
|
package/dist/core/codec/tasks.js
CHANGED
|
@@ -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 `
|
|
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
|
|
144
|
-
* nearer answer to
|
|
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) => {
|
package/dist/core/frame.d.ts
CHANGED
|
@@ -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
|
package/dist/core/frame.js
CHANGED
|
@@ -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
|
|
86
|
-
if (!
|
|
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
|
|
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
|
-
*
|
|
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 (
|
|
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
|
>
|
package/dist/visual/Card.svelte
CHANGED