@quillmark/svelte 0.27.0 → 0.28.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 (95) hide show
  1. package/NOTICE +4 -4
  2. package/README.md +26 -8
  3. package/THEMING.md +10 -8
  4. package/dist/core/address.d.ts +35 -64
  5. package/dist/core/address.js +35 -55
  6. package/dist/core/bloom.d.ts +4 -10
  7. package/dist/core/bloom.js +14 -27
  8. package/dist/core/codec/blocks.d.ts +41 -43
  9. package/dist/core/codec/blocks.js +97 -130
  10. package/dist/core/codec/code.d.ts +7 -10
  11. package/dist/core/codec/code.js +37 -46
  12. package/dist/core/codec/decode.d.ts +19 -23
  13. package/dist/core/codec/decode.js +76 -111
  14. package/dist/core/codec/encode.d.ts +11 -15
  15. package/dist/core/codec/encode.js +60 -67
  16. package/dist/core/codec/field.d.ts +62 -95
  17. package/dist/core/codec/field.js +107 -179
  18. package/dist/core/codec/islands.d.ts +33 -41
  19. package/dist/core/codec/islands.js +76 -86
  20. package/dist/core/codec/lists.d.ts +17 -26
  21. package/dist/core/codec/lists.js +117 -157
  22. package/dist/core/codec/marks.d.ts +4 -3
  23. package/dist/core/codec/marks.js +8 -3
  24. package/dist/core/codec/prose.css +84 -46
  25. package/dist/core/codec/schema.d.ts +18 -23
  26. package/dist/core/codec/schema.js +84 -76
  27. package/dist/core/codec/slash.d.ts +42 -48
  28. package/dist/core/codec/slash.js +0 -0
  29. package/dist/core/codec/table-copy.d.ts +4 -3
  30. package/dist/core/codec/table-copy.js +25 -7
  31. package/dist/core/codec/table-view.d.ts +12 -12
  32. package/dist/core/codec/table-view.js +460 -383
  33. package/dist/core/codec/table.d.ts +94 -61
  34. package/dist/core/codec/table.js +331 -83
  35. package/dist/core/codec/tasks.d.ts +6 -0
  36. package/dist/core/codec/tasks.js +30 -3
  37. package/dist/core/errors.d.ts +15 -30
  38. package/dist/core/errors.js +2 -6
  39. package/dist/core/index.js +7 -12
  40. package/dist/core/lifecycle.d.ts +7 -16
  41. package/dist/core/lifecycle.js +10 -21
  42. package/dist/core/rebind.svelte.d.ts +10 -20
  43. package/dist/core/rebind.svelte.js +15 -27
  44. package/dist/core/rungs.d.ts +14 -11
  45. package/dist/core/rungs.js +17 -19
  46. package/dist/core/teardown.d.ts +4 -6
  47. package/dist/core/teardown.js +7 -10
  48. package/dist/core/theme.css +74 -54
  49. package/dist/index.js +3 -8
  50. package/dist/preset/app.css +3 -1
  51. package/dist/preset/index.css +6 -8
  52. package/dist/preset/recipes.css +12 -15
  53. package/dist/preset/scale.css +18 -17
  54. package/dist/preset/shell.css +10 -0
  55. package/dist/preview/bridge.d.ts +18 -22
  56. package/dist/preview/bridge.js +29 -58
  57. package/dist/preview/controller.d.ts +21 -29
  58. package/dist/preview/controller.js +14 -39
  59. package/dist/preview/geometry.d.ts +13 -34
  60. package/dist/preview/geometry.js +13 -34
  61. package/dist/preview/index.js +4 -16
  62. package/dist/preview/paint.d.ts +3 -3
  63. package/dist/preview/paint.js +28 -68
  64. package/dist/preview/strings.d.ts +1 -1
  65. package/dist/preview/strings.js +2 -14
  66. package/dist/preview/zoom.d.ts +18 -23
  67. package/dist/preview/zoom.js +28 -27
  68. package/dist/visual/ArrayField.svelte +77 -16
  69. package/dist/visual/BooleanField.svelte +27 -14
  70. package/dist/visual/Card.svelte +61 -48
  71. package/dist/visual/CardControls.svelte +5 -11
  72. package/dist/visual/DateField.svelte +20 -4
  73. package/dist/visual/EnumField.svelte +3 -0
  74. package/dist/visual/FieldHint.svelte +2 -1
  75. package/dist/visual/FormatPopover.svelte +82 -15
  76. package/dist/visual/FormatPopover.svelte.d.ts +4 -0
  77. package/dist/visual/MatrixAdd.svelte +30 -12
  78. package/dist/visual/MatrixField.svelte +24 -16
  79. package/dist/visual/NumberField.svelte +7 -0
  80. package/dist/visual/ObjectField.svelte +4 -4
  81. package/dist/visual/ProseField.svelte +0 -5
  82. package/dist/visual/TipsCard.svelte +11 -10
  83. package/dist/visual/VariantField.svelte +3 -1
  84. package/dist/visual/VisualEditorInner.svelte +19 -3
  85. package/dist/visual/controls.css +7 -2
  86. package/dist/visual/fonts.d.ts +18 -0
  87. package/dist/visual/fonts.js +59 -0
  88. package/dist/visual/icons/nodes.d.ts +0 -5
  89. package/dist/visual/icons/nodes.js +0 -4
  90. package/dist/visual/props.d.ts +14 -1
  91. package/dist/visual/strings.d.ts +7 -0
  92. package/dist/visual/strings.js +5 -2
  93. package/dist/visual/structure.d.ts +43 -87
  94. package/dist/visual/structure.js +42 -83
  95. package/package.json +2 -2
@@ -1,67 +1,65 @@
1
1
  import type { Attrs, Schema } from 'prosemirror-model';
2
2
  import type { Command, EditorState, Transaction } from 'prosemirror-state';
3
- /** `# `: the heading `level` deep. `list_item` is `block+`, so one inside an item is a
4
- * shape the content holds and `importMarkdown` produces from `- # title`. */
3
+ /**
4
+ * `# `: the heading `level` deep. `list_item` is `block+`, so a heading inside an item is a shape
5
+ * `importMarkdown` produces from `- # title`.
6
+ */
5
7
  export declare function toHeading(level: number): Command;
6
- /** A fence, carrying `attrs` (its `lang`). The exit paragraph after it is the one a
7
- * block island mints for the same reason, sharpened: a code block is the one block a
8
- * gap cursor will not sit beside either, so a fence at the end of a body leaves the
9
- * caret nowhere to go. The caret stays in the fence, not in the exit it minted. */
8
+ /**
9
+ * A fence, carrying `attrs` (its `lang`). The exit paragraph after it exists because a gap cursor
10
+ * will not sit beside a code block, so a fence at the end of a body would leave the caret nowhere
11
+ * to go. The caret stays in the fence.
12
+ */
10
13
  export declare function toCodeBlock(attrs?: Attrs): Command;
11
- /** `---`. A divider is a whole block, so this replaces its textblock rather than
12
- * retyping one: `horizontal_rule` holds no content to retype into, and an empty block
13
- * is the whole of what it may replace — anything else in one is a paragraph being
14
- * edited, which a replace would eat. */
14
+ /**
15
+ * `---`. A divider is a whole block, so this replaces its textblock: `horizontal_rule` holds no
16
+ * content to retype into, and only an empty block may be replaced, anything else being a paragraph
17
+ * being edited.
18
+ */
15
19
  export declare function insertDivider(): Command;
16
- /** `> `. No item guard: what this wraps an item's first block in is a container the
17
- * content holds, where a list wrapping one mints an item whose only content is an
18
- * item. */
20
+ /**
21
+ * `> `. No item guard: wrapping an item's first block in a quote is a container the content holds.
22
+ */
19
23
  export declare function wrapInQuote(): Command;
20
- /** `- ` / `1. `. Beside a list of its kind the line joins it, whatever `N` is typed: a
21
- * number comes from position. Elsewhere `N. ` is the number the new list counts from,
22
- * and at the head of an item the shorthand is the item's (§`listAtItem`), `N` reading
23
- * the same way; a marker the item already shows is taken as typed and changes nothing. */
24
+ /**
25
+ * `- ` / `1. `. Beside a list of its kind the line joins it, whatever `N` is typed: a number comes
26
+ * from position. Elsewhere `N. ` is the number the new list counts from; at the head of an item the
27
+ * shorthand is the item's (§`listAtItem`), and a marker the item already shows changes nothing.
28
+ */
24
29
  export declare function wrapInList(ordered: boolean, attrs?: Attrs | null): Command;
25
30
  /**
26
- * `a. `, `(1) `, `(a) `: the markers a nested level draws, typed at the head of a nested
27
- * item's first line, where the item already is the thing typed. Taken as typed and
28
- * changing nothing, as `N. ` on an item of a numbered list is: the marker comes from the
29
- * item's position and the quill's style for its depth, never from the text. Anywhere
30
- * else these stay text, being no markdown list marker.
31
+ * `a. `, `(1) `, `(a) `: the markers a nested level draws, typed at the head of a nested item's
32
+ * first line, where the item already is the thing typed. Taken as typed and changing nothing: the
33
+ * marker comes from the item's position and the quill's style for its depth. Anywhere else these
34
+ * stay text.
31
35
  */
32
36
  export declare function takeNestedMarker(): Command;
33
37
  /**
34
- * A list pick, at whatever caret the writer has. `atHead` is the shorthand's guard,
35
- * where a prefix firing mid-sentence would eat a dash; a pick is a gesture at the caret.
38
+ * A list pick, at whatever caret the writer has. `atHead` is the shorthand's guard against a prefix
39
+ * eating a dash mid-sentence; a pick is a gesture at the caret.
36
40
  *
37
- * At the end of a non-empty block it opens a fresh empty item below it, Enter then `- `
38
- * as one gesture. Anywhere else it wraps the whole block, the smaller surprise: a writer
39
- * who meant to split presses Enter first. In an item's first block it is the shorthand's
40
- * item gesture (§`listAtItem`), offered only where that changes something.
41
+ * At the end of a non-empty block it opens a fresh empty item below (Enter then `- ` as one
42
+ * gesture); anywhere else it wraps the whole block. In an item's first block it is the item gesture
43
+ * (§`listAtItem`), offered only where that changes something.
41
44
  */
42
45
  export declare function pickList(ordered: boolean): Command;
43
46
  /**
44
- * The bullet pick where it puts a line under an item one level deeper than the caret
45
- * stood, and nowhere else: the pick a subparagraph names. Outside every item the bullet
46
- * it would mint stands at the first level, and on a list's first item the bullet pick
47
- * retypes the list instead.
47
+ * The bullet pick where it puts a line under an item one level deeper than the caret stood, and
48
+ * nowhere else: the subparagraph pick. Elsewhere the bullet would mint a first-level list, or on a
49
+ * list's first item retype it.
48
50
  */
49
51
  export declare function pickSubList(): Command;
50
52
  /**
51
- * Run `command` in place of the text at `[from, to)`: one transaction carrying the
52
- * delete and the command's own steps. One rather than two because two would be two
53
- * commits, two undo steps and two recompiles for one gesture; the command is built
54
- * against the state the delete leaves, which is exactly what its steps were computed
55
- * for.
56
- *
57
- * `null` is a command that declined, and nothing is consumed: the shorthand stays the
58
- * text it was typed as.
53
+ * Run `command` in place of the text at `[from, to)` as one transaction carrying the delete and the
54
+ * command's steps: two would be two commits, undo steps and recompiles for one gesture. `null` is a
55
+ * command that declined; nothing is consumed and the shorthand stays text.
59
56
  */
60
57
  export declare function consuming(state: EditorState, from: number, to: number, command: Command): {
61
58
  tr: Transaction;
62
59
  produced: Transaction;
63
60
  } | null;
64
- /** The body-wide link of the leaf's key chains: `{}` for a schema with no paragraph
65
- * to mint. Outermost of the structural links, being about the body, or about the
66
- * caret's own line, rather than about the surface either stands in. */
61
+ /**
62
+ * The body-wide link of the leaf's key chains: `{}` for a schema with no paragraph to mint.
63
+ * Outermost of the structural links.
64
+ */
67
65
  export declare function blockKeymap(schema: Schema): Record<string, Command>;
@@ -5,8 +5,7 @@ import { canJoin, findWrapping } from 'prosemirror-transform';
5
5
  import { withinNesting } from './nesting.js';
6
6
  import { takesLineBreak } from './schema.js';
7
7
  import { joinLists } from './touching.js';
8
- /** The head of a textblock: where a shorthand fires, and where a pick lands once its
9
- * run is consumed. */
8
+ /** The head of a textblock: where a shorthand fires and a pick lands once its run is consumed. */
10
9
  function atHead(state) {
11
10
  const { $from, empty } = state.selection;
12
11
  return empty && $from.parent.isTextblock && $from.parentOffset === 0;
@@ -17,11 +16,9 @@ function fits($from, type) {
17
16
  return $from.node(-1).canReplaceWith($from.index(-1), $from.indexAfter(-1), type);
18
17
  }
19
18
  /**
20
- * The first block of an item that already exists: where a list gesture retypes the
21
- * item's list rather than wrapping the block, which would mint an item whose only
22
- * content is another item, a level with nothing on it. Tab is the indent gesture. A
23
- * later block of the item is not this case: wrapping a continuation paragraph is how a
24
- * sub-list opens under text.
19
+ * The first block of an item that already exists: where a list gesture retypes the item's list
20
+ * rather than wrapping the block, which would mint an item whose only content is another item.
21
+ * Wrapping a later block is how a sub-list opens under text.
25
22
  */
26
23
  function openingAnItem($from, item) {
27
24
  if (!item || $from.depth < 2)
@@ -40,12 +37,12 @@ function retype(name, attrs) {
40
37
  return true;
41
38
  };
42
39
  }
43
- /** Replace every `hard_break` in the caret's block with a space, ahead of a retype into
44
- * a type that holds none. `setBlockType` clears what the new type cannot hold by
45
- * deleting it, which joins the text either side with nothing and glues the words; a
46
- * space is what the break becomes at every other door (`breaks.ts`, `decode.ts`). A
47
- * break and a space are both one position wide, so an earlier replacement leaves every
48
- * later one addressed. */
40
+ /**
41
+ * Replace every `hard_break` in the caret's block with a space, ahead of a retype into a type that
42
+ * holds none: `setBlockType` would delete them and glue the words (`breaks.ts`, `decode.ts` make
43
+ * the same space). Break and space are both one position wide, so later replacements stay
44
+ * addressed.
45
+ */
49
46
  function spaceBreaks(tr, $from, type) {
50
47
  const br = tr.doc.type.schema.nodes.hard_break;
51
48
  if (!br || takesLineBreak(type))
@@ -57,11 +54,11 @@ function spaceBreaks(tr, $from, type) {
57
54
  at += child.nodeSize;
58
55
  });
59
56
  }
60
- /** `wrappingInputRule`'s body: wrap the block range at `pos`, then join a sibling of
61
- * the same type — the boundaries the wrap itself opens (`lists.ts` §cleanup:
62
- * command-local, never a global pass). A list joins on both sides (`touching.ts`), a
63
- * quote the one above. False where no wrap fits, or where the one that does nests past
64
- * `MAX_NESTING_DEPTH` (`nesting.ts`). */
57
+ /**
58
+ * `wrappingInputRule`'s body: wrap the block range at `pos`, then join a sibling of the same type
59
+ * (a list on both sides, a quote the one above; `touching.ts`). False where no wrap fits or it
60
+ * nests past `MAX_NESTING_DEPTH` (`nesting.ts`).
61
+ */
65
62
  function wrapAt(tr, pos, type, attrs) {
66
63
  const range = tr.doc.resolve(pos).blockRange();
67
64
  const wrapping = range && findWrapping(range, type, attrs);
@@ -76,15 +73,18 @@ function wrapAt(tr, pos, type, attrs) {
76
73
  tr.join(range.start);
77
74
  return withinNesting(tr.doc);
78
75
  }
79
- /** `# `: the heading `level` deep. `list_item` is `block+`, so one inside an item is a
80
- * shape the content holds and `importMarkdown` produces from `- # title`. */
76
+ /**
77
+ * `# `: the heading `level` deep. `list_item` is `block+`, so a heading inside an item is a shape
78
+ * `importMarkdown` produces from `- # title`.
79
+ */
81
80
  export function toHeading(level) {
82
81
  return retype('heading', { level });
83
82
  }
84
- /** A fence, carrying `attrs` (its `lang`). The exit paragraph after it is the one a
85
- * block island mints for the same reason, sharpened: a code block is the one block a
86
- * gap cursor will not sit beside either, so a fence at the end of a body leaves the
87
- * caret nowhere to go. The caret stays in the fence, not in the exit it minted. */
83
+ /**
84
+ * A fence, carrying `attrs` (its `lang`). The exit paragraph after it exists because a gap cursor
85
+ * will not sit beside a code block, so a fence at the end of a body would leave the caret nowhere
86
+ * to go. The caret stays in the fence.
87
+ */
88
88
  export function toCodeBlock(attrs) {
89
89
  return (state, dispatch) => {
90
90
  const { code_block: code, paragraph } = state.schema.nodes;
@@ -99,10 +99,11 @@ export function toCodeBlock(attrs) {
99
99
  return true;
100
100
  };
101
101
  }
102
- /** `---`. A divider is a whole block, so this replaces its textblock rather than
103
- * retyping one: `horizontal_rule` holds no content to retype into, and an empty block
104
- * is the whole of what it may replace — anything else in one is a paragraph being
105
- * edited, which a replace would eat. */
102
+ /**
103
+ * `---`. A divider is a whole block, so this replaces its textblock: `horizontal_rule` holds no
104
+ * content to retype into, and only an empty block may be replaced, anything else being a paragraph
105
+ * being edited.
106
+ */
106
107
  export function insertDivider() {
107
108
  return (state, dispatch) => {
108
109
  const { horizontal_rule: rule, paragraph } = state.schema.nodes;
@@ -121,9 +122,9 @@ export function insertDivider() {
121
122
  return true;
122
123
  };
123
124
  }
124
- /** `> `. No item guard: what this wraps an item's first block in is a container the
125
- * content holds, where a list wrapping one mints an item whose only content is an
126
- * item. */
125
+ /**
126
+ * `> `. No item guard: wrapping an item's first block in a quote is a container the content holds.
127
+ */
127
128
  export function wrapInQuote() {
128
129
  return (state, dispatch) => {
129
130
  const quote = state.schema.nodes.blockquote;
@@ -137,10 +138,11 @@ export function wrapInQuote() {
137
138
  return true;
138
139
  };
139
140
  }
140
- /** `- ` / `1. `. Beside a list of its kind the line joins it, whatever `N` is typed: a
141
- * number comes from position. Elsewhere `N. ` is the number the new list counts from,
142
- * and at the head of an item the shorthand is the item's (§`listAtItem`), `N` reading
143
- * the same way; a marker the item already shows is taken as typed and changes nothing. */
141
+ /**
142
+ * `- ` / `1. `. Beside a list of its kind the line joins it, whatever `N` is typed: a number comes
143
+ * from position. Elsewhere `N. ` is the number the new list counts from; at the head of an item the
144
+ * shorthand is the item's (§`listAtItem`), and a marker the item already shows changes nothing.
145
+ */
144
146
  export function wrapInList(ordered, attrs = null) {
145
147
  return (state, dispatch) => {
146
148
  if (!atHead(state))
@@ -152,11 +154,10 @@ export function wrapInList(ordered, attrs = null) {
152
154
  };
153
155
  }
154
156
  /**
155
- * `a. `, `(1) `, `(a) `: the markers a nested level draws, typed at the head of a nested
156
- * item's first line, where the item already is the thing typed. Taken as typed and
157
- * changing nothing, as `N. ` on an item of a numbered list is: the marker comes from the
158
- * item's position and the quill's style for its depth, never from the text. Anywhere
159
- * else these stay text, being no markdown list marker.
157
+ * `a. `, `(1) `, `(a) `: the markers a nested level draws, typed at the head of a nested item's
158
+ * first line, where the item already is the thing typed. Taken as typed and changing nothing: the
159
+ * marker comes from the item's position and the quill's style for its depth. Anywhere else these
160
+ * stay text.
160
161
  */
161
162
  export function takeNestedMarker() {
162
163
  return (state, dispatch) => {
@@ -171,21 +172,16 @@ export function takeNestedMarker() {
171
172
  };
172
173
  }
173
174
  /**
174
- * A list gesture in an item's first block. On a list's first item it retypes the list,
175
- * every item with it: a list is one kind, and that item is where a writer changes it.
176
- * `number` is the shorthand's `N`, the list's `start`, the one door back to 1 for a list
177
- * that arrived counting from elsewhere. On a later item, a list of the other kind is a
178
- * sub-list: the item sinks under the one above, as Tab sinks it, into a list of that
179
- * kind — `- ` in a new numbered paragraph is its first lettered subparagraph, never the
180
- * whole memo turned to bullets. A sub-list already standing there of that kind takes the
181
- * item as its next.
175
+ * A list gesture in an item's first block. On a list's first item it retypes the whole list;
176
+ * `number` is the shorthand's `N`, the list's `start`, the one door back to 1 for a list that
177
+ * arrived counting from elsewhere. On a later item, a list of the other kind is a sub-list: the
178
+ * item sinks under the one above, as Tab sinks it, into a list of that kind (`- ` in a numbered
179
+ * paragraph is its first lettered subparagraph). A sub-list already standing there takes the item
180
+ * as its next.
182
181
  *
183
- * A gesture that changes nothing — the kind the item's list already is, and on a first
184
- * item the number it already counts from — goes unoffered as a pick. As a shorthand
185
- * (`take`) it is claimed and changes nothing, so the run is consumed: a writer typing
186
- * `2. Second` into the second item meant the number the item already shows, and an item
187
- * reading `2. 2. Second` is the one outcome no writer typed for. Backspace on the press
188
- * after gives the text back.
182
+ * A gesture that changes nothing goes unoffered as a pick. As a shorthand (`take`) it is claimed
183
+ * and consumes the run, since `2. 2. Second` is an outcome no writer typed for; Backspace on the
184
+ * press after gives the text back.
189
185
  */
190
186
  function listAtItem(ordered, number, take = false) {
191
187
  return (state, dispatch) => {
@@ -229,13 +225,12 @@ function listAtItem(ordered, number, take = false) {
229
225
  };
230
226
  }
231
227
  /**
232
- * A list pick, at whatever caret the writer has. `atHead` is the shorthand's guard,
233
- * where a prefix firing mid-sentence would eat a dash; a pick is a gesture at the caret.
228
+ * A list pick, at whatever caret the writer has. `atHead` is the shorthand's guard against a prefix
229
+ * eating a dash mid-sentence; a pick is a gesture at the caret.
234
230
  *
235
- * At the end of a non-empty block it opens a fresh empty item below it, Enter then `- `
236
- * as one gesture. Anywhere else it wraps the whole block, the smaller surprise: a writer
237
- * who meant to split presses Enter first. In an item's first block it is the shorthand's
238
- * item gesture (§`listAtItem`), offered only where that changes something.
231
+ * At the end of a non-empty block it opens a fresh empty item below (Enter then `- ` as one
232
+ * gesture); anywhere else it wraps the whole block. In an item's first block it is the item gesture
233
+ * (§`listAtItem`), offered only where that changes something.
239
234
  */
240
235
  export function pickList(ordered) {
241
236
  return (state, dispatch) => {
@@ -266,10 +261,9 @@ function itemDepth($pos, item) {
266
261
  return n;
267
262
  }
268
263
  /**
269
- * The bullet pick where it puts a line under an item one level deeper than the caret
270
- * stood, and nowhere else: the pick a subparagraph names. Outside every item the bullet
271
- * it would mint stands at the first level, and on a list's first item the bullet pick
272
- * retypes the list instead.
264
+ * The bullet pick where it puts a line under an item one level deeper than the caret stood, and
265
+ * nowhere else: the subparagraph pick. Elsewhere the bullet would mint a first-level list, or on a
266
+ * list's first item retype it.
273
267
  */
274
268
  export function pickSubList() {
275
269
  const pick = pickList(false);
@@ -287,9 +281,10 @@ export function pickSubList() {
287
281
  return true;
288
282
  };
289
283
  }
290
- /** Wrap the caret's whole block in a list, wherever in the block the caret sits: the
291
- * wrap opens at the block's head, so it joins the lists beside it as the shorthand's
292
- * does. */
284
+ /**
285
+ * Wrap the caret's whole block in a list wherever the caret sits; the wrap opens at the block's
286
+ * head, so it joins neighbouring lists as the shorthand does.
287
+ */
293
288
  function wrapBlock(state, dispatch, ordered, attrs) {
294
289
  const { paragraph, list_item: item } = state.schema.nodes;
295
290
  const list = state.schema.nodes[ordered ? 'ordered_list' : 'bullet_list'];
@@ -300,9 +295,8 @@ function wrapBlock(state, dispatch, ordered, attrs) {
300
295
  return listAtItem(ordered, null)(state, dispatch);
301
296
  const pos = $from.start();
302
297
  const tr = state.tr;
303
- // A paragraph item wherever this fires: `# ` inside the item is the gesture that
304
- // mints `list_item > heading`, and a wrap keeping the heading is a second door onto
305
- // that shape. Positions survive the retype — same content, same size.
298
+ // A paragraph item wherever this fires: a wrap keeping a heading would be a second door onto
299
+ // the `list_item > heading` shape `# ` mints. Positions survive the retype.
306
300
  if ($from.parent.type !== paragraph)
307
301
  tr.setBlockType(pos, pos, paragraph);
308
302
  if (!wrapAt(tr, pos, list, attrs))
@@ -311,14 +305,9 @@ function wrapBlock(state, dispatch, ordered, attrs) {
311
305
  return true;
312
306
  }
313
307
  /**
314
- * Run `command` in place of the text at `[from, to)`: one transaction carrying the
315
- * delete and the command's own steps. One rather than two because two would be two
316
- * commits, two undo steps and two recompiles for one gesture; the command is built
317
- * against the state the delete leaves, which is exactly what its steps were computed
318
- * for.
319
- *
320
- * `null` is a command that declined, and nothing is consumed: the shorthand stays the
321
- * text it was typed as.
308
+ * Run `command` in place of the text at `[from, to)` as one transaction carrying the delete and the
309
+ * command's steps: two would be two commits, undo steps and recompiles for one gesture. `null` is a
310
+ * command that declined; nothing is consumed and the shorthand stays text.
322
311
  */
323
312
  export function consuming(state, from, to, command) {
324
313
  const tr = state.tr.delete(from, to);
@@ -333,24 +322,20 @@ export function consuming(state, from, to, command) {
333
322
  tr.setSelection(Selection.fromJSON(tr.doc, produced.selection.toJSON()));
334
323
  return { tr, produced };
335
324
  }
336
- /** The head of the body's first block: one position per open token above the caret,
337
- * and nothing before it. */
325
+ /** The head of the body's first block: one position per open token above the caret. */
338
326
  function atBodyStart($from) {
339
327
  return $from.pos === $from.depth;
340
328
  }
341
329
  /**
342
- * Enter at the very start of a body whose first block takes no caret above it → an
343
- * empty paragraph there, the caret staying with the text it pushed down.
330
+ * Enter at the very start of a body whose first block takes no caret above it → an empty paragraph
331
+ * there, the caret staying with the text it pushed down.
344
332
  *
345
- * A code block and a quote are blocks `prosemirror-gapcursor` declines to sit beside,
346
- * and nothing else mints a block above one: two keystrokes on an empty body (` ``` `,
347
- * `> `) put one first, and a document carrying one there could never be given a title.
333
+ * `prosemirror-gapcursor` declines to sit beside a code block or a quote, and two keystrokes on an
334
+ * empty body (` ``` `, `> `) put one first, leaving a document that could never be given a title.
348
335
  *
349
- * Declines wherever the first block is a plain textblock, whose Enter-split already
350
- * leaves a paragraph above, and on an empty one, which the links after it answer. An
351
- * item's first line of prose declines too: Enter at its head is the list's new first
352
- * item, as at every item, and the empty item's own Enter lifts it out to the paragraph a
353
- * title takes. A fence opening that item is the fence case and takes the paragraph.
336
+ * Declines where the first block is a plain textblock (its Enter-split leaves a paragraph above) or
337
+ * empty (the links after answer). An item's first line of prose declines too: Enter there is the
338
+ * list's new first item. A fence opening that item takes the paragraph.
354
339
  */
355
340
  const paragraphAtBodyStart = (state, dispatch) => {
356
341
  const { paragraph, list_item: item } = state.schema.nodes;
@@ -367,16 +352,10 @@ const paragraphAtBodyStart = (state, dispatch) => {
367
352
  return true;
368
353
  };
369
354
  /**
370
- * Enter in an empty fence that opens the body → the fence, retyped to a paragraph.
371
- *
372
- * An empty first item exits its list and an empty first quoted paragraph lifts out of
373
- * the quote, each leaving the one paragraph a caret above needs. A fence answers with
374
- * `newlineInCode` instead — a line inside the block, in the direction already open —
375
- * so the empty fence a body's first ` ``` ` mints holds a caret with nothing above it
376
- * and no key that mints one.
377
- *
378
- * Retyping rather than inserting above, for the reason those exits leave one paragraph
379
- * and not two: an empty fence carries nothing to keep.
355
+ * Enter in an empty fence that opens the body → the fence, retyped to a paragraph. An empty first
356
+ * item exits its list and an empty first quoted paragraph lifts out of the quote, each leaving the
357
+ * one paragraph a caret above needs; a fence would answer `newlineInCode` and leave no key that
358
+ * mints one. Retyped rather than inserted above: an empty fence carries nothing to keep.
380
359
  */
381
360
  const paragraphFromEmptyFence = (state, dispatch) => {
382
361
  const paragraph = state.schema.nodes.paragraph;
@@ -391,15 +370,10 @@ const paragraphFromEmptyFence = (state, dispatch) => {
391
370
  return true;
392
371
  };
393
372
  /**
394
- * Enter over a selection spanning two textblocks: take the selection, then split
395
- * what is left, both in one transaction.
396
- *
397
- * The edit upstream's `splitBlock` means, computed against a document that exists.
398
- * It deletes the selection inside its own transaction and then reads the default
399
- * block's fit off the *pre-delete* document — `$from.node(splitDepth - 1)` against an
400
- * index resolved in the new one — so where the range starts at the head of a
401
- * `defining` block and ends inside a list, it retypes a `list_item` to a paragraph
402
- * and throws `RangeError` out of the keystroke.
373
+ * Enter over a selection spanning two textblocks: take the selection, then split what is left, in
374
+ * one transaction. Upstream's `splitBlock` reads the default block's fit off the pre-delete
375
+ * document, so where the range starts at the head of a `defining` block and ends inside a list it
376
+ * retypes a `list_item` to a paragraph and throws `RangeError`.
403
377
  */
404
378
  const splitAcrossBlocks = (state, dispatch) => {
405
379
  const { $from, $to, empty } = state.selection;
@@ -417,21 +391,14 @@ const splitAcrossBlocks = (state, dispatch) => {
417
391
  return true;
418
392
  };
419
393
  /**
420
- * Delete on an empty textblock → take the line, whatever stands below moving up
421
- * whole and keeping what it is.
422
- *
423
- * The links below it leave the line standing: the base keymap joins the block below
424
- * into it — a list's first item lifted out to fill it, its marker gone — and the atom
425
- * link arms an island for the press after. Upstream takes the line only where the
426
- * sibling holds the same kind of content, so a heading below keeps its level where a
427
- * bullet loses its marker.
394
+ * Delete on an empty textblock → take the line, whatever stands below moving up whole and keeping
395
+ * what it is. The links below leave the line standing: the base keymap joins the block below into
396
+ * it (a list's first item loses its marker), and upstream takes the line only where the sibling
397
+ * holds the same kind of content.
428
398
  *
429
- * Declines where the parent cannot spare the block: an empty item and an empty quote
430
- * are the whole of what holds them, and the key is whichever link answers a construct
431
- * with nothing in it. An empty fence is not that case — the doc spares it, and it
432
- * carries no text to lose. Declines with nothing after it too: a line with no next
433
- * line is Backspace's. The line was the one thing between two lists of a kind, they
434
- * are one list after it.
399
+ * Declines where the parent cannot spare the block (an empty item or quote is the whole of what
400
+ * holds it; an empty fence is spared) and with nothing after it, which is Backspace's. The line may
401
+ * have been the one thing between two lists of a kind; they are one list after it.
435
402
  */
436
403
  const takeEmptyLine = (state, dispatch) => {
437
404
  const { $from, empty } = state.selection;
@@ -450,10 +417,9 @@ const takeEmptyLine = (state, dispatch) => {
450
417
  return true;
451
418
  };
452
419
  /**
453
- * Backspace at a heading's head → a paragraph, where it stands, and the press after is
454
- * the join. The first press takes off the block's own shape, which is the whole of what
455
- * it edits: the base keymap's join would merge the heading's text into the block above
456
- * and lose the heading with it, and at the body's start it does nothing at all.
420
+ * Backspace at a heading's head → a paragraph, where it stands; the press after is the join. The
421
+ * base keymap's join would merge the heading's text into the block above and lose the heading, and
422
+ * at the body's start does nothing.
457
423
  */
458
424
  const unheading = (state, dispatch) => {
459
425
  const paragraph = state.schema.nodes.paragraph;
@@ -465,9 +431,10 @@ const unheading = (state, dispatch) => {
465
431
  dispatch?.(state.tr.setBlockType($from.pos, $from.pos, paragraph).scrollIntoView());
466
432
  return true;
467
433
  };
468
- /** The body-wide link of the leaf's key chains: `{}` for a schema with no paragraph
469
- * to mint. Outermost of the structural links, being about the body, or about the
470
- * caret's own line, rather than about the surface either stands in. */
434
+ /**
435
+ * The body-wide link of the leaf's key chains: `{}` for a schema with no paragraph to mint.
436
+ * Outermost of the structural links.
437
+ */
471
438
  export function blockKeymap(schema) {
472
439
  if (!schema.nodes.paragraph)
473
440
  return {};
@@ -1,16 +1,13 @@
1
1
  import type { Schema } from 'prosemirror-model';
2
2
  import { type Command } from 'prosemirror-state';
3
3
  /**
4
- * The `code_block` link of the body's key chains: `{}` for the one-line and plain
5
- * schemas, which declare no code node.
4
+ * The `code_block` link of the body's key chains: `{}` for the one-line and plain schemas, which
5
+ * declare no code node.
6
6
  *
7
- * `Enter` is upstream's `newlineInCode`, and it is load-bearing rather than
8
- * cosmetic: inside a `list_item > code_block` the list link's `splitListItem`
9
- * otherwise splits the item in two, each half holding a code block. `Shift-Enter` is
10
- * the same command because it is the same edit: the line break the key means
11
- * everywhere else (`breaks.ts`) is, inside a fence, the newline Enter already takes.
12
- * Every command here declines away from a code block — inside one for the keys about
13
- * its text and its last line, against one for the two about its edge — so the list
14
- * links keep the keys elsewhere.
7
+ * `Enter` is upstream's `newlineInCode`, load-bearing: inside a `list_item > code_block` the list
8
+ * link's `splitListItem` would otherwise split the item in two. `Shift-Enter` is the same command:
9
+ * the line break the key means elsewhere (`breaks.ts`) is, inside a fence, the newline Enter takes.
10
+ * Every command here declines away from a code block (inside it for the text and last-line keys,
11
+ * against it for the two edge keys), leaving the list links the keys elsewhere.
15
12
  */
16
13
  export declare function codeKeymap(schema: Schema): Record<string, Command>;