@openleaf-editor/core 0.1.0-beta.3 → 0.1.0-beta.5

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 (44) hide show
  1. package/README.md +38 -6
  2. package/dist/autolink.d.ts +15 -4
  3. package/dist/autolink.d.ts.map +1 -1
  4. package/dist/autolink.js +91 -21
  5. package/dist/autolink.js.map +1 -1
  6. package/dist/code-spellcheck.d.ts +33 -0
  7. package/dist/code-spellcheck.d.ts.map +1 -0
  8. package/dist/code-spellcheck.js +119 -0
  9. package/dist/code-spellcheck.js.map +1 -0
  10. package/dist/commands.d.ts +6 -2
  11. package/dist/commands.d.ts.map +1 -1
  12. package/dist/commands.js +137 -5
  13. package/dist/commands.js.map +1 -1
  14. package/dist/decoration-range.d.ts +26 -0
  15. package/dist/decoration-range.d.ts.map +1 -0
  16. package/dist/decoration-range.js +103 -0
  17. package/dist/decoration-range.js.map +1 -0
  18. package/dist/figure-drag.d.ts +26 -0
  19. package/dist/figure-drag.d.ts.map +1 -0
  20. package/dist/figure-drag.js +75 -0
  21. package/dist/figure-drag.js.map +1 -0
  22. package/dist/gapcursor.d.ts +14 -0
  23. package/dist/gapcursor.d.ts.map +1 -0
  24. package/dist/gapcursor.js +17 -0
  25. package/dist/gapcursor.js.map +1 -0
  26. package/dist/index.d.ts +3 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +6 -0
  29. package/dist/index.js.map +1 -1
  30. package/dist/isolating-selection.d.ts +19 -1
  31. package/dist/isolating-selection.d.ts.map +1 -1
  32. package/dist/isolating-selection.js +100 -11
  33. package/dist/isolating-selection.js.map +1 -1
  34. package/dist/keymap.d.ts +14 -3
  35. package/dist/keymap.d.ts.map +1 -1
  36. package/dist/keymap.js +14 -3
  37. package/dist/keymap.js.map +1 -1
  38. package/dist/schema.d.ts.map +1 -1
  39. package/dist/schema.js +9 -0
  40. package/dist/schema.js.map +1 -1
  41. package/dist/visual-aids.d.ts.map +1 -1
  42. package/dist/visual-aids.js +2 -52
  43. package/dist/visual-aids.js.map +1 -1
  44. package/package.json +4 -2
package/README.md CHANGED
@@ -73,6 +73,8 @@ import { setFontFamily, activeFontFamily } from '@openleaf-editor/core'
73
73
 
74
74
  activeFontFamily(view.state) // 'Georgia' | null
75
75
  setFontFamily('Georgia')(view.state, view.dispatch) // boolean
76
+ setFontFamily("Goudy's Old Style")(view.state, view.dispatch)
77
+ // stores '"Goudy\'s Old Style"' -- the canonical double-quoted form
76
78
  ```
77
79
 
78
80
  `selectedImage` / `updateImage` (and the matching media pair) are how the
@@ -84,6 +86,12 @@ A predicate returns `null` for a mixed selection rather than the first value it
84
86
  finds -- a dropdown showing "Georgia" for a range that is half Georgia would be
85
87
  worse than showing nothing.
86
88
 
89
+ `indent` / `outdent` (`Mod-]` / `Mod-[`) nest a list item or add a padding
90
+ step on a paragraph or heading. They never insert spaces into a
91
+ `code_block` — that node has no `indent` attribute — so a code sample is
92
+ indented by typing spaces. Tab is never captured, including there. If the
93
+ code block sits inside a list item, `indent` still nests that item.
94
+
87
95
  Block-type commands (`setHeading`, `setParagraph`, `toggleCodeBlock`) refuse a
88
96
  textblock whose content the destination cannot hold. A captioned `<figure>` is a
89
97
  textblock in the schema (`content: 'inline+'`) but not a paragraph: converting it
@@ -93,14 +101,38 @@ inserting an `<hr>` cannot split a figure.
93
101
 
94
102
  ## Isolating selections
95
103
 
96
- If you construct a ProseMirror editor yourself, install
97
- `isolatingSelectionPlugin()` next to `history()` and the keymap. A
98
- `TextSelection` that starts in a `<blockquote>` and ends inside a following
99
- `<details>` otherwise throws on the next keystroke (`Cannot join details onto
100
- blockquote`), and the recovery rewrites the document with no undo entry.
101
- `<openleaf-editor>` already installs the plugin. Details are in
104
+ If you construct a ProseMirror editor yourself, install `gapCursorPlugin()`
105
+ and `isolatingSelectionPlugin()` next to `history()` and the keymap.
106
+
107
+ Without the gap cursor, a document that is only a page-break or a `<details>`
108
+ has no legal caret beside it, and typing replaces the atom. Without the
109
+ isolating clamp, a `TextSelection` that starts in a `<blockquote>` and ends
110
+ inside a following `<details>` throws on the next keystroke (`Cannot join
111
+ details onto blockquote`), and the recovery rewrites the document with no undo
112
+ entry. The isolating plugin also handles `beforeinput` so a keystroke cannot
113
+ skip the clamp when the model caret is still collapsed and only the DOM range
114
+ crosses the boundary. `<openleaf-editor>` already installs both. Details are in
102
115
  [authoring-plugins.md §4.11](../../docs/authoring-plugins.md#411-isolating-nodes-clamp-the-selection-at-their-boundary).
103
116
 
117
+ ## Code is not spellchecked
118
+
119
+ If you construct a ProseMirror editor yourself, install `codeSpellcheckPlugin()`
120
+ alongside the others. It decorates code blocks and inline `<code>` with
121
+ `spellcheck="false"`, so the browser stops underlining identifiers in an editor
122
+ whose author asked for their *prose* to be checked. It is a decoration and not
123
+ part of `toDOM` on purpose: `serializeHtml` serializes with the schema, so an
124
+ attribute added there would be written into every stored document.
125
+ `<openleaf-editor>` already installs the plugin. WebKit applies `spellcheck`
126
+ from the editing host rather than per element, so this changes nothing on Safari
127
+ or iOS.
128
+
129
+ ## Captioned figures
130
+
131
+ If you construct a ProseMirror editor yourself, install `figureDragPlugin()`
132
+ next to `isolatingSelectionPlugin()`. Dragging the `<img>` inside a captioned
133
+ `<figure>` otherwise moves only the image and leaves the caption behind.
134
+ `<openleaf-editor>` already installs the plugin.
135
+
104
136
  ## Safety
105
137
 
106
138
  URL, CSS and embed rules come from
@@ -1,10 +1,21 @@
1
1
  /**
2
2
  * Turn a typed URL into a link when the author finishes it.
3
3
  *
4
- * Space and Enter are the commit keys, matching the behaviour authors already
5
- * have in mail clients and office software. The plugin never rewrites a range
6
- * that is already a link, and it refuses anything `isSafeUrl` would drop, so
7
- * typing `javascript:` cannot become a mark the serializer would then emit.
4
+ * Space, Enter, and the end of an IME composition are the commit points,
5
+ * matching the behaviour authors already have in mail clients and office
6
+ * software. The plugin never rewrites a range that is already a link, and it
7
+ * refuses anything `isSafeUrl` would drop, so typing `javascript:` cannot
8
+ * become a mark the serializer would then emit. It also never `addMark`s
9
+ * while `view.composing` is true: rewriting the document under an open IME
10
+ * is how keyboards start duplicating or dropping characters.
11
+ *
12
+ * The mark is never its own undo event. `AddMarkStep` maps no positions, so
13
+ * `prosemirror-history` treats a standalone mark as non-adjacent and starts a
14
+ * new group — Ctrl+Z then peels the link off and leaves the URL (#182). Space
15
+ * and Enter therefore add the mark from `appendTransaction`, which ProseMirror
16
+ * tags with `appendedTransaction` so history folds it into the keystroke.
17
+ * `compositionend` cannot append (it fires on a timeout after the composition
18
+ * transactions), so that dispatch sets the same meta by hand.
8
19
  */
9
20
  import { Plugin } from 'prosemirror-state';
10
21
  export declare function hrefFromTypedUrl(raw: string): string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"autolink.d.ts","sourceRoot":"","sources":["../src/autolink.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAiD,MAAM,mBAAmB,CAAA;AA8CzF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK3D;AAuCD,wBAAgB,cAAc,IAAI,MAAM,CA0BvC"}
1
+ {"version":3,"file":"autolink.d.ts","sourceRoot":"","sources":["../src/autolink.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,MAAM,EAAiD,MAAM,mBAAmB,CAAA;AA+CzF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK3D;AAoED,wBAAgB,cAAc,IAAI,MAAM,CA0DvC"}
package/dist/autolink.js CHANGED
@@ -1,10 +1,21 @@
1
1
  /**
2
2
  * Turn a typed URL into a link when the author finishes it.
3
3
  *
4
- * Space and Enter are the commit keys, matching the behaviour authors already
5
- * have in mail clients and office software. The plugin never rewrites a range
6
- * that is already a link, and it refuses anything `isSafeUrl` would drop, so
7
- * typing `javascript:` cannot become a mark the serializer would then emit.
4
+ * Space, Enter, and the end of an IME composition are the commit points,
5
+ * matching the behaviour authors already have in mail clients and office
6
+ * software. The plugin never rewrites a range that is already a link, and it
7
+ * refuses anything `isSafeUrl` would drop, so typing `javascript:` cannot
8
+ * become a mark the serializer would then emit. It also never `addMark`s
9
+ * while `view.composing` is true: rewriting the document under an open IME
10
+ * is how keyboards start duplicating or dropping characters.
11
+ *
12
+ * The mark is never its own undo event. `AddMarkStep` maps no positions, so
13
+ * `prosemirror-history` treats a standalone mark as non-adjacent and starts a
14
+ * new group — Ctrl+Z then peels the link off and leaves the URL (#182). Space
15
+ * and Enter therefore add the mark from `appendTransaction`, which ProseMirror
16
+ * tags with `appendedTransaction` so history folds it into the keystroke.
17
+ * `compositionend` cannot append (it fires on a timeout after the composition
18
+ * transactions), so that dispatch sets the same meta by hand.
8
19
  */
9
20
  import { Plugin, PluginKey } from 'prosemirror-state';
10
21
  import { isSafeUrl } from './url.js';
@@ -93,42 +104,101 @@ function applyAutolink(state, end) {
93
104
  return null;
94
105
  return state.tr.addMark(found.from, found.to, link.create({ href: found.href }));
95
106
  }
96
- function maybeAutolink(view, end) {
107
+ function maybeAutolink(view, end, groupWithPrevious = false) {
97
108
  const tr = applyAutolink(view.state, end);
98
109
  if (!tr)
99
110
  return false;
111
+ tr.setMeta(key, true);
112
+ // Same metadata `EditorState.applyTransaction` sets on a plugin's
113
+ // `appendTransaction` result. History reads it as "this belongs to the
114
+ // event already in progress" and will not open a new undo group, even
115
+ // though `AddMarkStep` is not adjacent to the text that was just typed.
116
+ if (groupWithPrevious)
117
+ tr.setMeta('appendedTransaction', tr);
100
118
  view.dispatch(tr);
101
119
  return true;
102
120
  }
121
+ /**
122
+ * After Enter (or any split that leaves the caret at the start of the next
123
+ * textblock), the URL lives at the end of the previous block. Space is handled
124
+ * separately because the caret stays in the same block, after the space.
125
+ *
126
+ * `$new.pos <= $old.pos` filters Backspace-at-start and deleting the first
127
+ * character of a paragraph: those also leave `parentOffset === 0` but must
128
+ * not autolink the block above.
129
+ */
130
+ function urlEndAfterBlockSplit(oldState, newState) {
131
+ if (!oldState.selection.empty || !newState.selection.empty)
132
+ return null;
133
+ const $old = oldState.selection.$from;
134
+ const $new = newState.selection.$from;
135
+ if (!$old.parent.isTextblock || !$new.parent.isTextblock)
136
+ return null;
137
+ if ($new.parentOffset !== 0 || $new.depth < 1)
138
+ return null;
139
+ if ($new.pos <= $old.pos)
140
+ return null;
141
+ return $new.before($new.depth) - 1;
142
+ }
103
143
  export function autolinkPlugin() {
144
+ // `appendTransaction` is handed states, not the view, and the composing
145
+ // guard is a property of the view. The `view` prop is the supported way to
146
+ // reach one: PM calls it once per editor this plugin is installed in, and
147
+ // `autolinkPlugin()` mints a fresh plugin per editor, so this holds the view
148
+ // that owns the transactions `appendTransaction` sees.
149
+ let host = null;
104
150
  return new Plugin({
105
151
  key,
106
- appendTransaction(transactions, _oldState, newState) {
152
+ view(editorView) {
153
+ host = editorView;
154
+ return {
155
+ destroy() {
156
+ host = null;
157
+ },
158
+ };
159
+ },
160
+ appendTransaction(transactions, oldState, newState) {
161
+ // The same guard `compositionend` carries, and the one this path was
162
+ // missing: a composing IME reaches here through `readDOMChange`, which
163
+ // dispatches a doc-changing transaction per composition update. A
164
+ // composition buffer that happens to hold a space after a URL would
165
+ // otherwise get an `addMark` under the open IME -- the exact rewrite the
166
+ // header comment says never happens.
167
+ if (host?.composing)
168
+ return null;
107
169
  if (!transactions.some((tr) => tr.docChanged))
108
170
  return null;
109
171
  if (transactions.some((tr) => tr.getMeta(key)))
110
172
  return null;
111
173
  const $from = newState.selection.$from;
112
- if (!$from.parent.isTextblock || $from.parentOffset === 0)
113
- return null;
114
- const prev = $from.parent.textBetween($from.parentOffset - 1, $from.parentOffset);
115
- if (prev !== ' ' && prev !== '\u00a0')
174
+ if ($from.parent.isTextblock && $from.parentOffset > 0) {
175
+ const prev = $from.parent.textBetween($from.parentOffset - 1, $from.parentOffset);
176
+ if (prev === ' ' || prev === '\u00a0') {
177
+ const tr = applyAutolink(newState, $from.pos);
178
+ return tr ? tr.setMeta(key, true) : null;
179
+ }
180
+ }
181
+ // Enter used to `dispatch` the mark from `handleKeyDown` and return
182
+ // false, so the keymap's split was a second undo event. Folding the
183
+ // mark into this appended transaction keeps one Enter as one Ctrl+Z.
184
+ const end = urlEndAfterBlockSplit(oldState, newState);
185
+ if (end == null)
116
186
  return null;
117
- const tr = applyAutolink(newState, $from.pos);
187
+ const tr = applyAutolink(newState, end);
118
188
  return tr ? tr.setMeta(key, true) : null;
119
189
  },
120
190
  props: {
121
- handleTextInput(view, from, _to, text) {
122
- if (text !== ' ' && text !== '\u00a0')
123
- return false;
124
- maybeAutolink(view, from);
125
- return false;
126
- },
127
- handleKeyDown(view, event) {
128
- if (event.key !== 'Enter' || event.shiftKey)
191
+ handleDOMEvents: {
192
+ compositionend(view) {
193
+ // This prop runs *before* PM's compositionend (which sets composing=false,
194
+ // then flushes pending records on a microtask). Never return true.
195
+ setTimeout(() => {
196
+ if (view.isDestroyed || view.composing)
197
+ return;
198
+ maybeAutolink(view, view.state.selection.from, true);
199
+ }, 0);
129
200
  return false;
130
- maybeAutolink(view, view.state.selection.from);
131
- return false;
201
+ },
132
202
  },
133
203
  },
134
204
  });
@@ -1 +1 @@
1
- {"version":3,"file":"autolink.js","sourceRoot":"","sources":["../src/autolink.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAsC,MAAM,mBAAmB,CAAA;AACzF,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,mBAAmB,CAAC,CAAA;AAE9C;;;;;GAKG;AACH,MAAM,YAAY,GAAG,iCAAiC,CAAA;AAEtD;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,eAAe,CAAA;AAE5C,SAAS,2BAA2B,CAAC,KAAa;IAChD,IAAI,CAAC,GAAG,KAAK,CAAA;IACb,OAAO,CAAC,CAAC,MAAM,GA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B,MAAM,EAAE,GAAG,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;YACvC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QAC1C,CAAC;QACD,KAAK,EAAE;YACL,eAAe,EAAE;gBACf,cAAc,CAAC,IAAI;oBACjB,2EAA2E;oBAC3E,mEAAmE;oBACnE,UAAU,CAAC,GAAG,EAAE;wBACd,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,SAAS;4BAAE,OAAM;wBAC9C,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;oBACtD,CAAC,EAAE,CAAC,CAAC,CAAA;oBACL,OAAO,KAAK,CAAA;gBACd,CAAC;aACF;SACF;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Stop the browser spell-checking code.
3
+ *
4
+ * `spellcheck="false"` on `<openleaf-editor>` is documented as the canvas-wide
5
+ * off switch, and source view has always hard-coded it on its textarea. The
6
+ * canvas had nothing between those two: a `<pre>` full of identifiers and a
7
+ * `<code>` run in a sentence were checked as prose, so every `getElementById`
8
+ * carried a red squiggle in an editor whose author had asked for spellchecking
9
+ * of their *writing*. This is not the same question as the host attribute and
10
+ * it is not conditional on it -- `spellcheck="true"` means "check my prose",
11
+ * and code is not prose either way.
12
+ *
13
+ * ## Decorations, not `toDOM`
14
+ *
15
+ * The obvious fix -- `['pre', { spellcheck: 'false' }, ...]` in the schema -- is
16
+ * wrong, because `serializeHtml` serializes with `DOMSerializer.fromSchema`, so
17
+ * the same `toDOM` that renders the canvas writes the stored HTML. That fix
18
+ * would put an editor-chrome attribute into every saved document and into every
19
+ * fidelity comparison. Decorations are view-only by construction: the worst a
20
+ * bug in this file can do is check, or fail to check, some spelling.
21
+ *
22
+ * ## What this does not fix
23
+ *
24
+ * WebKit honours `spellcheck` on the editing host rather than on descendants
25
+ * inside it, so on Safari and every iOS browser the squiggles stay. There is no
26
+ * DOM-level workaround short of a node view that removes the text from the
27
+ * editable tree, which costs far more than it buys. Chromium and Gecko, which
28
+ * do respect the attribute per element, are the browsers this helps.
29
+ */
30
+ import { Plugin } from 'prosemirror-state';
31
+ import { DecorationSet } from 'prosemirror-view';
32
+ export declare function codeSpellcheckPlugin(): Plugin<DecorationSet>;
33
+ //# sourceMappingURL=code-spellcheck.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-spellcheck.d.ts","sourceRoot":"","sources":["../src/code-spellcheck.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAE,MAAM,EAAa,MAAM,mBAAmB,CAAA;AACrD,OAAO,EAAc,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAuE5D,wBAAgB,oBAAoB,IAAI,MAAM,CAAC,aAAa,CAAC,CAiB5D"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Stop the browser spell-checking code.
3
+ *
4
+ * `spellcheck="false"` on `<openleaf-editor>` is documented as the canvas-wide
5
+ * off switch, and source view has always hard-coded it on its textarea. The
6
+ * canvas had nothing between those two: a `<pre>` full of identifiers and a
7
+ * `<code>` run in a sentence were checked as prose, so every `getElementById`
8
+ * carried a red squiggle in an editor whose author had asked for spellchecking
9
+ * of their *writing*. This is not the same question as the host attribute and
10
+ * it is not conditional on it -- `spellcheck="true"` means "check my prose",
11
+ * and code is not prose either way.
12
+ *
13
+ * ## Decorations, not `toDOM`
14
+ *
15
+ * The obvious fix -- `['pre', { spellcheck: 'false' }, ...]` in the schema -- is
16
+ * wrong, because `serializeHtml` serializes with `DOMSerializer.fromSchema`, so
17
+ * the same `toDOM` that renders the canvas writes the stored HTML. That fix
18
+ * would put an editor-chrome attribute into every saved document and into every
19
+ * fidelity comparison. Decorations are view-only by construction: the worst a
20
+ * bug in this file can do is check, or fail to check, some spelling.
21
+ *
22
+ * ## What this does not fix
23
+ *
24
+ * WebKit honours `spellcheck` on the editing host rather than on descendants
25
+ * inside it, so on Safari and every iOS browser the squiggles stay. There is no
26
+ * DOM-level workaround short of a node view that removes the text from the
27
+ * editable tree, which costs far more than it buys. Chromium and Gecko, which
28
+ * do respect the attribute per element, are the browsers this helps.
29
+ */
30
+ import { Plugin, PluginKey } from 'prosemirror-state';
31
+ import { Decoration, DecorationSet } from 'prosemirror-view';
32
+ import { rebuildChanged } from './decoration-range.js';
33
+ const key = new PluginKey('openleaf-code-spellcheck');
34
+ /**
35
+ * One shared attrs object rather than a literal per decoration.
36
+ *
37
+ * A long minified paste is one decoration per code run, and ProseMirror
38
+ * compares decoration attrs when it decides what to redraw; sharing the object
39
+ * makes that comparison a pointer check.
40
+ */
41
+ const OFF = { spellcheck: 'false' };
42
+ /** Marks named `code`, which is the inline `<code>` this schema and its extensions use. */
43
+ function isCodeMark(node) {
44
+ return node.marks.some((mark) => mark.type.name === 'code');
45
+ }
46
+ /**
47
+ * Decorate each run of inline `<code>` in one inline container.
48
+ *
49
+ * Adjacent text nodes are merged into one decoration. A `<code>` run that also
50
+ * carries bold is two text nodes in ProseMirror's model, and decorating each
51
+ * separately would put two spans where the DOM already has one element.
52
+ */
53
+ function markInlineCode(parent, contentStart, out) {
54
+ let offset = 0;
55
+ let from = -1;
56
+ let to = -1;
57
+ parent.forEach((child) => {
58
+ const start = contentStart + offset;
59
+ offset += child.nodeSize;
60
+ if (!isCodeMark(child)) {
61
+ if (from >= 0)
62
+ out.push(Decoration.inline(from, to, OFF));
63
+ from = -1;
64
+ return;
65
+ }
66
+ // Contiguous with the run in progress: extend it rather than close it.
67
+ if (from >= 0 && to === start) {
68
+ to = start + child.nodeSize;
69
+ return;
70
+ }
71
+ if (from >= 0)
72
+ out.push(Decoration.inline(from, to, OFF));
73
+ from = start;
74
+ to = start + child.nodeSize;
75
+ });
76
+ if (from >= 0)
77
+ out.push(Decoration.inline(from, to, OFF));
78
+ }
79
+ /** Every code decoration for the nodes overlapping `[from, to]`. */
80
+ function decorationsIn(doc, from, to) {
81
+ const out = [];
82
+ doc.nodesBetween(from, to, (node, pos) => {
83
+ // Text is scanned from its parent, which is where the offsets are known.
84
+ if (node.isText)
85
+ return false;
86
+ // `spec.code` rather than a `code_block` name test, so a schema extension
87
+ // that adds its own code-holding node is covered by the same rule its
88
+ // ProseMirror semantics already declare.
89
+ if (node.type.spec.code) {
90
+ out.push(Decoration.node(pos, pos + node.nodeSize, OFF));
91
+ // The attribute is inherited by everything below, and a `code_block`
92
+ // holds no marks anyway.
93
+ return false;
94
+ }
95
+ if (node.inlineContent && node.content.size > 0)
96
+ markInlineCode(node, pos + 1, out);
97
+ return true;
98
+ });
99
+ return out;
100
+ }
101
+ export function codeSpellcheckPlugin() {
102
+ return new Plugin({
103
+ key,
104
+ state: {
105
+ init(_config, state) {
106
+ return DecorationSet.create(state.doc, decorationsIn(state.doc, 0, state.doc.content.size));
107
+ },
108
+ apply(tr, set) {
109
+ return rebuildChanged(set, tr, decorationsIn);
110
+ },
111
+ },
112
+ props: {
113
+ decorations(state) {
114
+ return key.getState(state);
115
+ },
116
+ },
117
+ });
118
+ }
119
+ //# sourceMappingURL=code-spellcheck.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-spellcheck.js","sourceRoot":"","sources":["../src/code-spellcheck.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,MAAM,GAAG,GAAG,IAAI,SAAS,CAAgB,0BAA0B,CAAC,CAAA;AAEpE;;;;;;GAMG;AACH,MAAM,GAAG,GAAG,EAAE,UAAU,EA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EAAE,EAAE,GAAG;gBACX,OAAO,cAAc,CAAC,GAAG,EAAE,EAAE,EAAE,aAAa,CAAC,CAAA;YAC/C,CAAC;SACF;QACD,KAAK,EAAE;YACL,WAAW,CAAC,KAAK;gBACf,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;YAC5B,CAAC;SACF;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -13,7 +13,7 @@
13
13
  * button disabled-state free -- the same function answers "can I?" and "do it".
14
14
  */
15
15
  import { type Attrs } from 'prosemirror-model';
16
- import type { Command, EditorState } from 'prosemirror-state';
16
+ import { type Command, type EditorState } from 'prosemirror-state';
17
17
  import { type Align, type Dir, type ListStyle } from './css.js';
18
18
  /**
19
19
  * Is this mark active at the cursor, or across the selection?
@@ -93,7 +93,11 @@ export declare function activeListStyle(state: EditorState): ListStyle | null;
93
93
  */
94
94
  export declare function activeTextAlign(state: EditorState): Align | null;
95
95
  /**
96
- * Set the alignment of every alignable block in the selection. `null` clears it.
96
+ * Set the alignment of every alignable node in the selection. `null` clears it.
97
+ *
98
+ * Images store `left` / `right` / `center` on `image.attrs.align`; serialization
99
+ * maps those to the `ol-*` classes. Justify is skipped on images, because it
100
+ * is not an image alignment.
97
101
  *
98
102
  * Reports true whenever there is something to align, even if it already carries
99
103
  * this value. The alternative -- returning false because the work is already
@@ -1 +1 @@
1
- {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAE,KAAK,KAAK,EAAqD,MAAM,mBAAmB,CAAA;AAOjG,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAA+B,MAAM,mBAAmB,CAAA;AAC1F,OAAO,EASL,KAAK,KAAK,EACV,KAAK,GAAG,EACR,KAAK,SAAS,EACf,MAAM,UAAU,CAAA;AAgNjB;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,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