@damiro/stylo 0.16.0 → 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.
@@ -2,18 +2,18 @@ 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 ne } from "@codemirror/commands";
5
+ import { defaultKeymap as te, history as ne, historyKeymap as h, redo as g, undo as _ } from "@codemirror/commands";
6
6
  import { markdown as v, markdownLanguage as y } from "@codemirror/lang-markdown";
7
- import { SearchQuery as b, closeSearchPanel as x, findNext as S, findPrevious as C, getSearchQuery as w, openSearchPanel as T, replaceAll as re, replaceNext as ie, search as ae, searchKeymap as oe, searchPanelOpen as se, selectMatches as ce, setSearchQuery as le } from "@codemirror/search";
8
- import { syntaxTree as ue } from "@codemirror/language";
9
- import { autocompletion as de } from "@codemirror/autocomplete";
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 fe = "stylo-canvas-header", pe = 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 = fe, 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 fe = "stylo-canvas-header", pe = class {
29
29
  };
30
30
  //#endregion
31
31
  //#region src/toolbar/link-ops.ts
32
- function E(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 E(e, t) {
41
41
  }
42
42
  return null;
43
43
  }
44
- function me(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 me(e, t) {
59
59
  }
60
60
  return null;
61
61
  }
62
- function he(e, t, n) {
63
- let r = E(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 he(e, t, n) {
75
75
  }
76
76
  //#endregion
77
77
  //#region src/toolbar/wikilink-ops.ts
78
- function D(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 D(t, n) {
86
86
  }
87
87
  return null;
88
88
  }
89
- function ge(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 ge(t, n) {
102
102
  }
103
103
  return null;
104
104
  }
105
- function _e(e, t, n) {
106
- let r = D(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 _e(e, t, n) {
118
118
  }
119
119
  //#endregion
120
120
  //#region src/toolbar/underline-ops.ts
121
- function ve(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 ve(e, t) {
130
130
  }
131
131
  return null;
132
132
  }
133
- function ye(e, t, n) {
134
- let r = ve(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 ye(e, t, n) {
146
146
  }
147
147
  //#endregion
148
148
  //#region src/toolbar/inline-ops.ts
149
- function O(e) {
149
+ function k(e) {
150
150
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
151
151
  }
152
- function be(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 be(e, t, n) {
158
158
  from: r
159
159
  };
160
160
  }
161
- function xe(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,29 +174,29 @@ function xe(e, t) {
174
174
  }
175
175
  return n;
176
176
  }
177
- function Se(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 Ce = /[\p{L}\p{N}_]/u;
181
- function we(e, t) {
180
+ var Se = /[\p{L}\p{N}_]/u;
181
+ function Ce(e, t) {
182
182
  let n = t, r = t;
183
- for (; n > 0 && Ce.test(e[n - 1]);) n--;
184
- for (; r < e.length && Ce.test(e[r]);) r++;
183
+ for (; n > 0 && Se.test(e[n - 1]);) n--;
184
+ for (; r < e.length && Se.test(e[r]);) r++;
185
185
  return r > n ? {
186
186
  from: n,
187
187
  to: r
188
188
  } : null;
189
189
  }
190
- function Te(e, t, n, r) {
190
+ function we(e, t, n, r) {
191
191
  if (t === n) {
192
- let r = we(e, t);
192
+ let r = Ce(e, t);
193
193
  r && (t = r.from, n = r.to);
194
194
  }
195
195
  let i = r.length, a = r[0], o = e.slice(t, n), s = 0;
196
196
  for (; o[s] === a;) s++;
197
197
  let c = 0;
198
198
  for (; o[o.length - 1 - c] === a;) c++;
199
- if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) && Se(s, c, i)) return {
199
+ if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) && xe(s, c, i)) return {
200
200
  changes: [{
201
201
  from: t,
202
202
  to: t + i,
@@ -209,10 +209,10 @@ function Te(e, t, n, r) {
209
209
  from: t,
210
210
  to: n - 2 * i
211
211
  };
212
- let l = be(e, t, -1), u = be(e, n, 1), d = xe(l.text, a), f = xe(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();
213
213
  for (let e = 0; e < Math.min(d.length, f.length); e++) {
214
214
  let r = d[e], a = f[e];
215
- if (!Se(r.len, a.len, i)) continue;
215
+ if (!xe(r.len, a.len, i)) continue;
216
216
  let o = l.from + r.start + r.len, s = n + a.start;
217
217
  return {
218
218
  changes: [{
@@ -242,26 +242,26 @@ function Te(e, t, n, r) {
242
242
  to: n + i
243
243
  };
244
244
  }
245
- function Ee(e, t) {
245
+ function Te(e, t) {
246
246
  let n = e;
247
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);
248
248
  return n;
249
249
  }
250
- function k(e, t, n, r) {
251
- let i = Te(e, t, n, r);
250
+ function A(e, t, n, r) {
251
+ let i = we(e, t, n, r);
252
252
  return {
253
- text: Ee(e, i.changes),
253
+ text: Te(e, i.changes),
254
254
  from: i.from,
255
255
  to: i.to
256
256
  };
257
257
  }
258
- function De(e, t) {
259
- let n = E(e, t);
258
+ function Ee(e, t) {
259
+ let n = O(e, t);
260
260
  if (n) return {
261
261
  from: n.from,
262
262
  to: n.to
263
263
  };
264
- let r = ge(e, t);
264
+ let r = he(e, t);
265
265
  if (r) return {
266
266
  from: r.from,
267
267
  to: r.to
@@ -273,7 +273,7 @@ function De(e, t) {
273
273
  "*",
274
274
  "`"
275
275
  ]) {
276
- let r = RegExp(O(n) + "(?!\\s)(?:[^]*?\\S)??" + O(n), "g");
276
+ let r = RegExp(k(n) + "(?!\\s)(?:[^]*?\\S)??" + k(n), "g");
277
277
  for (let a; a = r.exec(e);) {
278
278
  if (a[0].length <= 2 * n.length) continue;
279
279
  let e = a.index + n.length, r = a.index + a[0].length - n.length;
@@ -287,8 +287,8 @@ function De(e, t) {
287
287
  }
288
288
  //#endregion
289
289
  //#region src/inplace/table-cell-dom.ts
290
- var Oe = (e) => [e.head, ...e.body].map((e) => [...e]), ke = (e) => e.map((e) => e.map((e) => e.trim())), Ae = (e) => e.replace(/\\\|/g, "|");
291
- function je(e, t) {
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, "|");
291
+ function j(e, t) {
292
292
  let n = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), r = 0;
293
293
  for (let e = n.nextNode(); e; e = n.nextNode()) {
294
294
  if (e === t) return r;
@@ -296,12 +296,12 @@ function je(e, t) {
296
296
  }
297
297
  return r;
298
298
  }
299
- function Me(e) {
299
+ function Ae(e) {
300
300
  let t = e.ownerDocument.getSelection(), n = t?.anchorNode;
301
- return !n || !e.contains(n) ? 0 : n.nodeType === Node.TEXT_NODE ? je(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;
302
302
  }
303
- function Ne(e) {
304
- let t = e.ownerDocument.getSelection(), n = (e.textContent ?? "").length, r = (t, r) => !t || !e.contains(t) ? n : t.nodeType === Node.TEXT_NODE ? je(e, t) + r : r > 0 ? n : 0;
303
+ function je(e) {
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;
305
305
  if (!t || t.rangeCount === 0) return {
306
306
  from: n,
307
307
  to: n
@@ -312,7 +312,7 @@ function Ne(e) {
312
312
  to: Math.max(i, a)
313
313
  };
314
314
  }
315
- function Pe(e, t, n) {
315
+ function Me(e, t, n) {
316
316
  let r = e.ownerDocument, i = null, a = 0;
317
317
  if (r.caretPositionFromPoint) {
318
318
  let e = r.caretPositionFromPoint(t, n);
@@ -321,18 +321,18 @@ function Pe(e, t, n) {
321
321
  let e = r.caretRangeFromPoint(t, n);
322
322
  e && ([i, a] = [e.startContainer, e.startOffset]);
323
323
  }
324
- return !i || !e.contains(i) ? 0 : je(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);
325
325
  }
326
- var Fe = /[\p{L}\p{N}_]/u;
327
- function Ie(e, t, n) {
328
- let r = e.textContent ?? "", i = Pe(e, t, n), a = De(r, i);
329
- if (a) return A(e, a.from, a.to), !0;
326
+ var Ne = /[\p{L}\p{N}_]/u;
327
+ function Pe(e, t, n) {
328
+ let r = e.textContent ?? "", i = Me(e, t, n), a = Ee(r, i);
329
+ if (a) return M(e, a.from, a.to), !0;
330
330
  let o = i, s = i;
331
- for (; o > 0 && Fe.test(r[o - 1]);) o--;
332
- for (; s < r.length && Fe.test(r[s]);) s++;
333
- return s <= o ? !1 : (A(e, o, s), !0);
331
+ for (; o > 0 && Ne.test(r[o - 1]);) o--;
332
+ for (; s < r.length && Ne.test(r[s]);) s++;
333
+ return s <= o ? !1 : (M(e, o, s), !0);
334
334
  }
335
- function A(e, t, n = t) {
335
+ function M(e, t, n = t) {
336
336
  e.focus();
337
337
  let r = e.ownerDocument, i = r.createRange(), a = e.firstChild;
338
338
  if (a && a.nodeType === Node.TEXT_NODE) {
@@ -345,38 +345,38 @@ function A(e, t, n = t) {
345
345
  }
346
346
  //#endregion
347
347
  //#region src/toolbar/cell-inline.ts
348
- function Le(e) {
348
+ function Fe(e) {
349
349
  let t = e.dom.ownerDocument.activeElement;
350
350
  return !(t instanceof HTMLElement) || !e.dom.contains(t) ? null : t.matches(".cm-inplace-tcell") ? t : null;
351
351
  }
352
- function Re(e, t) {
353
- let { from: n, to: r } = Ne(e), i = t(e.textContent ?? "", n, r);
354
- e.textContent = i.text, A(e, i.from, i.to), e.dispatchEvent(new Event("input", { bubbles: !0 }));
352
+ function Ie(e, t) {
353
+ let { from: n, to: r } = je(e), i = t(e.textContent ?? "", n, r);
354
+ e.textContent = i.text, M(e, i.from, i.to), e.dispatchEvent(new Event("input", { bubbles: !0 }));
355
355
  }
356
- function j(e, t) {
357
- let n = Le(e);
358
- return n ? (Re(n, t), !0) : !1;
359
- }
360
- var ze = {
361
- b: (e, t, n) => k(e, t, n, "**"),
362
- i: (e, t, n) => k(e, t, n, "*"),
363
- u: ye,
364
- k: he,
365
- K: _e
356
+ function N(e, t) {
357
+ let n = Fe(e);
358
+ return n ? (Ie(n, t), !0) : !1;
359
+ }
360
+ var Le = {
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
366
366
  };
367
- function Be(e, t) {
367
+ function Re(e, t) {
368
368
  if (!(e.metaKey || e.ctrlKey) || e.altKey) return !1;
369
- let n = ze[e.shiftKey ? e.key.toUpperCase() : e.key.toLowerCase()];
370
- return n ? (e.preventDefault(), Re(t, n), !0) : !1;
369
+ let n = Le[e.shiftKey ? e.key.toUpperCase() : e.key.toLowerCase()];
370
+ return n ? (e.preventDefault(), Ie(t, n), !0) : !1;
371
371
  }
372
372
  //#endregion
373
373
  //#region src/toolbar/block.ts
374
- function M(e) {
374
+ function P(e) {
375
375
  let { from: t, to: n } = e.selection.main;
376
376
  return [e.doc.lineAt(t).number, e.doc.lineAt(n).number];
377
377
  }
378
- function Ve(e, t) {
379
- let n = e.state, [r, i] = M(n), a = r === i && !n.doc.line(r).text.trim(), o = !a;
378
+ function ze(e, t) {
379
+ let n = e.state, [r, i] = P(n), a = r === i && !n.doc.line(r).text.trim(), o = !a;
380
380
  for (let e = r; e <= i && o; e++) {
381
381
  let r = n.doc.line(e).text;
382
382
  r.trim() && !t.match.test(r) && (o = !1);
@@ -413,13 +413,13 @@ function Ve(e, t) {
413
413
  scrollIntoView: !0
414
414
  }), e.focus(), !0) : !1;
415
415
  }
416
- function He(e, t) {
416
+ function Be(e, t) {
417
417
  return t.test(e.doc.lineAt(e.selection.main.head).text);
418
418
  }
419
419
  //#endregion
420
420
  //#region src/toolbar/fence.ts
421
- function N(e, t) {
422
- for (let n = ue(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) {
423
423
  if (n.name === "FencedCode") return {
424
424
  from: n.from,
425
425
  to: n.to
@@ -428,8 +428,8 @@ function N(e, t) {
428
428
  }
429
429
  return null;
430
430
  }
431
- function Ue(e) {
432
- let t = e.state, n = N(t, t.selection.main.head);
431
+ function Ve(e) {
432
+ let t = e.state, n = F(t, t.selection.main.head);
433
433
  if (n) {
434
434
  let r = t.doc.lineAt(n.from), i = t.doc.lineAt(n.to), a = [{
435
435
  from: r.from,
@@ -443,7 +443,7 @@ function Ue(e) {
443
443
  scrollIntoView: !0
444
444
  });
445
445
  } else {
446
- let [n, r] = M(t);
446
+ let [n, r] = P(t);
447
447
  e.dispatch({
448
448
  changes: [{
449
449
  from: t.doc.line(n).from,
@@ -458,11 +458,11 @@ function Ue(e) {
458
458
  }
459
459
  return e.focus(), !0;
460
460
  }
461
- function P(e) {
462
- return N(e, e.selection.main.head) !== null;
461
+ function I(e) {
462
+ return F(e, e.selection.main.head) !== null;
463
463
  }
464
- function We(e) {
465
- let t = N(e, e.selection.main.head);
464
+ function He(e) {
465
+ let t = F(e, e.selection.main.head);
466
466
  if (!t) return null;
467
467
  let n = e.doc.lineAt(t.from), r = /^(\s*(?:`{3,}|~{3,})[ \t]*)(.*?)[ \t]*$/.exec(n.text);
468
468
  if (!r) return null;
@@ -473,18 +473,18 @@ function We(e) {
473
473
  lang: r[2]
474
474
  };
475
475
  }
476
- var Ge = /^\s*\$\$\s*$/;
477
- function Ke(e, t) {
476
+ var Ue = /^\s*\$\$\s*$/;
477
+ function We(e, t) {
478
478
  let n = 0, r = 0;
479
- for (let i = 1; i <= e.doc.lines; i++) if (Ge.test(e.doc.line(i).text)) {
479
+ for (let i = 1; i <= e.doc.lines; i++) if (Ue.test(e.doc.line(i).text)) {
480
480
  if (r++, r % 2 == 1) {
481
481
  if (n = i, i > t) return null;
482
482
  } else if (i >= t) return [n, i];
483
483
  }
484
484
  return null;
485
485
  }
486
- function qe(e) {
487
- let t = e.state, [n, r] = M(t), i = Ke(t, t.doc.lineAt(t.selection.main.head).number);
486
+ function Ge(e) {
487
+ let t = e.state, [n, r] = P(t), i = We(t, t.doc.lineAt(t.selection.main.head).number);
488
488
  if (i) {
489
489
  let n = t.doc.line(i[0]), r = t.doc.line(i[1]);
490
490
  e.dispatch({
@@ -510,16 +510,16 @@ function qe(e) {
510
510
  });
511
511
  return e.focus(), !0;
512
512
  }
513
- function F(e) {
514
- return Ke(e, e.doc.lineAt(e.selection.main.head).number) !== null;
513
+ function L(e) {
514
+ return We(e, e.doc.lineAt(e.selection.main.head).number) !== null;
515
515
  }
516
516
  //#endregion
517
517
  //#region src/toolbar/heading.ts
518
- var I = /^(#{1,6}) +/;
519
- function Je(e, t) {
520
- 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 = [];
521
521
  for (let e = i; e <= a; e++) {
522
- let i = r.doc.line(e), a = I.exec(i.text);
522
+ let i = r.doc.line(e), a = Ke.exec(i.text);
523
523
  a && a[1].length === t ? o.push({
524
524
  from: i.from,
525
525
  to: i.from + a[0].length
@@ -537,10 +537,10 @@ function Je(e, t) {
537
537
  scrollIntoView: !0
538
538
  }), e.focus(), !0;
539
539
  }
540
- function Ye(e) {
541
- let t = e.state, [n, r] = M(t), i = [];
540
+ function Je(e) {
541
+ let t = e.state, [n, r] = P(t), i = [];
542
542
  for (let e = n; e <= r; e++) {
543
- let n = t.doc.line(e), r = I.exec(n.text);
543
+ let n = t.doc.line(e), r = Ke.exec(n.text);
544
544
  r && i.push({
545
545
  from: n.from,
546
546
  to: n.from + r[0].length
@@ -553,11 +553,11 @@ function Ye(e) {
553
553
  }
554
554
  //#endregion
555
555
  //#region src/toolbar/inline.ts
556
- function L(e, t) {
556
+ function R(e, t) {
557
557
  let n = e.state.doc.toString();
558
558
  return e.dispatch({
559
559
  ...e.state.changeByRange((e) => {
560
- let r = Te(n, e.from, e.to, t);
560
+ let r = we(n, e.from, e.to, t);
561
561
  return {
562
562
  changes: r.changes,
563
563
  range: r.from === r.to ? f.cursor(r.from) : f.range(r.from, r.to)
@@ -566,8 +566,8 @@ function L(e, t) {
566
566
  scrollIntoView: !0
567
567
  }), e.focus(), !0;
568
568
  }
569
- function R(e, t) {
570
- let n = e.selection.main, r = e.doc.lineAt(n.head), i = RegExp(O(t) + "(?!\\s)(?:[^]*?\\S)??" + O(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");
571
571
  for (let e; e = i.exec(r.text);) {
572
572
  if (e[0].length <= 2 * t.length || t === "$" && (r.text[e.index - 1] === "$" || r.text[e.index + e[0].length] === "$")) continue;
573
573
  let i = r.from + e.index;
@@ -575,16 +575,16 @@ function R(e, t) {
575
575
  }
576
576
  return !1;
577
577
  }
578
- function Xe(e) {
579
- let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = E(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);
580
580
  return r ? {
581
581
  from: n.from + r.from,
582
582
  to: n.from + r.to,
583
583
  text: r.label
584
584
  } : null;
585
585
  }
586
- function Ze(e) {
587
- let t = Xe(e.state);
586
+ function Xe(e) {
587
+ let t = Ye(e.state);
588
588
  if (t) return e.dispatch({
589
589
  changes: {
590
590
  from: t.from,
@@ -605,19 +605,19 @@ function Ze(e) {
605
605
  scrollIntoView: !0
606
606
  }), e.focus(), !0;
607
607
  }
608
- function Qe(e) {
609
- return Xe(e) !== null;
608
+ function Ze(e) {
609
+ return Ye(e) !== null;
610
610
  }
611
- function $e(e) {
612
- let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = D(n.text, t - n.from);
611
+ function Qe(e) {
612
+ let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = me(n.text, t - n.from);
613
613
  return r ? {
614
614
  from: n.from + r.from,
615
615
  to: n.from + r.to,
616
616
  text: r.label
617
617
  } : null;
618
618
  }
619
- function et(e) {
620
- let t = $e(e.state);
619
+ function $e(e) {
620
+ let t = Qe(e.state);
621
621
  if (t) return e.dispatch({
622
622
  changes: {
623
623
  from: t.from,
@@ -638,19 +638,19 @@ function et(e) {
638
638
  scrollIntoView: !0
639
639
  }), e.focus(), !0;
640
640
  }
641
- function tt(e) {
642
- return $e(e) !== null;
641
+ function et(e) {
642
+ return Qe(e) !== null;
643
643
  }
644
- function nt(e) {
645
- let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = ve(n.text, t - n.from);
644
+ function tt(e) {
645
+ let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = _e(n.text, t - n.from);
646
646
  return r ? {
647
647
  from: n.from + r.from,
648
648
  to: n.from + r.to,
649
649
  inner: r.inner
650
650
  } : null;
651
651
  }
652
- function rt(e) {
653
- let t = nt(e.state);
652
+ function nt(e) {
653
+ let t = tt(e.state);
654
654
  if (t) return e.dispatch({
655
655
  changes: {
656
656
  from: t.from,
@@ -671,29 +671,29 @@ function rt(e) {
671
671
  scrollIntoView: !0
672
672
  }), e.focus(), !0;
673
673
  }
674
- function it(e) {
675
- return nt(e) !== null;
674
+ function rt(e) {
675
+ return tt(e) !== null;
676
676
  }
677
677
  //#endregion
678
678
  //#region src/toolbar/table-grid.ts
679
- function at(e) {
679
+ function it(e) {
680
680
  let t = e.trim();
681
681
  return t.includes("-") && t.includes("|") && /^[\s|:-]+$/.test(t);
682
682
  }
683
- function ot(e) {
683
+ function at(e) {
684
684
  let t = e.trim();
685
685
  t.startsWith("|") && (t = t.slice(1)), t.endsWith("|") && !t.endsWith("\\|") && (t = t.slice(0, -1));
686
686
  let n = [], r = "";
687
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];
688
688
  return n.push(r.trim()), n;
689
689
  }
690
- function st(e) {
690
+ function ot(e) {
691
691
  let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
692
692
  return n && r ? "center" : r ? "right" : n ? "left" : "";
693
693
  }
694
- function z(e) {
695
- if (e.length < 2 || !at(e[1])) return null;
696
- 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) => {
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) => {
697
697
  let t = e.slice(0, r);
698
698
  for (; t.length < r;) t.push("");
699
699
  return t;
@@ -704,11 +704,11 @@ function z(e) {
704
704
  aligns: a
705
705
  };
706
706
  }
707
- function ct(e) {
707
+ function st(e) {
708
708
  return e.replace(/\\\|/g, "|").length;
709
709
  }
710
- function lt(e, t, n) {
711
- let r = t - ct(e);
710
+ function ct(e, t, n) {
711
+ let r = t - st(e);
712
712
  if (r <= 0) return e;
713
713
  if (n === "right") return " ".repeat(r) + e;
714
714
  if (n === "center") {
@@ -717,23 +717,23 @@ function lt(e, t, n) {
717
717
  }
718
718
  return e + " ".repeat(r);
719
719
  }
720
- function ut(e, t) {
720
+ function lt(e, t) {
721
721
  let n = Math.max(3, e);
722
722
  return t === "left" ? ":" + "-".repeat(n - 1) : t === "right" ? "-".repeat(n - 1) + ":" : t === "center" ? ":" + "-".repeat(n - 2) + ":" : "-".repeat(n);
723
723
  }
724
- function B(e) {
724
+ function V(e) {
725
725
  let t = e.aligns.length, n = [];
726
726
  for (let r = 0; r < t; r++) {
727
727
  let t = 3;
728
- for (let n of e.rows) t = Math.max(t, ct(n[r] ?? ""));
728
+ for (let n of e.rows) t = Math.max(t, st(n[r] ?? ""));
729
729
  n.push(t);
730
730
  }
731
- let r = (t) => "| " + t.map((t, r) => lt(t ?? "", n[r], e.aligns[r])).join(" | ") + " |", i = [r(e.rows[0] ?? [])];
732
- i.push("| " + e.aligns.map((e, t) => ut(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(" | ") + " |");
733
733
  for (let t = 1; t < e.rows.length; t++) i.push(r(e.rows[t]));
734
734
  return i.join("\n");
735
735
  }
736
- function dt(e) {
736
+ function ut(e) {
737
737
  let t = [];
738
738
  for (let n = 0; n < e.length; n++) {
739
739
  if (e[n] === "\\") {
@@ -756,7 +756,7 @@ function dt(e) {
756
756
  }
757
757
  //#endregion
758
758
  //#region src/toolbar/table-position.ts
759
- function V(e, t) {
759
+ function H(e, t) {
760
760
  let n = e.lineAt(t);
761
761
  if (!n.text.includes("|")) return null;
762
762
  let r = n.number;
@@ -774,13 +774,13 @@ function V(e, t) {
774
774
  if (i - r < 1) return null;
775
775
  let a = [];
776
776
  for (let t = r; t <= i; t++) a.push(e.line(t).text);
777
- return z(a) ? {
777
+ return B(a) ? {
778
778
  from: e.line(r).from,
779
779
  to: e.line(i).to,
780
780
  lines: a
781
781
  } : null;
782
782
  }
783
- function ft(e, t, n) {
783
+ function dt(e, t, n) {
784
784
  let r = t;
785
785
  for (let t = 0; t < e.length; t++) {
786
786
  let i = e[t];
@@ -796,7 +796,7 @@ function ft(e, t, n) {
796
796
  onDelimiter: !0
797
797
  };
798
798
  }
799
- let a = dt(i), o = 0;
799
+ let a = ut(i), o = 0;
800
800
  for (let t = 0; t < a.length && (o = t, !(e <= a[t].end)); t++);
801
801
  let s = a[o], c = s ? Math.max(0, Math.min(e, s.contentEnd) - s.contentStart) : 0;
802
802
  return {
@@ -810,15 +810,15 @@ function ft(e, t, n) {
810
810
  }
811
811
  return null;
812
812
  }
813
- function H(e, t, n) {
813
+ function U(e, t, n) {
814
814
  let r = e.split("\n"), i = n.onDelimiter ? 1 : n.row === 0 ? 0 : n.row + 1, a = t;
815
815
  for (let e = 0; e < i; e++) a += r[e].length + 1;
816
- let o = dt(r[i]), s = o[Math.min(n.col, o.length - 1)];
816
+ let o = ut(r[i]), s = o[Math.min(n.col, o.length - 1)];
817
817
  return s ? a + s.contentStart + Math.min(n.offset, s.contentEnd - s.contentStart) : a;
818
818
  }
819
- function pt(e, t, n, r) {
820
- let i = V(e, t);
821
- return i ? H(i.lines.join("\n"), i.from, {
819
+ function ft(e, t, n, r) {
820
+ let i = H(e, t);
821
+ return i ? U(i.lines.join("\n"), i.from, {
822
822
  row: n,
823
823
  col: r,
824
824
  offset: 0,
@@ -827,7 +827,7 @@ function pt(e, t, n, r) {
827
827
  }
828
828
  //#endregion
829
829
  //#region src/toolbar/table.ts
830
- function mt(e, t) {
830
+ function pt(e, t) {
831
831
  requestAnimationFrame(() => {
832
832
  let n = e.dom.querySelectorAll(".cm-inplace-table-edit");
833
833
  if (n.length === 0) return;
@@ -847,7 +847,7 @@ function mt(e, t) {
847
847
  s?.removeAllRanges(), s?.addRange(o), a.focus();
848
848
  });
849
849
  }
850
- function ht(e) {
850
+ function mt(e) {
851
851
  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;
852
852
  return e.dispatch({
853
853
  changes: {
@@ -857,30 +857,30 @@ function ht(e) {
857
857
  },
858
858
  selection: f.range(a, a + 8),
859
859
  scrollIntoView: !0
860
- }), e.focus(), mt(e, a), !0;
860
+ }), e.focus(), pt(e, a), !0;
861
861
  }
862
- function U(e) {
863
- return V(e.doc, e.selection.main.head) !== null;
862
+ function W(e) {
863
+ return H(e.doc, e.selection.main.head) !== null;
864
864
  }
865
- function W(e, t) {
866
- let n = V(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);
867
867
  if (!n) return !1;
868
- let r = z(n.lines), i = ft(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);
869
869
  if (!r || !i) return !1;
870
870
  let a = t(r, i);
871
871
  if (!a) return !1;
872
- let o = B(r);
872
+ let o = V(r);
873
873
  return e.dispatch({
874
874
  changes: {
875
875
  from: n.from,
876
876
  to: n.to,
877
877
  insert: o
878
878
  },
879
- selection: f.cursor(H(o, n.from, a)),
879
+ selection: f.cursor(U(o, n.from, a)),
880
880
  scrollIntoView: !0
881
881
  }), e.focus(), !0;
882
882
  }
883
- function gt(e, t, n) {
883
+ function ht(e, t, n) {
884
884
  let r = e.aligns.length, { row: i, col: a } = t;
885
885
  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("")), {
886
886
  row: i,
@@ -889,7 +889,7 @@ function gt(e, t, n) {
889
889
  onDelimiter: !1
890
890
  });
891
891
  }
892
- function _t(e, t) {
892
+ function gt(e, t) {
893
893
  let n = t.row + 1;
894
894
  return n >= e.rows.length && e.rows.push(Array(e.aligns.length).fill("")), {
895
895
  row: n,
@@ -898,58 +898,58 @@ function _t(e, t) {
898
898
  onDelimiter: !1
899
899
  };
900
900
  }
901
- var vt = o.of([
901
+ var _t = o.of([
902
902
  {
903
903
  key: "Tab",
904
- run: (e) => W(e, (e, t) => gt(e, t, 1))
904
+ run: (e) => G(e, (e, t) => ht(e, t, 1))
905
905
  },
906
906
  {
907
907
  key: "Shift-Tab",
908
- run: (e) => W(e, (e, t) => gt(e, t, -1))
908
+ run: (e) => G(e, (e, t) => ht(e, t, -1))
909
909
  },
910
910
  {
911
911
  key: "Enter",
912
- run: (e) => W(e, _t)
912
+ run: (e) => G(e, gt)
913
913
  }
914
- ]), yt = p.transactionFilter.of((e) => {
914
+ ]), vt = p.transactionFilter.of((e) => {
915
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 = V(e.newDoc, t);
916
+ let t = e.newSelection.main.head, n = H(e.newDoc, t);
917
917
  if (!n) return e;
918
- let r = z(n.lines);
918
+ let r = B(n.lines);
919
919
  if (!r) return e;
920
- let i = B(r);
920
+ let i = V(r);
921
921
  if (i === n.lines.join("\n")) return e;
922
- let a = ft(n.lines, n.from, t), o = u.of([{
922
+ let a = dt(n.lines, n.from, t), o = u.of([{
923
923
  from: n.from,
924
924
  to: n.to,
925
925
  insert: i
926
926
  }], e.newDoc.length);
927
927
  return {
928
928
  changes: e.changes.compose(o),
929
- selection: a ? f.cursor(H(i, n.from, a)) : e.newSelection,
929
+ selection: a ? f.cursor(U(i, n.from, a)) : e.newSelection,
930
930
  effects: e.effects,
931
931
  scrollIntoView: e.scrollIntoView
932
932
  };
933
- }), G = (e) => /^\s{0,3}#{1,6}(?:\s|$)/.test(e.doc.lineAt(e.selection.main.head).text), K = (e) => {
933
+ }), K = (e) => /^\s{0,3}#{1,6}(?:\s|$)/.test(e.doc.lineAt(e.selection.main.head).text), q = (e) => {
934
934
  let t = n(e.doc);
935
935
  return t !== null && e.selection.main.head <= t.to;
936
- }, q = (e) => K(e) || P(e) || F(e), bt = (e) => (t) => e !== "`" && R(t, "`") || e !== "$" && R(t, "$"), xt = (e) => e.selection.main.empty && !e.wordAt(e.selection.main.head), J = (...e) => (t) => e.some((e) => e(t)), Y = /^(\s*)(?:[-*+] \[[ xX]\] +|\d+[.)] +|[-*+] +)/, St = {
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 = {
937
937
  match: /^ {0,3}> ?/,
938
938
  insert: "> "
939
- }, Ct = {
939
+ }, St = {
940
940
  match: /^(\s*)[-*+] +(?!\[[ xX]\])/,
941
941
  insert: "- ",
942
- siblings: Y
943
- }, wt = {
942
+ siblings: X
943
+ }, Ct = {
944
944
  match: /^(\s*)\d+[.)] +/,
945
945
  insert: (e) => `${e + 1}. `,
946
- siblings: Y
947
- }, Tt = {
946
+ siblings: X
947
+ }, wt = {
948
948
  match: /^(\s*)[-*+] \[[ xX]\] +/,
949
949
  insert: "- [ ] ",
950
- siblings: Y
950
+ siblings: X
951
951
  };
952
- function Et(e, t, n) {
952
+ function Tt(e, t, n) {
953
953
  return {
954
954
  id: e,
955
955
  title: t,
@@ -959,24 +959,24 @@ function Et(e, t, n) {
959
959
  }
960
960
  };
961
961
  }
962
- function X(e, t, n, r) {
962
+ function Z(e, t, n, r) {
963
963
  return {
964
964
  id: e,
965
965
  title: t,
966
- run: (e) => j(e, (e, t, r) => k(e, t, r, n)) || L(e, n),
967
- isActive: (e) => R(e, n),
968
- disabled: J(q, bt(n), xt),
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),
969
969
  keys: r
970
970
  };
971
971
  }
972
- function Z(e) {
972
+ function Et(e) {
973
973
  let t = RegExp(`^#{${e}} `);
974
974
  return {
975
975
  id: `h${e}`,
976
976
  title: `Heading ${e}`,
977
- run: (t) => Je(t, e),
977
+ run: (t) => qe(t, e),
978
978
  isActive: (e) => t.test(e.doc.lineAt(e.selection.main.head).text),
979
- disabled: J(U, q),
979
+ disabled: Y(W, J),
980
980
  keys: [`Mod-Alt-${e}`]
981
981
  };
982
982
  }
@@ -1008,9 +1008,9 @@ function Q(e, t, n, ...r) {
1008
1008
  return {
1009
1009
  id: e,
1010
1010
  title: t,
1011
- run: (e) => Ve(e, n),
1012
- isActive: (e) => He(e, n.match),
1013
- disabled: J(U, q, ...r)
1011
+ run: (e) => ze(e, n),
1012
+ isActive: (e) => Be(e, n.match),
1013
+ disabled: Y(W, J, ...r)
1014
1014
  };
1015
1015
  }
1016
1016
  //#endregion
@@ -1134,29 +1134,29 @@ function Bt(e) {
1134
1134
  //#region src/editor/search-panel.ts
1135
1135
  var Vt = "cm-search-closing", Ht = 160;
1136
1136
  function Ut(e) {
1137
- return se(e.state) ? Wt(e) : T(e);
1137
+ return ae(e.state) ? Wt(e) : w(e);
1138
1138
  }
1139
1139
  function Wt(e) {
1140
1140
  let t = e.dom.querySelector(`.${It}`);
1141
1141
  return !t || t.classList.contains(Vt) ? !0 : (t.classList.add(Vt), setTimeout(() => {
1142
- e.dom.isConnected && x(e);
1142
+ e.dom.isConnected && b(e);
1143
1143
  }, Ht), !0);
1144
1144
  }
1145
1145
  function Gt(e) {
1146
- let t = Bt(e), n = w(e.state);
1146
+ let t = Bt(e), n = C(e.state);
1147
1147
  r(n);
1148
1148
  function r(e) {
1149
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;
1150
1150
  }
1151
1151
  function i() {
1152
- let r = new b({
1152
+ let r = new re({
1153
1153
  search: t.find.value,
1154
1154
  caseSensitive: t.caseSensitive.checked,
1155
1155
  regexp: t.regexp.checked,
1156
1156
  wholeWord: t.wholeWord.checked,
1157
1157
  replace: t.replace.value
1158
1158
  });
1159
- r.eq(n) || (n = r, e.dispatch({ effects: le.of(n) }));
1159
+ r.eq(n) || (n = r, e.dispatch({ effects: se.of(n) }));
1160
1160
  }
1161
1161
  for (let e of [
1162
1162
  t.find,
@@ -1174,20 +1174,20 @@ function Gt(e) {
1174
1174
  n.preventDefault();
1175
1175
  return;
1176
1176
  }
1177
- n.key === "Enter" && (n.preventDefault(), n.target === t.find ? (n.shiftKey ? C : S)(e) : n.target === t.replace && ie(e));
1178
- }), t.next.addEventListener("click", () => S(e)), t.prev.addEventListener("click", () => C(e)), t.all.addEventListener("click", () => ce(e)), t.replaceBtn.addEventListener("click", () => ie(e)), t.replaceAllBtn.addEventListener("click", () => re(e)), t.close.addEventListener("click", () => Wt(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)), {
1179
1179
  dom: t.root,
1180
1180
  top: !0,
1181
1181
  update(e) {
1182
- for (let t of e.transactions) for (let e of t.effects) e.is(le) && !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));
1183
1183
  }
1184
1184
  };
1185
1185
  }
1186
1186
  //#endregion
1187
1187
  //#region src/toolbar/commands.ts
1188
1188
  var Kt = [
1189
- Et("undo", "Undo", ne),
1190
- Et("redo", "Redo", _),
1189
+ Tt("undo", "Undo", _),
1190
+ Tt("redo", "Redo", g),
1191
1191
  {
1192
1192
  id: "save",
1193
1193
  title: "Save",
@@ -1201,86 +1201,86 @@ var Kt = [
1201
1201
  id: "search",
1202
1202
  title: "Find / replace",
1203
1203
  run: (e) => Ut(e),
1204
- isActive: (e) => se(e),
1204
+ isActive: (e) => ae(e),
1205
1205
  keys: ["Mod-f"]
1206
1206
  },
1207
- Z(1),
1208
- Z(2),
1209
- Z(3),
1207
+ Et(1),
1208
+ Et(2),
1209
+ Et(3),
1210
1210
  {
1211
1211
  id: "body",
1212
1212
  title: "Body",
1213
- run: (e) => (Ye(e) || e.focus(), !0),
1213
+ run: (e) => (Je(e) || e.focus(), !0),
1214
1214
  isActive: (e) => !/^#{1,6} /.test(e.doc.lineAt(e.selection.main.head).text),
1215
- disabled: J(U, q)
1215
+ disabled: Y(W, J)
1216
1216
  },
1217
- X("bold", "Bold", "**", ["Mod-b"]),
1218
- X("italic", "Italic", "*", ["Mod-i"]),
1219
- X("strike", "Strikethrough", "~~"),
1217
+ Z("bold", "Bold", "**", ["Mod-b"]),
1218
+ Z("italic", "Italic", "*", ["Mod-i"]),
1219
+ Z("strike", "Strikethrough", "~~"),
1220
1220
  {
1221
1221
  id: "underline",
1222
1222
  title: "Underline",
1223
- run: (e) => j(e, ye) || rt(e),
1224
- isActive: it,
1225
- disabled: J(q, bt("u"), xt),
1223
+ run: (e) => N(e, ve) || nt(e),
1224
+ isActive: rt,
1225
+ disabled: Y(J, yt("u"), bt),
1226
1226
  keys: ["Mod-u"]
1227
1227
  },
1228
- X("code", "Inline code", "`"),
1228
+ Z("code", "Inline code", "`"),
1229
1229
  {
1230
1230
  id: "codeBlock",
1231
1231
  title: "Code block",
1232
- run: (e) => j(e, (e, t, n) => k(e, t, n, "`")) || (U(e.state) ? L(e, "`") : Ue(e)),
1233
- isActive: (e) => U(e) ? R(e, "`") : P(e),
1234
- disabled: J(K, F, G)
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)
1235
1235
  },
1236
1236
  {
1237
1237
  id: "link",
1238
1238
  title: "Link",
1239
- run: (e) => j(e, he) || Ze(e),
1240
- isActive: Qe,
1241
- disabled: q,
1239
+ run: (e) => N(e, pe) || Xe(e),
1240
+ isActive: Ze,
1241
+ disabled: J,
1242
1242
  keys: ["Mod-k"]
1243
1243
  },
1244
1244
  {
1245
1245
  id: "wikilink",
1246
1246
  title: "Wikilink",
1247
- run: (e) => j(e, _e) || et(e),
1248
- isActive: tt,
1249
- disabled: q,
1247
+ run: (e) => N(e, ge) || $e(e),
1248
+ isActive: et,
1249
+ disabled: J,
1250
1250
  keys: ["Mod-Shift-k"]
1251
1251
  },
1252
- Q("quote", "Blockquote", St),
1253
- Q("bulletList", "Bulleted list", Ct, G),
1254
- Q("orderedList", "Numbered list", wt, G),
1255
- Q("task", "Task list", Tt, G),
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),
1256
1256
  {
1257
1257
  id: "hr",
1258
1258
  title: "Divider",
1259
1259
  run: Mt,
1260
1260
  isActive: Nt,
1261
- disabled: J(U, q)
1261
+ disabled: Y(W, J)
1262
1262
  },
1263
1263
  {
1264
1264
  id: "frontmatter",
1265
1265
  title: "Frontmatter",
1266
1266
  run: kt,
1267
1267
  isActive: At,
1268
- disabled: J(U, P, F, G)
1268
+ disabled: Y(W, I, L, K)
1269
1269
  },
1270
1270
  {
1271
1271
  id: "table",
1272
1272
  title: "Table",
1273
- run: ht,
1274
- isActive: U,
1275
- disabled: J(U, K, P, F, G)
1273
+ run: mt,
1274
+ isActive: W,
1275
+ disabled: Y(W, q, I, L, K)
1276
1276
  },
1277
- X("math", "Inline math", "$"),
1277
+ Z("math", "Inline math", "$"),
1278
1278
  {
1279
1279
  id: "mathBlock",
1280
1280
  title: "Block math",
1281
- run: (e) => j(e, (e, t, n) => k(e, t, n, "$")) || (U(e.state) ? L(e, "$") : qe(e)),
1282
- isActive: (e) => U(e) ? R(e, "$") : F(e),
1283
- disabled: J(K, P, G)
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)
1284
1284
  }
1285
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) => ({
1286
1286
  key: t,
@@ -1327,7 +1327,7 @@ function Zt(e, t) {
1327
1327
  };
1328
1328
  }
1329
1329
  function Qt(e, t) {
1330
- return e ? [de(), y.data.of({ autocomplete: Zt(e, t) })] : [];
1330
+ return e ? [le(), y.data.of({ autocomplete: Zt(e, t) })] : [];
1331
1331
  }
1332
1332
  //#endregion
1333
1333
  //#region src/editor/theme.ts
@@ -1347,7 +1347,11 @@ var $t = a.theme({
1347
1347
  ".cm-cursor, .cm-dropCursor": { borderLeftColor: "var(--stylo-text)" },
1348
1348
  "&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: "color-mix(in srgb, var(--stylo-accent) 15%, transparent)" },
1349
1349
  ".cm-placeholder": { color: "var(--stylo-text-muted)" },
1350
- ".cm-gutters": { display: "none" },
1350
+ ".cm-gutters": {
1351
+ backgroundColor: "transparent",
1352
+ color: "var(--stylo-text-muted)",
1353
+ border: "none"
1354
+ },
1351
1355
  ".cm-panels": { color: "var(--stylo-text)" },
1352
1356
  ".cm-panels.cm-panels-top": { background: "var(--stylo-bg)" },
1353
1357
  ".stylo-search-panel": {
@@ -1474,22 +1478,22 @@ function nn(e, t) {
1474
1478
  };
1475
1479
  }
1476
1480
  function rn(e, t) {
1477
- return e ? [de(), y.data.of({ autocomplete: nn(e, t) })] : [];
1481
+ return e ? [le(), y.data.of({ autocomplete: nn(e, t) })] : [];
1478
1482
  }
1479
1483
  //#endregion
1480
1484
  //#region src/editor/extensions.ts
1481
1485
  function an(e, n, r, i) {
1482
1486
  return [
1483
- h(),
1484
- o.of([...te, ...g]),
1485
- m.high(vt),
1487
+ ne(),
1488
+ o.of([...te, ...h]),
1489
+ m.high(_t),
1486
1490
  Jt,
1487
- yt,
1488
- ae({
1491
+ vt,
1492
+ D({
1489
1493
  top: !0,
1490
1494
  createPanel: Gt
1491
1495
  }),
1492
- o.of(oe),
1496
+ o.of(ie),
1493
1497
  v({
1494
1498
  base: y,
1495
1499
  codeLanguages: e
@@ -1512,18 +1516,18 @@ function on(e) {
1512
1516
  //#endregion
1513
1517
  //#region src/editor/useCodeMirror.ts
1514
1518
  var sn = l.define();
1515
- function cn({ value: e, onChange: t, readOnly: n = !1, placeholder: s, onSave: c, onViewChange: l, extensions: u, codeLanguages: f, wikiLinkSource: ee, tagSource: te, onResolveError: h }) {
1516
- let g = i(null), _ = i(null), ne = i(t);
1517
- ne.current = t;
1518
- let v = i([]), y = i(c);
1519
- y.current = c;
1520
- let b = i((e) => y.current?.(e)).current, x = i(h);
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 }) {
1520
+ let g = i(null), _ = i(null), v = i(t);
1521
+ v.current = t;
1522
+ let y = i([]), re = i(c);
1523
+ re.current = c;
1524
+ let b = i((e) => re.current?.(e)).current, x = i(h);
1521
1525
  x.current = h;
1522
1526
  let S = i((e, t) => {
1523
1527
  x.current?.(e, t);
1524
1528
  }).current, C = c != null, w = i(l);
1525
1529
  w.current = l;
1526
- let T = i(new d());
1530
+ let T = i(new d()), E = i(new d()), D = i(f);
1527
1531
  return r(() => {
1528
1532
  let t = g.current;
1529
1533
  if (!t) return;
@@ -1532,7 +1536,7 @@ function cn({ value: e, onChange: t, readOnly: n = !1, placeholder: s, onSave: c
1532
1536
  state: p.create({
1533
1537
  doc: e,
1534
1538
  extensions: [
1535
- an(f, ee, S, te),
1539
+ an(ee, te, S, ne),
1536
1540
  T.current.of(on({
1537
1541
  readOnly: n,
1538
1542
  placeholder: s,
@@ -1543,10 +1547,11 @@ function cn({ value: e, onChange: t, readOnly: n = !1, placeholder: s, onSave: c
1543
1547
  run: Ft
1544
1548
  }])),
1545
1549
  ...u ?? [],
1550
+ E.current.of(f ?? []),
1546
1551
  a.updateListener.of((e) => {
1547
1552
  if (!e.docChanged || e.transactions.some((e) => !!e.annotation(sn))) return;
1548
1553
  let t = e.state.doc.toString();
1549
- v.current.push(t), v.current.length > 20 && v.current.shift(), ne.current(t);
1554
+ y.current.push(t), y.current.length > 20 && y.current.shift(), v.current(t);
1550
1555
  })
1551
1556
  ]
1552
1557
  })
@@ -1558,14 +1563,14 @@ function cn({ value: e, onChange: t, readOnly: n = !1, placeholder: s, onSave: c
1558
1563
  let t = _.current;
1559
1564
  if (!t) return;
1560
1565
  let n = t.state.doc.toString();
1561
- n !== e && (v.current.includes(e) || (t.dispatch({
1566
+ n !== e && (y.current.includes(e) || (t.dispatch({
1562
1567
  changes: {
1563
1568
  from: 0,
1564
1569
  to: n.length,
1565
1570
  insert: e
1566
1571
  },
1567
1572
  annotations: sn.of(!0)
1568
- }), v.current = []));
1573
+ }), y.current = []));
1569
1574
  }, [e]), r(() => {
1570
1575
  _.current?.dispatch({ effects: T.current.reconfigure(on({
1571
1576
  readOnly: n,
@@ -1577,9 +1582,12 @@ function cn({ value: e, onChange: t, readOnly: n = !1, placeholder: s, onSave: c
1577
1582
  s,
1578
1583
  C,
1579
1584
  b
1580
- ]), 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;
1581
1589
  }
1582
1590
  //#endregion
1583
- export { Ne as C, ge as D, D as E, me as O, Ie as S, Ae as T, Be as _, Y as a, A as b, Tt as c, z as d, B as f, Le as g, P as h, Ct as i, pe as k, Ot as l, We as m, qt as n, wt as o, I as p, Mt as r, St as s, cn as t, pt as u, Oe as v, ke as w, Me as x, Pe 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 };
1584
1592
 
1585
- //# sourceMappingURL=useCodeMirror-TAWSJQiZ.js.map
1593
+ //# sourceMappingURL=useCodeMirror-B07wRexo.js.map