@quillmark/svelte 0.35.1 → 0.37.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 +30 -18
- package/THEMING.md +1 -1
- package/dist/core/address.d.ts +5 -0
- package/dist/core/address.js +14 -0
- package/dist/core/codec/decode.d.ts +4 -2
- package/dist/core/codec/decode.js +5 -2
- package/dist/core/codec/field.d.ts +42 -16
- package/dist/core/codec/field.js +97 -28
- package/dist/core/codec/index.d.ts +8 -5
- package/dist/core/codec/index.js +4 -5
- package/dist/core/codec/prose.css +25 -81
- package/dist/core/codec/review.d.ts +31 -26
- package/dist/core/codec/review.js +93 -169
- package/dist/core/codec/schema.d.ts +12 -2
- package/dist/core/codec/schema.js +27 -5
- package/dist/core/codec/shortcuts.d.ts +5 -4
- package/dist/core/codec/shortcuts.js +9 -8
- package/dist/core/codec/table-view.js +15 -3
- 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 +46 -15
- package/dist/core/tooltip.css +49 -0
- package/dist/core/tooltip.d.ts +6 -0
- package/dist/core/tooltip.js +176 -0
- package/dist/preview/Preview.svelte +22 -1
- package/dist/preview/controller.js +38 -0
- package/dist/preview/strings.d.ts +2 -0
- package/dist/preview/strings.js +1 -0
- package/dist/visual/ArrayField.svelte +374 -96
- package/dist/visual/Card.svelte +33 -12
- package/dist/visual/Card.svelte.d.ts +3 -0
- package/dist/visual/CardControls.svelte +3 -3
- package/dist/visual/DateField.svelte +47 -5
- package/dist/visual/DiagnosticList.svelte +3 -2
- package/dist/visual/EnumField.svelte +20 -5
- package/dist/visual/EnumField.svelte.d.ts +5 -0
- package/dist/visual/Field.svelte +56 -47
- package/dist/visual/FieldHint.svelte +20 -8
- package/dist/visual/FormatPopover.svelte +54 -20
- package/dist/visual/MatrixField.svelte +48 -6
- package/dist/visual/MatrixField.svelte.d.ts +5 -0
- package/dist/visual/NumberField.svelte +131 -6
- package/dist/visual/NumberField.svelte.d.ts +5 -0
- package/dist/visual/ObjectField.svelte +60 -18
- package/dist/visual/ProseField.svelte +21 -5
- package/dist/visual/ProseField.svelte.d.ts +5 -1
- package/dist/visual/ProseValue.svelte +49 -8
- package/dist/visual/ProseValue.svelte.d.ts +7 -1
- package/dist/visual/ReviewCard.svelte +400 -0
- package/dist/visual/ReviewCard.svelte.d.ts +20 -0
- package/dist/visual/ReviewProposal.svelte +98 -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/TipsCard.svelte +1 -1
- package/dist/visual/VariantField.svelte +45 -4
- package/dist/visual/VariantField.svelte.d.ts +5 -0
- package/dist/visual/VisualEditor.svelte +24 -9
- package/dist/visual/VisualEditor.svelte.d.ts +8 -1
- package/dist/visual/VisualEditorInner.svelte +917 -280
- package/dist/visual/VisualEditorInner.svelte.d.ts +8 -1
- package/dist/visual/controls.css +2 -2
- package/dist/visual/index.d.ts +2 -2
- package/dist/visual/proposals.d.ts +25 -24
- package/dist/visual/proposals.js +92 -32
- package/dist/visual/props.d.ts +18 -18
- package/dist/visual/review-order.d.ts +51 -0
- package/dist/visual/review-order.js +87 -0
- package/dist/visual/review.d.ts +94 -3
- package/dist/visual/review.js +37 -2
- package/dist/visual/review.svelte.d.ts +77 -20
- package/dist/visual/review.svelte.js +306 -49
- package/dist/visual/strings.d.ts +59 -25
- package/dist/visual/strings.js +90 -29
- package/dist/visual/structure.d.ts +17 -3
- package/dist/visual/structure.js +71 -5
- package/dist/visual/undo.svelte.d.ts +3 -1
- package/dist/visual/undo.svelte.js +7 -3
- package/package.json +2 -2
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
import Icon from './icons/Icon.svelte';
|
|
34
34
|
import { spacePx } from '../core/rungs.js';
|
|
35
35
|
import { renderGuidance } from './guidance.js';
|
|
36
|
+
import { wording } from './strings.js';
|
|
36
37
|
import './controls.css';
|
|
37
38
|
|
|
38
39
|
interface Props {
|
|
@@ -45,6 +46,7 @@
|
|
|
45
46
|
describedBy?: string;
|
|
46
47
|
}
|
|
47
48
|
let { description, label, describedBy }: Props = $props();
|
|
49
|
+
const t = wording();
|
|
48
50
|
|
|
49
51
|
let open = $state(false);
|
|
50
52
|
let triggerEl = $state<HTMLButtonElement | undefined>(undefined);
|
|
@@ -149,7 +151,7 @@
|
|
|
149
151
|
type="button"
|
|
150
152
|
class="qm-field-hint qm-icon-btn qm-focus-ring qm-tap-floor"
|
|
151
153
|
tabindex="-1"
|
|
152
|
-
aria-label=
|
|
154
|
+
aria-label={t.strings.fieldGuidance(label)}
|
|
153
155
|
aria-expanded={open}
|
|
154
156
|
aria-describedby={describedBy}
|
|
155
157
|
onpointerenter={(e) => {
|
|
@@ -210,6 +212,7 @@
|
|
|
210
212
|
<Popover.Content
|
|
211
213
|
customAnchor={triggerEl ?? null}
|
|
212
214
|
collisionBoundary={bounds}
|
|
215
|
+
strategy="absolute"
|
|
213
216
|
side={beside ? 'right' : 'top'}
|
|
214
217
|
align={beside ? 'center' : 'start'}
|
|
215
218
|
sideOffset={(spacePx(triggerEl) ?? 0) + reach}
|
|
@@ -257,12 +260,14 @@
|
|
|
257
260
|
|
|
258
261
|
It takes no fill either: the surface itself opens on hover.
|
|
259
262
|
|
|
260
|
-
At rest it
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
263
|
+
At rest it is absent: a card describing every field otherwise stands a glyph beside
|
|
264
|
+
each label, against the labels a reader is scanning
|
|
265
|
+
(INVARIANTS §"A field's own chrome waits for the field"). It keeps its box and arrives
|
|
266
|
+
by opacity alone, with the scope that owns its row (the field, the property, the array
|
|
267
|
+
or matrix, the table its column heads, the section a lone field is named by), each
|
|
268
|
+
reached by child steps so a nested field's marker stays absent under its container's
|
|
269
|
+
hover, and it stays while its surface is open, so the keyboard's `Mod-/` never raises
|
|
270
|
+
a surface off a glyph that is not drawn. The parked description does not depend on
|
|
266
271
|
the lift. */
|
|
267
272
|
.qm-field-hint {
|
|
268
273
|
/* The marker recedes to the label rung; the surface carries the text. */
|
|
@@ -271,7 +276,7 @@
|
|
|
271
276
|
cursor: help;
|
|
272
277
|
padding: 0;
|
|
273
278
|
background: none;
|
|
274
|
-
opacity:
|
|
279
|
+
opacity: 0;
|
|
275
280
|
transition: opacity var(--_qm-duration-fast) var(--_qm-ease-reverse);
|
|
276
281
|
}
|
|
277
282
|
:global(:is(.qm-field, .qm-object-prop):is(:hover, :focus-within) > .qm-field-label-row)
|
|
@@ -286,6 +291,13 @@
|
|
|
286
291
|
.qm-field-hint[aria-expanded='true'] {
|
|
287
292
|
opacity: 1;
|
|
288
293
|
}
|
|
294
|
+
/* Without a hover there is no lift to wait for, and a tap is the glyph's only door, so
|
|
295
|
+
it rests drawn at the rung a live glyph control rests at. */
|
|
296
|
+
@media (hover: none) {
|
|
297
|
+
.qm-field-hint {
|
|
298
|
+
opacity: var(--_qm-opacity-rest);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
289
301
|
/* The lift, the translucency, the blur and the scale-in come from
|
|
290
302
|
`.qm-popover-surface` (controls.css). This surface's own is a measure: guidance
|
|
291
303
|
is prose, and prose past ~40 characters a line stops being scannable; plus the
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
-->
|
|
75
75
|
<script lang="ts">
|
|
76
76
|
import { onDestroy } from 'svelte';
|
|
77
|
-
import { wording } from './strings.js';
|
|
77
|
+
import { keycap, keyshortcut, wording } from './strings.js';
|
|
78
78
|
|
|
79
79
|
// The surface's words, ambient from the editor root; the package's English
|
|
80
80
|
// off-tree, so this component renders standalone too.
|
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
import type { IconName } from './icons/nodes.js';
|
|
90
90
|
import {
|
|
91
91
|
FIELD_KEYS,
|
|
92
|
+
LIST_KEYS,
|
|
92
93
|
hasMarks,
|
|
93
94
|
rangeAnchor,
|
|
94
95
|
toggleList,
|
|
@@ -113,19 +114,41 @@
|
|
|
113
114
|
|
|
114
115
|
const SETTLE_MS = 450;
|
|
115
116
|
/** The six content formatting marks. `anchor` is withheld: it draws nothing until
|
|
116
|
-
* comments do.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
{ name: '
|
|
121
|
-
{ name: '
|
|
122
|
-
{
|
|
123
|
-
|
|
117
|
+
* comments do. A mark's string is its name, to assistive tech and in its tip
|
|
118
|
+
* (`core/tooltip.ts`); its shortcut is read off the binding, drawn in the tip and
|
|
119
|
+
* stated as `aria-keyshortcuts`, so the name is never the chord too. */
|
|
120
|
+
const MARKS: { name: string; icon: IconName; label: string; keys: string }[] = $derived([
|
|
121
|
+
{ name: 'strong', icon: 'bold', label: t.strings.formatBold, keys: FIELD_KEYS.bold },
|
|
122
|
+
{ name: 'em', icon: 'italic', label: t.strings.formatEmphasis, keys: FIELD_KEYS.italic },
|
|
123
|
+
{
|
|
124
|
+
name: 'underline',
|
|
125
|
+
icon: 'underline',
|
|
126
|
+
label: t.strings.formatUnderline,
|
|
127
|
+
keys: FIELD_KEYS.underline
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'strike',
|
|
131
|
+
icon: 'strikethrough',
|
|
132
|
+
label: t.strings.formatStrikethrough,
|
|
133
|
+
keys: FIELD_KEYS.strike
|
|
134
|
+
},
|
|
135
|
+
{ name: 'code', icon: 'code', label: t.strings.formatCode, keys: FIELD_KEYS.code },
|
|
136
|
+
{ name: 'link', icon: 'link', label: t.strings.formatLink, keys: FIELD_KEYS.link }
|
|
124
137
|
]);
|
|
125
138
|
|
|
126
|
-
const LISTS: { ordered: boolean; icon: IconName;
|
|
127
|
-
{
|
|
128
|
-
|
|
139
|
+
const LISTS: { ordered: boolean; icon: IconName; label: string; keys: string }[] = $derived([
|
|
140
|
+
{
|
|
141
|
+
ordered: true,
|
|
142
|
+
icon: 'list-ordered',
|
|
143
|
+
label: t.strings.formatNumberedList,
|
|
144
|
+
keys: LIST_KEYS.numbered
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
ordered: false,
|
|
148
|
+
icon: 'list',
|
|
149
|
+
label: t.strings.formatBulletedList,
|
|
150
|
+
keys: LIST_KEYS.bulleted
|
|
151
|
+
}
|
|
129
152
|
]);
|
|
130
153
|
|
|
131
154
|
let open = $state(false);
|
|
@@ -495,6 +518,7 @@
|
|
|
495
518
|
<Popover.Content
|
|
496
519
|
customAnchor={anchor ?? null}
|
|
497
520
|
collisionBoundary={portalTarget ?? []}
|
|
521
|
+
strategy="absolute"
|
|
498
522
|
{side}
|
|
499
523
|
align="center"
|
|
500
524
|
trapFocus={false}
|
|
@@ -518,7 +542,9 @@
|
|
|
518
542
|
floating-ui's positioning box: spread, never styled. `inert` is the half
|
|
519
543
|
of the dismissal the recipe cannot carry: the surface is still on screen
|
|
520
544
|
for the length of the fade, and a surface on its way out is not a thing
|
|
521
|
-
to click, tab into, or read.
|
|
545
|
+
to click, tab into, or read. `data-qm-tip-side` is the side the surface
|
|
546
|
+
landed on, so a button's tip (`core/tooltip.ts`) clears the whole surface
|
|
547
|
+
on the side away from the selection. -->
|
|
522
548
|
{#snippet child({ props, wrapperProps, open: raised })}
|
|
523
549
|
<div {...wrapperProps}>
|
|
524
550
|
<div
|
|
@@ -526,6 +552,7 @@
|
|
|
526
552
|
{...props}
|
|
527
553
|
class="qm-format-popover qm-popover-surface"
|
|
528
554
|
data-qm-root
|
|
555
|
+
data-qm-tip-side={props['data-side']}
|
|
529
556
|
inert={!raised}
|
|
530
557
|
onkeydown={onBarKeyDown}
|
|
531
558
|
onfocusout={onBarFocusOut}
|
|
@@ -544,7 +571,7 @@
|
|
|
544
571
|
class="qm-link-input qm-focus-ring"
|
|
545
572
|
type="text"
|
|
546
573
|
placeholder={t.strings.linkPlaceholder}
|
|
547
|
-
aria-label={t.strings.
|
|
574
|
+
aria-label={t.strings.linkAddress}
|
|
548
575
|
bind:value={linkValue}
|
|
549
576
|
/>
|
|
550
577
|
<button type="submit" class="qm-icon-btn qm-mark-btn qm-focus-ring"
|
|
@@ -576,14 +603,16 @@
|
|
|
576
603
|
class="qm-format-buttons"
|
|
577
604
|
role="group"
|
|
578
605
|
aria-label={t.strings.formatGroup}
|
|
579
|
-
aria-keyshortcuts={FIELD_KEYS.formatBar
|
|
606
|
+
aria-keyshortcuts={keyshortcut(FIELD_KEYS.formatBar)}
|
|
580
607
|
>
|
|
581
608
|
{#each MARKS as m (m.name)}
|
|
582
609
|
<button
|
|
583
610
|
type="button"
|
|
584
611
|
class="qm-icon-btn qm-mark-btn qm-focus-ring"
|
|
585
|
-
|
|
586
|
-
|
|
612
|
+
data-qm-tip={m.label}
|
|
613
|
+
data-qm-tip-keys={keycap(m.keys)}
|
|
614
|
+
aria-label={m.label}
|
|
615
|
+
aria-keyshortcuts={keyshortcut(m.keys)}
|
|
587
616
|
onmousedown={keepFocus}
|
|
588
617
|
onclick={() => toggle(m.name)}><Icon name={m.icon} /></button
|
|
589
618
|
>
|
|
@@ -592,7 +621,6 @@
|
|
|
592
621
|
<span class="qm-format-divider" aria-hidden="true"></span>
|
|
593
622
|
<select
|
|
594
623
|
class="qm-font-select qm-focus-ring"
|
|
595
|
-
title={t.strings.formatFont}
|
|
596
624
|
aria-label={t.strings.formatFont}
|
|
597
625
|
value={family ?? MIXED}
|
|
598
626
|
onchange={(e) => pickFamily(e.currentTarget.value)}
|
|
@@ -612,8 +640,10 @@
|
|
|
612
640
|
<button
|
|
613
641
|
type="button"
|
|
614
642
|
class="qm-icon-btn qm-mark-btn qm-focus-ring"
|
|
615
|
-
|
|
616
|
-
|
|
643
|
+
data-qm-tip={l.label}
|
|
644
|
+
data-qm-tip-keys={keycap(l.keys)}
|
|
645
|
+
aria-label={l.label}
|
|
646
|
+
aria-keyshortcuts={keyshortcut(l.keys)}
|
|
617
647
|
onmousedown={keepFocus}
|
|
618
648
|
onclick={() => toggleLines(l.ordered)}><Icon name={l.icon} /></button
|
|
619
649
|
>
|
|
@@ -688,6 +718,10 @@
|
|
|
688
718
|
border: none;
|
|
689
719
|
border-radius: var(--_qm-radius-inner);
|
|
690
720
|
background: var(--_qm-surface-well);
|
|
721
|
+
color: var(--_qm-ink);
|
|
691
722
|
min-width: 12rem;
|
|
692
723
|
}
|
|
724
|
+
.qm-link-input::placeholder {
|
|
725
|
+
color: var(--_qm-ink-label);
|
|
726
|
+
}
|
|
693
727
|
</style>
|
|
@@ -65,6 +65,9 @@
|
|
|
65
65
|
import ObjectField from './ObjectField.svelte';
|
|
66
66
|
import MatrixAdd from './MatrixAdd.svelte';
|
|
67
67
|
import DiagnosticList from './DiagnosticList.svelte';
|
|
68
|
+
import ReviewRows from './ReviewRows.svelte';
|
|
69
|
+
import { splitReview, type DeepReview } from './review.js';
|
|
70
|
+
import { review as reviewState } from './review.svelte.js';
|
|
68
71
|
import './controls.css';
|
|
69
72
|
|
|
70
73
|
interface Props {
|
|
@@ -91,6 +94,10 @@
|
|
|
91
94
|
/** The diagnostics routed into this field, each with its steps still to walk: one
|
|
92
95
|
* naming a drawn item draws under it, any other at the field's foot. */
|
|
93
96
|
diagnostics?: readonly DeepDiagnostic[];
|
|
97
|
+
/** The review items naming a member or a cell inside one, each with its steps still to
|
|
98
|
+
* walk: a member's tick shows the state it would come to, its cells take their own,
|
|
99
|
+
* and an item no drawn member holds stands at the field's foot. */
|
|
100
|
+
review?: readonly DeepReview[];
|
|
94
101
|
}
|
|
95
102
|
let {
|
|
96
103
|
value,
|
|
@@ -102,7 +109,8 @@
|
|
|
102
109
|
idBase,
|
|
103
110
|
contentAt,
|
|
104
111
|
onCommit,
|
|
105
|
-
diagnostics
|
|
112
|
+
diagnostics,
|
|
113
|
+
review
|
|
106
114
|
}: Props = $props();
|
|
107
115
|
|
|
108
116
|
const members = $derived(matrixMembers(schema.members));
|
|
@@ -120,6 +128,31 @@
|
|
|
120
128
|
const routed = $derived(splitDeep(diagnostics));
|
|
121
129
|
const foot = $derived(unrouted(routed, (step) => typeof step === 'string' && drawn(step)));
|
|
122
130
|
|
|
131
|
+
const reviewing = reviewState();
|
|
132
|
+
const reviewed = $derived(splitReview(review));
|
|
133
|
+
/** A member's own proposal: it ticks or unticks the member whole. */
|
|
134
|
+
const proposal = (id: string) => reviewed.below.get(id)?.find((e) => !e.steps.length)?.item;
|
|
135
|
+
/** Whether a member shows as held: as its proposal would leave it, else as stored, an
|
|
136
|
+
* unheld one under a proposal for a cell of it held, as taking that proposal writes it. */
|
|
137
|
+
const shownHeld = (id: string): boolean => {
|
|
138
|
+
const item = proposal(id);
|
|
139
|
+
return item ? matrixHeld(item.after) : held(id) || cellReview(id).length > 0;
|
|
140
|
+
};
|
|
141
|
+
/** The member's columns as shown: its proposal's where one ticks it, else the stored. */
|
|
142
|
+
const shownColumns = (id: string): Record<string, unknown> => {
|
|
143
|
+
const item = proposal(id);
|
|
144
|
+
return matrixColumns(item ? item.after : own(map, id));
|
|
145
|
+
};
|
|
146
|
+
/** The items inside a member's columns, one step down. */
|
|
147
|
+
const cellReview = (id: string): DeepReview[] =>
|
|
148
|
+
(reviewed.below.get(id) ?? []).filter((e) => e.steps.length);
|
|
149
|
+
const reviewFoot = $derived([
|
|
150
|
+
...reviewed.here,
|
|
151
|
+
...[...reviewed.below]
|
|
152
|
+
.filter(([step]) => typeof step !== 'string' || !drawn(step))
|
|
153
|
+
.flatMap(([step, list]) => list.map((e) => ({ steps: [step, ...e.steps], item: e.item })))
|
|
154
|
+
]);
|
|
155
|
+
|
|
123
156
|
// A member with no field id space around it still needs an id: the tick is what its
|
|
124
157
|
// title's `for` names. Stable across SSR and hydration, which a counter is not.
|
|
125
158
|
const uid = $props.id();
|
|
@@ -180,9 +213,15 @@
|
|
|
180
213
|
* new to write. The reassert after the flush is what the styled controls get from
|
|
181
214
|
* their local, a `$derived` of the value: the document is what the face reads. */
|
|
182
215
|
async function tick(id: string, on: boolean, el: HTMLInputElement): Promise<void> {
|
|
183
|
-
|
|
216
|
+
const item = proposal(id);
|
|
217
|
+
const cells = cellReview(id);
|
|
218
|
+
if (item && on === matrixHeld(item.after)) reviewing.act(item.id, 'accept');
|
|
219
|
+
else if (!item && !on && !held(id) && cells.length)
|
|
220
|
+
for (const { item: cell } of cells) reviewing.act(cell.id, 'dismiss');
|
|
221
|
+
else if (!item || !reviewing.answerWith(item.id, on ? ticked(id) : undefined))
|
|
222
|
+
commit(on ? commitMember(map, id, ticked(id)) : unticked(id));
|
|
184
223
|
await flush();
|
|
185
|
-
if (el.isConnected) el.checked =
|
|
224
|
+
if (el.isConnected) el.checked = shownHeld(id);
|
|
186
225
|
}
|
|
187
226
|
/** A column edit lands on a held item, an added one keeping its `title`. */
|
|
188
227
|
function commitColumns(id: string, columns: Record<string, unknown>): void {
|
|
@@ -301,7 +340,7 @@
|
|
|
301
340
|
bind:this={rosterEl}
|
|
302
341
|
>
|
|
303
342
|
{#each members as m (m.id)}
|
|
304
|
-
{@const on =
|
|
343
|
+
{@const on = shownHeld(m.id)}
|
|
305
344
|
<div
|
|
306
345
|
class={['qm-member qm-wash', { held: on, open: on && hasColumns }]}
|
|
307
346
|
data-qm-prop={m.id}
|
|
@@ -323,6 +362,7 @@
|
|
|
323
362
|
/>
|
|
324
363
|
<Icon name="check" class="qm-tick-mark" />
|
|
325
364
|
</span>
|
|
365
|
+
<ReviewRows entries={reviewed.below.get(m.id)?.filter((e) => !e.steps.length)} />
|
|
326
366
|
<label class="qm-member-title" id={titleId(m.id)} for={tickId(m.id)}>{m.title}</label>
|
|
327
367
|
</div>
|
|
328
368
|
{@render columns(m.id, m.title, on)}
|
|
@@ -355,7 +395,7 @@
|
|
|
355
395
|
<button
|
|
356
396
|
type="button"
|
|
357
397
|
class="qm-icon-btn qm-focus-ring qm-member-remove"
|
|
358
|
-
|
|
398
|
+
data-qm-tip={t.strings.matrixRemove(name)}
|
|
359
399
|
aria-label={t.strings.matrixRemove(name)}
|
|
360
400
|
onclick={() => removeItem(item.id, name)}><Icon name="x" /></button
|
|
361
401
|
>
|
|
@@ -373,6 +413,7 @@
|
|
|
373
413
|
/>
|
|
374
414
|
{/if}
|
|
375
415
|
<DiagnosticList diagnostics={foot} />
|
|
416
|
+
<ReviewRows entries={reviewFoot} />
|
|
376
417
|
</div>
|
|
377
418
|
|
|
378
419
|
<!-- A held item's columns, one rung in, the way a variant's cells unfold under the
|
|
@@ -383,7 +424,7 @@
|
|
|
383
424
|
{#if on && hasColumns}
|
|
384
425
|
<ObjectField
|
|
385
426
|
bind:this={colEls[id]}
|
|
386
|
-
value={
|
|
427
|
+
value={shownColumns(id)}
|
|
387
428
|
properties={schema.properties}
|
|
388
429
|
label={`${label ?? ''} ${title}`.trim()}
|
|
389
430
|
idBase={memberBase(id)}
|
|
@@ -391,6 +432,7 @@
|
|
|
391
432
|
contentAt={(path) => readAt([id, ...path])}
|
|
392
433
|
onCommit={(cols) => commitColumns(id, cols)}
|
|
393
434
|
diagnostics={deep?.filter((d) => d.steps[0] !== MATRIX_TITLE)}
|
|
435
|
+
review={cellReview(id)}
|
|
394
436
|
/>
|
|
395
437
|
<DiagnosticList
|
|
396
438
|
diagnostics={deep?.filter((d) => d.steps[0] === MATRIX_TITLE).map((d) => d.diagnostic)}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Content, PathStep, QuillFieldSchema } from '@quillmark/wasm';
|
|
2
2
|
import { type DeepDiagnostic } from './diagnostics.js';
|
|
3
3
|
import type { LandingBox } from './leaves.js';
|
|
4
|
+
import { type DeepReview } from './review.js';
|
|
4
5
|
interface Props {
|
|
5
6
|
/** The stored sparse map, or undefined while the field is unset. */
|
|
6
7
|
value: Record<string, unknown> | undefined;
|
|
@@ -25,6 +26,10 @@ interface Props {
|
|
|
25
26
|
/** The diagnostics routed into this field, each with its steps still to walk: one
|
|
26
27
|
* naming a drawn item draws under it, any other at the field's foot. */
|
|
27
28
|
diagnostics?: readonly DeepDiagnostic[];
|
|
29
|
+
/** The review items naming a member or a cell inside one, each with its steps still to
|
|
30
|
+
* walk: a member's tick shows the state it would come to, its cells take their own,
|
|
31
|
+
* and an item no drawn member holds stands at the field's foot. */
|
|
32
|
+
review?: readonly DeepReview[];
|
|
28
33
|
}
|
|
29
34
|
declare const MatrixField: import("svelte").Component<Props, {
|
|
30
35
|
focus: () => void;
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
Commits at `change` (blur/Enter), not per keystroke: a partial numeric entry
|
|
4
4
|
(`-`, `1.`) is never a document state worth a boundary round-trip, and
|
|
5
5
|
committing it live flashes a coercion diagnostic + `console.error` on every
|
|
6
|
-
intermediate prefix
|
|
7
|
-
region. Where the parent moves on at Enter (`onEnter`), Enter commits at once and
|
|
6
|
+
intermediate prefix. Where the parent moves on at Enter (`onEnter`), Enter commits at once and
|
|
8
7
|
the move follows a number, never a blank or a refused entry. Escape takes a pending
|
|
9
8
|
entry back to what the field holds, as it takes a card rename back, and the focus
|
|
10
9
|
stays; with nothing pending the key is not claimed.
|
|
@@ -13,7 +12,9 @@
|
|
|
13
12
|
(theme.css), and an edit that settles writes it as authored, as `TextField` takes
|
|
14
13
|
its default. A number has no empty answer (quillmark/INVARIANTS §"A blank is a property of the field"),
|
|
15
14
|
so a blank entry commits `undefined`, the unset rung: the parent removes the field,
|
|
16
|
-
the engine renders the default, and the input holds it again.
|
|
15
|
+
the engine renders the default, and the input holds it again. The input's own undo
|
|
16
|
+
back to the default it held unwritten settles as `undefined` too, so taking every edit
|
|
17
|
+
back leaves the field unset, as a text leaf's undo does.
|
|
17
18
|
|
|
18
19
|
The entry grammar is plain decimal: an optional sign and digits, and for a `number`
|
|
19
20
|
a `.` and an exponent, the form `String()` gives a value too small or large for
|
|
@@ -29,9 +30,16 @@
|
|
|
29
30
|
string to `onCommit`: the boundary's `writer.set` coercion is the judge (throws a
|
|
30
31
|
`QuillmarkError` the parent turns into a field diagnostic, INVARIANTS §Diagnostics). `Number()` alone is no gate: it reads `0x1F` and `Infinity` as
|
|
31
32
|
numbers, and `1.000` as a whole one.
|
|
33
|
+
|
|
34
|
+
A proposed value is drawn over the input, the text it holds struck where it stands and the
|
|
35
|
+
proposed one tinted beside it, as a one-line text leaf draws its own. The input holds its own
|
|
36
|
+
text throughout, so the caret moves through the struck text and an edit writes what the field
|
|
37
|
+
holds; once an entry is pending the input shows it, and the drawing keeps its place unseen, so
|
|
38
|
+
the answer card standing on it stays.
|
|
32
39
|
-->
|
|
33
40
|
<script lang="ts">
|
|
34
41
|
import './controls.css';
|
|
42
|
+
import { review } from './review.svelte.js';
|
|
35
43
|
|
|
36
44
|
interface Props {
|
|
37
45
|
value: number | undefined;
|
|
@@ -54,13 +62,55 @@
|
|
|
54
62
|
/** Enter settled the entry as a number: a list's row moves on from it. Enter
|
|
55
63
|
* claimed here commits at once rather than at the browser's own `change`. */
|
|
56
64
|
onEnter?: () => void;
|
|
65
|
+
/** A proposed value, drawn over the input at rest. */
|
|
66
|
+
proposed?: { id: string; after: string };
|
|
67
|
+
}
|
|
68
|
+
let {
|
|
69
|
+
value,
|
|
70
|
+
integer,
|
|
71
|
+
fallback,
|
|
72
|
+
placeholder,
|
|
73
|
+
label,
|
|
74
|
+
id,
|
|
75
|
+
describedBy,
|
|
76
|
+
onCommit,
|
|
77
|
+
onEnter,
|
|
78
|
+
proposed
|
|
79
|
+
}: Props = $props();
|
|
80
|
+
|
|
81
|
+
const reviewing = review();
|
|
82
|
+
|
|
83
|
+
/** The face stands over the input's own box, wherever the input stands in its parent. */
|
|
84
|
+
function over(face: HTMLElement) {
|
|
85
|
+
const input = face.previousElementSibling as HTMLElement | null;
|
|
86
|
+
if (!input) return;
|
|
87
|
+
const place = () => {
|
|
88
|
+
face.style.insetBlockStart = `${input.offsetTop}px`;
|
|
89
|
+
face.style.insetInlineStart = `${input.offsetLeft}px`;
|
|
90
|
+
face.style.width = `${input.offsetWidth}px`;
|
|
91
|
+
face.style.height = `${input.offsetHeight}px`;
|
|
92
|
+
};
|
|
93
|
+
place();
|
|
94
|
+
if (typeof ResizeObserver === 'undefined') return;
|
|
95
|
+
const watch = new ResizeObserver(place);
|
|
96
|
+
watch.observe(input);
|
|
97
|
+
return () => watch.disconnect();
|
|
57
98
|
}
|
|
58
|
-
let { value, integer, fallback, placeholder, label, id, describedBy, onCommit, onEnter }: Props =
|
|
59
|
-
$props();
|
|
60
99
|
|
|
61
100
|
const resting = $derived(value != null ? String(value) : (fallback ?? ''));
|
|
62
101
|
let local = $derived(resting);
|
|
63
102
|
const defaulted = $derived(value == null && !!fallback && local === fallback);
|
|
103
|
+
const drawn = $derived(proposed && proposed.after !== resting ? proposed : undefined);
|
|
104
|
+
|
|
105
|
+
// The default the input held while the field was unwritten, kept across the field's own
|
|
106
|
+
// commits and dropped by anyone else's write: what an undo can return the field to.
|
|
107
|
+
let unwrittenText: string | undefined;
|
|
108
|
+
let committed: number | undefined;
|
|
109
|
+
let undone = false;
|
|
110
|
+
$effect(() => {
|
|
111
|
+
if (value == null) [unwrittenText, committed] = [fallback, undefined];
|
|
112
|
+
else if (value !== committed) unwrittenText = undefined;
|
|
113
|
+
});
|
|
64
114
|
|
|
65
115
|
const partial = $derived(
|
|
66
116
|
integer ? /^\s*[+-]?\d*\s*$/ : /^\s*[+-]?\d*\.?\d*(?:[eE][+-]?\d*)?\s*$/
|
|
@@ -125,6 +175,11 @@
|
|
|
125
175
|
const raw = el.value;
|
|
126
176
|
const entry = raw.trim();
|
|
127
177
|
offered = false;
|
|
178
|
+
if (undone && unwrittenText != null && raw === unwrittenText) {
|
|
179
|
+
undone = false;
|
|
180
|
+
if (value != null) onCommit(undefined);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
128
183
|
if (entry === '') {
|
|
129
184
|
onCommit(undefined);
|
|
130
185
|
local = el.value = fallback ?? '';
|
|
@@ -133,6 +188,7 @@
|
|
|
133
188
|
// Finite as well: a digit run past `Number.MAX_VALUE` reads as `Infinity`.
|
|
134
189
|
const n = whole.test(entry) ? Number(entry) : NaN;
|
|
135
190
|
offered = !Number.isFinite(n);
|
|
191
|
+
if (!offered) committed = n;
|
|
136
192
|
onCommit(offered ? raw : n);
|
|
137
193
|
}
|
|
138
194
|
</script>
|
|
@@ -145,6 +201,7 @@
|
|
|
145
201
|
{id}
|
|
146
202
|
{placeholder}
|
|
147
203
|
data-default={defaulted ? '' : undefined}
|
|
204
|
+
data-proposed-over={drawn && local === resting ? '' : undefined}
|
|
148
205
|
aria-label={id ? undefined : label}
|
|
149
206
|
aria-describedby={describedBy}
|
|
150
207
|
onbeforeinput={filter}
|
|
@@ -152,6 +209,7 @@
|
|
|
152
209
|
local = (e.currentTarget as HTMLInputElement).value;
|
|
153
210
|
reverted = false;
|
|
154
211
|
settled = undefined;
|
|
212
|
+
undone = e instanceof InputEvent && e.inputType === 'historyUndo';
|
|
155
213
|
}}
|
|
156
214
|
onkeydown={onKey}
|
|
157
215
|
onchange={(e) => {
|
|
@@ -159,10 +217,77 @@
|
|
|
159
217
|
if (el.value !== settled) commit(el);
|
|
160
218
|
}}
|
|
161
219
|
/>
|
|
220
|
+
{#if drawn}
|
|
221
|
+
{@const lit = reviewing.lit === drawn.id}
|
|
222
|
+
<span
|
|
223
|
+
class={['qm-number-review', { pending: local !== resting }]}
|
|
224
|
+
aria-hidden="true"
|
|
225
|
+
{@attach over}
|
|
226
|
+
>
|
|
227
|
+
{#if resting}<del class={['qm-review-del', { 'qm-review-lit': lit }]}>{resting}</del>{/if}<ins
|
|
228
|
+
class={['qm-review-ins', { 'qm-review-lit': lit }]}
|
|
229
|
+
data-qm-review={drawn.id}>{drawn.after}</ins
|
|
230
|
+
>
|
|
231
|
+
</span>
|
|
232
|
+
{/if}
|
|
162
233
|
|
|
163
234
|
<style>
|
|
164
235
|
/* Tabular figures, so numbers stacked in a column line up digit for digit. */
|
|
165
|
-
.qm-input
|
|
236
|
+
.qm-input,
|
|
237
|
+
.qm-number-review {
|
|
166
238
|
font-variant-numeric: tabular-nums;
|
|
167
239
|
}
|
|
240
|
+
:global(:has(> .qm-number-review)) {
|
|
241
|
+
position: relative;
|
|
242
|
+
}
|
|
243
|
+
.qm-input[data-proposed-over] {
|
|
244
|
+
color: transparent;
|
|
245
|
+
caret-color: var(--_qm-ink);
|
|
246
|
+
}
|
|
247
|
+
.qm-number-review.pending {
|
|
248
|
+
visibility: hidden;
|
|
249
|
+
}
|
|
250
|
+
.qm-number-review {
|
|
251
|
+
position: absolute;
|
|
252
|
+
display: flex;
|
|
253
|
+
align-items: center;
|
|
254
|
+
box-sizing: border-box;
|
|
255
|
+
padding: var(--_qm-inset-control);
|
|
256
|
+
overflow: hidden;
|
|
257
|
+
font-size: var(--_qm-text-body);
|
|
258
|
+
line-height: var(--_qm-leading-body);
|
|
259
|
+
white-space: nowrap;
|
|
260
|
+
pointer-events: none;
|
|
261
|
+
}
|
|
262
|
+
.qm-review-del {
|
|
263
|
+
color: var(--_qm-ink-label);
|
|
264
|
+
text-decoration: line-through;
|
|
265
|
+
text-decoration-color: var(--_qm-review-line);
|
|
266
|
+
}
|
|
267
|
+
.qm-review-ins {
|
|
268
|
+
color: var(--_qm-ink);
|
|
269
|
+
text-decoration: underline;
|
|
270
|
+
text-decoration-color: var(--_qm-review-line);
|
|
271
|
+
text-decoration-thickness: var(--_qm-border-width);
|
|
272
|
+
text-underline-offset: 0.2em;
|
|
273
|
+
background: var(--_qm-review-tint);
|
|
274
|
+
box-shadow:
|
|
275
|
+
calc(-1 * var(--_qm-space-half)) 0 0 var(--_qm-review-tint),
|
|
276
|
+
var(--_qm-space-half) 0 0 var(--_qm-review-tint);
|
|
277
|
+
border-radius: var(--_qm-radius-inner);
|
|
278
|
+
}
|
|
279
|
+
.qm-review-ins.qm-review-lit {
|
|
280
|
+
background: var(--_qm-review-lit);
|
|
281
|
+
box-shadow:
|
|
282
|
+
calc(-1 * var(--_qm-space-half)) 0 0 var(--_qm-review-lit),
|
|
283
|
+
var(--_qm-space-half) 0 0 var(--_qm-review-lit);
|
|
284
|
+
}
|
|
285
|
+
.qm-review-del + .qm-review-ins {
|
|
286
|
+
margin-inline-start: calc(var(--_qm-space) + var(--_qm-space-half));
|
|
287
|
+
}
|
|
288
|
+
@media (forced-colors: active) {
|
|
289
|
+
.qm-review-ins {
|
|
290
|
+
text-decoration-color: currentColor;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
168
293
|
</style>
|
|
@@ -19,6 +19,11 @@ interface Props {
|
|
|
19
19
|
/** Enter settled the entry as a number: a list's row moves on from it. Enter
|
|
20
20
|
* claimed here commits at once rather than at the browser's own `change`. */
|
|
21
21
|
onEnter?: () => void;
|
|
22
|
+
/** A proposed value, drawn over the input at rest. */
|
|
23
|
+
proposed?: {
|
|
24
|
+
id: string;
|
|
25
|
+
after: string;
|
|
26
|
+
};
|
|
22
27
|
}
|
|
23
28
|
declare const NumberField: import("svelte").Component<Props, {}, "">;
|
|
24
29
|
type NumberField = ReturnType<typeof NumberField>;
|