@damiro/stylo 0.15.2 → 0.17.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 (79) hide show
  1. package/README.md +1 -1
  2. package/dist/{InPlaceView-DVX9qV68.js → InPlaceView-CRb5AkfX.js} +781 -743
  3. package/dist/InPlaceView-CRb5AkfX.js.map +1 -0
  4. package/dist/Preview-5lm2uUVj.js +319 -0
  5. package/dist/Preview-5lm2uUVj.js.map +1 -0
  6. package/dist/SplitView.d.ts +4 -1
  7. package/dist/SplitView.d.ts.map +1 -1
  8. package/dist/Stylo.d.ts.map +1 -1
  9. package/dist/editor/SourceView.d.ts +4 -1
  10. package/dist/editor/SourceView.d.ts.map +1 -1
  11. package/dist/editor/theme.d.ts.map +1 -1
  12. package/dist/editor/useCodeMirror.d.ts +7 -1
  13. package/dist/editor/useCodeMirror.d.ts.map +1 -1
  14. package/dist/embed-DKKeCE1Y.js +109 -0
  15. package/dist/embed-DKKeCE1Y.js.map +1 -0
  16. package/dist/{highlight-BLdNzTxQ.js → embed-cache-CcBfVrc9.js} +47 -4
  17. package/dist/embed-cache-CcBfVrc9.js.map +1 -0
  18. package/dist/inplace/InPlaceView.d.ts +4 -1
  19. package/dist/inplace/InPlaceView.d.ts.map +1 -1
  20. package/dist/inplace/context-menu-helpers.d.ts +3 -4
  21. package/dist/inplace/context-menu-helpers.d.ts.map +1 -1
  22. package/dist/inplace/decorate.d.ts.map +1 -1
  23. package/dist/inplace/edit-line-prefix.d.ts.map +1 -1
  24. package/dist/inplace/embed.d.ts.map +1 -1
  25. package/dist/inplace/extension.d.ts.map +1 -1
  26. package/dist/inplace/inline-md.d.ts.map +1 -1
  27. package/dist/inplace/link-row.d.ts +14 -13
  28. package/dist/inplace/link-row.d.ts.map +1 -1
  29. package/dist/inplace/list-guides.d.ts.map +1 -1
  30. package/dist/inplace/math.d.ts +18 -3
  31. package/dist/inplace/math.d.ts.map +1 -1
  32. package/dist/inplace/table-widget-keys.d.ts +46 -0
  33. package/dist/inplace/table-widget-keys.d.ts.map +1 -0
  34. package/dist/inplace/table-widget.d.ts +1 -2
  35. package/dist/inplace/table-widget.d.ts.map +1 -1
  36. package/dist/inplace/tables.d.ts.map +1 -1
  37. package/dist/inplace/wikilinks.d.ts +1 -1
  38. package/dist/inplace/wikilinks.d.ts.map +1 -1
  39. package/dist/render/Embed.d.ts.map +1 -1
  40. package/dist/render/Preview.d.ts.map +1 -1
  41. package/dist/render/embed-cache.d.ts +13 -0
  42. package/dist/render/embed-cache.d.ts.map +1 -1
  43. package/dist/render/preview-components.d.ts +22 -0
  44. package/dist/render/preview-components.d.ts.map +1 -0
  45. package/dist/render/remark-wikilink.d.ts.map +1 -1
  46. package/dist/render/taskCheckbox.d.ts +30 -0
  47. package/dist/render/taskCheckbox.d.ts.map +1 -1
  48. package/dist/stylo.js +213 -196
  49. package/dist/stylo.js.map +1 -1
  50. package/dist/toolbar/Toolbar.d.ts.map +1 -1
  51. package/dist/toolbar/command-helpers.d.ts +27 -0
  52. package/dist/toolbar/command-helpers.d.ts.map +1 -1
  53. package/dist/toolbar/heading.d.ts +3 -0
  54. package/dist/toolbar/heading.d.ts.map +1 -1
  55. package/dist/toolbar/inline-ops.d.ts +6 -0
  56. package/dist/toolbar/inline-ops.d.ts.map +1 -1
  57. package/dist/toolbar/table.d.ts.map +1 -1
  58. package/dist/types/core.d.ts +209 -0
  59. package/dist/types/core.d.ts.map +1 -0
  60. package/dist/types/inplace.d.ts +91 -0
  61. package/dist/types/inplace.d.ts.map +1 -0
  62. package/dist/types/sources.d.ts +66 -0
  63. package/dist/types/sources.d.ts.map +1 -0
  64. package/dist/types/toolbar.d.ts +72 -0
  65. package/dist/types/toolbar.d.ts.map +1 -0
  66. package/dist/types.d.ts +11 -406
  67. package/dist/types.d.ts.map +1 -1
  68. package/dist/{useCodeMirror-CXtuBlLf.js → useCodeMirror-B07wRexo.js} +317 -268
  69. package/dist/useCodeMirror-B07wRexo.js.map +1 -0
  70. package/package.json +4 -4
  71. package/dist/InPlaceView-DVX9qV68.js.map +0 -1
  72. package/dist/Preview-BcdSr09-.js +0 -304
  73. package/dist/Preview-BcdSr09-.js.map +0 -1
  74. package/dist/embed-Dsu6b-MV.js +0 -131
  75. package/dist/embed-Dsu6b-MV.js.map +0 -1
  76. package/dist/highlight-BLdNzTxQ.js.map +0 -1
  77. package/dist/inplace/table-widget-caret.d.ts +0 -11
  78. package/dist/inplace/table-widget-caret.d.ts.map +0 -1
  79. package/dist/useCodeMirror-CXtuBlLf.js.map +0 -1
@@ -1,19 +1,19 @@
1
- import { a as e, n as t, r as n } from "./highlight-BLdNzTxQ.js";
1
+ import { l as e, o as t, s as n } from "./embed-cache-CcBfVrc9.js";
2
2
  import { useEffect as r, useRef as i } from "react";
3
3
  import { EditorView as a, keymap as o, placeholder as s, runScopeHandlers as c } from "@codemirror/view";
4
4
  import { Annotation as l, ChangeSet as u, Compartment as d, EditorSelection as f, EditorState as p, Facet as ee, Prec as m } from "@codemirror/state";
5
- import { defaultKeymap as te, history as h, historyKeymap as g, redo as _, undo as v } from "@codemirror/commands";
6
- import { markdown as y, markdownLanguage as b } from "@codemirror/lang-markdown";
7
- import { SearchQuery as x, closeSearchPanel as ne, findNext as S, findPrevious as C, getSearchQuery as w, openSearchPanel as re, replaceAll as ie, replaceNext as ae, search as oe, searchKeymap as se, searchPanelOpen as ce, selectMatches as le, setSearchQuery as ue } from "@codemirror/search";
8
- import { syntaxTree as de } from "@codemirror/language";
9
- import { autocompletion as fe } from "@codemirror/autocomplete";
5
+ import { defaultKeymap as te, history as ne, historyKeymap as h, redo as g, undo as _ } from "@codemirror/commands";
6
+ import { markdown as v, markdownLanguage as y } from "@codemirror/lang-markdown";
7
+ import { SearchQuery as re, closeSearchPanel as b, findNext as x, findPrevious as S, getSearchQuery as C, openSearchPanel as w, replaceAll as T, replaceNext as E, search as D, searchKeymap as ie, searchPanelOpen as ae, selectMatches as oe, setSearchQuery as se } from "@codemirror/search";
8
+ import { syntaxTree as ce } from "@codemirror/language";
9
+ import { autocompletion as le } from "@codemirror/autocomplete";
10
10
  //#region src/editor/canvas-header-panel.ts
11
- var pe = "stylo-canvas-header", me = class {
11
+ var ue = "stylo-canvas-header", de = class {
12
12
  dom = null;
13
13
  listeners = /* @__PURE__ */ new Set();
14
14
  panel = () => {
15
15
  let e = document.createElement("div");
16
- return e.className = pe, this.dom = e, this.notify(), {
16
+ return e.className = ue, this.dom = e, this.notify(), {
17
17
  dom: e,
18
18
  top: !0,
19
19
  destroy: () => {
@@ -29,7 +29,7 @@ var pe = "stylo-canvas-header", me = class {
29
29
  };
30
30
  //#endregion
31
31
  //#region src/toolbar/link-ops.ts
32
- function T(e, t) {
32
+ function O(e, t) {
33
33
  let n = /\[([^\]]*)\]\([^)]*\)/g;
34
34
  for (let r; r = n.exec(e);) {
35
35
  let e = r.index, n = e + r[0].length;
@@ -41,7 +41,7 @@ function T(e, t) {
41
41
  }
42
42
  return null;
43
43
  }
44
- function he(e, t) {
44
+ function fe(e, t) {
45
45
  let n = /\[([^\]]*)\]\(([^)]*)\)/g;
46
46
  for (let r; r = n.exec(e);) {
47
47
  let e = r.index, n = e + r[0].length;
@@ -59,8 +59,8 @@ function he(e, t) {
59
59
  }
60
60
  return null;
61
61
  }
62
- function ge(e, t, n) {
63
- let r = T(e, t);
62
+ function pe(e, t, n) {
63
+ let r = O(e, t);
64
64
  if (r) return {
65
65
  text: e.slice(0, r.from) + r.label + e.slice(r.to),
66
66
  from: r.from,
@@ -75,7 +75,7 @@ function ge(e, t, n) {
75
75
  }
76
76
  //#endregion
77
77
  //#region src/toolbar/wikilink-ops.ts
78
- function E(t, n) {
78
+ function me(t, n) {
79
79
  for (let r of t.matchAll(e)) {
80
80
  let e = r.index ?? 0, t = e + r[0].length;
81
81
  if (n >= e && n <= t) return {
@@ -86,7 +86,7 @@ function E(t, n) {
86
86
  }
87
87
  return null;
88
88
  }
89
- function _e(t, n) {
89
+ function he(t, n) {
90
90
  for (let r of t.matchAll(e)) {
91
91
  let e = r.index ?? 0, t = e + r[0].length;
92
92
  if (n < e || n > t) continue;
@@ -102,8 +102,8 @@ function _e(t, n) {
102
102
  }
103
103
  return null;
104
104
  }
105
- function ve(e, t, n) {
106
- let r = E(e, t);
105
+ function ge(e, t, n) {
106
+ let r = me(e, t);
107
107
  if (r) return {
108
108
  text: e.slice(0, r.from) + r.label + e.slice(r.to),
109
109
  from: r.from,
@@ -118,7 +118,7 @@ function ve(e, t, n) {
118
118
  }
119
119
  //#endregion
120
120
  //#region src/toolbar/underline-ops.ts
121
- function ye(e, t) {
121
+ function _e(e, t) {
122
122
  let n = /<u>([\s\S]*?)<\/u>/gi;
123
123
  for (let r; r = n.exec(e);) {
124
124
  let e = r.index, n = e + r[0].length;
@@ -130,8 +130,8 @@ function ye(e, t) {
130
130
  }
131
131
  return null;
132
132
  }
133
- function be(e, t, n) {
134
- let r = ye(e, t);
133
+ function ve(e, t, n) {
134
+ let r = _e(e, t);
135
135
  if (r) return {
136
136
  text: e.slice(0, r.from) + r.inner + e.slice(r.to),
137
137
  from: r.from,
@@ -146,10 +146,10 @@ function be(e, t, n) {
146
146
  }
147
147
  //#endregion
148
148
  //#region src/toolbar/inline-ops.ts
149
- function D(e) {
149
+ function k(e) {
150
150
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
151
151
  }
152
- function xe(e, t, n) {
152
+ function ye(e, t, n) {
153
153
  let r = t, i = t;
154
154
  if (n < 0) for (; r > 0 && "*~`$".includes(e[r - 1]);) r--;
155
155
  else for (; i < e.length && "*~`$".includes(e[i]);) i++;
@@ -158,7 +158,7 @@ function xe(e, t, n) {
158
158
  from: r
159
159
  };
160
160
  }
161
- function Se(e, t) {
161
+ function be(e, t) {
162
162
  let n = [];
163
163
  for (let r = 0; r < e.length;) {
164
164
  if (e[r] !== t) {
@@ -174,15 +174,29 @@ function Se(e, t) {
174
174
  }
175
175
  return n;
176
176
  }
177
- function Ce(e, t, n) {
177
+ function xe(e, t, n) {
178
178
  return e < n || t < n ? !1 : n > 1 || e % 2 == 1 && t % 2 == 1;
179
179
  }
180
+ var Se = /[\p{L}\p{N}_]/u;
181
+ function Ce(e, t) {
182
+ let n = t, r = t;
183
+ for (; n > 0 && Se.test(e[n - 1]);) n--;
184
+ for (; r < e.length && Se.test(e[r]);) r++;
185
+ return r > n ? {
186
+ from: n,
187
+ to: r
188
+ } : null;
189
+ }
180
190
  function we(e, t, n, r) {
191
+ if (t === n) {
192
+ let r = Ce(e, t);
193
+ r && (t = r.from, n = r.to);
194
+ }
181
195
  let i = r.length, a = r[0], o = e.slice(t, n), s = 0;
182
196
  for (; o[s] === a;) s++;
183
197
  let c = 0;
184
198
  for (; o[o.length - 1 - c] === a;) c++;
185
- if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) && Ce(s, c, i)) return {
199
+ if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) && xe(s, c, i)) return {
186
200
  changes: [{
187
201
  from: t,
188
202
  to: t + i,
@@ -195,10 +209,10 @@ function we(e, t, n, r) {
195
209
  from: t,
196
210
  to: n - 2 * i
197
211
  };
198
- let l = xe(e, t, -1), u = xe(e, n, 1), d = Se(l.text, a), f = Se(u.text, a).reverse();
212
+ let l = ye(e, t, -1), u = ye(e, n, 1), d = be(l.text, a), f = be(u.text, a).reverse();
199
213
  for (let e = 0; e < Math.min(d.length, f.length); e++) {
200
214
  let r = d[e], a = f[e];
201
- if (!Ce(r.len, a.len, i)) continue;
215
+ if (!xe(r.len, a.len, i)) continue;
202
216
  let o = l.from + r.start + r.len, s = n + a.start;
203
217
  return {
204
218
  changes: [{
@@ -233,7 +247,7 @@ function Te(e, t) {
233
247
  for (let e of [...t].sort((e, t) => t.from - e.from)) n = n.slice(0, e.from) + e.insert + n.slice(e.to);
234
248
  return n;
235
249
  }
236
- function O(e, t, n, r) {
250
+ function A(e, t, n, r) {
237
251
  let i = we(e, t, n, r);
238
252
  return {
239
253
  text: Te(e, i.changes),
@@ -242,12 +256,12 @@ function O(e, t, n, r) {
242
256
  };
243
257
  }
244
258
  function Ee(e, t) {
245
- let n = T(e, t);
259
+ let n = O(e, t);
246
260
  if (n) return {
247
261
  from: n.from,
248
262
  to: n.to
249
263
  };
250
- let r = _e(e, t);
264
+ let r = he(e, t);
251
265
  if (r) return {
252
266
  from: r.from,
253
267
  to: r.to
@@ -259,7 +273,7 @@ function Ee(e, t) {
259
273
  "*",
260
274
  "`"
261
275
  ]) {
262
- let r = RegExp(D(n) + "(?!\\s)(?:[^]*?\\S)??" + D(n), "g");
276
+ let r = RegExp(k(n) + "(?!\\s)(?:[^]*?\\S)??" + k(n), "g");
263
277
  for (let a; a = r.exec(e);) {
264
278
  if (a[0].length <= 2 * n.length) continue;
265
279
  let e = a.index + n.length, r = a.index + a[0].length - n.length;
@@ -274,7 +288,7 @@ function Ee(e, t) {
274
288
  //#endregion
275
289
  //#region src/inplace/table-cell-dom.ts
276
290
  var De = (e) => [e.head, ...e.body].map((e) => [...e]), Oe = (e) => e.map((e) => e.map((e) => e.trim())), ke = (e) => e.replace(/\\\|/g, "|");
277
- function k(e, t) {
291
+ function j(e, t) {
278
292
  let n = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), r = 0;
279
293
  for (let e = n.nextNode(); e; e = n.nextNode()) {
280
294
  if (e === t) return r;
@@ -284,10 +298,10 @@ function k(e, t) {
284
298
  }
285
299
  function Ae(e) {
286
300
  let t = e.ownerDocument.getSelection(), n = t?.anchorNode;
287
- return !n || !e.contains(n) ? 0 : n.nodeType === Node.TEXT_NODE ? k(e, n) + (t?.anchorOffset ?? 0) : (t?.anchorOffset ?? 0) > 0 ? (e.textContent ?? "").length : 0;
301
+ return !n || !e.contains(n) ? 0 : n.nodeType === Node.TEXT_NODE ? j(e, n) + (t?.anchorOffset ?? 0) : (t?.anchorOffset ?? 0) > 0 ? (e.textContent ?? "").length : 0;
288
302
  }
289
303
  function je(e) {
290
- let t = e.ownerDocument.getSelection(), n = (e.textContent ?? "").length, r = (t, r) => !t || !e.contains(t) ? n : t.nodeType === Node.TEXT_NODE ? k(e, t) + r : r > 0 ? n : 0;
304
+ let t = e.ownerDocument.getSelection(), n = (e.textContent ?? "").length, r = (t, r) => !t || !e.contains(t) ? n : t.nodeType === Node.TEXT_NODE ? j(e, t) + r : r > 0 ? n : 0;
291
305
  if (!t || t.rangeCount === 0) return {
292
306
  from: n,
293
307
  to: n
@@ -307,18 +321,18 @@ function Me(e, t, n) {
307
321
  let e = r.caretRangeFromPoint(t, n);
308
322
  e && ([i, a] = [e.startContainer, e.startOffset]);
309
323
  }
310
- return !i || !e.contains(i) ? 0 : k(e, i) + (i.nodeType === Node.TEXT_NODE ? a : 0);
324
+ return !i || !e.contains(i) ? 0 : j(e, i) + (i.nodeType === Node.TEXT_NODE ? a : 0);
311
325
  }
312
326
  var Ne = /[\p{L}\p{N}_]/u;
313
327
  function Pe(e, t, n) {
314
328
  let r = e.textContent ?? "", i = Me(e, t, n), a = Ee(r, i);
315
- if (a) return A(e, a.from, a.to), !0;
329
+ if (a) return M(e, a.from, a.to), !0;
316
330
  let o = i, s = i;
317
331
  for (; o > 0 && Ne.test(r[o - 1]);) o--;
318
332
  for (; s < r.length && Ne.test(r[s]);) s++;
319
- return s <= o ? !1 : (A(e, o, s), !0);
333
+ return s <= o ? !1 : (M(e, o, s), !0);
320
334
  }
321
- function A(e, t, n = t) {
335
+ function M(e, t, n = t) {
322
336
  e.focus();
323
337
  let r = e.ownerDocument, i = r.createRange(), a = e.firstChild;
324
338
  if (a && a.nodeType === Node.TEXT_NODE) {
@@ -337,18 +351,18 @@ function Fe(e) {
337
351
  }
338
352
  function Ie(e, t) {
339
353
  let { from: n, to: r } = je(e), i = t(e.textContent ?? "", n, r);
340
- e.textContent = i.text, A(e, i.from, i.to), e.dispatchEvent(new Event("input", { bubbles: !0 }));
354
+ e.textContent = i.text, M(e, i.from, i.to), e.dispatchEvent(new Event("input", { bubbles: !0 }));
341
355
  }
342
- function j(e, t) {
356
+ function N(e, t) {
343
357
  let n = Fe(e);
344
358
  return n ? (Ie(n, t), !0) : !1;
345
359
  }
346
360
  var Le = {
347
- b: (e, t, n) => O(e, t, n, "**"),
348
- i: (e, t, n) => O(e, t, n, "*"),
349
- u: be,
350
- k: ge,
351
- K: ve
361
+ b: (e, t, n) => A(e, t, n, "**"),
362
+ i: (e, t, n) => A(e, t, n, "*"),
363
+ u: ve,
364
+ k: pe,
365
+ K: ge
352
366
  };
353
367
  function Re(e, t) {
354
368
  if (!(e.metaKey || e.ctrlKey) || e.altKey) return !1;
@@ -357,12 +371,12 @@ function Re(e, t) {
357
371
  }
358
372
  //#endregion
359
373
  //#region src/toolbar/block.ts
360
- function M(e) {
374
+ function P(e) {
361
375
  let { from: t, to: n } = e.selection.main;
362
376
  return [e.doc.lineAt(t).number, e.doc.lineAt(n).number];
363
377
  }
364
378
  function ze(e, t) {
365
- let n = e.state, [r, i] = M(n), a = r === i && !n.doc.line(r).text.trim(), o = !a;
379
+ let n = e.state, [r, i] = P(n), a = r === i && !n.doc.line(r).text.trim(), o = !a;
366
380
  for (let e = r; e <= i && o; e++) {
367
381
  let r = n.doc.line(e).text;
368
382
  r.trim() && !t.match.test(r) && (o = !1);
@@ -404,8 +418,8 @@ function Be(e, t) {
404
418
  }
405
419
  //#endregion
406
420
  //#region src/toolbar/fence.ts
407
- function N(e, t) {
408
- for (let n = de(e).resolveInner(t, 0); n; n = n.parent) {
421
+ function F(e, t) {
422
+ for (let n = ce(e).resolveInner(t, 0); n; n = n.parent) {
409
423
  if (n.name === "FencedCode") return {
410
424
  from: n.from,
411
425
  to: n.to
@@ -415,7 +429,7 @@ function N(e, t) {
415
429
  return null;
416
430
  }
417
431
  function Ve(e) {
418
- let t = e.state, n = N(t, t.selection.main.head);
432
+ let t = e.state, n = F(t, t.selection.main.head);
419
433
  if (n) {
420
434
  let r = t.doc.lineAt(n.from), i = t.doc.lineAt(n.to), a = [{
421
435
  from: r.from,
@@ -429,7 +443,7 @@ function Ve(e) {
429
443
  scrollIntoView: !0
430
444
  });
431
445
  } else {
432
- let [n, r] = M(t);
446
+ let [n, r] = P(t);
433
447
  e.dispatch({
434
448
  changes: [{
435
449
  from: t.doc.line(n).from,
@@ -444,11 +458,11 @@ function Ve(e) {
444
458
  }
445
459
  return e.focus(), !0;
446
460
  }
447
- function P(e) {
448
- return N(e, e.selection.main.head) !== null;
461
+ function I(e) {
462
+ return F(e, e.selection.main.head) !== null;
449
463
  }
450
464
  function He(e) {
451
- let t = N(e, e.selection.main.head);
465
+ let t = F(e, e.selection.main.head);
452
466
  if (!t) return null;
453
467
  let n = e.doc.lineAt(t.from), r = /^(\s*(?:`{3,}|~{3,})[ \t]*)(.*?)[ \t]*$/.exec(n.text);
454
468
  if (!r) return null;
@@ -470,7 +484,7 @@ function We(e, t) {
470
484
  return null;
471
485
  }
472
486
  function Ge(e) {
473
- let t = e.state, [n, r] = M(t), i = We(t, t.doc.lineAt(t.selection.main.head).number);
487
+ let t = e.state, [n, r] = P(t), i = We(t, t.doc.lineAt(t.selection.main.head).number);
474
488
  if (i) {
475
489
  let n = t.doc.line(i[0]), r = t.doc.line(i[1]);
476
490
  e.dispatch({
@@ -496,15 +510,16 @@ function Ge(e) {
496
510
  });
497
511
  return e.focus(), !0;
498
512
  }
499
- function F(e) {
513
+ function L(e) {
500
514
  return We(e, e.doc.lineAt(e.selection.main.head).number) !== null;
501
515
  }
502
516
  //#endregion
503
517
  //#region src/toolbar/heading.ts
504
- function Ke(e, t) {
505
- let n = "#".repeat(t) + " ", r = e.state, [i, a] = M(r), o = [];
518
+ var Ke = /^(#{1,6}) +/;
519
+ function qe(e, t) {
520
+ let n = "#".repeat(t) + " ", r = e.state, [i, a] = P(r), o = [];
506
521
  for (let e = i; e <= a; e++) {
507
- let i = r.doc.line(e), a = /^(#{1,6}) +/.exec(i.text);
522
+ let i = r.doc.line(e), a = Ke.exec(i.text);
508
523
  a && a[1].length === t ? o.push({
509
524
  from: i.from,
510
525
  to: i.from + a[0].length
@@ -522,10 +537,10 @@ function Ke(e, t) {
522
537
  scrollIntoView: !0
523
538
  }), e.focus(), !0;
524
539
  }
525
- function qe(e) {
526
- let t = e.state, [n, r] = M(t), i = [];
540
+ function Je(e) {
541
+ let t = e.state, [n, r] = P(t), i = [];
527
542
  for (let e = n; e <= r; e++) {
528
- let n = t.doc.line(e), r = /^#{1,6} +/.exec(n.text);
543
+ let n = t.doc.line(e), r = Ke.exec(n.text);
529
544
  r && i.push({
530
545
  from: n.from,
531
546
  to: n.from + r[0].length
@@ -538,7 +553,7 @@ function qe(e) {
538
553
  }
539
554
  //#endregion
540
555
  //#region src/toolbar/inline.ts
541
- function I(e, t) {
556
+ function R(e, t) {
542
557
  let n = e.state.doc.toString();
543
558
  return e.dispatch({
544
559
  ...e.state.changeByRange((e) => {
@@ -551,8 +566,8 @@ function I(e, t) {
551
566
  scrollIntoView: !0
552
567
  }), e.focus(), !0;
553
568
  }
554
- function L(e, t) {
555
- let n = e.selection.main, r = e.doc.lineAt(n.head), i = RegExp(D(t) + "(?!\\s)(?:[^]*?\\S)??" + D(t), "g");
569
+ function z(e, t) {
570
+ let n = e.selection.main, r = e.doc.lineAt(n.head), i = RegExp(k(t) + "(?!\\s)(?:[^]*?\\S)??" + k(t), "g");
556
571
  for (let e; e = i.exec(r.text);) {
557
572
  if (e[0].length <= 2 * t.length || t === "$" && (r.text[e.index - 1] === "$" || r.text[e.index + e[0].length] === "$")) continue;
558
573
  let i = r.from + e.index;
@@ -560,16 +575,16 @@ function L(e, t) {
560
575
  }
561
576
  return !1;
562
577
  }
563
- function Je(e) {
564
- let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = T(n.text, t - n.from);
578
+ function Ye(e) {
579
+ let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = O(n.text, t - n.from);
565
580
  return r ? {
566
581
  from: n.from + r.from,
567
582
  to: n.from + r.to,
568
583
  text: r.label
569
584
  } : null;
570
585
  }
571
- function Ye(e) {
572
- let t = Je(e.state);
586
+ function Xe(e) {
587
+ let t = Ye(e.state);
573
588
  if (t) return e.dispatch({
574
589
  changes: {
575
590
  from: t.from,
@@ -590,19 +605,19 @@ function Ye(e) {
590
605
  scrollIntoView: !0
591
606
  }), e.focus(), !0;
592
607
  }
593
- function Xe(e) {
594
- return Je(e) !== null;
595
- }
596
608
  function Ze(e) {
597
- let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = E(n.text, t - n.from);
609
+ return Ye(e) !== null;
610
+ }
611
+ function Qe(e) {
612
+ let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = me(n.text, t - n.from);
598
613
  return r ? {
599
614
  from: n.from + r.from,
600
615
  to: n.from + r.to,
601
616
  text: r.label
602
617
  } : null;
603
618
  }
604
- function Qe(e) {
605
- let t = Ze(e.state);
619
+ function $e(e) {
620
+ let t = Qe(e.state);
606
621
  if (t) return e.dispatch({
607
622
  changes: {
608
623
  from: t.from,
@@ -623,19 +638,19 @@ function Qe(e) {
623
638
  scrollIntoView: !0
624
639
  }), e.focus(), !0;
625
640
  }
626
- function $e(e) {
627
- return Ze(e) !== null;
628
- }
629
641
  function et(e) {
630
- let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = ye(n.text, t - n.from);
642
+ return Qe(e) !== null;
643
+ }
644
+ function tt(e) {
645
+ let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = _e(n.text, t - n.from);
631
646
  return r ? {
632
647
  from: n.from + r.from,
633
648
  to: n.from + r.to,
634
649
  inner: r.inner
635
650
  } : null;
636
651
  }
637
- function tt(e) {
638
- let t = et(e.state);
652
+ function nt(e) {
653
+ let t = tt(e.state);
639
654
  if (t) return e.dispatch({
640
655
  changes: {
641
656
  from: t.from,
@@ -656,29 +671,29 @@ function tt(e) {
656
671
  scrollIntoView: !0
657
672
  }), e.focus(), !0;
658
673
  }
659
- function nt(e) {
660
- return et(e) !== null;
674
+ function rt(e) {
675
+ return tt(e) !== null;
661
676
  }
662
677
  //#endregion
663
678
  //#region src/toolbar/table-grid.ts
664
- function rt(e) {
679
+ function it(e) {
665
680
  let t = e.trim();
666
681
  return t.includes("-") && t.includes("|") && /^[\s|:-]+$/.test(t);
667
682
  }
668
- function it(e) {
683
+ function at(e) {
669
684
  let t = e.trim();
670
685
  t.startsWith("|") && (t = t.slice(1)), t.endsWith("|") && !t.endsWith("\\|") && (t = t.slice(0, -1));
671
686
  let n = [], r = "";
672
687
  for (let e = 0; e < t.length; e++) t[e] === "\\" && t[e + 1] === "|" ? (r += "\\|", e++) : t[e] === "|" ? (n.push(r.trim()), r = "") : r += t[e];
673
688
  return n.push(r.trim()), n;
674
689
  }
675
- function at(e) {
690
+ function ot(e) {
676
691
  let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
677
692
  return n && r ? "center" : r ? "right" : n ? "left" : "";
678
693
  }
679
- function R(e) {
680
- if (e.length < 2 || !rt(e[1])) return null;
681
- let t = it(e[1]).map(at), n = e.filter((e, t) => t !== 1).map(it), r = Math.max(t.length, ...n.map((e) => e.length)), i = n.map((e) => {
694
+ function B(e) {
695
+ if (e.length < 2 || !it(e[1])) return null;
696
+ let t = at(e[1]).map(ot), n = e.filter((e, t) => t !== 1).map(at), r = Math.max(t.length, ...n.map((e) => e.length)), i = n.map((e) => {
682
697
  let t = e.slice(0, r);
683
698
  for (; t.length < r;) t.push("");
684
699
  return t;
@@ -689,11 +704,11 @@ function R(e) {
689
704
  aligns: a
690
705
  };
691
706
  }
692
- function ot(e) {
707
+ function st(e) {
693
708
  return e.replace(/\\\|/g, "|").length;
694
709
  }
695
- function st(e, t, n) {
696
- let r = t - ot(e);
710
+ function ct(e, t, n) {
711
+ let r = t - st(e);
697
712
  if (r <= 0) return e;
698
713
  if (n === "right") return " ".repeat(r) + e;
699
714
  if (n === "center") {
@@ -702,19 +717,19 @@ function st(e, t, n) {
702
717
  }
703
718
  return e + " ".repeat(r);
704
719
  }
705
- function ct(e, t) {
720
+ function lt(e, t) {
706
721
  let n = Math.max(3, e);
707
722
  return t === "left" ? ":" + "-".repeat(n - 1) : t === "right" ? "-".repeat(n - 1) + ":" : t === "center" ? ":" + "-".repeat(n - 2) + ":" : "-".repeat(n);
708
723
  }
709
- function lt(e) {
724
+ function V(e) {
710
725
  let t = e.aligns.length, n = [];
711
726
  for (let r = 0; r < t; r++) {
712
727
  let t = 3;
713
- for (let n of e.rows) t = Math.max(t, ot(n[r] ?? ""));
728
+ for (let n of e.rows) t = Math.max(t, st(n[r] ?? ""));
714
729
  n.push(t);
715
730
  }
716
- let r = (t) => "| " + t.map((t, r) => st(t ?? "", n[r], e.aligns[r])).join(" | ") + " |", i = [r(e.rows[0] ?? [])];
717
- i.push("| " + e.aligns.map((e, t) => ct(n[t], e)).join(" | ") + " |");
731
+ let r = (t) => "| " + t.map((t, r) => ct(t ?? "", n[r], e.aligns[r])).join(" | ") + " |", i = [r(e.rows[0] ?? [])];
732
+ i.push("| " + e.aligns.map((e, t) => lt(n[t], e)).join(" | ") + " |");
718
733
  for (let t = 1; t < e.rows.length; t++) i.push(r(e.rows[t]));
719
734
  return i.join("\n");
720
735
  }
@@ -741,7 +756,7 @@ function ut(e) {
741
756
  }
742
757
  //#endregion
743
758
  //#region src/toolbar/table-position.ts
744
- function z(e, t) {
759
+ function H(e, t) {
745
760
  let n = e.lineAt(t);
746
761
  if (!n.text.includes("|")) return null;
747
762
  let r = n.number;
@@ -759,7 +774,7 @@ function z(e, t) {
759
774
  if (i - r < 1) return null;
760
775
  let a = [];
761
776
  for (let t = r; t <= i; t++) a.push(e.line(t).text);
762
- return R(a) ? {
777
+ return B(a) ? {
763
778
  from: e.line(r).from,
764
779
  to: e.line(i).to,
765
780
  lines: a
@@ -795,15 +810,15 @@ function dt(e, t, n) {
795
810
  }
796
811
  return null;
797
812
  }
798
- function B(e, t, n) {
813
+ function U(e, t, n) {
799
814
  let r = e.split("\n"), i = n.onDelimiter ? 1 : n.row === 0 ? 0 : n.row + 1, a = t;
800
815
  for (let e = 0; e < i; e++) a += r[e].length + 1;
801
816
  let o = ut(r[i]), s = o[Math.min(n.col, o.length - 1)];
802
817
  return s ? a + s.contentStart + Math.min(n.offset, s.contentEnd - s.contentStart) : a;
803
818
  }
804
819
  function ft(e, t, n, r) {
805
- let i = z(e, t);
806
- return i ? B(i.lines.join("\n"), i.from, {
820
+ let i = H(e, t);
821
+ return i ? U(i.lines.join("\n"), i.from, {
807
822
  row: n,
808
823
  col: r,
809
824
  offset: 0,
@@ -844,24 +859,24 @@ function mt(e) {
844
859
  scrollIntoView: !0
845
860
  }), e.focus(), pt(e, a), !0;
846
861
  }
847
- function V(e) {
848
- return z(e.doc, e.selection.main.head) !== null;
862
+ function W(e) {
863
+ return H(e.doc, e.selection.main.head) !== null;
849
864
  }
850
- function H(e, t) {
851
- let n = z(e.state.doc, e.state.selection.main.head);
865
+ function G(e, t) {
866
+ let n = H(e.state.doc, e.state.selection.main.head);
852
867
  if (!n) return !1;
853
- let r = R(n.lines), i = dt(n.lines, n.from, e.state.selection.main.head);
868
+ let r = B(n.lines), i = dt(n.lines, n.from, e.state.selection.main.head);
854
869
  if (!r || !i) return !1;
855
870
  let a = t(r, i);
856
871
  if (!a) return !1;
857
- let o = lt(r);
872
+ let o = V(r);
858
873
  return e.dispatch({
859
874
  changes: {
860
875
  from: n.from,
861
876
  to: n.to,
862
877
  insert: o
863
878
  },
864
- selection: f.cursor(B(o, n.from, a)),
879
+ selection: f.cursor(U(o, n.from, a)),
865
880
  scrollIntoView: !0
866
881
  }), e.focus(), !0;
867
882
  }
@@ -886,23 +901,23 @@ function gt(e, t) {
886
901
  var _t = o.of([
887
902
  {
888
903
  key: "Tab",
889
- run: (e) => H(e, (e, t) => ht(e, t, 1))
904
+ run: (e) => G(e, (e, t) => ht(e, t, 1))
890
905
  },
891
906
  {
892
907
  key: "Shift-Tab",
893
- run: (e) => H(e, (e, t) => ht(e, t, -1))
908
+ run: (e) => G(e, (e, t) => ht(e, t, -1))
894
909
  },
895
910
  {
896
911
  key: "Enter",
897
- run: (e) => H(e, gt)
912
+ run: (e) => G(e, gt)
898
913
  }
899
914
  ]), vt = p.transactionFilter.of((e) => {
900
- if (!e.docChanged || !e.isUserEvent("input") && !e.isUserEvent("delete")) return e;
901
- let t = e.newSelection.main.head, n = z(e.newDoc, t);
915
+ if (!e.docChanged || e.isUserEvent("input.type.compose") || !e.isUserEvent("input") && !e.isUserEvent("delete")) return e;
916
+ let t = e.newSelection.main.head, n = H(e.newDoc, t);
902
917
  if (!n) return e;
903
- let r = R(n.lines);
918
+ let r = B(n.lines);
904
919
  if (!r) return e;
905
- let i = lt(r);
920
+ let i = V(r);
906
921
  if (i === n.lines.join("\n")) return e;
907
922
  let a = dt(n.lines, n.from, t), o = u.of([{
908
923
  from: n.from,
@@ -911,28 +926,28 @@ var _t = o.of([
911
926
  }], e.newDoc.length);
912
927
  return {
913
928
  changes: e.changes.compose(o),
914
- selection: a ? f.cursor(B(i, n.from, a)) : e.newSelection,
929
+ selection: a ? f.cursor(U(i, n.from, a)) : e.newSelection,
915
930
  effects: e.effects,
916
931
  scrollIntoView: e.scrollIntoView
917
932
  };
918
- }), U = (e) => /^\s{0,3}#{1,6}(?:\s|$)/.test(e.doc.lineAt(e.selection.main.head).text), W = (e) => {
933
+ }), K = (e) => /^\s{0,3}#{1,6}(?:\s|$)/.test(e.doc.lineAt(e.selection.main.head).text), q = (e) => {
919
934
  let t = n(e.doc);
920
935
  return t !== null && e.selection.main.head <= t.to;
921
- }, G = (e) => W(e) || P(e) || F(e), yt = (e) => (t) => e !== "`" && L(t, "`") || e !== "$" && L(t, "$"), bt = (e) => e.selection.main.empty && !e.wordAt(e.selection.main.head), K = (...e) => (t) => e.some((e) => e(t)), q = /^(\s*)(?:[-*+] \[[ xX]\] +|\d+\. +|[-*+] +)/, xt = {
936
+ }, J = (e) => q(e) || I(e) || L(e), yt = (e) => (t) => e !== "`" && z(t, "`") || e !== "$" && z(t, "$"), bt = (e) => e.selection.main.empty && !e.wordAt(e.selection.main.head), Y = (...e) => (t) => e.some((e) => e(t)), X = /^(\s*)(?:[-*+] \[[ xX]\] +|\d+[.)] +|[-*+] +)/, xt = {
922
937
  match: /^ {0,3}> ?/,
923
938
  insert: "> "
924
939
  }, St = {
925
940
  match: /^(\s*)[-*+] +(?!\[[ xX]\])/,
926
941
  insert: "- ",
927
- siblings: q
942
+ siblings: X
928
943
  }, Ct = {
929
- match: /^(\s*)\d+\. +/,
944
+ match: /^(\s*)\d+[.)] +/,
930
945
  insert: (e) => `${e + 1}. `,
931
- siblings: q
946
+ siblings: X
932
947
  }, wt = {
933
948
  match: /^(\s*)[-*+] \[[ xX]\] +/,
934
949
  insert: "- [ ] ",
935
- siblings: q
950
+ siblings: X
936
951
  };
937
952
  function Tt(e, t, n) {
938
953
  return {
@@ -944,39 +959,63 @@ function Tt(e, t, n) {
944
959
  }
945
960
  };
946
961
  }
947
- function J(e, t, n, r) {
962
+ function Z(e, t, n, r) {
948
963
  return {
949
964
  id: e,
950
965
  title: t,
951
- run: (e) => j(e, (e, t, r) => O(e, t, r, n)) || I(e, n),
952
- isActive: (e) => L(e, n),
953
- disabled: K(G, yt(n), bt),
966
+ run: (e) => N(e, (e, t, r) => A(e, t, r, n)) || R(e, n),
967
+ isActive: (e) => z(e, n),
968
+ disabled: Y(J, yt(n), bt),
954
969
  keys: r
955
970
  };
956
971
  }
957
- function Y(e) {
972
+ function Et(e) {
958
973
  let t = RegExp(`^#{${e}} `);
959
974
  return {
960
975
  id: `h${e}`,
961
976
  title: `Heading ${e}`,
962
- run: (t) => Ke(t, e),
977
+ run: (t) => qe(t, e),
963
978
  isActive: (e) => t.test(e.doc.lineAt(e.selection.main.head).text),
964
- disabled: K(V, G),
979
+ disabled: Y(W, J),
965
980
  keys: [`Mod-Alt-${e}`]
966
981
  };
967
982
  }
968
- function X(e, t, n, ...r) {
983
+ var Dt = /* @__PURE__ */ new Set([
984
+ "bold",
985
+ "italic",
986
+ "strike",
987
+ "underline",
988
+ "code",
989
+ "codeBlock",
990
+ "link",
991
+ "wikilink",
992
+ "math",
993
+ "mathBlock"
994
+ ]);
995
+ function Ot(e, t, n) {
996
+ return n ? Dt.has(t.id) ? {
997
+ disabled: !1,
998
+ active: !1
999
+ } : {
1000
+ disabled: !0,
1001
+ active: !1
1002
+ } : {
1003
+ disabled: !!t.disabled?.(e),
1004
+ active: !!t.isActive?.(e)
1005
+ };
1006
+ }
1007
+ function Q(e, t, n, ...r) {
969
1008
  return {
970
1009
  id: e,
971
1010
  title: t,
972
1011
  run: (e) => ze(e, n),
973
1012
  isActive: (e) => Be(e, n.match),
974
- disabled: K(V, G, ...r)
1013
+ disabled: Y(W, J, ...r)
975
1014
  };
976
1015
  }
977
1016
  //#endregion
978
1017
  //#region src/toolbar/frontmatter-toggle.ts
979
- function Et(e) {
1018
+ function kt(e) {
980
1019
  let t = e.state, r = n(t.doc);
981
1020
  if (r) {
982
1021
  let n = t.doc.lineAt(r.from), i = t.doc.lineAt(r.to);
@@ -1006,15 +1045,15 @@ function Et(e) {
1006
1045
  }
1007
1046
  return e.focus(), !0;
1008
1047
  }
1009
- function Dt(e) {
1048
+ function At(e) {
1010
1049
  return n(e.doc) !== null;
1011
1050
  }
1012
1051
  //#endregion
1013
1052
  //#region src/toolbar/rule.ts
1014
- var Ot = /^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/;
1015
- function kt(e) {
1053
+ var jt = /^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/;
1054
+ function Mt(e) {
1016
1055
  let t = e.state, n = t.doc.lineAt(t.selection.main.head);
1017
- return Ot.test(n.text) ? e.dispatch({
1056
+ return jt.test(n.text) ? e.dispatch({
1018
1057
  changes: {
1019
1058
  from: n.from,
1020
1059
  to: Math.min(n.to + 1, t.doc.length)
@@ -1037,46 +1076,46 @@ function kt(e) {
1037
1076
  scrollIntoView: !0
1038
1077
  }), e.focus(), !0;
1039
1078
  }
1040
- function At(e) {
1041
- return Ot.test(e.doc.lineAt(e.selection.main.head).text);
1079
+ function Nt(e) {
1080
+ return jt.test(e.doc.lineAt(e.selection.main.head).text);
1042
1081
  }
1043
1082
  //#endregion
1044
1083
  //#region src/editor/save.ts
1045
- var Z = ee.define({ combine: (e) => e[0] ?? null });
1046
- function jt(e) {
1047
- let t = e.state.facet(Z);
1084
+ var Pt = ee.define({ combine: (e) => e[0] ?? null });
1085
+ function Ft(e) {
1086
+ let t = e.state.facet(Pt);
1048
1087
  return t ? (t(e.state.doc.toString()), !0) : !1;
1049
1088
  }
1050
1089
  //#endregion
1051
1090
  //#region src/editor/search-panel-dom.ts
1052
- var Mt = "stylo-search-panel";
1053
- function Nt(e) {
1091
+ var It = "stylo-search-panel";
1092
+ function Lt(e) {
1054
1093
  e.setAttribute("form", "");
1055
1094
  }
1056
- function Pt(e, t, n) {
1095
+ function Rt(e, t, n) {
1057
1096
  let r = document.createElement("input");
1058
- return r.type = "text", r.name = e, r.placeholder = t, r.setAttribute("aria-label", t), r.className = n, Nt(r), r;
1097
+ return r.type = "text", r.name = e, r.placeholder = t, r.setAttribute("aria-label", t), r.className = n, Lt(r), r;
1059
1098
  }
1060
- function Q(e, t) {
1099
+ function $(e, t) {
1061
1100
  let n = document.createElement("button");
1062
1101
  return n.type = "button", n.name = e, n.className = "stylo-search-button", n.textContent = t, n;
1063
1102
  }
1064
- function $(e, t) {
1103
+ function zt(e, t) {
1065
1104
  let n = document.createElement("input");
1066
- n.type = "checkbox", n.name = e, Nt(n);
1105
+ n.type = "checkbox", n.name = e, Lt(n);
1067
1106
  let r = document.createElement("label");
1068
1107
  return r.className = "stylo-search-check", r.append(n, document.createTextNode(t)), {
1069
1108
  field: n,
1070
1109
  wrap: r
1071
1110
  };
1072
1111
  }
1073
- function Ft(e) {
1074
- let t = (t) => e.state.phrase(t), n = Pt("search", t("Find"), "stylo-search-field");
1112
+ function Bt(e) {
1113
+ let t = (t) => e.state.phrase(t), n = Rt("search", t("Find"), "stylo-search-field");
1075
1114
  n.setAttribute("main-field", "true");
1076
- let r = Q("next", t("next")), i = Q("prev", t("previous")), a = Q("select", t("all")), o = Pt("replace", t("Replace"), "stylo-search-field stylo-search-replace"), s = Q("replace", t("replace")), c = Q("replaceAll", t("replace all")), l = $("case", t("match case")), u = $("re", t("regexp")), d = $("word", t("by word")), f = Q("close", "×");
1115
+ let r = $("next", t("next")), i = $("prev", t("previous")), a = $("select", t("all")), o = Rt("replace", t("Replace"), "stylo-search-field stylo-search-replace"), s = $("replace", t("replace")), c = $("replaceAll", t("replace all")), l = zt("case", t("match case")), u = zt("re", t("regexp")), d = zt("word", t("by word")), f = $("close", "×");
1077
1116
  f.classList.add("stylo-search-close"), f.setAttribute("aria-label", t("close"));
1078
1117
  let p = document.createElement("div");
1079
- return p.className = Mt, p.append(n, r, i, a, o, s, c, l.wrap, u.wrap, d.wrap, f), {
1118
+ return p.className = It, p.append(n, r, i, a, o, s, c, l.wrap, u.wrap, d.wrap, f), {
1080
1119
  root: p,
1081
1120
  find: n,
1082
1121
  next: r,
@@ -1093,31 +1132,31 @@ function Ft(e) {
1093
1132
  }
1094
1133
  //#endregion
1095
1134
  //#region src/editor/search-panel.ts
1096
- var It = "cm-search-closing", Lt = 160;
1097
- function Rt(e) {
1098
- return ce(e.state) ? zt(e) : re(e);
1135
+ var Vt = "cm-search-closing", Ht = 160;
1136
+ function Ut(e) {
1137
+ return ae(e.state) ? Wt(e) : w(e);
1099
1138
  }
1100
- function zt(e) {
1101
- let t = e.dom.querySelector(`.${Mt}`);
1102
- return !t || t.classList.contains(It) ? !0 : (t.classList.add(It), setTimeout(() => {
1103
- e.dom.isConnected && ne(e);
1104
- }, Lt), !0);
1139
+ function Wt(e) {
1140
+ let t = e.dom.querySelector(`.${It}`);
1141
+ return !t || t.classList.contains(Vt) ? !0 : (t.classList.add(Vt), setTimeout(() => {
1142
+ e.dom.isConnected && b(e);
1143
+ }, Ht), !0);
1105
1144
  }
1106
- function Bt(e) {
1107
- let t = Ft(e), n = w(e.state);
1145
+ function Gt(e) {
1146
+ let t = Bt(e), n = C(e.state);
1108
1147
  r(n);
1109
1148
  function r(e) {
1110
1149
  t.find.value = e.search, t.replace.value = e.replace, t.caseSensitive.checked = e.caseSensitive, t.regexp.checked = e.regexp, t.wholeWord.checked = e.wholeWord;
1111
1150
  }
1112
1151
  function i() {
1113
- let r = new x({
1152
+ let r = new re({
1114
1153
  search: t.find.value,
1115
1154
  caseSensitive: t.caseSensitive.checked,
1116
1155
  regexp: t.regexp.checked,
1117
1156
  wholeWord: t.wholeWord.checked,
1118
1157
  replace: t.replace.value
1119
1158
  });
1120
- r.eq(n) || (n = r, e.dispatch({ effects: ue.of(n) }));
1159
+ r.eq(n) || (n = r, e.dispatch({ effects: se.of(n) }));
1121
1160
  }
1122
1161
  for (let e of [
1123
1162
  t.find,
@@ -1128,127 +1167,127 @@ function Bt(e) {
1128
1167
  ]) e.addEventListener("input", i), e.addEventListener("change", i);
1129
1168
  return t.root.addEventListener("keydown", (n) => {
1130
1169
  if (n.key === "Escape") {
1131
- n.preventDefault(), zt(e);
1170
+ n.preventDefault(), Wt(e);
1132
1171
  return;
1133
1172
  }
1134
1173
  if (c(e, n, "search-panel")) {
1135
1174
  n.preventDefault();
1136
1175
  return;
1137
1176
  }
1138
- n.key === "Enter" && (n.preventDefault(), n.target === t.find ? (n.shiftKey ? C : S)(e) : n.target === t.replace && ae(e));
1139
- }), t.next.addEventListener("click", () => S(e)), t.prev.addEventListener("click", () => C(e)), t.all.addEventListener("click", () => le(e)), t.replaceBtn.addEventListener("click", () => ae(e)), t.replaceAllBtn.addEventListener("click", () => ie(e)), t.close.addEventListener("click", () => zt(e)), {
1177
+ n.key === "Enter" && (n.preventDefault(), n.target === t.find ? (n.shiftKey ? S : x)(e) : n.target === t.replace && E(e));
1178
+ }), t.next.addEventListener("click", () => x(e)), t.prev.addEventListener("click", () => S(e)), t.all.addEventListener("click", () => oe(e)), t.replaceBtn.addEventListener("click", () => E(e)), t.replaceAllBtn.addEventListener("click", () => T(e)), t.close.addEventListener("click", () => Wt(e)), {
1140
1179
  dom: t.root,
1141
1180
  top: !0,
1142
1181
  update(e) {
1143
- for (let t of e.transactions) for (let e of t.effects) e.is(ue) && !e.value.eq(n) && (n = e.value, r(n));
1182
+ for (let t of e.transactions) for (let e of t.effects) e.is(se) && !e.value.eq(n) && (n = e.value, r(n));
1144
1183
  }
1145
1184
  };
1146
1185
  }
1147
1186
  //#endregion
1148
1187
  //#region src/toolbar/commands.ts
1149
- var Vt = [
1150
- Tt("undo", "Undo", v),
1151
- Tt("redo", "Redo", _),
1188
+ var Kt = [
1189
+ Tt("undo", "Undo", _),
1190
+ Tt("redo", "Redo", g),
1152
1191
  {
1153
1192
  id: "save",
1154
1193
  title: "Save",
1155
1194
  run: (e) => {
1156
- let t = jt(e);
1195
+ let t = Ft(e);
1157
1196
  return e.focus(), t;
1158
1197
  },
1159
- disabled: (e) => e.facet(Z) == null
1198
+ disabled: (e) => e.facet(Pt) == null
1160
1199
  },
1161
1200
  {
1162
1201
  id: "search",
1163
1202
  title: "Find / replace",
1164
- run: (e) => Rt(e),
1165
- isActive: (e) => ce(e),
1203
+ run: (e) => Ut(e),
1204
+ isActive: (e) => ae(e),
1166
1205
  keys: ["Mod-f"]
1167
1206
  },
1168
- Y(1),
1169
- Y(2),
1170
- Y(3),
1207
+ Et(1),
1208
+ Et(2),
1209
+ Et(3),
1171
1210
  {
1172
1211
  id: "body",
1173
1212
  title: "Body",
1174
- run: (e) => (qe(e) || e.focus(), !0),
1213
+ run: (e) => (Je(e) || e.focus(), !0),
1175
1214
  isActive: (e) => !/^#{1,6} /.test(e.doc.lineAt(e.selection.main.head).text),
1176
- disabled: K(V, G)
1215
+ disabled: Y(W, J)
1177
1216
  },
1178
- J("bold", "Bold", "**", ["Mod-b"]),
1179
- J("italic", "Italic", "*", ["Mod-i"]),
1180
- J("strike", "Strikethrough", "~~"),
1217
+ Z("bold", "Bold", "**", ["Mod-b"]),
1218
+ Z("italic", "Italic", "*", ["Mod-i"]),
1219
+ Z("strike", "Strikethrough", "~~"),
1181
1220
  {
1182
1221
  id: "underline",
1183
1222
  title: "Underline",
1184
- run: (e) => j(e, be) || tt(e),
1185
- isActive: nt,
1186
- disabled: K(G, yt("u"), bt),
1223
+ run: (e) => N(e, ve) || nt(e),
1224
+ isActive: rt,
1225
+ disabled: Y(J, yt("u"), bt),
1187
1226
  keys: ["Mod-u"]
1188
1227
  },
1189
- J("code", "Inline code", "`"),
1228
+ Z("code", "Inline code", "`"),
1190
1229
  {
1191
1230
  id: "codeBlock",
1192
1231
  title: "Code block",
1193
- run: (e) => j(e, (e, t, n) => O(e, t, n, "`")) || (V(e.state) ? I(e, "`") : Ve(e)),
1194
- isActive: (e) => V(e) ? L(e, "`") : P(e),
1195
- disabled: K(W, F, U)
1232
+ run: (e) => N(e, (e, t, n) => A(e, t, n, "`")) || (W(e.state) ? R(e, "`") : Ve(e)),
1233
+ isActive: (e) => W(e) ? z(e, "`") : I(e),
1234
+ disabled: Y(q, L, K)
1196
1235
  },
1197
1236
  {
1198
1237
  id: "link",
1199
1238
  title: "Link",
1200
- run: (e) => j(e, ge) || Ye(e),
1201
- isActive: Xe,
1202
- disabled: G,
1239
+ run: (e) => N(e, pe) || Xe(e),
1240
+ isActive: Ze,
1241
+ disabled: J,
1203
1242
  keys: ["Mod-k"]
1204
1243
  },
1205
1244
  {
1206
1245
  id: "wikilink",
1207
1246
  title: "Wikilink",
1208
- run: (e) => j(e, ve) || Qe(e),
1209
- isActive: $e,
1210
- disabled: G,
1247
+ run: (e) => N(e, ge) || $e(e),
1248
+ isActive: et,
1249
+ disabled: J,
1211
1250
  keys: ["Mod-Shift-k"]
1212
1251
  },
1213
- X("quote", "Blockquote", xt),
1214
- X("bulletList", "Bulleted list", St, U),
1215
- X("orderedList", "Numbered list", Ct, U),
1216
- X("task", "Task list", wt, U),
1252
+ Q("quote", "Blockquote", xt),
1253
+ Q("bulletList", "Bulleted list", St, K),
1254
+ Q("orderedList", "Numbered list", Ct, K),
1255
+ Q("task", "Task list", wt, K),
1217
1256
  {
1218
1257
  id: "hr",
1219
1258
  title: "Divider",
1220
- run: kt,
1221
- isActive: At,
1222
- disabled: K(V, G)
1259
+ run: Mt,
1260
+ isActive: Nt,
1261
+ disabled: Y(W, J)
1223
1262
  },
1224
1263
  {
1225
1264
  id: "frontmatter",
1226
1265
  title: "Frontmatter",
1227
- run: Et,
1228
- isActive: Dt,
1229
- disabled: K(V, P, F, U)
1266
+ run: kt,
1267
+ isActive: At,
1268
+ disabled: Y(W, I, L, K)
1230
1269
  },
1231
1270
  {
1232
1271
  id: "table",
1233
1272
  title: "Table",
1234
1273
  run: mt,
1235
- isActive: V,
1236
- disabled: K(V, W, P, F, U)
1274
+ isActive: W,
1275
+ disabled: Y(W, q, I, L, K)
1237
1276
  },
1238
- J("math", "Inline math", "$"),
1277
+ Z("math", "Inline math", "$"),
1239
1278
  {
1240
1279
  id: "mathBlock",
1241
1280
  title: "Block math",
1242
- run: (e) => j(e, (e, t, n) => O(e, t, n, "$")) || (V(e.state) ? I(e, "$") : Ge(e)),
1243
- isActive: (e) => V(e) ? L(e, "$") : F(e),
1244
- disabled: K(W, P, U)
1281
+ run: (e) => N(e, (e, t, n) => A(e, t, n, "$")) || (W(e.state) ? R(e, "$") : Ge(e)),
1282
+ isActive: (e) => W(e) ? z(e, "$") : L(e),
1283
+ disabled: Y(q, I, K)
1245
1284
  }
1246
- ], Ht = Object.fromEntries(Vt.map((e) => [e.id, e])), Ut = m.high(o.of(Vt.filter((e) => e.keys && e.keys.length > 0).flatMap((e) => e.keys.map((t) => ({
1285
+ ], qt = Object.fromEntries(Kt.map((e) => [e.id, e])), Jt = m.high(o.of(Kt.filter((e) => e.keys && e.keys.length > 0).flatMap((e) => e.keys.map((t) => ({
1247
1286
  key: t,
1248
1287
  preventDefault: !0,
1249
1288
  run: ((t) => !e.disabled?.(t.state) && e.run(t))
1250
- }))))), Wt = /(?<=^|\s)#[^\s#]*$/;
1251
- function Gt(e) {
1289
+ }))))), Yt = /(?<=^|\s)#[^\s#]*$/;
1290
+ function Xt(e) {
1252
1291
  return {
1253
1292
  label: e.tag,
1254
1293
  apply: (t, n, r, i) => {
@@ -1264,15 +1303,15 @@ function Gt(e) {
1264
1303
  }
1265
1304
  };
1266
1305
  }
1267
- function Kt(e, t) {
1306
+ function Zt(e, t) {
1268
1307
  return async (n) => {
1269
- let r = n.matchBefore(Wt);
1308
+ let r = n.matchBefore(Yt);
1270
1309
  if (!r || r.from + 1 === n.pos && !n.explicit) return null;
1271
1310
  let i = r.text.slice(1);
1272
1311
  if (/^\d/.test(i)) return null;
1273
1312
  let a;
1274
1313
  try {
1275
- a = (await e(i)).map(Gt);
1314
+ a = (await e(i)).map(Xt);
1276
1315
  } catch (e) {
1277
1316
  return t?.(e, {
1278
1317
  source: "tagSource",
@@ -1287,12 +1326,12 @@ function Kt(e, t) {
1287
1326
  } : null;
1288
1327
  };
1289
1328
  }
1290
- function qt(e, t) {
1291
- return e ? [fe(), b.data.of({ autocomplete: Kt(e, t) })] : [];
1329
+ function Qt(e, t) {
1330
+ return e ? [le(), y.data.of({ autocomplete: Zt(e, t) })] : [];
1292
1331
  }
1293
1332
  //#endregion
1294
1333
  //#region src/editor/theme.ts
1295
- var Jt = a.theme({
1334
+ var $t = a.theme({
1296
1335
  "&": {
1297
1336
  color: "var(--stylo-text)",
1298
1337
  backgroundColor: "var(--stylo-bg)",
@@ -1308,7 +1347,11 @@ var Jt = a.theme({
1308
1347
  ".cm-cursor, .cm-dropCursor": { borderLeftColor: "var(--stylo-text)" },
1309
1348
  "&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: "color-mix(in srgb, var(--stylo-accent) 15%, transparent)" },
1310
1349
  ".cm-placeholder": { color: "var(--stylo-text-muted)" },
1311
- ".cm-gutters": { display: "none" },
1350
+ ".cm-gutters": {
1351
+ backgroundColor: "transparent",
1352
+ color: "var(--stylo-text-muted)",
1353
+ border: "none"
1354
+ },
1312
1355
  ".cm-panels": { color: "var(--stylo-text)" },
1313
1356
  ".cm-panels.cm-panels-top": { background: "var(--stylo-bg)" },
1314
1357
  ".stylo-search-panel": {
@@ -1394,8 +1437,8 @@ var Jt = a.theme({
1394
1437
  backgroundColor: "color-mix(in srgb, var(--stylo-ring) 70%, transparent)",
1395
1438
  outline: "1px solid var(--stylo-ring)"
1396
1439
  }
1397
- }), Yt = /\[\[([^[\]\n|]*)$/;
1398
- function Xt(e) {
1440
+ }), en = /\[\[([^[\]\n|]*)$/;
1441
+ function tn(e) {
1399
1442
  let t = e.label && e.label !== e.target ? e.label : void 0, n = t ? `${e.target}|${t}` : e.target;
1400
1443
  return {
1401
1444
  label: e.label ?? e.target,
@@ -1413,13 +1456,13 @@ function Xt(e) {
1413
1456
  }
1414
1457
  };
1415
1458
  }
1416
- function Zt(e, t) {
1459
+ function nn(e, t) {
1417
1460
  return async (n) => {
1418
- let r = n.matchBefore(Yt);
1461
+ let r = n.matchBefore(en);
1419
1462
  if (!r || r.from + 2 === n.pos && !n.explicit) return null;
1420
1463
  let i = r.text.slice(2), a;
1421
1464
  try {
1422
- a = (await e(i)).map(Xt);
1465
+ a = (await e(i)).map(tn);
1423
1466
  } catch (e) {
1424
1467
  return t?.(e, {
1425
1468
  source: "wikiLinkSource",
@@ -1434,57 +1477,57 @@ function Zt(e, t) {
1434
1477
  } : null;
1435
1478
  };
1436
1479
  }
1437
- function Qt(e, t) {
1438
- return e ? [fe(), b.data.of({ autocomplete: Zt(e, t) })] : [];
1480
+ function rn(e, t) {
1481
+ return e ? [le(), y.data.of({ autocomplete: nn(e, t) })] : [];
1439
1482
  }
1440
1483
  //#endregion
1441
1484
  //#region src/editor/extensions.ts
1442
- function $t(e, n, r, i) {
1485
+ function an(e, n, r, i) {
1443
1486
  return [
1444
- h(),
1445
- o.of([...te, ...g]),
1487
+ ne(),
1488
+ o.of([...te, ...h]),
1446
1489
  m.high(_t),
1447
- Ut,
1490
+ Jt,
1448
1491
  vt,
1449
- oe({
1492
+ D({
1450
1493
  top: !0,
1451
- createPanel: Bt
1494
+ createPanel: Gt
1452
1495
  }),
1453
- o.of(se),
1454
- y({
1455
- base: b,
1496
+ o.of(ie),
1497
+ v({
1498
+ base: y,
1456
1499
  codeLanguages: e
1457
1500
  }),
1458
1501
  t,
1459
- Qt(n, r),
1460
- qt(i, r),
1502
+ rn(n, r),
1503
+ Qt(i, r),
1461
1504
  a.lineWrapping,
1462
- Jt
1505
+ $t
1463
1506
  ];
1464
1507
  }
1465
- function en(e) {
1508
+ function on(e) {
1466
1509
  return [
1467
1510
  p.readOnly.of(e.readOnly),
1468
1511
  a.editable.of(!e.readOnly),
1469
1512
  e.placeholder ? s(e.placeholder) : [],
1470
- e.save ? Z.of(e.save) : []
1513
+ e.save ? Pt.of(e.save) : []
1471
1514
  ];
1472
1515
  }
1473
1516
  //#endregion
1474
1517
  //#region src/editor/useCodeMirror.ts
1475
- var tn = l.define();
1476
- function nn({ value: e, onChange: t, readOnly: n = !1, placeholder: s, onSave: c, onViewChange: l, extensions: u, codeLanguages: f, wikiLinkSource: ee, tagSource: te, onResolveError: h }) {
1518
+ var sn = l.define();
1519
+ function cn({ value: e, onChange: t, readOnly: n = !1, placeholder: s, onSave: c, onViewChange: l, extensions: u, hostExtensions: f, codeLanguages: ee, wikiLinkSource: te, tagSource: ne, onResolveError: h }) {
1477
1520
  let g = i(null), _ = i(null), v = i(t);
1478
1521
  v.current = t;
1479
- let y = i(c);
1480
- y.current = c;
1481
- let b = i((e) => y.current?.(e)).current, x = i(h);
1522
+ let y = i([]), re = i(c);
1523
+ re.current = c;
1524
+ let b = i((e) => re.current?.(e)).current, x = i(h);
1482
1525
  x.current = h;
1483
- let ne = i((e, t) => {
1526
+ let S = i((e, t) => {
1484
1527
  x.current?.(e, t);
1485
- }).current, S = c != null, C = i(l);
1486
- C.current = l;
1487
- let w = i(new d());
1528
+ }).current, C = c != null, w = i(l);
1529
+ w.current = l;
1530
+ let T = i(new d()), E = i(new d()), D = i(f);
1488
1531
  return r(() => {
1489
1532
  let t = g.current;
1490
1533
  if (!t) return;
@@ -1493,52 +1536,58 @@ function nn({ value: e, onChange: t, readOnly: n = !1, placeholder: s, onSave: c
1493
1536
  state: p.create({
1494
1537
  doc: e,
1495
1538
  extensions: [
1496
- $t(f, ee, ne, te),
1497
- w.current.of(en({
1539
+ an(ee, te, S, ne),
1540
+ T.current.of(on({
1498
1541
  readOnly: n,
1499
1542
  placeholder: s,
1500
- save: S ? b : void 0
1543
+ save: C ? b : void 0
1501
1544
  })),
1502
1545
  m.high(o.of([{
1503
1546
  key: "Mod-s",
1504
- run: jt
1547
+ run: Ft
1505
1548
  }])),
1506
1549
  ...u ?? [],
1550
+ E.current.of(f ?? []),
1507
1551
  a.updateListener.of((e) => {
1508
- e.docChanged && (e.transactions.some((e) => !!e.annotation(tn)) || v.current(e.state.doc.toString()));
1552
+ if (!e.docChanged || e.transactions.some((e) => !!e.annotation(sn))) return;
1553
+ let t = e.state.doc.toString();
1554
+ y.current.push(t), y.current.length > 20 && y.current.shift(), v.current(t);
1509
1555
  })
1510
1556
  ]
1511
1557
  })
1512
1558
  });
1513
- return _.current = r, C.current?.(r), () => {
1514
- C.current?.(null), r.destroy(), _.current = null;
1559
+ return _.current = r, w.current?.(r), () => {
1560
+ w.current?.(null), r.destroy(), _.current = null;
1515
1561
  };
1516
1562
  }, []), r(() => {
1517
1563
  let t = _.current;
1518
1564
  if (!t) return;
1519
1565
  let n = t.state.doc.toString();
1520
- n !== e && t.dispatch({
1566
+ n !== e && (y.current.includes(e) || (t.dispatch({
1521
1567
  changes: {
1522
1568
  from: 0,
1523
1569
  to: n.length,
1524
1570
  insert: e
1525
1571
  },
1526
- annotations: tn.of(!0)
1527
- });
1572
+ annotations: sn.of(!0)
1573
+ }), y.current = []));
1528
1574
  }, [e]), r(() => {
1529
- _.current?.dispatch({ effects: w.current.reconfigure(en({
1575
+ _.current?.dispatch({ effects: T.current.reconfigure(on({
1530
1576
  readOnly: n,
1531
1577
  placeholder: s,
1532
- save: S ? b : void 0
1578
+ save: C ? b : void 0
1533
1579
  })) });
1534
1580
  }, [
1535
1581
  n,
1536
1582
  s,
1537
- S,
1583
+ C,
1538
1584
  b
1539
- ]), g;
1585
+ ]), r(() => {
1586
+ let e = D.current;
1587
+ e !== f && (e && f && e.length === f.length && e.every((e, t) => e === f[t]) || (D.current = f, _.current?.dispatch({ effects: E.current.reconfigure(f ?? []) })));
1588
+ }, [f]), g;
1540
1589
  }
1541
1590
  //#endregion
1542
- export { me as S, Oe as _, R as a, _e as b, P as c, De as d, Me as f, je as g, Pe as h, ft as i, Fe as l, Ae as m, Ht as n, lt as o, A as p, kt as r, He as s, nn as t, Re as u, ke as v, he as x, E as y };
1591
+ export { je as C, he as D, me as E, fe as O, Pe as S, ke as T, Re as _, X as a, M as b, wt as c, B as d, V as f, Fe as g, I as h, St as i, de as k, Ot as l, He as m, qt as n, Ct as o, Ke as p, Mt as r, xt as s, cn as t, ft as u, De as v, Oe as w, Ae as x, Me as y };
1543
1592
 
1544
- //# sourceMappingURL=useCodeMirror-CXtuBlLf.js.map
1593
+ //# sourceMappingURL=useCodeMirror-B07wRexo.js.map