@quillmark/svelte 0.35.0 → 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 +9 -15
- 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 -131
- 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
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
/** The current change, `undefined` for no card. */
|
|
3
|
+
id: string | undefined;
|
|
4
|
+
/** The editor's root, which every element of the change is under. */
|
|
5
|
+
root: HTMLElement | undefined;
|
|
6
|
+
/** The room, in px, the host's chrome takes at the pane's foot. */
|
|
7
|
+
inset: number;
|
|
8
|
+
/** Held out of the way: the reader is typing. */
|
|
9
|
+
hidden: boolean;
|
|
10
|
+
/** The reader's own writing meets the change. */
|
|
11
|
+
outdated: boolean;
|
|
12
|
+
onAnswer(action: 'accept' | 'dismiss'): void;
|
|
13
|
+
onHover(on: boolean): void;
|
|
14
|
+
}
|
|
15
|
+
declare const ReviewCard: import("svelte").Component<Props, {
|
|
16
|
+
enter: () => Promise<boolean>;
|
|
17
|
+
}, "">;
|
|
18
|
+
type ReviewCard = ReturnType<typeof ReviewCard>;
|
|
19
|
+
export default ReviewCard;
|
|
@@ -1,149 +1,122 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
A proposed value
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
A proposed value whose control cannot draw it as words, marked on that control. The control
|
|
3
|
+
shows the value it would hold (its caller hands it `after`) and takes the review tint, so a
|
|
4
|
+
proposal moves nothing around it; a member a proposal takes out is struck where it stands. A
|
|
5
|
+
one-line text leaf draws its proposal itself, as a word diff (`value-diff.ts`), and takes no
|
|
6
|
+
mark.
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
It draws nothing of its own. Its anchor holds what the mark says to assistive tech, the proposed
|
|
9
|
+
value being the one the control shows, and each focusable part of the control is described by it. Its anchor stands after the control it marks, and the control is
|
|
10
|
+
the nearest element before it that is neither another anchor, a diagnostic list nor a row's
|
|
11
|
+
actions; with none, its parent. The mark sits on that control's own box (`BOX`) where the
|
|
12
|
+
element found is a cell or a row holding one, so the tint never spreads past the control. The control carries the item's id among its `data-qm-review`
|
|
13
|
+
tokens, so the card stands on the control and a press on it names the item.
|
|
10
14
|
-->
|
|
11
15
|
<script lang="ts">
|
|
12
|
-
import {
|
|
13
|
-
import { reviewRuns, reviewText, type FieldProposal } from './review.js';
|
|
16
|
+
import { reviewText, type FieldProposal } from './review.js';
|
|
14
17
|
import { review } from './review.svelte.js';
|
|
18
|
+
import { wording } from './strings.js';
|
|
15
19
|
|
|
16
20
|
interface Props {
|
|
17
21
|
item: FieldProposal;
|
|
18
|
-
/** The value the control holds. */
|
|
19
|
-
value: unknown;
|
|
20
|
-
/** Take the focus back to the control: an answer given from the row unmounts it. */
|
|
21
|
-
refocus?: () => void;
|
|
22
|
-
/** Where the value is, for one drawn under a control that is not its own. */
|
|
23
|
-
label?: string;
|
|
24
22
|
/** It takes a list's member out, so nothing comes in its place. */
|
|
25
23
|
removes?: boolean;
|
|
24
|
+
/** The value the control would show without the proposal, where the caller knows it: a
|
|
25
|
+
* default an unset field prints. Else the value the place holds. */
|
|
26
|
+
current?: unknown;
|
|
26
27
|
}
|
|
27
|
-
let { item,
|
|
28
|
+
let { item, removes = false, current }: Props = $props();
|
|
28
29
|
|
|
29
|
-
let row = $state<HTMLElement>();
|
|
30
|
-
function answer(action: 'accept' | 'dismiss'): void {
|
|
31
|
-
const held = !!row?.contains(document.activeElement);
|
|
32
|
-
reviewing.act(item.id, action);
|
|
33
|
-
if (held) refocus?.();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const t = wording();
|
|
37
30
|
const reviewing = review();
|
|
31
|
+
const t = wording();
|
|
32
|
+
const describer = $props.id();
|
|
33
|
+
const description = $derived.by(() => {
|
|
34
|
+
if (removes) return t.strings.reviewRemoveCard;
|
|
35
|
+
const words = { on: t.strings.reviewOn, off: t.strings.reviewOff };
|
|
36
|
+
const now = current ?? reviewing.current(item);
|
|
37
|
+
const shown = now == null && typeof item.after === 'boolean' ? false : now;
|
|
38
|
+
return t.strings.reviewCurrently(reviewText(shown, words) || t.strings.reviewEmpty);
|
|
39
|
+
});
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
41
|
+
/** What a reader lands on in the control: the control itself where it takes focus, else each
|
|
42
|
+
* part of it that does, a date's segments. */
|
|
43
|
+
const FOCUSABLE =
|
|
44
|
+
'button, input, select, [contenteditable="true"], [tabindex]:not([tabindex="-1"])';
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
<div
|
|
46
|
-
bind:this={row}
|
|
47
|
-
class={['qm-review-proposal', { 'qm-review-lit': reviewing.lit === item.id }]}
|
|
48
|
-
data-qm-review={item.id}
|
|
49
|
-
role="group"
|
|
50
|
-
aria-label={t.strings.reviewProposal}
|
|
51
|
-
onpointerenter={() => reviewing.point(item.id, 'pointer')}
|
|
52
|
-
onpointerleave={() => reviewing.point(undefined, 'pointer')}
|
|
53
|
-
>
|
|
54
|
-
<span class="qm-review-value">
|
|
55
|
-
{#if label}<span class="qm-review-where">{label}: </span>{/if}
|
|
56
|
-
{#each runs as run, i (i)}
|
|
57
|
-
{#if run.kind === 'del'}<del class="qm-review-del">{run.text}</del
|
|
58
|
-
>{:else if run.kind === 'ins'}<ins class="qm-review-ins">{run.text}</ins
|
|
59
|
-
>{:else}{run.text}{/if}
|
|
60
|
-
{/each}
|
|
61
|
-
{#if !after && !removes}
|
|
62
|
-
<span class="qm-review-none">{t.strings.reviewEmpty}</span>
|
|
63
|
-
{/if}
|
|
64
|
-
</span>
|
|
65
|
-
<span class="qm-review-answers">
|
|
66
|
-
{#if reviewing.fieldOutdated.has(item.id)}
|
|
67
|
-
<span class="qm-review-outdated-label">{t.strings.reviewOutdated}</span>
|
|
68
|
-
{/if}
|
|
69
|
-
<button
|
|
70
|
-
type="button"
|
|
71
|
-
class="qm-review-act qm-review-accept qm-focus-ring"
|
|
72
|
-
title={t.strings.reviewAcceptTitle}
|
|
73
|
-
onclick={() => answer('accept')}>{t.strings.reviewAccept}</button
|
|
74
|
-
>
|
|
75
|
-
<button
|
|
76
|
-
type="button"
|
|
77
|
-
class="qm-review-act qm-review-dismiss qm-focus-ring"
|
|
78
|
-
title={t.strings.reviewDismissTitle}
|
|
79
|
-
onclick={() => answer('dismiss')}>{t.strings.reviewDismiss}</button
|
|
80
|
-
>
|
|
81
|
-
</span>
|
|
82
|
-
</div>
|
|
46
|
+
const SKIP = '.qm-review-anchor, .qm-diag-list, .qm-row-actions';
|
|
83
47
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
padding-inline-start: var(--_qm-space-3);
|
|
95
|
-
font-size: var(--_qm-text-body);
|
|
96
|
-
}
|
|
97
|
-
.qm-review-value {
|
|
98
|
-
min-width: 0;
|
|
99
|
-
overflow-wrap: anywhere;
|
|
100
|
-
white-space: pre-wrap;
|
|
101
|
-
}
|
|
102
|
-
.qm-review-del {
|
|
103
|
-
color: var(--_qm-ink-label);
|
|
104
|
-
text-decoration: line-through;
|
|
105
|
-
text-decoration-color: var(--_qm-review-line);
|
|
106
|
-
}
|
|
107
|
-
.qm-review-ins {
|
|
108
|
-
text-decoration: none;
|
|
109
|
-
background: var(--_qm-review-tint);
|
|
110
|
-
box-shadow:
|
|
111
|
-
calc(-1 * var(--_qm-space-half)) 0 0 var(--_qm-review-tint),
|
|
112
|
-
var(--_qm-space-half) 0 0 var(--_qm-review-tint);
|
|
113
|
-
border-radius: var(--_qm-radius-inner);
|
|
114
|
-
-webkit-box-decoration-break: clone;
|
|
115
|
-
box-decoration-break: clone;
|
|
116
|
-
transition:
|
|
117
|
-
background-color var(--_qm-duration-fast) var(--_qm-ease-reverse),
|
|
118
|
-
box-shadow var(--_qm-duration-fast) var(--_qm-ease-reverse);
|
|
119
|
-
}
|
|
120
|
-
.qm-review-del + .qm-review-ins {
|
|
121
|
-
margin-inline-start: calc(var(--_qm-space) + var(--_qm-space-half));
|
|
122
|
-
}
|
|
123
|
-
.qm-review-lit .qm-review-ins {
|
|
124
|
-
background: var(--_qm-review-lit);
|
|
125
|
-
box-shadow:
|
|
126
|
-
calc(-1 * var(--_qm-space-half)) 0 0 var(--_qm-review-lit),
|
|
127
|
-
var(--_qm-space-half) 0 0 var(--_qm-review-lit);
|
|
128
|
-
}
|
|
129
|
-
.qm-review-where {
|
|
130
|
-
color: var(--_qm-ink-label);
|
|
131
|
-
}
|
|
132
|
-
.qm-review-none {
|
|
133
|
-
color: var(--_qm-ink-label);
|
|
134
|
-
font-style: italic;
|
|
135
|
-
}
|
|
136
|
-
.qm-review-answers {
|
|
137
|
-
display: inline-flex;
|
|
138
|
-
flex-shrink: 0;
|
|
139
|
-
gap: var(--_qm-space-half);
|
|
140
|
-
font-size: var(--_qm-text-label);
|
|
141
|
-
font-weight: var(--_qm-weight-mid);
|
|
142
|
-
line-height: var(--_qm-leading-tight);
|
|
48
|
+
/** A control's own box: what the tint and the ring sit on, at any depth, where the control
|
|
49
|
+
* found is the cell or the row around it. */
|
|
50
|
+
const BOX = '.qm-control-box, .qm-toggle, .qm-tick';
|
|
51
|
+
|
|
52
|
+
function control(anchor: HTMLElement): HTMLElement | undefined {
|
|
53
|
+
let at = anchor.previousElementSibling;
|
|
54
|
+
while (at && at.matches(SKIP)) at = at.previousElementSibling;
|
|
55
|
+
const found = (at as HTMLElement | null) ?? anchor.parentElement ?? undefined;
|
|
56
|
+
if (!found || removes || found.matches(BOX)) return found;
|
|
57
|
+
return found.querySelector<HTMLElement>(BOX) ?? found;
|
|
143
58
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
59
|
+
|
|
60
|
+
function mark(anchor: HTMLElement) {
|
|
61
|
+
const target = control(anchor);
|
|
62
|
+
const id = item.id;
|
|
63
|
+
if (!target) return;
|
|
64
|
+
const tokens = () => (target.getAttribute('data-qm-review') ?? '').split(' ').filter(Boolean);
|
|
65
|
+
target.setAttribute('data-qm-review', [...tokens(), id].join(' '));
|
|
66
|
+
target.setAttribute('data-qm-proposed', '');
|
|
67
|
+
if (removes) target.setAttribute('data-qm-removes', '');
|
|
68
|
+
const enter = () => reviewing.point(id, 'pointer');
|
|
69
|
+
const leave = () => reviewing.point(undefined, 'pointer');
|
|
70
|
+
target.addEventListener('pointerenter', enter);
|
|
71
|
+
target.addEventListener('pointerleave', leave);
|
|
72
|
+
const by = (el: HTMLElement) =>
|
|
73
|
+
(el.getAttribute('aria-describedby') ?? '').split(' ').filter(Boolean);
|
|
74
|
+
const described = new Set<HTMLElement>();
|
|
75
|
+
// A control draws some of its parts after this mark is laid, a date its segments, and
|
|
76
|
+
// writes their attributes again as it renders, so each is described as it appears.
|
|
77
|
+
const describe = (): void => {
|
|
78
|
+
const parts = target.matches(FOCUSABLE)
|
|
79
|
+
? [target]
|
|
80
|
+
: target.querySelectorAll<HTMLElement>(FOCUSABLE);
|
|
81
|
+
for (const el of parts) {
|
|
82
|
+
described.add(el);
|
|
83
|
+
if (!by(el).includes(describer))
|
|
84
|
+
el.setAttribute('aria-describedby', [...by(el), describer].join(' '));
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
describe();
|
|
88
|
+
const watch = new MutationObserver(describe);
|
|
89
|
+
watch.observe(target, {
|
|
90
|
+
subtree: true,
|
|
91
|
+
childList: true,
|
|
92
|
+
attributes: true,
|
|
93
|
+
attributeFilter: ['tabindex', 'aria-describedby', 'contenteditable']
|
|
94
|
+
});
|
|
95
|
+
$effect(() => {
|
|
96
|
+
const lit = reviewing.lit !== undefined && tokens().includes(reviewing.lit);
|
|
97
|
+
target.toggleAttribute('data-qm-proposed-lit', lit);
|
|
98
|
+
});
|
|
99
|
+
return () => {
|
|
100
|
+
watch.disconnect();
|
|
101
|
+
for (const el of described) {
|
|
102
|
+
const rest = by(el).filter((d) => d !== describer);
|
|
103
|
+
if (rest.length) el.setAttribute('aria-describedby', rest.join(' '));
|
|
104
|
+
else el.removeAttribute('aria-describedby');
|
|
105
|
+
}
|
|
106
|
+
target.removeEventListener('pointerenter', enter);
|
|
107
|
+
target.removeEventListener('pointerleave', leave);
|
|
108
|
+
const rest = tokens().filter((t) => t !== id);
|
|
109
|
+
if (rest.length) {
|
|
110
|
+
target.setAttribute('data-qm-review', rest.join(' '));
|
|
111
|
+
target.toggleAttribute('data-qm-proposed-lit', rest.includes(reviewing.lit ?? ''));
|
|
112
|
+
} else {
|
|
113
|
+
target.removeAttribute('data-qm-review');
|
|
114
|
+
target.removeAttribute('data-qm-proposed');
|
|
115
|
+
target.removeAttribute('data-qm-removes');
|
|
116
|
+
target.removeAttribute('data-qm-proposed-lit');
|
|
117
|
+
}
|
|
118
|
+
};
|
|
148
119
|
}
|
|
149
|
-
</
|
|
120
|
+
</script>
|
|
121
|
+
|
|
122
|
+
<span class="qm-review-anchor" id={describer} hidden {@attach mark}>{description}</span>
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { type FieldProposal } from './review.js';
|
|
2
2
|
interface Props {
|
|
3
3
|
item: FieldProposal;
|
|
4
|
-
/** The value the control holds. */
|
|
5
|
-
value: unknown;
|
|
6
|
-
/** Take the focus back to the control: an answer given from the row unmounts it. */
|
|
7
|
-
refocus?: () => void;
|
|
8
|
-
/** Where the value is, for one drawn under a control that is not its own. */
|
|
9
|
-
label?: string;
|
|
10
4
|
/** It takes a list's member out, so nothing comes in its place. */
|
|
11
5
|
removes?: boolean;
|
|
6
|
+
/** The value the control would show without the proposal, where the caller knows it: a
|
|
7
|
+
* default an unset field prints. Else the value the place holds. */
|
|
8
|
+
current?: unknown;
|
|
12
9
|
}
|
|
13
10
|
declare const ReviewProposal: import("svelte").Component<Props, {}, "">;
|
|
14
11
|
type ReviewProposal = ReturnType<typeof ReviewProposal>;
|
|
@@ -1,43 +1,24 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
The review items a container hands to one of its places,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
number.
|
|
2
|
+
The review items a container hands to one of its places, each marked on that place's control:
|
|
3
|
+
the review tint where the control shows the value it would hold, struck where a member would be
|
|
4
|
+
taken out. An item naming a place deeper than the control it marks, which no control of its own
|
|
5
|
+
draws, tints the nearest control that holds it.
|
|
7
6
|
-->
|
|
8
7
|
<script lang="ts">
|
|
9
|
-
import type { PathStep } from '@quillmark/wasm';
|
|
10
8
|
import ReviewProposal from './ReviewProposal.svelte';
|
|
11
|
-
import {
|
|
12
|
-
import { wording } from './strings.js';
|
|
13
|
-
import { humanize } from './structure.js';
|
|
9
|
+
import type { DeepReview } from './review.js';
|
|
14
10
|
|
|
15
11
|
interface Props {
|
|
16
12
|
entries: readonly DeepReview[] | undefined;
|
|
17
|
-
/** The value the place holds, which the entries' steps walk from. */
|
|
18
|
-
value: unknown;
|
|
19
13
|
/** The place is a list's member, which a proposal of nothing takes out. */
|
|
20
14
|
member?: boolean;
|
|
21
15
|
}
|
|
22
|
-
let { entries,
|
|
23
|
-
|
|
24
|
-
const t = wording();
|
|
25
|
-
|
|
26
|
-
const where = (steps: readonly PathStep[]): string | undefined =>
|
|
27
|
-
steps.length
|
|
28
|
-
? steps
|
|
29
|
-
.map((step) =>
|
|
30
|
-
typeof step === 'number' ? t.strings.elementItem(step + 1) : humanize(step)
|
|
31
|
-
)
|
|
32
|
-
.join(' · ')
|
|
33
|
-
: undefined;
|
|
16
|
+
let { entries, member = false }: Props = $props();
|
|
34
17
|
</script>
|
|
35
18
|
|
|
36
19
|
{#each entries ?? [] as { steps, item } (item.id)}
|
|
37
20
|
<ReviewProposal
|
|
38
21
|
{item}
|
|
39
|
-
value={valueIn(value, steps)}
|
|
40
|
-
label={where(steps)}
|
|
41
22
|
removes={item.after === undefined && (steps.length ? typeof steps.at(-1) === 'number' : member)}
|
|
42
23
|
/>
|
|
43
24
|
{/each}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DeepReview } from './review.js';
|
|
2
2
|
interface Props {
|
|
3
3
|
entries: readonly DeepReview[] | undefined;
|
|
4
|
-
/** The value the place holds, which the entries' steps walk from. */
|
|
5
|
-
value: unknown;
|
|
6
4
|
/** The place is a list's member, which a proposal of nothing takes out. */
|
|
7
5
|
member?: boolean;
|
|
8
6
|
}
|
|
@@ -18,7 +18,10 @@
|
|
|
18
18
|
import EnumField from './EnumField.svelte';
|
|
19
19
|
import ObjectField from './ObjectField.svelte';
|
|
20
20
|
import DiagnosticList from './DiagnosticList.svelte';
|
|
21
|
+
import ReviewRows from './ReviewRows.svelte';
|
|
21
22
|
import type { DeepDiagnostic } from './diagnostics.js';
|
|
23
|
+
import { shownValue, splitReview, type DeepReview } from './review.js';
|
|
24
|
+
import { review as reviewState } from './review.svelte.js';
|
|
22
25
|
import type { LandingBox } from './leaves.js';
|
|
23
26
|
import {
|
|
24
27
|
VARIANT_DISCRIMINANT,
|
|
@@ -51,6 +54,10 @@
|
|
|
51
54
|
* naming a live cell draws under it; the rest — the discriminant's, a dormant
|
|
52
55
|
* world's — draw at the field's foot. */
|
|
53
56
|
diagnostics?: readonly DeepDiagnostic[];
|
|
57
|
+
/** The review items naming a place inside this field, each with its steps still to
|
|
58
|
+
* walk: the discriminant's drawn on its select, a live cell's in that cell, and the
|
|
59
|
+
* rest at the field's foot. */
|
|
60
|
+
review?: readonly DeepReview[];
|
|
54
61
|
}
|
|
55
62
|
let {
|
|
56
63
|
value,
|
|
@@ -64,12 +71,41 @@
|
|
|
64
71
|
onCommit,
|
|
65
72
|
optionAllowed,
|
|
66
73
|
enumDisallowed,
|
|
67
|
-
diagnostics
|
|
74
|
+
diagnostics,
|
|
75
|
+
review
|
|
68
76
|
}: Props = $props();
|
|
69
77
|
|
|
70
|
-
const
|
|
78
|
+
const reviewing = reviewState();
|
|
79
|
+
const reviewed = $derived(splitReview(review));
|
|
80
|
+
/** The discriminant's own proposal: the select shows the member it would pick, and the
|
|
81
|
+
* cells of that member's world. */
|
|
82
|
+
const pick = $derived(reviewed.below.get(VARIANT_DISCRIMINANT)?.find((e) => !e.steps.length));
|
|
83
|
+
const discriminant = $derived(
|
|
84
|
+
shownValue(pick?.item, value?.[VARIANT_DISCRIMINANT]) as string | undefined
|
|
85
|
+
);
|
|
86
|
+
const member = $derived(
|
|
87
|
+
variantMember(pick ? { ...value, [VARIANT_DISCRIMINANT]: discriminant } : value, ghostMember)
|
|
88
|
+
);
|
|
71
89
|
const cells = $derived(variantCells(schema, member));
|
|
72
|
-
|
|
90
|
+
/** The cells' items, by the live world's keys; the rest stand at the foot. */
|
|
91
|
+
const cellReview = $derived(
|
|
92
|
+
[...reviewed.below]
|
|
93
|
+
.filter(([step]) => live(step))
|
|
94
|
+
.flatMap(([step, list]) => list.map((e) => ({ steps: [step, ...e.steps], item: e.item })))
|
|
95
|
+
);
|
|
96
|
+
const reviewFoot = $derived([
|
|
97
|
+
...reviewed.here,
|
|
98
|
+
...[...reviewed.below]
|
|
99
|
+
.filter(([step]) => !live(step) && step !== VARIANT_DISCRIMINANT)
|
|
100
|
+
.flatMap(([step, list]) => list.map((e) => ({ steps: [step, ...e.steps], item: e.item })))
|
|
101
|
+
]);
|
|
102
|
+
/** A pick under the discriminant's proposal answers it: its member accepts, any other is
|
|
103
|
+
* written and dismisses it. */
|
|
104
|
+
function commitPick(v: string | undefined): void {
|
|
105
|
+
const next = commitDiscriminant(value, v);
|
|
106
|
+
if (pick && reviewing.answerWith(pick.item.id, next?.[VARIANT_DISCRIMINANT])) return;
|
|
107
|
+
onCommit(next);
|
|
108
|
+
}
|
|
73
109
|
|
|
74
110
|
type Subform = {
|
|
75
111
|
focus: () => void;
|
|
@@ -119,10 +155,12 @@
|
|
|
119
155
|
blankTitle={schema.ui?.blank_title}
|
|
120
156
|
{id}
|
|
121
157
|
{describedBy}
|
|
122
|
-
onCommit={
|
|
158
|
+
onCommit={commitPick}
|
|
159
|
+
proposing={!!pick}
|
|
123
160
|
{optionAllowed}
|
|
124
161
|
{enumDisallowed}
|
|
125
162
|
/>
|
|
163
|
+
<ReviewRows entries={reviewed.below.get(VARIANT_DISCRIMINANT)} />
|
|
126
164
|
<!-- Keyed on the member so a flip remounts the cells rather than re-targeting
|
|
127
165
|
them: two worlds' cells are different fields that happen to occupy one place,
|
|
128
166
|
and a control carrying local state (an unreconciled pick, a caret) across the
|
|
@@ -140,12 +178,14 @@
|
|
|
140
178
|
{contentAt}
|
|
141
179
|
onCommit={(obj) => onCommit(obj)}
|
|
142
180
|
diagnostics={inside}
|
|
181
|
+
review={cellReview}
|
|
143
182
|
/>
|
|
144
183
|
{/key}
|
|
145
184
|
{/if}
|
|
146
185
|
<!-- The field's own foot, drawn whether or not a world is: what the live world
|
|
147
186
|
cannot hold belongs under the field rather than inside the box its cells sit in. -->
|
|
148
187
|
<DiagnosticList diagnostics={foot} />
|
|
188
|
+
<ReviewRows entries={reviewFoot} />
|
|
149
189
|
</div>
|
|
150
190
|
|
|
151
191
|
<style>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Content, PathStep, QuillFieldSchema } from '@quillmark/wasm';
|
|
2
2
|
import type { DeepDiagnostic } from './diagnostics.js';
|
|
3
|
+
import { type DeepReview } from './review.js';
|
|
3
4
|
import type { LandingBox } from './leaves.js';
|
|
4
5
|
interface Props {
|
|
5
6
|
/** The stored container, or undefined while the field is unset. */
|
|
@@ -25,6 +26,10 @@ interface Props {
|
|
|
25
26
|
* naming a live cell draws under it; the rest — the discriminant's, a dormant
|
|
26
27
|
* world's — draw at the field's foot. */
|
|
27
28
|
diagnostics?: readonly DeepDiagnostic[];
|
|
29
|
+
/** The review items naming a place inside this field, each with its steps still to
|
|
30
|
+
* walk: the discriminant's drawn on its select, a live cell's in that cell, and the
|
|
31
|
+
* rest at the field's foot. */
|
|
32
|
+
review?: readonly DeepReview[];
|
|
28
33
|
}
|
|
29
34
|
declare const VariantField: import("svelte").Component<Props, {
|
|
30
35
|
focus: () => void;
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
import type { DocPath, Landing } from '../core/address.js';
|
|
29
29
|
import type { Delta } from '../core/codec/positions.js';
|
|
30
30
|
import type { CardId, CardOp } from './signals.js';
|
|
31
|
+
import type { Document } from '@quillmark/wasm';
|
|
31
32
|
import type { VisualEditorProps } from './props.js';
|
|
33
|
+
import { NO_PROJECTION, type ReviewProjection } from './review.js';
|
|
32
34
|
import VisualEditorInner from './VisualEditorInner.svelte';
|
|
33
35
|
|
|
34
36
|
let props: VisualEditorProps = $props();
|
|
@@ -106,22 +108,29 @@
|
|
|
106
108
|
export function applyCardOps(ops: readonly CardOp[]): void {
|
|
107
109
|
inner?.applyCardOps(ops);
|
|
108
110
|
}
|
|
109
|
-
/** Bring the review item `id` to the reader: its panel opened,
|
|
110
|
-
* the view
|
|
111
|
-
* the item
|
|
111
|
+
/** Bring the review item `id` to the reader as the current change: its panel opened,
|
|
112
|
+
* scrolled to the middle of the view. The focus stays put unless `focus` sends the caret
|
|
113
|
+
* into the item. False for an item not drawn. */
|
|
112
114
|
export async function revealReview(id: string, opts?: { focus?: boolean }): Promise<boolean> {
|
|
113
115
|
return (await inner?.revealReview(id, opts)) ?? false;
|
|
114
116
|
}
|
|
115
|
-
/** Answer items as
|
|
116
|
-
* moving neither the focus nor the caret
|
|
117
|
+
/** Answer items as the answer card would, in document order (`'all'`: every item drawn),
|
|
118
|
+
* moving neither the focus nor the caret; where the current change is among them, the next
|
|
119
|
+
* open one is current. Returns the ids answered. */
|
|
117
120
|
export function answerReview(
|
|
118
121
|
ids: readonly string[] | 'all',
|
|
119
122
|
action: 'accept' | 'dismiss'
|
|
120
123
|
): string[] {
|
|
121
124
|
return inner?.answerReview(ids, action) ?? [];
|
|
122
125
|
}
|
|
123
|
-
/**
|
|
124
|
-
*
|
|
126
|
+
/** Write every open item the editor draws into `target`, a copy of `doc` the host made, as
|
|
127
|
+
* accepting them all would, without writing to `doc` or raising a hook. Returns the way
|
|
128
|
+
* between places in `doc` and places in `target`, good until either changes. */
|
|
129
|
+
export function projectReview(target: Document): ReviewProjection {
|
|
130
|
+
return inner?.projectReview(target) ?? NO_PROJECTION;
|
|
131
|
+
}
|
|
132
|
+
/** Make the next or previous open item current, round from either end, the caret or the
|
|
133
|
+
* focus in it unless `focus` is false. Resolves its id, `undefined` for none. */
|
|
125
134
|
export async function stepReview(
|
|
126
135
|
dir: 1 | -1,
|
|
127
136
|
opts?: { focus?: boolean }
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { DocPath, Landing } from '../core/address.js';
|
|
2
2
|
import type { Delta } from '../core/codec/positions.js';
|
|
3
3
|
import type { CardId, CardOp } from './signals.js';
|
|
4
|
+
import type { Document } from '@quillmark/wasm';
|
|
4
5
|
import type { VisualEditorProps } from './props.js';
|
|
6
|
+
import { type ReviewProjection } from './review.js';
|
|
5
7
|
declare const VisualEditor: import("svelte").Component<VisualEditorProps, {
|
|
6
8
|
setCaret: (at: Landing) => Promise<void>;
|
|
7
9
|
focusField: (field: DocPath) => Promise<void>;
|
|
@@ -17,6 +19,7 @@ declare const VisualEditor: import("svelte").Component<VisualEditorProps, {
|
|
|
17
19
|
focus?: boolean;
|
|
18
20
|
}) => Promise<boolean>;
|
|
19
21
|
answerReview: (ids: readonly string[] | "all", action: "accept" | "dismiss") => string[];
|
|
22
|
+
projectReview: (target: Document) => ReviewProjection;
|
|
20
23
|
stepReview: (dir: 1 | -1, opts?: {
|
|
21
24
|
focus?: boolean;
|
|
22
25
|
}) => Promise<string | undefined>;
|