@quillmark/svelte 0.35.1 → 0.36.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 +21 -13
- package/dist/core/address.d.ts +5 -0
- package/dist/core/address.js +14 -0
- package/dist/core/codec/field.d.ts +30 -7
- package/dist/core/codec/field.js +67 -4
- package/dist/core/codec/index.d.ts +6 -3
- package/dist/core/codec/index.js +2 -3
- package/dist/core/codec/prose.css +11 -77
- package/dist/core/codec/review.d.ts +27 -21
- package/dist/core/codec/review.js +87 -148
- package/dist/core/codec/shortcuts.d.ts +3 -3
- package/dist/core/codec/shortcuts.js +7 -7
- package/dist/core/codec/value-diff.d.ts +21 -0
- package/dist/core/codec/value-diff.js +83 -0
- package/dist/core/codec/value-plan.d.ts +29 -0
- package/dist/core/codec/value-plan.js +157 -0
- package/dist/core/theme.css +7 -2
- package/dist/visual/ArrayField.svelte +191 -17
- package/dist/visual/Card.svelte +12 -1
- package/dist/visual/Card.svelte.d.ts +3 -0
- package/dist/visual/EnumField.svelte +14 -4
- package/dist/visual/EnumField.svelte.d.ts +3 -0
- package/dist/visual/Field.svelte +56 -47
- package/dist/visual/FieldHint.svelte +1 -0
- package/dist/visual/FormatPopover.svelte +1 -0
- package/dist/visual/MatrixField.svelte +43 -5
- package/dist/visual/MatrixField.svelte.d.ts +5 -0
- package/dist/visual/NumberField.svelte +112 -3
- package/dist/visual/NumberField.svelte.d.ts +5 -0
- package/dist/visual/ObjectField.svelte +54 -16
- package/dist/visual/ProseField.svelte +16 -3
- package/dist/visual/ProseField.svelte.d.ts +3 -0
- package/dist/visual/ProseValue.svelte +38 -2
- package/dist/visual/ProseValue.svelte.d.ts +3 -0
- package/dist/visual/ReviewCard.svelte +347 -0
- package/dist/visual/ReviewCard.svelte.d.ts +19 -0
- package/dist/visual/ReviewProposal.svelte +104 -138
- package/dist/visual/ReviewProposal.svelte.d.ts +3 -6
- package/dist/visual/ReviewRows.svelte +6 -25
- package/dist/visual/ReviewRows.svelte.d.ts +1 -3
- package/dist/visual/SlashMenu.svelte +1 -0
- package/dist/visual/VariantField.svelte +44 -4
- package/dist/visual/VariantField.svelte.d.ts +5 -0
- package/dist/visual/VisualEditor.svelte +16 -7
- package/dist/visual/VisualEditor.svelte.d.ts +3 -0
- package/dist/visual/VisualEditorInner.svelte +840 -115
- package/dist/visual/VisualEditorInner.svelte.d.ts +3 -0
- package/dist/visual/index.d.ts +2 -2
- package/dist/visual/proposals.d.ts +13 -22
- package/dist/visual/proposals.js +69 -32
- package/dist/visual/props.d.ts +18 -18
- package/dist/visual/review.d.ts +68 -3
- package/dist/visual/review.js +36 -1
- package/dist/visual/review.svelte.d.ts +55 -15
- package/dist/visual/review.svelte.js +156 -42
- package/dist/visual/strings.d.ts +23 -6
- package/dist/visual/strings.js +10 -5
- package/dist/visual/undo.svelte.d.ts +3 -1
- package/dist/visual/undo.svelte.js +7 -3
- package/package.json +1 -1
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
cardPath,
|
|
36
36
|
nestedAddrForFieldPath,
|
|
37
37
|
fieldPathForAddr,
|
|
38
|
+
cardOfPath,
|
|
39
|
+
pathOnCard,
|
|
38
40
|
type DocPath,
|
|
39
41
|
type Landing
|
|
40
42
|
} from '../core/address.js';
|
|
@@ -46,6 +48,7 @@
|
|
|
46
48
|
Addr,
|
|
47
49
|
CardAddr,
|
|
48
50
|
Diagnostic,
|
|
51
|
+
Document,
|
|
49
52
|
PathStep,
|
|
50
53
|
PayloadItem,
|
|
51
54
|
QuillFieldSchema,
|
|
@@ -58,17 +61,30 @@
|
|
|
58
61
|
import { createStructuralUndo, setStructuralUndo, type UndoOffer } from './undo.svelte.js';
|
|
59
62
|
import { undoChord } from './listhistory.js';
|
|
60
63
|
import { removedCards, type RemovedCard } from './removed.js';
|
|
61
|
-
import { createReview, setReview } from './review.svelte.js';
|
|
64
|
+
import { createReview, setReview, type CardAdd } from './review.svelte.js';
|
|
62
65
|
import {
|
|
63
66
|
byBlocks,
|
|
67
|
+
byCard,
|
|
68
|
+
locate,
|
|
64
69
|
onField,
|
|
70
|
+
reviewText,
|
|
65
71
|
valueIn,
|
|
66
72
|
valueWith,
|
|
73
|
+
NO_PROJECTION,
|
|
74
|
+
type CardProposal,
|
|
67
75
|
type FieldProposal,
|
|
68
|
-
type ReviewDrawn
|
|
76
|
+
type ReviewDrawn,
|
|
77
|
+
type ReviewItem,
|
|
78
|
+
type ReviewProjection
|
|
69
79
|
} from './review.js';
|
|
80
|
+
import ReviewCard from './ReviewCard.svelte';
|
|
70
81
|
import type { CardId, CardOp, ChangeSource } from './signals.js';
|
|
71
|
-
import {
|
|
82
|
+
import {
|
|
83
|
+
REVIEW_KEYS,
|
|
84
|
+
type FieldController,
|
|
85
|
+
type LeafProjection,
|
|
86
|
+
type LeafViews
|
|
87
|
+
} from '../core/codec/index.js';
|
|
72
88
|
import {
|
|
73
89
|
IdSeq,
|
|
74
90
|
controlKind,
|
|
@@ -79,6 +95,8 @@
|
|
|
79
95
|
cardTitle,
|
|
80
96
|
kindTitle,
|
|
81
97
|
fieldValues,
|
|
98
|
+
fieldTitle,
|
|
99
|
+
humanize,
|
|
82
100
|
bodyEnabled,
|
|
83
101
|
provenanceMap,
|
|
84
102
|
resolvedByCardIndex,
|
|
@@ -129,7 +147,7 @@
|
|
|
129
147
|
onReview,
|
|
130
148
|
onReviewFocus,
|
|
131
149
|
onReviewDrawn,
|
|
132
|
-
|
|
150
|
+
reviewInset = 0,
|
|
133
151
|
class: className,
|
|
134
152
|
style
|
|
135
153
|
}: VisualEditorProps = $props();
|
|
@@ -167,6 +185,12 @@
|
|
|
167
185
|
/** The card keys as they stood when the host set its review list: an item names its card by
|
|
168
186
|
* index into these, so it stays on that card through every card op since. */
|
|
169
187
|
let listed: { list: VisualEditorProps['review']; cards: readonly string[] } | undefined;
|
|
188
|
+
/** A card the list named, taken out and put back under a new key, is still the card it
|
|
189
|
+
* named. */
|
|
190
|
+
function relist(was: string, now: string): void {
|
|
191
|
+
const held = cardsListed();
|
|
192
|
+
listed = { list: review, cards: held.map((key) => (key === was ? now : key)) };
|
|
193
|
+
}
|
|
170
194
|
function cardsListed(): readonly string[] {
|
|
171
195
|
const held = listed;
|
|
172
196
|
if (held && held.list === review) return held.cards;
|
|
@@ -317,17 +341,26 @@
|
|
|
317
341
|
const addr = nearestAddrForFieldPath(path);
|
|
318
342
|
return addr && declaredField(addr) ? resolveCardKey(addr, cardIds) : undefined;
|
|
319
343
|
};
|
|
320
|
-
/**
|
|
321
|
-
|
|
344
|
+
/** The key of the prose leaf a rich text field's or a body's path names. */
|
|
345
|
+
function proseKeyFor(path: DocPath): string | undefined {
|
|
346
|
+
const addr = addrForFieldPath(path);
|
|
347
|
+
if (!addr) return undefined;
|
|
348
|
+
const key = addr.field == null ? resolveCardKey({ card: addr.card }, cardIds) : reviewed(path);
|
|
349
|
+
return key && fieldKeyToString(key);
|
|
350
|
+
}
|
|
351
|
+
/** Take a field's or a card's answer back: what it wrote taken back, if anything, and the
|
|
352
|
+
* item reopened and brought into view, where no leaf's own undo scrolls to it. */
|
|
322
353
|
const giveBack = (id: string, leaf: string, back?: () => void): void => {
|
|
323
354
|
back?.();
|
|
324
355
|
reviewing.heard(id, 'reopen', leaf);
|
|
356
|
+
void reveal(id, false, true);
|
|
325
357
|
};
|
|
326
358
|
/** The host's list with each card it names by index moved to where that card stands now. */
|
|
327
359
|
const reviewItems = $derived.by(() => {
|
|
328
360
|
const was = cardsListed();
|
|
329
361
|
if (!review?.length || was === cardIds) return review;
|
|
330
362
|
return review.map((item) => {
|
|
363
|
+
if (byCard(item)) return item;
|
|
331
364
|
const field = cardMoved(item.field, was, cardIds);
|
|
332
365
|
return field === item.field ? item : { ...item, field };
|
|
333
366
|
});
|
|
@@ -354,31 +387,32 @@
|
|
|
354
387
|
key.card === undefined ? model.main : model.cards[cardIndexOf(key.card as CardId)];
|
|
355
388
|
return card?.values[key.field];
|
|
356
389
|
},
|
|
357
|
-
leafFor
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
chorded(id) {
|
|
365
|
-
if (!reviewAdvance) return;
|
|
366
|
-
const index = drewOrder.indexOf(id);
|
|
367
|
-
void tick().then(() => {
|
|
368
|
-
if (span.alive) void step(1, true, index < 0 ? undefined : { id, index });
|
|
369
|
-
});
|
|
390
|
+
leafFor: proseKeyFor,
|
|
391
|
+
listedCards: () => cardsListed(),
|
|
392
|
+
liveCards: () => cardIds,
|
|
393
|
+
answered(id, current) {
|
|
394
|
+
if (!current) return;
|
|
395
|
+
if (batching) advancing = id;
|
|
396
|
+
else advanceFrom(id, drewOrder);
|
|
370
397
|
},
|
|
371
398
|
writing(on) {
|
|
372
399
|
writing += on ? 1 : -1;
|
|
373
400
|
},
|
|
374
|
-
answer(id, item, action, key) {
|
|
401
|
+
answer(id, item, action, key, write) {
|
|
375
402
|
let back: (() => void) | undefined;
|
|
376
|
-
if (
|
|
377
|
-
back = takeField(item);
|
|
403
|
+
if (write && item && onField(item)) {
|
|
404
|
+
back = takeField(item, write);
|
|
405
|
+
if (!back) return false;
|
|
406
|
+
} else if (action === 'accept' && item && (onField(item) || byCard(item))) {
|
|
407
|
+
back = onField(item) ? takeField(item) : takeCard(item);
|
|
378
408
|
if (!back) return false;
|
|
379
409
|
}
|
|
380
410
|
onReview?.({ id, action });
|
|
381
411
|
if (action !== 'accept' && action !== 'dismiss') return true;
|
|
412
|
+
if (item && byCard(item)) {
|
|
413
|
+
record(id, () => giveBack(id, '', back));
|
|
414
|
+
return true;
|
|
415
|
+
}
|
|
382
416
|
const field = item && onField(item) ? reviewed(item.field) : undefined;
|
|
383
417
|
const leaf = key ?? (field && fieldKeyToString(field));
|
|
384
418
|
if (leaf === undefined) return true;
|
|
@@ -389,8 +423,7 @@
|
|
|
389
423
|
? action === 'accept'
|
|
390
424
|
? () => void leaves.prose(leaf)?.undoReview()
|
|
391
425
|
: () => void leaves.prose(leaf)?.reopenReview(id)
|
|
392
|
-
: () => giveBack(id, leaf, back)
|
|
393
|
-
back && merged.reviewAccepted
|
|
426
|
+
: () => giveBack(id, leaf, back)
|
|
394
427
|
);
|
|
395
428
|
return true;
|
|
396
429
|
}
|
|
@@ -403,8 +436,6 @@
|
|
|
403
436
|
interface Answered {
|
|
404
437
|
ids: string[];
|
|
405
438
|
inverses: (() => void)[];
|
|
406
|
-
/** The toast it stands on; none where the key alone takes it back. */
|
|
407
|
-
notice?: string;
|
|
408
439
|
}
|
|
409
440
|
let journal: Answered[] = [];
|
|
410
441
|
/** The entry a batch of answers records into. */
|
|
@@ -419,13 +450,7 @@
|
|
|
419
450
|
}
|
|
420
451
|
function offerJournal(): void {
|
|
421
452
|
const top = journal.at(-1);
|
|
422
|
-
journalOffer =
|
|
423
|
-
top &&
|
|
424
|
-
undo.offer(top.notice ?? '', unanswer, {
|
|
425
|
-
standing: true,
|
|
426
|
-
quiet: top.notice === undefined,
|
|
427
|
-
answer: true
|
|
428
|
-
});
|
|
453
|
+
journalOffer = top && undo.offer('', unanswer, { standing: true, quiet: true, answer: true });
|
|
429
454
|
}
|
|
430
455
|
function unanswer(): void {
|
|
431
456
|
const top = journal.pop();
|
|
@@ -438,7 +463,7 @@
|
|
|
438
463
|
}
|
|
439
464
|
offerJournal();
|
|
440
465
|
}
|
|
441
|
-
function record(id: string, inverse: () => void
|
|
466
|
+
function record(id: string, inverse: () => void): void {
|
|
442
467
|
if (batching) {
|
|
443
468
|
batching.ids.push(id);
|
|
444
469
|
batching.inverses.push(inverse);
|
|
@@ -447,19 +472,20 @@
|
|
|
447
472
|
// Another step took the key since: the answers before it are no longer the last thing
|
|
448
473
|
// that happened.
|
|
449
474
|
if (!journalOffer || !undo.holds(journalOffer)) journal = [];
|
|
450
|
-
journal.push({ ids: [id], inverses: [inverse]
|
|
475
|
+
journal.push({ ids: [id], inverses: [inverse] });
|
|
451
476
|
offerJournal();
|
|
452
477
|
}
|
|
453
478
|
|
|
454
479
|
/**
|
|
455
480
|
* Take a field's proposal: its value down the lane the field's own control commits by, so
|
|
456
|
-
* the writer checks it and `onChange` reports it
|
|
457
|
-
*
|
|
458
|
-
* the
|
|
459
|
-
*
|
|
460
|
-
* the value, which the field then says as it
|
|
481
|
+
* the writer checks it and `onChange` reports it, or `edit`, the value a reader's own commit
|
|
482
|
+
* under it writes. A text leaf re-reads what was written. A place inside the field is written
|
|
483
|
+
* as the whole value with that place alone changed, down the lane an edit of the place takes.
|
|
484
|
+
* Returns the write back to the value it replaced, which the journal runs before any older
|
|
485
|
+
* answer's, or `undefined` where the writer refused the value, which the field then says as it
|
|
486
|
+
* says any refused commit.
|
|
461
487
|
*/
|
|
462
|
-
function takeField(item: FieldProposal): (() => void) | undefined {
|
|
488
|
+
function takeField(item: FieldProposal, edit?: { value: unknown }): (() => void) | undefined {
|
|
463
489
|
const key = reviewed(item.field);
|
|
464
490
|
if (!key?.field || typeof key.card === 'number') return undefined;
|
|
465
491
|
const isMain = key.card === undefined;
|
|
@@ -476,12 +502,14 @@
|
|
|
476
502
|
writing++;
|
|
477
503
|
try {
|
|
478
504
|
const before = doc.getStored(addr);
|
|
479
|
-
|
|
505
|
+
const to = (place: unknown): unknown => (edit ? edit.value : reviewing.writes(item, place));
|
|
506
|
+
let after: unknown;
|
|
480
507
|
if (!addrForFieldPath(item.field)) {
|
|
481
508
|
const steps = reviewing.at(leaf).nested?.find((e) => e.item.id === item.id)?.steps;
|
|
482
509
|
if (!steps) return undefined;
|
|
483
|
-
|
|
484
|
-
|
|
510
|
+
const value = current();
|
|
511
|
+
after = valueWith(value, steps, to(valueIn(value, steps)));
|
|
512
|
+
} else after = to(current());
|
|
485
513
|
if (!write(after)) return undefined;
|
|
486
514
|
return () => void write(before);
|
|
487
515
|
} finally {
|
|
@@ -495,15 +523,114 @@
|
|
|
495
523
|
return fieldValues((isMain ? doc.main : doc.card(at)).payloadItems)[name];
|
|
496
524
|
}
|
|
497
525
|
}
|
|
526
|
+
/**
|
|
527
|
+
* Take a card proposal: the card written or taken out as the editor's own card edit, which
|
|
528
|
+
* `onChange` reports with its op. A new card is written with its `$id` where no card holds
|
|
529
|
+
* that one, after the card it stands after as drawn. Returns the edit's inverse, which the
|
|
530
|
+
* journal runs before any older answer's: a removal puts the card back where it stood, and
|
|
531
|
+
* the list still names it. `undefined` where there is nothing to write.
|
|
532
|
+
*/
|
|
533
|
+
function takeCard(item: CardProposal): (() => void) | undefined {
|
|
534
|
+
if ('remove' in item) {
|
|
535
|
+
const key = cardsListed()[item.remove];
|
|
536
|
+
const at = key === undefined ? -1 : cardIndexOf(key);
|
|
537
|
+
if (at < 0) return undefined;
|
|
538
|
+
const card = doc.card(at);
|
|
539
|
+
doc.removeCard(at);
|
|
540
|
+
undo.withdraw();
|
|
541
|
+
arm.arm();
|
|
542
|
+
setCards(cardIds.filter((_, k) => k !== at));
|
|
543
|
+
forget(key);
|
|
544
|
+
bump('structure', key, undefined, { op: 'remove', at });
|
|
545
|
+
return () => {
|
|
546
|
+
const i = Math.min(at, cardIds.length);
|
|
547
|
+
if (!placeCard(card, i)) return;
|
|
548
|
+
const back = seq.next();
|
|
549
|
+
relist(key, back);
|
|
550
|
+
arm.arm();
|
|
551
|
+
setCards([...cardIds.slice(0, i), back, ...cardIds.slice(i)]);
|
|
552
|
+
bump('structure', back, i, { op: 'insert', at: i });
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
const lead = [...reviewing.cards.adds].find(([, list]) =>
|
|
556
|
+
list.some((a) => a.id === item.id)
|
|
557
|
+
)?.[0];
|
|
558
|
+
if (lead === undefined) return undefined;
|
|
559
|
+
const at = lead === 'head' ? 0 : lead === 'end' ? cardIds.length : cardIndexOf(lead) + 1;
|
|
560
|
+
if (at < 0 || !placeCard(item.add, at)) return undefined;
|
|
561
|
+
const key = seq.next();
|
|
562
|
+
arm.arm();
|
|
563
|
+
setCards([...cardIds.slice(0, at), key, ...cardIds.slice(at)]);
|
|
564
|
+
reviewing.wrote(item.id, key);
|
|
565
|
+
bump('structure', key, at, { op: 'insert', at });
|
|
566
|
+
return () => {
|
|
567
|
+
const i = cardIndexOf(key);
|
|
568
|
+
reviewing.wrote(item.id, undefined);
|
|
569
|
+
if (i < 0) return;
|
|
570
|
+
doc.removeCard(i);
|
|
571
|
+
arm.arm();
|
|
572
|
+
setCards(cardIds.filter((_, k) => k !== i));
|
|
573
|
+
forget(key);
|
|
574
|
+
bump('structure', key, undefined, { op: 'remove', at: i });
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
/** Write `card` into the document at `at`, with its `$id` where no card holds that one. */
|
|
578
|
+
function placeCard(card: CardAdd['add'], at: number): boolean {
|
|
579
|
+
const { id, ...bare } = card;
|
|
580
|
+
const free = id !== undefined && !cardIds.some((_, k) => doc.card(k).id === id);
|
|
581
|
+
try {
|
|
582
|
+
try {
|
|
583
|
+
doc.unchecked.insertCard(free ? card : bare, at);
|
|
584
|
+
} catch (e) {
|
|
585
|
+
if (!free) throw e;
|
|
586
|
+
doc.unchecked.insertCard(bare, at);
|
|
587
|
+
}
|
|
588
|
+
return true;
|
|
589
|
+
} catch (e) {
|
|
590
|
+
reportError(onError, {
|
|
591
|
+
code: 'card-op-failed',
|
|
592
|
+
severity: 'error',
|
|
593
|
+
message: `adding a ${card.kind} card failed: ${errorMessage(e)}`,
|
|
594
|
+
cause: e
|
|
595
|
+
});
|
|
596
|
+
return false;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
/** What a new card's preview shows: the title its header would, and the start of its body,
|
|
600
|
+
* else its values as words. */
|
|
601
|
+
function previewOf(item: CardAdd): {
|
|
602
|
+
title: string;
|
|
603
|
+
fields: { label: string; value: string }[];
|
|
604
|
+
text: string;
|
|
605
|
+
} {
|
|
606
|
+
const { add } = item;
|
|
607
|
+
const schema = quill.schema.card_kinds?.[add.kind];
|
|
608
|
+
const values = fieldValues(add.payloadItems);
|
|
609
|
+
const named = (add.ext?.editor as { title?: unknown } | undefined)?.title;
|
|
610
|
+
const title = cardTitle(
|
|
611
|
+
schema,
|
|
612
|
+
add.kind,
|
|
613
|
+
values,
|
|
614
|
+
typeof named === 'string' ? named : undefined
|
|
615
|
+
);
|
|
616
|
+
const words = { on: merged.reviewOn, off: merged.reviewOff };
|
|
617
|
+
const fields = Object.entries(values).flatMap(([key, v]) => {
|
|
618
|
+
const value = reviewText(v, words);
|
|
619
|
+
const field = schema?.fields[key];
|
|
620
|
+
return value ? [{ label: field ? fieldTitle(key, field) : humanize(key), value }] : [];
|
|
621
|
+
});
|
|
622
|
+
return { title, fields, text: add.body?.text?.trim() ?? '' };
|
|
623
|
+
}
|
|
498
624
|
setReview(reviewing);
|
|
499
625
|
span.onEnd(reviewing.dispose);
|
|
500
|
-
// The
|
|
501
|
-
// starts from.
|
|
626
|
+
// The current change, to a host counting its place: each change, and not the nothing a
|
|
627
|
+
// mount starts from.
|
|
502
628
|
let reported: string | undefined;
|
|
503
629
|
$effect(() => {
|
|
504
630
|
const id = reviewing.lit;
|
|
505
631
|
if (id === reported) return;
|
|
506
632
|
reported = id;
|
|
633
|
+
typing = false;
|
|
507
634
|
onReviewFocus?.(id);
|
|
508
635
|
});
|
|
509
636
|
/** The open items drawn, in document order: each id's first element under the root, then
|
|
@@ -514,6 +641,8 @@
|
|
|
514
641
|
for (const report of reviewing.reports.values()) for (const id of report.ids) drawn.add(id);
|
|
515
642
|
for (const item of reviewing.items)
|
|
516
643
|
if (onField(item) && !fieldUndrawn.has(item.id)) drawn.add(item.id);
|
|
644
|
+
for (const list of reviewing.cards.adds.values()) for (const item of list) drawn.add(item.id);
|
|
645
|
+
for (const item of reviewing.cards.removes.values()) drawn.add(item.id);
|
|
517
646
|
const order: string[] = [];
|
|
518
647
|
const seen = new Set<string>();
|
|
519
648
|
const take = (id: string | null): void => {
|
|
@@ -522,7 +651,7 @@
|
|
|
522
651
|
order.push(id);
|
|
523
652
|
};
|
|
524
653
|
for (const el of rootEl?.querySelectorAll('[data-qm-review]') ?? [])
|
|
525
|
-
|
|
654
|
+
for (const id of reviewIds(el)) take(id);
|
|
526
655
|
for (const item of reviewing.items) take(item.id);
|
|
527
656
|
return order;
|
|
528
657
|
}
|
|
@@ -555,13 +684,17 @@
|
|
|
555
684
|
};
|
|
556
685
|
}
|
|
557
686
|
// The report, to a host counting its own list: each change, read once the leaves the change
|
|
558
|
-
// mounted have drawn, so a list just handed over is not reported as anchored nowhere.
|
|
687
|
+
// mounted have drawn, so a list just handed over is not reported as anchored nowhere. A
|
|
688
|
+
// review starts on its first change, and goes on to the first open one wherever the current
|
|
689
|
+
// one went without an answer moving it on.
|
|
559
690
|
const NO_REPORT = JSON.stringify({ open: [], outdated: [], undrawn: [] } satisfies ReviewDrawn);
|
|
560
691
|
let drewReport = NO_REPORT;
|
|
561
|
-
let drewOrder
|
|
692
|
+
let drewOrder = $state.raw<readonly string[]>([]);
|
|
693
|
+
let drewOutdated = $state.raw<readonly string[]>([]);
|
|
562
694
|
$effect(() => {
|
|
563
695
|
void reviewing.items;
|
|
564
696
|
void reviewing.fieldUndrawn;
|
|
697
|
+
void reviewing.cards;
|
|
565
698
|
for (const id of reviewing.fieldOutdated) void id;
|
|
566
699
|
for (const report of reviewing.reports.values()) void report;
|
|
567
700
|
let live = true;
|
|
@@ -569,6 +702,8 @@
|
|
|
569
702
|
if (!live || !span.alive) return;
|
|
570
703
|
const report = reviewReport();
|
|
571
704
|
drewOrder = report.open;
|
|
705
|
+
drewOutdated = report.outdated;
|
|
706
|
+
if (reviewing.lit === undefined && report.open.length) reviewing.reveal(report.open[0]);
|
|
572
707
|
const joined = JSON.stringify(report);
|
|
573
708
|
if (joined === drewReport) return;
|
|
574
709
|
drewReport = joined;
|
|
@@ -578,45 +713,158 @@
|
|
|
578
713
|
live = false;
|
|
579
714
|
};
|
|
580
715
|
});
|
|
716
|
+
/** The current change answered by a host's batch, to move on from once the batch is done. */
|
|
717
|
+
let advancing: string | undefined;
|
|
718
|
+
/**
|
|
719
|
+
* Make the next open change current after `id`'s answer, in `order` as it stood before the
|
|
720
|
+
* answer, round from the end. The pane scrolls only where that change is out of comfortable
|
|
721
|
+
* view, and neither the focus nor the caret moves.
|
|
722
|
+
*/
|
|
723
|
+
function advanceFrom(id: string, order: readonly string[]): void {
|
|
724
|
+
const open = new Set(reviewing.items.map((item) => item.id));
|
|
725
|
+
const at = order.indexOf(id);
|
|
726
|
+
const next = [...order.slice(at + 1), ...order.slice(0, Math.max(at, 0))].find((n) =>
|
|
727
|
+
open.has(n)
|
|
728
|
+
);
|
|
729
|
+
if (next === undefined) return;
|
|
730
|
+
typing = false;
|
|
731
|
+
reviewing.reveal(next);
|
|
732
|
+
void reveal(next, false, true);
|
|
733
|
+
}
|
|
581
734
|
/** The item a step last went to, and where it stood in the order then, so a step from an
|
|
582
735
|
* item since answered goes on from its place. */
|
|
583
736
|
let stepped: { id: string; index: number } | undefined;
|
|
584
|
-
async function step(
|
|
585
|
-
dir: 1 | -1,
|
|
586
|
-
focus: boolean,
|
|
587
|
-
from?: { id: string; index: number }
|
|
588
|
-
): Promise<string | undefined> {
|
|
737
|
+
async function step(dir: 1 | -1, focus: boolean): Promise<string | undefined> {
|
|
589
738
|
if (!span.alive) return undefined;
|
|
590
739
|
const order = reviewOrder();
|
|
591
740
|
if (!order.length) return undefined;
|
|
592
|
-
const at =
|
|
593
|
-
const past = from ?? stepped;
|
|
741
|
+
const at = order.indexOf(reviewing.lit ?? stepped?.id ?? '');
|
|
594
742
|
const next =
|
|
595
|
-
at >= 0
|
|
743
|
+
at >= 0
|
|
744
|
+
? at + dir
|
|
745
|
+
: stepped
|
|
746
|
+
? dir > 0
|
|
747
|
+
? stepped.index
|
|
748
|
+
: stepped.index - 1
|
|
749
|
+
: dir > 0
|
|
750
|
+
? 0
|
|
751
|
+
: -1;
|
|
596
752
|
const index = ((next % order.length) + order.length) % order.length;
|
|
597
753
|
const id = order[index];
|
|
598
754
|
stepped = { id, index };
|
|
755
|
+
typing = false;
|
|
599
756
|
await reveal(id, focus, true);
|
|
600
757
|
return id;
|
|
601
758
|
}
|
|
602
|
-
|
|
759
|
+
|
|
760
|
+
// ── The review keys: the editor's wherever the focus is while a review is open ──────
|
|
761
|
+
/** Answer the current change, as its card would. False with none open. */
|
|
762
|
+
function answerCurrent(action: 'accept' | 'dismiss'): boolean {
|
|
763
|
+
const id = reviewing.lit;
|
|
764
|
+
return id !== undefined && answerReview([id], action).length > 0;
|
|
765
|
+
}
|
|
766
|
+
/** Whether a key at `target` is the review's: anywhere but a text control outside the editor,
|
|
767
|
+
* which keeps its own keys, or another editor. */
|
|
768
|
+
function reviewHears(target: EventTarget | null): boolean {
|
|
769
|
+
if (!(target instanceof Element) || !rootEl) return false;
|
|
770
|
+
if (rootEl.contains(target)) return true;
|
|
771
|
+
if (target.closest('.qm-editor')) return false;
|
|
772
|
+
return !target.closest('input, textarea, select, [contenteditable="true"]');
|
|
773
|
+
}
|
|
774
|
+
let answerCard = $state<ReviewCard | undefined>();
|
|
775
|
+
const reviewKeys = keydownHandler({
|
|
776
|
+
[REVIEW_KEYS.accept]: () => answerCurrent('accept'),
|
|
777
|
+
[REVIEW_KEYS.dismiss]: () => answerCurrent('dismiss'),
|
|
603
778
|
[REVIEW_KEYS.next]: () => {
|
|
604
|
-
void step(1,
|
|
779
|
+
void step(1, inside);
|
|
605
780
|
return true;
|
|
606
781
|
},
|
|
607
782
|
[REVIEW_KEYS.previous]: () => {
|
|
608
|
-
void step(-1,
|
|
783
|
+
void step(-1, inside);
|
|
784
|
+
return true;
|
|
785
|
+
},
|
|
786
|
+
'Alt-F10': () => {
|
|
787
|
+
if (!answerCard || document.getSelection()?.isCollapsed === false) return false;
|
|
788
|
+
void answerCard.enter();
|
|
609
789
|
return true;
|
|
610
790
|
}
|
|
611
791
|
});
|
|
612
|
-
/**
|
|
613
|
-
|
|
614
|
-
|
|
792
|
+
/** Whether the key being matched was pressed inside the editor, where a step takes the caret
|
|
793
|
+
* with it. */
|
|
794
|
+
let inside = false;
|
|
795
|
+
/** The review keys, captured on the document ahead of every other binding of them: a task
|
|
796
|
+
* item's tick, a leaf's arrows, a host's own. */
|
|
797
|
+
function onReviewKey(e: KeyboardEvent): void {
|
|
798
|
+
if (e.isComposing || reviewing.lit === undefined || !reviewHears(e.target)) return;
|
|
799
|
+
inside = !!rootEl?.contains(e.target as Node);
|
|
615
800
|
// The bindings read no view: this is `prosemirror-keymap`'s chord matcher alone.
|
|
616
|
-
if (!
|
|
801
|
+
if (!reviewKeys({} as never, e)) return;
|
|
617
802
|
e.preventDefault();
|
|
618
803
|
e.stopPropagation();
|
|
619
804
|
}
|
|
805
|
+
|
|
806
|
+
/** The reader is typing: the card keeps out of the way until the pointer moves or the
|
|
807
|
+
* current change does. */
|
|
808
|
+
let typing = $state(false);
|
|
809
|
+
let pointerAt = { x: NaN, y: NaN };
|
|
810
|
+
function onTyped(e: KeyboardEvent): void {
|
|
811
|
+
if (reviewing.lit === undefined || e.metaKey || e.ctrlKey || e.altKey) return;
|
|
812
|
+
if (e.key.length === 1 || e.key === 'Backspace' || e.key === 'Delete' || e.key === 'Enter')
|
|
813
|
+
typing = true;
|
|
814
|
+
}
|
|
815
|
+
function onPointerMove(e: PointerEvent): void {
|
|
816
|
+
if (!typing) {
|
|
817
|
+
pointerAt = { x: e.clientX, y: e.clientY };
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
const moved = Math.abs(e.clientX - pointerAt.x) + Math.abs(e.clientY - pointerAt.y);
|
|
821
|
+
pointerAt = { x: e.clientX, y: e.clientY };
|
|
822
|
+
if (moved >= MOVED_PX) typing = false;
|
|
823
|
+
}
|
|
824
|
+
/** How far, in px, the pointer moves before it means to: a hand resting on a trackpad
|
|
825
|
+
* jitters by less. */
|
|
826
|
+
const MOVED_PX = 3;
|
|
827
|
+
/** The items an element draws: one for a piece of a change, several for a control that
|
|
828
|
+
* marks a proposal for each place inside it. */
|
|
829
|
+
function reviewIds(el: Element | null | undefined): string[] {
|
|
830
|
+
return el?.getAttribute('data-qm-review')?.split(' ').filter(Boolean) ?? [];
|
|
831
|
+
}
|
|
832
|
+
/** A press on a change makes it current at once. */
|
|
833
|
+
function onPick(e: PointerEvent): void {
|
|
834
|
+
const ids = reviewIds((e.target as Element | null)?.closest?.('[data-qm-review]'));
|
|
835
|
+
const id = ids.includes(reviewing.lit ?? '') ? reviewing.lit : ids[0];
|
|
836
|
+
if (id && reviewing.items.some((item) => item.id === id)) {
|
|
837
|
+
typing = false;
|
|
838
|
+
reviewing.reveal(id);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
/** What the change `id` is to: the field it is drawn in, the body, or the card it adds or
|
|
842
|
+
* takes out. */
|
|
843
|
+
function reviewName(id: string): string {
|
|
844
|
+
const item = reviewing.items.find((it) => it.id === id);
|
|
845
|
+
if (!item) return '';
|
|
846
|
+
if ('add' in item) return `${merged.reviewNewCard}, ${previewOf(item).title}`;
|
|
847
|
+
if ('remove' in item) {
|
|
848
|
+
const c = model.cards.find((c) => reviewing.cards.removes.get(c.id)?.id === id);
|
|
849
|
+
const t = c && titled(c);
|
|
850
|
+
return t ? `${merged.reviewRemoveCard}, ${t.titleOverride || t.titlePlaceholder}` : '';
|
|
851
|
+
}
|
|
852
|
+
if (addrForFieldPath(item.field)?.field == null && byBlocks(item)) return merged.bodyLabel;
|
|
853
|
+
const key = reviewed(item.field);
|
|
854
|
+
if (!key?.field) return '';
|
|
855
|
+
const isMain = key.card === undefined;
|
|
856
|
+
const card = isMain ? model.main : model.cards[cardIndexOf(key.card as CardId)];
|
|
857
|
+
const schema = isMain ? quill.schema.main : quill.schema.card_kinds?.[card?.kind ?? ''];
|
|
858
|
+
const sub = schema?.fields[key.field];
|
|
859
|
+
return sub ? fieldTitle(key.field, sub) : humanize(key.field);
|
|
860
|
+
}
|
|
861
|
+
/** Where the current change stands and what it is to, for a screen reader to hear on each
|
|
862
|
+
* step. */
|
|
863
|
+
const reviewPlace = $derived.by(() => {
|
|
864
|
+
const id = reviewing.lit;
|
|
865
|
+
const at = id === undefined ? -1 : drewOrder.indexOf(id);
|
|
866
|
+
return at < 0 ? '' : merged.reviewPosition(at + 1, drewOrder.length, reviewName(id!));
|
|
867
|
+
});
|
|
620
868
|
// Card handles, for `setCaret`'s reveal hop: the one thing a leaf's own controller
|
|
621
869
|
// cannot do, since which group is open is the card's state (Card §revealLeaf).
|
|
622
870
|
type CardHandle = {
|
|
@@ -1393,48 +1641,81 @@
|
|
|
1393
1641
|
// ── Review ──────────────────────────────────────────────────────────────────
|
|
1394
1642
|
|
|
1395
1643
|
/**
|
|
1396
|
-
* Bring the review item `id` to the reader: open the panel holding
|
|
1397
|
-
* middle of the view
|
|
1398
|
-
* to look, unless `focus` asks for it: the caret then goes into the item, or the focus
|
|
1399
|
-
* its field
|
|
1644
|
+
* Bring the review item `id` to the reader as the current change: open the panel holding
|
|
1645
|
+
* it and scroll it to the middle of the view. The focus stays where it is, the reader having
|
|
1646
|
+
* asked to look, unless `focus` asks for it: the caret then goes into the item, or the focus
|
|
1647
|
+
* to its field. False for an item the editor does not draw.
|
|
1400
1648
|
*/
|
|
1401
1649
|
export function revealReview(id: string, opts: { focus?: boolean } = {}): Promise<boolean> {
|
|
1402
1650
|
return reveal(id, opts.focus ?? false, false);
|
|
1403
1651
|
}
|
|
1404
|
-
/** {@link revealReview}; a step scrolls
|
|
1405
|
-
* so a walk down neighbouring items
|
|
1406
|
-
* pane that scrolls on its own is shown by that pane. */
|
|
1652
|
+
/** {@link revealReview}; a step scrolls only where the item is out of comfortable view, room
|
|
1653
|
+
* for the answer card under it included, so a walk down neighbouring items moves the card
|
|
1654
|
+
* and not the page, and an item in a pane that scrolls on its own is shown by that pane. */
|
|
1407
1655
|
async function reveal(id: string, focus: boolean, stepping: boolean): Promise<boolean> {
|
|
1408
1656
|
if (!span.alive) return false;
|
|
1409
1657
|
const key = reviewing.keyOf(id);
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1658
|
+
const card = byCardId(id);
|
|
1659
|
+
if (key === undefined && !card) return false;
|
|
1660
|
+
if (key !== undefined) {
|
|
1661
|
+
mainCard?.revealLeaf(key);
|
|
1662
|
+
for (const ref of cardRefs) ref?.revealLeaf(key);
|
|
1663
|
+
}
|
|
1413
1664
|
if (!(await span.resumes(tick()))) return false;
|
|
1414
1665
|
reviewing.reveal(id);
|
|
1415
|
-
if (focus && !leaves.prose(key)?.enterReview(id))
|
|
1416
|
-
|
|
1666
|
+
if (focus && key !== undefined && !leaves.prose(key)?.enterReview(id))
|
|
1667
|
+
leaves.control(key)?.focus();
|
|
1668
|
+
// The current item is drawn again, so its element is read once it has been.
|
|
1417
1669
|
if (!(await span.resumes(tick()))) return false;
|
|
1670
|
+
const els = [...(rootEl?.querySelectorAll<HTMLElement>('[data-qm-review]') ?? [])].filter(
|
|
1671
|
+
(el) => reviewIds(el).includes(id)
|
|
1672
|
+
);
|
|
1418
1673
|
const at =
|
|
1419
|
-
leaves.prose(key)?.reviewElements(id)[0] ??
|
|
1420
|
-
[
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
leaves.control(key)?.el;
|
|
1674
|
+
(key !== undefined ? leaves.prose(key)?.reviewElements(id)[0] : undefined) ??
|
|
1675
|
+
els[0] ??
|
|
1676
|
+
(key !== undefined ? leaves.control(key)?.el : undefined);
|
|
1677
|
+
if (!at || (stepping && comfortable(els.length ? els : [at]))) return true;
|
|
1424
1678
|
const reduce = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
|
|
1425
|
-
at
|
|
1426
|
-
behavior: reduce ? 'auto' : 'smooth',
|
|
1427
|
-
block: stepping ? 'nearest' : 'center'
|
|
1428
|
-
});
|
|
1679
|
+
at.scrollIntoView({ behavior: reduce ? 'auto' : 'smooth', block: 'center' });
|
|
1429
1680
|
return true;
|
|
1430
1681
|
}
|
|
1682
|
+
/** Whether the open card item `id` is drawn. */
|
|
1683
|
+
function byCardId(id: string): boolean {
|
|
1684
|
+
for (const list of reviewing.cards.adds.values())
|
|
1685
|
+
if (list.some((a) => a.id === id)) return true;
|
|
1686
|
+
for (const item of reviewing.cards.removes.values()) if (item.id === id) return true;
|
|
1687
|
+
return false;
|
|
1688
|
+
}
|
|
1689
|
+
/** Whether `els` stand in the view the editor scrolls in, clear of the host's chrome at its
|
|
1690
|
+
* foot, with the answer card's room under them. */
|
|
1691
|
+
function comfortable(els: readonly HTMLElement[]): boolean {
|
|
1692
|
+
const rects = els.map((el) => el.getBoundingClientRect()).filter((r) => r.width || r.height);
|
|
1693
|
+
if (!rects.length) return false;
|
|
1694
|
+
let top = 0;
|
|
1695
|
+
let bottom = window.innerHeight;
|
|
1696
|
+
for (let at = rootEl ?? null; at; at = at.parentElement) {
|
|
1697
|
+
const { overflowY } = getComputedStyle(at);
|
|
1698
|
+
if (overflowY !== 'auto' && overflowY !== 'scroll') continue;
|
|
1699
|
+
const box = at.getBoundingClientRect();
|
|
1700
|
+
top = Math.max(box.top, 0);
|
|
1701
|
+
bottom = Math.min(box.bottom, window.innerHeight);
|
|
1702
|
+
break;
|
|
1703
|
+
}
|
|
1704
|
+
const room = (spacePx(rootEl, 1) ?? 0) * CARD_ROOM;
|
|
1705
|
+
return (
|
|
1706
|
+
Math.min(...rects.map((r) => r.top)) >= top &&
|
|
1707
|
+
Math.max(...rects.map((r) => r.bottom)) <= bottom - reviewInset - room
|
|
1708
|
+
);
|
|
1709
|
+
}
|
|
1710
|
+
/** The room the answer card takes under a change, in `--_qm-space` rungs. */
|
|
1711
|
+
const CARD_ROOM = 7;
|
|
1431
1712
|
|
|
1432
1713
|
/**
|
|
1433
|
-
* Answer items as
|
|
1714
|
+
* Answer items as the answer card would, in document order: `'all'` is every item drawn. An
|
|
1434
1715
|
* item that cannot be answered (a proposal that no longer writes, a value the field's writer
|
|
1435
|
-
* refuses) stands. `onReview` hears each answer, and neither the focus nor the caret moves
|
|
1436
|
-
*
|
|
1437
|
-
* Returns the ids answered.
|
|
1716
|
+
* refuses) stands. `onReview` hears each answer, and neither the focus nor the caret moves;
|
|
1717
|
+
* where the current change is answered, the next open one is current. ⌘Z takes the call
|
|
1718
|
+
* back whole. Returns the ids answered.
|
|
1438
1719
|
*/
|
|
1439
1720
|
export function answerReview(
|
|
1440
1721
|
ids: readonly string[] | 'all',
|
|
@@ -1442,7 +1723,12 @@
|
|
|
1442
1723
|
): string[] {
|
|
1443
1724
|
if (!span.alive) return [];
|
|
1444
1725
|
const order = reviewOrder();
|
|
1445
|
-
|
|
1726
|
+
// Accepting every item leaves the outdated ones open: each would write over the reader.
|
|
1727
|
+
const outdated = new Set(ids === 'all' && action === 'accept' ? reviewReport().outdated : []);
|
|
1728
|
+
const asked =
|
|
1729
|
+
ids === 'all'
|
|
1730
|
+
? order.filter((id) => !outdated.has(id))
|
|
1731
|
+
: order.filter((id) => ids.includes(id));
|
|
1446
1732
|
const out: string[] = [];
|
|
1447
1733
|
const entry: Answered = { ids: [], inverses: [] };
|
|
1448
1734
|
batching = entry;
|
|
@@ -1453,9 +1739,10 @@
|
|
|
1453
1739
|
if (!item) continue;
|
|
1454
1740
|
const key = reviewing.keyOf(id);
|
|
1455
1741
|
// Each one is planned against the document the one before it left.
|
|
1456
|
-
const answered =
|
|
1457
|
-
|
|
1458
|
-
|
|
1742
|
+
const answered =
|
|
1743
|
+
onField(item) || byCard(item)
|
|
1744
|
+
? reviewing.act(id, action)
|
|
1745
|
+
: key !== undefined && !!leaves.prose(key)?.answerReview(id, action);
|
|
1459
1746
|
if (answered) out.push(id);
|
|
1460
1747
|
}
|
|
1461
1748
|
} finally {
|
|
@@ -1467,13 +1754,200 @@
|
|
|
1467
1754
|
journal.push(entry);
|
|
1468
1755
|
offerJournal();
|
|
1469
1756
|
}
|
|
1757
|
+
const from = advancing;
|
|
1758
|
+
advancing = undefined;
|
|
1759
|
+
if (from !== undefined) advanceFrom(from, order);
|
|
1760
|
+
return out;
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
/**
|
|
1764
|
+
* Write every open item the editor draws into `target`, a copy of the document the host made,
|
|
1765
|
+
* as answering them all with Accept would: a field's value through the typed writer, a place
|
|
1766
|
+
* inside one as the field's whole value with that place changed, a card added or taken out,
|
|
1767
|
+
* and each prose leaf's proposals from the plans it draws them from. Nothing is written to the
|
|
1768
|
+
* document, and no hook, history or answer hears of it. Returns the way between places in the
|
|
1769
|
+
* document and places in `target`, which holds only while neither changes.
|
|
1770
|
+
*/
|
|
1771
|
+
export function projectReview(target: Document): ReviewProjection {
|
|
1772
|
+
if (!span.alive) return NO_PROJECTION;
|
|
1773
|
+
const order = reviewOrder();
|
|
1774
|
+
if (!order.length) return NO_PROJECTION;
|
|
1775
|
+
const open = new Set(order);
|
|
1776
|
+
const byId = new Map(reviewing.items.map((item) => [item.id, item]));
|
|
1777
|
+
const written = new Set<string>();
|
|
1778
|
+
|
|
1779
|
+
const texts = new Map<string, LeafProjection>();
|
|
1780
|
+
for (const [key, report] of reviewing.reports) {
|
|
1781
|
+
if (!report.ids.some((id) => open.has(id))) continue;
|
|
1782
|
+
const projected = leaves.prose(key)?.projectReview(target);
|
|
1783
|
+
if (!projected) continue;
|
|
1784
|
+
texts.set(key, projected);
|
|
1785
|
+
for (const id of projected.ids) written.add(id);
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
for (const [, field] of projectFields(order, byId)) {
|
|
1789
|
+
const at = field.isMain ? undefined : cardIndexOf(field.cardId);
|
|
1790
|
+
if (at !== undefined && at < 0) continue;
|
|
1791
|
+
try {
|
|
1792
|
+
if (field.value === undefined)
|
|
1793
|
+
target.removeField(at === undefined ? field.name : { card: at, field: field.name });
|
|
1794
|
+
else {
|
|
1795
|
+
const w = quill.writer(target);
|
|
1796
|
+
(at === undefined ? w : w.card(at)).set(field.name, field.value);
|
|
1797
|
+
}
|
|
1798
|
+
for (const id of field.ids) written.add(id);
|
|
1799
|
+
} catch {
|
|
1800
|
+
// A value the writer refuses is one its Accept could not write either.
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
type Slot = { key: string } | { add: CardAdd };
|
|
1805
|
+
const adds = (lead: string): Slot[] =>
|
|
1806
|
+
(reviewing.cards.adds.get(lead) ?? []).filter((a) => open.has(a.id)).map((add) => ({ add }));
|
|
1807
|
+
const gone = new Set<string>();
|
|
1808
|
+
for (const [key, item] of reviewing.cards.removes)
|
|
1809
|
+
if (open.has(item.id)) {
|
|
1810
|
+
gone.add(key);
|
|
1811
|
+
written.add(item.id);
|
|
1812
|
+
}
|
|
1813
|
+
const wanted: Slot[] = [...adds('head')];
|
|
1814
|
+
for (const key of cardIds) {
|
|
1815
|
+
if (!gone.has(key)) wanted.push({ key });
|
|
1816
|
+
wanted.push(...adds(key));
|
|
1817
|
+
}
|
|
1818
|
+
wanted.push(...adds('end'));
|
|
1819
|
+
for (let i = cardIds.length - 1; i >= 0; i--) if (gone.has(cardIds[i])) target.removeCard(i);
|
|
1820
|
+
const slots: Slot[] = [];
|
|
1821
|
+
for (const slot of wanted) {
|
|
1822
|
+
if ('add' in slot && !placeCardIn(target, slot.add.add, slots.length)) continue;
|
|
1823
|
+
if ('add' in slot) written.add(slot.add.id);
|
|
1824
|
+
slots.push(slot);
|
|
1825
|
+
}
|
|
1826
|
+
const projected = new Map(slots.flatMap((slot, j) => ('key' in slot ? [[slot.key, j]] : [])));
|
|
1827
|
+
|
|
1828
|
+
const field = (at: DocPath | Landing): DocPath => (typeof at === 'string' ? at : at.field);
|
|
1829
|
+
const moved = <T extends DocPath | Landing>(at: T, path: DocPath, pos?: number): T =>
|
|
1830
|
+
(typeof at === 'string'
|
|
1831
|
+
? path
|
|
1832
|
+
: { ...(at as Landing), field: path, ...(pos === undefined ? {} : { pos }) }) as T;
|
|
1833
|
+
const ids = order.filter((id) => written.has(id));
|
|
1834
|
+
return {
|
|
1835
|
+
ids,
|
|
1836
|
+
toProjection(at) {
|
|
1837
|
+
let path = field(at);
|
|
1838
|
+
const card = cardOfPath(path);
|
|
1839
|
+
if (card !== undefined && card < cardIds.length) {
|
|
1840
|
+
const j = projected.get(cardIds[card]);
|
|
1841
|
+
if (j === undefined) return undefined;
|
|
1842
|
+
path = pathOnCard(path, j);
|
|
1843
|
+
}
|
|
1844
|
+
const pos = typeof at === 'string' ? undefined : at.pos;
|
|
1845
|
+
const text = pos === undefined ? undefined : texts.get(proseKeyFor(field(at)) ?? '');
|
|
1846
|
+
return moved(at, path, text && pos !== undefined ? text.toProjection(pos) : pos);
|
|
1847
|
+
},
|
|
1848
|
+
toLive(at) {
|
|
1849
|
+
let path = field(at);
|
|
1850
|
+
const card = cardOfPath(path);
|
|
1851
|
+
if (card !== undefined) {
|
|
1852
|
+
const slot = slots[card];
|
|
1853
|
+
if (!slot) return undefined;
|
|
1854
|
+
if ('add' in slot) return { review: slot.add.id };
|
|
1855
|
+
path = pathOnCard(path, cardIndexOf(slot.key));
|
|
1856
|
+
}
|
|
1857
|
+
const pos = typeof at === 'string' ? undefined : at.pos;
|
|
1858
|
+
const text = pos === undefined ? undefined : texts.get(proseKeyFor(path) ?? '');
|
|
1859
|
+
const live = text && pos !== undefined ? text.toLive(pos) : pos;
|
|
1860
|
+
if (typeof live === 'object') return live;
|
|
1861
|
+
return moved(at, path, live);
|
|
1862
|
+
}
|
|
1863
|
+
};
|
|
1864
|
+
}
|
|
1865
|
+
/**
|
|
1866
|
+
* The value each field holds with every open field item on it taken, by leaf key, in the
|
|
1867
|
+
* page's order: a place inside a field found again in the value the items before it left, as
|
|
1868
|
+
* each accept finds it.
|
|
1869
|
+
*/
|
|
1870
|
+
function projectFields(
|
|
1871
|
+
order: readonly string[],
|
|
1872
|
+
byId: ReadonlyMap<string, ReviewItem>
|
|
1873
|
+
): Map<string, { cardId: string; isMain: boolean; name: string; value: unknown; ids: string[] }> {
|
|
1874
|
+
const out = new Map<
|
|
1875
|
+
string,
|
|
1876
|
+
{ cardId: string; isMain: boolean; name: string; value: unknown; ids: string[] }
|
|
1877
|
+
>();
|
|
1878
|
+
const fieldUndrawn = new Set(reviewing.fieldUndrawn.map((u) => u.id));
|
|
1879
|
+
const nested = (item: ReviewItem): item is FieldProposal =>
|
|
1880
|
+
onField(item) && !fieldUndrawn.has(item.id) && !addrForFieldPath(item.field);
|
|
1881
|
+
const left = new Set(order);
|
|
1882
|
+
for (const id of order) {
|
|
1883
|
+
const item = byId.get(id);
|
|
1884
|
+
left.delete(id);
|
|
1885
|
+
if (!item || !onField(item)) continue;
|
|
1886
|
+
const key = reviewed(item.field);
|
|
1887
|
+
if (!key?.field || typeof key.card === 'number') continue;
|
|
1888
|
+
const leaf = fieldKeyToString(key);
|
|
1889
|
+
const isMain = key.card === undefined;
|
|
1890
|
+
const cardId = key.card ?? model.main.id;
|
|
1891
|
+
let held = out.get(leaf);
|
|
1892
|
+
if (!held) {
|
|
1893
|
+
const at = isMain ? 0 : cardIndexOf(cardId);
|
|
1894
|
+
if (at < 0) continue;
|
|
1895
|
+
const value = fieldValues((isMain ? doc.main : doc.card(at)).payloadItems)[key.field];
|
|
1896
|
+
out.set(leaf, (held = { cardId, isMain, name: key.field, value, ids: [] }));
|
|
1897
|
+
}
|
|
1898
|
+
if (addrForFieldPath(item.field)) held.value = reviewing.writes(item, held.value);
|
|
1899
|
+
else {
|
|
1900
|
+
const steps = leafTargetFor(item.field)?.steps;
|
|
1901
|
+
if (!steps) continue;
|
|
1902
|
+
// Each item before it on the field claims its member first, as the derive does.
|
|
1903
|
+
const claimed = new Set<string>();
|
|
1904
|
+
let found: readonly PathStep[] | undefined;
|
|
1905
|
+
for (const other of reviewing.items) {
|
|
1906
|
+
if (other !== item && !(left.has(other.id) && nested(other))) continue;
|
|
1907
|
+
const otherKey = reviewed((other as FieldProposal).field);
|
|
1908
|
+
const path =
|
|
1909
|
+
other === item ? steps : leafTargetFor((other as FieldProposal).field)?.steps;
|
|
1910
|
+
if (!otherKey || fieldKeyToString(otherKey) !== leaf || !path) continue;
|
|
1911
|
+
const located = locate(held.value, path, other as FieldProposal, claimed);
|
|
1912
|
+
if (other === item) {
|
|
1913
|
+
found = located.steps;
|
|
1914
|
+
break;
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
if (!found) continue;
|
|
1918
|
+
held.value = valueWith(
|
|
1919
|
+
held.value,
|
|
1920
|
+
found,
|
|
1921
|
+
reviewing.writes(item, valueIn(held.value, found))
|
|
1922
|
+
);
|
|
1923
|
+
}
|
|
1924
|
+
held.ids.push(id);
|
|
1925
|
+
}
|
|
1470
1926
|
return out;
|
|
1471
1927
|
}
|
|
1928
|
+
/** Write `card` into `target` at `at`, with its `$id` where no card there holds that one,
|
|
1929
|
+
* as {@link placeCard} writes it into the document. */
|
|
1930
|
+
function placeCardIn(target: Document, card: CardAdd['add'], at: number): boolean {
|
|
1931
|
+
const { id, ...bare } = card;
|
|
1932
|
+
const free =
|
|
1933
|
+
id !== undefined &&
|
|
1934
|
+
!Array.from({ length: target.cardCount }, (_, k) => target.card(k).id).includes(id);
|
|
1935
|
+
try {
|
|
1936
|
+
try {
|
|
1937
|
+
target.unchecked.insertCard(free ? card : bare, at);
|
|
1938
|
+
} catch (e) {
|
|
1939
|
+
if (!free) throw e;
|
|
1940
|
+
target.unchecked.insertCard(bare, at);
|
|
1941
|
+
}
|
|
1942
|
+
return true;
|
|
1943
|
+
} catch {
|
|
1944
|
+
return false;
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1472
1947
|
|
|
1473
|
-
/**
|
|
1474
|
-
*
|
|
1475
|
-
*
|
|
1476
|
-
* drawn. */
|
|
1948
|
+
/** Make the next or previous open item current, in document order and round from either
|
|
1949
|
+
* end, from the current item or the one last stepped to: the caret in it, or the focus in
|
|
1950
|
+
* its field, unless `focus` is false. Resolves its id, `undefined` when none is drawn. */
|
|
1477
1951
|
export function stepReview(
|
|
1478
1952
|
dir: 1 | -1,
|
|
1479
1953
|
opts: { focus?: boolean } = {}
|
|
@@ -1548,7 +2022,13 @@
|
|
|
1548
2022
|
}
|
|
1549
2023
|
</script>
|
|
1550
2024
|
|
|
1551
|
-
<svelte:document
|
|
2025
|
+
<svelte:document
|
|
2026
|
+
onkeydowncapture={(e) => {
|
|
2027
|
+
onReviewKey(e);
|
|
2028
|
+
if (!e.defaultPrevented) onUndoKey(e);
|
|
2029
|
+
}}
|
|
2030
|
+
onpointermove={onPointerMove}
|
|
2031
|
+
/>
|
|
1552
2032
|
|
|
1553
2033
|
<!-- The keydown is a control's, bubbled: the root resolves which description it raises.
|
|
1554
2034
|
A file dragged over or dropped is refused here, after any control has seen it. -->
|
|
@@ -1558,7 +2038,8 @@
|
|
|
1558
2038
|
{style}
|
|
1559
2039
|
data-qm-root
|
|
1560
2040
|
bind:this={rootEl}
|
|
1561
|
-
onkeydowncapture={
|
|
2041
|
+
onkeydowncapture={onTyped}
|
|
2042
|
+
onpointerdowncapture={onPick}
|
|
1562
2043
|
onkeydown={raiseGuidance}
|
|
1563
2044
|
ondragover={refuseFiles}
|
|
1564
2045
|
ondrop={refuseFiles}
|
|
@@ -1592,32 +2073,62 @@
|
|
|
1592
2073
|
{/if}
|
|
1593
2074
|
</div>
|
|
1594
2075
|
|
|
2076
|
+
{@render cardsAdded('head')}
|
|
1595
2077
|
{@render addAffordance(0)}
|
|
1596
2078
|
<!-- A card and the gap under it are one slot, which is what a reorder moves: the
|
|
1597
2079
|
strip below a card is the same strip wherever the card lands, so it rides along
|
|
1598
2080
|
rather than being slid across. It is also the shape `animate:` asks for, being the
|
|
1599
2081
|
keyed block's only child. -->
|
|
1600
2082
|
{#each model.cards as c, i (c.id)}
|
|
2083
|
+
{@const removal = reviewing.cards.removes.get(c.id)}
|
|
1601
2084
|
<div class="qm-card-slot" bind:this={slotEls[i]} animate:reorder={arm.armed} in:slot out:slot>
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
{
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
{
|
|
1610
|
-
|
|
1611
|
-
{
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
2085
|
+
<!-- A removal's mark wraps the whole card it would take out, so the answer card
|
|
2086
|
+
stands under the card and not on it. -->
|
|
2087
|
+
<div
|
|
2088
|
+
class={[
|
|
2089
|
+
'qm-review-card-remove',
|
|
2090
|
+
{ 'qm-review-on': !!removal, 'qm-review-lit': !!removal && reviewing.lit === removal.id }
|
|
2091
|
+
]}
|
|
2092
|
+
data-qm-review={removal?.id}
|
|
2093
|
+
role={removal ? 'group' : undefined}
|
|
2094
|
+
aria-label={removal ? merged.reviewRemoveCard : undefined}
|
|
2095
|
+
onpointerenter={removal && (() => reviewing.point(removal.id, 'pointer'))}
|
|
2096
|
+
onpointerleave={removal && (() => reviewing.point(undefined, 'pointer'))}
|
|
2097
|
+
>
|
|
2098
|
+
<Card
|
|
2099
|
+
bind:this={cardRefs[i]}
|
|
2100
|
+
card={titled(c)}
|
|
2101
|
+
{doc}
|
|
2102
|
+
{quill}
|
|
2103
|
+
isFirst={i === 0}
|
|
2104
|
+
isLast={i === model.cards.length - 1}
|
|
2105
|
+
{kinds}
|
|
2106
|
+
ops={opsFor(c.id, false)}
|
|
2107
|
+
{enumDisallowed}
|
|
2108
|
+
onFocus={handleFocus}
|
|
2109
|
+
onCaretMove={handleCaret}
|
|
2110
|
+
onChange={proseChanged}
|
|
2111
|
+
{onError}
|
|
2112
|
+
{leaves}
|
|
2113
|
+
tag={removal ? merged.reviewRemoveCard : undefined}
|
|
2114
|
+
/>
|
|
2115
|
+
</div>
|
|
2116
|
+
{@render cardsAdded(c.id)}
|
|
1618
2117
|
{@render addAffordance(i + 1)}
|
|
1619
2118
|
</div>
|
|
1620
2119
|
{/each}
|
|
2120
|
+
{@render cardsAdded('end')}
|
|
2121
|
+
<ReviewCard
|
|
2122
|
+
bind:this={answerCard}
|
|
2123
|
+
id={reviewing.lit}
|
|
2124
|
+
root={rootEl}
|
|
2125
|
+
inset={reviewInset}
|
|
2126
|
+
hidden={typing}
|
|
2127
|
+
outdated={reviewing.lit !== undefined && drewOutdated.includes(reviewing.lit)}
|
|
2128
|
+
onAnswer={answerCurrent}
|
|
2129
|
+
onHover={(on) => reviewing.hoverCard(on)}
|
|
2130
|
+
/>
|
|
2131
|
+
<div class="qm-visually-hidden" role="status">{reviewPlace}</div>
|
|
1621
2132
|
<!-- The way back to a removed card once its toast has gone: the newest kept step, by
|
|
1622
2133
|
name, at the stack's foot, where the control that adds a card is looked for. -->
|
|
1623
2134
|
{#if undo.kept}
|
|
@@ -1662,6 +2173,42 @@
|
|
|
1662
2173
|
neither dropped nor trapped. The gate lives here rather than at each call site: the
|
|
1663
2174
|
strip is one decision, and two copies of it drift into a stack with a gap at one
|
|
1664
2175
|
end. -->
|
|
2176
|
+
<!-- The cards proposed new after the card at `lead`, each a preview where it would stand: its
|
|
2177
|
+
kind's title, its own title or the words that name it, and the start of its body. -->
|
|
2178
|
+
{#snippet cardsAdded(lead: string)}
|
|
2179
|
+
{@const adds = reviewing.cards.adds.get(lead)}
|
|
2180
|
+
{#if adds?.length}
|
|
2181
|
+
<div class="qm-review-head">
|
|
2182
|
+
{#each adds as item (item.id)}
|
|
2183
|
+
{@const preview = previewOf(item)}
|
|
2184
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
2185
|
+
<div
|
|
2186
|
+
class={['qm-review-card-add', { 'qm-review-lit': reviewing.lit === item.id }]}
|
|
2187
|
+
data-qm-review={item.id}
|
|
2188
|
+
role="group"
|
|
2189
|
+
aria-label={merged.reviewNewCard}
|
|
2190
|
+
onpointerenter={() => reviewing.point(item.id, 'pointer')}
|
|
2191
|
+
onpointerleave={() => reviewing.point(undefined, 'pointer')}
|
|
2192
|
+
>
|
|
2193
|
+
<div class="qm-review-card-add-head">
|
|
2194
|
+
<span class="qm-review-card-add-title">{preview.title}</span>
|
|
2195
|
+
<span class="qm-review-card-tag">{merged.reviewNewCard}</span>
|
|
2196
|
+
</div>
|
|
2197
|
+
{#if preview.fields.length}
|
|
2198
|
+
<dl class="qm-review-card-add-fields">
|
|
2199
|
+
{#each preview.fields as { label, value }, n (n)}
|
|
2200
|
+
<dt>{label}</dt>
|
|
2201
|
+
<dd>{value}</dd>
|
|
2202
|
+
{/each}
|
|
2203
|
+
</dl>
|
|
2204
|
+
{/if}
|
|
2205
|
+
{#if preview.text}<p class="qm-review-card-add-text">{preview.text}</p>{/if}
|
|
2206
|
+
</div>
|
|
2207
|
+
{/each}
|
|
2208
|
+
</div>
|
|
2209
|
+
{/if}
|
|
2210
|
+
{/snippet}
|
|
2211
|
+
|
|
1665
2212
|
{#snippet addAffordance(atIndex: number)}
|
|
1666
2213
|
{#if kinds.length}
|
|
1667
2214
|
<!-- The strip past the last card is the append point, the one a reader looks for
|
|
@@ -1696,6 +2243,7 @@
|
|
|
1696
2243
|
<DropdownMenu.Portal to={rootEl}>
|
|
1697
2244
|
<DropdownMenu.Content
|
|
1698
2245
|
collisionBoundary={rootEl ?? []}
|
|
2246
|
+
strategy="absolute"
|
|
1699
2247
|
sideOffset={spacePx(rootEl)}
|
|
1700
2248
|
onCloseAutoFocus={(e) => {
|
|
1701
2249
|
if (picked) e.preventDefault();
|
|
@@ -1806,6 +2354,9 @@
|
|
|
1806
2354
|
back to being one block clipped at its edges. That is the page form; a pane's
|
|
1807
2355
|
frame is the host's, and it spends less (`.qm-pane` below). */
|
|
1808
2356
|
:global(:where(.qm-editor)) {
|
|
2357
|
+
/* The frame every floating surface is placed in (INVARIANTS §Chrome), so a pane that
|
|
2358
|
+
scrolls carries them with the text. */
|
|
2359
|
+
position: relative;
|
|
1809
2360
|
box-sizing: border-box;
|
|
1810
2361
|
display: flex;
|
|
1811
2362
|
flex-direction: column;
|
|
@@ -1877,6 +2428,180 @@
|
|
|
1877
2428
|
flex-direction: column;
|
|
1878
2429
|
gap: var(--_qm-space-2);
|
|
1879
2430
|
}
|
|
2431
|
+
/* A card proposed new and a card proposed taken out, in the review's one hue: a preview
|
|
2432
|
+
where the new card would stand, the card's own ground under the tint, and a mark round
|
|
2433
|
+
the whole of a card that would go, its words receding as a struck word's do. The
|
|
2434
|
+
current one's mark is a step stronger, as a current proposal's words are. */
|
|
2435
|
+
.qm-review-card-remove {
|
|
2436
|
+
display: contents;
|
|
2437
|
+
}
|
|
2438
|
+
.qm-review-card-remove.qm-review-on {
|
|
2439
|
+
display: block;
|
|
2440
|
+
border-radius: var(--_qm-radius);
|
|
2441
|
+
box-shadow: 0 0 0 var(--_qm-border-width) var(--_qm-review-line);
|
|
2442
|
+
}
|
|
2443
|
+
.qm-review-card-remove.qm-review-on > :global(.qm-card) {
|
|
2444
|
+
opacity: var(--_qm-opacity-muted);
|
|
2445
|
+
}
|
|
2446
|
+
.qm-review-card-remove.qm-review-lit {
|
|
2447
|
+
box-shadow: 0 0 0 var(--_qm-vertical-width) var(--_qm-review-line);
|
|
2448
|
+
}
|
|
2449
|
+
.qm-review-head {
|
|
2450
|
+
display: flex;
|
|
2451
|
+
flex-direction: column;
|
|
2452
|
+
gap: var(--_qm-space-2);
|
|
2453
|
+
}
|
|
2454
|
+
.qm-review-card-add {
|
|
2455
|
+
display: flex;
|
|
2456
|
+
flex-direction: column;
|
|
2457
|
+
gap: var(--_qm-space);
|
|
2458
|
+
padding: var(--_qm-space-3) var(--_qm-card-inset);
|
|
2459
|
+
border-radius: var(--_qm-radius);
|
|
2460
|
+
background: linear-gradient(var(--_qm-review-tint), var(--_qm-review-tint)) var(--_qm-surface);
|
|
2461
|
+
}
|
|
2462
|
+
/* A control showing a value a proposal would write, which it cannot draw as words: the review
|
|
2463
|
+
tint over the whole control and an edge in the review line, so the mark is not colour alone,
|
|
2464
|
+
laid over it so it takes no room and moves nothing. It takes
|
|
2465
|
+
the box's `::after` whole, over what the arrival wash or a tap floor set there. A member a
|
|
2466
|
+
proposal takes out is struck where it stands. */
|
|
2467
|
+
:global([data-qm-proposed]),
|
|
2468
|
+
:global(.qm-review-added-box :is(.qm-toggle, .qm-tick)) {
|
|
2469
|
+
position: relative;
|
|
2470
|
+
}
|
|
2471
|
+
:global([data-qm-proposed])::after,
|
|
2472
|
+
:global(.qm-review-added-box :is(.qm-toggle, .qm-tick))::after {
|
|
2473
|
+
content: '';
|
|
2474
|
+
position: absolute;
|
|
2475
|
+
inset: 0;
|
|
2476
|
+
width: auto;
|
|
2477
|
+
height: auto;
|
|
2478
|
+
transform: none;
|
|
2479
|
+
border-radius: var(--_qm-radius-inner);
|
|
2480
|
+
background: var(--_qm-review-tint);
|
|
2481
|
+
box-shadow: inset 0 0 0 var(--_qm-border-width) var(--_qm-review-line);
|
|
2482
|
+
opacity: 1;
|
|
2483
|
+
pointer-events: none;
|
|
2484
|
+
transition: background-color var(--_qm-duration-fast) var(--_qm-ease-reverse);
|
|
2485
|
+
}
|
|
2486
|
+
/* A switch's track keeps its own shape under the mark. */
|
|
2487
|
+
:global(.qm-toggle[data-qm-proposed])::after,
|
|
2488
|
+
:global(.qm-review-added-box .qm-toggle)::after {
|
|
2489
|
+
border-radius: inherit;
|
|
2490
|
+
}
|
|
2491
|
+
/* The current one's edge is a step stronger, as a removed card's ring is. */
|
|
2492
|
+
:global([data-qm-proposed-lit])::after,
|
|
2493
|
+
:global(.qm-review-lit > .qm-review-added-box :is(.qm-toggle, .qm-tick))::after {
|
|
2494
|
+
background: var(--_qm-review-lit);
|
|
2495
|
+
box-shadow: inset 0 0 0 var(--_qm-vertical-width) var(--_qm-review-line);
|
|
2496
|
+
}
|
|
2497
|
+
:global([data-qm-removes]) {
|
|
2498
|
+
text-decoration: line-through;
|
|
2499
|
+
text-decoration-color: var(--_qm-review-line);
|
|
2500
|
+
}
|
|
2501
|
+
/* A member a proposal would add, drawn as its own control holding the value: each box in it
|
|
2502
|
+
under the tint, which a box's own fill keeps beneath, and the current one ringed. A switch's
|
|
2503
|
+
track and a tick's square paint their state over any image, so they take the overlay a
|
|
2504
|
+
proposed switch does. */
|
|
2505
|
+
:global(.qm-review-added-box) {
|
|
2506
|
+
display: contents;
|
|
2507
|
+
pointer-events: none;
|
|
2508
|
+
}
|
|
2509
|
+
:global(.qm-review-added-box :is(.qm-control-box, .qm-input)) {
|
|
2510
|
+
background-image: linear-gradient(var(--_qm-review-tint), var(--_qm-review-tint));
|
|
2511
|
+
box-shadow: inset 0 0 0 var(--_qm-border-width) var(--_qm-review-line);
|
|
2512
|
+
}
|
|
2513
|
+
:global(.qm-review-lit > .qm-review-added-box :is(.qm-control-box, .qm-input)) {
|
|
2514
|
+
background-image: linear-gradient(var(--_qm-review-lit), var(--_qm-review-lit));
|
|
2515
|
+
box-shadow: inset 0 0 0 var(--_qm-vertical-width) var(--_qm-review-line);
|
|
2516
|
+
}
|
|
2517
|
+
/* A row a proposal would take out: no tint, which only ever means "would come", but a ring
|
|
2518
|
+
in the review line laid outside the row so it takes no room, its values dimmed and struck
|
|
2519
|
+
and its labels left alone. The current one's ring is a step stronger, as a removed card's. */
|
|
2520
|
+
:global([data-qm-removed]) {
|
|
2521
|
+
border-radius: var(--_qm-radius-inner);
|
|
2522
|
+
box-shadow: 0 0 0 var(--_qm-border-width) var(--_qm-review-line);
|
|
2523
|
+
}
|
|
2524
|
+
:global([data-qm-removed-lit]) {
|
|
2525
|
+
box-shadow: 0 0 0 var(--_qm-vertical-width) var(--_qm-review-line);
|
|
2526
|
+
}
|
|
2527
|
+
:global(
|
|
2528
|
+
[data-qm-removed]
|
|
2529
|
+
:is(
|
|
2530
|
+
.qm-control-box:not(.qm-element-summary),
|
|
2531
|
+
.qm-toggle,
|
|
2532
|
+
.qm-tick,
|
|
2533
|
+
.qm-input,
|
|
2534
|
+
.qm-element-preview
|
|
2535
|
+
)
|
|
2536
|
+
) {
|
|
2537
|
+
opacity: var(--_qm-opacity-muted);
|
|
2538
|
+
text-decoration: line-through;
|
|
2539
|
+
text-decoration-color: var(--_qm-review-line);
|
|
2540
|
+
}
|
|
2541
|
+
@media (forced-colors: active) {
|
|
2542
|
+
:global([data-qm-proposed])::after {
|
|
2543
|
+
border: var(--_qm-border-width) dashed Highlight;
|
|
2544
|
+
}
|
|
2545
|
+
:global([data-qm-proposed-lit])::after {
|
|
2546
|
+
border-style: solid;
|
|
2547
|
+
}
|
|
2548
|
+
:global([data-qm-removed]) {
|
|
2549
|
+
outline: var(--_qm-border-width) dashed Highlight;
|
|
2550
|
+
}
|
|
2551
|
+
:global([data-qm-removed-lit]) {
|
|
2552
|
+
outline-style: solid;
|
|
2553
|
+
}
|
|
2554
|
+
:global(.qm-review-added-box :is(.qm-control-box, .qm-toggle, .qm-tick, .qm-input)) {
|
|
2555
|
+
outline: var(--_qm-border-width) dashed Highlight;
|
|
2556
|
+
outline-offset: calc(-1 * var(--_qm-border-width));
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
.qm-review-card-add.qm-review-lit {
|
|
2560
|
+
background: linear-gradient(var(--_qm-review-lit), var(--_qm-review-lit)) var(--_qm-surface);
|
|
2561
|
+
}
|
|
2562
|
+
.qm-review-card-add-head {
|
|
2563
|
+
display: flex;
|
|
2564
|
+
align-items: baseline;
|
|
2565
|
+
gap: var(--_qm-space-2);
|
|
2566
|
+
}
|
|
2567
|
+
.qm-review-card-add-title {
|
|
2568
|
+
font-size: var(--_qm-text-title);
|
|
2569
|
+
font-weight: var(--_qm-weight-mid);
|
|
2570
|
+
}
|
|
2571
|
+
.qm-review-card-tag {
|
|
2572
|
+
font-size: var(--_qm-text-label);
|
|
2573
|
+
font-weight: var(--_qm-weight-mid);
|
|
2574
|
+
color: var(--_qm-ink-label);
|
|
2575
|
+
}
|
|
2576
|
+
.qm-review-card-add-fields {
|
|
2577
|
+
display: grid;
|
|
2578
|
+
grid-template-columns: auto 1fr;
|
|
2579
|
+
gap: var(--_qm-space) var(--_qm-space-3);
|
|
2580
|
+
margin: 0;
|
|
2581
|
+
font-size: var(--_qm-text-label);
|
|
2582
|
+
}
|
|
2583
|
+
.qm-review-card-add-fields dt {
|
|
2584
|
+
color: var(--_qm-ink-label);
|
|
2585
|
+
}
|
|
2586
|
+
.qm-review-card-add-fields dd {
|
|
2587
|
+
margin: 0;
|
|
2588
|
+
overflow-wrap: anywhere;
|
|
2589
|
+
}
|
|
2590
|
+
.qm-review-card-add-text {
|
|
2591
|
+
margin: 0;
|
|
2592
|
+
color: var(--_qm-ink-label);
|
|
2593
|
+
white-space: pre-line;
|
|
2594
|
+
display: -webkit-box;
|
|
2595
|
+
-webkit-line-clamp: 3;
|
|
2596
|
+
line-clamp: 3;
|
|
2597
|
+
-webkit-box-orient: vertical;
|
|
2598
|
+
overflow: hidden;
|
|
2599
|
+
}
|
|
2600
|
+
@media (forced-colors: active) {
|
|
2601
|
+
.qm-review-card-add {
|
|
2602
|
+
outline: var(--_qm-border-width) solid CanvasText;
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
1880
2605
|
/* The strip between two blocks, and the whole of it is the target: a gap is found by
|
|
1881
2606
|
position, so reveal and hit region are the full-bleed row rather than a word to aim
|
|
1882
2607
|
at in the middle of it. Taking the editor's gap back on both sides is what makes it
|