@damiro/stylo 0.4.0 → 0.7.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 +94 -10
  2. package/dist/{InPlaceView-Ba7JCZ2Y.js → InPlaceView-CS1qy-Ba.js} +277 -265
  3. package/dist/InPlaceView-CS1qy-Ba.js.map +1 -0
  4. package/dist/{Preview-Dxb9zPVv.js → Preview-Bw0k3Mev.js} +2 -2
  5. package/dist/{Preview-Dxb9zPVv.js.map → Preview-Bw0k3Mev.js.map} +1 -1
  6. package/dist/SplitView.d.ts +3 -2
  7. package/dist/SplitView.d.ts.map +1 -1
  8. package/dist/Stylo.d.ts.map +1 -1
  9. package/dist/editor/SourceView.d.ts +4 -2
  10. package/dist/editor/SourceView.d.ts.map +1 -1
  11. package/dist/editor/extensions.d.ts +2 -2
  12. package/dist/editor/extensions.d.ts.map +1 -1
  13. package/dist/editor/theme.d.ts.map +1 -1
  14. package/dist/editor/useCodeMirror.d.ts +4 -2
  15. package/dist/editor/useCodeMirror.d.ts.map +1 -1
  16. package/dist/editor/wikilink-complete.d.ts +15 -0
  17. package/dist/editor/wikilink-complete.d.ts.map +1 -0
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/inplace/InPlaceView.d.ts +4 -2
  21. package/dist/inplace/InPlaceView.d.ts.map +1 -1
  22. package/dist/inplace/context-menu.d.ts +1 -1
  23. package/dist/inplace/context-menu.d.ts.map +1 -1
  24. package/dist/inplace/extension.d.ts.map +1 -1
  25. package/dist/inplace/menu-open.d.ts +11 -0
  26. package/dist/inplace/menu-open.d.ts.map +1 -0
  27. package/dist/inplace/menu-plugin.d.ts +1 -0
  28. package/dist/inplace/menu-plugin.d.ts.map +1 -1
  29. package/dist/inplace/selection-bar.d.ts.map +1 -1
  30. package/dist/inplace/theme.d.ts.map +1 -1
  31. package/dist/styles.css +1 -1
  32. package/dist/stylo.js +58 -53
  33. package/dist/stylo.js.map +1 -1
  34. package/dist/types.d.ts +25 -0
  35. package/dist/types.d.ts.map +1 -1
  36. package/dist/{useCodeMirror-YnIFkvKn.js → useCodeMirror-GPSkaYW6.js} +204 -168
  37. package/dist/useCodeMirror-GPSkaYW6.js.map +1 -0
  38. package/dist/wikilink-CTR8IFKc.js +42 -0
  39. package/dist/wikilink-CTR8IFKc.js.map +1 -0
  40. package/package.json +4 -1
  41. package/dist/InPlaceView-Ba7JCZ2Y.js.map +0 -1
  42. package/dist/useCodeMirror-YnIFkvKn.js.map +0 -1
  43. package/dist/wikilink-BFpTehto.js +0 -42
  44. package/dist/wikilink-BFpTehto.js.map +0 -1
@@ -1,15 +1,16 @@
1
- import { n as e, t } from "./wikilink-BFpTehto.js";
1
+ import { n as e, t } from "./wikilink-CTR8IFKc.js";
2
2
  import { useEffect as n, useRef as r } from "react";
3
3
  import { EditorView as i, keymap as a, placeholder as o } from "@codemirror/view";
4
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 m, 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 { openSearchPanel as b, search as x, searchKeymap as te } from "@codemirror/search";
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 x } from "@codemirror/search";
8
8
  import { HighlightStyle as ne, syntaxHighlighting as re, syntaxTree as ie } from "@codemirror/language";
9
9
  import { tags as S } from "@lezer/highlight";
10
+ import { autocompletion as ae } from "@codemirror/autocomplete";
10
11
  //#region src/editor/save.ts
11
12
  var C = f.define({ combine: (e) => e[0] ?? null });
12
- function ae(e) {
13
+ function oe(e) {
13
14
  let t = e.state.facet(C);
14
15
  return t ? (t(e.state.doc.toString()), !0) : !1;
15
16
  }
@@ -19,7 +20,7 @@ function w(e) {
19
20
  let { from: t, to: n } = e.selection.main;
20
21
  return [e.doc.lineAt(t).number, e.doc.lineAt(n).number];
21
22
  }
22
- function oe(e, t) {
23
+ function se(e, t) {
23
24
  let n = "#".repeat(t) + " ", r = e.state, [i, a] = w(r), o = [];
24
25
  for (let e = i; e <= a; e++) {
25
26
  let i = r.doc.line(e), a = /^(#{1,6}) +/.exec(i.text);
@@ -40,7 +41,7 @@ function oe(e, t) {
40
41
  scrollIntoView: !0
41
42
  }), e.focus(), !0;
42
43
  }
43
- function se(e) {
44
+ function ce(e) {
44
45
  let t = e.state, [n, r] = w(t), i = [];
45
46
  for (let e = n; e <= r; e++) {
46
47
  let n = t.doc.line(e), r = /^#{1,6} +/.exec(n.text);
@@ -54,7 +55,7 @@ function se(e) {
54
55
  scrollIntoView: !0
55
56
  }), e.focus(), !0) : !1;
56
57
  }
57
- function ce(e, t) {
58
+ function le(e, t) {
58
59
  let n = e.state, [r, i] = w(n), a = r === i && !n.doc.line(r).text.trim(), o = !a;
59
60
  for (let e = r; e <= i && o; e++) {
60
61
  let r = n.doc.line(e).text;
@@ -92,13 +93,13 @@ function ce(e, t) {
92
93
  scrollIntoView: !0
93
94
  }), e.focus(), !0) : !1;
94
95
  }
95
- function le(e, t) {
96
+ function ue(e, t) {
96
97
  return t.test(e.doc.lineAt(e.selection.main.head).text);
97
98
  }
98
- var ue = /^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/;
99
- function de(e) {
99
+ var de = /^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/;
100
+ function fe(e) {
100
101
  let t = e.state, n = t.doc.lineAt(t.selection.main.head);
101
- return ue.test(n.text) ? e.dispatch({
102
+ return de.test(n.text) ? e.dispatch({
102
103
  changes: {
103
104
  from: n.from,
104
105
  to: Math.min(n.to + 1, t.doc.length)
@@ -121,10 +122,10 @@ function de(e) {
121
122
  scrollIntoView: !0
122
123
  }), e.focus(), !0;
123
124
  }
124
- function fe(e) {
125
- return ue.test(e.doc.lineAt(e.selection.main.head).text);
125
+ function pe(e) {
126
+ return de.test(e.doc.lineAt(e.selection.main.head).text);
126
127
  }
127
- function pe(t) {
128
+ function me(t) {
128
129
  let n = t.state, r = e(n.doc);
129
130
  if (r) {
130
131
  let e = n.doc.lineAt(r.from), i = n.doc.lineAt(r.to);
@@ -154,7 +155,7 @@ function pe(t) {
154
155
  }
155
156
  return t.focus(), !0;
156
157
  }
157
- function me(t) {
158
+ function he(t) {
158
159
  return e(t.doc) !== null;
159
160
  }
160
161
  //#endregion
@@ -162,7 +163,7 @@ function me(t) {
162
163
  function T(e) {
163
164
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
164
165
  }
165
- function he(e, t, n) {
166
+ function ge(e, t, n) {
166
167
  let r = t, i = t;
167
168
  if (n < 0) for (; r > 0 && "*~`$".includes(e[r - 1]);) r--;
168
169
  else for (; i < e.length && "*~`$".includes(e[i]);) i++;
@@ -171,7 +172,7 @@ function he(e, t, n) {
171
172
  from: r
172
173
  };
173
174
  }
174
- function ge(e, t) {
175
+ function _e(e, t) {
175
176
  let n = [];
176
177
  for (let r = 0; r < e.length;) {
177
178
  if (e[r] !== t) {
@@ -187,15 +188,15 @@ function ge(e, t) {
187
188
  }
188
189
  return n;
189
190
  }
190
- function _e(e, t, n) {
191
+ function ve(e, t, n) {
191
192
  return e < n || t < n ? !1 : n > 1 || e % 2 == 1 && t % 2 == 1;
192
193
  }
193
- function ve(e, t, n, r) {
194
+ function ye(e, t, n, r) {
194
195
  let i = r.length, a = r[0], o = e.slice(t, n), s = 0;
195
196
  for (; o[s] === a;) s++;
196
197
  let c = 0;
197
198
  for (; o[o.length - 1 - c] === a;) c++;
198
- if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) && _e(s, c, i)) return {
199
+ if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) && ve(s, c, i)) return {
199
200
  changes: [{
200
201
  from: t,
201
202
  to: t + i,
@@ -208,10 +209,10 @@ function ve(e, t, n, r) {
208
209
  from: t,
209
210
  to: n - 2 * i
210
211
  };
211
- let l = he(e, t, -1), u = he(e, n, 1), d = ge(l.text, a), f = ge(u.text, a).reverse();
212
+ let l = ge(e, t, -1), u = ge(e, n, 1), d = _e(l.text, a), f = _e(u.text, a).reverse();
212
213
  for (let e = 0; e < Math.min(d.length, f.length); e++) {
213
214
  let r = d[e], a = f[e];
214
- if (!_e(r.len, a.len, i)) continue;
215
+ if (!ve(r.len, a.len, i)) continue;
215
216
  let o = l.from + r.start + r.len, s = n + a.start;
216
217
  return {
217
218
  changes: [{
@@ -241,26 +242,26 @@ function ve(e, t, n, r) {
241
242
  to: n + i
242
243
  };
243
244
  }
244
- function ye(e, t) {
245
+ function be(e, t) {
245
246
  let n = e;
246
247
  for (let e of [...t].sort((e, t) => t.from - e.from)) n = n.slice(0, e.from) + e.insert + n.slice(e.to);
247
248
  return n;
248
249
  }
249
250
  function E(e, t, n, r) {
250
- let i = ve(e, t, n, r);
251
+ let i = ye(e, t, n, r);
251
252
  return {
252
- text: ye(e, i.changes),
253
+ text: be(e, i.changes),
253
254
  from: i.from,
254
255
  to: i.to
255
256
  };
256
257
  }
257
- function be(e, t) {
258
+ function xe(e, t) {
258
259
  let n = D(e, t);
259
260
  if (n) return {
260
261
  from: n.from,
261
262
  to: n.to
262
263
  };
263
- let r = k(e, t);
264
+ let r = A(e, t);
264
265
  if (r) return {
265
266
  from: r.from,
266
267
  to: r.to
@@ -296,7 +297,7 @@ function D(e, t) {
296
297
  }
297
298
  return null;
298
299
  }
299
- function xe(e, t) {
300
+ function Se(e, t) {
300
301
  let n = /\[([^\]]*)\]\(([^)]*)\)/g;
301
302
  for (let r; r = n.exec(e);) {
302
303
  let e = r.index, n = e + r[0].length;
@@ -314,7 +315,7 @@ function xe(e, t) {
314
315
  }
315
316
  return null;
316
317
  }
317
- function Se(e, t, n) {
318
+ function Ce(e, t, n) {
318
319
  let r = D(e, t);
319
320
  if (r) return {
320
321
  text: e.slice(0, r.from) + r.label + e.slice(r.to),
@@ -328,7 +329,7 @@ function Se(e, t, n) {
328
329
  to: a + 3
329
330
  };
330
331
  }
331
- function Ce(e, t) {
332
+ function we(e, t) {
332
333
  let n = /<u>([\s\S]*?)<\/u>/gi;
333
334
  for (let r; r = n.exec(e);) {
334
335
  let e = r.index, n = e + r[0].length;
@@ -340,8 +341,8 @@ function Ce(e, t) {
340
341
  }
341
342
  return null;
342
343
  }
343
- function we(e, t, n) {
344
- let r = Ce(e, t);
344
+ function O(e, t, n) {
345
+ let r = we(e, t);
345
346
  if (r) return {
346
347
  text: e.slice(0, r.from) + r.inner + e.slice(r.to),
347
348
  from: r.from,
@@ -354,7 +355,7 @@ function we(e, t, n) {
354
355
  to: t + 3 + i.length
355
356
  };
356
357
  }
357
- function O(e, n) {
358
+ function k(e, n) {
358
359
  for (let r of e.matchAll(t)) {
359
360
  let e = r.index ?? 0, t = e + r[0].length;
360
361
  if (n >= e && n <= t) return {
@@ -365,7 +366,7 @@ function O(e, n) {
365
366
  }
366
367
  return null;
367
368
  }
368
- function k(e, n) {
369
+ function A(e, n) {
369
370
  for (let r of e.matchAll(t)) {
370
371
  let e = r.index ?? 0, t = e + r[0].length;
371
372
  if (n < e || n > t) continue;
@@ -382,7 +383,7 @@ function k(e, n) {
382
383
  return null;
383
384
  }
384
385
  function Te(e, t, n) {
385
- let r = O(e, t);
386
+ let r = k(e, t);
386
387
  if (r) return {
387
388
  text: e.slice(0, r.from) + r.label + e.slice(r.to),
388
389
  from: r.from,
@@ -398,7 +399,7 @@ function Te(e, t, n) {
398
399
  //#endregion
399
400
  //#region src/inplace/table-cell-dom.ts
400
401
  var Ee = (e) => [e.head, ...e.body].map((e) => [...e]), De = (e) => e.map((e) => e.map((e) => e.trim())), Oe = (e) => e.replace(/\\\|/g, "|");
401
- function A(e, t) {
402
+ function j(e, t) {
402
403
  let n = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), r = 0;
403
404
  for (let e = n.nextNode(); e; e = n.nextNode()) {
404
405
  if (e === t) return r;
@@ -408,10 +409,10 @@ function A(e, t) {
408
409
  }
409
410
  function ke(e) {
410
411
  let t = e.ownerDocument.getSelection(), n = t?.anchorNode;
411
- return !n || !e.contains(n) ? 0 : n.nodeType === Node.TEXT_NODE ? A(e, n) + (t?.anchorOffset ?? 0) : (t?.anchorOffset ?? 0) > 0 ? (e.textContent ?? "").length : 0;
412
+ return !n || !e.contains(n) ? 0 : n.nodeType === Node.TEXT_NODE ? j(e, n) + (t?.anchorOffset ?? 0) : (t?.anchorOffset ?? 0) > 0 ? (e.textContent ?? "").length : 0;
412
413
  }
413
414
  function Ae(e) {
414
- let t = e.ownerDocument.getSelection(), n = (e.textContent ?? "").length, r = (t, r) => !t || !e.contains(t) ? n : t.nodeType === Node.TEXT_NODE ? A(e, t) + r : r > 0 ? n : 0;
415
+ let t = e.ownerDocument.getSelection(), n = (e.textContent ?? "").length, r = (t, r) => !t || !e.contains(t) ? n : t.nodeType === Node.TEXT_NODE ? j(e, t) + r : r > 0 ? n : 0;
415
416
  if (!t || t.rangeCount === 0) return {
416
417
  from: n,
417
418
  to: n
@@ -431,18 +432,18 @@ function je(e, t, n) {
431
432
  let e = r.caretRangeFromPoint(t, n);
432
433
  e && ([i, a] = [e.startContainer, e.startOffset]);
433
434
  }
434
- return !i || !e.contains(i) ? 0 : A(e, i) + (i.nodeType === Node.TEXT_NODE ? a : 0);
435
+ return !i || !e.contains(i) ? 0 : j(e, i) + (i.nodeType === Node.TEXT_NODE ? a : 0);
435
436
  }
436
437
  var Me = /[\p{L}\p{N}_]/u;
437
438
  function Ne(e, t, n) {
438
- let r = e.textContent ?? "", i = je(e, t, n), a = be(r, i);
439
- if (a) return j(e, a.from, a.to), !0;
439
+ let r = e.textContent ?? "", i = je(e, t, n), a = xe(r, i);
440
+ if (a) return M(e, a.from, a.to), !0;
440
441
  let o = i, s = i;
441
442
  for (; o > 0 && Me.test(r[o - 1]);) o--;
442
443
  for (; s < r.length && Me.test(r[s]);) s++;
443
- return s <= o ? !1 : (j(e, o, s), !0);
444
+ return s <= o ? !1 : (M(e, o, s), !0);
444
445
  }
445
- function j(e, t, n = t) {
446
+ function M(e, t, n = t) {
446
447
  e.focus();
447
448
  let r = e.ownerDocument, i = r.createRange(), a = e.firstChild;
448
449
  if (a && a.nodeType === Node.TEXT_NODE) {
@@ -459,29 +460,29 @@ function Pe(e) {
459
460
  let t = e.dom.ownerDocument.activeElement;
460
461
  return !(t instanceof HTMLElement) || !e.dom.contains(t) ? null : t.matches(".cm-inplace-tcell") ? t : null;
461
462
  }
462
- function Fe(e, t) {
463
+ function N(e, t) {
463
464
  let { from: n, to: r } = Ae(e), i = t(e.textContent ?? "", n, r);
464
- e.textContent = i.text, j(e, i.from, i.to), e.dispatchEvent(new Event("input", { bubbles: !0 }));
465
+ e.textContent = i.text, M(e, i.from, i.to), e.dispatchEvent(new Event("input", { bubbles: !0 }));
465
466
  }
466
- function M(e, t) {
467
+ function P(e, t) {
467
468
  let n = Pe(e);
468
- return n ? (Fe(n, t), !0) : !1;
469
+ return n ? (N(n, t), !0) : !1;
469
470
  }
470
- var Ie = {
471
+ var Fe = {
471
472
  b: (e, t, n) => E(e, t, n, "**"),
472
473
  i: (e, t, n) => E(e, t, n, "*"),
473
- u: we,
474
- k: Se,
474
+ u: O,
475
+ k: Ce,
475
476
  K: Te
476
477
  };
477
- function Le(e, t) {
478
+ function Ie(e, t) {
478
479
  if (!(e.metaKey || e.ctrlKey) || e.altKey) return !1;
479
- let n = Ie[e.shiftKey ? e.key.toUpperCase() : e.key.toLowerCase()];
480
- return n ? (e.preventDefault(), Fe(t, n), !0) : !1;
480
+ let n = Fe[e.shiftKey ? e.key.toUpperCase() : e.key.toLowerCase()];
481
+ return n ? (e.preventDefault(), N(t, n), !0) : !1;
481
482
  }
482
483
  //#endregion
483
484
  //#region src/toolbar/fence.ts
484
- function N(e, t) {
485
+ function F(e, t) {
485
486
  for (let n = ie(e).resolveInner(t, 0); n; n = n.parent) {
486
487
  if (n.name === "FencedCode") return {
487
488
  from: n.from,
@@ -491,8 +492,8 @@ function N(e, t) {
491
492
  }
492
493
  return null;
493
494
  }
494
- function Re(e) {
495
- let t = e.state, n = N(t, t.selection.main.head);
495
+ function Le(e) {
496
+ let t = e.state, n = F(t, t.selection.main.head);
496
497
  if (n) {
497
498
  let r = t.doc.lineAt(n.from), i = t.doc.lineAt(n.to), a = [{
498
499
  from: r.from,
@@ -521,11 +522,11 @@ function Re(e) {
521
522
  }
522
523
  return e.focus(), !0;
523
524
  }
524
- function P(e) {
525
- return N(e, e.selection.main.head) !== null;
525
+ function I(e) {
526
+ return F(e, e.selection.main.head) !== null;
526
527
  }
527
- function ze(e) {
528
- let t = N(e, e.selection.main.head);
528
+ function Re(e) {
529
+ let t = F(e, e.selection.main.head);
529
530
  if (!t) return null;
530
531
  let n = e.doc.lineAt(t.from), r = /^(\s*(?:`{3,}|~{3,})[ \t]*)(.*?)[ \t]*$/.exec(n.text);
531
532
  if (!r) return null;
@@ -536,10 +537,10 @@ function ze(e) {
536
537
  lang: r[2]
537
538
  };
538
539
  }
539
- var Be = /^\s*\$\$\s*$/;
540
- function F(e, t) {
540
+ var ze = /^\s*\$\$\s*$/;
541
+ function Be(e, t) {
541
542
  let n = 0, r = 0;
542
- for (let i = 1; i <= e.doc.lines; i++) if (Be.test(e.doc.line(i).text)) {
543
+ for (let i = 1; i <= e.doc.lines; i++) if (ze.test(e.doc.line(i).text)) {
543
544
  if (r++, r % 2 == 1) {
544
545
  if (n = i, i > t) return null;
545
546
  } else if (i >= t) return [n, i];
@@ -547,7 +548,7 @@ function F(e, t) {
547
548
  return null;
548
549
  }
549
550
  function Ve(e) {
550
- let t = e.state, [n, r] = w(t), i = F(t, t.doc.lineAt(t.selection.main.head).number);
551
+ let t = e.state, [n, r] = w(t), i = Be(t, t.doc.lineAt(t.selection.main.head).number);
551
552
  if (i) {
552
553
  let n = t.doc.line(i[0]), r = t.doc.line(i[1]);
553
554
  e.dispatch({
@@ -573,16 +574,16 @@ function Ve(e) {
573
574
  });
574
575
  return e.focus(), !0;
575
576
  }
576
- function I(e) {
577
- return F(e, e.doc.lineAt(e.selection.main.head).number) !== null;
577
+ function L(e) {
578
+ return Be(e, e.doc.lineAt(e.selection.main.head).number) !== null;
578
579
  }
579
580
  //#endregion
580
581
  //#region src/toolbar/inline.ts
581
- function L(e, t) {
582
+ function R(e, t) {
582
583
  let n = e.state.doc.toString();
583
584
  return e.dispatch({
584
585
  ...e.state.changeByRange((e) => {
585
- let r = ve(n, e.from, e.to, t);
586
+ let r = ye(n, e.from, e.to, t);
586
587
  return {
587
588
  changes: r.changes,
588
589
  range: r.from === r.to ? u.cursor(r.from) : u.range(r.from, r.to)
@@ -591,7 +592,7 @@ function L(e, t) {
591
592
  scrollIntoView: !0
592
593
  }), e.focus(), !0;
593
594
  }
594
- function R(e, t) {
595
+ function z(e, t) {
595
596
  let n = e.selection.main, r = e.doc.lineAt(n.head), i = RegExp(T(t) + "(?!\\s)(?:[^]*?\\S)??" + T(t), "g");
596
597
  for (let e; e = i.exec(r.text);) {
597
598
  if (e[0].length <= 2 * t.length || t === "$" && (r.text[e.index - 1] === "$" || r.text[e.index + e[0].length] === "$")) continue;
@@ -634,7 +635,7 @@ function We(e) {
634
635
  return He(e) !== null;
635
636
  }
636
637
  function Ge(e) {
637
- let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = O(n.text, t - n.from);
638
+ let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = k(n.text, t - n.from);
638
639
  return r ? {
639
640
  from: n.from + r.from,
640
641
  to: n.from + r.to,
@@ -667,7 +668,7 @@ function qe(e) {
667
668
  return Ge(e) !== null;
668
669
  }
669
670
  function Je(e) {
670
- let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = Ce(n.text, t - n.from);
671
+ let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = we(n.text, t - n.from);
671
672
  return r ? {
672
673
  from: n.from + r.from,
673
674
  to: n.from + r.to,
@@ -716,7 +717,7 @@ function $e(e) {
716
717
  let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
717
718
  return n && r ? "center" : r ? "right" : n ? "left" : "";
718
719
  }
719
- function z(e) {
720
+ function B(e) {
720
721
  if (e.length < 2 || !Ze(e[1])) return null;
721
722
  let t = Qe(e[1]).map($e), n = e.filter((e, t) => t !== 1).map(Qe), r = Math.max(t.length, ...n.map((e) => e.length)), i = n.map((e) => {
722
723
  let t = e.slice(0, r);
@@ -746,7 +747,7 @@ function nt(e, t) {
746
747
  let n = Math.max(3, e);
747
748
  return t === "left" ? ":" + "-".repeat(n - 1) : t === "right" ? "-".repeat(n - 1) + ":" : t === "center" ? ":" + "-".repeat(n - 2) + ":" : "-".repeat(n);
748
749
  }
749
- function B(e) {
750
+ function V(e) {
750
751
  let t = e.aligns.length, n = [];
751
752
  for (let r = 0; r < t; r++) {
752
753
  let t = 3;
@@ -781,7 +782,7 @@ function rt(e) {
781
782
  }
782
783
  //#endregion
783
784
  //#region src/toolbar/table.ts
784
- function V(e, t) {
785
+ function H(e, t) {
785
786
  let n = e.lineAt(t);
786
787
  if (!n.text.includes("|")) return null;
787
788
  let r = n.number;
@@ -799,7 +800,7 @@ function V(e, t) {
799
800
  if (i - r < 1) return null;
800
801
  let a = [];
801
802
  for (let t = r; t <= i; t++) a.push(e.line(t).text);
802
- return z(a) ? {
803
+ return B(a) ? {
803
804
  from: e.line(r).from,
804
805
  to: e.line(i).to,
805
806
  lines: a
@@ -835,15 +836,15 @@ function it(e, t, n) {
835
836
  }
836
837
  return null;
837
838
  }
838
- function H(e, t, n) {
839
+ function U(e, t, n) {
839
840
  let r = e.split("\n"), i = n.onDelimiter ? 1 : n.row === 0 ? 0 : n.row + 1, a = t;
840
841
  for (let e = 0; e < i; e++) a += r[e].length + 1;
841
842
  let o = rt(r[i]), s = o[Math.min(n.col, o.length - 1)];
842
843
  return s ? a + s.contentStart + Math.min(n.offset, s.contentEnd - s.contentStart) : a;
843
844
  }
844
845
  function at(e, t, n, r) {
845
- let i = V(e, t);
846
- return i ? H(i.lines.join("\n"), i.from, {
846
+ let i = H(e, t);
847
+ return i ? U(i.lines.join("\n"), i.from, {
847
848
  row: n,
848
849
  col: r,
849
850
  offset: 0,
@@ -882,24 +883,24 @@ function st(e) {
882
883
  scrollIntoView: !0
883
884
  }), e.focus(), ot(e, a), !0;
884
885
  }
885
- function U(e) {
886
- return V(e.doc, e.selection.main.head) !== null;
886
+ function W(e) {
887
+ return H(e.doc, e.selection.main.head) !== null;
887
888
  }
888
- function W(e, t) {
889
- let n = V(e.state.doc, e.state.selection.main.head);
889
+ function G(e, t) {
890
+ let n = H(e.state.doc, e.state.selection.main.head);
890
891
  if (!n) return !1;
891
- let r = z(n.lines), i = it(n.lines, n.from, e.state.selection.main.head);
892
+ let r = B(n.lines), i = it(n.lines, n.from, e.state.selection.main.head);
892
893
  if (!r || !i) return !1;
893
894
  let a = t(r, i);
894
895
  if (!a) return !1;
895
- let o = B(r);
896
+ let o = V(r);
896
897
  return e.dispatch({
897
898
  changes: {
898
899
  from: n.from,
899
900
  to: n.to,
900
901
  insert: o
901
902
  },
902
- selection: u.cursor(H(o, n.from, a)),
903
+ selection: u.cursor(U(o, n.from, a)),
903
904
  scrollIntoView: !0
904
905
  }), e.focus(), !0;
905
906
  }
@@ -924,23 +925,23 @@ function lt(e, t) {
924
925
  var ut = a.of([
925
926
  {
926
927
  key: "Tab",
927
- run: (e) => W(e, (e, t) => ct(e, t, 1))
928
+ run: (e) => G(e, (e, t) => ct(e, t, 1))
928
929
  },
929
930
  {
930
931
  key: "Shift-Tab",
931
- run: (e) => W(e, (e, t) => ct(e, t, -1))
932
+ run: (e) => G(e, (e, t) => ct(e, t, -1))
932
933
  },
933
934
  {
934
935
  key: "Enter",
935
- run: (e) => W(e, lt)
936
+ run: (e) => G(e, lt)
936
937
  }
937
938
  ]), dt = d.transactionFilter.of((e) => {
938
939
  if (!e.docChanged || !e.isUserEvent("input") && !e.isUserEvent("delete")) return e;
939
- let t = e.newSelection.main.head, n = V(e.newDoc, t);
940
+ let t = e.newSelection.main.head, n = H(e.newDoc, t);
940
941
  if (!n) return e;
941
- let r = z(n.lines);
942
+ let r = B(n.lines);
942
943
  if (!r) return e;
943
- let i = B(r);
944
+ let i = V(r);
944
945
  if (i === n.lines.join("\n")) return e;
945
946
  let a = it(n.lines, n.from, t), o = c.of([{
946
947
  from: n.from,
@@ -949,28 +950,28 @@ var ut = a.of([
949
950
  }], e.newDoc.length);
950
951
  return {
951
952
  changes: e.changes.compose(o),
952
- selection: a ? u.cursor(H(i, n.from, a)) : e.newSelection,
953
+ selection: a ? u.cursor(U(i, n.from, a)) : e.newSelection,
953
954
  effects: e.effects,
954
955
  scrollIntoView: e.scrollIntoView
955
956
  };
956
- }), G = (e) => /^\s{0,3}#{1,6}(?:\s|$)/.test(e.doc.lineAt(e.selection.main.head).text), K = (t) => {
957
+ }), K = (e) => /^\s{0,3}#{1,6}(?:\s|$)/.test(e.doc.lineAt(e.selection.main.head).text), q = (t) => {
957
958
  let n = e(t.doc);
958
959
  return n !== null && t.selection.main.head <= n.to;
959
- }, q = (e) => K(e) || P(e) || I(e), ft = (e) => (t) => e !== "`" && R(t, "`") || e !== "$" && R(t, "$"), pt = (e) => e.selection.main.empty && !e.wordAt(e.selection.main.head), J = (...e) => (t) => e.some((e) => e(t)), Y = /^(\s*)(?:[-*+] \[[ xX]\] +|\d+\. +|[-*+] +)/, mt = {
960
+ }, J = (e) => q(e) || I(e) || L(e), ft = (e) => (t) => e !== "`" && z(t, "`") || e !== "$" && z(t, "$"), pt = (e) => e.selection.main.empty && !e.wordAt(e.selection.main.head), Y = (...e) => (t) => e.some((e) => e(t)), X = /^(\s*)(?:[-*+] \[[ xX]\] +|\d+\. +|[-*+] +)/, mt = {
960
961
  match: /^ {0,3}> ?/,
961
962
  insert: "> "
962
963
  }, ht = {
963
964
  match: /^(\s*)[-*+] +(?!\[[ xX]\])/,
964
965
  insert: "- ",
965
- siblings: Y
966
+ siblings: X
966
967
  }, gt = {
967
968
  match: /^(\s*)\d+\. +/,
968
969
  insert: (e) => `${e + 1}. `,
969
- siblings: Y
970
+ siblings: X
970
971
  }, _t = {
971
972
  match: /^(\s*)[-*+] \[[ xX]\] +/,
972
973
  insert: "- [ ] ",
973
- siblings: Y
974
+ siblings: X
974
975
  };
975
976
  function vt(e, t, n) {
976
977
  return {
@@ -982,44 +983,44 @@ function vt(e, t, n) {
982
983
  }
983
984
  };
984
985
  }
985
- function X(e, t, n, r) {
986
+ function Z(e, t, n, r) {
986
987
  return {
987
988
  id: e,
988
989
  title: t,
989
- run: (e) => M(e, (e, t, r) => E(e, t, r, n)) || L(e, n),
990
- isActive: (e) => R(e, n),
991
- disabled: J(q, ft(n), pt),
990
+ run: (e) => P(e, (e, t, r) => E(e, t, r, n)) || R(e, n),
991
+ isActive: (e) => z(e, n),
992
+ disabled: Y(J, ft(n), pt),
992
993
  keys: r
993
994
  };
994
995
  }
995
- function Z(e) {
996
+ function Q(e) {
996
997
  let t = RegExp(`^#{${e}} `);
997
998
  return {
998
999
  id: `h${e}`,
999
1000
  title: `Heading ${e}`,
1000
- run: (t) => oe(t, e),
1001
+ run: (t) => se(t, e),
1001
1002
  isActive: (e) => t.test(e.doc.lineAt(e.selection.main.head).text),
1002
- disabled: J(U, q),
1003
+ disabled: Y(W, J),
1003
1004
  keys: [`Mod-Alt-${e}`]
1004
1005
  };
1005
1006
  }
1006
- function Q(e, t, n, ...r) {
1007
+ function $(e, t, n, ...r) {
1007
1008
  return {
1008
1009
  id: e,
1009
1010
  title: t,
1010
- run: (e) => ce(e, n),
1011
- isActive: (e) => le(e, n.match),
1012
- disabled: J(U, q, ...r)
1011
+ run: (e) => le(e, n),
1012
+ isActive: (e) => ue(e, n.match),
1013
+ disabled: Y(W, J, ...r)
1013
1014
  };
1014
1015
  }
1015
1016
  var yt = [
1016
- vt("undo", "Undo", _),
1017
- vt("redo", "Redo", g),
1017
+ vt("undo", "Undo", g),
1018
+ vt("redo", "Redo", h),
1018
1019
  {
1019
1020
  id: "save",
1020
1021
  title: "Save",
1021
1022
  run: (e) => {
1022
- let t = ae(e);
1023
+ let t = oe(e);
1023
1024
  return e.focus(), t;
1024
1025
  },
1025
1026
  disabled: (e) => e.facet(C) == null
@@ -1027,86 +1028,86 @@ var yt = [
1027
1028
  {
1028
1029
  id: "search",
1029
1030
  title: "Find / replace",
1030
- run: (e) => b(e),
1031
+ run: (e) => y(e),
1031
1032
  keys: ["Mod-f"]
1032
1033
  },
1033
- Z(1),
1034
- Z(2),
1035
- Z(3),
1034
+ Q(1),
1035
+ Q(2),
1036
+ Q(3),
1036
1037
  {
1037
1038
  id: "body",
1038
1039
  title: "Body",
1039
- run: (e) => (se(e) || e.focus(), !0),
1040
+ run: (e) => (ce(e) || e.focus(), !0),
1040
1041
  isActive: (e) => !/^#{1,6} /.test(e.doc.lineAt(e.selection.main.head).text),
1041
- disabled: J(U, q)
1042
+ disabled: Y(W, J)
1042
1043
  },
1043
- X("bold", "Bold", "**", ["Mod-b"]),
1044
- X("italic", "Italic", "*", ["Mod-i"]),
1045
- X("strike", "Strikethrough", "~~"),
1044
+ Z("bold", "Bold", "**", ["Mod-b"]),
1045
+ Z("italic", "Italic", "*", ["Mod-i"]),
1046
+ Z("strike", "Strikethrough", "~~"),
1046
1047
  {
1047
1048
  id: "underline",
1048
1049
  title: "Underline",
1049
- run: (e) => M(e, we) || Ye(e),
1050
+ run: (e) => P(e, O) || Ye(e),
1050
1051
  isActive: Xe,
1051
- disabled: J(q, ft("u"), pt),
1052
+ disabled: Y(J, ft("u"), pt),
1052
1053
  keys: ["Mod-u"]
1053
1054
  },
1054
- X("code", "Inline code", "`"),
1055
+ Z("code", "Inline code", "`"),
1055
1056
  {
1056
1057
  id: "codeBlock",
1057
1058
  title: "Code block",
1058
- run: (e) => M(e, (e, t, n) => E(e, t, n, "`")) || (U(e.state) ? L(e, "`") : Re(e)),
1059
- isActive: (e) => U(e) ? R(e, "`") : P(e),
1060
- disabled: J(K, I, G)
1059
+ run: (e) => P(e, (e, t, n) => E(e, t, n, "`")) || (W(e.state) ? R(e, "`") : Le(e)),
1060
+ isActive: (e) => W(e) ? z(e, "`") : I(e),
1061
+ disabled: Y(q, L, K)
1061
1062
  },
1062
1063
  {
1063
1064
  id: "link",
1064
1065
  title: "Link",
1065
- run: (e) => M(e, Se) || Ue(e),
1066
+ run: (e) => P(e, Ce) || Ue(e),
1066
1067
  isActive: We,
1067
- disabled: q,
1068
+ disabled: J,
1068
1069
  keys: ["Mod-k"]
1069
1070
  },
1070
1071
  {
1071
1072
  id: "wikilink",
1072
1073
  title: "Wikilink",
1073
- run: (e) => M(e, Te) || Ke(e),
1074
+ run: (e) => P(e, Te) || Ke(e),
1074
1075
  isActive: qe,
1075
- disabled: q,
1076
+ disabled: J,
1076
1077
  keys: ["Mod-Shift-k"]
1077
1078
  },
1078
- Q("quote", "Blockquote", mt),
1079
- Q("bulletList", "Bulleted list", ht, G),
1080
- Q("orderedList", "Numbered list", gt, G),
1081
- Q("task", "Task list", _t, G),
1079
+ $("quote", "Blockquote", mt),
1080
+ $("bulletList", "Bulleted list", ht, K),
1081
+ $("orderedList", "Numbered list", gt, K),
1082
+ $("task", "Task list", _t, K),
1082
1083
  {
1083
1084
  id: "hr",
1084
1085
  title: "Divider",
1085
- run: de,
1086
- isActive: fe,
1087
- disabled: J(U, q)
1086
+ run: fe,
1087
+ isActive: pe,
1088
+ disabled: Y(W, J)
1088
1089
  },
1089
1090
  {
1090
1091
  id: "frontmatter",
1091
1092
  title: "Frontmatter",
1092
- run: pe,
1093
- isActive: me,
1094
- disabled: J(U, P, I, G)
1093
+ run: me,
1094
+ isActive: he,
1095
+ disabled: Y(W, I, L, K)
1095
1096
  },
1096
1097
  {
1097
1098
  id: "table",
1098
1099
  title: "Table",
1099
1100
  run: st,
1100
- isActive: U,
1101
- disabled: J(U, K, P, I, G)
1101
+ isActive: W,
1102
+ disabled: Y(W, q, I, L, K)
1102
1103
  },
1103
- X("math", "Inline math", "$"),
1104
+ Z("math", "Inline math", "$"),
1104
1105
  {
1105
1106
  id: "mathBlock",
1106
1107
  title: "Block math",
1107
- run: (e) => M(e, (e, t, n) => E(e, t, n, "$")) || (U(e.state) ? L(e, "$") : Ve(e)),
1108
- isActive: (e) => U(e) ? R(e, "$") : I(e),
1109
- disabled: J(K, P, G)
1108
+ run: (e) => P(e, (e, t, n) => E(e, t, n, "$")) || (W(e.state) ? R(e, "$") : Ve(e)),
1109
+ isActive: (e) => W(e) ? z(e, "$") : L(e),
1110
+ disabled: Y(q, I, K)
1110
1111
  }
1111
1112
  ], bt = Object.fromEntries(yt.map((e) => [e.id, e])), xt = p.high(a.of(yt.filter((e) => e.keys && e.keys.length > 0).flatMap((e) => e.keys.map((t) => ({
1112
1113
  key: t,
@@ -1200,10 +1201,10 @@ var yt = [
1200
1201
  "&": {
1201
1202
  color: "var(--stylo-text)",
1202
1203
  backgroundColor: "var(--stylo-bg)",
1203
- fontSize: "0.9375rem"
1204
+ fontSize: "var(--stylo-font-size, 0.9375rem)"
1204
1205
  },
1205
1206
  ".cm-content": {
1206
- fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
1207
+ fontFamily: "var(--stylo-font-family-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)",
1207
1208
  padding: "0.75rem 0",
1208
1209
  caretColor: "var(--stylo-text)"
1209
1210
  },
@@ -1262,28 +1263,63 @@ var yt = [
1262
1263
  backgroundColor: "color-mix(in srgb, var(--stylo-ring) 70%, transparent)",
1263
1264
  outline: "1px solid var(--stylo-ring)"
1264
1265
  }
1265
- });
1266
+ }), Tt = /\[\[([^[\]\n|]*)$/;
1267
+ function Et(e) {
1268
+ let t = e.label && e.label !== e.target ? e.label : void 0, n = t ? `${e.target}|${t}` : e.target;
1269
+ return {
1270
+ label: e.label ?? e.target,
1271
+ apply: (e, t, r, i) => {
1272
+ let a = e.state.sliceDoc(i, i + 2) === "]]";
1273
+ e.dispatch({
1274
+ changes: {
1275
+ from: r,
1276
+ to: i,
1277
+ insert: a ? n : `${n}]]`
1278
+ },
1279
+ selection: { anchor: r + n.length + 2 },
1280
+ userEvent: "input.complete"
1281
+ });
1282
+ }
1283
+ };
1284
+ }
1285
+ function Dt(e) {
1286
+ return async (t) => {
1287
+ let n = t.matchBefore(Tt);
1288
+ if (!n || n.from + 2 === t.pos && !t.explicit) return null;
1289
+ let r = (await e(n.text.slice(2))).map(Et);
1290
+ return r.length ? {
1291
+ from: n.from + 2,
1292
+ to: t.pos,
1293
+ options: r,
1294
+ filter: !1
1295
+ } : null;
1296
+ };
1297
+ }
1298
+ function Ot(e) {
1299
+ return e ? [ae(), v.data.of({ autocomplete: Dt(e) })] : [];
1300
+ }
1266
1301
  //#endregion
1267
1302
  //#region src/editor/extensions.ts
1268
- function Tt(e) {
1303
+ function kt(e, t) {
1269
1304
  return [
1270
- m(),
1271
- a.of([...ee, ...h]),
1305
+ te(),
1306
+ a.of([...ee, ...m]),
1272
1307
  p.high(ut),
1273
1308
  xt,
1274
1309
  dt,
1275
- x({ top: !0 }),
1276
- a.of(te),
1277
- v({
1278
- base: y,
1310
+ b({ top: !0 }),
1311
+ a.of(x),
1312
+ _({
1313
+ base: v,
1279
1314
  codeLanguages: e
1280
1315
  }),
1281
1316
  Ct,
1317
+ Ot(t),
1282
1318
  i.lineWrapping,
1283
1319
  wt
1284
1320
  ];
1285
1321
  }
1286
- function Et(e) {
1322
+ function At(e) {
1287
1323
  return [
1288
1324
  d.readOnly.of(e.readOnly),
1289
1325
  i.editable.of(!e.readOnly),
@@ -1293,8 +1329,8 @@ function Et(e) {
1293
1329
  }
1294
1330
  //#endregion
1295
1331
  //#region src/editor/useCodeMirror.ts
1296
- var $ = s.define();
1297
- function Dt({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c, onViewChange: u, extensions: f, codeLanguages: ee }) {
1332
+ var jt = s.define();
1333
+ function Mt({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c, onViewChange: u, extensions: f, codeLanguages: ee, wikiLinkSource: te }) {
1298
1334
  let m = r(null), h = r(null), g = r(t);
1299
1335
  g.current = t;
1300
1336
  let _ = r(c);
@@ -1310,19 +1346,19 @@ function Dt({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c
1310
1346
  state: d.create({
1311
1347
  doc: e,
1312
1348
  extensions: [
1313
- Tt(ee),
1314
- x.current.of(Et({
1349
+ kt(ee, te),
1350
+ x.current.of(At({
1315
1351
  readOnly: o,
1316
1352
  placeholder: s,
1317
1353
  save: y ? v : void 0
1318
1354
  })),
1319
1355
  p.high(a.of([{
1320
1356
  key: "Mod-s",
1321
- run: ae
1357
+ run: oe
1322
1358
  }])),
1323
1359
  ...f ?? [],
1324
1360
  i.updateListener.of((e) => {
1325
- e.docChanged && (e.transactions.some((e) => !!e.annotation($)) || g.current(e.state.doc.toString()));
1361
+ e.docChanged && (e.transactions.some((e) => !!e.annotation(jt)) || g.current(e.state.doc.toString()));
1326
1362
  })
1327
1363
  ]
1328
1364
  })
@@ -1340,10 +1376,10 @@ function Dt({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c
1340
1376
  to: n.length,
1341
1377
  insert: e
1342
1378
  },
1343
- annotations: $.of(!0)
1379
+ annotations: jt.of(!0)
1344
1380
  });
1345
1381
  }, [e]), n(() => {
1346
- h.current?.dispatch({ effects: x.current.reconfigure(Et({
1382
+ h.current?.dispatch({ effects: x.current.reconfigure(At({
1347
1383
  readOnly: o,
1348
1384
  placeholder: s,
1349
1385
  save: y ? v : void 0
@@ -1356,6 +1392,6 @@ function Dt({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c
1356
1392
  ]), m;
1357
1393
  }
1358
1394
  //#endregion
1359
- export { Oe as _, B as a, k as b, Pe as c, je as d, j as f, De as g, Ae as h, z as i, Le as l, Ne as m, bt as n, ze as o, ke as p, at as r, P as s, Dt as t, Ee as u, xe as v, O as y };
1395
+ export { Oe as _, V as a, A as b, Pe as c, je as d, M as f, De as g, Ae as h, B as i, Ie as l, Ne as m, bt as n, Re as o, ke as p, at as r, I as s, Mt as t, Ee as u, Se as v, k as y };
1360
1396
 
1361
- //# sourceMappingURL=useCodeMirror-YnIFkvKn.js.map
1397
+ //# sourceMappingURL=useCodeMirror-GPSkaYW6.js.map