@quillmark/svelte 0.37.0 → 0.38.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/dist/core/codec/field.d.ts +6 -5
- package/dist/core/codec/field.js +15 -21
- package/dist/core/codec/index.d.ts +1 -1
- package/dist/core/codec/index.js +1 -1
- package/dist/core/codec/prose.css +6 -0
- package/dist/core/codec/review.js +8 -4
- package/dist/core/codec/value-diff.d.ts +4 -3
- package/dist/core/codec/value-diff.js +12 -7
- package/dist/core/codec/value-plan.d.ts +9 -0
- package/dist/core/codec/value-plan.js +110 -0
- package/dist/core/theme.css +5 -4
- package/dist/visual/ArrayField.svelte +143 -78
- package/dist/visual/Card.svelte +4 -3
- package/dist/visual/Card.svelte.d.ts +3 -2
- package/dist/visual/Field.svelte +12 -10
- package/dist/visual/Field.svelte.d.ts +3 -3
- package/dist/visual/FieldHint.svelte +3 -5
- package/dist/visual/FieldLabel.svelte +6 -42
- package/dist/visual/FieldLabel.svelte.d.ts +0 -3
- package/dist/visual/MatrixAdd.svelte +9 -10
- package/dist/visual/MatrixField.svelte +107 -15
- package/dist/visual/ObjectField.svelte +24 -12
- package/dist/visual/ObjectField.svelte.d.ts +5 -0
- package/dist/visual/ProseField.svelte +16 -8
- package/dist/visual/ProseField.svelte.d.ts +3 -2
- package/dist/visual/ProseValue.svelte +25 -23
- package/dist/visual/ProseValue.svelte.d.ts +3 -2
- package/dist/visual/ReviewCard.svelte +11 -4
- package/dist/visual/VisualEditorInner.svelte +63 -38
- package/dist/visual/guidance.d.ts +0 -2
- package/dist/visual/guidance.js +0 -10
- package/dist/visual/proposals.d.ts +14 -11
- package/dist/visual/proposals.js +44 -28
- package/dist/visual/props.d.ts +6 -4
- package/dist/visual/review-order.d.ts +1 -0
- package/dist/visual/review-order.js +4 -3
- package/dist/visual/review.d.ts +15 -2
- package/dist/visual/review.js +29 -1
- package/dist/visual/review.svelte.d.ts +6 -1
- package/dist/visual/review.svelte.js +37 -10
- package/dist/visual/strings.d.ts +2 -0
- package/dist/visual/strings.js +1 -0
- package/dist/visual/structure.d.ts +17 -9
- package/dist/visual/structure.js +20 -17
- package/package.json +1 -1
|
@@ -58,8 +58,9 @@ interface Props {
|
|
|
58
58
|
* array repeater's Enter/Backspace (`ArrayField`). Fires before the view's own
|
|
59
59
|
* keymap, so the state it reads is the one this keystroke has yet to change. */
|
|
60
60
|
onKey?: (e: KeyboardEvent) => void;
|
|
61
|
-
/**
|
|
62
|
-
|
|
61
|
+
/** Proposed values over the leaf's words, a whole one or each run of one answer, drawn
|
|
62
|
+
* over its text as a word diff. */
|
|
63
|
+
proposed?: readonly TextProposal[];
|
|
63
64
|
}
|
|
64
65
|
declare const ProseValue: import("svelte").Component<Props, {
|
|
65
66
|
focus: () => void;
|
|
@@ -8,9 +8,14 @@
|
|
|
8
8
|
|
|
9
9
|
It sits under the block the change flows in, so it covers no line of its paragraph, or beside
|
|
10
10
|
that block's last line where the line ends short of it, centred on a block of one line such as a
|
|
11
|
-
one-line field's, right-aligned to the
|
|
11
|
+
one-line field's, right-aligned to the column the
|
|
12
12
|
change stands in, and flips above that block where there is no room below, keeping clear of the
|
|
13
|
-
host's chrome at the pane's foot (`inset`).
|
|
13
|
+
host's chrome at the pane's foot (`inset`). The column is the card's body or its form whole,
|
|
14
|
+
never the one field, so Accept stands at one edge from change to change and a pointer answering
|
|
15
|
+
a run of them does not hunt for it. A field or a property sharing its row with others takes the
|
|
16
|
+
card beside its line only where the card stands within its own slot, and under the row
|
|
17
|
+
otherwise: beside the line of one that ends short of the column's edge the card covers the
|
|
18
|
+
value of the next. Over a change taller than the pane it stays pinned
|
|
14
19
|
at the foot while any of the change shows. A change out of the pane keeps its card where it
|
|
15
20
|
would stand beside it, so the card scrolls out with the text and the pane's edge clips it as it
|
|
16
21
|
clips the text.
|
|
@@ -110,13 +115,15 @@
|
|
|
110
115
|
const h = el.offsetHeight;
|
|
111
116
|
const w = el.offsetWidth;
|
|
112
117
|
const column = (els[0].closest(
|
|
113
|
-
'.qm-
|
|
118
|
+
'.qm-fields, .qm-card, .qm-review-card-add, .qm-review-card-remove'
|
|
114
119
|
) ?? root)!;
|
|
115
120
|
left = Math.max(view.left + gap, column.getBoundingClientRect().right - w);
|
|
116
121
|
const at = (root ?? el).getBoundingClientRect();
|
|
117
122
|
const last = blocks.find((b, i) => b !== els[i] && b.getBoundingClientRect().bottom === lower);
|
|
118
123
|
const tuck = last && lastLine(last, h);
|
|
119
|
-
const
|
|
124
|
+
const slot = last?.closest('.qm-object-prop, .qm-field')?.getBoundingClientRect();
|
|
125
|
+
const beside = tuck && tuck.right + gap <= left && (!slot || left + w <= slot.right + 1);
|
|
126
|
+
const below = beside ? tuck.top : lower + gap;
|
|
120
127
|
const above = upper - gap - h;
|
|
121
128
|
const fits = below + h <= floor || above >= ceil;
|
|
122
129
|
const y =
|
|
@@ -67,9 +67,11 @@
|
|
|
67
67
|
byBlocks,
|
|
68
68
|
byCard,
|
|
69
69
|
locate,
|
|
70
|
+
putsIn,
|
|
70
71
|
onField,
|
|
71
72
|
reviewText,
|
|
72
73
|
valueIn,
|
|
74
|
+
valueInserting,
|
|
73
75
|
valueWith,
|
|
74
76
|
NO_PROJECTION,
|
|
75
77
|
type CardProposal,
|
|
@@ -234,6 +236,7 @@
|
|
|
234
236
|
function report(source: ChangeSource, cardId?: CardId, at?: Addr | number, op?: CardOp): void {
|
|
235
237
|
const path =
|
|
236
238
|
at == null ? undefined : typeof at === 'number' ? cardPath(at, liveKinds()) : pathFor(at);
|
|
239
|
+
if (source !== 'structure' && cardId !== undefined) reviewing.edited(cardId);
|
|
237
240
|
reviewing.settled();
|
|
238
241
|
onChange?.({ source, cardId, path, ...(op ? { op } : {}) });
|
|
239
242
|
}
|
|
@@ -416,6 +419,8 @@
|
|
|
416
419
|
if (write && item && onField(item)) {
|
|
417
420
|
back = takeField(item, write);
|
|
418
421
|
if (!back) return false;
|
|
422
|
+
const card = reviewed(item.field)?.card;
|
|
423
|
+
if (typeof card === 'string') reviewing.edited(card);
|
|
419
424
|
} else if (action === 'accept' && item && (onField(item) || byCard(item))) {
|
|
420
425
|
back = onField(item) ? takeField(item) : takeCard(item);
|
|
421
426
|
if (!back) return false;
|
|
@@ -467,7 +472,9 @@
|
|
|
467
472
|
const steps = reviewing.at(leaf).nested?.find((e) => e.item.id === item.id)?.steps;
|
|
468
473
|
if (!steps) return undefined;
|
|
469
474
|
const value = current();
|
|
470
|
-
after =
|
|
475
|
+
after = putsIn(item)
|
|
476
|
+
? valueInserting(value, steps, item.after)
|
|
477
|
+
: valueWith(value, steps, to(valueIn(value, steps)));
|
|
471
478
|
} else after = to(current());
|
|
472
479
|
if (!write(after)) return undefined;
|
|
473
480
|
return () => void write(before);
|
|
@@ -852,6 +859,7 @@
|
|
|
852
859
|
const cardId = cardIdOf(plain);
|
|
853
860
|
if (cardId == null) return;
|
|
854
861
|
refreshTitle(plain, cardId);
|
|
862
|
+
reviewing.edited(cardId);
|
|
855
863
|
reviewing.settled();
|
|
856
864
|
onChange?.({ source: 'prose', cardId, path: pathFor(plain) });
|
|
857
865
|
}
|
|
@@ -1255,8 +1263,8 @@
|
|
|
1255
1263
|
retype: (kind: string) => retypeCardById(id, kind),
|
|
1256
1264
|
rename: (title: string) => renameCardById(id, title),
|
|
1257
1265
|
diagFor: (field?: string) => diagByKey.get(leafKey(field)),
|
|
1258
|
-
enumAllowed: (field: string, value: string) =>
|
|
1259
|
-
enumOptionAllowed?.(makeAddr(id, isMain, field), value) ?? true
|
|
1266
|
+
enumAllowed: (field: string, value: string, steps?: readonly PathStep[]) =>
|
|
1267
|
+
enumOptionAllowed?.(makeAddr(id, isMain, field), value, steps) ?? true
|
|
1260
1268
|
};
|
|
1261
1269
|
}
|
|
1262
1270
|
|
|
@@ -1580,7 +1588,8 @@
|
|
|
1580
1588
|
* Bring the review item `id` to the reader as the current change: open the panel holding
|
|
1581
1589
|
* it and scroll it to the middle of the view. The focus stays where it is, the reader having
|
|
1582
1590
|
* asked to look, unless `focus` asks for it: the caret then goes into the item, or the focus
|
|
1583
|
-
* to
|
|
1591
|
+
* to the control drawing it, a property inside a field included. False for an item the
|
|
1592
|
+
* editor does not draw.
|
|
1584
1593
|
*/
|
|
1585
1594
|
export function revealReview(id: string, opts: { focus?: boolean } = {}): Promise<boolean> {
|
|
1586
1595
|
return reveal(id, opts.focus ?? false, false);
|
|
@@ -1599,8 +1608,12 @@
|
|
|
1599
1608
|
}
|
|
1600
1609
|
if (!(await span.resumes(tick()))) return false;
|
|
1601
1610
|
reviewing.reveal(id);
|
|
1602
|
-
if (focus && key !== undefined && !leaves.prose(key)?.enterReview(id))
|
|
1603
|
-
leaves.control(key)
|
|
1611
|
+
if (focus && key !== undefined && !leaves.prose(key)?.enterReview(id)) {
|
|
1612
|
+
const control = leaves.control(key);
|
|
1613
|
+
const steps = reviewing.at(key).nested?.find((e) => e.item.id === id)?.steps;
|
|
1614
|
+
if (steps && control?.focusPath) control.focusPath(steps);
|
|
1615
|
+
else control?.focus();
|
|
1616
|
+
}
|
|
1604
1617
|
// The current item is drawn again, so its element is read once it has been.
|
|
1605
1618
|
if (!(await span.resumes(tick()))) return false;
|
|
1606
1619
|
const els = reviewEls(id);
|
|
@@ -1843,11 +1856,9 @@
|
|
|
1843
1856
|
}
|
|
1844
1857
|
}
|
|
1845
1858
|
if (!found) continue;
|
|
1846
|
-
held.value =
|
|
1847
|
-
held.value,
|
|
1848
|
-
found,
|
|
1849
|
-
reviewing.writes(item, valueIn(held.value, found))
|
|
1850
|
-
);
|
|
1859
|
+
held.value = putsIn(item as FieldProposal)
|
|
1860
|
+
? valueInserting(held.value, found, (item as FieldProposal).after)
|
|
1861
|
+
: valueWith(held.value, found, reviewing.writes(item, valueIn(held.value, found)));
|
|
1851
1862
|
}
|
|
1852
1863
|
held.ids.push(id);
|
|
1853
1864
|
}
|
|
@@ -1866,8 +1877,8 @@
|
|
|
1866
1877
|
|
|
1867
1878
|
/** Make the next or previous open item current, in document order and round from either
|
|
1868
1879
|
* end, from the current item or the one last stepped to: the caret in it, or the focus in
|
|
1869
|
-
*
|
|
1870
|
-
* Resolves its id, `undefined` when none is drawn. */
|
|
1880
|
+
* the control drawing it, unless `focus` is false. With `group`, only that group's items
|
|
1881
|
+
* are stepped to. Resolves its id, `undefined` when none is drawn. */
|
|
1871
1882
|
export function stepReview(
|
|
1872
1883
|
dir: 1 | -1,
|
|
1873
1884
|
opts: { focus?: boolean; group?: string } = {}
|
|
@@ -2347,18 +2358,20 @@
|
|
|
2347
2358
|
}
|
|
2348
2359
|
/* A card proposed new and a card proposed taken out, in the review's one hue: a preview
|
|
2349
2360
|
where the new card would stand, the card's own ground under the tint, and a mark round
|
|
2350
|
-
the whole of a card that would go, its values struck as a removed row's are.
|
|
2351
|
-
|
|
2361
|
+
the whole of a card that would go, its values struck as a removed row's are. An edge
|
|
2362
|
+
is dashed at rest and solid and a step heavier on the current one, so the one the
|
|
2363
|
+
answer card is for is told from the open ones round it by more than strength. */
|
|
2352
2364
|
.qm-review-card-remove {
|
|
2353
2365
|
display: contents;
|
|
2354
2366
|
}
|
|
2355
2367
|
.qm-review-card-remove.qm-review-on {
|
|
2356
2368
|
display: block;
|
|
2357
2369
|
border-radius: var(--_qm-radius);
|
|
2358
|
-
|
|
2370
|
+
outline: var(--_qm-border-width) dashed var(--_qm-review-line);
|
|
2359
2371
|
}
|
|
2360
2372
|
.qm-review-card-remove.qm-review-lit {
|
|
2361
|
-
|
|
2373
|
+
outline-style: solid;
|
|
2374
|
+
outline-width: var(--_qm-vertical-width);
|
|
2362
2375
|
}
|
|
2363
2376
|
.qm-review-head {
|
|
2364
2377
|
display: flex;
|
|
@@ -2392,7 +2405,8 @@
|
|
|
2392
2405
|
transform: none;
|
|
2393
2406
|
border-radius: var(--_qm-radius-inner);
|
|
2394
2407
|
background: var(--_qm-review-tint);
|
|
2395
|
-
|
|
2408
|
+
outline: var(--_qm-border-width) dashed var(--_qm-review-line);
|
|
2409
|
+
outline-offset: calc(-1 * var(--_qm-border-width));
|
|
2396
2410
|
opacity: 1;
|
|
2397
2411
|
pointer-events: none;
|
|
2398
2412
|
transition: background-color var(--_qm-duration-fast) var(--_qm-ease-reverse);
|
|
@@ -2402,11 +2416,13 @@
|
|
|
2402
2416
|
:global(.qm-review-added-box .qm-toggle)::after {
|
|
2403
2417
|
border-radius: inherit;
|
|
2404
2418
|
}
|
|
2405
|
-
/* The current one's edge is a step
|
|
2419
|
+
/* The current one's edge is solid and a step heavier, as a removed card's ring is. */
|
|
2406
2420
|
:global([data-qm-proposed-lit])::after,
|
|
2407
2421
|
:global(.qm-review-lit > .qm-review-added-box :is(.qm-toggle, .qm-tick))::after {
|
|
2408
2422
|
background: var(--_qm-review-lit);
|
|
2409
|
-
|
|
2423
|
+
outline-style: solid;
|
|
2424
|
+
outline-width: var(--_qm-vertical-width);
|
|
2425
|
+
outline-offset: calc(-1 * var(--_qm-vertical-width));
|
|
2410
2426
|
}
|
|
2411
2427
|
:global([data-qm-removes]) {
|
|
2412
2428
|
text-decoration: line-through;
|
|
@@ -2422,21 +2438,25 @@
|
|
|
2422
2438
|
}
|
|
2423
2439
|
:global(.qm-review-added-box :is(.qm-control-box, .qm-input)) {
|
|
2424
2440
|
background-image: linear-gradient(var(--_qm-review-tint), var(--_qm-review-tint));
|
|
2425
|
-
|
|
2441
|
+
outline: var(--_qm-border-width) dashed var(--_qm-review-line);
|
|
2442
|
+
outline-offset: calc(-1 * var(--_qm-border-width));
|
|
2426
2443
|
}
|
|
2427
2444
|
:global(.qm-review-lit > .qm-review-added-box :is(.qm-control-box, .qm-input)) {
|
|
2428
2445
|
background-image: linear-gradient(var(--_qm-review-lit), var(--_qm-review-lit));
|
|
2429
|
-
|
|
2446
|
+
outline-style: solid;
|
|
2447
|
+
outline-width: var(--_qm-vertical-width);
|
|
2448
|
+
outline-offset: calc(-1 * var(--_qm-vertical-width));
|
|
2430
2449
|
}
|
|
2431
2450
|
/* A row a proposal would take out: no tint, which only ever means "would come", but a ring
|
|
2432
2451
|
in the review line laid outside the row so it takes no room, its values struck and its
|
|
2433
2452
|
labels left alone. The current one's ring is a step stronger, as a removed card's. */
|
|
2434
2453
|
:global([data-qm-removed]) {
|
|
2435
2454
|
border-radius: var(--_qm-radius-inner);
|
|
2436
|
-
|
|
2455
|
+
outline: var(--_qm-border-width) dashed var(--_qm-review-line);
|
|
2437
2456
|
}
|
|
2438
2457
|
:global([data-qm-removed-lit]) {
|
|
2439
|
-
|
|
2458
|
+
outline-style: solid;
|
|
2459
|
+
outline-width: var(--_qm-vertical-width);
|
|
2440
2460
|
}
|
|
2441
2461
|
/* What a removed row or card holds is what the reader reads to answer it, so its words
|
|
2442
2462
|
step back to the label ink under the strike, as a struck word does in a paragraph
|
|
@@ -2447,25 +2467,30 @@
|
|
|
2447
2467
|
:is(.qm-control-box:not(.qm-element-summary), .qm-input, .qm-prose, .qm-element-preview)
|
|
2448
2468
|
) {
|
|
2449
2469
|
color: var(--_qm-ink-label);
|
|
2470
|
+
}
|
|
2471
|
+
/* The strike falls on a value alone, never on the box holding it, which would carry it onto
|
|
2472
|
+
an empty field's hint and a button's label: a strike drawn on a box reaches every word
|
|
2473
|
+
in it. A date's segments are a value only once none of them is a hint. */
|
|
2474
|
+
:global(
|
|
2475
|
+
:is([data-qm-removed], .qm-review-card-remove.qm-review-on)
|
|
2476
|
+
:is(
|
|
2477
|
+
.qm-input:not(:placeholder-shown),
|
|
2478
|
+
.ProseMirror > :not(.qm-prose-placeholder),
|
|
2479
|
+
.qm-select:not([data-ghosted='']) .qm-select-shown,
|
|
2480
|
+
.qm-date:not(:has([data-ghosted='hint'])) .qm-date-segment,
|
|
2481
|
+
.qm-date-unread,
|
|
2482
|
+
.qm-element-preview
|
|
2483
|
+
)
|
|
2484
|
+
) {
|
|
2450
2485
|
text-decoration: line-through;
|
|
2451
2486
|
text-decoration-color: var(--_qm-review-line);
|
|
2452
2487
|
}
|
|
2453
2488
|
@media (forced-colors: active) {
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
:global([data-qm-proposed-lit])::after {
|
|
2458
|
-
border-style: solid;
|
|
2459
|
-
}
|
|
2460
|
-
:global([data-qm-removed]) {
|
|
2461
|
-
outline: var(--_qm-border-width) dashed Highlight;
|
|
2462
|
-
}
|
|
2463
|
-
:global([data-qm-removed-lit]) {
|
|
2464
|
-
outline-style: solid;
|
|
2465
|
-
}
|
|
2489
|
+
.qm-review-card-remove.qm-review-on,
|
|
2490
|
+
:global([data-qm-proposed])::after,
|
|
2491
|
+
:global([data-qm-removed]),
|
|
2466
2492
|
:global(.qm-review-added-box :is(.qm-control-box, .qm-toggle, .qm-tick, .qm-input)) {
|
|
2467
|
-
outline:
|
|
2468
|
-
outline-offset: calc(-1 * var(--_qm-border-width));
|
|
2493
|
+
outline-color: Highlight;
|
|
2469
2494
|
}
|
|
2470
2495
|
}
|
|
2471
2496
|
.qm-review-card-add.qm-review-lit {
|
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
* the literal text.
|
|
7
7
|
*/
|
|
8
8
|
export declare function renderGuidance(markdown: string): Node;
|
|
9
|
-
/** Whether a description stands in flow under its label, with no marker to raise. */
|
|
10
|
-
export declare const isBrief: (description: string) => boolean;
|
|
11
9
|
/** A description as the words alone, for the node that describes its control. */
|
|
12
10
|
export declare const guidanceText: (markdown: string) => string;
|
|
13
11
|
/** Root keydown: the key raises (or lowers) the nearest guidance. A trigger's `click()`
|
package/dist/visual/guidance.js
CHANGED
|
@@ -23,12 +23,6 @@ export function renderGuidance(markdown) {
|
|
|
23
23
|
return document.createTextNode(markdown);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
/** The longest description that stands under its label: about a line at the label rung
|
|
27
|
-
* across a card, two in a half-width field. Past it the text goes behind the marker,
|
|
28
|
-
* in flow under every field being the density a card avoids (`FieldHint`). */
|
|
29
|
-
const BRIEF_MAX = 72;
|
|
30
|
-
/** Whether a description stands in flow under its label, with no marker to raise. */
|
|
31
|
-
export const isBrief = (description) => description.length <= BRIEF_MAX;
|
|
32
26
|
/** A description as the words alone, for the node that describes its control. */
|
|
33
27
|
export const guidanceText = (markdown) => renderGuidance(markdown).textContent ?? markdown;
|
|
34
28
|
/** `Mod-/`, read off `key` so a layout that shifts to reach `/` still matches; either
|
|
@@ -50,10 +44,6 @@ function guidanceTrigger(from, root) {
|
|
|
50
44
|
const trigger = root.querySelector(`.qm-field-hint[aria-describedby="${id}"]`);
|
|
51
45
|
if (trigger)
|
|
52
46
|
return trigger;
|
|
53
|
-
// A description under its label is on screen already, and the key is not the
|
|
54
|
-
// container's to answer for it.
|
|
55
|
-
if (document.getElementById(id)?.matches('.qm-field-brief'))
|
|
56
|
-
return undefined;
|
|
57
47
|
}
|
|
58
48
|
el = el.parentElement?.closest('[aria-describedby]') ?? null;
|
|
59
49
|
}
|
|
@@ -11,17 +11,20 @@ export interface Proposed {
|
|
|
11
11
|
* block ids. Each item carries `before`, what the writer read, so the editor keeps what the
|
|
12
12
|
* reader has written since and reports a place both changed as outdated.
|
|
13
13
|
*
|
|
14
|
-
* Cards pair by id. Each paired card's body and
|
|
15
|
-
* per block the answer rewrote or took out, and one `insert` item per run of blocks
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
14
|
+
* Cards pair by id. Each paired card's body and its rich text fields of `blocks` take one
|
|
15
|
+
* `replace` item per block the answer rewrote or took out, and one `insert` item per run of blocks
|
|
16
|
+
* it added. A text field of one line or of lines, at the top of a card or inside a record or a
|
|
17
|
+
* list, takes one item per run of lines the answer changed, lines paired by their words: each the
|
|
18
|
+
* value read with that run alone written, runs at most two unchanged lines apart one item, and a
|
|
19
|
+
* value that changes one run proposed whole. Every other field takes an item per place that
|
|
20
|
+
* changed: a record's cell, and a list's member, changed, taken out, or appended past the end, two
|
|
21
|
+
* appends to one list at successive indices. Members a list gains anywhere but its end are one
|
|
22
|
+
* item per run, `ahead` naming the member that follows them. A record or a list written where none
|
|
23
|
+
* was is compared with an empty one. A choice with variants is compared as a record, its
|
|
24
|
+
* discriminant a cell of it, and a checklist member by member: one ticked or unticked is proposed
|
|
25
|
+
* whole, and one held on both sides cell by cell. A value of a type nothing nests in, a field the
|
|
26
|
+
* answer clears, and a rich text value of `blocks` inside a record or a list are proposed whole.
|
|
27
|
+
* Values are in the form the editor's controls are handed, a text cell as its `Content`.
|
|
25
28
|
*
|
|
26
29
|
* A card the answer adds is an `add` item after the nearest card before it that the answer
|
|
27
30
|
* keeps, so cards it adds in a run stand in list order; one it takes out is a `remove` item.
|
package/dist/visual/proposals.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { fieldPathForAddr } from '../core/address.js';
|
|
2
|
+
import { asContent, lineRuns } from '../core/codec/value-plan.js';
|
|
2
3
|
import { sameValue } from './review.js';
|
|
3
|
-
import { VARIANT_DISCRIMINANT, baseType, fieldValues,
|
|
4
|
+
import { VARIANT_DISCRIMINANT, baseType, fieldValues, textKind } from './structure.js';
|
|
4
5
|
let minted = 0;
|
|
5
6
|
/**
|
|
6
7
|
* The review list from `base`, the document as the answer's writer read it, to `answer`, the
|
|
@@ -8,17 +9,20 @@ let minted = 0;
|
|
|
8
9
|
* block ids. Each item carries `before`, what the writer read, so the editor keeps what the
|
|
9
10
|
* reader has written since and reports a place both changed as outdated.
|
|
10
11
|
*
|
|
11
|
-
* Cards pair by id. Each paired card's body and
|
|
12
|
-
* per block the answer rewrote or took out, and one `insert` item per run of blocks
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
12
|
+
* Cards pair by id. Each paired card's body and its rich text fields of `blocks` take one
|
|
13
|
+
* `replace` item per block the answer rewrote or took out, and one `insert` item per run of blocks
|
|
14
|
+
* it added. A text field of one line or of lines, at the top of a card or inside a record or a
|
|
15
|
+
* list, takes one item per run of lines the answer changed, lines paired by their words: each the
|
|
16
|
+
* value read with that run alone written, runs at most two unchanged lines apart one item, and a
|
|
17
|
+
* value that changes one run proposed whole. Every other field takes an item per place that
|
|
18
|
+
* changed: a record's cell, and a list's member, changed, taken out, or appended past the end, two
|
|
19
|
+
* appends to one list at successive indices. Members a list gains anywhere but its end are one
|
|
20
|
+
* item per run, `ahead` naming the member that follows them. A record or a list written where none
|
|
21
|
+
* was is compared with an empty one. A choice with variants is compared as a record, its
|
|
22
|
+
* discriminant a cell of it, and a checklist member by member: one ticked or unticked is proposed
|
|
23
|
+
* whole, and one held on both sides cell by cell. A value of a type nothing nests in, a field the
|
|
24
|
+
* answer clears, and a rich text value of `blocks` inside a record or a list are proposed whole.
|
|
25
|
+
* Values are in the form the editor's controls are handed, a text cell as its `Content`.
|
|
22
26
|
*
|
|
23
27
|
* A card the answer adds is an `add` item after the nearest card before it that the answer
|
|
24
28
|
* keeps, so cards it adds in a run stand in list order; one it takes out is a `remove` item.
|
|
@@ -43,7 +47,8 @@ export function proposalsBetween(quill, base, answer, opts = {}) {
|
|
|
43
47
|
const fields = schema?.fields ?? {};
|
|
44
48
|
for (const name of keysOf(fields, before, after)) {
|
|
45
49
|
const f = fields[name];
|
|
46
|
-
|
|
50
|
+
const kind = f && textKind(f);
|
|
51
|
+
if (kind?.type === 'richtext' && kind.shape === 'blocks') {
|
|
47
52
|
blocks(pathOf(at, name), base, addrOf(at, name), answer, addrOf(answerAt, name));
|
|
48
53
|
continue;
|
|
49
54
|
}
|
|
@@ -101,6 +106,16 @@ export function proposalsBetween(quill, base, answer, opts = {}) {
|
|
|
101
106
|
...(was !== undefined && { before: was }),
|
|
102
107
|
...(now !== undefined && { after: now })
|
|
103
108
|
});
|
|
109
|
+
const text = f && textKind(f);
|
|
110
|
+
const words = text ? [asContent(was), asContent(now)] : [];
|
|
111
|
+
if (text && words[0] && words[1] && now != null) {
|
|
112
|
+
const runs = lineRuns(words[0], words[1], text.shape === 'blocks' ? 'paragraph' : 'run');
|
|
113
|
+
if (runs.length > 1) {
|
|
114
|
+
for (const run of runs)
|
|
115
|
+
items.push({ id: mint(), field: pathAt(steps), before: was, after: run });
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
104
119
|
const kind = f && baseType(f);
|
|
105
120
|
const records = isRecord(now) && (was == null || isRecord(was));
|
|
106
121
|
const cells = isRecord(was) ? was : {};
|
|
@@ -140,11 +155,8 @@ export function proposalsBetween(quill, base, answer, opts = {}) {
|
|
|
140
155
|
if (kind !== 'array' || !Array.isArray(now) || !(was == null || Array.isArray(was)))
|
|
141
156
|
return whole();
|
|
142
157
|
const held = Array.isArray(was) ? was : [];
|
|
143
|
-
const runs = aligned(held, now) ?? [
|
|
144
|
-
{ from: 0, to: 0, removed: held.length, added: now.length }
|
|
145
|
-
];
|
|
146
158
|
let appended = held.length;
|
|
147
|
-
for (const { from, to, removed, added } of
|
|
159
|
+
for (const { from, to, removed, added } of aligned(held, now)) {
|
|
148
160
|
const paired = Math.min(removed, added);
|
|
149
161
|
for (let k = 0; k < paired; k++)
|
|
150
162
|
value(pathAt, f?.items, [...steps, from + k], held[from + k], now[to + k]);
|
|
@@ -154,12 +166,20 @@ export function proposalsBetween(quill, base, answer, opts = {}) {
|
|
|
154
166
|
field: pathAt([...steps, from + k]),
|
|
155
167
|
before: held[from + k]
|
|
156
168
|
});
|
|
157
|
-
|
|
169
|
+
if (added > paired && from + removed < held.length)
|
|
158
170
|
items.push({
|
|
159
171
|
id: mint(),
|
|
160
|
-
field: pathAt([...steps,
|
|
161
|
-
|
|
172
|
+
field: pathAt([...steps, from + removed]),
|
|
173
|
+
ahead: held[from + removed],
|
|
174
|
+
after: now.slice(to + paired, to + added)
|
|
162
175
|
});
|
|
176
|
+
else
|
|
177
|
+
for (let k = paired; k < added; k++)
|
|
178
|
+
items.push({
|
|
179
|
+
id: mint(),
|
|
180
|
+
field: pathAt([...steps, appended++]),
|
|
181
|
+
after: now[to + k]
|
|
182
|
+
});
|
|
163
183
|
}
|
|
164
184
|
};
|
|
165
185
|
diffCard(quill.schema.main, undefined, base.main, answer.main, undefined);
|
|
@@ -233,8 +253,7 @@ function keysOf(declared, ...values) {
|
|
|
233
253
|
/**
|
|
234
254
|
* The runs where two lists differ, members matched by value along their longest common run:
|
|
235
255
|
* at each, `removed` members of `was` from `from` and `added` members of `now` from `to`. A run
|
|
236
|
-
* pairs its members as changes, and takes out or
|
|
237
|
-
* more members than it takes out anywhere but the end, which no index names.
|
|
256
|
+
* pairs its members as changes, and takes out, appends or puts in the rest.
|
|
238
257
|
*/
|
|
239
258
|
function aligned(was, now) {
|
|
240
259
|
const m = was.length;
|
|
@@ -253,16 +272,12 @@ function aligned(was, now) {
|
|
|
253
272
|
const close = () => {
|
|
254
273
|
const removed = i - from;
|
|
255
274
|
const added = j - to;
|
|
256
|
-
if (added > removed && i < m)
|
|
257
|
-
return false;
|
|
258
275
|
if (removed || added)
|
|
259
276
|
runs.push({ from, to, removed, added });
|
|
260
|
-
return true;
|
|
261
277
|
};
|
|
262
278
|
while (i < m && j < n) {
|
|
263
279
|
if (sameValue(was[i], now[j])) {
|
|
264
|
-
|
|
265
|
-
return undefined;
|
|
280
|
+
close();
|
|
266
281
|
i++;
|
|
267
282
|
j++;
|
|
268
283
|
from = i;
|
|
@@ -275,5 +290,6 @@ function aligned(was, now) {
|
|
|
275
290
|
}
|
|
276
291
|
i = m;
|
|
277
292
|
j = n;
|
|
278
|
-
|
|
293
|
+
close();
|
|
294
|
+
return runs;
|
|
279
295
|
}
|
package/dist/visual/props.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Document, Quill, Addr, Diagnostic, FontFace } from '@quillmark/wasm';
|
|
1
|
+
import type { Document, Quill, Addr, Diagnostic, FontFace, PathStep } from '@quillmark/wasm';
|
|
2
2
|
import type { Place } from '../core/address.js';
|
|
3
3
|
import type { EditorErrorHandler } from '../core/errors.js';
|
|
4
4
|
import type { ActiveLeaf, EditorChange } from './signals.js';
|
|
@@ -70,10 +70,12 @@ export interface VisualEditorProps {
|
|
|
70
70
|
* return `false` to mark that option unavailable; `enumDisallowed` decides how
|
|
71
71
|
* the control then draws it. The stored payload is untouched either way: the
|
|
72
72
|
* schema is unchanged, this is runtime policy. Absent → every schema option is
|
|
73
|
-
* offered. It reaches a field's own enum control
|
|
74
|
-
*
|
|
73
|
+
* offered. It reaches a field's own enum control, where `steps` is absent, and an
|
|
74
|
+
* enum inside the field's object subform, at any depth, where `steps` names the
|
|
75
|
+
* properties from the field down to it (`['level']` for `classification.level`).
|
|
76
|
+
* An enum inside a list or matrix cell is offered whole.
|
|
75
77
|
*/
|
|
76
|
-
enumOptionAllowed?: (addr: Addr, value: string) => boolean;
|
|
78
|
+
enumOptionAllowed?: (addr: Addr, value: string, steps?: readonly PathStep[]) => boolean;
|
|
77
79
|
/**
|
|
78
80
|
* How an `enumOptionAllowed: false` option draws: `'disable'` (the default) greys
|
|
79
81
|
* it in place, `'hide'` leaves it out of the list. One policy for the surface, not
|
|
@@ -32,6 +32,7 @@ export interface Drawn {
|
|
|
32
32
|
/** The field items over the leaf at `key`. */
|
|
33
33
|
at(key: string): {
|
|
34
34
|
proposed?: FieldProposal;
|
|
35
|
+
more?: readonly FieldProposal[];
|
|
35
36
|
nested?: readonly DeepReview[];
|
|
36
37
|
};
|
|
37
38
|
/** What each prose leaf draws, by leaf key, its ids in the leaf's order. */
|
|
@@ -36,9 +36,10 @@ export function orderOf(drawn) {
|
|
|
36
36
|
out.push(id);
|
|
37
37
|
};
|
|
38
38
|
const leaf = ({ key, schema, value }) => {
|
|
39
|
-
const { proposed, nested } = drawn.at(key);
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const { proposed, more, nested } = drawn.at(key);
|
|
40
|
+
for (const p of proposed ? [proposed, ...(more ?? [])] : [])
|
|
41
|
+
if (!drawn.undrawn.has(p.id))
|
|
42
|
+
take(p.id);
|
|
42
43
|
const inside = (nested ?? [])
|
|
43
44
|
.filter((e) => !drawn.undrawn.has(e.item.id))
|
|
44
45
|
.map((e) => ({ id: e.item.id, rank: schema ? rankAt(schema, e.steps, value) : [] }));
|
package/dist/visual/review.d.ts
CHANGED
|
@@ -17,7 +17,8 @@ import { type BlockPlace, type ReviewAction } from '../core/codec/index.js';
|
|
|
17
17
|
* field's writer would take, an absent one proposing the field cleared, and `before` the value
|
|
18
18
|
* its writer read. A path to a place inside a record or a
|
|
19
19
|
* list names that place: a cell, or a member by its index, which `after` absent takes out
|
|
20
|
-
* and an index past the last appends.
|
|
20
|
+
* and an index past the last appends. One with `ahead` puts the members `after` holds in
|
|
21
|
+
* front of `ahead`, the member its writer read at that index.
|
|
21
22
|
* - `add` or `remove`: a whole card, proposed new or proposed taken out (`CardProposal`).
|
|
22
23
|
*
|
|
23
24
|
* A `field` on a card names the card by its index, read against the cards as they stood when
|
|
@@ -152,7 +153,12 @@ export type FieldProposal = {
|
|
|
152
153
|
card?: string;
|
|
153
154
|
before?: unknown;
|
|
154
155
|
after?: unknown;
|
|
156
|
+
/** The member a run of members proposed new inside a list goes in front of, as its writer
|
|
157
|
+
* read the list at the path's index; `after` then holds the members, in order. */
|
|
158
|
+
ahead?: unknown;
|
|
155
159
|
};
|
|
160
|
+
/** Whether a field item puts new members into a list in front of one it holds. */
|
|
161
|
+
export declare const putsIn: (item: FieldProposal) => boolean;
|
|
156
162
|
/** A field item routed past its field: the steps from the rung it is handed to down to the
|
|
157
163
|
* value it names, a member of a list by its index, a cell of a record by its key. */
|
|
158
164
|
export interface DeepReview {
|
|
@@ -170,11 +176,15 @@ export declare function valueIn(value: unknown, steps: readonly PathStep[]): unk
|
|
|
170
176
|
/** `value` with what `steps` reach set to `to`: a list's member past its end appended, and one
|
|
171
177
|
* set to nothing taken out; a record's cell set to nothing left out. Copies on the way down. */
|
|
172
178
|
export declare function valueWith(value: unknown, steps: readonly PathStep[], to: unknown): unknown;
|
|
179
|
+
/** `value` with `members` put into the list `steps` reach, in front of the member at its last
|
|
180
|
+
* step, or at its end past the last. */
|
|
181
|
+
export declare function valueInserting(value: unknown, steps: readonly PathStep[], members: unknown): unknown;
|
|
173
182
|
/**
|
|
174
183
|
* Where a field proposal's steps land in `value` as it stands. A list's member is found by its
|
|
175
184
|
* index where it holds `before`, else as the nearest member holding `before` that `claimed`
|
|
176
185
|
* does not already hold, so one member taken out does not move another's proposal onto the
|
|
177
|
-
* wrong row.
|
|
186
|
+
* wrong row. An insert lands in front of the nearest member holding its `ahead`, and claims
|
|
187
|
+
* none. `found` is false where the proposal has a `before` or an `ahead` nothing holds.
|
|
178
188
|
*/
|
|
179
189
|
export declare function locate(value: unknown, steps: readonly PathStep[], item: FieldProposal, claimed: Set<string>): {
|
|
180
190
|
steps: readonly PathStep[];
|
|
@@ -211,6 +221,9 @@ export interface TextProposal {
|
|
|
211
221
|
/** A proposal over a leaf of words, `undefined` where its values are not words. A cleared value
|
|
212
222
|
* is drawn as what Accept leaves: `cleared`, the default that would print, else nothing. */
|
|
213
223
|
export declare function textProposal(item: FieldProposal | undefined, cleared?: Content): TextProposal | undefined;
|
|
224
|
+
/** A place's proposals over a leaf of words, each run of one answer, or `undefined` where any
|
|
225
|
+
* of them is not words or there are none. */
|
|
226
|
+
export declare function textsOf(items: readonly FieldProposal[], cleared?: Content): TextProposal[] | undefined;
|
|
214
227
|
/** A number's proposal, drawn over its input as the struck and the proposed figures; `undefined`
|
|
215
228
|
* for one that clears it, which the input shows as what Accept leaves. */
|
|
216
229
|
export declare function numberProposal(item: FieldProposal | undefined): {
|