@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
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
An open matrix's add box (INVARIANTS §"The matrix"): a plain text input. Enter adds
|
|
3
3
|
what was typed, trimmed, and clears the box, and so does the focus leaving it: words
|
|
4
4
|
typed there are an item, not a draft a click elsewhere discards. Escape clears it
|
|
5
|
-
unadded. It is
|
|
6
|
-
it adds, unwritten: the plus in the tick's column and the words in the title's.
|
|
5
|
+
unadded. It is a box the width of the list, the plus inside it at its start.
|
|
7
6
|
-->
|
|
8
7
|
<script lang="ts">
|
|
9
8
|
import Icon from './icons/Icon.svelte';
|
|
@@ -66,21 +65,22 @@
|
|
|
66
65
|
.qm-matrix-add {
|
|
67
66
|
min-width: 0;
|
|
68
67
|
}
|
|
69
|
-
/*
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
so a press on the glyph lands in the box. */
|
|
68
|
+
/* The glyph stands inside the box, at its start inset, as a list's standing row draws
|
|
69
|
+
its words inside its own: the box is the whole row, and the input's words start a
|
|
70
|
+
gap past the glyph. A `<label>`, so a press on the glyph lands in the box. */
|
|
73
71
|
.qm-matrix-add-field {
|
|
72
|
+
position: relative;
|
|
74
73
|
display: flex;
|
|
75
74
|
align-items: center;
|
|
76
|
-
gap: var(--_qm-space-2);
|
|
77
75
|
min-width: 0;
|
|
78
76
|
}
|
|
79
77
|
.qm-matrix-add :global(.qm-matrix-add-glyph) {
|
|
80
|
-
|
|
78
|
+
position: absolute;
|
|
79
|
+
inset-inline-start: var(--_qm-space-3);
|
|
81
80
|
width: var(--_qm-glyph-control);
|
|
82
81
|
height: var(--_qm-glyph-control);
|
|
83
82
|
color: var(--_qm-ink-label);
|
|
83
|
+
pointer-events: none;
|
|
84
84
|
}
|
|
85
85
|
/* At rest the box is the add chip it stands in for: no well, and its words at the
|
|
86
86
|
label ink in full, as the add chip's are: words take the text floor, not the rest rung
|
|
@@ -88,8 +88,7 @@
|
|
|
88
88
|
.qm-matrix-add-field .qm-input {
|
|
89
89
|
flex: 1;
|
|
90
90
|
min-width: 0;
|
|
91
|
-
|
|
92
|
-
padding-inline-start: var(--_qm-space-2);
|
|
91
|
+
padding-inline-start: calc(var(--_qm-space-3) + var(--_qm-glyph-control) + var(--_qm-space-2));
|
|
93
92
|
transition: background-color var(--_qm-duration-fast) var(--_qm-ease-reverse);
|
|
94
93
|
}
|
|
95
94
|
.qm-matrix-add-field .qm-input:placeholder-shown:not(:focus) {
|
|
@@ -4,9 +4,12 @@
|
|
|
4
4
|
list, one member to a row, or abreast on the section's track ladder under
|
|
5
5
|
`ui.compact`; each member is a real checkbox whose checked state is the member's
|
|
6
6
|
presence, with its title as the `<label for>`, an unheld member reading at the label
|
|
7
|
-
ink and a held one at the value ink. A held member
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
ink and a held one at the value ink. A held member rests as one line, its title then
|
|
8
|
+
the words of its first one-line text column at the label ink, and a disclosure there
|
|
9
|
+
unfolds its columns beneath it, drawn by {@link ObjectField} over the matrix's
|
|
10
|
+
`properties` at the member's key, in the member's own track, so opening one moves no
|
|
11
|
+
other. A tick, an add and a landing unfold the member, as does a proposal or a
|
|
12
|
+
diagnostic on one of its columns; zero columns is a checklist and unfolds nothing.
|
|
10
13
|
|
|
11
14
|
An open matrix's added items follow the roster in id order, as the plate prints them:
|
|
12
15
|
held by being present, so each draws a fixed tick, its `title` as an input, a remove,
|
|
@@ -27,6 +30,7 @@
|
|
|
27
30
|
-->
|
|
28
31
|
<script lang="ts">
|
|
29
32
|
import { onDestroy, tick as flush } from 'svelte';
|
|
33
|
+
import { SvelteSet } from 'svelte/reactivity';
|
|
30
34
|
import { wording } from './strings.js';
|
|
31
35
|
import { structuralUndo } from './undo.svelte.js';
|
|
32
36
|
|
|
@@ -45,6 +49,7 @@
|
|
|
45
49
|
baseType,
|
|
46
50
|
commitMember,
|
|
47
51
|
declaredContent,
|
|
52
|
+
firstShortText,
|
|
48
53
|
matrixColumns,
|
|
49
54
|
matrixDeclares,
|
|
50
55
|
matrixEmpty,
|
|
@@ -132,10 +137,11 @@
|
|
|
132
137
|
const reviewed = $derived(splitReview(review));
|
|
133
138
|
/** A member's own proposal: it ticks or unticks the member whole. */
|
|
134
139
|
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
|
|
140
|
+
/** Whether a member shows as held: as its proposal would leave it, else as stored, an
|
|
141
|
+
* unheld one under a proposal for a cell of it held, as taking that proposal writes it. */
|
|
136
142
|
const shownHeld = (id: string): boolean => {
|
|
137
143
|
const item = proposal(id);
|
|
138
|
-
return item ? matrixHeld(item.after) : held(id);
|
|
144
|
+
return item ? matrixHeld(item.after) : held(id) || cellReview(id).length > 0;
|
|
139
145
|
};
|
|
140
146
|
/** The member's columns as shown: its proposal's where one ticks it, else the stored. */
|
|
141
147
|
const shownColumns = (id: string): Record<string, unknown> => {
|
|
@@ -164,6 +170,25 @@
|
|
|
164
170
|
/** An added item's title input: the `title` cell's own control id. */
|
|
165
171
|
const itemTitleId = (id: string): string => propertyDomIds(memberBase(id), MATRIX_TITLE).control;
|
|
166
172
|
|
|
173
|
+
/** The disclosure glyph, at the size an array row's takes. */
|
|
174
|
+
const CHEVRON = 16;
|
|
175
|
+
/** The held items whose details are unfolded, for this mount: a held item rests as one
|
|
176
|
+
* line, and a tick or an add opens it, its details being what the author came to fill. */
|
|
177
|
+
const expanded = new SvelteSet<string>();
|
|
178
|
+
/** Whether a held item's details are drawn: unfolded by the reader, or holding a
|
|
179
|
+
* proposal or a diagnostic for one of its cells, each drawn on its cell. */
|
|
180
|
+
const isOpen = (id: string): boolean =>
|
|
181
|
+
hasColumns &&
|
|
182
|
+
(expanded.has(id) ||
|
|
183
|
+
cellReview(id).length > 0 ||
|
|
184
|
+
(routed.below.get(id)?.some((d) => d.steps[0] !== MATRIX_TITLE) ?? false));
|
|
185
|
+
/** What a folded item shows of its details: the words an array row's summary reads. */
|
|
186
|
+
const tail = (id: string): string | undefined =>
|
|
187
|
+
firstShortText(schema.properties, shownColumns(id));
|
|
188
|
+
function toggle(id: string): void {
|
|
189
|
+
if (expanded.has(id)) expanded.delete(id);
|
|
190
|
+
else expanded.add(id);
|
|
191
|
+
}
|
|
167
192
|
/** The columns an untick took, by member id, for a retick in this mount to restore. */
|
|
168
193
|
const stash = new Map<string, Record<string, unknown>>();
|
|
169
194
|
/** Commit the map; one holding nothing is the field's empty answer (`matrixEmpty`). */
|
|
@@ -213,7 +238,12 @@
|
|
|
213
238
|
* their local, a `$derived` of the value: the document is what the face reads. */
|
|
214
239
|
async function tick(id: string, on: boolean, el: HTMLInputElement): Promise<void> {
|
|
215
240
|
const item = proposal(id);
|
|
241
|
+
const cells = cellReview(id);
|
|
242
|
+
if (on) expanded.add(id);
|
|
243
|
+
else expanded.delete(id);
|
|
216
244
|
if (item && on === matrixHeld(item.after)) reviewing.act(item.id, 'accept');
|
|
245
|
+
else if (!item && !on && !held(id) && cells.length)
|
|
246
|
+
for (const { item: cell } of cells) reviewing.act(cell.id, 'dismiss');
|
|
217
247
|
else if (!item || !reviewing.answerWith(item.id, on ? ticked(id) : undefined))
|
|
218
248
|
commit(on ? commitMember(map, id, ticked(id)) : unticked(id));
|
|
219
249
|
await flush();
|
|
@@ -264,6 +294,7 @@
|
|
|
264
294
|
undo.withdraw();
|
|
265
295
|
const id = addedId(title, taken);
|
|
266
296
|
commit(commitMember(map, id, memberWrite({}, title)));
|
|
297
|
+
expanded.add(id);
|
|
267
298
|
await flush();
|
|
268
299
|
const box = own(memberEls, id);
|
|
269
300
|
// The item's columns are what the author came to fill; a checklist has none, and
|
|
@@ -303,11 +334,16 @@
|
|
|
303
334
|
return undefined;
|
|
304
335
|
}
|
|
305
336
|
const column = rest[0];
|
|
306
|
-
const cells = own(colEls, id);
|
|
307
337
|
const member = own(memberEls, id);
|
|
308
|
-
if (column !== undefined && column !== MATRIX_TITLE &&
|
|
309
|
-
const
|
|
310
|
-
|
|
338
|
+
if (column !== undefined && column !== MATRIX_TITLE && hasColumns && shownHeld(id)) {
|
|
339
|
+
const into = (cells: Subform | undefined): LandingBox => {
|
|
340
|
+
if (!cells) return member;
|
|
341
|
+
const inner = cells.focusPath(rest, pos);
|
|
342
|
+
return inner instanceof Promise ? inner.then((box) => box ?? member) : (inner ?? member);
|
|
343
|
+
};
|
|
344
|
+
if (own(colEls, id)) return into(own(colEls, id));
|
|
345
|
+
expanded.add(id);
|
|
346
|
+
return flush().then(() => into(own(colEls, id)));
|
|
311
347
|
}
|
|
312
348
|
(own(tickEls, id) ?? own(titleEls, id))?.focus();
|
|
313
349
|
return member;
|
|
@@ -338,7 +374,7 @@
|
|
|
338
374
|
{#each members as m (m.id)}
|
|
339
375
|
{@const on = shownHeld(m.id)}
|
|
340
376
|
<div
|
|
341
|
-
class={['qm-member qm-wash', { held: on, open: on &&
|
|
377
|
+
class={['qm-member qm-wash', { held: on, open: on && isOpen(m.id) }]}
|
|
342
378
|
data-qm-prop={m.id}
|
|
343
379
|
bind:this={memberEls[m.id]}
|
|
344
380
|
>
|
|
@@ -360,6 +396,9 @@
|
|
|
360
396
|
</span>
|
|
361
397
|
<ReviewRows entries={reviewed.below.get(m.id)?.filter((e) => !e.steps.length)} />
|
|
362
398
|
<label class="qm-member-title" id={titleId(m.id)} for={tickId(m.id)}>{m.title}</label>
|
|
399
|
+
{#if on && hasColumns}
|
|
400
|
+
{@render disclosure(m.id, m.title)}
|
|
401
|
+
{/if}
|
|
363
402
|
</div>
|
|
364
403
|
{@render columns(m.id, m.title, on)}
|
|
365
404
|
</div>
|
|
@@ -367,7 +406,7 @@
|
|
|
367
406
|
{#each added as item, k (item.id)}
|
|
368
407
|
{@const name = item.title || t.strings.matrixItemTitle(label ?? '', k + 1)}
|
|
369
408
|
<div
|
|
370
|
-
class={['qm-member qm-wash held added', { open:
|
|
409
|
+
class={['qm-member qm-wash held added', { open: isOpen(item.id) }]}
|
|
371
410
|
data-qm-prop={item.id}
|
|
372
411
|
bind:this={memberEls[item.id]}
|
|
373
412
|
>
|
|
@@ -388,10 +427,13 @@
|
|
|
388
427
|
oninput={(e) => retitle(item.id, e.currentTarget.value)}
|
|
389
428
|
/>
|
|
390
429
|
<span class="qm-member-title" id={titleId(item.id)} hidden>{name}</span>
|
|
430
|
+
{#if hasColumns}
|
|
431
|
+
{@render disclosure(item.id, name)}
|
|
432
|
+
{/if}
|
|
391
433
|
<button
|
|
392
434
|
type="button"
|
|
393
435
|
class="qm-icon-btn qm-focus-ring qm-member-remove"
|
|
394
|
-
|
|
436
|
+
data-qm-tip={t.strings.matrixRemove(name)}
|
|
395
437
|
aria-label={t.strings.matrixRemove(name)}
|
|
396
438
|
onclick={() => removeItem(item.id, name)}><Icon name="x" /></button
|
|
397
439
|
>
|
|
@@ -417,7 +459,7 @@
|
|
|
417
459
|
a tick elsewhere leaves this subform mounted and the caret in it. -->
|
|
418
460
|
{#snippet columns(id: string, title: string, on: boolean)}
|
|
419
461
|
{@const deep = routed.below.get(id)}
|
|
420
|
-
{#if on &&
|
|
462
|
+
{#if on && isOpen(id)}
|
|
421
463
|
<ObjectField
|
|
422
464
|
bind:this={colEls[id]}
|
|
423
465
|
value={shownColumns(id)}
|
|
@@ -438,6 +480,22 @@
|
|
|
438
480
|
{/if}
|
|
439
481
|
{/snippet}
|
|
440
482
|
|
|
483
|
+
<!-- A held item's disclosure: its details' first line of words, muted after the name,
|
|
484
|
+
and the chevron that unfolds them, the way a record row opens. -->
|
|
485
|
+
{#snippet disclosure(id: string, title: string)}
|
|
486
|
+
{@const words = isOpen(id) ? undefined : tail(id)}
|
|
487
|
+
<button
|
|
488
|
+
type="button"
|
|
489
|
+
class="qm-focus-ring qm-member-summary"
|
|
490
|
+
aria-expanded={isOpen(id)}
|
|
491
|
+
aria-label={t.strings.matrixDetails(title)}
|
|
492
|
+
onclick={() => toggle(id)}
|
|
493
|
+
>
|
|
494
|
+
<span class="qm-member-tail">{words ?? ''}</span>
|
|
495
|
+
<Icon name="chevron-right" class="qm-member-chevron" size={CHEVRON} />
|
|
496
|
+
</button>
|
|
497
|
+
{/snippet}
|
|
498
|
+
|
|
441
499
|
<style>
|
|
442
500
|
.qm-matrix {
|
|
443
501
|
display: flex;
|
|
@@ -452,11 +510,6 @@
|
|
|
452
510
|
justify-content: space-between;
|
|
453
511
|
gap: var(--_qm-space-2);
|
|
454
512
|
}
|
|
455
|
-
/* Under a label that carries its description in flow, the count keeps the label's
|
|
456
|
-
line rather than centring on the two. */
|
|
457
|
-
.qm-matrix-header:has(> :global(.qm-field-label-row.briefed)) {
|
|
458
|
-
align-items: baseline;
|
|
459
|
-
}
|
|
460
513
|
/* The count reads at the label rung: a fact about the field, never a value. */
|
|
461
514
|
.qm-matrix-count {
|
|
462
515
|
font-size: var(--_qm-text-label);
|
|
@@ -496,6 +549,49 @@
|
|
|
496
549
|
.qm-matrix-roster:not(.compact) > .qm-member.open {
|
|
497
550
|
margin-block: var(--_qm-space);
|
|
498
551
|
}
|
|
552
|
+
/* The rest of the line is the disclosure: the details' words at the label ink, cut
|
|
553
|
+
to the line, then the chevron, which turns down as the details open. */
|
|
554
|
+
.qm-member-summary {
|
|
555
|
+
flex: 1;
|
|
556
|
+
min-width: 0;
|
|
557
|
+
align-self: stretch;
|
|
558
|
+
display: flex;
|
|
559
|
+
align-items: center;
|
|
560
|
+
gap: var(--_qm-space);
|
|
561
|
+
padding: 0;
|
|
562
|
+
margin: 0;
|
|
563
|
+
border: none;
|
|
564
|
+
border-radius: var(--_qm-radius-inner);
|
|
565
|
+
background: transparent;
|
|
566
|
+
font: inherit;
|
|
567
|
+
color: var(--_qm-ink-label);
|
|
568
|
+
text-align: start;
|
|
569
|
+
cursor: pointer;
|
|
570
|
+
}
|
|
571
|
+
.qm-member-tail {
|
|
572
|
+
flex: 1;
|
|
573
|
+
min-width: 0;
|
|
574
|
+
overflow: hidden;
|
|
575
|
+
white-space: nowrap;
|
|
576
|
+
text-overflow: ellipsis;
|
|
577
|
+
font-size: var(--_qm-text-body);
|
|
578
|
+
line-height: var(--_qm-leading-tight);
|
|
579
|
+
}
|
|
580
|
+
.qm-member-summary :global(.qm-member-chevron) {
|
|
581
|
+
flex-shrink: 0;
|
|
582
|
+
stroke-width: var(--_qm-glyph-stroke);
|
|
583
|
+
opacity: var(--_qm-opacity-rest);
|
|
584
|
+
transition:
|
|
585
|
+
transform var(--_qm-duration-slow) var(--_qm-ease-reverse),
|
|
586
|
+
opacity var(--_qm-duration-fast) var(--_qm-ease-reverse);
|
|
587
|
+
}
|
|
588
|
+
.qm-member-summary:hover :global(.qm-member-chevron),
|
|
589
|
+
.qm-member-summary:focus-visible :global(.qm-member-chevron) {
|
|
590
|
+
opacity: 1;
|
|
591
|
+
}
|
|
592
|
+
.qm-member-summary[aria-expanded='true'] :global(.qm-member-chevron) {
|
|
593
|
+
transform: rotate(90deg);
|
|
594
|
+
}
|
|
499
595
|
/* The tick and its title on one line, the line holding the tap floor a tick alone
|
|
500
596
|
would not reach: the title is the target, the `for` carrying its press to the input. */
|
|
501
597
|
.qm-member-head {
|
|
@@ -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
|
|
@@ -101,6 +102,16 @@
|
|
|
101
102
|
const defaulted = $derived(value == null && !!fallback && local === fallback);
|
|
102
103
|
const drawn = $derived(proposed && proposed.after !== resting ? proposed : undefined);
|
|
103
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
|
+
});
|
|
114
|
+
|
|
104
115
|
const partial = $derived(
|
|
105
116
|
integer ? /^\s*[+-]?\d*\s*$/ : /^\s*[+-]?\d*\.?\d*(?:[eE][+-]?\d*)?\s*$/
|
|
106
117
|
);
|
|
@@ -164,6 +175,11 @@
|
|
|
164
175
|
const raw = el.value;
|
|
165
176
|
const entry = raw.trim();
|
|
166
177
|
offered = false;
|
|
178
|
+
if (undone && unwrittenText != null && raw === unwrittenText) {
|
|
179
|
+
undone = false;
|
|
180
|
+
if (value != null) onCommit(undefined);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
167
183
|
if (entry === '') {
|
|
168
184
|
onCommit(undefined);
|
|
169
185
|
local = el.value = fallback ?? '';
|
|
@@ -172,6 +188,7 @@
|
|
|
172
188
|
// Finite as well: a digit run past `Number.MAX_VALUE` reads as `Infinity`.
|
|
173
189
|
const n = whole.test(entry) ? Number(entry) : NaN;
|
|
174
190
|
offered = !Number.isFinite(n);
|
|
191
|
+
if (!offered) committed = n;
|
|
175
192
|
onCommit(offered ? raw : n);
|
|
176
193
|
}
|
|
177
194
|
</script>
|
|
@@ -185,8 +202,6 @@
|
|
|
185
202
|
{placeholder}
|
|
186
203
|
data-default={defaulted ? '' : undefined}
|
|
187
204
|
data-proposed-over={drawn && local === resting ? '' : undefined}
|
|
188
|
-
onpointerenter={() => drawn && reviewing.point(drawn.id, 'pointer')}
|
|
189
|
-
onpointerleave={() => drawn && reviewing.point(undefined, 'pointer')}
|
|
190
205
|
aria-label={id ? undefined : label}
|
|
191
206
|
aria-describedby={describedBy}
|
|
192
207
|
onbeforeinput={filter}
|
|
@@ -194,6 +209,7 @@
|
|
|
194
209
|
local = (e.currentTarget as HTMLInputElement).value;
|
|
195
210
|
reverted = false;
|
|
196
211
|
settled = undefined;
|
|
212
|
+
undone = e instanceof InputEvent && e.inputType === 'historyUndo';
|
|
197
213
|
}}
|
|
198
214
|
onkeydown={onKey}
|
|
199
215
|
onchange={(e) => {
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
fieldModels,
|
|
44
44
|
fieldTitle,
|
|
45
45
|
isContainer,
|
|
46
|
+
linesOnly,
|
|
46
47
|
literalText,
|
|
47
48
|
mountKey,
|
|
48
49
|
optionalCell,
|
|
@@ -375,6 +376,7 @@
|
|
|
375
376
|
<EnumField
|
|
376
377
|
label={named}
|
|
377
378
|
id={ids?.control}
|
|
379
|
+
labelledBy={ids?.label}
|
|
378
380
|
describedBy={describes}
|
|
379
381
|
value={shown as string | undefined}
|
|
380
382
|
values={sub.values ?? []}
|
|
@@ -441,6 +443,7 @@
|
|
|
441
443
|
value={shown}
|
|
442
444
|
fallback={contentDefault(sub)}
|
|
443
445
|
plaintext={literalText(sub)}
|
|
446
|
+
paragraphs={linesOnly(sub)}
|
|
444
447
|
placeholder={ownItem ? undefined : noneOf(key, sub)}
|
|
445
448
|
{block}
|
|
446
449
|
label={named}
|
|
@@ -645,11 +648,12 @@
|
|
|
645
648
|
subgrid onto the row that holds them, so a cell's edge is the column's. No
|
|
646
649
|
vertical, no inset, no capacity of its own, and one row per cell, the label having
|
|
647
650
|
moved up to the header. `.qm-array-row` is the row (`ArrayField`), which spends
|
|
648
|
-
the
|
|
651
|
+
the first track on the row's handle and the last on its remove; this box takes the
|
|
652
|
+
rest. */
|
|
649
653
|
.qm-object-bare {
|
|
650
654
|
display: grid;
|
|
651
655
|
grid-template-columns: subgrid;
|
|
652
|
-
grid-column:
|
|
656
|
+
grid-column: 2 / -2;
|
|
653
657
|
}
|
|
654
658
|
.qm-object-bare > .qm-object-grid {
|
|
655
659
|
grid-template-columns: subgrid;
|
|
@@ -29,9 +29,10 @@
|
|
|
29
29
|
addr: Addr;
|
|
30
30
|
inline?: boolean;
|
|
31
31
|
plaintext?: boolean;
|
|
32
|
+
paragraphs?: boolean;
|
|
32
33
|
/**
|
|
33
34
|
* Draw no box: the card body's leaf, and nothing else. Not `block`, which is a
|
|
34
|
-
* different predicate: a `richtext` field declaring `
|
|
35
|
+
* different predicate: a `richtext` field declaring `shape: blocks` is block
|
|
35
36
|
* prose and still a control in a row of controls, so only the caller knows what
|
|
36
37
|
* is paper.
|
|
37
38
|
*/
|
|
@@ -83,6 +84,7 @@
|
|
|
83
84
|
addr,
|
|
84
85
|
inline,
|
|
85
86
|
plaintext,
|
|
87
|
+
paragraphs,
|
|
86
88
|
unframed,
|
|
87
89
|
label,
|
|
88
90
|
labelledBy,
|
|
@@ -141,6 +143,7 @@
|
|
|
141
143
|
container,
|
|
142
144
|
inline,
|
|
143
145
|
plaintext,
|
|
146
|
+
paragraphs,
|
|
144
147
|
label,
|
|
145
148
|
labelledBy,
|
|
146
149
|
describedBy,
|
|
@@ -157,7 +160,7 @@
|
|
|
157
160
|
slash = next;
|
|
158
161
|
},
|
|
159
162
|
onReview: (id, action) => reviewing.heard(id, action, leafKey),
|
|
160
|
-
onReviewPoint: (id
|
|
163
|
+
onReviewPoint: (id) => reviewing.point(id),
|
|
161
164
|
onReviewWriting: (on) => reviewing.writing(on),
|
|
162
165
|
onReviewDrawn: (report) => reviewing.drew(leafKey, report),
|
|
163
166
|
onValuePlanned: (id, state) => reviewing.planned(id, state),
|
|
@@ -241,7 +244,7 @@
|
|
|
241
244
|
.qm-prose-block :global(.ProseMirror) {
|
|
242
245
|
min-height: calc(1em * var(--_qm-leading-body));
|
|
243
246
|
}
|
|
244
|
-
/* Paper, and the withheld box is what says so. Not `block` alone: `
|
|
247
|
+
/* Paper, and the withheld box is what says so. Not `block` alone: `shape` is the
|
|
245
248
|
quill's to declare, so a schema spelling it on a richtext field puts a block leaf in
|
|
246
249
|
a field row, where this rung would break the height agreement above. */
|
|
247
250
|
.qm-prose-block:not(.qm-control-box) {
|
|
@@ -11,9 +11,10 @@ interface Props {
|
|
|
11
11
|
addr: Addr;
|
|
12
12
|
inline?: boolean;
|
|
13
13
|
plaintext?: boolean;
|
|
14
|
+
paragraphs?: boolean;
|
|
14
15
|
/**
|
|
15
16
|
* Draw no box: the card body's leaf, and nothing else. Not `block`, which is a
|
|
16
|
-
* different predicate: a `richtext` field declaring `
|
|
17
|
+
* different predicate: a `richtext` field declaring `shape: blocks` is block
|
|
17
18
|
* prose and still a control in a row of controls, so only the caller knows what
|
|
18
19
|
* is paper.
|
|
19
20
|
*/
|
|
@@ -28,8 +28,9 @@
|
|
|
28
28
|
it, so the echo replaces nothing and the caret and the history stay.
|
|
29
29
|
|
|
30
30
|
The schema is the declared type's where the parent has room for it: a subform cell
|
|
31
|
-
declaring
|
|
32
|
-
on the block schema
|
|
31
|
+
declaring a `shape` takes the full row ({@link ObjectField}), a `richtext` of blocks
|
|
32
|
+
on the block schema, a `richtext` of lines on the lines schema and a `text` one on the
|
|
33
|
+
plain schema, paragraphs and hard breaks.
|
|
33
34
|
An array element is one textblock whatever it declares, since Enter there is the
|
|
34
35
|
repeater's, and a paste or a drop of several lines into one is a row per line, as Enter
|
|
35
36
|
would open them, up to the array's `max:`, the last row taking what is left joined and
|
|
@@ -57,6 +58,7 @@
|
|
|
57
58
|
heldAttributes,
|
|
58
59
|
joinLines,
|
|
59
60
|
leafSchema,
|
|
61
|
+
isParagraphsSchema,
|
|
60
62
|
pastedLines,
|
|
61
63
|
pmToContent,
|
|
62
64
|
proseAttributes,
|
|
@@ -95,8 +97,11 @@
|
|
|
95
97
|
* as the field of that type mounts. */
|
|
96
98
|
plaintext?: boolean;
|
|
97
99
|
/** A multi-block schema, for a cell the parent draws at full width: the block
|
|
98
|
-
* schema,
|
|
100
|
+
* schema, the plain one with `plaintext`, or the lines one with `paragraphs`.
|
|
101
|
+
* Absent, the leaf is one textblock. */
|
|
99
102
|
block?: boolean;
|
|
103
|
+
/** A `richtext` cell of `shape: lines`: formatted paragraphs and hard breaks. */
|
|
104
|
+
paragraphs?: boolean;
|
|
100
105
|
/** Accessible name for the editable region, where nothing else names it: an
|
|
101
106
|
* array has no per-element label. A cell with a label element takes
|
|
102
107
|
* `labelledBy`. */
|
|
@@ -141,6 +146,7 @@
|
|
|
141
146
|
fallback,
|
|
142
147
|
plaintext = false,
|
|
143
148
|
block = false,
|
|
149
|
+
paragraphs = false,
|
|
144
150
|
label,
|
|
145
151
|
labelledBy,
|
|
146
152
|
describedBy,
|
|
@@ -243,7 +249,7 @@
|
|
|
243
249
|
function mountView(mount: HTMLDivElement): () => void {
|
|
244
250
|
return untrack(() => {
|
|
245
251
|
const inline = !block;
|
|
246
|
-
const leaf = { inline, plaintext, islands: false };
|
|
252
|
+
const leaf = { inline, plaintext, paragraphs, islands: false };
|
|
247
253
|
// Read per attribute pass, not captured: an element's name carries its index,
|
|
248
254
|
// which a remove above it moves.
|
|
249
255
|
const names = () => drawn;
|
|
@@ -273,13 +279,14 @@
|
|
|
273
279
|
// Which of `aria-label` / `aria-labelledby` wins is the codec's one answer
|
|
274
280
|
// (`proseAttributes`), so a cell carrying a label element and a row carrying
|
|
275
281
|
// none cannot name their regions by different rules.
|
|
276
|
-
const
|
|
282
|
+
const lineLeaf = isParagraphsSchema(leafSchema({ plaintext, inline, paragraphs }));
|
|
283
|
+
const plainNamed = () => proseAttributes(names(), !inline, lineLeaf);
|
|
277
284
|
const heldNamed = () => heldAttributes(names(), heldId);
|
|
278
285
|
const build = (rt: Content): EditorState => {
|
|
279
286
|
// The same keymap and plugin stack a `createField` leaf mounts (shared
|
|
280
287
|
// `proseLeafPlugins`), minus the anchor-position plugin: anchors are dropped on
|
|
281
288
|
// the parent's value write, per the header.
|
|
282
|
-
const schema = held ? blockSchema : leafSchema({ plaintext, inline });
|
|
289
|
+
const schema = held ? blockSchema : leafSchema({ plaintext, inline, paragraphs });
|
|
283
290
|
return EditorState.create({
|
|
284
291
|
doc: decode(rt, schema),
|
|
285
292
|
plugins: held
|
|
@@ -18,8 +18,11 @@ interface Props {
|
|
|
18
18
|
* as the field of that type mounts. */
|
|
19
19
|
plaintext?: boolean;
|
|
20
20
|
/** A multi-block schema, for a cell the parent draws at full width: the block
|
|
21
|
-
* schema,
|
|
21
|
+
* schema, the plain one with `plaintext`, or the lines one with `paragraphs`.
|
|
22
|
+
* Absent, the leaf is one textblock. */
|
|
22
23
|
block?: boolean;
|
|
24
|
+
/** A `richtext` cell of `shape: lines`: formatted paragraphs and hard breaks. */
|
|
25
|
+
paragraphs?: boolean;
|
|
23
26
|
/** Accessible name for the editable region, where nothing else names it: an
|
|
24
27
|
* array has no per-element label. A cell with a label element takes
|
|
25
28
|
* `labelledBy`. */
|