@quillmark/svelte 0.36.0 → 0.37.1
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 +18 -14
- package/THEMING.md +1 -1
- package/dist/core/codec/decode.d.ts +4 -2
- package/dist/core/codec/decode.js +5 -2
- package/dist/core/codec/field.d.ts +14 -10
- package/dist/core/codec/field.js +34 -24
- package/dist/core/codec/index.d.ts +3 -3
- package/dist/core/codec/index.js +2 -2
- package/dist/core/codec/prose.css +20 -4
- package/dist/core/codec/review.d.ts +4 -5
- package/dist/core/codec/review.js +6 -21
- package/dist/core/codec/schema.d.ts +12 -2
- package/dist/core/codec/schema.js +27 -5
- package/dist/core/codec/shortcuts.d.ts +3 -2
- package/dist/core/codec/shortcuts.js +3 -2
- package/dist/core/codec/table-view.js +15 -3
- package/dist/core/theme.css +44 -17
- 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 +262 -145
- package/dist/visual/Card.svelte +21 -11
- 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 +6 -1
- package/dist/visual/EnumField.svelte.d.ts +2 -0
- package/dist/visual/Field.svelte +3 -3
- package/dist/visual/FieldHint.svelte +22 -13
- package/dist/visual/FieldLabel.svelte +6 -42
- package/dist/visual/FieldLabel.svelte.d.ts +0 -3
- package/dist/visual/FormatPopover.svelte +53 -20
- package/dist/visual/MatrixAdd.svelte +9 -10
- package/dist/visual/MatrixField.svelte +114 -18
- package/dist/visual/NumberField.svelte +21 -5
- package/dist/visual/ObjectField.svelte +6 -2
- package/dist/visual/ProseField.svelte +6 -3
- package/dist/visual/ProseField.svelte.d.ts +2 -1
- package/dist/visual/ProseValue.svelte +13 -6
- package/dist/visual/ProseValue.svelte.d.ts +4 -1
- package/dist/visual/ReviewCard.svelte +93 -33
- package/dist/visual/ReviewCard.svelte.d.ts +2 -1
- package/dist/visual/ReviewProposal.svelte +0 -6
- package/dist/visual/TipsCard.svelte +1 -1
- package/dist/visual/VariantField.svelte +1 -0
- package/dist/visual/VisualEditor.svelte +12 -6
- package/dist/visual/VisualEditor.svelte.d.ts +5 -1
- package/dist/visual/VisualEditorInner.svelte +218 -302
- package/dist/visual/VisualEditorInner.svelte.d.ts +5 -1
- package/dist/visual/controls.css +2 -2
- package/dist/visual/guidance.d.ts +0 -2
- package/dist/visual/guidance.js +0 -10
- package/dist/visual/index.d.ts +2 -2
- package/dist/visual/proposals.d.ts +14 -4
- package/dist/visual/proposals.js +28 -5
- package/dist/visual/props.d.ts +1 -1
- package/dist/visual/review-order.d.ts +51 -0
- package/dist/visual/review-order.js +87 -0
- package/dist/visual/review.d.ts +27 -1
- package/dist/visual/review.js +1 -1
- package/dist/visual/review.svelte.d.ts +34 -17
- package/dist/visual/review.svelte.js +187 -44
- package/dist/visual/strings.d.ts +38 -19
- package/dist/visual/strings.js +81 -24
- package/dist/visual/structure.d.ts +17 -3
- package/dist/visual/structure.js +71 -5
- package/package.json +2 -2
package/dist/visual/Card.svelte
CHANGED
|
@@ -85,6 +85,12 @@
|
|
|
85
85
|
// title because a re-derive mid-edit hands `card` back with the title it stored.
|
|
86
86
|
let draft = $state<string | undefined>(undefined);
|
|
87
87
|
const shownTitle = $derived(draft ?? card.titleOverride);
|
|
88
|
+
/** What names the card to assistive tech: its section, and its title input after the
|
|
89
|
+
* input's own word. The stored title, never the rename in flight, so no name changes
|
|
90
|
+
* under the reader typing it. */
|
|
91
|
+
const named = $derived(
|
|
92
|
+
card.unschemable ? humanize(card.kind) : card.titleOverride.trim() || card.titlePlaceholder
|
|
93
|
+
);
|
|
88
94
|
|
|
89
95
|
// A focus the shell hands over (`focusHeader`) is not armed for replacement: the key
|
|
90
96
|
// that pressed a delete, pressed again, would retitle the card it landed on.
|
|
@@ -221,11 +227,14 @@
|
|
|
221
227
|
({@link FieldHint}): a surface portals to `[data-qm-root]`, so the card is not its
|
|
222
228
|
ancestor and nothing else marks the box its guidance belongs in. Its value is the card's
|
|
223
229
|
kind, `main` for the main card, which is the one schema-named hook a host's stylesheet
|
|
224
|
-
is promised (THEMING §"What a stylesheet may aim at").
|
|
230
|
+
is promised (THEMING §"What a stylesheet may aim at"). Named, the section is a region,
|
|
231
|
+
so a reader moving by landmark hears each card by the title its header shows; `main`
|
|
232
|
+
shows none and stays the unnamed form the regions follow. -->
|
|
225
233
|
<section
|
|
226
234
|
bind:this={el}
|
|
227
235
|
class={['qm-card', { 'qm-main': card.isMain, 'qm-unschemable': card.unschemable }]}
|
|
228
236
|
data-qm-card={card.kind}
|
|
237
|
+
aria-label={card.isMain ? undefined : named}
|
|
229
238
|
>
|
|
230
239
|
{#if card.unschemable}
|
|
231
240
|
{@render recoveryShell()}
|
|
@@ -239,7 +248,7 @@
|
|
|
239
248
|
class="qm-card-title qm-focus-ring"
|
|
240
249
|
value={shownTitle}
|
|
241
250
|
placeholder={card.titlePlaceholder}
|
|
242
|
-
aria-label={t.strings.cardTitle}
|
|
251
|
+
aria-label={t.strings.cardAction(t.strings.cardTitle, named)}
|
|
243
252
|
size="1"
|
|
244
253
|
onmousedown={onTitleMousedown}
|
|
245
254
|
onfocus={onTitleFocus}
|
|
@@ -432,6 +441,7 @@
|
|
|
432
441
|
<label class="qm-recovery-retype">
|
|
433
442
|
{t.strings.retypeLabel}
|
|
434
443
|
<select
|
|
444
|
+
class="qm-control-box qm-focus-ring"
|
|
435
445
|
onchange={(e) => {
|
|
436
446
|
const el = e.currentTarget as HTMLSelectElement;
|
|
437
447
|
if (el.value) ops.retype(el.value);
|
|
@@ -877,14 +887,14 @@
|
|
|
877
887
|
font-size: var(--_qm-text-label);
|
|
878
888
|
color: var(--_qm-ink-label);
|
|
879
889
|
}
|
|
880
|
-
/*
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
890
|
+
/* Forced colours drop a plane's tone, so a card draws its edge, and the placeholder's
|
|
891
|
+
GrayText would read the automatic title as disabled. */
|
|
892
|
+
@media (forced-colors: active) {
|
|
893
|
+
.qm-card {
|
|
894
|
+
border: var(--_qm-border-width) solid CanvasText;
|
|
895
|
+
}
|
|
896
|
+
.qm-card-title::placeholder {
|
|
897
|
+
color: CanvasText;
|
|
898
|
+
}
|
|
889
899
|
}
|
|
890
900
|
</style>
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
<button
|
|
37
37
|
type="button"
|
|
38
38
|
class="qm-chip qm-focus-ring"
|
|
39
|
-
|
|
39
|
+
data-qm-tip={t.strings.cardMoveUp}
|
|
40
40
|
aria-label={t.strings.cardAction(t.strings.cardMoveUp, name)}
|
|
41
41
|
aria-disabled={isFirst || undefined}
|
|
42
42
|
tabindex={isFirst ? -1 : undefined}
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
<button
|
|
46
46
|
type="button"
|
|
47
47
|
class="qm-chip qm-focus-ring"
|
|
48
|
-
|
|
48
|
+
data-qm-tip={t.strings.cardMoveDown}
|
|
49
49
|
aria-label={t.strings.cardAction(t.strings.cardMoveDown, name)}
|
|
50
50
|
aria-disabled={isLast || undefined}
|
|
51
51
|
tabindex={isLast ? -1 : undefined}
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
<button
|
|
56
56
|
type="button"
|
|
57
57
|
class="qm-chip qm-card-delete qm-focus-ring"
|
|
58
|
-
|
|
58
|
+
data-qm-tip={t.strings.cardDelete}
|
|
59
59
|
aria-label={t.strings.cardAction(t.strings.cardDelete, name)}
|
|
60
60
|
onclick={onDelete}><Icon name="trash-2" /></button
|
|
61
61
|
>
|
|
@@ -61,6 +61,13 @@
|
|
|
61
61
|
focus. Leaving with a segment filled puts the stored date back; a field storing no
|
|
62
62
|
date puts its segments back by remounting the primitive, which re-reads an unchanged
|
|
63
63
|
empty value as nothing to sync.
|
|
64
|
+
|
|
65
|
+
The field is one Tab stop (INVARIANTS §"A date field is one Tab stop"). The primitive
|
|
66
|
+
makes every segment a stop, so each is drawn through its `child` snippet, which is where
|
|
67
|
+
a `tabindex` outranks the primitive's own: the stop is the segment the focus is on, the
|
|
68
|
+
first while the focus is elsewhere, and Tab from any of them leaves the field. The
|
|
69
|
+
arrows walk the segments, the primitive's own keys, and one step past the last onto the
|
|
70
|
+
Today toggle and back, so the toggle is out of the tab order and still under the keys.
|
|
64
71
|
-->
|
|
65
72
|
<script lang="ts">
|
|
66
73
|
import { flushSync } from 'svelte';
|
|
@@ -110,13 +117,21 @@
|
|
|
110
117
|
let { value, fallback, label, labelledBy, describedBy, datetime, onCommit }: Props = $props();
|
|
111
118
|
|
|
112
119
|
let wrapEl: HTMLElement | undefined = $state();
|
|
120
|
+
let todayEl: HTMLButtonElement | undefined = $state();
|
|
121
|
+
/** The segments that take the focus. `literal` is the separator between them: present,
|
|
122
|
+
* never focusable. */
|
|
123
|
+
const segmentEls = (): HTMLElement[] => [
|
|
124
|
+
...(wrapEl?.querySelectorAll<HTMLElement>('[data-segment]:not([data-segment="literal"])') ?? [])
|
|
125
|
+
];
|
|
113
126
|
/** Take the caret: what the label click, and a parent placing focus here, calls.
|
|
114
127
|
* The first segment, not the field: focus lives on a segment (which is why the
|
|
115
|
-
* ring is `.qm-focus-ring-within`), and the container holds none.
|
|
116
|
-
* separator between segments: present, never focusable. */
|
|
128
|
+
* ring is `.qm-focus-ring-within`), and the container holds none. */
|
|
117
129
|
export function focus(): void {
|
|
118
|
-
|
|
130
|
+
segmentEls()[0]?.focus();
|
|
119
131
|
}
|
|
132
|
+
/** The field's one Tab stop while the focus is inside: a segment by its part, or the
|
|
133
|
+
* toggle as {@link TODAY}. Unset, the stop is the first segment. */
|
|
134
|
+
let stop = $state<string | undefined>(undefined);
|
|
120
135
|
|
|
121
136
|
/** The part of a stored string this control edits: all of a `datetime`, and the date
|
|
122
137
|
* half of a `date`, anything past `YYYY-MM-DD` being no part of its type. */
|
|
@@ -196,8 +211,23 @@
|
|
|
196
211
|
/** Focus moving between segments is neither an entry nor a leaving. */
|
|
197
212
|
const within = (e: FocusEvent): boolean => !!wrapEl?.contains(e.relatedTarget as Node | null);
|
|
198
213
|
function enter(e: FocusEvent): void {
|
|
214
|
+
stop = (e.target as HTMLElement).dataset.segment ?? TODAY;
|
|
199
215
|
if (!within(e) && value == null && fallbackDate) seat = true;
|
|
200
216
|
}
|
|
217
|
+
/** One step past the last segment is the toggle, and one step back returns. */
|
|
218
|
+
function step(e: KeyboardEvent): void {
|
|
219
|
+
if (!todayEl || e.ctrlKey || e.metaKey || e.altKey || e.shiftKey) return;
|
|
220
|
+
const last = segmentEls().at(-1);
|
|
221
|
+
const to =
|
|
222
|
+
e.key === 'ArrowRight' && e.target === last
|
|
223
|
+
? todayEl
|
|
224
|
+
: e.key === 'ArrowLeft' && e.target === todayEl
|
|
225
|
+
? last
|
|
226
|
+
: undefined;
|
|
227
|
+
if (!to) return;
|
|
228
|
+
e.preventDefault();
|
|
229
|
+
to.focus();
|
|
230
|
+
}
|
|
201
231
|
const filled = (): boolean =>
|
|
202
232
|
[...(wrapEl?.querySelectorAll('[data-segment]') ?? [])].some(
|
|
203
233
|
(s) => s.getAttribute('data-segment') !== 'literal' && !s.hasAttribute('data-ghosted')
|
|
@@ -209,6 +239,7 @@
|
|
|
209
239
|
}
|
|
210
240
|
function leave(e: FocusEvent): void {
|
|
211
241
|
if (within(e)) return;
|
|
242
|
+
stop = undefined;
|
|
212
243
|
const seated = seat;
|
|
213
244
|
seat = false;
|
|
214
245
|
const emptied = held;
|
|
@@ -314,13 +345,17 @@
|
|
|
314
345
|
aria-describedby={describedBy}
|
|
315
346
|
data-ghosted={ghost ? '' : undefined}
|
|
316
347
|
data-default={seated || follows ? '' : undefined}
|
|
317
|
-
onkeydown={
|
|
348
|
+
onkeydown={(e: KeyboardEvent) => {
|
|
349
|
+
settle();
|
|
350
|
+
step(e);
|
|
351
|
+
}}
|
|
318
352
|
>
|
|
319
353
|
{#snippet children({ segments })}
|
|
320
354
|
<!-- Keyed by index: `part` repeats (the `literal` separators between
|
|
321
355
|
segments all carry it) so a part-keyed block collides. -->
|
|
322
356
|
{@const hour = segments.find((seg) => seg.part === 'hour')?.value}
|
|
323
357
|
{@const twelve = segments.some((seg) => seg.part === 'dayPeriod')}
|
|
358
|
+
{@const first = segments.find((seg) => seg.part !== 'literal')?.part}
|
|
324
359
|
{#each segments as seg, i (i)}
|
|
325
360
|
{@const shown = segmentText(seg.part, seg.value, hour, twelve)}
|
|
326
361
|
<BitsDateField.Segment
|
|
@@ -328,7 +363,11 @@
|
|
|
328
363
|
part={seg.part}
|
|
329
364
|
data-ghosted={shown.ghosted}
|
|
330
365
|
>
|
|
331
|
-
{
|
|
366
|
+
{#snippet child({ props })}
|
|
367
|
+
{@const roving =
|
|
368
|
+
seg.part === 'literal' ? {} : { tabindex: seg.part === (stop ?? first) ? 0 : -1 }}
|
|
369
|
+
<span {...props} {...roving}>{shown.text}</span>
|
|
370
|
+
{/snippet}
|
|
332
371
|
</BitsDateField.Segment>
|
|
333
372
|
{/each}
|
|
334
373
|
{#if unread}
|
|
@@ -338,7 +377,10 @@
|
|
|
338
377
|
<button
|
|
339
378
|
type="button"
|
|
340
379
|
class="qm-chip qm-tap-floor qm-focus-ring qm-date-today"
|
|
380
|
+
bind:this={todayEl}
|
|
381
|
+
tabindex={stop === TODAY ? 0 : -1}
|
|
341
382
|
aria-pressed={!!follows}
|
|
383
|
+
aria-keyshortcuts="T"
|
|
342
384
|
data-default={follows === 'default' ? '' : undefined}
|
|
343
385
|
onclick={toggle}
|
|
344
386
|
>
|
|
@@ -56,8 +56,9 @@
|
|
|
56
56
|
</script>
|
|
57
57
|
|
|
58
58
|
{#if diagnostics && diagnostics.length}
|
|
59
|
-
<!--
|
|
60
|
-
|
|
59
|
+
<!-- Not a live region: the list arrives with its text in it, so the editor's standing
|
|
60
|
+
region says it (INVARIANTS §Diagnostics). -->
|
|
61
|
+
<div class="qm-diag-list" id={listId} {@attach markInvalid}>
|
|
61
62
|
{#each diagnostics as d, i (i)}
|
|
62
63
|
<span class="qm-diag-line">{diagnosticText(d, t.formatDiagnostic, t.strings)}</span>
|
|
63
64
|
{/each}
|
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
/** `<label for>` target. Set → the label names this trigger, so `aria-label`
|
|
38
38
|
* comes off: two names is where implementations disagree about which wins. */
|
|
39
39
|
id?: string;
|
|
40
|
+
/** The field's label element, which names the list as `label` does where it is unset. */
|
|
41
|
+
labelledBy?: string;
|
|
40
42
|
/** The parked `description` (FieldLabel): announced after the name. */
|
|
41
43
|
describedBy?: string;
|
|
42
44
|
onCommit: (v: string | undefined) => void;
|
|
@@ -57,6 +59,7 @@
|
|
|
57
59
|
optional = false,
|
|
58
60
|
label,
|
|
59
61
|
id,
|
|
62
|
+
labelledBy,
|
|
60
63
|
describedBy,
|
|
61
64
|
onCommit,
|
|
62
65
|
optionAllowed,
|
|
@@ -129,6 +132,8 @@
|
|
|
129
132
|
collisionBoundary={portalTarget ?? []}
|
|
130
133
|
strategy="absolute"
|
|
131
134
|
sideOffset={spacePx(wrapEl)}
|
|
135
|
+
aria-labelledby={labelledBy}
|
|
136
|
+
aria-label={labelledBy ? undefined : label}
|
|
132
137
|
>
|
|
133
138
|
<!-- The list portals out of the trigger's DOM but into the nearest
|
|
134
139
|
`[data-qm-root]`, and carries the marker itself, like FormatPopover.
|
|
@@ -170,7 +175,7 @@
|
|
|
170
175
|
<!-- The reset is the sentinel, offered once there is something to reset:
|
|
171
176
|
unset, the list's check already stands where a reset would land. -->
|
|
172
177
|
{#if !unset}
|
|
173
|
-
<div class="qm-select-divider"
|
|
178
|
+
<div class="qm-select-divider" aria-hidden="true"></div>
|
|
174
179
|
<Select.Item
|
|
175
180
|
class="qm-menu-item qm-select-item qm-select-unset"
|
|
176
181
|
value={UNSET}
|
|
@@ -16,6 +16,8 @@ interface Props {
|
|
|
16
16
|
/** `<label for>` target. Set → the label names this trigger, so `aria-label`
|
|
17
17
|
* comes off: two names is where implementations disagree about which wins. */
|
|
18
18
|
id?: string;
|
|
19
|
+
/** The field's label element, which names the list as `label` does where it is unset. */
|
|
20
|
+
labelledBy?: string;
|
|
19
21
|
/** The parked `description` (FieldLabel): announced after the name. */
|
|
20
22
|
describedBy?: string;
|
|
21
23
|
onCommit: (v: string | undefined) => void;
|
package/dist/visual/Field.svelte
CHANGED
|
@@ -382,10 +382,8 @@
|
|
|
382
382
|
{@attach registerControl}
|
|
383
383
|
onfocusin={(e) => {
|
|
384
384
|
reportFocus?.(e);
|
|
385
|
-
if (proposed) reviewing.point(proposed.id
|
|
385
|
+
if (proposed) reviewing.point(proposed.id);
|
|
386
386
|
}}
|
|
387
|
-
onpointerenter={() => worded && reviewing.point(worded.id, 'pointer')}
|
|
388
|
-
onpointerleave={() => worded && reviewing.point(undefined, 'pointer')}
|
|
389
387
|
>
|
|
390
388
|
{#if field.control === 'prose'}
|
|
391
389
|
<ProseField
|
|
@@ -395,6 +393,7 @@
|
|
|
395
393
|
{addr}
|
|
396
394
|
inline={field.inline}
|
|
397
395
|
plaintext={field.plaintext}
|
|
396
|
+
paragraphs={field.paragraphs}
|
|
398
397
|
fallback={printed ? (ghost as Content) : undefined}
|
|
399
398
|
placeholder={proposed ? undefined : none}
|
|
400
399
|
emptyUnsets={optional}
|
|
@@ -419,6 +418,7 @@
|
|
|
419
418
|
blankTitle={field.schema.ui?.blank_title}
|
|
420
419
|
{optional}
|
|
421
420
|
id={domIds.control}
|
|
421
|
+
labelledBy={domIds.label}
|
|
422
422
|
{describedBy}
|
|
423
423
|
onCommit={answerOrCommit}
|
|
424
424
|
proposing={!!proposed}
|
|
@@ -9,11 +9,9 @@
|
|
|
9
9
|
on touch, which leaves guidance the reference quill puts on nearly every field
|
|
10
10
|
reachable on a tablet only through a screen reader.
|
|
11
11
|
|
|
12
|
-
Floating, for
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
density the card is built to avoid. A short one stands under its label instead
|
|
16
|
-
({@link FieldLabel}) and raises no marker.
|
|
12
|
+
Floating, for every description: the reference quill's descriptions run to a median
|
|
13
|
+
of ~110 characters and past 250 at the tail, and permanently in flow that is several
|
|
14
|
+
wrapped lines under every field, which is the density the card is built to avoid.
|
|
17
15
|
|
|
18
16
|
The popover is chrome, not the announcement. Its content is `aria-hidden`: the
|
|
19
17
|
description reaches assistive tech through the always-present parked node
|
|
@@ -33,6 +31,7 @@
|
|
|
33
31
|
import Icon from './icons/Icon.svelte';
|
|
34
32
|
import { spacePx } from '../core/rungs.js';
|
|
35
33
|
import { renderGuidance } from './guidance.js';
|
|
34
|
+
import { wording } from './strings.js';
|
|
36
35
|
import './controls.css';
|
|
37
36
|
|
|
38
37
|
interface Props {
|
|
@@ -45,6 +44,7 @@
|
|
|
45
44
|
describedBy?: string;
|
|
46
45
|
}
|
|
47
46
|
let { description, label, describedBy }: Props = $props();
|
|
47
|
+
const t = wording();
|
|
48
48
|
|
|
49
49
|
let open = $state(false);
|
|
50
50
|
let triggerEl = $state<HTMLButtonElement | undefined>(undefined);
|
|
@@ -149,7 +149,7 @@
|
|
|
149
149
|
type="button"
|
|
150
150
|
class="qm-field-hint qm-icon-btn qm-focus-ring qm-tap-floor"
|
|
151
151
|
tabindex="-1"
|
|
152
|
-
aria-label=
|
|
152
|
+
aria-label={t.strings.fieldGuidance(label)}
|
|
153
153
|
aria-expanded={open}
|
|
154
154
|
aria-describedby={describedBy}
|
|
155
155
|
onpointerenter={(e) => {
|
|
@@ -258,12 +258,14 @@
|
|
|
258
258
|
|
|
259
259
|
It takes no fill either: the surface itself opens on hover.
|
|
260
260
|
|
|
261
|
-
At rest it
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
261
|
+
At rest it is absent: a card describing every field otherwise stands a glyph beside
|
|
262
|
+
each label, against the labels a reader is scanning
|
|
263
|
+
(INVARIANTS §"A field's own chrome waits for the field"). It keeps its box and arrives
|
|
264
|
+
by opacity alone, with the scope that owns its row (the field, the property, the array
|
|
265
|
+
or matrix, the table its column heads, the section a lone field is named by), each
|
|
266
|
+
reached by child steps so a nested field's marker stays absent under its container's
|
|
267
|
+
hover, and it stays while its surface is open, so the keyboard's `Mod-/` never raises
|
|
268
|
+
a surface off a glyph that is not drawn. The parked description does not depend on
|
|
267
269
|
the lift. */
|
|
268
270
|
.qm-field-hint {
|
|
269
271
|
/* The marker recedes to the label rung; the surface carries the text. */
|
|
@@ -272,7 +274,7 @@
|
|
|
272
274
|
cursor: help;
|
|
273
275
|
padding: 0;
|
|
274
276
|
background: none;
|
|
275
|
-
opacity:
|
|
277
|
+
opacity: 0;
|
|
276
278
|
transition: opacity var(--_qm-duration-fast) var(--_qm-ease-reverse);
|
|
277
279
|
}
|
|
278
280
|
:global(:is(.qm-field, .qm-object-prop):is(:hover, :focus-within) > .qm-field-label-row)
|
|
@@ -287,6 +289,13 @@
|
|
|
287
289
|
.qm-field-hint[aria-expanded='true'] {
|
|
288
290
|
opacity: 1;
|
|
289
291
|
}
|
|
292
|
+
/* Without a hover there is no lift to wait for, and a tap is the glyph's only door, so
|
|
293
|
+
it rests drawn at the rung a live glyph control rests at. */
|
|
294
|
+
@media (hover: none) {
|
|
295
|
+
.qm-field-hint {
|
|
296
|
+
opacity: var(--_qm-opacity-rest);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
290
299
|
/* The lift, the translucency, the blur and the scale-in come from
|
|
291
300
|
`.qm-popover-surface` (controls.css). This surface's own is a measure: guidance
|
|
292
301
|
is prose, and prose past ~40 characters a line stops being scannable; plus the
|
|
@@ -10,9 +10,8 @@
|
|
|
10
10
|
hands the click to `onActivate`. Both halves are needed: `for` on a non-labelable
|
|
11
11
|
element is inert and invalid.
|
|
12
12
|
|
|
13
|
-
One non-gating label decoration: the `description
|
|
14
|
-
|
|
15
|
-
control. A longer one is an info marker raising a themed popover ({@link FieldHint}).
|
|
13
|
+
One non-gating label decoration: the `description`, an info marker raising a themed
|
|
14
|
+
popover ({@link FieldHint}), whatever its length.
|
|
16
15
|
|
|
17
16
|
The row's end says where the field stands against its `default:` (INVARIANTS §"The
|
|
18
17
|
commitment ladder"). While the default is what prints, a tag says so in words, and the
|
|
@@ -20,7 +19,7 @@
|
|
|
20
19
|
holds the way back: one button for every control, arriving with the field's hover or
|
|
21
20
|
focus as the guidance marker does, and named for its field.
|
|
22
21
|
|
|
23
|
-
The description describes, it does not name.
|
|
22
|
+
The description describes, it does not name. It is parked in an
|
|
24
23
|
always-present visually-hidden node here and the control carries `aria-describedby`: name then
|
|
25
24
|
role then description, which is the announcement the markup visually implies. In
|
|
26
25
|
the name it would instead prepend ~110 characters of guidance (the reference
|
|
@@ -33,7 +32,7 @@
|
|
|
33
32
|
-->
|
|
34
33
|
<script lang="ts">
|
|
35
34
|
import FieldHint from './FieldHint.svelte';
|
|
36
|
-
import { guidanceText
|
|
35
|
+
import { guidanceText } from './guidance.js';
|
|
37
36
|
import { wording } from './strings.js';
|
|
38
37
|
import './controls.css';
|
|
39
38
|
|
|
@@ -52,9 +51,6 @@
|
|
|
52
51
|
onActivate?: () => void;
|
|
53
52
|
/** Schema `description`, or undefined: the affordance renders only when set. */
|
|
54
53
|
description?: string;
|
|
55
|
-
/** A short description stands under the label ({@link isBrief}). Off where the
|
|
56
|
-
* row has no second line to give, a table column's head. */
|
|
57
|
-
brief?: boolean;
|
|
58
54
|
/** A capped field's character count, drawn at the row's end. */
|
|
59
55
|
count?: string;
|
|
60
56
|
/** The count's own id, for the control's `aria-describedby`. */
|
|
@@ -73,7 +69,6 @@
|
|
|
73
69
|
descriptionId,
|
|
74
70
|
onActivate,
|
|
75
71
|
description,
|
|
76
|
-
brief = true,
|
|
77
72
|
count,
|
|
78
73
|
countId,
|
|
79
74
|
defaulted = false,
|
|
@@ -82,14 +77,9 @@
|
|
|
82
77
|
}: Props = $props();
|
|
83
78
|
|
|
84
79
|
const resetId = $props.id();
|
|
85
|
-
const inFlow = $derived(brief && description != null && isBrief(description));
|
|
86
|
-
/** The description is DOM, not text (`renderGuidance`), so it is written in. */
|
|
87
|
-
function paint(line: HTMLElement): void {
|
|
88
|
-
line.replaceChildren(renderGuidance(description ?? ''));
|
|
89
|
-
}
|
|
90
80
|
</script>
|
|
91
81
|
|
|
92
|
-
<div class=
|
|
82
|
+
<div class="qm-field-label-row">
|
|
93
83
|
<!-- svelte-ignore a11y_no_noninteractive_element_interactions, a11y_click_events_have_key_events -->
|
|
94
84
|
<!-- The handler stands in for exactly what `for` would have done, on the controls
|
|
95
85
|
where `for` is inert. It adds no keyboard surface because it needs none: a
|
|
@@ -103,10 +93,7 @@
|
|
|
103
93
|
>
|
|
104
94
|
<span>{label}</span>
|
|
105
95
|
</label>
|
|
106
|
-
{#if
|
|
107
|
-
<!-- The node that describes the control is the line a reader sees. -->
|
|
108
|
-
<div class="qm-field-brief" id={descriptionId} {@attach paint}></div>
|
|
109
|
-
{:else if description}
|
|
96
|
+
{#if description}
|
|
110
97
|
<!-- Outside the `<label>`, both of them: a trigger inside it would put its own
|
|
111
98
|
name in the control's, and the parked copy would put all ~110 characters
|
|
112
99
|
there. A `<button>` in a label is at least safe from the other hazard:
|
|
@@ -154,29 +141,6 @@
|
|
|
154
141
|
color: var(--_qm-ink-label);
|
|
155
142
|
min-width: 0;
|
|
156
143
|
}
|
|
157
|
-
/* A short description, in flow: the row's own second line, so the field's grid still
|
|
158
|
-
counts one label track and a row-sharing neighbour's control starts level. Last
|
|
159
|
-
whatever stands at the first line's end. One weight under the label, which names
|
|
160
|
-
where this only describes. */
|
|
161
|
-
.qm-field-label-row.briefed {
|
|
162
|
-
flex-wrap: wrap;
|
|
163
|
-
row-gap: 0;
|
|
164
|
-
}
|
|
165
|
-
.qm-field-brief {
|
|
166
|
-
order: 1;
|
|
167
|
-
flex: 0 0 100%;
|
|
168
|
-
min-width: 0;
|
|
169
|
-
font-size: var(--_qm-text-label);
|
|
170
|
-
line-height: var(--_qm-leading-body);
|
|
171
|
-
color: var(--_qm-ink-label);
|
|
172
|
-
}
|
|
173
|
-
.qm-field-brief :global(p) {
|
|
174
|
-
margin: 0;
|
|
175
|
-
}
|
|
176
|
-
.qm-field-brief :global(code) {
|
|
177
|
-
font-family: var(--_qm-font-mono);
|
|
178
|
-
font-size: inherit;
|
|
179
|
-
}
|
|
180
144
|
.qm-field-count {
|
|
181
145
|
margin-inline-start: auto;
|
|
182
146
|
font-size: var(--_qm-text-label);
|
|
@@ -11,9 +11,6 @@ interface Props {
|
|
|
11
11
|
onActivate?: () => void;
|
|
12
12
|
/** Schema `description`, or undefined: the affordance renders only when set. */
|
|
13
13
|
description?: string;
|
|
14
|
-
/** A short description stands under the label ({@link isBrief}). Off where the
|
|
15
|
-
* row has no second line to give, a table column's head. */
|
|
16
|
-
brief?: boolean;
|
|
17
14
|
/** A capped field's character count, drawn at the row's end. */
|
|
18
15
|
count?: string;
|
|
19
16
|
/** The count's own id, for the control's `aria-describedby`. */
|
|
@@ -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);
|
|
@@ -519,7 +542,9 @@
|
|
|
519
542
|
floating-ui's positioning box: spread, never styled. `inert` is the half
|
|
520
543
|
of the dismissal the recipe cannot carry: the surface is still on screen
|
|
521
544
|
for the length of the fade, and a surface on its way out is not a thing
|
|
522
|
-
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. -->
|
|
523
548
|
{#snippet child({ props, wrapperProps, open: raised })}
|
|
524
549
|
<div {...wrapperProps}>
|
|
525
550
|
<div
|
|
@@ -527,6 +552,7 @@
|
|
|
527
552
|
{...props}
|
|
528
553
|
class="qm-format-popover qm-popover-surface"
|
|
529
554
|
data-qm-root
|
|
555
|
+
data-qm-tip-side={props['data-side']}
|
|
530
556
|
inert={!raised}
|
|
531
557
|
onkeydown={onBarKeyDown}
|
|
532
558
|
onfocusout={onBarFocusOut}
|
|
@@ -545,7 +571,7 @@
|
|
|
545
571
|
class="qm-link-input qm-focus-ring"
|
|
546
572
|
type="text"
|
|
547
573
|
placeholder={t.strings.linkPlaceholder}
|
|
548
|
-
aria-label={t.strings.
|
|
574
|
+
aria-label={t.strings.linkAddress}
|
|
549
575
|
bind:value={linkValue}
|
|
550
576
|
/>
|
|
551
577
|
<button type="submit" class="qm-icon-btn qm-mark-btn qm-focus-ring"
|
|
@@ -577,14 +603,16 @@
|
|
|
577
603
|
class="qm-format-buttons"
|
|
578
604
|
role="group"
|
|
579
605
|
aria-label={t.strings.formatGroup}
|
|
580
|
-
aria-keyshortcuts={FIELD_KEYS.formatBar
|
|
606
|
+
aria-keyshortcuts={keyshortcut(FIELD_KEYS.formatBar)}
|
|
581
607
|
>
|
|
582
608
|
{#each MARKS as m (m.name)}
|
|
583
609
|
<button
|
|
584
610
|
type="button"
|
|
585
611
|
class="qm-icon-btn qm-mark-btn qm-focus-ring"
|
|
586
|
-
|
|
587
|
-
|
|
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)}
|
|
588
616
|
onmousedown={keepFocus}
|
|
589
617
|
onclick={() => toggle(m.name)}><Icon name={m.icon} /></button
|
|
590
618
|
>
|
|
@@ -593,7 +621,6 @@
|
|
|
593
621
|
<span class="qm-format-divider" aria-hidden="true"></span>
|
|
594
622
|
<select
|
|
595
623
|
class="qm-font-select qm-focus-ring"
|
|
596
|
-
title={t.strings.formatFont}
|
|
597
624
|
aria-label={t.strings.formatFont}
|
|
598
625
|
value={family ?? MIXED}
|
|
599
626
|
onchange={(e) => pickFamily(e.currentTarget.value)}
|
|
@@ -613,8 +640,10 @@
|
|
|
613
640
|
<button
|
|
614
641
|
type="button"
|
|
615
642
|
class="qm-icon-btn qm-mark-btn qm-focus-ring"
|
|
616
|
-
|
|
617
|
-
|
|
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)}
|
|
618
647
|
onmousedown={keepFocus}
|
|
619
648
|
onclick={() => toggleLines(l.ordered)}><Icon name={l.icon} /></button
|
|
620
649
|
>
|
|
@@ -689,6 +718,10 @@
|
|
|
689
718
|
border: none;
|
|
690
719
|
border-radius: var(--_qm-radius-inner);
|
|
691
720
|
background: var(--_qm-surface-well);
|
|
721
|
+
color: var(--_qm-ink);
|
|
692
722
|
min-width: 12rem;
|
|
693
723
|
}
|
|
724
|
+
.qm-link-input::placeholder {
|
|
725
|
+
color: var(--_qm-ink-label);
|
|
726
|
+
}
|
|
694
727
|
</style>
|