@damiro/stylo 0.19.0 → 0.20.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 (37) hide show
  1. package/dist/{InPlaceView-D2GIV1A-.js → InPlaceView-AZ_ufoP3.js} +634 -446
  2. package/dist/InPlaceView-AZ_ufoP3.js.map +1 -0
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/inplace/InPlaceView.d.ts.map +1 -1
  6. package/dist/inplace/config.d.ts +4 -2
  7. package/dist/inplace/config.d.ts.map +1 -1
  8. package/dist/inplace/context-menu-actions.d.ts +1 -1
  9. package/dist/inplace/context-menu-actions.d.ts.map +1 -1
  10. package/dist/inplace/extension.d.ts +4 -2
  11. package/dist/inplace/extension.d.ts.map +1 -1
  12. package/dist/inplace/host-cell.d.ts +5 -1
  13. package/dist/inplace/host-cell.d.ts.map +1 -1
  14. package/dist/inplace/host-items.d.ts +2 -0
  15. package/dist/inplace/host-items.d.ts.map +1 -1
  16. package/dist/inplace/selection-rect.d.ts +11 -0
  17. package/dist/inplace/selection-rect.d.ts.map +1 -0
  18. package/dist/inplace/table-cell-dom.d.ts +3 -2
  19. package/dist/inplace/table-cell-dom.d.ts.map +1 -1
  20. package/dist/inplace/table-cell-marks.d.ts +50 -0
  21. package/dist/inplace/table-cell-marks.d.ts.map +1 -0
  22. package/dist/inplace/table-marks-plugin.d.ts +12 -0
  23. package/dist/inplace/table-marks-plugin.d.ts.map +1 -0
  24. package/dist/inplace/table-widget-render.d.ts +6 -0
  25. package/dist/inplace/table-widget-render.d.ts.map +1 -1
  26. package/dist/inplace/table-widget.d.ts +8 -0
  27. package/dist/inplace/table-widget.d.ts.map +1 -1
  28. package/dist/stylo.js +2 -2
  29. package/dist/types/inplace.d.ts +26 -2
  30. package/dist/types/inplace.d.ts.map +1 -1
  31. package/dist/types.d.ts +1 -1
  32. package/dist/types.d.ts.map +1 -1
  33. package/dist/{useCodeMirror-Fn6qEfMx.js → useCodeMirror-DbhMZGZ7.js} +334 -322
  34. package/dist/useCodeMirror-DbhMZGZ7.js.map +1 -0
  35. package/package.json +1 -1
  36. package/dist/InPlaceView-D2GIV1A-.js.map +0 -1
  37. package/dist/useCodeMirror-Fn6qEfMx.js.map +0 -1
@@ -1,19 +1,19 @@
1
1
  import { l as e, o as t, s as n } from "./embed-cache-BU9Smn-h.js";
2
2
  import { useEffect as r, useRef as i } from "react";
3
3
  import { EditorView as a, keymap as o, placeholder as s, runScopeHandlers as c } from "@codemirror/view";
4
- import { Annotation as l, ChangeSet as u, Compartment as d, EditorSelection as f, EditorState as p, Facet as ee, Prec as m } from "@codemirror/state";
5
- import { defaultKeymap as te, history as ne, 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 re, closeSearchPanel as b, findNext as x, findPrevious as S, getSearchQuery as C, openSearchPanel as w, replaceAll as T, replaceNext as E, search as D, searchKeymap as ie, searchPanelOpen as ae, selectMatches as oe, setSearchQuery as se } from "@codemirror/search";
8
- import { syntaxTree as ce } from "@codemirror/language";
9
- import { autocompletion as le } from "@codemirror/autocomplete";
4
+ import { Annotation as l, ChangeSet as u, Compartment as d, EditorSelection as f, EditorState as p, Facet as ee, Prec as te } from "@codemirror/state";
5
+ import { defaultKeymap as ne, history as re, historyKeymap as m, redo as h, undo as g } from "@codemirror/commands";
6
+ import { markdown as ie, markdownLanguage as _ } from "@codemirror/lang-markdown";
7
+ import { SearchQuery as v, closeSearchPanel as y, findNext as b, findPrevious as x, getSearchQuery as S, openSearchPanel as C, replaceAll as w, replaceNext as T, search as E, searchKeymap as ae, searchPanelOpen as oe, selectMatches as se, setSearchQuery as ce } from "@codemirror/search";
8
+ import { syntaxTree as le } from "@codemirror/language";
9
+ import { autocompletion as ue } from "@codemirror/autocomplete";
10
10
  //#region src/editor/canvas-header-panel.ts
11
- var ue = "stylo-canvas-header", de = class {
11
+ var de = "stylo-canvas-header", fe = class {
12
12
  dom = null;
13
13
  listeners = /* @__PURE__ */ new Set();
14
14
  panel = () => {
15
15
  let e = document.createElement("div");
16
- return e.className = ue, this.dom = e, this.notify(), {
16
+ return e.className = de, this.dom = e, this.notify(), {
17
17
  dom: e,
18
18
  top: !0,
19
19
  destroy: () => {
@@ -29,7 +29,7 @@ var ue = "stylo-canvas-header", de = class {
29
29
  };
30
30
  //#endregion
31
31
  //#region src/toolbar/link-ops.ts
32
- function O(e, t) {
32
+ function D(e, t) {
33
33
  let n = /\[([^\]]*)\]\([^)]*\)/g;
34
34
  for (let r; r = n.exec(e);) {
35
35
  let e = r.index, n = e + r[0].length;
@@ -41,7 +41,7 @@ function O(e, t) {
41
41
  }
42
42
  return null;
43
43
  }
44
- function fe(e, t) {
44
+ function pe(e, t) {
45
45
  let n = /\[([^\]]*)\]\(([^)]*)\)/g;
46
46
  for (let r; r = n.exec(e);) {
47
47
  let e = r.index, n = e + r[0].length;
@@ -59,8 +59,8 @@ function fe(e, t) {
59
59
  }
60
60
  return null;
61
61
  }
62
- function pe(e, t, n) {
63
- let r = O(e, t);
62
+ function me(e, t, n) {
63
+ let r = D(e, t);
64
64
  if (r) return {
65
65
  text: e.slice(0, r.from) + r.label + e.slice(r.to),
66
66
  from: r.from,
@@ -75,7 +75,7 @@ function pe(e, t, n) {
75
75
  }
76
76
  //#endregion
77
77
  //#region src/toolbar/wikilink-ops.ts
78
- function me(t, n) {
78
+ function he(t, n) {
79
79
  for (let r of t.matchAll(e)) {
80
80
  let e = r.index ?? 0, t = e + r[0].length;
81
81
  if (n >= e && n <= t) return {
@@ -86,7 +86,7 @@ function me(t, n) {
86
86
  }
87
87
  return null;
88
88
  }
89
- function he(t, n) {
89
+ function ge(t, n) {
90
90
  for (let r of t.matchAll(e)) {
91
91
  let e = r.index ?? 0, t = e + r[0].length;
92
92
  if (n < e || n > t) continue;
@@ -102,8 +102,8 @@ function he(t, n) {
102
102
  }
103
103
  return null;
104
104
  }
105
- function ge(e, t, n) {
106
- let r = me(e, t);
105
+ function _e(e, t, n) {
106
+ let r = he(e, t);
107
107
  if (r) return {
108
108
  text: e.slice(0, r.from) + r.label + e.slice(r.to),
109
109
  from: r.from,
@@ -118,7 +118,7 @@ function ge(e, t, n) {
118
118
  }
119
119
  //#endregion
120
120
  //#region src/toolbar/underline-ops.ts
121
- function _e(e, t) {
121
+ function ve(e, t) {
122
122
  let n = /<u>([\s\S]*?)<\/u>/gi;
123
123
  for (let r; r = n.exec(e);) {
124
124
  let e = r.index, n = e + r[0].length;
@@ -130,8 +130,8 @@ function _e(e, t) {
130
130
  }
131
131
  return null;
132
132
  }
133
- function ve(e, t, n) {
134
- let r = _e(e, t);
133
+ function ye(e, t, n) {
134
+ let r = ve(e, t);
135
135
  if (r) return {
136
136
  text: e.slice(0, r.from) + r.inner + e.slice(r.to),
137
137
  from: r.from,
@@ -146,10 +146,10 @@ function ve(e, t, n) {
146
146
  }
147
147
  //#endregion
148
148
  //#region src/toolbar/inline-ops.ts
149
- function k(e) {
149
+ function O(e) {
150
150
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
151
151
  }
152
- function ye(e, t, n) {
152
+ function be(e, t, n) {
153
153
  let r = t, i = t;
154
154
  if (n < 0) for (; r > 0 && "*~`$".includes(e[r - 1]);) r--;
155
155
  else for (; i < e.length && "*~`$".includes(e[i]);) i++;
@@ -158,7 +158,7 @@ function ye(e, t, n) {
158
158
  from: r
159
159
  };
160
160
  }
161
- function be(e, t) {
161
+ function xe(e, t) {
162
162
  let n = [];
163
163
  for (let r = 0; r < e.length;) {
164
164
  if (e[r] !== t) {
@@ -174,29 +174,29 @@ function be(e, t) {
174
174
  }
175
175
  return n;
176
176
  }
177
- function xe(e, t, n) {
177
+ function Se(e, t, n) {
178
178
  return e < n || t < n ? !1 : n > 1 || e % 2 == 1 && t % 2 == 1;
179
179
  }
180
- var Se = /[\p{L}\p{N}_]/u;
181
- function Ce(e, t) {
180
+ var Ce = /[\p{L}\p{N}_]/u;
181
+ function we(e, t) {
182
182
  let n = t, r = t;
183
- for (; n > 0 && Se.test(e[n - 1]);) n--;
184
- for (; r < e.length && Se.test(e[r]);) r++;
183
+ for (; n > 0 && Ce.test(e[n - 1]);) n--;
184
+ for (; r < e.length && Ce.test(e[r]);) r++;
185
185
  return r > n ? {
186
186
  from: n,
187
187
  to: r
188
188
  } : null;
189
189
  }
190
- function we(e, t, n, r) {
190
+ function Te(e, t, n, r) {
191
191
  if (t === n) {
192
- let r = Ce(e, t);
192
+ let r = we(e, t);
193
193
  r && (t = r.from, n = r.to);
194
194
  }
195
195
  let i = r.length, a = r[0], o = e.slice(t, n), s = 0;
196
196
  for (; o[s] === a;) s++;
197
197
  let c = 0;
198
198
  for (; o[o.length - 1 - c] === a;) c++;
199
- if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) && xe(s, c, i)) return {
199
+ if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) && Se(s, c, i)) return {
200
200
  changes: [{
201
201
  from: t,
202
202
  to: t + i,
@@ -209,10 +209,10 @@ function we(e, t, n, r) {
209
209
  from: t,
210
210
  to: n - 2 * i
211
211
  };
212
- let l = ye(e, t, -1), u = ye(e, n, 1), d = be(l.text, a), f = be(u.text, a).reverse();
212
+ let l = be(e, t, -1), u = be(e, n, 1), d = xe(l.text, a), f = xe(u.text, a).reverse();
213
213
  for (let e = 0; e < Math.min(d.length, f.length); e++) {
214
214
  let r = d[e], a = f[e];
215
- if (!xe(r.len, a.len, i)) continue;
215
+ if (!Se(r.len, a.len, i)) continue;
216
216
  let o = l.from + r.start + r.len, s = n + a.start;
217
217
  return {
218
218
  changes: [{
@@ -242,26 +242,26 @@ function we(e, t, n, r) {
242
242
  to: n + i
243
243
  };
244
244
  }
245
- function Te(e, t) {
245
+ function Ee(e, t) {
246
246
  let n = e;
247
247
  for (let e of [...t].sort((e, t) => t.from - e.from)) n = n.slice(0, e.from) + e.insert + n.slice(e.to);
248
248
  return n;
249
249
  }
250
- function A(e, t, n, r) {
251
- let i = we(e, t, n, r);
250
+ function k(e, t, n, r) {
251
+ let i = Te(e, t, n, r);
252
252
  return {
253
- text: Te(e, i.changes),
253
+ text: Ee(e, i.changes),
254
254
  from: i.from,
255
255
  to: i.to
256
256
  };
257
257
  }
258
- function Ee(e, t) {
259
- let n = O(e, t);
258
+ function De(e, t) {
259
+ let n = D(e, t);
260
260
  if (n) return {
261
261
  from: n.from,
262
262
  to: n.to
263
263
  };
264
- let r = he(e, t);
264
+ let r = ge(e, t);
265
265
  if (r) return {
266
266
  from: r.from,
267
267
  to: r.to
@@ -273,7 +273,7 @@ function Ee(e, t) {
273
273
  "*",
274
274
  "`"
275
275
  ]) {
276
- let r = RegExp(k(n) + "(?!\\s)(?:[^]*?\\S)??" + k(n), "g");
276
+ let r = RegExp(O(n) + "(?!\\s)(?:[^]*?\\S)??" + O(n), "g");
277
277
  for (let a; a = r.exec(e);) {
278
278
  if (a[0].length <= 2 * n.length) continue;
279
279
  let e = a.index + n.length, r = a.index + a[0].length - n.length;
@@ -287,8 +287,8 @@ function Ee(e, t) {
287
287
  }
288
288
  //#endregion
289
289
  //#region src/inplace/table-cell-dom.ts
290
- var De = (e) => [e.head, ...e.body].map((e) => [...e]), Oe = (e) => e.map((e) => e.map((e) => e.trim())), ke = (e) => e.replace(/\\\|/g, "|");
291
- function j(e, t) {
290
+ var Oe = (e) => [e.head, ...e.body].map((e) => [...e]), ke = (e) => e.map((e) => e.map((e) => e.trim())), Ae = (e) => e.replace(/\\\|/g, "|");
291
+ function je(e, t) {
292
292
  let n = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), r = 0;
293
293
  for (let e = n.nextNode(); e; e = n.nextNode()) {
294
294
  if (e === t) return r;
@@ -296,23 +296,31 @@ function j(e, t) {
296
296
  }
297
297
  return r;
298
298
  }
299
- function Ae(e) {
300
- let t = e.ownerDocument.getSelection(), n = t?.anchorNode;
301
- return !n || !e.contains(n) ? 0 : n.nodeType === Node.TEXT_NODE ? j(e, n) + (t?.anchorOffset ?? 0) : (t?.anchorOffset ?? 0) > 0 ? (e.textContent ?? "").length : 0;
299
+ function A(e, t, n) {
300
+ if (!t || !e.contains(t)) return (e.textContent ?? "").length;
301
+ let r = e.ownerDocument.createRange();
302
+ return r.setStart(e, 0), r.setEnd(t, n), r.toString().length;
302
303
  }
303
- function je(e) {
304
- let t = e.ownerDocument.getSelection(), n = (e.textContent ?? "").length, r = (t, r) => !t || !e.contains(t) ? n : t.nodeType === Node.TEXT_NODE ? j(e, t) + r : r > 0 ? n : 0;
305
- if (!t || t.rangeCount === 0) return {
306
- from: n,
307
- to: n
308
- };
309
- let i = r(t.anchorNode, t.anchorOffset), a = r(t.focusNode, t.focusOffset);
304
+ function Me(e) {
305
+ let t = e.ownerDocument.getSelection();
306
+ return t?.anchorNode && e.contains(t.anchorNode) ? A(e, t.anchorNode, t.anchorOffset) : 0;
307
+ }
308
+ function Ne(e) {
309
+ let t = e.ownerDocument.getSelection();
310
+ if (!t || t.rangeCount === 0) {
311
+ let t = (e.textContent ?? "").length;
312
+ return {
313
+ from: t,
314
+ to: t
315
+ };
316
+ }
317
+ let n = A(e, t.anchorNode, t.anchorOffset), r = A(e, t.focusNode, t.focusOffset);
310
318
  return {
311
- from: Math.min(i, a),
312
- to: Math.max(i, a)
319
+ from: Math.min(n, r),
320
+ to: Math.max(n, r)
313
321
  };
314
322
  }
315
- function Me(e, t, n) {
323
+ function Pe(e, t, n) {
316
324
  let r = e.ownerDocument, i = null, a = 0;
317
325
  if (r.caretPositionFromPoint) {
318
326
  let e = r.caretPositionFromPoint(t, n);
@@ -321,62 +329,66 @@ function Me(e, t, n) {
321
329
  let e = r.caretRangeFromPoint(t, n);
322
330
  e && ([i, a] = [e.startContainer, e.startOffset]);
323
331
  }
324
- return !i || !e.contains(i) ? 0 : j(e, i) + (i.nodeType === Node.TEXT_NODE ? a : 0);
332
+ return !i || !e.contains(i) ? 0 : je(e, i) + (i.nodeType === Node.TEXT_NODE ? a : 0);
325
333
  }
326
- var Ne = /[\p{L}\p{N}_]/u;
327
- function Pe(e, t, n) {
328
- let r = e.textContent ?? "", i = Me(e, t, n), a = Ee(r, i);
329
- if (a) return M(e, a.from, a.to), !0;
334
+ var Fe = /[\p{L}\p{N}_]/u;
335
+ function Ie(e, t, n) {
336
+ let r = e.textContent ?? "", i = Pe(e, t, n), a = De(r, i);
337
+ if (a) return j(e, a.from, a.to), !0;
330
338
  let o = i, s = i;
331
- for (; o > 0 && Ne.test(r[o - 1]);) o--;
332
- for (; s < r.length && Ne.test(r[s]);) s++;
333
- return s <= o ? !1 : (M(e, o, s), !0);
339
+ for (; o > 0 && Fe.test(r[o - 1]);) o--;
340
+ for (; s < r.length && Fe.test(r[s]);) s++;
341
+ return s <= o ? !1 : (j(e, o, s), !0);
342
+ }
343
+ function Le(e, t) {
344
+ let n = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), r = t, i = null;
345
+ for (let e = n.nextNode(); e; e = n.nextNode()) {
346
+ if (r <= e.data.length) return [e, r];
347
+ r -= e.data.length, i = e;
348
+ }
349
+ return i ? [i, i.data.length] : [e, 0];
334
350
  }
335
- function M(e, t, n = t) {
351
+ function j(e, t, n = t) {
336
352
  e.focus();
337
- let r = e.ownerDocument, i = r.createRange(), a = e.firstChild;
338
- if (a && a.nodeType === Node.TEXT_NODE) {
339
- let e = a.textContent?.length ?? 0;
340
- i.setStart(a, Math.min(Math.min(t, n), e)), i.setEnd(a, Math.min(Math.max(t, n), e));
341
- } else i.selectNodeContents(e);
342
- t === n && i.collapse(!0);
343
- let o = r.getSelection();
344
- o?.removeAllRanges(), o?.addRange(i);
353
+ let r = e.ownerDocument, i = r.createRange(), [a, o] = [Math.min(t, n), Math.max(t, n)], [s, c] = [Le(e, a), Le(e, o)];
354
+ s[0] === e ? i.selectNodeContents(e) : (i.setStart(s[0], s[1]), i.setEnd(c[0], c[1])), t === n && i.collapse(!0);
355
+ let l = r.getSelection();
356
+ l?.removeAllRanges(), l?.addRange(i);
345
357
  }
346
358
  //#endregion
347
359
  //#region src/toolbar/cell-inline.ts
348
- function Fe(e) {
360
+ function Re(e) {
349
361
  let t = e.dom.ownerDocument.activeElement;
350
362
  return !(t instanceof HTMLElement) || !e.dom.contains(t) ? null : t.matches(".cm-inplace-tcell") ? t : null;
351
363
  }
352
- function Ie(e, t) {
353
- let { from: n, to: r } = je(e), i = t(e.textContent ?? "", n, r);
354
- e.textContent = i.text, M(e, i.from, i.to), e.dispatchEvent(new Event("input", { bubbles: !0 }));
355
- }
356
- function N(e, t) {
357
- let n = Fe(e);
358
- return n ? (Ie(n, t), !0) : !1;
359
- }
360
- var Le = {
361
- b: (e, t, n) => A(e, t, n, "**"),
362
- i: (e, t, n) => A(e, t, n, "*"),
363
- u: ve,
364
- k: pe,
365
- K: ge
364
+ function ze(e, t) {
365
+ let { from: n, to: r } = Ne(e), i = t(e.textContent ?? "", n, r);
366
+ e.textContent = i.text, j(e, i.from, i.to), e.dispatchEvent(new Event("input", { bubbles: !0 }));
367
+ }
368
+ function M(e, t) {
369
+ let n = Re(e);
370
+ return n ? (ze(n, t), !0) : !1;
371
+ }
372
+ var Be = {
373
+ b: (e, t, n) => k(e, t, n, "**"),
374
+ i: (e, t, n) => k(e, t, n, "*"),
375
+ u: ye,
376
+ k: me,
377
+ K: _e
366
378
  };
367
- function Re(e, t) {
379
+ function Ve(e, t) {
368
380
  if (!(e.metaKey || e.ctrlKey) || e.altKey) return !1;
369
- let n = Le[e.shiftKey ? e.key.toUpperCase() : e.key.toLowerCase()];
370
- return n ? (e.preventDefault(), Ie(t, n), !0) : !1;
381
+ let n = Be[e.shiftKey ? e.key.toUpperCase() : e.key.toLowerCase()];
382
+ return n ? (e.preventDefault(), ze(t, n), !0) : !1;
371
383
  }
372
384
  //#endregion
373
385
  //#region src/toolbar/block.ts
374
- function P(e) {
386
+ function N(e) {
375
387
  let { from: t, to: n } = e.selection.main;
376
388
  return [e.doc.lineAt(t).number, e.doc.lineAt(n).number];
377
389
  }
378
- function ze(e, t) {
379
- let n = e.state, [r, i] = P(n), a = r === i && !n.doc.line(r).text.trim(), o = !a;
390
+ function He(e, t) {
391
+ let n = e.state, [r, i] = N(n), a = r === i && !n.doc.line(r).text.trim(), o = !a;
380
392
  for (let e = r; e <= i && o; e++) {
381
393
  let r = n.doc.line(e).text;
382
394
  r.trim() && !t.match.test(r) && (o = !1);
@@ -413,13 +425,13 @@ function ze(e, t) {
413
425
  scrollIntoView: !0
414
426
  }), e.focus(), !0) : !1;
415
427
  }
416
- function Be(e, t) {
428
+ function Ue(e, t) {
417
429
  return t.test(e.doc.lineAt(e.selection.main.head).text);
418
430
  }
419
431
  //#endregion
420
432
  //#region src/toolbar/fence.ts
421
- function F(e, t) {
422
- for (let n = ce(e).resolveInner(t, 0); n; n = n.parent) {
433
+ function P(e, t) {
434
+ for (let n = le(e).resolveInner(t, 0); n; n = n.parent) {
423
435
  if (n.name === "FencedCode") return {
424
436
  from: n.from,
425
437
  to: n.to
@@ -428,8 +440,8 @@ function F(e, t) {
428
440
  }
429
441
  return null;
430
442
  }
431
- function Ve(e) {
432
- let t = e.state, n = F(t, t.selection.main.head);
443
+ function We(e) {
444
+ let t = e.state, n = P(t, t.selection.main.head);
433
445
  if (n) {
434
446
  let r = t.doc.lineAt(n.from), i = t.doc.lineAt(n.to), a = [{
435
447
  from: r.from,
@@ -443,7 +455,7 @@ function Ve(e) {
443
455
  scrollIntoView: !0
444
456
  });
445
457
  } else {
446
- let [n, r] = P(t);
458
+ let [n, r] = N(t);
447
459
  e.dispatch({
448
460
  changes: [{
449
461
  from: t.doc.line(n).from,
@@ -458,11 +470,11 @@ function Ve(e) {
458
470
  }
459
471
  return e.focus(), !0;
460
472
  }
461
- function I(e) {
462
- return F(e, e.selection.main.head) !== null;
473
+ function F(e) {
474
+ return P(e, e.selection.main.head) !== null;
463
475
  }
464
- function He(e) {
465
- let t = F(e, e.selection.main.head);
476
+ function Ge(e) {
477
+ let t = P(e, e.selection.main.head);
466
478
  if (!t) return null;
467
479
  let n = e.doc.lineAt(t.from), r = /^(\s*(?:`{3,}|~{3,})[ \t]*)(.*?)[ \t]*$/.exec(n.text);
468
480
  if (!r) return null;
@@ -473,18 +485,18 @@ function He(e) {
473
485
  lang: r[2]
474
486
  };
475
487
  }
476
- var Ue = /^\s*\$\$\s*$/;
477
- function We(e, t) {
488
+ var Ke = /^\s*\$\$\s*$/;
489
+ function qe(e, t) {
478
490
  let n = 0, r = 0;
479
- for (let i = 1; i <= e.doc.lines; i++) if (Ue.test(e.doc.line(i).text)) {
491
+ for (let i = 1; i <= e.doc.lines; i++) if (Ke.test(e.doc.line(i).text)) {
480
492
  if (r++, r % 2 == 1) {
481
493
  if (n = i, i > t) return null;
482
494
  } else if (i >= t) return [n, i];
483
495
  }
484
496
  return null;
485
497
  }
486
- function Ge(e) {
487
- let t = e.state, [n, r] = P(t), i = We(t, t.doc.lineAt(t.selection.main.head).number);
498
+ function Je(e) {
499
+ let t = e.state, [n, r] = N(t), i = qe(t, t.doc.lineAt(t.selection.main.head).number);
488
500
  if (i) {
489
501
  let n = t.doc.line(i[0]), r = t.doc.line(i[1]);
490
502
  e.dispatch({
@@ -510,16 +522,16 @@ function Ge(e) {
510
522
  });
511
523
  return e.focus(), !0;
512
524
  }
513
- function L(e) {
514
- return We(e, e.doc.lineAt(e.selection.main.head).number) !== null;
525
+ function I(e) {
526
+ return qe(e, e.doc.lineAt(e.selection.main.head).number) !== null;
515
527
  }
516
528
  //#endregion
517
529
  //#region src/toolbar/heading.ts
518
- var Ke = /^(#{1,6}) +/;
519
- function qe(e, t) {
520
- let n = "#".repeat(t) + " ", r = e.state, [i, a] = P(r), o = [];
530
+ var L = /^(#{1,6}) +/;
531
+ function Ye(e, t) {
532
+ let n = "#".repeat(t) + " ", r = e.state, [i, a] = N(r), o = [];
521
533
  for (let e = i; e <= a; e++) {
522
- let i = r.doc.line(e), a = Ke.exec(i.text);
534
+ let i = r.doc.line(e), a = L.exec(i.text);
523
535
  a && a[1].length === t ? o.push({
524
536
  from: i.from,
525
537
  to: i.from + a[0].length
@@ -537,10 +549,10 @@ function qe(e, t) {
537
549
  scrollIntoView: !0
538
550
  }), e.focus(), !0;
539
551
  }
540
- function Je(e) {
541
- let t = e.state, [n, r] = P(t), i = [];
552
+ function Xe(e) {
553
+ let t = e.state, [n, r] = N(t), i = [];
542
554
  for (let e = n; e <= r; e++) {
543
- let n = t.doc.line(e), r = Ke.exec(n.text);
555
+ let n = t.doc.line(e), r = L.exec(n.text);
544
556
  r && i.push({
545
557
  from: n.from,
546
558
  to: n.from + r[0].length
@@ -557,7 +569,7 @@ function R(e, t) {
557
569
  let n = e.state.doc.toString();
558
570
  return e.dispatch({
559
571
  ...e.state.changeByRange((e) => {
560
- let r = we(n, e.from, e.to, t);
572
+ let r = Te(n, e.from, e.to, t);
561
573
  return {
562
574
  changes: r.changes,
563
575
  range: r.from === r.to ? f.cursor(r.from) : f.range(r.from, r.to)
@@ -567,7 +579,7 @@ function R(e, t) {
567
579
  }), e.focus(), !0;
568
580
  }
569
581
  function z(e, t) {
570
- let n = e.selection.main, r = e.doc.lineAt(n.head), i = RegExp(k(t) + "(?!\\s)(?:[^]*?\\S)??" + k(t), "g");
582
+ let n = e.selection.main, r = e.doc.lineAt(n.head), i = RegExp(O(t) + "(?!\\s)(?:[^]*?\\S)??" + O(t), "g");
571
583
  for (let e; e = i.exec(r.text);) {
572
584
  if (e[0].length <= 2 * t.length || t === "$" && (r.text[e.index - 1] === "$" || r.text[e.index + e[0].length] === "$")) continue;
573
585
  let i = r.from + e.index;
@@ -575,16 +587,16 @@ function z(e, t) {
575
587
  }
576
588
  return !1;
577
589
  }
578
- function Ye(e) {
579
- let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = O(n.text, t - n.from);
590
+ function Ze(e) {
591
+ let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = D(n.text, t - n.from);
580
592
  return r ? {
581
593
  from: n.from + r.from,
582
594
  to: n.from + r.to,
583
595
  text: r.label
584
596
  } : null;
585
597
  }
586
- function Xe(e) {
587
- let t = Ye(e.state);
598
+ function Qe(e) {
599
+ let t = Ze(e.state);
588
600
  if (t) return e.dispatch({
589
601
  changes: {
590
602
  from: t.from,
@@ -605,19 +617,19 @@ function Xe(e) {
605
617
  scrollIntoView: !0
606
618
  }), e.focus(), !0;
607
619
  }
608
- function Ze(e) {
609
- return Ye(e) !== null;
620
+ function $e(e) {
621
+ return Ze(e) !== null;
610
622
  }
611
- function Qe(e) {
612
- let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = me(n.text, t - n.from);
623
+ function et(e) {
624
+ let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = he(n.text, t - n.from);
613
625
  return r ? {
614
626
  from: n.from + r.from,
615
627
  to: n.from + r.to,
616
628
  text: r.label
617
629
  } : null;
618
630
  }
619
- function $e(e) {
620
- let t = Qe(e.state);
631
+ function tt(e) {
632
+ let t = et(e.state);
621
633
  if (t) return e.dispatch({
622
634
  changes: {
623
635
  from: t.from,
@@ -638,19 +650,19 @@ function $e(e) {
638
650
  scrollIntoView: !0
639
651
  }), e.focus(), !0;
640
652
  }
641
- function et(e) {
642
- return Qe(e) !== null;
653
+ function nt(e) {
654
+ return et(e) !== null;
643
655
  }
644
- function tt(e) {
645
- let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = _e(n.text, t - n.from);
656
+ function rt(e) {
657
+ let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = ve(n.text, t - n.from);
646
658
  return r ? {
647
659
  from: n.from + r.from,
648
660
  to: n.from + r.to,
649
661
  inner: r.inner
650
662
  } : null;
651
663
  }
652
- function nt(e) {
653
- let t = tt(e.state);
664
+ function it(e) {
665
+ let t = rt(e.state);
654
666
  if (t) return e.dispatch({
655
667
  changes: {
656
668
  from: t.from,
@@ -671,29 +683,29 @@ function nt(e) {
671
683
  scrollIntoView: !0
672
684
  }), e.focus(), !0;
673
685
  }
674
- function rt(e) {
675
- return tt(e) !== null;
686
+ function at(e) {
687
+ return rt(e) !== null;
676
688
  }
677
689
  //#endregion
678
690
  //#region src/toolbar/table-grid.ts
679
- function it(e) {
691
+ function ot(e) {
680
692
  let t = e.trim();
681
693
  return t.includes("-") && t.includes("|") && /^[\s|:-]+$/.test(t);
682
694
  }
683
- function at(e) {
695
+ function st(e) {
684
696
  let t = e.trim();
685
697
  t.startsWith("|") && (t = t.slice(1)), t.endsWith("|") && !t.endsWith("\\|") && (t = t.slice(0, -1));
686
698
  let n = [], r = "";
687
699
  for (let e = 0; e < t.length; e++) t[e] === "\\" && t[e + 1] === "|" ? (r += "\\|", e++) : t[e] === "|" ? (n.push(r.trim()), r = "") : r += t[e];
688
700
  return n.push(r.trim()), n;
689
701
  }
690
- function ot(e) {
702
+ function ct(e) {
691
703
  let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
692
704
  return n && r ? "center" : r ? "right" : n ? "left" : "";
693
705
  }
694
706
  function B(e) {
695
- if (e.length < 2 || !it(e[1])) return null;
696
- let t = at(e[1]).map(ot), n = e.filter((e, t) => t !== 1).map(at), r = Math.max(t.length, ...n.map((e) => e.length)), i = n.map((e) => {
707
+ if (e.length < 2 || !ot(e[1])) return null;
708
+ let t = st(e[1]).map(ct), n = e.filter((e, t) => t !== 1).map(st), r = Math.max(t.length, ...n.map((e) => e.length)), i = n.map((e) => {
697
709
  let t = e.slice(0, r);
698
710
  for (; t.length < r;) t.push("");
699
711
  return t;
@@ -704,11 +716,11 @@ function B(e) {
704
716
  aligns: a
705
717
  };
706
718
  }
707
- function st(e) {
719
+ function lt(e) {
708
720
  return e.replace(/\\\|/g, "|").length;
709
721
  }
710
- function ct(e, t, n) {
711
- let r = t - st(e);
722
+ function ut(e, t, n) {
723
+ let r = t - lt(e);
712
724
  if (r <= 0) return e;
713
725
  if (n === "right") return " ".repeat(r) + e;
714
726
  if (n === "center") {
@@ -717,7 +729,7 @@ function ct(e, t, n) {
717
729
  }
718
730
  return e + " ".repeat(r);
719
731
  }
720
- function lt(e, t) {
732
+ function dt(e, t) {
721
733
  let n = Math.max(3, e);
722
734
  return t === "left" ? ":" + "-".repeat(n - 1) : t === "right" ? "-".repeat(n - 1) + ":" : t === "center" ? ":" + "-".repeat(n - 2) + ":" : "-".repeat(n);
723
735
  }
@@ -725,15 +737,15 @@ function V(e) {
725
737
  let t = e.aligns.length, n = [];
726
738
  for (let r = 0; r < t; r++) {
727
739
  let t = 3;
728
- for (let n of e.rows) t = Math.max(t, st(n[r] ?? ""));
740
+ for (let n of e.rows) t = Math.max(t, lt(n[r] ?? ""));
729
741
  n.push(t);
730
742
  }
731
- let r = (t) => "| " + t.map((t, r) => ct(t ?? "", n[r], e.aligns[r])).join(" | ") + " |", i = [r(e.rows[0] ?? [])];
732
- i.push("| " + e.aligns.map((e, t) => lt(n[t], e)).join(" | ") + " |");
743
+ let r = (t) => "| " + t.map((t, r) => ut(t ?? "", n[r], e.aligns[r])).join(" | ") + " |", i = [r(e.rows[0] ?? [])];
744
+ i.push("| " + e.aligns.map((e, t) => dt(n[t], e)).join(" | ") + " |");
733
745
  for (let t = 1; t < e.rows.length; t++) i.push(r(e.rows[t]));
734
746
  return i.join("\n");
735
747
  }
736
- function ut(e) {
748
+ function ft(e) {
737
749
  let t = [];
738
750
  for (let n = 0; n < e.length; n++) {
739
751
  if (e[n] === "\\") {
@@ -780,7 +792,7 @@ function H(e, t) {
780
792
  lines: a
781
793
  } : null;
782
794
  }
783
- function dt(e, t, n) {
795
+ function pt(e, t, n) {
784
796
  let r = t;
785
797
  for (let t = 0; t < e.length; t++) {
786
798
  let i = e[t];
@@ -796,7 +808,7 @@ function dt(e, t, n) {
796
808
  onDelimiter: !0
797
809
  };
798
810
  }
799
- let a = ut(i), o = 0;
811
+ let a = ft(i), o = 0;
800
812
  for (let t = 0; t < a.length && (o = t, !(e <= a[t].end)); t++);
801
813
  let s = a[o], c = s ? Math.max(0, Math.min(e, s.contentEnd) - s.contentStart) : 0;
802
814
  return {
@@ -813,21 +825,21 @@ function dt(e, t, n) {
813
825
  function U(e, t, n) {
814
826
  let r = e.split("\n"), i = n.onDelimiter ? 1 : n.row === 0 ? 0 : n.row + 1, a = t;
815
827
  for (let e = 0; e < i; e++) a += r[e].length + 1;
816
- let o = ut(r[i]), s = o[Math.min(n.col, o.length - 1)];
828
+ let o = ft(r[i]), s = o[Math.min(n.col, o.length - 1)];
817
829
  return s ? a + s.contentStart + Math.min(n.offset, s.contentEnd - s.contentStart) : a;
818
830
  }
819
- function ft(e, t, n, r) {
831
+ function mt(e, t, n, r) {
820
832
  let i = H(e, t);
821
- return i ? U(i.lines.join("\n"), i.from, {
833
+ return !i || n > i.lines.length - 2 ? null : U(i.lines.join("\n"), i.from, {
822
834
  row: n,
823
835
  col: r,
824
836
  offset: 0,
825
837
  onDelimiter: !1
826
- }) : null;
838
+ });
827
839
  }
828
840
  //#endregion
829
841
  //#region src/toolbar/table.ts
830
- function pt(e, t) {
842
+ function ht(e, t) {
831
843
  requestAnimationFrame(() => {
832
844
  let n = e.dom.querySelectorAll(".cm-inplace-table-edit");
833
845
  if (n.length === 0) return;
@@ -847,7 +859,7 @@ function pt(e, t) {
847
859
  s?.removeAllRanges(), s?.addRange(o), a.focus();
848
860
  });
849
861
  }
850
- function mt(e) {
862
+ function gt(e) {
851
863
  let { from: t, to: n } = e.state.selection.main, r = e.state.doc.lineAt(t), i = r.text.slice(0, t - r.from).trim() ? "\n\n" : "", a = t + i.length + 2;
852
864
  return e.dispatch({
853
865
  changes: {
@@ -857,7 +869,7 @@ function mt(e) {
857
869
  },
858
870
  selection: f.range(a, a + 8),
859
871
  scrollIntoView: !0
860
- }), e.focus(), pt(e, a), !0;
872
+ }), e.focus(), ht(e, a), !0;
861
873
  }
862
874
  function W(e) {
863
875
  return H(e.doc, e.selection.main.head) !== null;
@@ -865,7 +877,7 @@ function W(e) {
865
877
  function G(e, t) {
866
878
  let n = H(e.state.doc, e.state.selection.main.head);
867
879
  if (!n) return !1;
868
- let r = B(n.lines), i = dt(n.lines, n.from, e.state.selection.main.head);
880
+ let r = B(n.lines), i = pt(n.lines, n.from, e.state.selection.main.head);
869
881
  if (!r || !i) return !1;
870
882
  let a = t(r, i);
871
883
  if (!a) return !1;
@@ -880,7 +892,7 @@ function G(e, t) {
880
892
  scrollIntoView: !0
881
893
  }), e.focus(), !0;
882
894
  }
883
- function ht(e, t, n) {
895
+ function _t(e, t, n) {
884
896
  let r = e.aligns.length, { row: i, col: a } = t;
885
897
  return a += n, a >= r ? (i++, a = 0) : a < 0 && (i--, a = r - 1), i < 0 ? null : (i >= e.rows.length && e.rows.push(Array(r).fill("")), {
886
898
  row: i,
@@ -889,7 +901,7 @@ function ht(e, t, n) {
889
901
  onDelimiter: !1
890
902
  });
891
903
  }
892
- function gt(e, t) {
904
+ function vt(e, t) {
893
905
  let n = t.row + 1;
894
906
  return n >= e.rows.length && e.rows.push(Array(e.aligns.length).fill("")), {
895
907
  row: n,
@@ -898,20 +910,20 @@ function gt(e, t) {
898
910
  onDelimiter: !1
899
911
  };
900
912
  }
901
- var _t = o.of([
913
+ var yt = o.of([
902
914
  {
903
915
  key: "Tab",
904
- run: (e) => G(e, (e, t) => ht(e, t, 1))
916
+ run: (e) => G(e, (e, t) => _t(e, t, 1))
905
917
  },
906
918
  {
907
919
  key: "Shift-Tab",
908
- run: (e) => G(e, (e, t) => ht(e, t, -1))
920
+ run: (e) => G(e, (e, t) => _t(e, t, -1))
909
921
  },
910
922
  {
911
923
  key: "Enter",
912
- run: (e) => G(e, gt)
924
+ run: (e) => G(e, vt)
913
925
  }
914
- ]), vt = p.transactionFilter.of((e) => {
926
+ ]), bt = p.transactionFilter.of((e) => {
915
927
  if (!e.docChanged || e.isUserEvent("input.type.compose") || !e.isUserEvent("input") && !e.isUserEvent("delete")) return e;
916
928
  let t = e.newSelection.main.head, n = H(e.newDoc, t);
917
929
  if (!n) return e;
@@ -919,7 +931,7 @@ var _t = o.of([
919
931
  if (!r) return e;
920
932
  let i = V(r);
921
933
  if (i === n.lines.join("\n")) return e;
922
- let a = dt(n.lines, n.from, t), o = u.of([{
934
+ let a = pt(n.lines, n.from, t), o = u.of([{
923
935
  from: n.from,
924
936
  to: n.to,
925
937
  insert: i
@@ -933,23 +945,23 @@ var _t = o.of([
933
945
  }), K = (e) => /^\s{0,3}#{1,6}(?:\s|$)/.test(e.doc.lineAt(e.selection.main.head).text), q = (e) => {
934
946
  let t = n(e.doc);
935
947
  return t !== null && e.selection.main.head <= t.to;
936
- }, J = (e) => q(e) || I(e) || L(e), yt = (e) => (t) => e !== "`" && z(t, "`") || e !== "$" && z(t, "$"), bt = (e) => e.selection.main.empty && !e.wordAt(e.selection.main.head), Y = (...e) => (t) => e.some((e) => e(t)), X = /^(\s*)(?:[-*+] \[[ xX]\] +|\d+[.)] +|[-*+] +)/, xt = {
948
+ }, J = (e) => q(e) || F(e) || I(e), xt = (e) => (t) => e !== "`" && z(t, "`") || e !== "$" && z(t, "$"), St = (e) => e.selection.main.empty && !e.wordAt(e.selection.main.head), Y = (...e) => (t) => e.some((e) => e(t)), X = /^(\s*)(?:[-*+] \[[ xX]\] +|\d+[.)] +|[-*+] +)/, Ct = {
937
949
  match: /^ {0,3}> ?/,
938
950
  insert: "> "
939
- }, St = {
951
+ }, wt = {
940
952
  match: /^(\s*)[-*+] +(?!\[[ xX]\])/,
941
953
  insert: "- ",
942
954
  siblings: X
943
- }, Ct = {
955
+ }, Tt = {
944
956
  match: /^(\s*)\d+[.)] +/,
945
957
  insert: (e) => `${e + 1}. `,
946
958
  siblings: X
947
- }, wt = {
959
+ }, Et = {
948
960
  match: /^(\s*)[-*+] \[[ xX]\] +/,
949
961
  insert: "- [ ] ",
950
962
  siblings: X
951
963
  };
952
- function Tt(e, t, n) {
964
+ function Dt(e, t, n) {
953
965
  return {
954
966
  id: e,
955
967
  title: t,
@@ -963,24 +975,24 @@ function Z(e, t, n, r) {
963
975
  return {
964
976
  id: e,
965
977
  title: t,
966
- run: (e) => N(e, (e, t, r) => A(e, t, r, n)) || R(e, n),
978
+ run: (e) => M(e, (e, t, r) => k(e, t, r, n)) || R(e, n),
967
979
  isActive: (e) => z(e, n),
968
- disabled: Y(J, yt(n), bt),
980
+ disabled: Y(J, xt(n), St),
969
981
  keys: r
970
982
  };
971
983
  }
972
- function Et(e) {
984
+ function Ot(e) {
973
985
  let t = RegExp(`^#{${e}} `);
974
986
  return {
975
987
  id: `h${e}`,
976
988
  title: `Heading ${e}`,
977
- run: (t) => qe(t, e),
989
+ run: (t) => Ye(t, e),
978
990
  isActive: (e) => t.test(e.doc.lineAt(e.selection.main.head).text),
979
991
  disabled: Y(W, J),
980
992
  keys: [`Mod-Alt-${e}`]
981
993
  };
982
994
  }
983
- var Dt = /* @__PURE__ */ new Set([
995
+ var kt = /* @__PURE__ */ new Set([
984
996
  "bold",
985
997
  "italic",
986
998
  "strike",
@@ -992,8 +1004,8 @@ var Dt = /* @__PURE__ */ new Set([
992
1004
  "math",
993
1005
  "mathBlock"
994
1006
  ]);
995
- function Ot(e, t, n) {
996
- return n ? Dt.has(t.id) ? {
1007
+ function At(e, t, n) {
1008
+ return n ? kt.has(t.id) ? {
997
1009
  disabled: !1,
998
1010
  active: !1
999
1011
  } : {
@@ -1008,14 +1020,14 @@ function Q(e, t, n, ...r) {
1008
1020
  return {
1009
1021
  id: e,
1010
1022
  title: t,
1011
- run: (e) => ze(e, n),
1012
- isActive: (e) => Be(e, n.match),
1023
+ run: (e) => He(e, n),
1024
+ isActive: (e) => Ue(e, n.match),
1013
1025
  disabled: Y(W, J, ...r)
1014
1026
  };
1015
1027
  }
1016
1028
  //#endregion
1017
1029
  //#region src/toolbar/frontmatter-toggle.ts
1018
- function kt(e) {
1030
+ function jt(e) {
1019
1031
  let t = e.state, r = n(t.doc);
1020
1032
  if (r) {
1021
1033
  let n = t.doc.lineAt(r.from), i = t.doc.lineAt(r.to);
@@ -1045,15 +1057,15 @@ function kt(e) {
1045
1057
  }
1046
1058
  return e.focus(), !0;
1047
1059
  }
1048
- function At(e) {
1060
+ function Mt(e) {
1049
1061
  return n(e.doc) !== null;
1050
1062
  }
1051
1063
  //#endregion
1052
1064
  //#region src/toolbar/rule.ts
1053
- var jt = /^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/;
1054
- function Mt(e) {
1065
+ var Nt = /^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/;
1066
+ function Pt(e) {
1055
1067
  let t = e.state, n = t.doc.lineAt(t.selection.main.head);
1056
- return jt.test(n.text) ? e.dispatch({
1068
+ return Nt.test(n.text) ? e.dispatch({
1057
1069
  changes: {
1058
1070
  from: n.from,
1059
1071
  to: Math.min(n.to + 1, t.doc.length)
@@ -1076,46 +1088,46 @@ function Mt(e) {
1076
1088
  scrollIntoView: !0
1077
1089
  }), e.focus(), !0;
1078
1090
  }
1079
- function Nt(e) {
1080
- return jt.test(e.doc.lineAt(e.selection.main.head).text);
1091
+ function Ft(e) {
1092
+ return Nt.test(e.doc.lineAt(e.selection.main.head).text);
1081
1093
  }
1082
1094
  //#endregion
1083
1095
  //#region src/editor/save.ts
1084
- var Pt = ee.define({ combine: (e) => e[0] ?? null });
1085
- function Ft(e) {
1086
- let t = e.state.facet(Pt);
1096
+ var It = ee.define({ combine: (e) => e[0] ?? null });
1097
+ function Lt(e) {
1098
+ let t = e.state.facet(It);
1087
1099
  return t ? (t(e.state.doc.toString()), !0) : !1;
1088
1100
  }
1089
1101
  //#endregion
1090
1102
  //#region src/editor/search-panel-dom.ts
1091
- var It = "stylo-search-panel";
1092
- function Lt(e) {
1103
+ var Rt = "stylo-search-panel";
1104
+ function zt(e) {
1093
1105
  e.setAttribute("form", "");
1094
1106
  }
1095
- function Rt(e, t, n) {
1107
+ function Bt(e, t, n) {
1096
1108
  let r = document.createElement("input");
1097
- return r.type = "text", r.name = e, r.placeholder = t, r.setAttribute("aria-label", t), r.className = n, Lt(r), r;
1109
+ return r.type = "text", r.name = e, r.placeholder = t, r.setAttribute("aria-label", t), r.className = n, zt(r), r;
1098
1110
  }
1099
1111
  function $(e, t) {
1100
1112
  let n = document.createElement("button");
1101
1113
  return n.type = "button", n.name = e, n.className = "stylo-search-button", n.textContent = t, n;
1102
1114
  }
1103
- function zt(e, t) {
1115
+ function Vt(e, t) {
1104
1116
  let n = document.createElement("input");
1105
- n.type = "checkbox", n.name = e, Lt(n);
1117
+ n.type = "checkbox", n.name = e, zt(n);
1106
1118
  let r = document.createElement("label");
1107
1119
  return r.className = "stylo-search-check", r.append(n, document.createTextNode(t)), {
1108
1120
  field: n,
1109
1121
  wrap: r
1110
1122
  };
1111
1123
  }
1112
- function Bt(e) {
1113
- let t = (t) => e.state.phrase(t), n = Rt("search", t("Find"), "stylo-search-field");
1124
+ function Ht(e) {
1125
+ let t = (t) => e.state.phrase(t), n = Bt("search", t("Find"), "stylo-search-field");
1114
1126
  n.setAttribute("main-field", "true");
1115
- let r = $("next", t("next")), i = $("prev", t("previous")), a = $("select", t("all")), o = Rt("replace", t("Replace"), "stylo-search-field stylo-search-replace"), s = $("replace", t("replace")), c = $("replaceAll", t("replace all")), l = zt("case", t("match case")), u = zt("re", t("regexp")), d = zt("word", t("by word")), f = $("close", "×");
1127
+ let r = $("next", t("next")), i = $("prev", t("previous")), a = $("select", t("all")), o = Bt("replace", t("Replace"), "stylo-search-field stylo-search-replace"), s = $("replace", t("replace")), c = $("replaceAll", t("replace all")), l = Vt("case", t("match case")), u = Vt("re", t("regexp")), d = Vt("word", t("by word")), f = $("close", "×");
1116
1128
  f.classList.add("stylo-search-close"), f.setAttribute("aria-label", t("close"));
1117
1129
  let p = document.createElement("div");
1118
- return p.className = It, p.append(n, r, i, a, o, s, c, l.wrap, u.wrap, d.wrap, f), {
1130
+ return p.className = Rt, p.append(n, r, i, a, o, s, c, l.wrap, u.wrap, d.wrap, f), {
1119
1131
  root: p,
1120
1132
  find: n,
1121
1133
  next: r,
@@ -1132,31 +1144,31 @@ function Bt(e) {
1132
1144
  }
1133
1145
  //#endregion
1134
1146
  //#region src/editor/search-panel.ts
1135
- var Vt = "cm-search-closing", Ht = 160;
1136
- function Ut(e) {
1137
- return ae(e.state) ? Wt(e) : w(e);
1147
+ var Ut = "cm-search-closing", Wt = 160;
1148
+ function Gt(e) {
1149
+ return oe(e.state) ? Kt(e) : C(e);
1138
1150
  }
1139
- function Wt(e) {
1140
- let t = e.dom.querySelector(`.${It}`);
1141
- return !t || t.classList.contains(Vt) ? !0 : (t.classList.add(Vt), setTimeout(() => {
1142
- e.dom.isConnected && b(e);
1143
- }, Ht), !0);
1151
+ function Kt(e) {
1152
+ let t = e.dom.querySelector(`.${Rt}`);
1153
+ return !t || t.classList.contains(Ut) ? !0 : (t.classList.add(Ut), setTimeout(() => {
1154
+ e.dom.isConnected && y(e);
1155
+ }, Wt), !0);
1144
1156
  }
1145
- function Gt(e) {
1146
- let t = Bt(e), n = C(e.state);
1157
+ function qt(e) {
1158
+ let t = Ht(e), n = S(e.state);
1147
1159
  r(n);
1148
1160
  function r(e) {
1149
1161
  t.find.value = e.search, t.replace.value = e.replace, t.caseSensitive.checked = e.caseSensitive, t.regexp.checked = e.regexp, t.wholeWord.checked = e.wholeWord;
1150
1162
  }
1151
1163
  function i() {
1152
- let r = new re({
1164
+ let r = new v({
1153
1165
  search: t.find.value,
1154
1166
  caseSensitive: t.caseSensitive.checked,
1155
1167
  regexp: t.regexp.checked,
1156
1168
  wholeWord: t.wholeWord.checked,
1157
1169
  replace: t.replace.value
1158
1170
  });
1159
- r.eq(n) || (n = r, e.dispatch({ effects: se.of(n) }));
1171
+ r.eq(n) || (n = r, e.dispatch({ effects: ce.of(n) }));
1160
1172
  }
1161
1173
  for (let e of [
1162
1174
  t.find,
@@ -1167,50 +1179,50 @@ function Gt(e) {
1167
1179
  ]) e.addEventListener("input", i), e.addEventListener("change", i);
1168
1180
  return t.root.addEventListener("keydown", (n) => {
1169
1181
  if (n.key === "Escape") {
1170
- n.preventDefault(), Wt(e);
1182
+ n.preventDefault(), Kt(e);
1171
1183
  return;
1172
1184
  }
1173
1185
  if (c(e, n, "search-panel")) {
1174
1186
  n.preventDefault();
1175
1187
  return;
1176
1188
  }
1177
- n.key === "Enter" && (n.preventDefault(), n.target === t.find ? (n.shiftKey ? S : x)(e) : n.target === t.replace && E(e));
1178
- }), t.next.addEventListener("click", () => x(e)), t.prev.addEventListener("click", () => S(e)), t.all.addEventListener("click", () => oe(e)), t.replaceBtn.addEventListener("click", () => E(e)), t.replaceAllBtn.addEventListener("click", () => T(e)), t.close.addEventListener("click", () => Wt(e)), {
1189
+ n.key === "Enter" && (n.preventDefault(), n.target === t.find ? (n.shiftKey ? x : b)(e) : n.target === t.replace && T(e));
1190
+ }), t.next.addEventListener("click", () => b(e)), t.prev.addEventListener("click", () => x(e)), t.all.addEventListener("click", () => se(e)), t.replaceBtn.addEventListener("click", () => T(e)), t.replaceAllBtn.addEventListener("click", () => w(e)), t.close.addEventListener("click", () => Kt(e)), {
1179
1191
  dom: t.root,
1180
1192
  top: !0,
1181
1193
  update(e) {
1182
- for (let t of e.transactions) for (let e of t.effects) e.is(se) && !e.value.eq(n) && (n = e.value, r(n));
1194
+ for (let t of e.transactions) for (let e of t.effects) e.is(ce) && !e.value.eq(n) && (n = e.value, r(n));
1183
1195
  }
1184
1196
  };
1185
1197
  }
1186
1198
  //#endregion
1187
1199
  //#region src/toolbar/commands.ts
1188
- var Kt = [
1189
- Tt("undo", "Undo", _),
1190
- Tt("redo", "Redo", g),
1200
+ var Jt = [
1201
+ Dt("undo", "Undo", g),
1202
+ Dt("redo", "Redo", h),
1191
1203
  {
1192
1204
  id: "save",
1193
1205
  title: "Save",
1194
1206
  run: (e) => {
1195
- let t = Ft(e);
1207
+ let t = Lt(e);
1196
1208
  return e.focus(), t;
1197
1209
  },
1198
- disabled: (e) => e.facet(Pt) == null
1210
+ disabled: (e) => e.facet(It) == null
1199
1211
  },
1200
1212
  {
1201
1213
  id: "search",
1202
1214
  title: "Find / replace",
1203
- run: (e) => Ut(e),
1204
- isActive: (e) => ae(e),
1215
+ run: (e) => Gt(e),
1216
+ isActive: (e) => oe(e),
1205
1217
  keys: ["Mod-f"]
1206
1218
  },
1207
- Et(1),
1208
- Et(2),
1209
- Et(3),
1219
+ Ot(1),
1220
+ Ot(2),
1221
+ Ot(3),
1210
1222
  {
1211
1223
  id: "body",
1212
1224
  title: "Body",
1213
- run: (e) => (Je(e) || e.focus(), !0),
1225
+ run: (e) => (Xe(e) || e.focus(), !0),
1214
1226
  isActive: (e) => !/^#{1,6} /.test(e.doc.lineAt(e.selection.main.head).text),
1215
1227
  disabled: Y(W, J)
1216
1228
  },
@@ -1220,74 +1232,74 @@ var Kt = [
1220
1232
  {
1221
1233
  id: "underline",
1222
1234
  title: "Underline",
1223
- run: (e) => N(e, ve) || nt(e),
1224
- isActive: rt,
1225
- disabled: Y(J, yt("u"), bt),
1235
+ run: (e) => M(e, ye) || it(e),
1236
+ isActive: at,
1237
+ disabled: Y(J, xt("u"), St),
1226
1238
  keys: ["Mod-u"]
1227
1239
  },
1228
1240
  Z("code", "Inline code", "`"),
1229
1241
  {
1230
1242
  id: "codeBlock",
1231
1243
  title: "Code block",
1232
- run: (e) => N(e, (e, t, n) => A(e, t, n, "`")) || (W(e.state) ? R(e, "`") : Ve(e)),
1233
- isActive: (e) => W(e) ? z(e, "`") : I(e),
1234
- disabled: Y(q, L, K)
1244
+ run: (e) => M(e, (e, t, n) => k(e, t, n, "`")) || (W(e.state) ? R(e, "`") : We(e)),
1245
+ isActive: (e) => W(e) ? z(e, "`") : F(e),
1246
+ disabled: Y(q, I, K)
1235
1247
  },
1236
1248
  {
1237
1249
  id: "link",
1238
1250
  title: "Link",
1239
- run: (e) => N(e, pe) || Xe(e),
1240
- isActive: Ze,
1251
+ run: (e) => M(e, me) || Qe(e),
1252
+ isActive: $e,
1241
1253
  disabled: J,
1242
1254
  keys: ["Mod-k"]
1243
1255
  },
1244
1256
  {
1245
1257
  id: "wikilink",
1246
1258
  title: "Wikilink",
1247
- run: (e) => N(e, ge) || $e(e),
1248
- isActive: et,
1259
+ run: (e) => M(e, _e) || tt(e),
1260
+ isActive: nt,
1249
1261
  disabled: J,
1250
1262
  keys: ["Mod-Shift-k"]
1251
1263
  },
1252
- Q("quote", "Blockquote", xt),
1253
- Q("bulletList", "Bulleted list", St, K),
1254
- Q("orderedList", "Numbered list", Ct, K),
1255
- Q("task", "Task list", wt, K),
1264
+ Q("quote", "Blockquote", Ct),
1265
+ Q("bulletList", "Bulleted list", wt, K),
1266
+ Q("orderedList", "Numbered list", Tt, K),
1267
+ Q("task", "Task list", Et, K),
1256
1268
  {
1257
1269
  id: "hr",
1258
1270
  title: "Divider",
1259
- run: Mt,
1260
- isActive: Nt,
1271
+ run: Pt,
1272
+ isActive: Ft,
1261
1273
  disabled: Y(W, J)
1262
1274
  },
1263
1275
  {
1264
1276
  id: "frontmatter",
1265
1277
  title: "Frontmatter",
1266
- run: kt,
1267
- isActive: At,
1268
- disabled: Y(W, I, L, K)
1278
+ run: jt,
1279
+ isActive: Mt,
1280
+ disabled: Y(W, F, I, K)
1269
1281
  },
1270
1282
  {
1271
1283
  id: "table",
1272
1284
  title: "Table",
1273
- run: mt,
1285
+ run: gt,
1274
1286
  isActive: W,
1275
- disabled: Y(W, q, I, L, K)
1287
+ disabled: Y(W, q, F, I, K)
1276
1288
  },
1277
1289
  Z("math", "Inline math", "$"),
1278
1290
  {
1279
1291
  id: "mathBlock",
1280
1292
  title: "Block math",
1281
- run: (e) => N(e, (e, t, n) => A(e, t, n, "$")) || (W(e.state) ? R(e, "$") : Ge(e)),
1282
- isActive: (e) => W(e) ? z(e, "$") : L(e),
1283
- disabled: Y(q, I, K)
1293
+ run: (e) => M(e, (e, t, n) => k(e, t, n, "$")) || (W(e.state) ? R(e, "$") : Je(e)),
1294
+ isActive: (e) => W(e) ? z(e, "$") : I(e),
1295
+ disabled: Y(q, F, K)
1284
1296
  }
1285
- ], qt = Object.fromEntries(Kt.map((e) => [e.id, e])), Jt = m.high(o.of(Kt.filter((e) => e.keys && e.keys.length > 0).flatMap((e) => e.keys.map((t) => ({
1297
+ ], Yt = Object.fromEntries(Jt.map((e) => [e.id, e])), Xt = te.high(o.of(Jt.filter((e) => e.keys && e.keys.length > 0).flatMap((e) => e.keys.map((t) => ({
1286
1298
  key: t,
1287
1299
  preventDefault: !0,
1288
1300
  run: ((t) => !e.disabled?.(t.state) && e.run(t))
1289
- }))))), Yt = /(?<=^|\s)#[^\s#]*$/;
1290
- function Xt(e) {
1301
+ }))))), Zt = /(?<=^|\s)#[^\s#]*$/;
1302
+ function Qt(e) {
1291
1303
  return {
1292
1304
  label: e.tag,
1293
1305
  apply: (t, n, r, i) => {
@@ -1303,15 +1315,15 @@ function Xt(e) {
1303
1315
  }
1304
1316
  };
1305
1317
  }
1306
- function Zt(e, t) {
1318
+ function $t(e, t) {
1307
1319
  return async (n) => {
1308
- let r = n.matchBefore(Yt);
1320
+ let r = n.matchBefore(Zt);
1309
1321
  if (!r || r.from + 1 === n.pos && !n.explicit) return null;
1310
1322
  let i = r.text.slice(1);
1311
1323
  if (/^\d/.test(i)) return null;
1312
1324
  let a;
1313
1325
  try {
1314
- a = (await e(i)).map(Xt);
1326
+ a = (await e(i)).map(Qt);
1315
1327
  } catch (e) {
1316
1328
  return t?.(e, {
1317
1329
  source: "tagSource",
@@ -1326,12 +1338,12 @@ function Zt(e, t) {
1326
1338
  } : null;
1327
1339
  };
1328
1340
  }
1329
- function Qt(e, t) {
1330
- return e ? [le(), y.data.of({ autocomplete: Zt(e, t) })] : [];
1341
+ function en(e, t) {
1342
+ return e ? [ue(), _.data.of({ autocomplete: $t(e, t) })] : [];
1331
1343
  }
1332
1344
  //#endregion
1333
1345
  //#region src/editor/theme.ts
1334
- var $t = a.theme({
1346
+ var tn = a.theme({
1335
1347
  "&": {
1336
1348
  color: "var(--stylo-text)",
1337
1349
  backgroundColor: "var(--stylo-bg)",
@@ -1437,8 +1449,8 @@ var $t = a.theme({
1437
1449
  backgroundColor: "color-mix(in srgb, var(--stylo-ring) 70%, transparent)",
1438
1450
  outline: "1px solid var(--stylo-ring)"
1439
1451
  }
1440
- }), en = /\[\[([^[\]\n|]*)$/;
1441
- function tn(e) {
1452
+ }), nn = /\[\[([^[\]\n|]*)$/;
1453
+ function rn(e) {
1442
1454
  let t = e.label && e.label !== e.target ? e.label : void 0, n = t ? `${e.target}|${t}` : e.target;
1443
1455
  return {
1444
1456
  label: e.label ?? e.target,
@@ -1456,13 +1468,13 @@ function tn(e) {
1456
1468
  }
1457
1469
  };
1458
1470
  }
1459
- function nn(e, t) {
1471
+ function an(e, t) {
1460
1472
  return async (n) => {
1461
- let r = n.matchBefore(en);
1473
+ let r = n.matchBefore(nn);
1462
1474
  if (!r || r.from + 2 === n.pos && !n.explicit) return null;
1463
1475
  let i = r.text.slice(2), a;
1464
1476
  try {
1465
- a = (await e(i)).map(tn);
1477
+ a = (await e(i)).map(rn);
1466
1478
  } catch (e) {
1467
1479
  return t?.(e, {
1468
1480
  source: "wikiLinkSource",
@@ -1477,117 +1489,117 @@ function nn(e, t) {
1477
1489
  } : null;
1478
1490
  };
1479
1491
  }
1480
- function rn(e, t) {
1481
- return e ? [le(), y.data.of({ autocomplete: nn(e, t) })] : [];
1492
+ function on(e, t) {
1493
+ return e ? [ue(), _.data.of({ autocomplete: an(e, t) })] : [];
1482
1494
  }
1483
1495
  //#endregion
1484
1496
  //#region src/editor/extensions.ts
1485
- function an(e, n, r, i) {
1497
+ function sn(e, n, r, i) {
1486
1498
  return [
1487
- ne(),
1488
- o.of([...te, ...h]),
1489
- m.high(_t),
1490
- Jt,
1491
- vt,
1492
- D({
1499
+ re(),
1500
+ o.of([...ne, ...m]),
1501
+ te.high(yt),
1502
+ Xt,
1503
+ bt,
1504
+ E({
1493
1505
  top: !0,
1494
- createPanel: Gt
1506
+ createPanel: qt
1495
1507
  }),
1496
- o.of(ie),
1497
- v({
1498
- base: y,
1508
+ o.of(ae),
1509
+ ie({
1510
+ base: _,
1499
1511
  codeLanguages: e
1500
1512
  }),
1501
1513
  t,
1502
- rn(n, r),
1503
- Qt(i, r),
1514
+ on(n, r),
1515
+ en(i, r),
1504
1516
  a.lineWrapping,
1505
- $t
1517
+ tn
1506
1518
  ];
1507
1519
  }
1508
- function on(e) {
1520
+ function cn(e) {
1509
1521
  return [
1510
1522
  p.readOnly.of(e.readOnly),
1511
1523
  a.editable.of(!e.readOnly),
1512
1524
  e.placeholder ? s(e.placeholder) : [],
1513
- e.save ? Pt.of(e.save) : []
1525
+ e.save ? It.of(e.save) : []
1514
1526
  ];
1515
1527
  }
1516
1528
  //#endregion
1517
1529
  //#region src/editor/useCodeMirror.ts
1518
- var sn = l.define();
1519
- function cn({ value: e, onChange: t, readOnly: n = !1, placeholder: s, onSave: c, onViewChange: l, extensions: u, hostExtensions: f, codeLanguages: ee, wikiLinkSource: te, tagSource: ne, onResolveError: h }) {
1520
- let g = i(null), _ = i(null), v = i(t);
1521
- v.current = t;
1522
- let y = i([]), re = i(c);
1523
- re.current = c;
1524
- let b = i((e) => re.current?.(e)).current, x = i(h);
1525
- x.current = h;
1526
- let S = i((e, t) => {
1527
- x.current?.(e, t);
1528
- }).current, C = c != null, w = i(l);
1529
- w.current = l;
1530
- let T = i(new d()), E = i(new d()), D = i(f);
1530
+ var ln = l.define();
1531
+ function un({ value: e, onChange: t, readOnly: n = !1, placeholder: s, onSave: c, onViewChange: l, extensions: u, hostExtensions: f, codeLanguages: ee, wikiLinkSource: ne, tagSource: re, onResolveError: m }) {
1532
+ let h = i(null), g = i(null), ie = i(t);
1533
+ ie.current = t;
1534
+ let _ = i([]), v = i(c);
1535
+ v.current = c;
1536
+ let y = i((e) => v.current?.(e)).current, b = i(m);
1537
+ b.current = m;
1538
+ let x = i((e, t) => {
1539
+ b.current?.(e, t);
1540
+ }).current, S = c != null, C = i(l);
1541
+ C.current = l;
1542
+ let w = i(new d()), T = i(new d()), E = i(f);
1531
1543
  return r(() => {
1532
- let t = g.current;
1544
+ let t = h.current;
1533
1545
  if (!t) return;
1534
1546
  let r = new a({
1535
1547
  parent: t,
1536
1548
  state: p.create({
1537
1549
  doc: e,
1538
1550
  extensions: [
1539
- an(ee, te, S, ne),
1540
- T.current.of(on({
1551
+ sn(ee, ne, x, re),
1552
+ w.current.of(cn({
1541
1553
  readOnly: n,
1542
1554
  placeholder: s,
1543
- save: C ? b : void 0
1555
+ save: S ? y : void 0
1544
1556
  })),
1545
- m.high(o.of([{
1557
+ te.high(o.of([{
1546
1558
  key: "Mod-s",
1547
- run: Ft
1559
+ run: Lt
1548
1560
  }])),
1549
1561
  ...u ?? [],
1550
- E.current.of(f ?? []),
1562
+ T.current.of(f ?? []),
1551
1563
  a.updateListener.of((e) => {
1552
- if (!e.docChanged || e.transactions.some((e) => !!e.annotation(sn))) return;
1564
+ if (!e.docChanged || e.transactions.some((e) => !!e.annotation(ln))) return;
1553
1565
  let t = e.state.doc.toString();
1554
- y.current.push(t), y.current.length > 20 && y.current.shift(), v.current(t);
1566
+ _.current.push(t), _.current.length > 20 && _.current.shift(), ie.current(t);
1555
1567
  })
1556
1568
  ]
1557
1569
  })
1558
1570
  });
1559
- return _.current = r, w.current?.(r), () => {
1560
- w.current?.(null), r.destroy(), _.current = null;
1571
+ return g.current = r, C.current?.(r), () => {
1572
+ C.current?.(null), r.destroy(), g.current = null;
1561
1573
  };
1562
1574
  }, []), r(() => {
1563
- let t = _.current;
1575
+ let t = g.current;
1564
1576
  if (!t) return;
1565
1577
  let n = t.state.doc.toString();
1566
- n !== e && (y.current.includes(e) || (t.dispatch({
1578
+ n !== e && (_.current.includes(e) || (t.dispatch({
1567
1579
  changes: {
1568
1580
  from: 0,
1569
1581
  to: n.length,
1570
1582
  insert: e
1571
1583
  },
1572
- annotations: sn.of(!0)
1573
- }), y.current = []));
1584
+ annotations: ln.of(!0)
1585
+ }), _.current = []));
1574
1586
  }, [e]), r(() => {
1575
- _.current?.dispatch({ effects: T.current.reconfigure(on({
1587
+ g.current?.dispatch({ effects: w.current.reconfigure(cn({
1576
1588
  readOnly: n,
1577
1589
  placeholder: s,
1578
- save: C ? b : void 0
1590
+ save: S ? y : void 0
1579
1591
  })) });
1580
1592
  }, [
1581
1593
  n,
1582
1594
  s,
1583
- C,
1584
- b
1595
+ S,
1596
+ y
1585
1597
  ]), r(() => {
1586
- let e = D.current;
1587
- e !== f && (e && f && e.length === f.length && e.every((e, t) => e === f[t]) || (D.current = f, _.current?.dispatch({ effects: E.current.reconfigure(f ?? []) })));
1588
- }, [f]), g;
1598
+ let e = E.current;
1599
+ e !== f && (e && f && e.length === f.length && e.every((e, t) => e === f[t]) || (E.current = f, g.current?.dispatch({ effects: T.current.reconfigure(f ?? []) })));
1600
+ }, [f]), h;
1589
1601
  }
1590
1602
  //#endregion
1591
- export { je as C, he as D, me as E, fe as O, Pe as S, ke as T, Re as _, X as a, M as b, wt as c, B as d, V as f, Fe as g, I as h, St as i, de as k, Ot as l, He as m, qt as n, Ct as o, Ke as p, Mt as r, xt as s, cn as t, ft as u, De as v, Oe as w, Ae as x, Me as y };
1603
+ export { Ne as C, ge as D, he as E, pe as O, Ie as S, Ae as T, Ve as _, X as a, j as b, Et as c, B as d, V as f, Re as g, F as h, wt as i, fe as k, At as l, Ge as m, Yt as n, Tt as o, L as p, Pt as r, Ct as s, un as t, mt as u, Oe as v, ke as w, Me as x, Pe as y };
1592
1604
 
1593
- //# sourceMappingURL=useCodeMirror-Fn6qEfMx.js.map
1605
+ //# sourceMappingURL=useCodeMirror-DbhMZGZ7.js.map