@damiro/stylo 0.20.1 → 0.21.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.
- package/dist/{InPlaceView-gei6uiAm.js → InPlaceView-BIdyqlek.js} +603 -525
- package/dist/InPlaceView-BIdyqlek.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/inplace/InPlaceView.d.ts.map +1 -1
- package/dist/inplace/config.d.ts +3 -1
- package/dist/inplace/config.d.ts.map +1 -1
- package/dist/inplace/extension.d.ts +3 -1
- package/dist/inplace/extension.d.ts.map +1 -1
- package/dist/inplace/table-cell-align.d.ts +9 -0
- package/dist/inplace/table-cell-align.d.ts.map +1 -0
- package/dist/inplace/table-cell-dom.d.ts +2 -0
- package/dist/inplace/table-cell-dom.d.ts.map +1 -1
- package/dist/inplace/table-cell-marks.d.ts +2 -0
- package/dist/inplace/table-cell-marks.d.ts.map +1 -1
- package/dist/inplace/table-cell-widgets.d.ts +26 -0
- package/dist/inplace/table-cell-widgets.d.ts.map +1 -0
- package/dist/inplace/table-marks-plugin.d.ts +1 -1
- package/dist/inplace/table-marks-plugin.d.ts.map +1 -1
- package/dist/inplace/table-widget.d.ts.map +1 -1
- package/dist/stylo.js +2 -2
- package/dist/types/inplace.d.ts +24 -0
- package/dist/types/inplace.d.ts.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/{useCodeMirror-DbhMZGZ7.js → useCodeMirror-O1ProA2R.js} +246 -234
- package/dist/useCodeMirror-O1ProA2R.js.map +1 -0
- package/package.json +1 -1
- package/dist/InPlaceView-gei6uiAm.js.map +0 -1
- package/dist/useCodeMirror-DbhMZGZ7.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
|
|
5
|
-
import { defaultKeymap as
|
|
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 re, undo as g } from "@codemirror/commands";
|
|
6
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
|
|
8
|
-
import { syntaxTree as
|
|
9
|
-
import { autocompletion as
|
|
7
|
+
import { SearchQuery as v, closeSearchPanel as y, findNext as b, findPrevious as x, getSearchQuery as S, openSearchPanel as C, replaceAll as ae, replaceNext as w, search as T, searchKeymap as oe, searchPanelOpen as se, selectMatches as ce, setSearchQuery as le } from "@codemirror/search";
|
|
8
|
+
import { syntaxTree as ue } from "@codemirror/language";
|
|
9
|
+
import { autocompletion as de } from "@codemirror/autocomplete";
|
|
10
10
|
//#region src/editor/canvas-header-panel.ts
|
|
11
|
-
var
|
|
11
|
+
var fe = "stylo-canvas-header", pe = 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 =
|
|
16
|
+
return e.className = fe, this.dom = e, this.notify(), {
|
|
17
17
|
dom: e,
|
|
18
18
|
top: !0,
|
|
19
19
|
destroy: () => {
|
|
@@ -29,7 +29,7 @@ var de = "stylo-canvas-header", fe = class {
|
|
|
29
29
|
};
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/toolbar/link-ops.ts
|
|
32
|
-
function
|
|
32
|
+
function E(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 D(e, t) {
|
|
|
41
41
|
}
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function me(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 pe(e, t) {
|
|
|
59
59
|
}
|
|
60
60
|
return null;
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
let r =
|
|
62
|
+
function he(e, t, n) {
|
|
63
|
+
let r = E(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 me(e, t, n) {
|
|
|
75
75
|
}
|
|
76
76
|
//#endregion
|
|
77
77
|
//#region src/toolbar/wikilink-ops.ts
|
|
78
|
-
function
|
|
78
|
+
function D(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 {
|
|
@@ -103,7 +103,7 @@ function ge(t, n) {
|
|
|
103
103
|
return null;
|
|
104
104
|
}
|
|
105
105
|
function _e(e, t, n) {
|
|
106
|
-
let r =
|
|
106
|
+
let r = D(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,
|
|
@@ -256,7 +256,7 @@ function k(e, t, n, r) {
|
|
|
256
256
|
};
|
|
257
257
|
}
|
|
258
258
|
function De(e, t) {
|
|
259
|
-
let n =
|
|
259
|
+
let n = E(e, t);
|
|
260
260
|
if (n) return {
|
|
261
261
|
from: n.from,
|
|
262
262
|
to: n.to
|
|
@@ -287,34 +287,44 @@ function De(e, t) {
|
|
|
287
287
|
}
|
|
288
288
|
//#endregion
|
|
289
289
|
//#region src/inplace/table-cell-dom.ts
|
|
290
|
-
var Oe = (e) => [e.head, ...e.body].map((e) => [...e]), ke = (e) => e.map((e) => e.map((e) => e.trim())), Ae = (e) => e.replace(/\\\|/g, "|");
|
|
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, "|"), A = "[data-stylo-cell-widget]";
|
|
291
|
+
function j(e) {
|
|
292
|
+
return e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT, { acceptNode: (e) => e.parentElement?.closest(A) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT });
|
|
293
|
+
}
|
|
294
|
+
function M(e) {
|
|
295
|
+
let t = j(e), n = "";
|
|
296
|
+
for (let e = t.nextNode(); e; e = t.nextNode()) n += e.textContent;
|
|
297
|
+
return n;
|
|
298
|
+
}
|
|
291
299
|
function je(e, t) {
|
|
292
|
-
let n =
|
|
300
|
+
let n = j(e), r = 0;
|
|
293
301
|
for (let e = n.nextNode(); e; e = n.nextNode()) {
|
|
294
302
|
if (e === t) return r;
|
|
295
303
|
r += e.textContent?.length ?? 0;
|
|
296
304
|
}
|
|
297
305
|
return r;
|
|
298
306
|
}
|
|
299
|
-
function
|
|
300
|
-
if (!t || !e.contains(t)) return (e
|
|
307
|
+
function N(e, t, n) {
|
|
308
|
+
if (!t || !e.contains(t)) return M(e).length;
|
|
301
309
|
let r = e.ownerDocument.createRange();
|
|
302
|
-
|
|
310
|
+
r.setStart(e, 0), r.setEnd(t, n);
|
|
311
|
+
let i = r.cloneContents();
|
|
312
|
+
return i.querySelectorAll(A).forEach((e) => e.remove()), (i.textContent ?? "").length;
|
|
303
313
|
}
|
|
304
314
|
function Me(e) {
|
|
305
315
|
let t = e.ownerDocument.getSelection();
|
|
306
|
-
return t?.anchorNode && e.contains(t.anchorNode) ?
|
|
316
|
+
return t?.anchorNode && e.contains(t.anchorNode) ? N(e, t.anchorNode, t.anchorOffset) : 0;
|
|
307
317
|
}
|
|
308
318
|
function Ne(e) {
|
|
309
319
|
let t = e.ownerDocument.getSelection();
|
|
310
320
|
if (!t || t.rangeCount === 0) {
|
|
311
|
-
let t = (e
|
|
321
|
+
let t = M(e).length;
|
|
312
322
|
return {
|
|
313
323
|
from: t,
|
|
314
324
|
to: t
|
|
315
325
|
};
|
|
316
326
|
}
|
|
317
|
-
let n =
|
|
327
|
+
let n = N(e, t.anchorNode, t.anchorOffset), r = N(e, t.focusNode, t.focusOffset);
|
|
318
328
|
return {
|
|
319
329
|
from: Math.min(n, r),
|
|
320
330
|
to: Math.max(n, r)
|
|
@@ -329,26 +339,28 @@ function Pe(e, t, n) {
|
|
|
329
339
|
let e = r.caretRangeFromPoint(t, n);
|
|
330
340
|
e && ([i, a] = [e.startContainer, e.startOffset]);
|
|
331
341
|
}
|
|
332
|
-
|
|
342
|
+
if (!i || !e.contains(i)) return 0;
|
|
343
|
+
let o = i.parentElement?.closest(A);
|
|
344
|
+
return o ? N(e, o, 0) : je(e, i) + (i.nodeType === Node.TEXT_NODE ? a : 0);
|
|
333
345
|
}
|
|
334
346
|
var Fe = /[\p{L}\p{N}_]/u;
|
|
335
347
|
function Ie(e, t, n) {
|
|
336
|
-
let r = e
|
|
337
|
-
if (a) return
|
|
348
|
+
let r = M(e), i = Pe(e, t, n), a = De(r, i);
|
|
349
|
+
if (a) return P(e, a.from, a.to), !0;
|
|
338
350
|
let o = i, s = i;
|
|
339
351
|
for (; o > 0 && Fe.test(r[o - 1]);) o--;
|
|
340
352
|
for (; s < r.length && Fe.test(r[s]);) s++;
|
|
341
|
-
return s <= o ? !1 : (
|
|
353
|
+
return s <= o ? !1 : (P(e, o, s), !0);
|
|
342
354
|
}
|
|
343
355
|
function Le(e, t) {
|
|
344
|
-
let n =
|
|
356
|
+
let n = j(e), r = t, i = null;
|
|
345
357
|
for (let e = n.nextNode(); e; e = n.nextNode()) {
|
|
346
358
|
if (r <= e.data.length) return [e, r];
|
|
347
359
|
r -= e.data.length, i = e;
|
|
348
360
|
}
|
|
349
361
|
return i ? [i, i.data.length] : [e, 0];
|
|
350
362
|
}
|
|
351
|
-
function
|
|
363
|
+
function P(e, t, n = t) {
|
|
352
364
|
e.focus();
|
|
353
365
|
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
366
|
s[0] === e ? i.selectNodeContents(e) : (i.setStart(s[0], s[1]), i.setEnd(c[0], c[1])), t === n && i.collapse(!0);
|
|
@@ -363,9 +375,9 @@ function Re(e) {
|
|
|
363
375
|
}
|
|
364
376
|
function ze(e, t) {
|
|
365
377
|
let { from: n, to: r } = Ne(e), i = t(e.textContent ?? "", n, r);
|
|
366
|
-
e.textContent = i.text,
|
|
378
|
+
e.textContent = i.text, P(e, i.from, i.to), e.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
367
379
|
}
|
|
368
|
-
function
|
|
380
|
+
function F(e, t) {
|
|
369
381
|
let n = Re(e);
|
|
370
382
|
return n ? (ze(n, t), !0) : !1;
|
|
371
383
|
}
|
|
@@ -373,7 +385,7 @@ var Be = {
|
|
|
373
385
|
b: (e, t, n) => k(e, t, n, "**"),
|
|
374
386
|
i: (e, t, n) => k(e, t, n, "*"),
|
|
375
387
|
u: ye,
|
|
376
|
-
k:
|
|
388
|
+
k: he,
|
|
377
389
|
K: _e
|
|
378
390
|
};
|
|
379
391
|
function Ve(e, t) {
|
|
@@ -383,12 +395,12 @@ function Ve(e, t) {
|
|
|
383
395
|
}
|
|
384
396
|
//#endregion
|
|
385
397
|
//#region src/toolbar/block.ts
|
|
386
|
-
function
|
|
398
|
+
function I(e) {
|
|
387
399
|
let { from: t, to: n } = e.selection.main;
|
|
388
400
|
return [e.doc.lineAt(t).number, e.doc.lineAt(n).number];
|
|
389
401
|
}
|
|
390
402
|
function He(e, t) {
|
|
391
|
-
let n = e.state, [r, i] =
|
|
403
|
+
let n = e.state, [r, i] = I(n), a = r === i && !n.doc.line(r).text.trim(), o = !a;
|
|
392
404
|
for (let e = r; e <= i && o; e++) {
|
|
393
405
|
let r = n.doc.line(e).text;
|
|
394
406
|
r.trim() && !t.match.test(r) && (o = !1);
|
|
@@ -430,8 +442,8 @@ function Ue(e, t) {
|
|
|
430
442
|
}
|
|
431
443
|
//#endregion
|
|
432
444
|
//#region src/toolbar/fence.ts
|
|
433
|
-
function
|
|
434
|
-
for (let n =
|
|
445
|
+
function We(e, t) {
|
|
446
|
+
for (let n = ue(e).resolveInner(t, 0); n; n = n.parent) {
|
|
435
447
|
if (n.name === "FencedCode") return {
|
|
436
448
|
from: n.from,
|
|
437
449
|
to: n.to
|
|
@@ -440,8 +452,8 @@ function P(e, t) {
|
|
|
440
452
|
}
|
|
441
453
|
return null;
|
|
442
454
|
}
|
|
443
|
-
function
|
|
444
|
-
let t = e.state, n =
|
|
455
|
+
function Ge(e) {
|
|
456
|
+
let t = e.state, n = We(t, t.selection.main.head);
|
|
445
457
|
if (n) {
|
|
446
458
|
let r = t.doc.lineAt(n.from), i = t.doc.lineAt(n.to), a = [{
|
|
447
459
|
from: r.from,
|
|
@@ -455,7 +467,7 @@ function We(e) {
|
|
|
455
467
|
scrollIntoView: !0
|
|
456
468
|
});
|
|
457
469
|
} else {
|
|
458
|
-
let [n, r] =
|
|
470
|
+
let [n, r] = I(t);
|
|
459
471
|
e.dispatch({
|
|
460
472
|
changes: [{
|
|
461
473
|
from: t.doc.line(n).from,
|
|
@@ -470,11 +482,11 @@ function We(e) {
|
|
|
470
482
|
}
|
|
471
483
|
return e.focus(), !0;
|
|
472
484
|
}
|
|
473
|
-
function
|
|
474
|
-
return
|
|
485
|
+
function L(e) {
|
|
486
|
+
return We(e, e.selection.main.head) !== null;
|
|
475
487
|
}
|
|
476
|
-
function
|
|
477
|
-
let t =
|
|
488
|
+
function Ke(e) {
|
|
489
|
+
let t = We(e, e.selection.main.head);
|
|
478
490
|
if (!t) return null;
|
|
479
491
|
let n = e.doc.lineAt(t.from), r = /^(\s*(?:`{3,}|~{3,})[ \t]*)(.*?)[ \t]*$/.exec(n.text);
|
|
480
492
|
if (!r) return null;
|
|
@@ -485,18 +497,18 @@ function Ge(e) {
|
|
|
485
497
|
lang: r[2]
|
|
486
498
|
};
|
|
487
499
|
}
|
|
488
|
-
var
|
|
489
|
-
function
|
|
500
|
+
var qe = /^\s*\$\$\s*$/;
|
|
501
|
+
function Je(e, t) {
|
|
490
502
|
let n = 0, r = 0;
|
|
491
|
-
for (let i = 1; i <= e.doc.lines; i++) if (
|
|
503
|
+
for (let i = 1; i <= e.doc.lines; i++) if (qe.test(e.doc.line(i).text)) {
|
|
492
504
|
if (r++, r % 2 == 1) {
|
|
493
505
|
if (n = i, i > t) return null;
|
|
494
506
|
} else if (i >= t) return [n, i];
|
|
495
507
|
}
|
|
496
508
|
return null;
|
|
497
509
|
}
|
|
498
|
-
function
|
|
499
|
-
let t = e.state, [n, r] =
|
|
510
|
+
function Ye(e) {
|
|
511
|
+
let t = e.state, [n, r] = I(t), i = Je(t, t.doc.lineAt(t.selection.main.head).number);
|
|
500
512
|
if (i) {
|
|
501
513
|
let n = t.doc.line(i[0]), r = t.doc.line(i[1]);
|
|
502
514
|
e.dispatch({
|
|
@@ -522,16 +534,16 @@ function Je(e) {
|
|
|
522
534
|
});
|
|
523
535
|
return e.focus(), !0;
|
|
524
536
|
}
|
|
525
|
-
function
|
|
526
|
-
return
|
|
537
|
+
function R(e) {
|
|
538
|
+
return Je(e, e.doc.lineAt(e.selection.main.head).number) !== null;
|
|
527
539
|
}
|
|
528
540
|
//#endregion
|
|
529
541
|
//#region src/toolbar/heading.ts
|
|
530
|
-
var
|
|
531
|
-
function
|
|
532
|
-
let n = "#".repeat(t) + " ", r = e.state, [i, a] =
|
|
542
|
+
var Xe = /^(#{1,6}) +/;
|
|
543
|
+
function Ze(e, t) {
|
|
544
|
+
let n = "#".repeat(t) + " ", r = e.state, [i, a] = I(r), o = [];
|
|
533
545
|
for (let e = i; e <= a; e++) {
|
|
534
|
-
let i = r.doc.line(e), a =
|
|
546
|
+
let i = r.doc.line(e), a = Xe.exec(i.text);
|
|
535
547
|
a && a[1].length === t ? o.push({
|
|
536
548
|
from: i.from,
|
|
537
549
|
to: i.from + a[0].length
|
|
@@ -549,10 +561,10 @@ function Ye(e, t) {
|
|
|
549
561
|
scrollIntoView: !0
|
|
550
562
|
}), e.focus(), !0;
|
|
551
563
|
}
|
|
552
|
-
function
|
|
553
|
-
let t = e.state, [n, r] =
|
|
564
|
+
function Qe(e) {
|
|
565
|
+
let t = e.state, [n, r] = I(t), i = [];
|
|
554
566
|
for (let e = n; e <= r; e++) {
|
|
555
|
-
let n = t.doc.line(e), r =
|
|
567
|
+
let n = t.doc.line(e), r = Xe.exec(n.text);
|
|
556
568
|
r && i.push({
|
|
557
569
|
from: n.from,
|
|
558
570
|
to: n.from + r[0].length
|
|
@@ -565,7 +577,7 @@ function Xe(e) {
|
|
|
565
577
|
}
|
|
566
578
|
//#endregion
|
|
567
579
|
//#region src/toolbar/inline.ts
|
|
568
|
-
function
|
|
580
|
+
function $e(e, t) {
|
|
569
581
|
let n = e.state.doc.toString();
|
|
570
582
|
return e.dispatch({
|
|
571
583
|
...e.state.changeByRange((e) => {
|
|
@@ -587,16 +599,16 @@ function z(e, t) {
|
|
|
587
599
|
}
|
|
588
600
|
return !1;
|
|
589
601
|
}
|
|
590
|
-
function
|
|
591
|
-
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r =
|
|
602
|
+
function et(e) {
|
|
603
|
+
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = E(n.text, t - n.from);
|
|
592
604
|
return r ? {
|
|
593
605
|
from: n.from + r.from,
|
|
594
606
|
to: n.from + r.to,
|
|
595
607
|
text: r.label
|
|
596
608
|
} : null;
|
|
597
609
|
}
|
|
598
|
-
function
|
|
599
|
-
let t =
|
|
610
|
+
function tt(e) {
|
|
611
|
+
let t = et(e.state);
|
|
600
612
|
if (t) return e.dispatch({
|
|
601
613
|
changes: {
|
|
602
614
|
from: t.from,
|
|
@@ -617,19 +629,19 @@ function Qe(e) {
|
|
|
617
629
|
scrollIntoView: !0
|
|
618
630
|
}), e.focus(), !0;
|
|
619
631
|
}
|
|
620
|
-
function
|
|
621
|
-
return
|
|
632
|
+
function nt(e) {
|
|
633
|
+
return et(e) !== null;
|
|
622
634
|
}
|
|
623
|
-
function
|
|
624
|
-
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r =
|
|
635
|
+
function rt(e) {
|
|
636
|
+
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = D(n.text, t - n.from);
|
|
625
637
|
return r ? {
|
|
626
638
|
from: n.from + r.from,
|
|
627
639
|
to: n.from + r.to,
|
|
628
640
|
text: r.label
|
|
629
641
|
} : null;
|
|
630
642
|
}
|
|
631
|
-
function
|
|
632
|
-
let t =
|
|
643
|
+
function it(e) {
|
|
644
|
+
let t = rt(e.state);
|
|
633
645
|
if (t) return e.dispatch({
|
|
634
646
|
changes: {
|
|
635
647
|
from: t.from,
|
|
@@ -650,10 +662,10 @@ function tt(e) {
|
|
|
650
662
|
scrollIntoView: !0
|
|
651
663
|
}), e.focus(), !0;
|
|
652
664
|
}
|
|
653
|
-
function
|
|
654
|
-
return
|
|
665
|
+
function at(e) {
|
|
666
|
+
return rt(e) !== null;
|
|
655
667
|
}
|
|
656
|
-
function
|
|
668
|
+
function ot(e) {
|
|
657
669
|
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = ve(n.text, t - n.from);
|
|
658
670
|
return r ? {
|
|
659
671
|
from: n.from + r.from,
|
|
@@ -661,8 +673,8 @@ function rt(e) {
|
|
|
661
673
|
inner: r.inner
|
|
662
674
|
} : null;
|
|
663
675
|
}
|
|
664
|
-
function
|
|
665
|
-
let t =
|
|
676
|
+
function st(e) {
|
|
677
|
+
let t = ot(e.state);
|
|
666
678
|
if (t) return e.dispatch({
|
|
667
679
|
changes: {
|
|
668
680
|
from: t.from,
|
|
@@ -683,29 +695,29 @@ function it(e) {
|
|
|
683
695
|
scrollIntoView: !0
|
|
684
696
|
}), e.focus(), !0;
|
|
685
697
|
}
|
|
686
|
-
function
|
|
687
|
-
return
|
|
698
|
+
function ct(e) {
|
|
699
|
+
return ot(e) !== null;
|
|
688
700
|
}
|
|
689
701
|
//#endregion
|
|
690
702
|
//#region src/toolbar/table-grid.ts
|
|
691
|
-
function
|
|
703
|
+
function lt(e) {
|
|
692
704
|
let t = e.trim();
|
|
693
705
|
return t.includes("-") && t.includes("|") && /^[\s|:-]+$/.test(t);
|
|
694
706
|
}
|
|
695
|
-
function
|
|
707
|
+
function ut(e) {
|
|
696
708
|
let t = e.trim();
|
|
697
709
|
t.startsWith("|") && (t = t.slice(1)), t.endsWith("|") && !t.endsWith("\\|") && (t = t.slice(0, -1));
|
|
698
710
|
let n = [], r = "";
|
|
699
711
|
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];
|
|
700
712
|
return n.push(r.trim()), n;
|
|
701
713
|
}
|
|
702
|
-
function
|
|
714
|
+
function dt(e) {
|
|
703
715
|
let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
|
|
704
716
|
return n && r ? "center" : r ? "right" : n ? "left" : "";
|
|
705
717
|
}
|
|
706
718
|
function B(e) {
|
|
707
|
-
if (e.length < 2 || !
|
|
708
|
-
let t =
|
|
719
|
+
if (e.length < 2 || !lt(e[1])) return null;
|
|
720
|
+
let t = ut(e[1]).map(dt), n = e.filter((e, t) => t !== 1).map(ut), r = Math.max(t.length, ...n.map((e) => e.length)), i = n.map((e) => {
|
|
709
721
|
let t = e.slice(0, r);
|
|
710
722
|
for (; t.length < r;) t.push("");
|
|
711
723
|
return t;
|
|
@@ -716,11 +728,11 @@ function B(e) {
|
|
|
716
728
|
aligns: a
|
|
717
729
|
};
|
|
718
730
|
}
|
|
719
|
-
function
|
|
731
|
+
function ft(e) {
|
|
720
732
|
return e.replace(/\\\|/g, "|").length;
|
|
721
733
|
}
|
|
722
|
-
function
|
|
723
|
-
let r = t -
|
|
734
|
+
function pt(e, t, n) {
|
|
735
|
+
let r = t - ft(e);
|
|
724
736
|
if (r <= 0) return e;
|
|
725
737
|
if (n === "right") return " ".repeat(r) + e;
|
|
726
738
|
if (n === "center") {
|
|
@@ -729,7 +741,7 @@ function ut(e, t, n) {
|
|
|
729
741
|
}
|
|
730
742
|
return e + " ".repeat(r);
|
|
731
743
|
}
|
|
732
|
-
function
|
|
744
|
+
function mt(e, t) {
|
|
733
745
|
let n = Math.max(3, e);
|
|
734
746
|
return t === "left" ? ":" + "-".repeat(n - 1) : t === "right" ? "-".repeat(n - 1) + ":" : t === "center" ? ":" + "-".repeat(n - 2) + ":" : "-".repeat(n);
|
|
735
747
|
}
|
|
@@ -737,15 +749,15 @@ function V(e) {
|
|
|
737
749
|
let t = e.aligns.length, n = [];
|
|
738
750
|
for (let r = 0; r < t; r++) {
|
|
739
751
|
let t = 3;
|
|
740
|
-
for (let n of e.rows) t = Math.max(t,
|
|
752
|
+
for (let n of e.rows) t = Math.max(t, ft(n[r] ?? ""));
|
|
741
753
|
n.push(t);
|
|
742
754
|
}
|
|
743
|
-
let r = (t) => "| " + t.map((t, r) =>
|
|
744
|
-
i.push("| " + e.aligns.map((e, t) =>
|
|
755
|
+
let r = (t) => "| " + t.map((t, r) => pt(t ?? "", n[r], e.aligns[r])).join(" | ") + " |", i = [r(e.rows[0] ?? [])];
|
|
756
|
+
i.push("| " + e.aligns.map((e, t) => mt(n[t], e)).join(" | ") + " |");
|
|
745
757
|
for (let t = 1; t < e.rows.length; t++) i.push(r(e.rows[t]));
|
|
746
758
|
return i.join("\n");
|
|
747
759
|
}
|
|
748
|
-
function
|
|
760
|
+
function ht(e) {
|
|
749
761
|
let t = [];
|
|
750
762
|
for (let n = 0; n < e.length; n++) {
|
|
751
763
|
if (e[n] === "\\") {
|
|
@@ -792,7 +804,7 @@ function H(e, t) {
|
|
|
792
804
|
lines: a
|
|
793
805
|
} : null;
|
|
794
806
|
}
|
|
795
|
-
function
|
|
807
|
+
function gt(e, t, n) {
|
|
796
808
|
let r = t;
|
|
797
809
|
for (let t = 0; t < e.length; t++) {
|
|
798
810
|
let i = e[t];
|
|
@@ -808,7 +820,7 @@ function pt(e, t, n) {
|
|
|
808
820
|
onDelimiter: !0
|
|
809
821
|
};
|
|
810
822
|
}
|
|
811
|
-
let a =
|
|
823
|
+
let a = ht(i), o = 0;
|
|
812
824
|
for (let t = 0; t < a.length && (o = t, !(e <= a[t].end)); t++);
|
|
813
825
|
let s = a[o], c = s ? Math.max(0, Math.min(e, s.contentEnd) - s.contentStart) : 0;
|
|
814
826
|
return {
|
|
@@ -825,10 +837,10 @@ function pt(e, t, n) {
|
|
|
825
837
|
function U(e, t, n) {
|
|
826
838
|
let r = e.split("\n"), i = n.onDelimiter ? 1 : n.row === 0 ? 0 : n.row + 1, a = t;
|
|
827
839
|
for (let e = 0; e < i; e++) a += r[e].length + 1;
|
|
828
|
-
let o =
|
|
840
|
+
let o = ht(r[i]), s = o[Math.min(n.col, o.length - 1)];
|
|
829
841
|
return s ? a + s.contentStart + Math.min(n.offset, s.contentEnd - s.contentStart) : a;
|
|
830
842
|
}
|
|
831
|
-
function
|
|
843
|
+
function _t(e, t, n, r) {
|
|
832
844
|
let i = H(e, t);
|
|
833
845
|
return !i || n > i.lines.length - 2 ? null : U(i.lines.join("\n"), i.from, {
|
|
834
846
|
row: n,
|
|
@@ -839,7 +851,7 @@ function mt(e, t, n, r) {
|
|
|
839
851
|
}
|
|
840
852
|
//#endregion
|
|
841
853
|
//#region src/toolbar/table.ts
|
|
842
|
-
function
|
|
854
|
+
function vt(e, t) {
|
|
843
855
|
requestAnimationFrame(() => {
|
|
844
856
|
let n = e.dom.querySelectorAll(".cm-inplace-table-edit");
|
|
845
857
|
if (n.length === 0) return;
|
|
@@ -859,7 +871,7 @@ function ht(e, t) {
|
|
|
859
871
|
s?.removeAllRanges(), s?.addRange(o), a.focus();
|
|
860
872
|
});
|
|
861
873
|
}
|
|
862
|
-
function
|
|
874
|
+
function yt(e) {
|
|
863
875
|
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;
|
|
864
876
|
return e.dispatch({
|
|
865
877
|
changes: {
|
|
@@ -869,7 +881,7 @@ function gt(e) {
|
|
|
869
881
|
},
|
|
870
882
|
selection: f.range(a, a + 8),
|
|
871
883
|
scrollIntoView: !0
|
|
872
|
-
}), e.focus(),
|
|
884
|
+
}), e.focus(), vt(e, a), !0;
|
|
873
885
|
}
|
|
874
886
|
function W(e) {
|
|
875
887
|
return H(e.doc, e.selection.main.head) !== null;
|
|
@@ -877,7 +889,7 @@ function W(e) {
|
|
|
877
889
|
function G(e, t) {
|
|
878
890
|
let n = H(e.state.doc, e.state.selection.main.head);
|
|
879
891
|
if (!n) return !1;
|
|
880
|
-
let r = B(n.lines), i =
|
|
892
|
+
let r = B(n.lines), i = gt(n.lines, n.from, e.state.selection.main.head);
|
|
881
893
|
if (!r || !i) return !1;
|
|
882
894
|
let a = t(r, i);
|
|
883
895
|
if (!a) return !1;
|
|
@@ -892,7 +904,7 @@ function G(e, t) {
|
|
|
892
904
|
scrollIntoView: !0
|
|
893
905
|
}), e.focus(), !0;
|
|
894
906
|
}
|
|
895
|
-
function
|
|
907
|
+
function bt(e, t, n) {
|
|
896
908
|
let r = e.aligns.length, { row: i, col: a } = t;
|
|
897
909
|
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("")), {
|
|
898
910
|
row: i,
|
|
@@ -901,7 +913,7 @@ function _t(e, t, n) {
|
|
|
901
913
|
onDelimiter: !1
|
|
902
914
|
});
|
|
903
915
|
}
|
|
904
|
-
function
|
|
916
|
+
function xt(e, t) {
|
|
905
917
|
let n = t.row + 1;
|
|
906
918
|
return n >= e.rows.length && e.rows.push(Array(e.aligns.length).fill("")), {
|
|
907
919
|
row: n,
|
|
@@ -910,20 +922,20 @@ function vt(e, t) {
|
|
|
910
922
|
onDelimiter: !1
|
|
911
923
|
};
|
|
912
924
|
}
|
|
913
|
-
var
|
|
925
|
+
var St = o.of([
|
|
914
926
|
{
|
|
915
927
|
key: "Tab",
|
|
916
|
-
run: (e) => G(e, (e, t) =>
|
|
928
|
+
run: (e) => G(e, (e, t) => bt(e, t, 1))
|
|
917
929
|
},
|
|
918
930
|
{
|
|
919
931
|
key: "Shift-Tab",
|
|
920
|
-
run: (e) => G(e, (e, t) =>
|
|
932
|
+
run: (e) => G(e, (e, t) => bt(e, t, -1))
|
|
921
933
|
},
|
|
922
934
|
{
|
|
923
935
|
key: "Enter",
|
|
924
|
-
run: (e) => G(e,
|
|
936
|
+
run: (e) => G(e, xt)
|
|
925
937
|
}
|
|
926
|
-
]),
|
|
938
|
+
]), Ct = p.transactionFilter.of((e) => {
|
|
927
939
|
if (!e.docChanged || e.isUserEvent("input.type.compose") || !e.isUserEvent("input") && !e.isUserEvent("delete")) return e;
|
|
928
940
|
let t = e.newSelection.main.head, n = H(e.newDoc, t);
|
|
929
941
|
if (!n) return e;
|
|
@@ -931,7 +943,7 @@ var yt = o.of([
|
|
|
931
943
|
if (!r) return e;
|
|
932
944
|
let i = V(r);
|
|
933
945
|
if (i === n.lines.join("\n")) return e;
|
|
934
|
-
let a =
|
|
946
|
+
let a = gt(n.lines, n.from, t), o = u.of([{
|
|
935
947
|
from: n.from,
|
|
936
948
|
to: n.to,
|
|
937
949
|
insert: i
|
|
@@ -945,23 +957,23 @@ var yt = o.of([
|
|
|
945
957
|
}), K = (e) => /^\s{0,3}#{1,6}(?:\s|$)/.test(e.doc.lineAt(e.selection.main.head).text), q = (e) => {
|
|
946
958
|
let t = n(e.doc);
|
|
947
959
|
return t !== null && e.selection.main.head <= t.to;
|
|
948
|
-
}, J = (e) => q(e) ||
|
|
960
|
+
}, J = (e) => q(e) || L(e) || R(e), wt = (e) => (t) => e !== "`" && z(t, "`") || e !== "$" && z(t, "$"), Tt = (e) => e.selection.main.empty && !e.wordAt(e.selection.main.head), Y = (...e) => (t) => e.some((e) => e(t)), X = /^(\s*)(?:[-*+] \[[ xX]\] +|\d+[.)] +|[-*+] +)/, Et = {
|
|
949
961
|
match: /^ {0,3}> ?/,
|
|
950
962
|
insert: "> "
|
|
951
|
-
},
|
|
963
|
+
}, Dt = {
|
|
952
964
|
match: /^(\s*)[-*+] +(?!\[[ xX]\])/,
|
|
953
965
|
insert: "- ",
|
|
954
966
|
siblings: X
|
|
955
|
-
},
|
|
967
|
+
}, Ot = {
|
|
956
968
|
match: /^(\s*)\d+[.)] +/,
|
|
957
969
|
insert: (e) => `${e + 1}. `,
|
|
958
970
|
siblings: X
|
|
959
|
-
},
|
|
971
|
+
}, kt = {
|
|
960
972
|
match: /^(\s*)[-*+] \[[ xX]\] +/,
|
|
961
973
|
insert: "- [ ] ",
|
|
962
974
|
siblings: X
|
|
963
975
|
};
|
|
964
|
-
function
|
|
976
|
+
function At(e, t, n) {
|
|
965
977
|
return {
|
|
966
978
|
id: e,
|
|
967
979
|
title: t,
|
|
@@ -975,24 +987,24 @@ function Z(e, t, n, r) {
|
|
|
975
987
|
return {
|
|
976
988
|
id: e,
|
|
977
989
|
title: t,
|
|
978
|
-
run: (e) =>
|
|
990
|
+
run: (e) => F(e, (e, t, r) => k(e, t, r, n)) || $e(e, n),
|
|
979
991
|
isActive: (e) => z(e, n),
|
|
980
|
-
disabled: Y(J,
|
|
992
|
+
disabled: Y(J, wt(n), Tt),
|
|
981
993
|
keys: r
|
|
982
994
|
};
|
|
983
995
|
}
|
|
984
|
-
function
|
|
996
|
+
function jt(e) {
|
|
985
997
|
let t = RegExp(`^#{${e}} `);
|
|
986
998
|
return {
|
|
987
999
|
id: `h${e}`,
|
|
988
1000
|
title: `Heading ${e}`,
|
|
989
|
-
run: (t) =>
|
|
1001
|
+
run: (t) => Ze(t, e),
|
|
990
1002
|
isActive: (e) => t.test(e.doc.lineAt(e.selection.main.head).text),
|
|
991
1003
|
disabled: Y(W, J),
|
|
992
1004
|
keys: [`Mod-Alt-${e}`]
|
|
993
1005
|
};
|
|
994
1006
|
}
|
|
995
|
-
var
|
|
1007
|
+
var Mt = /* @__PURE__ */ new Set([
|
|
996
1008
|
"bold",
|
|
997
1009
|
"italic",
|
|
998
1010
|
"strike",
|
|
@@ -1004,8 +1016,8 @@ var kt = /* @__PURE__ */ new Set([
|
|
|
1004
1016
|
"math",
|
|
1005
1017
|
"mathBlock"
|
|
1006
1018
|
]);
|
|
1007
|
-
function
|
|
1008
|
-
return n ?
|
|
1019
|
+
function Nt(e, t, n) {
|
|
1020
|
+
return n ? Mt.has(t.id) ? {
|
|
1009
1021
|
disabled: !1,
|
|
1010
1022
|
active: !1
|
|
1011
1023
|
} : {
|
|
@@ -1027,7 +1039,7 @@ function Q(e, t, n, ...r) {
|
|
|
1027
1039
|
}
|
|
1028
1040
|
//#endregion
|
|
1029
1041
|
//#region src/toolbar/frontmatter-toggle.ts
|
|
1030
|
-
function
|
|
1042
|
+
function Pt(e) {
|
|
1031
1043
|
let t = e.state, r = n(t.doc);
|
|
1032
1044
|
if (r) {
|
|
1033
1045
|
let n = t.doc.lineAt(r.from), i = t.doc.lineAt(r.to);
|
|
@@ -1057,15 +1069,15 @@ function jt(e) {
|
|
|
1057
1069
|
}
|
|
1058
1070
|
return e.focus(), !0;
|
|
1059
1071
|
}
|
|
1060
|
-
function
|
|
1072
|
+
function Ft(e) {
|
|
1061
1073
|
return n(e.doc) !== null;
|
|
1062
1074
|
}
|
|
1063
1075
|
//#endregion
|
|
1064
1076
|
//#region src/toolbar/rule.ts
|
|
1065
|
-
var
|
|
1066
|
-
function
|
|
1077
|
+
var It = /^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/;
|
|
1078
|
+
function Lt(e) {
|
|
1067
1079
|
let t = e.state, n = t.doc.lineAt(t.selection.main.head);
|
|
1068
|
-
return
|
|
1080
|
+
return It.test(n.text) ? e.dispatch({
|
|
1069
1081
|
changes: {
|
|
1070
1082
|
from: n.from,
|
|
1071
1083
|
to: Math.min(n.to + 1, t.doc.length)
|
|
@@ -1088,46 +1100,46 @@ function Pt(e) {
|
|
|
1088
1100
|
scrollIntoView: !0
|
|
1089
1101
|
}), e.focus(), !0;
|
|
1090
1102
|
}
|
|
1091
|
-
function
|
|
1092
|
-
return
|
|
1103
|
+
function Rt(e) {
|
|
1104
|
+
return It.test(e.doc.lineAt(e.selection.main.head).text);
|
|
1093
1105
|
}
|
|
1094
1106
|
//#endregion
|
|
1095
1107
|
//#region src/editor/save.ts
|
|
1096
|
-
var
|
|
1097
|
-
function
|
|
1098
|
-
let t = e.state.facet(
|
|
1108
|
+
var zt = ee.define({ combine: (e) => e[0] ?? null });
|
|
1109
|
+
function Bt(e) {
|
|
1110
|
+
let t = e.state.facet(zt);
|
|
1099
1111
|
return t ? (t(e.state.doc.toString()), !0) : !1;
|
|
1100
1112
|
}
|
|
1101
1113
|
//#endregion
|
|
1102
1114
|
//#region src/editor/search-panel-dom.ts
|
|
1103
|
-
var
|
|
1104
|
-
function
|
|
1115
|
+
var Vt = "stylo-search-panel";
|
|
1116
|
+
function Ht(e) {
|
|
1105
1117
|
e.setAttribute("form", "");
|
|
1106
1118
|
}
|
|
1107
|
-
function
|
|
1119
|
+
function Ut(e, t, n) {
|
|
1108
1120
|
let r = document.createElement("input");
|
|
1109
|
-
return r.type = "text", r.name = e, r.placeholder = t, r.setAttribute("aria-label", t), r.className = n,
|
|
1121
|
+
return r.type = "text", r.name = e, r.placeholder = t, r.setAttribute("aria-label", t), r.className = n, Ht(r), r;
|
|
1110
1122
|
}
|
|
1111
1123
|
function $(e, t) {
|
|
1112
1124
|
let n = document.createElement("button");
|
|
1113
1125
|
return n.type = "button", n.name = e, n.className = "stylo-search-button", n.textContent = t, n;
|
|
1114
1126
|
}
|
|
1115
|
-
function
|
|
1127
|
+
function Wt(e, t) {
|
|
1116
1128
|
let n = document.createElement("input");
|
|
1117
|
-
n.type = "checkbox", n.name = e,
|
|
1129
|
+
n.type = "checkbox", n.name = e, Ht(n);
|
|
1118
1130
|
let r = document.createElement("label");
|
|
1119
1131
|
return r.className = "stylo-search-check", r.append(n, document.createTextNode(t)), {
|
|
1120
1132
|
field: n,
|
|
1121
1133
|
wrap: r
|
|
1122
1134
|
};
|
|
1123
1135
|
}
|
|
1124
|
-
function
|
|
1125
|
-
let t = (t) => e.state.phrase(t), n =
|
|
1136
|
+
function Gt(e) {
|
|
1137
|
+
let t = (t) => e.state.phrase(t), n = Ut("search", t("Find"), "stylo-search-field");
|
|
1126
1138
|
n.setAttribute("main-field", "true");
|
|
1127
|
-
let r = $("next", t("next")), i = $("prev", t("previous")), a = $("select", t("all")), o =
|
|
1139
|
+
let r = $("next", t("next")), i = $("prev", t("previous")), a = $("select", t("all")), o = Ut("replace", t("Replace"), "stylo-search-field stylo-search-replace"), s = $("replace", t("replace")), c = $("replaceAll", t("replace all")), l = Wt("case", t("match case")), u = Wt("re", t("regexp")), d = Wt("word", t("by word")), f = $("close", "×");
|
|
1128
1140
|
f.classList.add("stylo-search-close"), f.setAttribute("aria-label", t("close"));
|
|
1129
1141
|
let p = document.createElement("div");
|
|
1130
|
-
return p.className =
|
|
1142
|
+
return p.className = Vt, p.append(n, r, i, a, o, s, c, l.wrap, u.wrap, d.wrap, f), {
|
|
1131
1143
|
root: p,
|
|
1132
1144
|
find: n,
|
|
1133
1145
|
next: r,
|
|
@@ -1144,18 +1156,18 @@ function Ht(e) {
|
|
|
1144
1156
|
}
|
|
1145
1157
|
//#endregion
|
|
1146
1158
|
//#region src/editor/search-panel.ts
|
|
1147
|
-
var
|
|
1148
|
-
function
|
|
1149
|
-
return
|
|
1159
|
+
var Kt = "cm-search-closing", qt = 160;
|
|
1160
|
+
function Jt(e) {
|
|
1161
|
+
return se(e.state) ? Yt(e) : C(e);
|
|
1150
1162
|
}
|
|
1151
|
-
function
|
|
1152
|
-
let t = e.dom.querySelector(`.${
|
|
1153
|
-
return !t || t.classList.contains(
|
|
1163
|
+
function Yt(e) {
|
|
1164
|
+
let t = e.dom.querySelector(`.${Vt}`);
|
|
1165
|
+
return !t || t.classList.contains(Kt) ? !0 : (t.classList.add(Kt), setTimeout(() => {
|
|
1154
1166
|
e.dom.isConnected && y(e);
|
|
1155
|
-
},
|
|
1167
|
+
}, qt), !0);
|
|
1156
1168
|
}
|
|
1157
|
-
function
|
|
1158
|
-
let t =
|
|
1169
|
+
function Xt(e) {
|
|
1170
|
+
let t = Gt(e), n = S(e.state);
|
|
1159
1171
|
r(n);
|
|
1160
1172
|
function r(e) {
|
|
1161
1173
|
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;
|
|
@@ -1168,7 +1180,7 @@ function qt(e) {
|
|
|
1168
1180
|
wholeWord: t.wholeWord.checked,
|
|
1169
1181
|
replace: t.replace.value
|
|
1170
1182
|
});
|
|
1171
|
-
r.eq(n) || (n = r, e.dispatch({ effects:
|
|
1183
|
+
r.eq(n) || (n = r, e.dispatch({ effects: le.of(n) }));
|
|
1172
1184
|
}
|
|
1173
1185
|
for (let e of [
|
|
1174
1186
|
t.find,
|
|
@@ -1179,50 +1191,50 @@ function qt(e) {
|
|
|
1179
1191
|
]) e.addEventListener("input", i), e.addEventListener("change", i);
|
|
1180
1192
|
return t.root.addEventListener("keydown", (n) => {
|
|
1181
1193
|
if (n.key === "Escape") {
|
|
1182
|
-
n.preventDefault(),
|
|
1194
|
+
n.preventDefault(), Yt(e);
|
|
1183
1195
|
return;
|
|
1184
1196
|
}
|
|
1185
1197
|
if (c(e, n, "search-panel")) {
|
|
1186
1198
|
n.preventDefault();
|
|
1187
1199
|
return;
|
|
1188
1200
|
}
|
|
1189
|
-
n.key === "Enter" && (n.preventDefault(), n.target === t.find ? (n.shiftKey ? x : b)(e) : n.target === t.replace &&
|
|
1190
|
-
}), t.next.addEventListener("click", () => b(e)), t.prev.addEventListener("click", () => x(e)), t.all.addEventListener("click", () =>
|
|
1201
|
+
n.key === "Enter" && (n.preventDefault(), n.target === t.find ? (n.shiftKey ? x : b)(e) : n.target === t.replace && w(e));
|
|
1202
|
+
}), t.next.addEventListener("click", () => b(e)), t.prev.addEventListener("click", () => x(e)), t.all.addEventListener("click", () => ce(e)), t.replaceBtn.addEventListener("click", () => w(e)), t.replaceAllBtn.addEventListener("click", () => ae(e)), t.close.addEventListener("click", () => Yt(e)), {
|
|
1191
1203
|
dom: t.root,
|
|
1192
1204
|
top: !0,
|
|
1193
1205
|
update(e) {
|
|
1194
|
-
for (let t of e.transactions) for (let e of t.effects) e.is(
|
|
1206
|
+
for (let t of e.transactions) for (let e of t.effects) e.is(le) && !e.value.eq(n) && (n = e.value, r(n));
|
|
1195
1207
|
}
|
|
1196
1208
|
};
|
|
1197
1209
|
}
|
|
1198
1210
|
//#endregion
|
|
1199
1211
|
//#region src/toolbar/commands.ts
|
|
1200
|
-
var
|
|
1201
|
-
|
|
1202
|
-
|
|
1212
|
+
var Zt = [
|
|
1213
|
+
At("undo", "Undo", g),
|
|
1214
|
+
At("redo", "Redo", re),
|
|
1203
1215
|
{
|
|
1204
1216
|
id: "save",
|
|
1205
1217
|
title: "Save",
|
|
1206
1218
|
run: (e) => {
|
|
1207
|
-
let t =
|
|
1219
|
+
let t = Bt(e);
|
|
1208
1220
|
return e.focus(), t;
|
|
1209
1221
|
},
|
|
1210
|
-
disabled: (e) => e.facet(
|
|
1222
|
+
disabled: (e) => e.facet(zt) == null
|
|
1211
1223
|
},
|
|
1212
1224
|
{
|
|
1213
1225
|
id: "search",
|
|
1214
1226
|
title: "Find / replace",
|
|
1215
|
-
run: (e) =>
|
|
1216
|
-
isActive: (e) =>
|
|
1227
|
+
run: (e) => Jt(e),
|
|
1228
|
+
isActive: (e) => se(e),
|
|
1217
1229
|
keys: ["Mod-f"]
|
|
1218
1230
|
},
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1231
|
+
jt(1),
|
|
1232
|
+
jt(2),
|
|
1233
|
+
jt(3),
|
|
1222
1234
|
{
|
|
1223
1235
|
id: "body",
|
|
1224
1236
|
title: "Body",
|
|
1225
|
-
run: (e) => (
|
|
1237
|
+
run: (e) => (Qe(e) || e.focus(), !0),
|
|
1226
1238
|
isActive: (e) => !/^#{1,6} /.test(e.doc.lineAt(e.selection.main.head).text),
|
|
1227
1239
|
disabled: Y(W, J)
|
|
1228
1240
|
},
|
|
@@ -1232,74 +1244,74 @@ var Jt = [
|
|
|
1232
1244
|
{
|
|
1233
1245
|
id: "underline",
|
|
1234
1246
|
title: "Underline",
|
|
1235
|
-
run: (e) =>
|
|
1236
|
-
isActive:
|
|
1237
|
-
disabled: Y(J,
|
|
1247
|
+
run: (e) => F(e, ye) || st(e),
|
|
1248
|
+
isActive: ct,
|
|
1249
|
+
disabled: Y(J, wt("u"), Tt),
|
|
1238
1250
|
keys: ["Mod-u"]
|
|
1239
1251
|
},
|
|
1240
1252
|
Z("code", "Inline code", "`"),
|
|
1241
1253
|
{
|
|
1242
1254
|
id: "codeBlock",
|
|
1243
1255
|
title: "Code block",
|
|
1244
|
-
run: (e) =>
|
|
1245
|
-
isActive: (e) => W(e) ? z(e, "`") :
|
|
1246
|
-
disabled: Y(q,
|
|
1256
|
+
run: (e) => F(e, (e, t, n) => k(e, t, n, "`")) || (W(e.state) ? $e(e, "`") : Ge(e)),
|
|
1257
|
+
isActive: (e) => W(e) ? z(e, "`") : L(e),
|
|
1258
|
+
disabled: Y(q, R, K)
|
|
1247
1259
|
},
|
|
1248
1260
|
{
|
|
1249
1261
|
id: "link",
|
|
1250
1262
|
title: "Link",
|
|
1251
|
-
run: (e) =>
|
|
1252
|
-
isActive:
|
|
1263
|
+
run: (e) => F(e, he) || tt(e),
|
|
1264
|
+
isActive: nt,
|
|
1253
1265
|
disabled: J,
|
|
1254
1266
|
keys: ["Mod-k"]
|
|
1255
1267
|
},
|
|
1256
1268
|
{
|
|
1257
1269
|
id: "wikilink",
|
|
1258
1270
|
title: "Wikilink",
|
|
1259
|
-
run: (e) =>
|
|
1260
|
-
isActive:
|
|
1271
|
+
run: (e) => F(e, _e) || it(e),
|
|
1272
|
+
isActive: at,
|
|
1261
1273
|
disabled: J,
|
|
1262
1274
|
keys: ["Mod-Shift-k"]
|
|
1263
1275
|
},
|
|
1264
|
-
Q("quote", "Blockquote",
|
|
1265
|
-
Q("bulletList", "Bulleted list",
|
|
1266
|
-
Q("orderedList", "Numbered list",
|
|
1267
|
-
Q("task", "Task list",
|
|
1276
|
+
Q("quote", "Blockquote", Et),
|
|
1277
|
+
Q("bulletList", "Bulleted list", Dt, K),
|
|
1278
|
+
Q("orderedList", "Numbered list", Ot, K),
|
|
1279
|
+
Q("task", "Task list", kt, K),
|
|
1268
1280
|
{
|
|
1269
1281
|
id: "hr",
|
|
1270
1282
|
title: "Divider",
|
|
1271
|
-
run:
|
|
1272
|
-
isActive:
|
|
1283
|
+
run: Lt,
|
|
1284
|
+
isActive: Rt,
|
|
1273
1285
|
disabled: Y(W, J)
|
|
1274
1286
|
},
|
|
1275
1287
|
{
|
|
1276
1288
|
id: "frontmatter",
|
|
1277
1289
|
title: "Frontmatter",
|
|
1278
|
-
run:
|
|
1279
|
-
isActive:
|
|
1280
|
-
disabled: Y(W,
|
|
1290
|
+
run: Pt,
|
|
1291
|
+
isActive: Ft,
|
|
1292
|
+
disabled: Y(W, L, R, K)
|
|
1281
1293
|
},
|
|
1282
1294
|
{
|
|
1283
1295
|
id: "table",
|
|
1284
1296
|
title: "Table",
|
|
1285
|
-
run:
|
|
1297
|
+
run: yt,
|
|
1286
1298
|
isActive: W,
|
|
1287
|
-
disabled: Y(W, q,
|
|
1299
|
+
disabled: Y(W, q, L, R, K)
|
|
1288
1300
|
},
|
|
1289
1301
|
Z("math", "Inline math", "$"),
|
|
1290
1302
|
{
|
|
1291
1303
|
id: "mathBlock",
|
|
1292
1304
|
title: "Block math",
|
|
1293
|
-
run: (e) =>
|
|
1294
|
-
isActive: (e) => W(e) ? z(e, "$") :
|
|
1295
|
-
disabled: Y(q,
|
|
1305
|
+
run: (e) => F(e, (e, t, n) => k(e, t, n, "$")) || (W(e.state) ? $e(e, "$") : Ye(e)),
|
|
1306
|
+
isActive: (e) => W(e) ? z(e, "$") : R(e),
|
|
1307
|
+
disabled: Y(q, L, K)
|
|
1296
1308
|
}
|
|
1297
|
-
],
|
|
1309
|
+
], Qt = Object.fromEntries(Zt.map((e) => [e.id, e])), $t = m.high(o.of(Zt.filter((e) => e.keys && e.keys.length > 0).flatMap((e) => e.keys.map((t) => ({
|
|
1298
1310
|
key: t,
|
|
1299
1311
|
preventDefault: !0,
|
|
1300
1312
|
run: ((t) => !e.disabled?.(t.state) && e.run(t))
|
|
1301
|
-
}))))),
|
|
1302
|
-
function
|
|
1313
|
+
}))))), en = /(?<=^|\s)#[^\s#]*$/;
|
|
1314
|
+
function tn(e) {
|
|
1303
1315
|
return {
|
|
1304
1316
|
label: e.tag,
|
|
1305
1317
|
apply: (t, n, r, i) => {
|
|
@@ -1315,15 +1327,15 @@ function Qt(e) {
|
|
|
1315
1327
|
}
|
|
1316
1328
|
};
|
|
1317
1329
|
}
|
|
1318
|
-
function
|
|
1330
|
+
function nn(e, t) {
|
|
1319
1331
|
return async (n) => {
|
|
1320
|
-
let r = n.matchBefore(
|
|
1332
|
+
let r = n.matchBefore(en);
|
|
1321
1333
|
if (!r || r.from + 1 === n.pos && !n.explicit) return null;
|
|
1322
1334
|
let i = r.text.slice(1);
|
|
1323
1335
|
if (/^\d/.test(i)) return null;
|
|
1324
1336
|
let a;
|
|
1325
1337
|
try {
|
|
1326
|
-
a = (await e(i)).map(
|
|
1338
|
+
a = (await e(i)).map(tn);
|
|
1327
1339
|
} catch (e) {
|
|
1328
1340
|
return t?.(e, {
|
|
1329
1341
|
source: "tagSource",
|
|
@@ -1338,12 +1350,12 @@ function $t(e, t) {
|
|
|
1338
1350
|
} : null;
|
|
1339
1351
|
};
|
|
1340
1352
|
}
|
|
1341
|
-
function
|
|
1342
|
-
return e ? [
|
|
1353
|
+
function rn(e, t) {
|
|
1354
|
+
return e ? [de(), _.data.of({ autocomplete: nn(e, t) })] : [];
|
|
1343
1355
|
}
|
|
1344
1356
|
//#endregion
|
|
1345
1357
|
//#region src/editor/theme.ts
|
|
1346
|
-
var
|
|
1358
|
+
var an = a.theme({
|
|
1347
1359
|
"&": {
|
|
1348
1360
|
color: "var(--stylo-text)",
|
|
1349
1361
|
backgroundColor: "var(--stylo-bg)",
|
|
@@ -1449,8 +1461,8 @@ var tn = a.theme({
|
|
|
1449
1461
|
backgroundColor: "color-mix(in srgb, var(--stylo-ring) 70%, transparent)",
|
|
1450
1462
|
outline: "1px solid var(--stylo-ring)"
|
|
1451
1463
|
}
|
|
1452
|
-
}),
|
|
1453
|
-
function
|
|
1464
|
+
}), on = /\[\[([^[\]\n|]*)$/;
|
|
1465
|
+
function sn(e) {
|
|
1454
1466
|
let t = e.label && e.label !== e.target ? e.label : void 0, n = t ? `${e.target}|${t}` : e.target;
|
|
1455
1467
|
return {
|
|
1456
1468
|
label: e.label ?? e.target,
|
|
@@ -1468,13 +1480,13 @@ function rn(e) {
|
|
|
1468
1480
|
}
|
|
1469
1481
|
};
|
|
1470
1482
|
}
|
|
1471
|
-
function
|
|
1483
|
+
function cn(e, t) {
|
|
1472
1484
|
return async (n) => {
|
|
1473
|
-
let r = n.matchBefore(
|
|
1485
|
+
let r = n.matchBefore(on);
|
|
1474
1486
|
if (!r || r.from + 2 === n.pos && !n.explicit) return null;
|
|
1475
1487
|
let i = r.text.slice(2), a;
|
|
1476
1488
|
try {
|
|
1477
|
-
a = (await e(i)).map(
|
|
1489
|
+
a = (await e(i)).map(sn);
|
|
1478
1490
|
} catch (e) {
|
|
1479
1491
|
return t?.(e, {
|
|
1480
1492
|
source: "wikiLinkSource",
|
|
@@ -1489,79 +1501,79 @@ function an(e, t) {
|
|
|
1489
1501
|
} : null;
|
|
1490
1502
|
};
|
|
1491
1503
|
}
|
|
1492
|
-
function
|
|
1493
|
-
return e ? [
|
|
1504
|
+
function ln(e, t) {
|
|
1505
|
+
return e ? [de(), _.data.of({ autocomplete: cn(e, t) })] : [];
|
|
1494
1506
|
}
|
|
1495
1507
|
//#endregion
|
|
1496
1508
|
//#region src/editor/extensions.ts
|
|
1497
|
-
function
|
|
1509
|
+
function un(e, n, r, i) {
|
|
1498
1510
|
return [
|
|
1499
|
-
|
|
1500
|
-
o.of([...
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1511
|
+
ne(),
|
|
1512
|
+
o.of([...te, ...h]),
|
|
1513
|
+
m.high(St),
|
|
1514
|
+
$t,
|
|
1515
|
+
Ct,
|
|
1516
|
+
T({
|
|
1505
1517
|
top: !0,
|
|
1506
|
-
createPanel:
|
|
1518
|
+
createPanel: Xt
|
|
1507
1519
|
}),
|
|
1508
|
-
o.of(
|
|
1520
|
+
o.of(oe),
|
|
1509
1521
|
ie({
|
|
1510
1522
|
base: _,
|
|
1511
1523
|
codeLanguages: e
|
|
1512
1524
|
}),
|
|
1513
1525
|
t,
|
|
1514
|
-
|
|
1515
|
-
|
|
1526
|
+
ln(n, r),
|
|
1527
|
+
rn(i, r),
|
|
1516
1528
|
a.lineWrapping,
|
|
1517
|
-
|
|
1529
|
+
an
|
|
1518
1530
|
];
|
|
1519
1531
|
}
|
|
1520
|
-
function
|
|
1532
|
+
function dn(e) {
|
|
1521
1533
|
return [
|
|
1522
1534
|
p.readOnly.of(e.readOnly),
|
|
1523
1535
|
a.editable.of(!e.readOnly),
|
|
1524
1536
|
e.placeholder ? s(e.placeholder) : [],
|
|
1525
|
-
e.save ?
|
|
1537
|
+
e.save ? zt.of(e.save) : []
|
|
1526
1538
|
];
|
|
1527
1539
|
}
|
|
1528
1540
|
//#endregion
|
|
1529
1541
|
//#region src/editor/useCodeMirror.ts
|
|
1530
|
-
var
|
|
1531
|
-
function
|
|
1532
|
-
let
|
|
1542
|
+
var fn = l.define();
|
|
1543
|
+
function pn({ 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 }) {
|
|
1544
|
+
let re = i(null), g = i(null), ie = i(t);
|
|
1533
1545
|
ie.current = t;
|
|
1534
1546
|
let _ = i([]), v = i(c);
|
|
1535
1547
|
v.current = c;
|
|
1536
|
-
let y = i((e) => v.current?.(e)).current, b = i(
|
|
1537
|
-
b.current =
|
|
1548
|
+
let y = i((e) => v.current?.(e)).current, b = i(h);
|
|
1549
|
+
b.current = h;
|
|
1538
1550
|
let x = i((e, t) => {
|
|
1539
1551
|
b.current?.(e, t);
|
|
1540
1552
|
}).current, S = c != null, C = i(l);
|
|
1541
1553
|
C.current = l;
|
|
1542
|
-
let
|
|
1554
|
+
let ae = i(new d()), w = i(new d()), T = i(f);
|
|
1543
1555
|
return r(() => {
|
|
1544
|
-
let t =
|
|
1556
|
+
let t = re.current;
|
|
1545
1557
|
if (!t) return;
|
|
1546
1558
|
let r = new a({
|
|
1547
1559
|
parent: t,
|
|
1548
1560
|
state: p.create({
|
|
1549
1561
|
doc: e,
|
|
1550
1562
|
extensions: [
|
|
1551
|
-
|
|
1552
|
-
|
|
1563
|
+
un(ee, te, x, ne),
|
|
1564
|
+
ae.current.of(dn({
|
|
1553
1565
|
readOnly: n,
|
|
1554
1566
|
placeholder: s,
|
|
1555
1567
|
save: S ? y : void 0
|
|
1556
1568
|
})),
|
|
1557
|
-
|
|
1569
|
+
m.high(o.of([{
|
|
1558
1570
|
key: "Mod-s",
|
|
1559
|
-
run:
|
|
1571
|
+
run: Bt
|
|
1560
1572
|
}])),
|
|
1561
1573
|
...u ?? [],
|
|
1562
|
-
|
|
1574
|
+
w.current.of(f ?? []),
|
|
1563
1575
|
a.updateListener.of((e) => {
|
|
1564
|
-
if (!e.docChanged || e.transactions.some((e) => !!e.annotation(
|
|
1576
|
+
if (!e.docChanged || e.transactions.some((e) => !!e.annotation(fn))) return;
|
|
1565
1577
|
let t = e.state.doc.toString();
|
|
1566
1578
|
_.current.push(t), _.current.length > 20 && _.current.shift(), ie.current(t);
|
|
1567
1579
|
})
|
|
@@ -1581,10 +1593,10 @@ function un({ value: e, onChange: t, readOnly: n = !1, placeholder: s, onSave: c
|
|
|
1581
1593
|
to: n.length,
|
|
1582
1594
|
insert: e
|
|
1583
1595
|
},
|
|
1584
|
-
annotations:
|
|
1596
|
+
annotations: fn.of(!0)
|
|
1585
1597
|
}), _.current = []));
|
|
1586
1598
|
}, [e]), r(() => {
|
|
1587
|
-
g.current?.dispatch({ effects:
|
|
1599
|
+
g.current?.dispatch({ effects: ae.current.reconfigure(dn({
|
|
1588
1600
|
readOnly: n,
|
|
1589
1601
|
placeholder: s,
|
|
1590
1602
|
save: S ? y : void 0
|
|
@@ -1595,11 +1607,11 @@ function un({ value: e, onChange: t, readOnly: n = !1, placeholder: s, onSave: c
|
|
|
1595
1607
|
S,
|
|
1596
1608
|
y
|
|
1597
1609
|
]), r(() => {
|
|
1598
|
-
let e =
|
|
1599
|
-
e !== f && (e && f && e.length === f.length && e.every((e, t) => e === f[t]) || (
|
|
1600
|
-
}, [f]),
|
|
1610
|
+
let e = T.current;
|
|
1611
|
+
e !== f && (e && f && e.length === f.length && e.every((e, t) => e === f[t]) || (T.current = f, g.current?.dispatch({ effects: w.current.reconfigure(f ?? []) })));
|
|
1612
|
+
}, [f]), re;
|
|
1601
1613
|
}
|
|
1602
1614
|
//#endregion
|
|
1603
|
-
export { Ne as C, ge as D,
|
|
1615
|
+
export { Ne as C, ge as D, D as E, me as O, Ie as S, Ae as T, Ve as _, X as a, P as b, kt as c, B as d, V as f, Re as g, L as h, Dt as i, pe as k, Nt as l, Ke as m, Qt as n, Ot as o, Xe as p, Lt as r, Et as s, pn as t, _t as u, Oe as v, ke as w, Me as x, Pe as y };
|
|
1604
1616
|
|
|
1605
|
-
//# sourceMappingURL=useCodeMirror-
|
|
1617
|
+
//# sourceMappingURL=useCodeMirror-O1ProA2R.js.map
|