@quillmark/svelte 0.41.0 → 0.43.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
 
@@ -22,10 +22,3 @@ export declare function rangeAnchor(view: EditorView, from: number, to: number):
22
22
  * clears every one, as a surface over a selection in a table cell clears the cell's row.
23
23
  */
24
24
  export declare function across(anchor: RangeAnchor, boxes: readonly Element[]): RangeAnchor;
25
- /**
26
- * A virtual anchor over the first line box of the element `find` returns when asked: a mark a
27
- * view redraws under every edit, so no element outlives the surface hung off it. `context` is
28
- * the view's own element, which does. Total as {@link rangeAnchor} is: with nothing to measure
29
- * it returns the last rect that measured.
30
- */
31
- export declare function markAnchor(context: Element, find: () => Element | undefined): RangeAnchor;
@@ -78,22 +78,3 @@ export function across(anchor, boxes) {
78
78
  }
79
79
  };
80
80
  }
81
- /**
82
- * A virtual anchor over the first line box of the element `find` returns when asked: a mark a
83
- * view redraws under every edit, so no element outlives the surface hung off it. `context` is
84
- * the view's own element, which does. Total as {@link rangeAnchor} is: with nothing to measure
85
- * it returns the last rect that measured.
86
- */
87
- export function markAnchor(context, find) {
88
- let last;
89
- return {
90
- contextElement: context,
91
- getBoundingClientRect: () => {
92
- const el = find();
93
- const rect = el?.getClientRects()[0] ?? el?.getBoundingClientRect();
94
- if (rect)
95
- last = rect;
96
- return last ?? new DOMRect();
97
- }
98
- };
99
- }
@@ -177,7 +177,7 @@ function readLeaf(reader, addr) {
177
177
  function writeAddr(doc, addr) {
178
178
  if (typeof addr.card !== 'number')
179
179
  return addr;
180
- return { ...addr, card: doc.card(addr.card).id ?? addr.card };
180
+ return { ...addr, card: doc.cardId(addr.card) };
181
181
  }
182
182
  /** The canonical empty `Content`: one empty `para` block. */
183
183
  export function emptyContent() {
@@ -1,4 +1,4 @@
1
- export { markAnchor, rangeAnchor } from './anchor.js';
1
+ export { rangeAnchor } from './anchor.js';
2
2
  export type { RangeAnchor } from './anchor.js';
3
3
  export { createField, emptyContent, heldAttributes, isEmptyContent, proseAttributes, proseLeafPlugins } from './field.js';
4
4
  export type { CreateFieldOpts, FieldController, LeafProjection, LeafViews } from './field.js';
@@ -11,19 +11,16 @@ export { DEFAULT_SLASH_STRINGS } from './slash.js';
11
11
  export type { SlashState, SlashStrings } from './slash.js';
12
12
  export { DEFAULT_LEAVE_STRINGS } from './leave.js';
13
13
  export type { LeaveStrings } from './leave.js';
14
- export type { BlockPlace, LeafUndrawn, ReviewAction, ReviewReport, TextReview } from './review.js';
15
- export { wordDiff } from './review-diff.js';
14
+ export type { BlockPlace, ReviewAction, ReviewReport, TextReview } from './review.js';
16
15
  export { valueDiffPlugin, valueSpans } from './value-diff.js';
17
16
  export { reviewCaretPlugin } from './review-caret.js';
18
17
  export type { ValueProposal, ValueState } from './value-diff.js';
19
18
  export { asContent, planValue, valueChanges } from './value-plan.js';
20
- export type { ValuePlan, ValueChange } from './value-plan.js';
21
- export type { DiffHunk } from './review-diff.js';
22
19
  export { DEFAULT_SHORTCUT_STRINGS, FIELD_KEYS, LIST_KEYS, REVIEW_KEYS, editorShortcuts } from './shortcuts.js';
23
20
  export type { EditorShortcut, ShortcutScope, ShortcutStrings } from './shortcuts.js';
24
- export { blockSchema, inlineSchema, plaintextSchema, plainSchema, linesSchema, leafSchema, isParagraphsSchema, hasMarks } from './schema.js';
21
+ export { blockSchema, inlineSchema, plaintextSchema, plainSchema, leafSchema, isParagraphsSchema, hasMarks } from './schema.js';
25
22
  export { rendersHref, storableUrl } from './urls.js';
26
- export { decode, fitsInline, fitsLeaf, fitsPlain, renderContent, usvLength } from './decode.js';
23
+ export { decode, fitsInline, fitsLeaf, fitsPlain, renderContent } from './decode.js';
27
24
  export { pmToContent, lower } from './encode.js';
28
25
  export { offsetToPM, pmToOffset, buildLineIndex } from './positions.js';
29
26
  export { createReconciler, contentEqual, valueEqual } from './reconcile.js';
@@ -11,7 +11,7 @@ import 'prosemirror-gapcursor/style/gapcursor.css';
11
11
  import './prose.css';
12
12
  // What a floating surface anchors to. The visual tier's own surfaces mint one over a
13
13
  // selection (`visual/FormatPopover.svelte`), so it is reached off-barrel.
14
- export { markAnchor, rangeAnchor } from './anchor.js';
14
+ export { rangeAnchor } from './anchor.js';
15
15
  // The prose leaf.
16
16
  export { createField, emptyContent, heldAttributes, isEmptyContent, proseAttributes, proseLeafPlugins } from './field.js';
17
17
  export { capCount } from './cap.js';
@@ -25,7 +25,6 @@ export { DEFAULT_SLASH_STRINGS } from './slash.js';
25
25
  // The body's way out by the keyboard: the codec owns the keys and the hint's element,
26
26
  // the visual tier's `strings` set its wording.
27
27
  export { DEFAULT_LEAVE_STRINGS } from './leave.js';
28
- export { wordDiff } from './review-diff.js';
29
28
  export { valueDiffPlugin, valueSpans } from './value-diff.js';
30
29
  export { reviewCaretPlugin } from './review-caret.js';
31
30
  export { asContent, planValue, valueChanges } from './value-plan.js';
@@ -35,7 +34,7 @@ export { asContent, planValue, valueChanges } from './value-plan.js';
35
34
  export { DEFAULT_SHORTCUT_STRINGS, FIELD_KEYS, LIST_KEYS, REVIEW_KEYS, editorShortcuts } from './shortcuts.js';
36
35
  // Schemas (the decode/encode target; the VisualEditor mounts them). `hasMarks` is
37
36
  // what a mark surface asks before offering itself over a leaf.
38
- export { blockSchema, inlineSchema, plaintextSchema, plainSchema, linesSchema, leafSchema, isParagraphsSchema, hasMarks } from './schema.js';
37
+ export { blockSchema, inlineSchema, plaintextSchema, plainSchema, leafSchema, isParagraphsSchema, hasMarks } from './schema.js';
39
38
  // The url edge: `rendersHref` is the link gate the prompt re-asks on submit, and
40
39
  // `storableUrl` the encode the store's own refusal requires of the value it takes
41
40
  // (`visual/links.ts`).
@@ -45,7 +44,7 @@ export { rendersHref, storableUrl } from './urls.js';
45
44
  // The barrel carries what has an off-barrel caller, and nothing else. A symbol
46
45
  // reached only by relative import within `codec/` stays off it: an export nothing
47
46
  // imports is surface that still has to stay honest.
48
- export { decode, fitsInline, fitsLeaf, fitsPlain, renderContent, usvLength } from './decode.js';
47
+ export { decode, fitsInline, fitsLeaf, fitsPlain, renderContent } from './decode.js';
49
48
  export { pmToContent, lower } from './encode.js';
50
49
  export { offsetToPM, pmToOffset, buildLineIndex } from './positions.js';
51
50
  // Reconciliation gate.
@@ -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';
@@ -0,0 +1,6 @@
1
+ import type { Quill } from '@quillmark/wasm';
2
+ type QuillSchema = Quill['schema'];
3
+ /** `quill.schema`, built once per handle: the getter rebuilds and serializes the whole schema on
4
+ * every read, and a handle's schema never changes. Shared, so read-only. */
5
+ export declare function schemaOf(quill: Quill): QuillSchema;
6
+ export {};
@@ -0,0 +1,9 @@
1
+ const schemas = new WeakMap();
2
+ /** `quill.schema`, built once per handle: the getter rebuilds and serializes the whole schema on
3
+ * every read, and a handle's schema never changes. Shared, so read-only. */
4
+ export function schemaOf(quill) {
5
+ let schema = schemas.get(quill);
6
+ if (!schema)
7
+ schemas.set(quill, (schema = quill.schema));
8
+ return schema;
9
+ }
@@ -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';
@@ -130,7 +130,7 @@
130
130
  import ReviewRows from './ReviewRows.svelte';
131
131
  import { splitDeep, unrouted, type DeepDiagnostic } from './diagnostics.js';
132
132
  import { propertyDomIds } from './domid.js';
133
- import type { LandingBox } from './leaves.js';
133
+ import type { LandingBox, Subform } from './leaves.js';
134
134
  import { reorder, reorderArm } from './motion.js';
135
135
  import { rowDrag } from './rowdrag.svelte.js';
136
136
  import {
@@ -444,10 +444,6 @@
444
444
  // A table row's cells, on the same key: the subform a landing and the column-keeping
445
445
  // Enter hop reach into. Every table row is open, so there is one per row where the
446
446
  // list holds one per open row.
447
- type Subform = {
448
- focus: () => void;
449
- focusPath: (steps: readonly PathStep[], pos?: number) => LandingBox;
450
- };
451
447
  const cellEls: Record<string, Subform | undefined> = $state({});
452
448
  let addEl: HTMLButtonElement | undefined = $state();
453
449
  let rowsEl: HTMLElement | undefined = $state();
@@ -840,6 +836,19 @@
840
836
  else focusRow(id);
841
837
  return rowEls[id];
842
838
  }
839
+ /** Open the row `steps[0]` names where the walk goes on inside it, and the rows under it
840
+ * the rest names ({@link FieldControl.openPath}). A row's own address is drawn on its
841
+ * head, so it opens nothing. */
842
+ export async function openPath(steps: readonly PathStep[]): Promise<void> {
843
+ const [k, ...rest] = steps;
844
+ const id = typeof k === 'number' ? ids[k] : undefined;
845
+ if (id === undefined || !rest.length) return;
846
+ if (table) return cellEls[id]?.openPath(rest);
847
+ if (control !== 'object') return;
848
+ open.add(id);
849
+ if (!(await span.resumes(tick()))) return;
850
+ await objEls[id]?.openPath(rest);
851
+ }
843
852
  /** Focus element `id` after the flush, never in the same tick: a mutation commits
844
853
  * the array by value, so the parent re-derives and the row does not exist until
845
854
  * 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;
@@ -13,6 +13,7 @@
13
13
  import Icon from './icons/Icon.svelte';
14
14
  import type { Document, Quill, Addr, Diagnostic, PathStep } from '@quillmark/wasm';
15
15
  import type { EditorErrorHandler } from '../core/errors.js';
16
+ import { schemaOf } from '../core/schema.js';
16
17
  import type { LeafRegistry } from './leaves.js';
17
18
  import type { CardModel, FieldModel } from './structure.js';
18
19
  import { placeFields, humanize, initialExpandedGroup, kindTitle, mountKey } from './structure.js';
@@ -462,7 +463,7 @@
462
463
 
463
464
  {#snippet kindOptions()}
464
465
  {#each kinds as k (k)}
465
- <option value={k}>{kindTitle(quill.schema[k], k)}</option>
466
+ <option value={k}>{kindTitle(schemaOf(quill)[k], k)}</option>
466
467
  {/each}
467
468
  {/snippet}
468
469
 
@@ -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
  }
@@ -62,7 +62,7 @@
62
62
  schemaAt
63
63
  } from './structure.js';
64
64
  import { splitDeep, unrouted, type DeepDiagnostic } from './diagnostics.js';
65
- import type { LandingBox } from './leaves.js';
65
+ import type { LandingBox, Subform } from './leaves.js';
66
66
  import { propertyDomIds } from './domid.js';
67
67
  import { bloom } from '../core/bloom.js';
68
68
  import Icon from './icons/Icon.svelte';
@@ -198,10 +198,6 @@
198
198
  // The item boxes, the ticks, the title inputs and the column subforms, keyed by
199
199
  // member id — stable for the item's life. `$state` for the binding's sake
200
200
  // (`ArrayField` keeps its element refs the same way).
201
- type Subform = {
202
- focus: () => void;
203
- focusPath: (steps: readonly PathStep[], pos?: number) => LandingBox;
204
- };
205
201
  const memberEls: Record<string, HTMLElement | undefined> = $state({});
206
202
  const tickEls: Record<string, HTMLInputElement | undefined> = $state({});
207
203
  const titleEls: Record<string, HTMLInputElement | undefined> = $state({});
@@ -348,6 +344,13 @@
348
344
  (own(tickEls, id) ?? own(titleEls, id))?.focus();
349
345
  return member;
350
346
  }
347
+ /** Open the collapsed rows under a held item's column ({@link FieldControl.openPath}):
348
+ * the item's details are drawn already while a proposal or a diagnostic names a cell. */
349
+ export async function openPath(steps: readonly PathStep[]): Promise<void> {
350
+ const [id, ...rest] = steps;
351
+ if (typeof id !== 'string' || !rest.length) return;
352
+ await own(colEls, id)?.openPath(rest);
353
+ }
351
354
  </script>
352
355
 
353
356
  <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;
@@ -5,7 +5,7 @@
5
5
  this leaf's commits with the caret riding the untouched view.
6
6
  -->
7
7
  <script lang="ts">
8
- import { onDestroy, untrack } from 'svelte';
8
+ import { untrack } from 'svelte';
9
9
  import {
10
10
  createField,
11
11
  type FieldController,
@@ -15,7 +15,7 @@
15
15
  import type { LeafRegistry } from './leaves.js';
16
16
  import SlashMenu from './SlashMenu.svelte';
17
17
  import { wording } from './strings.js';
18
- import { review } from './review.svelte.js';
18
+ import { dropPlansOnLeave, review } from './review.svelte.js';
19
19
  import type { TextProposal } from './review.js';
20
20
  import './controls.css';
21
21
  import type { Document, Quill, Addr, Content, Diagnostic } from '@quillmark/wasm';
@@ -202,17 +202,7 @@
202
202
  (proposed ?? []).map((p) => ({ ...p, lit: reviewing.lit === p.id }))
203
203
  );
204
204
  });
205
- /** A proposal's plan goes when it leaves the list or the leaf goes, not when another in the
206
- * list is answered, which would leave its own Accept writing its value whole. */
207
- let plannedIds: readonly string[] = [];
208
- $effect(() => {
209
- const ids = (proposed ?? []).map((p) => p.id);
210
- for (const id of plannedIds) if (!ids.includes(id)) reviewing.planned(id, undefined);
211
- plannedIds = ids;
212
- });
213
- onDestroy(() => {
214
- for (const id of plannedIds) reviewing.planned(id, undefined);
215
- });
205
+ dropPlansOnLeave(reviewing, () => proposed);
216
206
 
217
207
  // Only a narrowed or a plain leaf holds by what a re-validation says, so only one of them asks.
218
208
  $effect(() => {
@@ -45,7 +45,7 @@
45
45
  replacement reads, so a write moving the value takes it or releases it.
46
46
  -->
47
47
  <script lang="ts">
48
- import { onDestroy, untrack } from 'svelte';
48
+ import { untrack } from 'svelte';
49
49
  import { Fragment, Slice, type Node as PMNode } from 'prosemirror-model';
50
50
  import { EditorState, Selection } from 'prosemirror-state';
51
51
  import { EditorView } from 'prosemirror-view';
@@ -76,7 +76,7 @@
76
76
  type TextCap
77
77
  } from '../core/codec/index.js';
78
78
  import { valueLeafSeat } from './leaves.js';
79
- import { review } from './review.svelte.js';
79
+ import { dropPlansOnLeave, review } from './review.svelte.js';
80
80
  import type { TextProposal } from './review.js';
81
81
  import { wording } from './strings.js';
82
82
  import './controls.css';
@@ -176,17 +176,7 @@
176
176
  litHere: () => drawnProposals.some((p) => p.lit),
177
177
  point: (id) => reviewing.point(id)
178
178
  });
179
- /** A proposal's plan goes when it leaves the list or the leaf goes, not when another in the
180
- * list is answered, which would leave its own Accept writing its value whole. */
181
- let plannedIds: readonly string[] = [];
182
- $effect(() => {
183
- const ids = (proposed ?? []).map((p) => p.id);
184
- for (const id of plannedIds) if (!ids.includes(id)) reviewing.planned(id, undefined);
185
- plannedIds = ids;
186
- });
187
- onDestroy(() => {
188
- for (const id of plannedIds) reviewing.planned(id, undefined);
189
- });
179
+ dropPlansOnLeave(reviewing, () => proposed);
190
180
 
191
181
  const t = wording();
192
182
  const seat = valueLeafSeat();
@@ -22,7 +22,7 @@
22
22
  import type { DeepDiagnostic } from './diagnostics.js';
23
23
  import { shownValue, splitReview, type DeepReview } from './review.js';
24
24
  import { review as reviewState } from './review.svelte.js';
25
- import type { LandingBox } from './leaves.js';
25
+ import type { LandingBox, Subform } from './leaves.js';
26
26
  import {
27
27
  VARIANT_DISCRIMINANT,
28
28
  commitDiscriminant,
@@ -107,10 +107,6 @@
107
107
  onCommit(next);
108
108
  }
109
109
 
110
- type Subform = {
111
- focus: () => void;
112
- focusPath: (steps: readonly PathStep[], pos?: number) => LandingBox;
113
- };
114
110
  let cellsEl = $state<Subform | undefined>();
115
111
 
116
112
  /** Whether a step names a cell the live world draws. The one test the landing and
@@ -145,6 +141,11 @@
145
141
  focus();
146
142
  return undefined;
147
143
  }
144
+ /** Open the collapsed rows under the live cell `steps[0]` names ({@link
145
+ * FieldControl.openPath}). */
146
+ export async function openPath(steps: readonly PathStep[]): Promise<void> {
147
+ if (live(steps[0])) await cellsEl?.openPath(steps);
148
+ }
148
149
  </script>
149
150
 
150
151
  <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;
@@ -46,16 +46,15 @@
46
46
  import { createLifespan } from '../core/teardown.js';
47
47
  import { spacePx } from '../core/rungs.js';
48
48
  import { tooltips } from '../core/tooltip.js';
49
+ import { schemaOf } from '../core/schema.js';
49
50
  import type {
50
51
  Addr,
51
- CardAddr,
52
52
  Diagnostic,
53
53
  Document,
54
54
  PathStep,
55
55
  PayloadItem,
56
56
  QuillFieldSchema,
57
- Resolved,
58
- ResolvedField
57
+ Resolved
59
58
  } from '@quillmark/wasm';
60
59
  import type { VisualEditorProps } from './props.js';
61
60
  import type { Delta } from '../core/codec/positions.js';
@@ -215,7 +214,7 @@
215
214
  // card reorder.
216
215
  const commitErrors = new SvelteMap<string, RoutedDiagnostic>();
217
216
 
218
- const kinds = $derived(Object.keys(quill.schema).filter((k) => k !== 'main'));
217
+ const kinds = $derived(Object.keys(schemaOf(quill)).filter((k) => k !== 'main'));
219
218
 
220
219
  // The removal's step back (`undo.svelte.ts`), published so an array's row removal
221
220
  // offers on the same toast a card's does.
@@ -279,7 +278,7 @@
279
278
  if (!running || value === undefined || !shown || !Object.hasOwn(shown.values, name))
280
279
  return rederive();
281
280
  const fresh = fieldValues((isMain ? doc.main : doc.card(at)).payloadItems);
282
- const cardSchema = isMain ? quill.schema.main : quill.schema[shown.kind];
281
+ const cardSchema = schemaOf(quill)[isMain ? 'main' : shown.kind];
283
282
  patched = {
284
283
  ...patched,
285
284
  [id]: {
@@ -366,7 +365,7 @@
366
365
  };
367
366
  /** The session key of the card holding `$id` `id`. */
368
367
  function cardKeyFor(id: string): string | undefined {
369
- return cardIds.find((_, k) => doc.card(k).id === id);
368
+ return cardIds.find((_, k) => doc.cardId(k) === id);
370
369
  }
371
370
  /** The host's list with each card a path names moved to where that card stands now: the card
372
371
  * holding the item's `card`, else the one at the path's index when the list was set. */
@@ -376,12 +375,24 @@
376
375
  if (!review?.length) return review;
377
376
  if (was === now && !review.some((item) => 'card' in item && item.card !== undefined))
378
377
  return review;
378
+ let keys: Map<string, string> | undefined;
379
+ const keyOf = (id: string): string | undefined => {
380
+ if (!keys) {
381
+ keys = new Map();
382
+ const cards = doc.cards;
383
+ for (const [k, key] of now.entries()) {
384
+ const at = cards[k]?.id;
385
+ if (at != null && !keys.has(at)) keys.set(at, key);
386
+ }
387
+ }
388
+ return keys.get(id);
389
+ };
379
390
  return review.map((item) => {
380
391
  if (byCard(item)) return item;
381
392
  let field: DocPath;
382
393
  if (item.card === undefined) field = cardMoved(item.field, was, now);
383
394
  else {
384
- const key = cardKeyFor(item.card);
395
+ const key = keyOf(item.card);
385
396
  field = pathOnCard(item.field, key === undefined ? now.length : now.indexOf(key));
386
397
  }
387
398
  return field === item.field ? item : { ...item, field };
@@ -566,7 +577,7 @@
566
577
  text: string;
567
578
  } {
568
579
  const { add } = item;
569
- const schema = quill.schema[add.kind];
580
+ const schema = schemaOf(quill)[add.kind];
570
581
  const values = fieldValues(add.payloadItems);
571
582
  const named = (add.ext?.editor as { title?: unknown } | undefined)?.title;
572
583
  const title = cardTitle(
@@ -921,7 +932,7 @@
921
932
  if (!key?.field) return '';
922
933
  const isMain = key.card === undefined;
923
934
  const card = isMain ? model.main : model.cards[cardIndexOf(key.card as CardId)];
924
- const schema = isMain ? quill.schema.main : quill.schema[card?.kind ?? ''];
935
+ const schema = schemaOf(quill)[isMain ? 'main' : (card?.kind ?? '')];
925
936
  const sub = schema?.fields[key.field];
926
937
  return sub ? fieldTitle(key.field, sub) : humanize(key.field);
927
938
  }
@@ -1036,7 +1047,7 @@
1036
1047
  const { card: at, field } = addr;
1037
1048
  if (typeof at !== 'number' || field == null) return;
1038
1049
  const shown = model.cards[at];
1039
- const cardSchema = shown && quill.schema[shown.kind];
1050
+ const cardSchema = shown && schemaOf(quill)[shown.kind];
1040
1051
  if (!cardSchema || cardSchema.title?.trim()) return;
1041
1052
  const sub = Object.hasOwn(cardSchema.fields, field) ? cardSchema.fields[field] : undefined;
1042
1053
  if (!sub || !shortCell(sub)) return;
@@ -1251,7 +1262,7 @@
1251
1262
  const name =
1252
1263
  shown?.titleOverride ||
1253
1264
  shown?.titlePlaceholder ||
1254
- kindTitle(quill.schema[card.kind], card.kind);
1265
+ kindTitle(schemaOf(quill)[card.kind], card.kind);
1255
1266
  const gone = removed.remove(id, card, cardIds, i);
1256
1267
  doc.removeCard(i);
1257
1268
  arm.arm();
@@ -1476,7 +1487,7 @@
1476
1487
 
1477
1488
  const tree = $derived.by(() => {
1478
1489
  revision; // re-derive on every mutation
1479
- const schema = quill.schema;
1490
+ const schema = schemaOf(quill);
1480
1491
  const main = doc.main;
1481
1492
  const cards = doc.cards;
1482
1493
  // The provenance channel (FIELD_PROVENANCE): one whole-doc resolve per
@@ -1752,7 +1763,7 @@
1752
1763
 
1753
1764
  /**
1754
1765
  * 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
1766
+ * 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
1767
  * asked to look, unless `focus` asks for it: the caret then goes into the item, or the focus
1757
1768
  * to the control drawing it, a property inside a field included. False for an item the
1758
1769
  * editor does not draw.
@@ -1773,12 +1784,17 @@
1773
1784
  for (const ref of cardRefs) ref?.revealLeaf(key);
1774
1785
  }
1775
1786
  if (!(await span.resumes(tick()))) return false;
1787
+ const steps =
1788
+ key !== undefined
1789
+ ? reviewing.at(key).nested?.find((e) => e.item.id === id)?.steps
1790
+ : undefined;
1791
+ if (steps) await leaves.control(key!)?.openPath?.(steps);
1792
+ if (!span.alive) return false;
1776
1793
  reviewing.reveal(id);
1777
1794
  const thing = focus ? reviewEls(id).find((el) => el.matches(THING)) : undefined;
1778
1795
  if (thing) thing.focus({ preventScroll: true });
1779
1796
  else if (focus && key !== undefined && !leaves.prose(key)?.enterReview(id)) {
1780
1797
  const control = leaves.control(key);
1781
- const steps = reviewing.at(key).nested?.find((e) => e.item.id === id)?.steps;
1782
1798
  if (steps && control?.focusPath) await control.focusPath(steps);
1783
1799
  else control?.focus();
1784
1800
  if (!span.alive) return false;
@@ -2153,7 +2169,7 @@
2153
2169
  function declaredField(addr: Addr): QuillFieldSchema | undefined {
2154
2170
  if (addr.field == null) return undefined;
2155
2171
  const kind = typeof addr.card === 'number' ? model.cards[addr.card]?.kind : undefined;
2156
- const schema = quill.schema;
2172
+ const schema = schemaOf(quill);
2157
2173
  const card = addr.card == null ? schema.main : kind ? schema[kind] : undefined;
2158
2174
  return card?.fields?.[addr.field];
2159
2175
  }
@@ -2415,7 +2431,7 @@
2415
2431
  <div class="qm-menu-surface" data-qm-root>
2416
2432
  {#each kinds as k (k)}
2417
2433
  <DropdownMenu.Item class="qm-menu-item" onSelect={() => addPicked(atIndex, k)}
2418
- >{kindTitle(quill.schema[k], k)}</DropdownMenu.Item
2434
+ >{kindTitle(schemaOf(quill)[k], k)}</DropdownMenu.Item
2419
2435
  >
2420
2436
  {/each}
2421
2437
  </div>
@@ -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';
@@ -7,6 +7,12 @@ import type { FieldController, LeafViews } from '../core/codec/index.js';
7
7
  * the walk had to open something on the way.
8
8
  */
9
9
  export type LandingBox = HTMLElement | undefined | Promise<HTMLElement | undefined>;
10
+ /** A nested form's handle, as a container field holds one per row, column or variant. */
11
+ export type Subform = {
12
+ focus: () => void;
13
+ focusPath: (steps: readonly PathStep[], pos?: number) => LandingBox;
14
+ openPath: (steps: readonly PathStep[]) => Promise<void>;
15
+ };
10
16
  /**
11
17
  * A mounted field's landing handle: focus it, and the `.qm-wash` box the arrival wash
12
18
  * plays over ({@link import('../core/bloom.js').bloom}).
@@ -39,6 +45,12 @@ export interface FieldControl {
39
45
  * {@link el}.
40
46
  */
41
47
  focusPath?(steps: readonly PathStep[], pos?: number): LandingBox;
48
+ /**
49
+ * Open every collapsed row `steps` walks through, taking no focus and no caret: the
50
+ * walk {@link focusPath} makes, short of the landing. Settles once the innermost row it
51
+ * opened has drawn. Absent where {@link focusPath} is.
52
+ */
53
+ openPath?(steps: readonly PathStep[]): Promise<void>;
42
54
  readonly el: HTMLElement;
43
55
  }
44
56
  /**
@@ -1,4 +1,5 @@
1
1
  import { addrForFieldPath, fieldPathForAddr } from '../core/address.js';
2
+ import { schemaOf } from '../core/schema.js';
2
3
  import { asContent, lineRuns } from '../core/codec/value-plan.js';
3
4
  import { byBlocks, sameValue } from './review.js';
4
5
  import { VARIANT_DISCRIMINANT, baseType, fieldValues, textKind } from './structure.js';
@@ -37,9 +38,12 @@ let minted = 0;
37
38
  export function proposalsBetween(quill, base, answer, opts = {}) {
38
39
  const { mint = () => `review-${minted++}`, label } = typeof opts === 'function' ? { mint: opts } : opts;
39
40
  const items = [];
40
- const kinds = Array.from({ length: base.cardCount }, (_, i) => base.card(i).kind);
41
- const baseIds = Array.from({ length: base.cardCount }, (_, i) => base.card(i).id ?? '');
42
- const answerIds = Array.from({ length: answer.cardCount }, (_, i) => answer.card(i).id ?? '');
41
+ const schemas = schemaOf(quill);
42
+ const baseCards = base.cards;
43
+ const answerCards = answer.cards;
44
+ const kinds = baseCards.map((c) => c.kind);
45
+ const baseIds = baseCards.map((c) => c.id ?? '');
46
+ const answerIds = answerCards.map((c) => c.id ?? '');
43
47
  const pathOf = (at, field, steps = []) => fieldPathForAddr(addrOf(at, field), kinds, steps);
44
48
  const diffCard = (schema, at, was, now, answerAt) => {
45
49
  const before = fieldValues(was.payloadItems);
@@ -182,21 +186,21 @@ export function proposalsBetween(quill, base, answer, opts = {}) {
182
186
  });
183
187
  }
184
188
  };
185
- diffCard(quill.schema.main, undefined, base.main, answer.main, undefined);
189
+ diffCard(schemas.main, undefined, base.main, answer.main, undefined);
186
190
  /** The base's index of each card the answer keeps as it was, by its answer index. */
187
191
  const kept = new Map();
188
192
  const removed = [];
189
193
  for (const [at, id] of baseIds.entries()) {
190
194
  const answerAt = answerIds.indexOf(id);
191
- const was = base.card(at);
192
- const now = answerAt < 0 ? undefined : answer.card(answerAt);
195
+ const was = baseCards[at];
196
+ const now = answerAt < 0 ? undefined : answerCards[answerAt];
193
197
  if (!now || now.kind !== was.kind) {
194
198
  removed.push(at);
195
199
  continue;
196
200
  }
197
201
  kept.set(answerAt, at);
198
202
  const first = items.length;
199
- diffCard(quill.schema[was.kind], at, was, now, answerAt);
203
+ diffCard(schemas[was.kind], at, was, now, answerAt);
200
204
  if (id)
201
205
  for (const item of items.slice(first))
202
206
  Object.assign(item, { card: id });
@@ -210,7 +214,7 @@ export function proposalsBetween(quill, base, answer, opts = {}) {
210
214
  const after = kept.get(lead);
211
215
  items.push({
212
216
  id: mint(),
213
- add: answer.card(at),
217
+ add: answerCards[at],
214
218
  ...(after !== undefined && { after }),
215
219
  ...(after !== undefined && baseIds[after] && { afterCard: baseIds[after] })
216
220
  });
@@ -208,18 +208,6 @@ export declare function reviewText(value: unknown, words: {
208
208
  on: string;
209
209
  off: string;
210
210
  }): string;
211
- /** A stretch of a proposal as a reader is shown it: kept, struck, or tinted. */
212
- export interface ReviewRun {
213
- text: string;
214
- kind?: 'del' | 'ins';
215
- }
216
- type Words = {
217
- on: string;
218
- off: string;
219
- };
220
- /** A proposal as runs, what it keeps, strikes and tints. Two lines of words differ by their words,
221
- * two lists by their members, two records by their keys; any other pair differs whole. */
222
- export declare function reviewRuns(before: unknown, after: unknown, words: Words): ReviewRun[];
223
211
  /** A proposal a leaf of words draws over its own value: what it would write, and the value its
224
212
  * writer read where it says, each as the leaf's content. */
225
213
  export interface TextProposal {
@@ -245,4 +233,3 @@ export declare function shownValue(item: FieldProposal | undefined, stored: unkn
245
233
  /** Whether a value a reader commits is the one a proposal would write: a blank and an unset value
246
234
  * are one, since a control cleared over a default commits `''`. */
247
235
  export declare function writesProposed(value: unknown, after: unknown): boolean;
248
- export {};
@@ -1,4 +1,4 @@
1
- import { asContent, wordDiff } from '../core/codec/index.js';
1
+ import { asContent } from '../core/codec/index.js';
2
2
  /** Whether an item proposes a whole card. */
3
3
  export const byCard = (item) => 'add' in item || 'remove' in item;
4
4
  /** Whether an item names blocks of a rich text field, which its prose leaf draws. */
@@ -167,110 +167,6 @@ export function reviewText(value, words) {
167
167
  .map(([key, v]) => `${key}: ${v}`)
168
168
  .join('; ');
169
169
  }
170
- const prose = (v) => typeof v === 'string' || (typeof v === 'object' && v !== null && 'text' in v);
171
- const record = (v) => typeof v === 'object' && v !== null && !Array.isArray(v) && !prose(v);
172
- const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
173
- function whole(before, after) {
174
- return [
175
- ...(before ? [{ text: before, kind: 'del' }] : []),
176
- ...(after ? [{ text: after, kind: 'ins' }] : [])
177
- ];
178
- }
179
- function joined(parts, by) {
180
- return parts.filter((p) => p.length).flatMap((p, i) => (i ? [{ text: by }, ...p] : p));
181
- }
182
- /** The keys of two records that differ, each as `key: ` with what goes struck and what comes
183
- * tinted. */
184
- function recordRuns(before, after, words) {
185
- const keys = [...new Set([...Object.keys(after), ...Object.keys(before)])];
186
- return joined(keys
187
- .filter((key) => !same(before[key], after[key]))
188
- .map((key) => {
189
- const runs = whole(reviewText(before[key], words), reviewText(after[key], words));
190
- return runs.length ? [{ text: `${key}: ` }, ...runs] : [];
191
- }), '; ');
192
- }
193
- /** Two lists by their members, in order: a member both hold is kept, one only `before` holds is
194
- * struck, one only `after` holds is tinted. In a list of records a kept record is left out, and a
195
- * record struck where one is tinted reads as the keys the two differ in. */
196
- function listRuns(before, after, words) {
197
- const n = before.length;
198
- const m = after.length;
199
- const common = Array.from({ length: n + 1 }, () => new Array(m + 1).fill(0));
200
- for (let i = n - 1; i >= 0; i--)
201
- for (let j = m - 1; j >= 0; j--)
202
- common[i][j] = same(before[i], after[j])
203
- ? common[i + 1][j + 1] + 1
204
- : Math.max(common[i + 1][j], common[i][j + 1]);
205
- const records = [...before, ...after].some(record);
206
- /** A record edited in place, named by its first value where that stays, so a reader can tell
207
- * which of the list it is with the records kept left out. */
208
- const edited = (was, now) => {
209
- const first = Object.keys(now)[0];
210
- const name = first !== undefined && same(was[first], now[first]) && reviewText(now[first], words);
211
- const runs = recordRuns(was, now, words);
212
- return name ? [{ text: `${name} (` }, ...runs, { text: ')' }] : runs;
213
- };
214
- const parts = [];
215
- let gone = [];
216
- let come = [];
217
- const flush = () => {
218
- const pairs = records ? Math.min(gone.length, come.length) : 0;
219
- for (let k = 0; k < pairs; k++)
220
- parts.push(record(gone[k]) && record(come[k])
221
- ? edited(gone[k], come[k])
222
- : whole(reviewText(gone[k], words), reviewText(come[k], words)));
223
- for (const v of gone.slice(pairs))
224
- parts.push(whole(reviewText(v, words), ''));
225
- for (const v of come.slice(pairs))
226
- parts.push(whole('', reviewText(v, words)));
227
- gone = [];
228
- come = [];
229
- };
230
- let i = 0;
231
- let j = 0;
232
- while (i < n || j < m) {
233
- if (i < n && j < m && same(before[i], after[j])) {
234
- flush();
235
- if (!records)
236
- parts.push([{ text: reviewText(before[i], words) }]);
237
- i++;
238
- j++;
239
- }
240
- else if (j < m && (i === n || common[i][j + 1] >= common[i + 1][j]))
241
- come.push(after[j++]);
242
- else
243
- gone.push(before[i++]);
244
- }
245
- flush();
246
- return joined(parts, ', ');
247
- }
248
- /** A proposal as runs, what it keeps, strikes and tints. Two lines of words differ by their words,
249
- * two lists by their members, two records by their keys; any other pair differs whole. */
250
- export function reviewRuns(before, after, words) {
251
- if (Array.isArray(before) && Array.isArray(after) && before.length && after.length)
252
- return listRuns(before, after, words);
253
- if (record(before) && record(after))
254
- return recordRuns(before, after, words);
255
- const was = reviewText(before, words);
256
- const now = reviewText(after, words);
257
- if (!prose(before) || !prose(after) || !was || !now)
258
- return whole(was, now);
259
- const out = [];
260
- let at = 0;
261
- for (const hunk of wordDiff(was, now)) {
262
- if (hunk.at > at)
263
- out.push({ text: was.slice(at, hunk.at) });
264
- if (hunk.end > hunk.at)
265
- out.push({ text: was.slice(hunk.at, hunk.end), kind: 'del' });
266
- if (hunk.insert)
267
- out.push({ text: hunk.insert, kind: 'ins' });
268
- at = hunk.end;
269
- }
270
- if (at < was.length)
271
- out.push({ text: was.slice(at) });
272
- return out;
273
- }
274
170
  /** A proposal over a leaf of words, `undefined` where its values are not words. A cleared value
275
171
  * is drawn as what Accept leaves: `cleared`, the default that would print, else nothing. */
276
172
  export function textProposal(item, cleared) {
@@ -143,3 +143,9 @@ export declare function createReview(source: ReviewSource): Review;
143
143
  export declare function setReview(review: Review): void;
144
144
  /** The editor's review state, or {@link NO_REVIEW} off-tree. */
145
145
  export declare function review(): Review;
146
+ /** A proposal's plan goes when it leaves the list or the leaf goes, not when another in the
147
+ * list is answered, which would leave its own Accept writing its value whole. Called during
148
+ * a leaf's init. */
149
+ export declare function dropPlansOnLeave(reviewing: Review, proposed: () => readonly {
150
+ id: string;
151
+ }[] | undefined): void;
@@ -13,7 +13,7 @@
13
13
  // empties it: an inverse is good against the document it was recorded over. An answer's own
14
14
  // writes, and an inverse's, go down the lanes an edit does, so they are flagged while they are
15
15
  // made.
16
- import { getContext, setContext } from 'svelte';
16
+ import { getContext, onDestroy, setContext } from 'svelte';
17
17
  import { SvelteMap } from 'svelte/reactivity';
18
18
  import { asContent, planValue } from '../core/codec/index.js';
19
19
  import { byBlocks, byCard, locate, onField, putsIn, sameValue, textProposal, valueIn, writesProposed } from './review.js';
@@ -541,3 +541,20 @@ const NO_REVIEW = {
541
541
  export function review() {
542
542
  return getContext(KEY) ?? NO_REVIEW;
543
543
  }
544
+ /** A proposal's plan goes when it leaves the list or the leaf goes, not when another in the
545
+ * list is answered, which would leave its own Accept writing its value whole. Called during
546
+ * a leaf's init. */
547
+ export function dropPlansOnLeave(reviewing, proposed) {
548
+ let plannedIds = [];
549
+ $effect(() => {
550
+ const ids = (proposed() ?? []).map((p) => p.id);
551
+ for (const id of plannedIds)
552
+ if (!ids.includes(id))
553
+ reviewing.planned(id, undefined);
554
+ plannedIds = ids;
555
+ });
556
+ onDestroy(() => {
557
+ for (const id of plannedIds)
558
+ reviewing.planned(id, undefined);
559
+ });
560
+ }
@@ -735,7 +735,7 @@ export class IdSeq {
735
735
  export function placeCardInto(target, card, at) {
736
736
  const { id, ...bare } = card;
737
737
  const free = id !== undefined &&
738
- !Array.from({ length: target.cardCount }, (_, k) => target.card(k).id).includes(id);
738
+ !Array.from({ length: target.cardCount }, (_, k) => target.cardId(k)).includes(id);
739
739
  try {
740
740
  target.unchecked.insertCard(free ? card : bare, at);
741
741
  }
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@quillmark/svelte",
3
- "version": "0.41.0",
3
+ "version": "0.43.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",
@@ -69,7 +69,7 @@
69
69
  "check": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings"
70
70
  },
71
71
  "peerDependencies": {
72
- "@quillmark/wasm": ">=0.140.0-0",
72
+ "@quillmark/wasm": ">=0.142.0-0",
73
73
  "svelte": "^5.33.0"
74
74
  },
75
75
  "dependencies": {