@quillmark/svelte 0.35.1 → 0.37.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 (82) hide show
  1. package/README.md +30 -18
  2. package/THEMING.md +1 -1
  3. package/dist/core/address.d.ts +5 -0
  4. package/dist/core/address.js +14 -0
  5. package/dist/core/codec/decode.d.ts +4 -2
  6. package/dist/core/codec/decode.js +5 -2
  7. package/dist/core/codec/field.d.ts +42 -16
  8. package/dist/core/codec/field.js +97 -28
  9. package/dist/core/codec/index.d.ts +8 -5
  10. package/dist/core/codec/index.js +4 -5
  11. package/dist/core/codec/prose.css +25 -81
  12. package/dist/core/codec/review.d.ts +31 -26
  13. package/dist/core/codec/review.js +93 -169
  14. package/dist/core/codec/schema.d.ts +12 -2
  15. package/dist/core/codec/schema.js +27 -5
  16. package/dist/core/codec/shortcuts.d.ts +5 -4
  17. package/dist/core/codec/shortcuts.js +9 -8
  18. package/dist/core/codec/table-view.js +15 -3
  19. package/dist/core/codec/value-diff.d.ts +21 -0
  20. package/dist/core/codec/value-diff.js +83 -0
  21. package/dist/core/codec/value-plan.d.ts +29 -0
  22. package/dist/core/codec/value-plan.js +157 -0
  23. package/dist/core/theme.css +46 -15
  24. package/dist/core/tooltip.css +49 -0
  25. package/dist/core/tooltip.d.ts +6 -0
  26. package/dist/core/tooltip.js +176 -0
  27. package/dist/preview/Preview.svelte +22 -1
  28. package/dist/preview/controller.js +38 -0
  29. package/dist/preview/strings.d.ts +2 -0
  30. package/dist/preview/strings.js +1 -0
  31. package/dist/visual/ArrayField.svelte +374 -96
  32. package/dist/visual/Card.svelte +33 -12
  33. package/dist/visual/Card.svelte.d.ts +3 -0
  34. package/dist/visual/CardControls.svelte +3 -3
  35. package/dist/visual/DateField.svelte +47 -5
  36. package/dist/visual/DiagnosticList.svelte +3 -2
  37. package/dist/visual/EnumField.svelte +20 -5
  38. package/dist/visual/EnumField.svelte.d.ts +5 -0
  39. package/dist/visual/Field.svelte +56 -47
  40. package/dist/visual/FieldHint.svelte +20 -8
  41. package/dist/visual/FormatPopover.svelte +54 -20
  42. package/dist/visual/MatrixField.svelte +48 -6
  43. package/dist/visual/MatrixField.svelte.d.ts +5 -0
  44. package/dist/visual/NumberField.svelte +131 -6
  45. package/dist/visual/NumberField.svelte.d.ts +5 -0
  46. package/dist/visual/ObjectField.svelte +60 -18
  47. package/dist/visual/ProseField.svelte +21 -5
  48. package/dist/visual/ProseField.svelte.d.ts +5 -1
  49. package/dist/visual/ProseValue.svelte +49 -8
  50. package/dist/visual/ProseValue.svelte.d.ts +7 -1
  51. package/dist/visual/ReviewCard.svelte +400 -0
  52. package/dist/visual/ReviewCard.svelte.d.ts +20 -0
  53. package/dist/visual/ReviewProposal.svelte +98 -138
  54. package/dist/visual/ReviewProposal.svelte.d.ts +3 -6
  55. package/dist/visual/ReviewRows.svelte +6 -25
  56. package/dist/visual/ReviewRows.svelte.d.ts +1 -3
  57. package/dist/visual/SlashMenu.svelte +1 -0
  58. package/dist/visual/TipsCard.svelte +1 -1
  59. package/dist/visual/VariantField.svelte +45 -4
  60. package/dist/visual/VariantField.svelte.d.ts +5 -0
  61. package/dist/visual/VisualEditor.svelte +24 -9
  62. package/dist/visual/VisualEditor.svelte.d.ts +8 -1
  63. package/dist/visual/VisualEditorInner.svelte +917 -280
  64. package/dist/visual/VisualEditorInner.svelte.d.ts +8 -1
  65. package/dist/visual/controls.css +2 -2
  66. package/dist/visual/index.d.ts +2 -2
  67. package/dist/visual/proposals.d.ts +25 -24
  68. package/dist/visual/proposals.js +92 -32
  69. package/dist/visual/props.d.ts +18 -18
  70. package/dist/visual/review-order.d.ts +51 -0
  71. package/dist/visual/review-order.js +87 -0
  72. package/dist/visual/review.d.ts +94 -3
  73. package/dist/visual/review.js +37 -2
  74. package/dist/visual/review.svelte.d.ts +77 -20
  75. package/dist/visual/review.svelte.js +306 -49
  76. package/dist/visual/strings.d.ts +59 -25
  77. package/dist/visual/strings.js +90 -29
  78. package/dist/visual/structure.d.ts +17 -3
  79. package/dist/visual/structure.js +71 -5
  80. package/dist/visual/undo.svelte.d.ts +3 -1
  81. package/dist/visual/undo.svelte.js +7 -3
  82. package/package.json +2 -2
@@ -16,6 +16,7 @@ import { EditorState, NodeSelection, Plugin, PluginKey, Selection, TextSelection
16
16
  import { Decoration, DecorationSet, EditorView } from 'prosemirror-view';
17
17
  import { revealProps } from './reveal.js';
18
18
  import { core } from '../lifecycle.js';
19
+ import { tooltips } from '../tooltip.js';
19
20
  import { reportError, errorMessage } from '../errors.js';
20
21
  import { decode, fitsLeaf } from './decode.js';
21
22
  import { offsetToPM, pmToOffset, buildLineIndex, lineIndexOf, mapThroughDelta } from './positions.js';
@@ -30,8 +31,9 @@ import { bodyKeymap, holdsTab } from './keymap.js';
30
31
  import { DEFAULT_LEAVE_STRINGS, leavePlugin } from './leave.js';
31
32
  import { FIELD_KEYS, markKeymap } from './shortcuts.js';
32
33
  import { remoteKey } from './remote.js';
33
- import { DEFAULT_REVIEW_STRINGS, renameBlocks, reviewLayer } from './review.js';
34
- import { blockSchema, isBlockSchema, isInlineSchema, leafSchema, plainSchema } from './schema.js';
34
+ import { renameBlocks, reviewLayer } from './review.js';
35
+ import { valueDiffPlugin } from './value-diff.js';
36
+ import { blockSchema, isBlockSchema, isInlineSchema, isParagraphsSchema, leafSchema } from './schema.js';
35
37
  import { linkPastePlugin } from './link-paste.js';
36
38
  import { dragMovePlugin } from './drag-move.js';
37
39
  import { linePastePlugin } from './line-paste.js';
@@ -195,29 +197,27 @@ function changeCommittable(doc, addr) {
195
197
  return stored !== null && typeof stored === 'object';
196
198
  }
197
199
  /**
198
- * The naming attributes for the `contenteditable`, shared with `ProseValue`. `aria-labelledby`
199
- * supersedes `aria-label`, and `undefined` is returned whole when a leaf takes neither, since
200
- * ProseMirror reads the absence.
200
+ * The `contenteditable`'s role and naming attributes, shared with `ProseValue`. A `div` takes no
201
+ * name without a role, so every leaf states itself a textbox, one-line or not by `multiline`.
202
+ * `aria-labelledby` supersedes `aria-label`.
201
203
  */
202
- export function proseAttributes(opts) {
203
- const attrs = {};
204
+ export function proseAttributes(opts, multiline) {
205
+ const attrs = { role: 'textbox', 'aria-multiline': String(multiline) };
204
206
  if (opts.labelledBy)
205
207
  attrs['aria-labelledby'] = opts.labelledBy;
206
208
  else if (opts.label)
207
209
  attrs['aria-label'] = opts.label;
208
210
  if (opts.describedBy)
209
211
  attrs['aria-describedby'] = opts.describedBy;
210
- return Object.keys(attrs).length ? attrs : undefined;
212
+ return attrs;
211
213
  }
212
- /** A held leaf's attributes, described by its note as well. A non-editable view is no
213
- * textbox to assistive tech or to Tab, so a held leaf states both itself. */
214
+ /** A held leaf's attributes, described by its note as well. A held leaf draws its structure
215
+ * in the block schema, and a non-editable view is no tab stop, so it states both itself. */
214
216
  export function heldAttributes(opts, noteId) {
215
217
  const describedBy = [opts.describedBy, noteId].filter(Boolean).join(' ') || undefined;
216
218
  return {
217
- ...proseAttributes({ ...opts, describedBy }),
218
- role: 'textbox',
219
+ ...proseAttributes({ ...opts, describedBy }, true),
219
220
  'aria-readonly': 'true',
220
- 'aria-multiline': 'true',
221
221
  tabindex: '0'
222
222
  };
223
223
  }
@@ -231,7 +231,8 @@ export function createField(opts) {
231
231
  const inline = !!opts.inline;
232
232
  const plaintext = !!opts.plaintext;
233
233
  // The declared type picks the schema; `plaintext` suppresses every mark (`schema.ts`).
234
- const schema = leafSchema({ plaintext, inline });
234
+ const paragraphs = !!opts.paragraphs;
235
+ const schema = leafSchema({ plaintext, inline, paragraphs });
235
236
  const block = isBlockSchema(schema);
236
237
  // Bound once: the reader reads live, so every read sees the commit before it.
237
238
  const reader = opts.quill.reader(doc);
@@ -264,12 +265,12 @@ export function createField(opts) {
264
265
  : reviewLayer({
265
266
  items: () => reviewItems,
266
267
  lit: () => reviewLit,
267
- strings: () => opts.reviewStrings?.() ?? DEFAULT_REVIEW_STRINGS,
268
268
  parse: (markdown) => {
269
269
  if (!parsed.has(markdown)) {
270
270
  let node;
271
271
  try {
272
- node = decode(core().importMarkdown(markdown).content, schema);
272
+ const shape = paragraphs && !inline ? 'lines' : undefined;
273
+ node = decode(core().importMarkdown(markdown, shape).content, schema);
273
274
  }
274
275
  catch {
275
276
  node = undefined;
@@ -278,24 +279,28 @@ export function createField(opts) {
278
279
  }
279
280
  return parsed.get(markdown);
280
281
  },
281
- act: (id, action, chord) => opts.onReview?.(id, action, chord),
282
+ act: (id, action) => opts.onReview?.(id, action),
282
283
  writing: (on) => opts.onReviewWriting?.(on),
283
- point: (id, via) => opts.onReviewPoint?.(id, via),
284
+ point: (id) => opts.onReviewPoint?.(id),
284
285
  drew: (report) => opts.onReviewDrawn?.(report)
285
286
  });
287
+ let valueProposal;
288
+ const valueDiff = inline || plaintext
289
+ ? valueDiffPlugin(() => valueProposal, (id, state) => opts.onValuePlanned?.(id, state))
290
+ : undefined;
286
291
  // The menu's report channel; the vocabulary is the codec's own constant (`slash.ts`).
287
292
  const slash = block ? opts.onSlash : undefined;
288
293
  // Judged of the value being mounted rather than read off a diagnostic: a routed set
289
294
  // can predate the value it arrives with, and `validation::not_plain` stands in for
290
295
  // `not_single_line` on a one-line `text` field.
291
- const holds = (rt) => !fitsLeaf(rt, { inline, plaintext, islands: true });
296
+ const holds = (rt) => !fitsLeaf(rt, { inline, plaintext, paragraphs, islands: true });
292
297
  let held = holds(reconciler.last);
293
- const named = proseAttributes(opts) ?? {};
298
+ const named = proseAttributes(opts, !inline);
294
299
  const defaultNamed = {
295
300
  ...proseAttributes({
296
301
  ...opts,
297
302
  describedBy: [opts.describedBy, opts.defaultNoteId].filter(Boolean).join(' ') || undefined
298
- }),
303
+ }, !inline),
299
304
  'data-default': ''
300
305
  };
301
306
  const heldNamed = heldAttributes(opts, opts.heldNoteId);
@@ -309,6 +314,10 @@ export function createField(opts) {
309
314
  // where the derivation is out of reach (jsdom).
310
315
  const lineBox = Number.parseFloat(getComputedStyle(container).lineHeight);
311
316
  const clearance = Number.isFinite(lineBox) ? lineBox : undefined;
317
+ // An island's chrome names itself by tip, and a leaf mounted outside the editor has no shell
318
+ // that serves them.
319
+ const root = block ? container.closest('[data-qm-root]') : null;
320
+ const releaseTips = root ? tooltips(root) : undefined;
312
321
  // Prepended, so what the caller draws inside `container` (a held leaf's note)
313
322
  // follows the text it is about.
314
323
  view = new EditorView((dom) => container.prepend(dom), {
@@ -403,7 +412,11 @@ export function createField(opts) {
403
412
  placeholder: () => placeholderText,
404
413
  placeholderUntilEdit: opts.placeholderUntilEdit,
405
414
  cap: opts.cap,
406
- afterHistory: [anchorPlugin(seededAnchors), ...(review ? [review.plugin] : [])]
415
+ afterHistory: [
416
+ anchorPlugin(seededAnchors),
417
+ ...(review ? [review.plugin] : []),
418
+ ...(valueDiff ? [valueDiff] : [])
419
+ ]
407
420
  })
408
421
  });
409
422
  return { state: built, index: seedIndex };
@@ -721,6 +734,17 @@ export function createField(opts) {
721
734
  parsed.delete(markdown);
722
735
  review.refresh(view);
723
736
  },
737
+ setValueProposal(p) {
738
+ if (!valueDiff)
739
+ return;
740
+ if (p?.id === valueProposal?.id &&
741
+ p?.lit === valueProposal?.lit &&
742
+ JSON.stringify([p?.after, p?.before]) ===
743
+ JSON.stringify([valueProposal?.after, valueProposal?.before]))
744
+ return;
745
+ valueProposal = p;
746
+ view.setProps({});
747
+ },
724
748
  reviewElements(id) {
725
749
  return review?.elements(view, id) ?? [];
726
750
  },
@@ -733,6 +757,50 @@ export function createField(opts) {
733
757
  undoReview() {
734
758
  return review?.undo(view) ?? false;
735
759
  },
760
+ projectReview(target) {
761
+ if (!review || held || plaintext)
762
+ return undefined;
763
+ const projected = review.project(view.state);
764
+ if (!projected)
765
+ return undefined;
766
+ const { state: next, mapping, added, ids } = projected;
767
+ const scan = scanDoc(next.doc);
768
+ const after = lineIndexOf(scan);
769
+ const anchors = (anchorKey.getState(next)?.anchors ?? []).map((a) => ({
770
+ id: a.id,
771
+ start: pmToOffset(after, a.start),
772
+ end: pmToOffset(after, a.end)
773
+ }));
774
+ const newRt = scanContent(scan, anchors);
775
+ const at = writeAddr(target, addr);
776
+ try {
777
+ if (opts.emptyUnsets && !anchors.length && isEmptyContent(newRt))
778
+ target.removeField(addr);
779
+ else if (!changeCommittable(target, addr))
780
+ target.replace(at, newRt);
781
+ else {
782
+ const change = lower(reconciler.last, newRt);
783
+ if (change) {
784
+ askCore(reconciler.last, change);
785
+ target.apply(at, change);
786
+ }
787
+ }
788
+ }
789
+ catch {
790
+ target.replace(at, newRt);
791
+ }
792
+ const back = mapping.invert();
793
+ const live = index;
794
+ return {
795
+ ids,
796
+ toProjection: (pos) => pmToOffset(after, mapping.map(offsetToPM(live, pos))),
797
+ toLive(pos) {
798
+ const pm = offsetToPM(after, pos);
799
+ const adds = added.find((a) => a.from <= pm && pm < a.to);
800
+ return adds ? { review: adds.id } : pmToOffset(live, back.map(pm));
801
+ }
802
+ };
803
+ },
736
804
  enterReview(id) {
737
805
  return review?.enter(view, id) ?? false;
738
806
  },
@@ -757,6 +825,7 @@ export function createField(opts) {
757
825
  };
758
826
  },
759
827
  destroy() {
828
+ releaseTips?.();
760
829
  view.destroy();
761
830
  }
762
831
  };
@@ -810,8 +879,8 @@ export function proseLeafPlugins(schema, opts) {
810
879
  // Each answers to something only the block schema holds.
811
880
  if (isBlockSchema(schema))
812
881
  list.push(gapCursor(), pastAtomPlugin(), islandPastePlugin(), tablePastePlugin(), tableCopyPlugin(), markdownPastePlugin(), wordPastePlugin(), listPastePlugin(), taskPlugin(), nestingPlugin());
813
- if (schema === plainSchema)
814
- list.push(plainClipboardPlugin());
882
+ if (isParagraphsSchema(schema))
883
+ list.push(plainClipboardPlugin(schema));
815
884
  if (isInlineSchema(schema))
816
885
  list.push(linePastePlugin());
817
886
  if (opts.placeholder)
@@ -819,18 +888,18 @@ export function proseLeafPlugins(schema, opts) {
819
888
  return list;
820
889
  }
821
890
  /**
822
- * A plain leaf's clipboard text is literal both ways, spelled as the engine spells a `text` value:
891
+ * The clipboard text of a leaf of paragraphs is literal both ways, spelled as the engine spells a `text` value:
823
892
  * a lone `\n` a hard break, a blank line a paragraph boundary, and a run of `\n` its pairs as
824
893
  * paragraph boundaries, an odd one over a hard break before them. Upstream's defaults split pasted
825
894
  * text on any run of newlines and write a copy's breaks as nothing.
826
895
  */
827
- function plainClipboardPlugin() {
828
- const { paragraph, hard_break } = plainSchema.nodes;
896
+ function plainClipboardPlugin(schema) {
897
+ const { paragraph, hard_break } = schema.nodes;
829
898
  const line = (text) => paragraph.create(null, text
830
899
  .split('\n')
831
900
  .flatMap((part, i) => [
832
901
  ...(i ? [hard_break.create()] : []),
833
- ...(part ? [plainSchema.text(part)] : [])
902
+ ...(part ? [schema.text(part)] : [])
834
903
  ]));
835
904
  return new Plugin({
836
905
  props: {
@@ -1,7 +1,7 @@
1
1
  export { markAnchor, 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
- export type { CreateFieldOpts, FieldController, LeafViews } from './field.js';
4
+ export type { CreateFieldOpts, FieldController, LeafProjection, LeafViews } from './field.js';
5
5
  export { capCount } from './cap.js';
6
6
  export { joinLines, pastedLines } from './line-paste.js';
7
7
  export type { TextCap } from './cap.js';
@@ -11,13 +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 { DEFAULT_REVIEW_STRINGS } from './review.js';
15
- export type { BlockPlace, LeafUndrawn, ReviewAction, ReviewReport, ReviewStrings, ReviewVia, TextReview } from './review.js';
14
+ export type { BlockPlace, LeafUndrawn, ReviewAction, ReviewReport, TextReview } from './review.js';
16
15
  export { wordDiff } from './review-diff.js';
16
+ export { valueDiffPlugin } from './value-diff.js';
17
+ export type { ValueProposal, ValueState } from './value-diff.js';
18
+ export { asContent, planValue, valueChanges } from './value-plan.js';
19
+ export type { ValuePlan, ValueChange } from './value-plan.js';
17
20
  export type { DiffHunk } from './review-diff.js';
18
- export { DEFAULT_SHORTCUT_STRINGS, FIELD_KEYS, REVIEW_KEYS, editorShortcuts } from './shortcuts.js';
21
+ export { DEFAULT_SHORTCUT_STRINGS, FIELD_KEYS, LIST_KEYS, REVIEW_KEYS, editorShortcuts } from './shortcuts.js';
19
22
  export type { EditorShortcut, ShortcutScope, ShortcutStrings } from './shortcuts.js';
20
- export { blockSchema, inlineSchema, plaintextSchema, plainSchema, leafSchema, hasMarks } from './schema.js';
23
+ export { blockSchema, inlineSchema, plaintextSchema, plainSchema, linesSchema, leafSchema, hasMarks } from './schema.js';
21
24
  export { rendersHref, storableUrl } from './urls.js';
22
25
  export { decode, fitsInline, fitsLeaf, fitsPlain, renderContent, usvLength } from './decode.js';
23
26
  export { pmToContent, lower } from './encode.js';
@@ -25,17 +25,16 @@ 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
- // The review layer a leaf draws over its blocks: the visual tier's `strings` set extends its
29
- // wording and its `ReviewItem` narrows to the leaf's own.
30
- export { DEFAULT_REVIEW_STRINGS } from './review.js';
31
28
  export { wordDiff } from './review-diff.js';
29
+ export { valueDiffPlugin } from './value-diff.js';
30
+ export { asContent, planValue, valueChanges } from './value-plan.js';
32
31
  // The rich editor's shortcuts as a host lists them, read off the tables the keymaps bind from;
33
32
  // the visual tier's `strings` set extends their wording, and the formatting popover binds its
34
33
  // link chord from `FIELD_KEYS`.
35
- export { DEFAULT_SHORTCUT_STRINGS, FIELD_KEYS, REVIEW_KEYS, editorShortcuts } from './shortcuts.js';
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, leafSchema, hasMarks } from './schema.js';
37
+ export { blockSchema, inlineSchema, plaintextSchema, plainSchema, linesSchema, leafSchema, 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`).
@@ -339,7 +339,7 @@ li.ProseMirror-selectednode::after {
339
339
  font-style: normal;
340
340
  line-height: 1;
341
341
  white-space: nowrap;
342
- color: var(--_qm-ink-label);
342
+ color: var(--_qm-ink-label-raised);
343
343
  pointer-events: none;
344
344
  }
345
345
  .qm-leave-hint:empty {
@@ -457,10 +457,13 @@ li.ProseMirror-selectednode::after {
457
457
  /* The header row is the one weight distinction the island draws: `header` is a
458
458
  separate field in the model rather than a flag on a row, so the surface says so.
459
459
  It takes a tone with it, the band rung, a step toward the ink at both poles. The
460
- rest of a table's type is paper's. */
460
+ rest of a table's type is paper's. Its words hold the ink whatever the table inherits:
461
+ the band leaves the label rung under 4.5:1 at the dark pole, so a header in a table
462
+ that would go is struck and not stepped back. */
461
463
  .qm-table-header-row .qm-table-cell {
462
464
  font-weight: var(--_qm-weight-strong);
463
465
  background: var(--_qm-surface-band);
466
+ color: var(--_qm-ink);
464
467
  }
465
468
  /* The corner cells take the frame's corner, inside its stroke, so a header's band or a
466
469
  selection's wash keeps to the rounded edge rather than painting a square one over
@@ -801,9 +804,13 @@ li.ProseMirror-selectednode::after {
801
804
  }
802
805
  /* The tint runs a hair past the words on either side, as a highlighter does, without moving
803
806
  them: a shadow in the tint's own colour beside the fill, so the line sets as it would
804
- without the proposal. */
807
+ without the proposal. A thin line in the review line under them says it in more than colour,
808
+ as the strike does for the words that would go. */
805
809
  .ProseMirror .qm-review-ins {
806
- text-decoration: none;
810
+ text-decoration: underline;
811
+ text-decoration-color: var(--_qm-review-line);
812
+ text-decoration-thickness: var(--_qm-border-width);
813
+ text-underline-offset: 0.2em;
807
814
  background: var(--_qm-review-tint);
808
815
  box-shadow:
809
816
  calc(-1 * var(--_qm-space-half)) 0 0 var(--_qm-review-tint),
@@ -829,7 +836,8 @@ li.ProseMirror-selectednode::after {
829
836
  background-color var(--_qm-duration-fast) var(--_qm-ease-reverse),
830
837
  box-shadow var(--_qm-duration-fast) var(--_qm-ease-reverse);
831
838
  }
832
- .ProseMirror .qm-review-lit .qm-review-ins {
839
+ .ProseMirror .qm-review-lit .qm-review-ins,
840
+ .ProseMirror .qm-review-ins.qm-review-lit {
833
841
  background: var(--_qm-review-lit);
834
842
  box-shadow:
835
843
  calc(-1 * var(--_qm-space-half)) 0 0 var(--_qm-review-lit),
@@ -841,93 +849,29 @@ li.ProseMirror-selectednode::after {
841
849
  calc(-1 * var(--_qm-space)) 0 0 var(--_qm-review-lit),
842
850
  var(--_qm-space) 0 0 var(--_qm-review-lit);
843
851
  }
844
- /* A block the proposal takes whole that has no words to strike: a rule, an island. */
845
- .ProseMirror .qm-review-out:is(hr, div) {
852
+ /* A block the proposal takes whole that is no line of words. A rule has nothing to read
853
+ and recedes. An island's words are struck where they stand, at the ink a struck word
854
+ takes, so a table that would go is still read cell by cell. */
855
+ .ProseMirror hr.qm-review-out {
846
856
  opacity: var(--_qm-opacity-muted);
847
857
  }
858
+ .ProseMirror div.qm-review-out {
859
+ color: var(--_qm-ink-label);
860
+ text-decoration: line-through;
861
+ text-decoration-color: var(--_qm-review-line);
862
+ }
848
863
  /* The empty paragraph a proposal writes into shows the proposal, not the leaf's ghost. */
849
864
  .ProseMirror .qm-review-held.qm-prose-placeholder[data-placeholder]::after {
850
865
  content: none;
851
866
  }
852
867
 
853
- /* A proposal's two answers, at the end of its last line: chrome set in the paragraph, so
854
- at the chrome's face and the label rung whatever the block around it is set in. A run
855
- rather than a row, so a proposal takes no line the paragraph did not have; the row is
856
- for a block with no line to end. The run stands a space off the words, and the space is
857
- a real one, widened: it hangs at the end of a line the answers wrap from, where a margin
858
- would indent them. Accept is the one outlined thing in the pair, on the card's own
859
- ground so it reads as a button over a tinted block too, and Dismiss rests as a word. */
860
- .ProseMirror .qm-review-chip {
861
- font-family: var(--_qm-font);
862
- font-size: var(--_qm-text-label);
863
- font-style: normal;
864
- font-weight: var(--_qm-weight-mid);
865
- line-height: var(--_qm-leading-tight);
866
- word-spacing: var(--_qm-space);
867
- user-select: none;
868
- }
869
- .qm-review-acts {
870
- display: inline-flex;
871
- gap: var(--_qm-space-half);
872
- vertical-align: baseline;
873
- word-spacing: normal;
874
- white-space: nowrap;
875
- }
876
- .ProseMirror .qm-review-chip-row {
877
- display: block;
878
- margin-block-start: var(--_qm-space);
879
- }
880
- .qm-review-act {
881
- padding: var(--_qm-space-half) var(--_qm-space-2);
882
- border: none;
883
- border-radius: var(--_qm-radius-inner);
884
- background: transparent;
885
- font: inherit;
886
- color: var(--_qm-ink-label);
887
- cursor: pointer;
888
- transition:
889
- background-color var(--_qm-duration-fast) var(--_qm-ease-reverse),
890
- color var(--_qm-duration-fast) var(--_qm-ease-reverse);
891
- }
892
- .qm-review-act:hover {
893
- background: var(--_qm-surface-hover);
894
- color: var(--_qm-ink);
895
- }
896
- .qm-review-act.qm-review-accept {
897
- background: var(--_qm-bg);
898
- box-shadow: inset 0 0 0 var(--_qm-vertical-width) var(--_qm-review-line);
899
- color: var(--_qm-ink);
900
- }
901
- .qm-review-act.qm-review-accept:hover {
902
- background: linear-gradient(var(--_qm-review-tint), var(--_qm-review-tint)) var(--_qm-bg);
903
- }
904
- /* Under a finger the two answers are a tap target each, and stand apart. */
905
- @media (pointer: coarse) {
906
- .qm-review-act {
907
- padding-block: var(--_qm-space);
908
- }
909
- .qm-review-acts {
910
- gap: var(--_qm-space-2);
911
- }
912
- }
913
- /* A proposal the reader's own writing meets says so before its answers, in the label's ink:
914
- taking it writes over what the reader wrote. */
915
- .qm-review-outdated-label {
916
- align-self: center;
917
- color: var(--_qm-ink-label);
918
- }
919
- /* Forced colours drop the tint, which is all that tells a proposed word from the document's
920
- and Accept from a word beside it. A line under the proposed words, an outline round an
921
- added block and the system's button stroke round each answer stand in. */
868
+ /* Forced colours drop the tint and the line's colour. The line under the proposed words stays,
869
+ in the text's own colour, and an outline round an added block stands in for its tint. */
922
870
  @media (forced-colors: active) {
923
871
  .ProseMirror .qm-review-ins {
924
- text-decoration: underline;
872
+ text-decoration-color: currentColor;
925
873
  }
926
874
  .ProseMirror .qm-review-add {
927
875
  outline: var(--_qm-border-width) solid CanvasText;
928
876
  }
929
- .qm-review-act.qm-review-accept,
930
- .qm-review-act.qm-review-dismiss {
931
- border: var(--_qm-border-width) solid ButtonText;
932
- }
933
877
  }
@@ -1,5 +1,6 @@
1
1
  import { type Node as PMNode } from 'prosemirror-model';
2
- import { Plugin, type Transaction } from 'prosemirror-state';
2
+ import { Plugin, type EditorState, type Transaction } from 'prosemirror-state';
3
+ import { Mapping } from 'prosemirror-transform';
3
4
  import { type EditorView } from 'prosemirror-view';
4
5
  /**
5
6
  * One proposal over a prose leaf, by the blocks that place it.
@@ -37,35 +38,19 @@ export type BlockPlace = {
37
38
  * so, turned it down, or undid an answer, so the item is open again with whatever was written
38
39
  * for it taken back by the leaf's own undo. */
39
40
  export type ReviewAction = 'accept' | 'dismiss' | 'reopen';
40
- /** What brought an item under attention: the pointer over it, or the caret in it. */
41
- export type ReviewVia = 'pointer' | 'caret';
42
- /** The words the leaf draws on a proposal's two buttons, and the names of what has no words. */
43
- export interface ReviewStrings {
44
- reviewAccept: string;
45
- reviewDismiss: string;
46
- /** The two buttons' tooltips, which name their chords (`REVIEW_KEYS`). */
47
- reviewAcceptTitle: string;
48
- reviewDismissTitle: string;
49
- /** The accessible name of a proposal's two buttons as a group. */
50
- reviewProposal: string;
51
- /** The label before the buttons of a proposal whose paragraph the reader rewrote since. */
52
- reviewOutdated: string;
53
- }
54
- export declare const DEFAULT_REVIEW_STRINGS: ReviewStrings;
55
41
  /** What the plugin reads and reports through; every reader is live. */
56
42
  export interface ReviewChannel {
57
43
  items(): readonly TextReview[];
58
44
  /** The item under attention, drawn a step stronger. */
59
45
  lit(): string | undefined;
60
- strings(): ReviewStrings;
61
46
  /** `after` as a document under the leaf's schema; `undefined` where it does not parse. */
62
47
  parse(markdown: string): PMNode | undefined;
63
- /** A reader's answer, `chord` where a key gave it. */
64
- act(id: string, action: ReviewAction, chord?: boolean): void;
48
+ /** An answer the leaf gave or took back. */
49
+ act(id: string, action: ReviewAction): void;
65
50
  /** The leaf is writing a taken proposal, and is done. */
66
51
  writing?(on: boolean): void;
67
- /** The item the pointer or the caret is in, `undefined` once it has left. */
68
- point(id: string | undefined, via: ReviewVia): void;
52
+ /** The item the caret is in, `undefined` once it has left. */
53
+ point(id: string | undefined): void;
69
54
  /** What the leaf draws and what it holds and does not draw, on each change of either. */
70
55
  drew(report: ReviewReport): void;
71
56
  }
@@ -75,7 +60,8 @@ export interface ReviewChannel {
75
60
  export type LeafUndrawn = 'parse' | 'taken' | 'applied' | 'block';
76
61
  /** What a leaf draws of the items it was handed. */
77
62
  export interface ReviewReport {
78
- /** The ids drawn, in the order the items were listed. */
63
+ /** The ids drawn, in the leaf's order: what is added ahead of the first block, then each
64
+ * block's rewrite ahead of what is added after it. */
79
65
  ids: readonly string[];
80
66
  /** The drawn proposals the reader's own writing meets: words both changed, or a block one
81
67
  * names gone or no longer the block it read. */
@@ -89,6 +75,22 @@ export interface ReviewReport {
89
75
  }
90
76
  /** Tell the review layer the store took blocks under new ids, each `[was, now]`. */
91
77
  export declare function renameBlocks(tr: Transaction, renamed: readonly (readonly [string, string])[]): void;
78
+ /** A leaf with every proposal it draws taken: the state the accepts leave it in, without one of
79
+ * them dispatched. */
80
+ export interface Projected {
81
+ /** The leaf's state as its accepts would leave it. */
82
+ state: EditorState;
83
+ /** The ids taken, in the order the leaf was handed them. */
84
+ ids: string[];
85
+ /** From the leaf as it stands to the projected one. */
86
+ mapping: Mapping;
87
+ /** The blocks a proposal adds, as ranges of the projected document, by its id. */
88
+ added: {
89
+ id: string;
90
+ from: number;
91
+ to: number;
92
+ }[];
93
+ }
92
94
  /** The handle the leaf keeps on its review layer. */
93
95
  export interface ReviewLayer {
94
96
  plugin: Plugin;
@@ -96,17 +98,20 @@ export interface ReviewLayer {
96
98
  refresh(view: EditorView): void;
97
99
  /** The elements item `id` draws, in document order. */
98
100
  elements(view: EditorView, id: string): HTMLElement[];
99
- /** Put the caret in item `id` and take the focus, so the item's chords answer. False for
100
- * an item the leaf does not draw. */
101
+ /** Put the caret in item `id` and take the focus. False for an item the leaf does not
102
+ * draw. */
101
103
  enter(view: EditorView, id: string): boolean;
102
- /** Answer item `id` as its button would, moving neither the caret nor the focus. False
103
- * where the leaf does not draw it or cannot write it. */
104
+ /** Answer item `id`, moving neither the caret nor the focus. False where the leaf does not
105
+ * draw it or cannot write it. */
104
106
  answer(id: string, action: 'accept' | 'dismiss'): boolean;
105
107
  /** Open a dismissal of item `id` again and say so, the dismissal still held here or
106
108
  * already pruned by the host taking the item off its list. */
107
109
  reopen(view: EditorView, id: string): void;
108
110
  /** Undo the leaf's newest history step: an accept's, which reopens its item. */
109
111
  undo(view: EditorView): boolean;
112
+ /** The leaf with every proposal it draws taken, nothing dispatched; `undefined` where it
113
+ * draws none, or taking them writes nothing. */
114
+ project(state: EditorState): Projected | undefined;
110
115
  }
111
116
  /**
112
117
  * The leaf's review layer. The decorations are a function of the document and the channel's