@qingwu-ui/ai-editor 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +2 -2
- package/README.md +2 -1
- package/dist/assets/katex-fonts/katex-0.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-1.woff +0 -0
- package/dist/assets/katex-fonts/katex-10.woff +0 -0
- package/dist/assets/katex-fonts/katex-11.ttf +0 -0
- package/dist/assets/katex-fonts/katex-12.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-13.woff +0 -0
- package/dist/assets/katex-fonts/katex-14.ttf +0 -0
- package/dist/assets/katex-fonts/katex-15.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-16.woff +0 -0
- package/dist/assets/katex-fonts/katex-17.ttf +0 -0
- package/dist/assets/katex-fonts/katex-18.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-19.woff +0 -0
- package/dist/assets/katex-fonts/katex-2.ttf +0 -0
- package/dist/assets/katex-fonts/katex-20.ttf +0 -0
- package/dist/assets/katex-fonts/katex-21.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-22.woff +0 -0
- package/dist/assets/katex-fonts/katex-23.ttf +0 -0
- package/dist/assets/katex-fonts/katex-24.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-25.woff +0 -0
- package/dist/assets/katex-fonts/katex-26.ttf +0 -0
- package/dist/assets/katex-fonts/katex-27.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-28.woff +0 -0
- package/dist/assets/katex-fonts/katex-29.ttf +0 -0
- package/dist/assets/katex-fonts/katex-3.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-30.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-31.woff +0 -0
- package/dist/assets/katex-fonts/katex-32.ttf +0 -0
- package/dist/assets/katex-fonts/katex-33.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-34.woff +0 -0
- package/dist/assets/katex-fonts/katex-35.ttf +0 -0
- package/dist/assets/katex-fonts/katex-36.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-37.woff +0 -0
- package/dist/assets/katex-fonts/katex-38.ttf +0 -0
- package/dist/assets/katex-fonts/katex-39.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-4.woff +0 -0
- package/dist/assets/katex-fonts/katex-40.woff +0 -0
- package/dist/assets/katex-fonts/katex-41.ttf +0 -0
- package/dist/assets/katex-fonts/katex-42.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-43.woff +0 -0
- package/dist/assets/katex-fonts/katex-44.ttf +0 -0
- package/dist/assets/katex-fonts/katex-45.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-46.woff +0 -0
- package/dist/assets/katex-fonts/katex-47.ttf +0 -0
- package/dist/assets/katex-fonts/katex-48.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-49.woff +0 -0
- package/dist/assets/katex-fonts/katex-5.ttf +0 -0
- package/dist/assets/katex-fonts/katex-50.ttf +0 -0
- package/dist/assets/katex-fonts/katex-51.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-52.woff +0 -0
- package/dist/assets/katex-fonts/katex-53.ttf +0 -0
- package/dist/assets/katex-fonts/katex-54.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-55.woff +0 -0
- package/dist/assets/katex-fonts/katex-56.ttf +0 -0
- package/dist/assets/katex-fonts/katex-57.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-58.woff +0 -0
- package/dist/assets/katex-fonts/katex-59.ttf +0 -0
- package/dist/assets/katex-fonts/katex-6.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-7.woff +0 -0
- package/dist/assets/katex-fonts/katex-8.ttf +0 -0
- package/dist/assets/katex-fonts/katex-9.woff2 +0 -0
- package/dist/components/release-notes-dialog.d.ts.map +1 -1
- package/dist/editor/extensions/code-block-view.d.ts.map +1 -1
- package/dist/editor/extensions/code-block.d.ts.map +1 -1
- package/dist/editor/extensions/index.d.ts +2 -1
- package/dist/editor/extensions/index.d.ts.map +1 -1
- package/dist/editor/extensions/math-utils.d.ts +9 -0
- package/dist/editor/extensions/math-utils.d.ts.map +1 -0
- package/dist/editor/extensions/math-view.d.ts +27 -0
- package/dist/editor/extensions/math-view.d.ts.map +1 -0
- package/dist/editor/extensions/math.d.ts +44 -0
- package/dist/editor/extensions/math.d.ts.map +1 -0
- package/dist/editor/extensions/slash-command.d.ts.map +1 -1
- package/dist/editor/i18n/en-US.d.ts +14 -0
- package/dist/editor/i18n/en-US.d.ts.map +1 -1
- package/dist/editor/i18n/zh-CN.d.ts +14 -0
- package/dist/editor/i18n/zh-CN.d.ts.map +1 -1
- package/dist/editor/index.d.ts +1 -1
- package/dist/editor/index.d.ts.map +1 -1
- package/dist/editor/utils/local-media.d.ts +1 -1
- package/dist/editor/utils/local-media.d.ts.map +1 -1
- package/dist/{export-dialog-BJReD1PN.cjs → export-dialog-BKShGPNv.cjs} +1 -1
- package/dist/{export-dialog-CJhm3uqR.js → export-dialog-DMY_QIVq.js} +1 -1
- package/dist/index.cjs +13 -11
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1379 -907
- package/dist/sanitize-D4Bd9RtA.cjs +1 -0
- package/dist/{sanitize-wGLeVLFO.js → sanitize-DdIs-mcO.js} +28 -0
- package/dist/{signed-fetch-BiI-JlzZ.cjs → signed-fetch-ULpEJyn5.cjs} +1 -1
- package/dist/{storage-settings-dialog-zPgJahMO.cjs → storage-settings-dialog-WBHfAUak.cjs} +1 -1
- package/dist/styles.css +1 -2
- package/package.json +3 -1
- package/scripts/cli.mjs +0 -0
- package/dist/sanitize-Bcj55kwd.cjs +0 -1
package/dist/index.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { a as e, n as t, r as n, t as r } from "./signed-fetch-CPPWCUUS.js";
|
|
2
2
|
import { a as i, i as a, n as o, r as s, t as c } from "./storage-DUcmM2Ex.js";
|
|
3
|
-
import { a as l, i as u, n as d, o as f, r as p, s as m, t as h } from "./sanitize-
|
|
3
|
+
import { a as l, i as u, n as d, o as f, r as p, s as m, t as h } from "./sanitize-DdIs-mcO.js";
|
|
4
4
|
import { n as g, t as _ } from "./local-B20eAPCo.js";
|
|
5
5
|
import { Suspense as v, lazy as y, useCallback as b, useEffect as x, useLayoutEffect as S, useMemo as C, useRef as w, useState as T } from "react";
|
|
6
6
|
import { Fragment as E, jsx as D, jsxs as O } from "react/jsx-runtime";
|
|
7
7
|
import { generateText as k, streamText as A } from "ai";
|
|
8
8
|
import { DOMParser as j, Fragment as M, Slice as N } from "@tiptap/pm/model";
|
|
9
|
-
import { EditorContent as
|
|
10
|
-
import { BubbleMenu as
|
|
11
|
-
import { createPortal as
|
|
12
|
-
import { Extension as R,
|
|
13
|
-
import { NodeSelection as
|
|
14
|
-
import { Decoration as
|
|
15
|
-
import { Image as
|
|
16
|
-
import { Link as
|
|
9
|
+
import { EditorContent as ee, NodeViewWrapper as P, ReactNodeViewRenderer as F, ReactRenderer as I, useEditor as te } from "@tiptap/react";
|
|
10
|
+
import { BubbleMenu as ne } from "@tiptap/react/menus";
|
|
11
|
+
import { createPortal as L } from "react-dom";
|
|
12
|
+
import { Extension as R, InputRule as re, Node as ie, markInputRule as z } from "@tiptap/core";
|
|
13
|
+
import { NodeSelection as B, Plugin as V, PluginKey as H, TextSelection as ae } from "@tiptap/pm/state";
|
|
14
|
+
import { Decoration as oe, DecorationSet as U } from "@tiptap/pm/view";
|
|
15
|
+
import { Image as W } from "@tiptap/extension-image";
|
|
16
|
+
import { Link as se } from "@tiptap/extension-link";
|
|
17
17
|
import { Underline as G } from "@tiptap/extension-underline";
|
|
18
18
|
import K from "@tiptap/starter-kit";
|
|
19
|
-
import { CharacterCount as
|
|
20
|
-
import { Color as
|
|
21
|
-
import { Highlight as
|
|
22
|
-
import { HorizontalRule as
|
|
23
|
-
import { Placeholder as
|
|
24
|
-
import { Table as
|
|
25
|
-
import { TableCell as
|
|
19
|
+
import { CharacterCount as ce } from "@tiptap/extension-character-count";
|
|
20
|
+
import { Color as q } from "@tiptap/extension-color";
|
|
21
|
+
import { Highlight as le } from "@tiptap/extension-highlight";
|
|
22
|
+
import { HorizontalRule as ue } from "@tiptap/extension-horizontal-rule";
|
|
23
|
+
import { Placeholder as de } from "@tiptap/extension-placeholder";
|
|
24
|
+
import { Table as fe } from "@tiptap/extension-table";
|
|
25
|
+
import { TableCell as J } from "@tiptap/extension-table-cell";
|
|
26
26
|
import { TableHeader as pe } from "@tiptap/extension-table-header";
|
|
27
27
|
import { TableRow as me } from "@tiptap/extension-table-row";
|
|
28
28
|
import { TaskItem as he } from "@tiptap/extension-task-item";
|
|
@@ -32,30 +32,31 @@ import { Markdown as ve } from "tiptap-markdown";
|
|
|
32
32
|
import { CodeBlockLowlight as ye } from "@tiptap/extension-code-block-lowlight";
|
|
33
33
|
import be from "highlight.js/lib/languages/dockerfile";
|
|
34
34
|
import { common as xe, createLowlight as Se } from "lowlight";
|
|
35
|
-
import Ce
|
|
35
|
+
import Ce from "katex";
|
|
36
|
+
import we, { exitSuggestion as Te, findSuggestionMatch as Ee } from "@tiptap/suggestion";
|
|
36
37
|
//#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(),
|
|
38
|
+
var De = null, Oe = null;
|
|
39
|
+
function ke() {
|
|
40
|
+
return Oe || (typeof document > "u" ? null : (De = document.createElement("canvas"), Oe = De.getContext("2d"), Oe));
|
|
41
|
+
}
|
|
42
|
+
var Ae = /* @__PURE__ */ new Map();
|
|
43
|
+
function je(e, t) {
|
|
44
|
+
let n = Ae.get(t);
|
|
45
|
+
n || (n = /* @__PURE__ */ new Map(), Ae.set(t, n));
|
|
45
46
|
let r = n.get(e);
|
|
46
47
|
if (r !== void 0) return r;
|
|
47
|
-
let i =
|
|
48
|
-
return i ? (i.font = t, r = i.measureText(e).width) : r =
|
|
48
|
+
let i = ke();
|
|
49
|
+
return i ? (i.font = t, r = i.measureText(e).width) : r = Me(e, t), n.set(e, r), r;
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
+
function Me(e, t) {
|
|
51
52
|
let n = parseFloat(t) || 16, r = 0;
|
|
52
|
-
for (let t of e)
|
|
53
|
+
for (let t of e) Ne(t.codePointAt(0) ?? 0) ? r += n : t === " " ? r += n * .3 : r += n * .55;
|
|
53
54
|
return r;
|
|
54
55
|
}
|
|
55
|
-
function
|
|
56
|
+
function Ne(e) {
|
|
56
57
|
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
58
|
}
|
|
58
|
-
function
|
|
59
|
+
function Y(e) {
|
|
59
60
|
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
61
|
}
|
|
61
62
|
function Pe(e, t) {
|
|
@@ -69,26 +70,26 @@ function Pe(e, t) {
|
|
|
69
70
|
else r = [...e];
|
|
70
71
|
for (let e of r) {
|
|
71
72
|
let r = e.codePointAt(0) ?? 0, i = "latin";
|
|
72
|
-
e === "\n" ? i = "break" : e === " " || e === " " ? i = "space" :
|
|
73
|
+
e === "\n" ? i = "break" : e === " " || e === " " ? i = "space" : Ne(r) && (i = Y(r) ? "punct" : "cjk"), n.push({
|
|
73
74
|
text: e,
|
|
74
|
-
width:
|
|
75
|
+
width: je(e, t),
|
|
75
76
|
type: i
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
79
|
return n;
|
|
79
80
|
}
|
|
80
|
-
function
|
|
81
|
+
function Fe(e, t, n) {
|
|
81
82
|
let r = 0, i = Math.min(n, e.length);
|
|
82
83
|
for (let n = t; n < i; n++) r += e[n].width;
|
|
83
84
|
return r;
|
|
84
85
|
}
|
|
85
|
-
function
|
|
86
|
+
function Ie(e, t, n, r) {
|
|
86
87
|
return {
|
|
87
88
|
text: e.slice(t, Math.min(n, e.length)).map((e) => e.text).join(""),
|
|
88
89
|
width: r
|
|
89
90
|
};
|
|
90
91
|
}
|
|
91
|
-
function
|
|
92
|
+
function Le(e, t, n = "16px system-ui") {
|
|
92
93
|
let { maxWidth: r, lineHeight: i, maxLines: a, overflowWrap: o = "break-word" } = t, s = Pe(e, n), c = [], l = {
|
|
93
94
|
lineStart: 0,
|
|
94
95
|
lineWidth: 0,
|
|
@@ -98,28 +99,28 @@ function Ie(e, t, n = "16px system-ui") {
|
|
|
98
99
|
for (let e = 0; e < s.length; e++) {
|
|
99
100
|
let t = s[e];
|
|
100
101
|
if (t.type === "break") {
|
|
101
|
-
c.push(
|
|
102
|
+
c.push(Ie(s, l.lineStart, e, l.lineWidth)), l.lineStart = e + 1, l.lineWidth = 0, l.lastBreakIdx = -1;
|
|
102
103
|
continue;
|
|
103
104
|
}
|
|
104
105
|
let n = l.lineWidth + t.width;
|
|
105
106
|
if (t.type === "space") {
|
|
106
|
-
if (n > r && l.lineWidth > 0 ? (l.lastBreakIdx >= 0 ? (c.push(
|
|
107
|
+
if (n > r && l.lineWidth > 0 ? (l.lastBreakIdx >= 0 ? (c.push(Ie(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Fe(s, l.lineStart, e + 1)) : (c.push(Ie(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
108
|
continue;
|
|
108
109
|
}
|
|
109
110
|
if (t.type === "cjk") {
|
|
110
|
-
if (n > r && l.lineWidth > 0 ? (c.push(
|
|
111
|
+
if (n > r && l.lineWidth > 0 ? (c.push(Ie(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
112
|
continue;
|
|
112
113
|
}
|
|
113
114
|
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(
|
|
115
|
+
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(Ie(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Fe(s, l.lineStart, e + 1)) : l.lineWidth = n, l.lastBreakIdx = -1) : l.lineWidth = n, a && c.length >= a) break;
|
|
115
116
|
continue;
|
|
116
117
|
}
|
|
117
|
-
if (n > r && l.lineWidth > 0 ? l.lastBreakIdx >= 0 ? (c.push(
|
|
118
|
+
if (n > r && l.lineWidth > 0 ? l.lastBreakIdx >= 0 ? (c.push(Ie(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Fe(s, l.lineStart, e + 1), l.lastBreakIdx = -1) : o === "break-word" ? (c.push(Ie(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
119
|
}
|
|
119
120
|
let u = l.lineStart < s.length;
|
|
120
121
|
if (u && (!a || c.length < a)) {
|
|
121
|
-
let e =
|
|
122
|
-
c.push(
|
|
122
|
+
let e = Fe(s, l.lineStart, s.length);
|
|
123
|
+
c.push(Ie(s, l.lineStart, s.length, e));
|
|
123
124
|
}
|
|
124
125
|
return {
|
|
125
126
|
lines: c,
|
|
@@ -130,8 +131,8 @@ function Ie(e, t, n = "16px system-ui") {
|
|
|
130
131
|
}
|
|
131
132
|
//#endregion
|
|
132
133
|
//#region ../toast/dist/index.mjs
|
|
133
|
-
var
|
|
134
|
-
function
|
|
134
|
+
var Re = typeof window < "u" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, ze = "13.5px -apple-system, BlinkMacSystemFont, \"SF Pro Text\", \"PingFang SC\", \"Microsoft YaHei\", system-ui, sans-serif";
|
|
135
|
+
function X() {
|
|
135
136
|
if (typeof window > "u") return 290;
|
|
136
137
|
let e = window.innerWidth;
|
|
137
138
|
return e <= 480 ? Math.max(140, e - 98) : 290;
|
|
@@ -141,25 +142,25 @@ var Be = {
|
|
|
141
142
|
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
143
|
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>",
|
|
143
144
|
error: "<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=\"15\" y1=\"9\" x2=\"9\" y2=\"15\"/><line x1=\"9\" y1=\"9\" x2=\"15\" y2=\"15\"/></svg>"
|
|
144
|
-
},
|
|
145
|
-
function
|
|
146
|
-
return `qt${
|
|
145
|
+
}, Ve = 1;
|
|
146
|
+
function He() {
|
|
147
|
+
return `qt${Ve++}${Date.now().toString(36)}`;
|
|
147
148
|
}
|
|
148
|
-
function
|
|
149
|
+
function Ue(e, t, n) {
|
|
149
150
|
let r = document.createElement(e);
|
|
150
151
|
return t && (r.className = t), n != null && (r.innerHTML = n), r;
|
|
151
152
|
}
|
|
152
|
-
function
|
|
153
|
+
function We(e, t) {
|
|
153
154
|
let n = t.split(/\*\*(.+?)\*\*/g);
|
|
154
155
|
for (let t = 0; t < n.length; t++) {
|
|
155
156
|
let r = n[t];
|
|
156
157
|
if (r) if (t % 2 == 1) {
|
|
157
|
-
let t =
|
|
158
|
+
let t = Ue("em", "qt-mark");
|
|
158
159
|
t.textContent = r, e.appendChild(t);
|
|
159
160
|
} else e.appendChild(document.createTextNode(r));
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
|
-
var
|
|
163
|
+
var Ge = {
|
|
163
164
|
type: "info",
|
|
164
165
|
position: "top-center",
|
|
165
166
|
duration: 4e3,
|
|
@@ -168,19 +169,19 @@ var Ue = {
|
|
|
168
169
|
persistMaxVisible: 3,
|
|
169
170
|
maxLines: void 0,
|
|
170
171
|
vibrate: !0
|
|
171
|
-
},
|
|
172
|
+
}, Ke = [
|
|
172
173
|
80,
|
|
173
174
|
40,
|
|
174
175
|
80
|
|
175
176
|
];
|
|
176
|
-
function
|
|
177
|
+
function qe() {
|
|
177
178
|
if (!(typeof navigator > "u" || !("vibrate" in navigator))) try {
|
|
178
|
-
navigator.vibrate(
|
|
179
|
+
navigator.vibrate(Ke);
|
|
179
180
|
} catch {}
|
|
180
181
|
}
|
|
181
|
-
var
|
|
182
|
+
var Je = class {
|
|
182
183
|
containers = /* @__PURE__ */ new Map();
|
|
183
|
-
opts = { ...
|
|
184
|
+
opts = { ...Ge };
|
|
184
185
|
toasts = /* @__PURE__ */ new Map();
|
|
185
186
|
queue = [];
|
|
186
187
|
_seq = 0;
|
|
@@ -189,10 +190,10 @@ var Ke = class {
|
|
|
189
190
|
}
|
|
190
191
|
ensureContainer(e) {
|
|
191
192
|
let t = this.containers.get(e);
|
|
192
|
-
return t || (t =
|
|
193
|
+
return t || (t = Ue("div", "qt-container"), t.setAttribute("data-qt-pos", e), t.setAttribute("role", "status"), t.setAttribute("aria-live", "polite"), t.setAttribute("aria-atomic", "false"), document.body.appendChild(t), this.containers.set(e, t)), t;
|
|
193
194
|
}
|
|
194
195
|
show(e, t) {
|
|
195
|
-
let n = t?.type ?? this.opts.type, r = t?.position ?? this.opts.position, i = t?.persist ?? this.opts.persist ? 0 : t?.duration ?? this.opts.duration, a = t?.dismissible ?? !0, o = t?.maxLines ?? this.opts.maxLines, s = t?.description, c = t?.action, l =
|
|
196
|
+
let n = t?.type ?? this.opts.type, r = t?.position ?? this.opts.position, i = t?.persist ?? this.opts.persist ? 0 : t?.duration ?? this.opts.duration, a = t?.dismissible ?? !0, o = t?.maxLines ?? this.opts.maxLines, s = t?.description, c = t?.action, l = He(), u = {
|
|
196
197
|
id: l,
|
|
197
198
|
type: n,
|
|
198
199
|
dismissible: a,
|
|
@@ -275,30 +276,30 @@ var Ke = class {
|
|
|
275
276
|
this.containers.clear();
|
|
276
277
|
}
|
|
277
278
|
buildElement(e, t, n, r, i, a, o) {
|
|
278
|
-
let s =
|
|
279
|
+
let s = Ue("div", `qt-toast qt-${n}${i == null ? "" : " qt-truncate"}${a || o ? " qt-rich" : ""}`);
|
|
279
280
|
s.setAttribute("data-qt-id", e);
|
|
280
|
-
let c =
|
|
281
|
+
let c = Ue("span", "qt-icon");
|
|
281
282
|
c.innerHTML = Be[n], s.appendChild(c);
|
|
282
|
-
let l =
|
|
283
|
-
maxWidth:
|
|
283
|
+
let l = Ue("div", "qt-body"), u = Ue("span", "qt-msg"), d = Le(t, {
|
|
284
|
+
maxWidth: X(),
|
|
284
285
|
lineHeight: 1,
|
|
285
286
|
maxLines: i
|
|
286
|
-
},
|
|
287
|
-
if (d.lineCount <= 1 ?
|
|
288
|
-
let n =
|
|
289
|
-
t === d.lines.length - 1 && d.truncated && !r.endsWith("…") && (r += "…"),
|
|
287
|
+
}, ze);
|
|
288
|
+
if (d.lineCount <= 1 ? We(u, t) : d.lines.forEach((e, t) => {
|
|
289
|
+
let n = Ue("span", "qt-line"), r = e.text;
|
|
290
|
+
t === d.lines.length - 1 && d.truncated && !r.endsWith("…") && (r += "…"), We(n, r), u.appendChild(n);
|
|
290
291
|
}), l.appendChild(u), a) {
|
|
291
|
-
let e =
|
|
292
|
+
let e = Ue("div", "qt-desc");
|
|
292
293
|
e.textContent = a, l.appendChild(e);
|
|
293
294
|
}
|
|
294
295
|
if (s.appendChild(l), o) {
|
|
295
|
-
let t =
|
|
296
|
+
let t = Ue("button", "qt-action");
|
|
296
297
|
t.type = "button", t.textContent = o.label, t.addEventListener("click", (t) => {
|
|
297
298
|
t.stopPropagation(), this.dismiss(e), o.onClick();
|
|
298
299
|
}), s.appendChild(t);
|
|
299
300
|
}
|
|
300
301
|
if (r) {
|
|
301
|
-
let t =
|
|
302
|
+
let t = Ue("button", "qt-close", "<svg width=\"10\" height=\"10\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\"><path d=\"M18 6 6 18M6 6l12 12\"/></svg>");
|
|
302
303
|
t.type = "button", t.setAttribute("aria-label", "关闭通知"), t.addEventListener("click", (t) => {
|
|
303
304
|
t.stopPropagation(), this.dismiss(e);
|
|
304
305
|
}), s.appendChild(t);
|
|
@@ -310,7 +311,7 @@ var Ke = class {
|
|
|
310
311
|
mount(e) {
|
|
311
312
|
e.duration === 0 && this.evictPersistIfNeeded(e);
|
|
312
313
|
let t = this.ensureContainer(e.position);
|
|
313
|
-
this.toasts.set(e.id, e), t.appendChild(e.element), e.type === "error" && this.opts.vibrate &&
|
|
314
|
+
this.toasts.set(e.id, e), t.appendChild(e.element), e.type === "error" && this.opts.vibrate && qe(), requestAnimationFrame(() => {
|
|
314
315
|
requestAnimationFrame(() => {
|
|
315
316
|
e.element.classList.add("qt-enter");
|
|
316
317
|
});
|
|
@@ -332,7 +333,7 @@ var Ke = class {
|
|
|
332
333
|
let t = () => {
|
|
333
334
|
e.element.remove(), this.toasts.delete(e.id), this._dequeue();
|
|
334
335
|
};
|
|
335
|
-
if (
|
|
336
|
+
if (Re) t();
|
|
336
337
|
else {
|
|
337
338
|
let n = !1, r = () => {
|
|
338
339
|
n || (n = !0, t());
|
|
@@ -345,46 +346,46 @@ var Ke = class {
|
|
|
345
346
|
let e = this.queue.shift();
|
|
346
347
|
this.mount(e);
|
|
347
348
|
}
|
|
348
|
-
},
|
|
349
|
-
function
|
|
350
|
-
return
|
|
351
|
-
}
|
|
352
|
-
var
|
|
353
|
-
info: (e, t) =>
|
|
354
|
-
success: (e, t) =>
|
|
355
|
-
warn: (e, t) =>
|
|
356
|
-
error: (e, t) =>
|
|
357
|
-
promise: (e, t, n) =>
|
|
358
|
-
dismiss: (e) =>
|
|
359
|
-
dismissAll: () =>
|
|
360
|
-
configure: (e) =>
|
|
361
|
-
}),
|
|
362
|
-
function
|
|
363
|
-
|
|
349
|
+
}, Ye = null;
|
|
350
|
+
function Xe() {
|
|
351
|
+
return Ye ||= new Je(), Ye;
|
|
352
|
+
}
|
|
353
|
+
var Ze = Object.assign((e, t) => Xe().show(e, t), {
|
|
354
|
+
info: (e, t) => Xe().info(e, t),
|
|
355
|
+
success: (e, t) => Xe().success(e, t),
|
|
356
|
+
warn: (e, t) => Xe().warn(e, t),
|
|
357
|
+
error: (e, t) => Xe().error(e, t),
|
|
358
|
+
promise: (e, t, n) => Xe().promise(e, t, n),
|
|
359
|
+
dismiss: (e) => Xe().dismiss(e),
|
|
360
|
+
dismissAll: () => Xe().dismissAll(),
|
|
361
|
+
configure: (e) => Xe().configure(e)
|
|
362
|
+
}), Qe = /* @__PURE__ */ new Set(), $e = null;
|
|
363
|
+
function et(e) {
|
|
364
|
+
$e = e;
|
|
364
365
|
}
|
|
365
366
|
function Z(e, t = "error", n) {
|
|
366
367
|
let r = {
|
|
367
368
|
persist: !0,
|
|
368
369
|
...n
|
|
369
370
|
};
|
|
370
|
-
if (
|
|
371
|
-
for (let n of
|
|
371
|
+
if (Qe.size > 0) {
|
|
372
|
+
for (let n of Qe) n(e, t, r);
|
|
372
373
|
return;
|
|
373
374
|
}
|
|
374
|
-
if (
|
|
375
|
-
|
|
375
|
+
if ($e) {
|
|
376
|
+
$e(e, t, r);
|
|
376
377
|
return;
|
|
377
378
|
}
|
|
378
|
-
t === "success" ?
|
|
379
|
+
t === "success" ? Ze.success(e, r) : t === "info" ? Ze.info(e, r) : Ze.error(e, r);
|
|
379
380
|
}
|
|
380
|
-
function
|
|
381
|
-
return
|
|
382
|
-
|
|
381
|
+
function tt(e) {
|
|
382
|
+
return Qe.add(e), () => {
|
|
383
|
+
Qe.delete(e);
|
|
383
384
|
};
|
|
384
385
|
}
|
|
385
386
|
//#endregion
|
|
386
387
|
//#region src/components/image-upload-dialog.tsx
|
|
387
|
-
var
|
|
388
|
+
var nt = /* @__PURE__ */ e({ ImageUploadDialog: () => rt }), rt = ({ open: e, onClose: t, onInsert: n, validate: r }) => {
|
|
388
389
|
let [i, a] = T("upload"), [s, c] = T(!1), [l, u] = T(!1), [d, f] = T(null), [p, m] = T(null), [h, g] = T(""), [_, v] = T(null), y = w(null), x = (() => {
|
|
389
390
|
try {
|
|
390
391
|
let e = o();
|
|
@@ -676,10 +677,10 @@ var et = /* @__PURE__ */ e({ ImageUploadDialog: () => tt }), tt = ({ open: e, on
|
|
|
676
677
|
};
|
|
677
678
|
//#endregion
|
|
678
679
|
//#region src/components/toc.tsx
|
|
679
|
-
function
|
|
680
|
+
function it(e, t) {
|
|
680
681
|
return `${e.trim().toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu, "").replace(/\s+/g, "-").slice(0, 40) || "heading"}-${t}`;
|
|
681
682
|
}
|
|
682
|
-
function
|
|
683
|
+
function at(e) {
|
|
683
684
|
let t = [], n = [];
|
|
684
685
|
for (let r of e) {
|
|
685
686
|
let e = {
|
|
@@ -691,18 +692,18 @@ function rt(e) {
|
|
|
691
692
|
}
|
|
692
693
|
return t;
|
|
693
694
|
}
|
|
694
|
-
function
|
|
695
|
+
function ot(e) {
|
|
695
696
|
let t = /* @__PURE__ */ new Set(), n = (e) => {
|
|
696
697
|
for (let r of e) r.children.length > 0 && (t.add(r.id), n(r.children));
|
|
697
698
|
};
|
|
698
699
|
return n(e), t;
|
|
699
700
|
}
|
|
700
|
-
function
|
|
701
|
+
function st(e, t) {
|
|
701
702
|
let n = [];
|
|
702
|
-
for (let r of e) n.push(r), r.children.length > 0 && !t.has(r.id) && n.push(...
|
|
703
|
+
for (let r of e) n.push(r), r.children.length > 0 && !t.has(r.id) && n.push(...st(r.children, t));
|
|
703
704
|
return n;
|
|
704
705
|
}
|
|
705
|
-
function
|
|
706
|
+
function ct(e, t) {
|
|
706
707
|
let n = t.toLowerCase(), r = (e) => {
|
|
707
708
|
let t = [];
|
|
708
709
|
for (let i of e) {
|
|
@@ -716,7 +717,7 @@ function ot(e, t) {
|
|
|
716
717
|
};
|
|
717
718
|
return r(e);
|
|
718
719
|
}
|
|
719
|
-
function
|
|
720
|
+
function lt(e) {
|
|
720
721
|
let t = e.parentElement;
|
|
721
722
|
for (; t && t !== document.documentElement;) {
|
|
722
723
|
let e = getComputedStyle(t).overflowY;
|
|
@@ -725,7 +726,7 @@ function st(e) {
|
|
|
725
726
|
}
|
|
726
727
|
return null;
|
|
727
728
|
}
|
|
728
|
-
function
|
|
729
|
+
function ut(e) {
|
|
729
730
|
if (e.isDestroyed) return null;
|
|
730
731
|
try {
|
|
731
732
|
return e.view.dom;
|
|
@@ -733,7 +734,7 @@ function ct(e) {
|
|
|
733
734
|
return null;
|
|
734
735
|
}
|
|
735
736
|
}
|
|
736
|
-
function
|
|
737
|
+
function dt(e, t) {
|
|
737
738
|
if (!t) return e;
|
|
738
739
|
let n = e.toLowerCase(), r = t.toLowerCase(), i = [], a = 0, o = 0;
|
|
739
740
|
for (;;) {
|
|
@@ -746,12 +747,12 @@ function lt(e, t) {
|
|
|
746
747
|
}
|
|
747
748
|
return a < e.length && i.push(e.slice(a)), i.length ? i : e;
|
|
748
749
|
}
|
|
749
|
-
var
|
|
750
|
+
var ft = 84, pt = 3e3, mt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
750
751
|
let [r, i] = T([]), [a, o] = T(""), [s, c] = T(/* @__PURE__ */ new Set()), [l, u] = T(""), d = w(""), f = w([]), p = w(null), m = w(null), h = w(null), g = w(0), _ = b(() => {
|
|
751
752
|
h.current &&= (clearTimeout(h.current.timer), null);
|
|
752
753
|
}, []), v = b(() => {
|
|
753
|
-
let t =
|
|
754
|
-
return t ? Array.from(t.querySelectorAll("h1,h2,h3,h4,h5,h6")).map((e, t) => (e.id ||=
|
|
754
|
+
let t = ut(e);
|
|
755
|
+
return t ? Array.from(t.querySelectorAll("h1,h2,h3,h4,h5,h6")).map((e, t) => (e.id ||= it(e.textContent || "", t), {
|
|
755
756
|
id: e.id,
|
|
756
757
|
level: Number(e.tagName.slice(1)),
|
|
757
758
|
text: e.textContent?.trim() || "(无标题)",
|
|
@@ -760,7 +761,7 @@ var ut = 84, dt = 3e3, ft = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
760
761
|
}, [e]), y = b(() => {
|
|
761
762
|
let e = f.current;
|
|
762
763
|
if ((!e.length || e.some((e) => !e.el.isConnected)) && (e = v(), f.current = e), !e.length) return;
|
|
763
|
-
let t = m.current, n = (t ? t.getBoundingClientRect().top : 0) +
|
|
764
|
+
let t = m.current, n = (t ? t.getBoundingClientRect().top : 0) + ft, r = t ? t.scrollHeight - t.scrollTop - t.clientHeight < 2 : document.documentElement.scrollHeight - window.scrollY - window.innerHeight < 2, i = "";
|
|
764
765
|
for (let t of e) t.el.isConnected && t.el.getBoundingClientRect().top <= n && (i = t.id);
|
|
765
766
|
if (r) {
|
|
766
767
|
for (let t = e.length - 1; t >= 0; t--) if (e[t].el.isConnected) {
|
|
@@ -784,7 +785,7 @@ var ut = 84, dt = 3e3, ft = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
784
785
|
t !== d.current && (d.current = t, f.current = e, i(e), S());
|
|
785
786
|
}, [v, S]);
|
|
786
787
|
x(() => {
|
|
787
|
-
let t =
|
|
788
|
+
let t = ut(e), n = t ? lt(t) : null;
|
|
788
789
|
m.current = n;
|
|
789
790
|
let r = n ?? window;
|
|
790
791
|
return r.addEventListener("scroll", S, { passive: !0 }), window.addEventListener("resize", S), r.addEventListener("wheel", _, { passive: !0 }), r.addEventListener("touchstart", _, { passive: !0 }), () => {
|
|
@@ -812,7 +813,7 @@ var ut = 84, dt = 3e3, ft = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
812
813
|
_
|
|
813
814
|
]);
|
|
814
815
|
let k = b((t) => {
|
|
815
|
-
let n =
|
|
816
|
+
let n = ut(e);
|
|
816
817
|
if (!n) return;
|
|
817
818
|
let r = t.el;
|
|
818
819
|
if ((!r || !n.contains(r)) && (r = n.querySelector(`[id="${CSS.escape(t.id)}"]`)), !r) {
|
|
@@ -825,59 +826,59 @@ var ut = 84, dt = 3e3, ft = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
825
826
|
if (!r) return;
|
|
826
827
|
_(), h.current = {
|
|
827
828
|
id: t.id,
|
|
828
|
-
timer: setTimeout(_,
|
|
829
|
+
timer: setTimeout(_, pt)
|
|
829
830
|
}, o(t.id);
|
|
830
831
|
let i = m.current, a = r.getBoundingClientRect().top;
|
|
831
832
|
if (i) {
|
|
832
833
|
let e = i.getBoundingClientRect().top;
|
|
833
834
|
i.scrollTo({
|
|
834
|
-
top: i.scrollTop + a - e -
|
|
835
|
+
top: i.scrollTop + a - e - ft,
|
|
835
836
|
behavior: "smooth"
|
|
836
837
|
});
|
|
837
838
|
} else window.scrollTo({
|
|
838
|
-
top: window.scrollY + a -
|
|
839
|
+
top: window.scrollY + a - ft,
|
|
839
840
|
behavior: "smooth"
|
|
840
841
|
});
|
|
841
|
-
}, [e, _]), A = C(() =>
|
|
842
|
+
}, [e, _]), A = C(() => at(r), [r]), j = C(() => ot(A), [A]), M = C(() => {
|
|
842
843
|
let e = /* @__PURE__ */ new Map(), t = (n, r) => {
|
|
843
844
|
for (let i of n) r && e.set(i.id, r), t(i.children, i.id);
|
|
844
845
|
};
|
|
845
846
|
return t(A, ""), e;
|
|
846
|
-
}, [A]), N = l.trim().length > 0,
|
|
847
|
+
}, [A]), N = l.trim().length > 0, ee = C(() => N ? ct(A, l.trim()) : A, [
|
|
847
848
|
A,
|
|
848
849
|
N,
|
|
849
850
|
l
|
|
850
|
-
]),
|
|
851
|
-
|
|
851
|
+
]), P = C(() => st(ee, N ? /* @__PURE__ */ new Set() : s), [
|
|
852
|
+
ee,
|
|
852
853
|
s,
|
|
853
854
|
N
|
|
854
|
-
]),
|
|
855
|
+
]), F = C(() => new Set(P.map((e) => e.id)), [P]), I = C(() => {
|
|
855
856
|
let e = a;
|
|
856
|
-
for (; e && !
|
|
857
|
+
for (; e && !F.has(e);) e = M.get(e) ?? "";
|
|
857
858
|
return e;
|
|
858
859
|
}, [
|
|
859
860
|
a,
|
|
860
|
-
|
|
861
|
+
F,
|
|
861
862
|
M
|
|
862
863
|
]);
|
|
863
864
|
x(() => {
|
|
864
865
|
let e = p.current;
|
|
865
|
-
if (!e || !
|
|
866
|
+
if (!e || !I) return;
|
|
866
867
|
let t = e.closest(".toc-scroll");
|
|
867
868
|
if (!(t instanceof HTMLElement)) return;
|
|
868
|
-
let n = e.querySelector(`[data-toc-id="${CSS.escape(
|
|
869
|
+
let n = e.querySelector(`[data-toc-id="${CSS.escape(I)}"]`);
|
|
869
870
|
if (!n) return;
|
|
870
871
|
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect();
|
|
871
872
|
i.top < r.top + 8 ? t.scrollTop -= r.top + 8 - i.top : i.bottom > r.bottom - 8 && (t.scrollTop += i.bottom - (r.bottom - 8));
|
|
872
|
-
}, [
|
|
873
|
-
let
|
|
873
|
+
}, [I]);
|
|
874
|
+
let te = b((e) => {
|
|
874
875
|
c((t) => {
|
|
875
876
|
let n = new Set(t);
|
|
876
877
|
return n.has(e) ? n.delete(e) : n.add(e), n;
|
|
877
878
|
});
|
|
878
|
-
}, []),
|
|
879
|
+
}, []), ne = b(() => {
|
|
879
880
|
c(new Set(j));
|
|
880
|
-
}, [j]),
|
|
881
|
+
}, [j]), L = b(() => {
|
|
881
882
|
c(/* @__PURE__ */ new Set());
|
|
882
883
|
}, []);
|
|
883
884
|
return r.length ? /* @__PURE__ */ O("nav", {
|
|
@@ -948,7 +949,7 @@ var ut = 84, dt = 3e3, ft = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
948
949
|
children: [/* @__PURE__ */ D("button", {
|
|
949
950
|
type: "button",
|
|
950
951
|
className: "toc-action-btn",
|
|
951
|
-
onClick:
|
|
952
|
+
onClick: ne,
|
|
952
953
|
title: "全部折叠",
|
|
953
954
|
"aria-label": "全部折叠",
|
|
954
955
|
disabled: N,
|
|
@@ -969,7 +970,7 @@ var ut = 84, dt = 3e3, ft = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
969
970
|
}), /* @__PURE__ */ D("button", {
|
|
970
971
|
type: "button",
|
|
971
972
|
className: "toc-action-btn",
|
|
972
|
-
onClick:
|
|
973
|
+
onClick: L,
|
|
973
974
|
title: "全部展开",
|
|
974
975
|
"aria-label": "全部展开",
|
|
975
976
|
disabled: N,
|
|
@@ -1040,22 +1041,22 @@ var ut = 84, dt = 3e3, ft = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
1040
1041
|
})
|
|
1041
1042
|
]
|
|
1042
1043
|
}),
|
|
1043
|
-
|
|
1044
|
+
P.length === 0 ? /* @__PURE__ */ D("div", {
|
|
1044
1045
|
className: "toc-search__empty",
|
|
1045
1046
|
children: N ? `未找到"${l.trim()}"相关标题` : "文档暂无标题"
|
|
1046
1047
|
}) : /* @__PURE__ */ D("ul", {
|
|
1047
1048
|
className: "toc-list",
|
|
1048
|
-
children:
|
|
1049
|
+
children: P.map((e) => {
|
|
1049
1050
|
let t = j.has(e.id), n = s.has(e.id);
|
|
1050
1051
|
return /* @__PURE__ */ O("li", {
|
|
1051
1052
|
"data-toc-id": e.id,
|
|
1052
|
-
className: `toc-item ${
|
|
1053
|
+
className: `toc-item ${I === e.id ? "is-active" : ""}`,
|
|
1053
1054
|
style: { paddingLeft: `${(e.level - 1) * 12 + 12}px` },
|
|
1054
1055
|
children: [t ? /* @__PURE__ */ D("button", {
|
|
1055
1056
|
type: "button",
|
|
1056
1057
|
className: `toc-toggle ${n ? "is-collapsed" : "is-expanded"}`,
|
|
1057
1058
|
onClick: (t) => {
|
|
1058
|
-
t.stopPropagation(),
|
|
1059
|
+
t.stopPropagation(), te(e.id);
|
|
1059
1060
|
},
|
|
1060
1061
|
title: n ? "展开子标题" : "折叠子标题",
|
|
1061
1062
|
"aria-label": n ? "展开子标题" : "折叠子标题",
|
|
@@ -1078,7 +1079,7 @@ var ut = 84, dt = 3e3, ft = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
1078
1079
|
title: e.text,
|
|
1079
1080
|
children: /* @__PURE__ */ D("span", {
|
|
1080
1081
|
className: "toc-text",
|
|
1081
|
-
children: N ?
|
|
1082
|
+
children: N ? dt(e.text, l.trim()) : e.text
|
|
1082
1083
|
})
|
|
1083
1084
|
})]
|
|
1084
1085
|
}, e.id);
|
|
@@ -1102,7 +1103,7 @@ var ut = 84, dt = 3e3, ft = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
1102
1103
|
};
|
|
1103
1104
|
//#endregion
|
|
1104
1105
|
//#region src/editor/ai/index.ts
|
|
1105
|
-
function
|
|
1106
|
+
function ht(e, t) {
|
|
1106
1107
|
return {
|
|
1107
1108
|
continue: "你是一个写作助手。请从下文尾部自然流畅地续写内容,保持风格一致。只输出续写的内容,不要加任何前缀说明。",
|
|
1108
1109
|
improve: "你是一个文字润色专家。请优化以下文本的表达,提升文采和流畅度,保持原意不变。只输出润色后的文本。",
|
|
@@ -1113,8 +1114,8 @@ function pt(e, t) {
|
|
|
1113
1114
|
zap: t || "你是一个全能的 AI 写作助手。请根据用户的指令处理文本。"
|
|
1114
1115
|
}[e];
|
|
1115
1116
|
}
|
|
1116
|
-
var
|
|
1117
|
-
async function
|
|
1117
|
+
var gt = null;
|
|
1118
|
+
async function _t(e) {
|
|
1118
1119
|
let t;
|
|
1119
1120
|
try {
|
|
1120
1121
|
({createOpenAI: t} = await import("@ai-sdk/openai"));
|
|
@@ -1129,7 +1130,7 @@ async function ht(e) {
|
|
|
1129
1130
|
async *stream(e) {
|
|
1130
1131
|
let t = await A({
|
|
1131
1132
|
model: n,
|
|
1132
|
-
system:
|
|
1133
|
+
system: ht(e.mode, e.instruction),
|
|
1133
1134
|
prompt: e.context,
|
|
1134
1135
|
temperature: .7,
|
|
1135
1136
|
maxOutputTokens: 2048
|
|
@@ -1139,7 +1140,7 @@ async function ht(e) {
|
|
|
1139
1140
|
async generate(e) {
|
|
1140
1141
|
return (await k({
|
|
1141
1142
|
model: n,
|
|
1142
|
-
system:
|
|
1143
|
+
system: ht(e.mode, e.instruction),
|
|
1143
1144
|
prompt: e.context,
|
|
1144
1145
|
temperature: .7,
|
|
1145
1146
|
maxOutputTokens: 2048
|
|
@@ -1147,16 +1148,16 @@ async function ht(e) {
|
|
|
1147
1148
|
}
|
|
1148
1149
|
};
|
|
1149
1150
|
}
|
|
1150
|
-
function
|
|
1151
|
-
|
|
1151
|
+
function vt(e) {
|
|
1152
|
+
gt = e;
|
|
1152
1153
|
}
|
|
1153
|
-
function
|
|
1154
|
-
if (!
|
|
1155
|
-
return
|
|
1154
|
+
function yt() {
|
|
1155
|
+
if (!gt) throw Error("未配置 AI 服务。请调用 createAILanguageModelProvider() 创建并通过 setAIProvider() 注册。");
|
|
1156
|
+
return gt;
|
|
1156
1157
|
}
|
|
1157
1158
|
//#endregion
|
|
1158
1159
|
//#region src/editor/ai/providers/openai-compat.ts
|
|
1159
|
-
function
|
|
1160
|
+
function bt(e) {
|
|
1160
1161
|
let { apiKey: t, baseURL: n, model: r, headers: i } = e;
|
|
1161
1162
|
async function* a(e, a) {
|
|
1162
1163
|
let o = await fetch(`${n}/chat/completions`, {
|
|
@@ -1207,10 +1208,10 @@ function vt(e) {
|
|
|
1207
1208
|
}
|
|
1208
1209
|
return {
|
|
1209
1210
|
async *stream(e) {
|
|
1210
|
-
yield* a(
|
|
1211
|
+
yield* a(ht(e.mode, e.instruction), e.context);
|
|
1211
1212
|
},
|
|
1212
1213
|
async generate(e) {
|
|
1213
|
-
let t =
|
|
1214
|
+
let t = ht(e.mode, e.instruction), n = "";
|
|
1214
1215
|
for await (let r of a(t, e.context)) n += r;
|
|
1215
1216
|
return n;
|
|
1216
1217
|
}
|
|
@@ -1218,8 +1219,8 @@ function vt(e) {
|
|
|
1218
1219
|
}
|
|
1219
1220
|
//#endregion
|
|
1220
1221
|
//#region src/editor/ai/providers/deepseek.ts
|
|
1221
|
-
function
|
|
1222
|
-
return
|
|
1222
|
+
function xt(e) {
|
|
1223
|
+
return bt({
|
|
1223
1224
|
apiKey: e.apiKey,
|
|
1224
1225
|
baseURL: e.baseURL || "https://api.deepseek.com/v1",
|
|
1225
1226
|
model: e.model || "deepseek-v4-flash",
|
|
@@ -1228,8 +1229,8 @@ function yt(e) {
|
|
|
1228
1229
|
}
|
|
1229
1230
|
//#endregion
|
|
1230
1231
|
//#region src/editor/ai/providers/openai.ts
|
|
1231
|
-
function
|
|
1232
|
-
return
|
|
1232
|
+
function St(e) {
|
|
1233
|
+
return bt({
|
|
1233
1234
|
apiKey: e.apiKey,
|
|
1234
1235
|
baseURL: e.baseURL || "https://api.openai.com/v1",
|
|
1235
1236
|
model: e.model || "gpt-5.6-luna",
|
|
@@ -1238,8 +1239,8 @@ function bt(e) {
|
|
|
1238
1239
|
}
|
|
1239
1240
|
//#endregion
|
|
1240
1241
|
//#region src/editor/ai/providers/qwen.ts
|
|
1241
|
-
function
|
|
1242
|
-
return
|
|
1242
|
+
function Ct(e) {
|
|
1243
|
+
return bt({
|
|
1243
1244
|
apiKey: e.apiKey,
|
|
1244
1245
|
baseURL: e.baseURL || "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
1245
1246
|
model: e.model || "qwen3.7-plus",
|
|
@@ -1248,20 +1249,20 @@ function xt(e) {
|
|
|
1248
1249
|
}
|
|
1249
1250
|
//#endregion
|
|
1250
1251
|
//#region src/editor/extensions/search-highlight.ts
|
|
1251
|
-
var
|
|
1252
|
+
var wt = {
|
|
1252
1253
|
keyword: "",
|
|
1253
1254
|
caseSensitive: !1,
|
|
1254
1255
|
wholeWord: !1,
|
|
1255
1256
|
matches: [],
|
|
1256
1257
|
currentIndex: -1
|
|
1257
|
-
},
|
|
1258
|
-
function
|
|
1258
|
+
}, Tt = new H("search-highlight");
|
|
1259
|
+
function Et(e) {
|
|
1259
1260
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1260
1261
|
}
|
|
1261
|
-
function
|
|
1262
|
+
function Dt(e, t) {
|
|
1262
1263
|
let { keyword: n, caseSensitive: r, wholeWord: i } = t;
|
|
1263
1264
|
if (!n) return [];
|
|
1264
|
-
let a = r ? "g" : "gi", o = i ? `\\b${
|
|
1265
|
+
let a = r ? "g" : "gi", o = i ? `\\b${Et(n)}\\b` : Et(n), s = new RegExp(o, a), c = [];
|
|
1265
1266
|
return e.descendants((e, t) => {
|
|
1266
1267
|
if (!e.isText || !e.text) return;
|
|
1267
1268
|
s.lastIndex = 0;
|
|
@@ -1275,12 +1276,12 @@ function Tt(e, t) {
|
|
|
1275
1276
|
}
|
|
1276
1277
|
}), c;
|
|
1277
1278
|
}
|
|
1278
|
-
function
|
|
1279
|
-
if (t.matches.length === 0) return
|
|
1280
|
-
let n = t.matches.map((e, n) =>
|
|
1281
|
-
return
|
|
1279
|
+
function Ot(e, t) {
|
|
1280
|
+
if (t.matches.length === 0) return U.empty;
|
|
1281
|
+
let n = t.matches.map((e, n) => oe.inline(e.from, e.to, { class: n === t.currentIndex ? "search-highlight search-highlight--active" : "search-highlight" }));
|
|
1282
|
+
return U.create(e, n);
|
|
1282
1283
|
}
|
|
1283
|
-
function
|
|
1284
|
+
function kt(e, t) {
|
|
1284
1285
|
if (t.currentIndex < 0 || t.currentIndex >= t.matches.length) return;
|
|
1285
1286
|
let n = t.matches[t.currentIndex];
|
|
1286
1287
|
n && requestAnimationFrame(() => {
|
|
@@ -1305,15 +1306,15 @@ function Dt(e, t) {
|
|
|
1305
1306
|
} catch {}
|
|
1306
1307
|
});
|
|
1307
1308
|
}
|
|
1308
|
-
var
|
|
1309
|
+
var At = R.create({
|
|
1309
1310
|
name: "searchHighlight",
|
|
1310
1311
|
addProseMirrorPlugins() {
|
|
1311
|
-
return [new
|
|
1312
|
-
key:
|
|
1312
|
+
return [new V({
|
|
1313
|
+
key: Tt,
|
|
1313
1314
|
state: {
|
|
1314
|
-
init: () =>
|
|
1315
|
+
init: () => wt,
|
|
1315
1316
|
apply(e, t) {
|
|
1316
|
-
let n = e.getMeta(
|
|
1317
|
+
let n = e.getMeta(Tt);
|
|
1317
1318
|
if (n) return {
|
|
1318
1319
|
...t,
|
|
1319
1320
|
...n,
|
|
@@ -1321,7 +1322,7 @@ var Ot = R.create({
|
|
|
1321
1322
|
currentIndex: n.currentIndex === void 0 ? t.currentIndex : n.currentIndex
|
|
1322
1323
|
};
|
|
1323
1324
|
if (e.docChanged && t.keyword) {
|
|
1324
|
-
let n =
|
|
1325
|
+
let n = Dt(e.doc, t), r = t.currentIndex;
|
|
1325
1326
|
return r >= n.length && (r = n.length - 1), r < 0 && (r = n.length > 0 ? 0 : -1), {
|
|
1326
1327
|
...t,
|
|
1327
1328
|
matches: n,
|
|
@@ -1332,52 +1333,52 @@ var Ot = R.create({
|
|
|
1332
1333
|
}
|
|
1333
1334
|
},
|
|
1334
1335
|
props: { decorations(e) {
|
|
1335
|
-
let t =
|
|
1336
|
-
return t ?
|
|
1336
|
+
let t = Tt.getState(e);
|
|
1337
|
+
return t ? Ot(e.doc, t) : U.empty;
|
|
1337
1338
|
} }
|
|
1338
1339
|
})];
|
|
1339
1340
|
},
|
|
1340
1341
|
addCommands() {
|
|
1341
1342
|
return {
|
|
1342
1343
|
setSearch: (e, t = {}) => ({ state: n, dispatch: r, view: i }) => {
|
|
1343
|
-
let a =
|
|
1344
|
+
let a = Tt.getState(n) || wt, o = {
|
|
1344
1345
|
keyword: e,
|
|
1345
1346
|
caseSensitive: t.caseSensitive ?? a.caseSensitive,
|
|
1346
1347
|
wholeWord: t.wholeWord ?? a.wholeWord,
|
|
1347
1348
|
matches: [],
|
|
1348
1349
|
currentIndex: -1
|
|
1349
1350
|
};
|
|
1350
|
-
return o.matches =
|
|
1351
|
+
return o.matches = Dt(n.doc, o), o.currentIndex = o.matches.length > 0 ? 0 : -1, r && (r(n.tr.setMeta(Tt, o)), i && kt(i, o)), !0;
|
|
1351
1352
|
},
|
|
1352
1353
|
nextMatch: () => ({ state: e, dispatch: t, view: n }) => {
|
|
1353
|
-
let r =
|
|
1354
|
+
let r = Tt.getState(e) || wt;
|
|
1354
1355
|
if (r.matches.length === 0) return !1;
|
|
1355
1356
|
let i = (r.currentIndex + 1) % r.matches.length;
|
|
1356
|
-
return t && (t(e.tr.setMeta(
|
|
1357
|
+
return t && (t(e.tr.setMeta(Tt, { currentIndex: i })), n && kt(n, {
|
|
1357
1358
|
...r,
|
|
1358
1359
|
currentIndex: i
|
|
1359
1360
|
})), !0;
|
|
1360
1361
|
},
|
|
1361
1362
|
prevMatch: () => ({ state: e, dispatch: t, view: n }) => {
|
|
1362
|
-
let r =
|
|
1363
|
+
let r = Tt.getState(e) || wt;
|
|
1363
1364
|
if (r.matches.length === 0) return !1;
|
|
1364
1365
|
let i = (r.currentIndex - 1 + r.matches.length) % r.matches.length;
|
|
1365
|
-
return t && (t(e.tr.setMeta(
|
|
1366
|
+
return t && (t(e.tr.setMeta(Tt, { currentIndex: i })), n && kt(n, {
|
|
1366
1367
|
...r,
|
|
1367
1368
|
currentIndex: i
|
|
1368
1369
|
})), !0;
|
|
1369
1370
|
},
|
|
1370
|
-
clearSearch: () => ({ state: e, dispatch: t }) => (t && t(e.tr.setMeta(
|
|
1371
|
+
clearSearch: () => ({ state: e, dispatch: t }) => (t && t(e.tr.setMeta(Tt, wt)), !0)
|
|
1371
1372
|
};
|
|
1372
1373
|
}
|
|
1373
1374
|
});
|
|
1374
|
-
function
|
|
1375
|
+
function jt(e) {
|
|
1375
1376
|
let t = e.state;
|
|
1376
|
-
return
|
|
1377
|
+
return Tt.getState(t) || wt;
|
|
1377
1378
|
}
|
|
1378
1379
|
//#endregion
|
|
1379
1380
|
//#region src/components/search-bar.tsx
|
|
1380
|
-
var
|
|
1381
|
+
var Mt = ({ editor: e, onClose: t }) => {
|
|
1381
1382
|
let [n, r] = T(""), [i, a] = T(!1), [o, s] = T(!1), [c, l] = T(0), u = w(null), d = w({
|
|
1382
1383
|
keyword: n,
|
|
1383
1384
|
caseSensitive: i,
|
|
@@ -1442,7 +1443,7 @@ var At = ({ editor: e, onClose: t }) => {
|
|
|
1442
1443
|
}, [f, p]), h = C(() => {
|
|
1443
1444
|
if (!e) return null;
|
|
1444
1445
|
try {
|
|
1445
|
-
return
|
|
1446
|
+
return jt(e);
|
|
1446
1447
|
} catch {
|
|
1447
1448
|
return null;
|
|
1448
1449
|
}
|
|
@@ -1594,36 +1595,36 @@ function Q({ children: e, ...t }) {
|
|
|
1594
1595
|
children: e
|
|
1595
1596
|
});
|
|
1596
1597
|
}
|
|
1597
|
-
var
|
|
1598
|
+
var Nt = (e) => /* @__PURE__ */ O(Q, {
|
|
1598
1599
|
...e,
|
|
1599
1600
|
children: [/* @__PURE__ */ D("path", { d: "M6 4h8a4 4 0 0 1 0 8H6z" }), /* @__PURE__ */ D("path", { d: "M6 12h9a4 4 0 0 1 0 8H6z" })]
|
|
1600
|
-
}),
|
|
1601
|
+
}), Pt = (e) => /* @__PURE__ */ O(Q, {
|
|
1601
1602
|
...e,
|
|
1602
1603
|
children: [
|
|
1603
1604
|
/* @__PURE__ */ D("path", { d: "M19 4h-9" }),
|
|
1604
1605
|
/* @__PURE__ */ D("path", { d: "M14 20H5" }),
|
|
1605
1606
|
/* @__PURE__ */ D("path", { d: "M15 4 9 20" })
|
|
1606
1607
|
]
|
|
1607
|
-
}),
|
|
1608
|
+
}), Ft = (e) => /* @__PURE__ */ O(Q, {
|
|
1608
1609
|
...e,
|
|
1609
1610
|
children: [/* @__PURE__ */ D("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }), /* @__PURE__ */ D("path", { d: "M4 20h16" })]
|
|
1610
|
-
}),
|
|
1611
|
+
}), It = (e) => /* @__PURE__ */ O(Q, {
|
|
1611
1612
|
...e,
|
|
1612
1613
|
children: [
|
|
1613
1614
|
/* @__PURE__ */ D("path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }),
|
|
1614
1615
|
/* @__PURE__ */ D("path", { d: "M14 12a4 4 0 0 1 0 8H6" }),
|
|
1615
1616
|
/* @__PURE__ */ D("path", { d: "M4 12h16" })
|
|
1616
1617
|
]
|
|
1617
|
-
}),
|
|
1618
|
+
}), Lt = (e) => /* @__PURE__ */ O(Q, {
|
|
1618
1619
|
...e,
|
|
1619
1620
|
children: [/* @__PURE__ */ D("path", { d: "m16 18 6-6-6-6" }), /* @__PURE__ */ D("path", { d: "m8 6-6 6 6 6" })]
|
|
1620
|
-
}),
|
|
1621
|
+
}), Rt = (e) => /* @__PURE__ */ O(Q, {
|
|
1621
1622
|
...e,
|
|
1622
1623
|
children: [/* @__PURE__ */ D("path", { d: "m9 11-6 6v3h9l3-3" }), /* @__PURE__ */ D("path", { d: "m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4" })]
|
|
1623
|
-
}),
|
|
1624
|
+
}), zt = (e) => /* @__PURE__ */ O(Q, {
|
|
1624
1625
|
...e,
|
|
1625
1626
|
children: [/* @__PURE__ */ D("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }), /* @__PURE__ */ D("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })]
|
|
1626
|
-
}),
|
|
1627
|
+
}), Bt = (e) => /* @__PURE__ */ O(Q, {
|
|
1627
1628
|
...e,
|
|
1628
1629
|
children: [/* @__PURE__ */ D("rect", {
|
|
1629
1630
|
x: "3",
|
|
@@ -1633,7 +1634,7 @@ var jt = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1633
1634
|
rx: "2",
|
|
1634
1635
|
ry: "2"
|
|
1635
1636
|
}), /* @__PURE__ */ D("path", { d: "M3 9h18M3 15h18M9 3v18M15 3v18" })]
|
|
1636
|
-
}),
|
|
1637
|
+
}), Vt = (e) => /* @__PURE__ */ O(Q, {
|
|
1637
1638
|
...e,
|
|
1638
1639
|
children: [/* @__PURE__ */ D("rect", {
|
|
1639
1640
|
x: "8",
|
|
@@ -1643,17 +1644,17 @@ var jt = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1643
1644
|
rx: "2",
|
|
1644
1645
|
ry: "2"
|
|
1645
1646
|
}), /* @__PURE__ */ D("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })]
|
|
1646
|
-
}),
|
|
1647
|
+
}), Ht = (e) => /* @__PURE__ */ O(Q, {
|
|
1647
1648
|
...e,
|
|
1648
1649
|
children: [/* @__PURE__ */ D("circle", {
|
|
1649
1650
|
cx: "11",
|
|
1650
1651
|
cy: "11",
|
|
1651
1652
|
r: "8"
|
|
1652
1653
|
}), /* @__PURE__ */ D("path", { d: "m21 21-4.3-4.3" })]
|
|
1653
|
-
}),
|
|
1654
|
+
}), Ut = (e) => /* @__PURE__ */ O(Q, {
|
|
1654
1655
|
...e,
|
|
1655
1656
|
children: [/* @__PURE__ */ D("path", { d: "M12 3l1.6 4.4L18 9l-4.4 1.6L12 15l-1.6-4.4L6 9l4.4-1.6L12 3z" }), /* @__PURE__ */ D("path", { d: "M18.5 14l.7 1.9 1.9.7-1.9.7-.7 1.9-.7-1.9-1.9-.7 1.9-.7.7-1.9z" })]
|
|
1656
|
-
}),
|
|
1657
|
+
}), Wt = (e) => /* @__PURE__ */ O(Q, {
|
|
1657
1658
|
...e,
|
|
1658
1659
|
children: [
|
|
1659
1660
|
/* @__PURE__ */ D("circle", {
|
|
@@ -1672,13 +1673,13 @@ var jt = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1672
1673
|
r: "1"
|
|
1673
1674
|
})
|
|
1674
1675
|
]
|
|
1675
|
-
}),
|
|
1676
|
+
}), Gt = (e) => /* @__PURE__ */ O(Q, {
|
|
1676
1677
|
...e,
|
|
1677
1678
|
children: [/* @__PURE__ */ D("path", { d: "M18 6 6 18" }), /* @__PURE__ */ D("path", { d: "m6 6 12 12" })]
|
|
1678
1679
|
});
|
|
1679
1680
|
//#endregion
|
|
1680
1681
|
//#region src/editor/storage/remove-resource.ts
|
|
1681
|
-
async function
|
|
1682
|
+
async function Kt(e) {
|
|
1682
1683
|
if (e) {
|
|
1683
1684
|
if (e.startsWith("blob:")) {
|
|
1684
1685
|
URL.revokeObjectURL(e);
|
|
@@ -1693,61 +1694,61 @@ async function Wt(e) {
|
|
|
1693
1694
|
}
|
|
1694
1695
|
//#endregion
|
|
1695
1696
|
//#region src/editor/ai/pending-removal.ts
|
|
1696
|
-
var
|
|
1697
|
+
var qt = 3e4, Jt = /* @__PURE__ */ new Set([
|
|
1697
1698
|
"image",
|
|
1698
1699
|
"attachmentEmbed",
|
|
1699
1700
|
"audioEmbed",
|
|
1700
1701
|
"videoEmbed"
|
|
1701
|
-
]),
|
|
1702
|
-
function
|
|
1702
|
+
]), Yt = /* @__PURE__ */ new WeakMap();
|
|
1703
|
+
function Xt(e) {
|
|
1703
1704
|
let t = /* @__PURE__ */ new Set();
|
|
1704
1705
|
return e.state.doc.descendants((e) => {
|
|
1705
|
-
if (
|
|
1706
|
+
if (Jt.has(e.type.name)) {
|
|
1706
1707
|
let n = e.attrs.src;
|
|
1707
1708
|
n && t.add(n);
|
|
1708
1709
|
}
|
|
1709
1710
|
return !0;
|
|
1710
1711
|
}), t;
|
|
1711
1712
|
}
|
|
1712
|
-
function
|
|
1713
|
-
let t =
|
|
1713
|
+
function Zt(e) {
|
|
1714
|
+
let t = Yt.get(e);
|
|
1714
1715
|
return t || (t = {
|
|
1715
1716
|
timers: /* @__PURE__ */ new Map(),
|
|
1716
1717
|
onTransaction: () => {},
|
|
1717
1718
|
listening: !1
|
|
1718
|
-
},
|
|
1719
|
+
}, Yt.set(e, t)), t;
|
|
1719
1720
|
}
|
|
1720
|
-
function
|
|
1721
|
+
function Qt(e, t) {
|
|
1721
1722
|
let n = [...new Set(t.filter(Boolean))];
|
|
1722
1723
|
if (n.length === 0) return;
|
|
1723
|
-
let r =
|
|
1724
|
+
let r = Zt(e);
|
|
1724
1725
|
r.listening ||= (r.onTransaction = () => {
|
|
1725
1726
|
if (r.timers.size === 0) return;
|
|
1726
|
-
let t =
|
|
1727
|
+
let t = Xt(e);
|
|
1727
1728
|
for (let [e, n] of r.timers) t.has(e) && (clearTimeout(n), r.timers.delete(e));
|
|
1728
1729
|
}, e.on("transaction", r.onTransaction), !0);
|
|
1729
1730
|
for (let t of n) {
|
|
1730
1731
|
if (r.timers.has(t)) continue;
|
|
1731
1732
|
let n = setTimeout(() => {
|
|
1732
|
-
|
|
1733
|
-
},
|
|
1733
|
+
Xt(e).has(t) || Kt(t), r.timers.delete(t);
|
|
1734
|
+
}, qt);
|
|
1734
1735
|
r.timers.set(t, n);
|
|
1735
1736
|
}
|
|
1736
1737
|
}
|
|
1737
|
-
function
|
|
1738
|
-
let t =
|
|
1738
|
+
function $t(e) {
|
|
1739
|
+
let t = Yt.get(e);
|
|
1739
1740
|
if (t) {
|
|
1740
1741
|
if (t.listening &&= (e.off("transaction", t.onTransaction), !1), t.timers.size > 0) {
|
|
1741
|
-
let n =
|
|
1742
|
-
for (let [e, r] of t.timers) clearTimeout(r), n.has(e) ||
|
|
1742
|
+
let n = Xt(e);
|
|
1743
|
+
for (let [e, r] of t.timers) clearTimeout(r), n.has(e) || Kt(e);
|
|
1743
1744
|
t.timers.clear();
|
|
1744
1745
|
}
|
|
1745
|
-
|
|
1746
|
+
Yt.delete(e);
|
|
1746
1747
|
}
|
|
1747
1748
|
}
|
|
1748
1749
|
//#endregion
|
|
1749
1750
|
//#region src/editor/ai/components/ai-selector.tsx
|
|
1750
|
-
var
|
|
1751
|
+
var en = [
|
|
1751
1752
|
{
|
|
1752
1753
|
mode: "continue",
|
|
1753
1754
|
labelKey: "editor.ai.continue",
|
|
@@ -1790,24 +1791,24 @@ var Qt = [
|
|
|
1790
1791
|
descKey: "editor.ai.zapDesc",
|
|
1791
1792
|
icon: "⚡"
|
|
1792
1793
|
}
|
|
1793
|
-
],
|
|
1794
|
+
], tn = /* @__PURE__ */ new Set([
|
|
1794
1795
|
"image",
|
|
1795
1796
|
"attachmentEmbed",
|
|
1796
1797
|
"audioEmbed",
|
|
1797
1798
|
"videoEmbed"
|
|
1798
|
-
]),
|
|
1799
|
+
]), nn = {
|
|
1799
1800
|
image: "editor.ai.nodeImage",
|
|
1800
1801
|
attachmentEmbed: "editor.ai.nodeAttachment",
|
|
1801
1802
|
videoEmbed: "editor.ai.nodeVideo",
|
|
1802
1803
|
audioEmbed: "editor.ai.nodeAudio"
|
|
1803
1804
|
};
|
|
1804
|
-
function
|
|
1805
|
+
function rn(e, t) {
|
|
1805
1806
|
return e.storage.qingwuUI?.parseMd?.(e.schema, t) || null;
|
|
1806
1807
|
}
|
|
1807
|
-
function
|
|
1808
|
+
function an(e, t, n) {
|
|
1808
1809
|
let r = [];
|
|
1809
1810
|
return e.state.doc.nodesBetween(t, n, (e) => {
|
|
1810
|
-
if (
|
|
1811
|
+
if (tn.has(e.type.name)) {
|
|
1811
1812
|
let t = e.attrs.src;
|
|
1812
1813
|
t && r.push({
|
|
1813
1814
|
type: e.type.name,
|
|
@@ -1817,27 +1818,27 @@ function nn(e, t, n) {
|
|
|
1817
1818
|
return !0;
|
|
1818
1819
|
}), r;
|
|
1819
1820
|
}
|
|
1820
|
-
function
|
|
1821
|
+
function on(e) {
|
|
1821
1822
|
let t = /* @__PURE__ */ new Set();
|
|
1822
1823
|
return e.state.doc.descendants((e) => {
|
|
1823
|
-
if (
|
|
1824
|
+
if (tn.has(e.type.name)) {
|
|
1824
1825
|
let n = e.attrs.src;
|
|
1825
1826
|
n && t.add(n);
|
|
1826
1827
|
}
|
|
1827
1828
|
return !0;
|
|
1828
1829
|
}), t;
|
|
1829
1830
|
}
|
|
1830
|
-
function
|
|
1831
|
-
let n =
|
|
1831
|
+
function sn(e, t) {
|
|
1832
|
+
let n = rn(e, t);
|
|
1832
1833
|
if (n && n.size > 0) {
|
|
1833
1834
|
let t = e.state.tr;
|
|
1834
|
-
t.replaceWith(0, e.state.doc.content.size, n), t.setSelection(
|
|
1835
|
+
t.replaceWith(0, e.state.doc.content.size, n), t.setSelection(ae.create(t.doc, t.doc.content.size)), e.view.dispatch(t.scrollIntoView()), e.commands.focus();
|
|
1835
1836
|
return;
|
|
1836
1837
|
}
|
|
1837
1838
|
e.commands.setContent(t), e.commands.focus();
|
|
1838
1839
|
}
|
|
1839
|
-
function
|
|
1840
|
-
let i =
|
|
1840
|
+
function cn(e, t, n, r) {
|
|
1841
|
+
let i = rn(e, t);
|
|
1841
1842
|
if (e.commands.focus(), !i) {
|
|
1842
1843
|
let i = e.chain().focus();
|
|
1843
1844
|
n === "replace" ? i.setTextSelection({
|
|
@@ -1849,7 +1850,7 @@ function on(e, t, n, r) {
|
|
|
1849
1850
|
let a = e.state.tr;
|
|
1850
1851
|
n === "replace" ? a.replaceRange(r.from, r.to, new N(i, 0, 0)) : a.insert(Math.min(r.to, e.state.doc.content.size), i), e.view.dispatch(a.scrollIntoView());
|
|
1851
1852
|
}
|
|
1852
|
-
function
|
|
1853
|
+
function ln({ editor: e, onClose: t }) {
|
|
1853
1854
|
let [n, r] = T(null), [i, a] = T(""), [o, s] = T(""), [c, l] = T(!1), [u, d] = T(null), [p, m] = T(null), h = w({
|
|
1854
1855
|
from: 0,
|
|
1855
1856
|
to: 0,
|
|
@@ -1868,7 +1869,7 @@ function sn({ editor: e, onClose: t }) {
|
|
|
1868
1869
|
empty: n.empty
|
|
1869
1870
|
}, l(!0), s(""), v.current = !0, d(null);
|
|
1870
1871
|
try {
|
|
1871
|
-
let r =
|
|
1872
|
+
let r = yt(), a = n.empty ? e.state.doc.textContent : e.state.doc.textBetween(n.from, n.to), o = [];
|
|
1872
1873
|
for await (let e of r.stream({
|
|
1873
1874
|
mode: t,
|
|
1874
1875
|
context: a,
|
|
@@ -1893,13 +1894,13 @@ function sn({ editor: e, onClose: t }) {
|
|
|
1893
1894
|
!e || !v.current || (e.scrollTop = e.scrollHeight);
|
|
1894
1895
|
}, [o]);
|
|
1895
1896
|
let k = b((t, n, r) => {
|
|
1896
|
-
let i = new Set(
|
|
1897
|
-
t === "replaceAll" ?
|
|
1898
|
-
let a =
|
|
1899
|
-
|
|
1897
|
+
let i = new Set(an(e, r.from, r.to).map((e) => e.src));
|
|
1898
|
+
t === "replaceAll" ? sn(e, n) : cn(e, n, "replace", h.current);
|
|
1899
|
+
let a = on(e);
|
|
1900
|
+
Qt(e, [...i].filter((e) => !a.has(e)));
|
|
1900
1901
|
}, [e]), A = b((n) => {
|
|
1901
1902
|
if (n === "below") {
|
|
1902
|
-
|
|
1903
|
+
cn(e, o, "below", h.current), t();
|
|
1903
1904
|
return;
|
|
1904
1905
|
}
|
|
1905
1906
|
let r = h.current, i = n === "replaceAll" ? {
|
|
@@ -1908,7 +1909,7 @@ function sn({ editor: e, onClose: t }) {
|
|
|
1908
1909
|
} : {
|
|
1909
1910
|
from: r.from,
|
|
1910
1911
|
to: r.to
|
|
1911
|
-
}, a =
|
|
1912
|
+
}, a = an(e, i.from, i.to);
|
|
1912
1913
|
if (a.length > 0) {
|
|
1913
1914
|
m({
|
|
1914
1915
|
position: n,
|
|
@@ -1949,19 +1950,19 @@ function sn({ editor: e, onClose: t }) {
|
|
|
1949
1950
|
className: "flex items-center justify-between pl-3 pr-1.5 py-1.5 border-b border-default-100 shrink-0",
|
|
1950
1951
|
children: [/* @__PURE__ */ O("span", {
|
|
1951
1952
|
className: "flex items-center gap-1.5 text-xs font-medium text-default-500",
|
|
1952
|
-
children: [/* @__PURE__ */ D(
|
|
1953
|
+
children: [/* @__PURE__ */ D(Ut, { className: "text-primary" }), f("editor.ai.trigger")]
|
|
1953
1954
|
}), /* @__PURE__ */ D("button", {
|
|
1954
1955
|
type: "button",
|
|
1955
1956
|
onClick: t,
|
|
1956
1957
|
"aria-label": f("editor.ai.close"),
|
|
1957
1958
|
title: f("editor.ai.close"),
|
|
1958
1959
|
className: "flex items-center justify-center w-6 h-6 rounded-md text-default-400 hover:bg-default-100 hover:text-default-700 transition-colors",
|
|
1959
|
-
children: /* @__PURE__ */ D(
|
|
1960
|
+
children: /* @__PURE__ */ D(Gt, {})
|
|
1960
1961
|
})]
|
|
1961
1962
|
}),
|
|
1962
1963
|
/* @__PURE__ */ D("div", {
|
|
1963
1964
|
className: "grid grid-cols-[repeat(auto-fit,minmax(64px,1fr))] gap-1.5 p-2 shrink-0",
|
|
1964
|
-
children:
|
|
1965
|
+
children: en.map(({ mode: e, labelKey: t, descKey: r, icon: i }) => /* @__PURE__ */ O("button", {
|
|
1965
1966
|
type: "button",
|
|
1966
1967
|
className: `flex flex-col items-center gap-1 px-1 py-2 rounded-xl border transition-colors ${n === e ? "border-primary/40 bg-primary/10 text-primary" : "border-default-200 text-default-600 hover:bg-default-100 hover:text-default-900"}`,
|
|
1967
1968
|
onClick: () => y(e),
|
|
@@ -2104,7 +2105,7 @@ function sn({ editor: e, onClose: t }) {
|
|
|
2104
2105
|
children: Object.entries(N).map(([e, t]) => /* @__PURE__ */ O("li", {
|
|
2105
2106
|
className: "text-sm text-default-700",
|
|
2106
2107
|
children: [
|
|
2107
|
-
f(
|
|
2108
|
+
f(nn[e] ?? e),
|
|
2108
2109
|
" ×",
|
|
2109
2110
|
t
|
|
2110
2111
|
]
|
|
@@ -2136,19 +2137,19 @@ function sn({ editor: e, onClose: t }) {
|
|
|
2136
2137
|
}
|
|
2137
2138
|
//#endregion
|
|
2138
2139
|
//#region src/editor/attachment-limits.ts
|
|
2139
|
-
var
|
|
2140
|
+
var un = /* @__PURE__ */ new Set([
|
|
2140
2141
|
"attachmentEmbed",
|
|
2141
2142
|
"videoEmbed",
|
|
2142
2143
|
"audioEmbed",
|
|
2143
2144
|
"image"
|
|
2144
2145
|
]);
|
|
2145
|
-
function
|
|
2146
|
+
function dn(e) {
|
|
2146
2147
|
let t = 0;
|
|
2147
2148
|
return e.descendants((e) => {
|
|
2148
|
-
|
|
2149
|
+
un.has(e.type.name) && (t += Number(e.attrs?.size) || 0);
|
|
2149
2150
|
}), t;
|
|
2150
2151
|
}
|
|
2151
|
-
function
|
|
2152
|
+
function fn(e) {
|
|
2152
2153
|
if (!Number.isFinite(e) || e <= 0) return "0 B";
|
|
2153
2154
|
let t = [
|
|
2154
2155
|
"B",
|
|
@@ -2159,41 +2160,41 @@ function un(e) {
|
|
|
2159
2160
|
], n = Math.min(t.length - 1, Math.floor(Math.log(e) / Math.log(1024))), r = e / 1024 ** n;
|
|
2160
2161
|
return `${n === 0 || r >= 100 ? `${Math.round(r)}` : `${Math.round(r * 10) / 10}`} ${t[n]}`;
|
|
2161
2162
|
}
|
|
2162
|
-
function
|
|
2163
|
+
function pn(e) {
|
|
2163
2164
|
return (e?.storage)?.qingwuUI?.limits;
|
|
2164
2165
|
}
|
|
2165
|
-
function
|
|
2166
|
+
function mn(e, t, n) {
|
|
2166
2167
|
let { maxAttachmentSize: r, maxTotalAttachmentSize: i } = n;
|
|
2167
|
-
if (r && t.size > r) return `单文件大小不能超过 ${
|
|
2168
|
+
if (r && t.size > r) return `单文件大小不能超过 ${fn(r)}(当前 ${fn(t.size)})`;
|
|
2168
2169
|
if (i) {
|
|
2169
|
-
let n =
|
|
2170
|
-
if (n > i) return `附件总大小不能超过 ${
|
|
2170
|
+
let n = dn(e) + t.size;
|
|
2171
|
+
if (n > i) return `附件总大小不能超过 ${fn(i)}(当前合计 ${fn(n)})`;
|
|
2171
2172
|
}
|
|
2172
2173
|
return null;
|
|
2173
2174
|
}
|
|
2174
2175
|
//#endregion
|
|
2175
2176
|
//#region src/editor/utils/delete-confirm.ts
|
|
2176
|
-
var
|
|
2177
|
-
function
|
|
2178
|
-
return
|
|
2177
|
+
var hn = !1, gn = null, _n = 5e3;
|
|
2178
|
+
function vn() {
|
|
2179
|
+
return hn;
|
|
2179
2180
|
}
|
|
2180
2181
|
function $(e) {
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
},
|
|
2182
|
+
hn = e, gn &&= (clearTimeout(gn), null), e && (gn = setTimeout(() => {
|
|
2183
|
+
hn = !1, gn = null;
|
|
2184
|
+
}, _n));
|
|
2184
2185
|
}
|
|
2185
|
-
var
|
|
2186
|
-
function
|
|
2187
|
-
|
|
2186
|
+
var yn = null;
|
|
2187
|
+
function bn(e) {
|
|
2188
|
+
yn = e;
|
|
2188
2189
|
}
|
|
2189
|
-
function
|
|
2190
|
-
return
|
|
2190
|
+
function xn() {
|
|
2191
|
+
return yn;
|
|
2191
2192
|
}
|
|
2192
2193
|
//#endregion
|
|
2193
2194
|
//#region src/editor/utils/delete-confirm-dialog.tsx
|
|
2194
|
-
var
|
|
2195
|
-
function
|
|
2196
|
-
let [s, c] = T(!1), l = w(!1), u =
|
|
2195
|
+
var Sn = 300;
|
|
2196
|
+
function Cn({ open: e, title: t, message: n, confirmText: r = "删除", cancelText: i = "取消", onConfirm: a, onCancel: o }) {
|
|
2197
|
+
let [s, c] = T(!1), l = w(!1), u = xn();
|
|
2197
2198
|
return x(() => {
|
|
2198
2199
|
if (!e) {
|
|
2199
2200
|
l.current = !1;
|
|
@@ -2219,7 +2220,7 @@ function xn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2219
2220
|
o
|
|
2220
2221
|
]), x(() => {
|
|
2221
2222
|
e || c(!1);
|
|
2222
|
-
}, [e]), u || !e ? null :
|
|
2223
|
+
}, [e]), u || !e ? null : L(/* @__PURE__ */ D("div", {
|
|
2223
2224
|
className: "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none",
|
|
2224
2225
|
onClick: () => {
|
|
2225
2226
|
s || o();
|
|
@@ -2263,7 +2264,7 @@ function xn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2263
2264
|
await a();
|
|
2264
2265
|
} finally {
|
|
2265
2266
|
let t = Date.now() - e;
|
|
2266
|
-
t <
|
|
2267
|
+
t < Sn && await new Promise((e) => setTimeout(e, Sn - t)), c(!1), o();
|
|
2267
2268
|
}
|
|
2268
2269
|
},
|
|
2269
2270
|
disabled: s,
|
|
@@ -2276,18 +2277,18 @@ function xn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2276
2277
|
}
|
|
2277
2278
|
//#endregion
|
|
2278
2279
|
//#region src/editor/extensions/image-view.tsx
|
|
2279
|
-
function
|
|
2280
|
+
function wn(e) {
|
|
2280
2281
|
return /^(\.\.?\/|[a-zA-Z]:\\|file:\/\/)/.test(e) ? !0 : !(/^[a-z]+:\/\//i.test(e) || e.startsWith("/") || e.startsWith("data:") || e.startsWith("blob:"));
|
|
2281
2282
|
}
|
|
2282
|
-
function
|
|
2283
|
-
let [i, a] = T(!1), [o, s] = T(!1), [c, l] = T(!1), u = w(!1), [d, f] = T(!1), p = e.attrs.src || "", m = e.attrs.alt || "", h = e.attrs.width || null, g = e.attrs.height || null, _ = w(null), v = w(null), y = w(null), S = w(null), C = w(null), E = w(!1), k = w(!1), A = w(0), [j, M] = T(p), N = r?.isEditable ?? !0,
|
|
2283
|
+
function Tn({ node: e, deleteNode: t, editor: r }) {
|
|
2284
|
+
let [i, a] = T(!1), [o, s] = T(!1), [c, l] = T(!1), u = w(!1), [d, f] = T(!1), p = e.attrs.src || "", m = e.attrs.alt || "", h = e.attrs.width || null, g = e.attrs.height || null, _ = w(null), v = w(null), y = w(null), S = w(null), C = w(null), E = w(!1), k = w(!1), A = w(0), [j, M] = T(p), N = r?.isEditable ?? !0, ee = b(() => {
|
|
2284
2285
|
o || (A.current = window.scrollY, a(!0));
|
|
2285
|
-
}, [o]),
|
|
2286
|
+
}, [o]), F = b(() => {
|
|
2286
2287
|
a(!1), requestAnimationFrame(() => window.scrollTo(0, A.current));
|
|
2287
|
-
}, []),
|
|
2288
|
+
}, []), I = b(() => {
|
|
2288
2289
|
let e = _.current;
|
|
2289
2290
|
e && (A.current = window.scrollY, e.requestFullscreen ? e.requestFullscreen() : e.webkitRequestFullscreen && e.webkitRequestFullscreen());
|
|
2290
|
-
}, []),
|
|
2291
|
+
}, []), te = b(() => {
|
|
2291
2292
|
let e = v.current;
|
|
2292
2293
|
e && (A.current = window.scrollY, e.requestFullscreen ? e.requestFullscreen() : e.webkitRequestFullscreen && e.webkitRequestFullscreen());
|
|
2293
2294
|
}, []);
|
|
@@ -2332,20 +2333,20 @@ function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2332
2333
|
};
|
|
2333
2334
|
return document.addEventListener("fullscreenchange", e), () => document.removeEventListener("fullscreenchange", e);
|
|
2334
2335
|
}, []);
|
|
2335
|
-
let
|
|
2336
|
-
return /* @__PURE__ */ O(
|
|
2336
|
+
let ne = o || wn(p);
|
|
2337
|
+
return /* @__PURE__ */ O(P, {
|
|
2337
2338
|
as: "div",
|
|
2338
2339
|
className: "image-node-view group/img",
|
|
2339
2340
|
contentEditable: !1,
|
|
2340
2341
|
children: [
|
|
2341
|
-
|
|
2342
|
+
ne ? /* @__PURE__ */ O("div", {
|
|
2342
2343
|
className: "image-placeholder",
|
|
2343
2344
|
children: [
|
|
2344
2345
|
N && /* @__PURE__ */ D("button", {
|
|
2345
2346
|
type: "button",
|
|
2346
2347
|
className: "img-ctrl-btn img-ctrl-btn--del image-placeholder-del",
|
|
2347
2348
|
onClick: () => {
|
|
2348
|
-
|
|
2349
|
+
vn() || ($(!0), f(!0));
|
|
2349
2350
|
},
|
|
2350
2351
|
title: "删除",
|
|
2351
2352
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -2377,7 +2378,7 @@ function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2377
2378
|
}),
|
|
2378
2379
|
/* @__PURE__ */ D("span", {
|
|
2379
2380
|
className: "image-placeholder-text",
|
|
2380
|
-
children:
|
|
2381
|
+
children: wn(p) ? "本地图片无法加载" : "图片加载失败"
|
|
2381
2382
|
}),
|
|
2382
2383
|
/* @__PURE__ */ D("span", {
|
|
2383
2384
|
className: "image-placeholder-path",
|
|
@@ -2393,7 +2394,7 @@ function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2393
2394
|
alt: m,
|
|
2394
2395
|
width: h || void 0,
|
|
2395
2396
|
height: g || void 0,
|
|
2396
|
-
onClick:
|
|
2397
|
+
onClick: ee,
|
|
2397
2398
|
onError: () => {
|
|
2398
2399
|
E.current || o || (E.current = !0, (async () => {
|
|
2399
2400
|
try {
|
|
@@ -2419,7 +2420,7 @@ function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2419
2420
|
/* @__PURE__ */ D("button", {
|
|
2420
2421
|
type: "button",
|
|
2421
2422
|
className: "img-ctrl-btn",
|
|
2422
|
-
onClick:
|
|
2423
|
+
onClick: ee,
|
|
2423
2424
|
title: "网页全屏",
|
|
2424
2425
|
children: /* @__PURE__ */ D("svg", {
|
|
2425
2426
|
width: "14",
|
|
@@ -2438,7 +2439,7 @@ function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2438
2439
|
/* @__PURE__ */ D("button", {
|
|
2439
2440
|
type: "button",
|
|
2440
2441
|
className: "img-ctrl-btn",
|
|
2441
|
-
onClick:
|
|
2442
|
+
onClick: I,
|
|
2442
2443
|
title: "全屏",
|
|
2443
2444
|
children: /* @__PURE__ */ D("svg", {
|
|
2444
2445
|
width: "14",
|
|
@@ -2458,7 +2459,7 @@ function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2458
2459
|
type: "button",
|
|
2459
2460
|
className: "img-ctrl-btn img-ctrl-btn--del",
|
|
2460
2461
|
onClick: () => {
|
|
2461
|
-
|
|
2462
|
+
vn() || ($(!0), f(!0));
|
|
2462
2463
|
},
|
|
2463
2464
|
title: "删除",
|
|
2464
2465
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -2478,15 +2479,15 @@ function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2478
2479
|
]
|
|
2479
2480
|
})]
|
|
2480
2481
|
}),
|
|
2481
|
-
i && !
|
|
2482
|
+
i && !ne && /* @__PURE__ */ O("div", {
|
|
2482
2483
|
className: "image-lightbox",
|
|
2483
|
-
onClick:
|
|
2484
|
+
onClick: F,
|
|
2484
2485
|
children: [/* @__PURE__ */ O("div", {
|
|
2485
2486
|
className: "image-lightbox-bar",
|
|
2486
2487
|
children: [/* @__PURE__ */ D("button", {
|
|
2487
2488
|
type: "button",
|
|
2488
2489
|
className: "image-lightbox-bar-btn",
|
|
2489
|
-
onClick:
|
|
2490
|
+
onClick: te,
|
|
2490
2491
|
title: "全屏",
|
|
2491
2492
|
children: /* @__PURE__ */ D("svg", {
|
|
2492
2493
|
width: "18",
|
|
@@ -2504,7 +2505,7 @@ function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2504
2505
|
}), /* @__PURE__ */ D("button", {
|
|
2505
2506
|
type: "button",
|
|
2506
2507
|
className: "image-lightbox-bar-btn",
|
|
2507
|
-
onClick:
|
|
2508
|
+
onClick: F,
|
|
2508
2509
|
title: "关闭",
|
|
2509
2510
|
children: /* @__PURE__ */ D("svg", {
|
|
2510
2511
|
width: "18",
|
|
@@ -2545,16 +2546,16 @@ function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2545
2546
|
}
|
|
2546
2547
|
})]
|
|
2547
2548
|
}),
|
|
2548
|
-
/* @__PURE__ */ D(
|
|
2549
|
+
/* @__PURE__ */ D(Cn, {
|
|
2549
2550
|
open: d,
|
|
2550
2551
|
title: "确认删除图片",
|
|
2551
|
-
message:
|
|
2552
|
+
message: ne ? "该图片无法在当前环境加载,仅从编辑器中移除该图片节点,不影响存储文件。" : "此操作将同时删除对象存储中的文件,不可撤销。",
|
|
2552
2553
|
onCancel: () => {
|
|
2553
2554
|
$(!1), f(!1);
|
|
2554
2555
|
},
|
|
2555
2556
|
onConfirm: async () => {
|
|
2556
|
-
if (!
|
|
2557
|
-
await
|
|
2557
|
+
if (!ne) try {
|
|
2558
|
+
await Kt(p);
|
|
2558
2559
|
} catch {}
|
|
2559
2560
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
2560
2561
|
}
|
|
@@ -2564,7 +2565,7 @@ function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2564
2565
|
}
|
|
2565
2566
|
//#endregion
|
|
2566
2567
|
//#region src/editor/embeds/attachment-view.tsx
|
|
2567
|
-
var
|
|
2568
|
+
var En = y(() => import("@file-viewer/react")), Dn = /* @__PURE__ */ new Set(), On = {
|
|
2568
2569
|
rendererMode: "replace",
|
|
2569
2570
|
autoRenderers: !0,
|
|
2570
2571
|
theme: "light",
|
|
@@ -2593,7 +2594,7 @@ var wn = y(() => import("@file-viewer/react")), Tn = /* @__PURE__ */ new Set(),
|
|
|
2593
2594
|
cache: !0,
|
|
2594
2595
|
workerTimeoutMs: 3e4
|
|
2595
2596
|
}
|
|
2596
|
-
},
|
|
2597
|
+
}, kn = {
|
|
2597
2598
|
pdf: "pdf",
|
|
2598
2599
|
docx: "word",
|
|
2599
2600
|
docm: "word",
|
|
@@ -2648,7 +2649,7 @@ var wn = y(() => import("@file-viewer/react")), Tn = /* @__PURE__ */ new Set(),
|
|
|
2648
2649
|
xml: "text",
|
|
2649
2650
|
yml: "text",
|
|
2650
2651
|
yaml: "text"
|
|
2651
|
-
},
|
|
2652
|
+
}, An = {
|
|
2652
2653
|
pdf: () => import("@file-viewer/renderer-pdf").then((e) => e.pdfRenderer),
|
|
2653
2654
|
word: () => import("@file-viewer/renderer-word").then((e) => e.wordRenderer),
|
|
2654
2655
|
spreadsheet: () => import("@file-viewer/renderer-spreadsheet").then((e) => e.spreadsheetRenderer),
|
|
@@ -2656,10 +2657,10 @@ var wn = y(() => import("@file-viewer/react")), Tn = /* @__PURE__ */ new Set(),
|
|
|
2656
2657
|
archive: () => import("@file-viewer/renderer-archive").then((e) => e.archiveRenderer),
|
|
2657
2658
|
text: () => import("@file-viewer/renderer-text").then((e) => e.textRenderer)
|
|
2658
2659
|
};
|
|
2659
|
-
function
|
|
2660
|
+
function jn(e) {
|
|
2660
2661
|
return e ? e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1048576).toFixed(1)} MB` : "";
|
|
2661
2662
|
}
|
|
2662
|
-
function
|
|
2663
|
+
function Mn(e) {
|
|
2663
2664
|
let t = e.split(".").pop()?.toLowerCase() || "", n = {
|
|
2664
2665
|
pdf: {
|
|
2665
2666
|
label: "PDF",
|
|
@@ -2832,22 +2833,22 @@ function An(e) {
|
|
|
2832
2833
|
]
|
|
2833
2834
|
});
|
|
2834
2835
|
}
|
|
2835
|
-
function
|
|
2836
|
+
function Nn(e) {
|
|
2836
2837
|
return e.split(".").pop()?.toLowerCase() || "";
|
|
2837
2838
|
}
|
|
2838
|
-
function
|
|
2839
|
+
function Pn(e) {
|
|
2839
2840
|
let t = e.split(".").pop()?.toLowerCase() || "";
|
|
2840
2841
|
return /^(pdf|docx?|dotx?|xlsx?|xltx?|pptx?|potx?|txt|md|html?|csv|json|xml|yml|yaml|log|zip|rar|7z|tar|gz|odt|ods|odp|rtf|xlsm|xlsb|ppsx|numbers|tgz|bz2|xz|zst|js|ts|tsx|py|sh|sql)$/.test(t);
|
|
2841
2842
|
}
|
|
2842
|
-
function
|
|
2843
|
+
function Fn(e) {
|
|
2843
2844
|
return !!e && !e.startsWith("file:");
|
|
2844
2845
|
}
|
|
2845
|
-
function
|
|
2846
|
+
function In(e) {
|
|
2846
2847
|
return btoa(encodeURIComponent(e)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
2847
2848
|
}
|
|
2848
|
-
async function
|
|
2849
|
+
async function Ln(e, t) {
|
|
2849
2850
|
try {
|
|
2850
|
-
let n =
|
|
2851
|
+
let n = In(e), r = await fetch(`/api/preview/${n}`, {
|
|
2851
2852
|
signal: t,
|
|
2852
2853
|
cache: "no-store"
|
|
2853
2854
|
});
|
|
@@ -2859,7 +2860,7 @@ async function Fn(e, t) {
|
|
|
2859
2860
|
return null;
|
|
2860
2861
|
}
|
|
2861
2862
|
}
|
|
2862
|
-
function
|
|
2863
|
+
function Rn(e, t, n) {
|
|
2863
2864
|
return new Promise((r, i) => {
|
|
2864
2865
|
let a = new XMLHttpRequest();
|
|
2865
2866
|
if (a.open("GET", e, !0), a.responseType = "arraybuffer", t) {
|
|
@@ -2897,51 +2898,51 @@ function In(e, t, n) {
|
|
|
2897
2898
|
a.send();
|
|
2898
2899
|
});
|
|
2899
2900
|
}
|
|
2900
|
-
function
|
|
2901
|
-
let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() =>
|
|
2901
|
+
function zn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
2902
|
+
let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() => Dn.has(s)), [u, d] = T(null), [p, m] = T(null), [h, g] = T(!1), [_, y] = T(null), [S, E] = T(!1), [k, A] = T(null), j = w(null), M = w(null), N = w(null), ee = w(0), F = w(!1), I = w(null), te = w(0), [ne, L] = T(!1), R = w(null), [re, ie] = T(0), [z, B] = T("none"), [V, H] = T(void 0), [ae, oe] = T(!1), U = e.attrs.src || "", W = e.attrs.name || U && U.split("/").pop()?.split("?")[0] || (U ? "attachment" : f("editor.attachment.lost")), se = e.attrs.size || 0, G = Nn(W), K = !U;
|
|
2902
2903
|
x(() => {
|
|
2903
2904
|
if (!c) {
|
|
2904
2905
|
H(void 0), oe(!1);
|
|
2905
2906
|
return;
|
|
2906
2907
|
}
|
|
2907
|
-
let e =
|
|
2908
|
+
let e = kn[G];
|
|
2908
2909
|
if (!e) {
|
|
2909
2910
|
H(void 0), oe(!1);
|
|
2910
2911
|
return;
|
|
2911
2912
|
}
|
|
2912
2913
|
let t = !0;
|
|
2913
|
-
return H(void 0), oe(!1),
|
|
2914
|
+
return H(void 0), oe(!1), An[e]().then((e) => {
|
|
2914
2915
|
t && H(e);
|
|
2915
2916
|
}).catch((n) => {
|
|
2916
2917
|
console.error(`[attachment] renderer "${e}" load failed:`, n), t && oe(!0);
|
|
2917
2918
|
}), () => {
|
|
2918
2919
|
t = !1;
|
|
2919
2920
|
};
|
|
2920
|
-
}, [c,
|
|
2921
|
-
let
|
|
2922
|
-
...
|
|
2921
|
+
}, [c, G]);
|
|
2922
|
+
let ce = C(() => ({
|
|
2923
|
+
...On,
|
|
2923
2924
|
renderers: V ? [V] : [],
|
|
2924
2925
|
rendererMode: "replace"
|
|
2925
|
-
}), [V]),
|
|
2926
|
+
}), [V]), q = b((e) => {
|
|
2926
2927
|
l((t) => {
|
|
2927
2928
|
let n = typeof e == "function" ? e(t) : e;
|
|
2928
|
-
return U && (n ?
|
|
2929
|
+
return U && (n ? Dn.add(U) : Dn.delete(U)), n;
|
|
2929
2930
|
});
|
|
2930
2931
|
}, [U]);
|
|
2931
2932
|
x(() => {
|
|
2932
|
-
l(U ?
|
|
2933
|
+
l(U ? Dn.has(U) : !1);
|
|
2933
2934
|
}, [U]);
|
|
2934
2935
|
let le = b(() => {
|
|
2935
|
-
|
|
2936
|
-
window.scrollTo(0,
|
|
2936
|
+
F.current = !0, q(!0), window.setTimeout(() => {
|
|
2937
|
+
window.scrollTo(0, ee.current), I.current && (I.current.scrollTop = te.current), F.current && q(!0), F.current = !1;
|
|
2937
2938
|
}, 0);
|
|
2938
|
-
}, [
|
|
2939
|
-
z === "web" ? (B("none"), document.body.style.overflow = "", le()) : (z === "native" && document.fullscreenElement && await document.exitFullscreen(),
|
|
2939
|
+
}, [q]), ue = b(async () => {
|
|
2940
|
+
z === "web" ? (B("none"), document.body.style.overflow = "", le()) : (z === "native" && document.fullscreenElement && await document.exitFullscreen(), ee.current = window.scrollY, te.current = I.current?.scrollTop ?? 0, document.body.style.overflow = "hidden", B("web"));
|
|
2940
2941
|
}, [z]), de = b(async () => {
|
|
2941
2942
|
let e = M.current;
|
|
2942
|
-
e && (z === "native" ? await document.exitFullscreen() : (z === "web" && (B("none"), document.body.style.overflow = ""),
|
|
2943
|
+
e && (z === "native" ? await document.exitFullscreen() : (z === "web" && (B("none"), document.body.style.overflow = ""), ee.current = window.scrollY, te.current = I.current?.scrollTop ?? 0, await e.requestFullscreen(), B("native")));
|
|
2943
2944
|
}, [z, le]), fe = b(() => {
|
|
2944
|
-
z === "none" && (
|
|
2945
|
+
z === "none" && (F.current || q((e) => !e));
|
|
2945
2946
|
}, [z]);
|
|
2946
2947
|
x(() => {
|
|
2947
2948
|
let e = () => {
|
|
@@ -2954,7 +2955,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2954
2955
|
};
|
|
2955
2956
|
}, [z, le]), x(() => {
|
|
2956
2957
|
let e = (e) => {
|
|
2957
|
-
if (e.key !== "Backspace" && e.key !== "Delete" || !o || !i ||
|
|
2958
|
+
if (e.key !== "Backspace" && e.key !== "Delete" || !o || !i || vn()) return;
|
|
2958
2959
|
let t = a?.view?.dom, n = e.target;
|
|
2959
2960
|
if (a?.isFocused && n instanceof Node && t?.contains(n)) {
|
|
2960
2961
|
if (e.preventDefault(), e.stopPropagation(), a) {
|
|
@@ -2964,7 +2965,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2964
2965
|
to: t
|
|
2965
2966
|
};
|
|
2966
2967
|
}
|
|
2967
|
-
window.getSelection()?.removeAllRanges(), $(!0),
|
|
2968
|
+
window.getSelection()?.removeAllRanges(), $(!0), L(!0);
|
|
2968
2969
|
}
|
|
2969
2970
|
};
|
|
2970
2971
|
return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
|
|
@@ -2973,7 +2974,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2973
2974
|
a,
|
|
2974
2975
|
o
|
|
2975
2976
|
]), x(() => {
|
|
2976
|
-
if (!c || !
|
|
2977
|
+
if (!c || !Fn(U)) {
|
|
2977
2978
|
d(null), y(null), N.current = null;
|
|
2978
2979
|
return;
|
|
2979
2980
|
}
|
|
@@ -2981,9 +2982,9 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2981
2982
|
let e = new AbortController(), r = !0;
|
|
2982
2983
|
return g(!0), y(null), (async () => {
|
|
2983
2984
|
let i = U.includes("?X-Amz-"), a = null, o = null;
|
|
2984
|
-
if (!a && !i && (a = await
|
|
2985
|
+
if (!a && !i && (a = await Ln(U, e.signal)), !a && !i) try {
|
|
2985
2986
|
let n = await t(U);
|
|
2986
|
-
n && (a = await
|
|
2987
|
+
n && (a = await Ln(n, e.signal) || await Rn(n, void 0, e.signal));
|
|
2987
2988
|
} catch (e) {
|
|
2988
2989
|
console.warn("[attachment] signPreviewUrl failed:", e);
|
|
2989
2990
|
}
|
|
@@ -2995,7 +2996,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2995
2996
|
n[t] = e;
|
|
2996
2997
|
});
|
|
2997
2998
|
try {
|
|
2998
|
-
a = await
|
|
2999
|
+
a = await Rn(U, n, e.signal);
|
|
2999
3000
|
} catch (e) {
|
|
3000
3001
|
console.warn("[attachment] signed headers XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
|
|
3001
3002
|
}
|
|
@@ -3004,7 +3005,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3004
3005
|
console.warn("[attachment] signPreviewUrlHeaders failed:", e);
|
|
3005
3006
|
}
|
|
3006
3007
|
if (!a) try {
|
|
3007
|
-
a = await
|
|
3008
|
+
a = await Rn(U, i ? void 0 : { "X-Requested-With": "XMLHttpRequest" }, e.signal);
|
|
3008
3009
|
} catch (e) {
|
|
3009
3010
|
console.warn("[attachment] plain XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
|
|
3010
3011
|
}
|
|
@@ -3033,7 +3034,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3033
3034
|
let e = window.setTimeout(() => A(null), 2400);
|
|
3034
3035
|
return () => window.clearTimeout(e);
|
|
3035
3036
|
}, [k]);
|
|
3036
|
-
let
|
|
3037
|
+
let J = b(async () => {
|
|
3037
3038
|
E(!0), A("loading");
|
|
3038
3039
|
try {
|
|
3039
3040
|
if (p) {
|
|
@@ -3066,7 +3067,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3066
3067
|
W,
|
|
3067
3068
|
p
|
|
3068
3069
|
]);
|
|
3069
|
-
return /* @__PURE__ */ O(
|
|
3070
|
+
return /* @__PURE__ */ O(P, {
|
|
3070
3071
|
ref: j,
|
|
3071
3072
|
as: "div",
|
|
3072
3073
|
className: `attachment-embed group/att ${i ? "is-selected" : ""}`,
|
|
@@ -3083,7 +3084,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3083
3084
|
className: "att-info",
|
|
3084
3085
|
children: [/* @__PURE__ */ D("span", {
|
|
3085
3086
|
className: "att-icon",
|
|
3086
|
-
children:
|
|
3087
|
+
children: K ? /* @__PURE__ */ O("svg", {
|
|
3087
3088
|
width: "22",
|
|
3088
3089
|
height: "22",
|
|
3089
3090
|
viewBox: "0 0 24 24",
|
|
@@ -3099,15 +3100,15 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3099
3100
|
/* @__PURE__ */ D("path", { d: "M12 9v4" }),
|
|
3100
3101
|
/* @__PURE__ */ D("path", { d: "M12 17h.01" })
|
|
3101
3102
|
]
|
|
3102
|
-
}) :
|
|
3103
|
+
}) : Mn(W)
|
|
3103
3104
|
}), /* @__PURE__ */ O("div", {
|
|
3104
3105
|
className: "att-meta",
|
|
3105
3106
|
children: [/* @__PURE__ */ D("span", {
|
|
3106
3107
|
className: "att-name",
|
|
3107
3108
|
children: W
|
|
3108
|
-
}),
|
|
3109
|
+
}), se > 0 && /* @__PURE__ */ D("span", {
|
|
3109
3110
|
className: "att-size",
|
|
3110
|
-
children:
|
|
3111
|
+
children: jn(se)
|
|
3111
3112
|
})]
|
|
3112
3113
|
})]
|
|
3113
3114
|
}), /* @__PURE__ */ O("div", {
|
|
@@ -3160,7 +3161,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3160
3161
|
}), /* @__PURE__ */ O("div", {
|
|
3161
3162
|
className: "att-actions",
|
|
3162
3163
|
children: [
|
|
3163
|
-
U &&
|
|
3164
|
+
U && Pn(W) && /* @__PURE__ */ D("button", {
|
|
3164
3165
|
type: "button",
|
|
3165
3166
|
className: "att-btn",
|
|
3166
3167
|
onMouseDown: (e) => {
|
|
@@ -3190,8 +3191,8 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3190
3191
|
/* @__PURE__ */ D("button", {
|
|
3191
3192
|
type: "button",
|
|
3192
3193
|
className: "att-btn",
|
|
3193
|
-
onClick:
|
|
3194
|
-
disabled: S ||
|
|
3194
|
+
onClick: J,
|
|
3195
|
+
disabled: S || K,
|
|
3195
3196
|
title: S ? "正在准备下载" : f("editor.attachment.download"),
|
|
3196
3197
|
"aria-label": S ? "正在准备下载" : f("editor.attachment.download"),
|
|
3197
3198
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -3213,7 +3214,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3213
3214
|
type: "button",
|
|
3214
3215
|
className: "att-btn att-btn--del",
|
|
3215
3216
|
onClick: () => {
|
|
3216
|
-
!o ||
|
|
3217
|
+
!o || vn() || ($(!0), L(!0));
|
|
3217
3218
|
},
|
|
3218
3219
|
title: f("editor.attachment.delete"),
|
|
3219
3220
|
"aria-label": f("editor.attachment.delete"),
|
|
@@ -3245,7 +3246,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3245
3246
|
background: "#fff"
|
|
3246
3247
|
},
|
|
3247
3248
|
children: [/* @__PURE__ */ D("div", {
|
|
3248
|
-
ref:
|
|
3249
|
+
ref: I,
|
|
3249
3250
|
className: "att-preview-scroll",
|
|
3250
3251
|
style: {
|
|
3251
3252
|
height: "100%",
|
|
@@ -3269,14 +3270,14 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3269
3270
|
style: { background: "#fff" },
|
|
3270
3271
|
children: f("editor.attachment.loadingPreview")
|
|
3271
3272
|
}),
|
|
3272
|
-
children: u || p || U ? V ? /* @__PURE__ */ D(
|
|
3273
|
+
children: u || p || U ? V ? /* @__PURE__ */ D(En, {
|
|
3273
3274
|
buffer: u || void 0,
|
|
3274
3275
|
url: p || U,
|
|
3275
3276
|
name: W,
|
|
3276
3277
|
filename: W,
|
|
3277
|
-
type:
|
|
3278
|
-
size:
|
|
3279
|
-
options:
|
|
3278
|
+
type: G,
|
|
3279
|
+
size: se || u?.byteLength || 0,
|
|
3280
|
+
options: ce
|
|
3280
3281
|
}, `${U}-${re}`) : /* @__PURE__ */ D("div", {
|
|
3281
3282
|
className: "flex h-full items-center justify-center text-sm text-default-400",
|
|
3282
3283
|
children: "正在加载预览引擎..."
|
|
@@ -3381,24 +3382,24 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3381
3382
|
})]
|
|
3382
3383
|
})]
|
|
3383
3384
|
})]
|
|
3384
|
-
}), /* @__PURE__ */ D(
|
|
3385
|
-
open:
|
|
3385
|
+
}), /* @__PURE__ */ D(Cn, {
|
|
3386
|
+
open: ne,
|
|
3386
3387
|
title: "确认删除附件",
|
|
3387
|
-
message:
|
|
3388
|
+
message: K ? "此操作将删除该附件节点,不可撤销。" : `此操作将同时删除对象存储中的文件(${W}),不可撤销。`,
|
|
3388
3389
|
onCancel: () => {
|
|
3389
|
-
$(!1),
|
|
3390
|
+
$(!1), L(!1);
|
|
3390
3391
|
},
|
|
3391
3392
|
onConfirm: async () => {
|
|
3392
3393
|
try {
|
|
3393
3394
|
if (a) {
|
|
3394
3395
|
let e = R.current, t = e?.from ?? a.state.selection.from, n = e?.to ?? a.state.selection.to, r = [];
|
|
3395
3396
|
a.state.doc.nodesBetween(t, n, (e) => {
|
|
3396
|
-
e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(
|
|
3397
|
+
e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(Kt(e.attrs.src));
|
|
3397
3398
|
}), await Promise.all(r), $(!1), await new Promise((e) => setTimeout(e, 300)), a.chain().focus().setTextSelection({
|
|
3398
3399
|
from: t,
|
|
3399
3400
|
to: n
|
|
3400
3401
|
}).deleteSelection().run();
|
|
3401
|
-
} else await
|
|
3402
|
+
} else await Kt(U), $(!1), await new Promise((e) => setTimeout(e, 300)), r();
|
|
3402
3403
|
} catch {
|
|
3403
3404
|
$(!1);
|
|
3404
3405
|
}
|
|
@@ -3408,13 +3409,13 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3408
3409
|
}
|
|
3409
3410
|
//#endregion
|
|
3410
3411
|
//#region src/editor/embeds/attachment.ts
|
|
3411
|
-
var
|
|
3412
|
+
var Bn = ie.create({
|
|
3412
3413
|
name: "attachmentEmbed",
|
|
3413
3414
|
group: "block",
|
|
3414
3415
|
atom: !0,
|
|
3415
3416
|
inline: !1,
|
|
3416
3417
|
addNodeView() {
|
|
3417
|
-
return
|
|
3418
|
+
return F(zn);
|
|
3418
3419
|
},
|
|
3419
3420
|
addAttributes() {
|
|
3420
3421
|
return {
|
|
@@ -3463,7 +3464,7 @@ var Rn = re.create({
|
|
|
3463
3464
|
});
|
|
3464
3465
|
//#endregion
|
|
3465
3466
|
//#region src/editor/embeds/audio-view.tsx
|
|
3466
|
-
function
|
|
3467
|
+
function Vn({ node: e, deleteNode: t, editor: r }) {
|
|
3467
3468
|
let i = e.attrs.src || "", a = e.attrs.name || i.split("/").pop()?.split("?")[0] || "audio", [o, s] = T(!1), c = r?.isEditable ?? !0;
|
|
3468
3469
|
x(() => () => {
|
|
3469
3470
|
i.startsWith("blob:") && URL.revokeObjectURL(i);
|
|
@@ -3495,7 +3496,7 @@ function zn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3495
3496
|
})(), () => {
|
|
3496
3497
|
e = !0, m.current &&= (URL.revokeObjectURL(m.current), null);
|
|
3497
3498
|
};
|
|
3498
|
-
}, [i]), /* @__PURE__ */ O(
|
|
3499
|
+
}, [i]), /* @__PURE__ */ O(P, {
|
|
3499
3500
|
as: "div",
|
|
3500
3501
|
className: "audio-embed group/audio",
|
|
3501
3502
|
style: { margin: "1rem 0" },
|
|
@@ -3529,7 +3530,7 @@ function zn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3529
3530
|
type: "button",
|
|
3530
3531
|
className: "audio-embed-btn audio-embed-btn--del",
|
|
3531
3532
|
onClick: () => {
|
|
3532
|
-
|
|
3533
|
+
vn() || ($(!0), s(!0));
|
|
3533
3534
|
},
|
|
3534
3535
|
title: "删除",
|
|
3535
3536
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -3575,7 +3576,7 @@ function zn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3575
3576
|
}), "音频文件缺失"]
|
|
3576
3577
|
})
|
|
3577
3578
|
})]
|
|
3578
|
-
}), /* @__PURE__ */ D(
|
|
3579
|
+
}), /* @__PURE__ */ D(Cn, {
|
|
3579
3580
|
open: o,
|
|
3580
3581
|
title: "确认删除音频",
|
|
3581
3582
|
message: `此操作将同时删除对象存储中的文件(${a}),不可撤销。`,
|
|
@@ -3584,7 +3585,7 @@ function zn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3584
3585
|
},
|
|
3585
3586
|
onConfirm: async () => {
|
|
3586
3587
|
try {
|
|
3587
|
-
await
|
|
3588
|
+
await Kt(i);
|
|
3588
3589
|
} catch {}
|
|
3589
3590
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
3590
3591
|
}
|
|
@@ -3593,25 +3594,25 @@ function zn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3593
3594
|
}
|
|
3594
3595
|
//#endregion
|
|
3595
3596
|
//#region src/editor/embeds/audio.ts
|
|
3596
|
-
function
|
|
3597
|
+
function Hn(e) {
|
|
3597
3598
|
return /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|$)/i.test(e) || /\/.*\.(mp3|wav|ogg|flac)/i.test(e);
|
|
3598
3599
|
}
|
|
3599
|
-
var
|
|
3600
|
+
var Un = ie.create({
|
|
3600
3601
|
name: "audioEmbed",
|
|
3601
3602
|
group: "block",
|
|
3602
3603
|
atom: !0,
|
|
3603
3604
|
inline: !1,
|
|
3604
3605
|
addNodeView() {
|
|
3605
|
-
return
|
|
3606
|
+
return F(Vn);
|
|
3606
3607
|
},
|
|
3607
3608
|
addProseMirrorPlugins() {
|
|
3608
|
-
return [new
|
|
3609
|
+
return [new V({ props: { handlePaste(e, t) {
|
|
3609
3610
|
let n = t.clipboardData?.getData("text/plain");
|
|
3610
3611
|
if (!n) return !1;
|
|
3611
3612
|
let r = n.split(/\r?\n/);
|
|
3612
3613
|
for (let n of r) {
|
|
3613
3614
|
let r = n.trim();
|
|
3614
|
-
if (!r || r.includes(" ") || !
|
|
3615
|
+
if (!r || r.includes(" ") || !Hn(r)) continue;
|
|
3615
3616
|
t.preventDefault();
|
|
3616
3617
|
let i = e.state.schema.nodes.audioEmbed.create({ src: r });
|
|
3617
3618
|
return e.dispatch(e.state.tr.replaceSelectionWith(i)), !0;
|
|
@@ -3658,17 +3659,17 @@ var Vn = re.create({
|
|
|
3658
3659
|
});
|
|
3659
3660
|
//#endregion
|
|
3660
3661
|
//#region src/editor/embeds/video-view.tsx
|
|
3661
|
-
function
|
|
3662
|
+
function Wn(e) {
|
|
3662
3663
|
return e ? /bilibili\.com|BV[a-zA-Z0-9]{10}|av\d+/i.test(e) ? "bilibili" : /xiaohongshu\.com|xhslink\.com/i.test(e) ? "xiaohongshu" : /\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|$)/i.test(e) || /\/.*\.(mp4|m3u8|mov|webm|flv|mkv)/i.test(e) ? "direct" : "unknown" : "unknown";
|
|
3663
3664
|
}
|
|
3664
|
-
function
|
|
3665
|
+
function Gn(e) {
|
|
3665
3666
|
let t = e.match(/BV[a-zA-Z0-9]{10}/);
|
|
3666
3667
|
if (t) return t[0];
|
|
3667
3668
|
let n = e.match(/av(\d+)/i);
|
|
3668
3669
|
return n ? n[0] : e;
|
|
3669
3670
|
}
|
|
3670
|
-
function
|
|
3671
|
-
let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ?
|
|
3671
|
+
function Kn({ node: e, deleteNode: t, editor: n }) {
|
|
3672
|
+
let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ? Wn(r) : i, [o, s] = T(!1), [c, l] = T(!1), [u, d] = T(!1), f = n?.isEditable ?? !0, p = !f && r.startsWith("blob:"), m = /* @__PURE__ */ D(Cn, {
|
|
3672
3673
|
open: o,
|
|
3673
3674
|
title: "确认删除视频",
|
|
3674
3675
|
message: "此操作将同时删除对象存储中的文件,不可撤销。",
|
|
@@ -3677,7 +3678,7 @@ function Wn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3677
3678
|
},
|
|
3678
3679
|
onConfirm: async () => {
|
|
3679
3680
|
try {
|
|
3680
|
-
await
|
|
3681
|
+
await Kt(r);
|
|
3681
3682
|
} catch {}
|
|
3682
3683
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
3683
3684
|
}
|
|
@@ -3691,7 +3692,7 @@ function Wn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3691
3692
|
e && (e.style.position === "fixed" ? A() : (e.style.position = "fixed", e.style.inset = "0", e.style.zIndex = "99999", e.style.borderRadius = "0", document.body.style.overflow = "hidden"));
|
|
3692
3693
|
}, [A]), N = b(() => {
|
|
3693
3694
|
k.current = window.scrollY, S.current?.requestFullscreen?.();
|
|
3694
|
-
}, []),
|
|
3695
|
+
}, []), ee = b(() => {
|
|
3695
3696
|
let e = v.current?.closest(".video-embed--direct") || v.current;
|
|
3696
3697
|
e && (k.current = window.scrollY, e.requestFullscreen?.());
|
|
3697
3698
|
}, []);
|
|
@@ -3780,8 +3781,8 @@ function Wn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3780
3781
|
}, [a, h]), x(() => {
|
|
3781
3782
|
u && (_.current?.destroy(), _.current = null);
|
|
3782
3783
|
}, [u]), a === "bilibili") {
|
|
3783
|
-
let e =
|
|
3784
|
-
return /* @__PURE__ */ O(
|
|
3784
|
+
let e = Gn(r);
|
|
3785
|
+
return /* @__PURE__ */ O(P, {
|
|
3785
3786
|
as: "div",
|
|
3786
3787
|
className: "video-embed video-embed--bilibili group/video",
|
|
3787
3788
|
style: { margin: "1rem 0" },
|
|
@@ -3857,7 +3858,7 @@ function Wn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3857
3858
|
className: "video-fs-btn video-fs-btn--del",
|
|
3858
3859
|
title: "删除",
|
|
3859
3860
|
onClick: () => {
|
|
3860
|
-
|
|
3861
|
+
vn() || ($(!0), s(!0));
|
|
3861
3862
|
},
|
|
3862
3863
|
children: /* @__PURE__ */ D("svg", {
|
|
3863
3864
|
width: "12",
|
|
@@ -3899,7 +3900,7 @@ function Wn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3899
3900
|
}), m]
|
|
3900
3901
|
});
|
|
3901
3902
|
}
|
|
3902
|
-
return a === "xiaohongshu" ? /* @__PURE__ */ O(
|
|
3903
|
+
return a === "xiaohongshu" ? /* @__PURE__ */ O(P, {
|
|
3903
3904
|
as: "div",
|
|
3904
3905
|
className: "video-embed video-embed--xiaohongshu",
|
|
3905
3906
|
style: {
|
|
@@ -3945,7 +3946,7 @@ function Wn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3945
3946
|
},
|
|
3946
3947
|
children: "在小红书中打开 →"
|
|
3947
3948
|
})] })]
|
|
3948
|
-
}) : /* @__PURE__ */ O(
|
|
3949
|
+
}) : /* @__PURE__ */ O(P, {
|
|
3949
3950
|
as: "div",
|
|
3950
3951
|
className: "video-embed video-embed--direct group/video",
|
|
3951
3952
|
style: {
|
|
@@ -3964,7 +3965,7 @@ function Wn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3964
3965
|
className: "video-fs-btn video-fs-btn--del",
|
|
3965
3966
|
title: "删除",
|
|
3966
3967
|
onClick: () => {
|
|
3967
|
-
|
|
3968
|
+
vn() || ($(!0), s(!0));
|
|
3968
3969
|
},
|
|
3969
3970
|
children: /* @__PURE__ */ D("svg", {
|
|
3970
3971
|
width: "12",
|
|
@@ -3983,7 +3984,7 @@ function Wn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3983
3984
|
type: "button",
|
|
3984
3985
|
className: "video-fs-btn",
|
|
3985
3986
|
title: "全屏",
|
|
3986
|
-
onClick:
|
|
3987
|
+
onClick: ee,
|
|
3987
3988
|
children: /* @__PURE__ */ D("svg", {
|
|
3988
3989
|
width: "12",
|
|
3989
3990
|
height: "12",
|
|
@@ -4121,33 +4122,33 @@ function Wn({ node: e, deleteNode: t, editor: n }) {
|
|
|
4121
4122
|
}
|
|
4122
4123
|
//#endregion
|
|
4123
4124
|
//#region src/editor/embeds/video.ts
|
|
4124
|
-
function
|
|
4125
|
+
function qn(e) {
|
|
4125
4126
|
return /bilibili\.com|BV[a-zA-Z0-9]{10}|av\d+/i.test(e) ? "bilibili" : /xiaohongshu\.com|xhslink\.com/i.test(e) ? "xiaohongshu" : /\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|$)/i.test(e) || /\/.*\.(mp4|m3u8|mov|webm|flv|mkv)/i.test(e) ? "direct" : "unknown";
|
|
4126
4127
|
}
|
|
4127
|
-
function
|
|
4128
|
+
function Jn(e) {
|
|
4128
4129
|
let t = e.match(/BV[a-zA-Z0-9]{10}/);
|
|
4129
4130
|
if (t) return t[0];
|
|
4130
4131
|
let n = e.match(/av(\d+)/i);
|
|
4131
4132
|
return n ? n[0] : e;
|
|
4132
4133
|
}
|
|
4133
|
-
function
|
|
4134
|
+
function Yn(e) {
|
|
4134
4135
|
let t = e.match(/explore\/([a-zA-Z0-9]+)/);
|
|
4135
4136
|
return t ? t[1] : e;
|
|
4136
4137
|
}
|
|
4137
|
-
var
|
|
4138
|
+
var Xn = ie.create({
|
|
4138
4139
|
name: "videoEmbed",
|
|
4139
4140
|
group: "block",
|
|
4140
4141
|
atom: !0,
|
|
4141
4142
|
inline: !1,
|
|
4142
4143
|
addNodeView() {
|
|
4143
|
-
return
|
|
4144
|
+
return F(Kn);
|
|
4144
4145
|
},
|
|
4145
4146
|
addProseMirrorPlugins() {
|
|
4146
|
-
return [new
|
|
4147
|
+
return [new V({ props: {
|
|
4147
4148
|
handleKeyDown(e, t) {
|
|
4148
4149
|
if (t.key !== " ") return !1;
|
|
4149
4150
|
let n = e.state.selection;
|
|
4150
|
-
if (n instanceof
|
|
4151
|
+
if (n instanceof B && n.node.type.name === "videoEmbed") {
|
|
4151
4152
|
t.preventDefault();
|
|
4152
4153
|
let r = e.nodeDOM(n.from);
|
|
4153
4154
|
if (r) {
|
|
@@ -4165,7 +4166,7 @@ var Jn = re.create({
|
|
|
4165
4166
|
for (let n of r) {
|
|
4166
4167
|
let r = n.trim();
|
|
4167
4168
|
if (!r || r.includes(" ")) continue;
|
|
4168
|
-
let i =
|
|
4169
|
+
let i = qn(r);
|
|
4169
4170
|
if (i === "unknown") continue;
|
|
4170
4171
|
t.preventDefault();
|
|
4171
4172
|
let a = e.state.schema.nodes.videoEmbed.create({
|
|
@@ -4197,7 +4198,7 @@ var Jn = re.create({
|
|
|
4197
4198
|
let t = e, n = t.getAttribute("src") || t.getAttribute("data-src") || "";
|
|
4198
4199
|
return {
|
|
4199
4200
|
src: n,
|
|
4200
|
-
source:
|
|
4201
|
+
source: qn(n)
|
|
4201
4202
|
};
|
|
4202
4203
|
}
|
|
4203
4204
|
},
|
|
@@ -4206,9 +4207,9 @@ var Jn = re.create({
|
|
|
4206
4207
|
];
|
|
4207
4208
|
},
|
|
4208
4209
|
renderHTML({ HTMLAttributes: e }) {
|
|
4209
|
-
let t = e.src || "", n =
|
|
4210
|
+
let t = e.src || "", n = qn(t);
|
|
4210
4211
|
if (n === "bilibili") {
|
|
4211
|
-
let e =
|
|
4212
|
+
let e = Jn(t);
|
|
4212
4213
|
return [
|
|
4213
4214
|
"div",
|
|
4214
4215
|
{
|
|
@@ -4229,7 +4230,7 @@ var Jn = re.create({
|
|
|
4229
4230
|
}]
|
|
4230
4231
|
];
|
|
4231
4232
|
}
|
|
4232
|
-
if (n === "xiaohongshu") return
|
|
4233
|
+
if (n === "xiaohongshu") return Yn(t), [
|
|
4233
4234
|
"div",
|
|
4234
4235
|
{
|
|
4235
4236
|
"data-video-embed": "xiaohongshu",
|
|
@@ -4281,7 +4282,7 @@ var Jn = re.create({
|
|
|
4281
4282
|
},
|
|
4282
4283
|
addCommands() {
|
|
4283
4284
|
return { insertVideo: (e) => ({ chain: t }) => {
|
|
4284
|
-
let n =
|
|
4285
|
+
let n = qn(e.src);
|
|
4285
4286
|
return t().insertContent({
|
|
4286
4287
|
type: this.name,
|
|
4287
4288
|
attrs: {
|
|
@@ -4291,13 +4292,20 @@ var Jn = re.create({
|
|
|
4291
4292
|
}).focus().run();
|
|
4292
4293
|
} };
|
|
4293
4294
|
}
|
|
4294
|
-
}),
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4295
|
+
}), Zn = null, Qn = {
|
|
4296
|
+
bg: "var(--color-background, #ffffff)",
|
|
4297
|
+
fg: "var(--color-foreground, #11181c)",
|
|
4298
|
+
accent: "var(--color-qingwu-600, #0891b2)",
|
|
4299
|
+
transparent: !0,
|
|
4300
|
+
font: "Inter, 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', system-ui, sans-serif",
|
|
4301
|
+
padding: 32
|
|
4302
|
+
}, $n = .25, er = 4, tr = .25;
|
|
4303
|
+
async function nr(e, t) {
|
|
4304
|
+
Zn ||= await import("beautiful-mermaid");
|
|
4305
|
+
let n = Zn.renderMermaidSVG;
|
|
4306
|
+
return n(e, t);
|
|
4307
|
+
}
|
|
4308
|
+
var rr = [
|
|
4301
4309
|
{
|
|
4302
4310
|
value: "javascript",
|
|
4303
4311
|
label: "JavaScript",
|
|
@@ -4458,7 +4466,7 @@ var Zn = [
|
|
|
4458
4466
|
label: "Plain Text",
|
|
4459
4467
|
color: "#6b7280"
|
|
4460
4468
|
}
|
|
4461
|
-
],
|
|
4469
|
+
], ir = {
|
|
4462
4470
|
javascript: "js",
|
|
4463
4471
|
typescript: "ts",
|
|
4464
4472
|
python: "py",
|
|
@@ -4484,7 +4492,7 @@ var Zn = [
|
|
|
4484
4492
|
txt: "txt",
|
|
4485
4493
|
vue: "vue",
|
|
4486
4494
|
react: "jsx"
|
|
4487
|
-
},
|
|
4495
|
+
}, ar = {
|
|
4488
4496
|
js: "javascript",
|
|
4489
4497
|
ts: "typescript",
|
|
4490
4498
|
py: "python",
|
|
@@ -4500,12 +4508,51 @@ var Zn = [
|
|
|
4500
4508
|
jsx: "javascript",
|
|
4501
4509
|
tsx: "typescript"
|
|
4502
4510
|
};
|
|
4503
|
-
function
|
|
4511
|
+
function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i, selected: a }) {
|
|
4504
4512
|
let o = n?.isEditable ?? !0, s = !o, [c, l] = T(!1), [u, d] = T(!1), [f, m] = T(!1), [h, g] = T(!1), [_, v] = T(220), [y, S] = T({
|
|
4505
4513
|
top: 0,
|
|
4506
4514
|
left: 0,
|
|
4507
4515
|
width: 210
|
|
4508
|
-
}), [k, A] = T(""), [j, M] = T(!1), [N,
|
|
4516
|
+
}), [k, A] = T(""), [j, M] = T(!1), [N, ee] = T(null), [P, F] = T(null), [I, te] = T(!1), [ne, R] = T(!1), [re, ie] = T(1), [z, B] = T({
|
|
4517
|
+
x: 0,
|
|
4518
|
+
y: 0
|
|
4519
|
+
}), [V, H] = T(!1), ae = w(null), oe = w(null), U = w(null), W = w(null), se = w(null), G = w(null), K = w(null), ce = e.attrs.language || "", q = rr.find((e) => e.value === (ar[ce] ?? ce)), le = ce === "mermaid", ue = (e) => Math.min(er, Math.max($n, e)), de = (e) => ie((t) => Math.round(ue(t + e) * 100) / 100), fe = () => {
|
|
4520
|
+
ie(1), B({
|
|
4521
|
+
x: 0,
|
|
4522
|
+
y: 0
|
|
4523
|
+
});
|
|
4524
|
+
}, J = () => {
|
|
4525
|
+
fe(), R(!0);
|
|
4526
|
+
};
|
|
4527
|
+
x(() => {
|
|
4528
|
+
N || R(!1);
|
|
4529
|
+
}, [N]), x(() => {
|
|
4530
|
+
if (!ne) return;
|
|
4531
|
+
let e = document.body.style.overflow;
|
|
4532
|
+
document.body.style.overflow = "hidden";
|
|
4533
|
+
let t = (e) => {
|
|
4534
|
+
e.key === "Escape" && R(!1);
|
|
4535
|
+
};
|
|
4536
|
+
return window.addEventListener("keydown", t), () => {
|
|
4537
|
+
document.body.style.overflow = e, window.removeEventListener("keydown", t);
|
|
4538
|
+
};
|
|
4539
|
+
}, [ne]);
|
|
4540
|
+
let pe = (e) => {
|
|
4541
|
+
e.button === 0 && (e.currentTarget.setPointerCapture(e.pointerId), ae.current = {
|
|
4542
|
+
x: e.clientX,
|
|
4543
|
+
y: e.clientY,
|
|
4544
|
+
panX: z.x,
|
|
4545
|
+
panY: z.y
|
|
4546
|
+
}, H(!0));
|
|
4547
|
+
}, me = (e) => {
|
|
4548
|
+
let t = ae.current;
|
|
4549
|
+
t && B({
|
|
4550
|
+
x: t.panX + e.clientX - t.x,
|
|
4551
|
+
y: t.panY + e.clientY - t.y
|
|
4552
|
+
});
|
|
4553
|
+
}, he = () => {
|
|
4554
|
+
ae.current = null, H(!1);
|
|
4555
|
+
}, ge = b(() => {
|
|
4509
4556
|
if (!n || typeof r != "function") return null;
|
|
4510
4557
|
let t = r();
|
|
4511
4558
|
return typeof t == "number" ? {
|
|
@@ -4516,19 +4563,19 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4516
4563
|
n,
|
|
4517
4564
|
r,
|
|
4518
4565
|
e.nodeSize
|
|
4519
|
-
]),
|
|
4520
|
-
o && (
|
|
4521
|
-
}, [
|
|
4566
|
+
]), _e = b(() => {
|
|
4567
|
+
o && (vn() || (K.current = ge(), window.getSelection()?.removeAllRanges(), $(!0), M(!0)));
|
|
4568
|
+
}, [ge, o]), ve = C(() => {
|
|
4522
4569
|
let e = k.trim().toLowerCase();
|
|
4523
|
-
return e ?
|
|
4570
|
+
return e ? rr.filter((t) => t.label.toLowerCase().includes(e) || t.value.toLowerCase().includes(e)) : rr;
|
|
4524
4571
|
}, [k]);
|
|
4525
4572
|
x(() => {
|
|
4526
|
-
(
|
|
4573
|
+
(G.current?.closest(".code-block-node-view"))?.classList.toggle("code-block-node-view--collapsed", u);
|
|
4527
4574
|
}, [u]);
|
|
4528
|
-
let
|
|
4529
|
-
let e =
|
|
4575
|
+
let ye = b(() => {
|
|
4576
|
+
let e = W.current;
|
|
4530
4577
|
if (!e) return;
|
|
4531
|
-
let t = e.getBoundingClientRect(), n = Math.min(t.left, window.innerWidth - 210 - 8), r = window.innerHeight - t.bottom - 12, i = t.top - 12, a =
|
|
4578
|
+
let t = e.getBoundingClientRect(), n = Math.min(t.left, window.innerWidth - 210 - 8), r = window.innerHeight - t.bottom - 12, i = t.top - 12, a = rr.length * 31 + 8, o = r - 52, s = i - 52;
|
|
4532
4579
|
o < 220 && s > o ? (g(!0), v(Math.max(120, Math.min(a, s))), S({
|
|
4533
4580
|
top: t.top,
|
|
4534
4581
|
left: n,
|
|
@@ -4541,16 +4588,16 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4541
4588
|
}, []);
|
|
4542
4589
|
x(() => {
|
|
4543
4590
|
if (!f) return;
|
|
4544
|
-
A(""),
|
|
4545
|
-
let e = setTimeout(() =>
|
|
4546
|
-
return window.addEventListener("resize",
|
|
4547
|
-
clearTimeout(e), window.removeEventListener("resize",
|
|
4591
|
+
A(""), ye();
|
|
4592
|
+
let e = setTimeout(() => se.current?.focus(), 50);
|
|
4593
|
+
return window.addEventListener("resize", ye), window.addEventListener("scroll", ye, !0), () => {
|
|
4594
|
+
clearTimeout(e), window.removeEventListener("resize", ye), window.removeEventListener("scroll", ye, !0);
|
|
4548
4595
|
};
|
|
4549
|
-
}, [f,
|
|
4596
|
+
}, [f, ye]), x(() => {
|
|
4550
4597
|
if (!f) return;
|
|
4551
4598
|
let e = (e) => {
|
|
4552
4599
|
let t = e.target;
|
|
4553
|
-
t && (
|
|
4600
|
+
t && (W.current?.contains(t) || U.current?.contains(t) || m(!1));
|
|
4554
4601
|
};
|
|
4555
4602
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
4556
4603
|
}, [f]), x(() => {
|
|
@@ -4561,12 +4608,12 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4561
4608
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
4562
4609
|
}, [f]), x(() => {
|
|
4563
4610
|
let e = (e) => {
|
|
4564
|
-
if (e.key !== "Backspace" && e.key !== "Delete" || !o || !a ||
|
|
4611
|
+
if (e.key !== "Backspace" && e.key !== "Delete" || !o || !a || vn()) return;
|
|
4565
4612
|
let t = n?.view?.dom, r = e.target;
|
|
4566
4613
|
if (n?.isFocused && r instanceof Node && t?.contains(r)) {
|
|
4567
4614
|
if (e.preventDefault(), e.stopPropagation(), n) {
|
|
4568
4615
|
let { from: e, to: t } = n.state.selection;
|
|
4569
|
-
|
|
4616
|
+
K.current = {
|
|
4570
4617
|
from: e,
|
|
4571
4618
|
to: t
|
|
4572
4619
|
};
|
|
@@ -4580,9 +4627,9 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4580
4627
|
n,
|
|
4581
4628
|
o
|
|
4582
4629
|
]);
|
|
4583
|
-
let
|
|
4630
|
+
let be = b((e) => {
|
|
4584
4631
|
t({ language: e || null }), m(!1);
|
|
4585
|
-
}, [t]),
|
|
4632
|
+
}, [t]), xe = b(() => {
|
|
4586
4633
|
if (o) {
|
|
4587
4634
|
if (n && r) {
|
|
4588
4635
|
let e = r();
|
|
@@ -4594,7 +4641,7 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4594
4641
|
n,
|
|
4595
4642
|
r,
|
|
4596
4643
|
o
|
|
4597
|
-
]),
|
|
4644
|
+
]), Se = b(() => {
|
|
4598
4645
|
let t = e.textContent, n = (e) => {
|
|
4599
4646
|
let t = document.createElement("textarea");
|
|
4600
4647
|
t.value = e, t.style.position = "fixed", t.style.opacity = "0", document.body.appendChild(t), t.select();
|
|
@@ -4604,35 +4651,35 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4604
4651
|
document.body.removeChild(t);
|
|
4605
4652
|
};
|
|
4606
4653
|
navigator.clipboard?.writeText ? navigator.clipboard.writeText(t).catch(() => n(t)) : n(t), l(!0), setTimeout(() => l(!1), 1500);
|
|
4607
|
-
}, [e.textContent]),
|
|
4608
|
-
let t =
|
|
4654
|
+
}, [e.textContent]), Ce = b(() => {
|
|
4655
|
+
let t = ir[ce] || "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");
|
|
4609
4656
|
a.href = i, a.download = n, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
4610
|
-
}, [e.textContent,
|
|
4611
|
-
if (N ||
|
|
4612
|
-
|
|
4657
|
+
}, [e.textContent, ce]), we = b(async () => {
|
|
4658
|
+
if (N || I) {
|
|
4659
|
+
ee(null), F(null), te(!1);
|
|
4613
4660
|
return;
|
|
4614
4661
|
}
|
|
4615
|
-
|
|
4662
|
+
te(!0), F(null), ee(null);
|
|
4616
4663
|
try {
|
|
4617
4664
|
let t = (e.textContent || "").trim();
|
|
4618
4665
|
if (!t) {
|
|
4619
|
-
|
|
4666
|
+
F("代码块内容为空");
|
|
4620
4667
|
return;
|
|
4621
4668
|
}
|
|
4622
|
-
let n = p(await
|
|
4623
|
-
|
|
4669
|
+
let n = p(await nr(t, Qn));
|
|
4670
|
+
ee(n);
|
|
4624
4671
|
} catch (e) {
|
|
4625
|
-
|
|
4672
|
+
F(e instanceof Error ? e.message : "Mermaid 渲染失败");
|
|
4626
4673
|
} finally {
|
|
4627
|
-
|
|
4674
|
+
te(!1);
|
|
4628
4675
|
}
|
|
4629
4676
|
}, [
|
|
4630
4677
|
e.textContent,
|
|
4631
4678
|
N,
|
|
4632
|
-
|
|
4633
|
-
]),
|
|
4634
|
-
className: `${
|
|
4635
|
-
style: { color:
|
|
4679
|
+
I
|
|
4680
|
+
]), Te = /* @__PURE__ */ O(E, { children: [q ? q.deviconClass ? /* @__PURE__ */ D("i", {
|
|
4681
|
+
className: `${q.deviconClass} colored cb-lang-icon`,
|
|
4682
|
+
style: { color: q.color }
|
|
4636
4683
|
}) : /* @__PURE__ */ D("span", {
|
|
4637
4684
|
className: "cb-lang-icon cb-lang-icon--auto",
|
|
4638
4685
|
children: "Tx"
|
|
@@ -4641,31 +4688,31 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4641
4688
|
children: "?"
|
|
4642
4689
|
}), /* @__PURE__ */ D("span", {
|
|
4643
4690
|
className: "cb-lang-label",
|
|
4644
|
-
children:
|
|
4691
|
+
children: q?.label || "自动"
|
|
4645
4692
|
})] });
|
|
4646
4693
|
return /* @__PURE__ */ O("div", {
|
|
4647
|
-
ref:
|
|
4694
|
+
ref: G,
|
|
4648
4695
|
className: "cb-react-shell group/cb",
|
|
4649
4696
|
style: { display: "contents" },
|
|
4650
4697
|
children: [
|
|
4651
4698
|
/* @__PURE__ */ O("div", {
|
|
4652
|
-
className: "cb-header"
|
|
4699
|
+
className: `cb-header${u ? " cb-header--collapsed" : ""}`,
|
|
4653
4700
|
contentEditable: !1,
|
|
4654
4701
|
onMouseDown: (e) => e.stopPropagation(),
|
|
4655
4702
|
children: [
|
|
4656
4703
|
/* @__PURE__ */ D("div", {
|
|
4657
4704
|
className: "cb-lang-wrap",
|
|
4658
|
-
ref:
|
|
4705
|
+
ref: oe,
|
|
4659
4706
|
contentEditable: !1,
|
|
4660
4707
|
children: s ? /* @__PURE__ */ D("span", {
|
|
4661
4708
|
className: "cb-lang-trigger cb-lang-trigger--static",
|
|
4662
|
-
children:
|
|
4709
|
+
children: Te
|
|
4663
4710
|
}) : /* @__PURE__ */ O("button", {
|
|
4664
|
-
ref:
|
|
4711
|
+
ref: W,
|
|
4665
4712
|
type: "button",
|
|
4666
4713
|
className: "cb-lang-trigger",
|
|
4667
4714
|
onClick: () => m(!f),
|
|
4668
|
-
children: [
|
|
4715
|
+
children: [Te, /* @__PURE__ */ D("svg", {
|
|
4669
4716
|
className: `cb-lang-chevron${f ? " cb-lang-chevron--open" : ""}`,
|
|
4670
4717
|
width: "10",
|
|
4671
4718
|
height: "10",
|
|
@@ -4681,8 +4728,29 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4681
4728
|
})]
|
|
4682
4729
|
})
|
|
4683
4730
|
}),
|
|
4684
|
-
|
|
4685
|
-
|
|
4731
|
+
u && /* @__PURE__ */ O("button", {
|
|
4732
|
+
type: "button",
|
|
4733
|
+
className: "cb-collapsed-bar",
|
|
4734
|
+
contentEditable: !1,
|
|
4735
|
+
onClick: () => d(!1),
|
|
4736
|
+
title: "展开代码块",
|
|
4737
|
+
children: [Te, /* @__PURE__ */ D("svg", {
|
|
4738
|
+
className: "cb-lang-chevron",
|
|
4739
|
+
width: "12",
|
|
4740
|
+
height: "12",
|
|
4741
|
+
viewBox: "0 0 24 24",
|
|
4742
|
+
fill: "none",
|
|
4743
|
+
stroke: "currentColor",
|
|
4744
|
+
strokeWidth: "2.5",
|
|
4745
|
+
children: /* @__PURE__ */ D("path", {
|
|
4746
|
+
strokeLinecap: "round",
|
|
4747
|
+
strokeLinejoin: "round",
|
|
4748
|
+
d: "M6 9l6 6 6-6"
|
|
4749
|
+
})
|
|
4750
|
+
})]
|
|
4751
|
+
}),
|
|
4752
|
+
o && f && L(/* @__PURE__ */ O("div", {
|
|
4753
|
+
ref: U,
|
|
4686
4754
|
className: `cb-lang-dropdown${h ? " cb-lang-dropdown--up" : ""}`,
|
|
4687
4755
|
style: {
|
|
4688
4756
|
position: "fixed",
|
|
@@ -4707,7 +4775,7 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4707
4775
|
d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
|
|
4708
4776
|
})
|
|
4709
4777
|
}), /* @__PURE__ */ D("input", {
|
|
4710
|
-
ref:
|
|
4778
|
+
ref: se,
|
|
4711
4779
|
className: "cb-lang-search",
|
|
4712
4780
|
type: "text",
|
|
4713
4781
|
placeholder: "搜索语言...",
|
|
@@ -4721,17 +4789,17 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4721
4789
|
children: [
|
|
4722
4790
|
/* @__PURE__ */ O("button", {
|
|
4723
4791
|
type: "button",
|
|
4724
|
-
className: `cb-lang-option${
|
|
4725
|
-
onClick: () =>
|
|
4792
|
+
className: `cb-lang-option${ce ? "" : " cb-lang-option--active"}`,
|
|
4793
|
+
onClick: () => be(""),
|
|
4726
4794
|
children: [/* @__PURE__ */ D("span", {
|
|
4727
4795
|
className: "cb-lang-icon cb-lang-icon--auto",
|
|
4728
4796
|
children: "?"
|
|
4729
4797
|
}), /* @__PURE__ */ D("span", { children: "自动检测" })]
|
|
4730
4798
|
}),
|
|
4731
|
-
|
|
4799
|
+
ve.map((e) => /* @__PURE__ */ O("button", {
|
|
4732
4800
|
type: "button",
|
|
4733
|
-
className: `cb-lang-option${
|
|
4734
|
-
onClick: () =>
|
|
4801
|
+
className: `cb-lang-option${ce === e.value ? " cb-lang-option--active" : ""}`,
|
|
4802
|
+
onClick: () => be(e.value),
|
|
4735
4803
|
children: [e.deviconClass ? /* @__PURE__ */ D("i", {
|
|
4736
4804
|
className: `${e.deviconClass} colored cb-lang-icon`,
|
|
4737
4805
|
style: { color: e.color }
|
|
@@ -4740,7 +4808,7 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4740
4808
|
children: "Tx"
|
|
4741
4809
|
}), /* @__PURE__ */ D("span", { children: e.label })]
|
|
4742
4810
|
}, e.value)),
|
|
4743
|
-
|
|
4811
|
+
ve.length === 0 && /* @__PURE__ */ D("div", {
|
|
4744
4812
|
className: "cb-lang-empty",
|
|
4745
4813
|
children: "无匹配语言"
|
|
4746
4814
|
})
|
|
@@ -4776,7 +4844,7 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4776
4844
|
/* @__PURE__ */ D("button", {
|
|
4777
4845
|
type: "button",
|
|
4778
4846
|
className: "cb-btn",
|
|
4779
|
-
onClick:
|
|
4847
|
+
onClick: Se,
|
|
4780
4848
|
contentEditable: !1,
|
|
4781
4849
|
title: "复制",
|
|
4782
4850
|
children: c ? /* @__PURE__ */ D("svg", {
|
|
@@ -4806,7 +4874,7 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4806
4874
|
/* @__PURE__ */ D("button", {
|
|
4807
4875
|
type: "button",
|
|
4808
4876
|
className: "cb-btn",
|
|
4809
|
-
onClick:
|
|
4877
|
+
onClick: Ce,
|
|
4810
4878
|
contentEditable: !1,
|
|
4811
4879
|
title: "下载",
|
|
4812
4880
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -4825,7 +4893,7 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4825
4893
|
o && /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("button", {
|
|
4826
4894
|
type: "button",
|
|
4827
4895
|
className: "cb-btn cb-btn--ai",
|
|
4828
|
-
onClick:
|
|
4896
|
+
onClick: xe,
|
|
4829
4897
|
contentEditable: !1,
|
|
4830
4898
|
title: "写作助手",
|
|
4831
4899
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -4843,7 +4911,7 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4843
4911
|
}), /* @__PURE__ */ D("button", {
|
|
4844
4912
|
type: "button",
|
|
4845
4913
|
className: "cb-btn cb-btn--del",
|
|
4846
|
-
onClick:
|
|
4914
|
+
onClick: _e,
|
|
4847
4915
|
contentEditable: !1,
|
|
4848
4916
|
title: "删除代码块",
|
|
4849
4917
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -4859,13 +4927,13 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4859
4927
|
})
|
|
4860
4928
|
})
|
|
4861
4929
|
})] }),
|
|
4862
|
-
|
|
4930
|
+
le && /* @__PURE__ */ D("button", {
|
|
4863
4931
|
type: "button",
|
|
4864
4932
|
className: "cb-btn cb-btn--diagram",
|
|
4865
|
-
onClick:
|
|
4933
|
+
onClick: we,
|
|
4866
4934
|
contentEditable: !1,
|
|
4867
|
-
title: N ||
|
|
4868
|
-
disabled:
|
|
4935
|
+
title: N || I ? "取消渲染" : "渲染图表",
|
|
4936
|
+
disabled: I,
|
|
4869
4937
|
children: /* @__PURE__ */ D("svg", {
|
|
4870
4938
|
className: "cb-btn-icon",
|
|
4871
4939
|
fill: "none",
|
|
@@ -4883,28 +4951,121 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4883
4951
|
})
|
|
4884
4952
|
]
|
|
4885
4953
|
}),
|
|
4886
|
-
(N ||
|
|
4954
|
+
(N || P || I) && /* @__PURE__ */ O("div", {
|
|
4887
4955
|
className: "cb-diagram-output",
|
|
4888
4956
|
contentEditable: !1,
|
|
4889
4957
|
children: [
|
|
4890
|
-
|
|
4958
|
+
I && /* @__PURE__ */ D("div", {
|
|
4891
4959
|
className: "cb-diagram-loading",
|
|
4892
4960
|
children: "渲染图表中…"
|
|
4893
4961
|
}),
|
|
4894
|
-
|
|
4962
|
+
P && /* @__PURE__ */ O("div", {
|
|
4895
4963
|
className: "cb-diagram-error",
|
|
4896
4964
|
children: [/* @__PURE__ */ D("span", {
|
|
4897
4965
|
className: "cb-diagram-error-icon",
|
|
4898
4966
|
children: "!"
|
|
4899
|
-
}),
|
|
4967
|
+
}), P]
|
|
4900
4968
|
}),
|
|
4901
|
-
N && /* @__PURE__ */
|
|
4969
|
+
N && /* @__PURE__ */ O("div", {
|
|
4902
4970
|
className: "cb-diagram-svg",
|
|
4903
|
-
|
|
4971
|
+
role: "button",
|
|
4972
|
+
tabIndex: 0,
|
|
4973
|
+
title: "点击放大查看",
|
|
4974
|
+
onClick: J,
|
|
4975
|
+
onKeyDown: (e) => {
|
|
4976
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), J());
|
|
4977
|
+
},
|
|
4978
|
+
children: [/* @__PURE__ */ D("div", {
|
|
4979
|
+
className: "cb-diagram-svg-inner",
|
|
4980
|
+
dangerouslySetInnerHTML: { __html: N }
|
|
4981
|
+
}), /* @__PURE__ */ D("span", {
|
|
4982
|
+
className: "cb-diagram-zoom-hint",
|
|
4983
|
+
children: "点击放大"
|
|
4984
|
+
})]
|
|
4904
4985
|
})
|
|
4905
4986
|
]
|
|
4906
4987
|
}),
|
|
4907
|
-
/* @__PURE__ */
|
|
4988
|
+
ne && N && L(/* @__PURE__ */ O("div", {
|
|
4989
|
+
className: "fixed inset-0 z-[10002] flex flex-col bg-black/75 backdrop-blur-sm select-none",
|
|
4990
|
+
role: "dialog",
|
|
4991
|
+
"aria-modal": "true",
|
|
4992
|
+
"aria-label": "Mermaid 图表预览",
|
|
4993
|
+
children: [/* @__PURE__ */ O("div", {
|
|
4994
|
+
className: "flex items-center justify-between gap-3 px-4 py-3 text-white",
|
|
4995
|
+
children: [/* @__PURE__ */ D("span", {
|
|
4996
|
+
className: "text-sm font-medium",
|
|
4997
|
+
children: "Mermaid 图表"
|
|
4998
|
+
}), /* @__PURE__ */ O("div", {
|
|
4999
|
+
className: "flex items-center gap-1.5",
|
|
5000
|
+
children: [
|
|
5001
|
+
/* @__PURE__ */ D("button", {
|
|
5002
|
+
type: "button",
|
|
5003
|
+
className: "flex h-8 min-w-8 items-center justify-center rounded-lg bg-white/10 px-2 text-base text-white transition-colors hover:bg-white/20",
|
|
5004
|
+
onClick: () => de(-.25),
|
|
5005
|
+
title: "缩小",
|
|
5006
|
+
"aria-label": "缩小",
|
|
5007
|
+
children: "−"
|
|
5008
|
+
}),
|
|
5009
|
+
/* @__PURE__ */ O("button", {
|
|
5010
|
+
type: "button",
|
|
5011
|
+
className: "flex h-8 min-w-14 items-center justify-center rounded-lg bg-white/10 px-2 text-xs text-white transition-colors hover:bg-white/20",
|
|
5012
|
+
onClick: fe,
|
|
5013
|
+
title: "重置为 100%",
|
|
5014
|
+
"aria-label": "重置缩放",
|
|
5015
|
+
children: [Math.round(re * 100), "%"]
|
|
5016
|
+
}),
|
|
5017
|
+
/* @__PURE__ */ D("button", {
|
|
5018
|
+
type: "button",
|
|
5019
|
+
className: "flex h-8 min-w-8 items-center justify-center rounded-lg bg-white/10 px-2 text-base text-white transition-colors hover:bg-white/20",
|
|
5020
|
+
onClick: () => de(tr),
|
|
5021
|
+
title: "放大",
|
|
5022
|
+
"aria-label": "放大",
|
|
5023
|
+
children: "+"
|
|
5024
|
+
}),
|
|
5025
|
+
/* @__PURE__ */ D("button", {
|
|
5026
|
+
type: "button",
|
|
5027
|
+
className: "flex h-8 min-w-8 items-center justify-center rounded-lg bg-white/10 px-2 text-sm text-white transition-colors hover:bg-white/20",
|
|
5028
|
+
onClick: fe,
|
|
5029
|
+
title: "重置",
|
|
5030
|
+
"aria-label": "重置",
|
|
5031
|
+
children: "⟲"
|
|
5032
|
+
}),
|
|
5033
|
+
/* @__PURE__ */ D("span", { className: "mx-1 h-5 w-px bg-white/20" }),
|
|
5034
|
+
/* @__PURE__ */ D("button", {
|
|
5035
|
+
type: "button",
|
|
5036
|
+
className: "flex h-8 min-w-8 items-center justify-center rounded-lg bg-white/10 px-2 text-lg text-white transition-colors hover:bg-white/20",
|
|
5037
|
+
onClick: () => R(!1),
|
|
5038
|
+
title: "关闭",
|
|
5039
|
+
"aria-label": "关闭",
|
|
5040
|
+
children: "×"
|
|
5041
|
+
})
|
|
5042
|
+
]
|
|
5043
|
+
})]
|
|
5044
|
+
}), /* @__PURE__ */ D("div", {
|
|
5045
|
+
className: "flex flex-1 touch-none items-center justify-center overflow-hidden",
|
|
5046
|
+
style: { cursor: V ? "grabbing" : re > 1 ? "grab" : "default" },
|
|
5047
|
+
onWheel: (e) => de(e.deltaY > 0 ? -.25 : tr),
|
|
5048
|
+
onPointerDown: pe,
|
|
5049
|
+
onPointerMove: me,
|
|
5050
|
+
onPointerUp: he,
|
|
5051
|
+
onPointerCancel: he,
|
|
5052
|
+
onDoubleClick: () => {
|
|
5053
|
+
ie((e) => e === 1 ? 2 : 1), B({
|
|
5054
|
+
x: 0,
|
|
5055
|
+
y: 0
|
|
5056
|
+
});
|
|
5057
|
+
},
|
|
5058
|
+
children: /* @__PURE__ */ D("div", {
|
|
5059
|
+
className: "cb-diagram-zoom-content",
|
|
5060
|
+
style: {
|
|
5061
|
+
transform: `translate(${z.x}px, ${z.y}px) scale(${re})`,
|
|
5062
|
+
transition: V ? "none" : "transform 120ms ease-out"
|
|
5063
|
+
},
|
|
5064
|
+
dangerouslySetInnerHTML: { __html: N }
|
|
5065
|
+
})
|
|
5066
|
+
})]
|
|
5067
|
+
}), document.body),
|
|
5068
|
+
/* @__PURE__ */ D(Cn, {
|
|
4908
5069
|
open: j,
|
|
4909
5070
|
title: "确认删除代码块",
|
|
4910
5071
|
message: "此操作不可撤销。",
|
|
@@ -4920,7 +5081,7 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4920
5081
|
}
|
|
4921
5082
|
//#endregion
|
|
4922
5083
|
//#region src/editor/extensions/code-block.ts
|
|
4923
|
-
var
|
|
5084
|
+
var sr = [
|
|
4924
5085
|
{
|
|
4925
5086
|
value: "javascript",
|
|
4926
5087
|
label: "JavaScript"
|
|
@@ -5021,12 +5182,12 @@ var tr = [
|
|
|
5021
5182
|
value: "mermaid",
|
|
5022
5183
|
label: "Mermaid"
|
|
5023
5184
|
}
|
|
5024
|
-
],
|
|
5025
|
-
|
|
5026
|
-
function
|
|
5185
|
+
], cr = Se(xe);
|
|
5186
|
+
cr.register({ dockerfile: be }), cr.registerAlias("xml", ["vue", "html"]), cr.registerAlias("javascript", ["react", "jsx"]), cr.registerAlias("typescript", ["tsx"]);
|
|
5187
|
+
function lr(e) {
|
|
5027
5188
|
return e ? e.split("\n") : [""];
|
|
5028
5189
|
}
|
|
5029
|
-
function
|
|
5190
|
+
function ur(e, t) {
|
|
5030
5191
|
if (e.childElementCount !== t) {
|
|
5031
5192
|
e.replaceChildren();
|
|
5032
5193
|
for (let n = 1; n <= t; n++) {
|
|
@@ -5035,14 +5196,14 @@ function ir(e, t) {
|
|
|
5035
5196
|
}
|
|
5036
5197
|
}
|
|
5037
5198
|
}
|
|
5038
|
-
function
|
|
5199
|
+
function dr(e, t) {
|
|
5039
5200
|
e.replaceChildren();
|
|
5040
5201
|
for (let n of t) {
|
|
5041
5202
|
let t = document.createElement("span");
|
|
5042
5203
|
t.className = "cb-mirror-line", t.textContent = n.length ? n : "\xA0", e.appendChild(t);
|
|
5043
5204
|
}
|
|
5044
5205
|
}
|
|
5045
|
-
function
|
|
5206
|
+
function fr(e, t, n) {
|
|
5046
5207
|
let r = getComputedStyle(e), i = parseFloat(r.paddingLeft), a = parseFloat(r.paddingRight);
|
|
5047
5208
|
t.style.boxSizing = "content-box", t.style.width = `${Math.max(0, e.clientWidth - i - a)}px`, t.style.padding = r.padding;
|
|
5048
5209
|
let o = getComputedStyle(n);
|
|
@@ -5089,7 +5250,7 @@ function or(e, t, n) {
|
|
|
5089
5250
|
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;
|
|
5090
5251
|
}
|
|
5091
5252
|
}
|
|
5092
|
-
var
|
|
5253
|
+
var pr = ye.extend({
|
|
5093
5254
|
addNodeView() {
|
|
5094
5255
|
return (e) => {
|
|
5095
5256
|
let { node: t, editor: n, getPos: r } = e, i = t, a = (e) => {
|
|
@@ -5108,16 +5269,18 @@ var sr = ye.extend({
|
|
|
5108
5269
|
let l = document.createElement("div");
|
|
5109
5270
|
l.className = "cb-code-area";
|
|
5110
5271
|
let u = document.createElement("div");
|
|
5111
|
-
u.className = "cb-
|
|
5112
|
-
let d = document.createElement("
|
|
5113
|
-
d.className = "cb-
|
|
5114
|
-
let f = document.createElement("
|
|
5115
|
-
|
|
5116
|
-
let p = document.createElement("
|
|
5117
|
-
|
|
5118
|
-
let m =
|
|
5119
|
-
|
|
5120
|
-
let h =
|
|
5272
|
+
u.className = "cb-code-inner";
|
|
5273
|
+
let d = document.createElement("div");
|
|
5274
|
+
d.className = "cb-line-numbers", d.contentEditable = "false", d.setAttribute("aria-hidden", "true");
|
|
5275
|
+
let f = document.createElement("pre");
|
|
5276
|
+
f.className = "cb-code-pre";
|
|
5277
|
+
let p = document.createElement("code");
|
|
5278
|
+
f.appendChild(p);
|
|
5279
|
+
let m = document.createElement("div");
|
|
5280
|
+
m.className = "cb-code-mirror", m.contentEditable = "false", m.setAttribute("aria-hidden", "true"), u.appendChild(d), u.appendChild(f), u.appendChild(m), l.appendChild(u), s.appendChild(l);
|
|
5281
|
+
let h = lr(t.textContent);
|
|
5282
|
+
ur(d, h.length), dr(m, h);
|
|
5283
|
+
let g = new I(or, {
|
|
5121
5284
|
editor: n,
|
|
5122
5285
|
props: {
|
|
5123
5286
|
node: t,
|
|
@@ -5128,28 +5291,28 @@ var sr = ye.extend({
|
|
|
5128
5291
|
selected: !1
|
|
5129
5292
|
}
|
|
5130
5293
|
});
|
|
5131
|
-
c.appendChild(
|
|
5132
|
-
let
|
|
5133
|
-
let t =
|
|
5134
|
-
|
|
5294
|
+
c.appendChild(g.element);
|
|
5295
|
+
let _ = (e) => {
|
|
5296
|
+
let t = lr(e.textContent);
|
|
5297
|
+
ur(d, t.length), dr(m, t), requestAnimationFrame(() => fr(f, m, d));
|
|
5135
5298
|
};
|
|
5136
|
-
requestAnimationFrame(() =>
|
|
5137
|
-
let
|
|
5138
|
-
return
|
|
5299
|
+
requestAnimationFrame(() => fr(f, m, d));
|
|
5300
|
+
let v = new ResizeObserver(() => fr(f, m, d));
|
|
5301
|
+
return v.observe(f), document.fonts?.ready?.then(() => fr(f, m, d)), {
|
|
5139
5302
|
dom: s,
|
|
5140
|
-
contentDOM:
|
|
5303
|
+
contentDOM: p,
|
|
5141
5304
|
update(e) {
|
|
5142
|
-
return e.type !== t.type || !e.sameMarkup(i) ? !1 : (i = e,
|
|
5305
|
+
return e.type !== t.type || !e.sameMarkup(i) ? !1 : (i = e, g.updateProps({
|
|
5143
5306
|
node: e,
|
|
5144
5307
|
editor: n,
|
|
5145
5308
|
getPos: r,
|
|
5146
5309
|
updateAttributes: a,
|
|
5147
5310
|
deleteNode: o,
|
|
5148
5311
|
selected: s.classList.contains("ProseMirror-selectednode")
|
|
5149
|
-
}),
|
|
5312
|
+
}), _(e), !0);
|
|
5150
5313
|
},
|
|
5151
5314
|
selectNode() {
|
|
5152
|
-
s.classList.add("ProseMirror-selectednode"),
|
|
5315
|
+
s.classList.add("ProseMirror-selectednode"), g.updateProps({
|
|
5153
5316
|
node: i,
|
|
5154
5317
|
editor: n,
|
|
5155
5318
|
getPos: r,
|
|
@@ -5159,7 +5322,7 @@ var sr = ye.extend({
|
|
|
5159
5322
|
});
|
|
5160
5323
|
},
|
|
5161
5324
|
deselectNode() {
|
|
5162
|
-
s.classList.remove("ProseMirror-selectednode"),
|
|
5325
|
+
s.classList.remove("ProseMirror-selectednode"), g.updateProps({
|
|
5163
5326
|
node: i,
|
|
5164
5327
|
editor: n,
|
|
5165
5328
|
getPos: r,
|
|
@@ -5173,10 +5336,10 @@ var sr = ye.extend({
|
|
|
5173
5336
|
return !!(t && c.contains(t));
|
|
5174
5337
|
},
|
|
5175
5338
|
ignoreMutation(e) {
|
|
5176
|
-
return !
|
|
5339
|
+
return !p.contains(e.target);
|
|
5177
5340
|
},
|
|
5178
5341
|
destroy() {
|
|
5179
|
-
|
|
5342
|
+
v.disconnect(), g.destroy();
|
|
5180
5343
|
}
|
|
5181
5344
|
};
|
|
5182
5345
|
};
|
|
@@ -5195,10 +5358,10 @@ var sr = ye.extend({
|
|
|
5195
5358
|
}
|
|
5196
5359
|
}));
|
|
5197
5360
|
}
|
|
5198
|
-
}).configure({ lowlight:
|
|
5361
|
+
}).configure({ lowlight: cr });
|
|
5199
5362
|
//#endregion
|
|
5200
5363
|
//#region src/editor/utils/import-choice-dialog.ts
|
|
5201
|
-
function
|
|
5364
|
+
function mr(e) {
|
|
5202
5365
|
return new Promise((t) => {
|
|
5203
5366
|
let n = document.createElement("div");
|
|
5204
5367
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5228,16 +5391,16 @@ function cr(e) {
|
|
|
5228
5391
|
}
|
|
5229
5392
|
//#endregion
|
|
5230
5393
|
//#region src/editor/utils/local-media.ts
|
|
5231
|
-
var
|
|
5232
|
-
function
|
|
5394
|
+
var hr = /\.(png|jpe?g|gif|webp|bmp|svg|avif|mp4|m4v|webm|ogg|mov|avi|mkv|mp3|wav|flac|m4a|aac|opus|pdf|docx?|xlsx?|pptx?|odt|rtf|txt|md|csv|zip|rar|7z|json)(\?|#|$)/i, gr = /^(?:mailto:|tel:|javascript:|about:|data:|blob:)/i;
|
|
5395
|
+
function _r(e) {
|
|
5233
5396
|
if (!e) return !1;
|
|
5234
5397
|
let t = e.trim();
|
|
5235
|
-
return !(!t || /^(?:https?:)?\/\//i.test(t) ||
|
|
5398
|
+
return !(!t || /^(?:https?:)?\/\//i.test(t) || gr.test(t) || t.startsWith("#"));
|
|
5236
5399
|
}
|
|
5237
|
-
function
|
|
5238
|
-
return
|
|
5400
|
+
function vr(e) {
|
|
5401
|
+
return hr.test(e);
|
|
5239
5402
|
}
|
|
5240
|
-
function
|
|
5403
|
+
function yr(e) {
|
|
5241
5404
|
let t = e.trim();
|
|
5242
5405
|
t = t.replace(/^(?:file|app):\/\/(?:localhost)?/i, "");
|
|
5243
5406
|
try {
|
|
@@ -5245,26 +5408,26 @@ function pr(e) {
|
|
|
5245
5408
|
} catch {}
|
|
5246
5409
|
return t = t.replace(/\\/g, "/"), t = t.replace(/^\.\//, ""), t = t.replace(/^\/+/, ""), t = t.replace(/^[a-zA-Z]:\//, ""), t;
|
|
5247
5410
|
}
|
|
5248
|
-
function
|
|
5249
|
-
let t =
|
|
5411
|
+
function br(e) {
|
|
5412
|
+
let t = yr(e), n = t.split("/").filter(Boolean);
|
|
5250
5413
|
return (n[n.length - 1] || t).toLowerCase();
|
|
5251
5414
|
}
|
|
5252
|
-
function
|
|
5415
|
+
function xr() {
|
|
5253
5416
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showDirectoryPicker == "function";
|
|
5254
5417
|
}
|
|
5255
|
-
async function
|
|
5256
|
-
if (!
|
|
5418
|
+
async function Sr() {
|
|
5419
|
+
if (!xr()) return null;
|
|
5257
5420
|
try {
|
|
5258
5421
|
return await window.showDirectoryPicker.call(window, { mode: "read" }) ?? null;
|
|
5259
5422
|
} catch {
|
|
5260
5423
|
return null;
|
|
5261
5424
|
}
|
|
5262
5425
|
}
|
|
5263
|
-
function
|
|
5426
|
+
function Cr() {
|
|
5264
5427
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showOpenFilePicker == "function";
|
|
5265
5428
|
}
|
|
5266
|
-
async function
|
|
5267
|
-
if (!
|
|
5429
|
+
async function wr() {
|
|
5430
|
+
if (!Cr()) return null;
|
|
5268
5431
|
try {
|
|
5269
5432
|
let e = await window.showOpenFilePicker.call(window, { multiple: !0 });
|
|
5270
5433
|
return await Promise.all(e.map((e) => e.getFile()));
|
|
@@ -5272,7 +5435,7 @@ async function vr() {
|
|
|
5272
5435
|
return null;
|
|
5273
5436
|
}
|
|
5274
5437
|
}
|
|
5275
|
-
async function
|
|
5438
|
+
async function Tr(e, t) {
|
|
5276
5439
|
if (t.length === 0) return { file: null };
|
|
5277
5440
|
let n = e;
|
|
5278
5441
|
for (let e = 0; e < t.length - 1; e++) try {
|
|
@@ -5294,7 +5457,7 @@ async function yr(e, t) {
|
|
|
5294
5457
|
return { file: null };
|
|
5295
5458
|
}
|
|
5296
5459
|
}
|
|
5297
|
-
async function
|
|
5460
|
+
async function Er(e, t, n = 5e3) {
|
|
5298
5461
|
let r = t.toLowerCase(), i = [e], a = 0, o;
|
|
5299
5462
|
for (; i.length > 0 && a < n;) {
|
|
5300
5463
|
let e = i.pop();
|
|
@@ -5316,37 +5479,37 @@ async function br(e, t, n = 5e3) {
|
|
|
5316
5479
|
readError: o
|
|
5317
5480
|
};
|
|
5318
5481
|
}
|
|
5319
|
-
async function
|
|
5320
|
-
let n =
|
|
5482
|
+
async function Dr(e, t) {
|
|
5483
|
+
let n = yr(t).split("/").filter(Boolean);
|
|
5321
5484
|
if (n.length === 0) return { file: null };
|
|
5322
5485
|
let r;
|
|
5323
5486
|
for (let t = 0; t < n.length; t++) {
|
|
5324
|
-
let i = await
|
|
5487
|
+
let i = await Tr(e, n.slice(t));
|
|
5325
5488
|
if (i.file) return i;
|
|
5326
5489
|
i.readError && (r = i.readError);
|
|
5327
5490
|
}
|
|
5328
|
-
let i = await
|
|
5491
|
+
let i = await Er(e, n[n.length - 1]);
|
|
5329
5492
|
return i.file || i.readError ? i : {
|
|
5330
5493
|
file: null,
|
|
5331
5494
|
readError: r
|
|
5332
5495
|
};
|
|
5333
5496
|
}
|
|
5334
|
-
var
|
|
5497
|
+
var Or = {
|
|
5335
5498
|
image: "image",
|
|
5336
5499
|
videoEmbed: "video",
|
|
5337
5500
|
audioEmbed: "audio",
|
|
5338
5501
|
attachmentEmbed: "attachment"
|
|
5339
5502
|
};
|
|
5340
|
-
function
|
|
5503
|
+
function kr(e, t) {
|
|
5341
5504
|
let n = /* @__PURE__ */ new Set(), r = [];
|
|
5342
5505
|
return e.descendants((e) => {
|
|
5343
|
-
let i =
|
|
5506
|
+
let i = Or[e.type?.name];
|
|
5344
5507
|
if (i) {
|
|
5345
5508
|
let a = e.attrs?.src, o = `node:${a}`;
|
|
5346
|
-
typeof a == "string" &&
|
|
5509
|
+
typeof a == "string" && _r(a) && !n.has(o) && !t?.(a) && (n.add(o), r.push({
|
|
5347
5510
|
src: a,
|
|
5348
|
-
normalized:
|
|
5349
|
-
basename:
|
|
5511
|
+
normalized: yr(a),
|
|
5512
|
+
basename: br(a),
|
|
5350
5513
|
kind: i,
|
|
5351
5514
|
isLink: !1
|
|
5352
5515
|
}));
|
|
@@ -5355,17 +5518,17 @@ function Cr(e, t) {
|
|
|
5355
5518
|
if (e.isText && e.marks) for (let i of e.marks) {
|
|
5356
5519
|
if (i.type.name !== "link") continue;
|
|
5357
5520
|
let e = i.attrs?.href, a = `link:${e}`;
|
|
5358
|
-
typeof e == "string" &&
|
|
5521
|
+
typeof e == "string" && _r(e) && vr(e) && !n.has(a) && !t?.(e) && (n.add(a), r.push({
|
|
5359
5522
|
src: e,
|
|
5360
|
-
normalized:
|
|
5361
|
-
basename:
|
|
5523
|
+
normalized: yr(e),
|
|
5524
|
+
basename: br(e),
|
|
5362
5525
|
kind: "attachment",
|
|
5363
5526
|
isLink: !0
|
|
5364
5527
|
}));
|
|
5365
5528
|
}
|
|
5366
5529
|
}), r;
|
|
5367
5530
|
}
|
|
5368
|
-
function
|
|
5531
|
+
function Ar(e, t, n) {
|
|
5369
5532
|
let r = t ? `${e}\n${t}` : e;
|
|
5370
5533
|
if (!r) return !1;
|
|
5371
5534
|
let i = [];
|
|
@@ -5373,28 +5536,28 @@ function wr(e, t, n) {
|
|
|
5373
5536
|
for (let e of r.matchAll(/!?\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g)) i.push(e[1]);
|
|
5374
5537
|
for (let e of r.matchAll(/<(?:img|video|audio|source)[^>]*\bsrc=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5375
5538
|
for (let e of r.matchAll(/<a[^>]*\bhref=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5376
|
-
return i.some((e) =>
|
|
5539
|
+
return i.some((e) => vr(e) && _r(e) && !n?.(e));
|
|
5377
5540
|
}
|
|
5378
5541
|
//#endregion
|
|
5379
5542
|
//#region src/editor/extensions/image-upload.ts
|
|
5380
|
-
function
|
|
5543
|
+
function jr(e) {
|
|
5381
5544
|
if (e.type.startsWith("image/")) return "image";
|
|
5382
5545
|
if (e.type.startsWith("video/")) return "video";
|
|
5383
5546
|
if (e.type.startsWith("audio/")) return "audio";
|
|
5384
5547
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5385
5548
|
return /^(png|jpe?g|gif|webp|bmp|svg|avif)$/.test(t) ? "image" : /^(mp4|m3u8|webm|ogg|mov|avi|wmv|flv|mkv|ts|m4v|3gp|f4v|rmvb)$/.test(t) ? "video" : /^(mp3|wav|flac|aac|m4a|wma|opus)$/.test(t) ? "audio" : /^(md|markdown)$/.test(t) ? "markdown" : "file";
|
|
5386
5549
|
}
|
|
5387
|
-
function
|
|
5550
|
+
function Mr(e) {
|
|
5388
5551
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5389
5552
|
return t === "md" || t === "markdown";
|
|
5390
5553
|
}
|
|
5391
|
-
async function
|
|
5392
|
-
let i = n ?? e.state.selection.from, a = r ?
|
|
5393
|
-
o?.chooseMd ? o.chooseMd(t.name, e) :
|
|
5554
|
+
async function Nr(e, t, n, r) {
|
|
5555
|
+
let i = n ?? e.state.selection.from, a = r ? pn(r) : void 0, o = r?.storage?.qingwuUI, s = await new Promise((e) => {
|
|
5556
|
+
o?.chooseMd ? o.chooseMd(t.name, e) : mr(t.name).then(e);
|
|
5394
5557
|
});
|
|
5395
5558
|
if (s === null) return;
|
|
5396
5559
|
if (s === "attach") {
|
|
5397
|
-
let n = a ?
|
|
5560
|
+
let n = a ? mn(e.state.doc, t, a) : null;
|
|
5398
5561
|
if (n) {
|
|
5399
5562
|
Z(n);
|
|
5400
5563
|
return;
|
|
@@ -5425,8 +5588,8 @@ async function Dr(e, t, n, r) {
|
|
|
5425
5588
|
e.dispatch(e.state.tr.insert(i, t.from(u)));
|
|
5426
5589
|
}
|
|
5427
5590
|
}
|
|
5428
|
-
function
|
|
5429
|
-
switch (
|
|
5591
|
+
function Pr(e, t, n) {
|
|
5592
|
+
switch (jr(t)) {
|
|
5430
5593
|
case "image": return e.nodes.image?.create({
|
|
5431
5594
|
src: n,
|
|
5432
5595
|
alt: t.name
|
|
@@ -5452,7 +5615,7 @@ function Or(e, t, n) {
|
|
|
5452
5615
|
}
|
|
5453
5616
|
}
|
|
5454
5617
|
}
|
|
5455
|
-
async function
|
|
5618
|
+
async function Fr(e, t, n) {
|
|
5456
5619
|
let r;
|
|
5457
5620
|
try {
|
|
5458
5621
|
r = o();
|
|
@@ -5471,13 +5634,13 @@ async function kr(e, t, n) {
|
|
|
5471
5634
|
return console.error(`${t.type} upload failed:`, e), URL.revokeObjectURL(n), null;
|
|
5472
5635
|
}
|
|
5473
5636
|
}
|
|
5474
|
-
async function
|
|
5475
|
-
let i = r ?
|
|
5637
|
+
async function Ir(e, t, n, r) {
|
|
5638
|
+
let i = r ? pn(r) : void 0, a = i ? mn(e.state.doc, t, i) : null;
|
|
5476
5639
|
if (a) {
|
|
5477
5640
|
Z(a);
|
|
5478
5641
|
return;
|
|
5479
5642
|
}
|
|
5480
|
-
let o = URL.createObjectURL(t), s =
|
|
5643
|
+
let o = URL.createObjectURL(t), s = Pr(e.state.schema, t, o);
|
|
5481
5644
|
if (!s) return;
|
|
5482
5645
|
let c = n ?? e.state.selection.from;
|
|
5483
5646
|
try {
|
|
@@ -5485,9 +5648,9 @@ async function Ar(e, t, n, r) {
|
|
|
5485
5648
|
} catch {
|
|
5486
5649
|
return;
|
|
5487
5650
|
}
|
|
5488
|
-
await
|
|
5651
|
+
await Fr(e, t, o);
|
|
5489
5652
|
}
|
|
5490
|
-
var
|
|
5653
|
+
var Lr = R.create({
|
|
5491
5654
|
name: "imageUpload",
|
|
5492
5655
|
addOptions() {
|
|
5493
5656
|
return {
|
|
@@ -5497,8 +5660,8 @@ var jr = R.create({
|
|
|
5497
5660
|
},
|
|
5498
5661
|
addProseMirrorPlugins() {
|
|
5499
5662
|
let e = this.editor;
|
|
5500
|
-
return [new
|
|
5501
|
-
key: new
|
|
5663
|
+
return [new V({
|
|
5664
|
+
key: new H("imageUpload"),
|
|
5502
5665
|
props: {
|
|
5503
5666
|
handleDrop(t, n) {
|
|
5504
5667
|
let r = n.dataTransfer?.files;
|
|
@@ -5508,23 +5671,23 @@ var jr = R.create({
|
|
|
5508
5671
|
left: n.clientX,
|
|
5509
5672
|
top: n.clientY
|
|
5510
5673
|
});
|
|
5511
|
-
for (let n of Array.from(r))
|
|
5674
|
+
for (let n of Array.from(r)) Mr(n) ? Nr(t, n, i?.pos, e) : Ir(t, n, i?.pos, e);
|
|
5512
5675
|
return !0;
|
|
5513
5676
|
},
|
|
5514
5677
|
handlePaste(t, n) {
|
|
5515
5678
|
let r = n.clipboardData?.items;
|
|
5516
5679
|
if (!r) return !1;
|
|
5517
5680
|
let i = n.clipboardData?.getData("text/plain") || "";
|
|
5518
|
-
if ((n.clipboardData?.files?.length ?? 0) > 0 &&
|
|
5681
|
+
if ((n.clipboardData?.files?.length ?? 0) > 0 && Ar(i, void 0, a())) return !1;
|
|
5519
5682
|
for (let i of Array.from(r)) {
|
|
5520
5683
|
if (i.type.startsWith("image/") || i.type.startsWith("video/") || i.type.startsWith("audio/")) {
|
|
5521
5684
|
n.preventDefault();
|
|
5522
5685
|
let r = i.getAsFile();
|
|
5523
|
-
return r &&
|
|
5686
|
+
return r && jr(r) !== "file" && Ir(t, r, void 0, e), !0;
|
|
5524
5687
|
}
|
|
5525
5688
|
if (i.kind === "file") {
|
|
5526
5689
|
let r = i.getAsFile();
|
|
5527
|
-
if (r &&
|
|
5690
|
+
if (r && Mr(r)) return n.preventDefault(), Nr(t, r, void 0, e), !0;
|
|
5528
5691
|
}
|
|
5529
5692
|
}
|
|
5530
5693
|
return !1;
|
|
@@ -5532,12 +5695,12 @@ var jr = R.create({
|
|
|
5532
5695
|
}
|
|
5533
5696
|
})];
|
|
5534
5697
|
}
|
|
5535
|
-
}),
|
|
5698
|
+
}), Rr = 100, zr = R.create({
|
|
5536
5699
|
name: "imeCommitSpaceGuard",
|
|
5537
5700
|
addProseMirrorPlugins() {
|
|
5538
5701
|
let e = 0;
|
|
5539
|
-
return [new
|
|
5540
|
-
key: new
|
|
5702
|
+
return [new V({
|
|
5703
|
+
key: new H("imeCommitSpaceGuard"),
|
|
5541
5704
|
props: { handleDOMEvents: {
|
|
5542
5705
|
compositionend() {
|
|
5543
5706
|
return e = performance.now(), !1;
|
|
@@ -5547,39 +5710,328 @@ var jr = R.create({
|
|
|
5547
5710
|
},
|
|
5548
5711
|
beforeinput(t, n) {
|
|
5549
5712
|
let r = n;
|
|
5550
|
-
return r.inputType !== "insertText" || r.data !== " " || r.isComposing || performance.now() - e >
|
|
5713
|
+
return r.inputType !== "insertText" || r.data !== " " || r.isComposing || performance.now() - e > Rr ? !1 : (r.preventDefault(), !0);
|
|
5551
5714
|
}
|
|
5552
5715
|
} }
|
|
5553
5716
|
})];
|
|
5554
5717
|
}
|
|
5555
|
-
}),
|
|
5718
|
+
}), Br = R.create({
|
|
5556
5719
|
name: "inlineCodeEnd",
|
|
5557
5720
|
addInputRules() {
|
|
5558
5721
|
let e = this.editor.schema.marks.code;
|
|
5559
|
-
return e ? [
|
|
5722
|
+
return e ? [z({
|
|
5560
5723
|
find: /`([^`]+)`$/,
|
|
5561
5724
|
type: e
|
|
5562
5725
|
})] : [];
|
|
5563
5726
|
}
|
|
5564
|
-
})
|
|
5565
|
-
|
|
5727
|
+
});
|
|
5728
|
+
//#endregion
|
|
5729
|
+
//#region src/editor/extensions/math-utils.ts
|
|
5730
|
+
function Vr(e) {
|
|
5731
|
+
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">").replace(/\n/g, " ");
|
|
5732
|
+
}
|
|
5733
|
+
function Hr(e) {
|
|
5734
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
5735
|
+
}
|
|
5736
|
+
function Ur(e, t) {
|
|
5737
|
+
let n = e ?? "";
|
|
5738
|
+
if (!n.trim()) return "";
|
|
5739
|
+
try {
|
|
5740
|
+
return Ce.renderToString(n, {
|
|
5741
|
+
displayMode: t,
|
|
5742
|
+
throwOnError: !1,
|
|
5743
|
+
strict: "ignore",
|
|
5744
|
+
trust: !1,
|
|
5745
|
+
output: "htmlAndMathml"
|
|
5746
|
+
});
|
|
5747
|
+
} catch {
|
|
5748
|
+
return `<span class="math-fallback">${Hr(n)}</span>`;
|
|
5749
|
+
}
|
|
5750
|
+
}
|
|
5751
|
+
//#endregion
|
|
5752
|
+
//#region src/editor/extensions/math-view.tsx
|
|
5753
|
+
function Wr({ node: e, updateAttributes: t, deleteNode: n, editor: r, selected: i }) {
|
|
5754
|
+
let a = e.type.name === "mathBlock", o = String(e.attrs.latex ?? ""), s = r?.isEditable ?? !0, [c, l] = T(!1), [u, d] = T(o), p = w(null), m = w(!1), h = w(() => {}), g = w(() => {}), _ = C(() => Ur(o, a), [o, a]), v = C(() => Ur(u, a), [u, a]), y = () => {
|
|
5755
|
+
let e = u.trim();
|
|
5756
|
+
if (!e) {
|
|
5757
|
+
l(!1), s && n?.();
|
|
5758
|
+
return;
|
|
5759
|
+
}
|
|
5760
|
+
t({ latex: e }), l(!1);
|
|
5761
|
+
}, b = () => {
|
|
5762
|
+
l(!1), !o && s && n?.();
|
|
5763
|
+
};
|
|
5764
|
+
h.current = y, g.current = b, x(() => {
|
|
5765
|
+
!s || m.current || (m.current = !0, o || l(!0));
|
|
5766
|
+
}, [s, o]), x(() => {
|
|
5767
|
+
if (!c) return;
|
|
5768
|
+
d(o);
|
|
5769
|
+
let e = window.setTimeout(() => {
|
|
5770
|
+
p.current?.focus(), p.current?.select();
|
|
5771
|
+
}, 30), t = (e) => {
|
|
5772
|
+
e.key === "Escape" ? (e.preventDefault(), g.current()) : (e.metaKey || e.ctrlKey) && e.key === "Enter" && (e.preventDefault(), h.current());
|
|
5773
|
+
};
|
|
5774
|
+
return window.addEventListener("keydown", t, !0), () => {
|
|
5775
|
+
window.clearTimeout(e), window.removeEventListener("keydown", t, !0);
|
|
5776
|
+
};
|
|
5777
|
+
}, [c, o]);
|
|
5778
|
+
let S = () => {
|
|
5779
|
+
s && l(!0);
|
|
5780
|
+
};
|
|
5781
|
+
return /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D(P, {
|
|
5782
|
+
as: a ? "div" : "span",
|
|
5783
|
+
className: `math-node ${a ? "math-node--block" : "math-node--inline"}${i ? " is-selected" : ""}`,
|
|
5784
|
+
contentEditable: !1,
|
|
5785
|
+
onMouseDown: (e) => {
|
|
5786
|
+
s && e.preventDefault();
|
|
5787
|
+
},
|
|
5788
|
+
onClick: (e) => {
|
|
5789
|
+
e.preventDefault(), e.stopPropagation(), S();
|
|
5790
|
+
},
|
|
5791
|
+
children: o ? /* @__PURE__ */ D("span", {
|
|
5792
|
+
className: "math-render",
|
|
5793
|
+
dangerouslySetInnerHTML: { __html: _ }
|
|
5794
|
+
}) : /* @__PURE__ */ D("span", {
|
|
5795
|
+
className: "math-placeholder",
|
|
5796
|
+
children: f("editor.math.empty")
|
|
5797
|
+
})
|
|
5798
|
+
}), c && L(/* @__PURE__ */ D("div", {
|
|
5799
|
+
className: "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none",
|
|
5800
|
+
onClick: b,
|
|
5801
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
5802
|
+
children: /* @__PURE__ */ O("div", {
|
|
5803
|
+
className: "w-full max-w-lg mx-4 rounded-xl border border-default-200 dark:border-zinc-700 bg-white dark:bg-zinc-800 p-5 shadow-xl",
|
|
5804
|
+
onClick: (e) => e.stopPropagation(),
|
|
5805
|
+
children: [
|
|
5806
|
+
/* @__PURE__ */ D("div", {
|
|
5807
|
+
className: "mb-3 text-sm font-medium text-default-800 dark:text-zinc-100",
|
|
5808
|
+
children: f(a ? "editor.math.blockTitle" : "editor.math.inlineTitle")
|
|
5809
|
+
}),
|
|
5810
|
+
/* @__PURE__ */ D("textarea", {
|
|
5811
|
+
ref: p,
|
|
5812
|
+
value: u,
|
|
5813
|
+
onChange: (e) => d(e.target.value),
|
|
5814
|
+
rows: a ? 5 : 2,
|
|
5815
|
+
spellCheck: !1,
|
|
5816
|
+
placeholder: f("editor.math.placeholder"),
|
|
5817
|
+
className: "w-full resize-y rounded-lg border border-default-200 dark:border-zinc-700 bg-default-50 dark:bg-zinc-900 px-3 py-2 font-mono text-sm text-default-800 dark:text-zinc-100 outline-none focus:ring-2 focus:ring-qingwu-500/40"
|
|
5818
|
+
}),
|
|
5819
|
+
/* @__PURE__ */ D("div", {
|
|
5820
|
+
className: "math-dialog-preview",
|
|
5821
|
+
children: u.trim() ? /* @__PURE__ */ D("div", { dangerouslySetInnerHTML: { __html: v } }) : /* @__PURE__ */ D("span", {
|
|
5822
|
+
className: "math-placeholder",
|
|
5823
|
+
children: f("editor.math.emptyPreview")
|
|
5824
|
+
})
|
|
5825
|
+
}),
|
|
5826
|
+
/* @__PURE__ */ O("div", {
|
|
5827
|
+
className: "mt-4 flex items-center justify-between gap-3",
|
|
5828
|
+
children: [/* @__PURE__ */ D("span", {
|
|
5829
|
+
className: "text-[11px] text-default-400 dark:text-zinc-500",
|
|
5830
|
+
children: f("editor.math.hint")
|
|
5831
|
+
}), /* @__PURE__ */ O("div", {
|
|
5832
|
+
className: "flex shrink-0 gap-2",
|
|
5833
|
+
children: [/* @__PURE__ */ D("button", {
|
|
5834
|
+
type: "button",
|
|
5835
|
+
className: "px-3 py-1.5 text-xs rounded-lg border border-default-200 dark:border-zinc-600 hover:bg-default-100 dark:hover:bg-zinc-700 transition-colors",
|
|
5836
|
+
onClick: b,
|
|
5837
|
+
children: f("editor.math.cancel")
|
|
5838
|
+
}), /* @__PURE__ */ D("button", {
|
|
5839
|
+
type: "button",
|
|
5840
|
+
className: "px-3 py-1.5 text-xs rounded-lg bg-qingwu-600 hover:bg-qingwu-700 text-white transition-colors",
|
|
5841
|
+
onClick: y,
|
|
5842
|
+
children: f("editor.math.save")
|
|
5843
|
+
})]
|
|
5844
|
+
})]
|
|
5845
|
+
})
|
|
5846
|
+
]
|
|
5847
|
+
})
|
|
5848
|
+
}), document.body)] });
|
|
5849
|
+
}
|
|
5850
|
+
//#endregion
|
|
5851
|
+
//#region src/editor/extensions/math.ts
|
|
5852
|
+
var Gr = /(?:^|[^\\$])\$([^\s$](?:[^$\n]*[^\s$])?)\$$/, Kr = /^\$\$([\s\S]+?)\$\$$/;
|
|
5853
|
+
function qr(e) {
|
|
5854
|
+
return new re({
|
|
5855
|
+
find: Gr,
|
|
5856
|
+
handler: ({ state: t, range: n, match: r }) => {
|
|
5857
|
+
let i = r[1], a = r[0].indexOf("$");
|
|
5858
|
+
if (a < 0) return;
|
|
5859
|
+
let o = n.from + a, s = n.to;
|
|
5860
|
+
o >= s || t.tr.replaceWith(o, s, e.create({ latex: i }));
|
|
5861
|
+
}
|
|
5862
|
+
});
|
|
5863
|
+
}
|
|
5864
|
+
function Jr(e) {
|
|
5865
|
+
return new re({
|
|
5866
|
+
find: Kr,
|
|
5867
|
+
handler: ({ state: t, range: n, match: r }) => {
|
|
5868
|
+
let i = r[1].trim();
|
|
5869
|
+
if (!i) return;
|
|
5870
|
+
let a = t.doc.resolve(n.from), o = a.depth, s = a.before(o), c = a.after(o), l = e.create({ latex: i }), u = t.tr.replaceWith(s, c, l), d = s + l.nodeSize, f = u.doc.resolve(d);
|
|
5871
|
+
(!f.nodeAfter || !f.nodeAfter.isTextblock) && u.insert(d, t.schema.nodes.paragraph.create()), u.setSelection(ae.near(u.doc.resolve(d), 1));
|
|
5872
|
+
}
|
|
5873
|
+
});
|
|
5874
|
+
}
|
|
5875
|
+
function Yr(e, t) {
|
|
5876
|
+
let n = e.src, r = e.pos;
|
|
5877
|
+
if (n.charCodeAt(r) !== 36 || n.charCodeAt(r + 1) === 36) return !1;
|
|
5878
|
+
let i = r + 1;
|
|
5879
|
+
for (; i < n.length;) {
|
|
5880
|
+
let e = n.charCodeAt(i);
|
|
5881
|
+
if (e === 10) return !1;
|
|
5882
|
+
if (e === 36 && n.charCodeAt(i - 1) !== 92) break;
|
|
5883
|
+
i += 1;
|
|
5884
|
+
}
|
|
5885
|
+
if (i >= n.length) return !1;
|
|
5886
|
+
let a = n.slice(r + 1, i);
|
|
5887
|
+
if (!a || /^\s|\s$/.test(a)) return !1;
|
|
5888
|
+
if (!t) {
|
|
5889
|
+
let t = e.push("html_inline", "", 0);
|
|
5890
|
+
t.content = `<span data-type="inline-math" data-latex="${Vr(a)}"></span>`;
|
|
5891
|
+
}
|
|
5892
|
+
return e.pos = i + 1, !0;
|
|
5893
|
+
}
|
|
5894
|
+
function Xr(e, t, n, r) {
|
|
5895
|
+
let i = e.bMarks[t] + e.tShift[t], a = e.eMarks[t];
|
|
5896
|
+
if (i + 1 >= a || e.src.charCodeAt(i) !== 36 || e.src.charCodeAt(i + 1) !== 36) return !1;
|
|
5897
|
+
let o = e.src.slice(i, a).trim(), s = "", c = t + 1;
|
|
5898
|
+
if (o.length > 4 && o.endsWith("$$")) s = o.slice(2, -2);
|
|
5899
|
+
else {
|
|
5900
|
+
let t = [], r = o.slice(2), i = r.endsWith("$$");
|
|
5901
|
+
if (i) s = r.slice(0, -2);
|
|
5902
|
+
else {
|
|
5903
|
+
for (r && t.push(r); c < n; c += 1) {
|
|
5904
|
+
let n = e.bMarks[c] + e.tShift[c], r = e.eMarks[c], a = e.src.slice(n, r), o = a.trimEnd();
|
|
5905
|
+
if (o.endsWith("$$")) {
|
|
5906
|
+
t.push(o.slice(0, -2)), i = !0, c += 1;
|
|
5907
|
+
break;
|
|
5908
|
+
}
|
|
5909
|
+
t.push(a);
|
|
5910
|
+
}
|
|
5911
|
+
if (!i) return !1;
|
|
5912
|
+
s = t.join("\n");
|
|
5913
|
+
}
|
|
5914
|
+
}
|
|
5915
|
+
if (r) return !0;
|
|
5916
|
+
let l = e.push("html_block", "", 0);
|
|
5917
|
+
return l.content = `<div data-type="block-math" data-latex="${Vr(s.trim())}"></div>\n`, e.line = c, !0;
|
|
5918
|
+
}
|
|
5919
|
+
function Zr(e) {
|
|
5920
|
+
e.__qingwuMathReg || (e.__qingwuMathReg = !0, e.inline.ruler.before("backticks", "qingwu_math_inline", Yr), e.block.ruler.before("fence", "qingwu_math_block", Xr, { alt: ["paragraph"] }));
|
|
5921
|
+
}
|
|
5922
|
+
function Qr(e) {
|
|
5923
|
+
return { markdown: {
|
|
5924
|
+
serialize(t, n) {
|
|
5925
|
+
let r = String(n.attrs.latex ?? "");
|
|
5926
|
+
if (!e) {
|
|
5927
|
+
t.write(`$${r}$`);
|
|
5928
|
+
return;
|
|
5929
|
+
}
|
|
5930
|
+
t.ensureNewLine(), t.write("$$"), t.ensureNewLine();
|
|
5931
|
+
for (let e of r.split("\n")) t.write(e), t.ensureNewLine();
|
|
5932
|
+
t.write("$$"), t.closeBlock(n);
|
|
5933
|
+
},
|
|
5934
|
+
parse: { setup(e) {
|
|
5935
|
+
Zr(e);
|
|
5936
|
+
} }
|
|
5937
|
+
} };
|
|
5938
|
+
}
|
|
5939
|
+
var $r = ie.create({
|
|
5940
|
+
name: "mathInline",
|
|
5941
|
+
group: "inline",
|
|
5942
|
+
inline: !0,
|
|
5943
|
+
atom: !0,
|
|
5944
|
+
selectable: !0,
|
|
5945
|
+
addAttributes() {
|
|
5946
|
+
return { latex: {
|
|
5947
|
+
default: "",
|
|
5948
|
+
parseHTML: (e) => e.getAttribute("data-latex") ?? e.textContent ?? ""
|
|
5949
|
+
} };
|
|
5950
|
+
},
|
|
5951
|
+
parseHTML() {
|
|
5952
|
+
return [{ tag: "span[data-type=\"inline-math\"]" }, { tag: "span.math-node--inline" }];
|
|
5953
|
+
},
|
|
5954
|
+
renderHTML({ node: e }) {
|
|
5955
|
+
let t = String(e.attrs.latex ?? ""), n = {
|
|
5956
|
+
"data-type": "inline-math",
|
|
5957
|
+
"data-latex": t,
|
|
5958
|
+
class: "math-node math-node--inline"
|
|
5959
|
+
};
|
|
5960
|
+
if (typeof document > "u") return [
|
|
5961
|
+
"span",
|
|
5962
|
+
n,
|
|
5963
|
+
t
|
|
5964
|
+
];
|
|
5965
|
+
let r = document.createElement("span");
|
|
5966
|
+
for (let [e, t] of Object.entries(n)) r.setAttribute(e, t);
|
|
5967
|
+
return r.innerHTML = Ur(t, !1), r;
|
|
5968
|
+
},
|
|
5969
|
+
addNodeView() {
|
|
5970
|
+
return F(Wr);
|
|
5971
|
+
},
|
|
5972
|
+
addInputRules() {
|
|
5973
|
+
return [qr(this.type)];
|
|
5974
|
+
},
|
|
5975
|
+
addStorage() {
|
|
5976
|
+
return Qr(!1);
|
|
5977
|
+
}
|
|
5978
|
+
}), ei = ie.create({
|
|
5979
|
+
name: "mathBlock",
|
|
5980
|
+
group: "block",
|
|
5981
|
+
atom: !0,
|
|
5982
|
+
selectable: !0,
|
|
5983
|
+
addAttributes() {
|
|
5984
|
+
return { latex: {
|
|
5985
|
+
default: "",
|
|
5986
|
+
parseHTML: (e) => e.getAttribute("data-latex") ?? e.textContent ?? ""
|
|
5987
|
+
} };
|
|
5988
|
+
},
|
|
5989
|
+
parseHTML() {
|
|
5990
|
+
return [{ tag: "div[data-type=\"block-math\"]" }, { tag: "div.math-node--block" }];
|
|
5991
|
+
},
|
|
5992
|
+
renderHTML({ node: e }) {
|
|
5993
|
+
let t = String(e.attrs.latex ?? ""), n = {
|
|
5994
|
+
"data-type": "block-math",
|
|
5995
|
+
"data-latex": t,
|
|
5996
|
+
class: "math-node math-node--block"
|
|
5997
|
+
};
|
|
5998
|
+
if (typeof document > "u") return [
|
|
5999
|
+
"div",
|
|
6000
|
+
n,
|
|
6001
|
+
t
|
|
6002
|
+
];
|
|
6003
|
+
let r = document.createElement("div");
|
|
6004
|
+
for (let [e, t] of Object.entries(n)) r.setAttribute(e, t);
|
|
6005
|
+
return r.innerHTML = Ur(t, !0), r;
|
|
6006
|
+
},
|
|
6007
|
+
addNodeView() {
|
|
6008
|
+
return F(Wr);
|
|
6009
|
+
},
|
|
6010
|
+
addInputRules() {
|
|
6011
|
+
return [Jr(this.type)];
|
|
6012
|
+
},
|
|
6013
|
+
addStorage() {
|
|
6014
|
+
return Qr(!0);
|
|
6015
|
+
}
|
|
6016
|
+
}), ti = /\.(png|jpe?g|gif|webp|bmp|svg|avif)(\?|#|$)/i, ni = /\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|#|$)/i, ri = /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|#|$)/i;
|
|
6017
|
+
function ii(e) {
|
|
5566
6018
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
5567
6019
|
}
|
|
5568
|
-
function
|
|
6020
|
+
function ai(e) {
|
|
5569
6021
|
let t = e.trim().replace(/\\/g, "/");
|
|
5570
6022
|
return t.split("/").pop() || t;
|
|
5571
6023
|
}
|
|
5572
|
-
function
|
|
6024
|
+
function oi(e, t) {
|
|
5573
6025
|
let n = e.src.slice(e.pos), r = /^!\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !0;
|
|
5574
6026
|
if (r || (r = /^\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !1), !r) return !1;
|
|
5575
6027
|
let a = r[1].trim(), o = r[2]?.trim();
|
|
5576
6028
|
if (!t) {
|
|
5577
|
-
let t = o ||
|
|
6029
|
+
let t = o || ai(a);
|
|
5578
6030
|
if (i) {
|
|
5579
6031
|
let n = "";
|
|
5580
|
-
if (
|
|
5581
|
-
else if (
|
|
5582
|
-
else if (
|
|
6032
|
+
if (ti.test(a) || /^data:image\//i.test(a)) n = `<img src="${ii(a)}" alt="${ii(t)}">`;
|
|
6033
|
+
else if (ni.test(a) || /^data:video\//i.test(a)) n = `<div data-video-embed src="${ii(a)}"></div>`;
|
|
6034
|
+
else if (ri.test(a) || /^data:audio\//i.test(a)) n = `<audio src="${ii(a)}"></audio>`;
|
|
5583
6035
|
else {
|
|
5584
6036
|
let n = e.push("link_open", "a", 1);
|
|
5585
6037
|
n.attrs = [["href", a]];
|
|
@@ -5597,14 +6049,14 @@ function Br(e, t) {
|
|
|
5597
6049
|
}
|
|
5598
6050
|
return e.pos += r[0].length, !0;
|
|
5599
6051
|
}
|
|
5600
|
-
var
|
|
6052
|
+
var si = R.create({
|
|
5601
6053
|
name: "obsidianMarkdown",
|
|
5602
6054
|
addStorage() {
|
|
5603
6055
|
return { markdown: { parse: { setup(e) {
|
|
5604
|
-
e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed",
|
|
6056
|
+
e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed", oi));
|
|
5605
6057
|
} } } };
|
|
5606
6058
|
}
|
|
5607
|
-
}),
|
|
6059
|
+
}), ci = R.create({
|
|
5608
6060
|
name: "qingwuUI",
|
|
5609
6061
|
addStorage() {
|
|
5610
6062
|
return {};
|
|
@@ -5612,7 +6064,7 @@ var Vr = R.create({
|
|
|
5612
6064
|
});
|
|
5613
6065
|
//#endregion
|
|
5614
6066
|
//#region src/editor/utils/render-probe.ts
|
|
5615
|
-
function
|
|
6067
|
+
function li(e, t) {
|
|
5616
6068
|
return new Promise((n) => {
|
|
5617
6069
|
if (typeof Image != "function") return n(!0);
|
|
5618
6070
|
let r = new Image(), i = !1, a = setTimeout(() => o(!1), t), o = (e) => {
|
|
@@ -5621,14 +6073,14 @@ function Ur(e, t) {
|
|
|
5621
6073
|
r.onload = () => o(!0), r.onerror = () => o(!1), r.src = e;
|
|
5622
6074
|
});
|
|
5623
6075
|
}
|
|
5624
|
-
async function
|
|
5625
|
-
if (await
|
|
6076
|
+
async function ui(e, t = 8e3) {
|
|
6077
|
+
if (await li(e, t)) return !0;
|
|
5626
6078
|
try {
|
|
5627
6079
|
let r = await n(e);
|
|
5628
6080
|
if (!r) return !1;
|
|
5629
6081
|
let i = await fetch(e, { headers: r });
|
|
5630
6082
|
if (!i.ok) return !1;
|
|
5631
|
-
let a = URL.createObjectURL(await i.blob()), o = await
|
|
6083
|
+
let a = URL.createObjectURL(await i.blob()), o = await li(a, t);
|
|
5632
6084
|
return URL.revokeObjectURL(a), o;
|
|
5633
6085
|
} catch {
|
|
5634
6086
|
return !1;
|
|
@@ -5636,7 +6088,7 @@ async function Wr(e, t = 8e3) {
|
|
|
5636
6088
|
}
|
|
5637
6089
|
//#endregion
|
|
5638
6090
|
//#region src/editor/utils/resolve-local-media.ts
|
|
5639
|
-
function
|
|
6091
|
+
function di() {
|
|
5640
6092
|
return {
|
|
5641
6093
|
uploaded: 0,
|
|
5642
6094
|
sessionOnly: 0,
|
|
@@ -5646,10 +6098,10 @@ function Gr() {
|
|
|
5646
6098
|
readFailed: []
|
|
5647
6099
|
};
|
|
5648
6100
|
}
|
|
5649
|
-
function
|
|
6101
|
+
function fi(e, t) {
|
|
5650
6102
|
e.uploaded += t.uploaded, e.sessionOnly += t.sessionOnly, e.limitRejected += t.limitRejected, e.renderFailed += t.renderFailed, e.missing.push(...t.missing), e.readFailed.push(...t.readFailed);
|
|
5651
6103
|
}
|
|
5652
|
-
function
|
|
6104
|
+
function pi(e, t, n, r) {
|
|
5653
6105
|
let { state: i } = e, a = [];
|
|
5654
6106
|
if (i.doc.descendants((e, n) => {
|
|
5655
6107
|
e.attrs?.src === t && a.push(n);
|
|
@@ -5665,7 +6117,7 @@ function qr(e, t, n, r) {
|
|
|
5665
6117
|
}
|
|
5666
6118
|
return e.dispatch(o), !0;
|
|
5667
6119
|
}
|
|
5668
|
-
function
|
|
6120
|
+
function mi(e, t, n) {
|
|
5669
6121
|
let { state: r } = e, i = r.schema.marks.link;
|
|
5670
6122
|
if (!i) return !1;
|
|
5671
6123
|
let a = [];
|
|
@@ -5683,7 +6135,7 @@ function Jr(e, t, n) {
|
|
|
5683
6135
|
}));
|
|
5684
6136
|
return e.dispatch(o), !0;
|
|
5685
6137
|
}
|
|
5686
|
-
function
|
|
6138
|
+
function hi(e) {
|
|
5687
6139
|
let t = /* @__PURE__ */ new Map();
|
|
5688
6140
|
for (let n of e) {
|
|
5689
6141
|
let e = t.get(n.normalized);
|
|
@@ -5691,36 +6143,36 @@ function Yr(e) {
|
|
|
5691
6143
|
}
|
|
5692
6144
|
return Array.from(t.values());
|
|
5693
6145
|
}
|
|
5694
|
-
async function
|
|
6146
|
+
async function gi(e, t, n, r) {
|
|
5695
6147
|
if (n.length === 0) return "sessionOnly";
|
|
5696
|
-
let i = n[0], a =
|
|
6148
|
+
let i = n[0], a = pn(t);
|
|
5697
6149
|
if (a) {
|
|
5698
|
-
let t =
|
|
6150
|
+
let t = mn(e.state.doc, r, a);
|
|
5699
6151
|
if (t) return Z(`${i.basename}:${t}`, "error"), "limitRejected";
|
|
5700
6152
|
}
|
|
5701
6153
|
let s = n.filter((e) => !e.isLink), c = n.filter((e) => e.isLink);
|
|
5702
6154
|
if (s.length === 0) try {
|
|
5703
6155
|
let t = await o().upload(r, "editor"), n = !1;
|
|
5704
|
-
for (let r of c)
|
|
6156
|
+
for (let r of c) mi(e, r.src, t) && (n = !0);
|
|
5705
6157
|
return n ? "uploaded" : "sessionOnly";
|
|
5706
6158
|
} catch (e) {
|
|
5707
6159
|
return console.error(`本地附件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), "sessionOnly";
|
|
5708
6160
|
}
|
|
5709
6161
|
let l = URL.createObjectURL(r), u = !1;
|
|
5710
|
-
for (let t of s)
|
|
6162
|
+
for (let t of s) pi(e, t.src, l, r.size) && (u = !0);
|
|
5711
6163
|
let d;
|
|
5712
6164
|
try {
|
|
5713
6165
|
d = await o().upload(r, "editor");
|
|
5714
6166
|
} catch (e) {
|
|
5715
6167
|
return console.error(`本地文件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), URL.revokeObjectURL(l), "sessionOnly";
|
|
5716
6168
|
}
|
|
5717
|
-
URL.revokeObjectURL(l), u &&
|
|
5718
|
-
for (let t of c)
|
|
5719
|
-
return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await
|
|
6169
|
+
URL.revokeObjectURL(l), u && pi(e, l, d, r.size);
|
|
6170
|
+
for (let t of c) mi(e, t.src, d);
|
|
6171
|
+
return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await ui(d) ? "uploaded" : "renderFailed" : "uploaded";
|
|
5720
6172
|
}
|
|
5721
|
-
function
|
|
6173
|
+
function _i(e, t) {
|
|
5722
6174
|
let n = [], r = [];
|
|
5723
|
-
for (let i of
|
|
6175
|
+
for (let i of hi(e)) {
|
|
5724
6176
|
let e = i[0], a = t.get(e.basename);
|
|
5725
6177
|
a ? (n.push({
|
|
5726
6178
|
refs: i,
|
|
@@ -5732,30 +6184,30 @@ function Zr(e, t) {
|
|
|
5732
6184
|
unmatched: r
|
|
5733
6185
|
};
|
|
5734
6186
|
}
|
|
5735
|
-
async function
|
|
5736
|
-
let i =
|
|
5737
|
-
for (let a of
|
|
5738
|
-
let n = a[0], { file: o, readError: s } = await
|
|
6187
|
+
async function vi(e, t, n, r) {
|
|
6188
|
+
let i = di();
|
|
6189
|
+
for (let a of hi(n)) {
|
|
6190
|
+
let n = a[0], { file: o, readError: s } = await Dr(r, n.src);
|
|
5739
6191
|
if (!o) {
|
|
5740
6192
|
s ? (console.warn(`本地文件「${n.basename}」在所选文件夹中找到但读取失败:`, s), i.readFailed.push(n)) : (console.warn(`本地文件「${n.basename}」未在所选文件夹「${r.name}」中找到`), i.missing.push(n));
|
|
5741
6193
|
continue;
|
|
5742
6194
|
}
|
|
5743
|
-
let c = await
|
|
6195
|
+
let c = await gi(e, t, a, o);
|
|
5744
6196
|
i[c]++;
|
|
5745
6197
|
}
|
|
5746
6198
|
return i;
|
|
5747
6199
|
}
|
|
5748
|
-
function
|
|
6200
|
+
function yi(e) {
|
|
5749
6201
|
let t = e.map((e) => e.basename);
|
|
5750
6202
|
return t.length <= 3 ? t.join("、") : `${t.slice(0, 3).join("、")} 等 ${t.length} 个文件`;
|
|
5751
6203
|
}
|
|
5752
|
-
function
|
|
6204
|
+
function bi(e) {
|
|
5753
6205
|
let t = [];
|
|
5754
|
-
if (e.uploaded > 0 && t.push(`${e.uploaded} 个已上传至存储`), e.sessionOnly > 0 && t.push(`${e.sessionOnly} 个仅本次会话可见(未配置存储或上传失败)`), e.limitRejected > 0 && t.push(`${e.limitRejected} 个超出大小限制`), e.renderFailed > 0 && t.push(`${e.renderFailed} 个上传成功但页面渲染失败(存储 URL 无法在浏览器访问/解码)`), e.readFailed.length > 0 && t.push(`${e.readFailed.length} 个找到但读取失败:${
|
|
6206
|
+
if (e.uploaded > 0 && t.push(`${e.uploaded} 个已上传至存储`), e.sessionOnly > 0 && t.push(`${e.sessionOnly} 个仅本次会话可见(未配置存储或上传失败)`), e.limitRejected > 0 && t.push(`${e.limitRejected} 个超出大小限制`), e.renderFailed > 0 && t.push(`${e.renderFailed} 个上传成功但页面渲染失败(存储 URL 无法在浏览器访问/解码)`), e.readFailed.length > 0 && t.push(`${e.readFailed.length} 个找到但读取失败:${yi(e.readFailed)}(若在 OneDrive / WPS 云盘等同步目录,请右键文件选择「始终保留在此设备」后重试)`), e.missing.length > 0 && t.push(`${e.missing.length} 个未能获取:${yi(e.missing)}(可把文件直接拖进编辑器上传)`), t.length === 0) return;
|
|
5755
6207
|
let n = e.uploaded > 0 && e.renderFailed === 0 && e.missing.length === 0 && e.readFailed.length === 0;
|
|
5756
6208
|
Z(`本地文件解析完成:${t.join(";")}`, n ? "success" : "info");
|
|
5757
6209
|
}
|
|
5758
|
-
function
|
|
6210
|
+
function xi(e) {
|
|
5759
6211
|
return new Promise((t) => {
|
|
5760
6212
|
let n = document.createElement("div");
|
|
5761
6213
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5782,7 +6234,7 @@ function ti(e) {
|
|
|
5782
6234
|
u.type = "button", u.className = "px-3 py-1.5 text-xs rounded-lg bg-blue-500 hover:bg-blue-600 text-white", u.textContent = "选择文件夹…", u.addEventListener("click", () => s("pick")), o.append(l, u), r.append(i, a, o), n.appendChild(r), document.addEventListener("keydown", c), document.body.appendChild(n);
|
|
5783
6235
|
});
|
|
5784
6236
|
}
|
|
5785
|
-
function
|
|
6237
|
+
function Si(e) {
|
|
5786
6238
|
let t = document.createElement("div");
|
|
5787
6239
|
t.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
5788
6240
|
let n = document.createElement("div");
|
|
@@ -5804,7 +6256,7 @@ function ni(e) {
|
|
|
5804
6256
|
let c = document.createElement("button");
|
|
5805
6257
|
c.type = "button", c.className = "px-3 py-1.5 text-xs rounded-lg bg-blue-500 hover:bg-blue-600 text-white", c.textContent = "知道了", c.addEventListener("click", o), a.append(c), n.append(r, i, a), t.appendChild(n), document.addEventListener("keydown", s), document.body.appendChild(t);
|
|
5806
6258
|
}
|
|
5807
|
-
function
|
|
6259
|
+
function Ci(e) {
|
|
5808
6260
|
return new Promise((t) => {
|
|
5809
6261
|
let n = document.createElement("div");
|
|
5810
6262
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5830,8 +6282,8 @@ function ri(e) {
|
|
|
5830
6282
|
u.type = "button", u.className = "px-3 py-1.5 text-xs rounded-lg bg-blue-500 hover:bg-blue-600 text-white", u.textContent = "选择文件…", u.addEventListener("click", () => s("pick")), o.append(l, u), r.append(i, a, o), n.appendChild(r), document.addEventListener("keydown", c), document.body.appendChild(n);
|
|
5831
6283
|
});
|
|
5832
6284
|
}
|
|
5833
|
-
async function
|
|
5834
|
-
let r =
|
|
6285
|
+
async function wi(e, t, n) {
|
|
6286
|
+
let r = di(), i = hi(n), a = await wr();
|
|
5835
6287
|
if (!a) {
|
|
5836
6288
|
for (let e of i) r.missing.push(e[0]);
|
|
5837
6289
|
return r;
|
|
@@ -5844,14 +6296,14 @@ async function ii(e, t, n) {
|
|
|
5844
6296
|
continue;
|
|
5845
6297
|
}
|
|
5846
6298
|
o.delete(i.basename);
|
|
5847
|
-
let s = await
|
|
6299
|
+
let s = await gi(e, t, n, a);
|
|
5848
6300
|
r[s]++;
|
|
5849
6301
|
}
|
|
5850
6302
|
return r;
|
|
5851
6303
|
}
|
|
5852
6304
|
//#endregion
|
|
5853
6305
|
//#region src/editor/extensions/relative-media.ts
|
|
5854
|
-
var
|
|
6306
|
+
var Ti = R.create({
|
|
5855
6307
|
name: "relativeMedia",
|
|
5856
6308
|
addStorage() {
|
|
5857
6309
|
return {
|
|
@@ -5861,42 +6313,42 @@ var ai = R.create({
|
|
|
5861
6313
|
},
|
|
5862
6314
|
addProseMirrorPlugins() {
|
|
5863
6315
|
let e = this.editor, t = this.storage, n = !1, r = null, i = async (n, i) => {
|
|
5864
|
-
let a = e.view, o =
|
|
6316
|
+
let a = e.view, o = di(), { matched: s, unmatched: c } = _i(n, t.clipboardFiles);
|
|
5865
6317
|
for (let { refs: t, file: n } of s) {
|
|
5866
|
-
let r = await
|
|
6318
|
+
let r = await gi(a, e, t, n);
|
|
5867
6319
|
o[r]++;
|
|
5868
6320
|
}
|
|
5869
6321
|
if (c.length > 0) {
|
|
5870
|
-
let t =
|
|
5871
|
-
if (
|
|
6322
|
+
let t = hi(c).length;
|
|
6323
|
+
if (xr()) {
|
|
5872
6324
|
let n = i ?? null;
|
|
5873
|
-
if (n || (await
|
|
5874
|
-
r = n,
|
|
6325
|
+
if (n || (await xi(t) === "pick" ? (n = await Sr(), n || Z("没有选择文件夹。本地文件暂以占位显示,稍后可直接把文件拖进编辑器上传", "info")) : Z("已选择稍后处理。本地文件暂以占位显示,可直接把文件拖进编辑器上传", "info")), n) {
|
|
6326
|
+
r = n, fi(o, await vi(a, e, c, n));
|
|
5875
6327
|
let t = [...o.missing, ...o.readFailed];
|
|
5876
|
-
if (t.length > 0 &&
|
|
5877
|
-
let n = await
|
|
5878
|
-
|
|
6328
|
+
if (t.length > 0 && Cr() && await Ci(t.map((e) => e.basename)) === "pick") {
|
|
6329
|
+
let n = await wi(a, e, t);
|
|
6330
|
+
fi(o, n), o.missing = n.missing, o.readFailed = [];
|
|
5879
6331
|
}
|
|
5880
6332
|
}
|
|
5881
|
-
} else
|
|
6333
|
+
} else Si(t);
|
|
5882
6334
|
}
|
|
5883
|
-
|
|
6335
|
+
bi(o);
|
|
5884
6336
|
}, o = () => {
|
|
5885
6337
|
if (!e || e.isDestroyed || t.pausedUntilPaste) return;
|
|
5886
|
-
let o = a(), s =
|
|
6338
|
+
let o = a(), s = kr(e.state.doc, o);
|
|
5887
6339
|
if (s.length === 0 || n) return;
|
|
5888
6340
|
n = !0;
|
|
5889
6341
|
let c = new Set(s.map((e) => e.src));
|
|
5890
6342
|
i(s).then(() => {
|
|
5891
6343
|
if (e.isDestroyed) return;
|
|
5892
|
-
let t =
|
|
6344
|
+
let t = kr(e.state.doc, o).filter((e) => !c.has(e.src));
|
|
5893
6345
|
if (t.length !== 0) return i(t, r);
|
|
5894
6346
|
}).finally(() => {
|
|
5895
|
-
n = !1, !(!e || e.isDestroyed) && (t.pausedUntilPaste =
|
|
6347
|
+
n = !1, !(!e || e.isDestroyed) && (t.pausedUntilPaste = kr(e.state.doc, o).length > 0);
|
|
5896
6348
|
});
|
|
5897
6349
|
};
|
|
5898
|
-
return [new
|
|
5899
|
-
key: new
|
|
6350
|
+
return [new V({
|
|
6351
|
+
key: new H("relativeMedia"),
|
|
5900
6352
|
props: { handlePaste(e, n) {
|
|
5901
6353
|
let r = n.clipboardData?.files;
|
|
5902
6354
|
return t.clipboardFiles = new Map(Array.from(r ?? []).map((e) => [e.name.toLowerCase(), e])), t.pausedUntilPaste = !1, !1;
|
|
@@ -5906,18 +6358,18 @@ var ai = R.create({
|
|
|
5906
6358
|
}
|
|
5907
6359
|
})];
|
|
5908
6360
|
}
|
|
5909
|
-
}),
|
|
5910
|
-
function
|
|
6361
|
+
}), Ei = new H("slashCommand");
|
|
6362
|
+
function Di(e) {
|
|
5911
6363
|
return R.create({
|
|
5912
6364
|
name: "slashCommand",
|
|
5913
6365
|
addProseMirrorPlugins() {
|
|
5914
6366
|
let t = {
|
|
5915
6367
|
char: "/",
|
|
5916
|
-
pluginKey:
|
|
6368
|
+
pluginKey: Ei,
|
|
5917
6369
|
findSuggestionMatch: (e) => {
|
|
5918
6370
|
let { $position: t } = e;
|
|
5919
6371
|
for (let e = t.depth; e >= 0; e--) if (t.node(e).type.name === "codeBlock") return null;
|
|
5920
|
-
return t.marks().some((e) => e.type.name === "code") ? null :
|
|
6372
|
+
return t.marks().some((e) => e.type.name === "code") ? null : Ee(e);
|
|
5921
6373
|
},
|
|
5922
6374
|
allow: ({ editor: e, state: t }) => {
|
|
5923
6375
|
if (!e.isEditable) return !1;
|
|
@@ -5999,7 +6451,7 @@ function si(e) {
|
|
|
5999
6451
|
if (e.key === "Escape") {
|
|
6000
6452
|
e.preventDefault();
|
|
6001
6453
|
let t = a?.view;
|
|
6002
|
-
t &&
|
|
6454
|
+
t && Te(t, Ei);
|
|
6003
6455
|
}
|
|
6004
6456
|
});
|
|
6005
6457
|
}
|
|
@@ -6017,7 +6469,7 @@ function si(e) {
|
|
|
6017
6469
|
if (!e || e.style.display === "none" || n.target instanceof Node && e.contains(n.target) || t) return;
|
|
6018
6470
|
let r = a?.view;
|
|
6019
6471
|
r && (t = !0, window.setTimeout(() => {
|
|
6020
|
-
t = !1, e?.style.display !== "none" &&
|
|
6472
|
+
t = !1, e?.style.display !== "none" && Te(r, Ei);
|
|
6021
6473
|
}, 0));
|
|
6022
6474
|
}, document.addEventListener("mousedown", o, !0), document.addEventListener("touchstart", o, !0);
|
|
6023
6475
|
}
|
|
@@ -6041,11 +6493,11 @@ function si(e) {
|
|
|
6041
6493
|
};
|
|
6042
6494
|
}
|
|
6043
6495
|
};
|
|
6044
|
-
return [
|
|
6496
|
+
return [we({
|
|
6045
6497
|
editor: this.editor,
|
|
6046
6498
|
...t
|
|
6047
|
-
}), new
|
|
6048
|
-
key: new
|
|
6499
|
+
}), new V({
|
|
6500
|
+
key: new H("slashCodeBlockGuard"),
|
|
6049
6501
|
appendTransaction: (e, t, n) => {
|
|
6050
6502
|
let { $from: r } = n.selection, i = !1;
|
|
6051
6503
|
for (let e = r.depth; e >= 0; e--) if (r.node(e).type.name === "codeBlock") {
|
|
@@ -6053,14 +6505,14 @@ function si(e) {
|
|
|
6053
6505
|
break;
|
|
6054
6506
|
}
|
|
6055
6507
|
if (!i && !r.marks().some((e) => e.type.name === "code")) return null;
|
|
6056
|
-
let a =
|
|
6057
|
-
return a && a.active ? n.tr.setMeta(
|
|
6508
|
+
let a = Ei.getState(n);
|
|
6509
|
+
return a && a.active ? n.tr.setMeta(Ei, { exit: !0 }) : null;
|
|
6058
6510
|
}
|
|
6059
6511
|
})];
|
|
6060
6512
|
}
|
|
6061
6513
|
});
|
|
6062
6514
|
}
|
|
6063
|
-
function
|
|
6515
|
+
function Oi(e, t) {
|
|
6064
6516
|
return [
|
|
6065
6517
|
{
|
|
6066
6518
|
title: e("editor.slash.heading1"),
|
|
@@ -6134,6 +6586,24 @@ function ci(e, t) {
|
|
|
6134
6586
|
icon: "—",
|
|
6135
6587
|
command: ({ editor: e }) => e.chain().focus().setHorizontalRule().run()
|
|
6136
6588
|
},
|
|
6589
|
+
{
|
|
6590
|
+
title: e("editor.slash.mathInline"),
|
|
6591
|
+
description: e("editor.slash.mathInlineDesc"),
|
|
6592
|
+
icon: "∑",
|
|
6593
|
+
command: ({ editor: e }) => e.chain().focus().insertContent({
|
|
6594
|
+
type: "mathInline",
|
|
6595
|
+
attrs: { latex: "" }
|
|
6596
|
+
}).run()
|
|
6597
|
+
},
|
|
6598
|
+
{
|
|
6599
|
+
title: e("editor.slash.mathBlock"),
|
|
6600
|
+
description: e("editor.slash.mathBlockDesc"),
|
|
6601
|
+
icon: "∫",
|
|
6602
|
+
command: ({ editor: e }) => e.chain().focus().insertContent({
|
|
6603
|
+
type: "mathBlock",
|
|
6604
|
+
attrs: { latex: "" }
|
|
6605
|
+
}).run()
|
|
6606
|
+
},
|
|
6137
6607
|
{
|
|
6138
6608
|
title: e("editor.slash.image"),
|
|
6139
6609
|
description: e("editor.slash.imageDesc"),
|
|
@@ -6159,7 +6629,7 @@ function ci(e, t) {
|
|
|
6159
6629
|
n.type = "file", n.accept = "audio/*", n.onchange = async () => {
|
|
6160
6630
|
let r = n.files?.[0];
|
|
6161
6631
|
if (!r) return;
|
|
6162
|
-
let i =
|
|
6632
|
+
let i = pn(e) ?? t, a = i ? mn(e.state.doc, r, i) : null;
|
|
6163
6633
|
if (a) {
|
|
6164
6634
|
Z(a);
|
|
6165
6635
|
return;
|
|
@@ -6169,7 +6639,7 @@ function ci(e, t) {
|
|
|
6169
6639
|
name: r.name,
|
|
6170
6640
|
size: r.size
|
|
6171
6641
|
});
|
|
6172
|
-
s && (e.chain().focus().insertContent(s).run(), await
|
|
6642
|
+
s && (e.chain().focus().insertContent(s).run(), await Fr(e.view, r, o));
|
|
6173
6643
|
}, n.click();
|
|
6174
6644
|
}
|
|
6175
6645
|
},
|
|
@@ -6182,7 +6652,7 @@ function ci(e, t) {
|
|
|
6182
6652
|
n.type = "file", n.accept = "*/*", n.multiple = !0, n.onchange = async () => {
|
|
6183
6653
|
let r = n.files;
|
|
6184
6654
|
if (!(!r || r.length === 0)) for (let n of Array.from(r)) {
|
|
6185
|
-
let r =
|
|
6655
|
+
let r = pn(e) ?? t, i = r ? mn(e.state.doc, n, r) : null;
|
|
6186
6656
|
if (i) {
|
|
6187
6657
|
Z(i);
|
|
6188
6658
|
continue;
|
|
@@ -6199,7 +6669,7 @@ function ci(e, t) {
|
|
|
6199
6669
|
} catch {
|
|
6200
6670
|
continue;
|
|
6201
6671
|
}
|
|
6202
|
-
await
|
|
6672
|
+
await Fr(e.view, n, a);
|
|
6203
6673
|
}
|
|
6204
6674
|
}
|
|
6205
6675
|
}, n.click();
|
|
@@ -6209,9 +6679,9 @@ function ci(e, t) {
|
|
|
6209
6679
|
}
|
|
6210
6680
|
//#endregion
|
|
6211
6681
|
//#region src/editor/extensions/index.ts
|
|
6212
|
-
var
|
|
6682
|
+
var ki = W.extend({
|
|
6213
6683
|
addNodeView() {
|
|
6214
|
-
return
|
|
6684
|
+
return F(Tn);
|
|
6215
6685
|
},
|
|
6216
6686
|
addAttributes() {
|
|
6217
6687
|
return {
|
|
@@ -6234,7 +6704,7 @@ var li = U.extend({
|
|
|
6234
6704
|
};
|
|
6235
6705
|
}
|
|
6236
6706
|
});
|
|
6237
|
-
function
|
|
6707
|
+
function Ai(e = {}) {
|
|
6238
6708
|
return [
|
|
6239
6709
|
K.configure({
|
|
6240
6710
|
codeBlock: !1,
|
|
@@ -6243,104 +6713,106 @@ function ui(e = {}) {
|
|
|
6243
6713
|
link: !1
|
|
6244
6714
|
}),
|
|
6245
6715
|
G,
|
|
6246
|
-
|
|
6716
|
+
se.configure({
|
|
6247
6717
|
openOnClick: !0,
|
|
6248
6718
|
HTMLAttributes: {
|
|
6249
6719
|
rel: "noopener noreferrer",
|
|
6250
6720
|
target: "_blank"
|
|
6251
6721
|
}
|
|
6252
6722
|
}),
|
|
6253
|
-
|
|
6723
|
+
ki.configure({
|
|
6254
6724
|
inline: !1,
|
|
6255
6725
|
allowBase64: !0
|
|
6256
6726
|
}),
|
|
6257
6727
|
ge,
|
|
6258
6728
|
he.configure({ nested: !0 }),
|
|
6259
|
-
|
|
6729
|
+
le.configure({ multicolor: !0 }),
|
|
6260
6730
|
_e,
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6731
|
+
q,
|
|
6732
|
+
ce.configure(e.maxLength ? { limit: e.maxLength } : {}),
|
|
6733
|
+
ue,
|
|
6734
|
+
Br,
|
|
6735
|
+
$r,
|
|
6736
|
+
ei,
|
|
6737
|
+
pr,
|
|
6738
|
+
fe.configure({ resizable: !0 }),
|
|
6267
6739
|
me,
|
|
6268
|
-
|
|
6740
|
+
J,
|
|
6269
6741
|
pe,
|
|
6270
6742
|
ve.configure({
|
|
6271
6743
|
html: !0,
|
|
6272
6744
|
transformPastedText: !0,
|
|
6273
6745
|
transformCopiedText: !1
|
|
6274
6746
|
}),
|
|
6275
|
-
|
|
6276
|
-
|
|
6747
|
+
de.configure({ placeholder: e.placeholder || "输入 '/' 打开菜单…" }),
|
|
6748
|
+
Di(() => Oi((e) => f(e), {
|
|
6277
6749
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
6278
6750
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
6279
6751
|
})),
|
|
6280
|
-
|
|
6752
|
+
Lr.configure({
|
|
6281
6753
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
6282
6754
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
6283
6755
|
}),
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6756
|
+
Ti,
|
|
6757
|
+
si,
|
|
6758
|
+
At,
|
|
6759
|
+
zr,
|
|
6760
|
+
ci,
|
|
6761
|
+
Xn,
|
|
6762
|
+
Un,
|
|
6763
|
+
Bn
|
|
6292
6764
|
];
|
|
6293
6765
|
}
|
|
6294
6766
|
//#endregion
|
|
6295
6767
|
//#region src/editor/extensions/bubble-menu.tsx
|
|
6296
|
-
var
|
|
6297
|
-
function
|
|
6298
|
-
|
|
6768
|
+
var ji = "https://www.bing.com/search?q={query}";
|
|
6769
|
+
function Mi(e) {
|
|
6770
|
+
ji = e;
|
|
6299
6771
|
}
|
|
6300
|
-
function
|
|
6301
|
-
return
|
|
6772
|
+
function Ni() {
|
|
6773
|
+
return ji;
|
|
6302
6774
|
}
|
|
6303
|
-
function
|
|
6775
|
+
function Pi(e) {
|
|
6304
6776
|
return [
|
|
6305
6777
|
{
|
|
6306
6778
|
key: "bold",
|
|
6307
6779
|
label: e("editor.bubble.bold"),
|
|
6308
|
-
icon: /* @__PURE__ */ D(
|
|
6780
|
+
icon: /* @__PURE__ */ D(Nt, {}),
|
|
6309
6781
|
isActive: (e) => e.isActive("bold"),
|
|
6310
6782
|
command: (e) => e.isEditable && e.chain().focus().toggleBold().run()
|
|
6311
6783
|
},
|
|
6312
6784
|
{
|
|
6313
6785
|
key: "italic",
|
|
6314
6786
|
label: e("editor.bubble.italic"),
|
|
6315
|
-
icon: /* @__PURE__ */ D(
|
|
6787
|
+
icon: /* @__PURE__ */ D(Pt, {}),
|
|
6316
6788
|
isActive: (e) => e.isActive("italic"),
|
|
6317
6789
|
command: (e) => e.isEditable && e.chain().focus().toggleItalic().run()
|
|
6318
6790
|
},
|
|
6319
6791
|
{
|
|
6320
6792
|
key: "underline",
|
|
6321
6793
|
label: e("editor.bubble.underline"),
|
|
6322
|
-
icon: /* @__PURE__ */ D(
|
|
6794
|
+
icon: /* @__PURE__ */ D(Ft, {}),
|
|
6323
6795
|
isActive: (e) => e.isActive("underline"),
|
|
6324
6796
|
command: (e) => e.isEditable && e.chain().focus().toggleUnderline().run()
|
|
6325
6797
|
},
|
|
6326
6798
|
{
|
|
6327
6799
|
key: "strikethrough",
|
|
6328
6800
|
label: e("editor.bubble.strikethrough"),
|
|
6329
|
-
icon: /* @__PURE__ */ D(
|
|
6801
|
+
icon: /* @__PURE__ */ D(It, {}),
|
|
6330
6802
|
isActive: (e) => e.isActive("strike"),
|
|
6331
6803
|
command: (e) => e.isEditable && e.chain().focus().toggleStrike().run()
|
|
6332
6804
|
},
|
|
6333
6805
|
{
|
|
6334
6806
|
key: "code",
|
|
6335
6807
|
label: e("editor.bubble.emphasis"),
|
|
6336
|
-
icon: /* @__PURE__ */ D(
|
|
6808
|
+
icon: /* @__PURE__ */ D(Lt, {}),
|
|
6337
6809
|
isActive: (e) => e.isActive("code"),
|
|
6338
6810
|
command: (e) => e.isEditable && e.chain().focus().toggleCode().run()
|
|
6339
6811
|
},
|
|
6340
6812
|
{
|
|
6341
6813
|
key: "highlight",
|
|
6342
6814
|
label: e("editor.bubble.highlight"),
|
|
6343
|
-
icon: /* @__PURE__ */ D(
|
|
6815
|
+
icon: /* @__PURE__ */ D(Rt, {}),
|
|
6344
6816
|
more: !0,
|
|
6345
6817
|
isActive: (e) => e.isActive("highlight"),
|
|
6346
6818
|
command: () => {}
|
|
@@ -6348,7 +6820,7 @@ function mi(e) {
|
|
|
6348
6820
|
{
|
|
6349
6821
|
key: "link",
|
|
6350
6822
|
label: e("editor.bubble.link"),
|
|
6351
|
-
icon: /* @__PURE__ */ D(
|
|
6823
|
+
icon: /* @__PURE__ */ D(zt, {}),
|
|
6352
6824
|
more: !0,
|
|
6353
6825
|
isActive: (e) => e.isActive("link"),
|
|
6354
6826
|
command: () => {}
|
|
@@ -6356,7 +6828,7 @@ function mi(e) {
|
|
|
6356
6828
|
{
|
|
6357
6829
|
key: "copy",
|
|
6358
6830
|
label: e("editor.bubble.copy"),
|
|
6359
|
-
icon: /* @__PURE__ */ D(
|
|
6831
|
+
icon: /* @__PURE__ */ D(Vt, {}),
|
|
6360
6832
|
more: !0,
|
|
6361
6833
|
isActive: () => !1,
|
|
6362
6834
|
command: (e) => {
|
|
@@ -6367,21 +6839,21 @@ function mi(e) {
|
|
|
6367
6839
|
{
|
|
6368
6840
|
key: "search",
|
|
6369
6841
|
label: e("editor.bubble.search"),
|
|
6370
|
-
icon: /* @__PURE__ */ D(
|
|
6842
|
+
icon: /* @__PURE__ */ D(Ht, {}),
|
|
6371
6843
|
more: !0,
|
|
6372
6844
|
isActive: () => !1,
|
|
6373
6845
|
command: (e) => {
|
|
6374
6846
|
if (e.isActive("table")) return;
|
|
6375
6847
|
let { from: t, to: n } = e.state.selection, r = e.state.doc.textBetween(t, n, " ").trim();
|
|
6376
6848
|
if (!r) return;
|
|
6377
|
-
let i =
|
|
6849
|
+
let i = ji.replace("{query}", encodeURIComponent(r));
|
|
6378
6850
|
window.open(i, "_blank", "noopener,noreferrer");
|
|
6379
6851
|
}
|
|
6380
6852
|
},
|
|
6381
6853
|
{
|
|
6382
6854
|
key: "table",
|
|
6383
6855
|
label: e("editor.bubble.table"),
|
|
6384
|
-
icon: /* @__PURE__ */ D(
|
|
6856
|
+
icon: /* @__PURE__ */ D(Bt, {}),
|
|
6385
6857
|
more: !0,
|
|
6386
6858
|
isActive: (e) => e.isActive("table"),
|
|
6387
6859
|
command: (e) => {
|
|
@@ -6397,7 +6869,7 @@ function mi(e) {
|
|
|
6397
6869
|
{
|
|
6398
6870
|
key: "ai",
|
|
6399
6871
|
label: e("editor.ai.trigger"),
|
|
6400
|
-
icon: /* @__PURE__ */ D(
|
|
6872
|
+
icon: /* @__PURE__ */ D(Ut, {}),
|
|
6401
6873
|
isActive: () => !1,
|
|
6402
6874
|
command: (e) => {
|
|
6403
6875
|
e.isEditable && e.storage.qingwuUI?.openAI?.();
|
|
@@ -6408,7 +6880,7 @@ function mi(e) {
|
|
|
6408
6880
|
R.create({ name: "bubbleMenu" });
|
|
6409
6881
|
//#endregion
|
|
6410
6882
|
//#region src/editor/extensions/table-toolbar.tsx
|
|
6411
|
-
function
|
|
6883
|
+
function Fi(e) {
|
|
6412
6884
|
let { $from: t } = e.state.selection;
|
|
6413
6885
|
for (let e = t.depth; e > 0; e--) {
|
|
6414
6886
|
let n = t.node(e);
|
|
@@ -6419,7 +6891,7 @@ function hi(e) {
|
|
|
6419
6891
|
}
|
|
6420
6892
|
return null;
|
|
6421
6893
|
}
|
|
6422
|
-
function
|
|
6894
|
+
function Ii(e) {
|
|
6423
6895
|
let t = [];
|
|
6424
6896
|
return e.forEach((e) => {
|
|
6425
6897
|
let n = [];
|
|
@@ -6428,7 +6900,7 @@ function gi(e) {
|
|
|
6428
6900
|
}), t.push(n);
|
|
6429
6901
|
}), t;
|
|
6430
6902
|
}
|
|
6431
|
-
function
|
|
6903
|
+
function Li(e) {
|
|
6432
6904
|
if (e.length === 0) return "";
|
|
6433
6905
|
let t = Math.max(...e.map((e) => e.length), 1), n = (e) => e.concat(Array(Math.max(0, t - e.length)).fill("")).slice(0, t), r = n(e[0]), i = e.slice(1).map(n), a = (e) => `| ${e.join(" | ")} |`;
|
|
6434
6906
|
return [
|
|
@@ -6437,11 +6909,11 @@ function _i(e) {
|
|
|
6437
6909
|
...i.map(a)
|
|
6438
6910
|
].join("\n");
|
|
6439
6911
|
}
|
|
6440
|
-
function
|
|
6912
|
+
function Ri(e) {
|
|
6441
6913
|
let t = (e) => /[",\n]/.test(e) ? `"${e.replace(/"/g, "\"\"")}"` : e;
|
|
6442
6914
|
return e.map((e) => e.map(t).join(",")).join("\n");
|
|
6443
6915
|
}
|
|
6444
|
-
function
|
|
6916
|
+
function zi(e) {
|
|
6445
6917
|
let t = e.trim();
|
|
6446
6918
|
if (!t) return null;
|
|
6447
6919
|
let n = t.split(/\r?\n/);
|
|
@@ -6455,7 +6927,7 @@ function yi(e) {
|
|
|
6455
6927
|
}
|
|
6456
6928
|
return null;
|
|
6457
6929
|
}
|
|
6458
|
-
function
|
|
6930
|
+
function Bi({ editor: e }) {
|
|
6459
6931
|
let [t, n] = T(null), [r, i] = T(!1), [a, o] = T(!1), s = w(null), c = w(null), l = e.isEditable, u = b(() => {
|
|
6460
6932
|
c.current != null && cancelAnimationFrame(c.current), c.current = requestAnimationFrame(() => {
|
|
6461
6933
|
c.current = null;
|
|
@@ -6471,7 +6943,7 @@ function bi({ editor: e }) {
|
|
|
6471
6943
|
n(null);
|
|
6472
6944
|
return;
|
|
6473
6945
|
}
|
|
6474
|
-
let t =
|
|
6946
|
+
let t = Fi(e);
|
|
6475
6947
|
if (!t) {
|
|
6476
6948
|
n(null);
|
|
6477
6949
|
return;
|
|
@@ -6500,24 +6972,24 @@ function bi({ editor: e }) {
|
|
|
6500
6972
|
});
|
|
6501
6973
|
return n.nodes.table.create(null, i);
|
|
6502
6974
|
}, p = () => {
|
|
6503
|
-
let t =
|
|
6975
|
+
let t = Fi(e);
|
|
6504
6976
|
if (!t) return;
|
|
6505
|
-
let n =
|
|
6977
|
+
let n = Li(Ii(t.node));
|
|
6506
6978
|
navigator.clipboard?.writeText(n), i(!0), setTimeout(() => i(!1), 1500);
|
|
6507
6979
|
}, m = () => {
|
|
6508
|
-
let t =
|
|
6980
|
+
let t = Fi(e);
|
|
6509
6981
|
if (!t) return;
|
|
6510
|
-
let n =
|
|
6982
|
+
let n = Ri(Ii(t.node)), r = new Blob([`\ufeff${n}`], { type: "text/csv;charset=utf-8" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
6511
6983
|
a.href = i, a.download = "table.csv", document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
6512
6984
|
}, h = async () => {
|
|
6513
6985
|
if (l) try {
|
|
6514
6986
|
let t = await navigator.clipboard?.readText();
|
|
6515
6987
|
if (!t) return;
|
|
6516
|
-
let n =
|
|
6988
|
+
let n = zi(t);
|
|
6517
6989
|
if (!n || n.length === 0) return;
|
|
6518
6990
|
let r = f(n);
|
|
6519
6991
|
if (!r) return;
|
|
6520
|
-
let i =
|
|
6992
|
+
let i = Fi(e), a = e.chain().focus();
|
|
6521
6993
|
if (i) {
|
|
6522
6994
|
let t = Math.min(i.pos + i.node.nodeSize, e.state.doc.content.size);
|
|
6523
6995
|
a.setTextSelection(t);
|
|
@@ -6637,7 +7109,7 @@ function bi({ editor: e }) {
|
|
|
6637
7109
|
type: "button",
|
|
6638
7110
|
className: "tbl-btn tbl-btn--del",
|
|
6639
7111
|
onClick: () => {
|
|
6640
|
-
!l ||
|
|
7112
|
+
!l || vn() || ($(!0), o(!0));
|
|
6641
7113
|
},
|
|
6642
7114
|
title: "删除",
|
|
6643
7115
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -6655,7 +7127,7 @@ function bi({ editor: e }) {
|
|
|
6655
7127
|
})
|
|
6656
7128
|
})
|
|
6657
7129
|
}),
|
|
6658
|
-
/* @__PURE__ */ D(
|
|
7130
|
+
/* @__PURE__ */ D(Cn, {
|
|
6659
7131
|
open: a,
|
|
6660
7132
|
title: "确认删除表格",
|
|
6661
7133
|
message: "此操作不可撤销。",
|
|
@@ -6671,7 +7143,7 @@ function bi({ editor: e }) {
|
|
|
6671
7143
|
}
|
|
6672
7144
|
//#endregion
|
|
6673
7145
|
//#region src/editor/ai-editor.tsx
|
|
6674
|
-
var
|
|
7146
|
+
var Vi = [
|
|
6675
7147
|
{
|
|
6676
7148
|
color: "#fef08a",
|
|
6677
7149
|
name: "黄"
|
|
@@ -6696,9 +7168,9 @@ var xi = [
|
|
|
6696
7168
|
color: "#ddd6fe",
|
|
6697
7169
|
name: "紫"
|
|
6698
7170
|
}
|
|
6699
|
-
],
|
|
6700
|
-
function
|
|
6701
|
-
let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth ||
|
|
7171
|
+
], Hi = 288, Ui = 480, Wi = 320;
|
|
7172
|
+
function Gi(e, t, n = {}) {
|
|
7173
|
+
let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth || Hi, Ui, r - 32), o = Math.max(t || Wi, 160);
|
|
6702
7174
|
if (r < 640) {
|
|
6703
7175
|
let t = Math.max(8, Math.min(e.top + 10, i - 420));
|
|
6704
7176
|
return {
|
|
@@ -6739,10 +7211,10 @@ function Ti(e, t, n = {}) {
|
|
|
6739
7211
|
arrowLeft: p
|
|
6740
7212
|
};
|
|
6741
7213
|
}
|
|
6742
|
-
function
|
|
6743
|
-
return /(^|\n)```|(^|\n)#{1,6}\s|(^|\n)>\s?|(^|\n)\s*([-*_])(?:\s*\4){2,}\s*(?=\n|$)|(^|\n)\s*[-*+]\s+|(^|\n)\s*\d+[.)]\s+|(^|\n)\s*<img\s+|(^|\n)\s
|
|
7214
|
+
function Ki(e) {
|
|
7215
|
+
return /(^|\n)```|(^|\n)#{1,6}\s|(^|\n)>\s?|(^|\n)\s*([-*_])(?:\s*\4){2,}\s*(?=\n|$)|(^|\n)\s*[-*+]\s+|(^|\n)\s*\d+[.)]\s+|(^|\n)\s*<img\s+|(^|\n)\s*\|.+\||(^|\n)\s*\$\$[\s\S]*?\$\$|(^|[^\\$])\$[^\s$\n](?:[^$\n]*[^\s$\n])?\$/i.test(e);
|
|
6744
7216
|
}
|
|
6745
|
-
function
|
|
7217
|
+
function qi(e, t) {
|
|
6746
7218
|
try {
|
|
6747
7219
|
let n = e.storage?.markdown?.parser;
|
|
6748
7220
|
if (!n) return null;
|
|
@@ -6752,20 +7224,20 @@ function Di(e, t) {
|
|
|
6752
7224
|
return null;
|
|
6753
7225
|
}
|
|
6754
7226
|
}
|
|
6755
|
-
var
|
|
7227
|
+
var Ji = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.ImageUploadDialog }))), Yi = y(() => import("./storage-settings-dialog-DnWNQWjN.js").then((e) => ({ default: e.StorageSettingsDialog }))), Xi = y(() => import("./export-dialog-DMY_QIVq.js").then((e) => ({ default: e.ExportDialog }))), Zi = y(() => import("./video-embed-dialog-B0_pc5xe.js").then((e) => ({ default: e.VideoEmbedDialog }))), Qi = y(() => import("./md-import-dialog-DbC-NCH_.js").then((e) => ({ default: e.MdImportDialog }))), $i = () => /* @__PURE__ */ O("div", {
|
|
6756
7228
|
className: "fixed inset-0 z-[9999] flex items-center justify-center",
|
|
6757
7229
|
children: [/* @__PURE__ */ D("div", { className: "absolute inset-0 bg-black/40 backdrop-blur-sm" }), /* @__PURE__ */ D("div", {
|
|
6758
7230
|
className: "relative bg-background rounded-2xl border border-default-200 p-8 flex items-center justify-center",
|
|
6759
7231
|
children: /* @__PURE__ */ D("div", { className: "w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin" })
|
|
6760
7232
|
})]
|
|
6761
|
-
}),
|
|
6762
|
-
let k = r === "view" || i, A = C(() => typeof e == "object" && e ||
|
|
7233
|
+
}), ea = ({ 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 }) => {
|
|
7234
|
+
let k = r === "view" || i, A = C(() => typeof e == "object" && e || Ki(e) ? e : d(e), [e]), [j, M] = T(!1), [P, F] = T({}), [I, R] = T("below"), [re, ie] = T(50), z = w(null), [B, V] = T(!1), [H, ae] = T(!1), [oe, U] = T(!1), [W, se] = T(!1), [G, K] = T("none"), [ce, q] = T({}), le = w(null), ue = w(null), [de, fe] = T(""), [J, pe] = T(null), [me, he] = T(m), [ge, _e] = T(!1);
|
|
6763
7235
|
x(() => {
|
|
6764
|
-
|
|
7236
|
+
he(m);
|
|
6765
7237
|
}, [m]);
|
|
6766
|
-
let [
|
|
6767
|
-
let e =
|
|
6768
|
-
e && (
|
|
7238
|
+
let [ve, ye] = T(!1), [be, xe] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 80rem)").matches : !0), [Se, Ce] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 64rem)").matches : !0), we = w(null), Te = w(null), Ee = w(null), De = w(0), Oe = w(null), ke = w(null), Ae = w(null), je = w(null), [Me, Ne] = T(!1), [Y, Pe] = T(!1), [Fe, Ie] = T(!1), Le = w(null), Re = b(() => {
|
|
7239
|
+
let e = Te.current, t = Ee.current;
|
|
7240
|
+
e && (Y ? (document.body.style.overflow = "", Object.assign(e.style, {
|
|
6769
7241
|
position: "",
|
|
6770
7242
|
top: "",
|
|
6771
7243
|
left: "",
|
|
@@ -6781,9 +7253,9 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
6781
7253
|
flex: "",
|
|
6782
7254
|
overflow: "",
|
|
6783
7255
|
minHeight: ""
|
|
6784
|
-
}),
|
|
6785
|
-
window.scrollTo(0,
|
|
6786
|
-
})) : (document.fullscreenElement && document.exitFullscreen(),
|
|
7256
|
+
}), Pe(!1), requestAnimationFrame(() => {
|
|
7257
|
+
window.scrollTo(0, De.current);
|
|
7258
|
+
})) : (document.fullscreenElement && document.exitFullscreen(), De.current = window.scrollY, Object.assign(e.style, {
|
|
6787
7259
|
position: "fixed",
|
|
6788
7260
|
top: "0",
|
|
6789
7261
|
left: "0",
|
|
@@ -6798,42 +7270,42 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
6798
7270
|
flex: "1",
|
|
6799
7271
|
overflow: "auto",
|
|
6800
7272
|
minHeight: "0"
|
|
6801
|
-
}), document.body.style.overflow = "hidden",
|
|
6802
|
-
}, [
|
|
6803
|
-
let e =
|
|
6804
|
-
e && (document.fullscreenElement ? document.exitFullscreen() : (
|
|
6805
|
-
}, [
|
|
7273
|
+
}), document.body.style.overflow = "hidden", Pe(!0)));
|
|
7274
|
+
}, [Y]), ze = b(() => {
|
|
7275
|
+
let e = Te.current;
|
|
7276
|
+
e && (document.fullscreenElement ? document.exitFullscreen() : (Y && Re(), De.current = window.scrollY, e.requestFullscreen()));
|
|
7277
|
+
}, [Y, Re]);
|
|
6806
7278
|
x(() => {
|
|
6807
7279
|
let e = (e) => {
|
|
6808
|
-
e.key === "Escape" &&
|
|
7280
|
+
e.key === "Escape" && Y && Re();
|
|
6809
7281
|
}, t = () => {
|
|
6810
|
-
document.fullscreenElement ?
|
|
6811
|
-
window.scrollTo(0,
|
|
7282
|
+
document.fullscreenElement ? Ie(!0) : (Ie(!1), requestAnimationFrame(() => {
|
|
7283
|
+
window.scrollTo(0, De.current);
|
|
6812
7284
|
}));
|
|
6813
7285
|
};
|
|
6814
7286
|
return window.addEventListener("keydown", e), document.addEventListener("fullscreenchange", t), () => {
|
|
6815
7287
|
window.removeEventListener("keydown", e), document.removeEventListener("fullscreenchange", t);
|
|
6816
7288
|
};
|
|
6817
|
-
}, [
|
|
7289
|
+
}, [Y, Re]), x(() => {
|
|
6818
7290
|
if (!h) return;
|
|
6819
7291
|
let e = (e) => {
|
|
6820
7292
|
if ((e.ctrlKey || e.metaKey) && (e.key === "f" || e.key === "F")) {
|
|
6821
|
-
if (!
|
|
6822
|
-
e.preventDefault(), e.stopPropagation(),
|
|
7293
|
+
if (!Te.current) return;
|
|
7294
|
+
e.preventDefault(), e.stopPropagation(), ye(!0);
|
|
6823
7295
|
}
|
|
6824
7296
|
};
|
|
6825
7297
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
6826
7298
|
}, [h]), x(() => {
|
|
6827
7299
|
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
6828
|
-
let e = window.matchMedia("(min-width: 80rem)"), t = (e) =>
|
|
6829
|
-
return
|
|
7300
|
+
let e = window.matchMedia("(min-width: 80rem)"), t = (e) => xe(e.matches);
|
|
7301
|
+
return xe(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
6830
7302
|
}, []), x(() => {
|
|
6831
7303
|
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
6832
|
-
let e = window.matchMedia("(min-width: 64rem)"), t = (e) =>
|
|
6833
|
-
return
|
|
7304
|
+
let e = window.matchMedia("(min-width: 64rem)"), t = (e) => Ce(e.matches);
|
|
7305
|
+
return Ce(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
6834
7306
|
}, []);
|
|
6835
|
-
let
|
|
6836
|
-
extensions:
|
|
7307
|
+
let X = te({
|
|
7308
|
+
extensions: Ai({
|
|
6837
7309
|
placeholder: n || f("editor.placeholder"),
|
|
6838
7310
|
maxLength: a,
|
|
6839
7311
|
maxAttachmentSize: o,
|
|
@@ -6843,7 +7315,7 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
6843
7315
|
editable: !k,
|
|
6844
7316
|
immediatelyRender: _,
|
|
6845
7317
|
onUpdate: ({ editor: e }) => {
|
|
6846
|
-
t && (
|
|
7318
|
+
t && (we.current && clearTimeout(we.current), we.current = setTimeout(() => {
|
|
6847
7319
|
t?.(e.getHTML(), e.getJSON());
|
|
6848
7320
|
}, 300));
|
|
6849
7321
|
},
|
|
@@ -6859,9 +7331,9 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
6859
7331
|
let r = n.getData("text/plain");
|
|
6860
7332
|
if (!r || !r.includes("[[")) return !1;
|
|
6861
7333
|
t.preventDefault();
|
|
6862
|
-
let i =
|
|
7334
|
+
let i = ke.current?.storage?.relativeMedia;
|
|
6863
7335
|
i && (i.clipboardFiles = new Map(Array.from(n.files ?? []).map((e) => [e.name.toLowerCase(), e])), i.pausedUntilPaste = !1);
|
|
6864
|
-
let a =
|
|
7336
|
+
let a = ke.current ? qi(ke.current, r) : null;
|
|
6865
7337
|
if (a) {
|
|
6866
7338
|
let t = new N(a, 0, 0);
|
|
6867
7339
|
e.dispatch(e.state.tr.replaceSelection(t).scrollIntoView());
|
|
@@ -6871,21 +7343,21 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
6871
7343
|
}
|
|
6872
7344
|
});
|
|
6873
7345
|
x(() => {
|
|
6874
|
-
|
|
6875
|
-
}, [
|
|
6876
|
-
if (
|
|
6877
|
-
}, [
|
|
6878
|
-
!
|
|
6879
|
-
}, [
|
|
6880
|
-
if (!
|
|
7346
|
+
ke.current = X, window.__editor = X;
|
|
7347
|
+
}, [X]), x(() => {
|
|
7348
|
+
if (X) return () => $t(X);
|
|
7349
|
+
}, [X]), x(() => {
|
|
7350
|
+
!X || !g || g(X);
|
|
7351
|
+
}, [X, g]), x(() => {
|
|
7352
|
+
if (!X) return;
|
|
6881
7353
|
let e = () => {
|
|
6882
|
-
|
|
7354
|
+
X.state.selection.empty && (K("none"), Ne(!1));
|
|
6883
7355
|
};
|
|
6884
|
-
return
|
|
6885
|
-
|
|
7356
|
+
return X.on("selectionUpdate", e), () => {
|
|
7357
|
+
X.off("selectionUpdate", e);
|
|
6886
7358
|
};
|
|
6887
|
-
}, [
|
|
6888
|
-
|
|
7359
|
+
}, [X]), x(() => {
|
|
7360
|
+
X && X.setOptions({ extensions: Ai({
|
|
6889
7361
|
placeholder: n || f("editor.placeholder"),
|
|
6890
7362
|
maxLength: a,
|
|
6891
7363
|
maxAttachmentSize: o,
|
|
@@ -6897,33 +7369,33 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
6897
7369
|
o,
|
|
6898
7370
|
s
|
|
6899
7371
|
]);
|
|
6900
|
-
let
|
|
7372
|
+
let Be = w(e);
|
|
6901
7373
|
x(() => {
|
|
6902
|
-
if (!
|
|
6903
|
-
|
|
6904
|
-
let t = typeof e == "object" && e ||
|
|
6905
|
-
|
|
6906
|
-
}, [
|
|
6907
|
-
|
|
6908
|
-
}, [
|
|
6909
|
-
if (y) return
|
|
7374
|
+
if (!X || e === Be.current) return;
|
|
7375
|
+
Be.current = e;
|
|
7376
|
+
let t = typeof e == "object" && e || Ki(e) ? e : d(e);
|
|
7377
|
+
X.commands.setContent(t, { emitUpdate: !1 });
|
|
7378
|
+
}, [X, e]), x(() => {
|
|
7379
|
+
X && X.setEditable(!k, !1);
|
|
7380
|
+
}, [X, k]), x(() => {
|
|
7381
|
+
if (y) return tt(y);
|
|
6910
7382
|
}, [y]), x(() => {
|
|
6911
|
-
if (!
|
|
6912
|
-
let e =
|
|
6913
|
-
e > s && Z(`文档内附件总大小 ${
|
|
6914
|
-
}, [
|
|
6915
|
-
if (!
|
|
6916
|
-
let e =
|
|
7383
|
+
if (!X) return;
|
|
7384
|
+
let e = dn(X.state.doc);
|
|
7385
|
+
e > s && Z(`文档内附件总大小 ${fn(e)} 已超过限制 ${fn(s)}`, "info");
|
|
7386
|
+
}, [X, s]), x(() => {
|
|
7387
|
+
if (!X) return;
|
|
7388
|
+
let e = X.storage.qingwuUI;
|
|
6917
7389
|
e && (e.limits = {
|
|
6918
7390
|
maxAttachmentSize: o,
|
|
6919
7391
|
maxTotalAttachmentSize: s
|
|
6920
7392
|
});
|
|
6921
7393
|
}, [
|
|
6922
|
-
|
|
7394
|
+
X,
|
|
6923
7395
|
o,
|
|
6924
7396
|
s
|
|
6925
7397
|
]);
|
|
6926
|
-
let
|
|
7398
|
+
let Ve = b((e, t) => {
|
|
6927
7399
|
let n = e ? Math.max(8, Math.min(e.left, window.innerWidth - 240 - 8)) : 8, r;
|
|
6928
7400
|
return r = e ? t && e.bottom + 8 + t > window.innerHeight ? Math.max(8, e.top - t - 8) : e.bottom + 8 : 8, {
|
|
6929
7401
|
position: "fixed",
|
|
@@ -6932,65 +7404,65 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
6932
7404
|
zIndex: 9999
|
|
6933
7405
|
};
|
|
6934
7406
|
}, []), He = b((e) => {
|
|
6935
|
-
let t =
|
|
6936
|
-
ue.current = t,
|
|
6937
|
-
}, [
|
|
7407
|
+
let t = je.current?.getBoundingClientRect() ?? null;
|
|
7408
|
+
ue.current = t, K(e), Ne(!1), q(Ve(t, void 0));
|
|
7409
|
+
}, [Ve]);
|
|
6938
7410
|
S(() => {
|
|
6939
|
-
if (
|
|
7411
|
+
if (G === "none") return;
|
|
6940
7412
|
let e = le.current;
|
|
6941
|
-
|
|
6942
|
-
}, [
|
|
6943
|
-
if (
|
|
6944
|
-
let e = () =>
|
|
7413
|
+
q(Ve(ue.current, e?.offsetHeight || void 0));
|
|
7414
|
+
}, [G, Ve]), x(() => {
|
|
7415
|
+
if (G === "none") return;
|
|
7416
|
+
let e = () => K("none"), t = () => {
|
|
6945
7417
|
let e = le.current;
|
|
6946
|
-
|
|
7418
|
+
q(Ve(ue.current, e?.offsetHeight || void 0));
|
|
6947
7419
|
};
|
|
6948
7420
|
return window.addEventListener("scroll", e, !0), window.addEventListener("resize", t), () => {
|
|
6949
7421
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", t);
|
|
6950
7422
|
};
|
|
6951
|
-
}, [
|
|
6952
|
-
|
|
6953
|
-
}, [
|
|
6954
|
-
let Ue =
|
|
6955
|
-
if (
|
|
7423
|
+
}, [G, Ve]), x(() => {
|
|
7424
|
+
G === "none" && (ue.current = null);
|
|
7425
|
+
}, [G]);
|
|
7426
|
+
let Ue = Pi((e) => f(e)), We = Ue.filter((e) => !e.more), Ge = Ue.filter((e) => e.more), Ke = We.filter((e) => e.key !== "ai"), qe = We.find((e) => e.key === "ai"), Je = b((e) => {
|
|
7427
|
+
if (X) if (Ne(!1), e.key === "link") if (X.isActive("link")) X.chain().focus().unsetLink().run();
|
|
6956
7428
|
else {
|
|
6957
|
-
let e =
|
|
7429
|
+
let e = X.getAttributes("link").href || "";
|
|
6958
7430
|
fe(e), He("link");
|
|
6959
7431
|
}
|
|
6960
|
-
else e.key === "highlight" ?
|
|
7432
|
+
else e.key === "highlight" ? G === "highlight" ? K("none") : He("highlight") : e.command(X);
|
|
6961
7433
|
}, [
|
|
6962
|
-
|
|
6963
|
-
|
|
7434
|
+
X,
|
|
7435
|
+
G,
|
|
6964
7436
|
He
|
|
6965
|
-
]), Ye = b((e) =>
|
|
7437
|
+
]), Ye = b((e) => X ? e.key === "highlight" ? G === "highlight" : e.key === "link" ? X.isActive("link") : e.isActive(X) : !1, [X, G]), [Xe, Ze] = T(0);
|
|
6966
7438
|
x(() => {
|
|
6967
|
-
if (!
|
|
7439
|
+
if (!X) return;
|
|
6968
7440
|
let e = () => Ze((e) => (e + 1) % 1e6);
|
|
6969
|
-
return
|
|
6970
|
-
|
|
7441
|
+
return X.on("update", e), () => {
|
|
7442
|
+
X.off("update", e);
|
|
6971
7443
|
};
|
|
6972
|
-
}, [
|
|
6973
|
-
let [Qe,
|
|
7444
|
+
}, [X]);
|
|
7445
|
+
let [Qe, $e] = T(!1);
|
|
6974
7446
|
x(() => {
|
|
6975
|
-
if (!
|
|
7447
|
+
if (!X) return;
|
|
6976
7448
|
let e = () => {
|
|
6977
7449
|
let e = !1;
|
|
6978
|
-
|
|
7450
|
+
X.state.doc.descendants((t) => {
|
|
6979
7451
|
t.type.name === "heading" && (e = !0);
|
|
6980
|
-
}),
|
|
7452
|
+
}), $e(e);
|
|
6981
7453
|
};
|
|
6982
|
-
return e(),
|
|
6983
|
-
|
|
7454
|
+
return e(), X.on("update", e), () => {
|
|
7455
|
+
X.off("update", e);
|
|
6984
7456
|
};
|
|
6985
|
-
}, [
|
|
6986
|
-
let
|
|
7457
|
+
}, [X]);
|
|
7458
|
+
let et = C(() => X?.storage?.characterCount?.characters?.() ?? 0, [X, Xe]), nt = a ? et > a : !1;
|
|
6987
7459
|
x(() => () => {
|
|
6988
|
-
|
|
7460
|
+
we.current && clearTimeout(we.current);
|
|
6989
7461
|
}, []), x(() => () => {
|
|
6990
|
-
|
|
7462
|
+
J && J.resolve(null);
|
|
6991
7463
|
}, []);
|
|
6992
7464
|
let rt = b((e) => {
|
|
6993
|
-
if (!
|
|
7465
|
+
if (!X?.isEditable) return;
|
|
6994
7466
|
let t = window.getSelection(), n;
|
|
6995
7467
|
if (e) {
|
|
6996
7468
|
let t = e.getBoundingClientRect();
|
|
@@ -7007,76 +7479,76 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7007
7479
|
width: e.width
|
|
7008
7480
|
};
|
|
7009
7481
|
} else {
|
|
7010
|
-
let e =
|
|
7482
|
+
let e = X.view.coordsAtPos(X.state.selection.from);
|
|
7011
7483
|
n = {
|
|
7012
7484
|
top: e.bottom,
|
|
7013
7485
|
left: e.left,
|
|
7014
7486
|
width: 0
|
|
7015
7487
|
};
|
|
7016
7488
|
}
|
|
7017
|
-
|
|
7018
|
-
let r =
|
|
7489
|
+
Oe.current = n;
|
|
7490
|
+
let r = Te.current?.getBoundingClientRect(), i = Gi(n, void 0, {
|
|
7019
7491
|
panelWidth: r?.width,
|
|
7020
7492
|
editorLeft: r?.left
|
|
7021
7493
|
});
|
|
7022
|
-
M(!0),
|
|
7023
|
-
}, [
|
|
7494
|
+
M(!0), F(i.style), R(i.placement), ie(i.arrowLeft);
|
|
7495
|
+
}, [X]);
|
|
7024
7496
|
x(() => {
|
|
7025
|
-
if (!
|
|
7026
|
-
let e =
|
|
7497
|
+
if (!X) return;
|
|
7498
|
+
let e = X.storage.qingwuUI;
|
|
7027
7499
|
if (e) return e.openImageDialog = () => V(!0), e.openVideoDialog = () => ae(!0), e.chooseMd = (e, t) => {
|
|
7028
|
-
|
|
7500
|
+
pe({
|
|
7029
7501
|
filename: e,
|
|
7030
7502
|
resolve: t
|
|
7031
7503
|
});
|
|
7032
|
-
}, e.openAI = rt, e.parseMd = (e, t) =>
|
|
7504
|
+
}, e.openAI = rt, e.parseMd = (e, t) => X ? qi(X, t) : null, () => {
|
|
7033
7505
|
delete e.openImageDialog, delete e.openVideoDialog, delete e.openAI, delete e.parseMd, delete e.chooseMd;
|
|
7034
7506
|
};
|
|
7035
|
-
}, [
|
|
7036
|
-
if (!j || !
|
|
7037
|
-
let e =
|
|
7507
|
+
}, [X, rt]), S(() => {
|
|
7508
|
+
if (!j || !X) return;
|
|
7509
|
+
let e = Oe.current;
|
|
7038
7510
|
if (!e) return;
|
|
7039
|
-
let t = z.current, n =
|
|
7511
|
+
let t = z.current, n = Te.current?.getBoundingClientRect(), r = Gi(e, t?.offsetHeight || void 0, {
|
|
7040
7512
|
panelWidth: n?.width,
|
|
7041
7513
|
editorLeft: n?.left
|
|
7042
7514
|
});
|
|
7043
|
-
R(r.placement), ie(r.arrowLeft),
|
|
7044
|
-
}, [j,
|
|
7045
|
-
if (!j || !
|
|
7515
|
+
R(r.placement), ie(r.arrowLeft), F(r.style);
|
|
7516
|
+
}, [j, X]), x(() => {
|
|
7517
|
+
if (!j || !X) return;
|
|
7046
7518
|
let e = () => {
|
|
7047
|
-
let e =
|
|
7519
|
+
let e = Oe.current;
|
|
7048
7520
|
if (!e) return;
|
|
7049
|
-
let t = z.current, n =
|
|
7521
|
+
let t = z.current, n = Te.current?.getBoundingClientRect(), r = Gi(e, t?.offsetHeight || void 0, {
|
|
7050
7522
|
panelWidth: n?.width,
|
|
7051
7523
|
editorLeft: n?.left
|
|
7052
7524
|
});
|
|
7053
|
-
R(r.placement), ie(r.arrowLeft),
|
|
7525
|
+
R(r.placement), ie(r.arrowLeft), F(r.style);
|
|
7054
7526
|
};
|
|
7055
7527
|
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
7056
|
-
}, [j,
|
|
7057
|
-
j || (
|
|
7528
|
+
}, [j, X]), x(() => {
|
|
7529
|
+
j || (Oe.current = null);
|
|
7058
7530
|
}, [j]);
|
|
7059
7531
|
let it = b((e) => {
|
|
7060
|
-
|
|
7061
|
-
}, [
|
|
7062
|
-
(
|
|
7063
|
-
}, [
|
|
7532
|
+
X?.chain().focus().setImage({ src: e }).run();
|
|
7533
|
+
}, [X]), at = b((e) => {
|
|
7534
|
+
(X?.commands).insertVideo?.({ src: e });
|
|
7535
|
+
}, [X]), ot = me && be && !Y && !Fe, st = !ot && !ge && (me || Qe && !(!k && Se)), ct = w(!1);
|
|
7064
7536
|
return x(() => {
|
|
7065
|
-
|
|
7066
|
-
}, [
|
|
7067
|
-
if (!
|
|
7537
|
+
ct.current || (ct.current = !0, me && !ot && _e(!0));
|
|
7538
|
+
}, [me, ot]), x(() => {
|
|
7539
|
+
if (!ge) return;
|
|
7068
7540
|
let e = (e) => {
|
|
7069
7541
|
let t = e.target;
|
|
7070
|
-
|
|
7542
|
+
Le.current?.contains(t) || _e(!1);
|
|
7071
7543
|
}, t = (e) => {
|
|
7072
|
-
e.key === "Escape" &&
|
|
7544
|
+
e.key === "Escape" && _e(!1);
|
|
7073
7545
|
};
|
|
7074
7546
|
return document.addEventListener("mousedown", e), document.addEventListener("touchstart", e, { passive: !0 }), document.addEventListener("keydown", t), () => {
|
|
7075
7547
|
document.removeEventListener("mousedown", e), document.removeEventListener("touchstart", e), document.removeEventListener("keydown", t);
|
|
7076
7548
|
};
|
|
7077
|
-
}, [
|
|
7078
|
-
if (!
|
|
7079
|
-
let e =
|
|
7549
|
+
}, [ge]), x(() => {
|
|
7550
|
+
if (!X || !ot) return;
|
|
7551
|
+
let e = Ae.current;
|
|
7080
7552
|
if (!(e instanceof HTMLElement)) return;
|
|
7081
7553
|
let t = (t) => {
|
|
7082
7554
|
let n = t.deltaY;
|
|
@@ -7086,17 +7558,17 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7086
7558
|
e.scrollTop += n, t.preventDefault(), t.stopPropagation();
|
|
7087
7559
|
return;
|
|
7088
7560
|
}
|
|
7089
|
-
let a =
|
|
7561
|
+
let a = ut(X), o = a ? lt(a) : null;
|
|
7090
7562
|
if (o) {
|
|
7091
7563
|
o.scrollTop += n, t.preventDefault(), t.stopPropagation();
|
|
7092
7564
|
return;
|
|
7093
7565
|
}
|
|
7094
7566
|
};
|
|
7095
7567
|
return e.addEventListener("wheel", t, { passive: !1 }), () => e.removeEventListener("wheel", t);
|
|
7096
|
-
}, [
|
|
7568
|
+
}, [X, ot]), X ? /* @__PURE__ */ O("div", {
|
|
7097
7569
|
className: "qingwu-editor-row",
|
|
7098
7570
|
children: [/* @__PURE__ */ O("div", {
|
|
7099
|
-
ref:
|
|
7571
|
+
ref: Te,
|
|
7100
7572
|
className: `qingwu-editor relative flex-1 min-w-0 bg-background ${k ? "qingwu-editor--readonly" : ""} ${l ? "" : "rounded-xl border border-default-200"} ${c}`,
|
|
7101
7573
|
style: u,
|
|
7102
7574
|
children: [
|
|
@@ -7107,13 +7579,13 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7107
7579
|
children: [
|
|
7108
7580
|
/* @__PURE__ */ D("button", {
|
|
7109
7581
|
type: "button",
|
|
7110
|
-
className: `qed-tb-btn qed-tb-btn--desktop-only${
|
|
7582
|
+
className: `qed-tb-btn qed-tb-btn--desktop-only${me ? " is-active" : ""}`,
|
|
7111
7583
|
onClick: () => {
|
|
7112
|
-
|
|
7584
|
+
me ? (he(!1), _e(!1)) : (he(!0), be && !Y && !Fe || _e(!0));
|
|
7113
7585
|
},
|
|
7114
|
-
title:
|
|
7115
|
-
"aria-label":
|
|
7116
|
-
"aria-pressed":
|
|
7586
|
+
title: me ? "隐藏目录" : "显示目录",
|
|
7587
|
+
"aria-label": me ? "隐藏目录" : "显示目录",
|
|
7588
|
+
"aria-pressed": me,
|
|
7117
7589
|
children: /* @__PURE__ */ D("svg", {
|
|
7118
7590
|
fill: "none",
|
|
7119
7591
|
viewBox: "0 0 24 24",
|
|
@@ -7129,11 +7601,11 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7129
7601
|
}),
|
|
7130
7602
|
h && /* @__PURE__ */ D("button", {
|
|
7131
7603
|
type: "button",
|
|
7132
|
-
className: `qed-tb-btn${
|
|
7133
|
-
onClick: () =>
|
|
7604
|
+
className: `qed-tb-btn${ve ? " is-active" : ""}`,
|
|
7605
|
+
onClick: () => ye(!ve),
|
|
7134
7606
|
title: "查找 (Ctrl+F)",
|
|
7135
7607
|
"aria-label": "查找",
|
|
7136
|
-
"aria-pressed":
|
|
7608
|
+
"aria-pressed": ve,
|
|
7137
7609
|
children: /* @__PURE__ */ D("svg", {
|
|
7138
7610
|
fill: "none",
|
|
7139
7611
|
viewBox: "0 0 24 24",
|
|
@@ -7178,7 +7650,7 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7178
7650
|
/* @__PURE__ */ O("button", {
|
|
7179
7651
|
type: "button",
|
|
7180
7652
|
className: "qed-tb-btn qed-tb-btn--solid",
|
|
7181
|
-
onClick: () =>
|
|
7653
|
+
onClick: () => se(!0),
|
|
7182
7654
|
title: f("editor.toolbar.exportTitle"),
|
|
7183
7655
|
children: [/* @__PURE__ */ D("svg", {
|
|
7184
7656
|
fill: "none",
|
|
@@ -7198,11 +7670,11 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7198
7670
|
}),
|
|
7199
7671
|
/* @__PURE__ */ D("button", {
|
|
7200
7672
|
type: "button",
|
|
7201
|
-
className: `qed-tb-btn${
|
|
7202
|
-
onClick:
|
|
7203
|
-
title:
|
|
7204
|
-
"aria-label":
|
|
7205
|
-
"aria-pressed":
|
|
7673
|
+
className: `qed-tb-btn${Y ? " is-active" : ""}`,
|
|
7674
|
+
onClick: Re,
|
|
7675
|
+
title: Y ? "退出网页全屏" : "网页全屏",
|
|
7676
|
+
"aria-label": Y ? "退出网页全屏" : "网页全屏",
|
|
7677
|
+
"aria-pressed": Y,
|
|
7206
7678
|
children: /* @__PURE__ */ D("svg", {
|
|
7207
7679
|
fill: "none",
|
|
7208
7680
|
viewBox: "0 0 24 24",
|
|
@@ -7218,11 +7690,11 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7218
7690
|
}),
|
|
7219
7691
|
/* @__PURE__ */ D("button", {
|
|
7220
7692
|
type: "button",
|
|
7221
|
-
className: `qed-tb-btn${
|
|
7222
|
-
onClick:
|
|
7223
|
-
title:
|
|
7224
|
-
"aria-label":
|
|
7225
|
-
"aria-pressed":
|
|
7693
|
+
className: `qed-tb-btn${Fe ? " is-active" : ""}`,
|
|
7694
|
+
onClick: ze,
|
|
7695
|
+
title: Fe ? "退出全屏" : "全屏",
|
|
7696
|
+
"aria-label": Fe ? "退出全屏" : "全屏",
|
|
7697
|
+
"aria-pressed": Fe,
|
|
7226
7698
|
children: /* @__PURE__ */ D("svg", {
|
|
7227
7699
|
fill: "none",
|
|
7228
7700
|
viewBox: "0 0 24 24",
|
|
@@ -7239,8 +7711,8 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7239
7711
|
]
|
|
7240
7712
|
})]
|
|
7241
7713
|
}),
|
|
7242
|
-
|
|
7243
|
-
editor:
|
|
7714
|
+
X && !k && X.isEditable && /* @__PURE__ */ D(ne, {
|
|
7715
|
+
editor: X,
|
|
7244
7716
|
shouldShow: ({ editor: e, state: t }) => !(e.isActive("image") || e.isActive("videoEmbed") || e.isActive("codeBlock") || e.isActive("audioEmbed") || e.isActive("attachmentEmbed") || t.selection.empty),
|
|
7245
7717
|
options: {
|
|
7246
7718
|
placement: "bottom",
|
|
@@ -7249,7 +7721,7 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7249
7721
|
},
|
|
7250
7722
|
className: "bubble-menu-pop bg-background border border-default-200 rounded-xl p-1 shadow-lg",
|
|
7251
7723
|
children: /* @__PURE__ */ O("div", {
|
|
7252
|
-
ref:
|
|
7724
|
+
ref: je,
|
|
7253
7725
|
className: "bubble-menu-items relative flex items-center gap-0.5",
|
|
7254
7726
|
onPointerDown: (e) => {
|
|
7255
7727
|
e.target.closest("button") && e.preventDefault();
|
|
@@ -7257,7 +7729,7 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7257
7729
|
children: [
|
|
7258
7730
|
Ke.map((e) => /* @__PURE__ */ D("button", {
|
|
7259
7731
|
type: "button",
|
|
7260
|
-
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${e.isActive(
|
|
7732
|
+
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"}`,
|
|
7261
7733
|
onClick: (t) => {
|
|
7262
7734
|
t.preventDefault(), Je(e);
|
|
7263
7735
|
},
|
|
@@ -7273,11 +7745,11 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7273
7745
|
type: "button",
|
|
7274
7746
|
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"}`,
|
|
7275
7747
|
onClick: (e) => {
|
|
7276
|
-
e.preventDefault(),
|
|
7748
|
+
e.preventDefault(), Ne(!1), qe?.command(X);
|
|
7277
7749
|
},
|
|
7278
7750
|
title: qe?.label,
|
|
7279
7751
|
"aria-label": qe?.label,
|
|
7280
|
-
children: /* @__PURE__ */ D(
|
|
7752
|
+
children: /* @__PURE__ */ D(Ut, {})
|
|
7281
7753
|
}),
|
|
7282
7754
|
/* @__PURE__ */ D("span", {
|
|
7283
7755
|
className: "w-px h-4 bg-default-200 mx-0.5 shrink-0",
|
|
@@ -7285,16 +7757,16 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7285
7757
|
}),
|
|
7286
7758
|
/* @__PURE__ */ D("button", {
|
|
7287
7759
|
type: "button",
|
|
7288
|
-
"aria-expanded":
|
|
7289
|
-
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${
|
|
7760
|
+
"aria-expanded": Me,
|
|
7761
|
+
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${Me ? "bg-default-100 text-default-900" : "text-default-600 hover:bg-default-100"}`,
|
|
7290
7762
|
onClick: (e) => {
|
|
7291
|
-
e.preventDefault(),
|
|
7763
|
+
e.preventDefault(), Ne((e) => !e);
|
|
7292
7764
|
},
|
|
7293
7765
|
title: f("editor.bubble.more"),
|
|
7294
7766
|
"aria-label": f("editor.bubble.more"),
|
|
7295
|
-
children: /* @__PURE__ */ D(
|
|
7767
|
+
children: /* @__PURE__ */ D(Wt, {})
|
|
7296
7768
|
}),
|
|
7297
|
-
|
|
7769
|
+
Me && /* @__PURE__ */ D("div", {
|
|
7298
7770
|
role: "menu",
|
|
7299
7771
|
className: "bubble-more-menu absolute right-0 top-full z-[9999] mt-1 w-max max-h-[70dvh] overflow-y-auto flex-col gap-1 rounded-xl border border-default-200 bg-background p-1.5 shadow-xl",
|
|
7300
7772
|
onPointerDown: (e) => {
|
|
@@ -7320,30 +7792,30 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7320
7792
|
]
|
|
7321
7793
|
})
|
|
7322
7794
|
}),
|
|
7323
|
-
|
|
7795
|
+
X && G !== "none" && L(/* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
|
|
7324
7796
|
className: "fixed inset-0 z-[9998]",
|
|
7325
|
-
onClick: () =>
|
|
7797
|
+
onClick: () => K("none")
|
|
7326
7798
|
}), /* @__PURE__ */ D("div", {
|
|
7327
7799
|
ref: le,
|
|
7328
|
-
style:
|
|
7800
|
+
style: ce,
|
|
7329
7801
|
className: "bg-background border border-default-200 rounded-xl shadow-xl",
|
|
7330
7802
|
onClick: (e) => e.stopPropagation(),
|
|
7331
|
-
children:
|
|
7803
|
+
children: G === "highlight" ? /* @__PURE__ */ O("div", {
|
|
7332
7804
|
className: "flex items-center gap-1 p-1.5 flex-wrap",
|
|
7333
|
-
children: [
|
|
7805
|
+
children: [Vi.map((e) => /* @__PURE__ */ D("button", {
|
|
7334
7806
|
type: "button",
|
|
7335
7807
|
className: "w-5 h-5 rounded-full border border-default-200 hover:scale-110 transition-transform",
|
|
7336
7808
|
style: { background: e.color },
|
|
7337
7809
|
title: e.name,
|
|
7338
7810
|
onClick: () => {
|
|
7339
|
-
|
|
7811
|
+
X.chain().focus().setHighlight({ color: e.color }).run(), K("none");
|
|
7340
7812
|
}
|
|
7341
7813
|
}, e.color)), /* @__PURE__ */ O("button", {
|
|
7342
7814
|
type: "button",
|
|
7343
7815
|
className: "w-5 h-5 rounded-full border border-default-200 text-default-500 hover:bg-default-100 flex items-center justify-center text-[10px]",
|
|
7344
7816
|
title: "清除高亮",
|
|
7345
7817
|
onClick: () => {
|
|
7346
|
-
|
|
7818
|
+
X.chain().focus().unsetHighlight().run(), K("none");
|
|
7347
7819
|
},
|
|
7348
7820
|
children: ["✕", " "]
|
|
7349
7821
|
})]
|
|
@@ -7356,101 +7828,101 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7356
7828
|
value: de,
|
|
7357
7829
|
onChange: (e) => fe(e.target.value),
|
|
7358
7830
|
onKeyDown: (e) => {
|
|
7359
|
-
e.key === "Enter" ? (de.trim() &&
|
|
7831
|
+
e.key === "Enter" ? (de.trim() && X.chain().focus().setLink({ href: de.trim() }).run(), K("none")) : e.key === "Escape" && K("none");
|
|
7360
7832
|
}
|
|
7361
7833
|
}), /* @__PURE__ */ D("button", {
|
|
7362
7834
|
type: "button",
|
|
7363
7835
|
className: "px-2 py-1 text-xs rounded-md bg-primary text-white hover:opacity-90",
|
|
7364
7836
|
onClick: () => {
|
|
7365
|
-
de.trim() &&
|
|
7837
|
+
de.trim() && X.chain().focus().setLink({ href: de.trim() }).run(), K("none");
|
|
7366
7838
|
},
|
|
7367
7839
|
children: "确定"
|
|
7368
7840
|
})]
|
|
7369
7841
|
})
|
|
7370
7842
|
})] }), document.body),
|
|
7371
|
-
!k && j &&
|
|
7843
|
+
!k && j && L(/* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
|
|
7372
7844
|
className: "fixed inset-0 z-[9998]",
|
|
7373
7845
|
onClick: () => M(!1)
|
|
7374
7846
|
}), /* @__PURE__ */ O("div", {
|
|
7375
7847
|
ref: z,
|
|
7376
7848
|
"data-lenis-prevent": !0,
|
|
7377
|
-
style:
|
|
7378
|
-
className: `ai-panel relative flex flex-col bg-background border border-default-200 rounded-xl shadow-xl${
|
|
7849
|
+
style: P,
|
|
7850
|
+
className: `ai-panel relative flex flex-col bg-background border border-default-200 rounded-xl shadow-xl${I === "above" ? " ai-panel--above" : ""}`,
|
|
7379
7851
|
onClick: (e) => e.stopPropagation(),
|
|
7380
7852
|
children: [/* @__PURE__ */ D("span", {
|
|
7381
7853
|
className: "ai-panel__arrow",
|
|
7382
7854
|
style: { left: `${re}%` },
|
|
7383
7855
|
"aria-hidden": "true"
|
|
7384
|
-
}), /* @__PURE__ */ D(
|
|
7385
|
-
editor:
|
|
7856
|
+
}), /* @__PURE__ */ D(ln, {
|
|
7857
|
+
editor: X,
|
|
7386
7858
|
onClose: () => M(!1)
|
|
7387
7859
|
})]
|
|
7388
7860
|
})] }), document.body),
|
|
7389
7861
|
B && /* @__PURE__ */ D(v, {
|
|
7390
|
-
fallback: /* @__PURE__ */ D(
|
|
7391
|
-
children: /* @__PURE__ */ D(
|
|
7862
|
+
fallback: /* @__PURE__ */ D($i, {}),
|
|
7863
|
+
children: /* @__PURE__ */ D(Ji, {
|
|
7392
7864
|
open: B,
|
|
7393
7865
|
onClose: () => V(!1),
|
|
7394
7866
|
onInsert: it,
|
|
7395
|
-
validate: (e) =>
|
|
7867
|
+
validate: (e) => X ? mn(X.state.doc, e, {
|
|
7396
7868
|
maxAttachmentSize: o,
|
|
7397
7869
|
maxTotalAttachmentSize: s
|
|
7398
7870
|
}) : null
|
|
7399
7871
|
})
|
|
7400
7872
|
}),
|
|
7401
7873
|
H && /* @__PURE__ */ D(v, {
|
|
7402
|
-
fallback: /* @__PURE__ */ D(
|
|
7403
|
-
children: /* @__PURE__ */ D(
|
|
7874
|
+
fallback: /* @__PURE__ */ D($i, {}),
|
|
7875
|
+
children: /* @__PURE__ */ D(Zi, {
|
|
7404
7876
|
open: H,
|
|
7405
7877
|
onClose: () => ae(!1),
|
|
7406
7878
|
onInsert: at
|
|
7407
7879
|
})
|
|
7408
7880
|
}),
|
|
7409
7881
|
oe && /* @__PURE__ */ D(v, {
|
|
7410
|
-
fallback: /* @__PURE__ */ D(
|
|
7411
|
-
children: /* @__PURE__ */ D(
|
|
7882
|
+
fallback: /* @__PURE__ */ D($i, {}),
|
|
7883
|
+
children: /* @__PURE__ */ D(Yi, {
|
|
7412
7884
|
open: oe,
|
|
7413
7885
|
onClose: () => U(!1)
|
|
7414
7886
|
})
|
|
7415
7887
|
}),
|
|
7416
7888
|
W && /* @__PURE__ */ D(v, {
|
|
7417
|
-
fallback: /* @__PURE__ */ D(
|
|
7418
|
-
children: /* @__PURE__ */ D(
|
|
7889
|
+
fallback: /* @__PURE__ */ D($i, {}),
|
|
7890
|
+
children: /* @__PURE__ */ D(Xi, {
|
|
7419
7891
|
open: W,
|
|
7420
|
-
onClose: () =>
|
|
7421
|
-
editor:
|
|
7892
|
+
onClose: () => se(!1),
|
|
7893
|
+
editor: X
|
|
7422
7894
|
})
|
|
7423
7895
|
}),
|
|
7424
|
-
|
|
7425
|
-
fallback: /* @__PURE__ */ D(
|
|
7426
|
-
children: /* @__PURE__ */ D(
|
|
7427
|
-
open: !!
|
|
7428
|
-
filename:
|
|
7896
|
+
J && /* @__PURE__ */ D(v, {
|
|
7897
|
+
fallback: /* @__PURE__ */ D($i, {}),
|
|
7898
|
+
children: /* @__PURE__ */ D(Qi, {
|
|
7899
|
+
open: !!J,
|
|
7900
|
+
filename: J.filename,
|
|
7429
7901
|
onRender: () => {
|
|
7430
|
-
|
|
7902
|
+
J.resolve("render"), pe(null);
|
|
7431
7903
|
},
|
|
7432
7904
|
onAttach: () => {
|
|
7433
|
-
|
|
7905
|
+
J.resolve("attach"), pe(null);
|
|
7434
7906
|
},
|
|
7435
7907
|
onClose: () => {
|
|
7436
|
-
|
|
7908
|
+
J.resolve(null), pe(null);
|
|
7437
7909
|
}
|
|
7438
7910
|
})
|
|
7439
7911
|
}),
|
|
7440
7912
|
/* @__PURE__ */ D("div", {
|
|
7441
|
-
ref:
|
|
7913
|
+
ref: Ee,
|
|
7442
7914
|
className: "flex editor-body",
|
|
7443
7915
|
children: /* @__PURE__ */ O("div", {
|
|
7444
7916
|
className: "relative min-w-0 flex-1",
|
|
7445
7917
|
children: [
|
|
7446
|
-
/* @__PURE__ */ D(
|
|
7447
|
-
!k && /* @__PURE__ */ D(
|
|
7918
|
+
/* @__PURE__ */ D(ee, { editor: X }),
|
|
7919
|
+
!k && /* @__PURE__ */ D(Bi, { editor: X }),
|
|
7448
7920
|
/* @__PURE__ */ D("div", {
|
|
7449
|
-
className: `${
|
|
7921
|
+
className: `${Y || Fe ? "fixed" : "absolute"} bottom-2 right-4 z-10 pointer-events-none select-none`,
|
|
7450
7922
|
children: /* @__PURE__ */ O("span", {
|
|
7451
|
-
className: `text-xs ${nt ? "bg-danger/10 text-danger font-medium px-2 py-0.5 rounded" : a &&
|
|
7923
|
+
className: `text-xs ${nt ? "bg-danger/10 text-danger font-medium px-2 py-0.5 rounded" : a && et > a * .9 ? "bg-warning/10 text-warning px-2 py-0.5 rounded" : "text-default-300"}`,
|
|
7452
7924
|
children: [
|
|
7453
|
-
|
|
7925
|
+
et,
|
|
7454
7926
|
a ? ` / ${a}` : "",
|
|
7455
7927
|
" 字"
|
|
7456
7928
|
]
|
|
@@ -7459,14 +7931,14 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7459
7931
|
]
|
|
7460
7932
|
})
|
|
7461
7933
|
}),
|
|
7462
|
-
h &&
|
|
7463
|
-
editor:
|
|
7464
|
-
onClose: () =>
|
|
7934
|
+
h && ve && /* @__PURE__ */ D(Mt, {
|
|
7935
|
+
editor: X,
|
|
7936
|
+
onClose: () => ye(!1)
|
|
7465
7937
|
}),
|
|
7466
|
-
|
|
7938
|
+
st && /* @__PURE__ */ D("button", {
|
|
7467
7939
|
type: "button",
|
|
7468
7940
|
className: "qingwu-toc-fab",
|
|
7469
|
-
onClick: () =>
|
|
7941
|
+
onClick: () => _e(!0),
|
|
7470
7942
|
title: "目录",
|
|
7471
7943
|
"aria-label": "打开目录",
|
|
7472
7944
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -7482,8 +7954,8 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7482
7954
|
})
|
|
7483
7955
|
})
|
|
7484
7956
|
}),
|
|
7485
|
-
|
|
7486
|
-
ref:
|
|
7957
|
+
ge && L(/* @__PURE__ */ O("div", {
|
|
7958
|
+
ref: Le,
|
|
7487
7959
|
className: "qingwu-toc-drawer toc-scroll",
|
|
7488
7960
|
"data-lenis-prevent": !0,
|
|
7489
7961
|
children: [/* @__PURE__ */ O("div", {
|
|
@@ -7494,7 +7966,7 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7494
7966
|
}), /* @__PURE__ */ D("button", {
|
|
7495
7967
|
type: "button",
|
|
7496
7968
|
className: "qed-drawer-head__close",
|
|
7497
|
-
onClick: () =>
|
|
7969
|
+
onClick: () => _e(!1),
|
|
7498
7970
|
"aria-label": "关闭目录",
|
|
7499
7971
|
children: /* @__PURE__ */ D("svg", {
|
|
7500
7972
|
fill: "none",
|
|
@@ -7509,21 +7981,21 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7509
7981
|
})
|
|
7510
7982
|
})
|
|
7511
7983
|
})]
|
|
7512
|
-
}), /* @__PURE__ */ D(
|
|
7513
|
-
editor:
|
|
7984
|
+
}), /* @__PURE__ */ D(mt, {
|
|
7985
|
+
editor: X,
|
|
7514
7986
|
className: "!p-3",
|
|
7515
7987
|
onClose: () => {
|
|
7516
|
-
|
|
7988
|
+
_e(!1), he(!1);
|
|
7517
7989
|
}
|
|
7518
7990
|
})]
|
|
7519
7991
|
}), document.body)
|
|
7520
7992
|
]
|
|
7521
|
-
}), ot &&
|
|
7522
|
-
ref:
|
|
7993
|
+
}), ot && L(/* @__PURE__ */ D("aside", {
|
|
7994
|
+
ref: Ae,
|
|
7523
7995
|
className: "qingwu-toc-desktop toc-scroll",
|
|
7524
|
-
children: /* @__PURE__ */ D(
|
|
7525
|
-
editor:
|
|
7526
|
-
onClose: () =>
|
|
7996
|
+
children: /* @__PURE__ */ D(mt, {
|
|
7997
|
+
editor: X,
|
|
7998
|
+
onClose: () => he(!1)
|
|
7527
7999
|
})
|
|
7528
8000
|
}), document.body)]
|
|
7529
8001
|
}) : /* @__PURE__ */ D("div", {
|
|
@@ -7533,7 +8005,7 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7533
8005
|
};
|
|
7534
8006
|
//#endregion
|
|
7535
8007
|
//#region src/editor/clipper/receiver-browser.ts
|
|
7536
|
-
function
|
|
8008
|
+
function ta(e) {
|
|
7537
8009
|
let t = async (t) => {
|
|
7538
8010
|
let n = t.data;
|
|
7539
8011
|
if (!n || typeof n != "object" || n.kind !== "qingwu-clip") return;
|
|
@@ -7550,7 +8022,7 @@ function Fi(e) {
|
|
|
7550
8022
|
}
|
|
7551
8023
|
//#endregion
|
|
7552
8024
|
//#region src/editor/storage/providers/cos.ts
|
|
7553
|
-
function
|
|
8025
|
+
function na(e) {
|
|
7554
8026
|
return g({
|
|
7555
8027
|
endpoint: `https://cos.${e.region}.myqcloud.com`,
|
|
7556
8028
|
bucket: e.bucket,
|
|
@@ -7564,7 +8036,7 @@ function Ii(e) {
|
|
|
7564
8036
|
}
|
|
7565
8037
|
//#endregion
|
|
7566
8038
|
//#region src/editor/storage/providers/oss.ts
|
|
7567
|
-
function
|
|
8039
|
+
function ra(e) {
|
|
7568
8040
|
return g({
|
|
7569
8041
|
endpoint: `https://${e.bucket}.${e.region}.aliyuncs.com`,
|
|
7570
8042
|
bucket: e.bucket,
|
|
@@ -7577,4 +8049,4 @@ function Li(e) {
|
|
|
7577
8049
|
});
|
|
7578
8050
|
}
|
|
7579
8051
|
//#endregion
|
|
7580
|
-
export {
|
|
8052
|
+
export { sr as CODE_LANGUAGES, pr as CodeBlock, Lr as ImageUpload, rt as ImageUploadDialog, ei as MathBlock, $r as MathInline, ea as QingWuAIEditor, Ti as RelativeMedia, At as SearchHighlight, mt as TocPanel, Xn as VideoEmbed, ht as buildSystemPrompt, _t as createAILanguageModelProvider, na as createCOSStorage, xt as createDeepSeekProvider, _ as createLocalStorage, ra as createOSSStorage, bt as createOpenAICompatProvider, St as createOpenAIProvider, Ct as createQwenProvider, g as createS3Storage, Di as createSlashCommandExtension, h as escapeHtml, fn as formatBytes, yt as getAIProvider, Pi as getBubbleMenuActions, Oi as getDefaultSlashCommands, dn as getDocAttachmentTotal, Ai as getEditorExtensions, u as getLocale, Ni as getSearchEngine, jt as getSearchState, c as getStorageInfo, o as getStorageProvider, s as loadStorageConfig, r as registerS3PreviewConfig, d as sanitizeHtml, p as sanitizeSvg, vt as setAIProvider, bn as setConfirmProvider, l as setLocale, Mi as setSearchEngine, i as setStorageProvider, et as setToastProvider, n as signPreviewUrlHeaders, ta as startBrowserClipperReceiver, tt as subscribeToast, f as t, m as tf, Z as toast, mn as validateAttachmentFile };
|