@quillmark/svelte 0.5.1 → 0.6.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.
Files changed (53) hide show
  1. package/README.md +6 -0
  2. package/THEMING.md +12 -16
  3. package/dist/core/address.d.ts +17 -3
  4. package/dist/core/address.js +20 -3
  5. package/dist/core/codec/blocks.d.ts +37 -0
  6. package/dist/core/codec/blocks.js +163 -0
  7. package/dist/core/codec/field.js +3 -5
  8. package/dist/core/codec/index.d.ts +1 -1
  9. package/dist/core/codec/index.js +3 -2
  10. package/dist/core/codec/inputrules.js +24 -144
  11. package/dist/core/codec/prose.css +14 -25
  12. package/dist/core/codec/schema.d.ts +8 -0
  13. package/dist/core/codec/schema.js +33 -1
  14. package/dist/core/codec/slash.d.ts +18 -16
  15. package/dist/core/codec/slash.js +0 -0
  16. package/dist/core/codec/table-view.js +127 -157
  17. package/dist/core/codec/table.d.ts +0 -10
  18. package/dist/core/codec/table.js +0 -15
  19. package/dist/core/theme.css +350 -344
  20. package/dist/preset/recipes.css +10 -17
  21. package/dist/preview/Preview.svelte +4 -2
  22. package/dist/preview/geometry.d.ts +10 -9
  23. package/dist/preview/geometry.js +11 -13
  24. package/dist/visual/ArrayField.svelte +242 -63
  25. package/dist/visual/ArrayField.svelte.d.ts +5 -1
  26. package/dist/visual/Card.svelte +21 -2
  27. package/dist/visual/EnumField.svelte +33 -1
  28. package/dist/visual/Field.svelte +28 -4
  29. package/dist/visual/FieldLabel.svelte +2 -2
  30. package/dist/visual/FormatPopover.svelte +13 -1
  31. package/dist/visual/ObjectField.svelte +157 -35
  32. package/dist/visual/ObjectField.svelte.d.ts +13 -4
  33. package/dist/visual/ProseArrayElement.svelte +22 -2
  34. package/dist/visual/ProseArrayElement.svelte.d.ts +1 -0
  35. package/dist/visual/TipsCard.svelte +33 -13
  36. package/dist/visual/VariantField.svelte +98 -0
  37. package/dist/visual/VariantField.svelte.d.ts +21 -0
  38. package/dist/visual/VisualEditorInner.svelte +15 -10
  39. package/dist/visual/controls.css +282 -283
  40. package/dist/visual/diagnostics.d.ts +13 -11
  41. package/dist/visual/diagnostics.js +11 -9
  42. package/dist/visual/domid.d.ts +13 -0
  43. package/dist/visual/domid.js +16 -0
  44. package/dist/visual/leaves.d.ts +9 -7
  45. package/dist/visual/links.d.ts +5 -2
  46. package/dist/visual/links.js +9 -3
  47. package/dist/visual/strings.d.ts +15 -0
  48. package/dist/visual/strings.js +3 -0
  49. package/dist/visual/structure.d.ts +32 -6
  50. package/dist/visual/structure.js +49 -3
  51. package/package.json +2 -2
  52. package/dist/core/codec/clipboard.d.ts +0 -59
  53. package/dist/core/codec/clipboard.js +0 -202
@@ -0,0 +1,98 @@
1
+ <!--
2
+ An `enum` declaring `variants:` → the discriminant's select, and under it the cells
3
+ the chosen world brings into play (VISUAL_EDITOR §"Enum variants"). The field rests as
4
+ a container, `{value: <member>, …that member's fields}`, and commits whole: it is one
5
+ cell to `Addr`, so there is no per-cell write address.
6
+
7
+ The cells are {@link ObjectField}, which already draws a scalar field set keyed by
8
+ name over a container its parent commits by value. It takes the whole container as its
9
+ `value` and the world's declaration as its `properties`, so what it hands back is the
10
+ container with one cell written — and cells outside the drawn world ride through
11
+ untouched rather than needing to be merged back.
12
+ -->
13
+ <script lang="ts">
14
+ import type { QuillFieldSchema } from '@quillmark/wasm';
15
+ import EnumField from './EnumField.svelte';
16
+ import ObjectField from './ObjectField.svelte';
17
+ import {
18
+ VARIANT_DISCRIMINANT,
19
+ commitDiscriminant,
20
+ variantCells,
21
+ variantMember
22
+ } from './structure.js';
23
+
24
+ interface Props {
25
+ /** The stored container, or undefined while the field is unset. */
26
+ value: Record<string, unknown> | undefined;
27
+ schema: QuillFieldSchema;
28
+ /** The resolved `default:`'s member: what an unset field renders as. */
29
+ ghostMember: string | undefined;
30
+ /** Field label, the naming prefix the cells' controls compose with. */
31
+ label: string;
32
+ /** `<label for>` target: the discriminant trigger, this control's one labelable
33
+ * element. The cells are named by their own composed labels. */
34
+ id?: string;
35
+ labelledBy?: string;
36
+ describedBy?: string;
37
+ onCommit: (v: Record<string, unknown> | undefined) => void;
38
+ optionAllowed?: (value: string) => boolean;
39
+ enumDisallowed?: 'hide' | 'disable';
40
+ }
41
+ let {
42
+ value,
43
+ schema,
44
+ ghostMember,
45
+ label,
46
+ id,
47
+ labelledBy,
48
+ describedBy,
49
+ onCommit,
50
+ optionAllowed,
51
+ enumDisallowed
52
+ }: Props = $props();
53
+
54
+ const member = $derived(variantMember(value, ghostMember));
55
+ const cells = $derived(variantCells(schema, member));
56
+ const discriminant = $derived(value?.[VARIANT_DISCRIMINANT] as string | undefined);
57
+ </script>
58
+
59
+ <div class="qm-variant">
60
+ <EnumField
61
+ value={discriminant}
62
+ values={schema.values ?? []}
63
+ fallback={ghostMember}
64
+ {id}
65
+ {describedBy}
66
+ onCommit={(v) => onCommit(commitDiscriminant(value, v))}
67
+ {optionAllowed}
68
+ {enumDisallowed}
69
+ />
70
+ <!-- Keyed on the member so a flip remounts the cells rather than re-targeting
71
+ them: two worlds' cells are different fields that happen to occupy one place,
72
+ and a control carrying local state (an unreconciled pick, a caret) across the
73
+ flip would carry it between them. -->
74
+ {#if cells}
75
+ {#key member}
76
+ <!-- `close`: the discriminant's box directly above IS the cells' top boundary,
77
+ so the band's opening stroke would state it twice. -->
78
+ <ObjectField
79
+ value={value ?? {}}
80
+ properties={cells}
81
+ {label}
82
+ idBase={id}
83
+ {labelledBy}
84
+ {describedBy}
85
+ edges="close"
86
+ onCommit={(obj) => onCommit(obj)}
87
+ />
88
+ {/key}
89
+ {/if}
90
+ </div>
91
+
92
+ <style>
93
+ .qm-variant {
94
+ display: flex;
95
+ flex-direction: column;
96
+ gap: var(--_qm-space-2);
97
+ }
98
+ </style>
@@ -0,0 +1,21 @@
1
+ import type { QuillFieldSchema } from '@quillmark/wasm';
2
+ interface Props {
3
+ /** The stored container, or undefined while the field is unset. */
4
+ value: Record<string, unknown> | undefined;
5
+ schema: QuillFieldSchema;
6
+ /** The resolved `default:`'s member: what an unset field renders as. */
7
+ ghostMember: string | undefined;
8
+ /** Field label, the naming prefix the cells' controls compose with. */
9
+ label: string;
10
+ /** `<label for>` target: the discriminant trigger, this control's one labelable
11
+ * element. The cells are named by their own composed labels. */
12
+ id?: string;
13
+ labelledBy?: string;
14
+ describedBy?: string;
15
+ onCommit: (v: Record<string, unknown> | undefined) => void;
16
+ optionAllowed?: (value: string) => boolean;
17
+ enumDisallowed?: 'hide' | 'disable';
18
+ }
19
+ declare const VariantField: import("svelte").Component<Props, {}, "">;
20
+ type VariantField = ReturnType<typeof VariantField>;
21
+ export default VariantField;
@@ -668,14 +668,15 @@
668
668
 
669
669
  /**
670
670
  * Put the caret in a revealed target, at the finest grain it can take: a USV offset
671
- * in a prose leaf, a bare focus everywhere else. An array element is no
672
- * `createField` leaf, and a form control has no coordinate to spend an offset in (an
673
- * `<input type="number">` refuses a selection outright), which is also the whole of
674
- * what a click on plate-placed ink can mean.
671
+ * in a prose leaf or an array element, a bare focus everywhere else. A form control
672
+ * has no coordinate to spend an offset in (an `<input type="number">` refuses a
673
+ * selection outright), which is also the whole of what a click on plate-placed ink
674
+ * can mean. An element is no `createField` leaf, so the offset goes down the element
675
+ * lane instead, where what it means is the row control's (`leaves.ts`).
675
676
  */
676
677
  function land(found: Landed, pos: number | undefined): void {
677
678
  if (found.element != null && found.control.focusElement) {
678
- return found.control.focusElement(found.element);
679
+ return found.control.focusElement(found.element, pos);
679
680
  }
680
681
  if (pos != null) {
681
682
  const prose = leaves.prose(found.key);
@@ -898,9 +899,13 @@
898
899
 
899
900
  The column, not only the cards in it: the gutter the stack sits in and the tone
900
901
  behind it are the surface's own, so a bare `<div>` is a mounting site and nothing
901
- is owed before the editor looks right. Consumer CSS is unlayered and beats all of
902
- it, which is how a host that wants the column back takes it. `border-box`, so a
903
- height from the caller is the height this draws.
902
+ is owed before the editor looks right. `border-box`, so a height from the caller is
903
+ the height this draws.
904
+
905
+ `:global(:where(…))` puts a promised class at zero rank, and both halves are
906
+ load-bearing: `:global` drops the scoping class, `:where` drops the rest
907
+ (ARCHITECTURE §Styling). The class is the surface's root wherever it mounts, so
908
+ leaving the component's scope costs nothing.
904
909
 
905
910
  The sunken rung, which is what makes a card an island: the cards are the base
906
911
  plane and this is the one they float on, so the gutter reads as ground rather
@@ -908,7 +913,7 @@
908
913
  ramp, which is what gives the ground enough of itself to read as ground: at a
909
914
  narrower one the stack meets whatever frames the surface and the islands are
910
915
  back to being one block clipped at its edges. */
911
- .qm-editor {
916
+ :global(:where(.qm-editor)) {
912
917
  box-sizing: border-box;
913
918
  display: flex;
914
919
  flex-direction: column;
@@ -933,7 +938,7 @@
933
938
  site with no height of its own, which is the page form kept. The cards do not
934
939
  shrink to fit: a flex item's automatic minimum floors each at its own height, so
935
940
  the stack overflows and scrolls rather than squashing. */
936
- .qm-editor.qm-pane {
941
+ :global(:where(.qm-editor.qm-pane)) {
937
942
  height: 100%;
938
943
  overflow: auto;
939
944
  overscroll-behavior: contain;