@quillmark/svelte 0.30.0 → 0.31.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 +2 -2
- package/dist/core/codec/decode.d.ts +3 -2
- package/dist/core/codec/decode.js +15 -11
- package/dist/core/codec/field.d.ts +2 -1
- package/dist/core/codec/field.js +119 -30
- package/dist/core/codec/positions.d.ts +12 -1
- package/dist/core/codec/prose.css +0 -8
- package/dist/core/codec/schema.d.ts +2 -2
- package/dist/core/codec/schema.js +3 -3
- package/dist/core/codec/slash.d.ts +4 -2
- package/dist/core/codec/slash.js +11 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/theme.css +14 -6
- package/dist/visual/ArrayField.svelte +167 -82
- package/dist/visual/BooleanField.svelte +2 -2
- package/dist/visual/Card.svelte +65 -44
- package/dist/visual/DateField.svelte +16 -1
- package/dist/visual/DiagnosticList.svelte +34 -2
- package/dist/visual/EnumField.svelte +58 -44
- package/dist/visual/Field.svelte +13 -3
- package/dist/visual/Field.svelte.d.ts +3 -1
- package/dist/visual/FieldHint.svelte +10 -3
- package/dist/visual/MatrixAdd.svelte +3 -18
- package/dist/visual/MatrixField.svelte +20 -12
- package/dist/visual/ObjectField.svelte +164 -145
- package/dist/visual/ProseField.svelte +6 -1
- package/dist/visual/SlashMenu.svelte +24 -12
- package/dist/visual/SlashMenu.svelte.d.ts +2 -0
- package/dist/visual/VisualEditor.svelte +1 -1
- package/dist/visual/VisualEditor.svelte.d.ts +1 -1
- package/dist/visual/VisualEditorInner.svelte +144 -9
- package/dist/visual/VisualEditorInner.svelte.d.ts +1 -1
- package/dist/visual/controls.css +42 -4
- package/dist/visual/strings.d.ts +27 -10
- package/dist/visual/strings.js +40 -6
- package/dist/visual/structure.d.ts +17 -9
- package/dist/visual/structure.js +19 -16
- package/dist/visual/undo.svelte.d.ts +36 -0
- package/dist/visual/undo.svelte.js +119 -0
- package/package.json +2 -2
- package/dist/visual/hold.d.ts +0 -17
- package/dist/visual/hold.js +0 -39
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
import type {
|
|
38
38
|
Addr,
|
|
39
39
|
CardAddr,
|
|
40
|
-
Delta,
|
|
41
40
|
Diagnostic,
|
|
42
41
|
PathStep,
|
|
43
42
|
PayloadItem,
|
|
@@ -46,7 +45,9 @@
|
|
|
46
45
|
ResolvedField
|
|
47
46
|
} from '@quillmark/wasm';
|
|
48
47
|
import type { VisualEditorProps } from './props.js';
|
|
48
|
+
import type { Delta } from '../core/codec/positions.js';
|
|
49
49
|
import { mergeStrings, setWording } from './strings.js';
|
|
50
|
+
import { createStructuralUndo, setStructuralUndo } from './undo.svelte.js';
|
|
50
51
|
import type { CardId, CardOp, ChangeSource } from './signals.js';
|
|
51
52
|
import type { FieldController, LeafViews } from '../core/codec/index.js';
|
|
52
53
|
import {
|
|
@@ -200,6 +201,23 @@
|
|
|
200
201
|
// going away as a whole, where a leaf's cleanup order relative to the parent's
|
|
201
202
|
// is Svelte's business and not something to depend on.
|
|
202
203
|
span.onEnd(() => leaves.clear());
|
|
204
|
+
|
|
205
|
+
// The removal's one step back (`undo.svelte.ts`), published so an array's row removal
|
|
206
|
+
// offers on the same toast a card's does.
|
|
207
|
+
const undo = createStructuralUndo();
|
|
208
|
+
setStructuralUndo(undo);
|
|
209
|
+
span.onEnd(undo.dispose);
|
|
210
|
+
/** ⌘Z/Ctrl+Z takes the standing offer where the offer accepts it (`undo.accepts`).
|
|
211
|
+
* On the document, since a removal under the pointer leaves the focus on the body, and
|
|
212
|
+
* captured, so a leaf the removal handed the focus to hears the key after the offer. */
|
|
213
|
+
function onUndoKey(e: KeyboardEvent): void {
|
|
214
|
+
if (e.defaultPrevented || e.isComposing || e.shiftKey || e.altKey) return;
|
|
215
|
+
if (!(e.metaKey || e.ctrlKey) || e.key.toLowerCase() !== 'z') return;
|
|
216
|
+
if (!undo.accepts(e.target, rootEl)) return;
|
|
217
|
+
e.preventDefault();
|
|
218
|
+
e.stopPropagation();
|
|
219
|
+
undo.take();
|
|
220
|
+
}
|
|
203
221
|
// Card handles, for `setCaret`'s reveal hop: the one thing a leaf's own controller
|
|
204
222
|
// cannot do, since which group is open is the card's state (Card §revealLeaf).
|
|
205
223
|
type CardHandle = {
|
|
@@ -420,7 +438,8 @@
|
|
|
420
438
|
const card = quill.seedCard(kind, overlay);
|
|
421
439
|
if (!card) return undefined;
|
|
422
440
|
const from = document.activeElement;
|
|
423
|
-
doc.insertCard(card, atIndex);
|
|
441
|
+
doc.unchecked.insertCard(card, atIndex);
|
|
442
|
+
undo.withdraw();
|
|
424
443
|
const id = seq.next();
|
|
425
444
|
arm.arm();
|
|
426
445
|
cardIds = [...cardIds.slice(0, atIndex), id, ...cardIds.slice(atIndex)];
|
|
@@ -483,6 +502,7 @@
|
|
|
483
502
|
if (to < 0 || to >= doc.cardCount) return;
|
|
484
503
|
arm.arm();
|
|
485
504
|
doc.moveCard(from, to);
|
|
505
|
+
undo.withdraw();
|
|
486
506
|
const w = cardIds.slice();
|
|
487
507
|
const [x] = w.splice(from, 1);
|
|
488
508
|
w.splice(to, 0, x);
|
|
@@ -499,6 +519,12 @@
|
|
|
499
519
|
// pressed button, and the hand-on is the keyboard's.
|
|
500
520
|
const focused = document.activeElement;
|
|
501
521
|
const held = !!focused && !!slotEls[i]?.contains(focused) && focused.matches(':focus-visible');
|
|
522
|
+
const card = doc.card(i);
|
|
523
|
+
const shown = model.cards[i];
|
|
524
|
+
const name =
|
|
525
|
+
shown?.titleOverride ||
|
|
526
|
+
shown?.titlePlaceholder ||
|
|
527
|
+
kindTitle(quill.schema.card_kinds?.[card.kind], card.kind);
|
|
502
528
|
doc.removeCard(i);
|
|
503
529
|
arm.arm();
|
|
504
530
|
cardIds = cardIds.filter((_, k) => k !== i);
|
|
@@ -506,8 +532,35 @@
|
|
|
506
532
|
// No addr: the removed card has none left and every survivor's shifted. The
|
|
507
533
|
// stack changed, not a leaf, and the id is the only handle the removal leaves.
|
|
508
534
|
bump('structure', id, undefined, { op: 'remove', at: i });
|
|
535
|
+
undo.offer(merged.undoRemoved(name), () => restoreCard(card, i));
|
|
509
536
|
if (held) void focusAfterRemove(i);
|
|
510
537
|
}
|
|
538
|
+
/** The removal's undo: the card back at the index it left, under a fresh session key
|
|
539
|
+
* (ids are never reused), with the focus on its title. The document holds what it held
|
|
540
|
+
* before the removal, so the insert is the removal's exact inverse. */
|
|
541
|
+
function restoreCard(card: ReturnType<typeof doc.card>, at: number): void {
|
|
542
|
+
if (!span.alive) return;
|
|
543
|
+
const i = Math.min(at, cardIds.length);
|
|
544
|
+
try {
|
|
545
|
+
doc.unchecked.insertCard(card, i);
|
|
546
|
+
} catch (e) {
|
|
547
|
+
reportError(onError, {
|
|
548
|
+
code: 'card-op-failed',
|
|
549
|
+
severity: 'error',
|
|
550
|
+
message: `restoring the ${card.kind} card failed: ${errorMessage(e)}`,
|
|
551
|
+
cause: e
|
|
552
|
+
});
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
const id = seq.next();
|
|
556
|
+
arm.arm();
|
|
557
|
+
cardIds = [...cardIds.slice(0, i), id, ...cardIds.slice(i)];
|
|
558
|
+
bump('structure', id, i, { op: 'insert', at: i });
|
|
559
|
+
void (async () => {
|
|
560
|
+
if (!(await scrollCardIntoView(id, 'nearest'))) return;
|
|
561
|
+
cardRefs[cardIndexOf(id)]?.focusHeader();
|
|
562
|
+
})();
|
|
563
|
+
}
|
|
511
564
|
/** Drop what the surface holds for a removed card. Ids are never reused, so an entry
|
|
512
565
|
* keyed to the gone card is unreachable rather than mis-attributed to whichever card
|
|
513
566
|
* takes this position: it needs dropping because nothing else will ever clear it. */
|
|
@@ -527,6 +580,7 @@
|
|
|
527
580
|
if (!(await span.resumes(tick()))) return;
|
|
528
581
|
if (cardIds.length) cardRefs[Math.max(at - 1, 0)]?.focusHeader();
|
|
529
582
|
else rootEl?.querySelector<HTMLElement>('.qm-add-btn')?.focus();
|
|
583
|
+
undo.hand(document.activeElement);
|
|
530
584
|
}
|
|
531
585
|
function retypeCardById(id: string, kind: string): void {
|
|
532
586
|
const i = cardIndexOf(id);
|
|
@@ -537,10 +591,11 @@
|
|
|
537
591
|
// it validates the whole card before it mutates, so the document is as it was.
|
|
538
592
|
const card = doc.card(i);
|
|
539
593
|
doc.removeCard(i);
|
|
594
|
+
undo.withdraw();
|
|
540
595
|
try {
|
|
541
|
-
doc.insertCard({ ...card, kind }, i);
|
|
596
|
+
doc.unchecked.insertCard({ ...card, kind }, i);
|
|
542
597
|
} catch (e) {
|
|
543
|
-
doc.insertCard(card, i);
|
|
598
|
+
doc.unchecked.insertCard(card, i);
|
|
544
599
|
throw e;
|
|
545
600
|
}
|
|
546
601
|
bump('structure', id, i);
|
|
@@ -895,6 +950,7 @@
|
|
|
895
950
|
* order it applied them, so every card that stays keeps its leaves. */
|
|
896
951
|
export function applyCardOps(ops: readonly CardOp[]): void {
|
|
897
952
|
if (!span.alive) return;
|
|
953
|
+
undo.withdraw();
|
|
898
954
|
const ids = cardIds.slice();
|
|
899
955
|
for (const op of ops) {
|
|
900
956
|
if (op.op === 'insert') ids.splice(op.at, 0, seq.next());
|
|
@@ -964,6 +1020,8 @@
|
|
|
964
1020
|
}
|
|
965
1021
|
</script>
|
|
966
1022
|
|
|
1023
|
+
<svelte:document onkeydowncapture={onUndoKey} />
|
|
1024
|
+
|
|
967
1025
|
<!-- The keydown is a control's, bubbled: the root resolves which description it raises. -->
|
|
968
1026
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
969
1027
|
<div
|
|
@@ -1028,6 +1086,29 @@
|
|
|
1028
1086
|
{@render addAffordance(i + 1)}
|
|
1029
1087
|
</div>
|
|
1030
1088
|
{/each}
|
|
1089
|
+
<!-- The removal's undo. The region stands empty between offers so the notice it takes is
|
|
1090
|
+
announced: a live region inserted along with its text is one a reader may not hear. -->
|
|
1091
|
+
<div class="qm-toast-slot" role="status">
|
|
1092
|
+
{#if undo.current}
|
|
1093
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
1094
|
+
<!-- The handlers hold the lapse while the toast is in use and add no interaction. -->
|
|
1095
|
+
<div
|
|
1096
|
+
class="qm-toast"
|
|
1097
|
+
onpointerenter={() => undo.pause()}
|
|
1098
|
+
onpointerleave={() => undo.resume()}
|
|
1099
|
+
onfocusin={() => undo.pause()}
|
|
1100
|
+
onfocusout={() => undo.resume()}
|
|
1101
|
+
>
|
|
1102
|
+
<span class="qm-toast-notice">{undo.current.notice}</span>
|
|
1103
|
+
<button
|
|
1104
|
+
type="button"
|
|
1105
|
+
class="qm-toast-action qm-focus-ring"
|
|
1106
|
+
aria-keyshortcuts="Meta+Z Control+Z"
|
|
1107
|
+
onclick={() => undo.take()}>{merged.undoAction}</button
|
|
1108
|
+
>
|
|
1109
|
+
</div>
|
|
1110
|
+
{/if}
|
|
1111
|
+
</div>
|
|
1031
1112
|
</div>
|
|
1032
1113
|
|
|
1033
1114
|
<FormatPopover {getActiveLeaf} families={fontFamilies} {fontLabels} />
|
|
@@ -1099,6 +1180,47 @@
|
|
|
1099
1180
|
{/snippet}
|
|
1100
1181
|
|
|
1101
1182
|
<style>
|
|
1183
|
+
/* Pinned to the foot of whatever scrolls the surface, and taking no room in the stack:
|
|
1184
|
+
zero tall, its gap handed back, so an offer raises a toast over the cards without
|
|
1185
|
+
moving one. */
|
|
1186
|
+
.qm-toast-slot {
|
|
1187
|
+
position: sticky;
|
|
1188
|
+
bottom: var(--toast-foot, var(--_qm-space-3));
|
|
1189
|
+
z-index: 1;
|
|
1190
|
+
display: flex;
|
|
1191
|
+
justify-content: center;
|
|
1192
|
+
align-items: flex-end;
|
|
1193
|
+
height: 0;
|
|
1194
|
+
margin-top: calc(-1 * var(--_qm-space-2));
|
|
1195
|
+
pointer-events: none;
|
|
1196
|
+
}
|
|
1197
|
+
.qm-toast {
|
|
1198
|
+
display: flex;
|
|
1199
|
+
align-items: center;
|
|
1200
|
+
gap: var(--_qm-space-3);
|
|
1201
|
+
padding: var(--_qm-space) var(--_qm-space) var(--_qm-space) var(--_qm-space-3);
|
|
1202
|
+
border: var(--_qm-border-width) solid var(--_qm-border);
|
|
1203
|
+
border-radius: var(--_qm-radius-pill);
|
|
1204
|
+
background: var(--_qm-surface-raised);
|
|
1205
|
+
box-shadow: var(--_qm-lift);
|
|
1206
|
+
font-size: var(--_qm-text-label);
|
|
1207
|
+
color: var(--_qm-ink);
|
|
1208
|
+
pointer-events: auto;
|
|
1209
|
+
}
|
|
1210
|
+
.qm-toast-action {
|
|
1211
|
+
min-height: var(--_qm-tap-min);
|
|
1212
|
+
padding-inline: var(--_qm-space-2);
|
|
1213
|
+
border: 0;
|
|
1214
|
+
border-radius: var(--_qm-radius-pill);
|
|
1215
|
+
background: transparent;
|
|
1216
|
+
font: inherit;
|
|
1217
|
+
font-weight: var(--_qm-weight-strong);
|
|
1218
|
+
color: var(--_qm-accent);
|
|
1219
|
+
cursor: pointer;
|
|
1220
|
+
}
|
|
1221
|
+
.qm-toast-action:hover {
|
|
1222
|
+
background: var(--_qm-accent-tint);
|
|
1223
|
+
}
|
|
1102
1224
|
/* A detached root, carrying `data-qm-root` for the derivation core/theme.css applies
|
|
1103
1225
|
to one — the baseline font and colour included, so nothing here restates them.
|
|
1104
1226
|
|
|
@@ -1164,6 +1286,10 @@
|
|
|
1164
1286
|
overscroll-behavior: contain;
|
|
1165
1287
|
padding: var(--_qm-space-4);
|
|
1166
1288
|
padding-block-end: var(--_qm-tail);
|
|
1289
|
+
/* The pane is the toast's scroller, and a sticky box stops at its scroller's
|
|
1290
|
+
padding: the tail would hold the toast a tail's height off the pane's foot. On a
|
|
1291
|
+
page the viewport scrolls, and the surface's padding is no bar. */
|
|
1292
|
+
--toast-foot: calc(var(--_qm-space-3) - var(--_qm-tail));
|
|
1167
1293
|
}
|
|
1168
1294
|
/* The stack's one gapless seam, which `TipsCard` draws and this holds the two
|
|
1169
1295
|
blocks to. `main` has to paint over the tip: a later sibling paints over an earlier
|
|
@@ -1214,8 +1340,8 @@
|
|
|
1214
1340
|
`.qm-tap-floor`'s (controls.css); what it overhangs is the card's own inset above and
|
|
1215
1341
|
below, which holds no target, so the floor costs a neighbour nothing.
|
|
1216
1342
|
|
|
1217
|
-
|
|
1218
|
-
the trigger arrives and leaves on opacity, and a tone moving under an opacity already
|
|
1343
|
+
A gap's ink is pinned to the label tone in every state, taking back the family's hover
|
|
1344
|
+
step: the trigger arrives and leaves on opacity, and a tone moving under an opacity already
|
|
1219
1345
|
moving reads as two trips at different speeds.
|
|
1220
1346
|
|
|
1221
1347
|
`:global`, because the multi-kind trigger is bits-ui's own element and a `class`
|
|
@@ -1233,13 +1359,22 @@
|
|
|
1233
1359
|
opacity var(--_qm-duration-fast) var(--_qm-ease-reverse),
|
|
1234
1360
|
background-color var(--_qm-duration-fast) var(--_qm-ease-reverse);
|
|
1235
1361
|
}
|
|
1236
|
-
/* The
|
|
1237
|
-
|
|
1362
|
+
/* The append point is the one strip read at rest, so it is a pill sized to its words
|
|
1363
|
+
at the ink, outlined by the well's hairline rather than dashed: the document's main
|
|
1364
|
+
structural action stands as plainly as the controls inside a card. */
|
|
1365
|
+
.qm-add-card-marked {
|
|
1366
|
+
justify-content: center;
|
|
1367
|
+
}
|
|
1238
1368
|
.qm-add-card-marked :global(.qm-add-btn) {
|
|
1369
|
+
width: auto;
|
|
1239
1370
|
height: var(--_qm-tap-min);
|
|
1371
|
+
padding-inline: var(--_qm-space-3);
|
|
1240
1372
|
font-size: var(--_qm-text-label);
|
|
1241
1373
|
font-weight: var(--_qm-weight-mid);
|
|
1242
|
-
|
|
1374
|
+
color: var(--_qm-ink);
|
|
1375
|
+
background: var(--_qm-surface);
|
|
1376
|
+
box-shadow: inset 0 0 0 var(--_qm-border-width) var(--_qm-well-edge);
|
|
1377
|
+
opacity: 1;
|
|
1243
1378
|
}
|
|
1244
1379
|
/* One arrival, three ways in. Keyboard focus, because the fill is the only thing that
|
|
1245
1380
|
reads as the trigger on a bare strip; and an open menu, because it portals out of
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type DocPath, type Landing } from '../core/address.js';
|
|
2
|
-
import type { Delta } from '@quillmark/wasm';
|
|
3
2
|
import type { VisualEditorProps } from './props.js';
|
|
3
|
+
import type { Delta } from '../core/codec/positions.js';
|
|
4
4
|
import type { CardId, CardOp } from './signals.js';
|
|
5
5
|
import { type ActiveProse } from './leaves.js';
|
|
6
6
|
declare const VisualEditorInner: import("svelte").Component<VisualEditorProps, {
|
package/dist/visual/controls.css
CHANGED
|
@@ -90,15 +90,25 @@
|
|
|
90
90
|
color: var(--_qm-ink);
|
|
91
91
|
caret-color: currentColor;
|
|
92
92
|
}
|
|
93
|
-
/* The box is
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
/* The box is the well rung with a hairline inside it (ARCHITECTURE §Styling): a
|
|
94
|
+
field is a hole cut into the card, and the edge is what finds it at a glance, the
|
|
95
|
+
fill alone standing too close to the card to. Inset, so the edge costs no layout
|
|
96
|
+
and a focus ring draws outside it. */
|
|
96
97
|
:where(.qm-control-box),
|
|
97
98
|
:where(.qm-input) {
|
|
98
99
|
padding: var(--_qm-inset-control);
|
|
99
100
|
border: none;
|
|
100
101
|
border-radius: var(--_qm-radius-inner);
|
|
101
102
|
background: var(--_qm-surface-well);
|
|
103
|
+
box-shadow: inset 0 0 0 var(--_qm-border-width) var(--_qm-well-edge);
|
|
104
|
+
}
|
|
105
|
+
/* A control with an error drawn under it takes the danger hue on its edge and in its
|
|
106
|
+
fill, so the field the message is about is the one that changed. The message stays
|
|
107
|
+
beside it: colour is never the whole of the state. */
|
|
108
|
+
:where(.qm-field-stack:has(> .qm-diag-list) .qm-control-box),
|
|
109
|
+
:where(.qm-prop-stack:has(> .qm-diag-list) .qm-control-box) {
|
|
110
|
+
box-shadow: inset 0 0 0 var(--_qm-ring-width) var(--_qm-danger);
|
|
111
|
+
background-image: linear-gradient(var(--_qm-danger-tint), var(--_qm-danger-tint));
|
|
102
112
|
}
|
|
103
113
|
/* What a form control adds over the box: it does not fill its row on its own. */
|
|
104
114
|
:where(.qm-input) {
|
|
@@ -296,21 +306,30 @@
|
|
|
296
306
|
of one takes (`--cols-half`) land on a track boundary. A field ends on its track's
|
|
297
307
|
own edge, so a rung is `n * 220px + gaps`. A subform three rungs in stands three
|
|
298
308
|
`--_qm-nest` and three verticals narrower than its section, and steps down where the
|
|
299
|
-
section does not: the count is the width the tracks actually get.
|
|
309
|
+
section does not: the count is the width the tracks actually get.
|
|
310
|
+
|
|
311
|
+
The two tails are where a run's last cell takes the row (`RunTail`, `placeFields`): the
|
|
312
|
+
placement a capacity leaves it alone in, so it spans there and shares a row elsewhere. */
|
|
300
313
|
:where(.qm-tracks) {
|
|
301
314
|
--cols: 1;
|
|
302
315
|
--cols-half: 1;
|
|
316
|
+
--tail-odd: span 1;
|
|
317
|
+
--tail-lone: span 1;
|
|
303
318
|
}
|
|
304
319
|
@container (min-width: 28rem) {
|
|
305
320
|
:where(.qm-tracks) {
|
|
306
321
|
--cols: 2;
|
|
307
322
|
--cols-half: 1;
|
|
323
|
+
--tail-odd: 1 / -1;
|
|
324
|
+
--tail-lone: 1 / -1;
|
|
308
325
|
}
|
|
309
326
|
}
|
|
310
327
|
@container (min-width: 57rem) {
|
|
311
328
|
:where(.qm-tracks) {
|
|
312
329
|
--cols: 4;
|
|
313
330
|
--cols-half: 2;
|
|
331
|
+
--tail-odd: span 1;
|
|
332
|
+
--tail-lone: 1 / -1;
|
|
314
333
|
}
|
|
315
334
|
}
|
|
316
335
|
|
|
@@ -420,3 +439,22 @@
|
|
|
420
439
|
transform: scale(0.94);
|
|
421
440
|
}
|
|
422
441
|
}
|
|
442
|
+
|
|
443
|
+
/* Forced colours drop every fill and shadow, which is every edge a field and a chip
|
|
444
|
+
draw here, and keep opacity, which would leave a resting control a ghost against a
|
|
445
|
+
system palette. The system's own strokes stand in for both. */
|
|
446
|
+
@media (forced-colors: active) {
|
|
447
|
+
:where(.qm-control-box),
|
|
448
|
+
:where(.qm-input) {
|
|
449
|
+
border: var(--_qm-border-width) solid CanvasText;
|
|
450
|
+
}
|
|
451
|
+
:where(.qm-chip),
|
|
452
|
+
:where(.qm-add-affordance) {
|
|
453
|
+
border: var(--_qm-border-width) solid ButtonText;
|
|
454
|
+
}
|
|
455
|
+
:where(.qm-icon-btn),
|
|
456
|
+
:where(.qm-add-affordance),
|
|
457
|
+
:where(.qm-chip) {
|
|
458
|
+
opacity: 1;
|
|
459
|
+
}
|
|
460
|
+
}
|
package/dist/visual/strings.d.ts
CHANGED
|
@@ -14,6 +14,13 @@ export interface VisualStrings extends TableChromeStrings, SlashStrings {
|
|
|
14
14
|
cardDelete: string;
|
|
15
15
|
/** The card-title input's accessible name. */
|
|
16
16
|
cardTitle: string;
|
|
17
|
+
/** A closed panel's header, spoken after its name (`Layout, has an issue`) when a field
|
|
18
|
+
* inside holds a diagnostic: the leading separator is part of the wording. */
|
|
19
|
+
groupFlagged: string;
|
|
20
|
+
/** The toast's notice, named for what went: `Authors 2 removed`. */
|
|
21
|
+
undoRemoved: (what: string) => string;
|
|
22
|
+
/** The toast's button, which puts it back. */
|
|
23
|
+
undoAction: string;
|
|
17
24
|
/** The trailing strip's visible words, drawn after a `+`, and every
|
|
18
25
|
* strip's accessible name. One string over
|
|
19
26
|
* one kind and many: the trigger seeds a card, and which kind is the menu's word
|
|
@@ -42,16 +49,25 @@ export interface VisualStrings extends TableChromeStrings, SlashStrings {
|
|
|
42
49
|
*/
|
|
43
50
|
textCount: (count: number, max: number) => string;
|
|
44
51
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
|
|
52
|
+
* An `object` array element's title, open or collapsed: the 1-based index, the label
|
|
53
|
+
* standing over the list already. Parametric, so word order stays the translator's.
|
|
54
|
+
*/
|
|
55
|
+
elementItem: (index: number) => string;
|
|
56
|
+
/**
|
|
57
|
+
* An `object` array element's accessible name: the label and {@link elementItem},
|
|
58
|
+
* so the words the row draws are inside the name it is spoken by.
|
|
48
59
|
*/
|
|
49
60
|
elementUntitled: (label: string, index: number) => string;
|
|
50
|
-
/**
|
|
51
|
-
|
|
61
|
+
/** `validation::type_mismatch`: the value is not the declared type (`args.expected`). */
|
|
62
|
+
diagTypeMismatch: (expected: string) => string;
|
|
63
|
+
/** `validation::format_violation`: the value misses a string format (`args.format`). */
|
|
64
|
+
diagFormatViolation: (format: string) => string;
|
|
65
|
+
/** The tag on the `default:` member's row ({@link EnumField}). */
|
|
52
66
|
enumUnsetTag: string;
|
|
53
|
-
/** The
|
|
54
|
-
|
|
67
|
+
/** The row under a stored value that clears it back to the `default:`. */
|
|
68
|
+
enumReset: string;
|
|
69
|
+
/** The same row where no `default:` prints: no `default:`, a blank one, or an `enum?`. */
|
|
70
|
+
enumClear: string;
|
|
55
71
|
/** The count in the matrix's label row: how many of its items are held. */
|
|
56
72
|
matrixHeld: (held: number, total: number) => string;
|
|
57
73
|
/** An open matrix's add box at rest, naming the list it adds to: `Add to Staff…`. The box
|
|
@@ -182,6 +198,7 @@ export declare function setWording(channel: Wording): void;
|
|
|
182
198
|
* composing one directly) still has every key.
|
|
183
199
|
*/
|
|
184
200
|
export declare function wording(): Wording;
|
|
185
|
-
/** A diagnostic's displayed text: the consumer's formatter,
|
|
186
|
-
*
|
|
187
|
-
|
|
201
|
+
/** A diagnostic's displayed text: the consumer's formatter, else the package's wording for
|
|
202
|
+
* a validation code whose `args` carry what it needs, else its message. The last arm is
|
|
203
|
+
* permanent, not a courtesy ({@link FormatDiagnostic}). */
|
|
204
|
+
export declare function diagnosticText(d: Diagnostic, format: FormatDiagnostic | undefined, strings?: VisualStrings): string;
|
package/dist/visual/strings.js
CHANGED
|
@@ -39,6 +39,9 @@ export const DEFAULT_VISUAL_STRINGS = {
|
|
|
39
39
|
cardMoveDown: 'Move down',
|
|
40
40
|
cardDelete: 'Delete card',
|
|
41
41
|
cardTitle: 'Card title',
|
|
42
|
+
groupFlagged: ', has an issue',
|
|
43
|
+
undoRemoved: (what) => `${what} removed`,
|
|
44
|
+
undoAction: 'Undo',
|
|
42
45
|
addCard: 'Add Card',
|
|
43
46
|
arrayAdd: '+ Add',
|
|
44
47
|
arrayRemove: 'Remove',
|
|
@@ -46,9 +49,23 @@ export const DEFAULT_VISUAL_STRINGS = {
|
|
|
46
49
|
arrayRowAction: (action, row) => `${action} ${row}`,
|
|
47
50
|
arrayCount: (count, max) => `${count} / ${max}`,
|
|
48
51
|
textCount: (count, max) => `${count} / ${max}`,
|
|
49
|
-
|
|
52
|
+
elementItem: (index) => `Item ${index}`,
|
|
53
|
+
elementUntitled: (label, index) => `${label}, item ${index}`,
|
|
54
|
+
diagTypeMismatch: (expected) => expected === 'boolean'
|
|
55
|
+
? 'Needs to be on or off.'
|
|
56
|
+
: expected === 'integer'
|
|
57
|
+
? 'Needs a whole number, like 12.'
|
|
58
|
+
: expected === 'number'
|
|
59
|
+
? 'Needs a number, like 12.'
|
|
60
|
+
: `Needs a ${expected} value.`,
|
|
61
|
+
diagFormatViolation: (format) => format === 'date'
|
|
62
|
+
? 'Not a real date. Type it as YYYY-MM-DD, or press Today.'
|
|
63
|
+
: format === 'datetime'
|
|
64
|
+
? 'Not a real date and time. Type it as YYYY-MM-DDTHH:MM.'
|
|
65
|
+
: `Doesn't match the ${format} format.`,
|
|
50
66
|
enumUnsetTag: 'Default',
|
|
51
|
-
|
|
67
|
+
enumReset: 'Reset to default',
|
|
68
|
+
enumClear: 'Clear',
|
|
52
69
|
matrixHeld: (held, total) => `${held} of ${total} held`,
|
|
53
70
|
matrixAdd: (list) => (list ? `Add to ${list}…` : 'Add…'),
|
|
54
71
|
matrixItemTitle: (list, index) => `${list ? `${list} item` : 'Item'} ${index}`,
|
|
@@ -102,8 +119,25 @@ export function setWording(channel) {
|
|
|
102
119
|
export function wording() {
|
|
103
120
|
return (getContext(KEY) ?? { strings: DEFAULT_VISUAL_STRINGS, formatDiagnostic: undefined });
|
|
104
121
|
}
|
|
105
|
-
/** A diagnostic's displayed text: the consumer's formatter,
|
|
106
|
-
*
|
|
107
|
-
|
|
108
|
-
|
|
122
|
+
/** A diagnostic's displayed text: the consumer's formatter, else the package's wording for
|
|
123
|
+
* a validation code whose `args` carry what it needs, else its message. The last arm is
|
|
124
|
+
* permanent, not a courtesy ({@link FormatDiagnostic}). */
|
|
125
|
+
export function diagnosticText(d, format, strings) {
|
|
126
|
+
return (format ? format(d) : undefined) ?? (strings && builtIn(d, strings)) ?? d.message;
|
|
127
|
+
}
|
|
128
|
+
function builtIn(d, strings) {
|
|
129
|
+
const args = (d.args ?? {});
|
|
130
|
+
const str = (k) => typeof args[k] === 'string' ? args[k] : undefined;
|
|
131
|
+
switch (d.code) {
|
|
132
|
+
case 'validation::type_mismatch': {
|
|
133
|
+
const expected = str('expected');
|
|
134
|
+
return expected ? strings.diagTypeMismatch(expected) : undefined;
|
|
135
|
+
}
|
|
136
|
+
case 'validation::format_violation': {
|
|
137
|
+
const format = str('format');
|
|
138
|
+
return format ? strings.diagFormatViolation(format) : undefined;
|
|
139
|
+
}
|
|
140
|
+
default:
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
109
143
|
}
|
|
@@ -248,11 +248,9 @@ export declare function matrixMemberSchema(matrix: QuillFieldSchema, id: string)
|
|
|
248
248
|
*/
|
|
249
249
|
export declare function schemaAt(field: QuillFieldSchema, steps: readonly PathStep[]): QuillFieldSchema | undefined;
|
|
250
250
|
/**
|
|
251
|
-
* Whether a cell is one line tall by declaration: what a table column
|
|
251
|
+
* Whether a cell is one line tall by declaration: what a table column can hold.
|
|
252
252
|
*/
|
|
253
253
|
export declare function shortCell(sub: QuillFieldSchema): boolean;
|
|
254
|
-
/** A collapsed row's own words ({@link firstShortText}). */
|
|
255
|
-
export declare function rowSummary(items: QuillFieldSchema | undefined, row: unknown): string | undefined;
|
|
256
254
|
/** How an `array` draws its elements. */
|
|
257
255
|
export type ArrayLayout = 'list' | 'table';
|
|
258
256
|
/**
|
|
@@ -314,27 +312,37 @@ export declare function objectSections(fields: FieldModel[]): GroupSection[];
|
|
|
314
312
|
*/
|
|
315
313
|
export declare function cardSections(cardSchema: QuillCardSchema): GroupSection[];
|
|
316
314
|
/**
|
|
317
|
-
* The group section a card
|
|
315
|
+
* The group section a card opens on first mount, or `null` when the card declares none.
|
|
318
316
|
* All-collapsed would disclose nothing of what is behind the chevrons, and a rule keyed on document
|
|
319
317
|
* state would move the opening under a user as they fill.
|
|
320
318
|
*/
|
|
321
319
|
export declare function initialExpandedGroup(sections: GroupSection[]): string | null;
|
|
322
320
|
/** How wide a field sits in its section grid. */
|
|
323
321
|
export type FieldSpan = 'cell' | 'full';
|
|
322
|
+
/**
|
|
323
|
+
* Where a run's last cell would stand alone in its row, by capacity: `odd` at two tracks
|
|
324
|
+
* (an odd run), `lone` at two and four (a run one past a multiple of four). The grid
|
|
325
|
+
* reads it against the capacity it stands at (`--tail-odd`, `--tail-lone`, the ladder in
|
|
326
|
+
* controls.css), so the field takes the row only where it would be alone in it.
|
|
327
|
+
*/
|
|
328
|
+
export type RunTail = 'odd' | 'lone';
|
|
324
329
|
export interface PlacedField {
|
|
325
330
|
field: FieldModel;
|
|
326
331
|
span: FieldSpan;
|
|
332
|
+
tail?: RunTail;
|
|
327
333
|
}
|
|
328
334
|
/**
|
|
329
|
-
* Consecutive packable fields are `cell`s the grid auto-places
|
|
330
|
-
*
|
|
331
|
-
* empty.
|
|
335
|
+
* Consecutive packable fields are `cell`s the grid auto-places, and a run of one is `full`:
|
|
336
|
+
* alone, a field would stand in a narrow track that reads as truncated against the width it
|
|
337
|
+
* leaves empty. A longer run's last cell carries its `tail`, which the grid spends at the
|
|
338
|
+
* capacity it stands at, so the last of three spans the row at two tracks and shares it at
|
|
339
|
+
* four. Everything else is `full`. No width is measured.
|
|
332
340
|
*/
|
|
333
341
|
export declare function placeFields(fields: FieldModel[]): PlacedField[];
|
|
334
342
|
/** A card's field values by key, off its payload items. */
|
|
335
343
|
export declare function fieldValues(items: readonly PayloadItem[]): Record<string, unknown>;
|
|
336
|
-
/** A field value as title text. A
|
|
337
|
-
*
|
|
344
|
+
/** A field value as title text. A text field rests as the authored string or as
|
|
345
|
+
* `Content`, whose `text` is the same words; a scalar reads as
|
|
338
346
|
* itself; a variant container reads as its discriminant member, the one cell of it
|
|
339
347
|
* that names the world; any other container as nothing. */
|
|
340
348
|
export declare function titleText(v: unknown): string;
|
package/dist/visual/structure.js
CHANGED
|
@@ -275,7 +275,7 @@ export function addedItems(matrix, map) {
|
|
|
275
275
|
const title = stored[MATRIX_TITLE];
|
|
276
276
|
if (title == null)
|
|
277
277
|
continue;
|
|
278
|
-
out.push({ id, title:
|
|
278
|
+
out.push({ id, title: titleText(title) });
|
|
279
279
|
}
|
|
280
280
|
return out.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
281
281
|
}
|
|
@@ -360,9 +360,9 @@ function stepInto(schema, step) {
|
|
|
360
360
|
return undefined;
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
|
-
// ──
|
|
363
|
+
// ── Short cells and layouts ──────────────────────────────────────────────────
|
|
364
364
|
/**
|
|
365
|
-
* Whether a cell is one line tall by declaration: what a table column
|
|
365
|
+
* Whether a cell is one line tall by declaration: what a table column can hold.
|
|
366
366
|
*/
|
|
367
367
|
export function shortCell(sub) {
|
|
368
368
|
const kind = controlKind(sub);
|
|
@@ -383,10 +383,6 @@ function firstShortText(cells, values) {
|
|
|
383
383
|
return undefined;
|
|
384
384
|
return titleText(own(values, named[0])).trim() || undefined;
|
|
385
385
|
}
|
|
386
|
-
/** A collapsed row's own words ({@link firstShortText}). */
|
|
387
|
-
export function rowSummary(items, row) {
|
|
388
|
-
return firstShortText(items?.properties, (row ?? {}));
|
|
389
|
-
}
|
|
390
386
|
/**
|
|
391
387
|
* The layout an array takes: `'table'` where the array's own `ui.layout` asks for it
|
|
392
388
|
* and every cell of the row is short (a block prose cell declines it, at load width and
|
|
@@ -544,7 +540,7 @@ export function cardSections(cardSchema) {
|
|
|
544
540
|
return [...panels, ...groupSections(grouped, order, (g) => groupLabel(cardSchema, g))];
|
|
545
541
|
}
|
|
546
542
|
/**
|
|
547
|
-
* The group section a card
|
|
543
|
+
* The group section a card opens on first mount, or `null` when the card declares none.
|
|
548
544
|
* All-collapsed would disclose nothing of what is behind the chevrons, and a rule keyed on document
|
|
549
545
|
* state would move the opening under a user as they fill.
|
|
550
546
|
*/
|
|
@@ -580,18 +576,25 @@ function packable(f) {
|
|
|
580
576
|
return f.control !== 'prose' || f.inline;
|
|
581
577
|
}
|
|
582
578
|
/**
|
|
583
|
-
* Consecutive packable fields are `cell`s the grid auto-places
|
|
584
|
-
*
|
|
585
|
-
* empty.
|
|
579
|
+
* Consecutive packable fields are `cell`s the grid auto-places, and a run of one is `full`:
|
|
580
|
+
* alone, a field would stand in a narrow track that reads as truncated against the width it
|
|
581
|
+
* leaves empty. A longer run's last cell carries its `tail`, which the grid spends at the
|
|
582
|
+
* capacity it stands at, so the last of three spans the row at two tracks and shares it at
|
|
583
|
+
* four. Everything else is `full`. No width is measured.
|
|
586
584
|
*/
|
|
587
585
|
export function placeFields(fields) {
|
|
588
586
|
const out = [];
|
|
589
587
|
let run = 0;
|
|
590
|
-
// A run
|
|
591
|
-
// field already placed.
|
|
588
|
+
// A run's length is only knowable at its end, so the span or tail is patched back onto
|
|
589
|
+
// the field already placed.
|
|
592
590
|
const flush = () => {
|
|
591
|
+
const last = out[out.length - 1];
|
|
593
592
|
if (run === 1)
|
|
594
|
-
|
|
593
|
+
last.span = 'full';
|
|
594
|
+
else if (run % 4 === 1)
|
|
595
|
+
last.tail = 'lone';
|
|
596
|
+
else if (run % 2 === 1)
|
|
597
|
+
last.tail = 'odd';
|
|
595
598
|
run = 0;
|
|
596
599
|
};
|
|
597
600
|
for (const f of fields) {
|
|
@@ -615,8 +618,8 @@ export function fieldValues(items) {
|
|
|
615
618
|
values[p.key] = p.value;
|
|
616
619
|
return values;
|
|
617
620
|
}
|
|
618
|
-
/** A field value as title text. A
|
|
619
|
-
*
|
|
621
|
+
/** A field value as title text. A text field rests as the authored string or as
|
|
622
|
+
* `Content`, whose `text` is the same words; a scalar reads as
|
|
620
623
|
* itself; a variant container reads as its discriminant member, the one cell of it
|
|
621
624
|
* that names the world; any other container as nothing. */
|
|
622
625
|
export function titleText(v) {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** How long an offer stands, in ms. Long enough to read the toast and reach its button;
|
|
2
|
+
* short enough that the toast is gone before the user has moved on to something else. */
|
|
3
|
+
export declare const OFFER_MS = 6000;
|
|
4
|
+
export interface UndoOffer {
|
|
5
|
+
/** What the toast says, already worded: `Item 2 removed`. */
|
|
6
|
+
readonly notice: string;
|
|
7
|
+
/** Put back what the removal took. Runs at most once. */
|
|
8
|
+
readonly restore: () => void;
|
|
9
|
+
}
|
|
10
|
+
export interface StructuralUndo {
|
|
11
|
+
/** The offer on show, if any. */
|
|
12
|
+
readonly current: UndoOffer | undefined;
|
|
13
|
+
/** Offer `restore` as the undo of the removal just made, replacing any standing offer. */
|
|
14
|
+
offer(notice: string, restore: () => void): void;
|
|
15
|
+
/** Name the control the removal handed the focus to. ⌘Z there is the offer's until the
|
|
16
|
+
* control takes an edit or the focus leaves it: the key that removed is the key that
|
|
17
|
+
* asks for it back, and the control has nothing of its own to undo yet. */
|
|
18
|
+
hand(el: Element | null): void;
|
|
19
|
+
/** Whether ⌘Z pressed at `target` is the offer's: the page's body, where a removal under
|
|
20
|
+
* the pointer leaves the focus, when this offer is the page's latest; the handed control; or a control under `root` that keeps
|
|
21
|
+
* no history of its own. A text control that is not the handed one keeps its key. */
|
|
22
|
+
accepts(target: EventTarget | null, root: Element | undefined): boolean;
|
|
23
|
+
/** Hold the lapse while the toast is under the pointer or the focus, and let it run again. */
|
|
24
|
+
pause(): void;
|
|
25
|
+
resume(): void;
|
|
26
|
+
/** Run the standing offer and clear it. False when there was none to run. */
|
|
27
|
+
take(): boolean;
|
|
28
|
+
/** Drop the standing offer without running it. */
|
|
29
|
+
withdraw(): void;
|
|
30
|
+
}
|
|
31
|
+
export declare function createStructuralUndo(): StructuralUndo & {
|
|
32
|
+
dispose(): void;
|
|
33
|
+
};
|
|
34
|
+
export declare function setStructuralUndo(undo: StructuralUndo): void;
|
|
35
|
+
/** The editor's undo, or {@link NO_UNDO} off-tree. */
|
|
36
|
+
export declare function structuralUndo(): StructuralUndo;
|