@damiro/stylo 0.9.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +5 -0
  2. package/dist/{InPlaceView-Bu91_3Ig.js → InPlaceView-Dyf7I4XQ.js} +566 -562
  3. package/dist/InPlaceView-Dyf7I4XQ.js.map +1 -0
  4. package/dist/{Preview-AaGGwLQP.js → Preview-DIsFdBFA.js} +3 -3
  5. package/dist/{Preview-AaGGwLQP.js.map → Preview-DIsFdBFA.js.map} +1 -1
  6. package/dist/SplitView.d.ts +6 -1
  7. package/dist/SplitView.d.ts.map +1 -1
  8. package/dist/Stylo.d.ts.map +1 -1
  9. package/dist/editor/SourceView.d.ts +6 -1
  10. package/dist/editor/SourceView.d.ts.map +1 -1
  11. package/dist/editor/canvas-header-panel.d.ts +27 -0
  12. package/dist/editor/canvas-header-panel.d.ts.map +1 -0
  13. package/dist/editor/extensions.d.ts.map +1 -1
  14. package/dist/editor/search-panel-dom.d.ts +27 -0
  15. package/dist/editor/search-panel-dom.d.ts.map +1 -0
  16. package/dist/editor/search-panel.d.ts +13 -0
  17. package/dist/editor/search-panel.d.ts.map +1 -0
  18. package/dist/editor/theme.d.ts.map +1 -1
  19. package/dist/{embed-B2Dfkpd_.js → embed-Dsu6b-MV.js} +16 -9
  20. package/dist/embed-Dsu6b-MV.js.map +1 -0
  21. package/dist/frontmatter-DTCC0gaa.js +40 -0
  22. package/dist/frontmatter-DTCC0gaa.js.map +1 -0
  23. package/dist/inplace/InPlaceView.d.ts +6 -1
  24. package/dist/inplace/InPlaceView.d.ts.map +1 -1
  25. package/dist/inplace/table-widget.d.ts +10 -5
  26. package/dist/inplace/table-widget.d.ts.map +1 -1
  27. package/dist/inplace/theme-canvas.d.ts +7 -1
  28. package/dist/inplace/theme-canvas.d.ts.map +1 -1
  29. package/dist/render/Embed.d.ts.map +1 -1
  30. package/dist/styles.css +1 -1
  31. package/dist/stylo.js +190 -163
  32. package/dist/stylo.js.map +1 -1
  33. package/dist/toolbar/Toolbar.d.ts.map +1 -1
  34. package/dist/toolbar/commands.d.ts.map +1 -1
  35. package/dist/types.d.ts +12 -0
  36. package/dist/types.d.ts.map +1 -1
  37. package/dist/{useCodeMirror-DtwupFgc.js → useCodeMirror-CjG9CwpB.js} +386 -228
  38. package/dist/useCodeMirror-CjG9CwpB.js.map +1 -0
  39. package/package.json +1 -1
  40. package/dist/InPlaceView-Bu91_3Ig.js.map +0 -1
  41. package/dist/embed-B2Dfkpd_.js.map +0 -1
  42. package/dist/frontmatter-DGUkb9z-.js +0 -39
  43. package/dist/frontmatter-DGUkb9z-.js.map +0 -1
  44. package/dist/useCodeMirror-DtwupFgc.js.map +0 -1
@@ -1,13 +1,34 @@
1
- import { r as e, t } from "./frontmatter-DGUkb9z-.js";
1
+ import { r as e, t } from "./frontmatter-DTCC0gaa.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 te, historyKeymap as h, redo as g, undo as _ } from "@codemirror/commands";
6
+ import { markdown as v, markdownLanguage as y } from "@codemirror/lang-markdown";
7
+ import { SearchQuery as b, closeSearchPanel as ne, findNext as x, findPrevious as S, getSearchQuery as C, openSearchPanel as re, replaceAll as ie, replaceNext as ae, search as oe, searchKeymap as se, searchPanelOpen as ce, selectMatches as le, setSearchQuery as ue } from "@codemirror/search";
8
+ import { HighlightStyle as de, syntaxHighlighting as fe, syntaxTree as pe } from "@codemirror/language";
9
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
+ //#region src/editor/canvas-header-panel.ts
12
+ var he = "stylo-canvas-header", ge = class {
13
+ dom = null;
14
+ listeners = /* @__PURE__ */ new Set();
15
+ panel = () => {
16
+ let e = document.createElement("div");
17
+ return e.className = he, this.dom = e, this.notify(), {
18
+ dom: e,
19
+ top: !0,
20
+ destroy: () => {
21
+ this.dom = null, this.notify();
22
+ }
23
+ };
24
+ };
25
+ subscribe = (e) => (this.listeners.add(e), () => this.listeners.delete(e));
26
+ getSnapshot = () => this.dom;
27
+ notify() {
28
+ for (let e of this.listeners) e();
29
+ }
30
+ };
31
+ //#endregion
11
32
  //#region src/toolbar/link-ops.ts
12
33
  function T(e, t) {
13
34
  let n = /\[([^\]]*)\]\([^)]*\)/g;
@@ -21,7 +42,7 @@ function T(e, t) {
21
42
  }
22
43
  return null;
23
44
  }
24
- function ie(e, t) {
45
+ function _e(e, t) {
25
46
  let n = /\[([^\]]*)\]\(([^)]*)\)/g;
26
47
  for (let r; r = n.exec(e);) {
27
48
  let e = r.index, n = e + r[0].length;
@@ -39,7 +60,7 @@ function ie(e, t) {
39
60
  }
40
61
  return null;
41
62
  }
42
- function ae(e, t, n) {
63
+ function ve(e, t, n) {
43
64
  let r = T(e, t);
44
65
  if (r) return {
45
66
  text: e.slice(0, r.from) + r.label + e.slice(r.to),
@@ -66,7 +87,7 @@ function E(t, n) {
66
87
  }
67
88
  return null;
68
89
  }
69
- function oe(t, n) {
90
+ function ye(t, n) {
70
91
  for (let r of t.matchAll(e)) {
71
92
  let e = r.index ?? 0, t = e + r[0].length;
72
93
  if (n < e || n > t) continue;
@@ -82,7 +103,7 @@ function oe(t, n) {
82
103
  }
83
104
  return null;
84
105
  }
85
- function se(e, t, n) {
106
+ function be(e, t, n) {
86
107
  let r = E(e, t);
87
108
  if (r) return {
88
109
  text: e.slice(0, r.from) + r.label + e.slice(r.to),
@@ -98,7 +119,7 @@ function se(e, t, n) {
98
119
  }
99
120
  //#endregion
100
121
  //#region src/toolbar/underline-ops.ts
101
- function ce(e, t) {
122
+ function xe(e, t) {
102
123
  let n = /<u>([\s\S]*?)<\/u>/gi;
103
124
  for (let r; r = n.exec(e);) {
104
125
  let e = r.index, n = e + r[0].length;
@@ -110,8 +131,8 @@ function ce(e, t) {
110
131
  }
111
132
  return null;
112
133
  }
113
- function le(e, t, n) {
114
- let r = ce(e, t);
134
+ function Se(e, t, n) {
135
+ let r = xe(e, t);
115
136
  if (r) return {
116
137
  text: e.slice(0, r.from) + r.inner + e.slice(r.to),
117
138
  from: r.from,
@@ -129,7 +150,7 @@ function le(e, t, n) {
129
150
  function D(e) {
130
151
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
131
152
  }
132
- function ue(e, t, n) {
153
+ function Ce(e, t, n) {
133
154
  let r = t, i = t;
134
155
  if (n < 0) for (; r > 0 && "*~`$".includes(e[r - 1]);) r--;
135
156
  else for (; i < e.length && "*~`$".includes(e[i]);) i++;
@@ -138,7 +159,7 @@ function ue(e, t, n) {
138
159
  from: r
139
160
  };
140
161
  }
141
- function de(e, t) {
162
+ function we(e, t) {
142
163
  let n = [];
143
164
  for (let r = 0; r < e.length;) {
144
165
  if (e[r] !== t) {
@@ -154,15 +175,15 @@ function de(e, t) {
154
175
  }
155
176
  return n;
156
177
  }
157
- function fe(e, t, n) {
178
+ function Te(e, t, n) {
158
179
  return e < n || t < n ? !1 : n > 1 || e % 2 == 1 && t % 2 == 1;
159
180
  }
160
- function pe(e, t, n, r) {
181
+ function Ee(e, t, n, r) {
161
182
  let i = r.length, a = r[0], o = e.slice(t, n), s = 0;
162
183
  for (; o[s] === a;) s++;
163
184
  let c = 0;
164
185
  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 {
186
+ if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) && Te(s, c, i)) return {
166
187
  changes: [{
167
188
  from: t,
168
189
  to: t + i,
@@ -175,10 +196,10 @@ function pe(e, t, n, r) {
175
196
  from: t,
176
197
  to: n - 2 * i
177
198
  };
178
- let l = ue(e, t, -1), u = ue(e, n, 1), d = de(l.text, a), f = de(u.text, a).reverse();
199
+ let l = Ce(e, t, -1), u = Ce(e, n, 1), d = we(l.text, a), f = we(u.text, a).reverse();
179
200
  for (let e = 0; e < Math.min(d.length, f.length); e++) {
180
201
  let r = d[e], a = f[e];
181
- if (!fe(r.len, a.len, i)) continue;
202
+ if (!Te(r.len, a.len, i)) continue;
182
203
  let o = l.from + r.start + r.len, s = n + a.start;
183
204
  return {
184
205
  changes: [{
@@ -208,26 +229,26 @@ function pe(e, t, n, r) {
208
229
  to: n + i
209
230
  };
210
231
  }
211
- function me(e, t) {
232
+ function De(e, t) {
212
233
  let n = e;
213
234
  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
235
  return n;
215
236
  }
216
237
  function O(e, t, n, r) {
217
- let i = pe(e, t, n, r);
238
+ let i = Ee(e, t, n, r);
218
239
  return {
219
- text: me(e, i.changes),
240
+ text: De(e, i.changes),
220
241
  from: i.from,
221
242
  to: i.to
222
243
  };
223
244
  }
224
- function he(e, t) {
245
+ function Oe(e, t) {
225
246
  let n = T(e, t);
226
247
  if (n) return {
227
248
  from: n.from,
228
249
  to: n.to
229
250
  };
230
- let r = oe(e, t);
251
+ let r = ye(e, t);
231
252
  if (r) return {
232
253
  from: r.from,
233
254
  to: r.to
@@ -253,7 +274,7 @@ function he(e, t) {
253
274
  }
254
275
  //#endregion
255
276
  //#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, "|");
277
+ var ke = (e) => [e.head, ...e.body].map((e) => [...e]), Ae = (e) => e.map((e) => e.map((e) => e.trim())), je = (e) => e.replace(/\\\|/g, "|");
257
278
  function k(e, t) {
258
279
  let n = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), r = 0;
259
280
  for (let e = n.nextNode(); e; e = n.nextNode()) {
@@ -262,11 +283,11 @@ function k(e, t) {
262
283
  }
263
284
  return r;
264
285
  }
265
- function ye(e) {
286
+ function Me(e) {
266
287
  let t = e.ownerDocument.getSelection(), n = t?.anchorNode;
267
288
  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
289
  }
269
- function be(e) {
290
+ function Ne(e) {
270
291
  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
292
  if (!t || t.rangeCount === 0) return {
272
293
  from: n,
@@ -278,7 +299,7 @@ function be(e) {
278
299
  to: Math.max(i, a)
279
300
  };
280
301
  }
281
- function xe(e, t, n) {
302
+ function Pe(e, t, n) {
282
303
  let r = e.ownerDocument, i = null, a = 0;
283
304
  if (r.caretPositionFromPoint) {
284
305
  let e = r.caretPositionFromPoint(t, n);
@@ -289,13 +310,13 @@ function xe(e, t, n) {
289
310
  }
290
311
  return !i || !e.contains(i) ? 0 : k(e, i) + (i.nodeType === Node.TEXT_NODE ? a : 0);
291
312
  }
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);
313
+ var Fe = /[\p{L}\p{N}_]/u;
314
+ function Ie(e, t, n) {
315
+ let r = e.textContent ?? "", i = Pe(e, t, n), a = Oe(r, i);
295
316
  if (a) return A(e, a.from, a.to), !0;
296
317
  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++;
318
+ for (; o > 0 && Fe.test(r[o - 1]);) o--;
319
+ for (; s < r.length && Fe.test(r[s]);) s++;
299
320
  return s <= o ? !1 : (A(e, o, s), !0);
300
321
  }
301
322
  function A(e, t, n = t) {
@@ -311,29 +332,29 @@ function A(e, t, n = t) {
311
332
  }
312
333
  //#endregion
313
334
  //#region src/toolbar/cell-inline.ts
314
- function we(e) {
335
+ function Le(e) {
315
336
  let t = e.dom.ownerDocument.activeElement;
316
337
  return !(t instanceof HTMLElement) || !e.dom.contains(t) ? null : t.matches(".cm-inplace-tcell") ? t : null;
317
338
  }
318
- function Te(e, t) {
319
- let { from: n, to: r } = be(e), i = t(e.textContent ?? "", n, r);
339
+ function Re(e, t) {
340
+ let { from: n, to: r } = Ne(e), i = t(e.textContent ?? "", n, r);
320
341
  e.textContent = i.text, A(e, i.from, i.to), e.dispatchEvent(new Event("input", { bubbles: !0 }));
321
342
  }
322
343
  function j(e, t) {
323
- let n = we(e);
324
- return n ? (Te(n, t), !0) : !1;
344
+ let n = Le(e);
345
+ return n ? (Re(n, t), !0) : !1;
325
346
  }
326
- var Ee = {
347
+ var ze = {
327
348
  b: (e, t, n) => O(e, t, n, "**"),
328
349
  i: (e, t, n) => O(e, t, n, "*"),
329
- u: le,
330
- k: ae,
331
- K: se
350
+ u: Se,
351
+ k: ve,
352
+ K: be
332
353
  };
333
- function De(e, t) {
354
+ function Be(e, t) {
334
355
  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;
356
+ let n = ze[e.shiftKey ? e.key.toUpperCase() : e.key.toLowerCase()];
357
+ return n ? (e.preventDefault(), Re(t, n), !0) : !1;
337
358
  }
338
359
  //#endregion
339
360
  //#region src/toolbar/block.ts
@@ -341,7 +362,7 @@ function M(e) {
341
362
  let { from: t, to: n } = e.selection.main;
342
363
  return [e.doc.lineAt(t).number, e.doc.lineAt(n).number];
343
364
  }
344
- function Oe(e, t) {
365
+ function Ve(e, t) {
345
366
  let n = e.state, [r, i] = M(n), a = r === i && !n.doc.line(r).text.trim(), o = !a;
346
367
  for (let e = r; e <= i && o; e++) {
347
368
  let r = n.doc.line(e).text;
@@ -379,13 +400,13 @@ function Oe(e, t) {
379
400
  scrollIntoView: !0
380
401
  }), e.focus(), !0) : !1;
381
402
  }
382
- function ke(e, t) {
403
+ function He(e, t) {
383
404
  return t.test(e.doc.lineAt(e.selection.main.head).text);
384
405
  }
385
406
  //#endregion
386
407
  //#region src/toolbar/fence.ts
387
408
  function N(e, t) {
388
- for (let n = C(e).resolveInner(t, 0); n; n = n.parent) {
409
+ for (let n = pe(e).resolveInner(t, 0); n; n = n.parent) {
389
410
  if (n.name === "FencedCode") return {
390
411
  from: n.from,
391
412
  to: n.to
@@ -394,7 +415,7 @@ function N(e, t) {
394
415
  }
395
416
  return null;
396
417
  }
397
- function Ae(e) {
418
+ function Ue(e) {
398
419
  let t = e.state, n = N(t, t.selection.main.head);
399
420
  if (n) {
400
421
  let r = t.doc.lineAt(n.from), i = t.doc.lineAt(n.to), a = [{
@@ -427,7 +448,7 @@ function Ae(e) {
427
448
  function P(e) {
428
449
  return N(e, e.selection.main.head) !== null;
429
450
  }
430
- function je(e) {
451
+ function We(e) {
431
452
  let t = N(e, e.selection.main.head);
432
453
  if (!t) return null;
433
454
  let n = e.doc.lineAt(t.from), r = /^(\s*(?:`{3,}|~{3,})[ \t]*)(.*?)[ \t]*$/.exec(n.text);
@@ -439,18 +460,18 @@ function je(e) {
439
460
  lang: r[2]
440
461
  };
441
462
  }
442
- var Me = /^\s*\$\$\s*$/;
443
- function Ne(e, t) {
463
+ var Ge = /^\s*\$\$\s*$/;
464
+ function Ke(e, t) {
444
465
  let n = 0, r = 0;
445
- for (let i = 1; i <= e.doc.lines; i++) if (Me.test(e.doc.line(i).text)) {
466
+ for (let i = 1; i <= e.doc.lines; i++) if (Ge.test(e.doc.line(i).text)) {
446
467
  if (r++, r % 2 == 1) {
447
468
  if (n = i, i > t) return null;
448
469
  } else if (i >= t) return [n, i];
449
470
  }
450
471
  return null;
451
472
  }
452
- function Pe(e) {
453
- let t = e.state, [n, r] = M(t), i = Ne(t, t.doc.lineAt(t.selection.main.head).number);
473
+ function qe(e) {
474
+ let t = e.state, [n, r] = M(t), i = Ke(t, t.doc.lineAt(t.selection.main.head).number);
454
475
  if (i) {
455
476
  let n = t.doc.line(i[0]), r = t.doc.line(i[1]);
456
477
  e.dispatch({
@@ -477,11 +498,11 @@ function Pe(e) {
477
498
  return e.focus(), !0;
478
499
  }
479
500
  function F(e) {
480
- return Ne(e, e.doc.lineAt(e.selection.main.head).number) !== null;
501
+ return Ke(e, e.doc.lineAt(e.selection.main.head).number) !== null;
481
502
  }
482
503
  //#endregion
483
504
  //#region src/toolbar/heading.ts
484
- function Fe(e, t) {
505
+ function Je(e, t) {
485
506
  let n = "#".repeat(t) + " ", r = e.state, [i, a] = M(r), o = [];
486
507
  for (let e = i; e <= a; e++) {
487
508
  let i = r.doc.line(e), a = /^(#{1,6}) +/.exec(i.text);
@@ -502,7 +523,7 @@ function Fe(e, t) {
502
523
  scrollIntoView: !0
503
524
  }), e.focus(), !0;
504
525
  }
505
- function Ie(e) {
526
+ function Ye(e) {
506
527
  let t = e.state, [n, r] = M(t), i = [];
507
528
  for (let e = n; e <= r; e++) {
508
529
  let n = t.doc.line(e), r = /^#{1,6} +/.exec(n.text);
@@ -522,10 +543,10 @@ function I(e, t) {
522
543
  let n = e.state.doc.toString();
523
544
  return e.dispatch({
524
545
  ...e.state.changeByRange((e) => {
525
- let r = pe(n, e.from, e.to, t);
546
+ let r = Ee(n, e.from, e.to, t);
526
547
  return {
527
548
  changes: r.changes,
528
- range: r.from === r.to ? u.cursor(r.from) : u.range(r.from, r.to)
549
+ range: r.from === r.to ? d.cursor(r.from) : d.range(r.from, r.to)
529
550
  };
530
551
  }),
531
552
  scrollIntoView: !0
@@ -540,7 +561,7 @@ function L(e, t) {
540
561
  }
541
562
  return !1;
542
563
  }
543
- function Le(e) {
564
+ function Xe(e) {
544
565
  let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = T(n.text, t - n.from);
545
566
  return r ? {
546
567
  from: n.from + r.from,
@@ -548,15 +569,15 @@ function Le(e) {
548
569
  text: r.label
549
570
  } : null;
550
571
  }
551
- function Re(e) {
552
- let t = Le(e.state);
572
+ function Ze(e) {
573
+ let t = Xe(e.state);
553
574
  if (t) return e.dispatch({
554
575
  changes: {
555
576
  from: t.from,
556
577
  to: t.to,
557
578
  insert: t.text
558
579
  },
559
- selection: u.range(t.from, t.from + t.text.length),
580
+ selection: d.range(t.from, t.from + t.text.length),
560
581
  scrollIntoView: !0
561
582
  }), e.focus(), !0;
562
583
  let { from: n, to: r } = e.state.selection.main, i = e.state.sliceDoc(n, r) || "text", a = n + i.length + 3;
@@ -566,14 +587,14 @@ function Re(e) {
566
587
  to: r,
567
588
  insert: `[${i}](url)`
568
589
  },
569
- selection: u.range(a, a + 3),
590
+ selection: d.range(a, a + 3),
570
591
  scrollIntoView: !0
571
592
  }), e.focus(), !0;
572
593
  }
573
- function ze(e) {
574
- return Le(e) !== null;
594
+ function Qe(e) {
595
+ return Xe(e) !== null;
575
596
  }
576
- function Be(e) {
597
+ function $e(e) {
577
598
  let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = E(n.text, t - n.from);
578
599
  return r ? {
579
600
  from: n.from + r.from,
@@ -581,15 +602,15 @@ function Be(e) {
581
602
  text: r.label
582
603
  } : null;
583
604
  }
584
- function Ve(e) {
585
- let t = Be(e.state);
605
+ function et(e) {
606
+ let t = $e(e.state);
586
607
  if (t) return e.dispatch({
587
608
  changes: {
588
609
  from: t.from,
589
610
  to: t.to,
590
611
  insert: t.text
591
612
  },
592
- selection: u.range(t.from, t.from + t.text.length),
613
+ selection: d.range(t.from, t.from + t.text.length),
593
614
  scrollIntoView: !0
594
615
  }), e.focus(), !0;
595
616
  let { from: n, to: r } = e.state.selection.main, i = e.state.sliceDoc(n, r) || "target";
@@ -599,30 +620,30 @@ function Ve(e) {
599
620
  to: r,
600
621
  insert: `[[${i}]]`
601
622
  },
602
- selection: u.range(n + 2, n + 2 + i.length),
623
+ selection: d.range(n + 2, n + 2 + i.length),
603
624
  scrollIntoView: !0
604
625
  }), e.focus(), !0;
605
626
  }
606
- function He(e) {
607
- return Be(e) !== null;
627
+ function tt(e) {
628
+ return $e(e) !== null;
608
629
  }
609
- function Ue(e) {
610
- let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = ce(n.text, t - n.from);
630
+ function nt(e) {
631
+ let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = xe(n.text, t - n.from);
611
632
  return r ? {
612
633
  from: n.from + r.from,
613
634
  to: n.from + r.to,
614
635
  inner: r.inner
615
636
  } : null;
616
637
  }
617
- function We(e) {
618
- let t = Ue(e.state);
638
+ function rt(e) {
639
+ let t = nt(e.state);
619
640
  if (t) return e.dispatch({
620
641
  changes: {
621
642
  from: t.from,
622
643
  to: t.to,
623
644
  insert: t.inner
624
645
  },
625
- selection: u.range(t.from, t.from + t.inner.length),
646
+ selection: d.range(t.from, t.from + t.inner.length),
626
647
  scrollIntoView: !0
627
648
  }), e.focus(), !0;
628
649
  let { from: n, to: r } = e.state.selection.main, i = e.state.sliceDoc(n, r) || "text";
@@ -632,33 +653,33 @@ function We(e) {
632
653
  to: r,
633
654
  insert: `<u>${i}</u>`
634
655
  },
635
- selection: u.range(n + 3, n + 3 + i.length),
656
+ selection: d.range(n + 3, n + 3 + i.length),
636
657
  scrollIntoView: !0
637
658
  }), e.focus(), !0;
638
659
  }
639
- function Ge(e) {
640
- return Ue(e) !== null;
660
+ function it(e) {
661
+ return nt(e) !== null;
641
662
  }
642
663
  //#endregion
643
664
  //#region src/toolbar/table-grid.ts
644
- function Ke(e) {
665
+ function at(e) {
645
666
  let t = e.trim();
646
667
  return t.includes("-") && t.includes("|") && /^[\s|:-]+$/.test(t);
647
668
  }
648
- function qe(e) {
669
+ function ot(e) {
649
670
  let t = e.trim();
650
671
  t.startsWith("|") && (t = t.slice(1)), t.endsWith("|") && !t.endsWith("\\|") && (t = t.slice(0, -1));
651
672
  let n = [], r = "";
652
673
  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
674
  return n.push(r.trim()), n;
654
675
  }
655
- function Je(e) {
676
+ function st(e) {
656
677
  let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
657
678
  return n && r ? "center" : r ? "right" : n ? "left" : "";
658
679
  }
659
680
  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) => {
681
+ if (e.length < 2 || !at(e[1])) return null;
682
+ let t = ot(e[1]).map(st), n = e.filter((e, t) => t !== 1).map(ot), r = Math.max(t.length, ...n.map((e) => e.length)), i = n.map((e) => {
662
683
  let t = e.slice(0, r);
663
684
  for (; t.length < r;) t.push("");
664
685
  return t;
@@ -669,11 +690,11 @@ function R(e) {
669
690
  aligns: a
670
691
  };
671
692
  }
672
- function Ye(e) {
693
+ function ct(e) {
673
694
  return e.replace(/\\\|/g, "|").length;
674
695
  }
675
- function Xe(e, t, n) {
676
- let r = t - Ye(e);
696
+ function lt(e, t, n) {
697
+ let r = t - ct(e);
677
698
  if (r <= 0) return e;
678
699
  if (n === "right") return " ".repeat(r) + e;
679
700
  if (n === "center") {
@@ -682,7 +703,7 @@ function Xe(e, t, n) {
682
703
  }
683
704
  return e + " ".repeat(r);
684
705
  }
685
- function Ze(e, t) {
706
+ function ut(e, t) {
686
707
  let n = Math.max(3, e);
687
708
  return t === "left" ? ":" + "-".repeat(n - 1) : t === "right" ? "-".repeat(n - 1) + ":" : t === "center" ? ":" + "-".repeat(n - 2) + ":" : "-".repeat(n);
688
709
  }
@@ -690,15 +711,15 @@ function z(e) {
690
711
  let t = e.aligns.length, n = [];
691
712
  for (let r = 0; r < t; r++) {
692
713
  let t = 3;
693
- for (let n of e.rows) t = Math.max(t, Ye(n[r] ?? ""));
714
+ for (let n of e.rows) t = Math.max(t, ct(n[r] ?? ""));
694
715
  n.push(t);
695
716
  }
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(" | ") + " |");
717
+ let r = (t) => "| " + t.map((t, r) => lt(t ?? "", n[r], e.aligns[r])).join(" | ") + " |", i = [r(e.rows[0] ?? [])];
718
+ i.push("| " + e.aligns.map((e, t) => ut(n[t], e)).join(" | ") + " |");
698
719
  for (let t = 1; t < e.rows.length; t++) i.push(r(e.rows[t]));
699
720
  return i.join("\n");
700
721
  }
701
- function Qe(e) {
722
+ function dt(e) {
702
723
  let t = [];
703
724
  for (let n = 0; n < e.length; n++) {
704
725
  if (e[n] === "\\") {
@@ -745,7 +766,7 @@ function B(e, t) {
745
766
  lines: a
746
767
  } : null;
747
768
  }
748
- function $e(e, t, n) {
769
+ function ft(e, t, n) {
749
770
  let r = t;
750
771
  for (let t = 0; t < e.length; t++) {
751
772
  let i = e[t];
@@ -761,7 +782,7 @@ function $e(e, t, n) {
761
782
  onDelimiter: !0
762
783
  };
763
784
  }
764
- let a = Qe(i), o = 0;
785
+ let a = dt(i), o = 0;
765
786
  for (let t = 0; t < a.length && (o = t, !(e <= a[t].end)); t++);
766
787
  let s = a[o], c = s ? Math.max(0, Math.min(e, s.contentEnd) - s.contentStart) : 0;
767
788
  return {
@@ -778,10 +799,10 @@ function $e(e, t, n) {
778
799
  function V(e, t, n) {
779
800
  let r = e.split("\n"), i = n.onDelimiter ? 1 : n.row === 0 ? 0 : n.row + 1, a = t;
780
801
  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)];
802
+ let o = dt(r[i]), s = o[Math.min(n.col, o.length - 1)];
782
803
  return s ? a + s.contentStart + Math.min(n.offset, s.contentEnd - s.contentStart) : a;
783
804
  }
784
- function et(e, t, n, r) {
805
+ function pt(e, t, n, r) {
785
806
  let i = B(e, t);
786
807
  return i ? V(i.lines.join("\n"), i.from, {
787
808
  row: n,
@@ -792,7 +813,7 @@ function et(e, t, n, r) {
792
813
  }
793
814
  //#endregion
794
815
  //#region src/toolbar/table.ts
795
- function tt(e, t) {
816
+ function mt(e, t) {
796
817
  requestAnimationFrame(() => {
797
818
  let n = e.dom.querySelectorAll(".cm-inplace-table-edit");
798
819
  if (n.length === 0) return;
@@ -812,7 +833,7 @@ function tt(e, t) {
812
833
  s?.removeAllRanges(), s?.addRange(o), a.focus();
813
834
  });
814
835
  }
815
- function nt(e) {
836
+ function ht(e) {
816
837
  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
838
  return e.dispatch({
818
839
  changes: {
@@ -820,9 +841,9 @@ function nt(e) {
820
841
  to: n,
821
842
  insert: i + "| Column 1 | Column 2 |\n| -------- | -------- |\n| | |\n"
822
843
  },
823
- selection: u.range(a, a + 8),
844
+ selection: d.range(a, a + 8),
824
845
  scrollIntoView: !0
825
- }), e.focus(), tt(e, a), !0;
846
+ }), e.focus(), mt(e, a), !0;
826
847
  }
827
848
  function H(e) {
828
849
  return B(e.doc, e.selection.main.head) !== null;
@@ -830,7 +851,7 @@ function H(e) {
830
851
  function U(e, t) {
831
852
  let n = B(e.state.doc, e.state.selection.main.head);
832
853
  if (!n) return !1;
833
- let r = R(n.lines), i = $e(n.lines, n.from, e.state.selection.main.head);
854
+ let r = R(n.lines), i = ft(n.lines, n.from, e.state.selection.main.head);
834
855
  if (!r || !i) return !1;
835
856
  let a = t(r, i);
836
857
  if (!a) return !1;
@@ -841,11 +862,11 @@ function U(e, t) {
841
862
  to: n.to,
842
863
  insert: o
843
864
  },
844
- selection: u.cursor(V(o, n.from, a)),
865
+ selection: d.cursor(V(o, n.from, a)),
845
866
  scrollIntoView: !0
846
867
  }), e.focus(), !0;
847
868
  }
848
- function rt(e, t, n) {
869
+ function gt(e, t, n) {
849
870
  let r = e.aligns.length, { row: i, col: a } = t;
850
871
  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
872
  row: i,
@@ -854,7 +875,7 @@ function rt(e, t, n) {
854
875
  onDelimiter: !1
855
876
  });
856
877
  }
857
- function it(e, t) {
878
+ function _t(e, t) {
858
879
  let n = t.row + 1;
859
880
  return n >= e.rows.length && e.rows.push(Array(e.aligns.length).fill("")), {
860
881
  row: n,
@@ -863,20 +884,20 @@ function it(e, t) {
863
884
  onDelimiter: !1
864
885
  };
865
886
  }
866
- var at = a.of([
887
+ var vt = a.of([
867
888
  {
868
889
  key: "Tab",
869
- run: (e) => U(e, (e, t) => rt(e, t, 1))
890
+ run: (e) => U(e, (e, t) => gt(e, t, 1))
870
891
  },
871
892
  {
872
893
  key: "Shift-Tab",
873
- run: (e) => U(e, (e, t) => rt(e, t, -1))
894
+ run: (e) => U(e, (e, t) => gt(e, t, -1))
874
895
  },
875
896
  {
876
897
  key: "Enter",
877
- run: (e) => U(e, it)
898
+ run: (e) => U(e, _t)
878
899
  }
879
- ]), ot = d.transactionFilter.of((e) => {
900
+ ]), yt = f.transactionFilter.of((e) => {
880
901
  if (!e.docChanged || !e.isUserEvent("input") && !e.isUserEvent("delete")) return e;
881
902
  let t = e.newSelection.main.head, n = B(e.newDoc, t);
882
903
  if (!n) return e;
@@ -884,37 +905,37 @@ var at = a.of([
884
905
  if (!r) return e;
885
906
  let i = z(r);
886
907
  if (i === n.lines.join("\n")) return e;
887
- let a = $e(n.lines, n.from, t), o = c.of([{
908
+ let a = ft(n.lines, n.from, t), o = l.of([{
888
909
  from: n.from,
889
910
  to: n.to,
890
911
  insert: i
891
912
  }], e.newDoc.length);
892
913
  return {
893
914
  changes: e.changes.compose(o),
894
- selection: a ? u.cursor(V(i, n.from, a)) : e.newSelection,
915
+ selection: a ? d.cursor(V(i, n.from, a)) : e.newSelection,
895
916
  effects: e.effects,
896
917
  scrollIntoView: e.scrollIntoView
897
918
  };
898
919
  }), W = (e) => /^\s{0,3}#{1,6}(?:\s|$)/.test(e.doc.lineAt(e.selection.main.head).text), G = (e) => {
899
920
  let n = t(e.doc);
900
921
  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 = {
922
+ }, K = (e) => G(e) || P(e) || F(e), bt = (e) => (t) => e !== "`" && L(t, "`") || e !== "$" && L(t, "$"), xt = (e) => e.selection.main.empty && !e.wordAt(e.selection.main.head), q = (...e) => (t) => e.some((e) => e(t)), J = /^(\s*)(?:[-*+] \[[ xX]\] +|\d+\. +|[-*+] +)/, St = {
902
923
  match: /^ {0,3}> ?/,
903
924
  insert: "> "
904
- }, ut = {
925
+ }, Ct = {
905
926
  match: /^(\s*)[-*+] +(?!\[[ xX]\])/,
906
927
  insert: "- ",
907
928
  siblings: J
908
- }, dt = {
929
+ }, wt = {
909
930
  match: /^(\s*)\d+\. +/,
910
931
  insert: (e) => `${e + 1}. `,
911
932
  siblings: J
912
- }, ft = {
933
+ }, Tt = {
913
934
  match: /^(\s*)[-*+] \[[ xX]\] +/,
914
935
  insert: "- [ ] ",
915
936
  siblings: J
916
937
  };
917
- function pt(e, t, n) {
938
+ function Et(e, t, n) {
918
939
  return {
919
940
  id: e,
920
941
  title: t,
@@ -930,7 +951,7 @@ function Y(e, t, n, r) {
930
951
  title: t,
931
952
  run: (e) => j(e, (e, t, r) => O(e, t, r, n)) || I(e, n),
932
953
  isActive: (e) => L(e, n),
933
- disabled: q(K, st(n), ct),
954
+ disabled: q(K, bt(n), xt),
934
955
  keys: r
935
956
  };
936
957
  }
@@ -939,7 +960,7 @@ function X(e) {
939
960
  return {
940
961
  id: `h${e}`,
941
962
  title: `Heading ${e}`,
942
- run: (t) => Fe(t, e),
963
+ run: (t) => Je(t, e),
943
964
  isActive: (e) => t.test(e.doc.lineAt(e.selection.main.head).text),
944
965
  disabled: q(H, K),
945
966
  keys: [`Mod-Alt-${e}`]
@@ -949,14 +970,14 @@ function Z(e, t, n, ...r) {
949
970
  return {
950
971
  id: e,
951
972
  title: t,
952
- run: (e) => Oe(e, n),
953
- isActive: (e) => ke(e, n.match),
973
+ run: (e) => Ve(e, n),
974
+ isActive: (e) => He(e, n.match),
954
975
  disabled: q(H, K, ...r)
955
976
  };
956
977
  }
957
978
  //#endregion
958
979
  //#region src/toolbar/frontmatter-toggle.ts
959
- function mt(e) {
980
+ function Dt(e) {
960
981
  let n = e.state, r = t(n.doc);
961
982
  if (r) {
962
983
  let t = n.doc.lineAt(r.from), i = n.doc.lineAt(r.to);
@@ -980,21 +1001,21 @@ function mt(e) {
980
1001
  from: n.doc.line(t).to,
981
1002
  insert: "\n---"
982
1003
  }],
983
- selection: u.cursor(4),
1004
+ selection: d.cursor(4),
984
1005
  scrollIntoView: !0
985
1006
  });
986
1007
  }
987
1008
  return e.focus(), !0;
988
1009
  }
989
- function ht(e) {
1010
+ function Ot(e) {
990
1011
  return t(e.doc) !== null;
991
1012
  }
992
1013
  //#endregion
993
1014
  //#region src/toolbar/rule.ts
994
- var gt = /^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/;
995
- function _t(e) {
1015
+ var kt = /^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/;
1016
+ function At(e) {
996
1017
  let t = e.state, n = t.doc.lineAt(t.selection.main.head);
997
- return gt.test(n.text) ? e.dispatch({
1018
+ return kt.test(n.text) ? e.dispatch({
998
1019
  changes: {
999
1020
  from: n.from,
1000
1021
  to: Math.min(n.to + 1, t.doc.length)
@@ -1006,37 +1027,134 @@ function _t(e) {
1006
1027
  to: n.to,
1007
1028
  insert: "---"
1008
1029
  },
1009
- selection: u.cursor(n.from + 3),
1030
+ selection: d.cursor(n.from + 3),
1010
1031
  scrollIntoView: !0
1011
1032
  }) : e.dispatch({
1012
1033
  changes: {
1013
1034
  from: n.to,
1014
1035
  insert: "\n\n---\n"
1015
1036
  },
1016
- selection: u.cursor(n.to + 6),
1037
+ selection: d.cursor(n.to + 6),
1017
1038
  scrollIntoView: !0
1018
1039
  }), e.focus(), !0;
1019
1040
  }
1020
- function vt(e) {
1021
- return gt.test(e.doc.lineAt(e.selection.main.head).text);
1041
+ function jt(e) {
1042
+ return kt.test(e.doc.lineAt(e.selection.main.head).text);
1022
1043
  }
1023
1044
  //#endregion
1024
1045
  //#region src/editor/save.ts
1025
- var Q = f.define({ combine: (e) => e[0] ?? null });
1026
- function yt(e) {
1046
+ var Q = p.define({ combine: (e) => e[0] ?? null });
1047
+ function Mt(e) {
1027
1048
  let t = e.state.facet(Q);
1028
1049
  return t ? (t(e.state.doc.toString()), !0) : !1;
1029
1050
  }
1030
1051
  //#endregion
1052
+ //#region src/editor/search-panel-dom.ts
1053
+ var Nt = "stylo-search-panel";
1054
+ function Pt(e) {
1055
+ e.setAttribute("form", "");
1056
+ }
1057
+ function Ft(e, t, n) {
1058
+ let r = document.createElement("input");
1059
+ return r.type = "text", r.name = e, r.placeholder = t, r.setAttribute("aria-label", t), r.className = n, Pt(r), r;
1060
+ }
1061
+ function $(e, t) {
1062
+ let n = document.createElement("button");
1063
+ return n.type = "button", n.name = e, n.className = "stylo-search-button", n.textContent = t, n;
1064
+ }
1065
+ function It(e, t) {
1066
+ let n = document.createElement("input");
1067
+ n.type = "checkbox", n.name = e, Pt(n);
1068
+ let r = document.createElement("label");
1069
+ return r.className = "stylo-search-check", r.append(n, document.createTextNode(t)), {
1070
+ field: n,
1071
+ wrap: r
1072
+ };
1073
+ }
1074
+ function Lt(e) {
1075
+ let t = (t) => e.state.phrase(t), n = Ft("search", t("Find"), "stylo-search-field");
1076
+ n.setAttribute("main-field", "true");
1077
+ let r = $("next", t("next")), i = $("prev", t("previous")), a = $("select", t("all")), o = Ft("replace", t("Replace"), "stylo-search-field stylo-search-replace"), s = $("replace", t("replace")), c = $("replaceAll", t("replace all")), l = It("case", t("match case")), u = It("re", t("regexp")), d = It("word", t("by word")), f = $("close", "×");
1078
+ f.classList.add("stylo-search-close"), f.setAttribute("aria-label", t("close"));
1079
+ let p = document.createElement("div");
1080
+ return p.className = Nt, p.append(n, r, i, a, o, s, c, l.wrap, u.wrap, d.wrap, f), {
1081
+ root: p,
1082
+ find: n,
1083
+ next: r,
1084
+ prev: i,
1085
+ all: a,
1086
+ replace: o,
1087
+ replaceBtn: s,
1088
+ replaceAllBtn: c,
1089
+ caseSensitive: l.field,
1090
+ regexp: u.field,
1091
+ wholeWord: d.field,
1092
+ close: f
1093
+ };
1094
+ }
1095
+ //#endregion
1096
+ //#region src/editor/search-panel.ts
1097
+ var Rt = "cm-search-closing", zt = 160;
1098
+ function Bt(e) {
1099
+ return ce(e.state) ? Vt(e) : re(e);
1100
+ }
1101
+ function Vt(e) {
1102
+ let t = e.dom.querySelector(`.${Nt}`);
1103
+ return !t || t.classList.contains(Rt) ? !0 : (t.classList.add(Rt), setTimeout(() => {
1104
+ e.dom.isConnected && ne(e);
1105
+ }, zt), !0);
1106
+ }
1107
+ function Ht(e) {
1108
+ let t = Lt(e), n = C(e.state);
1109
+ r(n);
1110
+ function r(e) {
1111
+ t.find.value = e.search, t.replace.value = e.replace, t.caseSensitive.checked = e.caseSensitive, t.regexp.checked = e.regexp, t.wholeWord.checked = e.wholeWord;
1112
+ }
1113
+ function i() {
1114
+ let r = new b({
1115
+ search: t.find.value,
1116
+ caseSensitive: t.caseSensitive.checked,
1117
+ regexp: t.regexp.checked,
1118
+ wholeWord: t.wholeWord.checked,
1119
+ replace: t.replace.value
1120
+ });
1121
+ r.eq(n) || (n = r, e.dispatch({ effects: ue.of(n) }));
1122
+ }
1123
+ for (let e of [
1124
+ t.find,
1125
+ t.replace,
1126
+ t.caseSensitive,
1127
+ t.regexp,
1128
+ t.wholeWord
1129
+ ]) e.addEventListener("input", i), e.addEventListener("change", i);
1130
+ return t.root.addEventListener("keydown", (n) => {
1131
+ if (n.key === "Escape") {
1132
+ n.preventDefault(), Vt(e);
1133
+ return;
1134
+ }
1135
+ if (s(e, n, "search-panel")) {
1136
+ n.preventDefault();
1137
+ return;
1138
+ }
1139
+ n.key === "Enter" && (n.preventDefault(), n.target === t.find ? (n.shiftKey ? S : x)(e) : n.target === t.replace && ae(e));
1140
+ }), t.next.addEventListener("click", () => x(e)), t.prev.addEventListener("click", () => S(e)), t.all.addEventListener("click", () => le(e)), t.replaceBtn.addEventListener("click", () => ae(e)), t.replaceAllBtn.addEventListener("click", () => ie(e)), t.close.addEventListener("click", () => Vt(e)), {
1141
+ dom: t.root,
1142
+ top: !0,
1143
+ update(e) {
1144
+ for (let t of e.transactions) for (let e of t.effects) e.is(ue) && !e.value.eq(n) && (n = e.value, r(n));
1145
+ }
1146
+ };
1147
+ }
1148
+ //#endregion
1031
1149
  //#region src/toolbar/commands.ts
1032
- var $ = [
1033
- pt("undo", "Undo", g),
1034
- pt("redo", "Redo", h),
1150
+ var Ut = [
1151
+ Et("undo", "Undo", _),
1152
+ Et("redo", "Redo", g),
1035
1153
  {
1036
1154
  id: "save",
1037
1155
  title: "Save",
1038
1156
  run: (e) => {
1039
- let t = yt(e);
1157
+ let t = Mt(e);
1040
1158
  return e.focus(), t;
1041
1159
  },
1042
1160
  disabled: (e) => e.facet(Q) == null
@@ -1044,7 +1162,8 @@ var $ = [
1044
1162
  {
1045
1163
  id: "search",
1046
1164
  title: "Find / replace",
1047
- run: (e) => y(e),
1165
+ run: (e) => Bt(e),
1166
+ isActive: (e) => ce(e),
1048
1167
  keys: ["Mod-f"]
1049
1168
  },
1050
1169
  X(1),
@@ -1053,7 +1172,7 @@ var $ = [
1053
1172
  {
1054
1173
  id: "body",
1055
1174
  title: "Body",
1056
- run: (e) => (Ie(e) || e.focus(), !0),
1175
+ run: (e) => (Ye(e) || e.focus(), !0),
1057
1176
  isActive: (e) => !/^#{1,6} /.test(e.doc.lineAt(e.selection.main.head).text),
1058
1177
  disabled: q(H, K)
1059
1178
  },
@@ -1063,57 +1182,57 @@ var $ = [
1063
1182
  {
1064
1183
  id: "underline",
1065
1184
  title: "Underline",
1066
- run: (e) => j(e, le) || We(e),
1067
- isActive: Ge,
1068
- disabled: q(K, st("u"), ct),
1185
+ run: (e) => j(e, Se) || rt(e),
1186
+ isActive: it,
1187
+ disabled: q(K, bt("u"), xt),
1069
1188
  keys: ["Mod-u"]
1070
1189
  },
1071
1190
  Y("code", "Inline code", "`"),
1072
1191
  {
1073
1192
  id: "codeBlock",
1074
1193
  title: "Code block",
1075
- run: (e) => j(e, (e, t, n) => O(e, t, n, "`")) || (H(e.state) ? I(e, "`") : Ae(e)),
1194
+ run: (e) => j(e, (e, t, n) => O(e, t, n, "`")) || (H(e.state) ? I(e, "`") : Ue(e)),
1076
1195
  isActive: (e) => H(e) ? L(e, "`") : P(e),
1077
1196
  disabled: q(G, F, W)
1078
1197
  },
1079
1198
  {
1080
1199
  id: "link",
1081
1200
  title: "Link",
1082
- run: (e) => j(e, ae) || Re(e),
1083
- isActive: ze,
1201
+ run: (e) => j(e, ve) || Ze(e),
1202
+ isActive: Qe,
1084
1203
  disabled: K,
1085
1204
  keys: ["Mod-k"]
1086
1205
  },
1087
1206
  {
1088
1207
  id: "wikilink",
1089
1208
  title: "Wikilink",
1090
- run: (e) => j(e, se) || Ve(e),
1091
- isActive: He,
1209
+ run: (e) => j(e, be) || et(e),
1210
+ isActive: tt,
1092
1211
  disabled: K,
1093
1212
  keys: ["Mod-Shift-k"]
1094
1213
  },
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),
1214
+ Z("quote", "Blockquote", St),
1215
+ Z("bulletList", "Bulleted list", Ct, W),
1216
+ Z("orderedList", "Numbered list", wt, W),
1217
+ Z("task", "Task list", Tt, W),
1099
1218
  {
1100
1219
  id: "hr",
1101
1220
  title: "Divider",
1102
- run: _t,
1103
- isActive: vt,
1221
+ run: At,
1222
+ isActive: jt,
1104
1223
  disabled: q(H, K)
1105
1224
  },
1106
1225
  {
1107
1226
  id: "frontmatter",
1108
1227
  title: "Frontmatter",
1109
- run: mt,
1110
- isActive: ht,
1228
+ run: Dt,
1229
+ isActive: Ot,
1111
1230
  disabled: q(H, P, F, W)
1112
1231
  },
1113
1232
  {
1114
1233
  id: "table",
1115
1234
  title: "Table",
1116
- run: nt,
1235
+ run: ht,
1117
1236
  isActive: H,
1118
1237
  disabled: q(H, G, P, F, W)
1119
1238
  },
@@ -1121,15 +1240,15 @@ var $ = [
1121
1240
  {
1122
1241
  id: "mathBlock",
1123
1242
  title: "Block math",
1124
- run: (e) => j(e, (e, t, n) => O(e, t, n, "$")) || (H(e.state) ? I(e, "$") : Pe(e)),
1243
+ run: (e) => j(e, (e, t, n) => O(e, t, n, "$")) || (H(e.state) ? I(e, "$") : qe(e)),
1125
1244
  isActive: (e) => H(e) ? L(e, "$") : F(e),
1126
1245
  disabled: q(G, P, W)
1127
1246
  }
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) => ({
1247
+ ], Wt = Object.fromEntries(Ut.map((e) => [e.id, e])), Gt = m.high(a.of(Ut.filter((e) => e.keys && e.keys.length > 0).flatMap((e) => e.keys.map((t) => ({
1129
1248
  key: t,
1130
1249
  preventDefault: !0,
1131
1250
  run: ((t) => !e.disabled?.(t.state) && e.run(t))
1132
- }))))), St = x.define([
1251
+ }))))), Kt = de.define([
1133
1252
  {
1134
1253
  tag: [
1135
1254
  w.keyword,
@@ -1213,7 +1332,7 @@ var $ = [
1213
1332
  tag: [w.invalid],
1214
1333
  color: "var(--stylo-syntax-invalid)"
1215
1334
  }
1216
- ]), Ct = S(St), wt = i.theme({
1335
+ ]), qt = fe(Kt), Jt = i.theme({
1217
1336
  "&": {
1218
1337
  color: "var(--stylo-text)",
1219
1338
  backgroundColor: "var(--stylo-bg)",
@@ -1230,46 +1349,82 @@ var $ = [
1230
1349
  "&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: "color-mix(in srgb, var(--stylo-accent) 15%, transparent)" },
1231
1350
  ".cm-placeholder": { color: "var(--stylo-text-muted)" },
1232
1351
  ".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",
1352
+ ".cm-panels": { color: "var(--stylo-text)" },
1353
+ ".cm-panels.cm-panels-top": { background: "var(--stylo-bg)" },
1354
+ ".stylo-search-panel": {
1355
+ "--h": "32px",
1356
+ display: "flex",
1357
+ flexWrap: "nowrap",
1358
+ alignItems: "center",
1359
+ gap: "4px",
1360
+ height: "var(--h)",
1361
+ boxSizing: "border-box",
1362
+ padding: "0 8px",
1363
+ overflowX: "auto",
1364
+ overflowY: "hidden",
1240
1365
  font: "inherit",
1241
- fontSize: "0.8125rem"
1242
- },
1243
- ".cm-panel.cm-search label": {
1244
1366
  fontSize: "0.75rem",
1245
- color: "var(--stylo-text-muted)"
1367
+ borderBottom: "1px solid var(--stylo-border)",
1368
+ animation: "stylo-search-slide-in 0.16s ease-out"
1369
+ },
1370
+ ".stylo-search-panel.cm-search-closing": { animation: "stylo-search-slide-out 0.16s ease-in forwards" },
1371
+ "@keyframes stylo-search-slide-in": {
1372
+ from: { height: "0px" },
1373
+ to: { height: "var(--h)" }
1374
+ },
1375
+ "@keyframes stylo-search-slide-out": {
1376
+ from: { height: "var(--h)" },
1377
+ to: { height: "0px" }
1378
+ },
1379
+ ".stylo-search-check": {
1380
+ display: "inline-flex",
1381
+ alignItems: "center",
1382
+ gap: "3px",
1383
+ whiteSpace: "nowrap",
1384
+ fontSize: "0.6875rem",
1385
+ color: "var(--stylo-text-muted)",
1386
+ flex: "0 0 auto"
1246
1387
  },
1247
- ".cm-panel.cm-search .cm-textfield": {
1248
- padding: "0.3em 0.5em",
1388
+ ".stylo-search-field": {
1389
+ flex: "1 1 90px",
1390
+ minWidth: "60px",
1391
+ padding: "0.2em 0.4em",
1249
1392
  border: "1px solid var(--stylo-border)",
1250
1393
  borderRadius: "calc(var(--stylo-radius) - 3px)",
1251
1394
  background: "var(--stylo-bg)",
1252
1395
  color: "var(--stylo-text)",
1253
- fontSize: "0.8125rem"
1396
+ fontSize: "0.75rem"
1254
1397
  },
1255
- ".cm-panel.cm-search .cm-textfield:focus-visible": {
1398
+ ".stylo-search-field:focus-visible": {
1256
1399
  outline: "2px solid var(--stylo-ring)",
1257
1400
  outlineOffset: "-1px"
1258
1401
  },
1259
- ".cm-panel.cm-search .cm-button": {
1260
- padding: "0.3em 0.65em",
1261
- border: "1px solid var(--stylo-border)",
1402
+ ".stylo-search-field.stylo-search-replace": {
1403
+ marginLeft: "6px",
1404
+ paddingLeft: "10px",
1405
+ borderLeft: "1px solid var(--stylo-border)",
1406
+ borderRadius: "0"
1407
+ },
1408
+ ".stylo-search-button": {
1409
+ flex: "0 0 auto",
1410
+ padding: "0.15em 0.4em",
1411
+ border: "0",
1262
1412
  borderRadius: "calc(var(--stylo-radius) - 3px)",
1263
- background: "var(--stylo-bg)",
1413
+ background: "none",
1264
1414
  backgroundImage: "none",
1265
- color: "var(--stylo-text)",
1266
- fontSize: "0.75rem",
1415
+ color: "var(--stylo-text-muted)",
1416
+ fontSize: "0.6875rem",
1417
+ fontWeight: "600",
1267
1418
  cursor: "pointer"
1268
1419
  },
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']": {
1420
+ ".stylo-search-button:hover": {
1421
+ background: "color-mix(in srgb, var(--stylo-border) 45%, transparent)",
1422
+ color: "var(--stylo-text)"
1423
+ },
1424
+ ".stylo-search-close": {
1425
+ marginLeft: "auto",
1271
1426
  color: "var(--stylo-text-muted)",
1272
- fontSize: "1.1rem"
1427
+ fontSize: "0.9rem"
1273
1428
  },
1274
1429
  ".cm-searchMatch": {
1275
1430
  backgroundColor: "color-mix(in srgb, var(--stylo-ring) 35%, transparent)",
@@ -1279,8 +1434,8 @@ var $ = [
1279
1434
  backgroundColor: "color-mix(in srgb, var(--stylo-ring) 70%, transparent)",
1280
1435
  outline: "1px solid var(--stylo-ring)"
1281
1436
  }
1282
- }), Tt = /\[\[([^[\]\n|]*)$/;
1283
- function Et(e) {
1437
+ }), Yt = /\[\[([^[\]\n|]*)$/;
1438
+ function Xt(e) {
1284
1439
  let t = e.label && e.label !== e.target ? e.label : void 0, n = t ? `${e.target}|${t}` : e.target;
1285
1440
  return {
1286
1441
  label: e.label ?? e.target,
@@ -1298,13 +1453,13 @@ function Et(e) {
1298
1453
  }
1299
1454
  };
1300
1455
  }
1301
- function Dt(e, t) {
1456
+ function Zt(e, t) {
1302
1457
  return async (n) => {
1303
- let r = n.matchBefore(Tt);
1458
+ let r = n.matchBefore(Yt);
1304
1459
  if (!r || r.from + 2 === n.pos && !n.explicit) return null;
1305
1460
  let i = r.text.slice(2), a;
1306
1461
  try {
1307
- a = (await e(i)).map(Et);
1462
+ a = (await e(i)).map(Xt);
1308
1463
  } catch (e) {
1309
1464
  return t?.(e, {
1310
1465
  source: "wikiLinkSource",
@@ -1319,33 +1474,36 @@ function Dt(e, t) {
1319
1474
  } : null;
1320
1475
  };
1321
1476
  }
1322
- function Ot(e, t) {
1323
- return e ? [re(), v.data.of({ autocomplete: Dt(e, t) })] : [];
1477
+ function Qt(e, t) {
1478
+ return e ? [me(), y.data.of({ autocomplete: Zt(e, t) })] : [];
1324
1479
  }
1325
1480
  //#endregion
1326
1481
  //#region src/editor/extensions.ts
1327
- function kt(e, t, n) {
1482
+ function $t(e, t, n) {
1328
1483
  return [
1329
1484
  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,
1485
+ a.of([...ee, ...h]),
1486
+ m.high(vt),
1487
+ Gt,
1488
+ yt,
1489
+ oe({
1490
+ top: !0,
1491
+ createPanel: Ht
1492
+ }),
1493
+ a.of(se),
1494
+ v({
1495
+ base: y,
1338
1496
  codeLanguages: e
1339
1497
  }),
1340
- Ct,
1341
- Ot(t, n),
1498
+ qt,
1499
+ Qt(t, n),
1342
1500
  i.lineWrapping,
1343
- wt
1501
+ Jt
1344
1502
  ];
1345
1503
  }
1346
- function At(e) {
1504
+ function en(e) {
1347
1505
  return [
1348
- d.readOnly.of(e.readOnly),
1506
+ f.readOnly.of(e.readOnly),
1349
1507
  i.editable.of(!e.readOnly),
1350
1508
  e.placeholder ? o(e.placeholder) : [],
1351
1509
  e.save ? Q.of(e.save) : []
@@ -1353,40 +1511,40 @@ function At(e) {
1353
1511
  }
1354
1512
  //#endregion
1355
1513
  //#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 }) {
1514
+ var tn = c.define();
1515
+ function nn({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c, onViewChange: l, extensions: d, codeLanguages: p, wikiLinkSource: ee, onResolveError: te }) {
1358
1516
  let h = r(null), g = r(null), _ = r(t);
1359
1517
  _.current = t;
1360
1518
  let v = r(c);
1361
1519
  v.current = c;
1362
- let y = r((e) => v.current?.(e)).current, b = r(m);
1363
- b.current = m;
1520
+ let y = r((e) => v.current?.(e)).current, b = r(te);
1521
+ b.current = te;
1364
1522
  let ne = r((e, t) => {
1365
1523
  b.current?.(e, t);
1366
- }).current, x = c != null, S = r(u);
1367
- S.current = u;
1368
- let C = r(new l());
1524
+ }).current, x = c != null, S = r(l);
1525
+ S.current = l;
1526
+ let C = r(new u());
1369
1527
  return n(() => {
1370
1528
  let t = h.current;
1371
1529
  if (!t) return;
1372
1530
  let n = new i({
1373
1531
  parent: t,
1374
- state: d.create({
1532
+ state: f.create({
1375
1533
  doc: e,
1376
1534
  extensions: [
1377
- kt(ee, te, ne),
1378
- C.current.of(At({
1535
+ $t(p, ee, ne),
1536
+ C.current.of(en({
1379
1537
  readOnly: o,
1380
1538
  placeholder: s,
1381
1539
  save: x ? y : void 0
1382
1540
  })),
1383
- p.high(a.of([{
1541
+ m.high(a.of([{
1384
1542
  key: "Mod-s",
1385
- run: yt
1543
+ run: Mt
1386
1544
  }])),
1387
- ...f ?? [],
1545
+ ...d ?? [],
1388
1546
  i.updateListener.of((e) => {
1389
- e.docChanged && (e.transactions.some((e) => !!e.annotation(jt)) || _.current(e.state.doc.toString()));
1547
+ e.docChanged && (e.transactions.some((e) => !!e.annotation(tn)) || _.current(e.state.doc.toString()));
1390
1548
  })
1391
1549
  ]
1392
1550
  })
@@ -1404,10 +1562,10 @@ function Mt({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c
1404
1562
  to: n.length,
1405
1563
  insert: e
1406
1564
  },
1407
- annotations: jt.of(!0)
1565
+ annotations: tn.of(!0)
1408
1566
  });
1409
1567
  }, [e]), n(() => {
1410
- g.current?.dispatch({ effects: C.current.reconfigure(At({
1568
+ g.current?.dispatch({ effects: C.current.reconfigure(en({
1411
1569
  readOnly: o,
1412
1570
  placeholder: s,
1413
1571
  save: x ? y : void 0
@@ -1420,6 +1578,6 @@ function Mt({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c
1420
1578
  ]), h;
1421
1579
  }
1422
1580
  //#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 };
1581
+ export { ge as S, Ae as _, R as a, ye as b, P as c, ke as d, Pe as f, Ne as g, Ie as h, pt as i, Le as l, Me as m, Wt as n, z as o, A as p, At as r, We as s, nn as t, Be as u, je as v, _e as x, E as y };
1424
1582
 
1425
- //# sourceMappingURL=useCodeMirror-DtwupFgc.js.map
1583
+ //# sourceMappingURL=useCodeMirror-CjG9CwpB.js.map