@qingwu-ui/ai-editor 1.1.8 → 1.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ai-settings-dialog.d.ts.map +1 -1
- package/dist/editor/ai/components/ai-selector.d.ts.map +1 -1
- package/dist/editor/ai/index.d.ts +11 -0
- package/dist/editor/ai/index.d.ts.map +1 -1
- package/dist/editor/ai/providers/deepseek.d.ts.map +1 -1
- package/dist/editor/ai/providers/openai-compat.d.ts.map +1 -1
- package/dist/editor/ai/providers/openai.d.ts.map +1 -1
- package/dist/editor/ai/providers/qwen.d.ts.map +1 -1
- package/dist/editor/extensions/chinese-emphasis.d.ts.map +1 -1
- package/dist/editor/i18n/en-US.d.ts +10 -0
- package/dist/editor/i18n/en-US.d.ts.map +1 -1
- package/dist/editor/i18n/zh-CN.d.ts +10 -0
- package/dist/editor/i18n/zh-CN.d.ts.map +1 -1
- package/dist/{export-dialog-Co3pPwTl.cjs → export-dialog-Bbcjve99.cjs} +1 -1
- package/dist/{export-dialog-Bnbjhxoc.js → export-dialog-BtkB6LbG.js} +1 -1
- package/dist/index.cjs +19 -15
- package/dist/index.js +829 -745
- package/dist/{sanitize-ths-sP-x.js → sanitize-DFL2uU6q.js} +20 -0
- package/dist/{sanitize-BebkUITX.cjs → sanitize-DgZP4RYI.cjs} +1 -1
- package/dist/{signed-fetch-BuPD4Q0V.cjs → signed-fetch-BEr-TrwK.cjs} +1 -1
- package/dist/{storage-settings-dialog-BPlrjhQc.cjs → storage-settings-dialog-aE92oAQF.cjs} +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/scripts/cli.mjs +0 -0
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { a as e, n as t, r as n, s as r, t as i } from "./signed-fetch-iBM0Zozv.js";
|
|
2
2
|
import { a, i as o, n as s, r as c, t as l } from "./storage-D68X3FCl.js";
|
|
3
|
-
import { a as u, i as d, n as f, o as p, r as m, s as h, t as g } from "./sanitize-
|
|
3
|
+
import { a as u, i as d, n as f, o as p, r as m, s as h, t as g } from "./sanitize-DFL2uU6q.js";
|
|
4
4
|
import { t as _ } from "./local-A1ZU5Y6C.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
|
-
import { DOMParser as
|
|
9
|
-
import { EditorContent as
|
|
8
|
+
import { DOMParser as ee, Fragment as j, Slice as M } from "@tiptap/pm/model";
|
|
9
|
+
import { EditorContent as N, NodeViewWrapper as P, ReactNodeViewRenderer as F, ReactRenderer as I, useEditor as te } from "@tiptap/react";
|
|
10
10
|
import { BubbleMenu as ne } from "@tiptap/react/menus";
|
|
11
11
|
import { createPortal as L } from "react-dom";
|
|
12
12
|
import { Extension as R, InputRule as re, Node as ie, markInputRule as z } from "@tiptap/core";
|
|
@@ -428,7 +428,7 @@ var nt = /* @__PURE__ */ r({ ImageUploadDialog: () => rt }), rt = ({ open: e, on
|
|
|
428
428
|
e.preventDefault(), c(!1);
|
|
429
429
|
let t = e.dataTransfer.files[0];
|
|
430
430
|
t && E(t);
|
|
431
|
-
}, [E]),
|
|
431
|
+
}, [E]), ee = b((e) => {
|
|
432
432
|
let t = e.clipboardData.items;
|
|
433
433
|
for (let n of Array.from(t)) if (n.type.startsWith("image/")) {
|
|
434
434
|
e.preventDefault();
|
|
@@ -436,13 +436,13 @@ var nt = /* @__PURE__ */ r({ ImageUploadDialog: () => rt }), rt = ({ open: e, on
|
|
|
436
436
|
t && E(t);
|
|
437
437
|
return;
|
|
438
438
|
}
|
|
439
|
-
}, [E]),
|
|
439
|
+
}, [E]), j = b(() => {
|
|
440
440
|
h.trim() && (n(h.trim()), C());
|
|
441
441
|
}, [
|
|
442
442
|
h,
|
|
443
443
|
n,
|
|
444
444
|
C
|
|
445
|
-
]),
|
|
445
|
+
]), M = b(() => {
|
|
446
446
|
_ && (n(_), C());
|
|
447
447
|
}, [
|
|
448
448
|
_,
|
|
@@ -456,7 +456,7 @@ var nt = /* @__PURE__ */ r({ ImageUploadDialog: () => rt }), rt = ({ open: e, on
|
|
|
456
456
|
onClick: C
|
|
457
457
|
}), /* @__PURE__ */ O("div", {
|
|
458
458
|
className: "relative w-[calc(100vw-2rem)] max-w-[420px] max-h-[90dvh] bg-background rounded-2xl shadow-2xl border border-default-200 overflow-hidden animate-in",
|
|
459
|
-
onPaste: i === "upload" ?
|
|
459
|
+
onPaste: i === "upload" ? ee : void 0,
|
|
460
460
|
children: [
|
|
461
461
|
/* @__PURE__ */ O("div", {
|
|
462
462
|
className: "flex items-center justify-between px-5 py-4 border-b border-default-100",
|
|
@@ -589,7 +589,7 @@ var nt = /* @__PURE__ */ r({ ImageUploadDialog: () => rt }), rt = ({ open: e, on
|
|
|
589
589
|
type: "button",
|
|
590
590
|
className: "flex-1 py-2 rounded-xl bg-primary text-white text-sm font-medium disabled:opacity-40 transition-opacity",
|
|
591
591
|
disabled: !_ || l,
|
|
592
|
-
onClick:
|
|
592
|
+
onClick: M,
|
|
593
593
|
children: "插入图片"
|
|
594
594
|
}), /* @__PURE__ */ D("button", {
|
|
595
595
|
type: "button",
|
|
@@ -630,7 +630,7 @@ var nt = /* @__PURE__ */ r({ ImageUploadDialog: () => rt }), rt = ({ open: e, on
|
|
|
630
630
|
value: h,
|
|
631
631
|
onChange: (e) => g(e.target.value),
|
|
632
632
|
onKeyDown: (e) => {
|
|
633
|
-
e.key === "Enter" &&
|
|
633
|
+
e.key === "Enter" && j();
|
|
634
634
|
}
|
|
635
635
|
})] }),
|
|
636
636
|
h && /* @__PURE__ */ D("div", {
|
|
@@ -648,7 +648,7 @@ var nt = /* @__PURE__ */ r({ ImageUploadDialog: () => rt }), rt = ({ open: e, on
|
|
|
648
648
|
type: "button",
|
|
649
649
|
className: "w-full py-2.5 rounded-xl bg-primary text-white text-sm font-medium disabled:opacity-40 transition-opacity",
|
|
650
650
|
disabled: !h.trim(),
|
|
651
|
-
onClick:
|
|
651
|
+
onClick: j,
|
|
652
652
|
children: "插入图片"
|
|
653
653
|
})
|
|
654
654
|
]
|
|
@@ -825,27 +825,27 @@ var ft = 84, pt = 3e3, mt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
825
825
|
top: window.scrollY + a - ft,
|
|
826
826
|
behavior: "smooth"
|
|
827
827
|
});
|
|
828
|
-
}, [e, _]), A = C(() => at(r), [r]),
|
|
828
|
+
}, [e, _]), A = C(() => at(r), [r]), ee = C(() => ot(A), [A]), j = C(() => {
|
|
829
829
|
let e = /* @__PURE__ */ new Map(), t = (n, r) => {
|
|
830
830
|
for (let i of n) r && e.set(i.id, r), t(i.children, i.id);
|
|
831
831
|
};
|
|
832
832
|
return t(A, ""), e;
|
|
833
|
-
}, [A]),
|
|
833
|
+
}, [A]), M = l.trim().length > 0, N = C(() => M ? ct(A, l.trim()) : A, [
|
|
834
834
|
A,
|
|
835
|
-
|
|
835
|
+
M,
|
|
836
836
|
l
|
|
837
|
-
]), P = C(() => st(
|
|
838
|
-
|
|
837
|
+
]), P = C(() => st(N, M ? /* @__PURE__ */ new Set() : s), [
|
|
838
|
+
N,
|
|
839
839
|
s,
|
|
840
|
-
|
|
840
|
+
M
|
|
841
841
|
]), F = C(() => new Set(P.map((e) => e.id)), [P]), I = C(() => {
|
|
842
842
|
let e = a;
|
|
843
|
-
for (; e && !F.has(e);) e =
|
|
843
|
+
for (; e && !F.has(e);) e = j.get(e) ?? "";
|
|
844
844
|
return e;
|
|
845
845
|
}, [
|
|
846
846
|
a,
|
|
847
847
|
F,
|
|
848
|
-
|
|
848
|
+
j
|
|
849
849
|
]);
|
|
850
850
|
x(() => {
|
|
851
851
|
let e = p.current;
|
|
@@ -863,8 +863,8 @@ var ft = 84, pt = 3e3, mt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
863
863
|
return n.has(e) ? n.delete(e) : n.add(e), n;
|
|
864
864
|
});
|
|
865
865
|
}, []), ne = b(() => {
|
|
866
|
-
c(new Set(
|
|
867
|
-
}, [
|
|
866
|
+
c(new Set(ee));
|
|
867
|
+
}, [ee]), L = b(() => {
|
|
868
868
|
c(/* @__PURE__ */ new Set());
|
|
869
869
|
}, []);
|
|
870
870
|
return r.length ? /* @__PURE__ */ O("nav", {
|
|
@@ -938,7 +938,7 @@ var ft = 84, pt = 3e3, mt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
938
938
|
onClick: ne,
|
|
939
939
|
title: "全部折叠",
|
|
940
940
|
"aria-label": "全部折叠",
|
|
941
|
-
disabled:
|
|
941
|
+
disabled: M,
|
|
942
942
|
children: /* @__PURE__ */ D("svg", {
|
|
943
943
|
width: "14",
|
|
944
944
|
height: "14",
|
|
@@ -959,7 +959,7 @@ var ft = 84, pt = 3e3, mt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
959
959
|
onClick: L,
|
|
960
960
|
title: "全部展开",
|
|
961
961
|
"aria-label": "全部展开",
|
|
962
|
-
disabled:
|
|
962
|
+
disabled: M,
|
|
963
963
|
children: /* @__PURE__ */ D("svg", {
|
|
964
964
|
width: "14",
|
|
965
965
|
height: "14",
|
|
@@ -1029,11 +1029,11 @@ var ft = 84, pt = 3e3, mt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
1029
1029
|
}),
|
|
1030
1030
|
P.length === 0 ? /* @__PURE__ */ D("div", {
|
|
1031
1031
|
className: "toc-search__empty",
|
|
1032
|
-
children:
|
|
1032
|
+
children: M ? `未找到"${l.trim()}"相关标题` : "文档暂无标题"
|
|
1033
1033
|
}) : /* @__PURE__ */ D("ul", {
|
|
1034
1034
|
className: "toc-list",
|
|
1035
1035
|
children: P.map((e) => {
|
|
1036
|
-
let t =
|
|
1036
|
+
let t = ee.has(e.id), n = s.has(e.id);
|
|
1037
1037
|
return /* @__PURE__ */ O("li", {
|
|
1038
1038
|
"data-toc-id": e.id,
|
|
1039
1039
|
className: `toc-item ${I === e.id ? "is-active" : ""}`,
|
|
@@ -1065,7 +1065,7 @@ var ft = 84, pt = 3e3, mt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
1065
1065
|
title: e.text,
|
|
1066
1066
|
children: /* @__PURE__ */ D("span", {
|
|
1067
1067
|
className: "toc-text",
|
|
1068
|
-
children:
|
|
1068
|
+
children: M ? dt(e.text, l.trim()) : e.text
|
|
1069
1069
|
})
|
|
1070
1070
|
})]
|
|
1071
1071
|
}, e.id);
|
|
@@ -1087,64 +1087,11 @@ var ft = 84, pt = 3e3, mt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
1087
1087
|
})]
|
|
1088
1088
|
});
|
|
1089
1089
|
};
|
|
1090
|
-
// src/editor/ai/index.ts
|
|
1091
|
-
function ht(e, t) {
|
|
1092
|
-
return {
|
|
1093
|
-
continue: "你是一个写作助手。请从下文尾部自然流畅地续写内容,保持风格一致。只输出续写的内容,不要加任何前缀说明。",
|
|
1094
|
-
improve: "你是一个文字润色专家。请优化以下文本的表达,提升文采和流畅度,保持原意不变。只输出润色后的文本。",
|
|
1095
|
-
shorter: "你是一个精简专家。请将以下文本精简,保留核心信息,删除冗余。只输出精简后的文本。",
|
|
1096
|
-
longer: "你是一个内容扩写专家。请丰富以下文本的细节和层次,增加深度。只输出扩写后的文本。",
|
|
1097
|
-
fix: "你是一个校对专家。请修正以下文本中的语法错误、错别字和标点问题。只输出修正后的文本。",
|
|
1098
|
-
translate: "你是一个翻译专家。请将以下文本翻译为英文。只输出翻译后的文本。",
|
|
1099
|
-
zap: t || "你是一个全能的 AI 写作助手。请根据用户的指令处理文本。"
|
|
1100
|
-
}[e];
|
|
1101
|
-
}
|
|
1102
|
-
var gt = null;
|
|
1103
|
-
async function _t(e) {
|
|
1104
|
-
let t;
|
|
1105
|
-
try {
|
|
1106
|
-
({createOpenAI: t} = await import("@ai-sdk/openai"));
|
|
1107
|
-
} catch {
|
|
1108
|
-
throw Error("缺少可选依赖 @ai-sdk/openai。使用默认 provider 请先安装:npm i @ai-sdk/openai;或调用 setAIProvider() 注册自定义 provider。");
|
|
1109
|
-
}
|
|
1110
|
-
let n = t({
|
|
1111
|
-
apiKey: e.apiKey,
|
|
1112
|
-
baseURL: e.baseURL
|
|
1113
|
-
}).chat(e.model);
|
|
1114
|
-
return {
|
|
1115
|
-
async *stream(e) {
|
|
1116
|
-
let t = await A({
|
|
1117
|
-
model: n,
|
|
1118
|
-
system: ht(e.mode, e.instruction),
|
|
1119
|
-
prompt: e.context,
|
|
1120
|
-
temperature: .7,
|
|
1121
|
-
maxOutputTokens: 2048
|
|
1122
|
-
});
|
|
1123
|
-
for await (let e of t.textStream) yield e;
|
|
1124
|
-
},
|
|
1125
|
-
async generate(e) {
|
|
1126
|
-
return (await k({
|
|
1127
|
-
model: n,
|
|
1128
|
-
system: ht(e.mode, e.instruction),
|
|
1129
|
-
prompt: e.context,
|
|
1130
|
-
temperature: .7,
|
|
1131
|
-
maxOutputTokens: 2048
|
|
1132
|
-
})).text;
|
|
1133
|
-
}
|
|
1134
|
-
};
|
|
1135
|
-
}
|
|
1136
|
-
function vt(e) {
|
|
1137
|
-
gt = e;
|
|
1138
|
-
}
|
|
1139
|
-
function yt() {
|
|
1140
|
-
if (!gt) throw Error("未配置 AI 服务。请调用 createAILanguageModelProvider() 创建并通过 setAIProvider() 注册。");
|
|
1141
|
-
return gt;
|
|
1142
|
-
}
|
|
1143
1090
|
// src/editor/ai/providers/openai-compat.ts
|
|
1144
|
-
function
|
|
1091
|
+
function ht(e) {
|
|
1145
1092
|
let { apiKey: t, baseURL: n, model: r, headers: i } = e;
|
|
1146
|
-
async function* a(
|
|
1147
|
-
let
|
|
1093
|
+
async function* a(a, o, s) {
|
|
1094
|
+
let c = await fetch(`${n}/chat/completions`, {
|
|
1148
1095
|
method: "POST",
|
|
1149
1096
|
headers: {
|
|
1150
1097
|
"Content-Type": "application/json",
|
|
@@ -1155,94 +1102,185 @@ function bt(e) {
|
|
|
1155
1102
|
model: r,
|
|
1156
1103
|
messages: [{
|
|
1157
1104
|
role: "system",
|
|
1158
|
-
content:
|
|
1105
|
+
content: a
|
|
1159
1106
|
}, {
|
|
1160
1107
|
role: "user",
|
|
1161
|
-
content:
|
|
1108
|
+
content: o
|
|
1162
1109
|
}],
|
|
1163
1110
|
stream: !0,
|
|
1164
1111
|
temperature: .7,
|
|
1165
|
-
max_tokens:
|
|
1112
|
+
max_tokens: e.maxOutputTokens ?? 8192,
|
|
1113
|
+
reasoning_effort: e.reasoningEffort
|
|
1166
1114
|
})
|
|
1167
1115
|
});
|
|
1168
|
-
if (!
|
|
1169
|
-
let e = await
|
|
1170
|
-
throw Error(`AI API 错误 (${
|
|
1116
|
+
if (!c.ok) {
|
|
1117
|
+
let e = await c.text();
|
|
1118
|
+
throw Error(`AI API 错误 (${c.status}): ${e}`);
|
|
1171
1119
|
}
|
|
1172
|
-
let
|
|
1173
|
-
if (!
|
|
1174
|
-
let
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1120
|
+
let l = c.body?.getReader();
|
|
1121
|
+
if (!l) throw Error("无法读取响应流");
|
|
1122
|
+
let u = new TextDecoder(), d = "", f = "", p, m = !1;
|
|
1123
|
+
try {
|
|
1124
|
+
for (; !m;) {
|
|
1125
|
+
let { done: e, value: t } = await l.read();
|
|
1126
|
+
d += u.decode(t, { stream: !e });
|
|
1127
|
+
let n = d.split("\n");
|
|
1128
|
+
d = e ? "" : n.pop() || "";
|
|
1129
|
+
for (let e of n) {
|
|
1130
|
+
let t = e.trim();
|
|
1131
|
+
if (!t.startsWith("data:")) continue;
|
|
1132
|
+
let n = t.slice(5).trim();
|
|
1133
|
+
if (n === "[DONE]") {
|
|
1134
|
+
m = !0;
|
|
1135
|
+
break;
|
|
1136
|
+
}
|
|
1137
|
+
let r;
|
|
1138
|
+
try {
|
|
1139
|
+
r = JSON.parse(n);
|
|
1140
|
+
} catch {
|
|
1141
|
+
continue;
|
|
1142
|
+
}
|
|
1143
|
+
if (r.error) throw Error(r.error.message || "AI API 错误");
|
|
1144
|
+
let i = r.choices?.[0];
|
|
1145
|
+
i?.finish_reason && (p = i.finish_reason), i?.delta?.reasoning_content && s?.(i.delta.reasoning_content);
|
|
1146
|
+
let a = i?.delta?.content;
|
|
1147
|
+
a && (f += a, yield a);
|
|
1148
|
+
}
|
|
1149
|
+
if (e) break;
|
|
1150
|
+
}
|
|
1151
|
+
gt(f, p);
|
|
1152
|
+
} finally {
|
|
1153
|
+
try {
|
|
1154
|
+
await l.cancel();
|
|
1155
|
+
} finally {
|
|
1156
|
+
l.releaseLock();
|
|
1190
1157
|
}
|
|
1191
1158
|
}
|
|
1192
1159
|
}
|
|
1193
1160
|
return {
|
|
1194
1161
|
async *stream(e) {
|
|
1195
|
-
yield* a(
|
|
1162
|
+
yield* a(_t(e.mode, e.instruction), e.context, e.onReasoning);
|
|
1196
1163
|
},
|
|
1197
1164
|
async generate(e) {
|
|
1198
|
-
let t =
|
|
1165
|
+
let t = _t(e.mode, e.instruction), n = "";
|
|
1199
1166
|
for await (let r of a(t, e.context)) n += r;
|
|
1200
1167
|
return n;
|
|
1201
1168
|
}
|
|
1202
1169
|
};
|
|
1203
1170
|
}
|
|
1171
|
+
function gt(e, t) {
|
|
1172
|
+
if (!e.trim()) throw Error(p(t === "length" ? "editor.ai.outputLimit" : "editor.ai.emptyResult"));
|
|
1173
|
+
}
|
|
1174
|
+
function _t(e, t) {
|
|
1175
|
+
return {
|
|
1176
|
+
continue: "你是一个写作助手。请从下文尾部自然流畅地续写内容,保持风格一致。只输出续写的内容,不要加任何前缀说明。",
|
|
1177
|
+
improve: "你是一个文字润色专家。请优化以下文本的表达,提升文采和流畅度,保持原意不变。只输出润色后的文本。",
|
|
1178
|
+
shorter: "你是一个精简专家。请将以下文本精简,保留核心信息,删除冗余。只输出精简后的文本。",
|
|
1179
|
+
longer: "你是一个内容扩写专家。请丰富以下文本的细节和层次,增加深度。只输出扩写后的文本。",
|
|
1180
|
+
fix: "你是一个校对专家。请修正以下文本中的语法错误、错别字和标点问题。只输出修正后的文本。",
|
|
1181
|
+
translate: "你是一个翻译专家。请将以下文本翻译为英文。只输出翻译后的文本。",
|
|
1182
|
+
zap: t || "你是一个全能的 AI 写作助手。请根据用户的指令处理文本。"
|
|
1183
|
+
}[e];
|
|
1184
|
+
}
|
|
1185
|
+
var vt = null;
|
|
1186
|
+
async function yt(e) {
|
|
1187
|
+
let t;
|
|
1188
|
+
try {
|
|
1189
|
+
({createOpenAI: t} = await import("@ai-sdk/openai"));
|
|
1190
|
+
} catch {
|
|
1191
|
+
throw Error("缺少可选依赖 @ai-sdk/openai。使用默认 provider 请先安装:npm i @ai-sdk/openai;或调用 setAIProvider() 注册自定义 provider。");
|
|
1192
|
+
}
|
|
1193
|
+
let n = t({
|
|
1194
|
+
apiKey: e.apiKey,
|
|
1195
|
+
baseURL: e.baseURL
|
|
1196
|
+
}).chat(e.model), r = ht(e);
|
|
1197
|
+
async function* i(t) {
|
|
1198
|
+
let r = A({
|
|
1199
|
+
model: n,
|
|
1200
|
+
system: _t(t.mode, t.instruction),
|
|
1201
|
+
prompt: t.context,
|
|
1202
|
+
temperature: .7,
|
|
1203
|
+
maxOutputTokens: e.maxOutputTokens ?? 8192,
|
|
1204
|
+
providerOptions: { openai: { reasoningEffort: e.reasoningEffort } }
|
|
1205
|
+
}), i = "", a;
|
|
1206
|
+
for await (let e of r.fullStream) {
|
|
1207
|
+
if (e.type === "error") throw e.error instanceof Error ? e.error : Error(e.error?.message || p("editor.ai.error"));
|
|
1208
|
+
e.type === "finish" && (a = e.finishReason), e.type === "reasoning-delta" && t.onReasoning?.(e.text), e.type === "text-delta" && (i += e.text, yield e.text);
|
|
1209
|
+
}
|
|
1210
|
+
gt(i, a);
|
|
1211
|
+
}
|
|
1212
|
+
return {
|
|
1213
|
+
stream(t) {
|
|
1214
|
+
return new URL(e.baseURL).hostname === "api.openai.com" ? i(t) : r.stream(t);
|
|
1215
|
+
},
|
|
1216
|
+
async generate(t) {
|
|
1217
|
+
let r = await k({
|
|
1218
|
+
model: n,
|
|
1219
|
+
system: _t(t.mode, t.instruction),
|
|
1220
|
+
prompt: t.context,
|
|
1221
|
+
temperature: .7,
|
|
1222
|
+
maxOutputTokens: e.maxOutputTokens ?? 8192,
|
|
1223
|
+
providerOptions: { openai: { reasoningEffort: e.reasoningEffort } }
|
|
1224
|
+
});
|
|
1225
|
+
return gt(r.text, r.finishReason), r.text;
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1228
|
+
}
|
|
1229
|
+
function bt(e) {
|
|
1230
|
+
vt = e;
|
|
1231
|
+
}
|
|
1232
|
+
function xt() {
|
|
1233
|
+
if (!vt) throw Error("未配置 AI 服务。请调用 createAILanguageModelProvider() 创建并通过 setAIProvider() 注册。");
|
|
1234
|
+
return vt;
|
|
1235
|
+
}
|
|
1204
1236
|
// src/editor/ai/providers/deepseek.ts
|
|
1205
|
-
function
|
|
1206
|
-
return
|
|
1237
|
+
function St(e) {
|
|
1238
|
+
return ht({
|
|
1207
1239
|
apiKey: e.apiKey,
|
|
1208
1240
|
baseURL: e.baseURL || "https://api.deepseek.com/v1",
|
|
1209
1241
|
model: e.model || "deepseek-v4-flash",
|
|
1210
|
-
headers: e.headers
|
|
1242
|
+
headers: e.headers,
|
|
1243
|
+
maxOutputTokens: e.maxOutputTokens,
|
|
1244
|
+
reasoningEffort: e.reasoningEffort
|
|
1211
1245
|
});
|
|
1212
1246
|
}
|
|
1213
1247
|
// src/editor/ai/providers/openai.ts
|
|
1214
|
-
function
|
|
1215
|
-
return
|
|
1248
|
+
function Ct(e) {
|
|
1249
|
+
return ht({
|
|
1216
1250
|
apiKey: e.apiKey,
|
|
1217
1251
|
baseURL: e.baseURL || "https://api.openai.com/v1",
|
|
1218
1252
|
model: e.model || "gpt-5.6-luna",
|
|
1219
|
-
headers: e.headers
|
|
1253
|
+
headers: e.headers,
|
|
1254
|
+
maxOutputTokens: e.maxOutputTokens,
|
|
1255
|
+
reasoningEffort: e.reasoningEffort
|
|
1220
1256
|
});
|
|
1221
1257
|
}
|
|
1222
1258
|
// src/editor/ai/providers/qwen.ts
|
|
1223
|
-
function
|
|
1224
|
-
return
|
|
1259
|
+
function wt(e) {
|
|
1260
|
+
return ht({
|
|
1225
1261
|
apiKey: e.apiKey,
|
|
1226
1262
|
baseURL: e.baseURL || "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
1227
1263
|
model: e.model || "qwen3.7-plus",
|
|
1228
|
-
headers: e.headers
|
|
1264
|
+
headers: e.headers,
|
|
1265
|
+
maxOutputTokens: e.maxOutputTokens,
|
|
1266
|
+
reasoningEffort: e.reasoningEffort
|
|
1229
1267
|
});
|
|
1230
1268
|
}
|
|
1231
1269
|
// src/editor/extensions/search-highlight.ts
|
|
1232
|
-
var
|
|
1270
|
+
var Tt = {
|
|
1233
1271
|
keyword: "",
|
|
1234
1272
|
caseSensitive: !1,
|
|
1235
1273
|
wholeWord: !1,
|
|
1236
1274
|
matches: [],
|
|
1237
1275
|
currentIndex: -1
|
|
1238
|
-
},
|
|
1239
|
-
function
|
|
1276
|
+
}, Et = new H("search-highlight");
|
|
1277
|
+
function Dt(e) {
|
|
1240
1278
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1241
1279
|
}
|
|
1242
|
-
function
|
|
1280
|
+
function Ot(e, t) {
|
|
1243
1281
|
let { keyword: n, caseSensitive: r, wholeWord: i } = t;
|
|
1244
1282
|
if (!n) return [];
|
|
1245
|
-
let a = r ? "g" : "gi", o = i ? `\\b${
|
|
1283
|
+
let a = r ? "g" : "gi", o = i ? `\\b${Dt(n)}\\b` : Dt(n), s = new RegExp(o, a), c = [];
|
|
1246
1284
|
return e.descendants((e, t) => {
|
|
1247
1285
|
if (!e.isText || !e.text) return;
|
|
1248
1286
|
s.lastIndex = 0;
|
|
@@ -1256,12 +1294,12 @@ function Dt(e, t) {
|
|
|
1256
1294
|
}
|
|
1257
1295
|
}), c;
|
|
1258
1296
|
}
|
|
1259
|
-
function
|
|
1297
|
+
function kt(e, t) {
|
|
1260
1298
|
if (t.matches.length === 0) return U.empty;
|
|
1261
1299
|
let n = t.matches.map((e, n) => oe.inline(e.from, e.to, { class: n === t.currentIndex ? "search-highlight search-highlight--active" : "search-highlight" }));
|
|
1262
1300
|
return U.create(e, n);
|
|
1263
1301
|
}
|
|
1264
|
-
function
|
|
1302
|
+
function At(e, t) {
|
|
1265
1303
|
if (t.currentIndex < 0 || t.currentIndex >= t.matches.length) return;
|
|
1266
1304
|
let n = t.matches[t.currentIndex];
|
|
1267
1305
|
n && requestAnimationFrame(() => {
|
|
@@ -1286,15 +1324,15 @@ function kt(e, t) {
|
|
|
1286
1324
|
} catch {}
|
|
1287
1325
|
});
|
|
1288
1326
|
}
|
|
1289
|
-
var
|
|
1327
|
+
var jt = R.create({
|
|
1290
1328
|
name: "searchHighlight",
|
|
1291
1329
|
addProseMirrorPlugins() {
|
|
1292
1330
|
return [new V({
|
|
1293
|
-
key:
|
|
1331
|
+
key: Et,
|
|
1294
1332
|
state: {
|
|
1295
|
-
init: () =>
|
|
1333
|
+
init: () => Tt,
|
|
1296
1334
|
apply(e, t) {
|
|
1297
|
-
let n = e.getMeta(
|
|
1335
|
+
let n = e.getMeta(Et);
|
|
1298
1336
|
if (n) return {
|
|
1299
1337
|
...t,
|
|
1300
1338
|
...n,
|
|
@@ -1302,7 +1340,7 @@ var At = R.create({
|
|
|
1302
1340
|
currentIndex: n.currentIndex === void 0 ? t.currentIndex : n.currentIndex
|
|
1303
1341
|
};
|
|
1304
1342
|
if (e.docChanged && t.keyword) {
|
|
1305
|
-
let n =
|
|
1343
|
+
let n = Ot(e.doc, t), r = t.currentIndex;
|
|
1306
1344
|
return r >= n.length && (r = n.length - 1), r < 0 && (r = n.length > 0 ? 0 : -1), {
|
|
1307
1345
|
...t,
|
|
1308
1346
|
matches: n,
|
|
@@ -1313,51 +1351,51 @@ var At = R.create({
|
|
|
1313
1351
|
}
|
|
1314
1352
|
},
|
|
1315
1353
|
props: { decorations(e) {
|
|
1316
|
-
let t =
|
|
1317
|
-
return t ?
|
|
1354
|
+
let t = Et.getState(e);
|
|
1355
|
+
return t ? kt(e.doc, t) : U.empty;
|
|
1318
1356
|
} }
|
|
1319
1357
|
})];
|
|
1320
1358
|
},
|
|
1321
1359
|
addCommands() {
|
|
1322
1360
|
return {
|
|
1323
1361
|
setSearch: (e, t = {}) => ({ state: n, dispatch: r, view: i }) => {
|
|
1324
|
-
let a =
|
|
1362
|
+
let a = Et.getState(n) || Tt, o = {
|
|
1325
1363
|
keyword: e,
|
|
1326
1364
|
caseSensitive: t.caseSensitive ?? a.caseSensitive,
|
|
1327
1365
|
wholeWord: t.wholeWord ?? a.wholeWord,
|
|
1328
1366
|
matches: [],
|
|
1329
1367
|
currentIndex: -1
|
|
1330
1368
|
};
|
|
1331
|
-
return o.matches =
|
|
1369
|
+
return o.matches = Ot(n.doc, o), o.currentIndex = o.matches.length > 0 ? 0 : -1, r && (r(n.tr.setMeta(Et, o)), i && At(i, o)), !0;
|
|
1332
1370
|
},
|
|
1333
1371
|
nextMatch: () => ({ state: e, dispatch: t, view: n }) => {
|
|
1334
|
-
let r =
|
|
1372
|
+
let r = Et.getState(e) || Tt;
|
|
1335
1373
|
if (r.matches.length === 0) return !1;
|
|
1336
1374
|
let i = (r.currentIndex + 1) % r.matches.length;
|
|
1337
|
-
return t && (t(e.tr.setMeta(
|
|
1375
|
+
return t && (t(e.tr.setMeta(Et, { currentIndex: i })), n && At(n, {
|
|
1338
1376
|
...r,
|
|
1339
1377
|
currentIndex: i
|
|
1340
1378
|
})), !0;
|
|
1341
1379
|
},
|
|
1342
1380
|
prevMatch: () => ({ state: e, dispatch: t, view: n }) => {
|
|
1343
|
-
let r =
|
|
1381
|
+
let r = Et.getState(e) || Tt;
|
|
1344
1382
|
if (r.matches.length === 0) return !1;
|
|
1345
1383
|
let i = (r.currentIndex - 1 + r.matches.length) % r.matches.length;
|
|
1346
|
-
return t && (t(e.tr.setMeta(
|
|
1384
|
+
return t && (t(e.tr.setMeta(Et, { currentIndex: i })), n && At(n, {
|
|
1347
1385
|
...r,
|
|
1348
1386
|
currentIndex: i
|
|
1349
1387
|
})), !0;
|
|
1350
1388
|
},
|
|
1351
|
-
clearSearch: () => ({ state: e, dispatch: t }) => (t && t(e.tr.setMeta(
|
|
1389
|
+
clearSearch: () => ({ state: e, dispatch: t }) => (t && t(e.tr.setMeta(Et, Tt)), !0)
|
|
1352
1390
|
};
|
|
1353
1391
|
}
|
|
1354
1392
|
});
|
|
1355
|
-
function
|
|
1393
|
+
function Mt(e) {
|
|
1356
1394
|
let t = e.state;
|
|
1357
|
-
return
|
|
1395
|
+
return Et.getState(t) || Tt;
|
|
1358
1396
|
}
|
|
1359
1397
|
// src/components/search-bar.tsx
|
|
1360
|
-
var
|
|
1398
|
+
var Nt = ({ editor: e, onClose: t }) => {
|
|
1361
1399
|
let [n, r] = T(""), [i, a] = T(!1), [o, s] = T(!1), [c, l] = T(0), u = w(null), d = w({
|
|
1362
1400
|
keyword: n,
|
|
1363
1401
|
caseSensitive: i,
|
|
@@ -1422,7 +1460,7 @@ var Mt = ({ editor: e, onClose: t }) => {
|
|
|
1422
1460
|
}, [f, p]), h = C(() => {
|
|
1423
1461
|
if (!e) return null;
|
|
1424
1462
|
try {
|
|
1425
|
-
return
|
|
1463
|
+
return Mt(e);
|
|
1426
1464
|
} catch {
|
|
1427
1465
|
return null;
|
|
1428
1466
|
}
|
|
@@ -1573,36 +1611,36 @@ function Q({ children: e, ...t }) {
|
|
|
1573
1611
|
children: e
|
|
1574
1612
|
});
|
|
1575
1613
|
}
|
|
1576
|
-
var
|
|
1614
|
+
var Pt = (e) => /* @__PURE__ */ O(Q, {
|
|
1577
1615
|
...e,
|
|
1578
1616
|
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" })]
|
|
1579
|
-
}),
|
|
1617
|
+
}), Ft = (e) => /* @__PURE__ */ O(Q, {
|
|
1580
1618
|
...e,
|
|
1581
1619
|
children: [
|
|
1582
1620
|
/* @__PURE__ */ D("path", { d: "M19 4h-9" }),
|
|
1583
1621
|
/* @__PURE__ */ D("path", { d: "M14 20H5" }),
|
|
1584
1622
|
/* @__PURE__ */ D("path", { d: "M15 4 9 20" })
|
|
1585
1623
|
]
|
|
1586
|
-
}),
|
|
1624
|
+
}), It = (e) => /* @__PURE__ */ O(Q, {
|
|
1587
1625
|
...e,
|
|
1588
1626
|
children: [/* @__PURE__ */ D("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }), /* @__PURE__ */ D("path", { d: "M4 20h16" })]
|
|
1589
|
-
}),
|
|
1627
|
+
}), Lt = (e) => /* @__PURE__ */ O(Q, {
|
|
1590
1628
|
...e,
|
|
1591
1629
|
children: [
|
|
1592
1630
|
/* @__PURE__ */ D("path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }),
|
|
1593
1631
|
/* @__PURE__ */ D("path", { d: "M14 12a4 4 0 0 1 0 8H6" }),
|
|
1594
1632
|
/* @__PURE__ */ D("path", { d: "M4 12h16" })
|
|
1595
1633
|
]
|
|
1596
|
-
}),
|
|
1634
|
+
}), Rt = (e) => /* @__PURE__ */ O(Q, {
|
|
1597
1635
|
...e,
|
|
1598
1636
|
children: [/* @__PURE__ */ D("path", { d: "m16 18 6-6-6-6" }), /* @__PURE__ */ D("path", { d: "m8 6-6 6 6 6" })]
|
|
1599
|
-
}),
|
|
1637
|
+
}), zt = (e) => /* @__PURE__ */ O(Q, {
|
|
1600
1638
|
...e,
|
|
1601
1639
|
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" })]
|
|
1602
|
-
}),
|
|
1640
|
+
}), Bt = (e) => /* @__PURE__ */ O(Q, {
|
|
1603
1641
|
...e,
|
|
1604
1642
|
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" })]
|
|
1605
|
-
}),
|
|
1643
|
+
}), Vt = (e) => /* @__PURE__ */ O(Q, {
|
|
1606
1644
|
...e,
|
|
1607
1645
|
children: [/* @__PURE__ */ D("rect", {
|
|
1608
1646
|
x: "3",
|
|
@@ -1612,7 +1650,7 @@ var Nt = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1612
1650
|
rx: "2",
|
|
1613
1651
|
ry: "2"
|
|
1614
1652
|
}), /* @__PURE__ */ D("path", { d: "M3 9h18M3 15h18M9 3v18M15 3v18" })]
|
|
1615
|
-
}),
|
|
1653
|
+
}), Ht = (e) => /* @__PURE__ */ O(Q, {
|
|
1616
1654
|
...e,
|
|
1617
1655
|
children: [/* @__PURE__ */ D("rect", {
|
|
1618
1656
|
x: "8",
|
|
@@ -1622,20 +1660,20 @@ var Nt = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1622
1660
|
rx: "2",
|
|
1623
1661
|
ry: "2"
|
|
1624
1662
|
}), /* @__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" })]
|
|
1625
|
-
}),
|
|
1663
|
+
}), Ut = (e) => /* @__PURE__ */ O(Q, {
|
|
1626
1664
|
...e,
|
|
1627
1665
|
children: [/* @__PURE__ */ D("circle", {
|
|
1628
1666
|
cx: "11",
|
|
1629
1667
|
cy: "11",
|
|
1630
1668
|
r: "8"
|
|
1631
1669
|
}), /* @__PURE__ */ D("path", { d: "m21 21-4.3-4.3" })]
|
|
1632
|
-
}),
|
|
1670
|
+
}), Wt = (e) => /* @__PURE__ */ O(Q, {
|
|
1633
1671
|
...e,
|
|
1634
1672
|
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" })]
|
|
1635
|
-
}),
|
|
1673
|
+
}), Gt = (e) => /* @__PURE__ */ D(Q, {
|
|
1636
1674
|
...e,
|
|
1637
1675
|
children: /* @__PURE__ */ D("path", { d: "M18 5H6l6 7-6 7h12" })
|
|
1638
|
-
}),
|
|
1676
|
+
}), Kt = (e) => /* @__PURE__ */ O(Q, {
|
|
1639
1677
|
...e,
|
|
1640
1678
|
children: [
|
|
1641
1679
|
/* @__PURE__ */ D("circle", {
|
|
@@ -1654,12 +1692,12 @@ var Nt = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1654
1692
|
r: "1"
|
|
1655
1693
|
})
|
|
1656
1694
|
]
|
|
1657
|
-
}),
|
|
1695
|
+
}), qt = (e) => /* @__PURE__ */ O(Q, {
|
|
1658
1696
|
...e,
|
|
1659
1697
|
children: [/* @__PURE__ */ D("path", { d: "M18 6 6 18" }), /* @__PURE__ */ D("path", { d: "m6 6 12 12" })]
|
|
1660
1698
|
});
|
|
1661
1699
|
// src/editor/storage/remove-resource.ts
|
|
1662
|
-
async function
|
|
1700
|
+
async function Jt(e) {
|
|
1663
1701
|
if (e) {
|
|
1664
1702
|
if (e.startsWith("blob:")) URL.revokeObjectURL(e);
|
|
1665
1703
|
else try {
|
|
@@ -1670,60 +1708,60 @@ async function qt(e) {
|
|
|
1670
1708
|
}
|
|
1671
1709
|
}
|
|
1672
1710
|
// src/editor/ai/pending-removal.ts
|
|
1673
|
-
var
|
|
1711
|
+
var Yt = 3e4, Xt = /* @__PURE__ */ new Set([
|
|
1674
1712
|
"image",
|
|
1675
1713
|
"attachmentEmbed",
|
|
1676
1714
|
"audioEmbed",
|
|
1677
1715
|
"videoEmbed"
|
|
1678
|
-
]),
|
|
1679
|
-
function
|
|
1716
|
+
]), Zt = /* @__PURE__ */ new WeakMap();
|
|
1717
|
+
function Qt(e) {
|
|
1680
1718
|
let t = /* @__PURE__ */ new Set();
|
|
1681
1719
|
return e.state.doc.descendants((e) => {
|
|
1682
|
-
if (
|
|
1720
|
+
if (Xt.has(e.type.name)) {
|
|
1683
1721
|
let n = e.attrs.src;
|
|
1684
1722
|
n && t.add(n);
|
|
1685
1723
|
}
|
|
1686
1724
|
return !0;
|
|
1687
1725
|
}), t;
|
|
1688
1726
|
}
|
|
1689
|
-
function
|
|
1690
|
-
let t =
|
|
1727
|
+
function $t(e) {
|
|
1728
|
+
let t = Zt.get(e);
|
|
1691
1729
|
return t || (t = {
|
|
1692
1730
|
timers: /* @__PURE__ */ new Map(),
|
|
1693
1731
|
onTransaction: () => {},
|
|
1694
1732
|
listening: !1
|
|
1695
|
-
},
|
|
1733
|
+
}, Zt.set(e, t)), t;
|
|
1696
1734
|
}
|
|
1697
|
-
function
|
|
1735
|
+
function en(e, t) {
|
|
1698
1736
|
let n = [...new Set(t.filter(Boolean))];
|
|
1699
1737
|
if (n.length === 0) return;
|
|
1700
|
-
let r =
|
|
1738
|
+
let r = $t(e);
|
|
1701
1739
|
r.listening ||= (r.onTransaction = () => {
|
|
1702
1740
|
if (r.timers.size === 0) return;
|
|
1703
|
-
let t =
|
|
1741
|
+
let t = Qt(e);
|
|
1704
1742
|
for (let [e, n] of r.timers) t.has(e) && (clearTimeout(n), r.timers.delete(e));
|
|
1705
1743
|
}, e.on("transaction", r.onTransaction), !0);
|
|
1706
1744
|
for (let t of n) {
|
|
1707
1745
|
if (r.timers.has(t)) continue;
|
|
1708
1746
|
let n = setTimeout(() => {
|
|
1709
|
-
|
|
1710
|
-
},
|
|
1747
|
+
Qt(e).has(t) || Jt(t), r.timers.delete(t);
|
|
1748
|
+
}, Yt);
|
|
1711
1749
|
r.timers.set(t, n);
|
|
1712
1750
|
}
|
|
1713
1751
|
}
|
|
1714
|
-
function
|
|
1715
|
-
let t =
|
|
1752
|
+
function tn(e) {
|
|
1753
|
+
let t = Zt.get(e);
|
|
1716
1754
|
if (t) {
|
|
1717
1755
|
if (t.listening &&= (e.off("transaction", t.onTransaction), !1), t.timers.size > 0) {
|
|
1718
|
-
let n =
|
|
1719
|
-
for (let [e, r] of t.timers) clearTimeout(r), n.has(e) ||
|
|
1756
|
+
let n = Qt(e);
|
|
1757
|
+
for (let [e, r] of t.timers) clearTimeout(r), n.has(e) || Jt(e);
|
|
1720
1758
|
t.timers.clear();
|
|
1721
1759
|
}
|
|
1722
|
-
|
|
1760
|
+
Zt.delete(e);
|
|
1723
1761
|
}
|
|
1724
1762
|
}
|
|
1725
1763
|
// src/editor/ai/components/ai-selector.tsx
|
|
1726
|
-
var
|
|
1764
|
+
var nn = [
|
|
1727
1765
|
{
|
|
1728
1766
|
mode: "continue",
|
|
1729
1767
|
labelKey: "editor.ai.continue",
|
|
@@ -1766,24 +1804,24 @@ var tn = [
|
|
|
1766
1804
|
descKey: "editor.ai.zapDesc",
|
|
1767
1805
|
icon: "⚡"
|
|
1768
1806
|
}
|
|
1769
|
-
],
|
|
1807
|
+
], rn = /* @__PURE__ */ new Set([
|
|
1770
1808
|
"image",
|
|
1771
1809
|
"attachmentEmbed",
|
|
1772
1810
|
"audioEmbed",
|
|
1773
1811
|
"videoEmbed"
|
|
1774
|
-
]),
|
|
1812
|
+
]), an = {
|
|
1775
1813
|
image: "editor.ai.nodeImage",
|
|
1776
1814
|
attachmentEmbed: "editor.ai.nodeAttachment",
|
|
1777
1815
|
videoEmbed: "editor.ai.nodeVideo",
|
|
1778
1816
|
audioEmbed: "editor.ai.nodeAudio"
|
|
1779
1817
|
};
|
|
1780
|
-
function
|
|
1818
|
+
function on(e, t) {
|
|
1781
1819
|
return e.storage.qingwuUI?.parseMd?.(e.schema, t) || null;
|
|
1782
1820
|
}
|
|
1783
|
-
function
|
|
1821
|
+
function sn(e, t, n) {
|
|
1784
1822
|
let r = [];
|
|
1785
1823
|
return e.state.doc.nodesBetween(t, n, (e) => {
|
|
1786
|
-
if (
|
|
1824
|
+
if (rn.has(e.type.name)) {
|
|
1787
1825
|
let t = e.attrs.src;
|
|
1788
1826
|
t && r.push({
|
|
1789
1827
|
type: e.type.name,
|
|
@@ -1793,25 +1831,25 @@ function on(e, t, n) {
|
|
|
1793
1831
|
return !0;
|
|
1794
1832
|
}), r;
|
|
1795
1833
|
}
|
|
1796
|
-
function
|
|
1834
|
+
function cn(e) {
|
|
1797
1835
|
let t = /* @__PURE__ */ new Set();
|
|
1798
1836
|
return e.state.doc.descendants((e) => {
|
|
1799
|
-
if (
|
|
1837
|
+
if (rn.has(e.type.name)) {
|
|
1800
1838
|
let n = e.attrs.src;
|
|
1801
1839
|
n && t.add(n);
|
|
1802
1840
|
}
|
|
1803
1841
|
return !0;
|
|
1804
1842
|
}), t;
|
|
1805
1843
|
}
|
|
1806
|
-
function
|
|
1807
|
-
let n =
|
|
1844
|
+
function ln(e, t) {
|
|
1845
|
+
let n = on(e, t);
|
|
1808
1846
|
if (n && n.size > 0) {
|
|
1809
1847
|
let t = e.state.tr;
|
|
1810
1848
|
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();
|
|
1811
1849
|
} else e.commands.setContent(t), e.commands.focus();
|
|
1812
1850
|
}
|
|
1813
|
-
function
|
|
1814
|
-
let i =
|
|
1851
|
+
function un(e, t, n, r) {
|
|
1852
|
+
let i = on(e, t);
|
|
1815
1853
|
if (e.commands.focus(), !i) {
|
|
1816
1854
|
let i = e.chain().focus();
|
|
1817
1855
|
n === "replace" ? i.setTextSelection({
|
|
@@ -1821,93 +1859,98 @@ function ln(e, t, n, r) {
|
|
|
1821
1859
|
return;
|
|
1822
1860
|
}
|
|
1823
1861
|
let a = e.state.tr;
|
|
1824
|
-
n === "replace" ? a.replaceRange(r.from, r.to, new
|
|
1862
|
+
n === "replace" ? a.replaceRange(r.from, r.to, new M(i, 0, 0)) : a.insert(Math.min(r.to, e.state.doc.content.size), i), e.view.dispatch(a.scrollIntoView());
|
|
1825
1863
|
}
|
|
1826
|
-
function
|
|
1827
|
-
let [n, r] = T(null), [i, a] = T(""), [o, s] = T(""), [c, l] = T(
|
|
1864
|
+
function dn({ editor: e, onClose: t }) {
|
|
1865
|
+
let [n, r] = T(null), [i, a] = T(""), [o, s] = T(""), [c, l] = T(""), [u, d] = T(!1), [f, m] = T(null), [h, g] = T(null), _ = w({
|
|
1828
1866
|
from: 0,
|
|
1829
1867
|
to: 0,
|
|
1830
1868
|
empty: !0
|
|
1831
|
-
}),
|
|
1832
|
-
r(e),
|
|
1833
|
-
}, [e]),
|
|
1869
|
+
}), v = w(null), y = w(null), C = w(!0), k = w(null), A = w(!0), ee = b(async (e) => {
|
|
1870
|
+
r(e), m(null), e === "zap" ? setTimeout(() => v.current?.focus(), 100) : await j(e);
|
|
1871
|
+
}, [e]), j = b(async (t) => {
|
|
1834
1872
|
let n = e.state.selection;
|
|
1835
|
-
|
|
1873
|
+
_.current = {
|
|
1836
1874
|
from: n.from,
|
|
1837
1875
|
to: n.to,
|
|
1838
1876
|
empty: n.empty
|
|
1839
|
-
},
|
|
1877
|
+
}, d(!0), s(""), l(""), A.current = !0, C.current = !0, m(null);
|
|
1840
1878
|
try {
|
|
1841
|
-
let r =
|
|
1879
|
+
let r = xt(), a = e.storage?.markdown, o = n.empty ? a?.getMarkdown?.() ?? e.getText({ blockSeparator: "\n\n" }) : e.state.doc.textBetween(n.from, n.to, "\n\n"), c = [];
|
|
1842
1880
|
for await (let e of r.stream({
|
|
1843
1881
|
mode: t,
|
|
1844
|
-
context:
|
|
1845
|
-
instruction: t === "zap" ? i : void 0
|
|
1846
|
-
|
|
1882
|
+
context: o,
|
|
1883
|
+
instruction: t === "zap" ? i : void 0,
|
|
1884
|
+
onReasoning: (e) => l((t) => t + e)
|
|
1885
|
+
})) c.push(e), s(c.join(""));
|
|
1886
|
+
if (!c.join("").trim()) throw Error(p("editor.ai.emptyResult"));
|
|
1847
1887
|
} catch (e) {
|
|
1848
|
-
|
|
1888
|
+
m(e instanceof Error ? e.message : p("editor.ai.error"));
|
|
1849
1889
|
} finally {
|
|
1850
|
-
|
|
1890
|
+
d(!1);
|
|
1851
1891
|
}
|
|
1852
1892
|
}, [e, i]);
|
|
1853
1893
|
x(() => {
|
|
1854
|
-
let e =
|
|
1894
|
+
let e = y.current;
|
|
1855
1895
|
if (!e) return;
|
|
1856
1896
|
let t = () => {
|
|
1857
1897
|
let t = e.scrollHeight - e.scrollTop - e.clientHeight < 24;
|
|
1858
|
-
|
|
1898
|
+
C.current = t;
|
|
1859
1899
|
};
|
|
1860
1900
|
return e.addEventListener("scroll", t, { passive: !0 }), () => e.removeEventListener("scroll", t);
|
|
1861
1901
|
}, [!!o]), S(() => {
|
|
1862
|
-
let e =
|
|
1863
|
-
e &&
|
|
1864
|
-
}, [o])
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1902
|
+
let e = y.current;
|
|
1903
|
+
e && C.current && (e.scrollTop = e.scrollHeight);
|
|
1904
|
+
}, [o]), S(() => {
|
|
1905
|
+
let e = k.current;
|
|
1906
|
+
e && A.current && (e.scrollTop = e.scrollHeight);
|
|
1907
|
+
}, [c]);
|
|
1908
|
+
let M = b((t, n, r) => {
|
|
1909
|
+
let i = new Set(sn(e, r.from, r.to).map((e) => e.src));
|
|
1910
|
+
t === "replaceAll" ? ln(e, n) : un(e, n, "replace", _.current);
|
|
1911
|
+
let a = cn(e);
|
|
1912
|
+
en(e, [...i].filter((e) => !a.has(e)));
|
|
1913
|
+
}, [e]), N = b((n) => {
|
|
1871
1914
|
if (n === "below") {
|
|
1872
|
-
|
|
1915
|
+
un(e, o, "below", _.current), t();
|
|
1873
1916
|
return;
|
|
1874
1917
|
}
|
|
1875
|
-
let r =
|
|
1918
|
+
let r = _.current, i = n === "replaceAll" ? {
|
|
1876
1919
|
from: 0,
|
|
1877
1920
|
to: e.state.doc.content.size
|
|
1878
1921
|
} : {
|
|
1879
1922
|
from: r.from,
|
|
1880
1923
|
to: r.to
|
|
1881
|
-
}, a =
|
|
1882
|
-
a.length > 0 ?
|
|
1924
|
+
}, a = sn(e, i.from, i.to);
|
|
1925
|
+
a.length > 0 ? g({
|
|
1883
1926
|
position: n,
|
|
1884
1927
|
willRemove: a
|
|
1885
|
-
}) : (
|
|
1928
|
+
}) : (M(n, o, i), t());
|
|
1886
1929
|
}, [
|
|
1887
1930
|
e,
|
|
1888
1931
|
o,
|
|
1889
|
-
|
|
1932
|
+
M,
|
|
1890
1933
|
t
|
|
1891
|
-
]),
|
|
1892
|
-
if (!
|
|
1893
|
-
let { position: n } =
|
|
1934
|
+
]), P = b(() => {
|
|
1935
|
+
if (!h) return;
|
|
1936
|
+
let { position: n } = h, r = n === "replaceAll" ? {
|
|
1894
1937
|
from: 0,
|
|
1895
1938
|
to: e.state.doc.content.size
|
|
1896
1939
|
} : {
|
|
1897
|
-
from:
|
|
1898
|
-
to:
|
|
1940
|
+
from: _.current.from,
|
|
1941
|
+
to: _.current.to
|
|
1899
1942
|
};
|
|
1900
|
-
|
|
1943
|
+
M(n, o, r), g(null), t();
|
|
1901
1944
|
}, [
|
|
1902
|
-
|
|
1945
|
+
h,
|
|
1903
1946
|
e,
|
|
1904
1947
|
o,
|
|
1905
|
-
|
|
1948
|
+
M,
|
|
1906
1949
|
t
|
|
1907
|
-
]),
|
|
1908
|
-
s(""), r(null),
|
|
1909
|
-
}, []),
|
|
1910
|
-
for (let e of
|
|
1950
|
+
]), F = b(() => {
|
|
1951
|
+
s(""), l(""), r(null), m(null);
|
|
1952
|
+
}, []), I = {};
|
|
1953
|
+
for (let e of h?.willRemove ?? []) I[e.type] = (I[e.type] ?? 0) + 1;
|
|
1911
1954
|
return /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ O("div", {
|
|
1912
1955
|
className: "ai-selector w-full flex-1 min-h-0 flex flex-col",
|
|
1913
1956
|
children: [
|
|
@@ -1915,22 +1958,23 @@ function un({ editor: e, onClose: t }) {
|
|
|
1915
1958
|
className: "flex items-center justify-between pl-3 pr-1.5 py-1.5 border-b border-default-100 shrink-0",
|
|
1916
1959
|
children: [/* @__PURE__ */ O("span", {
|
|
1917
1960
|
className: "flex items-center gap-1.5 text-xs font-medium text-default-500",
|
|
1918
|
-
children: [/* @__PURE__ */ D(
|
|
1961
|
+
children: [/* @__PURE__ */ D(Wt, { className: "text-primary" }), p("editor.ai.trigger")]
|
|
1919
1962
|
}), /* @__PURE__ */ D("button", {
|
|
1920
1963
|
type: "button",
|
|
1921
1964
|
onClick: t,
|
|
1922
1965
|
"aria-label": p("editor.ai.close"),
|
|
1923
1966
|
title: p("editor.ai.close"),
|
|
1924
1967
|
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",
|
|
1925
|
-
children: /* @__PURE__ */ D(
|
|
1968
|
+
children: /* @__PURE__ */ D(qt, {})
|
|
1926
1969
|
})]
|
|
1927
1970
|
}),
|
|
1928
1971
|
/* @__PURE__ */ D("div", {
|
|
1929
1972
|
className: "grid grid-cols-[repeat(auto-fit,minmax(64px,1fr))] gap-1.5 p-2 shrink-0",
|
|
1930
|
-
children:
|
|
1973
|
+
children: nn.map(({ mode: e, labelKey: t, descKey: r, icon: i }) => /* @__PURE__ */ O("button", {
|
|
1931
1974
|
type: "button",
|
|
1932
1975
|
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"}`,
|
|
1933
|
-
onClick: () =>
|
|
1976
|
+
onClick: () => ee(e),
|
|
1977
|
+
disabled: u,
|
|
1934
1978
|
title: p(r),
|
|
1935
1979
|
children: [/* @__PURE__ */ D("span", {
|
|
1936
1980
|
className: "text-base leading-none",
|
|
@@ -1948,14 +1992,14 @@ function un({ editor: e, onClose: t }) {
|
|
|
1948
1992
|
className: "text-[11px] text-default-400 leading-relaxed",
|
|
1949
1993
|
children: p("editor.ai.triggerDesc")
|
|
1950
1994
|
}),
|
|
1951
|
-
n === "zap" && !
|
|
1952
|
-
ref:
|
|
1995
|
+
n === "zap" && !u && !o && !f && /* @__PURE__ */ O("div", { children: [/* @__PURE__ */ D("input", {
|
|
1996
|
+
ref: v,
|
|
1953
1997
|
className: "w-full px-3 py-2 text-sm border border-default-200 rounded-lg focus:outline-none focus:border-primary bg-background",
|
|
1954
1998
|
placeholder: p("editor.ai.customPlaceholder"),
|
|
1955
1999
|
value: i,
|
|
1956
2000
|
onChange: (e) => a(e.target.value),
|
|
1957
2001
|
onKeyDown: (e) => {
|
|
1958
|
-
e.key === "Enter" && i.trim() &&
|
|
2002
|
+
e.key === "Enter" && i.trim() && j("zap");
|
|
1959
2003
|
}
|
|
1960
2004
|
}), /* @__PURE__ */ O("div", {
|
|
1961
2005
|
className: "flex gap-2 mt-2",
|
|
@@ -1963,7 +2007,7 @@ function un({ editor: e, onClose: t }) {
|
|
|
1963
2007
|
type: "button",
|
|
1964
2008
|
className: "px-3 py-1.5 text-xs bg-primary text-white rounded-lg disabled:opacity-50",
|
|
1965
2009
|
disabled: !i.trim(),
|
|
1966
|
-
onClick: () =>
|
|
2010
|
+
onClick: () => j("zap"),
|
|
1967
2011
|
children: p("editor.ai.confirm")
|
|
1968
2012
|
}), /* @__PURE__ */ D("button", {
|
|
1969
2013
|
type: "button",
|
|
@@ -1972,59 +2016,99 @@ function un({ editor: e, onClose: t }) {
|
|
|
1972
2016
|
children: p("editor.ai.back")
|
|
1973
2017
|
})]
|
|
1974
2018
|
})] }),
|
|
1975
|
-
(c || o ||
|
|
2019
|
+
(u || c || o || f) && /* @__PURE__ */ O("div", {
|
|
1976
2020
|
className: "flex-1 min-h-0 flex flex-col",
|
|
1977
2021
|
children: [
|
|
1978
|
-
c && !o && /* @__PURE__ */ O("div", {
|
|
1979
|
-
|
|
2022
|
+
u && !c && !o && /* @__PURE__ */ O("div", {
|
|
2023
|
+
role: "status",
|
|
2024
|
+
className: "flex items-center gap-2 text-sm text-default-600",
|
|
1980
2025
|
children: [/* @__PURE__ */ D("span", {
|
|
1981
2026
|
className: "animate-spin",
|
|
1982
2027
|
children: "⏳"
|
|
1983
2028
|
}), p("editor.ai.thinking")]
|
|
1984
2029
|
}),
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
className: "
|
|
1988
|
-
children: [
|
|
1989
|
-
className: "
|
|
1990
|
-
children: "
|
|
2030
|
+
c && /* @__PURE__ */ O("details", {
|
|
2031
|
+
open: !0,
|
|
2032
|
+
className: "mb-3 shrink-0",
|
|
2033
|
+
children: [/* @__PURE__ */ O("summary", {
|
|
2034
|
+
className: "cursor-pointer text-xs font-medium text-default-600",
|
|
2035
|
+
children: [p("editor.ai.reasoning"), /* @__PURE__ */ D("span", {
|
|
2036
|
+
role: "status",
|
|
2037
|
+
className: "ml-2 font-normal",
|
|
2038
|
+
children: p(o ? "editor.ai.reasoningDone" : f ? "editor.ai.reasoningStopped" : u ? "editor.ai.thinking" : "editor.ai.reasoningDone")
|
|
2039
|
+
})]
|
|
2040
|
+
}), /* @__PURE__ */ D("div", {
|
|
2041
|
+
ref: k,
|
|
2042
|
+
className: "mt-2 max-h-36 overflow-y-auto whitespace-pre-wrap break-words text-sm text-default-600",
|
|
2043
|
+
onScroll: (e) => {
|
|
2044
|
+
let t = e.currentTarget;
|
|
2045
|
+
A.current = t.scrollHeight - t.scrollTop - t.clientHeight < 24;
|
|
2046
|
+
},
|
|
2047
|
+
children: c
|
|
1991
2048
|
})]
|
|
1992
|
-
}),
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
className: "
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
children:
|
|
2011
|
-
})
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2049
|
+
}),
|
|
2050
|
+
o && /* @__PURE__ */ O(E, { children: [
|
|
2051
|
+
/* @__PURE__ */ O("div", {
|
|
2052
|
+
className: "mb-2 flex items-center justify-between gap-2 shrink-0",
|
|
2053
|
+
children: [/* @__PURE__ */ D("h3", {
|
|
2054
|
+
className: "text-xs font-medium text-default-700",
|
|
2055
|
+
children: p("editor.ai.result")
|
|
2056
|
+
}), /* @__PURE__ */ D("span", {
|
|
2057
|
+
role: "status",
|
|
2058
|
+
className: "text-xs text-default-600",
|
|
2059
|
+
children: p(u ? "editor.ai.generating" : f ? "editor.ai.interrupted" : "editor.ai.completed")
|
|
2060
|
+
})]
|
|
2061
|
+
}),
|
|
2062
|
+
/* @__PURE__ */ O("div", {
|
|
2063
|
+
ref: y,
|
|
2064
|
+
className: "flex-1 min-h-0 overflow-y-auto text-sm whitespace-pre-wrap text-default-700 mb-3",
|
|
2065
|
+
children: [o, u && /* @__PURE__ */ D("span", {
|
|
2066
|
+
className: "animate-pulse",
|
|
2067
|
+
children: "▊"
|
|
2068
|
+
})]
|
|
2069
|
+
}),
|
|
2070
|
+
!u && /* @__PURE__ */ O("div", {
|
|
2071
|
+
className: "flex gap-2 shrink-0",
|
|
2072
|
+
children: [
|
|
2073
|
+
_.current.empty ? /* @__PURE__ */ D("button", {
|
|
2074
|
+
type: "button",
|
|
2075
|
+
className: "px-3 py-1.5 text-xs bg-primary text-white rounded-lg",
|
|
2076
|
+
onClick: () => N("replaceAll"),
|
|
2077
|
+
children: p("editor.ai.replaceAll")
|
|
2078
|
+
}) : /* @__PURE__ */ D("button", {
|
|
2079
|
+
type: "button",
|
|
2080
|
+
className: "px-3 py-1.5 text-xs bg-primary text-white rounded-lg",
|
|
2081
|
+
onClick: () => N("replace"),
|
|
2082
|
+
children: p("editor.ai.replace")
|
|
2083
|
+
}),
|
|
2084
|
+
/* @__PURE__ */ D("button", {
|
|
2085
|
+
type: "button",
|
|
2086
|
+
className: "px-3 py-1.5 text-xs border border-default-200 rounded-lg hover:bg-default-100",
|
|
2087
|
+
onClick: () => N("below"),
|
|
2088
|
+
children: p("editor.ai.insert")
|
|
2089
|
+
}),
|
|
2090
|
+
/* @__PURE__ */ D("button", {
|
|
2091
|
+
type: "button",
|
|
2092
|
+
className: "px-3 py-1.5 text-xs text-danger",
|
|
2093
|
+
onClick: F,
|
|
2094
|
+
children: p("editor.ai.discard")
|
|
2095
|
+
})
|
|
2096
|
+
]
|
|
2097
|
+
})
|
|
2098
|
+
] }),
|
|
2099
|
+
f && /* @__PURE__ */ O("div", {
|
|
2021
2100
|
className: "text-sm text-danger",
|
|
2022
|
-
children: [/* @__PURE__ */
|
|
2101
|
+
children: [/* @__PURE__ */ O("p", {
|
|
2102
|
+
role: "alert",
|
|
2103
|
+
children: [
|
|
2104
|
+
/* @__PURE__ */ D("strong", { children: p(o ? "editor.ai.interrupted" : "editor.ai.failed") }),
|
|
2105
|
+
":",
|
|
2106
|
+
f
|
|
2107
|
+
]
|
|
2108
|
+
}), /* @__PURE__ */ D("button", {
|
|
2023
2109
|
type: "button",
|
|
2024
2110
|
className: "mt-2 px-3 py-1 text-xs border border-default-200 rounded-lg hover:bg-default-100",
|
|
2025
|
-
onClick:
|
|
2026
|
-
d(null), r(null);
|
|
2027
|
-
},
|
|
2111
|
+
onClick: F,
|
|
2028
2112
|
children: p("editor.ai.back")
|
|
2029
2113
|
})]
|
|
2030
2114
|
})
|
|
@@ -2033,13 +2117,13 @@ function un({ editor: e, onClose: t }) {
|
|
|
2033
2117
|
]
|
|
2034
2118
|
})
|
|
2035
2119
|
]
|
|
2036
|
-
}),
|
|
2120
|
+
}), h && /* @__PURE__ */ O("div", {
|
|
2037
2121
|
className: "qed-root",
|
|
2038
2122
|
style: { zIndex: 1e4 },
|
|
2039
|
-
onClick: () =>
|
|
2123
|
+
onClick: () => g(null),
|
|
2040
2124
|
children: [/* @__PURE__ */ D("div", {
|
|
2041
2125
|
className: "qed-backdrop",
|
|
2042
|
-
onClick: () =>
|
|
2126
|
+
onClick: () => g(null)
|
|
2043
2127
|
}), /* @__PURE__ */ O("div", {
|
|
2044
2128
|
className: "qed-card animate-in",
|
|
2045
2129
|
onClick: (e) => e.stopPropagation(),
|
|
@@ -2048,11 +2132,11 @@ function un({ editor: e, onClose: t }) {
|
|
|
2048
2132
|
className: "qed-header",
|
|
2049
2133
|
children: [/* @__PURE__ */ D("h2", {
|
|
2050
2134
|
className: "qed-title",
|
|
2051
|
-
children:
|
|
2135
|
+
children: h.position === "replaceAll" ? p("editor.ai.replaceAllTitle") : p("editor.ai.replaceTitle")
|
|
2052
2136
|
}), /* @__PURE__ */ D("button", {
|
|
2053
2137
|
type: "button",
|
|
2054
2138
|
className: "qed-close",
|
|
2055
|
-
onClick: () =>
|
|
2139
|
+
onClick: () => g(null),
|
|
2056
2140
|
"aria-label": p("editor.ai.close"),
|
|
2057
2141
|
children: "✕"
|
|
2058
2142
|
})]
|
|
@@ -2061,16 +2145,16 @@ function un({ editor: e, onClose: t }) {
|
|
|
2061
2145
|
className: "qed-body",
|
|
2062
2146
|
children: [/* @__PURE__ */ D("p", {
|
|
2063
2147
|
className: "mb-2",
|
|
2064
|
-
children:
|
|
2065
|
-
}), Object.keys(
|
|
2148
|
+
children: h.position === "replaceAll" ? p("editor.ai.replaceAllText") : p("editor.ai.replaceText")
|
|
2149
|
+
}), Object.keys(I).length > 0 && /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("p", {
|
|
2066
2150
|
className: "text-xs text-default-500",
|
|
2067
2151
|
children: p("editor.ai.removeNodes")
|
|
2068
2152
|
}), /* @__PURE__ */ D("ul", {
|
|
2069
2153
|
className: "mt-1 space-y-0.5",
|
|
2070
|
-
children: Object.entries(
|
|
2154
|
+
children: Object.entries(I).map(([e, t]) => /* @__PURE__ */ O("li", {
|
|
2071
2155
|
className: "text-sm text-default-700",
|
|
2072
2156
|
children: [
|
|
2073
|
-
p(
|
|
2157
|
+
p(an[e] ?? e),
|
|
2074
2158
|
" ×",
|
|
2075
2159
|
t
|
|
2076
2160
|
]
|
|
@@ -2087,12 +2171,12 @@ function un({ editor: e, onClose: t }) {
|
|
|
2087
2171
|
children: [/* @__PURE__ */ D("button", {
|
|
2088
2172
|
type: "button",
|
|
2089
2173
|
className: "qed-btn qed-btn--ghost",
|
|
2090
|
-
onClick: () =>
|
|
2174
|
+
onClick: () => g(null),
|
|
2091
2175
|
children: p("editor.ai.cancel")
|
|
2092
2176
|
}), /* @__PURE__ */ D("button", {
|
|
2093
2177
|
type: "button",
|
|
2094
2178
|
className: "qed-btn qed-btn--primary",
|
|
2095
|
-
onClick:
|
|
2179
|
+
onClick: P,
|
|
2096
2180
|
children: p("editor.ai.confirmReplace")
|
|
2097
2181
|
})]
|
|
2098
2182
|
})
|
|
@@ -2101,19 +2185,19 @@ function un({ editor: e, onClose: t }) {
|
|
|
2101
2185
|
})] });
|
|
2102
2186
|
}
|
|
2103
2187
|
// src/editor/attachment-limits.ts
|
|
2104
|
-
var
|
|
2188
|
+
var fn = /* @__PURE__ */ new Set([
|
|
2105
2189
|
"attachmentEmbed",
|
|
2106
2190
|
"videoEmbed",
|
|
2107
2191
|
"audioEmbed",
|
|
2108
2192
|
"image"
|
|
2109
2193
|
]);
|
|
2110
|
-
function
|
|
2194
|
+
function pn(e) {
|
|
2111
2195
|
let t = 0;
|
|
2112
2196
|
return e.descendants((e) => {
|
|
2113
|
-
|
|
2197
|
+
fn.has(e.type.name) && (t += Number(e.attrs?.size) || 0);
|
|
2114
2198
|
}), t;
|
|
2115
2199
|
}
|
|
2116
|
-
function
|
|
2200
|
+
function mn(e) {
|
|
2117
2201
|
if (!Number.isFinite(e) || e <= 0) return "0 B";
|
|
2118
2202
|
let t = [
|
|
2119
2203
|
"B",
|
|
@@ -2124,39 +2208,39 @@ function pn(e) {
|
|
|
2124
2208
|
], n = Math.min(t.length - 1, Math.floor(Math.log(e) / Math.log(1024))), r = e / 1024 ** n;
|
|
2125
2209
|
return `${n === 0 || r >= 100 ? `${Math.round(r)}` : `${Math.round(r * 10) / 10}`} ${t[n]}`;
|
|
2126
2210
|
}
|
|
2127
|
-
function
|
|
2211
|
+
function hn(e) {
|
|
2128
2212
|
return (e?.storage)?.qingwuUI?.limits;
|
|
2129
2213
|
}
|
|
2130
|
-
function
|
|
2214
|
+
function gn(e, t, n) {
|
|
2131
2215
|
let { maxAttachmentSize: r, maxTotalAttachmentSize: i } = n;
|
|
2132
|
-
if (r && t.size > r) return `单文件大小不能超过 ${
|
|
2216
|
+
if (r && t.size > r) return `单文件大小不能超过 ${mn(r)}(当前 ${mn(t.size)})`;
|
|
2133
2217
|
if (i) {
|
|
2134
|
-
let n =
|
|
2135
|
-
if (n > i) return `附件总大小不能超过 ${
|
|
2218
|
+
let n = pn(e) + t.size;
|
|
2219
|
+
if (n > i) return `附件总大小不能超过 ${mn(i)}(当前合计 ${mn(n)})`;
|
|
2136
2220
|
}
|
|
2137
2221
|
return null;
|
|
2138
2222
|
}
|
|
2139
2223
|
// src/editor/utils/delete-confirm.ts
|
|
2140
|
-
var
|
|
2141
|
-
function
|
|
2142
|
-
return
|
|
2224
|
+
var _n = !1, vn = null, yn = 5e3;
|
|
2225
|
+
function bn() {
|
|
2226
|
+
return _n;
|
|
2143
2227
|
}
|
|
2144
2228
|
function $(e) {
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
},
|
|
2229
|
+
_n = e, vn &&= (clearTimeout(vn), null), e && (vn = setTimeout(() => {
|
|
2230
|
+
_n = !1, vn = null;
|
|
2231
|
+
}, yn));
|
|
2148
2232
|
}
|
|
2149
|
-
var
|
|
2150
|
-
function
|
|
2151
|
-
|
|
2233
|
+
var xn = null;
|
|
2234
|
+
function Sn(e) {
|
|
2235
|
+
xn = e;
|
|
2152
2236
|
}
|
|
2153
|
-
function
|
|
2154
|
-
return
|
|
2237
|
+
function Cn() {
|
|
2238
|
+
return xn;
|
|
2155
2239
|
}
|
|
2156
2240
|
// src/editor/utils/delete-confirm-dialog.tsx
|
|
2157
|
-
var
|
|
2158
|
-
function
|
|
2159
|
-
let [s, c] = T(!1), l = w(!1), u =
|
|
2241
|
+
var wn = 300;
|
|
2242
|
+
function Tn({ open: e, title: t, message: n, confirmText: r = "删除", cancelText: i = "取消", onConfirm: a, onCancel: o }) {
|
|
2243
|
+
let [s, c] = T(!1), l = w(!1), u = Cn();
|
|
2160
2244
|
return x(() => {
|
|
2161
2245
|
e ? u && !l.current && (l.current = !0, u({
|
|
2162
2246
|
open: e,
|
|
@@ -2222,7 +2306,7 @@ function wn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2222
2306
|
await a();
|
|
2223
2307
|
} finally {
|
|
2224
2308
|
let t = Date.now() - e;
|
|
2225
|
-
t <
|
|
2309
|
+
t < wn && await new Promise((e) => setTimeout(e, wn - t)), c(!1), o();
|
|
2226
2310
|
}
|
|
2227
2311
|
},
|
|
2228
2312
|
disabled: s,
|
|
@@ -2234,11 +2318,11 @@ function wn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2234
2318
|
}), document.body);
|
|
2235
2319
|
}
|
|
2236
2320
|
// src/editor/extensions/image-view.tsx
|
|
2237
|
-
function
|
|
2321
|
+
function En(e) {
|
|
2238
2322
|
return /^(\.\.?\/|[a-zA-Z]:\\|file:\/\/)/.test(e) ? !0 : !(/^[a-z]+:\/\//i.test(e) || e.startsWith("/") || e.startsWith("data:") || e.startsWith("blob:"));
|
|
2239
2323
|
}
|
|
2240
|
-
function
|
|
2241
|
-
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), [
|
|
2324
|
+
function Dn({ node: e, deleteNode: t, editor: r }) {
|
|
2325
|
+
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), [ee, j] = T(p), M = r?.isEditable ?? !0, N = b(() => {
|
|
2242
2326
|
o || (A.current = window.scrollY, a(!0));
|
|
2243
2327
|
}, [o]), F = b(() => {
|
|
2244
2328
|
a(!1), requestAnimationFrame(() => window.scrollTo(0, A.current));
|
|
@@ -2250,7 +2334,7 @@ function En({ node: e, deleteNode: t, editor: r }) {
|
|
|
2250
2334
|
e && (A.current = window.scrollY, e.requestFullscreen ? e.requestFullscreen() : e.webkitRequestFullscreen && e.webkitRequestFullscreen());
|
|
2251
2335
|
}, []);
|
|
2252
2336
|
x(() => {
|
|
2253
|
-
s(!1),
|
|
2337
|
+
s(!1), j(p), E.current = !1, k.current = !1, S.current &&= (URL.revokeObjectURL(S.current), null), C.current &&= (URL.revokeObjectURL(C.current), null);
|
|
2254
2338
|
}, [p]), x(() => {
|
|
2255
2339
|
if (!p || p.startsWith("blob:") || p.startsWith("data:") || p.includes("?X-Amz-")) return;
|
|
2256
2340
|
let e = !1;
|
|
@@ -2265,7 +2349,7 @@ function En({ node: e, deleteNode: t, editor: r }) {
|
|
|
2265
2349
|
URL.revokeObjectURL(i);
|
|
2266
2350
|
return;
|
|
2267
2351
|
}
|
|
2268
|
-
S.current && URL.revokeObjectURL(S.current), S.current = i, E.current = !0,
|
|
2352
|
+
S.current && URL.revokeObjectURL(S.current), S.current = i, E.current = !0, j(i);
|
|
2269
2353
|
} catch {}
|
|
2270
2354
|
})(), () => {
|
|
2271
2355
|
e = !0;
|
|
@@ -2290,7 +2374,7 @@ function En({ node: e, deleteNode: t, editor: r }) {
|
|
|
2290
2374
|
};
|
|
2291
2375
|
return document.addEventListener("fullscreenchange", e), () => document.removeEventListener("fullscreenchange", e);
|
|
2292
2376
|
}, []);
|
|
2293
|
-
let ne = o ||
|
|
2377
|
+
let ne = o || En(p);
|
|
2294
2378
|
return /* @__PURE__ */ O(P, {
|
|
2295
2379
|
as: "div",
|
|
2296
2380
|
className: "image-node-view group/img",
|
|
@@ -2299,11 +2383,11 @@ function En({ node: e, deleteNode: t, editor: r }) {
|
|
|
2299
2383
|
ne ? /* @__PURE__ */ O("div", {
|
|
2300
2384
|
className: "image-placeholder",
|
|
2301
2385
|
children: [
|
|
2302
|
-
|
|
2386
|
+
M && /* @__PURE__ */ D("button", {
|
|
2303
2387
|
type: "button",
|
|
2304
2388
|
className: "img-ctrl-btn img-ctrl-btn--del image-placeholder-del",
|
|
2305
2389
|
onClick: () => {
|
|
2306
|
-
|
|
2390
|
+
bn() || ($(!0), f(!0));
|
|
2307
2391
|
},
|
|
2308
2392
|
title: "删除",
|
|
2309
2393
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -2335,7 +2419,7 @@ function En({ node: e, deleteNode: t, editor: r }) {
|
|
|
2335
2419
|
}),
|
|
2336
2420
|
/* @__PURE__ */ D("span", {
|
|
2337
2421
|
className: "image-placeholder-text",
|
|
2338
|
-
children:
|
|
2422
|
+
children: En(p) ? "本地图片无法加载" : "图片加载失败"
|
|
2339
2423
|
}),
|
|
2340
2424
|
/* @__PURE__ */ D("span", {
|
|
2341
2425
|
className: "image-placeholder-path",
|
|
@@ -2347,11 +2431,11 @@ function En({ node: e, deleteNode: t, editor: r }) {
|
|
|
2347
2431
|
className: "img-wrap",
|
|
2348
2432
|
children: [/* @__PURE__ */ D("img", {
|
|
2349
2433
|
ref: y,
|
|
2350
|
-
src:
|
|
2434
|
+
src: ee,
|
|
2351
2435
|
alt: m,
|
|
2352
2436
|
width: h || void 0,
|
|
2353
2437
|
height: g || void 0,
|
|
2354
|
-
onClick:
|
|
2438
|
+
onClick: N,
|
|
2355
2439
|
onError: () => {
|
|
2356
2440
|
E.current || o || (E.current = !0, (async () => {
|
|
2357
2441
|
try {
|
|
@@ -2377,7 +2461,7 @@ function En({ node: e, deleteNode: t, editor: r }) {
|
|
|
2377
2461
|
/* @__PURE__ */ D("button", {
|
|
2378
2462
|
type: "button",
|
|
2379
2463
|
className: "img-ctrl-btn",
|
|
2380
|
-
onClick:
|
|
2464
|
+
onClick: N,
|
|
2381
2465
|
title: "网页全屏",
|
|
2382
2466
|
children: /* @__PURE__ */ D("svg", {
|
|
2383
2467
|
width: "14",
|
|
@@ -2412,11 +2496,11 @@ function En({ node: e, deleteNode: t, editor: r }) {
|
|
|
2412
2496
|
})
|
|
2413
2497
|
})
|
|
2414
2498
|
}),
|
|
2415
|
-
|
|
2499
|
+
M && /* @__PURE__ */ D("button", {
|
|
2416
2500
|
type: "button",
|
|
2417
2501
|
className: "img-ctrl-btn img-ctrl-btn--del",
|
|
2418
2502
|
onClick: () => {
|
|
2419
|
-
|
|
2503
|
+
bn() || ($(!0), f(!0));
|
|
2420
2504
|
},
|
|
2421
2505
|
title: "删除",
|
|
2422
2506
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -2480,7 +2564,7 @@ function En({ node: e, deleteNode: t, editor: r }) {
|
|
|
2480
2564
|
})]
|
|
2481
2565
|
}), /* @__PURE__ */ D("img", {
|
|
2482
2566
|
ref: v,
|
|
2483
|
-
src:
|
|
2567
|
+
src: ee,
|
|
2484
2568
|
alt: m,
|
|
2485
2569
|
className: "image-lightbox-img",
|
|
2486
2570
|
onClick: (e) => e.stopPropagation(),
|
|
@@ -2497,7 +2581,7 @@ function En({ node: e, deleteNode: t, editor: r }) {
|
|
|
2497
2581
|
}
|
|
2498
2582
|
})]
|
|
2499
2583
|
}),
|
|
2500
|
-
/* @__PURE__ */ D(
|
|
2584
|
+
/* @__PURE__ */ D(Tn, {
|
|
2501
2585
|
open: d,
|
|
2502
2586
|
title: "确认删除图片",
|
|
2503
2587
|
message: ne ? "该图片无法在当前环境加载,仅从编辑器中移除该图片节点,不影响存储文件。" : "此操作将同时删除对象存储中的文件,不可撤销。",
|
|
@@ -2506,7 +2590,7 @@ function En({ node: e, deleteNode: t, editor: r }) {
|
|
|
2506
2590
|
},
|
|
2507
2591
|
onConfirm: async () => {
|
|
2508
2592
|
if (!ne) try {
|
|
2509
|
-
await
|
|
2593
|
+
await Jt(p);
|
|
2510
2594
|
} catch {}
|
|
2511
2595
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
2512
2596
|
}
|
|
@@ -2515,7 +2599,7 @@ function En({ node: e, deleteNode: t, editor: r }) {
|
|
|
2515
2599
|
});
|
|
2516
2600
|
}
|
|
2517
2601
|
// src/editor/embeds/attachment-view.tsx
|
|
2518
|
-
var
|
|
2602
|
+
var On = y(() => import("@file-viewer/react")), kn = /* @__PURE__ */ new Set(), An = {
|
|
2519
2603
|
rendererMode: "replace",
|
|
2520
2604
|
autoRenderers: !0,
|
|
2521
2605
|
theme: "light",
|
|
@@ -2544,7 +2628,7 @@ var Dn = y(() => import("@file-viewer/react")), On = /* @__PURE__ */ new Set(),
|
|
|
2544
2628
|
cache: !0,
|
|
2545
2629
|
workerTimeoutMs: 3e4
|
|
2546
2630
|
}
|
|
2547
|
-
},
|
|
2631
|
+
}, jn = {
|
|
2548
2632
|
pdf: "pdf",
|
|
2549
2633
|
docx: "word",
|
|
2550
2634
|
docm: "word",
|
|
@@ -2599,7 +2683,7 @@ var Dn = y(() => import("@file-viewer/react")), On = /* @__PURE__ */ new Set(),
|
|
|
2599
2683
|
xml: "text",
|
|
2600
2684
|
yml: "text",
|
|
2601
2685
|
yaml: "text"
|
|
2602
|
-
},
|
|
2686
|
+
}, Mn = {
|
|
2603
2687
|
pdf: () => import("@file-viewer/renderer-pdf").then((e) => e.pdfRenderer),
|
|
2604
2688
|
word: () => import("@file-viewer/renderer-word").then((e) => e.wordRenderer),
|
|
2605
2689
|
spreadsheet: () => import("@file-viewer/renderer-spreadsheet").then((e) => e.spreadsheetRenderer),
|
|
@@ -2607,10 +2691,10 @@ var Dn = y(() => import("@file-viewer/react")), On = /* @__PURE__ */ new Set(),
|
|
|
2607
2691
|
archive: () => import("@file-viewer/renderer-archive").then((e) => e.archiveRenderer),
|
|
2608
2692
|
text: () => import("@file-viewer/renderer-text").then((e) => e.textRenderer)
|
|
2609
2693
|
};
|
|
2610
|
-
function
|
|
2694
|
+
function Nn(e) {
|
|
2611
2695
|
return e ? e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1048576).toFixed(1)} MB` : "";
|
|
2612
2696
|
}
|
|
2613
|
-
function
|
|
2697
|
+
function Pn(e) {
|
|
2614
2698
|
let t = e.split(".").pop()?.toLowerCase() || "", n = {
|
|
2615
2699
|
pdf: {
|
|
2616
2700
|
label: "PDF",
|
|
@@ -2783,22 +2867,22 @@ function Nn(e) {
|
|
|
2783
2867
|
]
|
|
2784
2868
|
});
|
|
2785
2869
|
}
|
|
2786
|
-
function
|
|
2870
|
+
function Fn(e) {
|
|
2787
2871
|
return e.split(".").pop()?.toLowerCase() || "";
|
|
2788
2872
|
}
|
|
2789
|
-
function
|
|
2873
|
+
function In(e) {
|
|
2790
2874
|
let t = e.split(".").pop()?.toLowerCase() || "";
|
|
2791
2875
|
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);
|
|
2792
2876
|
}
|
|
2793
|
-
function
|
|
2877
|
+
function Ln(e) {
|
|
2794
2878
|
return !!e && !e.startsWith("file:");
|
|
2795
2879
|
}
|
|
2796
|
-
function
|
|
2880
|
+
function Rn(e) {
|
|
2797
2881
|
return btoa(encodeURIComponent(e)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
2798
2882
|
}
|
|
2799
|
-
async function
|
|
2883
|
+
async function zn(e, t) {
|
|
2800
2884
|
try {
|
|
2801
|
-
let n =
|
|
2885
|
+
let n = Rn(e), r = await fetch(`/api/preview/${n}`, {
|
|
2802
2886
|
signal: t,
|
|
2803
2887
|
cache: "no-store"
|
|
2804
2888
|
});
|
|
@@ -2810,7 +2894,7 @@ async function Rn(e, t) {
|
|
|
2810
2894
|
return null;
|
|
2811
2895
|
}
|
|
2812
2896
|
}
|
|
2813
|
-
function
|
|
2897
|
+
function Bn(e, t, n) {
|
|
2814
2898
|
return new Promise((r, i) => {
|
|
2815
2899
|
let a = new XMLHttpRequest();
|
|
2816
2900
|
if (a.open("GET", e, !0), a.responseType = "arraybuffer", t) {
|
|
@@ -2848,20 +2932,20 @@ function zn(e, t, n) {
|
|
|
2848
2932
|
a.send();
|
|
2849
2933
|
});
|
|
2850
2934
|
}
|
|
2851
|
-
function
|
|
2852
|
-
let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() =>
|
|
2935
|
+
function Vn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
2936
|
+
let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() => kn.has(s)), [u, d] = T(null), [f, m] = T(null), [h, g] = T(!1), [_, y] = T(null), [S, E] = T(!1), [k, A] = T(null), ee = w(null), j = w(null), M = w(null), N = 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" : p("editor.attachment.lost")), se = e.attrs.size || 0, ce = Fn(W), G = !U;
|
|
2853
2937
|
x(() => {
|
|
2854
2938
|
if (!c) {
|
|
2855
2939
|
H(void 0), oe(!1);
|
|
2856
2940
|
return;
|
|
2857
2941
|
}
|
|
2858
|
-
let e =
|
|
2942
|
+
let e = jn[ce];
|
|
2859
2943
|
if (!e) {
|
|
2860
2944
|
H(void 0), oe(!1);
|
|
2861
2945
|
return;
|
|
2862
2946
|
}
|
|
2863
2947
|
let t = !0;
|
|
2864
|
-
return H(void 0), oe(!1),
|
|
2948
|
+
return H(void 0), oe(!1), Mn[e]().then((e) => {
|
|
2865
2949
|
t && H(e);
|
|
2866
2950
|
}).catch((n) => {
|
|
2867
2951
|
console.error(`[attachment] renderer "${e}" load failed:`, n), t && oe(!0);
|
|
@@ -2870,27 +2954,27 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2870
2954
|
};
|
|
2871
2955
|
}, [c, ce]);
|
|
2872
2956
|
let K = C(() => ({
|
|
2873
|
-
...
|
|
2957
|
+
...An,
|
|
2874
2958
|
renderers: V ? [V] : [],
|
|
2875
2959
|
rendererMode: "replace"
|
|
2876
2960
|
}), [V]), le = b((e) => {
|
|
2877
2961
|
l((t) => {
|
|
2878
2962
|
let n = typeof e == "function" ? e(t) : e;
|
|
2879
|
-
return U && (n ?
|
|
2963
|
+
return U && (n ? kn.add(U) : kn.delete(U)), n;
|
|
2880
2964
|
});
|
|
2881
2965
|
}, [U]);
|
|
2882
2966
|
x(() => {
|
|
2883
|
-
l(U ?
|
|
2967
|
+
l(U ? kn.has(U) : !1);
|
|
2884
2968
|
}, [U]);
|
|
2885
2969
|
let ue = b(() => {
|
|
2886
2970
|
F.current = !0, le(!0), window.setTimeout(() => {
|
|
2887
|
-
window.scrollTo(0,
|
|
2971
|
+
window.scrollTo(0, N.current), I.current && (I.current.scrollTop = te.current), F.current && le(!0), F.current = !1;
|
|
2888
2972
|
}, 0);
|
|
2889
2973
|
}, [le]), de = b(async () => {
|
|
2890
|
-
z === "web" ? (B("none"), document.body.style.overflow = "", ue()) : (z === "native" && document.fullscreenElement && await document.exitFullscreen(),
|
|
2974
|
+
z === "web" ? (B("none"), document.body.style.overflow = "", ue()) : (z === "native" && document.fullscreenElement && await document.exitFullscreen(), N.current = window.scrollY, te.current = I.current?.scrollTop ?? 0, document.body.style.overflow = "hidden", B("web"));
|
|
2891
2975
|
}, [z]), fe = b(async () => {
|
|
2892
|
-
let e =
|
|
2893
|
-
e && (z === "native" ? await document.exitFullscreen() : (z === "web" && (B("none"), document.body.style.overflow = ""),
|
|
2976
|
+
let e = j.current;
|
|
2977
|
+
e && (z === "native" ? await document.exitFullscreen() : (z === "web" && (B("none"), document.body.style.overflow = ""), N.current = window.scrollY, te.current = I.current?.scrollTop ?? 0, await e.requestFullscreen(), B("native")));
|
|
2894
2978
|
}, [z, ue]), pe = b(() => {
|
|
2895
2979
|
z === "none" && (F.current || le((e) => !e));
|
|
2896
2980
|
}, [z]);
|
|
@@ -2905,7 +2989,7 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2905
2989
|
};
|
|
2906
2990
|
}, [z, ue]), x(() => {
|
|
2907
2991
|
let e = (e) => {
|
|
2908
|
-
if (e.key !== "Backspace" && e.key !== "Delete" || !o || !i ||
|
|
2992
|
+
if (e.key !== "Backspace" && e.key !== "Delete" || !o || !i || bn()) return;
|
|
2909
2993
|
let t = a?.view?.dom, n = e.target;
|
|
2910
2994
|
if (a?.isFocused && n instanceof Node && t?.contains(n)) {
|
|
2911
2995
|
if (e.preventDefault(), e.stopPropagation(), a) {
|
|
@@ -2924,17 +3008,17 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2924
3008
|
a,
|
|
2925
3009
|
o
|
|
2926
3010
|
]), x(() => {
|
|
2927
|
-
if (!c || !
|
|
2928
|
-
d(null), y(null),
|
|
3011
|
+
if (!c || !Ln(U)) {
|
|
3012
|
+
d(null), y(null), M.current = null;
|
|
2929
3013
|
return;
|
|
2930
3014
|
}
|
|
2931
|
-
if (
|
|
3015
|
+
if (M.current === U) return;
|
|
2932
3016
|
let e = new AbortController(), r = !0;
|
|
2933
3017
|
return g(!0), y(null), (async () => {
|
|
2934
3018
|
let i = U.includes("?X-Amz-"), a = null, o = null;
|
|
2935
|
-
if (!a && !i && (a = await
|
|
3019
|
+
if (!a && !i && (a = await zn(U, e.signal)), !a && !i) try {
|
|
2936
3020
|
let n = await t(U);
|
|
2937
|
-
n && (a = await
|
|
3021
|
+
n && (a = await zn(n, e.signal) || await Bn(n, void 0, e.signal));
|
|
2938
3022
|
} catch (e) {
|
|
2939
3023
|
console.warn("[attachment] signPreviewUrl failed:", e);
|
|
2940
3024
|
}
|
|
@@ -2946,7 +3030,7 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2946
3030
|
n[t] = e;
|
|
2947
3031
|
});
|
|
2948
3032
|
try {
|
|
2949
|
-
a = await
|
|
3033
|
+
a = await Bn(U, n, e.signal);
|
|
2950
3034
|
} catch (e) {
|
|
2951
3035
|
console.warn("[attachment] signed headers XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
|
|
2952
3036
|
}
|
|
@@ -2955,24 +3039,24 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2955
3039
|
console.warn("[attachment] signPreviewUrlHeaders failed:", e);
|
|
2956
3040
|
}
|
|
2957
3041
|
if (!a) try {
|
|
2958
|
-
a = await
|
|
3042
|
+
a = await Bn(U, i ? void 0 : { "X-Requested-With": "XMLHttpRequest" }, e.signal);
|
|
2959
3043
|
} catch (e) {
|
|
2960
3044
|
console.warn("[attachment] plain XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
|
|
2961
3045
|
}
|
|
2962
3046
|
if (!a) throw o || /* @__PURE__ */ Error("所有 fetch 方法均失败");
|
|
2963
3047
|
if (!r) return;
|
|
2964
|
-
d(a),
|
|
3048
|
+
d(a), M.current = U;
|
|
2965
3049
|
let s = URL.createObjectURL(new Blob([a], { type: "application/octet-stream" }));
|
|
2966
3050
|
m(s), g(!1);
|
|
2967
3051
|
})().catch((e) => {
|
|
2968
|
-
r && (e instanceof DOMException && e.name === "AbortError" || (
|
|
3052
|
+
r && (e instanceof DOMException && e.name === "AbortError" || (M.current === U ? g(!1) : y(e instanceof Error ? e.message : "附件读取失败,请检查对象存储 CORS 和公开访问权限")));
|
|
2969
3053
|
}), () => {
|
|
2970
3054
|
r = !1, e.abort();
|
|
2971
3055
|
};
|
|
2972
3056
|
}, [c, U]), x(() => () => {
|
|
2973
3057
|
f && URL.revokeObjectURL(f), d(null);
|
|
2974
3058
|
}, []), x(() => () => {
|
|
2975
|
-
f && URL.revokeObjectURL(f), m(null), d(null),
|
|
3059
|
+
f && URL.revokeObjectURL(f), m(null), d(null), M.current = null;
|
|
2976
3060
|
}, [U]), x(() => {
|
|
2977
3061
|
if (k !== "success" && k !== "error") return;
|
|
2978
3062
|
let e = window.setTimeout(() => A(null), 2400);
|
|
@@ -3012,7 +3096,7 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3012
3096
|
f
|
|
3013
3097
|
]);
|
|
3014
3098
|
return /* @__PURE__ */ O(P, {
|
|
3015
|
-
ref:
|
|
3099
|
+
ref: ee,
|
|
3016
3100
|
as: "div",
|
|
3017
3101
|
className: `attachment-embed group/att ${i ? "is-selected" : ""}`,
|
|
3018
3102
|
contentEditable: !1,
|
|
@@ -3044,7 +3128,7 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3044
3128
|
/* @__PURE__ */ D("path", { d: "M12 9v4" }),
|
|
3045
3129
|
/* @__PURE__ */ D("path", { d: "M12 17h.01" })
|
|
3046
3130
|
]
|
|
3047
|
-
}) :
|
|
3131
|
+
}) : Pn(W)
|
|
3048
3132
|
}), /* @__PURE__ */ O("div", {
|
|
3049
3133
|
className: "att-meta",
|
|
3050
3134
|
children: [/* @__PURE__ */ D("span", {
|
|
@@ -3052,7 +3136,7 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3052
3136
|
children: W
|
|
3053
3137
|
}), se > 0 && /* @__PURE__ */ D("span", {
|
|
3054
3138
|
className: "att-size",
|
|
3055
|
-
children:
|
|
3139
|
+
children: Nn(se)
|
|
3056
3140
|
})]
|
|
3057
3141
|
})]
|
|
3058
3142
|
}), /* @__PURE__ */ O("div", {
|
|
@@ -3105,7 +3189,7 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3105
3189
|
}), /* @__PURE__ */ O("div", {
|
|
3106
3190
|
className: "att-actions",
|
|
3107
3191
|
children: [
|
|
3108
|
-
U &&
|
|
3192
|
+
U && In(W) && /* @__PURE__ */ D("button", {
|
|
3109
3193
|
type: "button",
|
|
3110
3194
|
className: "att-btn",
|
|
3111
3195
|
onMouseDown: (e) => {
|
|
@@ -3158,7 +3242,7 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3158
3242
|
type: "button",
|
|
3159
3243
|
className: "att-btn att-btn--del",
|
|
3160
3244
|
onClick: () => {
|
|
3161
|
-
o && !
|
|
3245
|
+
o && !bn() && ($(!0), L(!0));
|
|
3162
3246
|
},
|
|
3163
3247
|
title: p("editor.attachment.delete"),
|
|
3164
3248
|
"aria-label": p("editor.attachment.delete"),
|
|
@@ -3181,7 +3265,7 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3181
3265
|
})]
|
|
3182
3266
|
})]
|
|
3183
3267
|
}), c && /* @__PURE__ */ O("div", {
|
|
3184
|
-
ref:
|
|
3268
|
+
ref: j,
|
|
3185
3269
|
className: `att-preview-wrap ${z === "web" ? "is-web-fs" : ""}`,
|
|
3186
3270
|
style: {
|
|
3187
3271
|
position: "relative",
|
|
@@ -3214,7 +3298,7 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3214
3298
|
style: { background: "#fff" },
|
|
3215
3299
|
children: p("editor.attachment.loadingPreview")
|
|
3216
3300
|
}),
|
|
3217
|
-
children: u || f || U ? V ? /* @__PURE__ */ D(
|
|
3301
|
+
children: u || f || U ? V ? /* @__PURE__ */ D(On, {
|
|
3218
3302
|
buffer: u || void 0,
|
|
3219
3303
|
url: f || U,
|
|
3220
3304
|
name: W,
|
|
@@ -3326,7 +3410,7 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3326
3410
|
})]
|
|
3327
3411
|
})]
|
|
3328
3412
|
})]
|
|
3329
|
-
}), /* @__PURE__ */ D(
|
|
3413
|
+
}), /* @__PURE__ */ D(Tn, {
|
|
3330
3414
|
open: ne,
|
|
3331
3415
|
title: "确认删除附件",
|
|
3332
3416
|
message: G ? "此操作将删除该附件节点,不可撤销。" : `此操作将同时删除对象存储中的文件(${W}),不可撤销。`,
|
|
@@ -3338,12 +3422,12 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3338
3422
|
if (a) {
|
|
3339
3423
|
let e = R.current, t = e?.from ?? a.state.selection.from, n = e?.to ?? a.state.selection.to, r = [];
|
|
3340
3424
|
a.state.doc.nodesBetween(t, n, (e) => {
|
|
3341
|
-
e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(
|
|
3425
|
+
e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(Jt(e.attrs.src));
|
|
3342
3426
|
}), await Promise.all(r), $(!1), await new Promise((e) => setTimeout(e, 300)), a.chain().focus().setTextSelection({
|
|
3343
3427
|
from: t,
|
|
3344
3428
|
to: n
|
|
3345
3429
|
}).deleteSelection().run();
|
|
3346
|
-
} else await
|
|
3430
|
+
} else await Jt(U), $(!1), await new Promise((e) => setTimeout(e, 300)), r();
|
|
3347
3431
|
} catch {
|
|
3348
3432
|
$(!1);
|
|
3349
3433
|
}
|
|
@@ -3352,13 +3436,13 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3352
3436
|
});
|
|
3353
3437
|
}
|
|
3354
3438
|
// src/editor/embeds/attachment.ts
|
|
3355
|
-
var
|
|
3439
|
+
var Hn = ie.create({
|
|
3356
3440
|
name: "attachmentEmbed",
|
|
3357
3441
|
group: "block",
|
|
3358
3442
|
atom: !0,
|
|
3359
3443
|
inline: !1,
|
|
3360
3444
|
addNodeView() {
|
|
3361
|
-
return F(
|
|
3445
|
+
return F(Vn);
|
|
3362
3446
|
},
|
|
3363
3447
|
addAttributes() {
|
|
3364
3448
|
return {
|
|
@@ -3406,7 +3490,7 @@ var Vn = ie.create({
|
|
|
3406
3490
|
}
|
|
3407
3491
|
});
|
|
3408
3492
|
// src/editor/utils/insert-media.ts
|
|
3409
|
-
function
|
|
3493
|
+
function Un(e, t, n) {
|
|
3410
3494
|
n === void 0 ? e.replaceSelectionWith(t) : e.insert(n, t);
|
|
3411
3495
|
let r = 0;
|
|
3412
3496
|
if (e.doc.descendants((e, n) => {
|
|
@@ -3415,12 +3499,12 @@ function Hn(e, t, n) {
|
|
|
3415
3499
|
let i = e.doc.nodeAt(r);
|
|
3416
3500
|
return (i?.type.name !== "paragraph" || i.content.size !== 0) && e.insert(r, e.doc.type.schema.nodes.paragraph.create()), e.setSelection(ae.create(e.doc, r + 1)), !0;
|
|
3417
3501
|
}
|
|
3418
|
-
function
|
|
3502
|
+
function Wn(e, t, n) {
|
|
3419
3503
|
let r = e.state.tr;
|
|
3420
|
-
return
|
|
3504
|
+
return Un(r, t, n) ? (e.dispatch(r.scrollIntoView()), e.focus(), !0) : !1;
|
|
3421
3505
|
}
|
|
3422
3506
|
// src/editor/embeds/audio-view.tsx
|
|
3423
|
-
function
|
|
3507
|
+
function Gn({ node: e, deleteNode: t, editor: r }) {
|
|
3424
3508
|
let i = e.attrs.src || "", a = e.attrs.name || i.split("/").pop()?.split("?")[0] || "audio", [o, s] = T(!1), c = r?.isEditable ?? !0;
|
|
3425
3509
|
x(() => () => {
|
|
3426
3510
|
i.startsWith("blob:") && URL.revokeObjectURL(i);
|
|
@@ -3485,7 +3569,7 @@ function Wn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3485
3569
|
type: "button",
|
|
3486
3570
|
className: "audio-embed-btn audio-embed-btn--del",
|
|
3487
3571
|
onClick: () => {
|
|
3488
|
-
|
|
3572
|
+
bn() || ($(!0), s(!0));
|
|
3489
3573
|
},
|
|
3490
3574
|
title: "删除",
|
|
3491
3575
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -3531,7 +3615,7 @@ function Wn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3531
3615
|
}), "音频文件缺失"]
|
|
3532
3616
|
})
|
|
3533
3617
|
})]
|
|
3534
|
-
}), /* @__PURE__ */ D(
|
|
3618
|
+
}), /* @__PURE__ */ D(Tn, {
|
|
3535
3619
|
open: o,
|
|
3536
3620
|
title: "确认删除音频",
|
|
3537
3621
|
message: `此操作将同时删除对象存储中的文件(${a}),不可撤销。`,
|
|
@@ -3540,7 +3624,7 @@ function Wn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3540
3624
|
},
|
|
3541
3625
|
onConfirm: async () => {
|
|
3542
3626
|
try {
|
|
3543
|
-
await
|
|
3627
|
+
await Jt(i);
|
|
3544
3628
|
} catch {}
|
|
3545
3629
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
3546
3630
|
}
|
|
@@ -3548,16 +3632,16 @@ function Wn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3548
3632
|
});
|
|
3549
3633
|
}
|
|
3550
3634
|
// src/editor/embeds/audio.ts
|
|
3551
|
-
function
|
|
3635
|
+
function Kn(e) {
|
|
3552
3636
|
return /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|$)/i.test(e) || /\/.*\.(mp3|wav|ogg|flac)/i.test(e);
|
|
3553
3637
|
}
|
|
3554
|
-
var
|
|
3638
|
+
var qn = ie.create({
|
|
3555
3639
|
name: "audioEmbed",
|
|
3556
3640
|
group: "block",
|
|
3557
3641
|
atom: !0,
|
|
3558
3642
|
inline: !1,
|
|
3559
3643
|
addNodeView() {
|
|
3560
|
-
return F(
|
|
3644
|
+
return F(Gn);
|
|
3561
3645
|
},
|
|
3562
3646
|
addProseMirrorPlugins() {
|
|
3563
3647
|
return [new V({ props: { handlePaste(e, t) {
|
|
@@ -3566,7 +3650,7 @@ var Kn = ie.create({
|
|
|
3566
3650
|
let r = n.split(/\r?\n/);
|
|
3567
3651
|
for (let n of r) {
|
|
3568
3652
|
let r = n.trim();
|
|
3569
|
-
if (r && !r.includes(" ") &&
|
|
3653
|
+
if (r && !r.includes(" ") && Kn(r)) return t.preventDefault(), Wn(e, e.state.schema.nodes.audioEmbed.create({ src: r })), !0;
|
|
3570
3654
|
}
|
|
3571
3655
|
return !1;
|
|
3572
3656
|
} } })];
|
|
@@ -3609,17 +3693,17 @@ var Kn = ie.create({
|
|
|
3609
3693
|
}
|
|
3610
3694
|
});
|
|
3611
3695
|
// src/editor/embeds/video-view.tsx
|
|
3612
|
-
function
|
|
3696
|
+
function Jn(e) {
|
|
3613
3697
|
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";
|
|
3614
3698
|
}
|
|
3615
|
-
function
|
|
3699
|
+
function Yn(e) {
|
|
3616
3700
|
let t = e.match(/BV[a-zA-Z0-9]{10}/);
|
|
3617
3701
|
if (t) return t[0];
|
|
3618
3702
|
let n = e.match(/av(\d+)/i);
|
|
3619
3703
|
return n ? n[0] : e;
|
|
3620
3704
|
}
|
|
3621
|
-
function
|
|
3622
|
-
let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ?
|
|
3705
|
+
function Xn({ node: e, deleteNode: t, editor: n }) {
|
|
3706
|
+
let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ? Jn(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(Tn, {
|
|
3623
3707
|
open: o,
|
|
3624
3708
|
title: "确认删除视频",
|
|
3625
3709
|
message: "此操作将同时删除对象存储中的文件,不可撤销。",
|
|
@@ -3628,21 +3712,21 @@ function Yn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3628
3712
|
},
|
|
3629
3713
|
onConfirm: async () => {
|
|
3630
3714
|
try {
|
|
3631
|
-
await
|
|
3715
|
+
await Jt(r);
|
|
3632
3716
|
} catch {}
|
|
3633
3717
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
3634
3718
|
}
|
|
3635
3719
|
}), [h, g] = T(""), _ = w(null), v = w(null), y = w(null), S = w(null), C = w(null), k = w(0), A = b(() => {
|
|
3636
3720
|
let e = y.current;
|
|
3637
3721
|
e && (e.style.position = "", e.style.inset = "", e.style.zIndex = "", e.style.borderRadius = "", document.body.style.overflow = "");
|
|
3638
|
-
}, []),
|
|
3722
|
+
}, []), ee = b(() => {
|
|
3639
3723
|
document.fullscreenElement && document.exitFullscreen?.(), A();
|
|
3640
|
-
}, [A]),
|
|
3724
|
+
}, [A]), j = b(() => {
|
|
3641
3725
|
let e = y.current;
|
|
3642
3726
|
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"));
|
|
3643
|
-
}, [A]),
|
|
3727
|
+
}, [A]), M = b(() => {
|
|
3644
3728
|
k.current = window.scrollY, S.current?.requestFullscreen?.();
|
|
3645
|
-
}, []),
|
|
3729
|
+
}, []), N = b(() => {
|
|
3646
3730
|
let e = v.current?.closest(".video-embed--direct") || v.current;
|
|
3647
3731
|
e && (k.current = window.scrollY, e.requestFullscreen?.());
|
|
3648
3732
|
}, []);
|
|
@@ -3731,7 +3815,7 @@ function Yn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3731
3815
|
}, [a, h]), x(() => {
|
|
3732
3816
|
u && (_.current?.destroy(), _.current = null);
|
|
3733
3817
|
}, [u]), a === "bilibili") {
|
|
3734
|
-
let e =
|
|
3818
|
+
let e = Yn(r);
|
|
3735
3819
|
return /* @__PURE__ */ O(P, {
|
|
3736
3820
|
as: "div",
|
|
3737
3821
|
className: "video-embed video-embed--bilibili group/video",
|
|
@@ -3749,7 +3833,7 @@ function Yn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3749
3833
|
type: "button",
|
|
3750
3834
|
className: "video-fs-btn",
|
|
3751
3835
|
title: "宽屏",
|
|
3752
|
-
onClick:
|
|
3836
|
+
onClick: ee,
|
|
3753
3837
|
children: /* @__PURE__ */ D("svg", {
|
|
3754
3838
|
width: "12",
|
|
3755
3839
|
height: "12",
|
|
@@ -3768,7 +3852,7 @@ function Yn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3768
3852
|
type: "button",
|
|
3769
3853
|
className: "video-fs-btn",
|
|
3770
3854
|
title: "网页全屏",
|
|
3771
|
-
onClick:
|
|
3855
|
+
onClick: j,
|
|
3772
3856
|
children: /* @__PURE__ */ D("svg", {
|
|
3773
3857
|
width: "12",
|
|
3774
3858
|
height: "12",
|
|
@@ -3787,7 +3871,7 @@ function Yn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3787
3871
|
type: "button",
|
|
3788
3872
|
className: "video-fs-btn",
|
|
3789
3873
|
title: "全屏",
|
|
3790
|
-
onClick:
|
|
3874
|
+
onClick: M,
|
|
3791
3875
|
children: /* @__PURE__ */ D("svg", {
|
|
3792
3876
|
width: "12",
|
|
3793
3877
|
height: "12",
|
|
@@ -3807,7 +3891,7 @@ function Yn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3807
3891
|
className: "video-fs-btn video-fs-btn--del",
|
|
3808
3892
|
title: "删除",
|
|
3809
3893
|
onClick: () => {
|
|
3810
|
-
|
|
3894
|
+
bn() || ($(!0), s(!0));
|
|
3811
3895
|
},
|
|
3812
3896
|
children: /* @__PURE__ */ D("svg", {
|
|
3813
3897
|
width: "12",
|
|
@@ -3912,7 +3996,7 @@ function Yn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3912
3996
|
className: "video-fs-btn video-fs-btn--del",
|
|
3913
3997
|
title: "删除",
|
|
3914
3998
|
onClick: () => {
|
|
3915
|
-
|
|
3999
|
+
bn() || ($(!0), s(!0));
|
|
3916
4000
|
},
|
|
3917
4001
|
children: /* @__PURE__ */ D("svg", {
|
|
3918
4002
|
width: "12",
|
|
@@ -3931,7 +4015,7 @@ function Yn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3931
4015
|
type: "button",
|
|
3932
4016
|
className: "video-fs-btn",
|
|
3933
4017
|
title: "全屏",
|
|
3934
|
-
onClick:
|
|
4018
|
+
onClick: N,
|
|
3935
4019
|
children: /* @__PURE__ */ D("svg", {
|
|
3936
4020
|
width: "12",
|
|
3937
4021
|
height: "12",
|
|
@@ -4068,26 +4152,26 @@ function Yn({ node: e, deleteNode: t, editor: n }) {
|
|
|
4068
4152
|
});
|
|
4069
4153
|
}
|
|
4070
4154
|
// src/editor/embeds/video.ts
|
|
4071
|
-
function
|
|
4155
|
+
function Zn(e) {
|
|
4072
4156
|
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";
|
|
4073
4157
|
}
|
|
4074
|
-
function
|
|
4158
|
+
function Qn(e) {
|
|
4075
4159
|
let t = e.match(/BV[a-zA-Z0-9]{10}/);
|
|
4076
4160
|
if (t) return t[0];
|
|
4077
4161
|
let n = e.match(/av(\d+)/i);
|
|
4078
4162
|
return n ? n[0] : e;
|
|
4079
4163
|
}
|
|
4080
|
-
function
|
|
4164
|
+
function $n(e) {
|
|
4081
4165
|
let t = e.match(/explore\/([a-zA-Z0-9]+)/);
|
|
4082
4166
|
return t ? t[1] : e;
|
|
4083
4167
|
}
|
|
4084
|
-
var
|
|
4168
|
+
var er = ie.create({
|
|
4085
4169
|
name: "videoEmbed",
|
|
4086
4170
|
group: "block",
|
|
4087
4171
|
atom: !0,
|
|
4088
4172
|
inline: !1,
|
|
4089
4173
|
addNodeView() {
|
|
4090
|
-
return F(
|
|
4174
|
+
return F(Xn);
|
|
4091
4175
|
},
|
|
4092
4176
|
addProseMirrorPlugins() {
|
|
4093
4177
|
return [new V({ props: {
|
|
@@ -4112,8 +4196,8 @@ var $n = ie.create({
|
|
|
4112
4196
|
for (let n of r) {
|
|
4113
4197
|
let r = n.trim();
|
|
4114
4198
|
if (!r || r.includes(" ")) continue;
|
|
4115
|
-
let i =
|
|
4116
|
-
if (i !== "unknown") return t.preventDefault(),
|
|
4199
|
+
let i = Zn(r);
|
|
4200
|
+
if (i !== "unknown") return t.preventDefault(), Wn(e, e.state.schema.nodes.videoEmbed.create({
|
|
4117
4201
|
src: r,
|
|
4118
4202
|
source: i
|
|
4119
4203
|
})), !0;
|
|
@@ -4141,7 +4225,7 @@ var $n = ie.create({
|
|
|
4141
4225
|
let t = e, n = t.getAttribute("src") || t.getAttribute("data-src") || "";
|
|
4142
4226
|
return {
|
|
4143
4227
|
src: n,
|
|
4144
|
-
source:
|
|
4228
|
+
source: Zn(n)
|
|
4145
4229
|
};
|
|
4146
4230
|
}
|
|
4147
4231
|
},
|
|
@@ -4150,9 +4234,9 @@ var $n = ie.create({
|
|
|
4150
4234
|
];
|
|
4151
4235
|
},
|
|
4152
4236
|
renderHTML({ HTMLAttributes: e }) {
|
|
4153
|
-
let t = e.src || "", n =
|
|
4237
|
+
let t = e.src || "", n = Zn(t);
|
|
4154
4238
|
if (n === "bilibili") {
|
|
4155
|
-
let e =
|
|
4239
|
+
let e = Qn(t);
|
|
4156
4240
|
return [
|
|
4157
4241
|
"div",
|
|
4158
4242
|
{
|
|
@@ -4173,7 +4257,7 @@ var $n = ie.create({
|
|
|
4173
4257
|
}]
|
|
4174
4258
|
];
|
|
4175
4259
|
}
|
|
4176
|
-
if (n === "xiaohongshu") return
|
|
4260
|
+
if (n === "xiaohongshu") return $n(t), [
|
|
4177
4261
|
"div",
|
|
4178
4262
|
{
|
|
4179
4263
|
"data-video-embed": "xiaohongshu",
|
|
@@ -4225,8 +4309,8 @@ var $n = ie.create({
|
|
|
4225
4309
|
},
|
|
4226
4310
|
addCommands() {
|
|
4227
4311
|
return { insertVideo: (e) => ({ chain: t }) => {
|
|
4228
|
-
let n =
|
|
4229
|
-
return t().command(({ tr: t }) =>
|
|
4312
|
+
let n = Zn(e.src);
|
|
4313
|
+
return t().command(({ tr: t }) => Un(t, this.type.create({
|
|
4230
4314
|
...e,
|
|
4231
4315
|
source: n
|
|
4232
4316
|
}))).focus().scrollIntoView().run();
|
|
@@ -4234,7 +4318,7 @@ var $n = ie.create({
|
|
|
4234
4318
|
}
|
|
4235
4319
|
});
|
|
4236
4320
|
// src/editor/extensions/chinese-emphasis.ts
|
|
4237
|
-
function
|
|
4321
|
+
function tr(e) {
|
|
4238
4322
|
e.__qingwuChineseEmphasis || (e.__qingwuChineseEmphasis = !0, e.inline.ruler.before("emphasis", "qingwu_chinese_emphasis", (e) => {
|
|
4239
4323
|
if (e.__qingwuChineseEmphasis) return !1;
|
|
4240
4324
|
e.__qingwuChineseEmphasis = !0;
|
|
@@ -4247,19 +4331,19 @@ function er(e) {
|
|
|
4247
4331
|
}, !1;
|
|
4248
4332
|
}));
|
|
4249
4333
|
}
|
|
4250
|
-
var
|
|
4334
|
+
var nr = R.create({
|
|
4251
4335
|
name: "chineseEmphasis",
|
|
4252
4336
|
addStorage() {
|
|
4253
|
-
return { markdown: { parse: { setup:
|
|
4337
|
+
return { markdown: { parse: { setup: tr } } };
|
|
4254
4338
|
}
|
|
4255
|
-
}),
|
|
4339
|
+
}), rr = null, ir = {
|
|
4256
4340
|
fontFamily: "Inter, 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', system-ui, sans-serif",
|
|
4257
4341
|
padding: 24
|
|
4258
|
-
},
|
|
4259
|
-
async function
|
|
4260
|
-
return
|
|
4342
|
+
}, ar = .25, or = 4, sr = .25;
|
|
4343
|
+
async function cr(e) {
|
|
4344
|
+
return rr ||= await import("pele"), rr.render(e, ir).svg;
|
|
4261
4345
|
}
|
|
4262
|
-
var
|
|
4346
|
+
var lr = [
|
|
4263
4347
|
{
|
|
4264
4348
|
value: "javascript",
|
|
4265
4349
|
label: "JavaScript",
|
|
@@ -4420,7 +4504,7 @@ var cr = [
|
|
|
4420
4504
|
label: "Plain Text",
|
|
4421
4505
|
color: "#6b7280"
|
|
4422
4506
|
}
|
|
4423
|
-
],
|
|
4507
|
+
], ur = {
|
|
4424
4508
|
javascript: "js",
|
|
4425
4509
|
typescript: "ts",
|
|
4426
4510
|
python: "py",
|
|
@@ -4446,7 +4530,7 @@ var cr = [
|
|
|
4446
4530
|
txt: "txt",
|
|
4447
4531
|
vue: "vue",
|
|
4448
4532
|
react: "jsx"
|
|
4449
|
-
},
|
|
4533
|
+
}, dr = {
|
|
4450
4534
|
js: "javascript",
|
|
4451
4535
|
ts: "typescript",
|
|
4452
4536
|
py: "python",
|
|
@@ -4462,15 +4546,15 @@ var cr = [
|
|
|
4462
4546
|
jsx: "javascript",
|
|
4463
4547
|
tsx: "typescript"
|
|
4464
4548
|
};
|
|
4465
|
-
function
|
|
4549
|
+
function fr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i, selected: a }) {
|
|
4466
4550
|
let o = n?.isEditable ?? !0, s = !o, [c, l] = T(!1), [u, d] = T(!1), [f, p] = T(!1), [h, g] = T(!1), [_, v] = T(220), [y, S] = T({
|
|
4467
4551
|
top: 0,
|
|
4468
4552
|
left: 0,
|
|
4469
4553
|
width: 210
|
|
4470
|
-
}), [k, A] = T(""), [
|
|
4554
|
+
}), [k, A] = T(""), [ee, j] = T(!1), [M, N] = T(null), [P, F] = T(null), [I, te] = T(!1), [ne, R] = T(!1), [re, ie] = T(1), [z, B] = T({
|
|
4471
4555
|
x: 0,
|
|
4472
4556
|
y: 0
|
|
4473
|
-
}), [V, H] = T(!1), ae = w(null), oe = w(null), U = w(null), W = w(null), se = w(null), ce = w(null), G = w(null), K = e.attrs.language || "", le =
|
|
4557
|
+
}), [V, H] = T(!1), ae = w(null), oe = w(null), U = w(null), W = w(null), se = w(null), ce = w(null), G = w(null), K = e.attrs.language || "", le = lr.find((e) => e.value === (dr[K] ?? K)), ue = K === "mermaid", de = (e) => Math.min(or, Math.max(ar, e)), fe = (e) => ie((t) => Math.round(de(t + e) * 100) / 100), pe = () => {
|
|
4474
4558
|
ie(1), B({
|
|
4475
4559
|
x: 0,
|
|
4476
4560
|
y: 0
|
|
@@ -4479,8 +4563,8 @@ function dr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4479
4563
|
pe(), R(!0);
|
|
4480
4564
|
};
|
|
4481
4565
|
x(() => {
|
|
4482
|
-
|
|
4483
|
-
}, [
|
|
4566
|
+
M || R(!1);
|
|
4567
|
+
}, [M]), x(() => {
|
|
4484
4568
|
if (!ne) return;
|
|
4485
4569
|
let e = document.body.style.overflow;
|
|
4486
4570
|
document.body.style.overflow = "hidden";
|
|
@@ -4518,10 +4602,10 @@ function dr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4518
4602
|
r,
|
|
4519
4603
|
e.nodeSize
|
|
4520
4604
|
]), ve = b(() => {
|
|
4521
|
-
o && (
|
|
4605
|
+
o && (bn() || (G.current = _e(), window.getSelection()?.removeAllRanges(), $(!0), j(!0)));
|
|
4522
4606
|
}, [_e, o]), ye = C(() => {
|
|
4523
4607
|
let e = k.trim().toLowerCase();
|
|
4524
|
-
return e ?
|
|
4608
|
+
return e ? lr.filter((t) => t.label.toLowerCase().includes(e) || t.value.toLowerCase().includes(e)) : lr;
|
|
4525
4609
|
}, [k]);
|
|
4526
4610
|
x(() => {
|
|
4527
4611
|
(ce.current?.closest(".code-block-node-view"))?.classList.toggle("code-block-node-view--collapsed", u);
|
|
@@ -4529,7 +4613,7 @@ function dr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4529
4613
|
let be = b(() => {
|
|
4530
4614
|
let e = W.current;
|
|
4531
4615
|
if (!e) return;
|
|
4532
|
-
let t = e.getBoundingClientRect(), n = Math.min(t.left, window.innerWidth - 210 - 8), r = window.innerHeight - t.bottom - 12, i = t.top - 12, a =
|
|
4616
|
+
let t = e.getBoundingClientRect(), n = Math.min(t.left, window.innerWidth - 210 - 8), r = window.innerHeight - t.bottom - 12, i = t.top - 12, a = lr.length * 31 + 8, o = r - 52, s = i - 52;
|
|
4533
4617
|
o < 220 && s > o ? (g(!0), v(Math.max(120, Math.min(a, s))), S({
|
|
4534
4618
|
top: t.top,
|
|
4535
4619
|
left: n,
|
|
@@ -4562,7 +4646,7 @@ function dr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4562
4646
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
4563
4647
|
}, [f]), x(() => {
|
|
4564
4648
|
let e = (e) => {
|
|
4565
|
-
if (e.key !== "Backspace" && e.key !== "Delete" || !o || !a ||
|
|
4649
|
+
if (e.key !== "Backspace" && e.key !== "Delete" || !o || !a || bn()) return;
|
|
4566
4650
|
let t = n?.view?.dom, r = e.target;
|
|
4567
4651
|
if (n?.isFocused && r instanceof Node && t?.contains(r)) {
|
|
4568
4652
|
if (e.preventDefault(), e.stopPropagation(), n) {
|
|
@@ -4572,7 +4656,7 @@ function dr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4572
4656
|
to: t
|
|
4573
4657
|
};
|
|
4574
4658
|
}
|
|
4575
|
-
window.getSelection()?.removeAllRanges(), $(!0),
|
|
4659
|
+
window.getSelection()?.removeAllRanges(), $(!0), j(!0);
|
|
4576
4660
|
}
|
|
4577
4661
|
};
|
|
4578
4662
|
return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
|
|
@@ -4606,20 +4690,20 @@ function dr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4606
4690
|
};
|
|
4607
4691
|
navigator.clipboard?.writeText ? navigator.clipboard.writeText(t).catch(() => n(t)) : n(t), l(!0), setTimeout(() => l(!1), 1500);
|
|
4608
4692
|
}, [e.textContent]), we = b(() => {
|
|
4609
|
-
let t =
|
|
4693
|
+
let t = ur[K] || "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");
|
|
4610
4694
|
a.href = i, a.download = n, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
4611
4695
|
}, [e.textContent, K]), Te = b(async () => {
|
|
4612
|
-
if (
|
|
4696
|
+
if (M || I) N(null), F(null), te(!1);
|
|
4613
4697
|
else {
|
|
4614
|
-
te(!0), F(null),
|
|
4698
|
+
te(!0), F(null), N(null);
|
|
4615
4699
|
try {
|
|
4616
4700
|
let t = (e.textContent || "").trim();
|
|
4617
4701
|
if (!t) {
|
|
4618
4702
|
F("代码块内容为空");
|
|
4619
4703
|
return;
|
|
4620
4704
|
}
|
|
4621
|
-
let n = await
|
|
4622
|
-
|
|
4705
|
+
let n = await cr(t), r = m(n);
|
|
4706
|
+
N(r);
|
|
4623
4707
|
} catch (e) {
|
|
4624
4708
|
F(e instanceof Error ? e.message : "图表渲染失败");
|
|
4625
4709
|
} finally {
|
|
@@ -4628,7 +4712,7 @@ function dr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4628
4712
|
}
|
|
4629
4713
|
}, [
|
|
4630
4714
|
e.textContent,
|
|
4631
|
-
|
|
4715
|
+
M,
|
|
4632
4716
|
I
|
|
4633
4717
|
]), Ee = /* @__PURE__ */ O(E, { children: [le ? le.deviconClass ? /* @__PURE__ */ D("i", {
|
|
4634
4718
|
className: `${le.deviconClass} colored cb-lang-icon`,
|
|
@@ -4885,7 +4969,7 @@ function dr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4885
4969
|
className: "cb-btn cb-btn--diagram",
|
|
4886
4970
|
onClick: Te,
|
|
4887
4971
|
contentEditable: !1,
|
|
4888
|
-
title:
|
|
4972
|
+
title: M || I ? "取消渲染" : "渲染图表",
|
|
4889
4973
|
disabled: I,
|
|
4890
4974
|
children: /* @__PURE__ */ D("svg", {
|
|
4891
4975
|
className: "cb-btn-icon",
|
|
@@ -4904,7 +4988,7 @@ function dr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4904
4988
|
})
|
|
4905
4989
|
]
|
|
4906
4990
|
}),
|
|
4907
|
-
(
|
|
4991
|
+
(M || P || I) && /* @__PURE__ */ O("div", {
|
|
4908
4992
|
className: "cb-diagram-output",
|
|
4909
4993
|
contentEditable: !1,
|
|
4910
4994
|
children: [
|
|
@@ -4919,7 +5003,7 @@ function dr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4919
5003
|
children: "!"
|
|
4920
5004
|
}), P]
|
|
4921
5005
|
}),
|
|
4922
|
-
|
|
5006
|
+
M && /* @__PURE__ */ O("div", {
|
|
4923
5007
|
className: "cb-diagram-svg",
|
|
4924
5008
|
role: "button",
|
|
4925
5009
|
tabIndex: 0,
|
|
@@ -4930,7 +5014,7 @@ function dr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4930
5014
|
},
|
|
4931
5015
|
children: [/* @__PURE__ */ D("div", {
|
|
4932
5016
|
className: "cb-diagram-svg-inner",
|
|
4933
|
-
dangerouslySetInnerHTML: { __html:
|
|
5017
|
+
dangerouslySetInnerHTML: { __html: M }
|
|
4934
5018
|
}), /* @__PURE__ */ D("span", {
|
|
4935
5019
|
className: "cb-diagram-zoom-hint",
|
|
4936
5020
|
children: "点击放大"
|
|
@@ -4938,7 +5022,7 @@ function dr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4938
5022
|
})
|
|
4939
5023
|
]
|
|
4940
5024
|
}),
|
|
4941
|
-
ne &&
|
|
5025
|
+
ne && M && L(/* @__PURE__ */ O("div", {
|
|
4942
5026
|
className: "fixed inset-0 z-[10002] flex flex-col bg-black/75 backdrop-blur-sm select-none",
|
|
4943
5027
|
role: "dialog",
|
|
4944
5028
|
"aria-modal": "true",
|
|
@@ -4970,7 +5054,7 @@ function dr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4970
5054
|
/* @__PURE__ */ D("button", {
|
|
4971
5055
|
type: "button",
|
|
4972
5056
|
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",
|
|
4973
|
-
onClick: () => fe(
|
|
5057
|
+
onClick: () => fe(sr),
|
|
4974
5058
|
title: "放大",
|
|
4975
5059
|
"aria-label": "放大",
|
|
4976
5060
|
children: "+"
|
|
@@ -4997,7 +5081,7 @@ function dr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4997
5081
|
}), /* @__PURE__ */ D("div", {
|
|
4998
5082
|
className: "flex flex-1 touch-none items-center justify-center overflow-hidden",
|
|
4999
5083
|
style: { cursor: V ? "grabbing" : re > 1 ? "grab" : "default" },
|
|
5000
|
-
onWheel: (e) => fe(e.deltaY > 0 ? -.25 :
|
|
5084
|
+
onWheel: (e) => fe(e.deltaY > 0 ? -.25 : sr),
|
|
5001
5085
|
onPointerDown: he,
|
|
5002
5086
|
onPointerMove: ge,
|
|
5003
5087
|
onPointerUp: q,
|
|
@@ -5014,16 +5098,16 @@ function dr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
5014
5098
|
transform: `translate(${z.x}px, ${z.y}px) scale(${re})`,
|
|
5015
5099
|
transition: V ? "none" : "transform 120ms ease-out"
|
|
5016
5100
|
},
|
|
5017
|
-
dangerouslySetInnerHTML: { __html:
|
|
5101
|
+
dangerouslySetInnerHTML: { __html: M }
|
|
5018
5102
|
})
|
|
5019
5103
|
})]
|
|
5020
5104
|
}), document.body),
|
|
5021
|
-
/* @__PURE__ */ D(
|
|
5022
|
-
open:
|
|
5105
|
+
/* @__PURE__ */ D(Tn, {
|
|
5106
|
+
open: ee,
|
|
5023
5107
|
title: "确认删除代码块",
|
|
5024
5108
|
message: "此操作不可撤销。",
|
|
5025
5109
|
onCancel: () => {
|
|
5026
|
-
$(!1),
|
|
5110
|
+
$(!1), j(!1);
|
|
5027
5111
|
},
|
|
5028
5112
|
onConfirm: async () => {
|
|
5029
5113
|
await new Promise((e) => setTimeout(e, 300)), $(!1), i();
|
|
@@ -5033,7 +5117,7 @@ function dr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
5033
5117
|
});
|
|
5034
5118
|
}
|
|
5035
5119
|
// src/editor/extensions/code-block.ts
|
|
5036
|
-
var
|
|
5120
|
+
var pr = [
|
|
5037
5121
|
{
|
|
5038
5122
|
value: "javascript",
|
|
5039
5123
|
label: "JavaScript"
|
|
@@ -5134,12 +5218,12 @@ var fr = [
|
|
|
5134
5218
|
value: "mermaid",
|
|
5135
5219
|
label: "Mermaid"
|
|
5136
5220
|
}
|
|
5137
|
-
],
|
|
5138
|
-
|
|
5139
|
-
function
|
|
5221
|
+
], mr = Ce(Se);
|
|
5222
|
+
mr.register({ dockerfile: xe }), mr.registerAlias("xml", ["vue", "html"]), mr.registerAlias("javascript", ["react", "jsx"]), mr.registerAlias("typescript", ["tsx"]);
|
|
5223
|
+
function hr(e) {
|
|
5140
5224
|
return e ? e.split("\n") : [""];
|
|
5141
5225
|
}
|
|
5142
|
-
function
|
|
5226
|
+
function gr(e, t) {
|
|
5143
5227
|
if (e.childElementCount !== t) {
|
|
5144
5228
|
e.replaceChildren();
|
|
5145
5229
|
for (let n = 1; n <= t; n++) {
|
|
@@ -5148,14 +5232,14 @@ function hr(e, t) {
|
|
|
5148
5232
|
}
|
|
5149
5233
|
}
|
|
5150
5234
|
}
|
|
5151
|
-
function
|
|
5235
|
+
function _r(e, t) {
|
|
5152
5236
|
e.replaceChildren();
|
|
5153
5237
|
for (let n of t) {
|
|
5154
5238
|
let t = document.createElement("span");
|
|
5155
5239
|
t.className = "cb-mirror-line", t.textContent = n.length ? n : "\xA0", e.appendChild(t);
|
|
5156
5240
|
}
|
|
5157
5241
|
}
|
|
5158
|
-
function
|
|
5242
|
+
function vr(e, t, n) {
|
|
5159
5243
|
let r = getComputedStyle(e), i = parseFloat(r.paddingLeft), a = parseFloat(r.paddingRight);
|
|
5160
5244
|
t.style.boxSizing = "content-box", t.style.width = `${Math.max(0, e.clientWidth - i - a)}px`, t.style.padding = r.padding;
|
|
5161
5245
|
let o = getComputedStyle(n);
|
|
@@ -5202,7 +5286,7 @@ function _r(e, t, n) {
|
|
|
5202
5286
|
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;
|
|
5203
5287
|
}
|
|
5204
5288
|
}
|
|
5205
|
-
var
|
|
5289
|
+
var yr = be.extend({
|
|
5206
5290
|
addNodeView() {
|
|
5207
5291
|
return (e) => {
|
|
5208
5292
|
let { node: t, editor: n, getPos: r } = e, i = t, a = (e) => {
|
|
@@ -5230,9 +5314,9 @@ var vr = be.extend({
|
|
|
5230
5314
|
f.appendChild(p);
|
|
5231
5315
|
let m = document.createElement("div");
|
|
5232
5316
|
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);
|
|
5233
|
-
let h =
|
|
5234
|
-
|
|
5235
|
-
let g = new I(
|
|
5317
|
+
let h = hr(t.textContent);
|
|
5318
|
+
gr(d, h.length), _r(m, h);
|
|
5319
|
+
let g = new I(fr, {
|
|
5236
5320
|
editor: n,
|
|
5237
5321
|
props: {
|
|
5238
5322
|
node: t,
|
|
@@ -5245,12 +5329,12 @@ var vr = be.extend({
|
|
|
5245
5329
|
});
|
|
5246
5330
|
c.appendChild(g.element);
|
|
5247
5331
|
let _ = (e) => {
|
|
5248
|
-
let t =
|
|
5249
|
-
|
|
5332
|
+
let t = hr(e.textContent);
|
|
5333
|
+
gr(d, t.length), _r(m, t), requestAnimationFrame(() => vr(f, m, d));
|
|
5250
5334
|
};
|
|
5251
|
-
requestAnimationFrame(() =>
|
|
5252
|
-
let v = new ResizeObserver(() =>
|
|
5253
|
-
return v.observe(f), document.fonts?.ready?.then(() =>
|
|
5335
|
+
requestAnimationFrame(() => vr(f, m, d));
|
|
5336
|
+
let v = new ResizeObserver(() => vr(f, m, d));
|
|
5337
|
+
return v.observe(f), document.fonts?.ready?.then(() => vr(f, m, d)), {
|
|
5254
5338
|
dom: s,
|
|
5255
5339
|
contentDOM: p,
|
|
5256
5340
|
update(e) {
|
|
@@ -5303,16 +5387,16 @@ var vr = be.extend({
|
|
|
5303
5387
|
let n = e, r = n.querySelector(":scope > code"), i = Array.from((r ?? n).querySelectorAll(":scope > div"));
|
|
5304
5388
|
if (i.length > 0) {
|
|
5305
5389
|
let e = i.map((e) => e.textContent ?? "").join("\n");
|
|
5306
|
-
return e ?
|
|
5390
|
+
return e ? j.from(t.text(e)) : j.empty;
|
|
5307
5391
|
}
|
|
5308
5392
|
let a = n.textContent ?? "";
|
|
5309
|
-
return a ?
|
|
5393
|
+
return a ? j.from(t.text(a)) : j.empty;
|
|
5310
5394
|
}
|
|
5311
5395
|
}));
|
|
5312
5396
|
}
|
|
5313
|
-
}).configure({ lowlight:
|
|
5397
|
+
}).configure({ lowlight: mr });
|
|
5314
5398
|
// src/editor/utils/import-choice-dialog.ts
|
|
5315
|
-
function
|
|
5399
|
+
function br(e) {
|
|
5316
5400
|
return new Promise((t) => {
|
|
5317
5401
|
let n = document.createElement("div");
|
|
5318
5402
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5341,16 +5425,16 @@ function yr(e) {
|
|
|
5341
5425
|
});
|
|
5342
5426
|
}
|
|
5343
5427
|
// src/editor/utils/local-media.ts
|
|
5344
|
-
var
|
|
5345
|
-
function
|
|
5428
|
+
var xr = /\.(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, Sr = /^(?:mailto:|tel:|javascript:|about:|data:|blob:)/i;
|
|
5429
|
+
function Cr(e) {
|
|
5346
5430
|
if (!e) return !1;
|
|
5347
5431
|
let t = e.trim();
|
|
5348
|
-
return !(!t || /^(?:https?:)?\/\//i.test(t) ||
|
|
5349
|
-
}
|
|
5350
|
-
function Cr(e) {
|
|
5351
|
-
return br.test(e);
|
|
5432
|
+
return !(!t || /^(?:https?:)?\/\//i.test(t) || Sr.test(t) || t.startsWith("#"));
|
|
5352
5433
|
}
|
|
5353
5434
|
function wr(e) {
|
|
5435
|
+
return xr.test(e);
|
|
5436
|
+
}
|
|
5437
|
+
function Tr(e) {
|
|
5354
5438
|
let t = e.trim();
|
|
5355
5439
|
t = t.replace(/^(?:file|app):\/\/(?:localhost)?/i, "");
|
|
5356
5440
|
try {
|
|
@@ -5358,26 +5442,26 @@ function wr(e) {
|
|
|
5358
5442
|
} catch {}
|
|
5359
5443
|
return t = t.replace(/\\/g, "/"), t = t.replace(/^\.\//, ""), t = t.replace(/^\/+/, ""), t = t.replace(/^[a-zA-Z]:\//, ""), t;
|
|
5360
5444
|
}
|
|
5361
|
-
function
|
|
5362
|
-
let t =
|
|
5445
|
+
function Er(e) {
|
|
5446
|
+
let t = Tr(e), n = t.split("/").filter(Boolean);
|
|
5363
5447
|
return (n[n.length - 1] || t).toLowerCase();
|
|
5364
5448
|
}
|
|
5365
|
-
function
|
|
5449
|
+
function Dr() {
|
|
5366
5450
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showDirectoryPicker == "function";
|
|
5367
5451
|
}
|
|
5368
|
-
async function
|
|
5369
|
-
if (!
|
|
5452
|
+
async function Or() {
|
|
5453
|
+
if (!Dr()) return null;
|
|
5370
5454
|
try {
|
|
5371
5455
|
return await window.showDirectoryPicker.call(window, { mode: "read" }) ?? null;
|
|
5372
5456
|
} catch {
|
|
5373
5457
|
return null;
|
|
5374
5458
|
}
|
|
5375
5459
|
}
|
|
5376
|
-
function
|
|
5460
|
+
function kr() {
|
|
5377
5461
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showOpenFilePicker == "function";
|
|
5378
5462
|
}
|
|
5379
|
-
async function
|
|
5380
|
-
if (!
|
|
5463
|
+
async function Ar() {
|
|
5464
|
+
if (!kr()) return null;
|
|
5381
5465
|
try {
|
|
5382
5466
|
let e = await window.showOpenFilePicker.call(window, { multiple: !0 });
|
|
5383
5467
|
return await Promise.all(e.map((e) => e.getFile()));
|
|
@@ -5385,7 +5469,7 @@ async function kr() {
|
|
|
5385
5469
|
return null;
|
|
5386
5470
|
}
|
|
5387
5471
|
}
|
|
5388
|
-
async function
|
|
5472
|
+
async function jr(e, t) {
|
|
5389
5473
|
if (t.length === 0) return { file: null };
|
|
5390
5474
|
let n = e;
|
|
5391
5475
|
for (let e = 0; e < t.length - 1; e++) try {
|
|
@@ -5407,7 +5491,7 @@ async function Ar(e, t) {
|
|
|
5407
5491
|
return { file: null };
|
|
5408
5492
|
}
|
|
5409
5493
|
}
|
|
5410
|
-
async function
|
|
5494
|
+
async function Mr(e, t, n = 5e3) {
|
|
5411
5495
|
let r = t.toLowerCase(), i = [e], a = 0, o;
|
|
5412
5496
|
for (; i.length > 0 && a < n;) {
|
|
5413
5497
|
let e = i.pop();
|
|
@@ -5429,54 +5513,54 @@ async function jr(e, t, n = 5e3) {
|
|
|
5429
5513
|
readError: o
|
|
5430
5514
|
};
|
|
5431
5515
|
}
|
|
5432
|
-
async function
|
|
5433
|
-
let n =
|
|
5516
|
+
async function Nr(e, t) {
|
|
5517
|
+
let n = Tr(t).split("/").filter(Boolean);
|
|
5434
5518
|
if (n.length === 0) return { file: null };
|
|
5435
5519
|
let r;
|
|
5436
5520
|
for (let t = 0; t < n.length; t++) {
|
|
5437
|
-
let i = await
|
|
5521
|
+
let i = await jr(e, n.slice(t));
|
|
5438
5522
|
if (i.file) return i;
|
|
5439
5523
|
i.readError && (r = i.readError);
|
|
5440
5524
|
}
|
|
5441
|
-
let i = await
|
|
5525
|
+
let i = await Mr(e, n[n.length - 1]);
|
|
5442
5526
|
return i.file || i.readError ? i : {
|
|
5443
5527
|
file: null,
|
|
5444
5528
|
readError: r
|
|
5445
5529
|
};
|
|
5446
5530
|
}
|
|
5447
|
-
var
|
|
5531
|
+
var Pr = {
|
|
5448
5532
|
image: "image",
|
|
5449
5533
|
videoEmbed: "video",
|
|
5450
5534
|
audioEmbed: "audio",
|
|
5451
5535
|
attachmentEmbed: "attachment"
|
|
5452
5536
|
};
|
|
5453
|
-
function
|
|
5537
|
+
function Fr(e, t) {
|
|
5454
5538
|
let n = /* @__PURE__ */ new Set(), r = [];
|
|
5455
5539
|
return e.descendants((e) => {
|
|
5456
|
-
let i =
|
|
5540
|
+
let i = Pr[e.type?.name];
|
|
5457
5541
|
if (i) {
|
|
5458
5542
|
let a = e.attrs?.src, o = `node:${a}`;
|
|
5459
|
-
typeof a == "string" &&
|
|
5543
|
+
typeof a == "string" && Cr(a) && !n.has(o) && !t?.(a) && (n.add(o), r.push({
|
|
5460
5544
|
src: a,
|
|
5461
|
-
normalized:
|
|
5462
|
-
basename:
|
|
5545
|
+
normalized: Tr(a),
|
|
5546
|
+
basename: Er(a),
|
|
5463
5547
|
kind: i,
|
|
5464
5548
|
isLink: !1
|
|
5465
5549
|
}));
|
|
5466
5550
|
} else if (e.isText && e.marks) for (let i of e.marks) {
|
|
5467
5551
|
if (i.type.name !== "link") continue;
|
|
5468
5552
|
let e = i.attrs?.href, a = `link:${e}`;
|
|
5469
|
-
typeof e == "string" &&
|
|
5553
|
+
typeof e == "string" && Cr(e) && wr(e) && !n.has(a) && !t?.(e) && (n.add(a), r.push({
|
|
5470
5554
|
src: e,
|
|
5471
|
-
normalized:
|
|
5472
|
-
basename:
|
|
5555
|
+
normalized: Tr(e),
|
|
5556
|
+
basename: Er(e),
|
|
5473
5557
|
kind: "attachment",
|
|
5474
5558
|
isLink: !0
|
|
5475
5559
|
}));
|
|
5476
5560
|
}
|
|
5477
5561
|
}), r;
|
|
5478
5562
|
}
|
|
5479
|
-
function
|
|
5563
|
+
function Ir(e, t, n) {
|
|
5480
5564
|
let r = t ? `${e}\n${t}` : e;
|
|
5481
5565
|
if (!r) return !1;
|
|
5482
5566
|
let i = [];
|
|
@@ -5484,27 +5568,27 @@ function Fr(e, t, n) {
|
|
|
5484
5568
|
for (let e of r.matchAll(/!?\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g)) i.push(e[1]);
|
|
5485
5569
|
for (let e of r.matchAll(/<(?:img|video|audio|source)[^>]*\bsrc=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5486
5570
|
for (let e of r.matchAll(/<a[^>]*\bhref=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5487
|
-
return i.some((e) =>
|
|
5571
|
+
return i.some((e) => wr(e) && Cr(e) && !n?.(e));
|
|
5488
5572
|
}
|
|
5489
5573
|
// src/editor/extensions/image-upload.ts
|
|
5490
|
-
function
|
|
5574
|
+
function Lr(e) {
|
|
5491
5575
|
if (e.type.startsWith("image/")) return "image";
|
|
5492
5576
|
if (e.type.startsWith("video/")) return "video";
|
|
5493
5577
|
if (e.type.startsWith("audio/")) return "audio";
|
|
5494
5578
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5495
5579
|
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";
|
|
5496
5580
|
}
|
|
5497
|
-
function
|
|
5581
|
+
function Rr(e) {
|
|
5498
5582
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5499
5583
|
return t === "md" || t === "markdown";
|
|
5500
5584
|
}
|
|
5501
|
-
async function
|
|
5502
|
-
let i = n ?? e.state.selection.from, a = r ?
|
|
5503
|
-
o?.chooseMd ? o.chooseMd(t.name, e) :
|
|
5585
|
+
async function zr(e, t, n, r) {
|
|
5586
|
+
let i = n ?? e.state.selection.from, a = r ? hn(r) : void 0, o = r?.storage?.qingwuUI, s = await new Promise((e) => {
|
|
5587
|
+
o?.chooseMd ? o.chooseMd(t.name, e) : br(t.name).then(e);
|
|
5504
5588
|
});
|
|
5505
5589
|
if (s === null) return;
|
|
5506
5590
|
if (s === "attach") {
|
|
5507
|
-
let r = a ?
|
|
5591
|
+
let r = a ? gn(e.state.doc, t, a) : null;
|
|
5508
5592
|
if (r) {
|
|
5509
5593
|
Z(r);
|
|
5510
5594
|
return;
|
|
@@ -5516,7 +5600,7 @@ async function Rr(e, t, n, r) {
|
|
|
5516
5600
|
type: t.type
|
|
5517
5601
|
});
|
|
5518
5602
|
if (o) try {
|
|
5519
|
-
|
|
5603
|
+
Wn(e, o, n);
|
|
5520
5604
|
} catch {}
|
|
5521
5605
|
return;
|
|
5522
5606
|
}
|
|
@@ -5535,8 +5619,8 @@ async function Rr(e, t, n, r) {
|
|
|
5535
5619
|
e.dispatch(e.state.tr.insert(i, t.from(u)));
|
|
5536
5620
|
}
|
|
5537
5621
|
}
|
|
5538
|
-
function
|
|
5539
|
-
switch (
|
|
5622
|
+
function Br(e, t, n) {
|
|
5623
|
+
switch (Lr(t)) {
|
|
5540
5624
|
case "image": return e.nodes.image?.create({
|
|
5541
5625
|
src: n,
|
|
5542
5626
|
alt: t.name
|
|
@@ -5562,7 +5646,7 @@ function zr(e, t, n) {
|
|
|
5562
5646
|
}
|
|
5563
5647
|
}
|
|
5564
5648
|
}
|
|
5565
|
-
async function
|
|
5649
|
+
async function Vr(e, t, n) {
|
|
5566
5650
|
let r;
|
|
5567
5651
|
try {
|
|
5568
5652
|
r = s();
|
|
@@ -5581,23 +5665,23 @@ async function Br(e, t, n) {
|
|
|
5581
5665
|
return console.error(`${t.type} upload failed:`, e), URL.revokeObjectURL(n), null;
|
|
5582
5666
|
}
|
|
5583
5667
|
}
|
|
5584
|
-
async function
|
|
5585
|
-
let i = r ?
|
|
5668
|
+
async function Hr(e, t, n, r) {
|
|
5669
|
+
let i = r ? hn(r) : void 0, a = i ? gn(e.state.doc, t, i) : null;
|
|
5586
5670
|
if (a) {
|
|
5587
5671
|
Z(a);
|
|
5588
5672
|
return;
|
|
5589
5673
|
}
|
|
5590
|
-
let o = URL.createObjectURL(t), s =
|
|
5674
|
+
let o = URL.createObjectURL(t), s = Br(e.state.schema, t, o);
|
|
5591
5675
|
if (s) {
|
|
5592
5676
|
try {
|
|
5593
|
-
|
|
5677
|
+
Wn(e, s, n);
|
|
5594
5678
|
} catch {
|
|
5595
5679
|
return;
|
|
5596
5680
|
}
|
|
5597
|
-
await
|
|
5681
|
+
await Vr(e, t, o);
|
|
5598
5682
|
}
|
|
5599
5683
|
}
|
|
5600
|
-
var
|
|
5684
|
+
var Ur = R.create({
|
|
5601
5685
|
name: "imageUpload",
|
|
5602
5686
|
addOptions() {
|
|
5603
5687
|
return {
|
|
@@ -5618,23 +5702,23 @@ var Hr = R.create({
|
|
|
5618
5702
|
left: n.clientX,
|
|
5619
5703
|
top: n.clientY
|
|
5620
5704
|
})?.pos;
|
|
5621
|
-
for (let n of Array.from(r))
|
|
5705
|
+
for (let n of Array.from(r)) Rr(n) ? zr(t, n, i, e) : Hr(t, n, i, e), i = void 0;
|
|
5622
5706
|
return !0;
|
|
5623
5707
|
},
|
|
5624
5708
|
handlePaste(t, n) {
|
|
5625
5709
|
let r = n.clipboardData?.items;
|
|
5626
5710
|
if (!r) return !1;
|
|
5627
5711
|
let i = n.clipboardData?.getData("text/plain") || "";
|
|
5628
|
-
if ((n.clipboardData?.files?.length ?? 0) > 0 &&
|
|
5712
|
+
if ((n.clipboardData?.files?.length ?? 0) > 0 && Ir(i, void 0, o())) return !1;
|
|
5629
5713
|
for (let i of Array.from(r)) {
|
|
5630
5714
|
if (i.type.startsWith("image/") || i.type.startsWith("video/") || i.type.startsWith("audio/")) {
|
|
5631
5715
|
n.preventDefault();
|
|
5632
5716
|
let r = i.getAsFile();
|
|
5633
|
-
return r &&
|
|
5717
|
+
return r && Lr(r) !== "file" && Hr(t, r, void 0, e), !0;
|
|
5634
5718
|
}
|
|
5635
5719
|
if (i.kind === "file") {
|
|
5636
5720
|
let r = i.getAsFile();
|
|
5637
|
-
if (r &&
|
|
5721
|
+
if (r && Rr(r)) return n.preventDefault(), zr(t, r, void 0, e), !0;
|
|
5638
5722
|
}
|
|
5639
5723
|
}
|
|
5640
5724
|
return !1;
|
|
@@ -5642,7 +5726,7 @@ var Hr = R.create({
|
|
|
5642
5726
|
}
|
|
5643
5727
|
})];
|
|
5644
5728
|
}
|
|
5645
|
-
}),
|
|
5729
|
+
}), Wr = 100, Gr = R.create({
|
|
5646
5730
|
name: "imeCommitSpaceGuard",
|
|
5647
5731
|
addProseMirrorPlugins() {
|
|
5648
5732
|
let e = 0;
|
|
@@ -5657,12 +5741,12 @@ var Hr = R.create({
|
|
|
5657
5741
|
},
|
|
5658
5742
|
beforeinput(t, n) {
|
|
5659
5743
|
let r = n;
|
|
5660
|
-
return r.inputType !== "insertText" || r.data !== " " || r.isComposing || performance.now() - e >
|
|
5744
|
+
return r.inputType !== "insertText" || r.data !== " " || r.isComposing || performance.now() - e > Wr ? !1 : (r.preventDefault(), !0);
|
|
5661
5745
|
}
|
|
5662
5746
|
} }
|
|
5663
5747
|
})];
|
|
5664
5748
|
}
|
|
5665
|
-
}),
|
|
5749
|
+
}), Kr = R.create({
|
|
5666
5750
|
name: "inlineCodeEnd",
|
|
5667
5751
|
addInputRules() {
|
|
5668
5752
|
let e = this.editor.schema.marks.code;
|
|
@@ -5671,7 +5755,7 @@ var Hr = R.create({
|
|
|
5671
5755
|
type: e
|
|
5672
5756
|
})] : [];
|
|
5673
5757
|
}
|
|
5674
|
-
}),
|
|
5758
|
+
}), qr = R.create({
|
|
5675
5759
|
name: "listQuoteHighlight",
|
|
5676
5760
|
addProseMirrorPlugins() {
|
|
5677
5761
|
return [new V({ props: { decorations: (e) => {
|
|
@@ -5690,13 +5774,13 @@ var Hr = R.create({
|
|
|
5690
5774
|
}
|
|
5691
5775
|
});
|
|
5692
5776
|
// src/editor/extensions/math-utils.ts
|
|
5693
|
-
function
|
|
5777
|
+
function Jr(e) {
|
|
5694
5778
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">").replace(/\n/g, " ");
|
|
5695
5779
|
}
|
|
5696
|
-
function
|
|
5780
|
+
function Yr(e) {
|
|
5697
5781
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
5698
5782
|
}
|
|
5699
|
-
function
|
|
5783
|
+
function Xr(e, t) {
|
|
5700
5784
|
let n = e ?? "";
|
|
5701
5785
|
if (!n.trim()) return "";
|
|
5702
5786
|
try {
|
|
@@ -5708,12 +5792,12 @@ function Yr(e, t) {
|
|
|
5708
5792
|
output: "htmlAndMathml"
|
|
5709
5793
|
});
|
|
5710
5794
|
} catch {
|
|
5711
|
-
return `<span class="math-fallback">${
|
|
5795
|
+
return `<span class="math-fallback">${Yr(n)}</span>`;
|
|
5712
5796
|
}
|
|
5713
5797
|
}
|
|
5714
5798
|
// src/editor/extensions/math-view.tsx
|
|
5715
|
-
function
|
|
5716
|
-
let o = e.type.name === "mathBlock", s = String(e.attrs.latex ?? ""), c = r?.isEditable ?? !0, [l, u] = T(!1), [d, f] = T(s), m = w(null), h = w(!1), g = w(() => {}), _ = w(() => {}), v = C(() =>
|
|
5799
|
+
function Zr({ node: e, updateAttributes: t, deleteNode: n, editor: r, getPos: i, selected: a }) {
|
|
5800
|
+
let o = e.type.name === "mathBlock", s = String(e.attrs.latex ?? ""), c = r?.isEditable ?? !0, [l, u] = T(!1), [d, f] = T(s), m = w(null), h = w(!1), g = w(() => {}), _ = w(() => {}), v = C(() => Xr(s, o), [s, o]), y = C(() => Xr(d, o), [d, o]), b = () => {
|
|
5717
5801
|
let e = d.trim();
|
|
5718
5802
|
e ? (t({ latex: e }), u(!1)) : (u(!1), c && n?.());
|
|
5719
5803
|
}, S = () => {
|
|
@@ -5813,8 +5897,8 @@ function Xr({ node: e, updateAttributes: t, deleteNode: n, editor: r, getPos: i,
|
|
|
5813
5897
|
}), document.body)] });
|
|
5814
5898
|
}
|
|
5815
5899
|
// src/editor/extensions/math.ts
|
|
5816
|
-
var
|
|
5817
|
-
function
|
|
5900
|
+
var Qr = /(?:^|[^\\$])\$([^\s$](?:[^$\n]*[^\s$])?)\$$/, $r = /^\$\$([\s\S]+?)\$\$$/;
|
|
5901
|
+
function ei(e) {
|
|
5818
5902
|
return new V({ appendTransaction(t, n, r) {
|
|
5819
5903
|
if (!e.isEditable || e.view.composing || !t.some((e) => e.docChanged)) return null;
|
|
5820
5904
|
let i = r.schema.nodes.paragraph, a = r.schema.nodes.mathBlock;
|
|
@@ -5845,9 +5929,9 @@ function $r(e) {
|
|
|
5845
5929
|
return c;
|
|
5846
5930
|
} });
|
|
5847
5931
|
}
|
|
5848
|
-
function
|
|
5932
|
+
function ti(e) {
|
|
5849
5933
|
return new re({
|
|
5850
|
-
find:
|
|
5934
|
+
find: Qr,
|
|
5851
5935
|
handler: ({ state: t, range: n, match: r }) => {
|
|
5852
5936
|
let i = r[1], a = r[0].indexOf("$");
|
|
5853
5937
|
if (a < 0) return;
|
|
@@ -5856,9 +5940,9 @@ function ei(e) {
|
|
|
5856
5940
|
}
|
|
5857
5941
|
});
|
|
5858
5942
|
}
|
|
5859
|
-
function
|
|
5943
|
+
function ni(e) {
|
|
5860
5944
|
return new re({
|
|
5861
|
-
find:
|
|
5945
|
+
find: $r,
|
|
5862
5946
|
handler: ({ state: t, range: n, match: r }) => {
|
|
5863
5947
|
let i = r[1].trim();
|
|
5864
5948
|
if (!i) return;
|
|
@@ -5867,7 +5951,7 @@ function ti(e) {
|
|
|
5867
5951
|
}
|
|
5868
5952
|
});
|
|
5869
5953
|
}
|
|
5870
|
-
function
|
|
5954
|
+
function ri(e, t) {
|
|
5871
5955
|
let n = e.src, r = e.pos;
|
|
5872
5956
|
if (n.charCodeAt(r) !== 36 || n.charCodeAt(r + 1) === 36) return !1;
|
|
5873
5957
|
let i = r + 1;
|
|
@@ -5882,11 +5966,11 @@ function ni(e, t) {
|
|
|
5882
5966
|
if (!a || /^\s|\s$/.test(a)) return !1;
|
|
5883
5967
|
if (!t) {
|
|
5884
5968
|
let t = e.push("html_inline", "", 0);
|
|
5885
|
-
t.content = `<span data-type="inline-math" data-latex="${
|
|
5969
|
+
t.content = `<span data-type="inline-math" data-latex="${Jr(a)}"></span>`;
|
|
5886
5970
|
}
|
|
5887
5971
|
return e.pos = i + 1, !0;
|
|
5888
5972
|
}
|
|
5889
|
-
function
|
|
5973
|
+
function ii(e, t, n, r) {
|
|
5890
5974
|
let i = e.bMarks[t] + e.tShift[t], a = e.eMarks[t];
|
|
5891
5975
|
if (i + 1 >= a || e.src.charCodeAt(i) !== 36 || e.src.charCodeAt(i + 1) !== 36) return !1;
|
|
5892
5976
|
let o = e.src.slice(i, a).trim(), s = "", c = t + 1;
|
|
@@ -5909,12 +5993,12 @@ function ri(e, t, n, r) {
|
|
|
5909
5993
|
}
|
|
5910
5994
|
if (r) return !0;
|
|
5911
5995
|
let l = e.push("html_block", "", 0);
|
|
5912
|
-
return l.content = `<div data-type="block-math" data-latex="${
|
|
5913
|
-
}
|
|
5914
|
-
function ii(e) {
|
|
5915
|
-
e.__qingwuMathReg || (e.__qingwuMathReg = !0, e.inline.ruler.before("backticks", "qingwu_math_inline", ni), e.block.ruler.before("fence", "qingwu_math_block", ri, { alt: ["paragraph"] }));
|
|
5996
|
+
return l.content = `<div data-type="block-math" data-latex="${Jr(s.trim())}"></div>\n`, e.line = c, !0;
|
|
5916
5997
|
}
|
|
5917
5998
|
function ai(e) {
|
|
5999
|
+
e.__qingwuMathReg || (e.__qingwuMathReg = !0, e.inline.ruler.before("backticks", "qingwu_math_inline", ri), e.block.ruler.before("fence", "qingwu_math_block", ii, { alt: ["paragraph"] }));
|
|
6000
|
+
}
|
|
6001
|
+
function oi(e) {
|
|
5918
6002
|
return { markdown: {
|
|
5919
6003
|
serialize(t, n) {
|
|
5920
6004
|
let r = String(n.attrs.latex ?? "");
|
|
@@ -5926,11 +6010,11 @@ function ai(e) {
|
|
|
5926
6010
|
}
|
|
5927
6011
|
},
|
|
5928
6012
|
parse: { setup(e) {
|
|
5929
|
-
|
|
6013
|
+
ai(e);
|
|
5930
6014
|
} }
|
|
5931
6015
|
} };
|
|
5932
6016
|
}
|
|
5933
|
-
var
|
|
6017
|
+
var si = ie.create({
|
|
5934
6018
|
name: "mathInline",
|
|
5935
6019
|
group: "inline",
|
|
5936
6020
|
inline: !0,
|
|
@@ -5958,18 +6042,18 @@ var oi = ie.create({
|
|
|
5958
6042
|
];
|
|
5959
6043
|
let r = document.createElement("span");
|
|
5960
6044
|
for (let [e, t] of Object.entries(n)) r.setAttribute(e, t);
|
|
5961
|
-
return r.innerHTML =
|
|
6045
|
+
return r.innerHTML = Xr(t, !1), r;
|
|
5962
6046
|
},
|
|
5963
6047
|
addNodeView() {
|
|
5964
|
-
return F(
|
|
6048
|
+
return F(Zr);
|
|
5965
6049
|
},
|
|
5966
6050
|
addInputRules() {
|
|
5967
|
-
return [
|
|
6051
|
+
return [ti(this.type)];
|
|
5968
6052
|
},
|
|
5969
6053
|
addStorage() {
|
|
5970
|
-
return
|
|
6054
|
+
return oi(!1);
|
|
5971
6055
|
}
|
|
5972
|
-
}),
|
|
6056
|
+
}), ci = ie.create({
|
|
5973
6057
|
name: "mathBlock",
|
|
5974
6058
|
group: "block",
|
|
5975
6059
|
atom: !0,
|
|
@@ -5996,39 +6080,39 @@ var oi = ie.create({
|
|
|
5996
6080
|
];
|
|
5997
6081
|
let r = document.createElement("div");
|
|
5998
6082
|
for (let [e, t] of Object.entries(n)) r.setAttribute(e, t);
|
|
5999
|
-
return r.innerHTML =
|
|
6083
|
+
return r.innerHTML = Xr(t, !0), r;
|
|
6000
6084
|
},
|
|
6001
6085
|
addNodeView() {
|
|
6002
|
-
return F(
|
|
6086
|
+
return F(Zr);
|
|
6003
6087
|
},
|
|
6004
6088
|
addInputRules() {
|
|
6005
|
-
return [
|
|
6089
|
+
return [ni(this.type)];
|
|
6006
6090
|
},
|
|
6007
6091
|
addProseMirrorPlugins() {
|
|
6008
|
-
return [
|
|
6092
|
+
return [ei(this.editor)];
|
|
6009
6093
|
},
|
|
6010
6094
|
addStorage() {
|
|
6011
|
-
return
|
|
6095
|
+
return oi(!0);
|
|
6012
6096
|
}
|
|
6013
|
-
}),
|
|
6014
|
-
function
|
|
6097
|
+
}), li = /\.(png|jpe?g|gif|webp|bmp|svg|avif)(\?|#|$)/i, ui = /\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|#|$)/i, di = /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|#|$)/i;
|
|
6098
|
+
function fi(e) {
|
|
6015
6099
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
6016
6100
|
}
|
|
6017
|
-
function
|
|
6101
|
+
function pi(e) {
|
|
6018
6102
|
let t = e.trim().replace(/\\/g, "/");
|
|
6019
6103
|
return t.split("/").pop() || t;
|
|
6020
6104
|
}
|
|
6021
|
-
function
|
|
6105
|
+
function mi(e, t) {
|
|
6022
6106
|
let n = e.src.slice(e.pos), r = /^!\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !0;
|
|
6023
6107
|
if (r || (r = /^\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !1), !r) return !1;
|
|
6024
6108
|
let a = r[1].trim(), o = r[2]?.trim();
|
|
6025
6109
|
if (!t) {
|
|
6026
|
-
let t = o ||
|
|
6110
|
+
let t = o || pi(a);
|
|
6027
6111
|
if (i) {
|
|
6028
6112
|
let n = "";
|
|
6029
|
-
if (
|
|
6030
|
-
else if (
|
|
6031
|
-
else if (
|
|
6113
|
+
if (li.test(a) || /^data:image\//i.test(a)) n = `<img src="${fi(a)}" alt="${fi(t)}">`;
|
|
6114
|
+
else if (ui.test(a) || /^data:video\//i.test(a)) n = `<div data-video-embed src="${fi(a)}"></div>`;
|
|
6115
|
+
else if (di.test(a) || /^data:audio\//i.test(a)) n = `<audio src="${fi(a)}"></audio>`;
|
|
6032
6116
|
else {
|
|
6033
6117
|
let n = e.push("link_open", "a", 1);
|
|
6034
6118
|
n.attrs = [["href", a]];
|
|
@@ -6046,14 +6130,14 @@ function pi(e, t) {
|
|
|
6046
6130
|
}
|
|
6047
6131
|
return e.pos += r[0].length, !0;
|
|
6048
6132
|
}
|
|
6049
|
-
var
|
|
6133
|
+
var hi = R.create({
|
|
6050
6134
|
name: "obsidianMarkdown",
|
|
6051
6135
|
addStorage() {
|
|
6052
6136
|
return { markdown: { parse: { setup(e) {
|
|
6053
|
-
e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed",
|
|
6137
|
+
e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed", mi));
|
|
6054
6138
|
} } } };
|
|
6055
6139
|
}
|
|
6056
|
-
}),
|
|
6140
|
+
}), gi = R.create({
|
|
6057
6141
|
name: "qingwuUI",
|
|
6058
6142
|
priority: 1e3,
|
|
6059
6143
|
addKeyboardShortcuts() {
|
|
@@ -6064,7 +6148,7 @@ var mi = R.create({
|
|
|
6064
6148
|
}
|
|
6065
6149
|
});
|
|
6066
6150
|
// src/editor/utils/render-probe.ts
|
|
6067
|
-
function
|
|
6151
|
+
function _i(e, t) {
|
|
6068
6152
|
return new Promise((n) => {
|
|
6069
6153
|
if (typeof Image != "function") return n(!0);
|
|
6070
6154
|
let r = new Image(), i = !1, a = setTimeout(() => o(!1), t), o = (e) => {
|
|
@@ -6073,21 +6157,21 @@ function gi(e, t) {
|
|
|
6073
6157
|
r.onload = () => o(!0), r.onerror = () => o(!1), r.src = e;
|
|
6074
6158
|
});
|
|
6075
6159
|
}
|
|
6076
|
-
async function
|
|
6077
|
-
if (await
|
|
6160
|
+
async function vi(e, t = 8e3) {
|
|
6161
|
+
if (await _i(e, t)) return !0;
|
|
6078
6162
|
try {
|
|
6079
6163
|
let r = await n(e);
|
|
6080
6164
|
if (!r) return !1;
|
|
6081
6165
|
let i = await fetch(e, { headers: r });
|
|
6082
6166
|
if (!i.ok) return !1;
|
|
6083
|
-
let a = URL.createObjectURL(await i.blob()), o = await
|
|
6167
|
+
let a = URL.createObjectURL(await i.blob()), o = await _i(a, t);
|
|
6084
6168
|
return URL.revokeObjectURL(a), o;
|
|
6085
6169
|
} catch {
|
|
6086
6170
|
return !1;
|
|
6087
6171
|
}
|
|
6088
6172
|
}
|
|
6089
6173
|
// src/editor/utils/resolve-local-media.ts
|
|
6090
|
-
function
|
|
6174
|
+
function yi() {
|
|
6091
6175
|
return {
|
|
6092
6176
|
uploaded: 0,
|
|
6093
6177
|
sessionOnly: 0,
|
|
@@ -6097,10 +6181,10 @@ function vi() {
|
|
|
6097
6181
|
readFailed: []
|
|
6098
6182
|
};
|
|
6099
6183
|
}
|
|
6100
|
-
function
|
|
6184
|
+
function bi(e, t) {
|
|
6101
6185
|
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);
|
|
6102
6186
|
}
|
|
6103
|
-
function
|
|
6187
|
+
function xi(e, t, n, r) {
|
|
6104
6188
|
let { state: i } = e, a = [];
|
|
6105
6189
|
if (i.doc.descendants((e, n) => {
|
|
6106
6190
|
e.attrs?.src === t && a.push(n);
|
|
@@ -6116,7 +6200,7 @@ function bi(e, t, n, r) {
|
|
|
6116
6200
|
}
|
|
6117
6201
|
return e.dispatch(o), !0;
|
|
6118
6202
|
}
|
|
6119
|
-
function
|
|
6203
|
+
function Si(e, t, n) {
|
|
6120
6204
|
let { state: r } = e, i = r.schema.marks.link;
|
|
6121
6205
|
if (!i) return !1;
|
|
6122
6206
|
let a = [];
|
|
@@ -6134,7 +6218,7 @@ function xi(e, t, n) {
|
|
|
6134
6218
|
}));
|
|
6135
6219
|
return e.dispatch(o), !0;
|
|
6136
6220
|
}
|
|
6137
|
-
function
|
|
6221
|
+
function Ci(e) {
|
|
6138
6222
|
let t = /* @__PURE__ */ new Map();
|
|
6139
6223
|
for (let n of e) {
|
|
6140
6224
|
let e = t.get(n.normalized);
|
|
@@ -6142,36 +6226,36 @@ function Si(e) {
|
|
|
6142
6226
|
}
|
|
6143
6227
|
return Array.from(t.values());
|
|
6144
6228
|
}
|
|
6145
|
-
async function
|
|
6229
|
+
async function wi(e, t, n, r) {
|
|
6146
6230
|
if (n.length === 0) return "sessionOnly";
|
|
6147
|
-
let i = n[0], a =
|
|
6231
|
+
let i = n[0], a = hn(t);
|
|
6148
6232
|
if (a) {
|
|
6149
|
-
let t =
|
|
6233
|
+
let t = gn(e.state.doc, r, a);
|
|
6150
6234
|
if (t) return Z(`${i.basename}:${t}`, "error"), "limitRejected";
|
|
6151
6235
|
}
|
|
6152
6236
|
let o = n.filter((e) => !e.isLink), c = n.filter((e) => e.isLink);
|
|
6153
6237
|
if (o.length === 0) try {
|
|
6154
6238
|
let t = await s().upload(r, "editor"), n = !1;
|
|
6155
|
-
for (let r of c)
|
|
6239
|
+
for (let r of c) Si(e, r.src, t) && (n = !0);
|
|
6156
6240
|
return n ? "uploaded" : "sessionOnly";
|
|
6157
6241
|
} catch (e) {
|
|
6158
6242
|
return console.error(`本地附件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), "sessionOnly";
|
|
6159
6243
|
}
|
|
6160
6244
|
let l = URL.createObjectURL(r), u = !1;
|
|
6161
|
-
for (let t of o)
|
|
6245
|
+
for (let t of o) xi(e, t.src, l, r.size) && (u = !0);
|
|
6162
6246
|
let d;
|
|
6163
6247
|
try {
|
|
6164
6248
|
d = await s().upload(r, "editor");
|
|
6165
6249
|
} catch (e) {
|
|
6166
6250
|
return console.error(`本地文件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), URL.revokeObjectURL(l), "sessionOnly";
|
|
6167
6251
|
}
|
|
6168
|
-
URL.revokeObjectURL(l), u &&
|
|
6169
|
-
for (let t of c)
|
|
6170
|
-
return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await
|
|
6252
|
+
URL.revokeObjectURL(l), u && xi(e, l, d, r.size);
|
|
6253
|
+
for (let t of c) Si(e, t.src, d);
|
|
6254
|
+
return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await vi(d) ? "uploaded" : "renderFailed" : "uploaded";
|
|
6171
6255
|
}
|
|
6172
|
-
function
|
|
6256
|
+
function Ti(e, t) {
|
|
6173
6257
|
let n = [], r = [];
|
|
6174
|
-
for (let i of
|
|
6258
|
+
for (let i of Ci(e)) {
|
|
6175
6259
|
let e = i[0], a = t.get(e.basename);
|
|
6176
6260
|
a ? (n.push({
|
|
6177
6261
|
refs: i,
|
|
@@ -6183,30 +6267,30 @@ function wi(e, t) {
|
|
|
6183
6267
|
unmatched: r
|
|
6184
6268
|
};
|
|
6185
6269
|
}
|
|
6186
|
-
async function
|
|
6187
|
-
let i =
|
|
6188
|
-
for (let a of
|
|
6189
|
-
let n = a[0], { file: o, readError: s } = await
|
|
6270
|
+
async function Ei(e, t, n, r) {
|
|
6271
|
+
let i = yi();
|
|
6272
|
+
for (let a of Ci(n)) {
|
|
6273
|
+
let n = a[0], { file: o, readError: s } = await Nr(r, n.src);
|
|
6190
6274
|
if (!o) {
|
|
6191
6275
|
s ? (console.warn(`本地文件「${n.basename}」在所选文件夹中找到但读取失败:`, s), i.readFailed.push(n)) : (console.warn(`本地文件「${n.basename}」未在所选文件夹「${r.name}」中找到`), i.missing.push(n));
|
|
6192
6276
|
continue;
|
|
6193
6277
|
}
|
|
6194
|
-
let c = await
|
|
6278
|
+
let c = await wi(e, t, a, o);
|
|
6195
6279
|
i[c]++;
|
|
6196
6280
|
}
|
|
6197
6281
|
return i;
|
|
6198
6282
|
}
|
|
6199
|
-
function
|
|
6283
|
+
function Di(e) {
|
|
6200
6284
|
let t = e.map((e) => e.basename);
|
|
6201
6285
|
return t.length <= 3 ? t.join("、") : `${t.slice(0, 3).join("、")} 等 ${t.length} 个文件`;
|
|
6202
6286
|
}
|
|
6203
|
-
function
|
|
6287
|
+
function Oi(e) {
|
|
6204
6288
|
let t = [];
|
|
6205
|
-
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} 个找到但读取失败:${
|
|
6289
|
+
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} 个找到但读取失败:${Di(e.readFailed)}(若在 OneDrive / WPS 云盘等同步目录,请右键文件选择「始终保留在此设备」后重试)`), e.missing.length > 0 && t.push(`${e.missing.length} 个未能获取:${Di(e.missing)}(可把文件直接拖进编辑器上传)`), t.length === 0) return;
|
|
6206
6290
|
let n = e.uploaded > 0 && e.renderFailed === 0 && e.missing.length === 0 && e.readFailed.length === 0;
|
|
6207
6291
|
Z(`本地文件解析完成:${t.join(";")}`, n ? "success" : "info");
|
|
6208
6292
|
}
|
|
6209
|
-
function
|
|
6293
|
+
function ki(e) {
|
|
6210
6294
|
return new Promise((t) => {
|
|
6211
6295
|
let n = document.createElement("div");
|
|
6212
6296
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -6233,7 +6317,7 @@ function Oi(e) {
|
|
|
6233
6317
|
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);
|
|
6234
6318
|
});
|
|
6235
6319
|
}
|
|
6236
|
-
function
|
|
6320
|
+
function Ai(e) {
|
|
6237
6321
|
let t = document.createElement("div");
|
|
6238
6322
|
t.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
6239
6323
|
let n = document.createElement("div");
|
|
@@ -6255,7 +6339,7 @@ function ki(e) {
|
|
|
6255
6339
|
let c = document.createElement("button");
|
|
6256
6340
|
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);
|
|
6257
6341
|
}
|
|
6258
|
-
function
|
|
6342
|
+
function ji(e) {
|
|
6259
6343
|
return new Promise((t) => {
|
|
6260
6344
|
let n = document.createElement("div");
|
|
6261
6345
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -6281,8 +6365,8 @@ function Ai(e) {
|
|
|
6281
6365
|
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);
|
|
6282
6366
|
});
|
|
6283
6367
|
}
|
|
6284
|
-
async function
|
|
6285
|
-
let r =
|
|
6368
|
+
async function Mi(e, t, n) {
|
|
6369
|
+
let r = yi(), i = Ci(n), a = await Ar();
|
|
6286
6370
|
if (!a) {
|
|
6287
6371
|
for (let e of i) r.missing.push(e[0]);
|
|
6288
6372
|
return r;
|
|
@@ -6295,13 +6379,13 @@ async function ji(e, t, n) {
|
|
|
6295
6379
|
continue;
|
|
6296
6380
|
}
|
|
6297
6381
|
o.delete(i.basename);
|
|
6298
|
-
let s = await
|
|
6382
|
+
let s = await wi(e, t, n, a);
|
|
6299
6383
|
r[s]++;
|
|
6300
6384
|
}
|
|
6301
6385
|
return r;
|
|
6302
6386
|
}
|
|
6303
6387
|
// src/editor/extensions/relative-media.ts
|
|
6304
|
-
var
|
|
6388
|
+
var Ni = R.create({
|
|
6305
6389
|
name: "relativeMedia",
|
|
6306
6390
|
addStorage() {
|
|
6307
6391
|
return {
|
|
@@ -6311,38 +6395,38 @@ var Mi = R.create({
|
|
|
6311
6395
|
},
|
|
6312
6396
|
addProseMirrorPlugins() {
|
|
6313
6397
|
let e = this.editor, t = this.storage, n = !1, r = null, i = async (n, i) => {
|
|
6314
|
-
let a = e.view, o =
|
|
6398
|
+
let a = e.view, o = yi(), { matched: s, unmatched: c } = Ti(n, t.clipboardFiles);
|
|
6315
6399
|
for (let { refs: t, file: n } of s) {
|
|
6316
|
-
let r = await
|
|
6400
|
+
let r = await wi(a, e, t, n);
|
|
6317
6401
|
o[r]++;
|
|
6318
6402
|
}
|
|
6319
6403
|
if (c.length > 0) {
|
|
6320
|
-
let t =
|
|
6321
|
-
if (
|
|
6404
|
+
let t = Ci(c).length;
|
|
6405
|
+
if (Dr()) {
|
|
6322
6406
|
let n = i ?? null;
|
|
6323
|
-
if (n || (await
|
|
6324
|
-
r = n,
|
|
6407
|
+
if (n || (await ki(t) === "pick" ? (n = await Or(), n || Z("没有选择文件夹。本地文件暂以占位显示,稍后可直接把文件拖进编辑器上传", "info")) : Z("已选择稍后处理。本地文件暂以占位显示,可直接把文件拖进编辑器上传", "info")), n) {
|
|
6408
|
+
r = n, bi(o, await Ei(a, e, c, n));
|
|
6325
6409
|
let t = [...o.missing, ...o.readFailed];
|
|
6326
|
-
if (t.length > 0 &&
|
|
6327
|
-
let n = await
|
|
6328
|
-
|
|
6410
|
+
if (t.length > 0 && kr() && await ji(t.map((e) => e.basename)) === "pick") {
|
|
6411
|
+
let n = await Mi(a, e, t);
|
|
6412
|
+
bi(o, n), o.missing = n.missing, o.readFailed = [];
|
|
6329
6413
|
}
|
|
6330
6414
|
}
|
|
6331
|
-
} else
|
|
6415
|
+
} else Ai(t);
|
|
6332
6416
|
}
|
|
6333
|
-
|
|
6417
|
+
Oi(o);
|
|
6334
6418
|
}, a = () => {
|
|
6335
6419
|
if (!e || e.isDestroyed || t.pausedUntilPaste) return;
|
|
6336
|
-
let a = o(), s =
|
|
6420
|
+
let a = o(), s = Fr(e.state.doc, a);
|
|
6337
6421
|
if (s.length === 0 || n) return;
|
|
6338
6422
|
n = !0;
|
|
6339
6423
|
let c = new Set(s.map((e) => e.src));
|
|
6340
6424
|
i(s).then(() => {
|
|
6341
6425
|
if (e.isDestroyed) return;
|
|
6342
|
-
let t =
|
|
6426
|
+
let t = Fr(e.state.doc, a).filter((e) => !c.has(e.src));
|
|
6343
6427
|
if (t.length !== 0) return i(t, r);
|
|
6344
6428
|
}).finally(() => {
|
|
6345
|
-
n = !1, e && !e.isDestroyed && (t.pausedUntilPaste =
|
|
6429
|
+
n = !1, e && !e.isDestroyed && (t.pausedUntilPaste = Fr(e.state.doc, a).length > 0);
|
|
6346
6430
|
});
|
|
6347
6431
|
};
|
|
6348
6432
|
return [new V({
|
|
@@ -6356,14 +6440,14 @@ var Mi = R.create({
|
|
|
6356
6440
|
}
|
|
6357
6441
|
})];
|
|
6358
6442
|
}
|
|
6359
|
-
}),
|
|
6360
|
-
function
|
|
6443
|
+
}), Pi = new H("slashCommand");
|
|
6444
|
+
function Fi(e) {
|
|
6361
6445
|
return R.create({
|
|
6362
6446
|
name: "slashCommand",
|
|
6363
6447
|
addProseMirrorPlugins() {
|
|
6364
6448
|
let t = {
|
|
6365
6449
|
char: "/",
|
|
6366
|
-
pluginKey:
|
|
6450
|
+
pluginKey: Pi,
|
|
6367
6451
|
findSuggestionMatch: (e) => {
|
|
6368
6452
|
let { $position: t } = e;
|
|
6369
6453
|
for (let e = t.depth; e >= 0; e--) if (t.node(e).type.name === "codeBlock") return null;
|
|
@@ -6444,7 +6528,7 @@ function Pi(e) {
|
|
|
6444
6528
|
} else if (e.key === "Escape") {
|
|
6445
6529
|
e.preventDefault();
|
|
6446
6530
|
let t = a?.view;
|
|
6447
|
-
t && Ee(t,
|
|
6531
|
+
t && Ee(t, Pi);
|
|
6448
6532
|
}
|
|
6449
6533
|
});
|
|
6450
6534
|
}
|
|
@@ -6462,7 +6546,7 @@ function Pi(e) {
|
|
|
6462
6546
|
if (!e || e.style.display === "none" || n.target instanceof Node && e.contains(n.target) || t) return;
|
|
6463
6547
|
let r = a?.view;
|
|
6464
6548
|
r && (t = !0, window.setTimeout(() => {
|
|
6465
|
-
t = !1, e?.style.display !== "none" && Ee(r,
|
|
6549
|
+
t = !1, e?.style.display !== "none" && Ee(r, Pi);
|
|
6466
6550
|
}, 0));
|
|
6467
6551
|
}, document.addEventListener("mousedown", o, !0), document.addEventListener("touchstart", o, !0);
|
|
6468
6552
|
}
|
|
@@ -6498,14 +6582,14 @@ function Pi(e) {
|
|
|
6498
6582
|
break;
|
|
6499
6583
|
}
|
|
6500
6584
|
if (!i && !r.marks().some((e) => e.type.name === "code")) return null;
|
|
6501
|
-
let a =
|
|
6502
|
-
return a && a.active ? n.tr.setMeta(
|
|
6585
|
+
let a = Pi.getState(n);
|
|
6586
|
+
return a && a.active ? n.tr.setMeta(Pi, { exit: !0 }) : null;
|
|
6503
6587
|
}
|
|
6504
6588
|
})];
|
|
6505
6589
|
}
|
|
6506
6590
|
});
|
|
6507
6591
|
}
|
|
6508
|
-
function
|
|
6592
|
+
function Ii(e, t) {
|
|
6509
6593
|
return [
|
|
6510
6594
|
{
|
|
6511
6595
|
title: e("editor.slash.heading1"),
|
|
@@ -6622,7 +6706,7 @@ function Fi(e, t) {
|
|
|
6622
6706
|
n.type = "file", n.accept = "audio/*", n.onchange = async () => {
|
|
6623
6707
|
let r = n.files?.[0];
|
|
6624
6708
|
if (!r) return;
|
|
6625
|
-
let i =
|
|
6709
|
+
let i = hn(e) ?? t, a = i ? gn(e.state.doc, r, i) : null;
|
|
6626
6710
|
if (a) {
|
|
6627
6711
|
Z(a);
|
|
6628
6712
|
return;
|
|
@@ -6632,7 +6716,7 @@ function Fi(e, t) {
|
|
|
6632
6716
|
name: r.name,
|
|
6633
6717
|
size: r.size
|
|
6634
6718
|
});
|
|
6635
|
-
s && (
|
|
6719
|
+
s && (Wn(e.view, s), await Vr(e.view, r, o));
|
|
6636
6720
|
}, n.click();
|
|
6637
6721
|
}
|
|
6638
6722
|
},
|
|
@@ -6645,7 +6729,7 @@ function Fi(e, t) {
|
|
|
6645
6729
|
n.type = "file", n.accept = "*/*", n.multiple = !0, n.onchange = async () => {
|
|
6646
6730
|
let r = n.files;
|
|
6647
6731
|
if (r && r.length !== 0) for (let n of Array.from(r)) {
|
|
6648
|
-
let r =
|
|
6732
|
+
let r = hn(e) ?? t, i = r ? gn(e.state.doc, n, r) : null;
|
|
6649
6733
|
if (i) {
|
|
6650
6734
|
Z(i);
|
|
6651
6735
|
continue;
|
|
@@ -6653,7 +6737,7 @@ function Fi(e, t) {
|
|
|
6653
6737
|
let a = URL.createObjectURL(n), o = e.schema.nodes.attachmentEmbed;
|
|
6654
6738
|
if (o) {
|
|
6655
6739
|
try {
|
|
6656
|
-
|
|
6740
|
+
Wn(e.view, o.create({
|
|
6657
6741
|
src: a,
|
|
6658
6742
|
name: n.name,
|
|
6659
6743
|
size: n.size,
|
|
@@ -6662,7 +6746,7 @@ function Fi(e, t) {
|
|
|
6662
6746
|
} catch {
|
|
6663
6747
|
continue;
|
|
6664
6748
|
}
|
|
6665
|
-
await
|
|
6749
|
+
await Vr(e.view, n, a);
|
|
6666
6750
|
}
|
|
6667
6751
|
}
|
|
6668
6752
|
}, n.click();
|
|
@@ -6671,9 +6755,9 @@ function Fi(e, t) {
|
|
|
6671
6755
|
];
|
|
6672
6756
|
}
|
|
6673
6757
|
// src/editor/extensions/index.ts
|
|
6674
|
-
var
|
|
6758
|
+
var Li = W.extend({
|
|
6675
6759
|
addNodeView() {
|
|
6676
|
-
return F(
|
|
6760
|
+
return F(Dn);
|
|
6677
6761
|
},
|
|
6678
6762
|
addAttributes() {
|
|
6679
6763
|
return {
|
|
@@ -6696,7 +6780,7 @@ var Ii = W.extend({
|
|
|
6696
6780
|
};
|
|
6697
6781
|
}
|
|
6698
6782
|
});
|
|
6699
|
-
function
|
|
6783
|
+
function Ri(e = {}) {
|
|
6700
6784
|
return [
|
|
6701
6785
|
G.configure({
|
|
6702
6786
|
codeBlock: !1,
|
|
@@ -6712,7 +6796,7 @@ function Li(e = {}) {
|
|
|
6712
6796
|
target: "_blank"
|
|
6713
6797
|
}
|
|
6714
6798
|
}),
|
|
6715
|
-
|
|
6799
|
+
Li.configure({
|
|
6716
6800
|
inline: !1,
|
|
6717
6801
|
allowBase64: !0
|
|
6718
6802
|
}),
|
|
@@ -6723,10 +6807,10 @@ function Li(e = {}) {
|
|
|
6723
6807
|
le,
|
|
6724
6808
|
K.configure(e.maxLength ? { limit: e.maxLength } : {}),
|
|
6725
6809
|
de,
|
|
6726
|
-
|
|
6727
|
-
oi,
|
|
6810
|
+
Kr,
|
|
6728
6811
|
si,
|
|
6729
|
-
|
|
6812
|
+
ci,
|
|
6813
|
+
yr,
|
|
6730
6814
|
pe.configure({ resizable: !0 }),
|
|
6731
6815
|
ge,
|
|
6732
6816
|
me,
|
|
@@ -6737,91 +6821,91 @@ function Li(e = {}) {
|
|
|
6737
6821
|
transformCopiedText: !1
|
|
6738
6822
|
}),
|
|
6739
6823
|
fe.configure({ placeholder: e.placeholder || "输入 '/' 打开菜单…" }),
|
|
6740
|
-
|
|
6824
|
+
Fi(() => Ii((e) => p(e), {
|
|
6741
6825
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
6742
6826
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
6743
6827
|
})),
|
|
6744
|
-
|
|
6828
|
+
Ur.configure({
|
|
6745
6829
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
6746
6830
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
6747
6831
|
}),
|
|
6748
|
-
|
|
6749
|
-
mi,
|
|
6750
|
-
tr,
|
|
6751
|
-
At,
|
|
6752
|
-
Kr,
|
|
6753
|
-
Wr,
|
|
6832
|
+
Ni,
|
|
6754
6833
|
hi,
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6834
|
+
nr,
|
|
6835
|
+
jt,
|
|
6836
|
+
qr,
|
|
6837
|
+
Gr,
|
|
6838
|
+
gi,
|
|
6839
|
+
er,
|
|
6840
|
+
qn,
|
|
6841
|
+
Hn
|
|
6758
6842
|
];
|
|
6759
6843
|
}
|
|
6760
6844
|
// src/editor/extensions/bubble-menu.tsx
|
|
6761
|
-
function
|
|
6845
|
+
function zi(e) {
|
|
6762
6846
|
let t = e.trim(), n = /^\$([^$]+?)\$$/.exec(t);
|
|
6763
6847
|
if (n) return n[1].trim();
|
|
6764
6848
|
let r = /^\$\$([\s\S]+?)\$\$$/.exec(t);
|
|
6765
6849
|
return r ? r[1].trim() : t;
|
|
6766
6850
|
}
|
|
6767
|
-
function
|
|
6851
|
+
function Bi(e) {
|
|
6768
6852
|
let t = e.trim();
|
|
6769
6853
|
return t ? /^\${1,2}[\s\S]*\${1,2}$/.test(t) ? !0 : /[0-9=]/.test(t) && /[+\-*/^=(){}_\\]/.test(t) : !1;
|
|
6770
6854
|
}
|
|
6771
|
-
var
|
|
6772
|
-
function
|
|
6773
|
-
|
|
6855
|
+
var Vi = "https://www.bing.com/search?q={query}";
|
|
6856
|
+
function Hi(e) {
|
|
6857
|
+
Vi = e;
|
|
6774
6858
|
}
|
|
6775
|
-
function
|
|
6776
|
-
return
|
|
6859
|
+
function Ui() {
|
|
6860
|
+
return Vi;
|
|
6777
6861
|
}
|
|
6778
|
-
function
|
|
6862
|
+
function Wi(e) {
|
|
6779
6863
|
return [
|
|
6780
6864
|
{
|
|
6781
6865
|
key: "bold",
|
|
6782
6866
|
label: e("editor.bubble.bold"),
|
|
6783
|
-
icon: /* @__PURE__ */ D(
|
|
6867
|
+
icon: /* @__PURE__ */ D(Pt, {}),
|
|
6784
6868
|
isActive: (e) => e.isActive("bold"),
|
|
6785
6869
|
command: (e) => e.isEditable && e.chain().focus().toggleBold().run()
|
|
6786
6870
|
},
|
|
6787
6871
|
{
|
|
6788
6872
|
key: "italic",
|
|
6789
6873
|
label: e("editor.bubble.italic"),
|
|
6790
|
-
icon: /* @__PURE__ */ D(
|
|
6874
|
+
icon: /* @__PURE__ */ D(Ft, {}),
|
|
6791
6875
|
isActive: (e) => e.isActive("italic"),
|
|
6792
6876
|
command: (e) => e.isEditable && e.chain().focus().toggleItalic().run()
|
|
6793
6877
|
},
|
|
6794
6878
|
{
|
|
6795
6879
|
key: "underline",
|
|
6796
6880
|
label: e("editor.bubble.underline"),
|
|
6797
|
-
icon: /* @__PURE__ */ D(
|
|
6881
|
+
icon: /* @__PURE__ */ D(It, {}),
|
|
6798
6882
|
isActive: (e) => e.isActive("underline"),
|
|
6799
6883
|
command: (e) => e.isEditable && e.chain().focus().toggleUnderline().run()
|
|
6800
6884
|
},
|
|
6801
6885
|
{
|
|
6802
6886
|
key: "strikethrough",
|
|
6803
6887
|
label: e("editor.bubble.strikethrough"),
|
|
6804
|
-
icon: /* @__PURE__ */ D(
|
|
6888
|
+
icon: /* @__PURE__ */ D(Lt, {}),
|
|
6805
6889
|
isActive: (e) => e.isActive("strike"),
|
|
6806
6890
|
command: (e) => e.isEditable && e.chain().focus().toggleStrike().run()
|
|
6807
6891
|
},
|
|
6808
6892
|
{
|
|
6809
6893
|
key: "code",
|
|
6810
6894
|
label: e("editor.bubble.emphasis"),
|
|
6811
|
-
icon: /* @__PURE__ */ D(
|
|
6895
|
+
icon: /* @__PURE__ */ D(Rt, {}),
|
|
6812
6896
|
isActive: (e) => e.isActive("code"),
|
|
6813
6897
|
command: (e) => e.isEditable && e.chain().focus().toggleCode().run()
|
|
6814
6898
|
},
|
|
6815
6899
|
{
|
|
6816
6900
|
key: "mathInline",
|
|
6817
6901
|
label: e("editor.bubble.mathInline"),
|
|
6818
|
-
icon: /* @__PURE__ */ D(
|
|
6902
|
+
icon: /* @__PURE__ */ D(Gt, {}),
|
|
6819
6903
|
isActive: (e) => e.isActive("mathInline"),
|
|
6820
6904
|
command: (e) => {
|
|
6821
6905
|
if (!e.isEditable) return;
|
|
6822
6906
|
let { from: t, to: n } = e.state.selection;
|
|
6823
6907
|
if (t === n) return;
|
|
6824
|
-
let r =
|
|
6908
|
+
let r = zi(e.state.doc.textBetween(t, n, "\n"));
|
|
6825
6909
|
r && e.chain().focus().insertContentAt({
|
|
6826
6910
|
from: t,
|
|
6827
6911
|
to: n
|
|
@@ -6834,7 +6918,7 @@ function Ui(e) {
|
|
|
6834
6918
|
{
|
|
6835
6919
|
key: "highlight",
|
|
6836
6920
|
label: e("editor.bubble.highlight"),
|
|
6837
|
-
icon: /* @__PURE__ */ D(
|
|
6921
|
+
icon: /* @__PURE__ */ D(zt, {}),
|
|
6838
6922
|
more: !0,
|
|
6839
6923
|
isActive: (e) => e.isActive("highlight"),
|
|
6840
6924
|
command: () => {}
|
|
@@ -6842,7 +6926,7 @@ function Ui(e) {
|
|
|
6842
6926
|
{
|
|
6843
6927
|
key: "link",
|
|
6844
6928
|
label: e("editor.bubble.link"),
|
|
6845
|
-
icon: /* @__PURE__ */ D(
|
|
6929
|
+
icon: /* @__PURE__ */ D(Bt, {}),
|
|
6846
6930
|
more: !0,
|
|
6847
6931
|
isActive: (e) => e.isActive("link"),
|
|
6848
6932
|
command: () => {}
|
|
@@ -6850,7 +6934,7 @@ function Ui(e) {
|
|
|
6850
6934
|
{
|
|
6851
6935
|
key: "copy",
|
|
6852
6936
|
label: e("editor.bubble.copy"),
|
|
6853
|
-
icon: /* @__PURE__ */ D(
|
|
6937
|
+
icon: /* @__PURE__ */ D(Ht, {}),
|
|
6854
6938
|
more: !0,
|
|
6855
6939
|
isActive: () => !1,
|
|
6856
6940
|
command: (e) => {
|
|
@@ -6861,21 +6945,21 @@ function Ui(e) {
|
|
|
6861
6945
|
{
|
|
6862
6946
|
key: "search",
|
|
6863
6947
|
label: e("editor.bubble.search"),
|
|
6864
|
-
icon: /* @__PURE__ */ D(
|
|
6948
|
+
icon: /* @__PURE__ */ D(Ut, {}),
|
|
6865
6949
|
more: !0,
|
|
6866
6950
|
isActive: () => !1,
|
|
6867
6951
|
command: (e) => {
|
|
6868
6952
|
if (e.isActive("table")) return;
|
|
6869
6953
|
let { from: t, to: n } = e.state.selection, r = e.state.doc.textBetween(t, n, " ").trim();
|
|
6870
6954
|
if (!r) return;
|
|
6871
|
-
let i =
|
|
6955
|
+
let i = Vi.replace("{query}", encodeURIComponent(r));
|
|
6872
6956
|
window.open(i, "_blank", "noopener,noreferrer");
|
|
6873
6957
|
}
|
|
6874
6958
|
},
|
|
6875
6959
|
{
|
|
6876
6960
|
key: "table",
|
|
6877
6961
|
label: e("editor.bubble.table"),
|
|
6878
|
-
icon: /* @__PURE__ */ D(
|
|
6962
|
+
icon: /* @__PURE__ */ D(Vt, {}),
|
|
6879
6963
|
more: !0,
|
|
6880
6964
|
isActive: (e) => e.isActive("table"),
|
|
6881
6965
|
command: (e) => {
|
|
@@ -6891,7 +6975,7 @@ function Ui(e) {
|
|
|
6891
6975
|
{
|
|
6892
6976
|
key: "ai",
|
|
6893
6977
|
label: e("editor.ai.trigger"),
|
|
6894
|
-
icon: /* @__PURE__ */ D(
|
|
6978
|
+
icon: /* @__PURE__ */ D(Wt, {}),
|
|
6895
6979
|
isActive: () => !1,
|
|
6896
6980
|
command: (e) => {
|
|
6897
6981
|
e.isEditable && e.storage.qingwuUI?.openAI?.();
|
|
@@ -6901,7 +6985,7 @@ function Ui(e) {
|
|
|
6901
6985
|
}
|
|
6902
6986
|
R.create({ name: "bubbleMenu" });
|
|
6903
6987
|
// src/editor/extensions/table-toolbar.tsx
|
|
6904
|
-
function
|
|
6988
|
+
function Gi(e) {
|
|
6905
6989
|
let { $from: t } = e.state.selection;
|
|
6906
6990
|
for (let e = t.depth; e > 0; e--) {
|
|
6907
6991
|
let n = t.node(e);
|
|
@@ -6912,7 +6996,7 @@ function Wi(e) {
|
|
|
6912
6996
|
}
|
|
6913
6997
|
return null;
|
|
6914
6998
|
}
|
|
6915
|
-
function
|
|
6999
|
+
function Ki(e) {
|
|
6916
7000
|
let t = [];
|
|
6917
7001
|
return e.forEach((e) => {
|
|
6918
7002
|
let n = [];
|
|
@@ -6921,7 +7005,7 @@ function Gi(e) {
|
|
|
6921
7005
|
}), t.push(n);
|
|
6922
7006
|
}), t;
|
|
6923
7007
|
}
|
|
6924
|
-
function
|
|
7008
|
+
function qi(e) {
|
|
6925
7009
|
if (e.length === 0) return "";
|
|
6926
7010
|
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(" | ")} |`;
|
|
6927
7011
|
return [
|
|
@@ -6930,11 +7014,11 @@ function Ki(e) {
|
|
|
6930
7014
|
...i.map(a)
|
|
6931
7015
|
].join("\n");
|
|
6932
7016
|
}
|
|
6933
|
-
function
|
|
7017
|
+
function Ji(e) {
|
|
6934
7018
|
let t = (e) => /[",\n]/.test(e) ? `"${e.replace(/"/g, "\"\"")}"` : e;
|
|
6935
7019
|
return e.map((e) => e.map(t).join(",")).join("\n");
|
|
6936
7020
|
}
|
|
6937
|
-
function
|
|
7021
|
+
function Yi(e) {
|
|
6938
7022
|
let t = e.trim();
|
|
6939
7023
|
if (!t) return null;
|
|
6940
7024
|
let n = t.split(/\r?\n/);
|
|
@@ -6948,7 +7032,7 @@ function Ji(e) {
|
|
|
6948
7032
|
}
|
|
6949
7033
|
return null;
|
|
6950
7034
|
}
|
|
6951
|
-
function
|
|
7035
|
+
function Xi({ editor: e }) {
|
|
6952
7036
|
let [t, n] = T(null), [r, i] = T(!1), [a, o] = T(!1), s = w(null), c = w(null), l = e.isEditable, u = b(() => {
|
|
6953
7037
|
c.current != null && cancelAnimationFrame(c.current), c.current = requestAnimationFrame(() => {
|
|
6954
7038
|
c.current = null;
|
|
@@ -6964,7 +7048,7 @@ function Yi({ editor: e }) {
|
|
|
6964
7048
|
n(null);
|
|
6965
7049
|
return;
|
|
6966
7050
|
}
|
|
6967
|
-
let t =
|
|
7051
|
+
let t = Gi(e);
|
|
6968
7052
|
n(t ? (e) => e === t.pos ? e : t.pos : null);
|
|
6969
7053
|
}, [e]);
|
|
6970
7054
|
x(() => (d(), e.on("selectionUpdate", d), e.on("focus", d), window.addEventListener("scroll", u, !0), window.addEventListener("resize", u), () => {
|
|
@@ -6989,24 +7073,24 @@ function Yi({ editor: e }) {
|
|
|
6989
7073
|
});
|
|
6990
7074
|
return n.nodes.table.create(null, i);
|
|
6991
7075
|
}, p = () => {
|
|
6992
|
-
let t =
|
|
7076
|
+
let t = Gi(e);
|
|
6993
7077
|
if (!t) return;
|
|
6994
|
-
let n = Ki(
|
|
7078
|
+
let n = qi(Ki(t.node));
|
|
6995
7079
|
navigator.clipboard?.writeText(n), i(!0), setTimeout(() => i(!1), 1500);
|
|
6996
7080
|
}, m = () => {
|
|
6997
|
-
let t =
|
|
7081
|
+
let t = Gi(e);
|
|
6998
7082
|
if (!t) return;
|
|
6999
|
-
let n =
|
|
7083
|
+
let n = Ji(Ki(t.node)), r = new Blob([`\ufeff${n}`], { type: "text/csv;charset=utf-8" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
7000
7084
|
a.href = i, a.download = "table.csv", document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
7001
7085
|
}, h = async () => {
|
|
7002
7086
|
if (l) try {
|
|
7003
7087
|
let t = await navigator.clipboard?.readText();
|
|
7004
7088
|
if (!t) return;
|
|
7005
|
-
let n =
|
|
7089
|
+
let n = Yi(t);
|
|
7006
7090
|
if (!n || n.length === 0) return;
|
|
7007
7091
|
let r = f(n);
|
|
7008
7092
|
if (!r) return;
|
|
7009
|
-
let i =
|
|
7093
|
+
let i = Gi(e), a = e.chain().focus();
|
|
7010
7094
|
if (i) {
|
|
7011
7095
|
let t = Math.min(i.pos + i.node.nodeSize, e.state.doc.content.size);
|
|
7012
7096
|
a.setTextSelection(t);
|
|
@@ -7126,7 +7210,7 @@ function Yi({ editor: e }) {
|
|
|
7126
7210
|
type: "button",
|
|
7127
7211
|
className: "tbl-btn tbl-btn--del",
|
|
7128
7212
|
onClick: () => {
|
|
7129
|
-
l && !
|
|
7213
|
+
l && !bn() && ($(!0), o(!0));
|
|
7130
7214
|
},
|
|
7131
7215
|
title: "删除",
|
|
7132
7216
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -7144,7 +7228,7 @@ function Yi({ editor: e }) {
|
|
|
7144
7228
|
})
|
|
7145
7229
|
})
|
|
7146
7230
|
}),
|
|
7147
|
-
/* @__PURE__ */ D(
|
|
7231
|
+
/* @__PURE__ */ D(Tn, {
|
|
7148
7232
|
open: a,
|
|
7149
7233
|
title: "确认删除表格",
|
|
7150
7234
|
message: "此操作不可撤销。",
|
|
@@ -7159,7 +7243,7 @@ function Yi({ editor: e }) {
|
|
|
7159
7243
|
});
|
|
7160
7244
|
}
|
|
7161
7245
|
// src/editor/ai-editor.tsx
|
|
7162
|
-
var
|
|
7246
|
+
var Zi = [
|
|
7163
7247
|
{
|
|
7164
7248
|
color: "#fef08a",
|
|
7165
7249
|
name: "黄"
|
|
@@ -7184,9 +7268,9 @@ var Xi = [
|
|
|
7184
7268
|
color: "#ddd6fe",
|
|
7185
7269
|
name: "紫"
|
|
7186
7270
|
}
|
|
7187
|
-
],
|
|
7188
|
-
function
|
|
7189
|
-
let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth ||
|
|
7271
|
+
], Qi = 288, $i = 480, ea = 320;
|
|
7272
|
+
function ta(e, t, n = {}) {
|
|
7273
|
+
let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth || Qi, $i, r - 32), o = Math.max(t || ea, 160);
|
|
7190
7274
|
if (r < 640) {
|
|
7191
7275
|
let t = Math.max(8, Math.min(e.top + 10, i - 420));
|
|
7192
7276
|
return {
|
|
@@ -7227,27 +7311,27 @@ function ea(e, t, n = {}) {
|
|
|
7227
7311
|
arrowLeft: p
|
|
7228
7312
|
};
|
|
7229
7313
|
}
|
|
7230
|
-
function
|
|
7314
|
+
function na(e) {
|
|
7231
7315
|
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);
|
|
7232
7316
|
}
|
|
7233
|
-
function
|
|
7317
|
+
function ra(e, t) {
|
|
7234
7318
|
try {
|
|
7235
7319
|
let n = e.storage?.markdown?.parser;
|
|
7236
7320
|
if (!n) return null;
|
|
7237
7321
|
let r = n.parse(t), i = document.createElement("div");
|
|
7238
|
-
return i.innerHTML = r,
|
|
7322
|
+
return i.innerHTML = r, ee.fromSchema(e.schema).parse(i).content;
|
|
7239
7323
|
} catch {
|
|
7240
7324
|
return null;
|
|
7241
7325
|
}
|
|
7242
7326
|
}
|
|
7243
|
-
var
|
|
7327
|
+
var ia = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.ImageUploadDialog }))), aa = y(() => import("./storage-settings-dialog-DfJuUAkg.js").then((e) => ({ default: e.StorageSettingsDialog }))), oa = y(() => import("./export-dialog-BtkB6LbG.js").then((e) => ({ default: e.ExportDialog }))), sa = y(() => import("./video-embed-dialog-eCCrqLDP.js").then((e) => ({ default: e.VideoEmbedDialog }))), ca = y(() => import("./md-import-dialog-WLWQ4INh.js").then((e) => ({ default: e.MdImportDialog }))), la = () => /* @__PURE__ */ O("div", {
|
|
7244
7328
|
className: "fixed inset-0 z-[9999] flex items-center justify-center",
|
|
7245
7329
|
children: [/* @__PURE__ */ D("div", { className: "absolute inset-0 bg-black/40 backdrop-blur-sm" }), /* @__PURE__ */ D("div", {
|
|
7246
7330
|
className: "relative bg-background rounded-2xl border border-default-200 p-8 flex items-center justify-center",
|
|
7247
7331
|
children: /* @__PURE__ */ D("div", { className: "w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin" })
|
|
7248
7332
|
})]
|
|
7249
|
-
}),
|
|
7250
|
-
let A = r === "view" || i,
|
|
7333
|
+
}), ua = ({ initialContent: e = "", onChange: t, placeholder: n, mode: r, readonly: i = !1, maxLength: a, wordCounter: o, maxAttachmentSize: s, maxTotalAttachmentSize: c, className: l = "", borderless: u = !1, style: d, showToolbar: m = !0, showToc: h = !0, showSearch: g = !0, onEditorReady: _, immediatelyRender: y, onToast: k }) => {
|
|
7334
|
+
let A = r === "view" || i, ee = C(() => typeof e == "object" && e || na(e) ? e : f(e), [e]), [j, P] = T(!1), [F, I] = T({}), [R, re] = T("below"), [ie, z] = T(50), B = w(null), [V, H] = T(!1), [ae, oe] = T(!1), [U, W] = T(!1), [se, ce] = T(!1), [G, K] = T("none"), [le, ue] = T({}), de = w(null), fe = w(null), [pe, me] = T(""), [he, ge] = T(null), [q, _e] = T(h), [ve, ye] = T(!1);
|
|
7251
7335
|
x(() => {
|
|
7252
7336
|
_e(h);
|
|
7253
7337
|
}, [h]);
|
|
@@ -7321,13 +7405,13 @@ var ra = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7321
7405
|
return Te(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
7322
7406
|
}, []);
|
|
7323
7407
|
let Y = te({
|
|
7324
|
-
extensions:
|
|
7408
|
+
extensions: Ri({
|
|
7325
7409
|
placeholder: n || p("editor.placeholder"),
|
|
7326
7410
|
maxLength: a,
|
|
7327
7411
|
maxAttachmentSize: s,
|
|
7328
7412
|
maxTotalAttachmentSize: c
|
|
7329
7413
|
}),
|
|
7330
|
-
content:
|
|
7414
|
+
content: ee,
|
|
7331
7415
|
editable: !A,
|
|
7332
7416
|
immediatelyRender: y,
|
|
7333
7417
|
onUpdate: ({ editor: e }) => {
|
|
@@ -7338,7 +7422,7 @@ var ra = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7338
7422
|
onCreate: () => {},
|
|
7339
7423
|
onSelectionUpdate: ({ editor: e }) => {
|
|
7340
7424
|
let { from: t, to: n } = e.state.selection, r = t === n ? "" : e.state.doc.textBetween(t, n, "\n");
|
|
7341
|
-
Re(
|
|
7425
|
+
Re(Bi(r));
|
|
7342
7426
|
},
|
|
7343
7427
|
editorProps: {
|
|
7344
7428
|
attributes: {
|
|
@@ -7353,9 +7437,9 @@ var ra = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7353
7437
|
t.preventDefault();
|
|
7354
7438
|
let i = je.current?.storage?.relativeMedia;
|
|
7355
7439
|
i && (i.clipboardFiles = new Map(Array.from(n.files ?? []).map((e) => [e.name.toLowerCase(), e])), i.pausedUntilPaste = !1);
|
|
7356
|
-
let a = je.current ?
|
|
7440
|
+
let a = je.current ? ra(je.current, r) : null;
|
|
7357
7441
|
if (a) {
|
|
7358
|
-
let t = new
|
|
7442
|
+
let t = new M(a, 0, 0);
|
|
7359
7443
|
e.dispatch(e.state.tr.replaceSelection(t).scrollIntoView());
|
|
7360
7444
|
} else e.dispatch(e.state.tr.insertText(r).scrollIntoView());
|
|
7361
7445
|
return !0;
|
|
@@ -7365,7 +7449,7 @@ var ra = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7365
7449
|
x(() => {
|
|
7366
7450
|
je.current = Y, window.__editor = Y;
|
|
7367
7451
|
}, [Y]), x(() => {
|
|
7368
|
-
if (Y) return () =>
|
|
7452
|
+
if (Y) return () => tn(Y);
|
|
7369
7453
|
}, [Y]), x(() => {
|
|
7370
7454
|
Y && _ && _(Y);
|
|
7371
7455
|
}, [Y, _]), x(() => {
|
|
@@ -7377,7 +7461,7 @@ var ra = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7377
7461
|
Y.off("selectionUpdate", e);
|
|
7378
7462
|
};
|
|
7379
7463
|
}, [Y]), x(() => {
|
|
7380
|
-
Y && Y.setOptions({ extensions:
|
|
7464
|
+
Y && Y.setOptions({ extensions: Ri({
|
|
7381
7465
|
placeholder: n || p("editor.placeholder"),
|
|
7382
7466
|
maxLength: a,
|
|
7383
7467
|
maxAttachmentSize: s,
|
|
@@ -7393,7 +7477,7 @@ var ra = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7393
7477
|
x(() => {
|
|
7394
7478
|
if (!Y || e === Ge.current) return;
|
|
7395
7479
|
Ge.current = e;
|
|
7396
|
-
let t = typeof e == "object" && e ||
|
|
7480
|
+
let t = typeof e == "object" && e || na(e) ? e : f(e);
|
|
7397
7481
|
Y.commands.setContent(t, { emitUpdate: !1 });
|
|
7398
7482
|
}, [Y, e]), x(() => {
|
|
7399
7483
|
Y && Y.setEditable(!A, !1);
|
|
@@ -7401,8 +7485,8 @@ var ra = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7401
7485
|
if (k) return tt(k);
|
|
7402
7486
|
}, [k]), x(() => {
|
|
7403
7487
|
if (!Y) return;
|
|
7404
|
-
let e =
|
|
7405
|
-
e > c && Z(`文档内附件总大小 ${
|
|
7488
|
+
let e = pn(Y.state.doc);
|
|
7489
|
+
e > c && Z(`文档内附件总大小 ${mn(e)} 已超过限制 ${mn(c)}`, "info");
|
|
7406
7490
|
}, [Y, c]), x(() => {
|
|
7407
7491
|
if (!Y) return;
|
|
7408
7492
|
let e = Y.storage.qingwuUI;
|
|
@@ -7460,7 +7544,7 @@ var ra = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7460
7544
|
}, [G, Ke]), x(() => {
|
|
7461
7545
|
G === "none" && (fe.current = null);
|
|
7462
7546
|
}, [G]);
|
|
7463
|
-
let Je =
|
|
7547
|
+
let Je = Wi((e) => p(e)), Ye = Je.filter((e) => !e.more), Xe = Je.filter((e) => e.more), Ze = Ye.filter((e) => e.key !== "ai" && (e.key !== "mathInline" || Le)), Qe = Ye.find((e) => e.key === "ai"), $e = b((e) => {
|
|
7464
7548
|
if (Y) {
|
|
7465
7549
|
if (Ie(!1), e.key === "link") {
|
|
7466
7550
|
if (Y.isActive("link")) Y.chain().focus().unsetLink().run();
|
|
@@ -7531,7 +7615,7 @@ var ra = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7531
7615
|
};
|
|
7532
7616
|
}
|
|
7533
7617
|
Ae.current = n;
|
|
7534
|
-
let r = De.current?.getBoundingClientRect(), i =
|
|
7618
|
+
let r = De.current?.getBoundingClientRect(), i = ta(n, void 0, {
|
|
7535
7619
|
panelWidth: r?.width,
|
|
7536
7620
|
editorLeft: r?.left
|
|
7537
7621
|
});
|
|
@@ -7545,35 +7629,35 @@ var ra = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7545
7629
|
filename: e,
|
|
7546
7630
|
resolve: t
|
|
7547
7631
|
});
|
|
7548
|
-
}, e.openAI = dt, e.parseMd = (e, t) => Y ?
|
|
7632
|
+
}, e.openAI = dt, e.parseMd = (e, t) => Y ? ra(Y, t) : null, () => {
|
|
7549
7633
|
delete e.openImageDialog, delete e.openVideoDialog, delete e.openAI, delete e.parseMd, delete e.chooseMd;
|
|
7550
7634
|
};
|
|
7551
7635
|
}, [Y, dt]), S(() => {
|
|
7552
|
-
if (!
|
|
7636
|
+
if (!j || !Y) return;
|
|
7553
7637
|
let e = Ae.current;
|
|
7554
7638
|
if (!e) return;
|
|
7555
|
-
let t = B.current, n = De.current?.getBoundingClientRect(), r =
|
|
7639
|
+
let t = B.current, n = De.current?.getBoundingClientRect(), r = ta(e, t?.offsetHeight || void 0, {
|
|
7556
7640
|
panelWidth: n?.width,
|
|
7557
7641
|
editorLeft: n?.left
|
|
7558
7642
|
});
|
|
7559
7643
|
re(r.placement), z(r.arrowLeft), I(r.style);
|
|
7560
|
-
}, [
|
|
7561
|
-
if (!
|
|
7644
|
+
}, [j, Y]), x(() => {
|
|
7645
|
+
if (!j || !Y) return;
|
|
7562
7646
|
let e = () => {
|
|
7563
7647
|
let e = Ae.current;
|
|
7564
7648
|
if (!e) return;
|
|
7565
|
-
let t = B.current, n = De.current?.getBoundingClientRect(), r =
|
|
7649
|
+
let t = B.current, n = De.current?.getBoundingClientRect(), r = ta(e, t?.offsetHeight || void 0, {
|
|
7566
7650
|
panelWidth: n?.width,
|
|
7567
7651
|
editorLeft: n?.left
|
|
7568
7652
|
});
|
|
7569
7653
|
re(r.placement), z(r.arrowLeft), I(r.style);
|
|
7570
7654
|
};
|
|
7571
7655
|
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
7572
|
-
}, [
|
|
7573
|
-
|
|
7574
|
-
}, [
|
|
7656
|
+
}, [j, Y]), x(() => {
|
|
7657
|
+
j || (Ae.current = null);
|
|
7658
|
+
}, [j]);
|
|
7575
7659
|
let ft = b((e) => {
|
|
7576
|
-
Y &&
|
|
7660
|
+
Y && Wn(Y.view, Y.schema.nodes.image.create({ src: e }));
|
|
7577
7661
|
}, [Y]), pt = b((e) => {
|
|
7578
7662
|
(Y?.commands).insertVideo?.({ src: e });
|
|
7579
7663
|
}, [Y]), ht = q && Se && !J && !Be, gt = !ht && !ve && (q || it && !(!A && we)), _t = w(!1);
|
|
@@ -7662,11 +7746,11 @@ var ra = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7662
7746
|
}),
|
|
7663
7747
|
!A && /* @__PURE__ */ D("button", {
|
|
7664
7748
|
type: "button",
|
|
7665
|
-
className: `qed-tb-btn qed-tb-btn--ai${
|
|
7666
|
-
onClick: (e) =>
|
|
7749
|
+
className: `qed-tb-btn qed-tb-btn--ai${j ? " is-active" : ""}`,
|
|
7750
|
+
onClick: (e) => j ? P(!1) : dt(e.currentTarget),
|
|
7667
7751
|
title: p("editor.toolbar.aiTitle"),
|
|
7668
7752
|
"aria-label": p("editor.toolbar.ai"),
|
|
7669
|
-
"aria-pressed":
|
|
7753
|
+
"aria-pressed": j,
|
|
7670
7754
|
children: /* @__PURE__ */ O("svg", {
|
|
7671
7755
|
fill: "none",
|
|
7672
7756
|
viewBox: "0 0 24 24",
|
|
@@ -7795,13 +7879,13 @@ var ra = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7795
7879
|
/* @__PURE__ */ D("button", {
|
|
7796
7880
|
type: "button",
|
|
7797
7881
|
className: "qw-bubble-button qw-bubble-button--ai",
|
|
7798
|
-
"data-active":
|
|
7882
|
+
"data-active": j,
|
|
7799
7883
|
onClick: (e) => {
|
|
7800
7884
|
e.preventDefault(), Ie(!1), Qe?.command(Y);
|
|
7801
7885
|
},
|
|
7802
7886
|
title: Qe?.label,
|
|
7803
7887
|
"aria-label": Qe?.label,
|
|
7804
|
-
children: /* @__PURE__ */ D(
|
|
7888
|
+
children: /* @__PURE__ */ D(Wt, {})
|
|
7805
7889
|
}),
|
|
7806
7890
|
/* @__PURE__ */ D("span", {
|
|
7807
7891
|
className: "qw-bubble-divider",
|
|
@@ -7818,7 +7902,7 @@ var ra = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7818
7902
|
},
|
|
7819
7903
|
title: p("editor.bubble.more"),
|
|
7820
7904
|
"aria-label": p("editor.bubble.more"),
|
|
7821
|
-
children: /* @__PURE__ */ D(
|
|
7905
|
+
children: /* @__PURE__ */ D(Kt, {})
|
|
7822
7906
|
}),
|
|
7823
7907
|
Fe && /* @__PURE__ */ D("div", {
|
|
7824
7908
|
ref: Pe,
|
|
@@ -7855,7 +7939,7 @@ var ra = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7855
7939
|
onClick: (e) => e.stopPropagation(),
|
|
7856
7940
|
children: G === "highlight" ? /* @__PURE__ */ O("div", {
|
|
7857
7941
|
className: "qw-bubble-colors",
|
|
7858
|
-
children: [
|
|
7942
|
+
children: [Zi.map((e) => /* @__PURE__ */ D("button", {
|
|
7859
7943
|
type: "button",
|
|
7860
7944
|
className: "qw-bubble-swatch",
|
|
7861
7945
|
style: { background: e.color },
|
|
@@ -7896,7 +7980,7 @@ var ra = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7896
7980
|
})]
|
|
7897
7981
|
})
|
|
7898
7982
|
})] }), document.body),
|
|
7899
|
-
!A &&
|
|
7983
|
+
!A && j && L(/* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
|
|
7900
7984
|
className: "fixed inset-0 z-[9998]",
|
|
7901
7985
|
onClick: () => P(!1)
|
|
7902
7986
|
}), /* @__PURE__ */ O("div", {
|
|
@@ -7909,49 +7993,49 @@ var ra = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7909
7993
|
className: "ai-panel__arrow",
|
|
7910
7994
|
style: { left: `${ie}%` },
|
|
7911
7995
|
"aria-hidden": "true"
|
|
7912
|
-
}), /* @__PURE__ */ D(
|
|
7996
|
+
}), /* @__PURE__ */ D(dn, {
|
|
7913
7997
|
editor: Y,
|
|
7914
7998
|
onClose: () => P(!1)
|
|
7915
7999
|
})]
|
|
7916
8000
|
})] }), document.body),
|
|
7917
8001
|
V && /* @__PURE__ */ D(v, {
|
|
7918
|
-
fallback: /* @__PURE__ */ D(
|
|
7919
|
-
children: /* @__PURE__ */ D(
|
|
8002
|
+
fallback: /* @__PURE__ */ D(la, {}),
|
|
8003
|
+
children: /* @__PURE__ */ D(ia, {
|
|
7920
8004
|
open: V,
|
|
7921
8005
|
onClose: () => H(!1),
|
|
7922
8006
|
onInsert: ft,
|
|
7923
|
-
validate: (e) => Y ?
|
|
8007
|
+
validate: (e) => Y ? gn(Y.state.doc, e, {
|
|
7924
8008
|
maxAttachmentSize: s,
|
|
7925
8009
|
maxTotalAttachmentSize: c
|
|
7926
8010
|
}) : null
|
|
7927
8011
|
})
|
|
7928
8012
|
}),
|
|
7929
8013
|
ae && /* @__PURE__ */ D(v, {
|
|
7930
|
-
fallback: /* @__PURE__ */ D(
|
|
7931
|
-
children: /* @__PURE__ */ D(
|
|
8014
|
+
fallback: /* @__PURE__ */ D(la, {}),
|
|
8015
|
+
children: /* @__PURE__ */ D(sa, {
|
|
7932
8016
|
open: ae,
|
|
7933
8017
|
onClose: () => oe(!1),
|
|
7934
8018
|
onInsert: pt
|
|
7935
8019
|
})
|
|
7936
8020
|
}),
|
|
7937
8021
|
U && /* @__PURE__ */ D(v, {
|
|
7938
|
-
fallback: /* @__PURE__ */ D(
|
|
7939
|
-
children: /* @__PURE__ */ D(
|
|
8022
|
+
fallback: /* @__PURE__ */ D(la, {}),
|
|
8023
|
+
children: /* @__PURE__ */ D(aa, {
|
|
7940
8024
|
open: U,
|
|
7941
8025
|
onClose: () => W(!1)
|
|
7942
8026
|
})
|
|
7943
8027
|
}),
|
|
7944
8028
|
se && /* @__PURE__ */ D(v, {
|
|
7945
|
-
fallback: /* @__PURE__ */ D(
|
|
7946
|
-
children: /* @__PURE__ */ D(
|
|
8029
|
+
fallback: /* @__PURE__ */ D(la, {}),
|
|
8030
|
+
children: /* @__PURE__ */ D(oa, {
|
|
7947
8031
|
open: se,
|
|
7948
8032
|
onClose: () => ce(!1),
|
|
7949
8033
|
editor: Y
|
|
7950
8034
|
})
|
|
7951
8035
|
}),
|
|
7952
8036
|
he && /* @__PURE__ */ D(v, {
|
|
7953
|
-
fallback: /* @__PURE__ */ D(
|
|
7954
|
-
children: /* @__PURE__ */ D(
|
|
8037
|
+
fallback: /* @__PURE__ */ D(la, {}),
|
|
8038
|
+
children: /* @__PURE__ */ D(ca, {
|
|
7955
8039
|
open: !!he,
|
|
7956
8040
|
filename: he.filename,
|
|
7957
8041
|
onRender: () => {
|
|
@@ -7971,8 +8055,8 @@ var ra = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7971
8055
|
children: /* @__PURE__ */ O("div", {
|
|
7972
8056
|
className: "relative min-w-0 flex-1",
|
|
7973
8057
|
children: [
|
|
7974
|
-
/* @__PURE__ */ D(
|
|
7975
|
-
!A && /* @__PURE__ */ D(
|
|
8058
|
+
/* @__PURE__ */ D(N, { editor: Y }),
|
|
8059
|
+
!A && /* @__PURE__ */ D(Xi, { editor: Y }),
|
|
7976
8060
|
/* @__PURE__ */ D("div", {
|
|
7977
8061
|
className: `${J || Be ? "fixed" : "absolute"} bottom-2 right-4 z-10 pointer-events-none select-none`,
|
|
7978
8062
|
children: /* @__PURE__ */ O("span", {
|
|
@@ -7983,7 +8067,7 @@ var ra = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7983
8067
|
]
|
|
7984
8068
|
})
|
|
7985
8069
|
}),
|
|
7986
|
-
g && be && /* @__PURE__ */ D(
|
|
8070
|
+
g && be && /* @__PURE__ */ D(Nt, {
|
|
7987
8071
|
editor: Y,
|
|
7988
8072
|
onClose: () => xe(!1)
|
|
7989
8073
|
}),
|
|
@@ -8056,7 +8140,7 @@ var ra = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
8056
8140
|
});
|
|
8057
8141
|
};
|
|
8058
8142
|
// src/editor/clipper/receiver-browser.ts
|
|
8059
|
-
function
|
|
8143
|
+
function da(e) {
|
|
8060
8144
|
let t = async (t) => {
|
|
8061
8145
|
let n = t.data;
|
|
8062
8146
|
if (!n || typeof n != "object" || n.kind !== "qingwu-clip" || t.origin !== window.location.origin || t.origin === "null" || t.source !== window) return;
|
|
@@ -8070,7 +8154,7 @@ function ua(e) {
|
|
|
8070
8154
|
return window.addEventListener("message", t), { close: () => window.removeEventListener("message", t) };
|
|
8071
8155
|
}
|
|
8072
8156
|
// src/editor/storage/providers/cos.ts
|
|
8073
|
-
function
|
|
8157
|
+
function fa(t) {
|
|
8074
8158
|
return e({
|
|
8075
8159
|
endpoint: `https://cos.${t.region}.myqcloud.com`,
|
|
8076
8160
|
bucket: t.bucket,
|
|
@@ -8083,7 +8167,7 @@ function da(t) {
|
|
|
8083
8167
|
});
|
|
8084
8168
|
}
|
|
8085
8169
|
// src/editor/storage/providers/oss.ts
|
|
8086
|
-
function
|
|
8170
|
+
function pa(t) {
|
|
8087
8171
|
return e({
|
|
8088
8172
|
endpoint: `https://${t.bucket}.${t.region}.aliyuncs.com`,
|
|
8089
8173
|
bucket: t.bucket,
|
|
@@ -8095,4 +8179,4 @@ function fa(t) {
|
|
|
8095
8179
|
nameTemplate: t.nameTemplate
|
|
8096
8180
|
});
|
|
8097
8181
|
}
|
|
8098
|
-
export {
|
|
8182
|
+
export { pr as CODE_LANGUAGES, yr as CodeBlock, Ur as ImageUpload, rt as ImageUploadDialog, ci as MathBlock, si as MathInline, ua as QingWuAIEditor, Ni as RelativeMedia, jt as SearchHighlight, mt as TocPanel, er as VideoEmbed, _t as buildSystemPrompt, yt as createAILanguageModelProvider, fa as createCOSStorage, St as createDeepSeekProvider, _ as createLocalStorage, pa as createOSSStorage, ht as createOpenAICompatProvider, Ct as createOpenAIProvider, wt as createQwenProvider, e as createS3Storage, Fi as createSlashCommandExtension, g as escapeHtml, mn as formatBytes, xt as getAIProvider, Wi as getBubbleMenuActions, Ii as getDefaultSlashCommands, pn as getDocAttachmentTotal, Ri as getEditorExtensions, d as getLocale, Ui as getSearchEngine, Mt as getSearchState, l as getStorageInfo, s as getStorageProvider, c as loadStorageConfig, i as registerS3PreviewConfig, f as sanitizeHtml, m as sanitizeSvg, bt as setAIProvider, Sn as setConfirmProvider, u as setLocale, Hi as setSearchEngine, a as setStorageProvider, et as setToastProvider, n as signPreviewUrlHeaders, da as startBrowserClipperReceiver, tt as subscribeToast, p as t, h as tf, Z as toast, gn as validateAttachmentFile };
|