zt-react-milkdown 0.1.35 → 0.1.37
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/index.cjs +6 -6
- package/dist/index.mjs +1146 -1022
- package/dist/src/core/createEditor.d.ts.map +1 -1
- package/dist/src/plugins/custom/cjk-friendly.d.ts +30 -0
- package/dist/src/plugins/custom/cjk-friendly.d.ts.map +1 -0
- package/dist/src/plugins/custom/code-block/code-block-language-picker.d.ts.map +1 -1
- package/dist/src/plugins/custom/code-block/code-block-prism-refresh.d.ts.map +1 -1
- package/dist/src/plugins/custom/selection-tooltip/index.d.ts.map +1 -1
- package/dist/src/plugins/custom/slash-menu/slash-menu.d.ts.map +1 -1
- package/dist/src/plugins/custom/table/table-focus-actions.d.ts.map +1 -1
- package/dist/src/plugins/preset-common.d.ts +3 -1
- package/dist/src/plugins/preset-common.d.ts.map +1 -1
- package/package.json +18 -16
package/dist/index.mjs
CHANGED
|
@@ -3,18 +3,17 @@ import { Fragment as t, createElement as n, useCallback as r, useEffect as i, us
|
|
|
3
3
|
import { Milkdown as l, MilkdownProvider as u, useEditor as d } from "@milkdown/react";
|
|
4
4
|
import f, { clsx as p } from "clsx";
|
|
5
5
|
import { debounce as m } from "es-toolkit/function";
|
|
6
|
-
import { AlertCircle as h, ArrowDownToLine as g, ArrowLeftToLine as _, ArrowRightToLine as v, ArrowUpToLine as y, Check as b, ChevronDown as x, ChevronRight as S, ChevronUp as C, Code2 as w, EllipsisVertical as T, Heading1 as E, Heading2 as D, Heading3 as O, Heading4 as k, Heading5 as A, Heading6 as
|
|
6
|
+
import { AlertCircle as h, ArrowDownToLine as g, ArrowLeftToLine as _, ArrowRightToLine as v, ArrowUpToLine as y, Check as b, ChevronDown as x, ChevronRight as S, ChevronUp as C, Code2 as w, EllipsisVertical as T, Heading1 as E, Heading2 as D, Heading3 as O, Heading4 as k, Heading5 as A, Heading6 as j, ImageOff as ee, ImagePlus as te, Link2 as ne, List as re, ListChecks as M, ListOrdered as ie, Loader2 as ae, Search as oe, TextQuote as se, Trash2 as ce, Type as le, X as ue, XIcon as de } from "lucide-react";
|
|
7
7
|
import { cva as fe } from "class-variance-authority";
|
|
8
8
|
import { Dialog as N, Slot as pe } from "radix-ui";
|
|
9
9
|
import { twMerge as me } from "tailwind-merge";
|
|
10
10
|
import { Fragment as he, jsx as P, jsxs as F } from "react/jsx-runtime";
|
|
11
11
|
import ge from "i18next";
|
|
12
12
|
import { NodeSelection as I, Plugin as L, PluginKey as R, TextSelection as z } from "@milkdown/prose/state";
|
|
13
|
-
import { Editor as _e, defaultValueCtx as ve, editorViewCtx as ye, editorViewOptionsCtx as be, nodeViewCtx as xe,
|
|
14
|
-
import { clipboard as
|
|
15
|
-
import { history as
|
|
16
|
-
import { indent as
|
|
17
|
-
import { listener as Oe } from "@milkdown/plugin-listener";
|
|
13
|
+
import { Editor as _e, defaultValueCtx as ve, editorViewCtx as ye, editorViewOptionsCtx as be, nodeViewCtx as xe, remarkStringifyOptionsCtx as Se, rootCtx as Ce, serializerCtx as we } from "@milkdown/core";
|
|
14
|
+
import { clipboard as Te } from "@milkdown/plugin-clipboard";
|
|
15
|
+
import { history as Ee } from "@milkdown/plugin-history";
|
|
16
|
+
import { indent as De, indentConfig as Oe } from "@milkdown/plugin-indent";
|
|
18
17
|
import { blockquoteKeymap as ke, bulletListKeymap as Ae, codeBlockKeymap as je, codeBlockSchema as Me, commonmark as Ne, headingKeymap as Pe, imageSchema as Fe, inlineCodeKeymap as Ie, orderedListKeymap as Le, paragraphKeymap as Re, paragraphSchema as ze } from "@milkdown/preset-commonmark";
|
|
19
18
|
import { gfm as Be } from "@milkdown/preset-gfm";
|
|
20
19
|
import { prismConfig as Ve } from "@milkdown/plugin-prism";
|
|
@@ -32,30 +31,32 @@ import Qe from "refractor/scala";
|
|
|
32
31
|
import $e from "refractor/toml";
|
|
33
32
|
import et from "refractor/tsx";
|
|
34
33
|
import tt from "refractor/zig";
|
|
35
|
-
import { Decoration as nt, DecorationSet as
|
|
36
|
-
import { $ctx as
|
|
37
|
-
import { dropCursor as
|
|
38
|
-
import { GapCursor as
|
|
39
|
-
import { createRoot as
|
|
40
|
-
import
|
|
41
|
-
import { InputRule as
|
|
42
|
-
import
|
|
43
|
-
import { liftTarget as
|
|
44
|
-
import { createPortal as
|
|
45
|
-
import
|
|
46
|
-
import { TooltipProvider as
|
|
47
|
-
import { setBlockType as
|
|
48
|
-
import { liftListItem as
|
|
49
|
-
import { slashFactory as
|
|
50
|
-
import { TableMap as
|
|
51
|
-
import { SearchQuery as
|
|
34
|
+
import { Decoration as nt, DecorationSet as rt } from "@milkdown/prose/view";
|
|
35
|
+
import { $ctx as it, $inputRule as at, $nodeSchema as ot, $prose as B, $remark as st, $useKeymap as ct, replaceAll as lt } from "@milkdown/utils";
|
|
36
|
+
import { dropCursor as ut } from "@milkdown/prose/dropcursor";
|
|
37
|
+
import { GapCursor as dt, gapCursor as ft } from "@milkdown/prose/gapcursor";
|
|
38
|
+
import { createRoot as pt } from "react-dom/client";
|
|
39
|
+
import mt from "katex";
|
|
40
|
+
import { InputRule as ht } from "@milkdown/prose/inputrules";
|
|
41
|
+
import gt from "remark-math";
|
|
42
|
+
import { liftTarget as _t } from "@milkdown/prose/transform";
|
|
43
|
+
import { createPortal as vt } from "react-dom";
|
|
44
|
+
import yt from "remark-frontmatter";
|
|
45
|
+
import { TooltipProvider as bt } from "@milkdown/plugin-tooltip";
|
|
46
|
+
import { setBlockType as xt, toggleMark as St, wrapIn as Ct } from "@milkdown/prose/commands";
|
|
47
|
+
import { liftListItem as wt, sinkListItem as Tt, wrapInList as Et } from "@milkdown/prose/schema-list";
|
|
48
|
+
import { slashFactory as Dt } from "@milkdown/plugin-slash";
|
|
49
|
+
import { TableMap as Ot, addColumnAfter as kt, addColumnBefore as At, addRowAfter as jt, addRowBefore as Mt, deleteColumn as Nt, deleteRow as Pt } from "@milkdown/prose/tables";
|
|
50
|
+
import { SearchQuery as Ft, findNext as It, findPrev as Lt, getSearchState as Rt, replaceAll as zt, replaceNext as Bt, search as Vt, setSearchState as Ht } from "prosemirror-search";
|
|
51
|
+
import Ut from "remark-cjk-friendly";
|
|
52
|
+
import Wt from "remark-cjk-friendly-gfm-strikethrough";
|
|
52
53
|
//#region src/lib/utils.ts
|
|
53
|
-
function
|
|
54
|
+
function V(...e) {
|
|
54
55
|
return me(p(e));
|
|
55
56
|
}
|
|
56
57
|
//#endregion
|
|
57
58
|
//#region src/components/ui/button.tsx
|
|
58
|
-
var
|
|
59
|
+
var Gt = fe("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
59
60
|
variants: {
|
|
60
61
|
variant: {
|
|
61
62
|
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
|
@@ -86,14 +87,14 @@ var Ut = fe("group/button inline-flex shrink-0 items-center justify-center round
|
|
|
86
87
|
"data-slot": "button",
|
|
87
88
|
"data-variant": t,
|
|
88
89
|
"data-size": n,
|
|
89
|
-
className:
|
|
90
|
+
className: V(Gt({
|
|
90
91
|
variant: t,
|
|
91
92
|
size: n,
|
|
92
93
|
className: e
|
|
93
94
|
})),
|
|
94
95
|
...i
|
|
95
96
|
});
|
|
96
|
-
}),
|
|
97
|
+
}), Kt = (e) => {
|
|
97
98
|
let t = e.snapshot.total === 0 || e.snapshot.isInvalidExpression;
|
|
98
99
|
return /* @__PURE__ */ F("section", {
|
|
99
100
|
className: "zt-md-search-panel",
|
|
@@ -259,10 +260,10 @@ var Ut = fe("group/button inline-flex shrink-0 items-center justify-center round
|
|
|
259
260
|
}) : null
|
|
260
261
|
]
|
|
261
262
|
});
|
|
262
|
-
},
|
|
263
|
-
let i = typeof e == "string", [a, s] = c(
|
|
263
|
+
}, qt = (e) => typeof e == "string" ? e : "", Jt = (e, t, n) => {
|
|
264
|
+
let i = typeof e == "string", [a, s] = c(qt(t));
|
|
264
265
|
return {
|
|
265
|
-
markdown: o(() => i ?
|
|
266
|
+
markdown: o(() => i ? qt(e) : a, [
|
|
266
267
|
a,
|
|
267
268
|
i,
|
|
268
269
|
e
|
|
@@ -272,7 +273,7 @@ var Ut = fe("group/button inline-flex shrink-0 items-center justify-center round
|
|
|
272
273
|
}, [i, n]),
|
|
273
274
|
isControlled: i
|
|
274
275
|
};
|
|
275
|
-
},
|
|
276
|
+
}, Yt = {
|
|
276
277
|
placeholder: "Type / to open the command menu...",
|
|
277
278
|
initError: "Editor initialization failed. Please refresh the page and try again.",
|
|
278
279
|
editorAriaLabel: "Markdown editor",
|
|
@@ -362,7 +363,7 @@ var Ut = fe("group/button inline-flex shrink-0 items-center justify-center round
|
|
|
362
363
|
frontmatterExpandAriaLabel: "Expand frontmatter",
|
|
363
364
|
frontmatterCopyAriaLabel: "Copy frontmatter",
|
|
364
365
|
frontmatterDeleteAriaLabel: "Delete frontmatter"
|
|
365
|
-
},
|
|
366
|
+
}, Xt = {
|
|
366
367
|
placeholder: "请输入 / 打开命令菜单...",
|
|
367
368
|
initError: "编辑器初始化失败,请刷新页面后重试。",
|
|
368
369
|
editorAriaLabel: "Markdown 编辑器",
|
|
@@ -452,31 +453,31 @@ var Ut = fe("group/button inline-flex shrink-0 items-center justify-center round
|
|
|
452
453
|
frontmatterExpandAriaLabel: "展开元数据",
|
|
453
454
|
frontmatterCopyAriaLabel: "复制元数据",
|
|
454
455
|
frontmatterDeleteAriaLabel: "删除元数据"
|
|
455
|
-
},
|
|
456
|
-
"zh-CN": { translation:
|
|
457
|
-
"en-US": { translation:
|
|
458
|
-
},
|
|
459
|
-
|
|
460
|
-
resources:
|
|
461
|
-
fallbackLng:
|
|
462
|
-
lng:
|
|
456
|
+
}, Zt = "zh-CN", Qt = {
|
|
457
|
+
"zh-CN": { translation: Xt },
|
|
458
|
+
"en-US": { translation: Yt }
|
|
459
|
+
}, $t = ge.createInstance(), en = !1, tn = () => {
|
|
460
|
+
en ||= ($t.init({
|
|
461
|
+
resources: Qt,
|
|
462
|
+
fallbackLng: Zt,
|
|
463
|
+
lng: Zt,
|
|
463
464
|
interpolation: { escapeValue: !1 }
|
|
464
465
|
}), !0);
|
|
465
|
-
}, U = (e =
|
|
466
|
-
|
|
466
|
+
}, U = (e = Zt, t, n) => {
|
|
467
|
+
tn();
|
|
467
468
|
let r = {
|
|
468
|
-
|
|
469
|
+
...$t.getResourceBundle(e, "translation"),
|
|
469
470
|
...t
|
|
470
471
|
};
|
|
471
472
|
return n !== void 0 && (r.placeholder = n), r;
|
|
472
|
-
},
|
|
473
|
-
let n =
|
|
474
|
-
return
|
|
473
|
+
}, nn = /* @__PURE__ */ new WeakMap(), W = (e, t) => {
|
|
474
|
+
let n = nn.get(e) ?? /* @__PURE__ */ new Set();
|
|
475
|
+
return nn.set(e, n), n.add(t), () => {
|
|
475
476
|
n.delete(t);
|
|
476
477
|
};
|
|
477
|
-
},
|
|
478
|
-
Object.keys(t).every((n) => e[n] === t[n]) || (Object.assign(e, t),
|
|
479
|
-
},
|
|
478
|
+
}, rn = (e, t) => {
|
|
479
|
+
Object.keys(t).every((n) => e[n] === t[n]) || (Object.assign(e, t), nn.get(e)?.forEach((e) => e()));
|
|
480
|
+
}, an = [
|
|
480
481
|
qe,
|
|
481
482
|
et,
|
|
482
483
|
We,
|
|
@@ -491,57 +492,92 @@ var Ut = fe("group/button inline-flex shrink-0 items-center justify-center round
|
|
|
491
492
|
Ke,
|
|
492
493
|
tt
|
|
493
494
|
];
|
|
494
|
-
function
|
|
495
|
+
function on(e) {
|
|
495
496
|
e.languages.text = {};
|
|
496
497
|
}
|
|
497
|
-
|
|
498
|
-
function
|
|
499
|
-
|
|
498
|
+
on.displayName = "text";
|
|
499
|
+
function sn(e) {
|
|
500
|
+
an.forEach((t) => {
|
|
500
501
|
e.registered(t.displayName) || e.register(t);
|
|
501
|
-
}), e.register(
|
|
502
|
+
}), e.register(on);
|
|
502
503
|
}
|
|
503
|
-
|
|
504
|
+
sn(He);
|
|
504
505
|
//#endregion
|
|
505
506
|
//#region src/plugins/custom/code-block/code-block-prism-refresh.ts
|
|
506
|
-
var
|
|
507
|
+
var cn = "code_block", ln = new R("MILKDOWN_PRISM"), un = (e, t = []) => {
|
|
507
508
|
let n = [];
|
|
508
509
|
for (let r of e) if (r.type === "element") {
|
|
509
510
|
let e = Array.isArray(r.properties?.className) ? [...t, ...r.properties.className.map(String)] : t;
|
|
510
|
-
n.push(...
|
|
511
|
+
n.push(...un(r.children, e));
|
|
511
512
|
} else r.type === "text" && r.value && n.push({
|
|
512
513
|
text: r.value,
|
|
513
514
|
classNames: t
|
|
514
515
|
});
|
|
515
516
|
return n;
|
|
516
|
-
},
|
|
517
|
+
}, dn = (e) => {
|
|
517
518
|
let t = [];
|
|
518
|
-
return e.descendants((e, n) => e.type.name ===
|
|
519
|
+
return e.descendants((e, n) => e.type.name === cn ? (t.push({
|
|
519
520
|
pos: n,
|
|
520
521
|
node: e
|
|
521
522
|
}), !1) : !0), t;
|
|
522
|
-
},
|
|
523
|
+
}, fn = (e, t, n) => {
|
|
523
524
|
let r = typeof e.node.attrs.language == "string" ? e.node.attrs.language : "";
|
|
524
525
|
if (!r || !n.has(r)) return [];
|
|
525
|
-
let i = e.pos + 1, a = [], o =
|
|
526
|
+
let i = e.pos + 1, a = [], o = un(t.highlight(e.node.textContent, r).children);
|
|
526
527
|
for (let e of o) {
|
|
527
528
|
let t = i + e.text.length;
|
|
528
529
|
e.classNames.length > 0 && t > i && a.push(nt.inline(i, t, { class: e.classNames.join(" ") })), i = t;
|
|
529
530
|
}
|
|
530
531
|
return a;
|
|
531
|
-
},
|
|
532
|
+
}, pn = (e, t) => {
|
|
532
533
|
if (e.length !== t.length) return !1;
|
|
533
534
|
for (let n = 0; n < e.length; n += 1) if (e[n].node !== t[n].node) return !1;
|
|
534
535
|
return !0;
|
|
535
|
-
},
|
|
536
|
+
}, mn = (e, t) => {
|
|
537
|
+
let n = Math.max(0, Math.min(e.content.size, t)), r = e.resolve(n);
|
|
538
|
+
for (let e = r.depth; e >= 0; --e) if (r.node(e).type.name === cn) return !0;
|
|
539
|
+
return !1;
|
|
540
|
+
}, hn = (e, t, n) => {
|
|
541
|
+
for (let r = 0; r < e.steps.length; r += 1) {
|
|
542
|
+
let i = e.steps[r], a = e.mapping.maps[r], o = [];
|
|
543
|
+
if (a.forEach((e, t, n, r) => {
|
|
544
|
+
o.push([
|
|
545
|
+
e,
|
|
546
|
+
t,
|
|
547
|
+
n,
|
|
548
|
+
r
|
|
549
|
+
]);
|
|
550
|
+
}), o.length === 0) {
|
|
551
|
+
if ("mark" in i) continue;
|
|
552
|
+
return !0;
|
|
553
|
+
}
|
|
554
|
+
let s = r > 0 ? e.mapping.slice(0, r).invert() : null, c = r + 1 < e.mapping.maps.length ? e.mapping.slice(r + 1) : null;
|
|
555
|
+
for (let [e, r, i, a] of o) {
|
|
556
|
+
let o = s ? s.map(e, -1) : e, l = s ? s.map(r, 1) : r;
|
|
557
|
+
for (let e of t) {
|
|
558
|
+
if (e.pos > l) break;
|
|
559
|
+
if (o <= e.pos + e.node.nodeSize && l >= e.pos) return !0;
|
|
560
|
+
}
|
|
561
|
+
let u = Math.max(0, Math.min(n.content.size, c ? c.map(i, -1) : i)), d = Math.max(u, Math.min(n.content.size, c ? c.map(a, 1) : a));
|
|
562
|
+
if (u === d) {
|
|
563
|
+
if (mn(n, u)) return !0;
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
let f = !1;
|
|
567
|
+
if (n.nodesBetween(u, d, (e) => e.type.name === cn ? (f = !0, !1) : !f), f) return !0;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
return !1;
|
|
571
|
+
}, gn = B((e) => {
|
|
536
572
|
let { configureRefractor: t } = e.get(Ve.key), n = t?.(He) ?? He, r = new Set(n.listLanguages());
|
|
537
573
|
return new L({
|
|
538
|
-
key:
|
|
574
|
+
key: ln,
|
|
539
575
|
state: {
|
|
540
576
|
init: (e, { doc: t }) => {
|
|
541
|
-
let i =
|
|
542
|
-
for (let e of i) a.push(...
|
|
577
|
+
let i = dn(t), a = [];
|
|
578
|
+
for (let e of i) a.push(...fn(e, n, r));
|
|
543
579
|
return {
|
|
544
|
-
decorations:
|
|
580
|
+
decorations: rt.create(t, a),
|
|
545
581
|
blocks: i
|
|
546
582
|
};
|
|
547
583
|
},
|
|
@@ -550,8 +586,18 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
550
586
|
decorations: t.decorations.map(e.mapping, e.doc),
|
|
551
587
|
blocks: t.blocks
|
|
552
588
|
};
|
|
553
|
-
|
|
554
|
-
|
|
589
|
+
if (!hn(e, t.blocks, a.doc)) {
|
|
590
|
+
let n = t.blocks.length === 0 ? t.blocks : t.blocks.map((t) => ({
|
|
591
|
+
pos: e.mapping.map(t.pos, 1),
|
|
592
|
+
node: t.node
|
|
593
|
+
}));
|
|
594
|
+
return {
|
|
595
|
+
decorations: t.decorations.map(e.mapping, e.doc),
|
|
596
|
+
blocks: n
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
let o = dn(a.doc);
|
|
600
|
+
if (pn(t.blocks, o)) return {
|
|
555
601
|
decorations: t.decorations.map(e.mapping, e.doc),
|
|
556
602
|
blocks: o
|
|
557
603
|
};
|
|
@@ -564,7 +610,7 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
564
610
|
for (let e of o) {
|
|
565
611
|
if (c.has(e.pos)) continue;
|
|
566
612
|
let t = s.find(e.pos, e.pos + e.node.nodeSize);
|
|
567
|
-
t.length > 0 && (s = s.remove(t)), l.push(...
|
|
613
|
+
t.length > 0 && (s = s.remove(t)), l.push(...fn(e, n, r));
|
|
568
614
|
}
|
|
569
615
|
return l.length > 0 && (s = s.add(a.doc, l)), {
|
|
570
616
|
decorations: s,
|
|
@@ -573,10 +619,10 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
573
619
|
}
|
|
574
620
|
},
|
|
575
621
|
props: { decorations(e) {
|
|
576
|
-
return this.getState(e)?.decorations ??
|
|
622
|
+
return this.getState(e)?.decorations ?? rt.empty;
|
|
577
623
|
} }
|
|
578
624
|
});
|
|
579
|
-
}),
|
|
625
|
+
}), _n = (e, t) => typeof e == "function" ? (n) => {
|
|
580
626
|
t.action(e(n));
|
|
581
627
|
} : () => void 0, G = (e, t, n) => {
|
|
582
628
|
if (Array.isArray(n)) {
|
|
@@ -592,23 +638,23 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
592
638
|
name: t,
|
|
593
639
|
plugin: n
|
|
594
640
|
});
|
|
595
|
-
},
|
|
641
|
+
}, vn = (e, t = {}) => {
|
|
596
642
|
let n = [], r = t.includeRuntime ?? !0;
|
|
597
|
-
return G(n, "listener", e.listener), G(n, "commonmark", e.commonmark), G(n, "frontmatter", e.frontmatter), G(n, "task-list-transform-keymap", e.taskListTransformKeymap), G(n, "inline-code-boundary-navigation", e.inlineCodeBoundaryNavigation), G(n, "gfm", e.gfm), G(n, "history", e.history), G(n, "editor-search", e.editorSearch), G(n, "code-block-prism", e.codeBlockPrism), G(n, "code-block-language-picker", e.codeBlockLanguagePicker), r && (G(n, "clipboard", e.clipboard), G(n, "indent", e.indent)), G(n, "image-delete-selection", e.imageDeleteSelection), G(n, "image-paste", e.imagePaste), G(n, "table-arrow-entry", e.tableArrowEntry), G(n, "block-boundary-navigation", e.blockBoundaryNavigation), G(n, "heading-backspace-empty-paragraph", e.headingBackspaceEmptyParagraph), G(n, "heading-focus-indicator", e.headingFocusIndicator), G(n, "math-backspace-entry", e.mathBackspaceEntry), G(n, "blockquote-backspace-lift", e.blockquoteBackspaceLift), G(n, "table-focus-actions", e.tableFocusActions), G(n, "selection-tooltip", e.selectionTooltip), G(n, "gap-cursor", e.gapCursor), G(n, "drop-cursor", e.dropCursor), G(n, "math", e.math), G(n, "math-inline-edit", e.mathInlineEdit), G(n, "math-inline-arrow-navigation", e.mathInlineArrowNavigation), G(n, "task-list-toggle", e.taskListToggle), G(n, "tab-space-indent", e.tabSpaceIndent), G(n, "code-block-mod-a-select", e.codeBlockModASelect), e.slash && G(n, "slash", e.slash), n;
|
|
598
|
-
},
|
|
599
|
-
color:
|
|
600
|
-
width:
|
|
601
|
-
})),
|
|
643
|
+
return e.listener && G(n, "listener", e.listener), G(n, "commonmark", e.commonmark), G(n, "frontmatter", e.frontmatter), G(n, "task-list-transform-keymap", e.taskListTransformKeymap), G(n, "inline-code-boundary-navigation", e.inlineCodeBoundaryNavigation), G(n, "gfm", e.gfm), G(n, "cjk-friendly", e.cjkFriendly), G(n, "history", e.history), G(n, "editor-search", e.editorSearch), G(n, "code-block-prism", e.codeBlockPrism), G(n, "code-block-language-picker", e.codeBlockLanguagePicker), r && (G(n, "clipboard", e.clipboard), G(n, "indent", e.indent)), G(n, "image-delete-selection", e.imageDeleteSelection), G(n, "image-paste", e.imagePaste), G(n, "table-arrow-entry", e.tableArrowEntry), G(n, "block-boundary-navigation", e.blockBoundaryNavigation), G(n, "heading-backspace-empty-paragraph", e.headingBackspaceEmptyParagraph), G(n, "heading-focus-indicator", e.headingFocusIndicator), G(n, "math-backspace-entry", e.mathBackspaceEntry), G(n, "blockquote-backspace-lift", e.blockquoteBackspaceLift), G(n, "table-focus-actions", e.tableFocusActions), G(n, "selection-tooltip", e.selectionTooltip), G(n, "gap-cursor", e.gapCursor), G(n, "drop-cursor", e.dropCursor), G(n, "math", e.math), G(n, "math-inline-edit", e.mathInlineEdit), G(n, "math-inline-arrow-navigation", e.mathInlineArrowNavigation), G(n, "task-list-toggle", e.taskListToggle), G(n, "tab-space-indent", e.tabSpaceIndent), G(n, "code-block-mod-a-select", e.codeBlockModASelect), e.slash && G(n, "slash", e.slash), n;
|
|
644
|
+
}, yn = 2, bn = "var(--zt-primary)", xn = B(() => ut({
|
|
645
|
+
color: bn,
|
|
646
|
+
width: yn
|
|
647
|
+
})), Sn = B(() => ft()), Cn = -1, wn = 1, Tn = new Set([
|
|
602
648
|
"math_block",
|
|
603
649
|
"code_block",
|
|
604
650
|
"frontmatter",
|
|
605
651
|
"table",
|
|
606
652
|
"image",
|
|
607
653
|
"hr"
|
|
608
|
-
]),
|
|
654
|
+
]), En = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, Dn = (e, t, n) => {
|
|
609
655
|
let r = e.state.doc.resolve(t);
|
|
610
|
-
return
|
|
611
|
-
},
|
|
656
|
+
return dt.valid(r) ? new dt(r) : z.near(r, n);
|
|
657
|
+
}, On = (e, t) => t === Cn ? e.nodeBefore !== null : e.nodeAfter !== null, kn = (e, t) => {
|
|
612
658
|
let n = e.state.schema.nodes.paragraph;
|
|
613
659
|
if (!n) return !1;
|
|
614
660
|
let r = e.state.doc.resolve(t), i = r.index();
|
|
@@ -617,53 +663,53 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
617
663
|
if (!a) return !1;
|
|
618
664
|
let o = e.state.tr.insert(t, a), s = t + 1;
|
|
619
665
|
return o.setSelection(z.near(o.doc.resolve(s), 1)).scrollIntoView(), e.dispatch(o), e.focus(), !0;
|
|
620
|
-
},
|
|
621
|
-
if (!
|
|
622
|
-
let i = r ===
|
|
666
|
+
}, An = (e, t, n, r) => {
|
|
667
|
+
if (!Tn.has(n.type.name) || n.type.name === "frontmatter" && r === Cn) return !1;
|
|
668
|
+
let i = r === Cn ? t : t + n.nodeSize;
|
|
623
669
|
if (i < 0 || i > e.state.doc.content.size) return !1;
|
|
624
|
-
if (!
|
|
625
|
-
let a = e.state.tr.setSelection(
|
|
670
|
+
if (!On(e.state.doc.resolve(i), r) && kn(e, i)) return !0;
|
|
671
|
+
let a = e.state.tr.setSelection(Dn(e, i, r)).scrollIntoView();
|
|
626
672
|
return e.dispatch(a), e.focus(), !0;
|
|
627
|
-
},
|
|
673
|
+
}, jn = (e) => {
|
|
628
674
|
for (let t = e.depth; t > 0; --t) {
|
|
629
675
|
let n = e.node(t);
|
|
630
|
-
if (
|
|
676
|
+
if (Tn.has(n.type.name)) return {
|
|
631
677
|
node: n,
|
|
632
678
|
position: e.before(t),
|
|
633
679
|
depth: t
|
|
634
680
|
};
|
|
635
681
|
}
|
|
636
682
|
return null;
|
|
637
|
-
},
|
|
683
|
+
}, Mn = (e, t, n) => {
|
|
638
684
|
for (let r = t; r < e.depth; r += 1) {
|
|
639
685
|
let t = e.node(r);
|
|
640
|
-
if (e.index(r) !== (n ===
|
|
686
|
+
if (e.index(r) !== (n === Cn ? 0 : t.childCount - 1)) return !1;
|
|
641
687
|
}
|
|
642
688
|
return !0;
|
|
643
|
-
},
|
|
689
|
+
}, Nn = (e, t) => {
|
|
644
690
|
let { selection: n } = e.state;
|
|
645
|
-
if (n instanceof I) return
|
|
691
|
+
if (n instanceof I) return An(e, n.from, n.node, t);
|
|
646
692
|
if (!n.empty) return !1;
|
|
647
|
-
let r =
|
|
648
|
-
return !r || !
|
|
649
|
-
},
|
|
693
|
+
let r = jn(n.$from);
|
|
694
|
+
return !r || !Mn(n.$from, r.depth, t) || !e.endOfTextblock(t === Cn ? "up" : "down") ? !1 : An(e, r.position, r.node, t);
|
|
695
|
+
}, Pn = (e) => {
|
|
650
696
|
let { doc: t, selection: n } = e.state;
|
|
651
|
-
return !(n instanceof z) || !n.empty || !(n.$from.after(1) === t.content.size &&
|
|
652
|
-
},
|
|
653
|
-
ArrowUp: (e) =>
|
|
654
|
-
ArrowDown: (e) =>
|
|
655
|
-
},
|
|
656
|
-
let i = r === "ArrowUp" ?
|
|
657
|
-
return i === null || !
|
|
658
|
-
},
|
|
697
|
+
return !(n instanceof z) || !n.empty || !(n.$from.after(1) === t.content.size && Mn(n.$from, 1, wn)) || !e.endOfTextblock("down") ? !1 : kn(e, t.content.size);
|
|
698
|
+
}, Fn = {
|
|
699
|
+
ArrowUp: (e) => Nn(e, Cn),
|
|
700
|
+
ArrowDown: (e) => Nn(e, wn) || Pn(e)
|
|
701
|
+
}, In = (e, t) => t.defaultPrevented || t.altKey || t.ctrlKey || t.metaKey || t.shiftKey || !En(e), Ln = (e, t, n, r) => {
|
|
702
|
+
let i = r === "ArrowUp" ? Cn : r === "ArrowDown" ? wn : null;
|
|
703
|
+
return i === null || !En(e) ? !1 : An(e, t, n, i);
|
|
704
|
+
}, Rn = B(() => new L({
|
|
659
705
|
key: new R("zt-md-block-boundary-navigation"),
|
|
660
706
|
props: { handleKeyDown: (e, t) => {
|
|
661
|
-
let n =
|
|
662
|
-
if (!n ||
|
|
707
|
+
let n = Fn[t.key];
|
|
708
|
+
if (!n || In(e, t)) return !1;
|
|
663
709
|
let r = n(e);
|
|
664
710
|
return r && t.preventDefault(), r;
|
|
665
711
|
} }
|
|
666
|
-
})),
|
|
712
|
+
})), zn = {
|
|
667
713
|
AlignCenter: [
|
|
668
714
|
["path", { d: "M21 5H3" }],
|
|
669
715
|
["path", { d: "M17 12H7" }],
|
|
@@ -902,28 +948,28 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
902
948
|
["path", { d: "M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2" }],
|
|
903
949
|
["path", { d: "M9 20h6" }]
|
|
904
950
|
]
|
|
905
|
-
},
|
|
906
|
-
let n = t.size ?? 16, r = t.strokeWidth ?? 2, i = t.ariaHidden ?? !0, a = `${e}:${n}:${r}:${i}`, o =
|
|
951
|
+
}, Bn = /* @__PURE__ */ new Map(), Vn = (e) => Object.entries(e).map(([e, t]) => `${e}="${t}"`).join(" "), Hn = (e, t) => e && Object.prototype.hasOwnProperty.call(zn, e) ? e : t, K = (e, t = {}) => {
|
|
952
|
+
let n = t.size ?? 16, r = t.strokeWidth ?? 2, i = t.ariaHidden ?? !0, a = `${e}:${n}:${r}:${i}`, o = Bn.get(a);
|
|
907
953
|
if (o !== void 0) return o;
|
|
908
|
-
let s =
|
|
909
|
-
return
|
|
910
|
-
},
|
|
954
|
+
let s = zn[e].map(([e, t]) => `<${e} ${Vn(t)}></${e}>`).join(""), c = `<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${n}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${r}" stroke-linecap="round" stroke-linejoin="round"${i ? " aria-hidden=\"true\"" : ""}>${s}</svg>`;
|
|
955
|
+
return Bn.set(a, c), c;
|
|
956
|
+
}, Un = new Set([
|
|
911
957
|
"http:",
|
|
912
958
|
"https:",
|
|
913
959
|
"mailto:",
|
|
914
960
|
"tel:"
|
|
915
|
-
]),
|
|
961
|
+
]), Wn = new Set(["data:"]), Gn = /[\u0000-\u0020\u007f]+/g, Kn = /^([a-z][a-z\d+\-.]*:)/i, qn = /[<>"'`]/, Jn = new Set([
|
|
916
962
|
"src",
|
|
917
963
|
"alt",
|
|
918
964
|
"title",
|
|
919
965
|
"style"
|
|
920
|
-
]),
|
|
966
|
+
]), Yn = (e, t) => {
|
|
921
967
|
if (typeof e != "string") return "";
|
|
922
968
|
let n = e.trim();
|
|
923
|
-
if (!n ||
|
|
924
|
-
let r = n.replace(
|
|
969
|
+
if (!n || qn.test(n) || /[\u0000-\u001f\u007f]/.test(n)) return "";
|
|
970
|
+
let r = n.replace(Gn, "");
|
|
925
971
|
if (r.startsWith("//")) return "";
|
|
926
|
-
let i = r.match(
|
|
972
|
+
let i = r.match(Kn)?.[1]?.toLowerCase() ?? "";
|
|
927
973
|
if (!i) return n;
|
|
928
974
|
if (!t.has(i)) return "";
|
|
929
975
|
try {
|
|
@@ -931,11 +977,11 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
931
977
|
} catch {
|
|
932
978
|
return "";
|
|
933
979
|
}
|
|
934
|
-
},
|
|
935
|
-
...
|
|
936
|
-
...
|
|
980
|
+
}, Xn = (e) => Yn(e, Un), Zn = (e, t = []) => Yn(e, new Set([
|
|
981
|
+
...Un,
|
|
982
|
+
...Wn,
|
|
937
983
|
...t.map((e) => e.trim().toLowerCase())
|
|
938
|
-
])),
|
|
984
|
+
])), Qn = (e, t, n = []) => {
|
|
939
985
|
if (typeof e != "string") return null;
|
|
940
986
|
let r = e.trim();
|
|
941
987
|
if (!r) return null;
|
|
@@ -948,32 +994,32 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
948
994
|
return null;
|
|
949
995
|
}
|
|
950
996
|
if (!a || a.tagName.toLowerCase() !== "img") return null;
|
|
951
|
-
for (let e of Array.from(a.attributes)) if (!
|
|
952
|
-
let o =
|
|
997
|
+
for (let e of Array.from(a.attributes)) if (!Jn.has(e.name.toLowerCase())) return null;
|
|
998
|
+
let o = Zn(a.getAttribute("src") ?? "", n);
|
|
953
999
|
return o ? {
|
|
954
1000
|
src: o,
|
|
955
1001
|
alt: a.getAttribute("alt") ?? "",
|
|
956
1002
|
title: a.getAttribute("title") ?? "",
|
|
957
1003
|
style: t(a.getAttribute("style") ?? "")
|
|
958
1004
|
} : null;
|
|
959
|
-
},
|
|
1005
|
+
}, $n = /^\s*width\s*:\s*(\d{1,3})%\s*;?\s*$/i, er = (e, t) => {
|
|
960
1006
|
let n = Array.isArray(e.children) ? e.children : [], r = n[0];
|
|
961
|
-
return n.length === 1 && (r?.type === "image" || r?.type === "html" &&
|
|
962
|
-
},
|
|
1007
|
+
return n.length === 1 && (r?.type === "image" || r?.type === "html" && Qn(r.value, ir, t) !== null) ? r : null;
|
|
1008
|
+
}, tr = (e) => Math.min(100, Math.max(10, e)), nr = (e) => `width: ${tr(Math.round(e))}%;`, rr = (e) => {
|
|
963
1009
|
if (typeof e != "string") return null;
|
|
964
|
-
let t = e.match(
|
|
1010
|
+
let t = e.match($n);
|
|
965
1011
|
if (!t) return null;
|
|
966
1012
|
let n = Number(t[1]);
|
|
967
|
-
return Number.isFinite(n) ?
|
|
968
|
-
},
|
|
969
|
-
let t =
|
|
970
|
-
return t === null ? "" :
|
|
971
|
-
},
|
|
972
|
-
let n =
|
|
1013
|
+
return Number.isFinite(n) ? tr(n) : null;
|
|
1014
|
+
}, ir = (e) => {
|
|
1015
|
+
let t = rr(e);
|
|
1016
|
+
return t === null ? "" : nr(t);
|
|
1017
|
+
}, ar = (e) => typeof e == "string" ? e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">") : "", or = (e, t) => {
|
|
1018
|
+
let n = Zn(e.src, t);
|
|
973
1019
|
if (!n) return "";
|
|
974
|
-
let r = typeof e.alt == "string" ? e.alt : "", i = typeof e.title == "string" ? e.title : "", a = i ? ` title="${
|
|
975
|
-
return `<img src="${
|
|
976
|
-
},
|
|
1020
|
+
let r = typeof e.alt == "string" ? e.alt : "", i = typeof e.title == "string" ? e.title : "", a = i ? ` title="${ar(i)}"` : "", o = ir(e.style);
|
|
1021
|
+
return `<img src="${ar(n)}" alt="${ar(r)}"${a} style="${ar(o)}">`;
|
|
1022
|
+
}, sr = (e, t) => (n) => {
|
|
977
1023
|
let r = e(n);
|
|
978
1024
|
return {
|
|
979
1025
|
...r,
|
|
@@ -989,24 +1035,24 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
989
1035
|
parseDOM: [{
|
|
990
1036
|
tag: "img[src]",
|
|
991
1037
|
getAttrs: (e) => {
|
|
992
|
-
let n = e, r =
|
|
1038
|
+
let n = e, r = Zn(n.getAttribute("src") ?? "", t);
|
|
993
1039
|
return r ? {
|
|
994
1040
|
src: r,
|
|
995
1041
|
alt: n.getAttribute("alt") ?? "",
|
|
996
1042
|
title: n.getAttribute("title") ?? n.getAttribute("alt") ?? "",
|
|
997
|
-
style:
|
|
1043
|
+
style: ir(n.getAttribute("style") ?? "")
|
|
998
1044
|
} : !1;
|
|
999
1045
|
}
|
|
1000
1046
|
}],
|
|
1001
1047
|
parseMarkdown: {
|
|
1002
|
-
match: (e) => e.type === "image" || e.type === "html" &&
|
|
1048
|
+
match: (e) => e.type === "image" || e.type === "html" && Qn(e.value, ir, t) !== null,
|
|
1003
1049
|
runner: (e, n, r) => {
|
|
1004
1050
|
if (n.type === "html") {
|
|
1005
|
-
let i =
|
|
1051
|
+
let i = Qn(n.value, ir, t);
|
|
1006
1052
|
i && e.addNode(r, i);
|
|
1007
1053
|
return;
|
|
1008
1054
|
}
|
|
1009
|
-
let i =
|
|
1055
|
+
let i = Zn(String(n.url ?? ""), t);
|
|
1010
1056
|
i && e.addNode(r, {
|
|
1011
1057
|
src: i,
|
|
1012
1058
|
alt: String(n.alt ?? ""),
|
|
@@ -1018,11 +1064,11 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
1018
1064
|
toMarkdown: {
|
|
1019
1065
|
match: (e) => e.type.name === "image",
|
|
1020
1066
|
runner: (e, n) => {
|
|
1021
|
-
let r =
|
|
1067
|
+
let r = Zn(n.attrs.src, t);
|
|
1022
1068
|
if (!r) return;
|
|
1023
|
-
let i =
|
|
1069
|
+
let i = ir(n.attrs.style);
|
|
1024
1070
|
if (i) {
|
|
1025
|
-
let a =
|
|
1071
|
+
let a = or({
|
|
1026
1072
|
...n.attrs,
|
|
1027
1073
|
src: r,
|
|
1028
1074
|
style: i
|
|
@@ -1040,14 +1086,14 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
1040
1086
|
}
|
|
1041
1087
|
}
|
|
1042
1088
|
};
|
|
1043
|
-
},
|
|
1089
|
+
}, cr = (e, t) => (n) => {
|
|
1044
1090
|
let r = e(n);
|
|
1045
1091
|
return {
|
|
1046
1092
|
...r,
|
|
1047
1093
|
parseMarkdown: {
|
|
1048
1094
|
...r.parseMarkdown,
|
|
1049
1095
|
runner: (e, n, i) => {
|
|
1050
|
-
let a =
|
|
1096
|
+
let a = er(n, t);
|
|
1051
1097
|
if (a) {
|
|
1052
1098
|
e.next(a);
|
|
1053
1099
|
return;
|
|
@@ -1056,32 +1102,32 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
1056
1102
|
}
|
|
1057
1103
|
}
|
|
1058
1104
|
};
|
|
1059
|
-
},
|
|
1105
|
+
}, lr = (e, t = []) => {
|
|
1060
1106
|
let n = e.get(Fe.key), r = e.get(ze.key);
|
|
1061
|
-
e.set(Fe.key,
|
|
1062
|
-
},
|
|
1107
|
+
e.set(Fe.key, sr(n, t)), e.set(ze.key, cr(r, t));
|
|
1108
|
+
}, ur = "image", dr = "left", fr = "right", pr = 160, mr = K("Trash2", {
|
|
1063
1109
|
size: 14,
|
|
1064
1110
|
strokeWidth: 2
|
|
1065
|
-
}),
|
|
1111
|
+
}), hr = K("ImageOff", {
|
|
1066
1112
|
size: 14,
|
|
1067
1113
|
strokeWidth: 2
|
|
1068
|
-
}),
|
|
1114
|
+
}), gr = (e) => typeof e == "function" ? e() : null, _r = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, vr = class {
|
|
1069
1115
|
constructor(e, t, n, r) {
|
|
1070
1116
|
this.resizeState = null, this.isSelected = !1, this.currentImageSrc = "", this.imageLoadingStartedAt = 0, this.imageLoadingFinishTimer = null, this.handleDeleteClick = (e) => {
|
|
1071
|
-
e.preventDefault(), e.stopPropagation(),
|
|
1117
|
+
e.preventDefault(), e.stopPropagation(), _r(this.view) && this.deleteCurrentImage();
|
|
1072
1118
|
}, this.handleImageLoad = () => {
|
|
1073
1119
|
delete this.dom.dataset.loadError, this.finishImageLoadingWithMinimumDuration();
|
|
1074
1120
|
}, this.handleImageError = () => {
|
|
1075
1121
|
this.dom.dataset.loadError = "true", this.finishImageLoadingWithMinimumDuration();
|
|
1076
1122
|
}, this.handleResizePointerDown = (e) => {
|
|
1077
|
-
if (e.preventDefault(), e.stopPropagation(), !
|
|
1123
|
+
if (e.preventDefault(), e.stopPropagation(), !_r(this.view)) return;
|
|
1078
1124
|
let t = e.currentTarget;
|
|
1079
1125
|
if (!(t instanceof HTMLElement)) return;
|
|
1080
|
-
let n = t.dataset.side ===
|
|
1126
|
+
let n = t.dataset.side === dr ? dr : fr, r = this.dom.parentElement;
|
|
1081
1127
|
if (!r) return;
|
|
1082
1128
|
let i = this.imageElement.getBoundingClientRect(), a = r.getBoundingClientRect();
|
|
1083
1129
|
if (i.width <= 0 || a.width <= 0) return;
|
|
1084
|
-
let o =
|
|
1130
|
+
let o = tr(i.width / a.width * 100);
|
|
1085
1131
|
this.resizeState = {
|
|
1086
1132
|
side: n,
|
|
1087
1133
|
startClientX: e.clientX,
|
|
@@ -1092,13 +1138,13 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
1092
1138
|
}, this.handleResizePointerMove = (e) => {
|
|
1093
1139
|
if (!this.resizeState) return;
|
|
1094
1140
|
e.preventDefault();
|
|
1095
|
-
let t = e.clientX - this.resizeState.startClientX, n = this.resizeState.side ===
|
|
1141
|
+
let t = e.clientX - this.resizeState.startClientX, n = this.resizeState.side === dr ? -t : t, r = tr((this.resizeState.startWidth + n) / this.resizeState.containerWidth * 100);
|
|
1096
1142
|
this.resizeState.widthPercent = r, this.applyPreviewWidth(r);
|
|
1097
1143
|
}, this.handleResizePointerUp = (e) => {
|
|
1098
1144
|
if (e.preventDefault(), !this.resizeState) return;
|
|
1099
1145
|
let t = Math.round(this.resizeState.widthPercent);
|
|
1100
1146
|
this.resizeState = null, delete this.dom.dataset.resizing, this.removeResizeWindowListeners(), this.commitImageWidth(t);
|
|
1101
|
-
}, this.node = e, this.view = t, this.getPos = n, this.deleteAriaLabel = r.imageDeleteAriaLabel, this.dom = document.createElement("span"), this.dom.dataset.type =
|
|
1147
|
+
}, this.node = e, this.view = t, this.getPos = n, this.deleteAriaLabel = r.imageDeleteAriaLabel, this.dom = document.createElement("span"), this.dom.dataset.type = ur, this.dom.className = "zt-md-image", this.updateEditableState(), this.syncSelectedState(), this.imageElement = document.createElement("img"), this.imageElement.loading = "lazy", this.imageElement.decoding = "async", this.imageElement.addEventListener("load", this.handleImageLoad), this.imageElement.addEventListener("error", this.handleImageError), this.imageLoadErrorElement = document.createElement("span"), this.imageLoadErrorElement.className = "zt-md-image-load-error", this.imageLoadErrorElement.contentEditable = "false", this.imageLoadErrorElement.innerHTML = hr, this.imageLoadErrorElement.append(r.imageUploadLoadFailed), this.leftResizeHandle = this.createResizeHandle(dr), this.rightResizeHandle = this.createResizeHandle(fr), this.actionsContainer = document.createElement("span"), this.actionsContainer.className = "zt-md-image-actions", this.deleteButton = document.createElement("button"), this.deleteButton.type = "button", this.deleteButton.className = "zt-md-image-action-button zt-md-image-action-button-danger", this.deleteButton.setAttribute("aria-label", this.deleteAriaLabel), this.deleteButton.innerHTML = mr, this.actionsContainer.appendChild(this.deleteButton), this.dom.append(this.imageElement, this.imageLoadErrorElement, this.leftResizeHandle, this.rightResizeHandle, this.actionsContainer), this.syncFromNode(e), this.deleteButton.addEventListener("click", this.handleDeleteClick), this.leftResizeHandle.addEventListener("pointerdown", this.handleResizePointerDown), this.rightResizeHandle.addEventListener("pointerdown", this.handleResizePointerDown), this.stopObservingMessages = W(r, () => {
|
|
1102
1148
|
this.deleteButton.setAttribute("aria-label", r.imageDeleteAriaLabel);
|
|
1103
1149
|
let e = this.imageLoadErrorElement.lastChild;
|
|
1104
1150
|
e && (e.textContent = r.imageUploadLoadFailed);
|
|
@@ -1109,7 +1155,7 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
1109
1155
|
return t.className = `zt-md-image-resize-handle zt-md-image-resize-handle-${e}`, t.dataset.side = e, t.setAttribute("aria-hidden", "true"), t;
|
|
1110
1156
|
}
|
|
1111
1157
|
deleteCurrentImage() {
|
|
1112
|
-
let e =
|
|
1158
|
+
let e = gr(this.getPos);
|
|
1113
1159
|
if (e === null) return;
|
|
1114
1160
|
let t = this.view.state.tr.delete(e, e + this.node.nodeSize).scrollIntoView();
|
|
1115
1161
|
this.view.dispatch(t), requestAnimationFrame(() => {
|
|
@@ -1117,7 +1163,7 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
1117
1163
|
});
|
|
1118
1164
|
}
|
|
1119
1165
|
updateEditableState() {
|
|
1120
|
-
this.dom.dataset.editable =
|
|
1166
|
+
this.dom.dataset.editable = _r(this.view) ? "true" : "false";
|
|
1121
1167
|
}
|
|
1122
1168
|
syncSelectedState() {
|
|
1123
1169
|
this.dom.dataset.selected = this.isSelected ? "true" : "false";
|
|
@@ -1129,7 +1175,7 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
1129
1175
|
this.clearImageLoadingFinishTimer(), delete this.dom.dataset.loading;
|
|
1130
1176
|
}
|
|
1131
1177
|
finishImageLoadingWithMinimumDuration() {
|
|
1132
|
-
let e = performance.now() - this.imageLoadingStartedAt, t = Math.max(0,
|
|
1178
|
+
let e = performance.now() - this.imageLoadingStartedAt, t = Math.max(0, pr - e);
|
|
1133
1179
|
if (t <= 0) {
|
|
1134
1180
|
this.finishImageLoading();
|
|
1135
1181
|
return;
|
|
@@ -1148,11 +1194,11 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
1148
1194
|
this.dom.style.width = `${Math.round(e)}%`, this.dom.dataset.hasWidth = "true";
|
|
1149
1195
|
}
|
|
1150
1196
|
commitImageWidth(e) {
|
|
1151
|
-
let t =
|
|
1197
|
+
let t = gr(this.getPos);
|
|
1152
1198
|
if (t === null) return;
|
|
1153
1199
|
let n = {
|
|
1154
1200
|
...this.node.attrs,
|
|
1155
|
-
style:
|
|
1201
|
+
style: nr(e)
|
|
1156
1202
|
}, r = this.view.state.tr.setNodeMarkup(t, void 0, n);
|
|
1157
1203
|
this.view.dispatch(r), requestAnimationFrame(() => {
|
|
1158
1204
|
this.view.focus();
|
|
@@ -1160,11 +1206,11 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
1160
1206
|
}
|
|
1161
1207
|
syncFromNode(e) {
|
|
1162
1208
|
this.updateEditableState();
|
|
1163
|
-
let t = typeof e.attrs.src == "string" ? e.attrs.src : "", n = typeof e.attrs.alt == "string" ? e.attrs.alt : "", r = typeof e.attrs.title == "string" ? e.attrs.title : "", i =
|
|
1209
|
+
let t = typeof e.attrs.src == "string" ? e.attrs.src : "", n = typeof e.attrs.alt == "string" ? e.attrs.alt : "", r = typeof e.attrs.title == "string" ? e.attrs.title : "", i = rr(ir(e.attrs.style));
|
|
1164
1210
|
t !== this.currentImageSrc && (delete this.dom.dataset.loadError, t && this.markImageLoading()), this.imageElement.setAttribute("src", t), this.currentImageSrc = t, this.imageElement.setAttribute("alt", n), r ? this.imageElement.title = r : this.imageElement.removeAttribute("title"), i === null ? (this.dom.style.removeProperty("width"), delete this.dom.dataset.hasWidth) : (this.dom.style.width = `${i}%`, this.dom.dataset.hasWidth = "true"), t ? this.imageElement.complete && this.imageElement.naturalWidth > 0 && this.finishImageLoadingWithMinimumDuration() : this.finishImageLoading();
|
|
1165
1211
|
}
|
|
1166
1212
|
update(e) {
|
|
1167
|
-
return e.type.name ===
|
|
1213
|
+
return e.type.name === ur ? (this.node = e, this.syncFromNode(e), !0) : !1;
|
|
1168
1214
|
}
|
|
1169
1215
|
selectNode() {
|
|
1170
1216
|
this.isSelected = !0, this.syncSelectedState();
|
|
@@ -1182,63 +1228,63 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
1182
1228
|
destroy() {
|
|
1183
1229
|
this.stopObservingMessages(), this.removeResizeWindowListeners(), this.clearImageLoadingFinishTimer(), this.imageElement.removeEventListener("load", this.handleImageLoad), this.imageElement.removeEventListener("error", this.handleImageError), this.deleteButton.removeEventListener("click", this.handleDeleteClick), this.leftResizeHandle.removeEventListener("pointerdown", this.handleResizePointerDown), this.rightResizeHandle.removeEventListener("pointerdown", this.handleResizePointerDown);
|
|
1184
1230
|
}
|
|
1185
|
-
},
|
|
1231
|
+
}, yr = (e = U()) => (t, n, r) => new vr(t, n, typeof r == "function" ? () => {
|
|
1186
1232
|
let e = r();
|
|
1187
1233
|
return typeof e == "number" ? e : 0;
|
|
1188
|
-
} : !1, e),
|
|
1234
|
+
} : !1, e), br = "image", xr = {
|
|
1189
1235
|
Backspace: "before",
|
|
1190
1236
|
Delete: "after"
|
|
1191
|
-
},
|
|
1237
|
+
}, Sr = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, Cr = (e) => e instanceof Element ? !!e.closest(".zt-md-image-actions, .zt-md-image-resize-handle") : !1, wr = (e) => e?.type.name === br, Tr = (e, t) => !xr[t.key] || t.defaultPrevented || t.altKey || t.ctrlKey || t.metaKey || t.shiftKey || !Sr(e) || Cr(t.target) || Cr(document.activeElement), Er = (e) => {
|
|
1192
1238
|
if (e.parent.type.name !== "paragraph" || e.parentOffset !== 0 || e.parent.textContent.length > 0 || e.depth < 1) return null;
|
|
1193
1239
|
let t = e.index(e.depth - 1);
|
|
1194
1240
|
if (t <= 0) return null;
|
|
1195
1241
|
let n = e.node(e.depth - 1).child(t - 1);
|
|
1196
|
-
return
|
|
1197
|
-
},
|
|
1242
|
+
return wr(n) ? { previousBlockStart: e.before(e.depth) - n.nodeSize } : null;
|
|
1243
|
+
}, Dr = (e, t) => {
|
|
1198
1244
|
try {
|
|
1199
1245
|
return z.create(e, t);
|
|
1200
1246
|
} catch {
|
|
1201
1247
|
return z.near(e.resolve(t), -1);
|
|
1202
1248
|
}
|
|
1203
|
-
},
|
|
1249
|
+
}, Or = (e, t, n) => {
|
|
1204
1250
|
n.preventDefault();
|
|
1205
1251
|
let r = t.from, i = e.state.tr.delete(t.from, t.to), a = i.doc.content.size, o = Math.min(r, a);
|
|
1206
|
-
return i.setSelection(
|
|
1207
|
-
},
|
|
1252
|
+
return i.setSelection(Dr(i.doc, o)).scrollIntoView(), e.dispatch(i), e.focus(), !0;
|
|
1253
|
+
}, kr = (e, t) => {
|
|
1208
1254
|
if (t.key !== "Backspace") return !1;
|
|
1209
1255
|
let { selection: n } = e.state;
|
|
1210
1256
|
if (!n.empty) return !1;
|
|
1211
|
-
let r = n.$from, i =
|
|
1257
|
+
let r = n.$from, i = Er(r);
|
|
1212
1258
|
if (!i) return !1;
|
|
1213
1259
|
let a = r.before(r.depth), o = a + r.parent.nodeSize;
|
|
1214
1260
|
t.preventDefault();
|
|
1215
1261
|
let s = e.state.tr;
|
|
1216
1262
|
return s.delete(a, o), s.setSelection(I.create(s.doc, i.previousBlockStart)).scrollIntoView(), e.dispatch(s), e.focus(), !0;
|
|
1217
|
-
},
|
|
1218
|
-
if (
|
|
1219
|
-
let n =
|
|
1263
|
+
}, Ar = (e, t) => {
|
|
1264
|
+
if (kr(e, t)) return !0;
|
|
1265
|
+
let n = xr[t.key];
|
|
1220
1266
|
if (!n) return !1;
|
|
1221
1267
|
let { selection: r } = e.state;
|
|
1222
1268
|
if (!r.empty) return !1;
|
|
1223
1269
|
let i = r.$from, a = n === "before" ? i.nodeBefore : i.nodeAfter;
|
|
1224
|
-
if (!
|
|
1270
|
+
if (!wr(a)) return !1;
|
|
1225
1271
|
t.preventDefault();
|
|
1226
1272
|
let o = n === "before" ? r.from - a.nodeSize : r.from;
|
|
1227
1273
|
return e.dispatch(e.state.tr.setSelection(I.create(e.state.doc, o)).scrollIntoView()), e.focus(), !0;
|
|
1228
|
-
},
|
|
1229
|
-
if (
|
|
1274
|
+
}, jr = (e, t) => {
|
|
1275
|
+
if (Tr(e, t)) return !1;
|
|
1230
1276
|
let { selection: n } = e.state;
|
|
1231
|
-
return n instanceof I &&
|
|
1232
|
-
},
|
|
1277
|
+
return n instanceof I && wr(n.node) ? Or(e, n, t) : Ar(e, t);
|
|
1278
|
+
}, Mr = B(() => new L({
|
|
1233
1279
|
key: new R("zt-md-image-delete-selection"),
|
|
1234
|
-
props: { handleKeyDown: (e, t) =>
|
|
1235
|
-
})),
|
|
1280
|
+
props: { handleKeyDown: (e, t) => jr(e, t) }
|
|
1281
|
+
})), Nr = (e) => e.state.schema.nodes.paragraph?.createAndFill() ?? null, Pr = (e, t) => e.state.schema.nodes.image?.create(t) ?? null, Fr = (e) => {
|
|
1236
1282
|
let t = e.$to.parent;
|
|
1237
1283
|
if (e.$to.parentOffset < t.content.size) return !0;
|
|
1238
1284
|
if (e.$to.depth < 1) return !1;
|
|
1239
1285
|
let n = e.$to.node(e.$to.depth - 1);
|
|
1240
1286
|
return e.$to.index(e.$to.depth - 1) < n.childCount - 1;
|
|
1241
|
-
},
|
|
1287
|
+
}, Ir = (e, t) => {
|
|
1242
1288
|
let n = [
|
|
1243
1289
|
t,
|
|
1244
1290
|
t - 1,
|
|
@@ -1246,20 +1292,20 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
1246
1292
|
];
|
|
1247
1293
|
for (let t of n) if (!(t < 0 || t > e.content.size) && e.nodeAt(t)?.type.name === "image") return t;
|
|
1248
1294
|
return null;
|
|
1249
|
-
},
|
|
1250
|
-
let n = e.selection.from - t, r =
|
|
1295
|
+
}, Lr = (e, t) => {
|
|
1296
|
+
let n = e.selection.from - t, r = Ir(e.doc, n);
|
|
1251
1297
|
return r === null ? null : I.create(e.doc, r);
|
|
1252
|
-
},
|
|
1253
|
-
let r =
|
|
1298
|
+
}, Rr = (e, t, n = e.state.selection) => {
|
|
1299
|
+
let r = Pr(e, t);
|
|
1254
1300
|
if (!r) return !1;
|
|
1255
|
-
let i =
|
|
1301
|
+
let i = Fr(n), a = e.state.tr.setSelection(n).replaceSelectionWith(r), o = a.selection.to;
|
|
1256
1302
|
if (!i) {
|
|
1257
|
-
let t =
|
|
1303
|
+
let t = Nr(e);
|
|
1258
1304
|
t && a.insert(o, t);
|
|
1259
1305
|
}
|
|
1260
|
-
let s =
|
|
1306
|
+
let s = Lr(a, r.nodeSize);
|
|
1261
1307
|
return s ? (a.setSelection(s).scrollIntoView(), e.dispatch(a), !0) : !1;
|
|
1262
|
-
},
|
|
1308
|
+
}, zr = "zt-md-image-upload-file-input", Br = "zt-md-image-upload-alt-input", Vr = (e) => new Promise((t, n) => {
|
|
1263
1309
|
let r = new FileReader();
|
|
1264
1310
|
r.onload = () => {
|
|
1265
1311
|
let e = r.result;
|
|
@@ -1271,77 +1317,77 @@ var on = "code_block", sn = new R("MILKDOWN_PRISM"), cn = (e, t = []) => {
|
|
|
1271
1317
|
}, r.onerror = () => {
|
|
1272
1318
|
n(r.error ?? /* @__PURE__ */ Error("File read failed"));
|
|
1273
1319
|
}, r.readAsDataURL(e);
|
|
1274
|
-
}),
|
|
1320
|
+
}), Hr = (e) => e < 1024 * 1024 ? `${Math.ceil(e / 1024)}KB` : `${(e / 1024 / 1024).toFixed(1)}MB`, Ur = (e) => {
|
|
1275
1321
|
try {
|
|
1276
1322
|
let t = new URL(e);
|
|
1277
1323
|
return !!(t.protocol && t.host);
|
|
1278
1324
|
} catch {
|
|
1279
1325
|
return !1;
|
|
1280
1326
|
}
|
|
1281
|
-
},
|
|
1327
|
+
}, Wr = (e) => new Promise((t, n) => {
|
|
1282
1328
|
let r = new Image();
|
|
1283
1329
|
r.onload = () => {
|
|
1284
1330
|
t();
|
|
1285
1331
|
}, r.onerror = () => {
|
|
1286
1332
|
n(/* @__PURE__ */ Error("Image load failed"));
|
|
1287
1333
|
}, r.src = e;
|
|
1288
|
-
}),
|
|
1334
|
+
}), Gr = (e) => e.replace(/\.[^/.]+$/, ""), Kr = new R("zt-md-image-paste"), qr = 0, Jr = (e) => (typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable) && !e.state.selection.$from.parent.type.spec.code, Yr = (e) => Array.from(e.items).find((e) => e.kind === "file" && e.type.startsWith("image/"))?.getAsFile() || (Array.from(e.files).find((e) => e.type.startsWith("image/")) ?? null), Xr = () => (qr += 1, `image-paste-${qr}`), Zr = (e, t) => {
|
|
1289
1335
|
let n = /* @__PURE__ */ new Map();
|
|
1290
1336
|
t.forEach((t, r) => {
|
|
1291
1337
|
n.set(r, t.map(e.mapping));
|
|
1292
1338
|
});
|
|
1293
|
-
let r = e.getMeta(
|
|
1339
|
+
let r = e.getMeta(Kr);
|
|
1294
1340
|
return r?.type === "add" && n.set(r.requestId, r.bookmark), r?.type === "remove" && n.delete(r.requestId), n;
|
|
1295
|
-
},
|
|
1296
|
-
e.isDestroyed || !
|
|
1341
|
+
}, Qr = (e, t) => {
|
|
1342
|
+
e.isDestroyed || !Kr.getState(e.state)?.has(t) || e.dispatch(e.state.tr.setMeta(Kr, {
|
|
1297
1343
|
type: "remove",
|
|
1298
1344
|
requestId: t
|
|
1299
1345
|
}));
|
|
1300
|
-
},
|
|
1301
|
-
let r = t?.upload ? await t.upload(e) : await
|
|
1346
|
+
}, $r = async (e, t, n) => {
|
|
1347
|
+
let r = t?.upload ? await t.upload(e) : await Vr(e);
|
|
1302
1348
|
if (!r) throw Error(n.imageUploadFailed);
|
|
1303
1349
|
return r;
|
|
1304
|
-
},
|
|
1350
|
+
}, ei = async (e, t, n, r, i) => {
|
|
1305
1351
|
try {
|
|
1306
|
-
let a = await
|
|
1352
|
+
let a = await $r(t, r, i);
|
|
1307
1353
|
if (e.isDestroyed) return;
|
|
1308
|
-
let o =
|
|
1354
|
+
let o = Kr.getState(e.state)?.get(n);
|
|
1309
1355
|
if (!o) return;
|
|
1310
1356
|
let s = o.resolve(e.state.doc);
|
|
1311
|
-
|
|
1357
|
+
Qr(e, n), Rr(e, {
|
|
1312
1358
|
src: a,
|
|
1313
|
-
alt:
|
|
1359
|
+
alt: Gr(t.name),
|
|
1314
1360
|
title: ""
|
|
1315
1361
|
}, s);
|
|
1316
1362
|
} catch (e) {
|
|
1317
1363
|
console.error(e);
|
|
1318
1364
|
} finally {
|
|
1319
|
-
|
|
1365
|
+
Qr(e, n);
|
|
1320
1366
|
}
|
|
1321
|
-
},
|
|
1322
|
-
key:
|
|
1367
|
+
}, ti = (e, t) => B(() => new L({
|
|
1368
|
+
key: Kr,
|
|
1323
1369
|
state: {
|
|
1324
1370
|
init: () => /* @__PURE__ */ new Map(),
|
|
1325
|
-
apply:
|
|
1371
|
+
apply: Zr
|
|
1326
1372
|
},
|
|
1327
1373
|
props: { handlePaste: (n, r) => {
|
|
1328
|
-
if (!
|
|
1329
|
-
let i = r.clipboardData ?
|
|
1374
|
+
if (!Jr(n)) return !1;
|
|
1375
|
+
let i = r.clipboardData ? Yr(r.clipboardData) : null;
|
|
1330
1376
|
if (!i) return !1;
|
|
1331
1377
|
r.preventDefault();
|
|
1332
1378
|
let a = e?.maxFileSize ?? 5242880;
|
|
1333
|
-
if (i.size > a) return console.error(Error(t.imageUploadFileSizeExceeded.replace("{size}",
|
|
1334
|
-
let o =
|
|
1335
|
-
return n.dispatch(n.state.tr.setMeta(
|
|
1379
|
+
if (i.size > a) return console.error(Error(t.imageUploadFileSizeExceeded.replace("{size}", Hr(a)))), !0;
|
|
1380
|
+
let o = Xr(), s = n.state.selection.getBookmark();
|
|
1381
|
+
return n.dispatch(n.state.tr.setMeta(Kr, {
|
|
1336
1382
|
type: "add",
|
|
1337
1383
|
requestId: o,
|
|
1338
1384
|
bookmark: s
|
|
1339
|
-
})),
|
|
1385
|
+
})), ei(n, i, o, e, t), !0;
|
|
1340
1386
|
} }
|
|
1341
1387
|
}));
|
|
1342
1388
|
//#endregion
|
|
1343
1389
|
//#region src/components/ui/dialog.tsx
|
|
1344
|
-
function
|
|
1390
|
+
function ni({ ...e }) {
|
|
1345
1391
|
return /* @__PURE__ */ P(N.Root, {
|
|
1346
1392
|
"data-slot": "dialog",
|
|
1347
1393
|
...e
|
|
@@ -1354,7 +1400,7 @@ e.forwardRef(function({ ...e }, t) {
|
|
|
1354
1400
|
...e
|
|
1355
1401
|
});
|
|
1356
1402
|
});
|
|
1357
|
-
function
|
|
1403
|
+
function ri({ container: e, ...t }) {
|
|
1358
1404
|
return /* @__PURE__ */ P(N.Portal, {
|
|
1359
1405
|
"data-slot": "dialog-portal",
|
|
1360
1406
|
container: e ?? void 0,
|
|
@@ -1368,20 +1414,20 @@ e.forwardRef(function({ ...e }, t) {
|
|
|
1368
1414
|
...e
|
|
1369
1415
|
});
|
|
1370
1416
|
});
|
|
1371
|
-
var
|
|
1417
|
+
var ii = e.forwardRef(function({ className: e, ...t }, n) {
|
|
1372
1418
|
return /* @__PURE__ */ P(N.Overlay, {
|
|
1373
1419
|
ref: n,
|
|
1374
1420
|
"data-slot": "dialog-overlay",
|
|
1375
|
-
className:
|
|
1421
|
+
className: V("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0", e),
|
|
1376
1422
|
...t
|
|
1377
1423
|
});
|
|
1378
|
-
}),
|
|
1379
|
-
return /* @__PURE__ */ F(
|
|
1424
|
+
}), ai = e.forwardRef(function({ container: e, className: t, children: n, showCloseButton: r = !0, closeLabel: i = "Close", ...a }, o) {
|
|
1425
|
+
return /* @__PURE__ */ F(ri, {
|
|
1380
1426
|
container: e,
|
|
1381
|
-
children: [/* @__PURE__ */ P(
|
|
1427
|
+
children: [/* @__PURE__ */ P(ii, {}), /* @__PURE__ */ F(N.Content, {
|
|
1382
1428
|
ref: o,
|
|
1383
1429
|
"data-slot": "dialog-content",
|
|
1384
|
-
className:
|
|
1430
|
+
className: V("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", t),
|
|
1385
1431
|
...a,
|
|
1386
1432
|
children: [n, r && /* @__PURE__ */ P(N.Close, {
|
|
1387
1433
|
"data-slot": "dialog-close",
|
|
@@ -1399,17 +1445,17 @@ var $r = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1399
1445
|
})]
|
|
1400
1446
|
});
|
|
1401
1447
|
});
|
|
1402
|
-
function
|
|
1448
|
+
function oi({ className: e, ...t }) {
|
|
1403
1449
|
return /* @__PURE__ */ P("div", {
|
|
1404
1450
|
"data-slot": "dialog-header",
|
|
1405
|
-
className:
|
|
1451
|
+
className: V("flex flex-col gap-2", e),
|
|
1406
1452
|
...t
|
|
1407
1453
|
});
|
|
1408
1454
|
}
|
|
1409
|
-
function
|
|
1455
|
+
function si({ className: e, showCloseButton: t = !1, children: n, ...r }) {
|
|
1410
1456
|
return /* @__PURE__ */ F("div", {
|
|
1411
1457
|
"data-slot": "dialog-footer",
|
|
1412
|
-
className:
|
|
1458
|
+
className: V("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end", e),
|
|
1413
1459
|
...r,
|
|
1414
1460
|
children: [n, t && /* @__PURE__ */ P(N.Close, {
|
|
1415
1461
|
asChild: !0,
|
|
@@ -1420,22 +1466,22 @@ function ni({ className: e, showCloseButton: t = !1, children: n, ...r }) {
|
|
|
1420
1466
|
})]
|
|
1421
1467
|
});
|
|
1422
1468
|
}
|
|
1423
|
-
var
|
|
1469
|
+
var ci = e.forwardRef(function({ className: e, ...t }, n) {
|
|
1424
1470
|
return /* @__PURE__ */ P(N.Title, {
|
|
1425
1471
|
ref: n,
|
|
1426
1472
|
"data-slot": "dialog-title",
|
|
1427
|
-
className:
|
|
1473
|
+
className: V("text-base leading-none font-medium", e),
|
|
1428
1474
|
...t
|
|
1429
1475
|
});
|
|
1430
|
-
}),
|
|
1476
|
+
}), li = e.forwardRef(function({ className: e, ...t }, n) {
|
|
1431
1477
|
return /* @__PURE__ */ P(N.Description, {
|
|
1432
1478
|
ref: n,
|
|
1433
1479
|
"data-slot": "dialog-description",
|
|
1434
|
-
className:
|
|
1480
|
+
className: V("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground", e),
|
|
1435
1481
|
...t
|
|
1436
1482
|
});
|
|
1437
|
-
}),
|
|
1438
|
-
let [l, u] = c("file"), [d, f] = c(""), [p, m] = c(""), [g, _] = c(!1), [v, y] = c(null), [b, x] = c(!1), [S, C] = c(!1), [w, T] = c(!1), E = s(null), D = s(null), O = s(!0), k = n?.maxFileSize ?? 5242880, A = b || S,
|
|
1483
|
+
}), ui = ({ messages: e, portalContainer: t, imageUpload: n, onConfirm: a, onCancel: o }) => {
|
|
1484
|
+
let [l, u] = c("file"), [d, f] = c(""), [p, m] = c(""), [g, _] = c(!1), [v, y] = c(null), [b, x] = c(!1), [S, C] = c(!1), [w, T] = c(!1), E = s(null), D = s(null), O = s(!0), k = n?.maxFileSize ?? 5242880, A = b || S, j = l === "file" && !!d && !A, ne = (v ? "key" in v ? e[v.key].replace("{size}", Hr(k)) : v.text : "") || (j ? e.imageUploadReselectHint : ""), re = !!v, M = !!ne, ie = !!d && !v && !b && !g, oe = !d || !!v || A || g, se = r(async (e) => {
|
|
1439
1485
|
if (!e.type.startsWith("image/")) {
|
|
1440
1486
|
f(""), m(""), y({ key: "imageUploadInvalidType" });
|
|
1441
1487
|
return;
|
|
@@ -1444,9 +1490,9 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1444
1490
|
f(""), m(""), y({ key: "imageUploadFileSizeExceeded" });
|
|
1445
1491
|
return;
|
|
1446
1492
|
}
|
|
1447
|
-
y(null), m(
|
|
1493
|
+
y(null), m(Gr(e.name)), _(!1), x(!0);
|
|
1448
1494
|
try {
|
|
1449
|
-
let t = n?.upload ? await n.upload(e) : await
|
|
1495
|
+
let t = n?.upload ? await n.upload(e) : await Vr(e);
|
|
1450
1496
|
if (!O.current) return;
|
|
1451
1497
|
if (!t) {
|
|
1452
1498
|
f(""), y({ key: "imageUploadFailed" });
|
|
@@ -1468,7 +1514,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1468
1514
|
y(null);
|
|
1469
1515
|
return;
|
|
1470
1516
|
}
|
|
1471
|
-
y(
|
|
1517
|
+
y(Ur(e) ? null : { key: "imageUploadInvalidUrl" });
|
|
1472
1518
|
}, []), ue = r((e) => {
|
|
1473
1519
|
e.preventDefault(), e.stopPropagation(), !A && (e.dataTransfer.dropEffect = "copy", T(!0));
|
|
1474
1520
|
}, [A]), de = r((e) => {
|
|
@@ -1488,13 +1534,13 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1488
1534
|
y({ key: "imageUploadSelectOrEnterImage" });
|
|
1489
1535
|
return;
|
|
1490
1536
|
}
|
|
1491
|
-
if (l === "url" && !
|
|
1537
|
+
if (l === "url" && !Ur(d)) {
|
|
1492
1538
|
y({ key: "imageUploadInvalidUrl" });
|
|
1493
1539
|
return;
|
|
1494
1540
|
}
|
|
1495
1541
|
y(null), C(!0);
|
|
1496
1542
|
try {
|
|
1497
|
-
if (await
|
|
1543
|
+
if (await Wr(d), !O.current) return;
|
|
1498
1544
|
a({
|
|
1499
1545
|
src: d,
|
|
1500
1546
|
alt: p.trim()
|
|
@@ -1517,10 +1563,10 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1517
1563
|
O.current = !1;
|
|
1518
1564
|
}), []), i(() => {
|
|
1519
1565
|
l === "url" && D.current?.focus();
|
|
1520
|
-
}, [l]), /* @__PURE__ */ P(
|
|
1566
|
+
}, [l]), /* @__PURE__ */ P(ni, {
|
|
1521
1567
|
open: !0,
|
|
1522
1568
|
onOpenChange: (e) => !e && o(),
|
|
1523
|
-
children: /* @__PURE__ */ F(
|
|
1569
|
+
children: /* @__PURE__ */ F(ai, {
|
|
1524
1570
|
container: t,
|
|
1525
1571
|
className: "zt-md-image-upload-content-shell max-w-2xl sm:!max-w-2xl max-h-[90vh] overflow-hidden flex flex-col",
|
|
1526
1572
|
closeLabel: e.imageUploadCancelLabel,
|
|
@@ -1528,7 +1574,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1528
1574
|
onMouseDown: (e) => e.stopPropagation(),
|
|
1529
1575
|
onKeyDown: me,
|
|
1530
1576
|
children: [
|
|
1531
|
-
/* @__PURE__ */ F(
|
|
1577
|
+
/* @__PURE__ */ F(oi, { children: [/* @__PURE__ */ P(ci, { children: e.imageUploadDialogTitle }), /* @__PURE__ */ P(li, {
|
|
1532
1578
|
className: "sr-only",
|
|
1533
1579
|
children: `${e.imageUploadFileTab},${e.imageUploadUrlTab}`
|
|
1534
1580
|
})] }),
|
|
@@ -1565,14 +1611,14 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1565
1611
|
className: "zt-md-image-upload-file",
|
|
1566
1612
|
children: [/* @__PURE__ */ P("input", {
|
|
1567
1613
|
ref: E,
|
|
1568
|
-
id:
|
|
1614
|
+
id: zr,
|
|
1569
1615
|
type: "file",
|
|
1570
1616
|
accept: "image/*",
|
|
1571
1617
|
className: "zt-md-image-upload-file-input",
|
|
1572
1618
|
disabled: A,
|
|
1573
1619
|
onChange: ce
|
|
1574
1620
|
}), /* @__PURE__ */ P("label", {
|
|
1575
|
-
htmlFor:
|
|
1621
|
+
htmlFor: zr,
|
|
1576
1622
|
className: "zt-md-image-upload-file-label",
|
|
1577
1623
|
"data-drag-over": w ? "true" : "false",
|
|
1578
1624
|
"data-has-preview": d ? "true" : "false",
|
|
@@ -1597,7 +1643,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1597
1643
|
className: "zt-md-image-upload-file-preview",
|
|
1598
1644
|
children: g ? /* @__PURE__ */ F("div", {
|
|
1599
1645
|
className: "zt-md-image-upload-preview-error",
|
|
1600
|
-
children: [/* @__PURE__ */ P(
|
|
1646
|
+
children: [/* @__PURE__ */ P(ee, { size: 40 }), /* @__PURE__ */ P("span", { children: e.imageUploadLoadFailed })]
|
|
1601
1647
|
}) : /* @__PURE__ */ P("img", {
|
|
1602
1648
|
src: d,
|
|
1603
1649
|
alt: "",
|
|
@@ -1607,7 +1653,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1607
1653
|
}) : /* @__PURE__ */ F(he, { children: [
|
|
1608
1654
|
/* @__PURE__ */ P("div", {
|
|
1609
1655
|
className: "zt-md-image-upload-file-icon",
|
|
1610
|
-
children: /* @__PURE__ */ P(
|
|
1656
|
+
children: /* @__PURE__ */ P(te, { size: 40 })
|
|
1611
1657
|
}),
|
|
1612
1658
|
/* @__PURE__ */ P("div", {
|
|
1613
1659
|
className: "zt-md-image-upload-file-text",
|
|
@@ -1615,7 +1661,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1615
1661
|
}),
|
|
1616
1662
|
/* @__PURE__ */ P("div", {
|
|
1617
1663
|
className: "zt-md-image-upload-file-hint",
|
|
1618
|
-
children: e.imageUploadSupportsAndMax.replace("{size}",
|
|
1664
|
+
children: e.imageUploadSupportsAndMax.replace("{size}", Hr(k))
|
|
1619
1665
|
})
|
|
1620
1666
|
] })
|
|
1621
1667
|
})]
|
|
@@ -1641,7 +1687,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1641
1687
|
className: "zt-md-image-upload-url-preview",
|
|
1642
1688
|
children: g ? /* @__PURE__ */ F("div", {
|
|
1643
1689
|
className: "zt-md-image-upload-preview-error",
|
|
1644
|
-
children: [/* @__PURE__ */ P(
|
|
1690
|
+
children: [/* @__PURE__ */ P(ee, { size: 32 }), /* @__PURE__ */ P("span", { children: e.imageUploadLoadFailed })]
|
|
1645
1691
|
}) : /* @__PURE__ */ P("img", {
|
|
1646
1692
|
src: d,
|
|
1647
1693
|
alt: "",
|
|
@@ -1655,10 +1701,10 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1655
1701
|
className: "zt-md-image-upload-alt",
|
|
1656
1702
|
children: [/* @__PURE__ */ P("label", {
|
|
1657
1703
|
className: "zt-md-image-upload-label",
|
|
1658
|
-
htmlFor:
|
|
1704
|
+
htmlFor: Br,
|
|
1659
1705
|
children: e.imageUploadAltLabel
|
|
1660
1706
|
}), /* @__PURE__ */ P("input", {
|
|
1661
|
-
id:
|
|
1707
|
+
id: Br,
|
|
1662
1708
|
type: "text",
|
|
1663
1709
|
className: "zt-md-image-upload-alt-input",
|
|
1664
1710
|
placeholder: e.imageUploadAltPlaceholder,
|
|
@@ -1669,23 +1715,23 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1669
1715
|
}) : null,
|
|
1670
1716
|
/* @__PURE__ */ F("div", {
|
|
1671
1717
|
className: "zt-md-image-upload-file-hint zt-md-image-upload-reselect-hint",
|
|
1672
|
-
"data-error":
|
|
1718
|
+
"data-error": re ? "true" : "false",
|
|
1673
1719
|
"data-placeholder": M ? "false" : "true",
|
|
1674
|
-
role:
|
|
1675
|
-
"aria-live":
|
|
1720
|
+
role: re ? "alert" : void 0,
|
|
1721
|
+
"aria-live": re ? "polite" : "off",
|
|
1676
1722
|
"aria-hidden": !M,
|
|
1677
|
-
children: [
|
|
1723
|
+
children: [re ? /* @__PURE__ */ P(h, {
|
|
1678
1724
|
size: 14,
|
|
1679
1725
|
className: "zt-md-image-upload-hint-icon"
|
|
1680
1726
|
}) : null, /* @__PURE__ */ P("span", {
|
|
1681
1727
|
className: "zt-md-image-upload-hint-text",
|
|
1682
|
-
children:
|
|
1728
|
+
children: ne || e.imageUploadReselectHint
|
|
1683
1729
|
})]
|
|
1684
1730
|
})
|
|
1685
1731
|
]
|
|
1686
1732
|
})
|
|
1687
1733
|
}),
|
|
1688
|
-
/* @__PURE__ */ F(
|
|
1734
|
+
/* @__PURE__ */ F(si, { children: [/* @__PURE__ */ P(H, {
|
|
1689
1735
|
type: "button",
|
|
1690
1736
|
variant: "outline",
|
|
1691
1737
|
onClick: o,
|
|
@@ -1701,7 +1747,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1701
1747
|
]
|
|
1702
1748
|
})
|
|
1703
1749
|
});
|
|
1704
|
-
},
|
|
1750
|
+
}, di = [
|
|
1705
1751
|
"--zt-font",
|
|
1706
1752
|
"--zt-font-mono",
|
|
1707
1753
|
"--zt-bg",
|
|
@@ -1727,18 +1773,18 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1727
1773
|
"--zt-shadow-lg",
|
|
1728
1774
|
"--zt-radius",
|
|
1729
1775
|
"--zt-radius-lg"
|
|
1730
|
-
],
|
|
1776
|
+
], fi = (e, t) => {
|
|
1731
1777
|
if (!t) return;
|
|
1732
1778
|
let n = window.getComputedStyle(t);
|
|
1733
|
-
|
|
1779
|
+
di.forEach((t) => {
|
|
1734
1780
|
let r = n.getPropertyValue(t);
|
|
1735
1781
|
r && e.style.setProperty(t, r.trim());
|
|
1736
1782
|
});
|
|
1737
|
-
},
|
|
1783
|
+
}, pi = (e, t) => {
|
|
1738
1784
|
let n = e.closest(".zt-md"), r = n?.classList.contains("zt-md-dark") ? "zt-md-dark" : "zt-md-light", i = document.createElement("div");
|
|
1739
|
-
return i.className = `zt-md zt-md-dialog-host ${t} ${r}`,
|
|
1740
|
-
},
|
|
1741
|
-
let t =
|
|
1785
|
+
return i.className = `zt-md zt-md-dialog-host ${t} ${r}`, fi(i, n), document.body.appendChild(i), i;
|
|
1786
|
+
}, mi = (e) => {
|
|
1787
|
+
let t = pi(e.portalContainer, "zt-md-image-upload-host"), r = pt(t), i = (e) => {
|
|
1742
1788
|
s(), queueMicrotask(() => {
|
|
1743
1789
|
r.unmount(), t.remove(), e?.();
|
|
1744
1790
|
});
|
|
@@ -1747,12 +1793,12 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1747
1793
|
e.view?.focus?.();
|
|
1748
1794
|
});
|
|
1749
1795
|
}, o = () => {
|
|
1750
|
-
r.render(n(
|
|
1796
|
+
r.render(n(ui, {
|
|
1751
1797
|
messages: { ...e.messages },
|
|
1752
1798
|
portalContainer: t,
|
|
1753
1799
|
imageUpload: e.imageUpload,
|
|
1754
1800
|
onConfirm: (t) => {
|
|
1755
|
-
let n =
|
|
1801
|
+
let n = Rr(e.view, {
|
|
1756
1802
|
src: t.src,
|
|
1757
1803
|
alt: t.alt,
|
|
1758
1804
|
title: ""
|
|
@@ -1765,39 +1811,39 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1765
1811
|
}));
|
|
1766
1812
|
}, s = W(e.messages, o);
|
|
1767
1813
|
o();
|
|
1768
|
-
},
|
|
1814
|
+
}, hi = "math_block", gi = "Backspace", _i = (e) => e.key !== gi || e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey, vi = (e) => {
|
|
1769
1815
|
if (e.parent.type.name !== "paragraph" || e.parentOffset !== 0 || e.depth < 1) return null;
|
|
1770
1816
|
let t = e.index(e.depth - 1);
|
|
1771
1817
|
if (t <= 0) return null;
|
|
1772
1818
|
let n = e.node(e.depth - 1).child(t - 1);
|
|
1773
|
-
return n.type.name ===
|
|
1819
|
+
return n.type.name === hi ? {
|
|
1774
1820
|
previousBlock: n,
|
|
1775
1821
|
previousBlockStart: e.before(e.depth) - n.nodeSize
|
|
1776
1822
|
} : null;
|
|
1777
|
-
},
|
|
1823
|
+
}, yi = (e, t) => {
|
|
1778
1824
|
let { selection: n } = e.state;
|
|
1779
1825
|
if (!n.empty) return !1;
|
|
1780
|
-
let r = n.$from, i =
|
|
1826
|
+
let r = n.$from, i = vi(r);
|
|
1781
1827
|
if (!i) return !1;
|
|
1782
1828
|
let a = r.parent.textContent.length === 0, o = r.before(r.depth), s = o + r.parent.nodeSize;
|
|
1783
1829
|
t.preventDefault();
|
|
1784
1830
|
let c = e.state.tr;
|
|
1785
1831
|
return a && c.delete(o, s), c.setSelection(I.create(c.doc, i.previousBlockStart)).scrollIntoView(), e.dispatch(c), !0;
|
|
1786
|
-
},
|
|
1832
|
+
}, bi = B(() => new L({
|
|
1787
1833
|
key: new R("zt-md-math-backspace-entry"),
|
|
1788
|
-
props: { handleKeyDown: (e, t) =>
|
|
1789
|
-
})),
|
|
1834
|
+
props: { handleKeyDown: (e, t) => _i(t) ? !1 : yi(e, t) }
|
|
1835
|
+
})), xi = "math_block", Si = 5, Ci = 1200, wi = K("Copy", {
|
|
1790
1836
|
size: 14,
|
|
1791
1837
|
strokeWidth: 2
|
|
1792
|
-
}),
|
|
1838
|
+
}), Ti = K("Check", {
|
|
1793
1839
|
size: 14,
|
|
1794
1840
|
strokeWidth: 2
|
|
1795
|
-
}),
|
|
1841
|
+
}), Ei = K("Trash2", {
|
|
1796
1842
|
size: 14,
|
|
1797
1843
|
strokeWidth: 2
|
|
1798
|
-
}),
|
|
1844
|
+
}), Di = (e) => typeof e == "function" ? e() : null, Oi = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, ki = class {
|
|
1799
1845
|
syncEditableState() {
|
|
1800
|
-
this.dom.dataset.editable =
|
|
1846
|
+
this.dom.dataset.editable = Oi(this.view) ? "true" : "false";
|
|
1801
1847
|
}
|
|
1802
1848
|
constructor(e, t, n, r) {
|
|
1803
1849
|
this.pointerStartX = null, this.pointerStartY = null, this.hasDragged = !1, this.isDeletingByBackspace = !1, this.copyFeedbackTimer = null, this.handleClick = () => {
|
|
@@ -1811,21 +1857,21 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1811
1857
|
}, this.handlePointerMove = (e) => {
|
|
1812
1858
|
if (this.pointerStartX === null || this.pointerStartY === null) return;
|
|
1813
1859
|
let t = Math.abs(e.clientX - this.pointerStartX), n = Math.abs(e.clientY - this.pointerStartY);
|
|
1814
|
-
(t >=
|
|
1860
|
+
(t >= Si || n >= Si) && (this.hasDragged = !0);
|
|
1815
1861
|
}, this.handlePointerUp = () => {
|
|
1816
1862
|
this.pointerStartX = null, this.pointerStartY = null;
|
|
1817
1863
|
}, this.handleCopyClick = (e) => {
|
|
1818
|
-
if (e.preventDefault(), e.stopPropagation(), !
|
|
1864
|
+
if (e.preventDefault(), e.stopPropagation(), !Oi(this.view)) return;
|
|
1819
1865
|
let t = typeof this.node.attrs.value == "string" ? this.node.attrs.value : "";
|
|
1820
1866
|
(typeof navigator < "u" && navigator.clipboard?.writeText ? navigator.clipboard.writeText(t) : Promise.resolve()).then(() => {
|
|
1821
|
-
this.copyButton.innerHTML =
|
|
1822
|
-
this.copyButton.innerHTML =
|
|
1823
|
-
},
|
|
1867
|
+
this.copyButton.innerHTML = Ti, this.copyButton.dataset.copied = "true", this.copyFeedbackTimer !== null && clearTimeout(this.copyFeedbackTimer), this.copyFeedbackTimer = setTimeout(() => {
|
|
1868
|
+
this.copyButton.innerHTML = wi, delete this.copyButton.dataset.copied, this.copyFeedbackTimer = null;
|
|
1869
|
+
}, Ci);
|
|
1824
1870
|
}).catch(() => {});
|
|
1825
1871
|
}, this.handleDeleteClick = (e) => {
|
|
1826
|
-
e.preventDefault(), e.stopPropagation(),
|
|
1872
|
+
e.preventDefault(), e.stopPropagation(), Oi(this.view) && this.deleteCurrentMathBlock();
|
|
1827
1873
|
}, this.handleInput = () => {
|
|
1828
|
-
let e = this.sourceTextarea.value, t =
|
|
1874
|
+
let e = this.sourceTextarea.value, t = Di(this.getPos);
|
|
1829
1875
|
if (t === null) return;
|
|
1830
1876
|
this.renderMath(e);
|
|
1831
1877
|
let n = this.view.state.tr.setNodeMarkup(t, void 0, {
|
|
@@ -1836,23 +1882,23 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1836
1882
|
}, this.handleKeyDown = (e) => {
|
|
1837
1883
|
let t = this.sourceTextarea.selectionStart, n = this.sourceTextarea.selectionEnd;
|
|
1838
1884
|
if (e.key === "Backspace") {
|
|
1839
|
-
if (!(t === 0 && n === 0) ||
|
|
1885
|
+
if (!(t === 0 && n === 0) || Di(this.getPos) === null) return;
|
|
1840
1886
|
e.preventDefault(), this.deleteCurrentMathBlock();
|
|
1841
1887
|
return;
|
|
1842
1888
|
}
|
|
1843
1889
|
if (e.key !== "ArrowUp" && e.key !== "ArrowDown" || e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || t !== n) return;
|
|
1844
1890
|
let r = this.sourceTextarea.value, i = r.slice(0, t), a = r.slice(n), o = !i.includes("\n"), s = !a.includes("\n");
|
|
1845
1891
|
if (!(e.key === "ArrowUp" && o || e.key === "ArrowDown" && s)) return;
|
|
1846
|
-
let c =
|
|
1847
|
-
c !== null &&
|
|
1892
|
+
let c = Di(this.getPos);
|
|
1893
|
+
c !== null && Ln(this.view, c, this.node, e.key) && e.preventDefault();
|
|
1848
1894
|
}, this.handleBlur = () => {
|
|
1849
1895
|
this.isDeletingByBackspace || this.exitEditMode();
|
|
1850
|
-
}, this.node = e, this.view = t, this.getPos = n, this.messages = r, this.dom = document.createElement("div"), this.dom.dataset.type =
|
|
1896
|
+
}, this.node = e, this.view = t, this.getPos = n, this.messages = r, this.dom = document.createElement("div"), this.dom.dataset.type = xi, this.dom.className = "zt-md-math-block", this.syncEditableState(), this.sourceContainer = document.createElement("div"), this.sourceContainer.className = "zt-md-math-block-source", this.sourceContainer.hidden = !0, this.sourceTextarea = document.createElement("textarea"), this.sourceTextarea.className = "zt-md-math-block-textarea", this.sourceTextarea.setAttribute("aria-label", this.messages.mathBlockSourceAriaLabel), this.sourceTextarea.spellcheck = !1, this.previewContainer = document.createElement("div"), this.previewContainer.className = "zt-md-math-block-preview", this.actionsContainer = document.createElement("div"), this.actionsContainer.className = "zt-md-math-block-actions", this.copyButton = document.createElement("button"), this.copyButton.type = "button", this.copyButton.className = "zt-md-math-block-action-button", this.copyButton.setAttribute("aria-label", this.messages.mathBlockCopyAriaLabel), this.copyButton.innerHTML = wi, this.deleteButton = document.createElement("button"), this.deleteButton.type = "button", this.deleteButton.className = "zt-md-math-block-action-button zt-md-math-block-action-button-danger", this.deleteButton.setAttribute("aria-label", this.messages.mathBlockDeleteAriaLabel), this.deleteButton.innerHTML = Ei, this.errorContainer = document.createElement("div"), this.errorContainer.className = "zt-md-math-block-error", this.errorContainer.hidden = !0, this.actionsContainer.append(this.copyButton, this.deleteButton), this.sourceContainer.appendChild(this.sourceTextarea), this.previewContainer.appendChild(this.errorContainer), this.dom.append(this.actionsContainer, this.sourceContainer, this.previewContainer), this.syncFromNode(e), this.dom.addEventListener("click", this.handleClick), this.dom.addEventListener("pointerdown", this.handlePointerDown), this.dom.addEventListener("pointermove", this.handlePointerMove), this.dom.addEventListener("pointerup", this.handlePointerUp), this.dom.addEventListener("pointercancel", this.handlePointerUp), this.copyButton.addEventListener("click", this.handleCopyClick), this.deleteButton.addEventListener("click", this.handleDeleteClick), this.sourceTextarea.addEventListener("input", this.handleInput), this.sourceTextarea.addEventListener("keydown", this.handleKeyDown), this.sourceTextarea.addEventListener("blur", this.handleBlur), this.stopObservingMessages = W(r, () => {
|
|
1851
1897
|
this.sourceTextarea.setAttribute("aria-label", r.mathBlockSourceAriaLabel), this.copyButton.setAttribute("aria-label", r.mathBlockCopyAriaLabel), this.deleteButton.setAttribute("aria-label", r.mathBlockDeleteAriaLabel), this.errorContainer.hidden || (this.errorContainer.textContent = r.mathRenderError);
|
|
1852
1898
|
});
|
|
1853
1899
|
}
|
|
1854
1900
|
deleteCurrentMathBlock() {
|
|
1855
|
-
let e =
|
|
1901
|
+
let e = Di(this.getPos);
|
|
1856
1902
|
if (e === null) return;
|
|
1857
1903
|
this.isDeletingByBackspace = !0;
|
|
1858
1904
|
let t = this.view.state.tr.delete(e, e + this.node.nodeSize), n = Math.min(e, t.doc.content.size);
|
|
@@ -1867,7 +1913,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1867
1913
|
renderMath(e) {
|
|
1868
1914
|
this.errorContainer.hidden = !0, this.errorContainer.textContent = "";
|
|
1869
1915
|
try {
|
|
1870
|
-
|
|
1916
|
+
mt.render(e, this.previewContainer, {
|
|
1871
1917
|
displayMode: !0,
|
|
1872
1918
|
throwOnError: !0
|
|
1873
1919
|
}), this.previewContainer.appendChild(this.errorContainer);
|
|
@@ -1876,13 +1922,13 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1876
1922
|
}
|
|
1877
1923
|
}
|
|
1878
1924
|
enterEditMode() {
|
|
1879
|
-
|
|
1925
|
+
Oi(this.view) && (this.sourceContainer.hidden = !1, this.dom.classList.add("zt-md-math-block-editing"), this.sourceTextarea.focus());
|
|
1880
1926
|
}
|
|
1881
1927
|
exitEditMode() {
|
|
1882
1928
|
this.sourceContainer.hidden = !0, this.dom.classList.remove("zt-md-math-block-editing");
|
|
1883
1929
|
}
|
|
1884
1930
|
update(e) {
|
|
1885
|
-
return e.type.name ===
|
|
1931
|
+
return e.type.name === xi ? (this.node = e, this.syncEditableState(), this.syncFromNode(e), !0) : !1;
|
|
1886
1932
|
}
|
|
1887
1933
|
selectNode() {
|
|
1888
1934
|
this.enterEditMode();
|
|
@@ -1898,18 +1944,18 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1898
1944
|
return !0;
|
|
1899
1945
|
}
|
|
1900
1946
|
destroy() {
|
|
1901
|
-
this.stopObservingMessages(), this.dom.removeEventListener("click", this.handleClick), this.dom.removeEventListener("pointerdown", this.handlePointerDown), this.dom.removeEventListener("pointermove", this.handlePointerMove), this.dom.removeEventListener("pointerup", this.handlePointerUp), this.dom.removeEventListener("pointercancel", this.handlePointerUp), this.copyButton.removeEventListener("click", this.handleCopyClick), this.deleteButton.removeEventListener("click", this.handleDeleteClick), this.sourceTextarea.removeEventListener("input", this.handleInput), this.sourceTextarea.removeEventListener("keydown", this.handleKeyDown), this.sourceTextarea.removeEventListener("blur", this.handleBlur), this.copyFeedbackTimer !== null && (clearTimeout(this.copyFeedbackTimer), this.copyFeedbackTimer = null), this.copyButton.innerHTML =
|
|
1947
|
+
this.stopObservingMessages(), this.dom.removeEventListener("click", this.handleClick), this.dom.removeEventListener("pointerdown", this.handlePointerDown), this.dom.removeEventListener("pointermove", this.handlePointerMove), this.dom.removeEventListener("pointerup", this.handlePointerUp), this.dom.removeEventListener("pointercancel", this.handlePointerUp), this.copyButton.removeEventListener("click", this.handleCopyClick), this.deleteButton.removeEventListener("click", this.handleDeleteClick), this.sourceTextarea.removeEventListener("input", this.handleInput), this.sourceTextarea.removeEventListener("keydown", this.handleKeyDown), this.sourceTextarea.removeEventListener("blur", this.handleBlur), this.copyFeedbackTimer !== null && (clearTimeout(this.copyFeedbackTimer), this.copyFeedbackTimer = null), this.copyButton.innerHTML = wi, delete this.copyButton.dataset.copied;
|
|
1902
1948
|
}
|
|
1903
|
-
},
|
|
1949
|
+
}, Ai = (e = U()) => (t, n, r) => new ki(t, n, typeof r == "function" ? () => {
|
|
1904
1950
|
let e = r();
|
|
1905
1951
|
return typeof e == "number" ? e : 0;
|
|
1906
|
-
} : !1, e),
|
|
1907
|
-
|
|
1952
|
+
} : !1, e), ji = "math_inline", q = new R("zt-md-math-inline-edit"), Mi = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, Ni = (e) => e?.type.name === ji, Pi = (e) => String(e.attrs.value ?? e.textContent ?? ""), Fi = (e, t, n) => {
|
|
1953
|
+
Mi(e) && e.dispatch(e.state.tr.setMeta(q, {
|
|
1908
1954
|
type: "open",
|
|
1909
1955
|
position: t,
|
|
1910
1956
|
caret: n?.caret === "start" ? "start" : "end"
|
|
1911
1957
|
}));
|
|
1912
|
-
},
|
|
1958
|
+
}, Ii = class {
|
|
1913
1959
|
createSafeTextSelection(e, t) {
|
|
1914
1960
|
try {
|
|
1915
1961
|
return z.create(e, t);
|
|
@@ -1940,7 +1986,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1940
1986
|
return;
|
|
1941
1987
|
}
|
|
1942
1988
|
let t = this.currentPosition, n = this.currentPosition + e.nodeSize, r = this.view.state.tr.delete(t, n);
|
|
1943
|
-
r.setSelection(this.createSafeTextSelection(r.doc, t)).setMeta(
|
|
1989
|
+
r.setSelection(this.createSafeTextSelection(r.doc, t)).setMeta(q, { type: "close" }).scrollIntoView(), this.view.dispatch(r), this.view.focus();
|
|
1944
1990
|
}
|
|
1945
1991
|
constructor(e, t) {
|
|
1946
1992
|
this.currentPosition = null, this.currentMathInlineElement = null, this.isCommitting = !1, this.currentCaret = "end", this.handleMouseDown = (e) => {
|
|
@@ -1977,7 +2023,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1977
2023
|
renderMath(e) {
|
|
1978
2024
|
this.errorContainer.hidden = !0, this.errorContainer.textContent = "", this.previewContainer.textContent = "";
|
|
1979
2025
|
try {
|
|
1980
|
-
|
|
2026
|
+
mt.render(e, this.previewContainer, {
|
|
1981
2027
|
displayMode: !1,
|
|
1982
2028
|
throwOnError: !0
|
|
1983
2029
|
});
|
|
@@ -1988,19 +2034,19 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1988
2034
|
resolveCurrentNode() {
|
|
1989
2035
|
if (this.currentPosition === null) return null;
|
|
1990
2036
|
let e = this.view.state.doc.nodeAt(this.currentPosition);
|
|
1991
|
-
return
|
|
2037
|
+
return Ni(e) ? e : null;
|
|
1992
2038
|
}
|
|
1993
2039
|
openEditor(e) {
|
|
1994
|
-
if (!
|
|
2040
|
+
if (!Mi(this.view)) {
|
|
1995
2041
|
this.closeEditor(!1);
|
|
1996
2042
|
return;
|
|
1997
2043
|
}
|
|
1998
2044
|
let t = this.view.state.doc.nodeAt(e);
|
|
1999
|
-
if (!
|
|
2045
|
+
if (!Ni(t)) {
|
|
2000
2046
|
this.closeEditor(!1);
|
|
2001
2047
|
return;
|
|
2002
2048
|
}
|
|
2003
|
-
this.currentPosition = e, this.sourceInput.value =
|
|
2049
|
+
this.currentPosition = e, this.sourceInput.value = Pi(t), this.renderMath(this.sourceInput.value);
|
|
2004
2050
|
let n = this.resolveMathInlineElement(e);
|
|
2005
2051
|
if (!n) {
|
|
2006
2052
|
this.closeEditor(!1);
|
|
@@ -2028,21 +2074,21 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2028
2074
|
...t.attrs,
|
|
2029
2075
|
value: n
|
|
2030
2076
|
});
|
|
2031
|
-
i.setSelection(this.createSafeTextSelection(i.doc, r)).setMeta(
|
|
2077
|
+
i.setSelection(this.createSafeTextSelection(i.doc, r)).setMeta(q, { type: "close" }).scrollIntoView(), this.isCommitting = !0, this.view.dispatch(i), this.isCommitting = !1, this.view.focus();
|
|
2032
2078
|
}
|
|
2033
2079
|
closeEditor(e) {
|
|
2034
|
-
this.currentMathInlineElement && (this.currentMathInlineElement.dataset.editing = "false"), this.currentPosition = null, this.currentMathInlineElement = null, this.host.hidden = !0, this.host.remove(), e && this.view.dispatch(this.view.state.tr.setMeta(
|
|
2080
|
+
this.currentMathInlineElement && (this.currentMathInlineElement.dataset.editing = "false"), this.currentPosition = null, this.currentMathInlineElement = null, this.host.hidden = !0, this.host.remove(), e && this.view.dispatch(this.view.state.tr.setMeta(q, { type: "close" }));
|
|
2035
2081
|
}
|
|
2036
2082
|
resolveMathInlineElement(e) {
|
|
2037
2083
|
let t = this.view.nodeDOM(e);
|
|
2038
2084
|
return t instanceof HTMLElement ? t : null;
|
|
2039
2085
|
}
|
|
2040
2086
|
update(e) {
|
|
2041
|
-
if (this.view = e, !
|
|
2087
|
+
if (this.view = e, !Mi(e)) {
|
|
2042
2088
|
this.closeEditor(!1);
|
|
2043
2089
|
return;
|
|
2044
2090
|
}
|
|
2045
|
-
let t =
|
|
2091
|
+
let t = q.getState(e.state);
|
|
2046
2092
|
if (!t || t.position === null) {
|
|
2047
2093
|
this.currentPosition !== null && this.closeEditor(!1);
|
|
2048
2094
|
return;
|
|
@@ -2059,15 +2105,15 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2059
2105
|
destroy() {
|
|
2060
2106
|
this.stopObservingMessages(), this.sourceInput.removeEventListener("input", this.handleInput), this.sourceInput.removeEventListener("beforeinput", this.handleBeforeInput), this.sourceInput.removeEventListener("keydown", this.handleKeyDown), this.sourceInput.removeEventListener("blur", this.handleBlur), this.host.removeEventListener("mousedown", this.handleMouseDown), this.view.dom.removeEventListener("focusin", this.handleEditorFocusIn), this.closeEditor(!1);
|
|
2061
2107
|
}
|
|
2062
|
-
},
|
|
2063
|
-
key:
|
|
2108
|
+
}, Li = (e, t) => B(() => new L({
|
|
2109
|
+
key: q,
|
|
2064
2110
|
state: {
|
|
2065
2111
|
init: () => ({
|
|
2066
2112
|
position: null,
|
|
2067
2113
|
caret: "end"
|
|
2068
2114
|
}),
|
|
2069
2115
|
apply: (e, t) => {
|
|
2070
|
-
let n = e.getMeta(
|
|
2116
|
+
let n = e.getMeta(q);
|
|
2071
2117
|
if (n?.type === "open" && typeof n.position == "number") return {
|
|
2072
2118
|
position: n.position,
|
|
2073
2119
|
caret: n.caret === "start" ? "start" : "end"
|
|
@@ -2078,7 +2124,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2078
2124
|
};
|
|
2079
2125
|
if (t.position === null || !e.docChanged) return t;
|
|
2080
2126
|
let r = e.mapping.map(t.position, -1);
|
|
2081
|
-
return
|
|
2127
|
+
return Ni(e.doc.nodeAt(r)) ? {
|
|
2082
2128
|
position: r,
|
|
2083
2129
|
caret: t.caret
|
|
2084
2130
|
} : {
|
|
@@ -2087,30 +2133,30 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2087
2133
|
};
|
|
2088
2134
|
}
|
|
2089
2135
|
},
|
|
2090
|
-
view: (t) => new
|
|
2091
|
-
})),
|
|
2136
|
+
view: (t) => new Ii(t, e)
|
|
2137
|
+
})), Ri = "math_inline", zi = (e) => typeof e == "function" ? e() : null, Bi = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, Vi = (e) => String(e.attrs.value ?? e.textContent ?? ""), Hi = class {
|
|
2092
2138
|
syncEditableState() {
|
|
2093
|
-
this.dom.dataset.editable =
|
|
2139
|
+
this.dom.dataset.editable = Bi(this.view) ? "true" : "false";
|
|
2094
2140
|
}
|
|
2095
2141
|
constructor(e, t, n, r) {
|
|
2096
2142
|
this.handleMouseDown = (e) => {
|
|
2097
|
-
|
|
2143
|
+
Bi(this.view) || (e.preventDefault(), e.stopPropagation());
|
|
2098
2144
|
}, this.handleClick = (e) => {
|
|
2099
|
-
if (e.preventDefault(), e.stopPropagation(), !
|
|
2100
|
-
let t =
|
|
2101
|
-
t !== null &&
|
|
2102
|
-
}, this.node = e, this.view = t, this.getPos = n, this.messages = r, this.dom = document.createElement("span"), this.dom.dataset.type =
|
|
2145
|
+
if (e.preventDefault(), e.stopPropagation(), !Bi(this.view)) return;
|
|
2146
|
+
let t = zi(this.getPos);
|
|
2147
|
+
t !== null && Fi(this.view, t);
|
|
2148
|
+
}, this.node = e, this.view = t, this.getPos = n, this.messages = r, this.dom = document.createElement("span"), this.dom.dataset.type = Ri, this.dom.className = "zt-md-math-inline", this.dom.dataset.editing = "false", this.syncEditableState(), this.previewContainer = document.createElement("span"), this.previewContainer.className = "zt-md-math-inline-preview", this.errorContainer = document.createElement("span"), this.errorContainer.className = "zt-md-math-inline-error", this.errorContainer.hidden = !0, this.dom.append(this.previewContainer, this.errorContainer), this.syncFromNode(e), this.dom.addEventListener("mousedown", this.handleMouseDown), this.dom.addEventListener("click", this.handleClick), this.stopObservingMessages = W(r, () => {
|
|
2103
2149
|
this.errorContainer.hidden || (this.errorContainer.textContent = r.mathRenderError);
|
|
2104
2150
|
});
|
|
2105
2151
|
}
|
|
2106
2152
|
syncFromNode(e) {
|
|
2107
|
-
let t =
|
|
2153
|
+
let t = Vi(e);
|
|
2108
2154
|
this.dom.dataset.value = t, this.renderMath(t);
|
|
2109
2155
|
}
|
|
2110
2156
|
renderMath(e) {
|
|
2111
2157
|
this.errorContainer.hidden = !0, this.errorContainer.textContent = "", this.previewContainer.textContent = "";
|
|
2112
2158
|
try {
|
|
2113
|
-
|
|
2159
|
+
mt.render(e, this.previewContainer, {
|
|
2114
2160
|
displayMode: !1,
|
|
2115
2161
|
throwOnError: !0
|
|
2116
2162
|
});
|
|
@@ -2119,7 +2165,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2119
2165
|
}
|
|
2120
2166
|
}
|
|
2121
2167
|
update(e) {
|
|
2122
|
-
return e.type.name ===
|
|
2168
|
+
return e.type.name === Ri ? (this.node = e, this.syncEditableState(), this.syncFromNode(e), !0) : !1;
|
|
2123
2169
|
}
|
|
2124
2170
|
stopEvent(e) {
|
|
2125
2171
|
let t = e.target;
|
|
@@ -2131,72 +2177,72 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2131
2177
|
destroy() {
|
|
2132
2178
|
this.stopObservingMessages(), this.dom.removeEventListener("mousedown", this.handleMouseDown), this.dom.removeEventListener("click", this.handleClick);
|
|
2133
2179
|
}
|
|
2134
|
-
},
|
|
2180
|
+
}, Ui = (e = U()) => (t, n, r) => new Hi(t, n, typeof r == "function" ? () => {
|
|
2135
2181
|
let e = r();
|
|
2136
2182
|
return typeof e == "number" ? e : 0;
|
|
2137
|
-
} : !1, e),
|
|
2183
|
+
} : !1, e), Wi = "math_inline", Gi = "zt-md-math-inline-arrow-navigation", Ki = {
|
|
2138
2184
|
ArrowLeft: { positionKey: "from" },
|
|
2139
2185
|
ArrowRight: { positionKey: "to" }
|
|
2140
|
-
},
|
|
2186
|
+
}, qi = {
|
|
2141
2187
|
ArrowLeft: "end",
|
|
2142
2188
|
ArrowRight: "start"
|
|
2143
|
-
},
|
|
2189
|
+
}, Ji = {
|
|
2144
2190
|
Backspace: "before",
|
|
2145
2191
|
Delete: "after"
|
|
2146
|
-
},
|
|
2147
|
-
if (!
|
|
2192
|
+
}, Yi = (e) => e instanceof Element ? !!e.closest(".zt-md-math-inline-editor") : !1, Xi = (e) => e?.type.name === Wi, Zi = (e) => !Ji[e.key] || e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || Yi(e.target) || Yi(document.activeElement), Qi = (e, t) => {
|
|
2193
|
+
if (!Ki[t.key] || Yi(t.target)) return !1;
|
|
2148
2194
|
let { selection: n } = e.state;
|
|
2149
|
-
return !(n instanceof I) || n.node.type.name !==
|
|
2150
|
-
},
|
|
2151
|
-
let n =
|
|
2152
|
-
if (!n ||
|
|
2195
|
+
return !(n instanceof I) || n.node.type.name !== Wi ? !1 : (t.preventDefault(), Fi(e, n.from, { caret: qi[t.key] ?? "end" }), !0);
|
|
2196
|
+
}, $i = (e, t) => {
|
|
2197
|
+
let n = Ki[t.key];
|
|
2198
|
+
if (!n || Yi(t.target)) return !1;
|
|
2153
2199
|
let { selection: r } = e.state;
|
|
2154
2200
|
if (!r.empty) return !1;
|
|
2155
2201
|
let i = r.$from, a = n.positionKey === "from" ? i.nodeBefore : i.nodeAfter;
|
|
2156
|
-
return
|
|
2157
|
-
},
|
|
2202
|
+
return Xi(a) ? (t.preventDefault(), Fi(e, n.positionKey === "from" ? r.from - a.nodeSize : r.from, { caret: qi[t.key] ?? "end" }), !0) : !1;
|
|
2203
|
+
}, ea = (e, t) => {
|
|
2158
2204
|
try {
|
|
2159
2205
|
return z.create(e, t);
|
|
2160
2206
|
} catch {
|
|
2161
2207
|
return z.near(e.resolve(t), -1);
|
|
2162
2208
|
}
|
|
2163
|
-
},
|
|
2209
|
+
}, ta = (e, t, n) => {
|
|
2164
2210
|
n.preventDefault();
|
|
2165
2211
|
let r = t.from, i = e.state.tr.delete(t.from, t.to), a = i.doc.content.size, o = Math.min(r, a);
|
|
2166
|
-
return i.setSelection(
|
|
2167
|
-
},
|
|
2168
|
-
let n =
|
|
2212
|
+
return i.setSelection(ea(i.doc, o)).scrollIntoView(), e.dispatch(i), e.focus(), !0;
|
|
2213
|
+
}, na = (e, t) => {
|
|
2214
|
+
let n = Ji[t.key];
|
|
2169
2215
|
if (!n) return !1;
|
|
2170
2216
|
let { selection: r } = e.state;
|
|
2171
2217
|
if (!r.empty) return !1;
|
|
2172
2218
|
let i = r.$from, a = n === "before" ? i.nodeBefore : i.nodeAfter;
|
|
2173
|
-
if (!
|
|
2219
|
+
if (!Xi(a)) return !1;
|
|
2174
2220
|
t.preventDefault();
|
|
2175
2221
|
let o = n === "before" ? r.from - a.nodeSize : r.from;
|
|
2176
2222
|
return e.dispatch(e.state.tr.setSelection(I.create(e.state.doc, o)).scrollIntoView()), e.focus(), !0;
|
|
2177
|
-
},
|
|
2178
|
-
if (
|
|
2223
|
+
}, ra = (e, t) => {
|
|
2224
|
+
if (Zi(t)) return !1;
|
|
2179
2225
|
let { selection: n } = e.state;
|
|
2180
|
-
return n instanceof I &&
|
|
2181
|
-
},
|
|
2182
|
-
if (
|
|
2226
|
+
return n instanceof I && Xi(n.node) ? ta(e, n, t) : na(e, t);
|
|
2227
|
+
}, ia = (e, t) => {
|
|
2228
|
+
if (Yi(document.activeElement)) return !1;
|
|
2183
2229
|
let { selection: n } = e.state;
|
|
2184
|
-
if (!(n instanceof I) || n.node.type.name !==
|
|
2230
|
+
if (!(n instanceof I) || n.node.type.name !== Wi) return !1;
|
|
2185
2231
|
let r = n.to, i = r + t.length, a = e.state.tr.insertText(t, r, r);
|
|
2186
2232
|
return a.setSelection(z.create(a.doc, i)).scrollIntoView(), e.dispatch(a), e.focus(), !0;
|
|
2187
|
-
},
|
|
2188
|
-
key: new R(
|
|
2233
|
+
}, aa = B(() => new L({
|
|
2234
|
+
key: new R(Gi),
|
|
2189
2235
|
props: {
|
|
2190
|
-
handleKeyDown: (e, t) =>
|
|
2191
|
-
handleTextInput: (e, t, n, r) =>
|
|
2236
|
+
handleKeyDown: (e, t) => $i(e, t) || ra(e, t) ? !0 : Qi(e, t),
|
|
2237
|
+
handleTextInput: (e, t, n, r) => ia(e, r)
|
|
2192
2238
|
}
|
|
2193
|
-
})),
|
|
2239
|
+
})), oa = "math_inline", sa = "math_block", ca = /(?:\$)([^$]+)(?:\$)$/, la = /^\$\$\s$/, ua = st("remarkMath", () => gt), da = it({}, "katexOptions"), fa = ot(oa, (e) => ({
|
|
2194
2240
|
group: "inline",
|
|
2195
2241
|
inline: !0,
|
|
2196
2242
|
atom: !0,
|
|
2197
2243
|
attrs: { value: { default: "" } },
|
|
2198
2244
|
parseDOM: [{
|
|
2199
|
-
tag: `span[data-type="${
|
|
2245
|
+
tag: `span[data-type="${oa}"]`,
|
|
2200
2246
|
getAttrs: (e) => {
|
|
2201
2247
|
let t = e;
|
|
2202
2248
|
return { value: t.dataset.value ?? t.textContent ?? "" };
|
|
@@ -2204,7 +2250,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2204
2250
|
}],
|
|
2205
2251
|
toDOM: (t) => {
|
|
2206
2252
|
let n = String(t.attrs.value ?? t.textContent ?? ""), r = document.createElement("span");
|
|
2207
|
-
return r.dataset.type =
|
|
2253
|
+
return r.dataset.type = oa, r.dataset.value = n, mt.render(n, r, e.get(da.key)), r;
|
|
2208
2254
|
},
|
|
2209
2255
|
parseMarkdown: {
|
|
2210
2256
|
match: (e) => e.type === "inlineMath",
|
|
@@ -2214,13 +2260,13 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2214
2260
|
}
|
|
2215
2261
|
},
|
|
2216
2262
|
toMarkdown: {
|
|
2217
|
-
match: (e) => e.type.name ===
|
|
2263
|
+
match: (e) => e.type.name === oa,
|
|
2218
2264
|
runner: (e, t) => {
|
|
2219
2265
|
let n = String(t.attrs.value ?? t.textContent ?? "");
|
|
2220
2266
|
e.addNode("inlineMath", void 0, n);
|
|
2221
2267
|
}
|
|
2222
2268
|
}
|
|
2223
|
-
})),
|
|
2269
|
+
})), pa = ot(sa, (e) => ({
|
|
2224
2270
|
content: "text*",
|
|
2225
2271
|
group: "block",
|
|
2226
2272
|
marks: "",
|
|
@@ -2229,13 +2275,13 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2229
2275
|
isolating: !0,
|
|
2230
2276
|
attrs: { value: { default: "" } },
|
|
2231
2277
|
parseDOM: [{
|
|
2232
|
-
tag: `div[data-type="${
|
|
2278
|
+
tag: `div[data-type="${sa}"]`,
|
|
2233
2279
|
preserveWhitespace: "full",
|
|
2234
2280
|
getAttrs: (e) => ({ value: e.dataset.value ?? "" })
|
|
2235
2281
|
}],
|
|
2236
2282
|
toDOM: (t) => {
|
|
2237
2283
|
let n = String(t.attrs.value ?? ""), r = document.createElement("div");
|
|
2238
|
-
return r.dataset.type =
|
|
2284
|
+
return r.dataset.type = sa, r.dataset.value = n, mt.render(n, r, e.get(da.key)), r;
|
|
2239
2285
|
},
|
|
2240
2286
|
parseMarkdown: {
|
|
2241
2287
|
match: (e) => e.type === "math",
|
|
@@ -2245,30 +2291,30 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2245
2291
|
}
|
|
2246
2292
|
},
|
|
2247
2293
|
toMarkdown: {
|
|
2248
|
-
match: (e) => e.type.name ===
|
|
2294
|
+
match: (e) => e.type.name === sa,
|
|
2249
2295
|
runner: (e, t) => {
|
|
2250
2296
|
let n = String(t.attrs.value ?? "");
|
|
2251
2297
|
e.addNode("math", void 0, n);
|
|
2252
2298
|
}
|
|
2253
2299
|
}
|
|
2254
|
-
})),
|
|
2255
|
-
let a =
|
|
2300
|
+
})), ma = at((e) => new ht(ca, (t, n, r, i) => {
|
|
2301
|
+
let a = fa.type(e), o = n[1] ?? "", s = t.doc.resolve(r);
|
|
2256
2302
|
return s.parent.canReplaceWith(s.index(), s.indexAfter(), a) ? t.tr.replaceWith(r, i, a.create({ value: o })) : null;
|
|
2257
|
-
})),
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
let a = t.doc.resolve(r), o =
|
|
2303
|
+
})), ha = [
|
|
2304
|
+
ua,
|
|
2305
|
+
da,
|
|
2306
|
+
fa,
|
|
2307
|
+
pa,
|
|
2308
|
+
at((e) => new ht(la, (t, n, r, i) => {
|
|
2309
|
+
let a = t.doc.resolve(r), o = pa.type(e);
|
|
2264
2310
|
return a.node(-1).canReplaceWith(a.index(-1), a.indexAfter(-1), o) ? t.tr.delete(r, i).setBlockType(r, r, o) : null;
|
|
2265
2311
|
})),
|
|
2266
|
-
|
|
2267
|
-
].flat(),
|
|
2268
|
-
if (e.parent.type.name !==
|
|
2312
|
+
ma
|
|
2313
|
+
].flat(), ga = "blockquote", _a = "paragraph", va = "Backspace", ya = (e) => e.key !== va || e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey, ba = (e) => {
|
|
2314
|
+
if (e.parent.type.name !== _a || e.parentOffset !== 0) return null;
|
|
2269
2315
|
for (let t = e.depth; t > 0; --t) {
|
|
2270
2316
|
let n = e.node(t);
|
|
2271
|
-
if (n.type.name !==
|
|
2317
|
+
if (n.type.name !== ga) continue;
|
|
2272
2318
|
let r = e.depth, i = e.index(t);
|
|
2273
2319
|
return r <= t || i !== 0 ? null : {
|
|
2274
2320
|
paragraphDepth: r,
|
|
@@ -2277,80 +2323,80 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2277
2323
|
};
|
|
2278
2324
|
}
|
|
2279
2325
|
return null;
|
|
2280
|
-
},
|
|
2326
|
+
}, xa = (e, t) => {
|
|
2281
2327
|
let { selection: n } = e.state;
|
|
2282
2328
|
if (!n.empty) return !1;
|
|
2283
|
-
let r = n.$from, i =
|
|
2329
|
+
let r = n.$from, i = ba(r);
|
|
2284
2330
|
if (!i) return !1;
|
|
2285
2331
|
let a = r.blockRange(r, (e) => e.type === i.blockquoteType);
|
|
2286
2332
|
if (!a) return !1;
|
|
2287
|
-
let o =
|
|
2333
|
+
let o = _t(a);
|
|
2288
2334
|
if (o === null) return !1;
|
|
2289
2335
|
t.preventDefault();
|
|
2290
2336
|
let s = e.state.tr.lift(a, o).scrollIntoView();
|
|
2291
2337
|
return e.dispatch(s), !0;
|
|
2292
|
-
},
|
|
2338
|
+
}, Sa = B(() => new L({
|
|
2293
2339
|
key: new R("zt-md-blockquote-backspace-lift"),
|
|
2294
|
-
props: { handleKeyDown: (e, t) =>
|
|
2295
|
-
})),
|
|
2296
|
-
if (e.type.name !==
|
|
2340
|
+
props: { handleKeyDown: (e, t) => ya(t) ? !1 : xa(e, t) }
|
|
2341
|
+
})), Ca = "Backspace", wa = "heading", Ta = "paragraph", Ea = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, Da = (e) => {
|
|
2342
|
+
if (e.type.name !== Ta) return !1;
|
|
2297
2343
|
let t = e.textContent;
|
|
2298
2344
|
return t.trim().length === 0 && e.content.size === t.length;
|
|
2299
|
-
},
|
|
2300
|
-
if (e.parent.type.name !==
|
|
2345
|
+
}, Oa = (e) => {
|
|
2346
|
+
if (e.parent.type.name !== wa || e.parentOffset !== 0 || e.depth < 1) return null;
|
|
2301
2347
|
let t = e.index(e.depth - 1);
|
|
2302
2348
|
if (t <= 0) return null;
|
|
2303
2349
|
let n = e.node(e.depth - 1).child(t - 1);
|
|
2304
|
-
if (!
|
|
2350
|
+
if (!Da(n)) return null;
|
|
2305
2351
|
let r = e.before(e.depth);
|
|
2306
2352
|
return {
|
|
2307
2353
|
from: r - n.nodeSize,
|
|
2308
2354
|
to: r
|
|
2309
2355
|
};
|
|
2310
|
-
},
|
|
2311
|
-
if (t.key !==
|
|
2356
|
+
}, ka = (e, t) => {
|
|
2357
|
+
if (t.key !== Ca || t.defaultPrevented || t.altKey || t.ctrlKey || t.metaKey || t.shiftKey || !Ea(e)) return !1;
|
|
2312
2358
|
let { selection: n } = e.state;
|
|
2313
2359
|
if (!n.empty) return !1;
|
|
2314
|
-
let r =
|
|
2360
|
+
let r = Oa(n.$from);
|
|
2315
2361
|
if (!r) return !1;
|
|
2316
2362
|
t.preventDefault();
|
|
2317
2363
|
let i = e.state.tr.delete(r.from, r.to);
|
|
2318
2364
|
return i.setSelection(z.create(i.doc, r.from + 1)).scrollIntoView(), e.dispatch(i), !0;
|
|
2319
|
-
},
|
|
2365
|
+
}, Aa = B(() => new L({
|
|
2320
2366
|
key: new R("zt-md-heading-backspace-empty-paragraph"),
|
|
2321
|
-
props: { handleKeyDown: (e, t) =>
|
|
2322
|
-
})),
|
|
2367
|
+
props: { handleKeyDown: (e, t) => ka(e, t) }
|
|
2368
|
+
})), ja = "heading", Ma = "zt-md-heading-focused", Na = "zt-md-heading-focus-indicator", Pa = (e) => {
|
|
2323
2369
|
let t = e.selection.$from;
|
|
2324
2370
|
for (let n = t.depth; n > 0; --n) {
|
|
2325
2371
|
let r = t.node(n);
|
|
2326
|
-
if (r.type.name !==
|
|
2372
|
+
if (r.type.name !== ja) continue;
|
|
2327
2373
|
let i = t.before(n), a = Number(r.attrs.level), o = nt.node(i, i + r.nodeSize, {
|
|
2328
|
-
class:
|
|
2374
|
+
class: Ma,
|
|
2329
2375
|
"data-heading-level": `H${a}`
|
|
2330
2376
|
});
|
|
2331
|
-
return
|
|
2377
|
+
return rt.create(e.doc, [o]);
|
|
2332
2378
|
}
|
|
2333
|
-
return
|
|
2334
|
-
},
|
|
2335
|
-
key: new R(
|
|
2336
|
-
props: { decorations:
|
|
2337
|
-
})),
|
|
2379
|
+
return rt.empty;
|
|
2380
|
+
}, Fa = B(() => new L({
|
|
2381
|
+
key: new R(Na),
|
|
2382
|
+
props: { decorations: Pa }
|
|
2383
|
+
})), Ia = "text", La = {
|
|
2338
2384
|
svg: "svg",
|
|
2339
2385
|
html: "html"
|
|
2340
|
-
},
|
|
2386
|
+
}, Ra = {
|
|
2341
2387
|
html: !0,
|
|
2342
2388
|
svg: !0
|
|
2343
|
-
},
|
|
2389
|
+
}, J = (e) => {
|
|
2344
2390
|
let t = e.trim().toLowerCase();
|
|
2345
|
-
return t ? t.startsWith("canvas-") ? Object.entries(
|
|
2346
|
-
},
|
|
2391
|
+
return t ? t.startsWith("canvas-") ? Object.entries(La).find(([e]) => t.includes(e))?.[1] ?? t : t : Ia;
|
|
2392
|
+
}, za = (e) => (t) => {
|
|
2347
2393
|
let n = e(t);
|
|
2348
2394
|
return {
|
|
2349
2395
|
...n,
|
|
2350
2396
|
attrs: {
|
|
2351
2397
|
...n.attrs,
|
|
2352
2398
|
language: {
|
|
2353
|
-
default:
|
|
2399
|
+
default: Ia,
|
|
2354
2400
|
validate: "string"
|
|
2355
2401
|
}
|
|
2356
2402
|
},
|
|
@@ -2359,7 +2405,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2359
2405
|
runner: (e, t, r) => {
|
|
2360
2406
|
let i = {
|
|
2361
2407
|
...t,
|
|
2362
|
-
lang:
|
|
2408
|
+
lang: J(String(t.lang ?? ""))
|
|
2363
2409
|
};
|
|
2364
2410
|
n.parseMarkdown.runner(e, i, r);
|
|
2365
2411
|
}
|
|
@@ -2367,15 +2413,15 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2367
2413
|
toMarkdown: {
|
|
2368
2414
|
...n.toMarkdown,
|
|
2369
2415
|
runner: (e, t) => {
|
|
2370
|
-
let n =
|
|
2416
|
+
let n = J(String(t.attrs.language ?? ""));
|
|
2371
2417
|
e.addNode("code", void 0, t.content.firstChild?.text || "", { lang: n });
|
|
2372
2418
|
}
|
|
2373
2419
|
}
|
|
2374
2420
|
};
|
|
2375
|
-
},
|
|
2421
|
+
}, Ba = (e) => {
|
|
2376
2422
|
let t = e.get(Me.key);
|
|
2377
|
-
e.set(Me.key,
|
|
2378
|
-
},
|
|
2423
|
+
e.set(Me.key, za(t));
|
|
2424
|
+
}, Va = (e) => Ra[J(e)] === !0, Ha = "code_block", Ua = 1200, Wa = "html", Ga = "ZT_MD_CODE_BLOCK_PREVIEW_LAYOUT", Ka = [
|
|
2379
2425
|
"default-src 'none'",
|
|
2380
2426
|
"style-src 'unsafe-inline'",
|
|
2381
2427
|
"img-src data: blob:",
|
|
@@ -2386,27 +2432,27 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2386
2432
|
"object-src 'none'",
|
|
2387
2433
|
"form-action 'none'",
|
|
2388
2434
|
"base-uri 'none'"
|
|
2389
|
-
],
|
|
2435
|
+
], qa = K("Copy", {
|
|
2390
2436
|
size: 14,
|
|
2391
2437
|
strokeWidth: 2
|
|
2392
|
-
}),
|
|
2438
|
+
}), Ja = K("Check", {
|
|
2393
2439
|
size: 14,
|
|
2394
2440
|
strokeWidth: 2
|
|
2395
|
-
}),
|
|
2441
|
+
}), Ya = K("Trash2", {
|
|
2396
2442
|
size: 14,
|
|
2397
2443
|
strokeWidth: 2
|
|
2398
|
-
}),
|
|
2444
|
+
}), Xa = K("Eye", {
|
|
2399
2445
|
size: 14,
|
|
2400
2446
|
strokeWidth: 2
|
|
2401
|
-
}),
|
|
2447
|
+
}), Za = K("Code2", {
|
|
2402
2448
|
size: 14,
|
|
2403
2449
|
strokeWidth: 2
|
|
2404
|
-
}),
|
|
2450
|
+
}), Qa = (e, t) => `<!doctype html>
|
|
2405
2451
|
<html>
|
|
2406
2452
|
<head>
|
|
2407
2453
|
<meta charset="UTF-8" />
|
|
2408
2454
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
2409
|
-
<meta http-equiv="Content-Security-Policy" content="${[...
|
|
2455
|
+
<meta http-equiv="Content-Security-Policy" content="${[...Ka, ...t ? ["script-src 'unsafe-inline'"] : []].join("; ")}" />
|
|
2410
2456
|
<style>
|
|
2411
2457
|
*, *::before, *::after { box-sizing: border-box; }
|
|
2412
2458
|
html, body { min-height: 100%; margin: 0; }
|
|
@@ -2415,7 +2461,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2415
2461
|
</style>
|
|
2416
2462
|
</head>
|
|
2417
2463
|
<body>${e}</body>
|
|
2418
|
-
</html>`,
|
|
2464
|
+
</html>`, $a = (e) => typeof e == "function" ? e() : null, eo = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, to = class {
|
|
2419
2465
|
syncLanguageAttribute(e) {
|
|
2420
2466
|
let t = typeof e.attrs.language == "string" ? e.attrs.language.trim() : "";
|
|
2421
2467
|
if (!t) {
|
|
@@ -2426,29 +2472,29 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2426
2472
|
}
|
|
2427
2473
|
constructor(e, t, n, r) {
|
|
2428
2474
|
this.previewFrame = null, this.isPreviewAvailable = !1, this.isPreviewMode = !1, this.renderedPreviewKey = null, this.copyFeedbackTimer = null, this.handlePreviewClick = (e) => {
|
|
2429
|
-
e.preventDefault(), e.stopPropagation(), this.isPreviewAvailable && (this.isPreviewMode = !this.isPreviewMode, this.syncPreviewState(), this.view.dispatch(this.view.state.tr.setMeta(
|
|
2475
|
+
e.preventDefault(), e.stopPropagation(), this.isPreviewAvailable && (this.isPreviewMode = !this.isPreviewMode, this.syncPreviewState(), this.view.dispatch(this.view.state.tr.setMeta(Ga, !0)));
|
|
2430
2476
|
}, this.handlePreviewKeyDown = (e) => {
|
|
2431
2477
|
if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
|
|
2432
|
-
let t =
|
|
2433
|
-
t !== null &&
|
|
2478
|
+
let t = $a(this.getPos);
|
|
2479
|
+
t !== null && Ln(this.view, t, this.node, e.key) && e.preventDefault();
|
|
2434
2480
|
}, this.handleCopyClick = (e) => {
|
|
2435
|
-
if (e.preventDefault(), e.stopPropagation(), !
|
|
2481
|
+
if (e.preventDefault(), e.stopPropagation(), !eo(this.view)) return;
|
|
2436
2482
|
let t = this.node.textContent;
|
|
2437
2483
|
(typeof navigator < "u" && navigator.clipboard?.writeText ? navigator.clipboard.writeText(t) : Promise.resolve()).then(() => {
|
|
2438
|
-
this.copyButton.innerHTML =
|
|
2439
|
-
this.copyButton.innerHTML =
|
|
2440
|
-
},
|
|
2484
|
+
this.copyButton.innerHTML = Ja, this.copyButton.dataset.copied = "true", this.copyFeedbackTimer !== null && clearTimeout(this.copyFeedbackTimer), this.copyFeedbackTimer = setTimeout(() => {
|
|
2485
|
+
this.copyButton.innerHTML = qa, delete this.copyButton.dataset.copied, this.copyFeedbackTimer = null;
|
|
2486
|
+
}, Ua);
|
|
2441
2487
|
}).catch(() => {});
|
|
2442
2488
|
}, this.handleDeleteClick = (e) => {
|
|
2443
|
-
e.preventDefault(), e.stopPropagation(),
|
|
2444
|
-
}, this.node = e, this.view = t, this.getPos = n, this.messages = r, this.dom = document.createElement("div"), this.dom.className = "zt-md-code-block", this.dom.dataset.type =
|
|
2489
|
+
e.preventDefault(), e.stopPropagation(), eo(this.view) && this.deleteCurrentCodeBlock();
|
|
2490
|
+
}, this.node = e, this.view = t, this.getPos = n, this.messages = r, this.dom = document.createElement("div"), this.dom.className = "zt-md-code-block", this.dom.dataset.type = Ha, this.contentDOM = document.createElement("pre"), this.previewContainer = document.createElement("div"), this.previewContainer.className = "zt-md-code-block-preview", this.previewContainer.contentEditable = "false", this.previewContainer.hidden = !0, this.previewContainer.tabIndex = -1, this.previewContainer.setAttribute("role", "region"), this.previewContainer.setAttribute("aria-label", r.codeBlockPreviewAriaLabel), this.actionsContainer = document.createElement("span"), this.actionsContainer.className = "zt-md-code-block-actions", this.actionsContainer.contentEditable = "false", this.previewButton = document.createElement("button"), this.previewButton.type = "button", this.previewButton.className = "zt-md-code-block-action-button", this.previewButton.hidden = !0, this.previewButton.innerHTML = Xa, this.copyButton = document.createElement("button"), this.copyButton.type = "button", this.copyButton.className = "zt-md-code-block-action-button zt-md-code-block-editable-action", this.copyButton.setAttribute("aria-label", r.codeBlockCopyAriaLabel), this.copyButton.innerHTML = qa, this.deleteButton = document.createElement("button"), this.deleteButton.type = "button", this.deleteButton.className = "zt-md-code-block-action-button zt-md-code-block-editable-action zt-md-code-block-action-button-danger", this.deleteButton.setAttribute("aria-label", r.codeBlockDeleteAriaLabel), this.deleteButton.innerHTML = Ya, this.actionsContainer.append(this.previewButton, this.copyButton, this.deleteButton), this.dom.append(this.contentDOM, this.previewContainer, this.actionsContainer), this.updateEditableState(), this.syncLanguageAttribute(e), this.syncPreviewAvailability(e), this.previewButton.addEventListener("click", this.handlePreviewClick), this.copyButton.addEventListener("click", this.handleCopyClick), this.deleteButton.addEventListener("click", this.handleDeleteClick), this.previewContainer.addEventListener("keydown", this.handlePreviewKeyDown), this.stopObservingMessages = W(r, () => {
|
|
2445
2491
|
this.previewContainer.setAttribute("aria-label", r.codeBlockPreviewAriaLabel), this.copyButton.setAttribute("aria-label", r.codeBlockCopyAriaLabel), this.deleteButton.setAttribute("aria-label", r.codeBlockDeleteAriaLabel);
|
|
2446
2492
|
let e = this.isPreviewAvailable && this.isPreviewMode ? r.codeBlockSourceAriaLabel : r.codeBlockPreviewAriaLabel;
|
|
2447
2493
|
this.previewButton.setAttribute("aria-label", e), this.previewButton.title = e, this.previewFrame && (this.previewFrame.title = r.codeBlockPreviewAriaLabel);
|
|
2448
2494
|
});
|
|
2449
2495
|
}
|
|
2450
2496
|
deleteCurrentCodeBlock() {
|
|
2451
|
-
let e =
|
|
2497
|
+
let e = $a(this.getPos);
|
|
2452
2498
|
if (e === null) return;
|
|
2453
2499
|
let t = this.view.state.tr.delete(e, e + this.node.nodeSize), n = Math.min(e, t.doc.content.size);
|
|
2454
2500
|
t.setSelection(z.near(t.doc.resolve(n), -1)).scrollIntoView(), this.view.dispatch(t), requestAnimationFrame(() => {
|
|
@@ -2456,36 +2502,36 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2456
2502
|
});
|
|
2457
2503
|
}
|
|
2458
2504
|
updateEditableState() {
|
|
2459
|
-
this.dom.dataset.editable =
|
|
2505
|
+
this.dom.dataset.editable = eo(this.view) ? "true" : "false";
|
|
2460
2506
|
}
|
|
2461
2507
|
syncPreviewAvailability(e) {
|
|
2462
2508
|
let t = typeof e.attrs.language == "string" ? e.attrs.language : "";
|
|
2463
|
-
this.isPreviewAvailable =
|
|
2509
|
+
this.isPreviewAvailable = Va(t), this.isPreviewAvailable || (this.isPreviewMode = !1), this.previewButton.hidden = !this.isPreviewAvailable, this.syncPreviewState(), this.syncActionsVisibility();
|
|
2464
2510
|
}
|
|
2465
2511
|
syncPreviewState() {
|
|
2466
2512
|
let e = this.isPreviewAvailable && this.isPreviewMode, t = e ? this.messages.codeBlockSourceAriaLabel : this.messages.codeBlockPreviewAriaLabel;
|
|
2467
|
-
if (this.dom.dataset.viewMode = e ? "preview" : "source", this.previewContainer.hidden = !e, this.previewContainer.tabIndex = e ? 0 : -1, this.previewButton.dataset.active = e ? "true" : "false", this.previewButton.setAttribute("aria-pressed", e ? "true" : "false"), this.previewButton.setAttribute("aria-label", t), this.previewButton.title = t, this.previewButton.innerHTML = e ?
|
|
2513
|
+
if (this.dom.dataset.viewMode = e ? "preview" : "source", this.previewContainer.hidden = !e, this.previewContainer.tabIndex = e ? 0 : -1, this.previewButton.dataset.active = e ? "true" : "false", this.previewButton.setAttribute("aria-pressed", e ? "true" : "false"), this.previewButton.setAttribute("aria-label", t), this.previewButton.title = t, this.previewButton.innerHTML = e ? Za : Xa, e) {
|
|
2468
2514
|
this.contentDOM.setAttribute("aria-hidden", "true"), this.renderPreview();
|
|
2469
2515
|
return;
|
|
2470
2516
|
}
|
|
2471
2517
|
this.contentDOM.removeAttribute("aria-hidden"), this.clearPreview();
|
|
2472
2518
|
}
|
|
2473
2519
|
syncActionsVisibility() {
|
|
2474
|
-
let e =
|
|
2520
|
+
let e = eo(this.view) || this.isPreviewAvailable;
|
|
2475
2521
|
this.actionsContainer.dataset.visible = e ? "true" : "false";
|
|
2476
2522
|
}
|
|
2477
2523
|
renderPreview() {
|
|
2478
|
-
let e = this.node.textContent, t =
|
|
2524
|
+
let e = this.node.textContent, t = J(String(this.node.attrs.language ?? "")), n = t === Wa, r = `${t}\u0000${e}`;
|
|
2479
2525
|
if (this.renderedPreviewKey === r) return;
|
|
2480
2526
|
this.renderedPreviewKey = r;
|
|
2481
2527
|
let i = document.createElement("iframe");
|
|
2482
|
-
i.className = "zt-md-code-block-preview-frame", i.title = this.messages.codeBlockPreviewAriaLabel, i.tabIndex = -1, i.referrerPolicy = "no-referrer", i.setAttribute("sandbox", n ? "allow-scripts" : ""), i.srcdoc =
|
|
2528
|
+
i.className = "zt-md-code-block-preview-frame", i.title = this.messages.codeBlockPreviewAriaLabel, i.tabIndex = -1, i.referrerPolicy = "no-referrer", i.setAttribute("sandbox", n ? "allow-scripts" : ""), i.srcdoc = Qa(e, n), this.previewContainer.replaceChildren(i), this.previewFrame = i;
|
|
2483
2529
|
}
|
|
2484
2530
|
clearPreview() {
|
|
2485
2531
|
this.renderedPreviewKey = null, this.previewFrame?.remove(), this.previewFrame = null;
|
|
2486
2532
|
}
|
|
2487
2533
|
update(e) {
|
|
2488
|
-
return e.type.name ===
|
|
2534
|
+
return e.type.name === Ha ? (this.node = e, this.updateEditableState(), this.syncLanguageAttribute(e), this.syncPreviewAvailability(e), !0) : !1;
|
|
2489
2535
|
}
|
|
2490
2536
|
stopEvent(e) {
|
|
2491
2537
|
let t = e.target;
|
|
@@ -2495,30 +2541,30 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2495
2541
|
return e.type === "selection" ? !1 : e.type === "attributes" && (e.target === this.dom && e.attributeName === "data-view-mode" || e.target === this.contentDOM && e.attributeName === "aria-hidden") ? !0 : this.actionsContainer.contains(e.target) || this.previewContainer.contains(e.target);
|
|
2496
2542
|
}
|
|
2497
2543
|
destroy() {
|
|
2498
|
-
this.stopObservingMessages(), this.previewButton.removeEventListener("click", this.handlePreviewClick), this.copyButton.removeEventListener("click", this.handleCopyClick), this.deleteButton.removeEventListener("click", this.handleDeleteClick), this.previewContainer.removeEventListener("keydown", this.handlePreviewKeyDown), this.copyFeedbackTimer !== null && (clearTimeout(this.copyFeedbackTimer), this.copyFeedbackTimer = null), this.copyButton.innerHTML =
|
|
2544
|
+
this.stopObservingMessages(), this.previewButton.removeEventListener("click", this.handlePreviewClick), this.copyButton.removeEventListener("click", this.handleCopyClick), this.deleteButton.removeEventListener("click", this.handleDeleteClick), this.previewContainer.removeEventListener("keydown", this.handlePreviewKeyDown), this.copyFeedbackTimer !== null && (clearTimeout(this.copyFeedbackTimer), this.copyFeedbackTimer = null), this.copyButton.innerHTML = qa, delete this.copyButton.dataset.copied, this.clearPreview();
|
|
2499
2545
|
}
|
|
2500
|
-
},
|
|
2546
|
+
}, no = (e = U()) => (t, n, r) => new to(t, n, typeof r == "function" ? () => {
|
|
2501
2547
|
let e = r();
|
|
2502
2548
|
return typeof e == "number" ? e : 0;
|
|
2503
|
-
} : !1, e),
|
|
2504
|
-
Array.from(
|
|
2505
|
-
},
|
|
2506
|
-
|
|
2549
|
+
} : !1, e), ro = /* @__PURE__ */ new Set(), io = !1, ao = () => typeof document < "u", oo = (e) => {
|
|
2550
|
+
Array.from(ro).forEach((t) => t(e));
|
|
2551
|
+
}, so = () => {
|
|
2552
|
+
io || !ao() || (document.addEventListener("scroll", oo, {
|
|
2507
2553
|
capture: !0,
|
|
2508
2554
|
passive: !0
|
|
2509
|
-
}),
|
|
2510
|
-
},
|
|
2511
|
-
|
|
2512
|
-
},
|
|
2513
|
-
if (!
|
|
2555
|
+
}), io = !0);
|
|
2556
|
+
}, co = () => {
|
|
2557
|
+
!io || !ao() || (document.removeEventListener("scroll", oo, !0), io = !1);
|
|
2558
|
+
}, lo = (e) => {
|
|
2559
|
+
if (!ao()) return () => void 0;
|
|
2514
2560
|
let t = !0;
|
|
2515
|
-
return
|
|
2516
|
-
t && (t = !1,
|
|
2561
|
+
return ro.add(e), so(), () => {
|
|
2562
|
+
t && (t = !1, ro.delete(e), ro.size === 0 && co());
|
|
2517
2563
|
};
|
|
2518
|
-
},
|
|
2564
|
+
}, uo = (e) => e ? e.closest(".zt-md-editor") ?? e : null, fo = (e, t, n) => {
|
|
2519
2565
|
let r = typeof window > "u" ? e.bottom : window.innerHeight, i = n?.top ?? 0, a = n?.bottom ?? r, o = e.top - i, s = a - e.bottom;
|
|
2520
2566
|
return s < t && o > s ? "top" : "bottom";
|
|
2521
|
-
},
|
|
2567
|
+
}, po = (e, t, n) => {
|
|
2522
2568
|
let r = n ?? t.getBoundingClientRect();
|
|
2523
2569
|
return {
|
|
2524
2570
|
anchorTopInContent: e.top - r.top + t.scrollTop,
|
|
@@ -2526,28 +2572,28 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2526
2572
|
anchorLeftInContent: e.left - r.left + t.scrollLeft,
|
|
2527
2573
|
anchorRightInContent: e.right - r.left + t.scrollLeft
|
|
2528
2574
|
};
|
|
2529
|
-
},
|
|
2575
|
+
}, mo = (e) => {
|
|
2530
2576
|
let { anchor: t, overlaySize: n, horizontalAlign: r = "start" } = e, i = t.anchorRightInContent ?? t.anchorLeftInContent;
|
|
2531
2577
|
return r === "end" ? i - n.width : r === "center" ? t.anchorLeftInContent + (i - t.anchorLeftInContent - n.width) / 2 : t.anchorLeftInContent;
|
|
2532
|
-
},
|
|
2533
|
-
let { wrapper: n, anchor: r, overlaySize: i, placement: a, offsetY: o, boundaryInset: s } = e, c = t ?? n.getBoundingClientRect(), l = n.scrollLeft + s, u = n.scrollLeft + n.clientWidth - i.width - s, d =
|
|
2578
|
+
}, ho = (e, t) => {
|
|
2579
|
+
let { wrapper: n, anchor: r, overlaySize: i, placement: a, offsetY: o, boundaryInset: s } = e, c = t ?? n.getBoundingClientRect(), l = n.scrollLeft + s, u = n.scrollLeft + n.clientWidth - i.width - s, d = mo(e), f = Math.min(Math.max(d, l), Math.max(l, u)), p = a === "top" ? r.anchorTopInContent - (i.height ?? 0) - o : r.anchorBottomInContent + o;
|
|
2534
2580
|
return {
|
|
2535
2581
|
left: c.left + f - n.scrollLeft,
|
|
2536
2582
|
top: c.top + p - n.scrollTop
|
|
2537
2583
|
};
|
|
2538
|
-
},
|
|
2539
|
-
let r =
|
|
2584
|
+
}, go = (e, t, n) => {
|
|
2585
|
+
let r = ho(e, n), i = t.getBoundingClientRect();
|
|
2540
2586
|
return {
|
|
2541
2587
|
left: r.left - i.left,
|
|
2542
2588
|
top: r.top - i.top
|
|
2543
2589
|
};
|
|
2544
|
-
},
|
|
2590
|
+
}, _o = (e) => {
|
|
2545
2591
|
let t = 0, n = null, r = null, i = () => {
|
|
2546
2592
|
typeof window > "u" || (t && window.cancelAnimationFrame(t), t = window.requestAnimationFrame(() => {
|
|
2547
2593
|
t = 0, e();
|
|
2548
2594
|
}));
|
|
2549
2595
|
}, a = () => {
|
|
2550
|
-
window.addEventListener("resize", i), r ||=
|
|
2596
|
+
window.addEventListener("resize", i), r ||= lo(i);
|
|
2551
2597
|
}, o = () => {
|
|
2552
2598
|
window.removeEventListener("resize", i), r?.(), r = null;
|
|
2553
2599
|
}, s = (e) => {
|
|
@@ -2562,18 +2608,18 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2562
2608
|
typeof window < "u" && t && (window.cancelAnimationFrame(t), t = 0), o(), s(null);
|
|
2563
2609
|
}
|
|
2564
2610
|
};
|
|
2565
|
-
},
|
|
2611
|
+
}, vo = (e, t, n, r) => {
|
|
2566
2612
|
let i = t.top - r.top, a = r.bottom - t.bottom;
|
|
2567
2613
|
return e === "top" ? i < n && a > i ? "bottom" : "top" : a < n && i > a ? "top" : "bottom";
|
|
2568
|
-
},
|
|
2614
|
+
}, yo = ({ open: e, portalContainer: t, editorWrapper: n, defaultPlacement: o = "bottom", horizontalAlign: c = "start", offsetY: l = 8, boundaryInset: u = 2, fallbackWidth: d, fallbackHeight: f, onOutside: p }) => {
|
|
2569
2615
|
let m = s(null), h = s(null), g = s(e), _ = s(p);
|
|
2570
2616
|
_.current = p;
|
|
2571
2617
|
let v = r(() => {
|
|
2572
2618
|
let e = m.current, r = h.current;
|
|
2573
2619
|
if (!g.current || !e || !r || !t || !n) return;
|
|
2574
|
-
let i = e.getBoundingClientRect(), a = n.getBoundingClientRect(), s = r.offsetWidth || d, p = r.offsetHeight || f, _ =
|
|
2620
|
+
let i = e.getBoundingClientRect(), a = n.getBoundingClientRect(), s = r.offsetWidth || d, p = r.offsetHeight || f, _ = vo(o, i, p, a), v = go({
|
|
2575
2621
|
wrapper: n,
|
|
2576
|
-
anchor:
|
|
2622
|
+
anchor: po(i, n, a),
|
|
2577
2623
|
overlaySize: {
|
|
2578
2624
|
width: s,
|
|
2579
2625
|
height: p
|
|
@@ -2604,7 +2650,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2604
2650
|
v();
|
|
2605
2651
|
}, [e, v]), i(() => {
|
|
2606
2652
|
if (!e) return;
|
|
2607
|
-
let t =
|
|
2653
|
+
let t = _o(v);
|
|
2608
2654
|
return t.bindGlobal(), t.bindWrapper(n ?? null), t.schedule(), () => {
|
|
2609
2655
|
t.destroy();
|
|
2610
2656
|
};
|
|
@@ -2627,7 +2673,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2627
2673
|
panelRef: y,
|
|
2628
2674
|
updatePosition: v
|
|
2629
2675
|
};
|
|
2630
|
-
},
|
|
2676
|
+
}, bo = ({ panel: e, portalContainer: t, className: r, role: i, onMouseDown: a, children: o }) => !e.open || !t ? null : vt(n("div", {
|
|
2631
2677
|
ref: e.panelRef,
|
|
2632
2678
|
role: i,
|
|
2633
2679
|
className: r,
|
|
@@ -2636,7 +2682,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2636
2682
|
visibility: "hidden"
|
|
2637
2683
|
},
|
|
2638
2684
|
onMouseDown: a
|
|
2639
|
-
}, o), t),
|
|
2685
|
+
}, o), t), xo = "code_block", So = "ZT_MD_CODE_BLOCK_LANGUAGE_PICKER", Co = 8, wo = 96, To = 26, Eo = 224, Do = 220, Oo = [
|
|
2640
2686
|
"javascript",
|
|
2641
2687
|
"typescript",
|
|
2642
2688
|
"tsx",
|
|
@@ -2657,16 +2703,16 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2657
2703
|
"csharp",
|
|
2658
2704
|
"php",
|
|
2659
2705
|
"docker"
|
|
2660
|
-
],
|
|
2661
|
-
let t = He.listLanguages(), n = new Set(t.map((e) =>
|
|
2662
|
-
for (let e of
|
|
2706
|
+
], ko = (e) => {
|
|
2707
|
+
let t = He.listLanguages(), n = new Set(t.map((e) => J(e)).filter((e) => e !== Ia)), r = [];
|
|
2708
|
+
for (let e of Oo) n.delete(e) && r.push({
|
|
2663
2709
|
value: e,
|
|
2664
2710
|
label: e
|
|
2665
2711
|
});
|
|
2666
2712
|
let i = [...n].sort((e, t) => e.localeCompare(t));
|
|
2667
2713
|
return [
|
|
2668
2714
|
{
|
|
2669
|
-
value:
|
|
2715
|
+
value: Ia,
|
|
2670
2716
|
label: e
|
|
2671
2717
|
},
|
|
2672
2718
|
...r,
|
|
@@ -2675,21 +2721,21 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2675
2721
|
label: e
|
|
2676
2722
|
}))
|
|
2677
2723
|
];
|
|
2678
|
-
},
|
|
2724
|
+
}, Ao = (e) => {
|
|
2679
2725
|
let t = e.state.selection.$from;
|
|
2680
2726
|
for (let e = t.depth; e >= 0; --e) {
|
|
2681
2727
|
let n = t.node(e);
|
|
2682
|
-
if (n.type.name ===
|
|
2728
|
+
if (n.type.name === xo) return {
|
|
2683
2729
|
position: e === 0 ? 0 : t.before(e),
|
|
2684
2730
|
node: n
|
|
2685
2731
|
};
|
|
2686
2732
|
}
|
|
2687
2733
|
return null;
|
|
2688
|
-
},
|
|
2734
|
+
}, jo = (e, t) => {
|
|
2689
2735
|
let n = e.nodeDOM(t);
|
|
2690
2736
|
return n instanceof HTMLPreElement ? n : n instanceof HTMLElement ? n.querySelector("pre") : null;
|
|
2691
|
-
},
|
|
2692
|
-
let [r, l] = c(!1), [u, d] = c(""), [f, p] = c(0), m = s(null), h = s(null), g =
|
|
2737
|
+
}, Mo = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, No = (e) => {
|
|
2738
|
+
let [r, l] = c(!1), [u, d] = c(""), [f, p] = c(0), m = s(null), h = s(null), g = J(e.currentLanguage), _ = g === "text" ? e.messages.codeBlockLanguagePlainText : g, v = o(() => ko(e.messages.codeBlockLanguagePlainText), [e.messages.codeBlockLanguagePlainText]), y = o(() => {
|
|
2693
2739
|
let e = u.trim().toLowerCase();
|
|
2694
2740
|
if (!e) return v;
|
|
2695
2741
|
let t = [], n = [];
|
|
@@ -2698,14 +2744,14 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2698
2744
|
a.startsWith(e) || i.startsWith(e) ? t.push(r) : (a.includes(e) || i.includes(e)) && n.push(r);
|
|
2699
2745
|
}
|
|
2700
2746
|
return [...t, ...n];
|
|
2701
|
-
}, [u, v]), S =
|
|
2747
|
+
}, [u, v]), S = yo({
|
|
2702
2748
|
open: r,
|
|
2703
2749
|
portalContainer: e.portalContainer,
|
|
2704
2750
|
editorWrapper: e.collisionBoundary,
|
|
2705
2751
|
horizontalAlign: "end",
|
|
2706
2752
|
offsetY: 6,
|
|
2707
|
-
fallbackWidth:
|
|
2708
|
-
fallbackHeight:
|
|
2753
|
+
fallbackWidth: Eo,
|
|
2754
|
+
fallbackHeight: Do,
|
|
2709
2755
|
onOutside: () => l(!1)
|
|
2710
2756
|
}), C = (e) => e instanceof HTMLElement ? e.closest("input, textarea, [contenteditable]:not([contenteditable=\"false\"])") !== null : !1, w = (e) => {
|
|
2711
2757
|
C(e.target) || e.preventDefault();
|
|
@@ -2755,7 +2801,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2755
2801
|
size: 14,
|
|
2756
2802
|
strokeWidth: 2,
|
|
2757
2803
|
"aria-hidden": "true"
|
|
2758
|
-
}))), n(
|
|
2804
|
+
}))), n(bo, {
|
|
2759
2805
|
panel: S,
|
|
2760
2806
|
portalContainer: e.portalContainer,
|
|
2761
2807
|
className: "zt-md-code-language-picker-panel",
|
|
@@ -2800,13 +2846,13 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2800
2846
|
strokeWidth: 2,
|
|
2801
2847
|
"aria-hidden": "true"
|
|
2802
2848
|
}) : null)) : n("div", { className: "zt-md-code-language-picker-empty" }, "-"))));
|
|
2803
|
-
},
|
|
2849
|
+
}, Po = class {
|
|
2804
2850
|
constructor(e, t, n) {
|
|
2805
|
-
this.isAttached = !1, this.currentCodeBlockPosition = null, this.currentPreElement = null, this.currentActionsContainer = null, this.currentRenderedLanguage = null, this.hasPositionContext = !1, this.repositionScheduler =
|
|
2851
|
+
this.isAttached = !1, this.currentCodeBlockPosition = null, this.currentPreElement = null, this.currentActionsContainer = null, this.currentRenderedLanguage = null, this.hasPositionContext = !1, this.repositionScheduler = _o(() => {
|
|
2806
2852
|
this.hasPositionContext && this.updateOverlayPosition();
|
|
2807
2853
|
}), this.handlePickerLayoutChange = () => {
|
|
2808
2854
|
this.hasPositionContext && this.updateOverlayPosition();
|
|
2809
|
-
}, this.view = e, this.messages = t, this.portalContainer = n, this.editorWrapper =
|
|
2855
|
+
}, this.view = e, this.messages = t, this.portalContainer = n, this.editorWrapper = uo(e.dom), this.host = document.createElement("span"), this.host.className = "zt-md-code-language-picker-host", this.hostRoot = pt(this.host), this.update(e), this.stopObservingMessages = W(t, () => {
|
|
2810
2856
|
let e = this.currentRenderedLanguage;
|
|
2811
2857
|
this.currentRenderedLanguage = null, e !== null && this.render(e);
|
|
2812
2858
|
});
|
|
@@ -2814,8 +2860,8 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2814
2860
|
applyLanguage(e) {
|
|
2815
2861
|
if (this.currentCodeBlockPosition === null) return;
|
|
2816
2862
|
let t = this.view.state.doc.nodeAt(this.currentCodeBlockPosition);
|
|
2817
|
-
if (!t || t.type.name !==
|
|
2818
|
-
let n =
|
|
2863
|
+
if (!t || t.type.name !== xo) return;
|
|
2864
|
+
let n = J(e), r = {
|
|
2819
2865
|
...t.attrs,
|
|
2820
2866
|
language: n
|
|
2821
2867
|
};
|
|
@@ -2824,7 +2870,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2824
2870
|
this.view.dispatch(i), this.view.focus();
|
|
2825
2871
|
}
|
|
2826
2872
|
render(e) {
|
|
2827
|
-
this.currentRenderedLanguage !== null && this.currentRenderedLanguage === e || (this.hostRoot.render(n(
|
|
2873
|
+
this.currentRenderedLanguage !== null && this.currentRenderedLanguage === e || (this.hostRoot.render(n(No, {
|
|
2828
2874
|
currentLanguage: e,
|
|
2829
2875
|
messages: { ...this.messages },
|
|
2830
2876
|
portalContainer: this.portalContainer,
|
|
@@ -2841,14 +2887,14 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2841
2887
|
}
|
|
2842
2888
|
updateOverlayPosition() {
|
|
2843
2889
|
if (!this.editorWrapper || !this.currentPreElement || this.host.parentElement !== this.portalContainer) return;
|
|
2844
|
-
let e = this.editorWrapper.getBoundingClientRect(), t = this.currentPreElement.getBoundingClientRect(), n =
|
|
2890
|
+
let e = this.editorWrapper.getBoundingClientRect(), t = this.currentPreElement.getBoundingClientRect(), n = po(t, this.editorWrapper, e), r = n.anchorRightInContent ?? n.anchorLeftInContent + t.width, i = Math.max(0, Math.min(t.width, this.editorWrapper.clientWidth) - Co * 2);
|
|
2845
2891
|
this.host.style.setProperty("--zt-md-code-language-picker-max-width", `${i}px`);
|
|
2846
|
-
let a = this.host.offsetWidth || Math.min(
|
|
2892
|
+
let a = this.host.offsetWidth || Math.min(wo, i), o = this.host.offsetHeight || To, s = go({
|
|
2847
2893
|
wrapper: this.editorWrapper,
|
|
2848
2894
|
anchor: {
|
|
2849
|
-
anchorLeftInContent: r - a -
|
|
2850
|
-
anchorTopInContent: n.anchorTopInContent + t.height - o -
|
|
2851
|
-
anchorBottomInContent: n.anchorTopInContent + t.height - o -
|
|
2895
|
+
anchorLeftInContent: r - a - Co,
|
|
2896
|
+
anchorTopInContent: n.anchorTopInContent + t.height - o - Co,
|
|
2897
|
+
anchorBottomInContent: n.anchorTopInContent + t.height - o - Co
|
|
2852
2898
|
},
|
|
2853
2899
|
overlaySize: { width: a },
|
|
2854
2900
|
placement: "top",
|
|
@@ -2858,16 +2904,17 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2858
2904
|
this.host.style.left = `${s.left}px`, this.host.style.top = `${s.top}px`;
|
|
2859
2905
|
}
|
|
2860
2906
|
update(e) {
|
|
2861
|
-
if (this.view = e,
|
|
2907
|
+
if (this.view = e, e.composing) return;
|
|
2908
|
+
if (!Mo(e) || !this.editorWrapper) {
|
|
2862
2909
|
this.detach();
|
|
2863
2910
|
return;
|
|
2864
2911
|
}
|
|
2865
|
-
let t =
|
|
2912
|
+
let t = Ao(e);
|
|
2866
2913
|
if (!t) {
|
|
2867
2914
|
this.detach();
|
|
2868
2915
|
return;
|
|
2869
2916
|
}
|
|
2870
|
-
let n =
|
|
2917
|
+
let n = jo(e, t.position);
|
|
2871
2918
|
if (!n) {
|
|
2872
2919
|
this.detach();
|
|
2873
2920
|
return;
|
|
@@ -2876,19 +2923,19 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2876
2923
|
this.syncFocusedActionsContainer(r);
|
|
2877
2924
|
let i = this.isAttached;
|
|
2878
2925
|
this.isAttached || (this.isAttached = !0, this.repositionScheduler.bindGlobal(), this.repositionScheduler.bindWrapper(this.editorWrapper)), this.host.parentElement !== this.portalContainer && this.portalContainer.append(this.host);
|
|
2879
|
-
let a =
|
|
2926
|
+
let a = J(String(t.node.attrs.language ?? "")), o = this.currentCodeBlockPosition === t.position && this.currentPreElement === n && this.currentRenderedLanguage !== null && this.currentRenderedLanguage === a;
|
|
2880
2927
|
this.currentCodeBlockPosition = t.position, this.currentPreElement = n, this.hasPositionContext = !0, o || this.render(a), i ? this.repositionScheduler.schedule() : this.updateOverlayPosition();
|
|
2881
2928
|
}
|
|
2882
2929
|
destroy() {
|
|
2883
2930
|
this.stopObservingMessages(), this.detach(), this.repositionScheduler.destroy(), this.hostRoot.unmount();
|
|
2884
2931
|
}
|
|
2885
|
-
},
|
|
2886
|
-
key: new R(
|
|
2887
|
-
view: (n) => new
|
|
2888
|
-
})),
|
|
2932
|
+
}, Fo = (e, t) => B(() => new L({
|
|
2933
|
+
key: new R(So),
|
|
2934
|
+
view: (n) => new Po(n, e, t)
|
|
2935
|
+
})), Io = new Set(["code_block", "frontmatter"]), Lo = "a", Ro = "zt-md-code-block-mod-a-select", zo = (e) => e.key.toLowerCase() !== Lo || e.defaultPrevented || e.altKey || e.shiftKey || !e.ctrlKey && !e.metaKey, Bo = (e) => {
|
|
2889
2936
|
for (let t = e.depth; t >= 0; --t) {
|
|
2890
2937
|
let n = e.node(t);
|
|
2891
|
-
if (!
|
|
2938
|
+
if (!Io.has(n.type.name)) continue;
|
|
2892
2939
|
let r = t === 0 ? 0 : e.before(t);
|
|
2893
2940
|
return {
|
|
2894
2941
|
codeBlockStart: r + 1,
|
|
@@ -2896,15 +2943,15 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2896
2943
|
};
|
|
2897
2944
|
}
|
|
2898
2945
|
return null;
|
|
2899
|
-
},
|
|
2900
|
-
let n = e.state.selection.$from, r =
|
|
2946
|
+
}, Vo = (e, t) => {
|
|
2947
|
+
let n = e.state.selection.$from, r = Bo(n);
|
|
2901
2948
|
if (!r) return !1;
|
|
2902
2949
|
let i = e.state.tr.setSelection(z.create(e.state.doc, r.codeBlockStart, r.codeBlockEnd));
|
|
2903
2950
|
return t.preventDefault(), e.dispatch(i), !0;
|
|
2904
|
-
},
|
|
2905
|
-
key: new R(
|
|
2906
|
-
props: { handleKeyDown: (e, t) =>
|
|
2907
|
-
})),
|
|
2951
|
+
}, Ho = B(() => new L({
|
|
2952
|
+
key: new R(Ro),
|
|
2953
|
+
props: { handleKeyDown: (e, t) => zo(t) ? !1 : Vo(e, t) }
|
|
2954
|
+
})), Uo = "frontmatter", Wo = ["yaml", "toml"], Go = (e) => e === "toml" ? "toml" : "yaml", Ko = [st("remarkFrontmatter", () => yt, [...Wo]), ot(Uo, () => ({
|
|
2908
2955
|
content: "text*",
|
|
2909
2956
|
group: "block",
|
|
2910
2957
|
marks: "",
|
|
@@ -2916,48 +2963,48 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2916
2963
|
validate: "string"
|
|
2917
2964
|
} },
|
|
2918
2965
|
parseDOM: [{
|
|
2919
|
-
tag: `pre[data-type="${
|
|
2966
|
+
tag: `pre[data-type="${Uo}"]`,
|
|
2920
2967
|
preserveWhitespace: "full",
|
|
2921
|
-
getAttrs: (e) => ({ format:
|
|
2968
|
+
getAttrs: (e) => ({ format: Go(e.dataset.format) })
|
|
2922
2969
|
}],
|
|
2923
2970
|
toDOM: (e) => [
|
|
2924
2971
|
"pre",
|
|
2925
2972
|
{
|
|
2926
|
-
"data-type":
|
|
2927
|
-
"data-format":
|
|
2973
|
+
"data-type": Uo,
|
|
2974
|
+
"data-format": Go(e.attrs.format)
|
|
2928
2975
|
},
|
|
2929
2976
|
["code", 0]
|
|
2930
2977
|
],
|
|
2931
2978
|
parseMarkdown: {
|
|
2932
2979
|
match: (e) => e.type === "yaml" || e.type === "toml",
|
|
2933
2980
|
runner: (e, t, n) => {
|
|
2934
|
-
let r =
|
|
2981
|
+
let r = Go(t.type), i = typeof t.value == "string" ? t.value : "";
|
|
2935
2982
|
e.openNode(n, { format: r }), i && e.addText(i), e.closeNode();
|
|
2936
2983
|
}
|
|
2937
2984
|
},
|
|
2938
2985
|
toMarkdown: {
|
|
2939
|
-
match: (e) => e.type.name ===
|
|
2986
|
+
match: (e) => e.type.name === Uo,
|
|
2940
2987
|
runner: (e, t) => {
|
|
2941
|
-
let n =
|
|
2988
|
+
let n = Go(t.attrs.format);
|
|
2942
2989
|
e.addNode(n, void 0, t.textContent);
|
|
2943
2990
|
}
|
|
2944
2991
|
}
|
|
2945
|
-
}))].flat(),
|
|
2992
|
+
}))].flat(), qo = 1200, Jo = {
|
|
2946
2993
|
yaml: "frontmatterYamlLabel",
|
|
2947
2994
|
toml: "frontmatterTomlLabel"
|
|
2948
|
-
},
|
|
2995
|
+
}, Yo = K("ChevronDown", {
|
|
2949
2996
|
size: 14,
|
|
2950
2997
|
strokeWidth: 2
|
|
2951
|
-
}),
|
|
2998
|
+
}), Xo = K("Copy", {
|
|
2952
2999
|
size: 14,
|
|
2953
3000
|
strokeWidth: 2
|
|
2954
|
-
}),
|
|
3001
|
+
}), Zo = K("Check", {
|
|
2955
3002
|
size: 14,
|
|
2956
3003
|
strokeWidth: 2
|
|
2957
|
-
}),
|
|
3004
|
+
}), Qo = K("Trash2", {
|
|
2958
3005
|
size: 14,
|
|
2959
3006
|
strokeWidth: 2
|
|
2960
|
-
}),
|
|
3007
|
+
}), $o = (e) => typeof e == "function" ? e() : null, es = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, ts = class {
|
|
2961
3008
|
constructor(e, t, n, r) {
|
|
2962
3009
|
this.isCollapsed = !1, this.copyFeedbackTimer = null, this.handleToggleClick = (e) => {
|
|
2963
3010
|
e.preventDefault(), e.stopPropagation(), this.isCollapsed = !this.isCollapsed, this.syncCollapsedState(), this.syncLocalizedLabels();
|
|
@@ -2965,13 +3012,13 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2965
3012
|
e.preventDefault(), e.stopPropagation();
|
|
2966
3013
|
let t = this.node.textContent;
|
|
2967
3014
|
(typeof navigator < "u" && navigator.clipboard?.writeText ? navigator.clipboard.writeText(t) : Promise.resolve()).then(() => {
|
|
2968
|
-
this.copyButton.innerHTML =
|
|
2969
|
-
this.copyButton.innerHTML =
|
|
2970
|
-
},
|
|
3015
|
+
this.copyButton.innerHTML = Zo, this.copyButton.dataset.copied = "true", this.copyFeedbackTimer !== null && clearTimeout(this.copyFeedbackTimer), this.copyFeedbackTimer = setTimeout(() => {
|
|
3016
|
+
this.copyButton.innerHTML = Xo, delete this.copyButton.dataset.copied, this.copyFeedbackTimer = null;
|
|
3017
|
+
}, qo);
|
|
2971
3018
|
}).catch(() => {});
|
|
2972
3019
|
}, this.handleDeleteClick = (e) => {
|
|
2973
|
-
if (e.preventDefault(), e.stopPropagation(), !
|
|
2974
|
-
let t =
|
|
3020
|
+
if (e.preventDefault(), e.stopPropagation(), !es(this.view)) return;
|
|
3021
|
+
let t = $o(this.getPos);
|
|
2975
3022
|
if (t === null) return;
|
|
2976
3023
|
let n = t + this.node.nodeSize, r = t === 0 && n === this.view.state.doc.content.size, i = this.view.state.schema.nodes.paragraph, a = r ? i?.createAndFill() : null;
|
|
2977
3024
|
if (a) {
|
|
@@ -2981,23 +3028,23 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2981
3028
|
}
|
|
2982
3029
|
let o = this.view.state.tr.delete(t, n), s = Math.min(t, o.doc.content.size);
|
|
2983
3030
|
o.setSelection(z.near(o.doc.resolve(s), 1)).scrollIntoView(), this.view.dispatch(o), this.view.focus();
|
|
2984
|
-
}, this.node = e, this.view = t, this.getPos = n, this.messages = r, this.dom = document.createElement("div"), this.dom.className = "zt-md-frontmatter", this.dom.dataset.type =
|
|
3031
|
+
}, this.node = e, this.view = t, this.getPos = n, this.messages = r, this.dom = document.createElement("div"), this.dom.className = "zt-md-frontmatter", this.dom.dataset.type = Uo, this.headerContainer = document.createElement("div"), this.headerContainer.className = "zt-md-frontmatter-header", this.headerContainer.contentEditable = "false", this.toggleButton = document.createElement("button"), this.toggleButton.type = "button", this.toggleButton.className = "zt-md-frontmatter-toggle", this.chevronIcon = document.createElement("span"), this.chevronIcon.className = "zt-md-frontmatter-chevron", this.chevronIcon.innerHTML = Yo, this.titleSpan = document.createElement("span"), this.titleSpan.className = "zt-md-frontmatter-title", this.toggleButton.append(this.chevronIcon, this.titleSpan), this.actionsContainer = document.createElement("span"), this.actionsContainer.className = "zt-md-frontmatter-actions", this.copyButton = document.createElement("button"), this.copyButton.type = "button", this.copyButton.className = "zt-md-frontmatter-action-button", this.copyButton.innerHTML = Xo, this.deleteButton = document.createElement("button"), this.deleteButton.type = "button", this.deleteButton.className = "zt-md-frontmatter-action-button zt-md-frontmatter-editable-action zt-md-frontmatter-action-button-danger", this.deleteButton.innerHTML = Qo, this.actionsContainer.append(this.copyButton, this.deleteButton), this.headerContainer.append(this.toggleButton, this.actionsContainer), this.contentDOM = document.createElement("pre"), this.contentDOM.className = "zt-md-frontmatter-body", this.dom.append(this.headerContainer, this.contentDOM), this.syncFormatState(e), this.syncEditableState(), this.syncCollapsedState(), this.syncLocalizedLabels(), this.toggleButton.addEventListener("click", this.handleToggleClick), this.copyButton.addEventListener("click", this.handleCopyClick), this.deleteButton.addEventListener("click", this.handleDeleteClick), this.stopObservingMessages = W(r, () => {
|
|
2985
3032
|
this.syncLocalizedLabels();
|
|
2986
3033
|
});
|
|
2987
3034
|
}
|
|
2988
3035
|
syncFormatState(e) {
|
|
2989
|
-
let t =
|
|
2990
|
-
this.dom.dataset.format = t, this.titleSpan.textContent = this.messages[
|
|
3036
|
+
let t = Go(e.attrs.format);
|
|
3037
|
+
this.dom.dataset.format = t, this.titleSpan.textContent = this.messages[Jo[t]];
|
|
2991
3038
|
}
|
|
2992
3039
|
syncEditableState() {
|
|
2993
|
-
this.dom.dataset.editable =
|
|
3040
|
+
this.dom.dataset.editable = es(this.view) ? "true" : "false";
|
|
2994
3041
|
}
|
|
2995
3042
|
syncCollapsedState() {
|
|
2996
3043
|
this.dom.dataset.collapsed = this.isCollapsed ? "true" : "false", this.toggleButton.setAttribute("aria-expanded", String(!this.isCollapsed)), this.contentDOM.hidden = this.isCollapsed, this.contentDOM.setAttribute("aria-hidden", String(this.isCollapsed));
|
|
2997
3044
|
}
|
|
2998
3045
|
syncLocalizedLabels() {
|
|
2999
|
-
let e =
|
|
3000
|
-
this.titleSpan.textContent = this.messages[
|
|
3046
|
+
let e = Go(this.node.attrs.format);
|
|
3047
|
+
this.titleSpan.textContent = this.messages[Jo[e]];
|
|
3001
3048
|
let t = this.isCollapsed ? this.messages.frontmatterExpandAriaLabel : this.messages.frontmatterCollapseAriaLabel;
|
|
3002
3049
|
this.toggleButton.setAttribute("aria-label", t), this.toggleButton.title = t, this.copyButton.setAttribute("aria-label", this.messages.frontmatterCopyAriaLabel), this.copyButton.title = this.messages.frontmatterCopyAriaLabel, this.deleteButton.setAttribute("aria-label", this.messages.frontmatterDeleteAriaLabel), this.deleteButton.title = this.messages.frontmatterDeleteAriaLabel;
|
|
3003
3050
|
}
|
|
@@ -3014,10 +3061,10 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3014
3061
|
destroy() {
|
|
3015
3062
|
this.stopObservingMessages(), this.toggleButton.removeEventListener("click", this.handleToggleClick), this.copyButton.removeEventListener("click", this.handleCopyClick), this.deleteButton.removeEventListener("click", this.handleDeleteClick), this.copyFeedbackTimer !== null && (clearTimeout(this.copyFeedbackTimer), this.copyFeedbackTimer = null);
|
|
3016
3063
|
}
|
|
3017
|
-
},
|
|
3064
|
+
}, ns = (e = U()) => (t, n, r) => new ts(t, n, typeof r == "function" ? () => {
|
|
3018
3065
|
let e = r();
|
|
3019
3066
|
return typeof e == "number" ? e : 0;
|
|
3020
|
-
} : !1, e),
|
|
3067
|
+
} : !1, e), rs = (e, t) => e(t.state, t.dispatch, t), is = (e, t) => {
|
|
3021
3068
|
let n = e?.state?.selection?.$from;
|
|
3022
3069
|
if (!n || !e?.dispatch) return !1;
|
|
3023
3070
|
for (let r = n.depth; r > 0; --r) {
|
|
@@ -3031,17 +3078,17 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3031
3078
|
})), !0;
|
|
3032
3079
|
}
|
|
3033
3080
|
return !1;
|
|
3034
|
-
},
|
|
3081
|
+
}, as = {
|
|
3035
3082
|
heading1: 1,
|
|
3036
3083
|
heading2: 2,
|
|
3037
3084
|
heading3: 3,
|
|
3038
3085
|
heading4: 4,
|
|
3039
3086
|
heading5: 5,
|
|
3040
3087
|
heading6: 6
|
|
3041
|
-
},
|
|
3088
|
+
}, os = {
|
|
3042
3089
|
bulletList: "bullet_list",
|
|
3043
3090
|
orderedList: "ordered_list"
|
|
3044
|
-
},
|
|
3091
|
+
}, ss = [
|
|
3045
3092
|
"codeBlock",
|
|
3046
3093
|
"heading1",
|
|
3047
3094
|
"heading2",
|
|
@@ -3054,35 +3101,35 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3054
3101
|
"bulletList",
|
|
3055
3102
|
"blockquote",
|
|
3056
3103
|
"paragraph"
|
|
3057
|
-
],
|
|
3104
|
+
], cs = (e, t) => {
|
|
3058
3105
|
if (!e?.state || !e?.dispatch) return !1;
|
|
3059
3106
|
let n = e.state.schema.nodes;
|
|
3060
3107
|
if (t === "paragraph") {
|
|
3061
3108
|
let t = n.paragraph;
|
|
3062
|
-
return t ?
|
|
3109
|
+
return t ? rs(xt(t), e) : !1;
|
|
3063
3110
|
}
|
|
3064
|
-
if (t in
|
|
3065
|
-
let r = n.heading, i =
|
|
3066
|
-
return !r || typeof i != "number" ? !1 :
|
|
3111
|
+
if (t in as) {
|
|
3112
|
+
let r = n.heading, i = as[t];
|
|
3113
|
+
return !r || typeof i != "number" ? !1 : rs(xt(r, { level: i }), e);
|
|
3067
3114
|
}
|
|
3068
3115
|
if (t === "blockquote") {
|
|
3069
3116
|
let t = n.blockquote;
|
|
3070
|
-
return t ?
|
|
3117
|
+
return t ? rs(Ct(t), e) : !1;
|
|
3071
3118
|
}
|
|
3072
3119
|
if (t === "taskList") {
|
|
3073
3120
|
let t = n.bullet_list;
|
|
3074
|
-
return !t || !
|
|
3121
|
+
return !t || !rs(Et(t), e) ? !1 : is(e, !1);
|
|
3075
3122
|
}
|
|
3076
3123
|
if (t === "codeBlock") {
|
|
3077
3124
|
let t = n.code_block;
|
|
3078
|
-
return t ?
|
|
3125
|
+
return t ? rs(xt(t, { language: "text" }), e) : !1;
|
|
3079
3126
|
}
|
|
3080
|
-
if (t in
|
|
3081
|
-
let r = n[
|
|
3082
|
-
return r ?
|
|
3127
|
+
if (t in os) {
|
|
3128
|
+
let r = n[os[t]];
|
|
3129
|
+
return r ? rs(Et(r), e) : !1;
|
|
3083
3130
|
}
|
|
3084
3131
|
return !1;
|
|
3085
|
-
},
|
|
3132
|
+
}, ls = (e) => {
|
|
3086
3133
|
let t = e.state.selection.$from, n = /* @__PURE__ */ new Set();
|
|
3087
3134
|
for (let e = t.depth; e > 0; --e) {
|
|
3088
3135
|
let r = t.node(e), i = r.type.name;
|
|
@@ -3121,10 +3168,10 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3121
3168
|
i === "paragraph" && n.add("paragraph");
|
|
3122
3169
|
}
|
|
3123
3170
|
return n.has("taskList") && n.delete("bulletList"), n.size === 0 && n.add("paragraph"), n;
|
|
3124
|
-
},
|
|
3125
|
-
let t =
|
|
3126
|
-
return
|
|
3127
|
-
},
|
|
3171
|
+
}, us = (e) => {
|
|
3172
|
+
let t = ls(e);
|
|
3173
|
+
return ss.find((e) => t.has(e)) || "paragraph";
|
|
3174
|
+
}, ds = /Mac|iPhone|iPad|iPod/, fs = {
|
|
3128
3175
|
paragraph: {
|
|
3129
3176
|
key: "p",
|
|
3130
3177
|
code: "KeyP",
|
|
@@ -3197,25 +3244,25 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3197
3244
|
key: "i",
|
|
3198
3245
|
code: "KeyI"
|
|
3199
3246
|
}
|
|
3200
|
-
},
|
|
3247
|
+
}, ps = (e) => Object.fromEntries(Object.entries(fs).map(([t, n]) => [t, n.modeOverrides?.[e] ?? n])), ms = {
|
|
3201
3248
|
Mod: "Ctrl",
|
|
3202
3249
|
Alt: "Alt",
|
|
3203
3250
|
Shift: "Shift"
|
|
3204
|
-
},
|
|
3251
|
+
}, hs = {
|
|
3205
3252
|
Mod: "⌘",
|
|
3206
3253
|
Alt: "⌥",
|
|
3207
3254
|
Shift: "⇧"
|
|
3208
|
-
},
|
|
3209
|
-
let t = e === "modAlt" ? "Mod-Alt" : "Mod-Shift", n =
|
|
3255
|
+
}, gs = () => typeof navigator < "u" && ds.test(navigator.platform), _s = (e) => {
|
|
3256
|
+
let t = e === "modAlt" ? "Mod-Alt" : "Mod-Shift", n = ps(e);
|
|
3210
3257
|
return Object.fromEntries(Object.entries(n).map(([e, n]) => [e, `${t}-${n.key}`]));
|
|
3211
|
-
},
|
|
3212
|
-
let t =
|
|
3258
|
+
}, vs = (e) => {
|
|
3259
|
+
let t = gs(), n = t ? hs : ms;
|
|
3213
3260
|
return e.split("-").map((e) => n[e] ?? e.toUpperCase()).join(t ? "" : "+");
|
|
3214
|
-
},
|
|
3215
|
-
let t =
|
|
3216
|
-
return Object.fromEntries(Object.entries(t).map(([e, t]) => [e,
|
|
3217
|
-
},
|
|
3218
|
-
let t =
|
|
3261
|
+
}, ys = (e) => {
|
|
3262
|
+
let t = _s(e);
|
|
3263
|
+
return Object.fromEntries(Object.entries(t).map(([e, t]) => [e, vs(t)]));
|
|
3264
|
+
}, bs = (e) => {
|
|
3265
|
+
let t = ys(e);
|
|
3219
3266
|
return {
|
|
3220
3267
|
paragraph: t.paragraph,
|
|
3221
3268
|
heading1: t.heading1,
|
|
@@ -3230,8 +3277,8 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3230
3277
|
blockquote: t.blockquote,
|
|
3231
3278
|
codeBlock: t.codeBlock
|
|
3232
3279
|
};
|
|
3233
|
-
},
|
|
3234
|
-
let n =
|
|
3280
|
+
}, xs = (e, t) => {
|
|
3281
|
+
let n = _s(t);
|
|
3235
3282
|
e.update(Re.key, (e) => ({
|
|
3236
3283
|
...e,
|
|
3237
3284
|
TurnIntoText: {
|
|
@@ -3295,13 +3342,13 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3295
3342
|
shortcuts: n.inlineCode
|
|
3296
3343
|
}
|
|
3297
3344
|
}));
|
|
3298
|
-
},
|
|
3299
|
-
let t =
|
|
3300
|
-
return
|
|
3345
|
+
}, Ss = (e) => {
|
|
3346
|
+
let t = _s(e).taskList;
|
|
3347
|
+
return ct("taskListTransform", { WrapInTaskList: {
|
|
3301
3348
|
shortcuts: t,
|
|
3302
|
-
command: () => (e, t, n) => n ?
|
|
3349
|
+
command: () => (e, t, n) => n ? cs(n, "taskList") : !1
|
|
3303
3350
|
} });
|
|
3304
|
-
},
|
|
3351
|
+
}, Cs = "zt-md-selection-tooltip", ws = (e) => [
|
|
3305
3352
|
{
|
|
3306
3353
|
command: "strong",
|
|
3307
3354
|
iconName: "Bold",
|
|
@@ -3332,124 +3379,124 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3332
3379
|
title: e.selectionTooltipLinkTitle,
|
|
3333
3380
|
markNames: ["link"]
|
|
3334
3381
|
}
|
|
3335
|
-
],
|
|
3382
|
+
], Y = {
|
|
3336
3383
|
paragraph: le,
|
|
3337
3384
|
heading1: E,
|
|
3338
3385
|
heading2: D,
|
|
3339
3386
|
heading3: O,
|
|
3340
3387
|
heading4: k,
|
|
3341
3388
|
heading5: A,
|
|
3342
|
-
heading6:
|
|
3343
|
-
bulletList:
|
|
3389
|
+
heading6: j,
|
|
3390
|
+
bulletList: re,
|
|
3344
3391
|
orderedList: ie,
|
|
3345
3392
|
taskList: M,
|
|
3346
3393
|
blockquote: se,
|
|
3347
3394
|
codeBlock: w
|
|
3348
|
-
},
|
|
3349
|
-
let n =
|
|
3395
|
+
}, Ts = (e, t) => {
|
|
3396
|
+
let n = bs(t);
|
|
3350
3397
|
return [
|
|
3351
3398
|
{
|
|
3352
3399
|
command: "paragraph",
|
|
3353
|
-
icon:
|
|
3400
|
+
icon: Y.paragraph,
|
|
3354
3401
|
label: e.selectionTooltipTransformParagraphLabel,
|
|
3355
3402
|
shortcut: n.paragraph
|
|
3356
3403
|
},
|
|
3357
3404
|
{
|
|
3358
3405
|
command: "heading1",
|
|
3359
|
-
icon:
|
|
3406
|
+
icon: Y.heading1,
|
|
3360
3407
|
label: e.selectionTooltipTransformHeading1Label,
|
|
3361
3408
|
shortcut: n.heading1
|
|
3362
3409
|
},
|
|
3363
3410
|
{
|
|
3364
3411
|
command: "heading2",
|
|
3365
|
-
icon:
|
|
3412
|
+
icon: Y.heading2,
|
|
3366
3413
|
label: e.selectionTooltipTransformHeading2Label,
|
|
3367
3414
|
shortcut: n.heading2
|
|
3368
3415
|
},
|
|
3369
3416
|
{
|
|
3370
3417
|
command: "heading3",
|
|
3371
|
-
icon:
|
|
3418
|
+
icon: Y.heading3,
|
|
3372
3419
|
label: e.selectionTooltipTransformHeading3Label,
|
|
3373
3420
|
shortcut: n.heading3
|
|
3374
3421
|
},
|
|
3375
3422
|
{
|
|
3376
3423
|
command: "heading4",
|
|
3377
|
-
icon:
|
|
3424
|
+
icon: Y.heading4,
|
|
3378
3425
|
label: e.selectionTooltipTransformHeading4Label,
|
|
3379
3426
|
shortcut: n.heading4
|
|
3380
3427
|
},
|
|
3381
3428
|
{
|
|
3382
3429
|
command: "heading5",
|
|
3383
|
-
icon:
|
|
3430
|
+
icon: Y.heading5,
|
|
3384
3431
|
label: e.selectionTooltipTransformHeading5Label,
|
|
3385
3432
|
shortcut: n.heading5
|
|
3386
3433
|
},
|
|
3387
3434
|
{
|
|
3388
3435
|
command: "heading6",
|
|
3389
|
-
icon:
|
|
3436
|
+
icon: Y.heading6,
|
|
3390
3437
|
label: e.selectionTooltipTransformHeading6Label,
|
|
3391
3438
|
shortcut: n.heading6
|
|
3392
3439
|
},
|
|
3393
3440
|
{
|
|
3394
3441
|
command: "bulletList",
|
|
3395
|
-
icon:
|
|
3442
|
+
icon: Y.bulletList,
|
|
3396
3443
|
label: e.selectionTooltipTransformBulletListLabel,
|
|
3397
3444
|
shortcut: n.bulletList
|
|
3398
3445
|
},
|
|
3399
3446
|
{
|
|
3400
3447
|
command: "orderedList",
|
|
3401
|
-
icon:
|
|
3448
|
+
icon: Y.orderedList,
|
|
3402
3449
|
label: e.selectionTooltipTransformOrderedListLabel,
|
|
3403
3450
|
shortcut: n.orderedList
|
|
3404
3451
|
},
|
|
3405
3452
|
{
|
|
3406
3453
|
command: "taskList",
|
|
3407
|
-
icon:
|
|
3454
|
+
icon: Y.taskList,
|
|
3408
3455
|
label: e.selectionTooltipTransformTaskListLabel,
|
|
3409
3456
|
shortcut: n.taskList
|
|
3410
3457
|
},
|
|
3411
3458
|
{
|
|
3412
3459
|
command: "blockquote",
|
|
3413
|
-
icon:
|
|
3460
|
+
icon: Y.blockquote,
|
|
3414
3461
|
label: e.selectionTooltipTransformBlockquoteLabel,
|
|
3415
3462
|
shortcut: n.blockquote
|
|
3416
3463
|
},
|
|
3417
3464
|
{
|
|
3418
3465
|
command: "codeBlock",
|
|
3419
|
-
icon:
|
|
3466
|
+
icon: Y.codeBlock,
|
|
3420
3467
|
label: e.selectionTooltipTransformCodeBlockLabel,
|
|
3421
3468
|
shortcut: n.codeBlock
|
|
3422
3469
|
}
|
|
3423
3470
|
];
|
|
3424
|
-
},
|
|
3471
|
+
}, Es = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, X = (e, t) => {
|
|
3425
3472
|
let n = e.state.schema.marks, r = t.find((e) => n[e]);
|
|
3426
3473
|
return r ? n[r] ?? null : null;
|
|
3427
|
-
},
|
|
3474
|
+
}, Ds = (e, t) => {
|
|
3428
3475
|
let { from: n, to: r } = e.selection;
|
|
3429
3476
|
return e.doc.rangeHasMark(n, r, t);
|
|
3430
|
-
},
|
|
3477
|
+
}, Os = (e, t) => {
|
|
3431
3478
|
let { from: n, to: r } = e.selection, i = "";
|
|
3432
3479
|
return e.doc.nodesBetween(n, r, (e) => {
|
|
3433
3480
|
let n = e.marks.find((e) => e.type === t);
|
|
3434
3481
|
return n ? (i = typeof n.attrs.href == "string" ? n.attrs.href : "", !1) : !0;
|
|
3435
3482
|
}), i;
|
|
3436
|
-
},
|
|
3437
|
-
|
|
3438
|
-
},
|
|
3483
|
+
}, ks = (e) => {
|
|
3484
|
+
St(e.markType)(e.view.state, e.view.dispatch, e.view), e.view.focus();
|
|
3485
|
+
}, As = (e) => {
|
|
3439
3486
|
e.toggleLinkPopover(e.view);
|
|
3440
|
-
},
|
|
3487
|
+
}, js = (e, t) => {
|
|
3441
3488
|
({
|
|
3442
|
-
strong:
|
|
3443
|
-
em:
|
|
3444
|
-
strike:
|
|
3445
|
-
inlineCode:
|
|
3446
|
-
link:
|
|
3489
|
+
strong: ks,
|
|
3490
|
+
em: ks,
|
|
3491
|
+
strike: ks,
|
|
3492
|
+
inlineCode: ks,
|
|
3493
|
+
link: As
|
|
3447
3494
|
})[e](t);
|
|
3448
|
-
},
|
|
3495
|
+
}, Ms = (e, t, n, r) => {
|
|
3449
3496
|
let i = document.createElement("button");
|
|
3450
3497
|
i.type = "button", i.className = "zt-md-selection-tooltip-button", i.dataset.command = e.command, i.title = e.title, i.setAttribute("aria-label", e.title);
|
|
3451
3498
|
let a = document.createElement("span");
|
|
3452
|
-
return a.className = "zt-md-selection-tooltip-button-icon", a.innerHTML =
|
|
3499
|
+
return a.className = "zt-md-selection-tooltip-button-icon", a.innerHTML = K(e.iconName, {
|
|
3453
3500
|
size: 14,
|
|
3454
3501
|
strokeWidth: 2
|
|
3455
3502
|
}), i.append(a), i.addEventListener("mousedown", (e) => {
|
|
@@ -3457,20 +3504,20 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3457
3504
|
}), i.addEventListener("click", (i) => {
|
|
3458
3505
|
i.preventDefault();
|
|
3459
3506
|
let a = n();
|
|
3460
|
-
!a || a.state.selection.empty ||
|
|
3507
|
+
!a || a.state.selection.empty || js(e.command, {
|
|
3461
3508
|
view: a,
|
|
3462
3509
|
markType: t,
|
|
3463
3510
|
toggleLinkPopover: r
|
|
3464
3511
|
});
|
|
3465
3512
|
}), i;
|
|
3466
|
-
},
|
|
3513
|
+
}, Ns = (e, t, n, r, i) => {
|
|
3467
3514
|
let a = document.createElement("div");
|
|
3468
3515
|
return a.className = "zt-md-selection-tooltip", a.append(i), t.forEach((t) => {
|
|
3469
|
-
let i =
|
|
3470
|
-
i && t.command !== "link" && a.append(
|
|
3516
|
+
let i = X(e, t.markNames);
|
|
3517
|
+
i && t.command !== "link" && a.append(Ms(t, i, n, r));
|
|
3471
3518
|
}), a;
|
|
3472
|
-
},
|
|
3473
|
-
let r =
|
|
3519
|
+
}, Ps = (e) => {
|
|
3520
|
+
let r = yo({
|
|
3474
3521
|
open: e.open,
|
|
3475
3522
|
portalContainer: e.portalContainer,
|
|
3476
3523
|
editorWrapper: e.collisionBoundary,
|
|
@@ -3486,7 +3533,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3486
3533
|
e.onOpenChange(!1);
|
|
3487
3534
|
return;
|
|
3488
3535
|
}
|
|
3489
|
-
|
|
3536
|
+
cs(n, t), e.onOpenChange(!1), n.focus();
|
|
3490
3537
|
};
|
|
3491
3538
|
return n(t, null, n("button", {
|
|
3492
3539
|
ref: r.triggerRef,
|
|
@@ -3507,7 +3554,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3507
3554
|
size: e.iconSize,
|
|
3508
3555
|
strokeWidth: e.iconStrokeWidth,
|
|
3509
3556
|
"aria-hidden": "true"
|
|
3510
|
-
})), n(
|
|
3557
|
+
})), n(bo, {
|
|
3511
3558
|
panel: r,
|
|
3512
3559
|
portalContainer: e.portalContainer,
|
|
3513
3560
|
className: "zt-md-selection-transform-popover !w-[224px] p-1",
|
|
@@ -3528,7 +3575,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3528
3575
|
"aria-hidden": "true"
|
|
3529
3576
|
}), n("span", { className: "zt-md-selection-transform-item-label" }, t.label), n("kbd", { className: "zt-md-selection-transform-item-shortcut" }, t.shortcut));
|
|
3530
3577
|
}))));
|
|
3531
|
-
},
|
|
3578
|
+
}, Fs = (e) => {
|
|
3532
3579
|
let [r, a] = c(""), o = s(null), l = (e) => {
|
|
3533
3580
|
e.preventDefault();
|
|
3534
3581
|
}, u = (t) => {
|
|
@@ -3537,25 +3584,25 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3537
3584
|
e.onOpenChange(!1);
|
|
3538
3585
|
return;
|
|
3539
3586
|
}
|
|
3540
|
-
let r =
|
|
3587
|
+
let r = X(n, ["link"]);
|
|
3541
3588
|
if (!r) {
|
|
3542
3589
|
e.onOpenChange(!1);
|
|
3543
3590
|
return;
|
|
3544
3591
|
}
|
|
3545
|
-
let i =
|
|
3592
|
+
let i = Xn(t), { from: a, to: o } = n.state.selection, s = n.state.tr.removeMark(a, o, r);
|
|
3546
3593
|
i && s.addMark(a, o, r.create({ href: i })), n.dispatch(s.scrollIntoView()), e.onOpenChange(!1), n.focus();
|
|
3547
3594
|
}, d = (t) => {
|
|
3548
3595
|
if (!t) {
|
|
3549
3596
|
e.onOpenChange(!1);
|
|
3550
3597
|
return;
|
|
3551
3598
|
}
|
|
3552
|
-
let n = e.getCurrentView(), r = n ?
|
|
3599
|
+
let n = e.getCurrentView(), r = n ? X(n, ["link"]) : null;
|
|
3553
3600
|
if (!n || !r || n.state.selection.empty) {
|
|
3554
3601
|
e.onOpenChange(!1);
|
|
3555
3602
|
return;
|
|
3556
3603
|
}
|
|
3557
|
-
a(
|
|
3558
|
-
}, f =
|
|
3604
|
+
a(Xn(Os(n.state, r))), e.onOpenChange(!0);
|
|
3605
|
+
}, f = yo({
|
|
3559
3606
|
open: e.open,
|
|
3560
3607
|
portalContainer: e.portalContainer,
|
|
3561
3608
|
editorWrapper: e.collisionBoundary,
|
|
@@ -3567,7 +3614,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3567
3614
|
});
|
|
3568
3615
|
return i(() => {
|
|
3569
3616
|
if (!e.open) return;
|
|
3570
|
-
let t = e.getCurrentView(), n = t ?
|
|
3617
|
+
let t = e.getCurrentView(), n = t ? X(t, ["link"]) : null;
|
|
3571
3618
|
(!t || !n || t.state.selection.empty) && e.onOpenChange(!1);
|
|
3572
3619
|
}, [
|
|
3573
3620
|
e.open,
|
|
@@ -3593,10 +3640,10 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3593
3640
|
}
|
|
3594
3641
|
f.updatePosition(), d(!0);
|
|
3595
3642
|
}
|
|
3596
|
-
}, n("span", { className: "zt-md-selection-tooltip-button-icon" }, n(
|
|
3643
|
+
}, n("span", { className: "zt-md-selection-tooltip-button-icon" }, n(ne, {
|
|
3597
3644
|
size: e.iconSize,
|
|
3598
3645
|
strokeWidth: e.iconStrokeWidth
|
|
3599
|
-
}))), n(
|
|
3646
|
+
}))), n(bo, {
|
|
3600
3647
|
panel: f,
|
|
3601
3648
|
portalContainer: e.portalContainer,
|
|
3602
3649
|
className: "zt-md-selection-link-popover w-fit min-w-0 gap-0 p-2"
|
|
@@ -3629,39 +3676,39 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3629
3676
|
size: e.iconSize,
|
|
3630
3677
|
strokeWidth: e.iconStrokeWidth
|
|
3631
3678
|
})))));
|
|
3632
|
-
},
|
|
3679
|
+
}, Is = (e, t, n) => {
|
|
3633
3680
|
n.forEach((n) => {
|
|
3634
|
-
let r =
|
|
3681
|
+
let r = X(t, n.markNames);
|
|
3635
3682
|
if (!r) return;
|
|
3636
3683
|
let i = e.querySelector(`[data-command="${n.command}"]`);
|
|
3637
|
-
i instanceof HTMLButtonElement && (i.dataset.active =
|
|
3684
|
+
i instanceof HTMLButtonElement && (i.dataset.active = Ds(t.state, r) ? "true" : "false");
|
|
3638
3685
|
});
|
|
3639
|
-
},
|
|
3686
|
+
}, Ls = (e) => {
|
|
3640
3687
|
let { from: t, to: n } = e.state.selection, r = !1;
|
|
3641
3688
|
return e.state.doc.nodesBetween(t, n, (e) => e.type.name === "code_block" ? (r = !0, !1) : !0), r;
|
|
3642
|
-
},
|
|
3689
|
+
}, Rs = (e, t, n) => (r) => {
|
|
3643
3690
|
let { selection: i, doc: a } = r.state, o = e.contains(document.activeElement);
|
|
3644
|
-
return !
|
|
3645
|
-
},
|
|
3691
|
+
return !Es(r) || i.empty || !(i instanceof z) || !r.hasFocus() && !o && !t() && !n() || Ls(r) ? !1 : e.childElementCount > 0 && a.textBetween(i.from, i.to).trim().length > 0;
|
|
3692
|
+
}, zs = (e) => {
|
|
3646
3693
|
let { $from: t } = e.state.selection;
|
|
3647
3694
|
for (let e = t.depth; e > 0; --e) {
|
|
3648
3695
|
let n = t.node(e).type.name;
|
|
3649
3696
|
if (n === "table" || n === "table_cell" || n === "table_header") return !0;
|
|
3650
3697
|
}
|
|
3651
3698
|
return !1;
|
|
3652
|
-
},
|
|
3653
|
-
let a =
|
|
3699
|
+
}, Bs = (e, t, r, i) => {
|
|
3700
|
+
let a = ws(r), o = Ts(r, i), s = e, c = !1, l = !1, u = !1, d = 0, f = "", p = document.createElement("span"), m = pt(p), h = document.createElement("span"), g = null, _ = pt(h), v = t.closest(".zt-md-editor"), y = (e) => {
|
|
3654
3701
|
c !== e && (c = e, C());
|
|
3655
3702
|
}, b = (e) => {
|
|
3656
3703
|
l !== e && (l = e, S());
|
|
3657
3704
|
}, x = (e) => {
|
|
3658
3705
|
e.state.selection.empty || y(!c);
|
|
3659
3706
|
}, S = () => {
|
|
3660
|
-
let e = s ?
|
|
3707
|
+
let e = s ? ls(s) : new Set(["paragraph"]), i = s ? us(s) : "paragraph", a = `${d}:${i}:${l}:${Array.from(e).sort().join(",")}`;
|
|
3661
3708
|
if (f === a) return;
|
|
3662
3709
|
f = a;
|
|
3663
3710
|
let c = o.find((e) => e.command === i) ?? o[0];
|
|
3664
|
-
m.render(n(
|
|
3711
|
+
m.render(n(Ps, {
|
|
3665
3712
|
getCurrentView: () => s,
|
|
3666
3713
|
portalContainer: t,
|
|
3667
3714
|
collisionBoundary: v,
|
|
@@ -3675,7 +3722,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3675
3722
|
activeCommands: e
|
|
3676
3723
|
}));
|
|
3677
3724
|
}, C = () => {
|
|
3678
|
-
_.render(n(
|
|
3725
|
+
_.render(n(Fs, {
|
|
3679
3726
|
getCurrentView: () => s,
|
|
3680
3727
|
portalContainer: t,
|
|
3681
3728
|
collisionBoundary: v,
|
|
@@ -3688,9 +3735,9 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3688
3735
|
onOpenChange: y,
|
|
3689
3736
|
messages: r
|
|
3690
3737
|
}));
|
|
3691
|
-
}, w =
|
|
3692
|
-
S(),
|
|
3693
|
-
let T =
|
|
3738
|
+
}, w = Ns(e, a, () => s, x, p);
|
|
3739
|
+
S(), X(e, ["link"]) && (w.append(h), C());
|
|
3740
|
+
let T = Rs(w, () => c, () => l), E = new bt({
|
|
3694
3741
|
content: w,
|
|
3695
3742
|
debounce: 80,
|
|
3696
3743
|
offset: 8,
|
|
@@ -3705,52 +3752,56 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3705
3752
|
E.onHide = O;
|
|
3706
3753
|
let k = () => {
|
|
3707
3754
|
y(!1), b(!1), E.hide(), O();
|
|
3708
|
-
}, A = (e) => e instanceof Node ? !!s?.dom.contains(e) || w.contains(e) || t.contains(e) : !1,
|
|
3755
|
+
}, A = (e) => e instanceof Node ? !!s?.dom.contains(e) || w.contains(e) || t.contains(e) : !1, j = () => {
|
|
3709
3756
|
requestAnimationFrame(() => {
|
|
3710
3757
|
u || A(document.activeElement) || k();
|
|
3711
3758
|
});
|
|
3712
|
-
},
|
|
3759
|
+
}, ee = (e) => {
|
|
3713
3760
|
A(e.target) || k();
|
|
3714
3761
|
};
|
|
3715
|
-
e.dom.addEventListener("blur",
|
|
3716
|
-
let
|
|
3717
|
-
d += 1, a =
|
|
3762
|
+
e.dom.addEventListener("blur", j), document.addEventListener("mousedown", ee, !0);
|
|
3763
|
+
let te = W(r, () => {
|
|
3764
|
+
d += 1, a = ws(r), o = Ts(r, i), a.forEach((e) => {
|
|
3718
3765
|
let t = w.querySelector(`[data-command="${e.command}"]`);
|
|
3719
3766
|
t && (t.title = e.title, t.setAttribute("aria-label", e.title));
|
|
3720
|
-
}), S(),
|
|
3767
|
+
}), S(), X(e, ["link"]) && C();
|
|
3721
3768
|
});
|
|
3722
3769
|
return {
|
|
3723
3770
|
update: (e, t) => {
|
|
3724
|
-
if (s = e, s.
|
|
3771
|
+
if (s = e, s.composing) {
|
|
3772
|
+
w.parentElement && k();
|
|
3773
|
+
return;
|
|
3774
|
+
}
|
|
3775
|
+
if (s.state.selection.empty && (y(!1), b(!1)), !T(s)) {
|
|
3725
3776
|
E.hide(), O();
|
|
3726
3777
|
return;
|
|
3727
3778
|
}
|
|
3728
|
-
let n =
|
|
3729
|
-
if (p.hidden = n, n ? b(!1) : S(),
|
|
3730
|
-
let e =
|
|
3731
|
-
g.dataset.active = e &&
|
|
3779
|
+
let n = zs(s);
|
|
3780
|
+
if (p.hidden = n, n ? b(!1) : S(), Is(w, s, a), g) {
|
|
3781
|
+
let e = X(s, ["link"]);
|
|
3782
|
+
g.dataset.active = e && Ds(s.state, e) ? "true" : "false";
|
|
3732
3783
|
}
|
|
3733
3784
|
D(), E.update(s, t);
|
|
3734
3785
|
},
|
|
3735
3786
|
destroy: () => {
|
|
3736
|
-
|
|
3787
|
+
te(), u = !0, s = null, e.dom.removeEventListener("blur", j), document.removeEventListener("mousedown", ee, !0), m.unmount(), _.unmount(), E.destroy(), w.remove();
|
|
3737
3788
|
}
|
|
3738
3789
|
};
|
|
3739
|
-
},
|
|
3740
|
-
key: new R(
|
|
3741
|
-
view: (r) =>
|
|
3742
|
-
})),
|
|
3790
|
+
}, Vs = (e, t, n) => B(() => new L({
|
|
3791
|
+
key: new R(Cs),
|
|
3792
|
+
view: (r) => Bs(r, e, t, n)
|
|
3793
|
+
})), Hs = (e, t) => e(t.state, t.dispatch, t), Us = (e) => {
|
|
3743
3794
|
let t = e?.state?.selection?.$from;
|
|
3744
3795
|
if (!t) return !1;
|
|
3745
3796
|
for (let e = t.depth; e > 0; --e) if (t.node(e)?.type?.name === "table") return !0;
|
|
3746
3797
|
return !1;
|
|
3747
|
-
},
|
|
3798
|
+
}, Ws = (e, t) => {
|
|
3748
3799
|
let n = e?.state?.doc;
|
|
3749
3800
|
if (!n || typeof t != "number") return -1;
|
|
3750
3801
|
let r = Math.min(Math.max(t, 0), n.content.size), i = n.resolve(r);
|
|
3751
3802
|
for (let e = i.depth; e > 0; --e) if (i.node(e)?.type?.name === "table") return i.before(e);
|
|
3752
3803
|
return -1;
|
|
3753
|
-
},
|
|
3804
|
+
}, Gs = (e, t, n, r) => {
|
|
3754
3805
|
let i = e?.state?.schema?.nodes;
|
|
3755
3806
|
if (!i) return null;
|
|
3756
3807
|
let a = i.table, o = i.table_header_row, s = i.table_row, c = i.table_header, l = i.table_cell;
|
|
@@ -3760,21 +3811,21 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3760
3811
|
return i.create(null, u);
|
|
3761
3812
|
});
|
|
3762
3813
|
return a.create(null, f);
|
|
3763
|
-
},
|
|
3764
|
-
if (!e?.state || !e?.dispatch ||
|
|
3765
|
-
let t = e.state.selection.from, n =
|
|
3814
|
+
}, Ks = (e) => {
|
|
3815
|
+
if (!e?.state || !e?.dispatch || Us(e)) return !1;
|
|
3816
|
+
let t = e.state.selection.from, n = Gs(e, 3, 3, !0);
|
|
3766
3817
|
if (!n) return !1;
|
|
3767
3818
|
e.dispatch(e.state.tr.replaceSelectionWith(n).scrollIntoView());
|
|
3768
|
-
let r =
|
|
3769
|
-
if (r < 0 && t > 0 && (r =
|
|
3819
|
+
let r = Ws(e, t);
|
|
3820
|
+
if (r < 0 && t > 0 && (r = Ws(e, t - 1)), r < 0) return !0;
|
|
3770
3821
|
let i = r + 2;
|
|
3771
3822
|
if (i > e.state.doc.content.size) return !0;
|
|
3772
3823
|
let a = z.near(e.state.doc.resolve(i), 1);
|
|
3773
3824
|
return e.dispatch(e.state.tr.setSelection(a).scrollIntoView()), e.focus(), !0;
|
|
3774
|
-
},
|
|
3825
|
+
}, qs = (e, t) => {
|
|
3775
3826
|
let n = e?.state?.schema?.marks ?? {}, r = t.find((e) => n[e]);
|
|
3776
3827
|
return r ? n[r] ?? null : null;
|
|
3777
|
-
},
|
|
3828
|
+
}, Js = new Set([
|
|
3778
3829
|
"paragraph",
|
|
3779
3830
|
"heading1",
|
|
3780
3831
|
"heading2",
|
|
@@ -3787,23 +3838,23 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3787
3838
|
"taskList",
|
|
3788
3839
|
"blockquote",
|
|
3789
3840
|
"codeBlock"
|
|
3790
|
-
]),
|
|
3841
|
+
]), Ys = (e) => Js.has(e), Xs = {
|
|
3791
3842
|
inlineCode: (e) => {
|
|
3792
|
-
let t =
|
|
3793
|
-
return t ?
|
|
3843
|
+
let t = qs(e, ["inlineCode", "code_inline"]);
|
|
3844
|
+
return t ? Hs(St(t), e) : !1;
|
|
3794
3845
|
},
|
|
3795
3846
|
inlineMath: (e) => {
|
|
3796
3847
|
let t = e?.state?.schema?.nodes?.math_inline;
|
|
3797
3848
|
if (!t || !e?.dispatch) return !1;
|
|
3798
3849
|
let n = e.state.selection.from, r = t.create({ value: "" });
|
|
3799
|
-
return e.dispatch(e.state.tr.replaceSelectionWith(r).setMeta(
|
|
3850
|
+
return e.dispatch(e.state.tr.replaceSelectionWith(r).setMeta(q, {
|
|
3800
3851
|
type: "open",
|
|
3801
3852
|
position: n
|
|
3802
3853
|
}).scrollIntoView()), !0;
|
|
3803
3854
|
},
|
|
3804
3855
|
mathBlock: (e) => {
|
|
3805
3856
|
let t = e.state.schema.nodes?.math_block;
|
|
3806
|
-
if (!t || !
|
|
3857
|
+
if (!t || !Hs(xt(t), e)) return !1;
|
|
3807
3858
|
let n = e.state.selection?.$from;
|
|
3808
3859
|
if (!n) return !0;
|
|
3809
3860
|
let r = null;
|
|
@@ -3815,8 +3866,8 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3815
3866
|
let i = I.create(e.state.doc, r);
|
|
3816
3867
|
return e.dispatch(e.state.tr.setSelection(i).scrollIntoView()), !0;
|
|
3817
3868
|
},
|
|
3818
|
-
table:
|
|
3819
|
-
},
|
|
3869
|
+
table: Ks
|
|
3870
|
+
}, Zs = (e, t) => !e?.state || !e?.dispatch ? !1 : Ys(t) ? cs(e, t) : t === "image" ? !1 : Xs[t](e), Qs = (e) => typeof e?.props?.editable == "function" ? e.props.editable(e.state) : !!e?.editable, $s = [
|
|
3820
3871
|
{
|
|
3821
3872
|
id: "paragraph",
|
|
3822
3873
|
label: "普通文本",
|
|
@@ -3936,7 +3987,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3936
3987
|
icon: "Image",
|
|
3937
3988
|
command: "image"
|
|
3938
3989
|
}
|
|
3939
|
-
],
|
|
3990
|
+
], ec = [
|
|
3940
3991
|
{
|
|
3941
3992
|
id: "paragraph",
|
|
3942
3993
|
label: "Paragraph",
|
|
@@ -4056,7 +4107,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4056
4107
|
icon: "Image",
|
|
4057
4108
|
command: "image"
|
|
4058
4109
|
}
|
|
4059
|
-
],
|
|
4110
|
+
], tc = (e, t = "zh-CN") => e?.items && e.items.length > 0 ? e.items : t === "en-US" ? ec : $s, nc = (e) => {
|
|
4060
4111
|
let t = e?.state?.selection?.$from;
|
|
4061
4112
|
if (!t) return !1;
|
|
4062
4113
|
let n = String(t.parent?.type?.name ?? "");
|
|
@@ -4066,17 +4117,17 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4066
4117
|
if (n === "table" || n === "table_cell" || n === "table_header") return !0;
|
|
4067
4118
|
}
|
|
4068
4119
|
return !1;
|
|
4069
|
-
},
|
|
4120
|
+
}, rc = (e) => {
|
|
4070
4121
|
let t = e?.state, n = t?.selection?.$from;
|
|
4071
4122
|
if (!t || !n) return "";
|
|
4072
4123
|
let r = n.start(), i = n.pos;
|
|
4073
4124
|
return t.doc.textBetween(r, i, "\n", "\n");
|
|
4074
|
-
},
|
|
4075
|
-
let t =
|
|
4125
|
+
}, ic = (e) => {
|
|
4126
|
+
let t = rc(e), n = t.lastIndexOf("/");
|
|
4076
4127
|
if (n < 0) return null;
|
|
4077
4128
|
let r = t.slice(n + 1);
|
|
4078
4129
|
return /\s/.test(r) ? null : r;
|
|
4079
|
-
},
|
|
4130
|
+
}, ac = (e, t) => {
|
|
4080
4131
|
if (t === null || t.length === 0) return e;
|
|
4081
4132
|
let n = t.toLowerCase();
|
|
4082
4133
|
return e.filter((e) => [
|
|
@@ -4085,27 +4136,27 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4085
4136
|
e.command,
|
|
4086
4137
|
e.id
|
|
4087
4138
|
].some((e) => String(e).toLowerCase().startsWith(n)));
|
|
4088
|
-
},
|
|
4089
|
-
if (!
|
|
4139
|
+
}, oc = (e, t) => {
|
|
4140
|
+
if (!Qs(e)) return {
|
|
4090
4141
|
visibleItems: [],
|
|
4091
4142
|
shouldShow: !1
|
|
4092
4143
|
};
|
|
4093
|
-
let n =
|
|
4144
|
+
let n = ic(e), r = ac(t, n);
|
|
4094
4145
|
return {
|
|
4095
4146
|
visibleItems: r,
|
|
4096
|
-
shouldShow: !
|
|
4147
|
+
shouldShow: !nc(e) && n !== null && r.length > 0
|
|
4097
4148
|
};
|
|
4098
|
-
},
|
|
4149
|
+
}, sc = (e) => {
|
|
4099
4150
|
let t = e?.state, n = t?.selection?.$from;
|
|
4100
4151
|
if (!t || !n || !e?.dispatch) return !1;
|
|
4101
4152
|
let r = n.start(), i = n.pos, a = t.doc.textBetween(r, i, "\n", "\n").lastIndexOf("/");
|
|
4102
4153
|
if (a < 0) return !1;
|
|
4103
4154
|
let o = r + a, s = t.tr.delete(o, i);
|
|
4104
4155
|
return e.dispatch(s.scrollIntoView()), !0;
|
|
4105
|
-
},
|
|
4156
|
+
}, cc = (e, t) => {
|
|
4106
4157
|
let n = t ? "true" : "false";
|
|
4107
4158
|
e.dataset.selected = n, e.setAttribute("aria-selected", n);
|
|
4108
|
-
},
|
|
4159
|
+
}, lc = (e, t, n, r) => {
|
|
4109
4160
|
e.innerHTML = "";
|
|
4110
4161
|
let i = [], a = "";
|
|
4111
4162
|
return t.forEach((t, o) => {
|
|
@@ -4114,9 +4165,9 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4114
4165
|
n.className = "slash-menu-group", n.textContent = t.group, e.appendChild(n), a = t.group;
|
|
4115
4166
|
}
|
|
4116
4167
|
let s = document.createElement("div");
|
|
4117
|
-
s.className = "slash-menu-item", s.setAttribute("role", "option"), s.dataset.command = t.command, s.dataset.index = String(o),
|
|
4168
|
+
s.className = "slash-menu-item", s.setAttribute("role", "option"), s.dataset.command = t.command, s.dataset.index = String(o), cc(s, o === n);
|
|
4118
4169
|
let c = document.createElement("span");
|
|
4119
|
-
c.className = "slash-menu-item-icon", t.icon && (c.innerHTML =
|
|
4170
|
+
c.className = "slash-menu-item-icon", t.icon && (c.innerHTML = K(Hn(t.icon, "Circle"), {
|
|
4120
4171
|
size: 16,
|
|
4121
4172
|
strokeWidth: 2
|
|
4122
4173
|
}));
|
|
@@ -4125,12 +4176,12 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4125
4176
|
let u = r[t.command], d = u ? document.createElement("kbd") : null;
|
|
4126
4177
|
d && (d.className = "slash-menu-item-shortcut", d.textContent = u), s.appendChild(c), s.appendChild(l), d && s.appendChild(d), e.appendChild(s), i.push(s);
|
|
4127
4178
|
}), i;
|
|
4128
|
-
},
|
|
4179
|
+
}, uc = (e, t) => {
|
|
4129
4180
|
let n = document.createElement("div");
|
|
4130
4181
|
n.className = "slash-menu", n.setAttribute("role", "listbox"), n.style.display = "none", e.appendChild(n);
|
|
4131
|
-
let r = !1, i = "", a = -1, o = [], s = !1, c = null, l =
|
|
4182
|
+
let r = !1, i = "", a = -1, o = [], s = !1, c = null, l = ys(t), u = () => {
|
|
4132
4183
|
if (!r || !c) return;
|
|
4133
|
-
let { editorWrapper: t, anchorTopInContent: i, anchorBottomInContent: a, anchorLeftInContent: o, placement: s, offsetY: l } = c, u =
|
|
4184
|
+
let { editorWrapper: t, anchorTopInContent: i, anchorBottomInContent: a, anchorLeftInContent: o, placement: s, offsetY: l } = c, u = go({
|
|
4134
4185
|
wrapper: t,
|
|
4135
4186
|
anchor: {
|
|
4136
4187
|
anchorTopInContent: i,
|
|
@@ -4143,7 +4194,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4143
4194
|
boundaryInset: 4
|
|
4144
4195
|
}, e);
|
|
4145
4196
|
n.style.left = `${u.left}px`, n.style.top = `${u.top}px`, n.dataset.placement = s;
|
|
4146
|
-
}, d =
|
|
4197
|
+
}, d = _o(() => {
|
|
4147
4198
|
r && u();
|
|
4148
4199
|
}), f = () => {
|
|
4149
4200
|
n.style.top = "", n.style.left = "", n.style.transform = "", delete n.dataset.placement;
|
|
@@ -4168,10 +4219,10 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4168
4219
|
e.icon
|
|
4169
4220
|
]));
|
|
4170
4221
|
if (i !== r) {
|
|
4171
|
-
o =
|
|
4222
|
+
o = lc(n, e, t, l), i = r, a = t;
|
|
4172
4223
|
return;
|
|
4173
4224
|
}
|
|
4174
|
-
a !== t && (a >= 0 && o[a] &&
|
|
4225
|
+
a !== t && (a >= 0 && o[a] && cc(o[a], !1), t >= 0 && o[t] && cc(o[t], !0), a = t);
|
|
4175
4226
|
},
|
|
4176
4227
|
scrollActiveItemIntoView: (e) => {
|
|
4177
4228
|
let t = o[a] ?? null;
|
|
@@ -4188,34 +4239,34 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4188
4239
|
d.destroy(), o = [], n.remove();
|
|
4189
4240
|
}
|
|
4190
4241
|
};
|
|
4191
|
-
},
|
|
4242
|
+
}, dc = (e, t) => {
|
|
4192
4243
|
if (!(!e || typeof e != "object")) return e[t];
|
|
4193
|
-
},
|
|
4194
|
-
if (typeof
|
|
4195
|
-
let e =
|
|
4244
|
+
}, fc = () => {
|
|
4245
|
+
if (typeof Dt != "function") return console.error("[zt-md/slash] slashFactory not found"), null;
|
|
4246
|
+
let e = Dt("zt-md-slash"), t = Array.isArray(e) ? e[0] : void 0, n = Array.isArray(e) ? e[1] : e, r = Array.isArray(e) ? e[2] : void 0;
|
|
4196
4247
|
if (!n) return null;
|
|
4197
|
-
let i = Array.isArray(e) ? e.filter((e, t) => t < 2 && e != null) : [n], a =
|
|
4248
|
+
let i = Array.isArray(e) ? e.filter((e, t) => t < 2 && e != null) : [n], a = dc(t, "key") ?? dc(n, "key") ?? dc(r, "key") ?? dc(e, "key");
|
|
4198
4249
|
return i.length === 0 || a === void 0 ? null : {
|
|
4199
4250
|
plugins: i,
|
|
4200
4251
|
key: a
|
|
4201
4252
|
};
|
|
4202
|
-
},
|
|
4253
|
+
}, pc = (e, t, n, r, i = "zh-CN", a = "modShift") => {
|
|
4203
4254
|
if (t?.enabled === !1) return {
|
|
4204
4255
|
plugins: [],
|
|
4205
4256
|
config: null
|
|
4206
4257
|
};
|
|
4207
4258
|
try {
|
|
4208
|
-
let o =
|
|
4259
|
+
let o = fc();
|
|
4209
4260
|
if (!o) return {
|
|
4210
4261
|
plugins: [],
|
|
4211
4262
|
config: null
|
|
4212
4263
|
};
|
|
4213
|
-
let s =
|
|
4264
|
+
let s = tc(t, i), c = uc(e, a), l = 0, u = null, d = s, f = !1, p = new Set([
|
|
4214
4265
|
"ArrowDown",
|
|
4215
4266
|
"ArrowUp",
|
|
4216
4267
|
"Enter",
|
|
4217
4268
|
"Escape"
|
|
4218
|
-
]), m = (e) => !p.has(e.key) || !f ? !1 : e.key === "ArrowDown" ? (e.preventDefault(), d.length === 0 ? !0 : (l = (l + 1) % d.length, c.renderIfNeeded(d, l), c.scrollActiveItemIntoView(() => {
|
|
4269
|
+
]), m = (e) => e.isComposing || !p.has(e.key) || !f ? !1 : e.key === "ArrowDown" ? (e.preventDefault(), d.length === 0 ? !0 : (l = (l + 1) % d.length, c.renderIfNeeded(d, l), c.scrollActiveItemIntoView(() => {
|
|
4219
4270
|
c.updatePosition();
|
|
4220
4271
|
}), !0)) : e.key === "ArrowUp" ? (e.preventDefault(), d.length === 0 ? !0 : (l = (l - 1 + d.length) % d.length, c.renderIfNeeded(d, l), c.scrollActiveItemIntoView(() => {
|
|
4221
4272
|
c.updatePosition();
|
|
@@ -4225,18 +4276,18 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4225
4276
|
let n = e?.coordsAtPos?.(t);
|
|
4226
4277
|
return n ? new DOMRect(n.left, n.top, Math.max(n.right - n.left, 1), n.bottom - n.top) : null;
|
|
4227
4278
|
}, g = (e) => {
|
|
4228
|
-
if (!
|
|
4279
|
+
if (!Qs(e)) {
|
|
4229
4280
|
d = [], f = !1, c.updatePositionContext(null), c.setVisible(!1);
|
|
4230
4281
|
return;
|
|
4231
4282
|
}
|
|
4232
|
-
let t =
|
|
4283
|
+
let t = oc(e, s);
|
|
4233
4284
|
if (d = t.visibleItems, f = t.shouldShow, t.shouldShow && l >= d.length && (l = 0), t.shouldShow && !c.isVisible() && (l = 0), !t.shouldShow) {
|
|
4234
4285
|
c.updatePositionContext(null), c.setVisible(!1);
|
|
4235
4286
|
return;
|
|
4236
4287
|
}
|
|
4237
|
-
let n = h(e), r =
|
|
4288
|
+
let n = h(e), r = uo(e?.dom);
|
|
4238
4289
|
if (n && r) {
|
|
4239
|
-
let e =
|
|
4290
|
+
let e = fo(n, 320), t = po(n, r);
|
|
4240
4291
|
c.updatePositionContext({
|
|
4241
4292
|
editorWrapper: r,
|
|
4242
4293
|
anchorTopInContent: t.anchorTopInContent,
|
|
@@ -4250,15 +4301,15 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4250
4301
|
c.updatePosition();
|
|
4251
4302
|
});
|
|
4252
4303
|
}, _ = () => {
|
|
4253
|
-
if (!
|
|
4304
|
+
if (!Qs(u)) {
|
|
4254
4305
|
f = !1, c.updatePositionContext(null), c.setVisible(!1);
|
|
4255
4306
|
return;
|
|
4256
4307
|
}
|
|
4257
4308
|
if (!u || l < 0 || l >= d.length) return;
|
|
4258
4309
|
let t = d[l];
|
|
4259
|
-
if (
|
|
4310
|
+
if (sc(u)) {
|
|
4260
4311
|
if (t.command === "image") {
|
|
4261
|
-
c.setVisible(!1), n &&
|
|
4312
|
+
c.setVisible(!1), n && mi({
|
|
4262
4313
|
portalContainer: e,
|
|
4263
4314
|
view: u,
|
|
4264
4315
|
messages: n,
|
|
@@ -4266,7 +4317,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4266
4317
|
});
|
|
4267
4318
|
return;
|
|
4268
4319
|
}
|
|
4269
|
-
|
|
4320
|
+
Zs(u, t.command) && (c.setVisible(!1), t.command === "mathBlock" && queueMicrotask(() => {
|
|
4270
4321
|
let e = u?.dom?.querySelector?.(".zt-md-math-block-editing .zt-md-math-block-textarea");
|
|
4271
4322
|
!e || document.activeElement === e || e.focus();
|
|
4272
4323
|
}));
|
|
@@ -4289,7 +4340,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4289
4340
|
props: { handleKeyDown: (e, t) => m(t) },
|
|
4290
4341
|
view: () => ({
|
|
4291
4342
|
update: (e) => {
|
|
4292
|
-
u = e, g(e);
|
|
4343
|
+
u = e, !e?.composing && g(e);
|
|
4293
4344
|
},
|
|
4294
4345
|
destroy: () => {
|
|
4295
4346
|
u = null, f = !1, c.destroy();
|
|
@@ -4300,8 +4351,8 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4300
4351
|
updateLocale: (e) => {
|
|
4301
4352
|
if (i === e) return;
|
|
4302
4353
|
let n = d[l]?.command;
|
|
4303
|
-
if (i = e, s =
|
|
4304
|
-
let e =
|
|
4354
|
+
if (i = e, s = tc(t, i), u) {
|
|
4355
|
+
let e = oc(u, s).visibleItems;
|
|
4305
4356
|
l = Math.max(0, e.findIndex((e) => e.command === n)), g(u);
|
|
4306
4357
|
}
|
|
4307
4358
|
}
|
|
@@ -4312,36 +4363,36 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4312
4363
|
config: null
|
|
4313
4364
|
};
|
|
4314
4365
|
}
|
|
4315
|
-
},
|
|
4366
|
+
}, mc = /Mac|iPhone|iPad|iPod/, hc = (e, t) => (typeof navigator < "u" && mc.test(navigator.platform) ? e.metaKey && !e.ctrlKey : e.ctrlKey && !e.metaKey) ? t === "modAlt" ? e.altKey && !e.shiftKey : e.shiftKey && !e.altKey : !1, gc = (e, t, n, r) => (mi({
|
|
4316
4367
|
portalContainer: t,
|
|
4317
4368
|
view: e,
|
|
4318
4369
|
messages: n,
|
|
4319
4370
|
imageUpload: r
|
|
4320
|
-
}), !0),
|
|
4321
|
-
let i =
|
|
4371
|
+
}), !0), _c = (e, t, n, r) => {
|
|
4372
|
+
let i = ps(n), a = Object.fromEntries(Object.entries(i).map(([e, t]) => [t.code, e]));
|
|
4322
4373
|
return (i, o) => {
|
|
4323
|
-
if (o.isComposing || !
|
|
4374
|
+
if (o.isComposing || !hc(o, n) || !Qs(i)) return !1;
|
|
4324
4375
|
let s = a[o.code];
|
|
4325
4376
|
if (!s) return !1;
|
|
4326
|
-
let c = s === "image" ?
|
|
4377
|
+
let c = s === "image" ? gc(i, e, t, r) : Zs(i, s);
|
|
4327
4378
|
return c && o.preventDefault(), c;
|
|
4328
4379
|
};
|
|
4329
|
-
},
|
|
4380
|
+
}, vc = "table", yc = "ArrowUp", bc = (e) => e.key !== yc || e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey, xc = (e, t) => {
|
|
4330
4381
|
let n = t.nodeBefore;
|
|
4331
|
-
return !n || n.type.name !==
|
|
4382
|
+
return !n || n.type.name !== vc ? null : {
|
|
4332
4383
|
tableNode: n,
|
|
4333
4384
|
tableStart: e - n.nodeSize
|
|
4334
4385
|
};
|
|
4335
|
-
},
|
|
4386
|
+
}, Sc = (e) => {
|
|
4336
4387
|
if (e.parent.type.name !== "paragraph" || e.parentOffset !== 0 || e.parent.childCount > 0 || e.depth < 1) return null;
|
|
4337
4388
|
let t = e.index(e.depth - 1);
|
|
4338
4389
|
if (t <= 0) return null;
|
|
4339
4390
|
let n = e.node(e.depth - 1).child(t - 1);
|
|
4340
|
-
return n.type.name ===
|
|
4391
|
+
return n.type.name === vc ? {
|
|
4341
4392
|
tableNode: n,
|
|
4342
4393
|
tableStart: e.before(e.depth) - n.nodeSize
|
|
4343
4394
|
} : null;
|
|
4344
|
-
},
|
|
4395
|
+
}, Cc = (e, t) => {
|
|
4345
4396
|
if (e.childCount === 0) return null;
|
|
4346
4397
|
let n = e.childCount - 1, r = e.child(n);
|
|
4347
4398
|
if (r.childCount === 0) return null;
|
|
@@ -4350,21 +4401,21 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4350
4401
|
let a = r.childCount - 1, o = r.child(a), s = 0;
|
|
4351
4402
|
for (let e = 0; e < a; e += 1) s += r.child(e).nodeSize;
|
|
4352
4403
|
return t + 1 + i + 1 + s + o.nodeSize - 1;
|
|
4353
|
-
},
|
|
4404
|
+
}, wc = (e) => {
|
|
4354
4405
|
let { selection: t } = e.state, n = t.$from, r = null;
|
|
4355
|
-
if (t instanceof
|
|
4356
|
-
let i =
|
|
4406
|
+
if (t instanceof dt ? r = xc(t.from, n) : t.empty && (r = Sc(n)), !r) return !1;
|
|
4407
|
+
let i = Cc(r.tableNode, r.tableStart);
|
|
4357
4408
|
if (i === null) return !1;
|
|
4358
4409
|
let a = e.state.tr.setSelection(z.near(e.state.doc.resolve(i), -1)).scrollIntoView();
|
|
4359
4410
|
return e.dispatch(a), e.focus(), !0;
|
|
4360
|
-
},
|
|
4411
|
+
}, Tc = B(() => new L({
|
|
4361
4412
|
key: new R("zt-md-table-arrow-entry"),
|
|
4362
|
-
props: { handleKeyDown: (e, t) =>
|
|
4363
|
-
})),
|
|
4413
|
+
props: { handleKeyDown: (e, t) => bc(t) ? !1 : wc(e) }
|
|
4414
|
+
})), Ec = "table", Dc = "table_header_row", Oc = "table_row", kc = "table_header", Ac = "table_cell", Z = (e) => {
|
|
4364
4415
|
let t = e.selection.$from, n = -1, r = -1;
|
|
4365
4416
|
for (let e = t.depth; e >= 0; --e) {
|
|
4366
4417
|
let i = t.node(e);
|
|
4367
|
-
if (r < 0 && (i.type.name ===
|
|
4418
|
+
if (r < 0 && (i.type.name === Ac || i.type.name === kc) && (r = t.index(e - 1)), n < 0 && (i.type.name === Oc || i.type.name === Dc) && (n = t.index(e - 1)), i.type.name === Ec) return {
|
|
4368
4419
|
tableNode: i,
|
|
4369
4420
|
tableStart: e === 0 ? 0 : t.before(e),
|
|
4370
4421
|
tableNodeSize: i.nodeSize,
|
|
@@ -4373,7 +4424,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4373
4424
|
};
|
|
4374
4425
|
}
|
|
4375
4426
|
return null;
|
|
4376
|
-
},
|
|
4427
|
+
}, jc = (e, t, n, r) => {
|
|
4377
4428
|
if (n < 0 || n >= e.childCount) return null;
|
|
4378
4429
|
let i = 0;
|
|
4379
4430
|
for (let t = 0; t < n; t += 1) i += e.child(t).nodeSize;
|
|
@@ -4382,18 +4433,18 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4382
4433
|
let o = 0;
|
|
4383
4434
|
for (let e = 0; e < r; e += 1) o += a.child(e).nodeSize;
|
|
4384
4435
|
return t + 1 + i + 1 + o + 1 + 1;
|
|
4385
|
-
},
|
|
4436
|
+
}, Mc = (e) => {
|
|
4386
4437
|
if (e.columnIndex < 0 || e.tableNode.childCount === 0) return !1;
|
|
4387
4438
|
let t = e.tableNode.child(0);
|
|
4388
4439
|
return e.columnIndex < t.childCount;
|
|
4389
|
-
},
|
|
4390
|
-
let i =
|
|
4440
|
+
}, Nc = (e, t, n, r) => {
|
|
4441
|
+
let i = jc(t.tableNode, t.tableStart, n, r);
|
|
4391
4442
|
if (i === null) return !1;
|
|
4392
4443
|
let a = e.state.tr.setSelection(z.near(e.state.tr.doc.resolve(i), 1));
|
|
4393
4444
|
return e.dispatch(a), !0;
|
|
4394
|
-
},
|
|
4445
|
+
}, Pc = (e, t) => t(e.state, e.dispatch, e) ? (e.dispatch(e.state.tr.scrollIntoView()), e.focus(), !0) : !1, Fc = (e, t, n) => t.rowIndex < 0 || t.columnIndex < 0 || !Nc(e, t, t.rowIndex, t.columnIndex) ? !1 : Pc(e, n === "above" ? Mt : jt), Ic = (e, t) => t.rowIndex <= 0 || t.columnIndex < 0 || !Nc(e, t, t.rowIndex, t.columnIndex) ? !1 : Pc(e, Pt), Lc = (e, t, n) => t.rowIndex < 0 || t.columnIndex < 0 || !Nc(e, t, t.rowIndex, t.columnIndex) ? !1 : Pc(e, n === "left" ? At : kt), Rc = (e, t) => t.rowIndex < 0 || t.columnIndex < 0 || (t.tableNode.childCount > 0 ? t.tableNode.child(0).childCount : 0) <= 1 || !Nc(e, t, t.rowIndex, t.columnIndex) ? !1 : Pc(e, Nt), zc = (e, t, n) => {
|
|
4395
4446
|
if (t.columnIndex < 0) return !1;
|
|
4396
|
-
let r =
|
|
4447
|
+
let r = Ot.get(t.tableNode), i = t.tableStart + 1, a = t.columnIndex, o = e.state.tr;
|
|
4397
4448
|
for (let e = 0; e < r.height; e += 1) {
|
|
4398
4449
|
let t = e * r.width + a, s = r.map[t];
|
|
4399
4450
|
if (typeof s != "number") continue;
|
|
@@ -4406,14 +4457,14 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4406
4457
|
o.setNodeMarkup(c, l.type, u, l.marks);
|
|
4407
4458
|
}
|
|
4408
4459
|
return o.docChanged ? (o.scrollIntoView(), e.dispatch(o), e.focus(), !0) : !1;
|
|
4409
|
-
},
|
|
4410
|
-
let t =
|
|
4411
|
-
!t || t.rowIndex <= 0 ||
|
|
4412
|
-
},
|
|
4413
|
-
let t =
|
|
4414
|
-
!t || t.rowIndex < 0 || t.columnIndex < 0 ||
|
|
4415
|
-
},
|
|
4416
|
-
let [r, i] = c(!1), a =
|
|
4460
|
+
}, Bc = (e) => {
|
|
4461
|
+
let t = Z(e.state);
|
|
4462
|
+
!t || t.rowIndex <= 0 || Ic(e, t);
|
|
4463
|
+
}, Vc = (e) => {
|
|
4464
|
+
let t = Z(e.state);
|
|
4465
|
+
!t || t.rowIndex < 0 || t.columnIndex < 0 || Rc(e, t);
|
|
4466
|
+
}, Hc = (e) => {
|
|
4467
|
+
let [r, i] = c(!1), a = yo({
|
|
4417
4468
|
open: r,
|
|
4418
4469
|
portalContainer: e.portalContainer,
|
|
4419
4470
|
editorWrapper: e.collisionBoundary,
|
|
@@ -4501,7 +4552,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4501
4552
|
size: 15,
|
|
4502
4553
|
strokeWidth: 2,
|
|
4503
4554
|
"aria-hidden": "true"
|
|
4504
|
-
})), n(
|
|
4555
|
+
})), n(bo, {
|
|
4505
4556
|
panel: a,
|
|
4506
4557
|
portalContainer: e.portalContainer,
|
|
4507
4558
|
className: "zt-md-table-action-popover",
|
|
@@ -4510,27 +4561,27 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4510
4561
|
className: "zt-md-table-action-menu-divider",
|
|
4511
4562
|
"aria-hidden": "true"
|
|
4512
4563
|
}), n("div", { className: "zt-md-table-action-menu-group" }, ...d.map(f))));
|
|
4513
|
-
},
|
|
4564
|
+
}, Uc = "zt-md-table-focus-actions", Wc = 8, Gc = 8, Kc = "left", qc = K("Trash2", {
|
|
4514
4565
|
size: 15,
|
|
4515
4566
|
strokeWidth: 2
|
|
4516
|
-
}),
|
|
4567
|
+
}), Jc = K("AlignLeft", {
|
|
4517
4568
|
size: 15,
|
|
4518
4569
|
strokeWidth: 2
|
|
4519
|
-
}),
|
|
4570
|
+
}), Yc = K("AlignCenter", {
|
|
4520
4571
|
size: 15,
|
|
4521
4572
|
strokeWidth: 2
|
|
4522
|
-
}),
|
|
4573
|
+
}), Xc = K("AlignRight", {
|
|
4523
4574
|
size: 15,
|
|
4524
4575
|
strokeWidth: 2
|
|
4525
|
-
}),
|
|
4576
|
+
}), Zc = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, Qc = (e) => {
|
|
4526
4577
|
let { selection: t, doc: n } = e.state;
|
|
4527
4578
|
return t.empty || !(t instanceof z) ? !1 : n.textBetween(t.from, t.to).trim().length > 0;
|
|
4528
|
-
},
|
|
4579
|
+
}, $c = () => {
|
|
4529
4580
|
let e = document.createElement("span");
|
|
4530
4581
|
return e.className = "zt-md-table-actions-divider", e.setAttribute("aria-hidden", "true"), e;
|
|
4531
|
-
},
|
|
4582
|
+
}, el = (e, t, n) => t < 0 || n < 0 ? null : e.rows.item(t)?.cells.item(n) ?? null, tl = class {
|
|
4532
4583
|
constructor(e, t, n) {
|
|
4533
|
-
this.isAttached = !1, this.messageVersion = 0, this.lastMoreActionsKey = "", this.currentTableStart = null, this.currentTableNodeSize = null, this.currentColumnIndex = null, this.currentColumnAlignment =
|
|
4584
|
+
this.isAttached = !1, this.messageVersion = 0, this.lastMoreActionsKey = "", this.currentTableStart = null, this.currentTableNodeSize = null, this.currentColumnIndex = null, this.currentColumnAlignment = Kc, this.currentAnchorElement = null, this.currentTableWrapper = null, this.hasPositionContext = !1, this.repositionScheduler = _o(() => {
|
|
4534
4585
|
this.hasPositionContext && this.updateOverlayPosition();
|
|
4535
4586
|
}), this.handleActionsMouseDown = (e) => {
|
|
4536
4587
|
e.preventDefault();
|
|
@@ -4547,20 +4598,20 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4547
4598
|
}, this.handleAlignRightClick = () => {
|
|
4548
4599
|
this.applyColumnAlignment("right");
|
|
4549
4600
|
}, this.handleInsertRowBelow = () => {
|
|
4550
|
-
let e =
|
|
4551
|
-
!e || e.rowIndex < 0 ||
|
|
4601
|
+
let e = Z(this.view.state);
|
|
4602
|
+
!e || e.rowIndex < 0 || Fc(this.view, e, "below");
|
|
4552
4603
|
}, this.handleInsertRowAbove = () => {
|
|
4553
|
-
let e =
|
|
4554
|
-
!e || e.rowIndex <= 0 ||
|
|
4604
|
+
let e = Z(this.view.state);
|
|
4605
|
+
!e || e.rowIndex <= 0 || Fc(this.view, e, "above");
|
|
4555
4606
|
}, this.handleInsertColumnLeft = () => {
|
|
4556
4607
|
this.insertColumn("left");
|
|
4557
4608
|
}, this.handleInsertColumnRight = () => {
|
|
4558
4609
|
this.insertColumn("right");
|
|
4559
4610
|
}, this.handleDeleteRow = () => {
|
|
4560
|
-
|
|
4611
|
+
Bc(this.view);
|
|
4561
4612
|
}, this.handleDeleteColumn = () => {
|
|
4562
|
-
|
|
4563
|
-
}, this.view = e, this.messages = t, this.portalContainer = n, this.editorWrapper =
|
|
4613
|
+
Vc(this.view);
|
|
4614
|
+
}, this.view = e, this.messages = t, this.portalContainer = n, this.editorWrapper = uo(e.dom), this.actionsContainer = document.createElement("div"), this.actionsContainer.className = "zt-md-table-actions-overlay", this.deleteButton = document.createElement("button"), this.deleteButton.type = "button", this.deleteButton.className = "zt-md-table-action-button zt-md-table-action-button-danger", this.deleteButton.style.display = "inline-flex", this.deleteButton.setAttribute("aria-label", t.tableDeleteAriaLabel), this.deleteButton.innerHTML = qc, this.alignLeftButton = this.createColumnAlignmentButton(t.tableAlignLeftAriaLabel, Jc), this.alignCenterButton = this.createColumnAlignmentButton(t.tableAlignCenterAriaLabel, Yc), this.alignRightButton = this.createColumnAlignmentButton(t.tableAlignRightAriaLabel, Xc), this.moreActionsMount = document.createElement("span"), this.moreActionsMount.className = "zt-md-table-more-actions-mount", this.moreActionsRoot = pt(this.moreActionsMount), this.actionsContainer.append(this.moreActionsMount, $c(), this.alignLeftButton, this.alignCenterButton, this.alignRightButton, $c(), this.deleteButton), this.actionsContainer.addEventListener("mousedown", this.handleActionsMouseDown), this.deleteButton.addEventListener("click", this.handleDeleteClick), this.alignLeftButton.addEventListener("click", this.handleAlignLeftClick), this.alignCenterButton.addEventListener("click", this.handleAlignCenterClick), this.alignRightButton.addEventListener("click", this.handleAlignRightClick), this.update(e), this.stopObservingMessages = W(t, () => {
|
|
4564
4615
|
this.messageVersion += 1, this.deleteButton.setAttribute("aria-label", t.tableDeleteAriaLabel), this.alignLeftButton.setAttribute("aria-label", t.tableAlignLeftAriaLabel), this.alignCenterButton.setAttribute("aria-label", t.tableAlignCenterAriaLabel), this.alignRightButton.setAttribute("aria-label", t.tableAlignRightAriaLabel), this.isAttached && this.update(this.view);
|
|
4565
4616
|
});
|
|
4566
4617
|
}
|
|
@@ -4576,22 +4627,22 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4576
4627
|
return n.type = "button", n.className = "zt-md-table-action-button", n.style.display = "inline-flex", n.setAttribute("aria-label", e), n.innerHTML = t, n;
|
|
4577
4628
|
}
|
|
4578
4629
|
resolveColumnAlignment(e) {
|
|
4579
|
-
return e === "center" || e === "right" ? e :
|
|
4630
|
+
return e === "center" || e === "right" ? e : Kc;
|
|
4580
4631
|
}
|
|
4581
4632
|
updateAlignmentButtonsState(e) {
|
|
4582
4633
|
this.alignLeftButton.disabled = !e, this.alignCenterButton.disabled = !e, this.alignRightButton.disabled = !e, this.alignLeftButton.classList.toggle("zt-md-table-action-button-active", e && this.currentColumnAlignment === "left"), this.alignCenterButton.classList.toggle("zt-md-table-action-button-active", e && this.currentColumnAlignment === "center"), this.alignRightButton.classList.toggle("zt-md-table-action-button-active", e && this.currentColumnAlignment === "right");
|
|
4583
4634
|
}
|
|
4584
4635
|
applyColumnAlignment(e) {
|
|
4585
|
-
let t =
|
|
4586
|
-
!t || t.rowIndex < 0 || t.columnIndex < 0 ||
|
|
4636
|
+
let t = Z(this.view.state);
|
|
4637
|
+
!t || t.rowIndex < 0 || t.columnIndex < 0 || zc(this.view, t, e);
|
|
4587
4638
|
}
|
|
4588
4639
|
insertColumn(e) {
|
|
4589
|
-
let t =
|
|
4590
|
-
!t || t.rowIndex < 0 || t.columnIndex < 0 ||
|
|
4640
|
+
let t = Z(this.view.state);
|
|
4641
|
+
!t || t.rowIndex < 0 || t.columnIndex < 0 || Lc(this.view, t, e);
|
|
4591
4642
|
}
|
|
4592
4643
|
renderMoreActions(e, t, r, i) {
|
|
4593
4644
|
let a = `${this.messageVersion}:${e}:${t}:${r}:${i}`;
|
|
4594
|
-
this.lastMoreActionsKey !== a && (this.lastMoreActionsKey = a, this.moreActionsRoot.render(n(
|
|
4645
|
+
this.lastMoreActionsKey !== a && (this.lastMoreActionsKey = a, this.moreActionsRoot.render(n(Hc, {
|
|
4595
4646
|
messages: this.messages,
|
|
4596
4647
|
portalContainer: this.portalContainer,
|
|
4597
4648
|
collisionBoundary: this.editorWrapper,
|
|
@@ -4623,23 +4674,24 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4623
4674
|
if (!this.editorWrapper || !this.currentAnchorElement || this.actionsContainer.parentElement !== this.portalContainer) return;
|
|
4624
4675
|
let e = this.resolveActionsContainerSize();
|
|
4625
4676
|
if (!e) return;
|
|
4626
|
-
let t = this.currentAnchorElement.getBoundingClientRect(), n = this.editorWrapper.getBoundingClientRect(), r = t.top - n.top, i = n.bottom - t.bottom, a = r >= e.height +
|
|
4677
|
+
let t = this.currentAnchorElement.getBoundingClientRect(), n = this.editorWrapper.getBoundingClientRect(), r = t.top - n.top, i = n.bottom - t.bottom, a = r >= e.height + Wc + Gc || r >= i ? "top" : "bottom", o = po(t, this.editorWrapper, n), s = go({
|
|
4627
4678
|
wrapper: this.editorWrapper,
|
|
4628
4679
|
anchor: o,
|
|
4629
4680
|
overlaySize: e,
|
|
4630
4681
|
placement: a,
|
|
4631
4682
|
horizontalAlign: "center",
|
|
4632
|
-
offsetY:
|
|
4633
|
-
boundaryInset:
|
|
4683
|
+
offsetY: Wc,
|
|
4684
|
+
boundaryInset: Gc
|
|
4634
4685
|
}, this.portalContainer, n);
|
|
4635
4686
|
this.actionsContainer.style.left = `${s.left}px`, this.actionsContainer.style.top = `${s.top}px`;
|
|
4636
4687
|
}
|
|
4637
4688
|
update(e) {
|
|
4638
|
-
if (this.view = e,
|
|
4689
|
+
if (this.view = e, e.composing) return;
|
|
4690
|
+
if (!this.editorWrapper || !Zc(e) || Qc(e)) {
|
|
4639
4691
|
this.detach();
|
|
4640
4692
|
return;
|
|
4641
4693
|
}
|
|
4642
|
-
let t =
|
|
4694
|
+
let t = Z(e.state);
|
|
4643
4695
|
if (!t) {
|
|
4644
4696
|
this.detach();
|
|
4645
4697
|
return;
|
|
@@ -4656,102 +4708,102 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4656
4708
|
}
|
|
4657
4709
|
let i = this.isAttached;
|
|
4658
4710
|
this.isAttached || (this.isAttached = !0, this.repositionScheduler.bindGlobal(), this.repositionScheduler.bindWrapper(this.editorWrapper)), this.actionsContainer.parentElement !== this.portalContainer && this.portalContainer.append(this.actionsContainer);
|
|
4659
|
-
let a =
|
|
4660
|
-
this.currentColumnIndex = a ? t.columnIndex : null, this.currentColumnAlignment = this.resolveColumnAlignment(this.currentColumnIndex === null ? null : l?.maybeChild(this.currentColumnIndex)?.attrs?.alignment), this.updateAlignmentButtonsState(a), this.renderMoreActions(s, a, c, o), this.bindTableWrapperScroll(r), this.currentAnchorElement =
|
|
4711
|
+
let a = Mc(t), o = a && t.tableNode.child(0).childCount > 1, s = t.rowIndex > 0, c = t.rowIndex > 0, l = t.tableNode.childCount > 0 ? t.tableNode.child(0) : null;
|
|
4712
|
+
this.currentColumnIndex = a ? t.columnIndex : null, this.currentColumnAlignment = this.resolveColumnAlignment(this.currentColumnIndex === null ? null : l?.maybeChild(this.currentColumnIndex)?.attrs?.alignment), this.updateAlignmentButtonsState(a), this.renderMoreActions(s, a, c, o), this.bindTableWrapperScroll(r), this.currentAnchorElement = el(r, t.rowIndex, t.columnIndex) ?? r, this.currentTableStart = t.tableStart, this.currentTableNodeSize = t.tableNodeSize, this.hasPositionContext = !0, i ? this.repositionScheduler.schedule() : this.updateOverlayPosition();
|
|
4661
4713
|
}
|
|
4662
4714
|
detach() {
|
|
4663
|
-
this.isAttached && (this.isAttached = !1, this.repositionScheduler.unbindGlobal(), this.repositionScheduler.bindWrapper(null), this.unbindTableWrapperScroll(), this.lastMoreActionsKey = "", this.moreActionsRoot.render(null), this.actionsContainer.remove(), this.currentAnchorElement = null, this.currentTableStart = null, this.currentTableNodeSize = null, this.currentColumnIndex = null, this.currentColumnAlignment =
|
|
4715
|
+
this.isAttached && (this.isAttached = !1, this.repositionScheduler.unbindGlobal(), this.repositionScheduler.bindWrapper(null), this.unbindTableWrapperScroll(), this.lastMoreActionsKey = "", this.moreActionsRoot.render(null), this.actionsContainer.remove(), this.currentAnchorElement = null, this.currentTableStart = null, this.currentTableNodeSize = null, this.currentColumnIndex = null, this.currentColumnAlignment = Kc, this.updateAlignmentButtonsState(!1), this.hasPositionContext = !1);
|
|
4664
4716
|
}
|
|
4665
4717
|
destroy() {
|
|
4666
4718
|
this.stopObservingMessages(), this.detach(), this.repositionScheduler.destroy(), this.moreActionsRoot.unmount(), this.actionsContainer.removeEventListener("mousedown", this.handleActionsMouseDown), this.deleteButton.removeEventListener("click", this.handleDeleteClick), this.alignLeftButton.removeEventListener("click", this.handleAlignLeftClick), this.alignCenterButton.removeEventListener("click", this.handleAlignCenterClick), this.alignRightButton.removeEventListener("click", this.handleAlignRightClick);
|
|
4667
4719
|
}
|
|
4668
|
-
},
|
|
4720
|
+
}, nl = (e, t) => {
|
|
4669
4721
|
let n = t ?? U();
|
|
4670
|
-
return
|
|
4671
|
-
key: new R(
|
|
4672
|
-
view: (t) => new
|
|
4722
|
+
return B(() => new L({
|
|
4723
|
+
key: new R(Uc),
|
|
4724
|
+
view: (t) => new tl(t, n, e)
|
|
4673
4725
|
}));
|
|
4674
|
-
},
|
|
4726
|
+
}, rl = "list_item", il = "li[data-item-type=\"task\"]", al = 24, ol = (e, t) => {
|
|
4675
4727
|
let n = t.getBoundingClientRect();
|
|
4676
|
-
return e.clientX >= n.left && e.clientX <= n.left +
|
|
4677
|
-
},
|
|
4728
|
+
return e.clientX >= n.left && e.clientX <= n.left + al && e.clientY >= n.top && e.clientY <= n.top + al;
|
|
4729
|
+
}, sl = (e) => {
|
|
4678
4730
|
if (!(e instanceof Element)) return null;
|
|
4679
|
-
let t = e.closest(
|
|
4731
|
+
let t = e.closest(il);
|
|
4680
4732
|
return t instanceof HTMLElement ? t : null;
|
|
4681
|
-
},
|
|
4733
|
+
}, cl = (e, t) => {
|
|
4682
4734
|
if (!e.editable) return !1;
|
|
4683
|
-
let n =
|
|
4684
|
-
return !n || !
|
|
4685
|
-
},
|
|
4735
|
+
let n = sl(t.target);
|
|
4736
|
+
return !n || !ol(t, n) ? !1 : (t.preventDefault(), !0);
|
|
4737
|
+
}, ll = (e, t) => {
|
|
4686
4738
|
let n = e.posAtDOM(t, 0) - 1, r = e.state.doc.nodeAt(n);
|
|
4687
|
-
return !r || r.type.name !==
|
|
4739
|
+
return !r || r.type.name !== rl || r.attrs.checked == null ? !1 : (e.dispatch(e.state.tr.setNodeMarkup(n, void 0, {
|
|
4688
4740
|
...r.attrs,
|
|
4689
4741
|
checked: !r.attrs.checked
|
|
4690
4742
|
})), !0);
|
|
4691
|
-
},
|
|
4692
|
-
mousedown: (e, t) =>
|
|
4693
|
-
dblclick: (e, t) =>
|
|
4743
|
+
}, ul = B(() => new L({ props: { handleDOMEvents: {
|
|
4744
|
+
mousedown: (e, t) => cl(e, t),
|
|
4745
|
+
dblclick: (e, t) => cl(e, t),
|
|
4694
4746
|
click: (e, t) => {
|
|
4695
4747
|
if (!e.editable) return !1;
|
|
4696
|
-
let n =
|
|
4697
|
-
return !n || !
|
|
4748
|
+
let n = sl(t.target);
|
|
4749
|
+
return !n || !ol(t, n) || !ll(e, n) ? !1 : (t.preventDefault(), !0);
|
|
4698
4750
|
}
|
|
4699
|
-
} } })),
|
|
4751
|
+
} } })), dl = "Tab", fl = 4, pl = /^ */, ml = "list_item", hl = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, gl = (e) => {
|
|
4700
4752
|
let { $from: t } = e.selection;
|
|
4701
4753
|
for (let e = t.depth; e >= 0; --e) {
|
|
4702
4754
|
let n = t.node(e);
|
|
4703
|
-
if (n.type.name ===
|
|
4755
|
+
if (n.type.name === ml) return n.type;
|
|
4704
4756
|
}
|
|
4705
4757
|
return null;
|
|
4706
|
-
},
|
|
4758
|
+
}, _l = (e) => {
|
|
4707
4759
|
let { selection: t, doc: n } = e;
|
|
4708
4760
|
if (t.empty) return [t.$from.start()];
|
|
4709
4761
|
let r = /* @__PURE__ */ new Set();
|
|
4710
4762
|
return n.nodesBetween(t.from, t.to, (e, t) => {
|
|
4711
4763
|
e.isTextblock && r.add(t + 1);
|
|
4712
4764
|
}), Array.from(r);
|
|
4713
|
-
},
|
|
4714
|
-
let { state: n } = e, r = " ".repeat(
|
|
4765
|
+
}, vl = (e, t) => {
|
|
4766
|
+
let { state: n } = e, r = " ".repeat(fl), i = _l(n).sort((e, t) => t - e), a = n.tr;
|
|
4715
4767
|
return n.selection.empty ? a.insertText(r, n.selection.to) : i.forEach((e) => {
|
|
4716
4768
|
a.insertText(r, e);
|
|
4717
4769
|
}), a.docChanged ? (t.preventDefault(), e.dispatch(a), !0) : !1;
|
|
4718
|
-
},
|
|
4770
|
+
}, yl = (e, t) => {
|
|
4719
4771
|
let { state: n } = e, { selection: r } = n;
|
|
4720
4772
|
if (!(r instanceof z)) return !1;
|
|
4721
|
-
let i =
|
|
4773
|
+
let i = _l(n).sort((e, t) => t - e), a = n.tr;
|
|
4722
4774
|
return i.forEach((e) => {
|
|
4723
|
-
let t = n.doc.resolve(e).parent.textContent.match(
|
|
4775
|
+
let t = n.doc.resolve(e).parent.textContent.match(pl)?.[0].length ?? 0, r = Math.min(t, fl);
|
|
4724
4776
|
r <= 0 || a.delete(e, e + r);
|
|
4725
4777
|
}), a.docChanged ? (t.preventDefault(), e.dispatch(a), !0) : !1;
|
|
4726
|
-
},
|
|
4778
|
+
}, bl = B(() => new L({
|
|
4727
4779
|
key: new R("zt-md-tab-space-indent"),
|
|
4728
4780
|
props: { handleKeyDown: (e, t) => {
|
|
4729
4781
|
let n = e;
|
|
4730
|
-
if (!
|
|
4731
|
-
let r =
|
|
4782
|
+
if (!hl(n) || t.defaultPrevented || t.key !== dl || t.altKey || t.ctrlKey || t.metaKey) return !1;
|
|
4783
|
+
let r = gl(n.state);
|
|
4732
4784
|
if (r) {
|
|
4733
|
-
let e = (t.shiftKey ?
|
|
4785
|
+
let e = (t.shiftKey ? wt(r) : Tt(r))(n.state, n.dispatch);
|
|
4734
4786
|
return t.preventDefault(), e || !0;
|
|
4735
4787
|
}
|
|
4736
|
-
return t.shiftKey ?
|
|
4788
|
+
return t.shiftKey ? yl(n, t) : vl(n, t);
|
|
4737
4789
|
} }
|
|
4738
|
-
})),
|
|
4790
|
+
})), xl = (e) => {
|
|
4739
4791
|
let t = (e instanceof Element ? e : e.parentElement)?.closest("code");
|
|
4740
4792
|
return t instanceof HTMLElement && !t.closest("pre") ? t : null;
|
|
4741
|
-
},
|
|
4793
|
+
}, Sl = (e, t, n) => xl(e.domAtPos(t, n).node), Cl = (e) => {
|
|
4742
4794
|
let t = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), n = t.nextNode(), r = null;
|
|
4743
4795
|
for (; n;) n.data.length > 0 && (r = n), n = t.nextNode();
|
|
4744
4796
|
return r;
|
|
4745
|
-
},
|
|
4797
|
+
}, wl = (e, t, n) => {
|
|
4746
4798
|
let r = e.domAtPos(t, n);
|
|
4747
4799
|
e.dom.ownerDocument.getSelection()?.collapse(r.node, r.offset);
|
|
4748
|
-
},
|
|
4749
|
-
let n = e.domAtPos(t, -1), r =
|
|
4800
|
+
}, Tl = (e, t) => {
|
|
4801
|
+
let n = e.domAtPos(t, -1), r = xl(n.node), i = e.dom.ownerDocument.getSelection();
|
|
4750
4802
|
if (!r) {
|
|
4751
4803
|
i?.collapse(n.node, n.offset);
|
|
4752
4804
|
return;
|
|
4753
4805
|
}
|
|
4754
|
-
let a =
|
|
4806
|
+
let a = Cl(r);
|
|
4755
4807
|
if (!a) {
|
|
4756
4808
|
let e = r.childNodes.length;
|
|
4757
4809
|
i?.collapse(r, e);
|
|
@@ -4759,7 +4811,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4759
4811
|
}
|
|
4760
4812
|
let o = a.data.length;
|
|
4761
4813
|
i?.collapse(a, o);
|
|
4762
|
-
},
|
|
4814
|
+
}, El = {
|
|
4763
4815
|
left: {
|
|
4764
4816
|
inwardKey: "ArrowRight",
|
|
4765
4817
|
outwardKey: "ArrowLeft"
|
|
@@ -4768,13 +4820,13 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4768
4820
|
inwardKey: "ArrowLeft",
|
|
4769
4821
|
outwardKey: "ArrowRight"
|
|
4770
4822
|
}
|
|
4771
|
-
},
|
|
4823
|
+
}, Dl = {
|
|
4772
4824
|
left: "nodeAfter",
|
|
4773
4825
|
right: "nodeBefore"
|
|
4774
|
-
},
|
|
4826
|
+
}, Ol = (e, t) => {
|
|
4775
4827
|
e.dispatch(e.state.tr.setMeta(t, null));
|
|
4776
|
-
},
|
|
4777
|
-
if (t.key === "ArrowRight") return
|
|
4828
|
+
}, kl = (e, t, n, r, i) => {
|
|
4829
|
+
if (t.key === "ArrowRight") return Ol(e, i), !1;
|
|
4778
4830
|
if (t.key !== "ArrowLeft") return !1;
|
|
4779
4831
|
t.preventDefault();
|
|
4780
4832
|
let a = (e.state.storedMarks ?? e.state.selection.$from.marks()).filter((e) => e.type !== n);
|
|
@@ -4782,35 +4834,35 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4782
4834
|
...r,
|
|
4783
4835
|
placement: "outside"
|
|
4784
4836
|
})), !0;
|
|
4785
|
-
},
|
|
4786
|
-
if (r.placement === "inside") return
|
|
4787
|
-
let a =
|
|
4788
|
-
if (t.key === a.outwardKey) return
|
|
4837
|
+
}, Al = (e, t, n, r, i) => {
|
|
4838
|
+
if (r.placement === "inside") return kl(e, t, n, r, i);
|
|
4839
|
+
let a = El[r.side];
|
|
4840
|
+
if (t.key === a.outwardKey) return Ol(e, i), !1;
|
|
4789
4841
|
if (t.key !== a.inwardKey) return !1;
|
|
4790
|
-
let o =
|
|
4791
|
-
if (!c) return
|
|
4842
|
+
let o = Dl[r.side], s = e.state.selection.$from[o], c = s ? n.isInSet(s.marks) : null;
|
|
4843
|
+
if (!c) return Ol(e, i), !1;
|
|
4792
4844
|
t.preventDefault();
|
|
4793
4845
|
let l = e.state.storedMarks ?? e.state.selection.$from.marks(), u = c.addToSet(l);
|
|
4794
4846
|
return e.dispatch(e.state.tr.setSelection(z.create(e.state.doc, r.position)).setStoredMarks(u).setMeta(i, r.side === "left" ? {
|
|
4795
4847
|
...r,
|
|
4796
4848
|
placement: "inside"
|
|
4797
|
-
} : null)), r.side === "right" &&
|
|
4798
|
-
}, Q = (e, t) => !!t.isInSet(e),
|
|
4849
|
+
} : null)), r.side === "right" && Tl(e, r.position), !0;
|
|
4850
|
+
}, Q = (e, t) => !!t.isInSet(e), jl = (e, t, n) => {
|
|
4799
4851
|
let r = e.state.doc.resolve(t), i = r.nodeBefore, a = r.nodeAfter;
|
|
4800
4852
|
return !a || Q(i?.marks ?? [], n) || !Q(a.marks, n) ? null : n.isInSet(a.marks);
|
|
4801
|
-
},
|
|
4853
|
+
}, Ml = (e, t, n) => {
|
|
4802
4854
|
let r = e.state.doc.resolve(t), i = r.nodeBefore, a = r.nodeAfter;
|
|
4803
4855
|
return !i || !Q(i.marks, n) || Q(a?.marks ?? [], n) ? null : n.isInSet(i.marks);
|
|
4804
|
-
}, $ = new R("zt-md-inline-code-boundary-navigation"),
|
|
4856
|
+
}, $ = new R("zt-md-inline-code-boundary-navigation"), Nl = "inlineCode", Pl = 2, Fl = (e, t, n, r) => {
|
|
4805
4857
|
let i = t > 0 ? [t, t - 1] : [t];
|
|
4806
4858
|
for (let [t, a] of i.entries()) {
|
|
4807
|
-
let i =
|
|
4859
|
+
let i = Ml(e, a, r);
|
|
4808
4860
|
if (!i) continue;
|
|
4809
4861
|
let o = e.state.doc.resolve(a).nodeAfter;
|
|
4810
4862
|
if (o !== null && !o.isText) continue;
|
|
4811
|
-
let s =
|
|
4863
|
+
let s = Sl(e, a, -1);
|
|
4812
4864
|
if (!s) continue;
|
|
4813
|
-
let c = n <= s.getBoundingClientRect().right +
|
|
4865
|
+
let c = n <= s.getBoundingClientRect().right + Pl;
|
|
4814
4866
|
if (!(t > 0 && !c)) return {
|
|
4815
4867
|
boundaryPosition: a,
|
|
4816
4868
|
inlineCodeMark: i,
|
|
@@ -4819,76 +4871,76 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4819
4871
|
};
|
|
4820
4872
|
}
|
|
4821
4873
|
return null;
|
|
4822
|
-
},
|
|
4874
|
+
}, Il = (e, t) => {
|
|
4823
4875
|
if (t.button !== 0 || t.altKey || t.ctrlKey || t.metaKey || t.shiftKey || !e.editable) return !1;
|
|
4824
4876
|
let n = e.posAtCoords({
|
|
4825
4877
|
left: t.clientX,
|
|
4826
4878
|
top: t.clientY
|
|
4827
|
-
}), r = e.state.schema.marks[
|
|
4879
|
+
}), r = e.state.schema.marks[Nl];
|
|
4828
4880
|
if (!n || !r) return !1;
|
|
4829
|
-
let i = n.pos, a = e.state.doc.resolve(i), o =
|
|
4881
|
+
let i = n.pos, a = e.state.doc.resolve(i), o = jl(e, i, r), s = a.nodeBefore;
|
|
4830
4882
|
if (o && (!s || s.isText)) {
|
|
4831
|
-
let n =
|
|
4883
|
+
let n = Sl(e, i, 1);
|
|
4832
4884
|
if (!n) return !1;
|
|
4833
4885
|
let c = n.getBoundingClientRect(), l = t.clientX >= c.left, u = (s?.marks ?? a.marks()).filter((e) => e.type !== r), d = l ? o.addToSet(a.marks()) : u, f = l ? {
|
|
4834
4886
|
position: i,
|
|
4835
4887
|
side: "left",
|
|
4836
4888
|
placement: "inside"
|
|
4837
4889
|
} : null;
|
|
4838
|
-
return t.preventDefault(), e.dispatch(e.state.tr.setSelection(z.create(e.state.doc, i)).setStoredMarks(d).setMeta($, f)), e.focus(), l ||
|
|
4890
|
+
return t.preventDefault(), e.dispatch(e.state.tr.setSelection(z.create(e.state.doc, i)).setStoredMarks(d).setMeta($, f)), e.focus(), l || wl(e, i, -1), !0;
|
|
4839
4891
|
}
|
|
4840
|
-
let c =
|
|
4892
|
+
let c = Fl(e, i, t.clientX, r);
|
|
4841
4893
|
if (!c) return !1;
|
|
4842
4894
|
let l = c.boundaryPosition, u = e.state.doc.resolve(l), d = c.codeElement.getBoundingClientRect(), f = t.clientX >= d.right, p = (c.rightPlainTextNode?.marks ?? u.marks()).filter((e) => e.type !== r), m = f ? p : c.inlineCodeMark.addToSet(u.marks()), h = f ? {
|
|
4843
4895
|
position: l,
|
|
4844
4896
|
side: "right",
|
|
4845
4897
|
placement: "outside"
|
|
4846
4898
|
} : null;
|
|
4847
|
-
return t.preventDefault(), e.dispatch(e.state.tr.setSelection(z.create(e.state.doc, l)).setStoredMarks(m).setMeta($, h)), e.focus(), f ||
|
|
4848
|
-
},
|
|
4899
|
+
return t.preventDefault(), e.dispatch(e.state.tr.setSelection(z.create(e.state.doc, l)).setStoredMarks(m).setMeta($, h)), e.focus(), f || Tl(e, l), !0;
|
|
4900
|
+
}, Ll = "inlineCode", Rl = "zt-md-inline-code-boundary-indicator", zl = "zt-md-inline-code-boundary-indicator-widget", Bl = "zt-md-inline-code-boundary-active", Vl = {
|
|
4849
4901
|
left: -1,
|
|
4850
4902
|
right: 1
|
|
4851
|
-
},
|
|
4903
|
+
}, Hl = {
|
|
4852
4904
|
left: 1,
|
|
4853
4905
|
right: -1
|
|
4854
|
-
},
|
|
4906
|
+
}, Ul = (e) => {
|
|
4855
4907
|
let t = document.createElement("span");
|
|
4856
|
-
return t.className =
|
|
4857
|
-
},
|
|
4908
|
+
return t.className = Rl, t.dataset.side = e.side, t.dataset.placement = e.placement, t.contentEditable = "false", t.setAttribute("aria-hidden", "true"), t;
|
|
4909
|
+
}, Wl = (e, t) => {
|
|
4858
4910
|
if (t.placement === "outside") return [];
|
|
4859
|
-
let n = e.schema.marks[
|
|
4911
|
+
let n = e.schema.marks[Ll], r = e.doc.resolve(t.position).nodeAfter, i = r && n ? n.isInSet(r.marks) : null;
|
|
4860
4912
|
return i ? [i] : null;
|
|
4861
|
-
},
|
|
4913
|
+
}, Gl = (e) => {
|
|
4862
4914
|
let t = $.getState(e);
|
|
4863
|
-
if (!t) return
|
|
4864
|
-
let n =
|
|
4865
|
-
if (!n) return
|
|
4866
|
-
let r = t.placement === "inside" ? 1 :
|
|
4915
|
+
if (!t) return rt.empty;
|
|
4916
|
+
let n = Wl(e, t);
|
|
4917
|
+
if (!n) return rt.empty;
|
|
4918
|
+
let r = t.placement === "inside" ? 1 : Vl[t.side], i = Ul(t), a = nt.widget(t.position, i, {
|
|
4867
4919
|
side: r,
|
|
4868
4920
|
marks: n,
|
|
4869
|
-
key: `${
|
|
4921
|
+
key: `${zl}-${t.side}-${t.placement}`,
|
|
4870
4922
|
ignoreSelection: !0,
|
|
4871
4923
|
relaxedSide: !0
|
|
4872
4924
|
});
|
|
4873
|
-
return
|
|
4874
|
-
},
|
|
4925
|
+
return rt.create(e.doc, [a]);
|
|
4926
|
+
}, Kl = (e, t) => {
|
|
4875
4927
|
if (t?.placement !== "outside") return;
|
|
4876
|
-
let n = e.dom.querySelector(`.${
|
|
4928
|
+
let n = e.dom.querySelector(`.${Rl}[data-side='${t.side}'][data-placement='outside']`), r = Hl[t.side], i = Sl(e, t.position, r);
|
|
4877
4929
|
if (!n || !i) return;
|
|
4878
4930
|
let a = n.getBoundingClientRect().left, o = i.getBoundingClientRect(), s = t.side === "left" ? o.left - 1 : o.right + 1, c = Math.round(s - a);
|
|
4879
4931
|
n.style.setProperty("--zt-md-inline-code-boundary-offset-x", `${c}px`);
|
|
4880
|
-
},
|
|
4932
|
+
}, ql = "inlineCode", Jl = (e, t) => {
|
|
4881
4933
|
let { selection: n } = e.state;
|
|
4882
4934
|
if (!n.empty) return !1;
|
|
4883
4935
|
let r = n.$from.nodeBefore, i = n.$from.nodeAfter;
|
|
4884
4936
|
return !!(r && Q(r.marks, t) && (!i || !Q(i.marks, t)));
|
|
4885
|
-
},
|
|
4937
|
+
}, Yl = (e, t) => {
|
|
4886
4938
|
let { selection: n } = e.state;
|
|
4887
4939
|
if (!n.empty) return !1;
|
|
4888
4940
|
let r = n.$from.nodeBefore, i = n.$from.nodeAfter;
|
|
4889
4941
|
return !!(i && Q(i.marks, t) && (!r || !Q(r.marks, t)));
|
|
4890
|
-
},
|
|
4891
|
-
let r =
|
|
4942
|
+
}, Xl = (e, t, n) => {
|
|
4943
|
+
let r = jl(e, t, n);
|
|
4892
4944
|
if (!r) return !1;
|
|
4893
4945
|
let i = e.state.storedMarks ?? e.state.doc.resolve(t).marks(), a = r.addToSet(i);
|
|
4894
4946
|
return e.dispatch(e.state.tr.setSelection(z.create(e.state.doc, t)).setStoredMarks(a).setMeta($, {
|
|
@@ -4896,14 +4948,14 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4896
4948
|
side: "left",
|
|
4897
4949
|
placement: "inside"
|
|
4898
4950
|
})), !0;
|
|
4899
|
-
},
|
|
4951
|
+
}, Zl = (e, t) => t.defaultPrevented || t.altKey || t.ctrlKey || t.metaKey || t.shiftKey || !e.editable, Ql = (e, t) => {
|
|
4900
4952
|
let { selection: n } = e.state;
|
|
4901
4953
|
if (!n.empty) return null;
|
|
4902
4954
|
let r = n.$from.nodeBefore;
|
|
4903
4955
|
return !r || !Q(r.marks, t) ? null : Array.from(r.textContent).length === 1 ? n.from - r.nodeSize : null;
|
|
4904
|
-
},
|
|
4956
|
+
}, $l = (e, t, n) => {
|
|
4905
4957
|
if (t.key !== "ArrowLeft") return !1;
|
|
4906
|
-
let r =
|
|
4958
|
+
let r = Ql(e, n);
|
|
4907
4959
|
if (r === null) return !1;
|
|
4908
4960
|
let i = e.state.storedMarks ?? e.state.selection.$from.marks();
|
|
4909
4961
|
return Q(i, n) ? (t.preventDefault(), e.dispatch(e.state.tr.setSelection(z.create(e.state.doc, r)).setStoredMarks(i).setMeta($, {
|
|
@@ -4911,120 +4963,120 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4911
4963
|
side: "left",
|
|
4912
4964
|
placement: "inside"
|
|
4913
4965
|
})), !0) : !1;
|
|
4914
|
-
},
|
|
4915
|
-
if (!
|
|
4966
|
+
}, eu = (e, t, n) => {
|
|
4967
|
+
if (!Yl(e, n)) return !1;
|
|
4916
4968
|
let r = e.state.storedMarks ?? e.state.selection.$from.marks();
|
|
4917
|
-
if (!Q(r, n)) return
|
|
4969
|
+
if (!Q(r, n)) return su(e), !1;
|
|
4918
4970
|
t.preventDefault();
|
|
4919
4971
|
let i = r.filter((e) => e.type !== n);
|
|
4920
4972
|
return e.dispatch(e.state.tr.setStoredMarks(i).setMeta($, {
|
|
4921
4973
|
position: e.state.selection.from,
|
|
4922
4974
|
side: "left",
|
|
4923
4975
|
placement: "outside"
|
|
4924
|
-
})),
|
|
4925
|
-
},
|
|
4926
|
-
if (t.key !== "ArrowLeft" || !
|
|
4976
|
+
})), wl(e, e.state.selection.from, -1), !0;
|
|
4977
|
+
}, tu = (e, t, n) => {
|
|
4978
|
+
if (t.key !== "ArrowLeft" || !Jl(e, n)) return !1;
|
|
4927
4979
|
let r = e.state.storedMarks ?? e.state.selection.$from.marks();
|
|
4928
4980
|
return Q(r, n) ? !1 : (t.preventDefault(), e.dispatch(e.state.tr.setStoredMarks(r).setMeta($, {
|
|
4929
4981
|
position: e.state.selection.from,
|
|
4930
4982
|
side: "right",
|
|
4931
4983
|
placement: "outside"
|
|
4932
|
-
})),
|
|
4933
|
-
},
|
|
4984
|
+
})), wl(e, e.state.selection.from, 1), !0);
|
|
4985
|
+
}, nu = (e, t) => {
|
|
4934
4986
|
let { selection: n } = e.state;
|
|
4935
4987
|
if (!n.empty) return null;
|
|
4936
4988
|
let r = n.$from.nodeBefore;
|
|
4937
4989
|
if (!r?.isText || Q(r.marks, t) || Array.from(r.textContent).length !== 1) return null;
|
|
4938
4990
|
let i = n.from - r.nodeSize;
|
|
4939
|
-
return
|
|
4940
|
-
},
|
|
4991
|
+
return Ml(e, i, t) ? i : null;
|
|
4992
|
+
}, ru = (e, t, n) => {
|
|
4941
4993
|
if (t.key !== "ArrowLeft") return !1;
|
|
4942
|
-
let r =
|
|
4994
|
+
let r = nu(e, n);
|
|
4943
4995
|
if (r === null) return !1;
|
|
4944
4996
|
let i = (e.state.selection.$from.nodeBefore?.marks ?? []).filter((e) => e.type !== n);
|
|
4945
4997
|
return t.preventDefault(), e.dispatch(e.state.tr.setSelection(z.create(e.state.doc, r)).setStoredMarks(i).setMeta($, {
|
|
4946
4998
|
position: r,
|
|
4947
4999
|
side: "right",
|
|
4948
5000
|
placement: "outside"
|
|
4949
|
-
})),
|
|
4950
|
-
},
|
|
5001
|
+
})), wl(e, r, 1), !0;
|
|
5002
|
+
}, iu = (e, t, n) => ru(e, t, n) || tu(e, t, n) || $l(e, t, n) || eu(e, t, n), au = () => null, ou = (e, t) => {
|
|
4951
5003
|
let n = e.getMeta($);
|
|
4952
5004
|
return n === void 0 ? e.docChanged || e.selectionSet || e.storedMarksSet ? null : t : n;
|
|
4953
|
-
},
|
|
5005
|
+
}, su = (e) => {
|
|
4954
5006
|
$.getState(e.state) != null && e.dispatch(e.state.tr.setMeta($, null));
|
|
4955
|
-
},
|
|
5007
|
+
}, cu = (e) => (su(e), !1), lu = class {
|
|
4956
5008
|
constructor(e) {
|
|
4957
5009
|
this.editorDom = e.dom, this.update(e);
|
|
4958
5010
|
}
|
|
4959
5011
|
update(e) {
|
|
4960
5012
|
let t = $.getState(e.state), n = t != null;
|
|
4961
|
-
this.editorDom.classList.toggle(
|
|
5013
|
+
this.editorDom.classList.toggle(Bl, n), Kl(e, t);
|
|
4962
5014
|
}
|
|
4963
5015
|
destroy() {
|
|
4964
|
-
this.editorDom.classList.remove(
|
|
5016
|
+
this.editorDom.classList.remove(Bl);
|
|
4965
5017
|
}
|
|
4966
|
-
},
|
|
5018
|
+
}, uu = (e) => new lu(e), du = (e) => {
|
|
4967
5019
|
if (!(e instanceof Element)) return !1;
|
|
4968
5020
|
let t = e.closest("code");
|
|
4969
5021
|
return !!(t && !t.closest("pre"));
|
|
4970
|
-
},
|
|
5022
|
+
}, fu = (e, t, n) => {
|
|
4971
5023
|
if (!e.state.selection.empty) return !1;
|
|
4972
|
-
if (
|
|
4973
|
-
let r =
|
|
4974
|
-
if (i && r &&
|
|
5024
|
+
if (Il(e, n)) return !0;
|
|
5025
|
+
let r = du(n.target), i = e.state.schema.marks[ql];
|
|
5026
|
+
if (i && r && Xl(e, t, i)) return n.preventDefault(), !0;
|
|
4975
5027
|
let a = $.getState(e.state);
|
|
4976
5028
|
if (!r || !a) return !1;
|
|
4977
5029
|
let o = e.state.storedMarks, s = e.state.tr.setMeta($, null);
|
|
4978
5030
|
return o !== null && i && !Q(o, i) && s.setStoredMarks(null), e.dispatch(s), !1;
|
|
4979
|
-
},
|
|
4980
|
-
ArrowLeft:
|
|
5031
|
+
}, pu = (e, t, n) => t.key !== "ArrowRight" || !Yl(e, n) || Q(e.state.storedMarks ?? e.state.selection.$from.marks(), n) || !Xl(e, e.state.selection.from, n) ? !1 : (t.preventDefault(), !0), mu = {
|
|
5032
|
+
ArrowLeft: iu,
|
|
4981
5033
|
ArrowRight: (e, t, n) => {
|
|
4982
5034
|
if (t.key !== "ArrowRight") return !1;
|
|
4983
|
-
if (
|
|
4984
|
-
if (!
|
|
5035
|
+
if (pu(e, t, n)) return !0;
|
|
5036
|
+
if (!Jl(e, n)) return !1;
|
|
4985
5037
|
let r = e.state.storedMarks ?? e.state.selection.$from.marks();
|
|
4986
|
-
if (!Q(r, n)) return
|
|
5038
|
+
if (!Q(r, n)) return su(e), !1;
|
|
4987
5039
|
t.preventDefault();
|
|
4988
5040
|
let i = r.filter((e) => e.type !== n);
|
|
4989
5041
|
return e.dispatch(e.state.tr.setStoredMarks(i).setMeta($, {
|
|
4990
5042
|
position: e.state.selection.from,
|
|
4991
5043
|
side: "right",
|
|
4992
5044
|
placement: "outside"
|
|
4993
|
-
})),
|
|
5045
|
+
})), wl(e, e.state.selection.from, 1), !0;
|
|
4994
5046
|
}
|
|
4995
|
-
},
|
|
4996
|
-
if (
|
|
4997
|
-
let n =
|
|
5047
|
+
}, hu = (e, t) => {
|
|
5048
|
+
if (Zl(e, t)) return !1;
|
|
5049
|
+
let n = mu[t.key];
|
|
4998
5050
|
if (!n) return !1;
|
|
4999
|
-
let r = e.state.schema.marks[
|
|
5051
|
+
let r = e.state.schema.marks[ql];
|
|
5000
5052
|
if (!r) return !1;
|
|
5001
5053
|
let i = $.getState(e.state);
|
|
5002
|
-
return i ?
|
|
5003
|
-
},
|
|
5054
|
+
return i ? Al(e, t, r, i, $) : n(e, t, r);
|
|
5055
|
+
}, gu = B(() => new L({
|
|
5004
5056
|
key: $,
|
|
5005
|
-
view:
|
|
5057
|
+
view: uu,
|
|
5006
5058
|
state: {
|
|
5007
|
-
init:
|
|
5008
|
-
apply:
|
|
5059
|
+
init: au,
|
|
5060
|
+
apply: ou
|
|
5009
5061
|
},
|
|
5010
5062
|
props: {
|
|
5011
|
-
handleKeyDown:
|
|
5012
|
-
handleClick:
|
|
5013
|
-
decorations:
|
|
5014
|
-
handleDOMEvents: { blur:
|
|
5063
|
+
handleKeyDown: hu,
|
|
5064
|
+
handleClick: fu,
|
|
5065
|
+
decorations: Gl,
|
|
5066
|
+
handleDOMEvents: { blur: cu }
|
|
5015
5067
|
}
|
|
5016
|
-
})),
|
|
5068
|
+
})), _u = ".zt-md-code-block-action-button[data-active='true']", vu = ".zt-md-search-panel", yu = 8, bu = {
|
|
5017
5069
|
current: 0,
|
|
5018
5070
|
total: 0,
|
|
5019
5071
|
isInvalidExpression: !1
|
|
5020
|
-
},
|
|
5072
|
+
}, xu = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, Su = (e) => new Ft({
|
|
5021
5073
|
search: e.search,
|
|
5022
5074
|
replace: e.replace,
|
|
5023
5075
|
caseSensitive: e.caseSensitive,
|
|
5024
5076
|
wholeWord: e.wholeWord,
|
|
5025
5077
|
regexp: e.regexp,
|
|
5026
5078
|
literal: !0
|
|
5027
|
-
}),
|
|
5079
|
+
}), Cu = (e, t) => {
|
|
5028
5080
|
if (!t.valid) return [];
|
|
5029
5081
|
let n = [], r = 0, i = e.doc.content.size;
|
|
5030
5082
|
for (; r < i;) {
|
|
@@ -5033,7 +5085,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5033
5085
|
n.push(a), r = Math.max(a.to, r + 1);
|
|
5034
5086
|
}
|
|
5035
5087
|
return n;
|
|
5036
|
-
},
|
|
5088
|
+
}, wu = (e, t, n) => {
|
|
5037
5089
|
let r = 0, i = e.length - 1;
|
|
5038
5090
|
for (; r <= i;) {
|
|
5039
5091
|
let a = r + i >> 1, o = e[a];
|
|
@@ -5041,126 +5093,180 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5041
5093
|
o.from < t ? r = a + 1 : i = a - 1;
|
|
5042
5094
|
}
|
|
5043
5095
|
return -1;
|
|
5044
|
-
},
|
|
5045
|
-
let r = n.regexp && n.search.length > 0 && !n.valid, i =
|
|
5096
|
+
}, Tu = (e, t, n) => {
|
|
5097
|
+
let r = n.regexp && n.search.length > 0 && !n.valid, i = wu(t, e.selection.from, e.selection.to);
|
|
5046
5098
|
return {
|
|
5047
5099
|
current: i < 0 ? 0 : i + 1,
|
|
5048
5100
|
total: t.length,
|
|
5049
5101
|
isInvalidExpression: r
|
|
5050
5102
|
};
|
|
5051
|
-
},
|
|
5103
|
+
}, Eu = (e, t) => e.current === t.current && e.total === t.total && e.isInvalidExpression === t.isInvalidExpression, Du = (e) => {
|
|
5052
5104
|
if (e.state.selection.empty) return;
|
|
5053
|
-
let t =
|
|
5105
|
+
let t = uo(e.dom);
|
|
5054
5106
|
if (!t) return;
|
|
5055
|
-
let n = e.coordsAtPos(e.state.selection.from), r = e.coordsAtPos(e.state.selection.to), i = Math.min(n.top, r.top), a = Math.max(n.bottom, r.bottom), o = t.getBoundingClientRect(), s = (t.closest(".zt-md")?.querySelector(
|
|
5107
|
+
let n = e.coordsAtPos(e.state.selection.from), r = e.coordsAtPos(e.state.selection.to), i = Math.min(n.top, r.top), a = Math.max(n.bottom, r.bottom), o = t.getBoundingClientRect(), s = (t.closest(".zt-md")?.querySelector(vu))?.getBoundingClientRect(), c = Math.max(o.top + yu, (s?.bottom ?? o.top) + yu), l = o.bottom - yu;
|
|
5056
5108
|
if (i < c) {
|
|
5057
5109
|
t.scrollTop += i - c;
|
|
5058
5110
|
return;
|
|
5059
5111
|
}
|
|
5060
5112
|
a > l && (t.scrollTop += a - l);
|
|
5061
|
-
},
|
|
5113
|
+
}, Ou = (e) => {
|
|
5062
5114
|
if (e.state.selection.empty) return;
|
|
5063
5115
|
let t = e.domAtPos(e.state.selection.from), n = (t.node instanceof Element ? t.node : t.node.parentElement)?.closest(".zt-md-code-block");
|
|
5064
5116
|
if (n?.dataset.viewMode !== "preview") {
|
|
5065
|
-
|
|
5117
|
+
Du(e);
|
|
5066
5118
|
return;
|
|
5067
5119
|
}
|
|
5068
|
-
n.querySelector(
|
|
5069
|
-
|
|
5120
|
+
n.querySelector(_u)?.click(), window.requestAnimationFrame(() => {
|
|
5121
|
+
Du(e);
|
|
5070
5122
|
});
|
|
5071
|
-
},
|
|
5123
|
+
}, ku = class {
|
|
5072
5124
|
constructor(e, t) {
|
|
5073
|
-
this.onSnapshotChange = t, this.snapshot =
|
|
5125
|
+
this.onSnapshotChange = t, this.snapshot = bu, this.cachedDoc = null, this.cachedQuery = null, this.cachedResults = [], this.emitSnapshot(e.state);
|
|
5074
5126
|
}
|
|
5075
5127
|
update(e) {
|
|
5076
5128
|
this.emitSnapshot(e.state);
|
|
5077
5129
|
}
|
|
5078
5130
|
destroy() {
|
|
5079
|
-
this.cachedDoc = null, this.cachedQuery = null, this.cachedResults = [], this.onSnapshotChange(
|
|
5131
|
+
this.cachedDoc = null, this.cachedQuery = null, this.cachedResults = [], this.onSnapshotChange(bu);
|
|
5080
5132
|
}
|
|
5081
5133
|
resolveSearchResults(e, t) {
|
|
5082
5134
|
if (this.cachedDoc === e.doc && this.cachedQuery && this.cachedQuery.eq(t)) return this.cachedResults;
|
|
5083
|
-
let n =
|
|
5135
|
+
let n = Cu(e, t);
|
|
5084
5136
|
return this.cachedDoc = e.doc, this.cachedQuery = t, this.cachedResults = n, n;
|
|
5085
5137
|
}
|
|
5086
5138
|
emitSnapshot(e) {
|
|
5087
|
-
let t =
|
|
5139
|
+
let t = Rt(e);
|
|
5088
5140
|
if (!t) {
|
|
5089
|
-
this.cachedDoc = null, this.cachedQuery = null, this.cachedResults = [],
|
|
5141
|
+
this.cachedDoc = null, this.cachedQuery = null, this.cachedResults = [], Eu(this.snapshot, bu) || (this.snapshot = bu, this.onSnapshotChange(bu));
|
|
5090
5142
|
return;
|
|
5091
5143
|
}
|
|
5092
|
-
let n =
|
|
5093
|
-
|
|
5144
|
+
let n = Tu(e, this.resolveSearchResults(e, t.query), t.query);
|
|
5145
|
+
Eu(this.snapshot, n) || (this.snapshot = n, this.onSnapshotChange(n));
|
|
5094
5146
|
}
|
|
5095
|
-
},
|
|
5147
|
+
}, Au = (e) => [B(() => Vt()), B(() => new L({ view: (t) => new ku(t, e) }))], ju = (e) => {
|
|
5096
5148
|
let t = (t) => {
|
|
5097
5149
|
e((e) => {
|
|
5098
|
-
let n =
|
|
5150
|
+
let n = Su(t), r = Ht(e.state.tr, n);
|
|
5099
5151
|
if (n.valid) {
|
|
5100
5152
|
let t = n.findNext(e.state, e.state.selection.from) ?? n.findNext(e.state, 0, e.state.selection.from);
|
|
5101
5153
|
t && r.setSelection(z.create(r.doc, t.from, t.to)).scrollIntoView();
|
|
5102
5154
|
}
|
|
5103
|
-
e.dispatch(r),
|
|
5155
|
+
e.dispatch(r), Ou(e);
|
|
5104
5156
|
});
|
|
5105
5157
|
}, n = (e, t) => {
|
|
5106
5158
|
e(t.state, (e) => {
|
|
5107
5159
|
t.dispatch(e.scrollIntoView());
|
|
5108
|
-
}) &&
|
|
5160
|
+
}) && Ou(t);
|
|
5109
5161
|
};
|
|
5110
5162
|
return {
|
|
5111
5163
|
updateQuery: t,
|
|
5112
5164
|
findPrevious: () => {
|
|
5113
5165
|
e((e) => {
|
|
5114
|
-
n(
|
|
5166
|
+
n(Lt, e);
|
|
5115
5167
|
});
|
|
5116
5168
|
},
|
|
5117
5169
|
findNext: () => {
|
|
5118
5170
|
e((e) => {
|
|
5119
|
-
n(
|
|
5171
|
+
n(It, e);
|
|
5120
5172
|
});
|
|
5121
5173
|
},
|
|
5122
5174
|
replaceCurrent: () => {
|
|
5123
5175
|
e((e) => {
|
|
5124
|
-
|
|
5176
|
+
xu(e) && n(Bt, e);
|
|
5125
5177
|
});
|
|
5126
5178
|
},
|
|
5127
5179
|
replaceAll: () => {
|
|
5128
5180
|
e((e) => {
|
|
5129
|
-
if (!
|
|
5130
|
-
let t =
|
|
5131
|
-
!t ||
|
|
5181
|
+
if (!xu(e)) return;
|
|
5182
|
+
let t = Rt(e.state);
|
|
5183
|
+
!t || Cu(e.state, t.query).length === 0 || zt(e.state, (t) => {
|
|
5132
5184
|
e.dispatch(t);
|
|
5133
5185
|
});
|
|
5134
5186
|
});
|
|
5135
5187
|
},
|
|
5136
5188
|
clear: () => {
|
|
5137
5189
|
e((e) => {
|
|
5138
|
-
let t = new
|
|
5190
|
+
let t = new Ft({
|
|
5139
5191
|
search: "",
|
|
5140
5192
|
literal: !0
|
|
5141
5193
|
});
|
|
5142
|
-
e.dispatch(
|
|
5194
|
+
e.dispatch(Ht(e.state.tr, t));
|
|
5143
5195
|
});
|
|
5144
5196
|
},
|
|
5145
5197
|
focusCurrent: () => {
|
|
5146
5198
|
e((e) => {
|
|
5147
|
-
e.dispatch(e.state.tr.scrollIntoView()),
|
|
5199
|
+
e.dispatch(e.state.tr.scrollIntoView()), Du(e), e.focus();
|
|
5148
5200
|
});
|
|
5149
5201
|
}
|
|
5150
5202
|
};
|
|
5151
|
-
},
|
|
5203
|
+
}, Mu = /^[ \t]+/, Nu = /[ \t]+$/, Pu = [st("remarkCjkFriendly", () => Ut), st("remarkCjkFriendlyGfmStrikethrough", () => Wt)].flat(), Fu = (e) => {
|
|
5204
|
+
let t = ((t, n, r, i) => {
|
|
5205
|
+
let { delimiter: a, after: o } = e.resolveDelimiters(t, r), s = r.enter(e.constructName), c = r.createTracker(i), l = r.createTracker(i);
|
|
5206
|
+
l.move(a);
|
|
5207
|
+
let u = r.containerPhrasing(t, {
|
|
5208
|
+
before: a,
|
|
5209
|
+
after: o,
|
|
5210
|
+
...l.current()
|
|
5211
|
+
});
|
|
5212
|
+
s();
|
|
5213
|
+
let d = Mu.exec(u)?.[0] ?? "", f = Nu.exec(u)?.[0] ?? "", p = u.slice(d.length, u.length - f.length);
|
|
5214
|
+
if (!p) return c.move(u);
|
|
5215
|
+
let m = "";
|
|
5216
|
+
return d && (m += c.move(d)), m += c.move(a), m += c.move(p), m += c.move(a), f && (m += c.move(f)), m;
|
|
5217
|
+
});
|
|
5218
|
+
return t.peek = e.peek, t;
|
|
5219
|
+
}, Iu = (e) => {
|
|
5220
|
+
let t = e.get(Se) ?? {}, n = Fu({
|
|
5221
|
+
constructName: "strong",
|
|
5222
|
+
resolveDelimiters: (e, t) => {
|
|
5223
|
+
let n = e.marker || t.options.strong || "*";
|
|
5224
|
+
return {
|
|
5225
|
+
delimiter: n + n,
|
|
5226
|
+
after: n
|
|
5227
|
+
};
|
|
5228
|
+
},
|
|
5229
|
+
peek: (e, t, n) => n.options.strong || "*"
|
|
5230
|
+
}), r = Fu({
|
|
5231
|
+
constructName: "emphasis",
|
|
5232
|
+
resolveDelimiters: (e, t) => {
|
|
5233
|
+
let n = e.marker || t.options.emphasis || "*";
|
|
5234
|
+
return {
|
|
5235
|
+
delimiter: n,
|
|
5236
|
+
after: n
|
|
5237
|
+
};
|
|
5238
|
+
},
|
|
5239
|
+
peek: (e, t, n) => n.options.emphasis || "*"
|
|
5240
|
+
}), i = Fu({
|
|
5241
|
+
constructName: "strikethrough",
|
|
5242
|
+
resolveDelimiters: () => ({
|
|
5243
|
+
delimiter: "~~",
|
|
5244
|
+
after: "~"
|
|
5245
|
+
}),
|
|
5246
|
+
peek: () => "~"
|
|
5247
|
+
});
|
|
5248
|
+
e.set(Se, {
|
|
5249
|
+
...t,
|
|
5250
|
+
handlers: {
|
|
5251
|
+
...t.handlers,
|
|
5252
|
+
strong: n,
|
|
5253
|
+
emphasis: r,
|
|
5254
|
+
delete: i
|
|
5255
|
+
}
|
|
5256
|
+
});
|
|
5257
|
+
}, Lu = "ZT_MD_READONLY_CHANGE", Ru = new R("ZT_MD_MARKDOWN_SYNC"), zu = "[data-type=\"code_block\"], [data-type=\"image\"], [data-type=\"math_block\"], [data-type=\"math_inline\"], [data-type=\"frontmatter\"]", Bu = 30, Vu = (e) => {
|
|
5152
5258
|
let t = e.target;
|
|
5153
5259
|
if (!(t instanceof Element)) return null;
|
|
5154
5260
|
let n = t.closest("a[href]");
|
|
5155
5261
|
return n instanceof HTMLAnchorElement ? n : null;
|
|
5156
|
-
},
|
|
5157
|
-
let n =
|
|
5262
|
+
}, Hu = (e) => e?.type.name === "image", Uu = (e, t) => {
|
|
5263
|
+
let n = Vu(e);
|
|
5158
5264
|
if (!n) return !1;
|
|
5159
|
-
let r =
|
|
5265
|
+
let r = Xn(n.getAttribute("href"));
|
|
5160
5266
|
return !r || t || !e.ctrlKey ? !1 : (e.preventDefault(), e.stopPropagation(), window.open(r, "_blank", "noopener,noreferrer"), !0);
|
|
5161
|
-
},
|
|
5267
|
+
}, Wu = (e, t) => !t || !Vu(e) ? !1 : (e.preventDefault(), e.stopPropagation(), !0), Gu = (e, t) => {
|
|
5162
5268
|
let n = t ? "false" : "true";
|
|
5163
|
-
e.dom.querySelectorAll(
|
|
5269
|
+
e.dom.querySelectorAll(zu).forEach((e) => {
|
|
5164
5270
|
if (e.dataset.editable = n, e.dataset.type === "code_block") {
|
|
5165
5271
|
let n = e.querySelector(":scope > .zt-md-code-block-actions");
|
|
5166
5272
|
if (n) {
|
|
@@ -5175,103 +5281,121 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5175
5281
|
t && (t.hidden = !0);
|
|
5176
5282
|
}
|
|
5177
5283
|
});
|
|
5178
|
-
},
|
|
5179
|
-
let t = e.readOnly, n = Math.max(0, e.debounceMs ?? 0), r = !1, i = null, a = null, o = null, s = null, c = null, l = null, u = (
|
|
5180
|
-
|
|
5284
|
+
}, Ku = (e) => {
|
|
5285
|
+
let t = e.readOnly, n = Math.max(0, e.debounceMs ?? 0), r = !1, i = null, a = null, o = null, s = null, c = null, l = null, u = !1, d = null, f = () => {
|
|
5286
|
+
d !== null && (clearTimeout(d), d = null);
|
|
5287
|
+
}, p = (t) => {
|
|
5288
|
+
if (t.composing) {
|
|
5289
|
+
u = !0;
|
|
5290
|
+
return;
|
|
5291
|
+
}
|
|
5292
|
+
if (u = !1, t.state.doc === o || (c ||= j.action((e) => e.get(we)), !c)) return;
|
|
5181
5293
|
o = t.state.doc;
|
|
5182
5294
|
let n = c(t.state.doc);
|
|
5183
5295
|
n !== a && (a = n, e.onChange(n));
|
|
5184
|
-
},
|
|
5296
|
+
}, h = (e) => {
|
|
5297
|
+
if (n <= 0 || !l) {
|
|
5298
|
+
p(e);
|
|
5299
|
+
return;
|
|
5300
|
+
}
|
|
5301
|
+
l();
|
|
5302
|
+
}, g = () => {
|
|
5185
5303
|
l?.cancel(), l = n > 0 ? m(() => {
|
|
5186
|
-
s &&
|
|
5304
|
+
s && p(s);
|
|
5187
5305
|
}, n) : null;
|
|
5188
5306
|
};
|
|
5189
|
-
|
|
5190
|
-
let
|
|
5191
|
-
key:
|
|
5307
|
+
g();
|
|
5308
|
+
let _ = { ...e.messages ?? U(e.locale) }, v = nl(e.contentPortalContainer, _), y = Vs(e.contentPortalContainer, _, e.shortcutMode), b = Fo(_, e.contentPortalContainer), x = Li(_, e.contentPortalContainer), S = ti(e.imageUpload, _), C = Au(e.onSearchSnapshotChange), w = B(() => new L({
|
|
5309
|
+
key: Ru,
|
|
5310
|
+
props: { handleDOMEvents: {
|
|
5311
|
+
compositionstart: () => (f(), l?.cancel(), !1),
|
|
5312
|
+
compositionend: () => (f(), d = setTimeout(() => {
|
|
5313
|
+
d = null, s && !s.composing && !r && (u || s.state.doc !== o) && (u = !1, h(s));
|
|
5314
|
+
}, Bu), !1),
|
|
5315
|
+
blur: (e) => e.composing || r ? !1 : (f(), l?.cancel(), p(e), !1)
|
|
5316
|
+
} },
|
|
5192
5317
|
view: (e) => (s = e, o = e.state.doc, {
|
|
5193
5318
|
update: (e, t) => {
|
|
5194
5319
|
if (s = e, r) {
|
|
5195
|
-
o = e.state.doc, a = i, l?.cancel();
|
|
5320
|
+
o = e.state.doc, a = i, u = !1, f(), l?.cancel();
|
|
5196
5321
|
return;
|
|
5197
5322
|
}
|
|
5198
|
-
if (
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
return;
|
|
5202
|
-
}
|
|
5203
|
-
l();
|
|
5323
|
+
if (e.composing) {
|
|
5324
|
+
(t.doc !== e.state.doc || e.state.doc !== o) && (u = !0), f(), l?.cancel();
|
|
5325
|
+
return;
|
|
5204
5326
|
}
|
|
5327
|
+
let n = t.doc !== e.state.doc, c = u && e.state.doc !== o;
|
|
5328
|
+
!n && !c || (u = !1, f(), h(e));
|
|
5205
5329
|
},
|
|
5206
5330
|
destroy: () => {
|
|
5207
|
-
l?.cancel(), c = null, s = null;
|
|
5331
|
+
f(), u = !1, l?.cancel(), c = null, s = null;
|
|
5208
5332
|
}
|
|
5209
5333
|
})
|
|
5210
|
-
})),
|
|
5211
|
-
listener: Oe,
|
|
5334
|
+
})), T = pc(e.portalContainer, e.slashMenu, _, e.imageUpload, e.locale, e.shortcutMode), E = T.plugins, D = _c(e.portalContainer, _, e.shortcutMode, e.imageUpload), O = {
|
|
5212
5335
|
commonmark: Ne,
|
|
5213
|
-
frontmatter:
|
|
5214
|
-
taskListTransformKeymap:
|
|
5215
|
-
inlineCodeBoundaryNavigation:
|
|
5336
|
+
frontmatter: Ko,
|
|
5337
|
+
taskListTransformKeymap: Ss(e.shortcutMode),
|
|
5338
|
+
inlineCodeBoundaryNavigation: gu,
|
|
5216
5339
|
gfm: Be,
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5340
|
+
cjkFriendly: Pu,
|
|
5341
|
+
history: Ee,
|
|
5342
|
+
editorSearch: C,
|
|
5343
|
+
codeBlockPrism: [gn, Ve],
|
|
5344
|
+
codeBlockLanguagePicker: b,
|
|
5345
|
+
clipboard: Te,
|
|
5346
|
+
indent: De,
|
|
5347
|
+
imageDeleteSelection: Mr,
|
|
5348
|
+
imagePaste: S,
|
|
5349
|
+
tableArrowEntry: Tc,
|
|
5350
|
+
blockBoundaryNavigation: Rn,
|
|
5351
|
+
headingBackspaceEmptyParagraph: Aa,
|
|
5352
|
+
headingFocusIndicator: Fa,
|
|
5353
|
+
mathBackspaceEntry: bi,
|
|
5354
|
+
blockquoteBackspaceLift: Sa,
|
|
5355
|
+
tableFocusActions: v,
|
|
5356
|
+
selectionTooltip: y,
|
|
5357
|
+
gapCursor: Sn,
|
|
5358
|
+
dropCursor: xn,
|
|
5359
|
+
math: ha,
|
|
5360
|
+
mathInlineEdit: x,
|
|
5361
|
+
mathInlineArrowNavigation: aa,
|
|
5362
|
+
taskListToggle: ul,
|
|
5363
|
+
tabSpaceIndent: bl,
|
|
5364
|
+
codeBlockModASelect: Ho,
|
|
5365
|
+
slash: E.length > 0 ? E : null
|
|
5366
|
+
}, k = vn(O, { includeRuntime: !1 }), A = vn(O, { includeRuntime: !0 }).filter((e) => e.name === "clipboard" || e.name === "indent"), j = _e.make();
|
|
5367
|
+
j.config((n) => {
|
|
5368
|
+
xs(n, e.shortcutMode), Ba(n), n.set(Ve.key, { configureRefractor: sn }), lr(n, e.imageUpload?.allowedProtocols), Iu(n), n.set(Ce, e.root), n.set(ve, e.markdown), n.set(be, {
|
|
5245
5369
|
editable: () => !t,
|
|
5246
|
-
handleKeyDown:
|
|
5370
|
+
handleKeyDown: D,
|
|
5247
5371
|
handleDOMEvents: {
|
|
5248
|
-
mousedown: (e, n) => n instanceof MouseEvent ?
|
|
5249
|
-
click: (e, n) => n instanceof MouseEvent ?
|
|
5372
|
+
mousedown: (e, n) => n instanceof MouseEvent ? Wu(n, t) : !1,
|
|
5373
|
+
click: (e, n) => n instanceof MouseEvent ? Wu(n, t) : !1
|
|
5250
5374
|
},
|
|
5251
|
-
handleClick: (e, n, r) =>
|
|
5252
|
-
handleClickOn: (e, n, r, i, a, o) =>
|
|
5375
|
+
handleClick: (e, n, r) => Uu(r, t),
|
|
5376
|
+
handleClickOn: (e, n, r, i, a, o) => Uu(a, t) ? !0 : t && o && Hu(r) ? (a.preventDefault(), !0) : !1
|
|
5253
5377
|
});
|
|
5254
5378
|
let r = n.get(xe) ?? [];
|
|
5255
5379
|
n.set(xe, [
|
|
5256
5380
|
...r,
|
|
5257
|
-
["image",
|
|
5258
|
-
["math_block",
|
|
5259
|
-
["math_inline",
|
|
5260
|
-
["code_block",
|
|
5261
|
-
[
|
|
5262
|
-
]),
|
|
5263
|
-
}),
|
|
5264
|
-
|
|
5265
|
-
}),
|
|
5266
|
-
let
|
|
5267
|
-
|
|
5381
|
+
["image", yr(_)],
|
|
5382
|
+
["math_block", Ai(_)],
|
|
5383
|
+
["math_inline", Ui(_)],
|
|
5384
|
+
["code_block", no(_)],
|
|
5385
|
+
[Uo, ns(_)]
|
|
5386
|
+
]), T.config && T.config(n);
|
|
5387
|
+
}), k.forEach((e) => {
|
|
5388
|
+
j.use(e.plugin);
|
|
5389
|
+
}), j.use(w);
|
|
5390
|
+
let ee = ju((e) => {
|
|
5391
|
+
j.action((t) => {
|
|
5268
5392
|
e(t.get(ye));
|
|
5269
5393
|
});
|
|
5270
|
-
}),
|
|
5271
|
-
|
|
5394
|
+
}), te = () => {
|
|
5395
|
+
A.forEach((e) => {
|
|
5272
5396
|
try {
|
|
5273
|
-
|
|
5274
|
-
e.set(
|
|
5397
|
+
j.use(e.plugin), e.name === "indent" && j.action((e) => {
|
|
5398
|
+
e.set(Oe, {
|
|
5275
5399
|
type: "space",
|
|
5276
5400
|
size: 4
|
|
5277
5401
|
});
|
|
@@ -5280,25 +5404,25 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5280
5404
|
console.error(e);
|
|
5281
5405
|
}
|
|
5282
5406
|
});
|
|
5283
|
-
},
|
|
5407
|
+
}, ne = _n(lt, j);
|
|
5284
5408
|
return {
|
|
5285
|
-
editor:
|
|
5409
|
+
editor: j,
|
|
5286
5410
|
updateLocalization: (e, t) => {
|
|
5287
|
-
|
|
5411
|
+
rn(_, t), T.updateLocale?.(e);
|
|
5288
5412
|
},
|
|
5289
5413
|
setReadOnly: (e) => {
|
|
5290
|
-
t !== e && (t = e,
|
|
5414
|
+
t !== e && (t = e, j.action((e) => {
|
|
5291
5415
|
let n = e.get(ye);
|
|
5292
|
-
n.setProps({ editable: () => !t }),
|
|
5416
|
+
n.setProps({ editable: () => !t }), Gu(n, t), n.dispatch(n.state.tr.setMeta(Lu, t));
|
|
5293
5417
|
}));
|
|
5294
5418
|
},
|
|
5295
5419
|
setDebounceMs: (e) => {
|
|
5296
5420
|
let t = Math.max(0, e);
|
|
5297
|
-
n !== t && (n = t,
|
|
5421
|
+
n !== t && (n = t, g());
|
|
5298
5422
|
},
|
|
5299
|
-
installRuntimePlugins:
|
|
5423
|
+
installRuntimePlugins: te,
|
|
5300
5424
|
focusEditor: (e) => {
|
|
5301
|
-
|
|
5425
|
+
j.action((t) => {
|
|
5302
5426
|
let n = t.get(ye), r = n.state.doc.lastChild, i = r ? n.state.doc.content.size - r.nodeSize : null, a = i === null ? null : n.nodeDOM(i), o = a instanceof Element ? a : a?.parentElement ?? null;
|
|
5303
5427
|
if (e !== void 0 && o !== null && e.top > o.getBoundingClientRect().bottom) {
|
|
5304
5428
|
let e = n.state.schema.nodes.paragraph;
|
|
@@ -5312,17 +5436,17 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5312
5436
|
n.state.selection.eq(c) || n.dispatch(n.state.tr.setSelection(c).scrollIntoView()), n.focus();
|
|
5313
5437
|
});
|
|
5314
5438
|
},
|
|
5315
|
-
searchController:
|
|
5439
|
+
searchController: ee,
|
|
5316
5440
|
setMarkdown: (e) => {
|
|
5317
|
-
l?.cancel(), i = e, r = !0;
|
|
5441
|
+
f(), u = !1, l?.cancel(), i = e, r = !0;
|
|
5318
5442
|
try {
|
|
5319
|
-
|
|
5443
|
+
ne(e);
|
|
5320
5444
|
} finally {
|
|
5321
5445
|
r = !1, i = null;
|
|
5322
5446
|
}
|
|
5323
5447
|
}
|
|
5324
5448
|
};
|
|
5325
|
-
},
|
|
5449
|
+
}, qu = (e, t, n, r) => {
|
|
5326
5450
|
let i = e, a = i.create.bind(e);
|
|
5327
5451
|
return i.create = async () => {
|
|
5328
5452
|
try {
|
|
@@ -5332,12 +5456,12 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5332
5456
|
throw console.error("Milkdown init failed:", e), r(e), e;
|
|
5333
5457
|
}
|
|
5334
5458
|
}, i;
|
|
5335
|
-
},
|
|
5459
|
+
}, Ju = (e) => {
|
|
5336
5460
|
let t = s(null), n = s(e.markdown), r = s(e.readOnly), a = s(e.debounceMs), o = s(e.onMarkdownChange), c = s(e.onInitError), l = s(e.onInitReady), u = s(e.onSearchSnapshotChange);
|
|
5337
5461
|
r.current = e.readOnly, a.current = e.debounceMs;
|
|
5338
5462
|
let f = d((i) => {
|
|
5339
5463
|
t.current = null, e.focusEditorRef && (e.focusEditorRef.current = null), e.searchControllerRef && (e.searchControllerRef.current = null), n.current = e.markdown;
|
|
5340
|
-
let s =
|
|
5464
|
+
let s = Ku({
|
|
5341
5465
|
root: i,
|
|
5342
5466
|
portalContainer: e.portalContainer,
|
|
5343
5467
|
contentPortalContainer: e.contentPortalContainer,
|
|
@@ -5356,7 +5480,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5356
5480
|
u.current?.(e);
|
|
5357
5481
|
}
|
|
5358
5482
|
});
|
|
5359
|
-
return
|
|
5483
|
+
return qu(s.editor, s.installRuntimePlugins, () => {
|
|
5360
5484
|
t.current = s, e.focusEditorRef && (e.focusEditorRef.current = s.focusEditor), e.searchControllerRef && (e.searchControllerRef.current = s.searchController), l.current?.();
|
|
5361
5485
|
}, (e) => {
|
|
5362
5486
|
c.current?.(e);
|
|
@@ -5398,20 +5522,20 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5398
5522
|
let r = t.current;
|
|
5399
5523
|
!r || f.loading || e.markdown !== n.current && (n.current = e.markdown, r.setMarkdown(e.markdown));
|
|
5400
5524
|
}, [f.loading, e.markdown]);
|
|
5401
|
-
},
|
|
5525
|
+
}, Yu = 160, Xu = 120, Zu = {
|
|
5402
5526
|
search: "",
|
|
5403
5527
|
replace: "",
|
|
5404
5528
|
caseSensitive: !1,
|
|
5405
5529
|
wholeWord: !1,
|
|
5406
5530
|
regexp: !1
|
|
5407
|
-
},
|
|
5531
|
+
}, Qu = {
|
|
5408
5532
|
current: 0,
|
|
5409
5533
|
total: 0,
|
|
5410
5534
|
isInvalidExpression: !1
|
|
5411
|
-
},
|
|
5535
|
+
}, $u = {
|
|
5412
5536
|
"zh-CN": "只读",
|
|
5413
5537
|
"en-US": "Read only"
|
|
5414
|
-
},
|
|
5538
|
+
}, ed = (e) => e.length === 0 ? "\"\"" : `"${e.replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\r\n|\r|\n/g, "\\A ")}"`, td = (e) => (Ju({
|
|
5415
5539
|
markdown: e.markdown,
|
|
5416
5540
|
portalContainer: e.portalContainer,
|
|
5417
5541
|
contentPortalContainer: e.contentPortalContainer,
|
|
@@ -5428,28 +5552,28 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5428
5552
|
onInitReady: e.onInitReady,
|
|
5429
5553
|
onInitError: e.onInitError,
|
|
5430
5554
|
onSearchSnapshotChange: e.onSearchSnapshotChange
|
|
5431
|
-
}), /* @__PURE__ */ P(l, {})),
|
|
5432
|
-
let [t, n] = c(""), [a, l] = c(null), [d, p] = c(null), [h, g] = c(!1), [_, v] = c(!1), [y, b] = c(
|
|
5555
|
+
}), /* @__PURE__ */ P(l, {})), nd = (e) => {
|
|
5556
|
+
let [t, n] = c(""), [a, l] = c(null), [d, p] = c(null), [h, g] = c(!1), [_, v] = c(!1), [y, b] = c(Zu), [x, S] = c(Qu), C = s(null), w = s(null), T = s(null), E = s(h), D = s(y);
|
|
5433
5557
|
E.current = h, D.current = y;
|
|
5434
5558
|
let O = o(() => m((e) => {
|
|
5435
5559
|
w.current?.updateQuery(e);
|
|
5436
|
-
},
|
|
5560
|
+
}, Xu), []);
|
|
5437
5561
|
i(() => () => {
|
|
5438
5562
|
O.cancel();
|
|
5439
5563
|
}, [O]);
|
|
5440
|
-
let k = e.theme ?? "light", A = e.readOnly ?? !1,
|
|
5564
|
+
let k = e.theme ?? "light", A = e.readOnly ?? !1, j = $u[e.locale ?? "zh-CN"], ee = e.debounceMs ?? Yu, te = e.shortcutMode ?? "modShift", { markdown: ne, setMarkdown: re } = Jt(e.value, e.defaultValue, e.onChange), M = o(() => U(e.locale, e.messages, e.placeholder), [
|
|
5441
5565
|
e.locale,
|
|
5442
5566
|
e.messages,
|
|
5443
5567
|
e.placeholder
|
|
5444
5568
|
]), ie = o(() => ({
|
|
5445
|
-
"--zt-gap-placeholder-content":
|
|
5569
|
+
"--zt-gap-placeholder-content": ed(M.placeholder),
|
|
5446
5570
|
...e.maxHeight === void 0 ? {} : {
|
|
5447
5571
|
maxHeight: e.maxHeight,
|
|
5448
5572
|
overflowY: "auto"
|
|
5449
5573
|
}
|
|
5450
5574
|
}), [M.placeholder, e.maxHeight]), ae = r((e) => {
|
|
5451
|
-
|
|
5452
|
-
}, [
|
|
5575
|
+
re(e);
|
|
5576
|
+
}, [re]), oe = r(() => {
|
|
5453
5577
|
n(""), E.current && w.current?.updateQuery(D.current);
|
|
5454
5578
|
}, []), se = r((e) => {
|
|
5455
5579
|
n(e instanceof Error ? e.message : M.initError);
|
|
@@ -5473,7 +5597,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5473
5597
|
}, N = () => {
|
|
5474
5598
|
O.cancel();
|
|
5475
5599
|
let e = w.current;
|
|
5476
|
-
e?.clear(), S(
|
|
5600
|
+
e?.clear(), S(Qu), g(!1), v(!1), e && requestAnimationFrame(e.focusCurrent);
|
|
5477
5601
|
}, pe = (e) => {
|
|
5478
5602
|
O.cancel(), b(e), w.current?.updateQuery(e);
|
|
5479
5603
|
}, me = (e) => {
|
|
@@ -5511,7 +5635,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5511
5635
|
"data-search-open": h ? "true" : "false",
|
|
5512
5636
|
"data-search-replace-expanded": !A && _ ? "true" : "false",
|
|
5513
5637
|
"data-search-invalid": h && x.isInvalidExpression ? "true" : "false",
|
|
5514
|
-
"data-readonly-label":
|
|
5638
|
+
"data-readonly-label": j,
|
|
5515
5639
|
onKeyDownCapture: (e) => {
|
|
5516
5640
|
if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey && e.key.toLowerCase() === "f") {
|
|
5517
5641
|
e.preventDefault(), fe();
|
|
@@ -5541,7 +5665,7 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5541
5665
|
className: "zt-md-error",
|
|
5542
5666
|
children: t
|
|
5543
5667
|
}) : null,
|
|
5544
|
-
h ? /* @__PURE__ */ P(
|
|
5668
|
+
h ? /* @__PURE__ */ P(Kt, {
|
|
5545
5669
|
options: y,
|
|
5546
5670
|
snapshot: x,
|
|
5547
5671
|
messages: M,
|
|
@@ -5564,19 +5688,19 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5564
5688
|
"aria-readonly": A,
|
|
5565
5689
|
onMouseDown: ce,
|
|
5566
5690
|
style: ie,
|
|
5567
|
-
children: [a && d ? /* @__PURE__ */ P(u, { children: /* @__PURE__ */ P(
|
|
5568
|
-
markdown:
|
|
5691
|
+
children: [a && d ? /* @__PURE__ */ P(u, { children: /* @__PURE__ */ P(td, {
|
|
5692
|
+
markdown: ne,
|
|
5569
5693
|
locale: e.locale,
|
|
5570
5694
|
portalContainer: a,
|
|
5571
5695
|
contentPortalContainer: d,
|
|
5572
5696
|
focusEditorRef: C,
|
|
5573
5697
|
searchControllerRef: w,
|
|
5574
5698
|
readOnly: A,
|
|
5575
|
-
debounceMs:
|
|
5699
|
+
debounceMs: ee,
|
|
5576
5700
|
messages: M,
|
|
5577
5701
|
slashMenu: e.slashMenu,
|
|
5578
5702
|
imageUpload: e.imageUpload,
|
|
5579
|
-
shortcutMode:
|
|
5703
|
+
shortcutMode: te,
|
|
5580
5704
|
onMarkdownChange: ae,
|
|
5581
5705
|
onInitReady: oe,
|
|
5582
5706
|
onInitError: se,
|
|
@@ -5595,4 +5719,4 @@ var ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5595
5719
|
});
|
|
5596
5720
|
};
|
|
5597
5721
|
//#endregion
|
|
5598
|
-
export {
|
|
5722
|
+
export { nd as MilkdownEditor };
|