@damiro/stylo 0.9.1 → 0.10.1

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.
@@ -1,13 +1,13 @@
1
1
  import { r as e, t } from "./frontmatter-DGUkb9z-.js";
2
2
  import { useEffect as n, useRef as r } from "react";
3
- import { EditorView as i, keymap as a, placeholder as o } from "@codemirror/view";
4
- import { Annotation as s, ChangeSet as c, Compartment as l, EditorSelection as u, EditorState as d, Facet as f, Prec as p } from "@codemirror/state";
5
- import { defaultKeymap as ee, history as te, historyKeymap as m, redo as h, undo as g } from "@codemirror/commands";
6
- import { markdown as _, markdownLanguage as v } from "@codemirror/lang-markdown";
7
- import { openSearchPanel as y, search as b, searchKeymap as ne } from "@codemirror/search";
8
- import { HighlightStyle as x, syntaxHighlighting as S, syntaxTree as C } from "@codemirror/language";
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 h, historyKeymap as g, redo as _, undo as te } 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
9
  import { tags as w } from "@lezer/highlight";
10
- import { autocompletion as re } from "@codemirror/autocomplete";
10
+ import { autocompletion as me } from "@codemirror/autocomplete";
11
11
  //#region src/toolbar/link-ops.ts
12
12
  function T(e, t) {
13
13
  let n = /\[([^\]]*)\]\([^)]*\)/g;
@@ -21,7 +21,7 @@ function T(e, t) {
21
21
  }
22
22
  return null;
23
23
  }
24
- function ie(e, t) {
24
+ function he(e, t) {
25
25
  let n = /\[([^\]]*)\]\(([^)]*)\)/g;
26
26
  for (let r; r = n.exec(e);) {
27
27
  let e = r.index, n = e + r[0].length;
@@ -39,7 +39,7 @@ function ie(e, t) {
39
39
  }
40
40
  return null;
41
41
  }
42
- function ae(e, t, n) {
42
+ function ge(e, t, n) {
43
43
  let r = T(e, t);
44
44
  if (r) return {
45
45
  text: e.slice(0, r.from) + r.label + e.slice(r.to),
@@ -66,7 +66,7 @@ function E(t, n) {
66
66
  }
67
67
  return null;
68
68
  }
69
- function oe(t, n) {
69
+ function _e(t, n) {
70
70
  for (let r of t.matchAll(e)) {
71
71
  let e = r.index ?? 0, t = e + r[0].length;
72
72
  if (n < e || n > t) continue;
@@ -82,7 +82,7 @@ function oe(t, n) {
82
82
  }
83
83
  return null;
84
84
  }
85
- function se(e, t, n) {
85
+ function ve(e, t, n) {
86
86
  let r = E(e, t);
87
87
  if (r) return {
88
88
  text: e.slice(0, r.from) + r.label + e.slice(r.to),
@@ -98,7 +98,7 @@ function se(e, t, n) {
98
98
  }
99
99
  //#endregion
100
100
  //#region src/toolbar/underline-ops.ts
101
- function ce(e, t) {
101
+ function ye(e, t) {
102
102
  let n = /<u>([\s\S]*?)<\/u>/gi;
103
103
  for (let r; r = n.exec(e);) {
104
104
  let e = r.index, n = e + r[0].length;
@@ -110,8 +110,8 @@ function ce(e, t) {
110
110
  }
111
111
  return null;
112
112
  }
113
- function le(e, t, n) {
114
- let r = ce(e, t);
113
+ function be(e, t, n) {
114
+ let r = ye(e, t);
115
115
  if (r) return {
116
116
  text: e.slice(0, r.from) + r.inner + e.slice(r.to),
117
117
  from: r.from,
@@ -129,7 +129,7 @@ function le(e, t, n) {
129
129
  function D(e) {
130
130
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
131
131
  }
132
- function ue(e, t, n) {
132
+ function xe(e, t, n) {
133
133
  let r = t, i = t;
134
134
  if (n < 0) for (; r > 0 && "*~`$".includes(e[r - 1]);) r--;
135
135
  else for (; i < e.length && "*~`$".includes(e[i]);) i++;
@@ -138,7 +138,7 @@ function ue(e, t, n) {
138
138
  from: r
139
139
  };
140
140
  }
141
- function de(e, t) {
141
+ function Se(e, t) {
142
142
  let n = [];
143
143
  for (let r = 0; r < e.length;) {
144
144
  if (e[r] !== t) {
@@ -154,15 +154,15 @@ function de(e, t) {
154
154
  }
155
155
  return n;
156
156
  }
157
- function fe(e, t, n) {
157
+ function Ce(e, t, n) {
158
158
  return e < n || t < n ? !1 : n > 1 || e % 2 == 1 && t % 2 == 1;
159
159
  }
160
- function pe(e, t, n, r) {
160
+ function we(e, t, n, r) {
161
161
  let i = r.length, a = r[0], o = e.slice(t, n), s = 0;
162
162
  for (; o[s] === a;) s++;
163
163
  let c = 0;
164
164
  for (; o[o.length - 1 - c] === a;) c++;
165
- if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) && fe(s, c, i)) return {
165
+ if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) && Ce(s, c, i)) return {
166
166
  changes: [{
167
167
  from: t,
168
168
  to: t + i,
@@ -175,10 +175,10 @@ function pe(e, t, n, r) {
175
175
  from: t,
176
176
  to: n - 2 * i
177
177
  };
178
- let l = ue(e, t, -1), u = ue(e, n, 1), d = de(l.text, a), f = de(u.text, a).reverse();
178
+ let l = xe(e, t, -1), u = xe(e, n, 1), d = Se(l.text, a), f = Se(u.text, a).reverse();
179
179
  for (let e = 0; e < Math.min(d.length, f.length); e++) {
180
180
  let r = d[e], a = f[e];
181
- if (!fe(r.len, a.len, i)) continue;
181
+ if (!Ce(r.len, a.len, i)) continue;
182
182
  let o = l.from + r.start + r.len, s = n + a.start;
183
183
  return {
184
184
  changes: [{
@@ -208,26 +208,26 @@ function pe(e, t, n, r) {
208
208
  to: n + i
209
209
  };
210
210
  }
211
- function me(e, t) {
211
+ function Te(e, t) {
212
212
  let n = e;
213
213
  for (let e of [...t].sort((e, t) => t.from - e.from)) n = n.slice(0, e.from) + e.insert + n.slice(e.to);
214
214
  return n;
215
215
  }
216
216
  function O(e, t, n, r) {
217
- let i = pe(e, t, n, r);
217
+ let i = we(e, t, n, r);
218
218
  return {
219
- text: me(e, i.changes),
219
+ text: Te(e, i.changes),
220
220
  from: i.from,
221
221
  to: i.to
222
222
  };
223
223
  }
224
- function he(e, t) {
224
+ function Ee(e, t) {
225
225
  let n = T(e, t);
226
226
  if (n) return {
227
227
  from: n.from,
228
228
  to: n.to
229
229
  };
230
- let r = oe(e, t);
230
+ let r = _e(e, t);
231
231
  if (r) return {
232
232
  from: r.from,
233
233
  to: r.to
@@ -253,7 +253,7 @@ function he(e, t) {
253
253
  }
254
254
  //#endregion
255
255
  //#region src/inplace/table-cell-dom.ts
256
- var ge = (e) => [e.head, ...e.body].map((e) => [...e]), _e = (e) => e.map((e) => e.map((e) => e.trim())), ve = (e) => e.replace(/\\\|/g, "|");
256
+ 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, "|");
257
257
  function k(e, t) {
258
258
  let n = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), r = 0;
259
259
  for (let e = n.nextNode(); e; e = n.nextNode()) {
@@ -262,11 +262,11 @@ function k(e, t) {
262
262
  }
263
263
  return r;
264
264
  }
265
- function ye(e) {
265
+ function Ae(e) {
266
266
  let t = e.ownerDocument.getSelection(), n = t?.anchorNode;
267
267
  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;
268
268
  }
269
- function be(e) {
269
+ function je(e) {
270
270
  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;
271
271
  if (!t || t.rangeCount === 0) return {
272
272
  from: n,
@@ -278,7 +278,7 @@ function be(e) {
278
278
  to: Math.max(i, a)
279
279
  };
280
280
  }
281
- function xe(e, t, n) {
281
+ function Me(e, t, n) {
282
282
  let r = e.ownerDocument, i = null, a = 0;
283
283
  if (r.caretPositionFromPoint) {
284
284
  let e = r.caretPositionFromPoint(t, n);
@@ -289,13 +289,13 @@ function xe(e, t, n) {
289
289
  }
290
290
  return !i || !e.contains(i) ? 0 : k(e, i) + (i.nodeType === Node.TEXT_NODE ? a : 0);
291
291
  }
292
- var Se = /[\p{L}\p{N}_]/u;
293
- function Ce(e, t, n) {
294
- let r = e.textContent ?? "", i = xe(e, t, n), a = he(r, i);
292
+ var Ne = /[\p{L}\p{N}_]/u;
293
+ function Pe(e, t, n) {
294
+ let r = e.textContent ?? "", i = Me(e, t, n), a = Ee(r, i);
295
295
  if (a) return A(e, a.from, a.to), !0;
296
296
  let o = i, s = i;
297
- for (; o > 0 && Se.test(r[o - 1]);) o--;
298
- for (; s < r.length && Se.test(r[s]);) s++;
297
+ for (; o > 0 && Ne.test(r[o - 1]);) o--;
298
+ for (; s < r.length && Ne.test(r[s]);) s++;
299
299
  return s <= o ? !1 : (A(e, o, s), !0);
300
300
  }
301
301
  function A(e, t, n = t) {
@@ -311,29 +311,29 @@ function A(e, t, n = t) {
311
311
  }
312
312
  //#endregion
313
313
  //#region src/toolbar/cell-inline.ts
314
- function we(e) {
314
+ function Fe(e) {
315
315
  let t = e.dom.ownerDocument.activeElement;
316
316
  return !(t instanceof HTMLElement) || !e.dom.contains(t) ? null : t.matches(".cm-inplace-tcell") ? t : null;
317
317
  }
318
- function Te(e, t) {
319
- let { from: n, to: r } = be(e), i = t(e.textContent ?? "", n, r);
318
+ function Ie(e, t) {
319
+ let { from: n, to: r } = je(e), i = t(e.textContent ?? "", n, r);
320
320
  e.textContent = i.text, A(e, i.from, i.to), e.dispatchEvent(new Event("input", { bubbles: !0 }));
321
321
  }
322
322
  function j(e, t) {
323
- let n = we(e);
324
- return n ? (Te(n, t), !0) : !1;
323
+ let n = Fe(e);
324
+ return n ? (Ie(n, t), !0) : !1;
325
325
  }
326
- var Ee = {
326
+ var Le = {
327
327
  b: (e, t, n) => O(e, t, n, "**"),
328
328
  i: (e, t, n) => O(e, t, n, "*"),
329
- u: le,
330
- k: ae,
331
- K: se
329
+ u: be,
330
+ k: ge,
331
+ K: ve
332
332
  };
333
- function De(e, t) {
333
+ function Re(e, t) {
334
334
  if (!(e.metaKey || e.ctrlKey) || e.altKey) return !1;
335
- let n = Ee[e.shiftKey ? e.key.toUpperCase() : e.key.toLowerCase()];
336
- return n ? (e.preventDefault(), Te(t, n), !0) : !1;
335
+ let n = Le[e.shiftKey ? e.key.toUpperCase() : e.key.toLowerCase()];
336
+ return n ? (e.preventDefault(), Ie(t, n), !0) : !1;
337
337
  }
338
338
  //#endregion
339
339
  //#region src/toolbar/block.ts
@@ -341,7 +341,7 @@ function M(e) {
341
341
  let { from: t, to: n } = e.selection.main;
342
342
  return [e.doc.lineAt(t).number, e.doc.lineAt(n).number];
343
343
  }
344
- function Oe(e, t) {
344
+ function ze(e, t) {
345
345
  let n = e.state, [r, i] = M(n), a = r === i && !n.doc.line(r).text.trim(), o = !a;
346
346
  for (let e = r; e <= i && o; e++) {
347
347
  let r = n.doc.line(e).text;
@@ -379,13 +379,13 @@ function Oe(e, t) {
379
379
  scrollIntoView: !0
380
380
  }), e.focus(), !0) : !1;
381
381
  }
382
- function ke(e, t) {
382
+ function Be(e, t) {
383
383
  return t.test(e.doc.lineAt(e.selection.main.head).text);
384
384
  }
385
385
  //#endregion
386
386
  //#region src/toolbar/fence.ts
387
387
  function N(e, t) {
388
- for (let n = C(e).resolveInner(t, 0); n; n = n.parent) {
388
+ for (let n = pe(e).resolveInner(t, 0); n; n = n.parent) {
389
389
  if (n.name === "FencedCode") return {
390
390
  from: n.from,
391
391
  to: n.to
@@ -394,7 +394,7 @@ function N(e, t) {
394
394
  }
395
395
  return null;
396
396
  }
397
- function Ae(e) {
397
+ function Ve(e) {
398
398
  let t = e.state, n = N(t, t.selection.main.head);
399
399
  if (n) {
400
400
  let r = t.doc.lineAt(n.from), i = t.doc.lineAt(n.to), a = [{
@@ -427,7 +427,7 @@ function Ae(e) {
427
427
  function P(e) {
428
428
  return N(e, e.selection.main.head) !== null;
429
429
  }
430
- function je(e) {
430
+ function He(e) {
431
431
  let t = N(e, e.selection.main.head);
432
432
  if (!t) return null;
433
433
  let n = e.doc.lineAt(t.from), r = /^(\s*(?:`{3,}|~{3,})[ \t]*)(.*?)[ \t]*$/.exec(n.text);
@@ -439,18 +439,18 @@ function je(e) {
439
439
  lang: r[2]
440
440
  };
441
441
  }
442
- var Me = /^\s*\$\$\s*$/;
443
- function Ne(e, t) {
442
+ var Ue = /^\s*\$\$\s*$/;
443
+ function We(e, t) {
444
444
  let n = 0, r = 0;
445
- for (let i = 1; i <= e.doc.lines; i++) if (Me.test(e.doc.line(i).text)) {
445
+ for (let i = 1; i <= e.doc.lines; i++) if (Ue.test(e.doc.line(i).text)) {
446
446
  if (r++, r % 2 == 1) {
447
447
  if (n = i, i > t) return null;
448
448
  } else if (i >= t) return [n, i];
449
449
  }
450
450
  return null;
451
451
  }
452
- function Pe(e) {
453
- let t = e.state, [n, r] = M(t), i = Ne(t, t.doc.lineAt(t.selection.main.head).number);
452
+ function Ge(e) {
453
+ let t = e.state, [n, r] = M(t), i = We(t, t.doc.lineAt(t.selection.main.head).number);
454
454
  if (i) {
455
455
  let n = t.doc.line(i[0]), r = t.doc.line(i[1]);
456
456
  e.dispatch({
@@ -477,11 +477,11 @@ function Pe(e) {
477
477
  return e.focus(), !0;
478
478
  }
479
479
  function F(e) {
480
- return Ne(e, e.doc.lineAt(e.selection.main.head).number) !== null;
480
+ return We(e, e.doc.lineAt(e.selection.main.head).number) !== null;
481
481
  }
482
482
  //#endregion
483
483
  //#region src/toolbar/heading.ts
484
- function Fe(e, t) {
484
+ function Ke(e, t) {
485
485
  let n = "#".repeat(t) + " ", r = e.state, [i, a] = M(r), o = [];
486
486
  for (let e = i; e <= a; e++) {
487
487
  let i = r.doc.line(e), a = /^(#{1,6}) +/.exec(i.text);
@@ -502,7 +502,7 @@ function Fe(e, t) {
502
502
  scrollIntoView: !0
503
503
  }), e.focus(), !0;
504
504
  }
505
- function Ie(e) {
505
+ function qe(e) {
506
506
  let t = e.state, [n, r] = M(t), i = [];
507
507
  for (let e = n; e <= r; e++) {
508
508
  let n = t.doc.line(e), r = /^#{1,6} +/.exec(n.text);
@@ -522,10 +522,10 @@ function I(e, t) {
522
522
  let n = e.state.doc.toString();
523
523
  return e.dispatch({
524
524
  ...e.state.changeByRange((e) => {
525
- let r = pe(n, e.from, e.to, t);
525
+ let r = we(n, e.from, e.to, t);
526
526
  return {
527
527
  changes: r.changes,
528
- range: r.from === r.to ? u.cursor(r.from) : u.range(r.from, r.to)
528
+ range: r.from === r.to ? d.cursor(r.from) : d.range(r.from, r.to)
529
529
  };
530
530
  }),
531
531
  scrollIntoView: !0
@@ -540,7 +540,7 @@ function L(e, t) {
540
540
  }
541
541
  return !1;
542
542
  }
543
- function Le(e) {
543
+ function Je(e) {
544
544
  let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = T(n.text, t - n.from);
545
545
  return r ? {
546
546
  from: n.from + r.from,
@@ -548,15 +548,15 @@ function Le(e) {
548
548
  text: r.label
549
549
  } : null;
550
550
  }
551
- function Re(e) {
552
- let t = Le(e.state);
551
+ function Ye(e) {
552
+ let t = Je(e.state);
553
553
  if (t) return e.dispatch({
554
554
  changes: {
555
555
  from: t.from,
556
556
  to: t.to,
557
557
  insert: t.text
558
558
  },
559
- selection: u.range(t.from, t.from + t.text.length),
559
+ selection: d.range(t.from, t.from + t.text.length),
560
560
  scrollIntoView: !0
561
561
  }), e.focus(), !0;
562
562
  let { from: n, to: r } = e.state.selection.main, i = e.state.sliceDoc(n, r) || "text", a = n + i.length + 3;
@@ -566,14 +566,14 @@ function Re(e) {
566
566
  to: r,
567
567
  insert: `[${i}](url)`
568
568
  },
569
- selection: u.range(a, a + 3),
569
+ selection: d.range(a, a + 3),
570
570
  scrollIntoView: !0
571
571
  }), e.focus(), !0;
572
572
  }
573
- function ze(e) {
574
- return Le(e) !== null;
573
+ function Xe(e) {
574
+ return Je(e) !== null;
575
575
  }
576
- function Be(e) {
576
+ function Ze(e) {
577
577
  let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = E(n.text, t - n.from);
578
578
  return r ? {
579
579
  from: n.from + r.from,
@@ -581,15 +581,15 @@ function Be(e) {
581
581
  text: r.label
582
582
  } : null;
583
583
  }
584
- function Ve(e) {
585
- let t = Be(e.state);
584
+ function Qe(e) {
585
+ let t = Ze(e.state);
586
586
  if (t) return e.dispatch({
587
587
  changes: {
588
588
  from: t.from,
589
589
  to: t.to,
590
590
  insert: t.text
591
591
  },
592
- selection: u.range(t.from, t.from + t.text.length),
592
+ selection: d.range(t.from, t.from + t.text.length),
593
593
  scrollIntoView: !0
594
594
  }), e.focus(), !0;
595
595
  let { from: n, to: r } = e.state.selection.main, i = e.state.sliceDoc(n, r) || "target";
@@ -599,30 +599,30 @@ function Ve(e) {
599
599
  to: r,
600
600
  insert: `[[${i}]]`
601
601
  },
602
- selection: u.range(n + 2, n + 2 + i.length),
602
+ selection: d.range(n + 2, n + 2 + i.length),
603
603
  scrollIntoView: !0
604
604
  }), e.focus(), !0;
605
605
  }
606
- function He(e) {
607
- return Be(e) !== null;
606
+ function $e(e) {
607
+ return Ze(e) !== null;
608
608
  }
609
- function Ue(e) {
610
- let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = ce(n.text, t - n.from);
609
+ function et(e) {
610
+ let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = ye(n.text, t - n.from);
611
611
  return r ? {
612
612
  from: n.from + r.from,
613
613
  to: n.from + r.to,
614
614
  inner: r.inner
615
615
  } : null;
616
616
  }
617
- function We(e) {
618
- let t = Ue(e.state);
617
+ function tt(e) {
618
+ let t = et(e.state);
619
619
  if (t) return e.dispatch({
620
620
  changes: {
621
621
  from: t.from,
622
622
  to: t.to,
623
623
  insert: t.inner
624
624
  },
625
- selection: u.range(t.from, t.from + t.inner.length),
625
+ selection: d.range(t.from, t.from + t.inner.length),
626
626
  scrollIntoView: !0
627
627
  }), e.focus(), !0;
628
628
  let { from: n, to: r } = e.state.selection.main, i = e.state.sliceDoc(n, r) || "text";
@@ -632,33 +632,33 @@ function We(e) {
632
632
  to: r,
633
633
  insert: `<u>${i}</u>`
634
634
  },
635
- selection: u.range(n + 3, n + 3 + i.length),
635
+ selection: d.range(n + 3, n + 3 + i.length),
636
636
  scrollIntoView: !0
637
637
  }), e.focus(), !0;
638
638
  }
639
- function Ge(e) {
640
- return Ue(e) !== null;
639
+ function nt(e) {
640
+ return et(e) !== null;
641
641
  }
642
642
  //#endregion
643
643
  //#region src/toolbar/table-grid.ts
644
- function Ke(e) {
644
+ function rt(e) {
645
645
  let t = e.trim();
646
646
  return t.includes("-") && t.includes("|") && /^[\s|:-]+$/.test(t);
647
647
  }
648
- function qe(e) {
648
+ function it(e) {
649
649
  let t = e.trim();
650
650
  t.startsWith("|") && (t = t.slice(1)), t.endsWith("|") && !t.endsWith("\\|") && (t = t.slice(0, -1));
651
651
  let n = [], r = "";
652
652
  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];
653
653
  return n.push(r.trim()), n;
654
654
  }
655
- function Je(e) {
655
+ function at(e) {
656
656
  let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
657
657
  return n && r ? "center" : r ? "right" : n ? "left" : "";
658
658
  }
659
659
  function R(e) {
660
- if (e.length < 2 || !Ke(e[1])) return null;
661
- let t = qe(e[1]).map(Je), n = e.filter((e, t) => t !== 1).map(qe), r = Math.max(t.length, ...n.map((e) => e.length)), i = n.map((e) => {
660
+ if (e.length < 2 || !rt(e[1])) return null;
661
+ 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) => {
662
662
  let t = e.slice(0, r);
663
663
  for (; t.length < r;) t.push("");
664
664
  return t;
@@ -669,11 +669,11 @@ function R(e) {
669
669
  aligns: a
670
670
  };
671
671
  }
672
- function Ye(e) {
672
+ function ot(e) {
673
673
  return e.replace(/\\\|/g, "|").length;
674
674
  }
675
- function Xe(e, t, n) {
676
- let r = t - Ye(e);
675
+ function st(e, t, n) {
676
+ let r = t - ot(e);
677
677
  if (r <= 0) return e;
678
678
  if (n === "right") return " ".repeat(r) + e;
679
679
  if (n === "center") {
@@ -682,7 +682,7 @@ function Xe(e, t, n) {
682
682
  }
683
683
  return e + " ".repeat(r);
684
684
  }
685
- function Ze(e, t) {
685
+ function ct(e, t) {
686
686
  let n = Math.max(3, e);
687
687
  return t === "left" ? ":" + "-".repeat(n - 1) : t === "right" ? "-".repeat(n - 1) + ":" : t === "center" ? ":" + "-".repeat(n - 2) + ":" : "-".repeat(n);
688
688
  }
@@ -690,15 +690,15 @@ function z(e) {
690
690
  let t = e.aligns.length, n = [];
691
691
  for (let r = 0; r < t; r++) {
692
692
  let t = 3;
693
- for (let n of e.rows) t = Math.max(t, Ye(n[r] ?? ""));
693
+ for (let n of e.rows) t = Math.max(t, ot(n[r] ?? ""));
694
694
  n.push(t);
695
695
  }
696
- let r = (t) => "| " + t.map((t, r) => Xe(t ?? "", n[r], e.aligns[r])).join(" | ") + " |", i = [r(e.rows[0] ?? [])];
697
- i.push("| " + e.aligns.map((e, t) => Ze(n[t], e)).join(" | ") + " |");
696
+ let r = (t) => "| " + t.map((t, r) => st(t ?? "", n[r], e.aligns[r])).join(" | ") + " |", i = [r(e.rows[0] ?? [])];
697
+ i.push("| " + e.aligns.map((e, t) => ct(n[t], e)).join(" | ") + " |");
698
698
  for (let t = 1; t < e.rows.length; t++) i.push(r(e.rows[t]));
699
699
  return i.join("\n");
700
700
  }
701
- function Qe(e) {
701
+ function lt(e) {
702
702
  let t = [];
703
703
  for (let n = 0; n < e.length; n++) {
704
704
  if (e[n] === "\\") {
@@ -745,7 +745,7 @@ function B(e, t) {
745
745
  lines: a
746
746
  } : null;
747
747
  }
748
- function $e(e, t, n) {
748
+ function ut(e, t, n) {
749
749
  let r = t;
750
750
  for (let t = 0; t < e.length; t++) {
751
751
  let i = e[t];
@@ -761,7 +761,7 @@ function $e(e, t, n) {
761
761
  onDelimiter: !0
762
762
  };
763
763
  }
764
- let a = Qe(i), o = 0;
764
+ let a = lt(i), o = 0;
765
765
  for (let t = 0; t < a.length && (o = t, !(e <= a[t].end)); t++);
766
766
  let s = a[o], c = s ? Math.max(0, Math.min(e, s.contentEnd) - s.contentStart) : 0;
767
767
  return {
@@ -778,10 +778,10 @@ function $e(e, t, n) {
778
778
  function V(e, t, n) {
779
779
  let r = e.split("\n"), i = n.onDelimiter ? 1 : n.row === 0 ? 0 : n.row + 1, a = t;
780
780
  for (let e = 0; e < i; e++) a += r[e].length + 1;
781
- let o = Qe(r[i]), s = o[Math.min(n.col, o.length - 1)];
781
+ let o = lt(r[i]), s = o[Math.min(n.col, o.length - 1)];
782
782
  return s ? a + s.contentStart + Math.min(n.offset, s.contentEnd - s.contentStart) : a;
783
783
  }
784
- function et(e, t, n, r) {
784
+ function dt(e, t, n, r) {
785
785
  let i = B(e, t);
786
786
  return i ? V(i.lines.join("\n"), i.from, {
787
787
  row: n,
@@ -792,7 +792,7 @@ function et(e, t, n, r) {
792
792
  }
793
793
  //#endregion
794
794
  //#region src/toolbar/table.ts
795
- function tt(e, t) {
795
+ function ft(e, t) {
796
796
  requestAnimationFrame(() => {
797
797
  let n = e.dom.querySelectorAll(".cm-inplace-table-edit");
798
798
  if (n.length === 0) return;
@@ -812,7 +812,7 @@ function tt(e, t) {
812
812
  s?.removeAllRanges(), s?.addRange(o), a.focus();
813
813
  });
814
814
  }
815
- function nt(e) {
815
+ function pt(e) {
816
816
  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;
817
817
  return e.dispatch({
818
818
  changes: {
@@ -820,9 +820,9 @@ function nt(e) {
820
820
  to: n,
821
821
  insert: i + "| Column 1 | Column 2 |\n| -------- | -------- |\n| | |\n"
822
822
  },
823
- selection: u.range(a, a + 8),
823
+ selection: d.range(a, a + 8),
824
824
  scrollIntoView: !0
825
- }), e.focus(), tt(e, a), !0;
825
+ }), e.focus(), ft(e, a), !0;
826
826
  }
827
827
  function H(e) {
828
828
  return B(e.doc, e.selection.main.head) !== null;
@@ -830,7 +830,7 @@ function H(e) {
830
830
  function U(e, t) {
831
831
  let n = B(e.state.doc, e.state.selection.main.head);
832
832
  if (!n) return !1;
833
- let r = R(n.lines), i = $e(n.lines, n.from, e.state.selection.main.head);
833
+ let r = R(n.lines), i = ut(n.lines, n.from, e.state.selection.main.head);
834
834
  if (!r || !i) return !1;
835
835
  let a = t(r, i);
836
836
  if (!a) return !1;
@@ -841,11 +841,11 @@ function U(e, t) {
841
841
  to: n.to,
842
842
  insert: o
843
843
  },
844
- selection: u.cursor(V(o, n.from, a)),
844
+ selection: d.cursor(V(o, n.from, a)),
845
845
  scrollIntoView: !0
846
846
  }), e.focus(), !0;
847
847
  }
848
- function rt(e, t, n) {
848
+ function mt(e, t, n) {
849
849
  let r = e.aligns.length, { row: i, col: a } = t;
850
850
  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("")), {
851
851
  row: i,
@@ -854,7 +854,7 @@ function rt(e, t, n) {
854
854
  onDelimiter: !1
855
855
  });
856
856
  }
857
- function it(e, t) {
857
+ function ht(e, t) {
858
858
  let n = t.row + 1;
859
859
  return n >= e.rows.length && e.rows.push(Array(e.aligns.length).fill("")), {
860
860
  row: n,
@@ -863,20 +863,20 @@ function it(e, t) {
863
863
  onDelimiter: !1
864
864
  };
865
865
  }
866
- var at = a.of([
866
+ var gt = a.of([
867
867
  {
868
868
  key: "Tab",
869
- run: (e) => U(e, (e, t) => rt(e, t, 1))
869
+ run: (e) => U(e, (e, t) => mt(e, t, 1))
870
870
  },
871
871
  {
872
872
  key: "Shift-Tab",
873
- run: (e) => U(e, (e, t) => rt(e, t, -1))
873
+ run: (e) => U(e, (e, t) => mt(e, t, -1))
874
874
  },
875
875
  {
876
876
  key: "Enter",
877
- run: (e) => U(e, it)
877
+ run: (e) => U(e, ht)
878
878
  }
879
- ]), ot = d.transactionFilter.of((e) => {
879
+ ]), _t = f.transactionFilter.of((e) => {
880
880
  if (!e.docChanged || !e.isUserEvent("input") && !e.isUserEvent("delete")) return e;
881
881
  let t = e.newSelection.main.head, n = B(e.newDoc, t);
882
882
  if (!n) return e;
@@ -884,37 +884,37 @@ var at = a.of([
884
884
  if (!r) return e;
885
885
  let i = z(r);
886
886
  if (i === n.lines.join("\n")) return e;
887
- let a = $e(n.lines, n.from, t), o = c.of([{
887
+ let a = ut(n.lines, n.from, t), o = l.of([{
888
888
  from: n.from,
889
889
  to: n.to,
890
890
  insert: i
891
891
  }], e.newDoc.length);
892
892
  return {
893
893
  changes: e.changes.compose(o),
894
- selection: a ? u.cursor(V(i, n.from, a)) : e.newSelection,
894
+ selection: a ? d.cursor(V(i, n.from, a)) : e.newSelection,
895
895
  effects: e.effects,
896
896
  scrollIntoView: e.scrollIntoView
897
897
  };
898
898
  }), W = (e) => /^\s{0,3}#{1,6}(?:\s|$)/.test(e.doc.lineAt(e.selection.main.head).text), G = (e) => {
899
899
  let n = t(e.doc);
900
900
  return n !== null && e.selection.main.head <= n.to;
901
- }, K = (e) => G(e) || P(e) || F(e), st = (e) => (t) => e !== "`" && L(t, "`") || e !== "$" && L(t, "$"), ct = (e) => e.selection.main.empty && !e.wordAt(e.selection.main.head), q = (...e) => (t) => e.some((e) => e(t)), J = /^(\s*)(?:[-*+] \[[ xX]\] +|\d+\. +|[-*+] +)/, lt = {
901
+ }, K = (e) => G(e) || P(e) || F(e), vt = (e) => (t) => e !== "`" && L(t, "`") || e !== "$" && L(t, "$"), yt = (e) => e.selection.main.empty && !e.wordAt(e.selection.main.head), q = (...e) => (t) => e.some((e) => e(t)), J = /^(\s*)(?:[-*+] \[[ xX]\] +|\d+\. +|[-*+] +)/, bt = {
902
902
  match: /^ {0,3}> ?/,
903
903
  insert: "> "
904
- }, ut = {
904
+ }, xt = {
905
905
  match: /^(\s*)[-*+] +(?!\[[ xX]\])/,
906
906
  insert: "- ",
907
907
  siblings: J
908
- }, dt = {
908
+ }, St = {
909
909
  match: /^(\s*)\d+\. +/,
910
910
  insert: (e) => `${e + 1}. `,
911
911
  siblings: J
912
- }, ft = {
912
+ }, Ct = {
913
913
  match: /^(\s*)[-*+] \[[ xX]\] +/,
914
914
  insert: "- [ ] ",
915
915
  siblings: J
916
916
  };
917
- function pt(e, t, n) {
917
+ function wt(e, t, n) {
918
918
  return {
919
919
  id: e,
920
920
  title: t,
@@ -930,7 +930,7 @@ function Y(e, t, n, r) {
930
930
  title: t,
931
931
  run: (e) => j(e, (e, t, r) => O(e, t, r, n)) || I(e, n),
932
932
  isActive: (e) => L(e, n),
933
- disabled: q(K, st(n), ct),
933
+ disabled: q(K, vt(n), yt),
934
934
  keys: r
935
935
  };
936
936
  }
@@ -939,7 +939,7 @@ function X(e) {
939
939
  return {
940
940
  id: `h${e}`,
941
941
  title: `Heading ${e}`,
942
- run: (t) => Fe(t, e),
942
+ run: (t) => Ke(t, e),
943
943
  isActive: (e) => t.test(e.doc.lineAt(e.selection.main.head).text),
944
944
  disabled: q(H, K),
945
945
  keys: [`Mod-Alt-${e}`]
@@ -949,14 +949,14 @@ function Z(e, t, n, ...r) {
949
949
  return {
950
950
  id: e,
951
951
  title: t,
952
- run: (e) => Oe(e, n),
953
- isActive: (e) => ke(e, n.match),
952
+ run: (e) => ze(e, n),
953
+ isActive: (e) => Be(e, n.match),
954
954
  disabled: q(H, K, ...r)
955
955
  };
956
956
  }
957
957
  //#endregion
958
958
  //#region src/toolbar/frontmatter-toggle.ts
959
- function mt(e) {
959
+ function Tt(e) {
960
960
  let n = e.state, r = t(n.doc);
961
961
  if (r) {
962
962
  let t = n.doc.lineAt(r.from), i = n.doc.lineAt(r.to);
@@ -980,21 +980,21 @@ function mt(e) {
980
980
  from: n.doc.line(t).to,
981
981
  insert: "\n---"
982
982
  }],
983
- selection: u.cursor(4),
983
+ selection: d.cursor(4),
984
984
  scrollIntoView: !0
985
985
  });
986
986
  }
987
987
  return e.focus(), !0;
988
988
  }
989
- function ht(e) {
989
+ function Et(e) {
990
990
  return t(e.doc) !== null;
991
991
  }
992
992
  //#endregion
993
993
  //#region src/toolbar/rule.ts
994
- var gt = /^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/;
995
- function _t(e) {
994
+ var Dt = /^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/;
995
+ function Ot(e) {
996
996
  let t = e.state, n = t.doc.lineAt(t.selection.main.head);
997
- return gt.test(n.text) ? e.dispatch({
997
+ return Dt.test(n.text) ? e.dispatch({
998
998
  changes: {
999
999
  from: n.from,
1000
1000
  to: Math.min(n.to + 1, t.doc.length)
@@ -1006,45 +1006,142 @@ function _t(e) {
1006
1006
  to: n.to,
1007
1007
  insert: "---"
1008
1008
  },
1009
- selection: u.cursor(n.from + 3),
1009
+ selection: d.cursor(n.from + 3),
1010
1010
  scrollIntoView: !0
1011
1011
  }) : e.dispatch({
1012
1012
  changes: {
1013
1013
  from: n.to,
1014
1014
  insert: "\n\n---\n"
1015
1015
  },
1016
- selection: u.cursor(n.to + 6),
1016
+ selection: d.cursor(n.to + 6),
1017
1017
  scrollIntoView: !0
1018
1018
  }), e.focus(), !0;
1019
1019
  }
1020
- function vt(e) {
1021
- return gt.test(e.doc.lineAt(e.selection.main.head).text);
1020
+ function kt(e) {
1021
+ return Dt.test(e.doc.lineAt(e.selection.main.head).text);
1022
1022
  }
1023
1023
  //#endregion
1024
1024
  //#region src/editor/save.ts
1025
- var Q = f.define({ combine: (e) => e[0] ?? null });
1026
- function yt(e) {
1027
- let t = e.state.facet(Q);
1025
+ var At = p.define({ combine: (e) => e[0] ?? null });
1026
+ function jt(e) {
1027
+ let t = e.state.facet(At);
1028
1028
  return t ? (t(e.state.doc.toString()), !0) : !1;
1029
1029
  }
1030
1030
  //#endregion
1031
+ //#region src/editor/search-panel-dom.ts
1032
+ var Mt = "stylo-search-panel";
1033
+ function Nt(e) {
1034
+ e.setAttribute("form", "");
1035
+ }
1036
+ function Pt(e, t, n) {
1037
+ let r = document.createElement("input");
1038
+ return r.type = "text", r.name = e, r.placeholder = t, r.setAttribute("aria-label", t), r.className = n, Nt(r), r;
1039
+ }
1040
+ function Q(e, t) {
1041
+ let n = document.createElement("button");
1042
+ return n.type = "button", n.name = e, n.className = "stylo-search-button", n.textContent = t, n;
1043
+ }
1044
+ function Ft(e, t) {
1045
+ let n = document.createElement("input");
1046
+ n.type = "checkbox", n.name = e, Nt(n);
1047
+ let r = document.createElement("label");
1048
+ return r.className = "stylo-search-check", r.append(n, document.createTextNode(t)), {
1049
+ field: n,
1050
+ wrap: r
1051
+ };
1052
+ }
1053
+ function It(e) {
1054
+ let t = (t) => e.state.phrase(t), n = Pt("search", t("Find"), "stylo-search-field");
1055
+ n.setAttribute("main-field", "true");
1056
+ 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 = Ft("case", t("match case")), u = Ft("re", t("regexp")), d = Ft("word", t("by word")), f = Q("close", "×");
1057
+ f.classList.add("stylo-search-close"), f.setAttribute("aria-label", t("close"));
1058
+ let p = document.createElement("div");
1059
+ return p.className = Mt, p.append(n, r, i, a, o, s, c, l.wrap, u.wrap, d.wrap, f), {
1060
+ root: p,
1061
+ find: n,
1062
+ next: r,
1063
+ prev: i,
1064
+ all: a,
1065
+ replace: o,
1066
+ replaceBtn: s,
1067
+ replaceAllBtn: c,
1068
+ caseSensitive: l.field,
1069
+ regexp: u.field,
1070
+ wholeWord: d.field,
1071
+ close: f
1072
+ };
1073
+ }
1074
+ //#endregion
1075
+ //#region src/editor/search-panel.ts
1076
+ var Lt = "cm-search-closing", Rt = 160;
1077
+ function zt(e) {
1078
+ return ce(e.state) ? $(e) : re(e);
1079
+ }
1080
+ function $(e) {
1081
+ let t = e.dom.querySelector(`.${Mt}`);
1082
+ return !t || t.classList.contains(Lt) ? !0 : (t.classList.add(Lt), setTimeout(() => {
1083
+ e.dom.isConnected && ne(e);
1084
+ }, Rt), !0);
1085
+ }
1086
+ function Bt(e) {
1087
+ let t = It(e), n = C(e.state);
1088
+ r(n);
1089
+ function r(e) {
1090
+ 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;
1091
+ }
1092
+ function i() {
1093
+ let r = new b({
1094
+ search: t.find.value,
1095
+ caseSensitive: t.caseSensitive.checked,
1096
+ regexp: t.regexp.checked,
1097
+ wholeWord: t.wholeWord.checked,
1098
+ replace: t.replace.value
1099
+ });
1100
+ r.eq(n) || (n = r, e.dispatch({ effects: ue.of(n) }));
1101
+ }
1102
+ for (let e of [
1103
+ t.find,
1104
+ t.replace,
1105
+ t.caseSensitive,
1106
+ t.regexp,
1107
+ t.wholeWord
1108
+ ]) e.addEventListener("input", i), e.addEventListener("change", i);
1109
+ return t.root.addEventListener("keydown", (n) => {
1110
+ if (n.key === "Escape") {
1111
+ n.preventDefault(), $(e);
1112
+ return;
1113
+ }
1114
+ if (s(e, n, "search-panel")) {
1115
+ n.preventDefault();
1116
+ return;
1117
+ }
1118
+ n.key === "Enter" && (n.preventDefault(), n.target === t.find ? (n.shiftKey ? S : x)(e) : n.target === t.replace && ae(e));
1119
+ }), 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", () => $(e)), {
1120
+ dom: t.root,
1121
+ top: !0,
1122
+ update(e) {
1123
+ for (let t of e.transactions) for (let e of t.effects) e.is(ue) && !e.value.eq(n) && (n = e.value, r(n));
1124
+ }
1125
+ };
1126
+ }
1127
+ //#endregion
1031
1128
  //#region src/toolbar/commands.ts
1032
- var $ = [
1033
- pt("undo", "Undo", g),
1034
- pt("redo", "Redo", h),
1129
+ var Vt = [
1130
+ wt("undo", "Undo", te),
1131
+ wt("redo", "Redo", _),
1035
1132
  {
1036
1133
  id: "save",
1037
1134
  title: "Save",
1038
1135
  run: (e) => {
1039
- let t = yt(e);
1136
+ let t = jt(e);
1040
1137
  return e.focus(), t;
1041
1138
  },
1042
- disabled: (e) => e.facet(Q) == null
1139
+ disabled: (e) => e.facet(At) == null
1043
1140
  },
1044
1141
  {
1045
1142
  id: "search",
1046
1143
  title: "Find / replace",
1047
- run: (e) => y(e),
1144
+ run: (e) => zt(e),
1048
1145
  keys: ["Mod-f"]
1049
1146
  },
1050
1147
  X(1),
@@ -1053,7 +1150,7 @@ var $ = [
1053
1150
  {
1054
1151
  id: "body",
1055
1152
  title: "Body",
1056
- run: (e) => (Ie(e) || e.focus(), !0),
1153
+ run: (e) => (qe(e) || e.focus(), !0),
1057
1154
  isActive: (e) => !/^#{1,6} /.test(e.doc.lineAt(e.selection.main.head).text),
1058
1155
  disabled: q(H, K)
1059
1156
  },
@@ -1063,57 +1160,57 @@ var $ = [
1063
1160
  {
1064
1161
  id: "underline",
1065
1162
  title: "Underline",
1066
- run: (e) => j(e, le) || We(e),
1067
- isActive: Ge,
1068
- disabled: q(K, st("u"), ct),
1163
+ run: (e) => j(e, be) || tt(e),
1164
+ isActive: nt,
1165
+ disabled: q(K, vt("u"), yt),
1069
1166
  keys: ["Mod-u"]
1070
1167
  },
1071
1168
  Y("code", "Inline code", "`"),
1072
1169
  {
1073
1170
  id: "codeBlock",
1074
1171
  title: "Code block",
1075
- run: (e) => j(e, (e, t, n) => O(e, t, n, "`")) || (H(e.state) ? I(e, "`") : Ae(e)),
1172
+ run: (e) => j(e, (e, t, n) => O(e, t, n, "`")) || (H(e.state) ? I(e, "`") : Ve(e)),
1076
1173
  isActive: (e) => H(e) ? L(e, "`") : P(e),
1077
1174
  disabled: q(G, F, W)
1078
1175
  },
1079
1176
  {
1080
1177
  id: "link",
1081
1178
  title: "Link",
1082
- run: (e) => j(e, ae) || Re(e),
1083
- isActive: ze,
1179
+ run: (e) => j(e, ge) || Ye(e),
1180
+ isActive: Xe,
1084
1181
  disabled: K,
1085
1182
  keys: ["Mod-k"]
1086
1183
  },
1087
1184
  {
1088
1185
  id: "wikilink",
1089
1186
  title: "Wikilink",
1090
- run: (e) => j(e, se) || Ve(e),
1091
- isActive: He,
1187
+ run: (e) => j(e, ve) || Qe(e),
1188
+ isActive: $e,
1092
1189
  disabled: K,
1093
1190
  keys: ["Mod-Shift-k"]
1094
1191
  },
1095
- Z("quote", "Blockquote", lt),
1096
- Z("bulletList", "Bulleted list", ut, W),
1097
- Z("orderedList", "Numbered list", dt, W),
1098
- Z("task", "Task list", ft, W),
1192
+ Z("quote", "Blockquote", bt),
1193
+ Z("bulletList", "Bulleted list", xt, W),
1194
+ Z("orderedList", "Numbered list", St, W),
1195
+ Z("task", "Task list", Ct, W),
1099
1196
  {
1100
1197
  id: "hr",
1101
1198
  title: "Divider",
1102
- run: _t,
1103
- isActive: vt,
1199
+ run: Ot,
1200
+ isActive: kt,
1104
1201
  disabled: q(H, K)
1105
1202
  },
1106
1203
  {
1107
1204
  id: "frontmatter",
1108
1205
  title: "Frontmatter",
1109
- run: mt,
1110
- isActive: ht,
1206
+ run: Tt,
1207
+ isActive: Et,
1111
1208
  disabled: q(H, P, F, W)
1112
1209
  },
1113
1210
  {
1114
1211
  id: "table",
1115
1212
  title: "Table",
1116
- run: nt,
1213
+ run: pt,
1117
1214
  isActive: H,
1118
1215
  disabled: q(H, G, P, F, W)
1119
1216
  },
@@ -1121,15 +1218,15 @@ var $ = [
1121
1218
  {
1122
1219
  id: "mathBlock",
1123
1220
  title: "Block math",
1124
- run: (e) => j(e, (e, t, n) => O(e, t, n, "$")) || (H(e.state) ? I(e, "$") : Pe(e)),
1221
+ run: (e) => j(e, (e, t, n) => O(e, t, n, "$")) || (H(e.state) ? I(e, "$") : Ge(e)),
1125
1222
  isActive: (e) => H(e) ? L(e, "$") : F(e),
1126
1223
  disabled: q(G, P, W)
1127
1224
  }
1128
- ], bt = Object.fromEntries($.map((e) => [e.id, e])), xt = p.high(a.of($.filter((e) => e.keys && e.keys.length > 0).flatMap((e) => e.keys.map((t) => ({
1225
+ ], Ht = Object.fromEntries(Vt.map((e) => [e.id, e])), Ut = m.high(a.of(Vt.filter((e) => e.keys && e.keys.length > 0).flatMap((e) => e.keys.map((t) => ({
1129
1226
  key: t,
1130
1227
  preventDefault: !0,
1131
1228
  run: ((t) => !e.disabled?.(t.state) && e.run(t))
1132
- }))))), St = x.define([
1229
+ }))))), Wt = de.define([
1133
1230
  {
1134
1231
  tag: [
1135
1232
  w.keyword,
@@ -1213,7 +1310,7 @@ var $ = [
1213
1310
  tag: [w.invalid],
1214
1311
  color: "var(--stylo-syntax-invalid)"
1215
1312
  }
1216
- ]), Ct = S(St), wt = i.theme({
1313
+ ]), Gt = fe(Wt), Kt = i.theme({
1217
1314
  "&": {
1218
1315
  color: "var(--stylo-text)",
1219
1316
  backgroundColor: "var(--stylo-bg)",
@@ -1230,46 +1327,82 @@ var $ = [
1230
1327
  "&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: "color-mix(in srgb, var(--stylo-accent) 15%, transparent)" },
1231
1328
  ".cm-placeholder": { color: "var(--stylo-text-muted)" },
1232
1329
  ".cm-gutters": { display: "none" },
1233
- ".cm-panels": {
1234
- background: "var(--stylo-surface-floating, #fff)",
1235
- color: "var(--stylo-text)"
1236
- },
1237
- ".cm-panels.cm-panels-top": { borderBottom: "1px solid var(--stylo-border)" },
1238
- ".cm-panel.cm-search": {
1239
- padding: "6px 8px",
1330
+ ".cm-panels": { color: "var(--stylo-text)" },
1331
+ ".cm-panels.cm-panels-top": { background: "var(--stylo-bg)" },
1332
+ ".stylo-search-panel": {
1333
+ "--h": "32px",
1334
+ display: "flex",
1335
+ flexWrap: "nowrap",
1336
+ alignItems: "center",
1337
+ gap: "4px",
1338
+ height: "var(--h)",
1339
+ boxSizing: "border-box",
1340
+ padding: "0 8px",
1341
+ overflowX: "auto",
1342
+ overflowY: "hidden",
1240
1343
  font: "inherit",
1241
- fontSize: "0.8125rem"
1242
- },
1243
- ".cm-panel.cm-search label": {
1244
1344
  fontSize: "0.75rem",
1245
- color: "var(--stylo-text-muted)"
1345
+ borderBottom: "1px solid var(--stylo-border)",
1346
+ animation: "stylo-search-slide-in 0.16s ease-out"
1347
+ },
1348
+ ".stylo-search-panel.cm-search-closing": { animation: "stylo-search-slide-out 0.16s ease-in forwards" },
1349
+ "@keyframes stylo-search-slide-in": {
1350
+ from: { height: "0px" },
1351
+ to: { height: "var(--h)" }
1246
1352
  },
1247
- ".cm-panel.cm-search .cm-textfield": {
1248
- padding: "0.3em 0.5em",
1353
+ "@keyframes stylo-search-slide-out": {
1354
+ from: { height: "var(--h)" },
1355
+ to: { height: "0px" }
1356
+ },
1357
+ ".stylo-search-check": {
1358
+ display: "inline-flex",
1359
+ alignItems: "center",
1360
+ gap: "3px",
1361
+ whiteSpace: "nowrap",
1362
+ fontSize: "0.6875rem",
1363
+ color: "var(--stylo-text-muted)",
1364
+ flex: "0 0 auto"
1365
+ },
1366
+ ".stylo-search-field": {
1367
+ flex: "1 1 90px",
1368
+ minWidth: "60px",
1369
+ padding: "0.2em 0.4em",
1249
1370
  border: "1px solid var(--stylo-border)",
1250
1371
  borderRadius: "calc(var(--stylo-radius) - 3px)",
1251
1372
  background: "var(--stylo-bg)",
1252
1373
  color: "var(--stylo-text)",
1253
- fontSize: "0.8125rem"
1374
+ fontSize: "0.75rem"
1254
1375
  },
1255
- ".cm-panel.cm-search .cm-textfield:focus-visible": {
1376
+ ".stylo-search-field:focus-visible": {
1256
1377
  outline: "2px solid var(--stylo-ring)",
1257
1378
  outlineOffset: "-1px"
1258
1379
  },
1259
- ".cm-panel.cm-search .cm-button": {
1260
- padding: "0.3em 0.65em",
1261
- border: "1px solid var(--stylo-border)",
1380
+ ".stylo-search-field.stylo-search-replace": {
1381
+ marginLeft: "6px",
1382
+ paddingLeft: "10px",
1383
+ borderLeft: "1px solid var(--stylo-border)",
1384
+ borderRadius: "0"
1385
+ },
1386
+ ".stylo-search-button": {
1387
+ flex: "0 0 auto",
1388
+ padding: "0.15em 0.4em",
1389
+ border: "0",
1262
1390
  borderRadius: "calc(var(--stylo-radius) - 3px)",
1263
- background: "var(--stylo-bg)",
1391
+ background: "none",
1264
1392
  backgroundImage: "none",
1265
- color: "var(--stylo-text)",
1266
- fontSize: "0.75rem",
1393
+ color: "var(--stylo-text-muted)",
1394
+ fontSize: "0.6875rem",
1395
+ fontWeight: "600",
1267
1396
  cursor: "pointer"
1268
1397
  },
1269
- ".cm-panel.cm-search .cm-button:hover": { background: "color-mix(in srgb, var(--stylo-border) 45%, transparent)" },
1270
- ".cm-panel.cm-search [name='close']": {
1398
+ ".stylo-search-button:hover": {
1399
+ background: "color-mix(in srgb, var(--stylo-border) 45%, transparent)",
1400
+ color: "var(--stylo-text)"
1401
+ },
1402
+ ".stylo-search-close": {
1403
+ marginLeft: "auto",
1271
1404
  color: "var(--stylo-text-muted)",
1272
- fontSize: "1.1rem"
1405
+ fontSize: "0.9rem"
1273
1406
  },
1274
1407
  ".cm-searchMatch": {
1275
1408
  backgroundColor: "color-mix(in srgb, var(--stylo-ring) 35%, transparent)",
@@ -1279,8 +1412,8 @@ var $ = [
1279
1412
  backgroundColor: "color-mix(in srgb, var(--stylo-ring) 70%, transparent)",
1280
1413
  outline: "1px solid var(--stylo-ring)"
1281
1414
  }
1282
- }), Tt = /\[\[([^[\]\n|]*)$/;
1283
- function Et(e) {
1415
+ }), qt = /\[\[([^[\]\n|]*)$/;
1416
+ function Jt(e) {
1284
1417
  let t = e.label && e.label !== e.target ? e.label : void 0, n = t ? `${e.target}|${t}` : e.target;
1285
1418
  return {
1286
1419
  label: e.label ?? e.target,
@@ -1298,13 +1431,13 @@ function Et(e) {
1298
1431
  }
1299
1432
  };
1300
1433
  }
1301
- function Dt(e, t) {
1434
+ function Yt(e, t) {
1302
1435
  return async (n) => {
1303
- let r = n.matchBefore(Tt);
1436
+ let r = n.matchBefore(qt);
1304
1437
  if (!r || r.from + 2 === n.pos && !n.explicit) return null;
1305
1438
  let i = r.text.slice(2), a;
1306
1439
  try {
1307
- a = (await e(i)).map(Et);
1440
+ a = (await e(i)).map(Jt);
1308
1441
  } catch (e) {
1309
1442
  return t?.(e, {
1310
1443
  source: "wikiLinkSource",
@@ -1319,83 +1452,86 @@ function Dt(e, t) {
1319
1452
  } : null;
1320
1453
  };
1321
1454
  }
1322
- function Ot(e, t) {
1323
- return e ? [re(), v.data.of({ autocomplete: Dt(e, t) })] : [];
1455
+ function Xt(e, t) {
1456
+ return e ? [me(), y.data.of({ autocomplete: Yt(e, t) })] : [];
1324
1457
  }
1325
1458
  //#endregion
1326
1459
  //#region src/editor/extensions.ts
1327
- function kt(e, t, n) {
1460
+ function Zt(e, t, n) {
1328
1461
  return [
1329
- te(),
1330
- a.of([...ee, ...m]),
1331
- p.high(at),
1332
- xt,
1333
- ot,
1334
- b({ top: !0 }),
1335
- a.of(ne),
1336
- _({
1337
- base: v,
1462
+ h(),
1463
+ a.of([...ee, ...g]),
1464
+ m.high(gt),
1465
+ Ut,
1466
+ _t,
1467
+ oe({
1468
+ top: !0,
1469
+ createPanel: Bt
1470
+ }),
1471
+ a.of(se),
1472
+ v({
1473
+ base: y,
1338
1474
  codeLanguages: e
1339
1475
  }),
1340
- Ct,
1341
- Ot(t, n),
1476
+ Gt,
1477
+ Xt(t, n),
1342
1478
  i.lineWrapping,
1343
- wt
1479
+ Kt
1344
1480
  ];
1345
1481
  }
1346
- function At(e) {
1482
+ function Qt(e) {
1347
1483
  return [
1348
- d.readOnly.of(e.readOnly),
1484
+ f.readOnly.of(e.readOnly),
1349
1485
  i.editable.of(!e.readOnly),
1350
1486
  e.placeholder ? o(e.placeholder) : [],
1351
- e.save ? Q.of(e.save) : []
1487
+ e.save ? At.of(e.save) : []
1352
1488
  ];
1353
1489
  }
1354
1490
  //#endregion
1355
1491
  //#region src/editor/useCodeMirror.ts
1356
- var jt = s.define();
1357
- function Mt({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c, onViewChange: u, extensions: f, codeLanguages: ee, wikiLinkSource: te, onResolveError: m }) {
1358
- let h = r(null), g = r(null), _ = r(t);
1359
- _.current = t;
1492
+ var $t = c.define();
1493
+ function en({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c, onViewChange: l, extensions: d, codeLanguages: p, wikiLinkSource: ee, onResolveError: h }) {
1494
+ let g = r(null), _ = r(null), te = r(t);
1495
+ te.current = t;
1360
1496
  let v = r(c);
1361
1497
  v.current = c;
1362
- let y = r((e) => v.current?.(e)).current, b = r(m);
1363
- b.current = m;
1498
+ let y = r((e) => v.current?.(e)).current, b = r(h);
1499
+ b.current = h;
1364
1500
  let ne = r((e, t) => {
1365
1501
  b.current?.(e, t);
1366
- }).current, x = c != null, S = r(u);
1367
- S.current = u;
1368
- let C = r(new l());
1502
+ }).current, x = c != null, S = r(l);
1503
+ S.current = l;
1504
+ let C = r(new u());
1369
1505
  return n(() => {
1370
- let t = h.current;
1506
+ let t = g.current;
1371
1507
  if (!t) return;
1372
1508
  let n = new i({
1373
1509
  parent: t,
1374
- state: d.create({
1510
+ state: f.create({
1375
1511
  doc: e,
1376
1512
  extensions: [
1377
- kt(ee, te, ne),
1378
- C.current.of(At({
1513
+ Zt(p, ee, ne),
1514
+ C.current.of(Qt({
1379
1515
  readOnly: o,
1380
1516
  placeholder: s,
1381
1517
  save: x ? y : void 0
1382
1518
  })),
1383
- p.high(a.of([{
1519
+ m.high(a.of([{
1384
1520
  key: "Mod-s",
1385
- run: yt
1521
+ run: jt
1386
1522
  }])),
1387
- ...f ?? [],
1523
+ ...d ?? [],
1388
1524
  i.updateListener.of((e) => {
1389
- e.docChanged && (e.transactions.some((e) => !!e.annotation(jt)) || _.current(e.state.doc.toString()));
1525
+ e.docChanged && (e.transactions.some((e) => !!e.annotation($t)) || te.current(e.state.doc.toString()));
1390
1526
  })
1391
1527
  ]
1392
1528
  })
1393
1529
  });
1394
- return g.current = n, S.current?.(n), () => {
1395
- S.current?.(null), n.destroy(), g.current = null;
1530
+ return _.current = n, S.current?.(n), () => {
1531
+ S.current?.(null), n.destroy(), _.current = null;
1396
1532
  };
1397
1533
  }, []), n(() => {
1398
- let t = g.current;
1534
+ let t = _.current;
1399
1535
  if (!t) return;
1400
1536
  let n = t.state.doc.toString();
1401
1537
  n !== e && t.dispatch({
@@ -1404,10 +1540,10 @@ function Mt({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c
1404
1540
  to: n.length,
1405
1541
  insert: e
1406
1542
  },
1407
- annotations: jt.of(!0)
1543
+ annotations: $t.of(!0)
1408
1544
  });
1409
1545
  }, [e]), n(() => {
1410
- g.current?.dispatch({ effects: C.current.reconfigure(At({
1546
+ _.current?.dispatch({ effects: C.current.reconfigure(Qt({
1411
1547
  readOnly: o,
1412
1548
  placeholder: s,
1413
1549
  save: x ? y : void 0
@@ -1417,9 +1553,9 @@ function Mt({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c
1417
1553
  s,
1418
1554
  x,
1419
1555
  y
1420
- ]), h;
1556
+ ]), g;
1421
1557
  }
1422
1558
  //#endregion
1423
- export { _e as _, R as a, oe as b, P as c, ge as d, xe as f, be as g, Ce as h, et as i, we as l, ye as m, bt as n, z as o, A as p, _t as r, je as s, Mt as t, De as u, ve as v, ie as x, E as y };
1559
+ export { Oe as _, R as a, _e as b, P as c, De as d, Me as f, je as g, Pe as h, dt as i, Fe as l, Ae as m, Ht as n, z as o, A as p, Ot as r, He as s, en as t, Re as u, ke as v, he as x, E as y };
1424
1560
 
1425
- //# sourceMappingURL=useCodeMirror-DtwupFgc.js.map
1561
+ //# sourceMappingURL=useCodeMirror-CpE_Ncfn.js.map