@quillmark/svelte 0.41.0 → 0.42.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 CHANGED
@@ -1,8 +1,8 @@
1
1
  # @quillmark/svelte
2
2
 
3
- Editor + live-preview components for [Quillmark](https://github.com/borb-sh/quillmark) WASM consumers. A WYSIWYG **VisualEditor**, and a canvas **Preview** that paints the compiled document and round-trips clicks to the editor, over one `@quillmark/wasm` session. Vanilla-TS cores with thin Svelte 5 wrappers.
3
+ Editor + live-preview components for [Quillmark](https://github.com/birdorbs/quillmark) WASM consumers. A WYSIWYG **VisualEditor**, and a canvas **Preview** that paints the compiled document and round-trips clicks to the editor, over one `@quillmark/wasm` session. Vanilla-TS cores with thin Svelte 5 wrappers.
4
4
 
5
- Quillmark is pre-1.0. Its [stability statement](https://github.com/borb-sh/quillmark#status) says what any release can change and what every release keeps.
5
+ Quillmark is pre-1.0. Its [stability statement](https://github.com/birdorbs/quillmark#status) says what any release can change and what every release keeps.
6
6
 
7
7
  ## Install
8
8
 
@@ -20,7 +20,7 @@ Each subpath is its own module root; a bundler pulls only what the entry you imp
20
20
  | --------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
21
21
  | `@quillmark/svelte/core` | What the surfaces share: the `DocPath`/`Place` address vocabulary, the `EditorError` channel, `init`. No UI framework. |
22
22
  | `@quillmark/svelte/preview` | The live preview: `createPreview` + `<Preview>`. Reaches nothing editor-side. |
23
- | `@quillmark/svelte/visual` | The federated WYSIWYG: `<VisualEditor>`, the codec's `createField` prose leaf. |
23
+ | `@quillmark/svelte/visual` | The federated WYSIWYG: `<VisualEditor>`. |
24
24
  | `@quillmark/svelte` | Re-exports `/core`. |
25
25
  | `@quillmark/svelte/preset` | The opt-in stylesheet for the page around a surface ([THEMING.md](THEMING.md)). |
26
26
 
@@ -235,7 +235,7 @@ While a review is open, `REVIEW_KEYS` answer the current item from anywhere on t
235
235
 
236
236
  ### Wording
237
237
 
238
- The package ships English and a seam to replace it. `strings` is keyed and **partial**: set what you have translations for, and the rest stay the package's. Several keys are **accessible names** rather than decoration (the card controls, the add trigger), so an untranslated surface reads the wrong language to a screen reader. A string is words alone: a glyph drawn beside it, the `+` on every add control, is the control's own. `DEFAULT_VISUAL_STRINGS` is the English, exported so you can compose against it. A control's name is the name alone: where it has a shortcut the editor prints the keys beside the name in the control's tooltip and states them as `aria-keyshortcuts`, both read off the binding, so a translation carries no chord. `<Preview>` takes its own `strings`: the states it shows when there is nothing to paint, the zoom pill's action, and what a screen reader hears: the names of the pane and each page, and the pages standing again after a state it was told of.
238
+ The package ships English and a seam to replace it. `strings` is keyed and **partial**: set what you have translations for, and the rest stay the package's. Several keys are **accessible names** rather than decoration (the card controls, the add trigger), so an untranslated surface reads the wrong language to a screen reader. A string is words alone: a glyph drawn beside it, the `+` on every add control, is the control's own. A control's name is the name alone: where it has a shortcut the editor prints the keys beside the name in the control's tooltip and states them as `aria-keyshortcuts`, both read off the binding, so a translation carries no chord. `<Preview>` takes its own `strings`: the states it shows when there is nothing to paint, the zoom pill's action, and what a screen reader hears: the names of the pane and each page, and the pages standing again after a state it was told of.
239
239
 
240
240
  ```svelte
241
241
  <VisualEditor
@@ -320,7 +320,7 @@ Both editor→preview hops or neither. A control reports its focus and no caret
320
320
 
321
321
  A pick carries a caret where the compile tracks the content under the point, and the field alone where it tracks only the placement — a scalar the plate prints without tracking. `setCaret` takes both: an absent `pos` reveals and focuses the field, which is the whole of what a click on plate-placed ink can mean. The address may name an array element (`main.keywords[0]`), which lands on that row.
322
322
 
323
- A consumer holding an `Addr` of its own maps it with `fieldPathForAddr` (from `@quillmark/svelte/core`). The playground app's split-pane route is the full reference shell: one session, both bridge directions, the preview following edits, and diagnostics routed inline.
323
+ A consumer holding an `Addr` of its own maps it with the Document's `pathFor`. The playground app's split-pane route is the full reference shell: one session, both bridge directions, the preview following edits, and diagnostics routed inline.
324
324
 
325
325
  ## Errors
326
326
 
@@ -1,5 +1,4 @@
1
1
  export { init } from './lifecycle.js';
2
2
  export type { DocPath, Landing, Place } from './address.js';
3
- export { fieldPathForAddr, addrForFieldPath } from './address.js';
4
3
  export type { Delta } from './codec/positions.js';
5
4
  export type { EditorError, EditorErrorCode, EditorErrorHandler } from './errors.js';
@@ -8,5 +8,3 @@
8
8
  // dev server serves a side-effect sheet as a module that writes a `<style>` into one. The surface
9
9
  // barrels carry the theme; `check:deps` holds it.
10
10
  export { init } from './lifecycle.js';
11
- // The hop between that vocabulary and the `Addr` the document verbs take.
12
- export { fieldPathForAddr, addrForFieldPath } from './address.js';
@@ -1,5 +1,4 @@
1
1
  export { createPreview } from './controller.js';
2
2
  export type { PreviewOptions, PreviewController } from './controller.js';
3
3
  export { default as Preview } from './Preview.svelte';
4
- export { DEFAULT_PREVIEW_STRINGS } from './strings.js';
5
4
  export type { PreviewStrings, PreviewStringsInput } from './strings.js';
@@ -5,4 +5,3 @@
5
5
  import '../core/theme.css';
6
6
  export { createPreview } from './controller.js';
7
7
  export { default as Preview } from './Preview.svelte';
8
- export { DEFAULT_PREVIEW_STRINGS } from './strings.js';
@@ -447,6 +447,7 @@
447
447
  type Subform = {
448
448
  focus: () => void;
449
449
  focusPath: (steps: readonly PathStep[], pos?: number) => LandingBox;
450
+ openPath: (steps: readonly PathStep[]) => Promise<void>;
450
451
  };
451
452
  const cellEls: Record<string, Subform | undefined> = $state({});
452
453
  let addEl: HTMLButtonElement | undefined = $state();
@@ -840,6 +841,19 @@
840
841
  else focusRow(id);
841
842
  return rowEls[id];
842
843
  }
844
+ /** Open the row `steps[0]` names where the walk goes on inside it, and the rows under it
845
+ * the rest names ({@link FieldControl.openPath}). A row's own address is drawn on its
846
+ * head, so it opens nothing. */
847
+ export async function openPath(steps: readonly PathStep[]): Promise<void> {
848
+ const [k, ...rest] = steps;
849
+ const id = typeof k === 'number' ? ids[k] : undefined;
850
+ if (id === undefined || !rest.length) return;
851
+ if (table) return cellEls[id]?.openPath(rest);
852
+ if (control !== 'object') return;
853
+ open.add(id);
854
+ if (!(await span.resumes(tick()))) return;
855
+ await objEls[id]?.openPath(rest);
856
+ }
843
857
  /** Focus element `id` after the flush, never in the same tick: a mutation commits
844
858
  * the array by value, so the parent re-derives and the row does not exist until
845
859
  * then. `undefined` is the empty list: the add affordance. `column` is a table
@@ -50,6 +50,7 @@ declare const ArrayField: import("svelte").Component<Props, {
50
50
  focus: () => void;
51
51
  washBox: () => HTMLElement | undefined;
52
52
  focusPath: (steps: readonly PathStep[], pos?: number) => LandingBox;
53
+ openPath: (steps: readonly PathStep[]) => Promise<void>;
53
54
  }, "">;
54
55
  type ArrayField = ReturnType<typeof ArrayField>;
55
56
  export default ArrayField;
@@ -244,6 +244,7 @@
244
244
  type Inside = {
245
245
  focus: () => void;
246
246
  focusPath: (steps: readonly PathStep[], pos?: number) => LandingBox;
247
+ openPath: (steps: readonly PathStep[]) => Promise<void>;
247
248
  washBox?: () => HTMLElement | undefined;
248
249
  };
249
250
  let proseEl = $state<{ focus: () => void } | undefined>();
@@ -264,6 +265,9 @@
264
265
  function focusPath(steps: readonly PathStep[], pos?: number): LandingBox {
265
266
  return inside()?.focusPath(steps, pos);
266
267
  }
268
+ async function openPath(steps: readonly PathStep[]): Promise<void> {
269
+ await inside()?.openPath(steps);
270
+ }
267
271
  // Only where `for` cannot reach; the labelable four are the browser's own, and a
268
272
  // second handler over them would be a focus the label already placed.
269
273
  const onActivate = $derived(labelable ? undefined : focusControl);
@@ -299,6 +303,7 @@
299
303
  registry.registerControl(key, {
300
304
  focus: focusControl,
301
305
  focusPath: isContainer(field.control) ? focusPath : undefined,
306
+ openPath: isContainer(field.control) ? openPath : undefined,
302
307
  get el() {
303
308
  return inside()?.washBox?.() ?? wrapper;
304
309
  }
@@ -201,6 +201,7 @@
201
201
  type Subform = {
202
202
  focus: () => void;
203
203
  focusPath: (steps: readonly PathStep[], pos?: number) => LandingBox;
204
+ openPath: (steps: readonly PathStep[]) => Promise<void>;
204
205
  };
205
206
  const memberEls: Record<string, HTMLElement | undefined> = $state({});
206
207
  const tickEls: Record<string, HTMLInputElement | undefined> = $state({});
@@ -348,6 +349,13 @@
348
349
  (own(tickEls, id) ?? own(titleEls, id))?.focus();
349
350
  return member;
350
351
  }
352
+ /** Open the collapsed rows under a held item's column ({@link FieldControl.openPath}):
353
+ * the item's details are drawn already while a proposal or a diagnostic names a cell. */
354
+ export async function openPath(steps: readonly PathStep[]): Promise<void> {
355
+ const [id, ...rest] = steps;
356
+ if (typeof id !== 'string' || !rest.length) return;
357
+ await own(colEls, id)?.openPath(rest);
358
+ }
351
359
  </script>
352
360
 
353
361
  <div
@@ -35,6 +35,7 @@ declare const MatrixField: import("svelte").Component<Props, {
35
35
  focus: () => void;
36
36
  washBox: () => HTMLElement | undefined;
37
37
  focusPath: (steps: readonly PathStep[], pos?: number) => LandingBox;
38
+ openPath: (steps: readonly PathStep[]) => Promise<void>;
38
39
  }, "">;
39
40
  type MatrixField = ReturnType<typeof MatrixField>;
40
41
  export default MatrixField;
@@ -214,7 +214,11 @@
214
214
  > = $state({});
215
215
  const nestedEls: Record<
216
216
  string,
217
- | { focus: () => void; focusPath: (steps: readonly PathStep[], pos?: number) => LandingBox }
217
+ | {
218
+ focus: () => void;
219
+ focusPath: (steps: readonly PathStep[], pos?: number) => LandingBox;
220
+ openPath: (steps: readonly PathStep[]) => Promise<void>;
221
+ }
218
222
  | undefined
219
223
  > = $state({});
220
224
  let rootEl = $state<HTMLElement | undefined>();
@@ -250,6 +254,13 @@
250
254
  focusProp(key);
251
255
  return undefined;
252
256
  }
257
+ /** Open the collapsed rows under the property `steps[0]` names ({@link
258
+ * FieldControl.openPath}). */
259
+ export async function openPath(steps: readonly PathStep[]): Promise<void> {
260
+ const [key, ...rest] = steps;
261
+ if (typeof key !== 'string' || !has(key)) return;
262
+ await own(nestedEls, key)?.openPath(rest);
263
+ }
253
264
  /** A label click for the properties `for` cannot reach: the date control, whose
254
265
  * focus lives on a segment, a prose cell, which is a `contenteditable`, and a
255
266
  * nested subform. Scoped to that property's own cell, so the click lands where the
@@ -63,6 +63,7 @@ interface Props {
63
63
  declare const ObjectField: import("svelte").Component<Props, {
64
64
  focus: () => void;
65
65
  focusPath: (steps: readonly PathStep[], pos?: number) => LandingBox;
66
+ openPath: (steps: readonly PathStep[]) => Promise<void>;
66
67
  }, "">;
67
68
  type ObjectField = ReturnType<typeof ObjectField>;
68
69
  export default ObjectField;
@@ -110,6 +110,7 @@
110
110
  type Subform = {
111
111
  focus: () => void;
112
112
  focusPath: (steps: readonly PathStep[], pos?: number) => LandingBox;
113
+ openPath: (steps: readonly PathStep[]) => Promise<void>;
113
114
  };
114
115
  let cellsEl = $state<Subform | undefined>();
115
116
 
@@ -145,6 +146,11 @@
145
146
  focus();
146
147
  return undefined;
147
148
  }
149
+ /** Open the collapsed rows under the live cell `steps[0]` names ({@link
150
+ * FieldControl.openPath}). */
151
+ export async function openPath(steps: readonly PathStep[]): Promise<void> {
152
+ if (live(steps[0])) await cellsEl?.openPath(steps);
153
+ }
148
154
  </script>
149
155
 
150
156
  <div class="qm-variant">
@@ -34,6 +34,7 @@ interface Props {
34
34
  declare const VariantField: import("svelte").Component<Props, {
35
35
  focus: () => void;
36
36
  focusPath: (steps: readonly PathStep[], pos?: number) => LandingBox;
37
+ openPath: (steps: readonly PathStep[]) => Promise<void>;
37
38
  }, "">;
38
39
  type VariantField = ReturnType<typeof VariantField>;
39
40
  export default VariantField;
@@ -1752,7 +1752,7 @@
1752
1752
 
1753
1753
  /**
1754
1754
  * Bring the review item `id` to the reader as the current change: open the panel holding
1755
- * it and scroll it to the middle of the view. The focus stays where it is, the reader having
1755
+ * it and every collapsed row it is under, and scroll it to the middle of the view. The focus stays where it is, the reader having
1756
1756
  * asked to look, unless `focus` asks for it: the caret then goes into the item, or the focus
1757
1757
  * to the control drawing it, a property inside a field included. False for an item the
1758
1758
  * editor does not draw.
@@ -1773,12 +1773,17 @@
1773
1773
  for (const ref of cardRefs) ref?.revealLeaf(key);
1774
1774
  }
1775
1775
  if (!(await span.resumes(tick()))) return false;
1776
+ const steps =
1777
+ key !== undefined
1778
+ ? reviewing.at(key).nested?.find((e) => e.item.id === id)?.steps
1779
+ : undefined;
1780
+ if (steps) await leaves.control(key!)?.openPath?.(steps);
1781
+ if (!span.alive) return false;
1776
1782
  reviewing.reveal(id);
1777
1783
  const thing = focus ? reviewEls(id).find((el) => el.matches(THING)) : undefined;
1778
1784
  if (thing) thing.focus({ preventScroll: true });
1779
1785
  else if (focus && key !== undefined && !leaves.prose(key)?.enterReview(id)) {
1780
1786
  const control = leaves.control(key);
1781
- const steps = reviewing.at(key).nested?.find((e) => e.item.id === id)?.steps;
1782
1787
  if (steps && control?.focusPath) await control.focusPath(steps);
1783
1788
  else control?.focus();
1784
1789
  if (!span.alive) return false;
@@ -1,8 +1,5 @@
1
1
  export { default as VisualEditor } from './VisualEditor.svelte';
2
2
  export type { VisualEditorProps } from './props.js';
3
- export { createField } from '../core/codec/index.js';
4
- export type { CreateFieldOpts, FieldController } from '../core/codec/index.js';
5
- export { DEFAULT_VISUAL_STRINGS } from './strings.js';
6
3
  export type { VisualStrings, VisualStringsInput, FormatDiagnostic } from './strings.js';
7
4
  export type { BodyPlaceholder, BodyPlaceholderContext } from './structure.js';
8
5
  export { editorShortcuts } from '../core/codec/index.js';
@@ -1,8 +1,8 @@
1
1
  // `@quillmark/svelte/visual`: the WYSIWYG surface.
2
2
  //
3
3
  // The federated VisualEditor: a thin Svelte composition over many small editors.
4
- // Each content leaf is the codec's `createField` prose leaf; scalar fields are
5
- // form controls; structure/cards are the editor's own. Depends on `/core` and the
4
+ // Each content leaf is the codec's prose leaf; scalar fields are form controls;
5
+ // structure/cards are the editor's own. Depends on `/core` and the
6
6
  // codec. Relative imports (not `$lib`): svelte-package ships this as-is.
7
7
  //
8
8
  // The barrel carries what a consumer story wants, and nothing else: a symbol
@@ -14,14 +14,6 @@
14
14
  // `check:deps` holds the reach.
15
15
  import '../core/theme.css';
16
16
  export { default as VisualEditor } from './VisualEditor.svelte';
17
- // The prose leaf: the vanilla mount API a non-Svelte consumer (or a custom
18
- // surface) builds on.
19
- export { createField } from '../core/codec/index.js';
20
- // What the surface says, and how it words a diagnostic. `strings` is keyed and
21
- // partial (unset keys take the package's English) and `DEFAULT_VISUAL_STRINGS` is
22
- // that English, exported so a consumer can compose against it rather than restate
23
- // it. The empty body's per-card hook is the `bodyPlaceholder` key inside it.
24
- export { DEFAULT_VISUAL_STRINGS } from './strings.js';
25
17
  // The prose leaf's shortcuts, for a host's shortcut list: read off the keymaps' own tables and
26
18
  // worded by the same `strings` (pass the editor's, or none for the package's English).
27
19
  export { editorShortcuts } from '../core/codec/index.js';
@@ -39,6 +39,12 @@ export interface FieldControl {
39
39
  * {@link el}.
40
40
  */
41
41
  focusPath?(steps: readonly PathStep[], pos?: number): LandingBox;
42
+ /**
43
+ * Open every collapsed row `steps` walks through, taking no focus and no caret: the
44
+ * walk {@link focusPath} makes, short of the landing. Settles once the innermost row it
45
+ * opened has drawn. Absent where {@link focusPath} is.
46
+ */
47
+ openPath?(steps: readonly PathStep[]): Promise<void>;
42
48
  readonly el: HTMLElement;
43
49
  }
44
50
  /**
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@quillmark/svelte",
3
- "version": "0.41.0",
3
+ "version": "0.42.0",
4
4
  "description": "Editor, live-preview and source surfaces over a Quillmark WASM session.",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "git+https://github.com/borb-sh/quillmark-js.git",
7
+ "url": "git+https://github.com/birdorbs/quillmark-js.git",
8
8
  "directory": "packages/svelte"
9
9
  },
10
10
  "bugs": {
11
- "url": "https://github.com/borb-sh/quillmark-js/issues"
11
+ "url": "https://github.com/birdorbs/quillmark-js/issues"
12
12
  },
13
- "homepage": "https://github.com/borb-sh/quillmark-js/tree/main/packages/svelte#readme",
13
+ "homepage": "https://github.com/birdorbs/quillmark-js/tree/main/packages/svelte#readme",
14
14
  "license": "Apache-2.0",
15
15
  "keywords": [
16
16
  "quillmark",