@damiro/stylo 0.11.0 → 0.13.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 (43) hide show
  1. package/README.md +16 -6
  2. package/dist/{InPlaceView-Dyf7I4XQ.js → InPlaceView-BGVCST5f.js} +449 -448
  3. package/dist/{InPlaceView-Dyf7I4XQ.js.map → InPlaceView-BGVCST5f.js.map} +1 -1
  4. package/dist/Preview-C5Oi_jpI.js +238 -0
  5. package/dist/Preview-C5Oi_jpI.js.map +1 -0
  6. package/dist/SplitView.d.ts +3 -2
  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 +5 -3
  10. package/dist/editor/SourceView.d.ts.map +1 -1
  11. package/dist/editor/extensions.d.ts +2 -2
  12. package/dist/editor/extensions.d.ts.map +1 -1
  13. package/dist/editor/highlight.d.ts +20 -0
  14. package/dist/editor/highlight.d.ts.map +1 -1
  15. package/dist/editor/tag-complete.d.ts +16 -0
  16. package/dist/editor/tag-complete.d.ts.map +1 -0
  17. package/dist/editor/useCodeMirror.d.ts +8 -3
  18. package/dist/editor/useCodeMirror.d.ts.map +1 -1
  19. package/dist/highlight-DNGJlCDY.js +133 -0
  20. package/dist/highlight-DNGJlCDY.js.map +1 -0
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/inplace/InPlaceView.d.ts +5 -3
  24. package/dist/inplace/InPlaceView.d.ts.map +1 -1
  25. package/dist/render/CodeBlock.d.ts +18 -0
  26. package/dist/render/CodeBlock.d.ts.map +1 -0
  27. package/dist/render/Preview.d.ts +9 -2
  28. package/dist/render/Preview.d.ts.map +1 -1
  29. package/dist/render/highlightCode.d.ts +10 -0
  30. package/dist/render/highlightCode.d.ts.map +1 -0
  31. package/dist/styles.css +1 -1
  32. package/dist/stylo.js +120 -113
  33. package/dist/stylo.js.map +1 -1
  34. package/dist/types.d.ts +35 -12
  35. package/dist/types.d.ts.map +1 -1
  36. package/dist/{useCodeMirror-CjG9CwpB.js → useCodeMirror-COmcRrUo.js} +348 -387
  37. package/dist/useCodeMirror-COmcRrUo.js.map +1 -0
  38. package/package.json +1 -1
  39. package/dist/Preview-DIsFdBFA.js +0 -170
  40. package/dist/Preview-DIsFdBFA.js.map +0 -1
  41. package/dist/frontmatter-DTCC0gaa.js +0 -40
  42. package/dist/frontmatter-DTCC0gaa.js.map +0 -1
  43. package/dist/useCodeMirror-CjG9CwpB.js.map +0 -1
@@ -1,20 +1,19 @@
1
- import { r as e, t } from "./frontmatter-DTCC0gaa.js";
2
- import { useEffect as n, useRef as r } from "react";
3
- import { EditorView as i, keymap as a, placeholder as o, runScopeHandlers as s } from "@codemirror/view";
4
- import { Annotation as c, ChangeSet as l, Compartment as u, EditorSelection as d, EditorState as f, Facet as p, Prec as m } from "@codemirror/state";
5
- import { defaultKeymap as ee, history as te, 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 b, closeSearchPanel as ne, findNext as x, findPrevious as S, getSearchQuery as C, 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 { HighlightStyle as de, syntaxHighlighting as fe, syntaxTree as pe } from "@codemirror/language";
9
- import { tags as w } from "@lezer/highlight";
10
- import { autocompletion as me } from "@codemirror/autocomplete";
1
+ import { a as e, n as t, r as n } from "./highlight-DNGJlCDY.js";
2
+ import { useEffect as r, useRef as i } from "react";
3
+ import { EditorView as a, keymap as o, placeholder as s, runScopeHandlers as c } from "@codemirror/view";
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";
11
10
  //#region src/editor/canvas-header-panel.ts
12
- var he = "stylo-canvas-header", ge = class {
11
+ var pe = "stylo-canvas-header", me = class {
13
12
  dom = null;
14
13
  listeners = /* @__PURE__ */ new Set();
15
14
  panel = () => {
16
15
  let e = document.createElement("div");
17
- return e.className = he, this.dom = e, this.notify(), {
16
+ return e.className = pe, this.dom = e, this.notify(), {
18
17
  dom: e,
19
18
  top: !0,
20
19
  destroy: () => {
@@ -42,7 +41,7 @@ function T(e, t) {
42
41
  }
43
42
  return null;
44
43
  }
45
- function _e(e, t) {
44
+ function he(e, t) {
46
45
  let n = /\[([^\]]*)\]\(([^)]*)\)/g;
47
46
  for (let r; r = n.exec(e);) {
48
47
  let e = r.index, n = e + r[0].length;
@@ -60,7 +59,7 @@ function _e(e, t) {
60
59
  }
61
60
  return null;
62
61
  }
63
- function ve(e, t, n) {
62
+ function ge(e, t, n) {
64
63
  let r = T(e, t);
65
64
  if (r) return {
66
65
  text: e.slice(0, r.from) + r.label + e.slice(r.to),
@@ -87,7 +86,7 @@ function E(t, n) {
87
86
  }
88
87
  return null;
89
88
  }
90
- function ye(t, n) {
89
+ function _e(t, n) {
91
90
  for (let r of t.matchAll(e)) {
92
91
  let e = r.index ?? 0, t = e + r[0].length;
93
92
  if (n < e || n > t) continue;
@@ -103,7 +102,7 @@ function ye(t, n) {
103
102
  }
104
103
  return null;
105
104
  }
106
- function be(e, t, n) {
105
+ function ve(e, t, n) {
107
106
  let r = E(e, t);
108
107
  if (r) return {
109
108
  text: e.slice(0, r.from) + r.label + e.slice(r.to),
@@ -119,7 +118,7 @@ function be(e, t, n) {
119
118
  }
120
119
  //#endregion
121
120
  //#region src/toolbar/underline-ops.ts
122
- function xe(e, t) {
121
+ function ye(e, t) {
123
122
  let n = /<u>([\s\S]*?)<\/u>/gi;
124
123
  for (let r; r = n.exec(e);) {
125
124
  let e = r.index, n = e + r[0].length;
@@ -131,8 +130,8 @@ function xe(e, t) {
131
130
  }
132
131
  return null;
133
132
  }
134
- function Se(e, t, n) {
135
- let r = xe(e, t);
133
+ function be(e, t, n) {
134
+ let r = ye(e, t);
136
135
  if (r) return {
137
136
  text: e.slice(0, r.from) + r.inner + e.slice(r.to),
138
137
  from: r.from,
@@ -150,7 +149,7 @@ function Se(e, t, n) {
150
149
  function D(e) {
151
150
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
152
151
  }
153
- function Ce(e, t, n) {
152
+ function xe(e, t, n) {
154
153
  let r = t, i = t;
155
154
  if (n < 0) for (; r > 0 && "*~`$".includes(e[r - 1]);) r--;
156
155
  else for (; i < e.length && "*~`$".includes(e[i]);) i++;
@@ -159,7 +158,7 @@ function Ce(e, t, n) {
159
158
  from: r
160
159
  };
161
160
  }
162
- function we(e, t) {
161
+ function Se(e, t) {
163
162
  let n = [];
164
163
  for (let r = 0; r < e.length;) {
165
164
  if (e[r] !== t) {
@@ -175,15 +174,15 @@ function we(e, t) {
175
174
  }
176
175
  return n;
177
176
  }
178
- function Te(e, t, n) {
177
+ function Ce(e, t, n) {
179
178
  return e < n || t < n ? !1 : n > 1 || e % 2 == 1 && t % 2 == 1;
180
179
  }
181
- function Ee(e, t, n, r) {
180
+ function we(e, t, n, r) {
182
181
  let i = r.length, a = r[0], o = e.slice(t, n), s = 0;
183
182
  for (; o[s] === a;) s++;
184
183
  let c = 0;
185
184
  for (; o[o.length - 1 - c] === a;) c++;
186
- if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) && Te(s, c, i)) return {
185
+ if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) && Ce(s, c, i)) return {
187
186
  changes: [{
188
187
  from: t,
189
188
  to: t + i,
@@ -196,10 +195,10 @@ function Ee(e, t, n, r) {
196
195
  from: t,
197
196
  to: n - 2 * i
198
197
  };
199
- let l = Ce(e, t, -1), u = Ce(e, n, 1), d = we(l.text, a), f = we(u.text, a).reverse();
198
+ let l = xe(e, t, -1), u = xe(e, n, 1), d = Se(l.text, a), f = Se(u.text, a).reverse();
200
199
  for (let e = 0; e < Math.min(d.length, f.length); e++) {
201
200
  let r = d[e], a = f[e];
202
- if (!Te(r.len, a.len, i)) continue;
201
+ if (!Ce(r.len, a.len, i)) continue;
203
202
  let o = l.from + r.start + r.len, s = n + a.start;
204
203
  return {
205
204
  changes: [{
@@ -229,26 +228,26 @@ function Ee(e, t, n, r) {
229
228
  to: n + i
230
229
  };
231
230
  }
232
- function De(e, t) {
231
+ function Te(e, t) {
233
232
  let n = e;
234
233
  for (let e of [...t].sort((e, t) => t.from - e.from)) n = n.slice(0, e.from) + e.insert + n.slice(e.to);
235
234
  return n;
236
235
  }
237
236
  function O(e, t, n, r) {
238
- let i = Ee(e, t, n, r);
237
+ let i = we(e, t, n, r);
239
238
  return {
240
- text: De(e, i.changes),
239
+ text: Te(e, i.changes),
241
240
  from: i.from,
242
241
  to: i.to
243
242
  };
244
243
  }
245
- function Oe(e, t) {
244
+ function Ee(e, t) {
246
245
  let n = T(e, t);
247
246
  if (n) return {
248
247
  from: n.from,
249
248
  to: n.to
250
249
  };
251
- let r = ye(e, t);
250
+ let r = _e(e, t);
252
251
  if (r) return {
253
252
  from: r.from,
254
253
  to: r.to
@@ -274,7 +273,7 @@ function Oe(e, t) {
274
273
  }
275
274
  //#endregion
276
275
  //#region src/inplace/table-cell-dom.ts
277
- var ke = (e) => [e.head, ...e.body].map((e) => [...e]), Ae = (e) => e.map((e) => e.map((e) => e.trim())), je = (e) => e.replace(/\\\|/g, "|");
276
+ 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, "|");
278
277
  function k(e, t) {
279
278
  let n = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), r = 0;
280
279
  for (let e = n.nextNode(); e; e = n.nextNode()) {
@@ -283,11 +282,11 @@ function k(e, t) {
283
282
  }
284
283
  return r;
285
284
  }
286
- function Me(e) {
285
+ function Ae(e) {
287
286
  let t = e.ownerDocument.getSelection(), n = t?.anchorNode;
288
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;
289
288
  }
290
- function Ne(e) {
289
+ function je(e) {
291
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;
292
291
  if (!t || t.rangeCount === 0) return {
293
292
  from: n,
@@ -299,7 +298,7 @@ function Ne(e) {
299
298
  to: Math.max(i, a)
300
299
  };
301
300
  }
302
- function Pe(e, t, n) {
301
+ function Me(e, t, n) {
303
302
  let r = e.ownerDocument, i = null, a = 0;
304
303
  if (r.caretPositionFromPoint) {
305
304
  let e = r.caretPositionFromPoint(t, n);
@@ -310,13 +309,13 @@ function Pe(e, t, n) {
310
309
  }
311
310
  return !i || !e.contains(i) ? 0 : k(e, i) + (i.nodeType === Node.TEXT_NODE ? a : 0);
312
311
  }
313
- var Fe = /[\p{L}\p{N}_]/u;
314
- function Ie(e, t, n) {
315
- let r = e.textContent ?? "", i = Pe(e, t, n), a = Oe(r, i);
312
+ var Ne = /[\p{L}\p{N}_]/u;
313
+ function Pe(e, t, n) {
314
+ let r = e.textContent ?? "", i = Me(e, t, n), a = Ee(r, i);
316
315
  if (a) return A(e, a.from, a.to), !0;
317
316
  let o = i, s = i;
318
- for (; o > 0 && Fe.test(r[o - 1]);) o--;
319
- for (; s < r.length && Fe.test(r[s]);) s++;
317
+ for (; o > 0 && Ne.test(r[o - 1]);) o--;
318
+ for (; s < r.length && Ne.test(r[s]);) s++;
320
319
  return s <= o ? !1 : (A(e, o, s), !0);
321
320
  }
322
321
  function A(e, t, n = t) {
@@ -332,29 +331,29 @@ function A(e, t, n = t) {
332
331
  }
333
332
  //#endregion
334
333
  //#region src/toolbar/cell-inline.ts
335
- function Le(e) {
334
+ function Fe(e) {
336
335
  let t = e.dom.ownerDocument.activeElement;
337
336
  return !(t instanceof HTMLElement) || !e.dom.contains(t) ? null : t.matches(".cm-inplace-tcell") ? t : null;
338
337
  }
339
- function Re(e, t) {
340
- let { from: n, to: r } = Ne(e), i = t(e.textContent ?? "", n, r);
338
+ function Ie(e, t) {
339
+ let { from: n, to: r } = je(e), i = t(e.textContent ?? "", n, r);
341
340
  e.textContent = i.text, A(e, i.from, i.to), e.dispatchEvent(new Event("input", { bubbles: !0 }));
342
341
  }
343
342
  function j(e, t) {
344
- let n = Le(e);
345
- return n ? (Re(n, t), !0) : !1;
343
+ let n = Fe(e);
344
+ return n ? (Ie(n, t), !0) : !1;
346
345
  }
347
- var ze = {
346
+ var Le = {
348
347
  b: (e, t, n) => O(e, t, n, "**"),
349
348
  i: (e, t, n) => O(e, t, n, "*"),
350
- u: Se,
351
- k: ve,
352
- K: be
349
+ u: be,
350
+ k: ge,
351
+ K: ve
353
352
  };
354
- function Be(e, t) {
353
+ function Re(e, t) {
355
354
  if (!(e.metaKey || e.ctrlKey) || e.altKey) return !1;
356
- let n = ze[e.shiftKey ? e.key.toUpperCase() : e.key.toLowerCase()];
357
- return n ? (e.preventDefault(), Re(t, n), !0) : !1;
355
+ let n = Le[e.shiftKey ? e.key.toUpperCase() : e.key.toLowerCase()];
356
+ return n ? (e.preventDefault(), Ie(t, n), !0) : !1;
358
357
  }
359
358
  //#endregion
360
359
  //#region src/toolbar/block.ts
@@ -362,7 +361,7 @@ function M(e) {
362
361
  let { from: t, to: n } = e.selection.main;
363
362
  return [e.doc.lineAt(t).number, e.doc.lineAt(n).number];
364
363
  }
365
- function Ve(e, t) {
364
+ function ze(e, t) {
366
365
  let n = e.state, [r, i] = M(n), a = r === i && !n.doc.line(r).text.trim(), o = !a;
367
366
  for (let e = r; e <= i && o; e++) {
368
367
  let r = n.doc.line(e).text;
@@ -400,13 +399,13 @@ function Ve(e, t) {
400
399
  scrollIntoView: !0
401
400
  }), e.focus(), !0) : !1;
402
401
  }
403
- function He(e, t) {
402
+ function Be(e, t) {
404
403
  return t.test(e.doc.lineAt(e.selection.main.head).text);
405
404
  }
406
405
  //#endregion
407
406
  //#region src/toolbar/fence.ts
408
407
  function N(e, t) {
409
- for (let n = pe(e).resolveInner(t, 0); n; n = n.parent) {
408
+ for (let n = de(e).resolveInner(t, 0); n; n = n.parent) {
410
409
  if (n.name === "FencedCode") return {
411
410
  from: n.from,
412
411
  to: n.to
@@ -415,7 +414,7 @@ function N(e, t) {
415
414
  }
416
415
  return null;
417
416
  }
418
- function Ue(e) {
417
+ function Ve(e) {
419
418
  let t = e.state, n = N(t, t.selection.main.head);
420
419
  if (n) {
421
420
  let r = t.doc.lineAt(n.from), i = t.doc.lineAt(n.to), a = [{
@@ -448,7 +447,7 @@ function Ue(e) {
448
447
  function P(e) {
449
448
  return N(e, e.selection.main.head) !== null;
450
449
  }
451
- function We(e) {
450
+ function He(e) {
452
451
  let t = N(e, e.selection.main.head);
453
452
  if (!t) return null;
454
453
  let n = e.doc.lineAt(t.from), r = /^(\s*(?:`{3,}|~{3,})[ \t]*)(.*?)[ \t]*$/.exec(n.text);
@@ -460,18 +459,18 @@ function We(e) {
460
459
  lang: r[2]
461
460
  };
462
461
  }
463
- var Ge = /^\s*\$\$\s*$/;
464
- function Ke(e, t) {
462
+ var Ue = /^\s*\$\$\s*$/;
463
+ function We(e, t) {
465
464
  let n = 0, r = 0;
466
- for (let i = 1; i <= e.doc.lines; i++) if (Ge.test(e.doc.line(i).text)) {
465
+ for (let i = 1; i <= e.doc.lines; i++) if (Ue.test(e.doc.line(i).text)) {
467
466
  if (r++, r % 2 == 1) {
468
467
  if (n = i, i > t) return null;
469
468
  } else if (i >= t) return [n, i];
470
469
  }
471
470
  return null;
472
471
  }
473
- function qe(e) {
474
- let t = e.state, [n, r] = M(t), i = Ke(t, t.doc.lineAt(t.selection.main.head).number);
472
+ function Ge(e) {
473
+ let t = e.state, [n, r] = M(t), i = We(t, t.doc.lineAt(t.selection.main.head).number);
475
474
  if (i) {
476
475
  let n = t.doc.line(i[0]), r = t.doc.line(i[1]);
477
476
  e.dispatch({
@@ -498,11 +497,11 @@ function qe(e) {
498
497
  return e.focus(), !0;
499
498
  }
500
499
  function F(e) {
501
- return Ke(e, e.doc.lineAt(e.selection.main.head).number) !== null;
500
+ return We(e, e.doc.lineAt(e.selection.main.head).number) !== null;
502
501
  }
503
502
  //#endregion
504
503
  //#region src/toolbar/heading.ts
505
- function Je(e, t) {
504
+ function Ke(e, t) {
506
505
  let n = "#".repeat(t) + " ", r = e.state, [i, a] = M(r), o = [];
507
506
  for (let e = i; e <= a; e++) {
508
507
  let i = r.doc.line(e), a = /^(#{1,6}) +/.exec(i.text);
@@ -523,7 +522,7 @@ function Je(e, t) {
523
522
  scrollIntoView: !0
524
523
  }), e.focus(), !0;
525
524
  }
526
- function Ye(e) {
525
+ function qe(e) {
527
526
  let t = e.state, [n, r] = M(t), i = [];
528
527
  for (let e = n; e <= r; e++) {
529
528
  let n = t.doc.line(e), r = /^#{1,6} +/.exec(n.text);
@@ -543,10 +542,10 @@ function I(e, t) {
543
542
  let n = e.state.doc.toString();
544
543
  return e.dispatch({
545
544
  ...e.state.changeByRange((e) => {
546
- let r = Ee(n, e.from, e.to, t);
545
+ let r = we(n, e.from, e.to, t);
547
546
  return {
548
547
  changes: r.changes,
549
- range: r.from === r.to ? d.cursor(r.from) : d.range(r.from, r.to)
548
+ range: r.from === r.to ? f.cursor(r.from) : f.range(r.from, r.to)
550
549
  };
551
550
  }),
552
551
  scrollIntoView: !0
@@ -561,7 +560,7 @@ function L(e, t) {
561
560
  }
562
561
  return !1;
563
562
  }
564
- function Xe(e) {
563
+ function Je(e) {
565
564
  let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = T(n.text, t - n.from);
566
565
  return r ? {
567
566
  from: n.from + r.from,
@@ -569,15 +568,15 @@ function Xe(e) {
569
568
  text: r.label
570
569
  } : null;
571
570
  }
572
- function Ze(e) {
573
- let t = Xe(e.state);
571
+ function Ye(e) {
572
+ let t = Je(e.state);
574
573
  if (t) return e.dispatch({
575
574
  changes: {
576
575
  from: t.from,
577
576
  to: t.to,
578
577
  insert: t.text
579
578
  },
580
- selection: d.range(t.from, t.from + t.text.length),
579
+ selection: f.range(t.from, t.from + t.text.length),
581
580
  scrollIntoView: !0
582
581
  }), e.focus(), !0;
583
582
  let { from: n, to: r } = e.state.selection.main, i = e.state.sliceDoc(n, r) || "text", a = n + i.length + 3;
@@ -587,14 +586,14 @@ function Ze(e) {
587
586
  to: r,
588
587
  insert: `[${i}](url)`
589
588
  },
590
- selection: d.range(a, a + 3),
589
+ selection: f.range(a, a + 3),
591
590
  scrollIntoView: !0
592
591
  }), e.focus(), !0;
593
592
  }
594
- function Qe(e) {
595
- return Xe(e) !== null;
593
+ function Xe(e) {
594
+ return Je(e) !== null;
596
595
  }
597
- function $e(e) {
596
+ function Ze(e) {
598
597
  let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = E(n.text, t - n.from);
599
598
  return r ? {
600
599
  from: n.from + r.from,
@@ -602,15 +601,15 @@ function $e(e) {
602
601
  text: r.label
603
602
  } : null;
604
603
  }
605
- function et(e) {
606
- let t = $e(e.state);
604
+ function Qe(e) {
605
+ let t = Ze(e.state);
607
606
  if (t) return e.dispatch({
608
607
  changes: {
609
608
  from: t.from,
610
609
  to: t.to,
611
610
  insert: t.text
612
611
  },
613
- selection: d.range(t.from, t.from + t.text.length),
612
+ selection: f.range(t.from, t.from + t.text.length),
614
613
  scrollIntoView: !0
615
614
  }), e.focus(), !0;
616
615
  let { from: n, to: r } = e.state.selection.main, i = e.state.sliceDoc(n, r) || "target";
@@ -620,30 +619,30 @@ function et(e) {
620
619
  to: r,
621
620
  insert: `[[${i}]]`
622
621
  },
623
- selection: d.range(n + 2, n + 2 + i.length),
622
+ selection: f.range(n + 2, n + 2 + i.length),
624
623
  scrollIntoView: !0
625
624
  }), e.focus(), !0;
626
625
  }
627
- function tt(e) {
628
- return $e(e) !== null;
626
+ function $e(e) {
627
+ return Ze(e) !== null;
629
628
  }
630
- function nt(e) {
631
- let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = xe(n.text, t - n.from);
629
+ function et(e) {
630
+ let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = ye(n.text, t - n.from);
632
631
  return r ? {
633
632
  from: n.from + r.from,
634
633
  to: n.from + r.to,
635
634
  inner: r.inner
636
635
  } : null;
637
636
  }
638
- function rt(e) {
639
- let t = nt(e.state);
637
+ function tt(e) {
638
+ let t = et(e.state);
640
639
  if (t) return e.dispatch({
641
640
  changes: {
642
641
  from: t.from,
643
642
  to: t.to,
644
643
  insert: t.inner
645
644
  },
646
- selection: d.range(t.from, t.from + t.inner.length),
645
+ selection: f.range(t.from, t.from + t.inner.length),
647
646
  scrollIntoView: !0
648
647
  }), e.focus(), !0;
649
648
  let { from: n, to: r } = e.state.selection.main, i = e.state.sliceDoc(n, r) || "text";
@@ -653,33 +652,33 @@ function rt(e) {
653
652
  to: r,
654
653
  insert: `<u>${i}</u>`
655
654
  },
656
- selection: d.range(n + 3, n + 3 + i.length),
655
+ selection: f.range(n + 3, n + 3 + i.length),
657
656
  scrollIntoView: !0
658
657
  }), e.focus(), !0;
659
658
  }
660
- function it(e) {
661
- return nt(e) !== null;
659
+ function nt(e) {
660
+ return et(e) !== null;
662
661
  }
663
662
  //#endregion
664
663
  //#region src/toolbar/table-grid.ts
665
- function at(e) {
664
+ function rt(e) {
666
665
  let t = e.trim();
667
666
  return t.includes("-") && t.includes("|") && /^[\s|:-]+$/.test(t);
668
667
  }
669
- function ot(e) {
668
+ function it(e) {
670
669
  let t = e.trim();
671
670
  t.startsWith("|") && (t = t.slice(1)), t.endsWith("|") && !t.endsWith("\\|") && (t = t.slice(0, -1));
672
671
  let n = [], r = "";
673
672
  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];
674
673
  return n.push(r.trim()), n;
675
674
  }
676
- function st(e) {
675
+ function at(e) {
677
676
  let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
678
677
  return n && r ? "center" : r ? "right" : n ? "left" : "";
679
678
  }
680
679
  function R(e) {
681
- if (e.length < 2 || !at(e[1])) return null;
682
- let t = ot(e[1]).map(st), n = e.filter((e, t) => t !== 1).map(ot), r = Math.max(t.length, ...n.map((e) => e.length)), i = n.map((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) => {
683
682
  let t = e.slice(0, r);
684
683
  for (; t.length < r;) t.push("");
685
684
  return t;
@@ -690,11 +689,11 @@ function R(e) {
690
689
  aligns: a
691
690
  };
692
691
  }
693
- function ct(e) {
692
+ function ot(e) {
694
693
  return e.replace(/\\\|/g, "|").length;
695
694
  }
696
- function lt(e, t, n) {
697
- let r = t - ct(e);
695
+ function st(e, t, n) {
696
+ let r = t - ot(e);
698
697
  if (r <= 0) return e;
699
698
  if (n === "right") return " ".repeat(r) + e;
700
699
  if (n === "center") {
@@ -703,23 +702,23 @@ function lt(e, t, n) {
703
702
  }
704
703
  return e + " ".repeat(r);
705
704
  }
706
- function ut(e, t) {
705
+ function ct(e, t) {
707
706
  let n = Math.max(3, e);
708
707
  return t === "left" ? ":" + "-".repeat(n - 1) : t === "right" ? "-".repeat(n - 1) + ":" : t === "center" ? ":" + "-".repeat(n - 2) + ":" : "-".repeat(n);
709
708
  }
710
- function z(e) {
709
+ function lt(e) {
711
710
  let t = e.aligns.length, n = [];
712
711
  for (let r = 0; r < t; r++) {
713
712
  let t = 3;
714
- for (let n of e.rows) t = Math.max(t, ct(n[r] ?? ""));
713
+ for (let n of e.rows) t = Math.max(t, ot(n[r] ?? ""));
715
714
  n.push(t);
716
715
  }
717
- let r = (t) => "| " + t.map((t, r) => lt(t ?? "", n[r], e.aligns[r])).join(" | ") + " |", i = [r(e.rows[0] ?? [])];
718
- i.push("| " + e.aligns.map((e, t) => ut(n[t], e)).join(" | ") + " |");
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(" | ") + " |");
719
718
  for (let t = 1; t < e.rows.length; t++) i.push(r(e.rows[t]));
720
719
  return i.join("\n");
721
720
  }
722
- function dt(e) {
721
+ function ut(e) {
723
722
  let t = [];
724
723
  for (let n = 0; n < e.length; n++) {
725
724
  if (e[n] === "\\") {
@@ -742,7 +741,7 @@ function dt(e) {
742
741
  }
743
742
  //#endregion
744
743
  //#region src/toolbar/table-position.ts
745
- function B(e, t) {
744
+ function z(e, t) {
746
745
  let n = e.lineAt(t);
747
746
  if (!n.text.includes("|")) return null;
748
747
  let r = n.number;
@@ -766,7 +765,7 @@ function B(e, t) {
766
765
  lines: a
767
766
  } : null;
768
767
  }
769
- function ft(e, t, n) {
768
+ function dt(e, t, n) {
770
769
  let r = t;
771
770
  for (let t = 0; t < e.length; t++) {
772
771
  let i = e[t];
@@ -782,7 +781,7 @@ function ft(e, t, n) {
782
781
  onDelimiter: !0
783
782
  };
784
783
  }
785
- let a = dt(i), o = 0;
784
+ let a = ut(i), o = 0;
786
785
  for (let t = 0; t < a.length && (o = t, !(e <= a[t].end)); t++);
787
786
  let s = a[o], c = s ? Math.max(0, Math.min(e, s.contentEnd) - s.contentStart) : 0;
788
787
  return {
@@ -796,15 +795,15 @@ function ft(e, t, n) {
796
795
  }
797
796
  return null;
798
797
  }
799
- function V(e, t, n) {
798
+ function B(e, t, n) {
800
799
  let r = e.split("\n"), i = n.onDelimiter ? 1 : n.row === 0 ? 0 : n.row + 1, a = t;
801
800
  for (let e = 0; e < i; e++) a += r[e].length + 1;
802
- let o = dt(r[i]), s = o[Math.min(n.col, o.length - 1)];
801
+ let o = ut(r[i]), s = o[Math.min(n.col, o.length - 1)];
803
802
  return s ? a + s.contentStart + Math.min(n.offset, s.contentEnd - s.contentStart) : a;
804
803
  }
805
- function pt(e, t, n, r) {
806
- let i = B(e, t);
807
- return i ? V(i.lines.join("\n"), i.from, {
804
+ function ft(e, t, n, r) {
805
+ let i = z(e, t);
806
+ return i ? B(i.lines.join("\n"), i.from, {
808
807
  row: n,
809
808
  col: r,
810
809
  offset: 0,
@@ -813,7 +812,7 @@ function pt(e, t, n, r) {
813
812
  }
814
813
  //#endregion
815
814
  //#region src/toolbar/table.ts
816
- function mt(e, t) {
815
+ function pt(e, t) {
817
816
  requestAnimationFrame(() => {
818
817
  let n = e.dom.querySelectorAll(".cm-inplace-table-edit");
819
818
  if (n.length === 0) return;
@@ -833,7 +832,7 @@ function mt(e, t) {
833
832
  s?.removeAllRanges(), s?.addRange(o), a.focus();
834
833
  });
835
834
  }
836
- function ht(e) {
835
+ function mt(e) {
837
836
  let { from: t, to: n } = e.state.selection.main, r = e.state.doc.lineAt(t), i = r.text.slice(0, t - r.from).trim() ? "\n\n" : "", a = t + i.length + 2;
838
837
  return e.dispatch({
839
838
  changes: {
@@ -841,32 +840,32 @@ function ht(e) {
841
840
  to: n,
842
841
  insert: i + "| Column 1 | Column 2 |\n| -------- | -------- |\n| | |\n"
843
842
  },
844
- selection: d.range(a, a + 8),
843
+ selection: f.range(a, a + 8),
845
844
  scrollIntoView: !0
846
- }), e.focus(), mt(e, a), !0;
845
+ }), e.focus(), pt(e, a), !0;
847
846
  }
848
- function H(e) {
849
- return B(e.doc, e.selection.main.head) !== null;
847
+ function V(e) {
848
+ return z(e.doc, e.selection.main.head) !== null;
850
849
  }
851
- function U(e, t) {
852
- let n = B(e.state.doc, e.state.selection.main.head);
850
+ function H(e, t) {
851
+ let n = z(e.state.doc, e.state.selection.main.head);
853
852
  if (!n) return !1;
854
- let r = R(n.lines), i = ft(n.lines, n.from, e.state.selection.main.head);
853
+ let r = R(n.lines), i = dt(n.lines, n.from, e.state.selection.main.head);
855
854
  if (!r || !i) return !1;
856
855
  let a = t(r, i);
857
856
  if (!a) return !1;
858
- let o = z(r);
857
+ let o = lt(r);
859
858
  return e.dispatch({
860
859
  changes: {
861
860
  from: n.from,
862
861
  to: n.to,
863
862
  insert: o
864
863
  },
865
- selection: d.cursor(V(o, n.from, a)),
864
+ selection: f.cursor(B(o, n.from, a)),
866
865
  scrollIntoView: !0
867
866
  }), e.focus(), !0;
868
867
  }
869
- function gt(e, t, n) {
868
+ function ht(e, t, n) {
870
869
  let r = e.aligns.length, { row: i, col: a } = t;
871
870
  return a += n, a >= r ? (i++, a = 0) : a < 0 && (i--, a = r - 1), i < 0 ? null : (i >= e.rows.length && e.rows.push(Array(r).fill("")), {
872
871
  row: i,
@@ -875,7 +874,7 @@ function gt(e, t, n) {
875
874
  onDelimiter: !1
876
875
  });
877
876
  }
878
- function _t(e, t) {
877
+ function gt(e, t) {
879
878
  let n = t.row + 1;
880
879
  return n >= e.rows.length && e.rows.push(Array(e.aligns.length).fill("")), {
881
880
  row: n,
@@ -884,58 +883,58 @@ function _t(e, t) {
884
883
  onDelimiter: !1
885
884
  };
886
885
  }
887
- var vt = a.of([
886
+ var _t = o.of([
888
887
  {
889
888
  key: "Tab",
890
- run: (e) => U(e, (e, t) => gt(e, t, 1))
889
+ run: (e) => H(e, (e, t) => ht(e, t, 1))
891
890
  },
892
891
  {
893
892
  key: "Shift-Tab",
894
- run: (e) => U(e, (e, t) => gt(e, t, -1))
893
+ run: (e) => H(e, (e, t) => ht(e, t, -1))
895
894
  },
896
895
  {
897
896
  key: "Enter",
898
- run: (e) => U(e, _t)
897
+ run: (e) => H(e, gt)
899
898
  }
900
- ]), yt = f.transactionFilter.of((e) => {
899
+ ]), vt = p.transactionFilter.of((e) => {
901
900
  if (!e.docChanged || !e.isUserEvent("input") && !e.isUserEvent("delete")) return e;
902
- let t = e.newSelection.main.head, n = B(e.newDoc, t);
901
+ let t = e.newSelection.main.head, n = z(e.newDoc, t);
903
902
  if (!n) return e;
904
903
  let r = R(n.lines);
905
904
  if (!r) return e;
906
- let i = z(r);
905
+ let i = lt(r);
907
906
  if (i === n.lines.join("\n")) return e;
908
- let a = ft(n.lines, n.from, t), o = l.of([{
907
+ let a = dt(n.lines, n.from, t), o = u.of([{
909
908
  from: n.from,
910
909
  to: n.to,
911
910
  insert: i
912
911
  }], e.newDoc.length);
913
912
  return {
914
913
  changes: e.changes.compose(o),
915
- selection: a ? d.cursor(V(i, n.from, a)) : e.newSelection,
914
+ selection: a ? f.cursor(B(i, n.from, a)) : e.newSelection,
916
915
  effects: e.effects,
917
916
  scrollIntoView: e.scrollIntoView
918
917
  };
919
- }), W = (e) => /^\s{0,3}#{1,6}(?:\s|$)/.test(e.doc.lineAt(e.selection.main.head).text), G = (e) => {
920
- let n = t(e.doc);
921
- return n !== null && e.selection.main.head <= n.to;
922
- }, K = (e) => G(e) || P(e) || F(e), bt = (e) => (t) => e !== "`" && L(t, "`") || e !== "$" && L(t, "$"), xt = (e) => e.selection.main.empty && !e.wordAt(e.selection.main.head), q = (...e) => (t) => e.some((e) => e(t)), J = /^(\s*)(?:[-*+] \[[ xX]\] +|\d+\. +|[-*+] +)/, St = {
918
+ }), U = (e) => /^\s{0,3}#{1,6}(?:\s|$)/.test(e.doc.lineAt(e.selection.main.head).text), W = (e) => {
919
+ let t = n(e.doc);
920
+ 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 = {
923
922
  match: /^ {0,3}> ?/,
924
923
  insert: "> "
925
- }, Ct = {
924
+ }, St = {
926
925
  match: /^(\s*)[-*+] +(?!\[[ xX]\])/,
927
926
  insert: "- ",
928
- siblings: J
929
- }, wt = {
927
+ siblings: q
928
+ }, Ct = {
930
929
  match: /^(\s*)\d+\. +/,
931
930
  insert: (e) => `${e + 1}. `,
932
- siblings: J
933
- }, Tt = {
931
+ siblings: q
932
+ }, wt = {
934
933
  match: /^(\s*)[-*+] \[[ xX]\] +/,
935
934
  insert: "- [ ] ",
936
- siblings: J
935
+ siblings: q
937
936
  };
938
- function Et(e, t, n) {
937
+ function Tt(e, t, n) {
939
938
  return {
940
939
  id: e,
941
940
  title: t,
@@ -945,77 +944,77 @@ function Et(e, t, n) {
945
944
  }
946
945
  };
947
946
  }
948
- function Y(e, t, n, r) {
947
+ function J(e, t, n, r) {
949
948
  return {
950
949
  id: e,
951
950
  title: t,
952
951
  run: (e) => j(e, (e, t, r) => O(e, t, r, n)) || I(e, n),
953
952
  isActive: (e) => L(e, n),
954
- disabled: q(K, bt(n), xt),
953
+ disabled: K(G, yt(n), bt),
955
954
  keys: r
956
955
  };
957
956
  }
958
- function X(e) {
957
+ function Y(e) {
959
958
  let t = RegExp(`^#{${e}} `);
960
959
  return {
961
960
  id: `h${e}`,
962
961
  title: `Heading ${e}`,
963
- run: (t) => Je(t, e),
962
+ run: (t) => Ke(t, e),
964
963
  isActive: (e) => t.test(e.doc.lineAt(e.selection.main.head).text),
965
- disabled: q(H, K),
964
+ disabled: K(V, G),
966
965
  keys: [`Mod-Alt-${e}`]
967
966
  };
968
967
  }
969
- function Z(e, t, n, ...r) {
968
+ function X(e, t, n, ...r) {
970
969
  return {
971
970
  id: e,
972
971
  title: t,
973
- run: (e) => Ve(e, n),
974
- isActive: (e) => He(e, n.match),
975
- disabled: q(H, K, ...r)
972
+ run: (e) => ze(e, n),
973
+ isActive: (e) => Be(e, n.match),
974
+ disabled: K(V, G, ...r)
976
975
  };
977
976
  }
978
977
  //#endregion
979
978
  //#region src/toolbar/frontmatter-toggle.ts
980
- function Dt(e) {
981
- let n = e.state, r = t(n.doc);
979
+ function Et(e) {
980
+ let t = e.state, r = n(t.doc);
982
981
  if (r) {
983
- let t = n.doc.lineAt(r.from), i = n.doc.lineAt(r.to);
982
+ let n = t.doc.lineAt(r.from), i = t.doc.lineAt(r.to);
984
983
  e.dispatch({
985
984
  changes: [{
986
- from: t.from,
987
- to: Math.min(t.to + 1, n.doc.length)
985
+ from: n.from,
986
+ to: Math.min(n.to + 1, t.doc.length)
988
987
  }, {
989
988
  from: i.from,
990
- to: Math.min(i.to + 1, n.doc.length)
989
+ to: Math.min(i.to + 1, t.doc.length)
991
990
  }],
992
991
  scrollIntoView: !0
993
992
  });
994
993
  } else {
995
- let t = n.doc.lineAt(n.selection.main.to).number;
994
+ let n = t.doc.lineAt(t.selection.main.to).number;
996
995
  e.dispatch({
997
996
  changes: [{
998
997
  from: 0,
999
998
  insert: "---\n"
1000
999
  }, {
1001
- from: n.doc.line(t).to,
1000
+ from: t.doc.line(n).to,
1002
1001
  insert: "\n---"
1003
1002
  }],
1004
- selection: d.cursor(4),
1003
+ selection: f.cursor(4),
1005
1004
  scrollIntoView: !0
1006
1005
  });
1007
1006
  }
1008
1007
  return e.focus(), !0;
1009
1008
  }
1010
- function Ot(e) {
1011
- return t(e.doc) !== null;
1009
+ function Dt(e) {
1010
+ return n(e.doc) !== null;
1012
1011
  }
1013
1012
  //#endregion
1014
1013
  //#region src/toolbar/rule.ts
1015
- var kt = /^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/;
1016
- function At(e) {
1014
+ var Ot = /^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/;
1015
+ function kt(e) {
1017
1016
  let t = e.state, n = t.doc.lineAt(t.selection.main.head);
1018
- return kt.test(n.text) ? e.dispatch({
1017
+ return Ot.test(n.text) ? e.dispatch({
1019
1018
  changes: {
1020
1019
  from: n.from,
1021
1020
  to: Math.min(n.to + 1, t.doc.length)
@@ -1027,57 +1026,57 @@ function At(e) {
1027
1026
  to: n.to,
1028
1027
  insert: "---"
1029
1028
  },
1030
- selection: d.cursor(n.from + 3),
1029
+ selection: f.cursor(n.from + 3),
1031
1030
  scrollIntoView: !0
1032
1031
  }) : e.dispatch({
1033
1032
  changes: {
1034
1033
  from: n.to,
1035
1034
  insert: "\n\n---\n"
1036
1035
  },
1037
- selection: d.cursor(n.to + 6),
1036
+ selection: f.cursor(n.to + 6),
1038
1037
  scrollIntoView: !0
1039
1038
  }), e.focus(), !0;
1040
1039
  }
1041
- function jt(e) {
1042
- return kt.test(e.doc.lineAt(e.selection.main.head).text);
1040
+ function At(e) {
1041
+ return Ot.test(e.doc.lineAt(e.selection.main.head).text);
1043
1042
  }
1044
1043
  //#endregion
1045
1044
  //#region src/editor/save.ts
1046
- var Q = p.define({ combine: (e) => e[0] ?? null });
1047
- function Mt(e) {
1048
- let t = e.state.facet(Q);
1045
+ var Z = ee.define({ combine: (e) => e[0] ?? null });
1046
+ function jt(e) {
1047
+ let t = e.state.facet(Z);
1049
1048
  return t ? (t(e.state.doc.toString()), !0) : !1;
1050
1049
  }
1051
1050
  //#endregion
1052
1051
  //#region src/editor/search-panel-dom.ts
1053
- var Nt = "stylo-search-panel";
1054
- function Pt(e) {
1052
+ var Mt = "stylo-search-panel";
1053
+ function Nt(e) {
1055
1054
  e.setAttribute("form", "");
1056
1055
  }
1057
- function Ft(e, t, n) {
1056
+ function Pt(e, t, n) {
1058
1057
  let r = document.createElement("input");
1059
- return r.type = "text", r.name = e, r.placeholder = t, r.setAttribute("aria-label", t), r.className = n, Pt(r), r;
1058
+ return r.type = "text", r.name = e, r.placeholder = t, r.setAttribute("aria-label", t), r.className = n, Nt(r), r;
1060
1059
  }
1061
- function $(e, t) {
1060
+ function Q(e, t) {
1062
1061
  let n = document.createElement("button");
1063
1062
  return n.type = "button", n.name = e, n.className = "stylo-search-button", n.textContent = t, n;
1064
1063
  }
1065
- function It(e, t) {
1064
+ function $(e, t) {
1066
1065
  let n = document.createElement("input");
1067
- n.type = "checkbox", n.name = e, Pt(n);
1066
+ n.type = "checkbox", n.name = e, Nt(n);
1068
1067
  let r = document.createElement("label");
1069
1068
  return r.className = "stylo-search-check", r.append(n, document.createTextNode(t)), {
1070
1069
  field: n,
1071
1070
  wrap: r
1072
1071
  };
1073
1072
  }
1074
- function Lt(e) {
1075
- let t = (t) => e.state.phrase(t), n = Ft("search", t("Find"), "stylo-search-field");
1073
+ function Ft(e) {
1074
+ let t = (t) => e.state.phrase(t), n = Pt("search", t("Find"), "stylo-search-field");
1076
1075
  n.setAttribute("main-field", "true");
1077
- let r = $("next", t("next")), i = $("prev", t("previous")), a = $("select", t("all")), o = Ft("replace", t("Replace"), "stylo-search-field stylo-search-replace"), s = $("replace", t("replace")), c = $("replaceAll", t("replace all")), l = It("case", t("match case")), u = It("re", t("regexp")), d = It("word", t("by word")), f = $("close", "×");
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", "×");
1078
1077
  f.classList.add("stylo-search-close"), f.setAttribute("aria-label", t("close"));
1079
1078
  let p = document.createElement("div");
1080
- return p.className = Nt, p.append(n, r, i, a, o, s, c, l.wrap, u.wrap, d.wrap, f), {
1079
+ return p.className = Mt, p.append(n, r, i, a, o, s, c, l.wrap, u.wrap, d.wrap, f), {
1081
1080
  root: p,
1082
1081
  find: n,
1083
1082
  next: r,
@@ -1094,24 +1093,24 @@ function Lt(e) {
1094
1093
  }
1095
1094
  //#endregion
1096
1095
  //#region src/editor/search-panel.ts
1097
- var Rt = "cm-search-closing", zt = 160;
1098
- function Bt(e) {
1099
- return ce(e.state) ? Vt(e) : re(e);
1096
+ var It = "cm-search-closing", Lt = 160;
1097
+ function Rt(e) {
1098
+ return ce(e.state) ? zt(e) : re(e);
1100
1099
  }
1101
- function Vt(e) {
1102
- let t = e.dom.querySelector(`.${Nt}`);
1103
- return !t || t.classList.contains(Rt) ? !0 : (t.classList.add(Rt), setTimeout(() => {
1100
+ function zt(e) {
1101
+ let t = e.dom.querySelector(`.${Mt}`);
1102
+ return !t || t.classList.contains(It) ? !0 : (t.classList.add(It), setTimeout(() => {
1104
1103
  e.dom.isConnected && ne(e);
1105
- }, zt), !0);
1104
+ }, Lt), !0);
1106
1105
  }
1107
- function Ht(e) {
1108
- let t = Lt(e), n = C(e.state);
1106
+ function Bt(e) {
1107
+ let t = Ft(e), n = w(e.state);
1109
1108
  r(n);
1110
1109
  function r(e) {
1111
1110
  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;
1112
1111
  }
1113
1112
  function i() {
1114
- let r = new b({
1113
+ let r = new x({
1115
1114
  search: t.find.value,
1116
1115
  caseSensitive: t.caseSensitive.checked,
1117
1116
  regexp: t.regexp.checked,
@@ -1129,15 +1128,15 @@ function Ht(e) {
1129
1128
  ]) e.addEventListener("input", i), e.addEventListener("change", i);
1130
1129
  return t.root.addEventListener("keydown", (n) => {
1131
1130
  if (n.key === "Escape") {
1132
- n.preventDefault(), Vt(e);
1131
+ n.preventDefault(), zt(e);
1133
1132
  return;
1134
1133
  }
1135
- if (s(e, n, "search-panel")) {
1134
+ if (c(e, n, "search-panel")) {
1136
1135
  n.preventDefault();
1137
1136
  return;
1138
1137
  }
1139
- n.key === "Enter" && (n.preventDefault(), n.target === t.find ? (n.shiftKey ? S : x)(e) : n.target === t.replace && ae(e));
1140
- }), t.next.addEventListener("click", () => x(e)), t.prev.addEventListener("click", () => S(e)), t.all.addEventListener("click", () => le(e)), t.replaceBtn.addEventListener("click", () => ae(e)), t.replaceAllBtn.addEventListener("click", () => ie(e)), t.close.addEventListener("click", () => Vt(e)), {
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)), {
1141
1140
  dom: t.root,
1142
1141
  top: !0,
1143
1142
  update(e) {
@@ -1147,192 +1146,153 @@ function Ht(e) {
1147
1146
  }
1148
1147
  //#endregion
1149
1148
  //#region src/toolbar/commands.ts
1150
- var Ut = [
1151
- Et("undo", "Undo", _),
1152
- Et("redo", "Redo", g),
1149
+ var Vt = [
1150
+ Tt("undo", "Undo", v),
1151
+ Tt("redo", "Redo", _),
1153
1152
  {
1154
1153
  id: "save",
1155
1154
  title: "Save",
1156
1155
  run: (e) => {
1157
- let t = Mt(e);
1156
+ let t = jt(e);
1158
1157
  return e.focus(), t;
1159
1158
  },
1160
- disabled: (e) => e.facet(Q) == null
1159
+ disabled: (e) => e.facet(Z) == null
1161
1160
  },
1162
1161
  {
1163
1162
  id: "search",
1164
1163
  title: "Find / replace",
1165
- run: (e) => Bt(e),
1164
+ run: (e) => Rt(e),
1166
1165
  isActive: (e) => ce(e),
1167
1166
  keys: ["Mod-f"]
1168
1167
  },
1169
- X(1),
1170
- X(2),
1171
- X(3),
1168
+ Y(1),
1169
+ Y(2),
1170
+ Y(3),
1172
1171
  {
1173
1172
  id: "body",
1174
1173
  title: "Body",
1175
- run: (e) => (Ye(e) || e.focus(), !0),
1174
+ run: (e) => (qe(e) || e.focus(), !0),
1176
1175
  isActive: (e) => !/^#{1,6} /.test(e.doc.lineAt(e.selection.main.head).text),
1177
- disabled: q(H, K)
1176
+ disabled: K(V, G)
1178
1177
  },
1179
- Y("bold", "Bold", "**", ["Mod-b"]),
1180
- Y("italic", "Italic", "*", ["Mod-i"]),
1181
- Y("strike", "Strikethrough", "~~"),
1178
+ J("bold", "Bold", "**", ["Mod-b"]),
1179
+ J("italic", "Italic", "*", ["Mod-i"]),
1180
+ J("strike", "Strikethrough", "~~"),
1182
1181
  {
1183
1182
  id: "underline",
1184
1183
  title: "Underline",
1185
- run: (e) => j(e, Se) || rt(e),
1186
- isActive: it,
1187
- disabled: q(K, bt("u"), xt),
1184
+ run: (e) => j(e, be) || tt(e),
1185
+ isActive: nt,
1186
+ disabled: K(G, yt("u"), bt),
1188
1187
  keys: ["Mod-u"]
1189
1188
  },
1190
- Y("code", "Inline code", "`"),
1189
+ J("code", "Inline code", "`"),
1191
1190
  {
1192
1191
  id: "codeBlock",
1193
1192
  title: "Code block",
1194
- run: (e) => j(e, (e, t, n) => O(e, t, n, "`")) || (H(e.state) ? I(e, "`") : Ue(e)),
1195
- isActive: (e) => H(e) ? L(e, "`") : P(e),
1196
- disabled: q(G, F, W)
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)
1197
1196
  },
1198
1197
  {
1199
1198
  id: "link",
1200
1199
  title: "Link",
1201
- run: (e) => j(e, ve) || Ze(e),
1202
- isActive: Qe,
1203
- disabled: K,
1200
+ run: (e) => j(e, ge) || Ye(e),
1201
+ isActive: Xe,
1202
+ disabled: G,
1204
1203
  keys: ["Mod-k"]
1205
1204
  },
1206
1205
  {
1207
1206
  id: "wikilink",
1208
1207
  title: "Wikilink",
1209
- run: (e) => j(e, be) || et(e),
1210
- isActive: tt,
1211
- disabled: K,
1208
+ run: (e) => j(e, ve) || Qe(e),
1209
+ isActive: $e,
1210
+ disabled: G,
1212
1211
  keys: ["Mod-Shift-k"]
1213
1212
  },
1214
- Z("quote", "Blockquote", St),
1215
- Z("bulletList", "Bulleted list", Ct, W),
1216
- Z("orderedList", "Numbered list", wt, W),
1217
- Z("task", "Task list", Tt, W),
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),
1218
1217
  {
1219
1218
  id: "hr",
1220
1219
  title: "Divider",
1221
- run: At,
1222
- isActive: jt,
1223
- disabled: q(H, K)
1220
+ run: kt,
1221
+ isActive: At,
1222
+ disabled: K(V, G)
1224
1223
  },
1225
1224
  {
1226
1225
  id: "frontmatter",
1227
1226
  title: "Frontmatter",
1228
- run: Dt,
1229
- isActive: Ot,
1230
- disabled: q(H, P, F, W)
1227
+ run: Et,
1228
+ isActive: Dt,
1229
+ disabled: K(V, P, F, U)
1231
1230
  },
1232
1231
  {
1233
1232
  id: "table",
1234
1233
  title: "Table",
1235
- run: ht,
1236
- isActive: H,
1237
- disabled: q(H, G, P, F, W)
1234
+ run: mt,
1235
+ isActive: V,
1236
+ disabled: K(V, W, P, F, U)
1238
1237
  },
1239
- Y("math", "Inline math", "$"),
1238
+ J("math", "Inline math", "$"),
1240
1239
  {
1241
1240
  id: "mathBlock",
1242
1241
  title: "Block math",
1243
- run: (e) => j(e, (e, t, n) => O(e, t, n, "$")) || (H(e.state) ? I(e, "$") : qe(e)),
1244
- isActive: (e) => H(e) ? L(e, "$") : F(e),
1245
- disabled: q(G, P, W)
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)
1246
1245
  }
1247
- ], Wt = Object.fromEntries(Ut.map((e) => [e.id, e])), Gt = m.high(a.of(Ut.filter((e) => e.keys && e.keys.length > 0).flatMap((e) => e.keys.map((t) => ({
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) => ({
1248
1247
  key: t,
1249
1248
  preventDefault: !0,
1250
1249
  run: ((t) => !e.disabled?.(t.state) && e.run(t))
1251
- }))))), Kt = de.define([
1252
- {
1253
- tag: [
1254
- w.keyword,
1255
- w.modifier,
1256
- w.controlKeyword,
1257
- w.operatorKeyword,
1258
- w.definitionKeyword,
1259
- w.moduleKeyword
1260
- ],
1261
- color: "var(--stylo-syntax-keyword)"
1262
- },
1263
- {
1264
- tag: [
1265
- w.string,
1266
- w.special(w.string),
1267
- w.regexp,
1268
- w.attributeValue
1269
- ],
1270
- color: "var(--stylo-syntax-string)"
1271
- },
1272
- {
1273
- tag: [w.escape, w.character],
1274
- color: "var(--stylo-syntax-escape)"
1275
- },
1276
- {
1277
- tag: [
1278
- w.comment,
1279
- w.lineComment,
1280
- w.blockComment,
1281
- w.docComment
1282
- ],
1283
- color: "var(--stylo-syntax-comment)",
1284
- fontStyle: "italic"
1285
- },
1286
- {
1287
- tag: [
1288
- w.number,
1289
- w.integer,
1290
- w.float
1291
- ],
1292
- color: "var(--stylo-syntax-number)"
1293
- },
1294
- {
1295
- tag: [
1296
- w.bool,
1297
- w.null,
1298
- w.atom,
1299
- w.constant(w.name)
1300
- ],
1301
- color: "var(--stylo-syntax-constant)"
1302
- },
1303
- {
1304
- tag: [
1305
- w.function(w.variableName),
1306
- w.function(w.propertyName),
1307
- w.macroName
1308
- ],
1309
- color: "var(--stylo-syntax-function)"
1310
- },
1311
- {
1312
- tag: [
1313
- w.typeName,
1314
- w.className,
1315
- w.namespace
1316
- ],
1317
- color: "var(--stylo-syntax-type)"
1318
- },
1319
- {
1320
- tag: [w.propertyName, w.attributeName],
1321
- color: "var(--stylo-syntax-property)"
1322
- },
1323
- {
1324
- tag: [w.tagName],
1325
- color: "var(--stylo-syntax-tag)"
1326
- },
1327
- {
1328
- tag: [w.meta, w.annotation],
1329
- color: "var(--stylo-syntax-comment)"
1330
- },
1331
- {
1332
- tag: [w.invalid],
1333
- color: "var(--stylo-syntax-invalid)"
1334
- }
1335
- ]), qt = fe(Kt), Jt = i.theme({
1250
+ }))))), Wt = /(?<=^|\s)#[^\s#]*$/;
1251
+ function Gt(e) {
1252
+ return {
1253
+ label: e.tag,
1254
+ apply: (t, n, r, i) => {
1255
+ t.dispatch({
1256
+ changes: {
1257
+ from: r,
1258
+ to: i,
1259
+ insert: e.tag
1260
+ },
1261
+ selection: { anchor: r + e.tag.length },
1262
+ userEvent: "input.complete"
1263
+ });
1264
+ }
1265
+ };
1266
+ }
1267
+ function Kt(e, t) {
1268
+ return async (n) => {
1269
+ let r = n.matchBefore(Wt);
1270
+ if (!r || r.from + 1 === n.pos && !n.explicit) return null;
1271
+ let i = r.text.slice(1);
1272
+ if (/^\d/.test(i)) return null;
1273
+ let a;
1274
+ try {
1275
+ a = (await e(i)).map(Gt);
1276
+ } catch (e) {
1277
+ return t?.(e, {
1278
+ source: "tagSource",
1279
+ input: i
1280
+ }), null;
1281
+ }
1282
+ return a.length ? {
1283
+ from: r.from + 1,
1284
+ to: n.pos,
1285
+ options: a,
1286
+ filter: !1
1287
+ } : null;
1288
+ };
1289
+ }
1290
+ function qt(e, t) {
1291
+ return e ? [fe(), b.data.of({ autocomplete: Kt(e, t) })] : [];
1292
+ }
1293
+ //#endregion
1294
+ //#region src/editor/theme.ts
1295
+ var Jt = a.theme({
1336
1296
  "&": {
1337
1297
  color: "var(--stylo-text)",
1338
1298
  backgroundColor: "var(--stylo-bg)",
@@ -1475,85 +1435,86 @@ function Zt(e, t) {
1475
1435
  };
1476
1436
  }
1477
1437
  function Qt(e, t) {
1478
- return e ? [me(), y.data.of({ autocomplete: Zt(e, t) })] : [];
1438
+ return e ? [fe(), b.data.of({ autocomplete: Zt(e, t) })] : [];
1479
1439
  }
1480
1440
  //#endregion
1481
1441
  //#region src/editor/extensions.ts
1482
- function $t(e, t, n) {
1442
+ function $t(e, n, r, i) {
1483
1443
  return [
1484
- te(),
1485
- a.of([...ee, ...h]),
1486
- m.high(vt),
1487
- Gt,
1488
- yt,
1444
+ h(),
1445
+ o.of([...te, ...g]),
1446
+ m.high(_t),
1447
+ Ut,
1448
+ vt,
1489
1449
  oe({
1490
1450
  top: !0,
1491
- createPanel: Ht
1451
+ createPanel: Bt
1492
1452
  }),
1493
- a.of(se),
1494
- v({
1495
- base: y,
1453
+ o.of(se),
1454
+ y({
1455
+ base: b,
1496
1456
  codeLanguages: e
1497
1457
  }),
1498
- qt,
1499
- Qt(t, n),
1500
- i.lineWrapping,
1458
+ t,
1459
+ Qt(n, r),
1460
+ qt(i, r),
1461
+ a.lineWrapping,
1501
1462
  Jt
1502
1463
  ];
1503
1464
  }
1504
1465
  function en(e) {
1505
1466
  return [
1506
- f.readOnly.of(e.readOnly),
1507
- i.editable.of(!e.readOnly),
1508
- e.placeholder ? o(e.placeholder) : [],
1509
- e.save ? Q.of(e.save) : []
1467
+ p.readOnly.of(e.readOnly),
1468
+ a.editable.of(!e.readOnly),
1469
+ e.placeholder ? s(e.placeholder) : [],
1470
+ e.save ? Z.of(e.save) : []
1510
1471
  ];
1511
1472
  }
1512
1473
  //#endregion
1513
1474
  //#region src/editor/useCodeMirror.ts
1514
- var tn = c.define();
1515
- function nn({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c, onViewChange: l, extensions: d, codeLanguages: p, wikiLinkSource: ee, onResolveError: te }) {
1516
- let h = r(null), g = r(null), _ = r(t);
1517
- _.current = t;
1518
- let v = r(c);
1519
- v.current = c;
1520
- let y = r((e) => v.current?.(e)).current, b = r(te);
1521
- b.current = te;
1522
- let ne = r((e, t) => {
1523
- b.current?.(e, t);
1524
- }).current, x = c != null, S = r(l);
1525
- S.current = l;
1526
- let C = r(new u());
1527
- return n(() => {
1528
- let t = h.current;
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 }) {
1477
+ let g = i(null), _ = i(null), v = i(t);
1478
+ v.current = t;
1479
+ let y = i(c);
1480
+ y.current = c;
1481
+ let b = i((e) => y.current?.(e)).current, x = i(h);
1482
+ x.current = h;
1483
+ let ne = i((e, t) => {
1484
+ x.current?.(e, t);
1485
+ }).current, S = c != null, C = i(l);
1486
+ C.current = l;
1487
+ let w = i(new d());
1488
+ return r(() => {
1489
+ let t = g.current;
1529
1490
  if (!t) return;
1530
- let n = new i({
1491
+ let r = new a({
1531
1492
  parent: t,
1532
- state: f.create({
1493
+ state: p.create({
1533
1494
  doc: e,
1534
1495
  extensions: [
1535
- $t(p, ee, ne),
1536
- C.current.of(en({
1537
- readOnly: o,
1496
+ $t(f, ee, ne, te),
1497
+ w.current.of(en({
1498
+ readOnly: n,
1538
1499
  placeholder: s,
1539
- save: x ? y : void 0
1500
+ save: S ? b : void 0
1540
1501
  })),
1541
- m.high(a.of([{
1502
+ m.high(o.of([{
1542
1503
  key: "Mod-s",
1543
- run: Mt
1504
+ run: jt
1544
1505
  }])),
1545
- ...d ?? [],
1546
- i.updateListener.of((e) => {
1547
- e.docChanged && (e.transactions.some((e) => !!e.annotation(tn)) || _.current(e.state.doc.toString()));
1506
+ ...u ?? [],
1507
+ a.updateListener.of((e) => {
1508
+ e.docChanged && (e.transactions.some((e) => !!e.annotation(tn)) || v.current(e.state.doc.toString()));
1548
1509
  })
1549
1510
  ]
1550
1511
  })
1551
1512
  });
1552
- return g.current = n, S.current?.(n), () => {
1553
- S.current?.(null), n.destroy(), g.current = null;
1513
+ return _.current = r, C.current?.(r), () => {
1514
+ C.current?.(null), r.destroy(), _.current = null;
1554
1515
  };
1555
- }, []), n(() => {
1556
- let t = g.current;
1516
+ }, []), r(() => {
1517
+ let t = _.current;
1557
1518
  if (!t) return;
1558
1519
  let n = t.state.doc.toString();
1559
1520
  n !== e && t.dispatch({
@@ -1564,20 +1525,20 @@ function nn({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c
1564
1525
  },
1565
1526
  annotations: tn.of(!0)
1566
1527
  });
1567
- }, [e]), n(() => {
1568
- g.current?.dispatch({ effects: C.current.reconfigure(en({
1569
- readOnly: o,
1528
+ }, [e]), r(() => {
1529
+ _.current?.dispatch({ effects: w.current.reconfigure(en({
1530
+ readOnly: n,
1570
1531
  placeholder: s,
1571
- save: x ? y : void 0
1532
+ save: S ? b : void 0
1572
1533
  })) });
1573
1534
  }, [
1574
- o,
1535
+ n,
1575
1536
  s,
1576
- x,
1577
- y
1578
- ]), h;
1537
+ S,
1538
+ b
1539
+ ]), g;
1579
1540
  }
1580
1541
  //#endregion
1581
- export { ge as S, Ae as _, R as a, ye as b, P as c, ke as d, Pe as f, Ne as g, Ie as h, pt as i, Le as l, Me as m, Wt as n, z as o, A as p, At as r, We as s, nn as t, Be as u, je as v, _e as x, E as y };
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 };
1582
1543
 
1583
- //# sourceMappingURL=useCodeMirror-CjG9CwpB.js.map
1544
+ //# sourceMappingURL=useCodeMirror-COmcRrUo.js.map