@qingwu-ui/ai-editor 0.9.0-beta.16 → 0.9.0-beta.17
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/components/toc.d.ts +5 -0
- package/dist/components/toc.d.ts.map +1 -1
- package/dist/editor/ai-editor.d.ts.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +222 -203
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20,45 +20,45 @@ import { CharacterCount as K } from "@tiptap/extension-character-count";
|
|
|
20
20
|
import { Color as q } from "@tiptap/extension-color";
|
|
21
21
|
import { Highlight as se } from "@tiptap/extension-highlight";
|
|
22
22
|
import { HorizontalRule as ce } from "@tiptap/extension-horizontal-rule";
|
|
23
|
-
import { Placeholder as
|
|
24
|
-
import { Table as
|
|
25
|
-
import { TableCell as
|
|
26
|
-
import { TableHeader as
|
|
27
|
-
import { TableRow as
|
|
28
|
-
import { TaskItem as
|
|
29
|
-
import { TaskList as
|
|
30
|
-
import { TextStyle as
|
|
31
|
-
import { Markdown as
|
|
32
|
-
import { CodeBlockLowlight as
|
|
33
|
-
import
|
|
34
|
-
import { common as
|
|
35
|
-
import
|
|
23
|
+
import { Placeholder as le } from "@tiptap/extension-placeholder";
|
|
24
|
+
import { Table as ue } from "@tiptap/extension-table";
|
|
25
|
+
import { TableCell as de } from "@tiptap/extension-table-cell";
|
|
26
|
+
import { TableHeader as fe } from "@tiptap/extension-table-header";
|
|
27
|
+
import { TableRow as pe } from "@tiptap/extension-table-row";
|
|
28
|
+
import { TaskItem as me } from "@tiptap/extension-task-item";
|
|
29
|
+
import { TaskList as he } from "@tiptap/extension-task-list";
|
|
30
|
+
import { TextStyle as ge } from "@tiptap/extension-text-style";
|
|
31
|
+
import { Markdown as _e } from "tiptap-markdown";
|
|
32
|
+
import { CodeBlockLowlight as ve } from "@tiptap/extension-code-block-lowlight";
|
|
33
|
+
import ye from "highlight.js/lib/languages/dockerfile";
|
|
34
|
+
import { common as be, createLowlight as xe } from "lowlight";
|
|
35
|
+
import Se, { exitSuggestion as Ce, findSuggestionMatch as we } from "@tiptap/suggestion";
|
|
36
36
|
//#region ../text-layout/dist/index.mjs
|
|
37
|
-
var
|
|
38
|
-
function
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
var
|
|
42
|
-
function
|
|
43
|
-
let n =
|
|
44
|
-
n || (n = /* @__PURE__ */ new Map(),
|
|
37
|
+
var Te = null, Ee = null;
|
|
38
|
+
function De() {
|
|
39
|
+
return Ee || (typeof document > "u" ? null : (Te = document.createElement("canvas"), Ee = Te.getContext("2d"), Ee));
|
|
40
|
+
}
|
|
41
|
+
var Oe = /* @__PURE__ */ new Map();
|
|
42
|
+
function ke(e, t) {
|
|
43
|
+
let n = Oe.get(t);
|
|
44
|
+
n || (n = /* @__PURE__ */ new Map(), Oe.set(t, n));
|
|
45
45
|
let r = n.get(e);
|
|
46
46
|
if (r !== void 0) return r;
|
|
47
|
-
let i =
|
|
48
|
-
return i ? (i.font = t, r = i.measureText(e).width) : r =
|
|
47
|
+
let i = De();
|
|
48
|
+
return i ? (i.font = t, r = i.measureText(e).width) : r = Ae(e, t), n.set(e, r), r;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function Ae(e, t) {
|
|
51
51
|
let n = parseFloat(t) || 16, r = 0;
|
|
52
|
-
for (let t of e)
|
|
52
|
+
for (let t of e) je(t.codePointAt(0) ?? 0) ? r += n : t === " " ? r += n * .3 : r += n * .55;
|
|
53
53
|
return r;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function je(e) {
|
|
56
56
|
return e >= 19968 && e <= 40959 || e >= 13312 && e <= 19903 || e >= 131072 && e <= 173791 || e >= 63744 && e <= 64255 || e >= 194560 && e <= 195103 || e >= 12288 && e <= 12351 || e >= 65280 && e <= 65519 || e >= 11904 && e <= 12031 || e >= 12736 && e <= 12783 || e >= 44032 && e <= 55215;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function Me(e) {
|
|
59
59
|
return e === 12289 || e === 12290 || e === 65292 || e === 65294 || e === 65306 || e === 65307 || e === 65311 || e === 65281 || e === 65289 || e === 65341 || e === 12301 || e === 12303 || e === 12299 || e === 12305;
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function J(e, t) {
|
|
62
62
|
let n = [], r = [];
|
|
63
63
|
if (typeof Intl < "u" && Intl.Segmenter) try {
|
|
64
64
|
let t = new Intl.Segmenter("zh", { granularity: "grapheme" });
|
|
@@ -69,27 +69,27 @@ function je(e, t) {
|
|
|
69
69
|
else r = [...e];
|
|
70
70
|
for (let e of r) {
|
|
71
71
|
let r = e.codePointAt(0) ?? 0, i = "latin";
|
|
72
|
-
e === "\n" ? i = "break" : e === " " || e === " " ? i = "space" :
|
|
72
|
+
e === "\n" ? i = "break" : e === " " || e === " " ? i = "space" : je(r) && (i = Me(r) ? "punct" : "cjk"), n.push({
|
|
73
73
|
text: e,
|
|
74
|
-
width:
|
|
74
|
+
width: ke(e, t),
|
|
75
75
|
type: i
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
return n;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function Ne(e, t, n) {
|
|
81
81
|
let r = 0, i = Math.min(n, e.length);
|
|
82
82
|
for (let n = t; n < i; n++) r += e[n].width;
|
|
83
83
|
return r;
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function Y(e, t, n, r) {
|
|
86
86
|
return {
|
|
87
87
|
text: e.slice(t, Math.min(n, e.length)).map((e) => e.text).join(""),
|
|
88
88
|
width: r
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
function Pe(e, t, n = "16px system-ui") {
|
|
92
|
-
let { maxWidth: r, lineHeight: i, maxLines: a, overflowWrap: o = "break-word" } = t, s =
|
|
92
|
+
let { maxWidth: r, lineHeight: i, maxLines: a, overflowWrap: o = "break-word" } = t, s = J(e, n), c = [], l = {
|
|
93
93
|
lineStart: 0,
|
|
94
94
|
lineWidth: 0,
|
|
95
95
|
lastBreakIdx: -1,
|
|
@@ -98,28 +98,28 @@ function Pe(e, t, n = "16px system-ui") {
|
|
|
98
98
|
for (let e = 0; e < s.length; e++) {
|
|
99
99
|
let t = s[e];
|
|
100
100
|
if (t.type === "break") {
|
|
101
|
-
c.push(
|
|
101
|
+
c.push(Y(s, l.lineStart, e, l.lineWidth)), l.lineStart = e + 1, l.lineWidth = 0, l.lastBreakIdx = -1;
|
|
102
102
|
continue;
|
|
103
103
|
}
|
|
104
104
|
let n = l.lineWidth + t.width;
|
|
105
105
|
if (t.type === "space") {
|
|
106
|
-
if (n > r && l.lineWidth > 0 ? (l.lastBreakIdx >= 0 ? (c.push(
|
|
106
|
+
if (n > r && l.lineWidth > 0 ? (l.lastBreakIdx >= 0 ? (c.push(Y(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Ne(s, l.lineStart, e + 1)) : (c.push(Y(s, l.lineStart, e, l.lineWidth)), l.lineStart = e, l.lineWidth = t.width), l.lastBreakIdx = -1) : (l.lineWidth = n, l.lastBreakIdx = e, l.lastBreakWidth = l.lineWidth), a && c.length >= a) break;
|
|
107
107
|
continue;
|
|
108
108
|
}
|
|
109
109
|
if (t.type === "cjk") {
|
|
110
|
-
if (n > r && l.lineWidth > 0 ? (c.push(
|
|
110
|
+
if (n > r && l.lineWidth > 0 ? (c.push(Y(s, l.lineStart, e, l.lineWidth)), l.lineStart = e, l.lineWidth = t.width, l.lastBreakIdx = -1) : (l.lineWidth = n, l.lastBreakIdx = e, l.lastBreakWidth = l.lineWidth), a && c.length >= a) break;
|
|
111
111
|
continue;
|
|
112
112
|
}
|
|
113
113
|
if (t.type === "punct") {
|
|
114
|
-
if (l.lineWidth === 0 && c.length > 0 ? c[c.length - 1].text.length > 0 && (l.lineWidth = t.width) : n > r ? (l.lastBreakIdx >= 0 ? (c.push(
|
|
114
|
+
if (l.lineWidth === 0 && c.length > 0 ? c[c.length - 1].text.length > 0 && (l.lineWidth = t.width) : n > r ? (l.lastBreakIdx >= 0 ? (c.push(Y(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Ne(s, l.lineStart, e + 1)) : l.lineWidth = n, l.lastBreakIdx = -1) : l.lineWidth = n, a && c.length >= a) break;
|
|
115
115
|
continue;
|
|
116
116
|
}
|
|
117
|
-
if (n > r && l.lineWidth > 0 ? l.lastBreakIdx >= 0 ? (c.push(
|
|
117
|
+
if (n > r && l.lineWidth > 0 ? l.lastBreakIdx >= 0 ? (c.push(Y(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Ne(s, l.lineStart, e + 1), l.lastBreakIdx = -1) : o === "break-word" ? (c.push(Y(s, l.lineStart, e, l.lineWidth)), l.lineStart = e, l.lineWidth = t.width) : l.lineWidth = n : l.lineWidth = n, a && c.length >= a) break;
|
|
118
118
|
}
|
|
119
119
|
let u = l.lineStart < s.length;
|
|
120
120
|
if (u && (!a || c.length < a)) {
|
|
121
|
-
let e =
|
|
122
|
-
c.push(
|
|
121
|
+
let e = Ne(s, l.lineStart, s.length);
|
|
122
|
+
c.push(Y(s, l.lineStart, s.length, e));
|
|
123
123
|
}
|
|
124
124
|
return {
|
|
125
125
|
lines: c,
|
|
@@ -131,12 +131,12 @@ function Pe(e, t, n = "16px system-ui") {
|
|
|
131
131
|
//#endregion
|
|
132
132
|
//#region ../toast/dist/index.mjs
|
|
133
133
|
var Fe = typeof window < "u" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, Ie = "13.5px -apple-system, BlinkMacSystemFont, \"SF Pro Text\", \"PingFang SC\", \"Microsoft YaHei\", system-ui, sans-serif";
|
|
134
|
-
function
|
|
134
|
+
function Le() {
|
|
135
135
|
if (typeof window > "u") return 290;
|
|
136
136
|
let e = window.innerWidth;
|
|
137
137
|
return e <= 480 ? Math.max(140, e - 98) : 290;
|
|
138
138
|
}
|
|
139
|
-
var
|
|
139
|
+
var X = {
|
|
140
140
|
info: "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"12\" y1=\"16\" x2=\"12\" y2=\"12\"/><line x1=\"12\" y1=\"8\" x2=\"12.01\" y2=\"8\"/></svg>",
|
|
141
141
|
success: "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"M9 12l2 2 4-4\"/></svg>",
|
|
142
142
|
warning: "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z\"/><line x1=\"12\" y1=\"9\" x2=\"12\" y2=\"13\"/><line x1=\"12\" y1=\"17\" x2=\"12.01\" y2=\"17\"/></svg>",
|
|
@@ -278,9 +278,9 @@ var Ge = class {
|
|
|
278
278
|
let s = Be("div", `qt-toast qt-${n}${i == null ? "" : " qt-truncate"}${a || o ? " qt-rich" : ""}`);
|
|
279
279
|
s.setAttribute("data-qt-id", e);
|
|
280
280
|
let c = Be("span", "qt-icon");
|
|
281
|
-
c.innerHTML =
|
|
281
|
+
c.innerHTML = X[n], s.appendChild(c);
|
|
282
282
|
let l = Be("div", "qt-body"), u = Be("span", "qt-msg"), d = Pe(t, {
|
|
283
|
-
maxWidth:
|
|
283
|
+
maxWidth: Le(),
|
|
284
284
|
lineHeight: 1,
|
|
285
285
|
maxLines: i
|
|
286
286
|
}, Ie);
|
|
@@ -2918,28 +2918,28 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2918
2918
|
x(() => {
|
|
2919
2919
|
l(U ? Cn.has(U) : !1);
|
|
2920
2920
|
}, [U]);
|
|
2921
|
-
let
|
|
2921
|
+
let le = b(() => {
|
|
2922
2922
|
I.current = !0, ce(!0), window.setTimeout(() => {
|
|
2923
2923
|
window.scrollTo(0, P.current), L.current && (L.current.scrollTop = ee.current), I.current && ce(!0), I.current = !1;
|
|
2924
2924
|
}, 0);
|
|
2925
|
-
}, [ce]),
|
|
2926
|
-
z === "web" ? (B("none"), document.body.style.overflow = "",
|
|
2927
|
-
}, [z]),
|
|
2925
|
+
}, [ce]), ue = b(async () => {
|
|
2926
|
+
z === "web" ? (B("none"), document.body.style.overflow = "", le()) : (z === "native" && document.fullscreenElement && await document.exitFullscreen(), P.current = window.scrollY, ee.current = L.current?.scrollTop ?? 0, document.body.style.overflow = "hidden", B("web"));
|
|
2927
|
+
}, [z]), de = b(async () => {
|
|
2928
2928
|
let e = M.current;
|
|
2929
2929
|
e && (z === "native" ? await document.exitFullscreen() : (z === "web" && (B("none"), document.body.style.overflow = ""), P.current = window.scrollY, ee.current = L.current?.scrollTop ?? 0, await e.requestFullscreen(), B("native")));
|
|
2930
|
-
}, [z,
|
|
2930
|
+
}, [z, le]), fe = b(() => {
|
|
2931
2931
|
z === "none" && (I.current || ce((e) => !e));
|
|
2932
2932
|
}, [z]);
|
|
2933
2933
|
x(() => {
|
|
2934
2934
|
let e = () => {
|
|
2935
|
-
document.fullscreenElement || (z === "native" && B("none"),
|
|
2935
|
+
document.fullscreenElement || (z === "native" && B("none"), le());
|
|
2936
2936
|
}, t = (e) => {
|
|
2937
|
-
e.key === "Escape" && z === "web" && (B("none"), document.body.style.overflow = "",
|
|
2937
|
+
e.key === "Escape" && z === "web" && (B("none"), document.body.style.overflow = "", le());
|
|
2938
2938
|
};
|
|
2939
2939
|
return document.addEventListener("fullscreenchange", e), window.addEventListener("keydown", t), () => {
|
|
2940
2940
|
document.removeEventListener("fullscreenchange", e), window.removeEventListener("keydown", t);
|
|
2941
2941
|
};
|
|
2942
|
-
}, [z,
|
|
2942
|
+
}, [z, le]), x(() => {
|
|
2943
2943
|
let e = (e) => {
|
|
2944
2944
|
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && i && !mn()) {
|
|
2945
2945
|
if (e.preventDefault(), e.stopPropagation(), a) {
|
|
@@ -3018,7 +3018,7 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3018
3018
|
let e = window.setTimeout(() => A(null), 2400);
|
|
3019
3019
|
return () => window.clearTimeout(e);
|
|
3020
3020
|
}, [k]);
|
|
3021
|
-
let
|
|
3021
|
+
let pe = b(async () => {
|
|
3022
3022
|
E(!0), A("loading");
|
|
3023
3023
|
try {
|
|
3024
3024
|
if (p) {
|
|
@@ -3149,7 +3149,7 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3149
3149
|
type: "button",
|
|
3150
3150
|
className: "att-btn",
|
|
3151
3151
|
onMouseDown: (e) => {
|
|
3152
|
-
e.preventDefault(), e.stopPropagation(),
|
|
3152
|
+
e.preventDefault(), e.stopPropagation(), fe();
|
|
3153
3153
|
},
|
|
3154
3154
|
title: f("editor.attachment.preview"),
|
|
3155
3155
|
"aria-label": f("editor.attachment.preview"),
|
|
@@ -3175,7 +3175,7 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3175
3175
|
/* @__PURE__ */ D("button", {
|
|
3176
3176
|
type: "button",
|
|
3177
3177
|
className: "att-btn",
|
|
3178
|
-
onClick:
|
|
3178
|
+
onClick: pe,
|
|
3179
3179
|
disabled: S || q,
|
|
3180
3180
|
title: S ? "正在准备下载" : f("editor.attachment.download"),
|
|
3181
3181
|
"aria-label": S ? "正在准备下载" : f("editor.attachment.download"),
|
|
@@ -3289,7 +3289,7 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3289
3289
|
},
|
|
3290
3290
|
children: [/* @__PURE__ */ D("button", {
|
|
3291
3291
|
type: "button",
|
|
3292
|
-
onClick:
|
|
3292
|
+
onClick: ue,
|
|
3293
3293
|
title: z === "web" ? "退出网页全屏" : "网页全屏",
|
|
3294
3294
|
"aria-label": z === "web" ? "退出网页全屏" : "网页全屏",
|
|
3295
3295
|
style: {
|
|
@@ -3327,7 +3327,7 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3327
3327
|
})
|
|
3328
3328
|
}), /* @__PURE__ */ D("button", {
|
|
3329
3329
|
type: "button",
|
|
3330
|
-
onClick:
|
|
3330
|
+
onClick: de,
|
|
3331
3331
|
title: z === "native" ? "退出全屏" : "全屏",
|
|
3332
3332
|
"aria-label": z === "native" ? "退出全屏" : "全屏",
|
|
3333
3333
|
style: {
|
|
@@ -4590,7 +4590,7 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4590
4590
|
}, [e.textContent]), ce = b(() => {
|
|
4591
4591
|
let t = Xn[V] || "txt", n = t ? `code.${t}` : "code.txt", r = new Blob([e.textContent], { type: "text/plain;charset=utf-8" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
4592
4592
|
a.href = i, a.download = n, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
4593
|
-
}, [e.textContent, V]),
|
|
4593
|
+
}, [e.textContent, V]), le = b(async () => {
|
|
4594
4594
|
if (N || L) {
|
|
4595
4595
|
P(null), I(null), ee(!1);
|
|
4596
4596
|
return;
|
|
@@ -4613,7 +4613,7 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4613
4613
|
e.textContent,
|
|
4614
4614
|
N,
|
|
4615
4615
|
L
|
|
4616
|
-
]),
|
|
4616
|
+
]), ue = /* @__PURE__ */ O(E, { children: [H ? H.deviconClass ? /* @__PURE__ */ D("i", {
|
|
4617
4617
|
className: `${H.deviconClass} colored cb-lang-icon`,
|
|
4618
4618
|
style: { color: H.color }
|
|
4619
4619
|
}) : /* @__PURE__ */ D("span", {
|
|
@@ -4641,13 +4641,13 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4641
4641
|
contentEditable: !1,
|
|
4642
4642
|
children: s ? /* @__PURE__ */ D("span", {
|
|
4643
4643
|
className: "cb-lang-trigger cb-lang-trigger--static",
|
|
4644
|
-
children:
|
|
4644
|
+
children: ue
|
|
4645
4645
|
}) : /* @__PURE__ */ O("button", {
|
|
4646
4646
|
ref: re,
|
|
4647
4647
|
type: "button",
|
|
4648
4648
|
className: "cb-lang-trigger",
|
|
4649
4649
|
onClick: () => m(!f),
|
|
4650
|
-
children: [
|
|
4650
|
+
children: [ue, /* @__PURE__ */ D("svg", {
|
|
4651
4651
|
className: `cb-lang-chevron${f ? " cb-lang-chevron--open" : ""}`,
|
|
4652
4652
|
width: "10",
|
|
4653
4653
|
height: "10",
|
|
@@ -4844,7 +4844,7 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4844
4844
|
ae && /* @__PURE__ */ D("button", {
|
|
4845
4845
|
type: "button",
|
|
4846
4846
|
className: "cb-btn cb-btn--diagram",
|
|
4847
|
-
onClick:
|
|
4847
|
+
onClick: le,
|
|
4848
4848
|
contentEditable: !1,
|
|
4849
4849
|
title: N || L ? "取消渲染" : "渲染图表",
|
|
4850
4850
|
disabled: L,
|
|
@@ -5003,8 +5003,8 @@ var $n = [
|
|
|
5003
5003
|
value: "mermaid",
|
|
5004
5004
|
label: "Mermaid"
|
|
5005
5005
|
}
|
|
5006
|
-
], er = be
|
|
5007
|
-
er.register({ dockerfile:
|
|
5006
|
+
], er = xe(be);
|
|
5007
|
+
er.register({ dockerfile: ye }), er.registerAlias("xml", ["vue", "html"]), er.registerAlias("javascript", ["react", "jsx"]), er.registerAlias("typescript", ["tsx"]);
|
|
5008
5008
|
function tr(e) {
|
|
5009
5009
|
return e ? e.split("\n") : [""];
|
|
5010
5010
|
}
|
|
@@ -5071,7 +5071,7 @@ function ir(e, t, n) {
|
|
|
5071
5071
|
r = e + 1 < C.length ? C[e + 1] - C[e] : w - T, (!Number.isFinite(r) || r < 1) && (r = c), t.style.height = `${r}px`, T += r;
|
|
5072
5072
|
}
|
|
5073
5073
|
}
|
|
5074
|
-
var ar =
|
|
5074
|
+
var ar = ve.extend({
|
|
5075
5075
|
addNodeView() {
|
|
5076
5076
|
return (e) => {
|
|
5077
5077
|
let { node: t, editor: n, getPos: r } = e, i = t, a = (e) => {
|
|
@@ -5870,7 +5870,7 @@ function ni(e) {
|
|
|
5870
5870
|
findSuggestionMatch: (e) => {
|
|
5871
5871
|
let { $position: t } = e;
|
|
5872
5872
|
for (let e = t.depth; e >= 0; e--) if (t.node(e).type.name === "codeBlock") return null;
|
|
5873
|
-
return t.marks().some((e) => e.type.name === "code") ? null :
|
|
5873
|
+
return t.marks().some((e) => e.type.name === "code") ? null : we(e);
|
|
5874
5874
|
},
|
|
5875
5875
|
allow: ({ editor: e, state: t }) => {
|
|
5876
5876
|
if (!e.isEditable) return !1;
|
|
@@ -5952,7 +5952,7 @@ function ni(e) {
|
|
|
5952
5952
|
if (e.key === "Escape") {
|
|
5953
5953
|
e.preventDefault();
|
|
5954
5954
|
let t = a?.view;
|
|
5955
|
-
t &&
|
|
5955
|
+
t && Ce(t, ti);
|
|
5956
5956
|
}
|
|
5957
5957
|
});
|
|
5958
5958
|
}
|
|
@@ -5970,7 +5970,7 @@ function ni(e) {
|
|
|
5970
5970
|
if (!e || e.style.display === "none" || n.target instanceof Node && e.contains(n.target) || t) return;
|
|
5971
5971
|
let r = a?.view;
|
|
5972
5972
|
r && (t = !0, window.setTimeout(() => {
|
|
5973
|
-
t = !1, e?.style.display !== "none" &&
|
|
5973
|
+
t = !1, e?.style.display !== "none" && Ce(r, ti);
|
|
5974
5974
|
}, 0));
|
|
5975
5975
|
}, document.addEventListener("mousedown", o, !0), document.addEventListener("touchstart", o, !0);
|
|
5976
5976
|
}
|
|
@@ -5994,7 +5994,7 @@ function ni(e) {
|
|
|
5994
5994
|
};
|
|
5995
5995
|
}
|
|
5996
5996
|
};
|
|
5997
|
-
return [
|
|
5997
|
+
return [Se({
|
|
5998
5998
|
editor: this.editor,
|
|
5999
5999
|
...t
|
|
6000
6000
|
}), new z({
|
|
@@ -6207,24 +6207,24 @@ function ai(e = {}) {
|
|
|
6207
6207
|
inline: !1,
|
|
6208
6208
|
allowBase64: !0
|
|
6209
6209
|
}),
|
|
6210
|
-
me,
|
|
6211
|
-
pe.configure({ nested: !0 }),
|
|
6212
|
-
se.configure({ multicolor: !0 }),
|
|
6213
6210
|
he,
|
|
6211
|
+
me.configure({ nested: !0 }),
|
|
6212
|
+
se.configure({ multicolor: !0 }),
|
|
6213
|
+
ge,
|
|
6214
6214
|
q,
|
|
6215
6215
|
K.configure(e.maxLength ? { limit: e.maxLength } : {}),
|
|
6216
6216
|
ce,
|
|
6217
6217
|
ar,
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
ue,
|
|
6218
|
+
ue.configure({ resizable: !0 }),
|
|
6219
|
+
pe,
|
|
6221
6220
|
de,
|
|
6222
|
-
|
|
6221
|
+
fe,
|
|
6222
|
+
_e.configure({
|
|
6223
6223
|
html: !0,
|
|
6224
6224
|
transformPastedText: !0,
|
|
6225
6225
|
transformCopiedText: !1
|
|
6226
6226
|
}),
|
|
6227
|
-
|
|
6227
|
+
le.configure({ placeholder: e.placeholder || "输入 '/' 打开菜单…" }),
|
|
6228
6228
|
ni(() => ri((e) => f(e), {
|
|
6229
6229
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
6230
6230
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
@@ -6710,13 +6710,13 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6710
6710
|
children: /* @__PURE__ */ D("div", { className: "w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin" })
|
|
6711
6711
|
})]
|
|
6712
6712
|
}), ki = ({ initialContent: e = "", onChange: t, placeholder: n, mode: r, readonly: i = !1, maxLength: a, maxAttachmentSize: o, maxTotalAttachmentSize: s, className: c = "", borderless: l = !1, style: u, showToolbar: p = !0, showToc: m = !0, showSearch: h = !0, onEditorReady: g, immediatelyRender: _, onToast: y }) => {
|
|
6713
|
-
let k = r === "view" || i, A = C(() => typeof e == "object" && e || xi(e) ? e : d(e), [e]), [j, M] = T(!1), [F, I] = T({}), [L, R] = T("below"), [re, ie] = T(50), z = w(null), [B, V] = T(!1), [H, ae] = T(!1), [oe, U] = T(!1), [W, G] = T(!1), [K, q] = T("none"), [se, ce] = T({}), [
|
|
6713
|
+
let k = r === "view" || i, A = C(() => typeof e == "object" && e || xi(e) ? e : d(e), [e]), [j, M] = T(!1), [F, I] = T({}), [L, R] = T("below"), [re, ie] = T(50), z = w(null), [B, V] = T(!1), [H, ae] = T(!1), [oe, U] = T(!1), [W, G] = T(!1), [K, q] = T("none"), [se, ce] = T({}), [le, ue] = T(""), [de, fe] = T(null), [pe, me] = T(m), [he, ge] = T(!1);
|
|
6714
6714
|
x(() => {
|
|
6715
|
-
|
|
6715
|
+
me(m);
|
|
6716
6716
|
}, [m]);
|
|
6717
|
-
let [
|
|
6718
|
-
let e =
|
|
6719
|
-
e && (
|
|
6717
|
+
let [_e, ve] = T(!1), [ye, be] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 80rem)").matches : !0), [xe, Se] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 64rem)").matches : !0), Ce = w(null), we = w(null), Te = w(null), Ee = w(0), De = w(null), Oe = w(null), ke = w(null), Ae = w(null), [je, Me] = T(!1), [J, Ne] = T(!1), [Y, Pe] = T(!1), Fe = w(null), Ie = b(() => {
|
|
6718
|
+
let e = we.current, t = Te.current;
|
|
6719
|
+
e && (J ? (document.body.style.overflow = "", Object.assign(e.style, {
|
|
6720
6720
|
position: "",
|
|
6721
6721
|
top: "",
|
|
6722
6722
|
left: "",
|
|
@@ -6732,9 +6732,9 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6732
6732
|
flex: "",
|
|
6733
6733
|
overflow: "",
|
|
6734
6734
|
minHeight: ""
|
|
6735
|
-
}),
|
|
6736
|
-
window.scrollTo(0,
|
|
6737
|
-
})) : (document.fullscreenElement && document.exitFullscreen(),
|
|
6735
|
+
}), Ne(!1), requestAnimationFrame(() => {
|
|
6736
|
+
window.scrollTo(0, Ee.current);
|
|
6737
|
+
})) : (document.fullscreenElement && document.exitFullscreen(), Ee.current = window.scrollY, Object.assign(e.style, {
|
|
6738
6738
|
position: "fixed",
|
|
6739
6739
|
top: "0",
|
|
6740
6740
|
left: "0",
|
|
@@ -6750,39 +6750,39 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6750
6750
|
flex: "1",
|
|
6751
6751
|
overflow: "auto",
|
|
6752
6752
|
minHeight: "0"
|
|
6753
|
-
}), document.body.style.overflow = "hidden",
|
|
6754
|
-
}, [
|
|
6755
|
-
let e =
|
|
6756
|
-
e && (document.fullscreenElement ? document.exitFullscreen() : (
|
|
6757
|
-
}, [
|
|
6753
|
+
}), document.body.style.overflow = "hidden", Ne(!0)));
|
|
6754
|
+
}, [J]), Le = b(() => {
|
|
6755
|
+
let e = we.current;
|
|
6756
|
+
e && (document.fullscreenElement ? document.exitFullscreen() : (J && Ie(), Ee.current = window.scrollY, e.requestFullscreen()));
|
|
6757
|
+
}, [J, Ie]);
|
|
6758
6758
|
x(() => {
|
|
6759
6759
|
let e = (e) => {
|
|
6760
|
-
e.key === "Escape" &&
|
|
6760
|
+
e.key === "Escape" && J && Ie();
|
|
6761
6761
|
}, t = () => {
|
|
6762
|
-
document.fullscreenElement ?
|
|
6763
|
-
window.scrollTo(0,
|
|
6762
|
+
document.fullscreenElement ? Pe(!0) : (Pe(!1), requestAnimationFrame(() => {
|
|
6763
|
+
window.scrollTo(0, Ee.current);
|
|
6764
6764
|
}));
|
|
6765
6765
|
};
|
|
6766
6766
|
return window.addEventListener("keydown", e), document.addEventListener("fullscreenchange", t), () => {
|
|
6767
6767
|
window.removeEventListener("keydown", e), document.removeEventListener("fullscreenchange", t);
|
|
6768
6768
|
};
|
|
6769
|
-
}, [
|
|
6769
|
+
}, [J, Ie]), x(() => {
|
|
6770
6770
|
if (!h) return;
|
|
6771
6771
|
let e = (e) => {
|
|
6772
6772
|
if ((e.ctrlKey || e.metaKey) && (e.key === "f" || e.key === "F")) {
|
|
6773
|
-
if (!
|
|
6774
|
-
e.preventDefault(), e.stopPropagation(),
|
|
6773
|
+
if (!we.current) return;
|
|
6774
|
+
e.preventDefault(), e.stopPropagation(), ve(!0);
|
|
6775
6775
|
}
|
|
6776
6776
|
};
|
|
6777
6777
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
6778
6778
|
}, [h]), x(() => {
|
|
6779
6779
|
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
6780
|
-
let e = window.matchMedia("(min-width: 80rem)"), t = (e) =>
|
|
6781
|
-
return
|
|
6780
|
+
let e = window.matchMedia("(min-width: 80rem)"), t = (e) => be(e.matches);
|
|
6781
|
+
return be(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
6782
6782
|
}, []), x(() => {
|
|
6783
6783
|
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
6784
|
-
let e = window.matchMedia("(min-width: 64rem)"), t = (e) =>
|
|
6785
|
-
return
|
|
6784
|
+
let e = window.matchMedia("(min-width: 64rem)"), t = (e) => Se(e.matches);
|
|
6785
|
+
return Se(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
6786
6786
|
}, []);
|
|
6787
6787
|
let X = ee({
|
|
6788
6788
|
extensions: ai({
|
|
@@ -6795,7 +6795,7 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6795
6795
|
editable: !k,
|
|
6796
6796
|
immediatelyRender: _,
|
|
6797
6797
|
onUpdate: ({ editor: e }) => {
|
|
6798
|
-
t && (
|
|
6798
|
+
t && (Ce.current && clearTimeout(Ce.current), Ce.current = setTimeout(() => {
|
|
6799
6799
|
t?.(e.getHTML(), e.getJSON());
|
|
6800
6800
|
}, 300));
|
|
6801
6801
|
},
|
|
@@ -6811,9 +6811,9 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6811
6811
|
let r = n.getData("text/plain");
|
|
6812
6812
|
if (!r || !r.includes("[[")) return !1;
|
|
6813
6813
|
t.preventDefault();
|
|
6814
|
-
let i =
|
|
6814
|
+
let i = Oe.current?.storage?.relativeMedia;
|
|
6815
6815
|
i && (i.clipboardFiles = new Map(Array.from(n.files ?? []).map((e) => [e.name.toLowerCase(), e])), i.pausedUntilPaste = !1);
|
|
6816
|
-
let a =
|
|
6816
|
+
let a = Oe.current ? Si(Oe.current, r) : null;
|
|
6817
6817
|
if (a) {
|
|
6818
6818
|
let t = new N(a, 0, 0);
|
|
6819
6819
|
e.dispatch(e.state.tr.replaceSelection(t).scrollIntoView());
|
|
@@ -6823,7 +6823,7 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6823
6823
|
}
|
|
6824
6824
|
});
|
|
6825
6825
|
x(() => {
|
|
6826
|
-
|
|
6826
|
+
Oe.current = X, window.__editor = X;
|
|
6827
6827
|
}, [X]), x(() => {
|
|
6828
6828
|
if (X) return () => Yt(X);
|
|
6829
6829
|
}, [X]), x(() => {
|
|
@@ -6831,7 +6831,7 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6831
6831
|
}, [X, g]), x(() => {
|
|
6832
6832
|
if (!X) return;
|
|
6833
6833
|
let e = () => {
|
|
6834
|
-
X.state.selection.empty && (q("none"),
|
|
6834
|
+
X.state.selection.empty && (q("none"), Me(!1));
|
|
6835
6835
|
};
|
|
6836
6836
|
return X.on("selectionUpdate", e), () => {
|
|
6837
6837
|
X.off("selectionUpdate", e);
|
|
@@ -6849,10 +6849,10 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6849
6849
|
o,
|
|
6850
6850
|
s
|
|
6851
6851
|
]);
|
|
6852
|
-
let
|
|
6852
|
+
let Re = w(e);
|
|
6853
6853
|
x(() => {
|
|
6854
|
-
if (!X || e ===
|
|
6855
|
-
|
|
6854
|
+
if (!X || e === Re.current) return;
|
|
6855
|
+
Re.current = e;
|
|
6856
6856
|
let t = typeof e == "object" && e || xi(e) ? e : d(e);
|
|
6857
6857
|
X.commands.setContent(t, { emitUpdate: !1 });
|
|
6858
6858
|
}, [X, e]), x(() => {
|
|
@@ -6875,53 +6875,53 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6875
6875
|
o,
|
|
6876
6876
|
s
|
|
6877
6877
|
]);
|
|
6878
|
-
let
|
|
6879
|
-
let t =
|
|
6880
|
-
q(e),
|
|
6878
|
+
let ze = b((e) => {
|
|
6879
|
+
let t = Ae.current?.getBoundingClientRect();
|
|
6880
|
+
q(e), Me(!1), ce({
|
|
6881
6881
|
position: "fixed",
|
|
6882
6882
|
top: t ? t.bottom + 8 : void 0,
|
|
6883
6883
|
left: t ? Math.max(8, Math.min(t.left, window.innerWidth - 240)) : 8,
|
|
6884
6884
|
zIndex: 9999
|
|
6885
6885
|
});
|
|
6886
|
-
}, []),
|
|
6887
|
-
if (X) if (
|
|
6886
|
+
}, []), Be = li((e) => f(e)), Ve = Be.filter((e) => !e.more), He = Be.filter((e) => e.more), Ue = Ve.filter((e) => e.key !== "ai"), We = Ve.find((e) => e.key === "ai"), Ge = b((e) => {
|
|
6887
|
+
if (X) if (Me(!1), e.key === "link") if (X.isActive("link")) X.chain().focus().unsetLink().run();
|
|
6888
6888
|
else {
|
|
6889
6889
|
let e = X.getAttributes("link").href || "";
|
|
6890
|
-
|
|
6890
|
+
ue(e), ze("link");
|
|
6891
6891
|
}
|
|
6892
|
-
else e.key === "highlight" ? K === "highlight" ? q("none") :
|
|
6892
|
+
else e.key === "highlight" ? K === "highlight" ? q("none") : ze("highlight") : e.command(X);
|
|
6893
6893
|
}, [
|
|
6894
6894
|
X,
|
|
6895
6895
|
K,
|
|
6896
|
-
|
|
6897
|
-
]),
|
|
6896
|
+
ze
|
|
6897
|
+
]), Ke = b((e) => X ? e.key === "highlight" ? K === "highlight" : e.key === "link" ? X.isActive("link") : e.isActive(X) : !1, [X, K]), [qe, Je] = T(0);
|
|
6898
6898
|
x(() => {
|
|
6899
6899
|
if (!X) return;
|
|
6900
|
-
let e = () =>
|
|
6900
|
+
let e = () => Je((e) => (e + 1) % 1e6);
|
|
6901
6901
|
return X.on("update", e), () => {
|
|
6902
6902
|
X.off("update", e);
|
|
6903
6903
|
};
|
|
6904
6904
|
}, [X]);
|
|
6905
|
-
let [
|
|
6905
|
+
let [Ye, Xe] = T(!1);
|
|
6906
6906
|
x(() => {
|
|
6907
6907
|
if (!X) return;
|
|
6908
6908
|
let e = () => {
|
|
6909
6909
|
let e = !1;
|
|
6910
6910
|
X.state.doc.descendants((t) => {
|
|
6911
6911
|
t.type.name === "heading" && (e = !0);
|
|
6912
|
-
}),
|
|
6912
|
+
}), Xe(e);
|
|
6913
6913
|
};
|
|
6914
6914
|
return e(), X.on("update", e), () => {
|
|
6915
6915
|
X.off("update", e);
|
|
6916
6916
|
};
|
|
6917
6917
|
}, [X]);
|
|
6918
|
-
let
|
|
6918
|
+
let Ze = C(() => X?.storage?.characterCount?.characters?.() ?? 0, [X, qe]), $e = a ? Ze > a : !1;
|
|
6919
6919
|
x(() => () => {
|
|
6920
|
-
|
|
6920
|
+
Ce.current && clearTimeout(Ce.current);
|
|
6921
6921
|
}, []), x(() => () => {
|
|
6922
|
-
|
|
6922
|
+
de && de.resolve(null);
|
|
6923
6923
|
}, []);
|
|
6924
|
-
let
|
|
6924
|
+
let et = b((e) => {
|
|
6925
6925
|
if (!X?.isEditable) return;
|
|
6926
6926
|
let t = window.getSelection(), n;
|
|
6927
6927
|
if (e) {
|
|
@@ -6946,8 +6946,8 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6946
6946
|
width: 0
|
|
6947
6947
|
};
|
|
6948
6948
|
}
|
|
6949
|
-
|
|
6950
|
-
let r =
|
|
6949
|
+
De.current = n;
|
|
6950
|
+
let r = we.current?.getBoundingClientRect(), i = bi(n, void 0, {
|
|
6951
6951
|
panelWidth: r?.width,
|
|
6952
6952
|
editorLeft: r?.left
|
|
6953
6953
|
});
|
|
@@ -6957,18 +6957,18 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6957
6957
|
if (!X) return;
|
|
6958
6958
|
let e = X.storage.qingwuUI;
|
|
6959
6959
|
if (e) return e.openImageDialog = () => V(!0), e.openVideoDialog = () => ae(!0), e.chooseMd = (e, t) => {
|
|
6960
|
-
|
|
6960
|
+
fe({
|
|
6961
6961
|
filename: e,
|
|
6962
6962
|
resolve: t
|
|
6963
6963
|
});
|
|
6964
|
-
}, e.openAI =
|
|
6964
|
+
}, e.openAI = et, e.parseMd = (e, t) => X ? Si(X, t) : null, () => {
|
|
6965
6965
|
delete e.openImageDialog, delete e.openVideoDialog, delete e.openAI, delete e.parseMd, delete e.chooseMd;
|
|
6966
6966
|
};
|
|
6967
|
-
}, [X,
|
|
6967
|
+
}, [X, et]), S(() => {
|
|
6968
6968
|
if (!j || !X) return;
|
|
6969
|
-
let e =
|
|
6969
|
+
let e = De.current;
|
|
6970
6970
|
if (!e) return;
|
|
6971
|
-
let t = z.current, n =
|
|
6971
|
+
let t = z.current, n = we.current?.getBoundingClientRect(), r = bi(e, t?.offsetHeight || void 0, {
|
|
6972
6972
|
panelWidth: n?.width,
|
|
6973
6973
|
editorLeft: n?.left
|
|
6974
6974
|
});
|
|
@@ -6976,9 +6976,9 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6976
6976
|
}, [j, X]), x(() => {
|
|
6977
6977
|
if (!j || !X) return;
|
|
6978
6978
|
let e = () => {
|
|
6979
|
-
let e =
|
|
6979
|
+
let e = De.current;
|
|
6980
6980
|
if (!e) return;
|
|
6981
|
-
let t = z.current, n =
|
|
6981
|
+
let t = z.current, n = we.current?.getBoundingClientRect(), r = bi(e, t?.offsetHeight || void 0, {
|
|
6982
6982
|
panelWidth: n?.width,
|
|
6983
6983
|
editorLeft: n?.left
|
|
6984
6984
|
});
|
|
@@ -6986,30 +6986,49 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6986
6986
|
};
|
|
6987
6987
|
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
6988
6988
|
}, [j, X]), x(() => {
|
|
6989
|
-
j || (
|
|
6989
|
+
j || (De.current = null);
|
|
6990
6990
|
}, [j]);
|
|
6991
|
-
let
|
|
6991
|
+
let tt = b((e) => {
|
|
6992
6992
|
X?.chain().focus().setImage({ src: e }).run();
|
|
6993
|
-
}, [X]),
|
|
6993
|
+
}, [X]), nt = b((e) => {
|
|
6994
6994
|
(X?.commands).insertVideo?.({ src: e });
|
|
6995
|
-
}, [X]),
|
|
6995
|
+
}, [X]), rt = pe && ye && !J && !Y, it = !rt && !he && (pe || Ye && !(!k && xe)), at = w(!1);
|
|
6996
6996
|
return x(() => {
|
|
6997
|
-
|
|
6998
|
-
}, [
|
|
6999
|
-
if (!
|
|
6997
|
+
at.current || (at.current = !0, pe && !rt && ge(!0));
|
|
6998
|
+
}, [pe, rt]), x(() => {
|
|
6999
|
+
if (!he) return;
|
|
7000
7000
|
let e = (e) => {
|
|
7001
7001
|
let t = e.target;
|
|
7002
|
-
|
|
7002
|
+
Fe.current?.contains(t) || ge(!1);
|
|
7003
7003
|
}, t = (e) => {
|
|
7004
|
-
e.key === "Escape" &&
|
|
7004
|
+
e.key === "Escape" && ge(!1);
|
|
7005
7005
|
};
|
|
7006
7006
|
return document.addEventListener("mousedown", e), document.addEventListener("touchstart", e, { passive: !0 }), document.addEventListener("keydown", t), () => {
|
|
7007
7007
|
document.removeEventListener("mousedown", e), document.removeEventListener("touchstart", e), document.removeEventListener("keydown", t);
|
|
7008
7008
|
};
|
|
7009
|
-
}, [
|
|
7009
|
+
}, [he]), x(() => {
|
|
7010
|
+
if (!X || !rt) return;
|
|
7011
|
+
let e = ke.current;
|
|
7012
|
+
if (!(e instanceof HTMLElement)) return;
|
|
7013
|
+
let t = (t) => {
|
|
7014
|
+
let n = t.deltaY;
|
|
7015
|
+
if (n === 0) return;
|
|
7016
|
+
let r = e.scrollTop <= 0, i = !(e.scrollTop + e.clientHeight >= e.scrollHeight - 1);
|
|
7017
|
+
if (n > 0 && i || n < 0 && !r) {
|
|
7018
|
+
e.scrollTop += n, t.preventDefault(), t.stopPropagation();
|
|
7019
|
+
return;
|
|
7020
|
+
}
|
|
7021
|
+
let a = ot(X.view.dom);
|
|
7022
|
+
if (a) {
|
|
7023
|
+
a.scrollTop += n, t.preventDefault(), t.stopPropagation();
|
|
7024
|
+
return;
|
|
7025
|
+
}
|
|
7026
|
+
};
|
|
7027
|
+
return e.addEventListener("wheel", t, { passive: !1 }), () => e.removeEventListener("wheel", t);
|
|
7028
|
+
}, [X, rt]), X ? /* @__PURE__ */ O("div", {
|
|
7010
7029
|
className: "qingwu-editor-row",
|
|
7011
7030
|
children: [/* @__PURE__ */ O("div", {
|
|
7012
|
-
ref:
|
|
7031
|
+
ref: we,
|
|
7013
7032
|
className: `qingwu-editor relative flex-1 min-w-0 bg-background ${k ? "qingwu-editor--readonly" : ""} ${l ? "" : "rounded-xl border border-default-200"} ${c}`,
|
|
7014
7033
|
style: u,
|
|
7015
7034
|
children: [
|
|
@@ -7020,13 +7039,13 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7020
7039
|
children: [
|
|
7021
7040
|
/* @__PURE__ */ D("button", {
|
|
7022
7041
|
type: "button",
|
|
7023
|
-
className: `qed-tb-btn qed-tb-btn--desktop-only${
|
|
7042
|
+
className: `qed-tb-btn qed-tb-btn--desktop-only${pe ? " is-active" : ""}`,
|
|
7024
7043
|
onClick: () => {
|
|
7025
|
-
|
|
7044
|
+
pe ? (me(!1), ge(!1)) : (me(!0), ye && !J && !Y || ge(!0));
|
|
7026
7045
|
},
|
|
7027
|
-
title:
|
|
7028
|
-
"aria-label":
|
|
7029
|
-
"aria-pressed":
|
|
7046
|
+
title: pe ? "隐藏目录" : "显示目录",
|
|
7047
|
+
"aria-label": pe ? "隐藏目录" : "显示目录",
|
|
7048
|
+
"aria-pressed": pe,
|
|
7030
7049
|
children: /* @__PURE__ */ D("svg", {
|
|
7031
7050
|
fill: "none",
|
|
7032
7051
|
viewBox: "0 0 24 24",
|
|
@@ -7042,11 +7061,11 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7042
7061
|
}),
|
|
7043
7062
|
h && /* @__PURE__ */ D("button", {
|
|
7044
7063
|
type: "button",
|
|
7045
|
-
className: `qed-tb-btn${
|
|
7046
|
-
onClick: () =>
|
|
7064
|
+
className: `qed-tb-btn${_e ? " is-active" : ""}`,
|
|
7065
|
+
onClick: () => ve(!_e),
|
|
7047
7066
|
title: "查找 (Ctrl+F)",
|
|
7048
7067
|
"aria-label": "查找",
|
|
7049
|
-
"aria-pressed":
|
|
7068
|
+
"aria-pressed": _e,
|
|
7050
7069
|
children: /* @__PURE__ */ D("svg", {
|
|
7051
7070
|
fill: "none",
|
|
7052
7071
|
viewBox: "0 0 24 24",
|
|
@@ -7063,7 +7082,7 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7063
7082
|
!k && /* @__PURE__ */ D("button", {
|
|
7064
7083
|
type: "button",
|
|
7065
7084
|
className: `qed-tb-btn qed-tb-btn--ai${j ? " is-active" : ""}`,
|
|
7066
|
-
onClick: (e) => j ? M(!1) :
|
|
7085
|
+
onClick: (e) => j ? M(!1) : et(e.currentTarget),
|
|
7067
7086
|
title: f("editor.toolbar.aiTitle"),
|
|
7068
7087
|
"aria-label": f("editor.toolbar.ai"),
|
|
7069
7088
|
"aria-pressed": j,
|
|
@@ -7111,11 +7130,11 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7111
7130
|
}),
|
|
7112
7131
|
/* @__PURE__ */ D("button", {
|
|
7113
7132
|
type: "button",
|
|
7114
|
-
className: `qed-tb-btn${
|
|
7115
|
-
onClick:
|
|
7116
|
-
title:
|
|
7117
|
-
"aria-label":
|
|
7118
|
-
"aria-pressed":
|
|
7133
|
+
className: `qed-tb-btn${J ? " is-active" : ""}`,
|
|
7134
|
+
onClick: Ie,
|
|
7135
|
+
title: J ? "退出网页全屏" : "网页全屏",
|
|
7136
|
+
"aria-label": J ? "退出网页全屏" : "网页全屏",
|
|
7137
|
+
"aria-pressed": J,
|
|
7119
7138
|
children: /* @__PURE__ */ D("svg", {
|
|
7120
7139
|
fill: "none",
|
|
7121
7140
|
viewBox: "0 0 24 24",
|
|
@@ -7131,11 +7150,11 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7131
7150
|
}),
|
|
7132
7151
|
/* @__PURE__ */ D("button", {
|
|
7133
7152
|
type: "button",
|
|
7134
|
-
className: `qed-tb-btn${
|
|
7135
|
-
onClick:
|
|
7136
|
-
title:
|
|
7137
|
-
"aria-label":
|
|
7138
|
-
"aria-pressed":
|
|
7153
|
+
className: `qed-tb-btn${Y ? " is-active" : ""}`,
|
|
7154
|
+
onClick: Le,
|
|
7155
|
+
title: Y ? "退出全屏" : "全屏",
|
|
7156
|
+
"aria-label": Y ? "退出全屏" : "全屏",
|
|
7157
|
+
"aria-pressed": Y,
|
|
7139
7158
|
children: /* @__PURE__ */ D("svg", {
|
|
7140
7159
|
fill: "none",
|
|
7141
7160
|
viewBox: "0 0 24 24",
|
|
@@ -7162,17 +7181,17 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7162
7181
|
},
|
|
7163
7182
|
className: "bubble-menu-pop bg-background border border-default-200 rounded-xl p-1 shadow-lg",
|
|
7164
7183
|
children: /* @__PURE__ */ O("div", {
|
|
7165
|
-
ref:
|
|
7184
|
+
ref: Ae,
|
|
7166
7185
|
className: "bubble-menu-items relative flex items-center gap-0.5",
|
|
7167
7186
|
onPointerDown: (e) => {
|
|
7168
7187
|
e.target.closest("button") && e.preventDefault();
|
|
7169
7188
|
},
|
|
7170
7189
|
children: [
|
|
7171
|
-
|
|
7190
|
+
Ue.map((e) => /* @__PURE__ */ D("button", {
|
|
7172
7191
|
type: "button",
|
|
7173
7192
|
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${e.isActive(X) ? "bg-primary/10 text-primary" : "text-default-600 hover:bg-default-100"}`,
|
|
7174
7193
|
onClick: (t) => {
|
|
7175
|
-
t.preventDefault(),
|
|
7194
|
+
t.preventDefault(), Ge(e);
|
|
7176
7195
|
},
|
|
7177
7196
|
title: e.label,
|
|
7178
7197
|
"aria-label": e.label,
|
|
@@ -7186,10 +7205,10 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7186
7205
|
type: "button",
|
|
7187
7206
|
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${j ? "bg-primary/15 text-primary" : "text-primary hover:bg-primary/10"}`,
|
|
7188
7207
|
onClick: (e) => {
|
|
7189
|
-
e.preventDefault(),
|
|
7208
|
+
e.preventDefault(), Me(!1), We?.command(X);
|
|
7190
7209
|
},
|
|
7191
|
-
title:
|
|
7192
|
-
"aria-label":
|
|
7210
|
+
title: We?.label,
|
|
7211
|
+
"aria-label": We?.label,
|
|
7193
7212
|
children: /* @__PURE__ */ D(zt, {})
|
|
7194
7213
|
}),
|
|
7195
7214
|
/* @__PURE__ */ D("span", {
|
|
@@ -7198,27 +7217,27 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7198
7217
|
}),
|
|
7199
7218
|
/* @__PURE__ */ D("button", {
|
|
7200
7219
|
type: "button",
|
|
7201
|
-
"aria-expanded":
|
|
7202
|
-
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${
|
|
7220
|
+
"aria-expanded": je,
|
|
7221
|
+
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${je ? "bg-default-100 text-default-900" : "text-default-600 hover:bg-default-100"}`,
|
|
7203
7222
|
onClick: (e) => {
|
|
7204
|
-
e.preventDefault(),
|
|
7223
|
+
e.preventDefault(), Me((e) => !e);
|
|
7205
7224
|
},
|
|
7206
7225
|
title: f("editor.bubble.more"),
|
|
7207
7226
|
"aria-label": f("editor.bubble.more"),
|
|
7208
7227
|
children: /* @__PURE__ */ D(Bt, {})
|
|
7209
7228
|
}),
|
|
7210
|
-
|
|
7229
|
+
je && /* @__PURE__ */ D("div", {
|
|
7211
7230
|
role: "menu",
|
|
7212
7231
|
className: "bubble-more-menu absolute right-0 top-full z-[9999] mt-1 w-max max-h-[70vh] overflow-y-auto flex-col gap-1 rounded-xl border border-default-200 bg-background p-1.5 shadow-xl",
|
|
7213
7232
|
onPointerDown: (e) => {
|
|
7214
7233
|
e.target.closest("button") && e.preventDefault();
|
|
7215
7234
|
},
|
|
7216
|
-
children:
|
|
7235
|
+
children: He.map((e) => /* @__PURE__ */ O("button", {
|
|
7217
7236
|
type: "button",
|
|
7218
7237
|
role: "menuitem",
|
|
7219
|
-
className: `flex items-center gap-2 w-full whitespace-nowrap px-3 py-1.5 text-xs rounded-md transition-colors ${
|
|
7238
|
+
className: `flex items-center gap-2 w-full whitespace-nowrap px-3 py-1.5 text-xs rounded-md transition-colors ${Ke(e) ? "bg-primary/10 text-primary" : "text-default-600 hover:bg-default-100"}`,
|
|
7220
7239
|
onClick: (t) => {
|
|
7221
|
-
t.preventDefault(),
|
|
7240
|
+
t.preventDefault(), Ge(e);
|
|
7222
7241
|
},
|
|
7223
7242
|
title: e.label,
|
|
7224
7243
|
children: [/* @__PURE__ */ D("span", {
|
|
@@ -7265,16 +7284,16 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7265
7284
|
type: "url",
|
|
7266
7285
|
className: "flex-1 px-2 py-1 text-xs rounded-md border border-default-200 bg-background focus:outline-none focus:border-primary",
|
|
7267
7286
|
placeholder: "https://...",
|
|
7268
|
-
value:
|
|
7269
|
-
onChange: (e) =>
|
|
7287
|
+
value: le,
|
|
7288
|
+
onChange: (e) => ue(e.target.value),
|
|
7270
7289
|
onKeyDown: (e) => {
|
|
7271
|
-
e.key === "Enter" ? (
|
|
7290
|
+
e.key === "Enter" ? (le.trim() && X.chain().focus().setLink({ href: le.trim() }).run(), q("none")) : e.key === "Escape" && q("none");
|
|
7272
7291
|
}
|
|
7273
7292
|
}), /* @__PURE__ */ D("button", {
|
|
7274
7293
|
type: "button",
|
|
7275
7294
|
className: "px-2 py-1 text-xs rounded-md bg-primary text-white hover:opacity-90",
|
|
7276
7295
|
onClick: () => {
|
|
7277
|
-
|
|
7296
|
+
le.trim() && X.chain().focus().setLink({ href: le.trim() }).run(), q("none");
|
|
7278
7297
|
},
|
|
7279
7298
|
children: "确定"
|
|
7280
7299
|
})]
|
|
@@ -7303,7 +7322,7 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7303
7322
|
children: /* @__PURE__ */ D(Ci, {
|
|
7304
7323
|
open: B,
|
|
7305
7324
|
onClose: () => V(!1),
|
|
7306
|
-
onInsert:
|
|
7325
|
+
onInsert: tt,
|
|
7307
7326
|
validate: (e) => X ? un(X.state.doc, e, {
|
|
7308
7327
|
maxAttachmentSize: o,
|
|
7309
7328
|
maxTotalAttachmentSize: s
|
|
@@ -7315,7 +7334,7 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7315
7334
|
children: /* @__PURE__ */ D(Ei, {
|
|
7316
7335
|
open: H,
|
|
7317
7336
|
onClose: () => ae(!1),
|
|
7318
|
-
onInsert:
|
|
7337
|
+
onInsert: nt
|
|
7319
7338
|
})
|
|
7320
7339
|
}),
|
|
7321
7340
|
oe && /* @__PURE__ */ D(v, {
|
|
@@ -7333,24 +7352,24 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7333
7352
|
editor: X
|
|
7334
7353
|
})
|
|
7335
7354
|
}),
|
|
7336
|
-
|
|
7355
|
+
de && /* @__PURE__ */ D(v, {
|
|
7337
7356
|
fallback: /* @__PURE__ */ D(Oi, {}),
|
|
7338
7357
|
children: /* @__PURE__ */ D(Di, {
|
|
7339
|
-
open: !!
|
|
7340
|
-
filename:
|
|
7358
|
+
open: !!de,
|
|
7359
|
+
filename: de.filename,
|
|
7341
7360
|
onRender: () => {
|
|
7342
|
-
|
|
7361
|
+
de.resolve("render"), fe(null);
|
|
7343
7362
|
},
|
|
7344
7363
|
onAttach: () => {
|
|
7345
|
-
|
|
7364
|
+
de.resolve("attach"), fe(null);
|
|
7346
7365
|
},
|
|
7347
7366
|
onClose: () => {
|
|
7348
|
-
|
|
7367
|
+
de.resolve(null), fe(null);
|
|
7349
7368
|
}
|
|
7350
7369
|
})
|
|
7351
7370
|
}),
|
|
7352
7371
|
/* @__PURE__ */ D("div", {
|
|
7353
|
-
ref:
|
|
7372
|
+
ref: Te,
|
|
7354
7373
|
className: "flex editor-body",
|
|
7355
7374
|
children: /* @__PURE__ */ O("div", {
|
|
7356
7375
|
className: "relative min-w-0 flex-1",
|
|
@@ -7358,11 +7377,11 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7358
7377
|
/* @__PURE__ */ D(P, { editor: X }),
|
|
7359
7378
|
!k && /* @__PURE__ */ D(hi, { editor: X }),
|
|
7360
7379
|
/* @__PURE__ */ D("div", {
|
|
7361
|
-
className: `${
|
|
7380
|
+
className: `${J || Y ? "fixed" : "absolute"} bottom-2 right-4 z-10 pointer-events-none select-none`,
|
|
7362
7381
|
children: /* @__PURE__ */ O("span", {
|
|
7363
|
-
className: `text-xs ${
|
|
7382
|
+
className: `text-xs ${$e ? "bg-danger/10 text-danger font-medium px-2 py-0.5 rounded" : a && Ze > a * .9 ? "bg-warning/10 text-warning px-2 py-0.5 rounded" : "text-default-300"}`,
|
|
7364
7383
|
children: [
|
|
7365
|
-
|
|
7384
|
+
Ze,
|
|
7366
7385
|
a ? ` / ${a}` : "",
|
|
7367
7386
|
" 字"
|
|
7368
7387
|
]
|
|
@@ -7371,14 +7390,14 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7371
7390
|
]
|
|
7372
7391
|
})
|
|
7373
7392
|
}),
|
|
7374
|
-
h &&
|
|
7393
|
+
h && _e && /* @__PURE__ */ D(Ot, {
|
|
7375
7394
|
editor: X,
|
|
7376
|
-
onClose: () =>
|
|
7395
|
+
onClose: () => ve(!1)
|
|
7377
7396
|
}),
|
|
7378
|
-
|
|
7397
|
+
it && /* @__PURE__ */ D("button", {
|
|
7379
7398
|
type: "button",
|
|
7380
7399
|
className: "qingwu-toc-fab",
|
|
7381
|
-
onClick: () =>
|
|
7400
|
+
onClick: () => ge(!0),
|
|
7382
7401
|
title: "目录",
|
|
7383
7402
|
"aria-label": "打开目录",
|
|
7384
7403
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -7394,8 +7413,8 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7394
7413
|
})
|
|
7395
7414
|
})
|
|
7396
7415
|
}),
|
|
7397
|
-
|
|
7398
|
-
ref:
|
|
7416
|
+
he && ne(/* @__PURE__ */ O("div", {
|
|
7417
|
+
ref: Fe,
|
|
7399
7418
|
className: "qingwu-toc-drawer toc-scroll",
|
|
7400
7419
|
"data-lenis-prevent": !0,
|
|
7401
7420
|
children: [/* @__PURE__ */ O("div", {
|
|
@@ -7406,7 +7425,7 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7406
7425
|
}), /* @__PURE__ */ D("button", {
|
|
7407
7426
|
type: "button",
|
|
7408
7427
|
className: "qed-drawer-head__close",
|
|
7409
|
-
onClick: () =>
|
|
7428
|
+
onClick: () => ge(!1),
|
|
7410
7429
|
"aria-label": "关闭目录",
|
|
7411
7430
|
children: /* @__PURE__ */ D("svg", {
|
|
7412
7431
|
fill: "none",
|
|
@@ -7425,17 +7444,17 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7425
7444
|
editor: X,
|
|
7426
7445
|
className: "!p-3",
|
|
7427
7446
|
onClose: () => {
|
|
7428
|
-
|
|
7447
|
+
ge(!1), me(!1);
|
|
7429
7448
|
}
|
|
7430
7449
|
})]
|
|
7431
7450
|
}), document.body)
|
|
7432
7451
|
]
|
|
7433
|
-
}),
|
|
7452
|
+
}), rt && /* @__PURE__ */ D("aside", {
|
|
7453
|
+
ref: ke,
|
|
7434
7454
|
className: "qingwu-toc-desktop toc-scroll",
|
|
7435
|
-
"data-lenis-prevent": !0,
|
|
7436
7455
|
children: /* @__PURE__ */ D(ut, {
|
|
7437
7456
|
editor: X,
|
|
7438
|
-
onClose: () =>
|
|
7457
|
+
onClose: () => me(!1)
|
|
7439
7458
|
})
|
|
7440
7459
|
})]
|
|
7441
7460
|
}) : /* @__PURE__ */ D("div", {
|