@qingwu-ui/ai-editor 0.9.0-beta.19 → 0.9.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/toc.d.ts +6 -0
- package/dist/components/toc.d.ts.map +1 -1
- package/dist/editor/ai-editor.d.ts.map +1 -1
- package/dist/index.cjs +10 -10
- package/dist/index.js +483 -470
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -725,7 +725,15 @@ function ot(e) {
|
|
|
725
725
|
}
|
|
726
726
|
return null;
|
|
727
727
|
}
|
|
728
|
-
function st(e
|
|
728
|
+
function st(e) {
|
|
729
|
+
if (e.isDestroyed) return null;
|
|
730
|
+
try {
|
|
731
|
+
return e.view.dom;
|
|
732
|
+
} catch {
|
|
733
|
+
return null;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
function ct(e, t) {
|
|
729
737
|
if (!t) return e;
|
|
730
738
|
let n = e.toLowerCase(), r = t.toLowerCase(), i = [], a = 0, o = 0;
|
|
731
739
|
for (;;) {
|
|
@@ -738,18 +746,21 @@ function st(e, t) {
|
|
|
738
746
|
}
|
|
739
747
|
return a < e.length && i.push(e.slice(a)), i.length ? i : e;
|
|
740
748
|
}
|
|
741
|
-
var
|
|
749
|
+
var lt = 84, ut = 3e3, dt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
742
750
|
let [r, i] = T([]), [a, o] = T(""), [s, c] = T(/* @__PURE__ */ new Set()), [l, u] = T(""), d = w(""), f = w([]), p = w(null), m = w(null), h = w(null), g = w(0), _ = b(() => {
|
|
743
751
|
h.current &&= (clearTimeout(h.current.timer), null);
|
|
744
|
-
}, []), v = b(() =>
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
752
|
+
}, []), v = b(() => {
|
|
753
|
+
let t = st(e);
|
|
754
|
+
return t ? Array.from(t.querySelectorAll("h1,h2,h3,h4,h5,h6")).map((e, t) => (e.id ||= tt(e.textContent || "", t), {
|
|
755
|
+
id: e.id,
|
|
756
|
+
level: Number(e.tagName.slice(1)),
|
|
757
|
+
text: e.textContent?.trim() || "(无标题)",
|
|
758
|
+
el: e
|
|
759
|
+
})) : [];
|
|
760
|
+
}, [e]), y = b(() => {
|
|
750
761
|
let e = f.current;
|
|
751
762
|
if ((!e.length || e.some((e) => !e.el.isConnected)) && (e = v(), f.current = e), !e.length) return;
|
|
752
|
-
let t = m.current, n = (t ? t.getBoundingClientRect().top : 0) +
|
|
763
|
+
let t = m.current, n = (t ? t.getBoundingClientRect().top : 0) + lt, r = t ? t.scrollHeight - t.scrollTop - t.clientHeight < 2 : document.documentElement.scrollHeight - window.scrollY - window.innerHeight < 2, i = "";
|
|
753
764
|
for (let t of e) t.el.isConnected && t.el.getBoundingClientRect().top <= n && (i = t.id);
|
|
754
765
|
if (r) {
|
|
755
766
|
for (let t = e.length - 1; t >= 0; t--) if (e[t].el.isConnected) {
|
|
@@ -773,11 +784,11 @@ var ct = 84, lt = 3e3, ut = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
773
784
|
t !== d.current && (d.current = t, f.current = e, i(e), S());
|
|
774
785
|
}, [v, S]);
|
|
775
786
|
x(() => {
|
|
776
|
-
let t =
|
|
777
|
-
m.current =
|
|
778
|
-
let
|
|
779
|
-
return
|
|
780
|
-
|
|
787
|
+
let t = st(e), n = t ? ot(t) : null;
|
|
788
|
+
m.current = n;
|
|
789
|
+
let r = n ?? window;
|
|
790
|
+
return r.addEventListener("scroll", S, { passive: !0 }), window.addEventListener("resize", S), r.addEventListener("wheel", _, { passive: !0 }), r.addEventListener("touchstart", _, { passive: !0 }), () => {
|
|
791
|
+
r.removeEventListener("scroll", S), window.removeEventListener("resize", S), r.removeEventListener("wheel", _), r.removeEventListener("touchstart", _);
|
|
781
792
|
};
|
|
782
793
|
}, [
|
|
783
794
|
e,
|
|
@@ -801,28 +812,30 @@ var ct = 84, lt = 3e3, ut = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
801
812
|
_
|
|
802
813
|
]);
|
|
803
814
|
let k = b((t) => {
|
|
804
|
-
let n =
|
|
805
|
-
if (
|
|
806
|
-
|
|
815
|
+
let n = st(e);
|
|
816
|
+
if (!n) return;
|
|
817
|
+
let r = t.el;
|
|
818
|
+
if ((!r || !n.contains(r)) && (r = n.querySelector(`[id="${CSS.escape(t.id)}"]`)), !r) {
|
|
819
|
+
let e = `h${t.level}`, i = n.querySelectorAll(e);
|
|
807
820
|
for (let e of i) if (e.textContent?.trim() === t.text) {
|
|
808
|
-
|
|
821
|
+
r = e;
|
|
809
822
|
break;
|
|
810
823
|
}
|
|
811
824
|
}
|
|
812
|
-
if (!
|
|
825
|
+
if (!r) return;
|
|
813
826
|
_(), h.current = {
|
|
814
827
|
id: t.id,
|
|
815
|
-
timer: setTimeout(_,
|
|
828
|
+
timer: setTimeout(_, ut)
|
|
816
829
|
}, o(t.id);
|
|
817
|
-
let
|
|
818
|
-
if (
|
|
819
|
-
let e =
|
|
820
|
-
|
|
821
|
-
top:
|
|
830
|
+
let i = m.current, a = r.getBoundingClientRect().top;
|
|
831
|
+
if (i) {
|
|
832
|
+
let e = i.getBoundingClientRect().top;
|
|
833
|
+
i.scrollTo({
|
|
834
|
+
top: i.scrollTop + a - e - lt,
|
|
822
835
|
behavior: "smooth"
|
|
823
836
|
});
|
|
824
837
|
} else window.scrollTo({
|
|
825
|
-
top: window.scrollY +
|
|
838
|
+
top: window.scrollY + a - lt,
|
|
826
839
|
behavior: "smooth"
|
|
827
840
|
});
|
|
828
841
|
}, [e, _]), A = C(() => nt(r), [r]), j = C(() => rt(A), [A]), M = C(() => {
|
|
@@ -1065,7 +1078,7 @@ var ct = 84, lt = 3e3, ut = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
1065
1078
|
title: e.text,
|
|
1066
1079
|
children: /* @__PURE__ */ D("span", {
|
|
1067
1080
|
className: "toc-text",
|
|
1068
|
-
children: N ?
|
|
1081
|
+
children: N ? ct(e.text, l.trim()) : e.text
|
|
1069
1082
|
})
|
|
1070
1083
|
})]
|
|
1071
1084
|
}, e.id);
|
|
@@ -1089,7 +1102,7 @@ var ct = 84, lt = 3e3, ut = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
1089
1102
|
};
|
|
1090
1103
|
//#endregion
|
|
1091
1104
|
//#region src/editor/ai/index.ts
|
|
1092
|
-
function
|
|
1105
|
+
function ft(e, t) {
|
|
1093
1106
|
return {
|
|
1094
1107
|
continue: "你是一个写作助手。请从下文尾部自然流畅地续写内容,保持风格一致。只输出续写的内容,不要加任何前缀说明。",
|
|
1095
1108
|
improve: "你是一个文字润色专家。请优化以下文本的表达,提升文采和流畅度,保持原意不变。只输出润色后的文本。",
|
|
@@ -1100,8 +1113,8 @@ function dt(e, t) {
|
|
|
1100
1113
|
zap: t || "你是一个全能的 AI 写作助手。请根据用户的指令处理文本。"
|
|
1101
1114
|
}[e];
|
|
1102
1115
|
}
|
|
1103
|
-
var
|
|
1104
|
-
async function
|
|
1116
|
+
var pt = null;
|
|
1117
|
+
async function mt(e) {
|
|
1105
1118
|
let t;
|
|
1106
1119
|
try {
|
|
1107
1120
|
({createOpenAI: t} = await import("@ai-sdk/openai"));
|
|
@@ -1116,7 +1129,7 @@ async function pt(e) {
|
|
|
1116
1129
|
async *stream(e) {
|
|
1117
1130
|
let t = await A({
|
|
1118
1131
|
model: n,
|
|
1119
|
-
system:
|
|
1132
|
+
system: ft(e.mode, e.instruction),
|
|
1120
1133
|
prompt: e.context,
|
|
1121
1134
|
temperature: .7,
|
|
1122
1135
|
maxOutputTokens: 2048
|
|
@@ -1126,7 +1139,7 @@ async function pt(e) {
|
|
|
1126
1139
|
async generate(e) {
|
|
1127
1140
|
return (await k({
|
|
1128
1141
|
model: n,
|
|
1129
|
-
system:
|
|
1142
|
+
system: ft(e.mode, e.instruction),
|
|
1130
1143
|
prompt: e.context,
|
|
1131
1144
|
temperature: .7,
|
|
1132
1145
|
maxOutputTokens: 2048
|
|
@@ -1134,16 +1147,16 @@ async function pt(e) {
|
|
|
1134
1147
|
}
|
|
1135
1148
|
};
|
|
1136
1149
|
}
|
|
1137
|
-
function
|
|
1138
|
-
|
|
1150
|
+
function ht(e) {
|
|
1151
|
+
pt = e;
|
|
1139
1152
|
}
|
|
1140
|
-
function
|
|
1141
|
-
if (!
|
|
1142
|
-
return
|
|
1153
|
+
function gt() {
|
|
1154
|
+
if (!pt) throw Error("未配置 AI 服务。请调用 createAILanguageModelProvider() 创建并通过 setAIProvider() 注册。");
|
|
1155
|
+
return pt;
|
|
1143
1156
|
}
|
|
1144
1157
|
//#endregion
|
|
1145
1158
|
//#region src/editor/ai/providers/openai-compat.ts
|
|
1146
|
-
function
|
|
1159
|
+
function _t(e) {
|
|
1147
1160
|
let { apiKey: t, baseURL: n, model: r, headers: i } = e;
|
|
1148
1161
|
async function* a(e, a) {
|
|
1149
1162
|
let o = await fetch(`${n}/chat/completions`, {
|
|
@@ -1194,10 +1207,10 @@ function gt(e) {
|
|
|
1194
1207
|
}
|
|
1195
1208
|
return {
|
|
1196
1209
|
async *stream(e) {
|
|
1197
|
-
yield* a(
|
|
1210
|
+
yield* a(ft(e.mode, e.instruction), e.context);
|
|
1198
1211
|
},
|
|
1199
1212
|
async generate(e) {
|
|
1200
|
-
let t =
|
|
1213
|
+
let t = ft(e.mode, e.instruction), n = "";
|
|
1201
1214
|
for await (let r of a(t, e.context)) n += r;
|
|
1202
1215
|
return n;
|
|
1203
1216
|
}
|
|
@@ -1205,8 +1218,8 @@ function gt(e) {
|
|
|
1205
1218
|
}
|
|
1206
1219
|
//#endregion
|
|
1207
1220
|
//#region src/editor/ai/providers/deepseek.ts
|
|
1208
|
-
function
|
|
1209
|
-
return
|
|
1221
|
+
function vt(e) {
|
|
1222
|
+
return _t({
|
|
1210
1223
|
apiKey: e.apiKey,
|
|
1211
1224
|
baseURL: e.baseURL || "https://api.deepseek.com/v1",
|
|
1212
1225
|
model: e.model || "deepseek-v4-flash",
|
|
@@ -1215,8 +1228,8 @@ function _t(e) {
|
|
|
1215
1228
|
}
|
|
1216
1229
|
//#endregion
|
|
1217
1230
|
//#region src/editor/ai/providers/openai.ts
|
|
1218
|
-
function
|
|
1219
|
-
return
|
|
1231
|
+
function yt(e) {
|
|
1232
|
+
return _t({
|
|
1220
1233
|
apiKey: e.apiKey,
|
|
1221
1234
|
baseURL: e.baseURL || "https://api.openai.com/v1",
|
|
1222
1235
|
model: e.model || "gpt-5.6-luna",
|
|
@@ -1225,8 +1238,8 @@ function vt(e) {
|
|
|
1225
1238
|
}
|
|
1226
1239
|
//#endregion
|
|
1227
1240
|
//#region src/editor/ai/providers/qwen.ts
|
|
1228
|
-
function
|
|
1229
|
-
return
|
|
1241
|
+
function bt(e) {
|
|
1242
|
+
return _t({
|
|
1230
1243
|
apiKey: e.apiKey,
|
|
1231
1244
|
baseURL: e.baseURL || "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
1232
1245
|
model: e.model || "qwen3.7-plus",
|
|
@@ -1235,20 +1248,20 @@ function yt(e) {
|
|
|
1235
1248
|
}
|
|
1236
1249
|
//#endregion
|
|
1237
1250
|
//#region src/editor/extensions/search-highlight.ts
|
|
1238
|
-
var
|
|
1251
|
+
var xt = {
|
|
1239
1252
|
keyword: "",
|
|
1240
1253
|
caseSensitive: !1,
|
|
1241
1254
|
wholeWord: !1,
|
|
1242
1255
|
matches: [],
|
|
1243
1256
|
currentIndex: -1
|
|
1244
|
-
},
|
|
1245
|
-
function
|
|
1257
|
+
}, St = new B("search-highlight");
|
|
1258
|
+
function Ct(e) {
|
|
1246
1259
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1247
1260
|
}
|
|
1248
|
-
function
|
|
1261
|
+
function wt(e, t) {
|
|
1249
1262
|
let { keyword: n, caseSensitive: r, wholeWord: i } = t;
|
|
1250
1263
|
if (!n) return [];
|
|
1251
|
-
let a = r ? "g" : "gi", o = i ? `\\b${
|
|
1264
|
+
let a = r ? "g" : "gi", o = i ? `\\b${Ct(n)}\\b` : Ct(n), s = new RegExp(o, a), c = [];
|
|
1252
1265
|
return e.descendants((e, t) => {
|
|
1253
1266
|
if (!e.isText || !e.text) return;
|
|
1254
1267
|
s.lastIndex = 0;
|
|
@@ -1262,12 +1275,12 @@ function Ct(e, t) {
|
|
|
1262
1275
|
}
|
|
1263
1276
|
}), c;
|
|
1264
1277
|
}
|
|
1265
|
-
function
|
|
1278
|
+
function Tt(e, t) {
|
|
1266
1279
|
if (t.matches.length === 0) return ae.empty;
|
|
1267
1280
|
let n = t.matches.map((e, n) => H.inline(e.from, e.to, { class: n === t.currentIndex ? "search-highlight search-highlight--active" : "search-highlight" }));
|
|
1268
1281
|
return ae.create(e, n);
|
|
1269
1282
|
}
|
|
1270
|
-
function
|
|
1283
|
+
function Et(e, t) {
|
|
1271
1284
|
if (t.currentIndex < 0 || t.currentIndex >= t.matches.length) return;
|
|
1272
1285
|
let n = t.matches[t.currentIndex];
|
|
1273
1286
|
n && requestAnimationFrame(() => {
|
|
@@ -1292,15 +1305,15 @@ function Tt(e, t) {
|
|
|
1292
1305
|
} catch {}
|
|
1293
1306
|
});
|
|
1294
1307
|
}
|
|
1295
|
-
var
|
|
1308
|
+
var Dt = R.create({
|
|
1296
1309
|
name: "searchHighlight",
|
|
1297
1310
|
addProseMirrorPlugins() {
|
|
1298
1311
|
return [new z({
|
|
1299
|
-
key:
|
|
1312
|
+
key: St,
|
|
1300
1313
|
state: {
|
|
1301
|
-
init: () =>
|
|
1314
|
+
init: () => xt,
|
|
1302
1315
|
apply(e, t) {
|
|
1303
|
-
let n = e.getMeta(
|
|
1316
|
+
let n = e.getMeta(St);
|
|
1304
1317
|
if (n) return {
|
|
1305
1318
|
...t,
|
|
1306
1319
|
...n,
|
|
@@ -1308,7 +1321,7 @@ var Et = R.create({
|
|
|
1308
1321
|
currentIndex: n.currentIndex === void 0 ? t.currentIndex : n.currentIndex
|
|
1309
1322
|
};
|
|
1310
1323
|
if (e.docChanged && t.keyword) {
|
|
1311
|
-
let n =
|
|
1324
|
+
let n = wt(e.doc, t), r = t.currentIndex;
|
|
1312
1325
|
return r >= n.length && (r = n.length - 1), r < 0 && (r = n.length > 0 ? 0 : -1), {
|
|
1313
1326
|
...t,
|
|
1314
1327
|
matches: n,
|
|
@@ -1319,52 +1332,52 @@ var Et = R.create({
|
|
|
1319
1332
|
}
|
|
1320
1333
|
},
|
|
1321
1334
|
props: { decorations(e) {
|
|
1322
|
-
let t =
|
|
1323
|
-
return t ?
|
|
1335
|
+
let t = St.getState(e);
|
|
1336
|
+
return t ? Tt(e.doc, t) : ae.empty;
|
|
1324
1337
|
} }
|
|
1325
1338
|
})];
|
|
1326
1339
|
},
|
|
1327
1340
|
addCommands() {
|
|
1328
1341
|
return {
|
|
1329
1342
|
setSearch: (e, t = {}) => ({ state: n, dispatch: r, view: i }) => {
|
|
1330
|
-
let a =
|
|
1343
|
+
let a = St.getState(n) || xt, o = {
|
|
1331
1344
|
keyword: e,
|
|
1332
1345
|
caseSensitive: t.caseSensitive ?? a.caseSensitive,
|
|
1333
1346
|
wholeWord: t.wholeWord ?? a.wholeWord,
|
|
1334
1347
|
matches: [],
|
|
1335
1348
|
currentIndex: -1
|
|
1336
1349
|
};
|
|
1337
|
-
return o.matches =
|
|
1350
|
+
return o.matches = wt(n.doc, o), o.currentIndex = o.matches.length > 0 ? 0 : -1, r && (r(n.tr.setMeta(St, o)), i && Et(i, o)), !0;
|
|
1338
1351
|
},
|
|
1339
1352
|
nextMatch: () => ({ state: e, dispatch: t, view: n }) => {
|
|
1340
|
-
let r =
|
|
1353
|
+
let r = St.getState(e) || xt;
|
|
1341
1354
|
if (r.matches.length === 0) return !1;
|
|
1342
1355
|
let i = (r.currentIndex + 1) % r.matches.length;
|
|
1343
|
-
return t && (t(e.tr.setMeta(
|
|
1356
|
+
return t && (t(e.tr.setMeta(St, { currentIndex: i })), n && Et(n, {
|
|
1344
1357
|
...r,
|
|
1345
1358
|
currentIndex: i
|
|
1346
1359
|
})), !0;
|
|
1347
1360
|
},
|
|
1348
1361
|
prevMatch: () => ({ state: e, dispatch: t, view: n }) => {
|
|
1349
|
-
let r =
|
|
1362
|
+
let r = St.getState(e) || xt;
|
|
1350
1363
|
if (r.matches.length === 0) return !1;
|
|
1351
1364
|
let i = (r.currentIndex - 1 + r.matches.length) % r.matches.length;
|
|
1352
|
-
return t && (t(e.tr.setMeta(
|
|
1365
|
+
return t && (t(e.tr.setMeta(St, { currentIndex: i })), n && Et(n, {
|
|
1353
1366
|
...r,
|
|
1354
1367
|
currentIndex: i
|
|
1355
1368
|
})), !0;
|
|
1356
1369
|
},
|
|
1357
|
-
clearSearch: () => ({ state: e, dispatch: t }) => (t && t(e.tr.setMeta(
|
|
1370
|
+
clearSearch: () => ({ state: e, dispatch: t }) => (t && t(e.tr.setMeta(St, xt)), !0)
|
|
1358
1371
|
};
|
|
1359
1372
|
}
|
|
1360
1373
|
});
|
|
1361
|
-
function
|
|
1374
|
+
function Ot(e) {
|
|
1362
1375
|
let t = e.state;
|
|
1363
|
-
return
|
|
1376
|
+
return St.getState(t) || xt;
|
|
1364
1377
|
}
|
|
1365
1378
|
//#endregion
|
|
1366
1379
|
//#region src/components/search-bar.tsx
|
|
1367
|
-
var
|
|
1380
|
+
var kt = ({ editor: e, onClose: t }) => {
|
|
1368
1381
|
let [n, r] = T(""), [i, a] = T(!1), [o, s] = T(!1), [c, l] = T(0), u = w(null), d = w({
|
|
1369
1382
|
keyword: n,
|
|
1370
1383
|
caseSensitive: i,
|
|
@@ -1429,7 +1442,7 @@ var Ot = ({ editor: e, onClose: t }) => {
|
|
|
1429
1442
|
}, [f, p]), h = C(() => {
|
|
1430
1443
|
if (!e) return null;
|
|
1431
1444
|
try {
|
|
1432
|
-
return
|
|
1445
|
+
return Ot(e);
|
|
1433
1446
|
} catch {
|
|
1434
1447
|
return null;
|
|
1435
1448
|
}
|
|
@@ -1581,36 +1594,36 @@ function Q({ children: e, ...t }) {
|
|
|
1581
1594
|
children: e
|
|
1582
1595
|
});
|
|
1583
1596
|
}
|
|
1584
|
-
var
|
|
1597
|
+
var At = (e) => /* @__PURE__ */ O(Q, {
|
|
1585
1598
|
...e,
|
|
1586
1599
|
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" })]
|
|
1587
|
-
}),
|
|
1600
|
+
}), jt = (e) => /* @__PURE__ */ O(Q, {
|
|
1588
1601
|
...e,
|
|
1589
1602
|
children: [
|
|
1590
1603
|
/* @__PURE__ */ D("path", { d: "M19 4h-9" }),
|
|
1591
1604
|
/* @__PURE__ */ D("path", { d: "M14 20H5" }),
|
|
1592
1605
|
/* @__PURE__ */ D("path", { d: "M15 4 9 20" })
|
|
1593
1606
|
]
|
|
1594
|
-
}),
|
|
1607
|
+
}), Mt = (e) => /* @__PURE__ */ O(Q, {
|
|
1595
1608
|
...e,
|
|
1596
1609
|
children: [/* @__PURE__ */ D("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }), /* @__PURE__ */ D("path", { d: "M4 20h16" })]
|
|
1597
|
-
}),
|
|
1610
|
+
}), Nt = (e) => /* @__PURE__ */ O(Q, {
|
|
1598
1611
|
...e,
|
|
1599
1612
|
children: [
|
|
1600
1613
|
/* @__PURE__ */ D("path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }),
|
|
1601
1614
|
/* @__PURE__ */ D("path", { d: "M14 12a4 4 0 0 1 0 8H6" }),
|
|
1602
1615
|
/* @__PURE__ */ D("path", { d: "M4 12h16" })
|
|
1603
1616
|
]
|
|
1604
|
-
}),
|
|
1617
|
+
}), Pt = (e) => /* @__PURE__ */ O(Q, {
|
|
1605
1618
|
...e,
|
|
1606
1619
|
children: [/* @__PURE__ */ D("path", { d: "m16 18 6-6-6-6" }), /* @__PURE__ */ D("path", { d: "m8 6-6 6 6 6" })]
|
|
1607
|
-
}),
|
|
1620
|
+
}), Ft = (e) => /* @__PURE__ */ O(Q, {
|
|
1608
1621
|
...e,
|
|
1609
1622
|
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" })]
|
|
1610
|
-
}),
|
|
1623
|
+
}), It = (e) => /* @__PURE__ */ O(Q, {
|
|
1611
1624
|
...e,
|
|
1612
1625
|
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" })]
|
|
1613
|
-
}),
|
|
1626
|
+
}), Lt = (e) => /* @__PURE__ */ O(Q, {
|
|
1614
1627
|
...e,
|
|
1615
1628
|
children: [/* @__PURE__ */ D("rect", {
|
|
1616
1629
|
x: "3",
|
|
@@ -1620,7 +1633,7 @@ var kt = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1620
1633
|
rx: "2",
|
|
1621
1634
|
ry: "2"
|
|
1622
1635
|
}), /* @__PURE__ */ D("path", { d: "M3 9h18M3 15h18M9 3v18M15 3v18" })]
|
|
1623
|
-
}),
|
|
1636
|
+
}), Rt = (e) => /* @__PURE__ */ O(Q, {
|
|
1624
1637
|
...e,
|
|
1625
1638
|
children: [/* @__PURE__ */ D("rect", {
|
|
1626
1639
|
x: "8",
|
|
@@ -1630,17 +1643,17 @@ var kt = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1630
1643
|
rx: "2",
|
|
1631
1644
|
ry: "2"
|
|
1632
1645
|
}), /* @__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" })]
|
|
1633
|
-
}),
|
|
1646
|
+
}), zt = (e) => /* @__PURE__ */ O(Q, {
|
|
1634
1647
|
...e,
|
|
1635
1648
|
children: [/* @__PURE__ */ D("circle", {
|
|
1636
1649
|
cx: "11",
|
|
1637
1650
|
cy: "11",
|
|
1638
1651
|
r: "8"
|
|
1639
1652
|
}), /* @__PURE__ */ D("path", { d: "m21 21-4.3-4.3" })]
|
|
1640
|
-
}),
|
|
1653
|
+
}), Bt = (e) => /* @__PURE__ */ O(Q, {
|
|
1641
1654
|
...e,
|
|
1642
1655
|
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" })]
|
|
1643
|
-
}),
|
|
1656
|
+
}), Vt = (e) => /* @__PURE__ */ O(Q, {
|
|
1644
1657
|
...e,
|
|
1645
1658
|
children: [
|
|
1646
1659
|
/* @__PURE__ */ D("circle", {
|
|
@@ -1659,13 +1672,13 @@ var kt = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1659
1672
|
r: "1"
|
|
1660
1673
|
})
|
|
1661
1674
|
]
|
|
1662
|
-
}),
|
|
1675
|
+
}), Ht = (e) => /* @__PURE__ */ O(Q, {
|
|
1663
1676
|
...e,
|
|
1664
1677
|
children: [/* @__PURE__ */ D("path", { d: "M18 6 6 18" }), /* @__PURE__ */ D("path", { d: "m6 6 12 12" })]
|
|
1665
1678
|
});
|
|
1666
1679
|
//#endregion
|
|
1667
1680
|
//#region src/editor/storage/remove-resource.ts
|
|
1668
|
-
async function
|
|
1681
|
+
async function Ut(e) {
|
|
1669
1682
|
if (e) {
|
|
1670
1683
|
if (e.startsWith("blob:")) {
|
|
1671
1684
|
URL.revokeObjectURL(e);
|
|
@@ -1680,61 +1693,61 @@ async function Ht(e) {
|
|
|
1680
1693
|
}
|
|
1681
1694
|
//#endregion
|
|
1682
1695
|
//#region src/editor/ai/pending-removal.ts
|
|
1683
|
-
var
|
|
1696
|
+
var Wt = 3e4, Gt = /* @__PURE__ */ new Set([
|
|
1684
1697
|
"image",
|
|
1685
1698
|
"attachmentEmbed",
|
|
1686
1699
|
"audioEmbed",
|
|
1687
1700
|
"videoEmbed"
|
|
1688
|
-
]),
|
|
1689
|
-
function
|
|
1701
|
+
]), Kt = /* @__PURE__ */ new WeakMap();
|
|
1702
|
+
function qt(e) {
|
|
1690
1703
|
let t = /* @__PURE__ */ new Set();
|
|
1691
1704
|
return e.state.doc.descendants((e) => {
|
|
1692
|
-
if (
|
|
1705
|
+
if (Gt.has(e.type.name)) {
|
|
1693
1706
|
let n = e.attrs.src;
|
|
1694
1707
|
n && t.add(n);
|
|
1695
1708
|
}
|
|
1696
1709
|
return !0;
|
|
1697
1710
|
}), t;
|
|
1698
1711
|
}
|
|
1699
|
-
function
|
|
1700
|
-
let t =
|
|
1712
|
+
function Jt(e) {
|
|
1713
|
+
let t = Kt.get(e);
|
|
1701
1714
|
return t || (t = {
|
|
1702
1715
|
timers: /* @__PURE__ */ new Map(),
|
|
1703
1716
|
onTransaction: () => {},
|
|
1704
1717
|
listening: !1
|
|
1705
|
-
},
|
|
1718
|
+
}, Kt.set(e, t)), t;
|
|
1706
1719
|
}
|
|
1707
|
-
function
|
|
1720
|
+
function Yt(e, t) {
|
|
1708
1721
|
let n = [...new Set(t.filter(Boolean))];
|
|
1709
1722
|
if (n.length === 0) return;
|
|
1710
|
-
let r =
|
|
1723
|
+
let r = Jt(e);
|
|
1711
1724
|
r.listening ||= (r.onTransaction = () => {
|
|
1712
1725
|
if (r.timers.size === 0) return;
|
|
1713
|
-
let t =
|
|
1726
|
+
let t = qt(e);
|
|
1714
1727
|
for (let [e, n] of r.timers) t.has(e) && (clearTimeout(n), r.timers.delete(e));
|
|
1715
1728
|
}, e.on("transaction", r.onTransaction), !0);
|
|
1716
1729
|
for (let t of n) {
|
|
1717
1730
|
if (r.timers.has(t)) continue;
|
|
1718
1731
|
let n = setTimeout(() => {
|
|
1719
|
-
|
|
1720
|
-
},
|
|
1732
|
+
qt(e).has(t) || Ut(t), r.timers.delete(t);
|
|
1733
|
+
}, Wt);
|
|
1721
1734
|
r.timers.set(t, n);
|
|
1722
1735
|
}
|
|
1723
1736
|
}
|
|
1724
|
-
function
|
|
1725
|
-
let t =
|
|
1737
|
+
function Xt(e) {
|
|
1738
|
+
let t = Kt.get(e);
|
|
1726
1739
|
if (t) {
|
|
1727
1740
|
if (t.listening &&= (e.off("transaction", t.onTransaction), !1), t.timers.size > 0) {
|
|
1728
|
-
let n =
|
|
1729
|
-
for (let [e, r] of t.timers) clearTimeout(r), n.has(e) ||
|
|
1741
|
+
let n = qt(e);
|
|
1742
|
+
for (let [e, r] of t.timers) clearTimeout(r), n.has(e) || Ut(e);
|
|
1730
1743
|
t.timers.clear();
|
|
1731
1744
|
}
|
|
1732
|
-
|
|
1745
|
+
Kt.delete(e);
|
|
1733
1746
|
}
|
|
1734
1747
|
}
|
|
1735
1748
|
//#endregion
|
|
1736
1749
|
//#region src/editor/ai/components/ai-selector.tsx
|
|
1737
|
-
var
|
|
1750
|
+
var Zt = [
|
|
1738
1751
|
{
|
|
1739
1752
|
mode: "continue",
|
|
1740
1753
|
labelKey: "editor.ai.continue",
|
|
@@ -1777,24 +1790,24 @@ var Xt = [
|
|
|
1777
1790
|
descKey: "editor.ai.zapDesc",
|
|
1778
1791
|
icon: "⚡"
|
|
1779
1792
|
}
|
|
1780
|
-
],
|
|
1793
|
+
], Qt = /* @__PURE__ */ new Set([
|
|
1781
1794
|
"image",
|
|
1782
1795
|
"attachmentEmbed",
|
|
1783
1796
|
"audioEmbed",
|
|
1784
1797
|
"videoEmbed"
|
|
1785
|
-
]),
|
|
1798
|
+
]), $t = {
|
|
1786
1799
|
image: "editor.ai.nodeImage",
|
|
1787
1800
|
attachmentEmbed: "editor.ai.nodeAttachment",
|
|
1788
1801
|
videoEmbed: "editor.ai.nodeVideo",
|
|
1789
1802
|
audioEmbed: "editor.ai.nodeAudio"
|
|
1790
1803
|
};
|
|
1791
|
-
function
|
|
1804
|
+
function en(e, t) {
|
|
1792
1805
|
return e.storage.qingwuUI?.parseMd?.(e.schema, t) || null;
|
|
1793
1806
|
}
|
|
1794
|
-
function
|
|
1807
|
+
function tn(e, t, n) {
|
|
1795
1808
|
let r = [];
|
|
1796
1809
|
return e.state.doc.nodesBetween(t, n, (e) => {
|
|
1797
|
-
if (
|
|
1810
|
+
if (Qt.has(e.type.name)) {
|
|
1798
1811
|
let t = e.attrs.src;
|
|
1799
1812
|
t && r.push({
|
|
1800
1813
|
type: e.type.name,
|
|
@@ -1804,18 +1817,18 @@ function en(e, t, n) {
|
|
|
1804
1817
|
return !0;
|
|
1805
1818
|
}), r;
|
|
1806
1819
|
}
|
|
1807
|
-
function
|
|
1820
|
+
function nn(e) {
|
|
1808
1821
|
let t = /* @__PURE__ */ new Set();
|
|
1809
1822
|
return e.state.doc.descendants((e) => {
|
|
1810
|
-
if (
|
|
1823
|
+
if (Qt.has(e.type.name)) {
|
|
1811
1824
|
let n = e.attrs.src;
|
|
1812
1825
|
n && t.add(n);
|
|
1813
1826
|
}
|
|
1814
1827
|
return !0;
|
|
1815
1828
|
}), t;
|
|
1816
1829
|
}
|
|
1817
|
-
function
|
|
1818
|
-
let n =
|
|
1830
|
+
function rn(e, t) {
|
|
1831
|
+
let n = en(e, t);
|
|
1819
1832
|
if (n && n.size > 0) {
|
|
1820
1833
|
let t = e.state.tr;
|
|
1821
1834
|
t.replaceWith(0, e.state.doc.content.size, n), t.setSelection(V.create(t.doc, t.doc.content.size)), e.view.dispatch(t.scrollIntoView()), e.commands.focus();
|
|
@@ -1823,8 +1836,8 @@ function nn(e, t) {
|
|
|
1823
1836
|
}
|
|
1824
1837
|
e.commands.setContent(t), e.commands.focus();
|
|
1825
1838
|
}
|
|
1826
|
-
function
|
|
1827
|
-
let i =
|
|
1839
|
+
function an(e, t, n, r) {
|
|
1840
|
+
let i = en(e, t);
|
|
1828
1841
|
if (e.commands.focus(), !i) {
|
|
1829
1842
|
let i = e.chain().focus();
|
|
1830
1843
|
n === "replace" ? i.setTextSelection({
|
|
@@ -1836,7 +1849,7 @@ function rn(e, t, n, r) {
|
|
|
1836
1849
|
let a = e.state.tr;
|
|
1837
1850
|
n === "replace" ? a.replaceRange(r.from, r.to, new N(i, 0, 0)) : a.insert(Math.min(r.to, e.state.doc.content.size), i), e.view.dispatch(a.scrollIntoView());
|
|
1838
1851
|
}
|
|
1839
|
-
function
|
|
1852
|
+
function on({ editor: e, onClose: t }) {
|
|
1840
1853
|
let [n, r] = T(null), [i, a] = T(""), [o, s] = T(""), [c, l] = T(!1), [u, d] = T(null), [p, m] = T(null), h = w({
|
|
1841
1854
|
from: 0,
|
|
1842
1855
|
to: 0,
|
|
@@ -1855,7 +1868,7 @@ function an({ editor: e, onClose: t }) {
|
|
|
1855
1868
|
empty: n.empty
|
|
1856
1869
|
}, l(!0), s(""), v.current = !0, d(null);
|
|
1857
1870
|
try {
|
|
1858
|
-
let r =
|
|
1871
|
+
let r = gt(), a = n.empty ? e.state.doc.textContent : e.state.doc.textBetween(n.from, n.to), o = [];
|
|
1859
1872
|
for await (let e of r.stream({
|
|
1860
1873
|
mode: t,
|
|
1861
1874
|
context: a,
|
|
@@ -1880,13 +1893,13 @@ function an({ editor: e, onClose: t }) {
|
|
|
1880
1893
|
!e || !v.current || (e.scrollTop = e.scrollHeight);
|
|
1881
1894
|
}, [o]);
|
|
1882
1895
|
let k = b((t, n, r) => {
|
|
1883
|
-
let i = new Set(
|
|
1884
|
-
t === "replaceAll" ?
|
|
1885
|
-
let a =
|
|
1886
|
-
|
|
1896
|
+
let i = new Set(tn(e, r.from, r.to).map((e) => e.src));
|
|
1897
|
+
t === "replaceAll" ? rn(e, n) : an(e, n, "replace", h.current);
|
|
1898
|
+
let a = nn(e);
|
|
1899
|
+
Yt(e, [...i].filter((e) => !a.has(e)));
|
|
1887
1900
|
}, [e]), A = b((n) => {
|
|
1888
1901
|
if (n === "below") {
|
|
1889
|
-
|
|
1902
|
+
an(e, o, "below", h.current), t();
|
|
1890
1903
|
return;
|
|
1891
1904
|
}
|
|
1892
1905
|
let r = h.current, i = n === "replaceAll" ? {
|
|
@@ -1895,7 +1908,7 @@ function an({ editor: e, onClose: t }) {
|
|
|
1895
1908
|
} : {
|
|
1896
1909
|
from: r.from,
|
|
1897
1910
|
to: r.to
|
|
1898
|
-
}, a =
|
|
1911
|
+
}, a = tn(e, i.from, i.to);
|
|
1899
1912
|
if (a.length > 0) {
|
|
1900
1913
|
m({
|
|
1901
1914
|
position: n,
|
|
@@ -1936,19 +1949,19 @@ function an({ editor: e, onClose: t }) {
|
|
|
1936
1949
|
className: "flex items-center justify-between pl-3 pr-1.5 py-1.5 border-b border-default-100 shrink-0",
|
|
1937
1950
|
children: [/* @__PURE__ */ O("span", {
|
|
1938
1951
|
className: "flex items-center gap-1.5 text-xs font-medium text-default-500",
|
|
1939
|
-
children: [/* @__PURE__ */ D(
|
|
1952
|
+
children: [/* @__PURE__ */ D(Bt, { className: "text-primary" }), f("editor.ai.trigger")]
|
|
1940
1953
|
}), /* @__PURE__ */ D("button", {
|
|
1941
1954
|
type: "button",
|
|
1942
1955
|
onClick: t,
|
|
1943
1956
|
"aria-label": f("editor.ai.close"),
|
|
1944
1957
|
title: f("editor.ai.close"),
|
|
1945
1958
|
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",
|
|
1946
|
-
children: /* @__PURE__ */ D(
|
|
1959
|
+
children: /* @__PURE__ */ D(Ht, {})
|
|
1947
1960
|
})]
|
|
1948
1961
|
}),
|
|
1949
1962
|
/* @__PURE__ */ D("div", {
|
|
1950
1963
|
className: "grid grid-cols-[repeat(auto-fit,minmax(64px,1fr))] gap-1.5 p-2 shrink-0",
|
|
1951
|
-
children:
|
|
1964
|
+
children: Zt.map(({ mode: e, labelKey: t, descKey: r, icon: i }) => /* @__PURE__ */ O("button", {
|
|
1952
1965
|
type: "button",
|
|
1953
1966
|
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"}`,
|
|
1954
1967
|
onClick: () => y(e),
|
|
@@ -2091,7 +2104,7 @@ function an({ editor: e, onClose: t }) {
|
|
|
2091
2104
|
children: Object.entries(N).map(([e, t]) => /* @__PURE__ */ O("li", {
|
|
2092
2105
|
className: "text-sm text-default-700",
|
|
2093
2106
|
children: [
|
|
2094
|
-
f(
|
|
2107
|
+
f($t[e] ?? e),
|
|
2095
2108
|
" ×",
|
|
2096
2109
|
t
|
|
2097
2110
|
]
|
|
@@ -2123,19 +2136,19 @@ function an({ editor: e, onClose: t }) {
|
|
|
2123
2136
|
}
|
|
2124
2137
|
//#endregion
|
|
2125
2138
|
//#region src/editor/attachment-limits.ts
|
|
2126
|
-
var
|
|
2139
|
+
var sn = /* @__PURE__ */ new Set([
|
|
2127
2140
|
"attachmentEmbed",
|
|
2128
2141
|
"videoEmbed",
|
|
2129
2142
|
"audioEmbed",
|
|
2130
2143
|
"image"
|
|
2131
2144
|
]);
|
|
2132
|
-
function
|
|
2145
|
+
function cn(e) {
|
|
2133
2146
|
let t = 0;
|
|
2134
2147
|
return e.descendants((e) => {
|
|
2135
|
-
|
|
2148
|
+
sn.has(e.type.name) && (t += Number(e.attrs?.size) || 0);
|
|
2136
2149
|
}), t;
|
|
2137
2150
|
}
|
|
2138
|
-
function
|
|
2151
|
+
function ln(e) {
|
|
2139
2152
|
if (!Number.isFinite(e) || e <= 0) return "0 B";
|
|
2140
2153
|
let t = [
|
|
2141
2154
|
"B",
|
|
@@ -2146,41 +2159,41 @@ function cn(e) {
|
|
|
2146
2159
|
], n = Math.min(t.length - 1, Math.floor(Math.log(e) / Math.log(1024))), r = e / 1024 ** n;
|
|
2147
2160
|
return `${n === 0 || r >= 100 ? `${Math.round(r)}` : `${Math.round(r * 10) / 10}`} ${t[n]}`;
|
|
2148
2161
|
}
|
|
2149
|
-
function
|
|
2162
|
+
function un(e) {
|
|
2150
2163
|
return (e?.storage)?.qingwuUI?.limits;
|
|
2151
2164
|
}
|
|
2152
|
-
function
|
|
2165
|
+
function dn(e, t, n) {
|
|
2153
2166
|
let { maxAttachmentSize: r, maxTotalAttachmentSize: i } = n;
|
|
2154
|
-
if (r && t.size > r) return `单文件大小不能超过 ${
|
|
2167
|
+
if (r && t.size > r) return `单文件大小不能超过 ${ln(r)}(当前 ${ln(t.size)})`;
|
|
2155
2168
|
if (i) {
|
|
2156
|
-
let n =
|
|
2157
|
-
if (n > i) return `附件总大小不能超过 ${
|
|
2169
|
+
let n = cn(e) + t.size;
|
|
2170
|
+
if (n > i) return `附件总大小不能超过 ${ln(i)}(当前合计 ${ln(n)})`;
|
|
2158
2171
|
}
|
|
2159
2172
|
return null;
|
|
2160
2173
|
}
|
|
2161
2174
|
//#endregion
|
|
2162
2175
|
//#region src/editor/utils/delete-confirm.ts
|
|
2163
|
-
var
|
|
2164
|
-
function
|
|
2165
|
-
return
|
|
2176
|
+
var fn = !1, pn = null, mn = 5e3;
|
|
2177
|
+
function hn() {
|
|
2178
|
+
return fn;
|
|
2166
2179
|
}
|
|
2167
2180
|
function $(e) {
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
},
|
|
2181
|
+
fn = e, pn &&= (clearTimeout(pn), null), e && (pn = setTimeout(() => {
|
|
2182
|
+
fn = !1, pn = null;
|
|
2183
|
+
}, mn));
|
|
2171
2184
|
}
|
|
2172
|
-
var
|
|
2173
|
-
function
|
|
2174
|
-
|
|
2185
|
+
var gn = null;
|
|
2186
|
+
function _n(e) {
|
|
2187
|
+
gn = e;
|
|
2175
2188
|
}
|
|
2176
|
-
function
|
|
2177
|
-
return
|
|
2189
|
+
function vn() {
|
|
2190
|
+
return gn;
|
|
2178
2191
|
}
|
|
2179
2192
|
//#endregion
|
|
2180
2193
|
//#region src/editor/utils/delete-confirm-dialog.tsx
|
|
2181
|
-
var
|
|
2182
|
-
function
|
|
2183
|
-
let [s, c] = T(!1), l = w(!1), u =
|
|
2194
|
+
var yn = 300;
|
|
2195
|
+
function bn({ open: e, title: t, message: n, confirmText: r = "删除", cancelText: i = "取消", onConfirm: a, onCancel: o }) {
|
|
2196
|
+
let [s, c] = T(!1), l = w(!1), u = vn();
|
|
2184
2197
|
return x(() => {
|
|
2185
2198
|
if (!e) {
|
|
2186
2199
|
l.current = !1;
|
|
@@ -2250,7 +2263,7 @@ function yn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2250
2263
|
await a();
|
|
2251
2264
|
} finally {
|
|
2252
2265
|
let t = Date.now() - e;
|
|
2253
|
-
t <
|
|
2266
|
+
t < yn && await new Promise((e) => setTimeout(e, yn - t)), c(!1), o();
|
|
2254
2267
|
}
|
|
2255
2268
|
},
|
|
2256
2269
|
disabled: s,
|
|
@@ -2263,10 +2276,10 @@ function yn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2263
2276
|
}
|
|
2264
2277
|
//#endregion
|
|
2265
2278
|
//#region src/editor/extensions/image-view.tsx
|
|
2266
|
-
function
|
|
2279
|
+
function xn(e) {
|
|
2267
2280
|
return /^(\.\.?\/|[a-zA-Z]:\\|file:\/\/)/.test(e) ? !0 : !(/^[a-z]+:\/\//i.test(e) || e.startsWith("/") || e.startsWith("data:") || e.startsWith("blob:"));
|
|
2268
2281
|
}
|
|
2269
|
-
function
|
|
2282
|
+
function Sn({ node: e, deleteNode: t, editor: r }) {
|
|
2270
2283
|
let [i, a] = T(!1), [o, s] = T(!1), [c, l] = T(!1), u = w(!1), [d, f] = T(!1), p = e.attrs.src || "", m = e.attrs.alt || "", h = e.attrs.width || null, g = e.attrs.height || null, _ = w(null), v = w(null), y = w(null), S = w(null), C = w(null), E = w(!1), k = w(!1), A = w(0), [j, M] = T(p), N = r?.isEditable ?? !0, P = b(() => {
|
|
2271
2284
|
o || (A.current = window.scrollY, a(!0));
|
|
2272
2285
|
}, [o]), I = b(() => {
|
|
@@ -2319,7 +2332,7 @@ function xn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2319
2332
|
};
|
|
2320
2333
|
return document.addEventListener("fullscreenchange", e), () => document.removeEventListener("fullscreenchange", e);
|
|
2321
2334
|
}, []);
|
|
2322
|
-
let te = o ||
|
|
2335
|
+
let te = o || xn(p);
|
|
2323
2336
|
return /* @__PURE__ */ O(F, {
|
|
2324
2337
|
as: "div",
|
|
2325
2338
|
className: "image-node-view group/img",
|
|
@@ -2332,7 +2345,7 @@ function xn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2332
2345
|
type: "button",
|
|
2333
2346
|
className: "img-ctrl-btn img-ctrl-btn--del image-placeholder-del",
|
|
2334
2347
|
onClick: () => {
|
|
2335
|
-
|
|
2348
|
+
hn() || ($(!0), f(!0));
|
|
2336
2349
|
},
|
|
2337
2350
|
title: "删除",
|
|
2338
2351
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -2364,7 +2377,7 @@ function xn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2364
2377
|
}),
|
|
2365
2378
|
/* @__PURE__ */ D("span", {
|
|
2366
2379
|
className: "image-placeholder-text",
|
|
2367
|
-
children:
|
|
2380
|
+
children: xn(p) ? "本地图片无法加载" : "图片加载失败"
|
|
2368
2381
|
}),
|
|
2369
2382
|
/* @__PURE__ */ D("span", {
|
|
2370
2383
|
className: "image-placeholder-path",
|
|
@@ -2445,7 +2458,7 @@ function xn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2445
2458
|
type: "button",
|
|
2446
2459
|
className: "img-ctrl-btn img-ctrl-btn--del",
|
|
2447
2460
|
onClick: () => {
|
|
2448
|
-
|
|
2461
|
+
hn() || ($(!0), f(!0));
|
|
2449
2462
|
},
|
|
2450
2463
|
title: "删除",
|
|
2451
2464
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -2532,7 +2545,7 @@ function xn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2532
2545
|
}
|
|
2533
2546
|
})]
|
|
2534
2547
|
}),
|
|
2535
|
-
/* @__PURE__ */ D(
|
|
2548
|
+
/* @__PURE__ */ D(bn, {
|
|
2536
2549
|
open: d,
|
|
2537
2550
|
title: "确认删除图片",
|
|
2538
2551
|
message: te ? "该图片无法在当前环境加载,仅从编辑器中移除该图片节点,不影响存储文件。" : "此操作将同时删除对象存储中的文件,不可撤销。",
|
|
@@ -2541,7 +2554,7 @@ function xn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2541
2554
|
},
|
|
2542
2555
|
onConfirm: async () => {
|
|
2543
2556
|
if (!te) try {
|
|
2544
|
-
await
|
|
2557
|
+
await Ut(p);
|
|
2545
2558
|
} catch {}
|
|
2546
2559
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
2547
2560
|
}
|
|
@@ -2551,7 +2564,7 @@ function xn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2551
2564
|
}
|
|
2552
2565
|
//#endregion
|
|
2553
2566
|
//#region src/editor/embeds/attachment-view.tsx
|
|
2554
|
-
var
|
|
2567
|
+
var Cn = y(() => import("@file-viewer/react")), wn = /* @__PURE__ */ new Set(), Tn = {
|
|
2555
2568
|
rendererMode: "replace",
|
|
2556
2569
|
autoRenderers: !0,
|
|
2557
2570
|
theme: "light",
|
|
@@ -2580,7 +2593,7 @@ var Sn = y(() => import("@file-viewer/react")), Cn = /* @__PURE__ */ new Set(),
|
|
|
2580
2593
|
cache: !0,
|
|
2581
2594
|
workerTimeoutMs: 3e4
|
|
2582
2595
|
}
|
|
2583
|
-
},
|
|
2596
|
+
}, En = {
|
|
2584
2597
|
pdf: "pdf",
|
|
2585
2598
|
docx: "word",
|
|
2586
2599
|
docm: "word",
|
|
@@ -2635,7 +2648,7 @@ var Sn = y(() => import("@file-viewer/react")), Cn = /* @__PURE__ */ new Set(),
|
|
|
2635
2648
|
xml: "text",
|
|
2636
2649
|
yml: "text",
|
|
2637
2650
|
yaml: "text"
|
|
2638
|
-
},
|
|
2651
|
+
}, Dn = {
|
|
2639
2652
|
pdf: () => import("@file-viewer/renderer-pdf").then((e) => e.pdfRenderer),
|
|
2640
2653
|
word: () => import("@file-viewer/renderer-word").then((e) => e.wordRenderer),
|
|
2641
2654
|
spreadsheet: () => import("@file-viewer/renderer-spreadsheet").then((e) => e.spreadsheetRenderer),
|
|
@@ -2643,10 +2656,10 @@ var Sn = y(() => import("@file-viewer/react")), Cn = /* @__PURE__ */ new Set(),
|
|
|
2643
2656
|
archive: () => import("@file-viewer/renderer-archive").then((e) => e.archiveRenderer),
|
|
2644
2657
|
text: () => import("@file-viewer/renderer-text").then((e) => e.textRenderer)
|
|
2645
2658
|
};
|
|
2646
|
-
function
|
|
2659
|
+
function On(e) {
|
|
2647
2660
|
return e ? e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1048576).toFixed(1)} MB` : "";
|
|
2648
2661
|
}
|
|
2649
|
-
function
|
|
2662
|
+
function kn(e) {
|
|
2650
2663
|
let t = e.split(".").pop()?.toLowerCase() || "", n = {
|
|
2651
2664
|
pdf: {
|
|
2652
2665
|
label: "PDF",
|
|
@@ -2819,22 +2832,22 @@ function On(e) {
|
|
|
2819
2832
|
]
|
|
2820
2833
|
});
|
|
2821
2834
|
}
|
|
2822
|
-
function
|
|
2835
|
+
function An(e) {
|
|
2823
2836
|
return e.split(".").pop()?.toLowerCase() || "";
|
|
2824
2837
|
}
|
|
2825
|
-
function
|
|
2838
|
+
function jn(e) {
|
|
2826
2839
|
let t = e.split(".").pop()?.toLowerCase() || "";
|
|
2827
2840
|
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);
|
|
2828
2841
|
}
|
|
2829
|
-
function
|
|
2842
|
+
function Mn(e) {
|
|
2830
2843
|
return !!e && !e.startsWith("file:");
|
|
2831
2844
|
}
|
|
2832
|
-
function
|
|
2845
|
+
function Nn(e) {
|
|
2833
2846
|
return btoa(encodeURIComponent(e)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
2834
2847
|
}
|
|
2835
|
-
async function
|
|
2848
|
+
async function Pn(e, t) {
|
|
2836
2849
|
try {
|
|
2837
|
-
let n =
|
|
2850
|
+
let n = Nn(e), r = await fetch(`/api/preview/${n}`, {
|
|
2838
2851
|
signal: t,
|
|
2839
2852
|
cache: "no-store"
|
|
2840
2853
|
});
|
|
@@ -2846,7 +2859,7 @@ async function Nn(e, t) {
|
|
|
2846
2859
|
return null;
|
|
2847
2860
|
}
|
|
2848
2861
|
}
|
|
2849
|
-
function
|
|
2862
|
+
function Fn(e, t, n) {
|
|
2850
2863
|
return new Promise((r, i) => {
|
|
2851
2864
|
let a = new XMLHttpRequest();
|
|
2852
2865
|
if (a.open("GET", e, !0), a.responseType = "arraybuffer", t) {
|
|
@@ -2884,20 +2897,20 @@ function Pn(e, t, n) {
|
|
|
2884
2897
|
a.send();
|
|
2885
2898
|
});
|
|
2886
2899
|
}
|
|
2887
|
-
function
|
|
2888
|
-
let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() =>
|
|
2900
|
+
function In({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
2901
|
+
let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() => wn.has(s)), [u, d] = T(null), [p, m] = T(null), [h, g] = T(!1), [_, y] = T(null), [S, E] = T(!1), [k, A] = T(null), j = w(null), M = w(null), N = w(null), P = w(0), I = w(!1), L = w(null), ee = w(0), [te, ne] = T(!1), R = w(null), [re, ie] = T(0), [z, B] = T("none"), [V, H] = T(void 0), [ae, oe] = T(!1), U = e.attrs.src || "", W = e.attrs.name || U && U.split("/").pop()?.split("?")[0] || (U ? "attachment" : f("editor.attachment.lost")), G = e.attrs.size || 0, K = An(W), q = !U;
|
|
2889
2902
|
x(() => {
|
|
2890
2903
|
if (!c) {
|
|
2891
2904
|
H(void 0), oe(!1);
|
|
2892
2905
|
return;
|
|
2893
2906
|
}
|
|
2894
|
-
let e =
|
|
2907
|
+
let e = En[K];
|
|
2895
2908
|
if (!e) {
|
|
2896
2909
|
H(void 0), oe(!1);
|
|
2897
2910
|
return;
|
|
2898
2911
|
}
|
|
2899
2912
|
let t = !0;
|
|
2900
|
-
return H(void 0), oe(!1),
|
|
2913
|
+
return H(void 0), oe(!1), Dn[e]().then((e) => {
|
|
2901
2914
|
t && H(e);
|
|
2902
2915
|
}).catch((n) => {
|
|
2903
2916
|
console.error(`[attachment] renderer "${e}" load failed:`, n), t && oe(!0);
|
|
@@ -2906,17 +2919,17 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2906
2919
|
};
|
|
2907
2920
|
}, [c, K]);
|
|
2908
2921
|
let se = C(() => ({
|
|
2909
|
-
...
|
|
2922
|
+
...Tn,
|
|
2910
2923
|
renderers: V ? [V] : [],
|
|
2911
2924
|
rendererMode: "replace"
|
|
2912
2925
|
}), [V]), ce = b((e) => {
|
|
2913
2926
|
l((t) => {
|
|
2914
2927
|
let n = typeof e == "function" ? e(t) : e;
|
|
2915
|
-
return U && (n ?
|
|
2928
|
+
return U && (n ? wn.add(U) : wn.delete(U)), n;
|
|
2916
2929
|
});
|
|
2917
2930
|
}, [U]);
|
|
2918
2931
|
x(() => {
|
|
2919
|
-
l(U ?
|
|
2932
|
+
l(U ? wn.has(U) : !1);
|
|
2920
2933
|
}, [U]);
|
|
2921
2934
|
let le = b(() => {
|
|
2922
2935
|
I.current = !0, ce(!0), window.setTimeout(() => {
|
|
@@ -2941,7 +2954,7 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2941
2954
|
};
|
|
2942
2955
|
}, [z, le]), x(() => {
|
|
2943
2956
|
let e = (e) => {
|
|
2944
|
-
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && i && !
|
|
2957
|
+
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && i && !hn()) {
|
|
2945
2958
|
if (e.preventDefault(), e.stopPropagation(), a) {
|
|
2946
2959
|
let { from: e, to: t } = a.state.selection;
|
|
2947
2960
|
R.current = {
|
|
@@ -2958,7 +2971,7 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2958
2971
|
a,
|
|
2959
2972
|
o
|
|
2960
2973
|
]), x(() => {
|
|
2961
|
-
if (!c || !
|
|
2974
|
+
if (!c || !Mn(U)) {
|
|
2962
2975
|
d(null), y(null), N.current = null;
|
|
2963
2976
|
return;
|
|
2964
2977
|
}
|
|
@@ -2966,9 +2979,9 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2966
2979
|
let e = new AbortController(), r = !0;
|
|
2967
2980
|
return g(!0), y(null), (async () => {
|
|
2968
2981
|
let i = U.includes("?X-Amz-"), a = null, o = null;
|
|
2969
|
-
if (!a && !i && (a = await
|
|
2982
|
+
if (!a && !i && (a = await Pn(U, e.signal)), !a && !i) try {
|
|
2970
2983
|
let n = await t(U);
|
|
2971
|
-
n && (a = await
|
|
2984
|
+
n && (a = await Pn(n, e.signal) || await Fn(n, void 0, e.signal));
|
|
2972
2985
|
} catch (e) {
|
|
2973
2986
|
console.warn("[attachment] signPreviewUrl failed:", e);
|
|
2974
2987
|
}
|
|
@@ -2980,7 +2993,7 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2980
2993
|
n[t] = e;
|
|
2981
2994
|
});
|
|
2982
2995
|
try {
|
|
2983
|
-
a = await
|
|
2996
|
+
a = await Fn(U, n, e.signal);
|
|
2984
2997
|
} catch (e) {
|
|
2985
2998
|
console.warn("[attachment] signed headers XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
|
|
2986
2999
|
}
|
|
@@ -2989,7 +3002,7 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2989
3002
|
console.warn("[attachment] signPreviewUrlHeaders failed:", e);
|
|
2990
3003
|
}
|
|
2991
3004
|
if (!a) try {
|
|
2992
|
-
a = await
|
|
3005
|
+
a = await Fn(U, i ? void 0 : { "X-Requested-With": "XMLHttpRequest" }, e.signal);
|
|
2993
3006
|
} catch (e) {
|
|
2994
3007
|
console.warn("[attachment] plain XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
|
|
2995
3008
|
}
|
|
@@ -3084,7 +3097,7 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3084
3097
|
/* @__PURE__ */ D("path", { d: "M12 9v4" }),
|
|
3085
3098
|
/* @__PURE__ */ D("path", { d: "M12 17h.01" })
|
|
3086
3099
|
]
|
|
3087
|
-
}) :
|
|
3100
|
+
}) : kn(W)
|
|
3088
3101
|
}), /* @__PURE__ */ O("div", {
|
|
3089
3102
|
className: "att-meta",
|
|
3090
3103
|
children: [/* @__PURE__ */ D("span", {
|
|
@@ -3092,7 +3105,7 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3092
3105
|
children: W
|
|
3093
3106
|
}), G > 0 && /* @__PURE__ */ D("span", {
|
|
3094
3107
|
className: "att-size",
|
|
3095
|
-
children:
|
|
3108
|
+
children: On(G)
|
|
3096
3109
|
})]
|
|
3097
3110
|
})]
|
|
3098
3111
|
}), /* @__PURE__ */ O("div", {
|
|
@@ -3145,7 +3158,7 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3145
3158
|
}), /* @__PURE__ */ O("div", {
|
|
3146
3159
|
className: "att-actions",
|
|
3147
3160
|
children: [
|
|
3148
|
-
U &&
|
|
3161
|
+
U && jn(W) && /* @__PURE__ */ D("button", {
|
|
3149
3162
|
type: "button",
|
|
3150
3163
|
className: "att-btn",
|
|
3151
3164
|
onMouseDown: (e) => {
|
|
@@ -3198,7 +3211,7 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3198
3211
|
type: "button",
|
|
3199
3212
|
className: "att-btn att-btn--del",
|
|
3200
3213
|
onClick: () => {
|
|
3201
|
-
!o ||
|
|
3214
|
+
!o || hn() || ($(!0), ne(!0));
|
|
3202
3215
|
},
|
|
3203
3216
|
title: f("editor.attachment.delete"),
|
|
3204
3217
|
"aria-label": f("editor.attachment.delete"),
|
|
@@ -3254,7 +3267,7 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3254
3267
|
style: { background: "#fff" },
|
|
3255
3268
|
children: f("editor.attachment.loadingPreview")
|
|
3256
3269
|
}),
|
|
3257
|
-
children: u || p || U ? V ? /* @__PURE__ */ D(
|
|
3270
|
+
children: u || p || U ? V ? /* @__PURE__ */ D(Cn, {
|
|
3258
3271
|
buffer: u || void 0,
|
|
3259
3272
|
url: p || U,
|
|
3260
3273
|
name: W,
|
|
@@ -3366,7 +3379,7 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3366
3379
|
})]
|
|
3367
3380
|
})]
|
|
3368
3381
|
})]
|
|
3369
|
-
}), /* @__PURE__ */ D(
|
|
3382
|
+
}), /* @__PURE__ */ D(bn, {
|
|
3370
3383
|
open: te,
|
|
3371
3384
|
title: "确认删除附件",
|
|
3372
3385
|
message: q ? "此操作将删除该附件节点,不可撤销。" : `此操作将同时删除对象存储中的文件(${W}),不可撤销。`,
|
|
@@ -3378,12 +3391,12 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3378
3391
|
if (a) {
|
|
3379
3392
|
let e = R.current, t = e?.from ?? a.state.selection.from, n = e?.to ?? a.state.selection.to, r = [];
|
|
3380
3393
|
a.state.doc.nodesBetween(t, n, (e) => {
|
|
3381
|
-
e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(
|
|
3394
|
+
e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(Ut(e.attrs.src));
|
|
3382
3395
|
}), await Promise.all(r), $(!1), await new Promise((e) => setTimeout(e, 300)), a.chain().focus().setTextSelection({
|
|
3383
3396
|
from: t,
|
|
3384
3397
|
to: n
|
|
3385
3398
|
}).deleteSelection().run();
|
|
3386
|
-
} else await
|
|
3399
|
+
} else await Ut(U), $(!1), await new Promise((e) => setTimeout(e, 300)), r();
|
|
3387
3400
|
} catch {
|
|
3388
3401
|
$(!1);
|
|
3389
3402
|
}
|
|
@@ -3393,13 +3406,13 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3393
3406
|
}
|
|
3394
3407
|
//#endregion
|
|
3395
3408
|
//#region src/editor/embeds/attachment.ts
|
|
3396
|
-
var
|
|
3409
|
+
var Ln = re.create({
|
|
3397
3410
|
name: "attachmentEmbed",
|
|
3398
3411
|
group: "block",
|
|
3399
3412
|
atom: !0,
|
|
3400
3413
|
inline: !1,
|
|
3401
3414
|
addNodeView() {
|
|
3402
|
-
return I(
|
|
3415
|
+
return I(In);
|
|
3403
3416
|
},
|
|
3404
3417
|
addAttributes() {
|
|
3405
3418
|
return {
|
|
@@ -3448,7 +3461,7 @@ var In = re.create({
|
|
|
3448
3461
|
});
|
|
3449
3462
|
//#endregion
|
|
3450
3463
|
//#region src/editor/embeds/audio-view.tsx
|
|
3451
|
-
function
|
|
3464
|
+
function Rn({ node: e, deleteNode: t, editor: r }) {
|
|
3452
3465
|
let i = e.attrs.src || "", a = e.attrs.name || i.split("/").pop()?.split("?")[0] || "audio", [o, s] = T(!1), c = r?.isEditable ?? !0;
|
|
3453
3466
|
x(() => () => {
|
|
3454
3467
|
i.startsWith("blob:") && URL.revokeObjectURL(i);
|
|
@@ -3514,7 +3527,7 @@ function Ln({ node: e, deleteNode: t, editor: r }) {
|
|
|
3514
3527
|
type: "button",
|
|
3515
3528
|
className: "audio-embed-btn audio-embed-btn--del",
|
|
3516
3529
|
onClick: () => {
|
|
3517
|
-
|
|
3530
|
+
hn() || ($(!0), s(!0));
|
|
3518
3531
|
},
|
|
3519
3532
|
title: "删除",
|
|
3520
3533
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -3560,7 +3573,7 @@ function Ln({ node: e, deleteNode: t, editor: r }) {
|
|
|
3560
3573
|
}), "音频文件缺失"]
|
|
3561
3574
|
})
|
|
3562
3575
|
})]
|
|
3563
|
-
}), /* @__PURE__ */ D(
|
|
3576
|
+
}), /* @__PURE__ */ D(bn, {
|
|
3564
3577
|
open: o,
|
|
3565
3578
|
title: "确认删除音频",
|
|
3566
3579
|
message: `此操作将同时删除对象存储中的文件(${a}),不可撤销。`,
|
|
@@ -3569,7 +3582,7 @@ function Ln({ node: e, deleteNode: t, editor: r }) {
|
|
|
3569
3582
|
},
|
|
3570
3583
|
onConfirm: async () => {
|
|
3571
3584
|
try {
|
|
3572
|
-
await
|
|
3585
|
+
await Ut(i);
|
|
3573
3586
|
} catch {}
|
|
3574
3587
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
3575
3588
|
}
|
|
@@ -3578,16 +3591,16 @@ function Ln({ node: e, deleteNode: t, editor: r }) {
|
|
|
3578
3591
|
}
|
|
3579
3592
|
//#endregion
|
|
3580
3593
|
//#region src/editor/embeds/audio.ts
|
|
3581
|
-
function
|
|
3594
|
+
function zn(e) {
|
|
3582
3595
|
return /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|$)/i.test(e) || /\/.*\.(mp3|wav|ogg|flac)/i.test(e);
|
|
3583
3596
|
}
|
|
3584
|
-
var
|
|
3597
|
+
var Bn = re.create({
|
|
3585
3598
|
name: "audioEmbed",
|
|
3586
3599
|
group: "block",
|
|
3587
3600
|
atom: !0,
|
|
3588
3601
|
inline: !1,
|
|
3589
3602
|
addNodeView() {
|
|
3590
|
-
return I(
|
|
3603
|
+
return I(Rn);
|
|
3591
3604
|
},
|
|
3592
3605
|
addProseMirrorPlugins() {
|
|
3593
3606
|
return [new z({ props: { handlePaste(e, t) {
|
|
@@ -3596,7 +3609,7 @@ var zn = re.create({
|
|
|
3596
3609
|
let r = n.split(/\r?\n/);
|
|
3597
3610
|
for (let n of r) {
|
|
3598
3611
|
let r = n.trim();
|
|
3599
|
-
if (!r || r.includes(" ") || !
|
|
3612
|
+
if (!r || r.includes(" ") || !zn(r)) continue;
|
|
3600
3613
|
t.preventDefault();
|
|
3601
3614
|
let i = e.state.schema.nodes.audioEmbed.create({ src: r });
|
|
3602
3615
|
return e.dispatch(e.state.tr.replaceSelectionWith(i)), !0;
|
|
@@ -3643,17 +3656,17 @@ var zn = re.create({
|
|
|
3643
3656
|
});
|
|
3644
3657
|
//#endregion
|
|
3645
3658
|
//#region src/editor/embeds/video-view.tsx
|
|
3646
|
-
function
|
|
3659
|
+
function Vn(e) {
|
|
3647
3660
|
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";
|
|
3648
3661
|
}
|
|
3649
|
-
function
|
|
3662
|
+
function Hn(e) {
|
|
3650
3663
|
let t = e.match(/BV[a-zA-Z0-9]{10}/);
|
|
3651
3664
|
if (t) return t[0];
|
|
3652
3665
|
let n = e.match(/av(\d+)/i);
|
|
3653
3666
|
return n ? n[0] : e;
|
|
3654
3667
|
}
|
|
3655
|
-
function
|
|
3656
|
-
let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ?
|
|
3668
|
+
function Un({ node: e, deleteNode: t, editor: n }) {
|
|
3669
|
+
let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ? Vn(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(bn, {
|
|
3657
3670
|
open: o,
|
|
3658
3671
|
title: "确认删除视频",
|
|
3659
3672
|
message: "此操作将同时删除对象存储中的文件,不可撤销。",
|
|
@@ -3662,7 +3675,7 @@ function Hn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3662
3675
|
},
|
|
3663
3676
|
onConfirm: async () => {
|
|
3664
3677
|
try {
|
|
3665
|
-
await
|
|
3678
|
+
await Ut(r);
|
|
3666
3679
|
} catch {}
|
|
3667
3680
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
3668
3681
|
}
|
|
@@ -3765,7 +3778,7 @@ function Hn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3765
3778
|
}, [a, h]), x(() => {
|
|
3766
3779
|
u && (_.current?.destroy(), _.current = null);
|
|
3767
3780
|
}, [u]), a === "bilibili") {
|
|
3768
|
-
let e =
|
|
3781
|
+
let e = Hn(r);
|
|
3769
3782
|
return /* @__PURE__ */ O(F, {
|
|
3770
3783
|
as: "div",
|
|
3771
3784
|
className: "video-embed video-embed--bilibili group/video",
|
|
@@ -3842,7 +3855,7 @@ function Hn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3842
3855
|
className: "video-fs-btn video-fs-btn--del",
|
|
3843
3856
|
title: "删除",
|
|
3844
3857
|
onClick: () => {
|
|
3845
|
-
|
|
3858
|
+
hn() || ($(!0), s(!0));
|
|
3846
3859
|
},
|
|
3847
3860
|
children: /* @__PURE__ */ D("svg", {
|
|
3848
3861
|
width: "12",
|
|
@@ -3949,7 +3962,7 @@ function Hn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3949
3962
|
className: "video-fs-btn video-fs-btn--del",
|
|
3950
3963
|
title: "删除",
|
|
3951
3964
|
onClick: () => {
|
|
3952
|
-
|
|
3965
|
+
hn() || ($(!0), s(!0));
|
|
3953
3966
|
},
|
|
3954
3967
|
children: /* @__PURE__ */ D("svg", {
|
|
3955
3968
|
width: "12",
|
|
@@ -4106,26 +4119,26 @@ function Hn({ node: e, deleteNode: t, editor: n }) {
|
|
|
4106
4119
|
}
|
|
4107
4120
|
//#endregion
|
|
4108
4121
|
//#region src/editor/embeds/video.ts
|
|
4109
|
-
function
|
|
4122
|
+
function Wn(e) {
|
|
4110
4123
|
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";
|
|
4111
4124
|
}
|
|
4112
|
-
function
|
|
4125
|
+
function Gn(e) {
|
|
4113
4126
|
let t = e.match(/BV[a-zA-Z0-9]{10}/);
|
|
4114
4127
|
if (t) return t[0];
|
|
4115
4128
|
let n = e.match(/av(\d+)/i);
|
|
4116
4129
|
return n ? n[0] : e;
|
|
4117
4130
|
}
|
|
4118
|
-
function
|
|
4131
|
+
function Kn(e) {
|
|
4119
4132
|
let t = e.match(/explore\/([a-zA-Z0-9]+)/);
|
|
4120
4133
|
return t ? t[1] : e;
|
|
4121
4134
|
}
|
|
4122
|
-
var
|
|
4135
|
+
var qn = re.create({
|
|
4123
4136
|
name: "videoEmbed",
|
|
4124
4137
|
group: "block",
|
|
4125
4138
|
atom: !0,
|
|
4126
4139
|
inline: !1,
|
|
4127
4140
|
addNodeView() {
|
|
4128
|
-
return I(
|
|
4141
|
+
return I(Un);
|
|
4129
4142
|
},
|
|
4130
4143
|
addProseMirrorPlugins() {
|
|
4131
4144
|
return [new z({ props: {
|
|
@@ -4150,7 +4163,7 @@ var Kn = re.create({
|
|
|
4150
4163
|
for (let n of r) {
|
|
4151
4164
|
let r = n.trim();
|
|
4152
4165
|
if (!r || r.includes(" ")) continue;
|
|
4153
|
-
let i =
|
|
4166
|
+
let i = Wn(r);
|
|
4154
4167
|
if (i === "unknown") continue;
|
|
4155
4168
|
t.preventDefault();
|
|
4156
4169
|
let a = e.state.schema.nodes.videoEmbed.create({
|
|
@@ -4182,7 +4195,7 @@ var Kn = re.create({
|
|
|
4182
4195
|
let t = e, n = t.getAttribute("src") || t.getAttribute("data-src") || "";
|
|
4183
4196
|
return {
|
|
4184
4197
|
src: n,
|
|
4185
|
-
source:
|
|
4198
|
+
source: Wn(n)
|
|
4186
4199
|
};
|
|
4187
4200
|
}
|
|
4188
4201
|
},
|
|
@@ -4191,9 +4204,9 @@ var Kn = re.create({
|
|
|
4191
4204
|
];
|
|
4192
4205
|
},
|
|
4193
4206
|
renderHTML({ HTMLAttributes: e }) {
|
|
4194
|
-
let t = e.src || "", n =
|
|
4207
|
+
let t = e.src || "", n = Wn(t);
|
|
4195
4208
|
if (n === "bilibili") {
|
|
4196
|
-
let e =
|
|
4209
|
+
let e = Gn(t);
|
|
4197
4210
|
return [
|
|
4198
4211
|
"div",
|
|
4199
4212
|
{
|
|
@@ -4214,7 +4227,7 @@ var Kn = re.create({
|
|
|
4214
4227
|
}]
|
|
4215
4228
|
];
|
|
4216
4229
|
}
|
|
4217
|
-
if (n === "xiaohongshu") return
|
|
4230
|
+
if (n === "xiaohongshu") return Kn(t), [
|
|
4218
4231
|
"div",
|
|
4219
4232
|
{
|
|
4220
4233
|
"data-video-embed": "xiaohongshu",
|
|
@@ -4266,7 +4279,7 @@ var Kn = re.create({
|
|
|
4266
4279
|
},
|
|
4267
4280
|
addCommands() {
|
|
4268
4281
|
return { insertVideo: (e) => ({ chain: t }) => {
|
|
4269
|
-
let n =
|
|
4282
|
+
let n = Wn(e.src);
|
|
4270
4283
|
return t().insertContent({
|
|
4271
4284
|
type: this.name,
|
|
4272
4285
|
attrs: {
|
|
@@ -4276,13 +4289,13 @@ var Kn = re.create({
|
|
|
4276
4289
|
}).focus().run();
|
|
4277
4290
|
} };
|
|
4278
4291
|
}
|
|
4279
|
-
}),
|
|
4280
|
-
async function
|
|
4281
|
-
|
|
4282
|
-
let t =
|
|
4292
|
+
}), Jn = null;
|
|
4293
|
+
async function Yn(e) {
|
|
4294
|
+
Jn ||= await import("beautiful-mermaid");
|
|
4295
|
+
let t = Jn.renderMermaidSVG;
|
|
4283
4296
|
return t(e);
|
|
4284
4297
|
}
|
|
4285
|
-
var
|
|
4298
|
+
var Xn = [
|
|
4286
4299
|
{
|
|
4287
4300
|
value: "javascript",
|
|
4288
4301
|
label: "JavaScript",
|
|
@@ -4443,7 +4456,7 @@ var Yn = [
|
|
|
4443
4456
|
label: "Plain Text",
|
|
4444
4457
|
color: "#6b7280"
|
|
4445
4458
|
}
|
|
4446
|
-
],
|
|
4459
|
+
], Zn = {
|
|
4447
4460
|
javascript: "js",
|
|
4448
4461
|
typescript: "ts",
|
|
4449
4462
|
python: "py",
|
|
@@ -4469,7 +4482,7 @@ var Yn = [
|
|
|
4469
4482
|
txt: "txt",
|
|
4470
4483
|
vue: "vue",
|
|
4471
4484
|
react: "jsx"
|
|
4472
|
-
},
|
|
4485
|
+
}, Qn = {
|
|
4473
4486
|
js: "javascript",
|
|
4474
4487
|
ts: "typescript",
|
|
4475
4488
|
py: "python",
|
|
@@ -4485,12 +4498,12 @@ var Yn = [
|
|
|
4485
4498
|
jsx: "javascript",
|
|
4486
4499
|
tsx: "typescript"
|
|
4487
4500
|
};
|
|
4488
|
-
function
|
|
4501
|
+
function $n({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i, selected: a }) {
|
|
4489
4502
|
let o = n?.isEditable ?? !0, s = !o, [c, l] = T(!1), [u, d] = T(!1), [f, m] = T(!1), [h, g] = T(!1), [_, v] = T(220), [y, S] = T({
|
|
4490
4503
|
top: 0,
|
|
4491
4504
|
left: 0,
|
|
4492
4505
|
width: 210
|
|
4493
|
-
}), [k, A] = T(""), [j, M] = T(!1), [N, P] = T(null), [F, I] = T(null), [L, ee] = T(!1), te = w(null), R = w(null), re = w(null), ie = w(null), z = w(null), B = w(null), V = e.attrs.language || "", H =
|
|
4506
|
+
}), [k, A] = T(""), [j, M] = T(!1), [N, P] = T(null), [F, I] = T(null), [L, ee] = T(!1), te = w(null), R = w(null), re = w(null), ie = w(null), z = w(null), B = w(null), V = e.attrs.language || "", H = Xn.find((e) => e.value === (Qn[V] ?? V)), ae = V === "mermaid", oe = b(() => {
|
|
4494
4507
|
if (!n || typeof r != "function") return null;
|
|
4495
4508
|
let t = r();
|
|
4496
4509
|
return typeof t == "number" ? {
|
|
@@ -4502,10 +4515,10 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4502
4515
|
r,
|
|
4503
4516
|
e.nodeSize
|
|
4504
4517
|
]), U = b(() => {
|
|
4505
|
-
o && (
|
|
4518
|
+
o && (hn() || (B.current = oe(), window.getSelection()?.removeAllRanges(), $(!0), M(!0)));
|
|
4506
4519
|
}, [oe, o]), W = C(() => {
|
|
4507
4520
|
let e = k.trim().toLowerCase();
|
|
4508
|
-
return e ?
|
|
4521
|
+
return e ? Xn.filter((t) => t.label.toLowerCase().includes(e) || t.value.toLowerCase().includes(e)) : Xn;
|
|
4509
4522
|
}, [k]);
|
|
4510
4523
|
x(() => {
|
|
4511
4524
|
(z.current?.parentElement?.querySelector(".cb-code-area"))?.classList.toggle("cb-code-area--collapsed", u);
|
|
@@ -4513,7 +4526,7 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4513
4526
|
let G = b(() => {
|
|
4514
4527
|
let e = re.current;
|
|
4515
4528
|
if (!e) return;
|
|
4516
|
-
let t = e.getBoundingClientRect(), n = Math.min(t.left, window.innerWidth - 210 - 8), r = window.innerHeight - t.bottom - 12, i = t.top - 12, a =
|
|
4529
|
+
let t = e.getBoundingClientRect(), n = Math.min(t.left, window.innerWidth - 210 - 8), r = window.innerHeight - t.bottom - 12, i = t.top - 12, a = Xn.length * 31 + 8, o = r - 52, s = i - 52;
|
|
4517
4530
|
o < 220 && s > o ? (g(!0), v(Math.max(120, Math.min(a, s))), S({
|
|
4518
4531
|
top: t.top,
|
|
4519
4532
|
left: n,
|
|
@@ -4546,7 +4559,7 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4546
4559
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
4547
4560
|
}, [f]), x(() => {
|
|
4548
4561
|
let e = (e) => {
|
|
4549
|
-
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && a && !
|
|
4562
|
+
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && a && !hn()) {
|
|
4550
4563
|
if (e.preventDefault(), e.stopPropagation(), n) {
|
|
4551
4564
|
let { from: e, to: t } = n.state.selection;
|
|
4552
4565
|
B.current = {
|
|
@@ -4588,7 +4601,7 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4588
4601
|
};
|
|
4589
4602
|
navigator.clipboard?.writeText ? navigator.clipboard.writeText(t).catch(() => n(t)) : n(t), l(!0), setTimeout(() => l(!1), 1500);
|
|
4590
4603
|
}, [e.textContent]), ce = b(() => {
|
|
4591
|
-
let t =
|
|
4604
|
+
let t = Zn[V] || "txt", n = t ? `code.${t}` : "code.txt", r = new Blob([e.textContent], { type: "text/plain;charset=utf-8" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
4592
4605
|
a.href = i, a.download = n, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
4593
4606
|
}, [e.textContent, V]), le = b(async () => {
|
|
4594
4607
|
if (N || L) {
|
|
@@ -4602,7 +4615,7 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4602
4615
|
I("代码块内容为空");
|
|
4603
4616
|
return;
|
|
4604
4617
|
}
|
|
4605
|
-
let n = p(await
|
|
4618
|
+
let n = p(await Yn(t));
|
|
4606
4619
|
P(n);
|
|
4607
4620
|
} catch (e) {
|
|
4608
4621
|
I(e instanceof Error ? e.message : "Mermaid 渲染失败");
|
|
@@ -4887,7 +4900,7 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4887
4900
|
})
|
|
4888
4901
|
]
|
|
4889
4902
|
}),
|
|
4890
|
-
/* @__PURE__ */ D(
|
|
4903
|
+
/* @__PURE__ */ D(bn, {
|
|
4891
4904
|
open: j,
|
|
4892
4905
|
title: "确认删除代码块",
|
|
4893
4906
|
message: "此操作不可撤销。",
|
|
@@ -4903,7 +4916,7 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4903
4916
|
}
|
|
4904
4917
|
//#endregion
|
|
4905
4918
|
//#region src/editor/extensions/code-block.ts
|
|
4906
|
-
var
|
|
4919
|
+
var er = [
|
|
4907
4920
|
{
|
|
4908
4921
|
value: "javascript",
|
|
4909
4922
|
label: "JavaScript"
|
|
@@ -5004,12 +5017,12 @@ var $n = [
|
|
|
5004
5017
|
value: "mermaid",
|
|
5005
5018
|
label: "Mermaid"
|
|
5006
5019
|
}
|
|
5007
|
-
],
|
|
5008
|
-
|
|
5009
|
-
function
|
|
5020
|
+
], tr = xe(be);
|
|
5021
|
+
tr.register({ dockerfile: ye }), tr.registerAlias("xml", ["vue", "html"]), tr.registerAlias("javascript", ["react", "jsx"]), tr.registerAlias("typescript", ["tsx"]);
|
|
5022
|
+
function nr(e) {
|
|
5010
5023
|
return e ? e.split("\n") : [""];
|
|
5011
5024
|
}
|
|
5012
|
-
function
|
|
5025
|
+
function rr(e, t) {
|
|
5013
5026
|
if (e.childElementCount !== t) {
|
|
5014
5027
|
e.replaceChildren();
|
|
5015
5028
|
for (let n = 1; n <= t; n++) {
|
|
@@ -5018,14 +5031,14 @@ function nr(e, t) {
|
|
|
5018
5031
|
}
|
|
5019
5032
|
}
|
|
5020
5033
|
}
|
|
5021
|
-
function
|
|
5034
|
+
function ir(e, t) {
|
|
5022
5035
|
e.replaceChildren();
|
|
5023
5036
|
for (let n of t) {
|
|
5024
5037
|
let t = document.createElement("span");
|
|
5025
5038
|
t.className = "cb-mirror-line", t.textContent = n.length ? n : "\xA0", e.appendChild(t);
|
|
5026
5039
|
}
|
|
5027
5040
|
}
|
|
5028
|
-
function
|
|
5041
|
+
function ar(e, t, n) {
|
|
5029
5042
|
let r = getComputedStyle(e), i = parseFloat(r.paddingLeft), a = parseFloat(r.paddingRight);
|
|
5030
5043
|
t.style.boxSizing = "content-box", t.style.width = `${Math.max(0, e.clientWidth - i - a)}px`, t.style.padding = r.padding;
|
|
5031
5044
|
let o = getComputedStyle(n);
|
|
@@ -5072,7 +5085,7 @@ function ir(e, t, n) {
|
|
|
5072
5085
|
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;
|
|
5073
5086
|
}
|
|
5074
5087
|
}
|
|
5075
|
-
var
|
|
5088
|
+
var or = ve.extend({
|
|
5076
5089
|
addNodeView() {
|
|
5077
5090
|
return (e) => {
|
|
5078
5091
|
let { node: t, editor: n, getPos: r } = e, i = t, a = (e) => {
|
|
@@ -5098,9 +5111,9 @@ var ar = ve.extend({
|
|
|
5098
5111
|
d.appendChild(f);
|
|
5099
5112
|
let p = document.createElement("div");
|
|
5100
5113
|
p.className = "cb-code-mirror", p.contentEditable = "false", p.setAttribute("aria-hidden", "true"), l.appendChild(u), l.appendChild(d), l.appendChild(p), s.appendChild(l);
|
|
5101
|
-
let m =
|
|
5102
|
-
|
|
5103
|
-
let h = new L(
|
|
5114
|
+
let m = nr(t.textContent);
|
|
5115
|
+
rr(u, m.length), ir(p, m);
|
|
5116
|
+
let h = new L($n, {
|
|
5104
5117
|
editor: n,
|
|
5105
5118
|
props: {
|
|
5106
5119
|
node: t,
|
|
@@ -5113,12 +5126,12 @@ var ar = ve.extend({
|
|
|
5113
5126
|
});
|
|
5114
5127
|
c.appendChild(h.element);
|
|
5115
5128
|
let g = (e) => {
|
|
5116
|
-
let t =
|
|
5117
|
-
|
|
5129
|
+
let t = nr(e.textContent);
|
|
5130
|
+
rr(u, t.length), ir(p, t), requestAnimationFrame(() => ar(d, p, u));
|
|
5118
5131
|
};
|
|
5119
|
-
requestAnimationFrame(() =>
|
|
5120
|
-
let _ = new ResizeObserver(() =>
|
|
5121
|
-
return _.observe(d), document.fonts?.ready?.then(() =>
|
|
5132
|
+
requestAnimationFrame(() => ar(d, p, u));
|
|
5133
|
+
let _ = new ResizeObserver(() => ar(d, p, u));
|
|
5134
|
+
return _.observe(d), document.fonts?.ready?.then(() => ar(d, p, u)), {
|
|
5122
5135
|
dom: s,
|
|
5123
5136
|
contentDOM: f,
|
|
5124
5137
|
update(e) {
|
|
@@ -5178,10 +5191,10 @@ var ar = ve.extend({
|
|
|
5178
5191
|
}
|
|
5179
5192
|
}));
|
|
5180
5193
|
}
|
|
5181
|
-
}).configure({ lowlight:
|
|
5194
|
+
}).configure({ lowlight: tr });
|
|
5182
5195
|
//#endregion
|
|
5183
5196
|
//#region src/editor/utils/import-choice-dialog.ts
|
|
5184
|
-
function
|
|
5197
|
+
function sr(e) {
|
|
5185
5198
|
return new Promise((t) => {
|
|
5186
5199
|
let n = document.createElement("div");
|
|
5187
5200
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5211,16 +5224,16 @@ function or(e) {
|
|
|
5211
5224
|
}
|
|
5212
5225
|
//#endregion
|
|
5213
5226
|
//#region src/editor/utils/local-media.ts
|
|
5214
|
-
var
|
|
5215
|
-
function
|
|
5227
|
+
var cr = /\.(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, lr = /^(?:mailto:|tel:|javascript:|about:|data:|blob:)/i;
|
|
5228
|
+
function ur(e) {
|
|
5216
5229
|
if (!e) return !1;
|
|
5217
5230
|
let t = e.trim();
|
|
5218
|
-
return !(!t || /^(?:https?:)?\/\//i.test(t) ||
|
|
5219
|
-
}
|
|
5220
|
-
function ur(e) {
|
|
5221
|
-
return sr.test(e);
|
|
5231
|
+
return !(!t || /^(?:https?:)?\/\//i.test(t) || lr.test(t) || t.startsWith("#"));
|
|
5222
5232
|
}
|
|
5223
5233
|
function dr(e) {
|
|
5234
|
+
return cr.test(e);
|
|
5235
|
+
}
|
|
5236
|
+
function fr(e) {
|
|
5224
5237
|
let t = e.trim();
|
|
5225
5238
|
t = t.replace(/^(?:file|app):\/\/(?:localhost)?/i, "");
|
|
5226
5239
|
try {
|
|
@@ -5228,26 +5241,26 @@ function dr(e) {
|
|
|
5228
5241
|
} catch {}
|
|
5229
5242
|
return t = t.replace(/\\/g, "/"), t = t.replace(/^\.\//, ""), t = t.replace(/^\/+/, ""), t = t.replace(/^[a-zA-Z]:\//, ""), t;
|
|
5230
5243
|
}
|
|
5231
|
-
function
|
|
5232
|
-
let t =
|
|
5244
|
+
function pr(e) {
|
|
5245
|
+
let t = fr(e), n = t.split("/").filter(Boolean);
|
|
5233
5246
|
return (n[n.length - 1] || t).toLowerCase();
|
|
5234
5247
|
}
|
|
5235
|
-
function
|
|
5248
|
+
function mr() {
|
|
5236
5249
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showDirectoryPicker == "function";
|
|
5237
5250
|
}
|
|
5238
|
-
async function
|
|
5239
|
-
if (!
|
|
5251
|
+
async function hr() {
|
|
5252
|
+
if (!mr()) return null;
|
|
5240
5253
|
try {
|
|
5241
5254
|
return await window.showDirectoryPicker.call(window, { mode: "read" }) ?? null;
|
|
5242
5255
|
} catch {
|
|
5243
5256
|
return null;
|
|
5244
5257
|
}
|
|
5245
5258
|
}
|
|
5246
|
-
function
|
|
5259
|
+
function gr() {
|
|
5247
5260
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showOpenFilePicker == "function";
|
|
5248
5261
|
}
|
|
5249
|
-
async function
|
|
5250
|
-
if (!
|
|
5262
|
+
async function _r() {
|
|
5263
|
+
if (!gr()) return null;
|
|
5251
5264
|
try {
|
|
5252
5265
|
let e = await window.showOpenFilePicker.call(window, { multiple: !0 });
|
|
5253
5266
|
return await Promise.all(e.map((e) => e.getFile()));
|
|
@@ -5255,7 +5268,7 @@ async function gr() {
|
|
|
5255
5268
|
return null;
|
|
5256
5269
|
}
|
|
5257
5270
|
}
|
|
5258
|
-
async function
|
|
5271
|
+
async function vr(e, t) {
|
|
5259
5272
|
if (t.length === 0) return { file: null };
|
|
5260
5273
|
let n = e;
|
|
5261
5274
|
for (let e = 0; e < t.length - 1; e++) try {
|
|
@@ -5277,7 +5290,7 @@ async function _r(e, t) {
|
|
|
5277
5290
|
return { file: null };
|
|
5278
5291
|
}
|
|
5279
5292
|
}
|
|
5280
|
-
async function
|
|
5293
|
+
async function yr(e, t, n = 5e3) {
|
|
5281
5294
|
let r = t.toLowerCase(), i = [e], a = 0, o;
|
|
5282
5295
|
for (; i.length > 0 && a < n;) {
|
|
5283
5296
|
let e = i.pop();
|
|
@@ -5299,37 +5312,37 @@ async function vr(e, t, n = 5e3) {
|
|
|
5299
5312
|
readError: o
|
|
5300
5313
|
};
|
|
5301
5314
|
}
|
|
5302
|
-
async function
|
|
5303
|
-
let n =
|
|
5315
|
+
async function br(e, t) {
|
|
5316
|
+
let n = fr(t).split("/").filter(Boolean);
|
|
5304
5317
|
if (n.length === 0) return { file: null };
|
|
5305
5318
|
let r;
|
|
5306
5319
|
for (let t = 0; t < n.length; t++) {
|
|
5307
|
-
let i = await
|
|
5320
|
+
let i = await vr(e, n.slice(t));
|
|
5308
5321
|
if (i.file) return i;
|
|
5309
5322
|
i.readError && (r = i.readError);
|
|
5310
5323
|
}
|
|
5311
|
-
let i = await
|
|
5324
|
+
let i = await yr(e, n[n.length - 1]);
|
|
5312
5325
|
return i.file || i.readError ? i : {
|
|
5313
5326
|
file: null,
|
|
5314
5327
|
readError: r
|
|
5315
5328
|
};
|
|
5316
5329
|
}
|
|
5317
|
-
var
|
|
5330
|
+
var xr = {
|
|
5318
5331
|
image: "image",
|
|
5319
5332
|
videoEmbed: "video",
|
|
5320
5333
|
audioEmbed: "audio",
|
|
5321
5334
|
attachmentEmbed: "attachment"
|
|
5322
5335
|
};
|
|
5323
|
-
function
|
|
5336
|
+
function Sr(e, t) {
|
|
5324
5337
|
let n = /* @__PURE__ */ new Set(), r = [];
|
|
5325
5338
|
return e.descendants((e) => {
|
|
5326
|
-
let i =
|
|
5339
|
+
let i = xr[e.type?.name];
|
|
5327
5340
|
if (i) {
|
|
5328
5341
|
let a = e.attrs?.src, o = `node:${a}`;
|
|
5329
|
-
typeof a == "string" &&
|
|
5342
|
+
typeof a == "string" && ur(a) && !n.has(o) && !t?.(a) && (n.add(o), r.push({
|
|
5330
5343
|
src: a,
|
|
5331
|
-
normalized:
|
|
5332
|
-
basename:
|
|
5344
|
+
normalized: fr(a),
|
|
5345
|
+
basename: pr(a),
|
|
5333
5346
|
kind: i,
|
|
5334
5347
|
isLink: !1
|
|
5335
5348
|
}));
|
|
@@ -5338,17 +5351,17 @@ function xr(e, t) {
|
|
|
5338
5351
|
if (e.isText && e.marks) for (let i of e.marks) {
|
|
5339
5352
|
if (i.type.name !== "link") continue;
|
|
5340
5353
|
let e = i.attrs?.href, a = `link:${e}`;
|
|
5341
|
-
typeof e == "string" &&
|
|
5354
|
+
typeof e == "string" && ur(e) && dr(e) && !n.has(a) && !t?.(e) && (n.add(a), r.push({
|
|
5342
5355
|
src: e,
|
|
5343
|
-
normalized:
|
|
5344
|
-
basename:
|
|
5356
|
+
normalized: fr(e),
|
|
5357
|
+
basename: pr(e),
|
|
5345
5358
|
kind: "attachment",
|
|
5346
5359
|
isLink: !0
|
|
5347
5360
|
}));
|
|
5348
5361
|
}
|
|
5349
5362
|
}), r;
|
|
5350
5363
|
}
|
|
5351
|
-
function
|
|
5364
|
+
function Cr(e, t, n) {
|
|
5352
5365
|
let r = t ? `${e}\n${t}` : e;
|
|
5353
5366
|
if (!r) return !1;
|
|
5354
5367
|
let i = [];
|
|
@@ -5356,28 +5369,28 @@ function Sr(e, t, n) {
|
|
|
5356
5369
|
for (let e of r.matchAll(/!?\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g)) i.push(e[1]);
|
|
5357
5370
|
for (let e of r.matchAll(/<(?:img|video|audio|source)[^>]*\bsrc=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5358
5371
|
for (let e of r.matchAll(/<a[^>]*\bhref=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5359
|
-
return i.some((e) =>
|
|
5372
|
+
return i.some((e) => dr(e) && ur(e) && !n?.(e));
|
|
5360
5373
|
}
|
|
5361
5374
|
//#endregion
|
|
5362
5375
|
//#region src/editor/extensions/image-upload.ts
|
|
5363
|
-
function
|
|
5376
|
+
function wr(e) {
|
|
5364
5377
|
if (e.type.startsWith("image/")) return "image";
|
|
5365
5378
|
if (e.type.startsWith("video/")) return "video";
|
|
5366
5379
|
if (e.type.startsWith("audio/")) return "audio";
|
|
5367
5380
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5368
5381
|
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";
|
|
5369
5382
|
}
|
|
5370
|
-
function
|
|
5383
|
+
function Tr(e) {
|
|
5371
5384
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5372
5385
|
return t === "md" || t === "markdown";
|
|
5373
5386
|
}
|
|
5374
|
-
async function
|
|
5375
|
-
let i = n ?? e.state.selection.from, a = r ?
|
|
5376
|
-
o?.chooseMd ? o.chooseMd(t.name, e) :
|
|
5387
|
+
async function Er(e, t, n, r) {
|
|
5388
|
+
let i = n ?? e.state.selection.from, a = r ? un(r) : void 0, o = r?.storage?.qingwuUI, s = await new Promise((e) => {
|
|
5389
|
+
o?.chooseMd ? o.chooseMd(t.name, e) : sr(t.name).then(e);
|
|
5377
5390
|
});
|
|
5378
5391
|
if (s === null) return;
|
|
5379
5392
|
if (s === "attach") {
|
|
5380
|
-
let n = a ?
|
|
5393
|
+
let n = a ? dn(e.state.doc, t, a) : null;
|
|
5381
5394
|
if (n) {
|
|
5382
5395
|
Z(n);
|
|
5383
5396
|
return;
|
|
@@ -5408,8 +5421,8 @@ async function Tr(e, t, n, r) {
|
|
|
5408
5421
|
e.dispatch(e.state.tr.insert(i, t.from(u)));
|
|
5409
5422
|
}
|
|
5410
5423
|
}
|
|
5411
|
-
function
|
|
5412
|
-
switch (
|
|
5424
|
+
function Dr(e, t, n) {
|
|
5425
|
+
switch (wr(t)) {
|
|
5413
5426
|
case "image": return e.nodes.image?.create({
|
|
5414
5427
|
src: n,
|
|
5415
5428
|
alt: t.name
|
|
@@ -5435,7 +5448,7 @@ function Er(e, t, n) {
|
|
|
5435
5448
|
}
|
|
5436
5449
|
}
|
|
5437
5450
|
}
|
|
5438
|
-
async function
|
|
5451
|
+
async function Or(e, t, n) {
|
|
5439
5452
|
let r;
|
|
5440
5453
|
try {
|
|
5441
5454
|
r = o();
|
|
@@ -5454,13 +5467,13 @@ async function Dr(e, t, n) {
|
|
|
5454
5467
|
return console.error(`${t.type} upload failed:`, e), URL.revokeObjectURL(n), null;
|
|
5455
5468
|
}
|
|
5456
5469
|
}
|
|
5457
|
-
async function
|
|
5458
|
-
let i = r ?
|
|
5470
|
+
async function kr(e, t, n, r) {
|
|
5471
|
+
let i = r ? un(r) : void 0, a = i ? dn(e.state.doc, t, i) : null;
|
|
5459
5472
|
if (a) {
|
|
5460
5473
|
Z(a);
|
|
5461
5474
|
return;
|
|
5462
5475
|
}
|
|
5463
|
-
let o = URL.createObjectURL(t), s =
|
|
5476
|
+
let o = URL.createObjectURL(t), s = Dr(e.state.schema, t, o);
|
|
5464
5477
|
if (!s) return;
|
|
5465
5478
|
let c = n ?? e.state.selection.from;
|
|
5466
5479
|
try {
|
|
@@ -5468,9 +5481,9 @@ async function Or(e, t, n, r) {
|
|
|
5468
5481
|
} catch {
|
|
5469
5482
|
return;
|
|
5470
5483
|
}
|
|
5471
|
-
await
|
|
5484
|
+
await Or(e, t, o);
|
|
5472
5485
|
}
|
|
5473
|
-
var
|
|
5486
|
+
var Ar = R.create({
|
|
5474
5487
|
name: "imageUpload",
|
|
5475
5488
|
addOptions() {
|
|
5476
5489
|
return {
|
|
@@ -5491,23 +5504,23 @@ var kr = R.create({
|
|
|
5491
5504
|
left: n.clientX,
|
|
5492
5505
|
top: n.clientY
|
|
5493
5506
|
});
|
|
5494
|
-
for (let n of Array.from(r))
|
|
5507
|
+
for (let n of Array.from(r)) Tr(n) ? Er(t, n, i?.pos, e) : kr(t, n, i?.pos, e);
|
|
5495
5508
|
return !0;
|
|
5496
5509
|
},
|
|
5497
5510
|
handlePaste(t, n) {
|
|
5498
5511
|
let r = n.clipboardData?.items;
|
|
5499
5512
|
if (!r) return !1;
|
|
5500
5513
|
let i = n.clipboardData?.getData("text/plain") || "";
|
|
5501
|
-
if ((n.clipboardData?.files?.length ?? 0) > 0 &&
|
|
5514
|
+
if ((n.clipboardData?.files?.length ?? 0) > 0 && Cr(i, void 0, a())) return !1;
|
|
5502
5515
|
for (let i of Array.from(r)) {
|
|
5503
5516
|
if (i.type.startsWith("image/") || i.type.startsWith("video/") || i.type.startsWith("audio/")) {
|
|
5504
5517
|
n.preventDefault();
|
|
5505
5518
|
let r = i.getAsFile();
|
|
5506
|
-
return r &&
|
|
5519
|
+
return r && wr(r) !== "file" && kr(t, r, void 0, e), !0;
|
|
5507
5520
|
}
|
|
5508
5521
|
if (i.kind === "file") {
|
|
5509
5522
|
let r = i.getAsFile();
|
|
5510
|
-
if (r &&
|
|
5523
|
+
if (r && Tr(r)) return n.preventDefault(), Er(t, r, void 0, e), !0;
|
|
5511
5524
|
}
|
|
5512
5525
|
}
|
|
5513
5526
|
return !1;
|
|
@@ -5515,7 +5528,7 @@ var kr = R.create({
|
|
|
5515
5528
|
}
|
|
5516
5529
|
})];
|
|
5517
5530
|
}
|
|
5518
|
-
}),
|
|
5531
|
+
}), jr = 100, Mr = R.create({
|
|
5519
5532
|
name: "imeCommitSpaceGuard",
|
|
5520
5533
|
addProseMirrorPlugins() {
|
|
5521
5534
|
let e = 0;
|
|
@@ -5530,30 +5543,30 @@ var kr = R.create({
|
|
|
5530
5543
|
},
|
|
5531
5544
|
beforeinput(t, n) {
|
|
5532
5545
|
let r = n;
|
|
5533
|
-
return r.inputType !== "insertText" || r.data !== " " || r.isComposing || performance.now() - e >
|
|
5546
|
+
return r.inputType !== "insertText" || r.data !== " " || r.isComposing || performance.now() - e > jr ? !1 : (r.preventDefault(), !0);
|
|
5534
5547
|
}
|
|
5535
5548
|
} }
|
|
5536
5549
|
})];
|
|
5537
5550
|
}
|
|
5538
|
-
}),
|
|
5539
|
-
function
|
|
5551
|
+
}), Nr = /\.(png|jpe?g|gif|webp|bmp|svg|avif)(\?|#|$)/i, Pr = /\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|#|$)/i, Fr = /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|#|$)/i;
|
|
5552
|
+
function Ir(e) {
|
|
5540
5553
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
5541
5554
|
}
|
|
5542
|
-
function
|
|
5555
|
+
function Lr(e) {
|
|
5543
5556
|
let t = e.trim().replace(/\\/g, "/");
|
|
5544
5557
|
return t.split("/").pop() || t;
|
|
5545
5558
|
}
|
|
5546
|
-
function
|
|
5559
|
+
function Rr(e, t) {
|
|
5547
5560
|
let n = e.src.slice(e.pos), r = /^!\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !0;
|
|
5548
5561
|
if (r || (r = /^\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !1), !r) return !1;
|
|
5549
5562
|
let a = r[1].trim(), o = r[2]?.trim();
|
|
5550
5563
|
if (!t) {
|
|
5551
|
-
let t = o ||
|
|
5564
|
+
let t = o || Lr(a);
|
|
5552
5565
|
if (i) {
|
|
5553
5566
|
let n = "";
|
|
5554
|
-
if (
|
|
5555
|
-
else if (
|
|
5556
|
-
else if (
|
|
5567
|
+
if (Nr.test(a) || /^data:image\//i.test(a)) n = `<img src="${Ir(a)}" alt="${Ir(t)}">`;
|
|
5568
|
+
else if (Pr.test(a) || /^data:video\//i.test(a)) n = `<div data-video-embed src="${Ir(a)}"></div>`;
|
|
5569
|
+
else if (Fr.test(a) || /^data:audio\//i.test(a)) n = `<audio src="${Ir(a)}"></audio>`;
|
|
5557
5570
|
else {
|
|
5558
5571
|
let n = e.push("link_open", "a", 1);
|
|
5559
5572
|
n.attrs = [["href", a]];
|
|
@@ -5571,14 +5584,14 @@ function Lr(e, t) {
|
|
|
5571
5584
|
}
|
|
5572
5585
|
return e.pos += r[0].length, !0;
|
|
5573
5586
|
}
|
|
5574
|
-
var
|
|
5587
|
+
var zr = R.create({
|
|
5575
5588
|
name: "obsidianMarkdown",
|
|
5576
5589
|
addStorage() {
|
|
5577
5590
|
return { markdown: { parse: { setup(e) {
|
|
5578
|
-
e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed",
|
|
5591
|
+
e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed", Rr));
|
|
5579
5592
|
} } } };
|
|
5580
5593
|
}
|
|
5581
|
-
}),
|
|
5594
|
+
}), Br = R.create({
|
|
5582
5595
|
name: "qingwuUI",
|
|
5583
5596
|
addStorage() {
|
|
5584
5597
|
return {};
|
|
@@ -5586,7 +5599,7 @@ var Rr = R.create({
|
|
|
5586
5599
|
});
|
|
5587
5600
|
//#endregion
|
|
5588
5601
|
//#region src/editor/utils/render-probe.ts
|
|
5589
|
-
function
|
|
5602
|
+
function Vr(e, t) {
|
|
5590
5603
|
return new Promise((n) => {
|
|
5591
5604
|
if (typeof Image != "function") return n(!0);
|
|
5592
5605
|
let r = new Image(), i = !1, a = setTimeout(() => o(!1), t), o = (e) => {
|
|
@@ -5595,14 +5608,14 @@ function Br(e, t) {
|
|
|
5595
5608
|
r.onload = () => o(!0), r.onerror = () => o(!1), r.src = e;
|
|
5596
5609
|
});
|
|
5597
5610
|
}
|
|
5598
|
-
async function
|
|
5599
|
-
if (await
|
|
5611
|
+
async function Hr(e, t = 8e3) {
|
|
5612
|
+
if (await Vr(e, t)) return !0;
|
|
5600
5613
|
try {
|
|
5601
5614
|
let r = await n(e);
|
|
5602
5615
|
if (!r) return !1;
|
|
5603
5616
|
let i = await fetch(e, { headers: r });
|
|
5604
5617
|
if (!i.ok) return !1;
|
|
5605
|
-
let a = URL.createObjectURL(await i.blob()), o = await
|
|
5618
|
+
let a = URL.createObjectURL(await i.blob()), o = await Vr(a, t);
|
|
5606
5619
|
return URL.revokeObjectURL(a), o;
|
|
5607
5620
|
} catch {
|
|
5608
5621
|
return !1;
|
|
@@ -5610,7 +5623,7 @@ async function Vr(e, t = 8e3) {
|
|
|
5610
5623
|
}
|
|
5611
5624
|
//#endregion
|
|
5612
5625
|
//#region src/editor/utils/resolve-local-media.ts
|
|
5613
|
-
function
|
|
5626
|
+
function Ur() {
|
|
5614
5627
|
return {
|
|
5615
5628
|
uploaded: 0,
|
|
5616
5629
|
sessionOnly: 0,
|
|
@@ -5620,10 +5633,10 @@ function Hr() {
|
|
|
5620
5633
|
readFailed: []
|
|
5621
5634
|
};
|
|
5622
5635
|
}
|
|
5623
|
-
function
|
|
5636
|
+
function Wr(e, t) {
|
|
5624
5637
|
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);
|
|
5625
5638
|
}
|
|
5626
|
-
function
|
|
5639
|
+
function Gr(e, t, n, r) {
|
|
5627
5640
|
let { state: i } = e, a = [];
|
|
5628
5641
|
if (i.doc.descendants((e, n) => {
|
|
5629
5642
|
e.attrs?.src === t && a.push(n);
|
|
@@ -5639,7 +5652,7 @@ function Wr(e, t, n, r) {
|
|
|
5639
5652
|
}
|
|
5640
5653
|
return e.dispatch(o), !0;
|
|
5641
5654
|
}
|
|
5642
|
-
function
|
|
5655
|
+
function Kr(e, t, n) {
|
|
5643
5656
|
let { state: r } = e, i = r.schema.marks.link;
|
|
5644
5657
|
if (!i) return !1;
|
|
5645
5658
|
let a = [];
|
|
@@ -5657,7 +5670,7 @@ function Gr(e, t, n) {
|
|
|
5657
5670
|
}));
|
|
5658
5671
|
return e.dispatch(o), !0;
|
|
5659
5672
|
}
|
|
5660
|
-
function
|
|
5673
|
+
function qr(e) {
|
|
5661
5674
|
let t = /* @__PURE__ */ new Map();
|
|
5662
5675
|
for (let n of e) {
|
|
5663
5676
|
let e = t.get(n.normalized);
|
|
@@ -5665,36 +5678,36 @@ function Kr(e) {
|
|
|
5665
5678
|
}
|
|
5666
5679
|
return Array.from(t.values());
|
|
5667
5680
|
}
|
|
5668
|
-
async function
|
|
5681
|
+
async function Jr(e, t, n, r) {
|
|
5669
5682
|
if (n.length === 0) return "sessionOnly";
|
|
5670
|
-
let i = n[0], a =
|
|
5683
|
+
let i = n[0], a = un(t);
|
|
5671
5684
|
if (a) {
|
|
5672
|
-
let t =
|
|
5685
|
+
let t = dn(e.state.doc, r, a);
|
|
5673
5686
|
if (t) return Z(`${i.basename}:${t}`, "error"), "limitRejected";
|
|
5674
5687
|
}
|
|
5675
5688
|
let s = n.filter((e) => !e.isLink), c = n.filter((e) => e.isLink);
|
|
5676
5689
|
if (s.length === 0) try {
|
|
5677
5690
|
let t = await o().upload(r, "editor"), n = !1;
|
|
5678
|
-
for (let r of c)
|
|
5691
|
+
for (let r of c) Kr(e, r.src, t) && (n = !0);
|
|
5679
5692
|
return n ? "uploaded" : "sessionOnly";
|
|
5680
5693
|
} catch (e) {
|
|
5681
5694
|
return console.error(`本地附件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), "sessionOnly";
|
|
5682
5695
|
}
|
|
5683
5696
|
let l = URL.createObjectURL(r), u = !1;
|
|
5684
|
-
for (let t of s)
|
|
5697
|
+
for (let t of s) Gr(e, t.src, l, r.size) && (u = !0);
|
|
5685
5698
|
let d;
|
|
5686
5699
|
try {
|
|
5687
5700
|
d = await o().upload(r, "editor");
|
|
5688
5701
|
} catch (e) {
|
|
5689
5702
|
return console.error(`本地文件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), URL.revokeObjectURL(l), "sessionOnly";
|
|
5690
5703
|
}
|
|
5691
|
-
URL.revokeObjectURL(l), u &&
|
|
5692
|
-
for (let t of c)
|
|
5693
|
-
return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await
|
|
5704
|
+
URL.revokeObjectURL(l), u && Gr(e, l, d, r.size);
|
|
5705
|
+
for (let t of c) Kr(e, t.src, d);
|
|
5706
|
+
return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await Hr(d) ? "uploaded" : "renderFailed" : "uploaded";
|
|
5694
5707
|
}
|
|
5695
|
-
function
|
|
5708
|
+
function Yr(e, t) {
|
|
5696
5709
|
let n = [], r = [];
|
|
5697
|
-
for (let i of
|
|
5710
|
+
for (let i of qr(e)) {
|
|
5698
5711
|
let e = i[0], a = t.get(e.basename);
|
|
5699
5712
|
a ? (n.push({
|
|
5700
5713
|
refs: i,
|
|
@@ -5706,30 +5719,30 @@ function Jr(e, t) {
|
|
|
5706
5719
|
unmatched: r
|
|
5707
5720
|
};
|
|
5708
5721
|
}
|
|
5709
|
-
async function
|
|
5710
|
-
let i =
|
|
5711
|
-
for (let a of
|
|
5712
|
-
let n = a[0], { file: o, readError: s } = await
|
|
5722
|
+
async function Xr(e, t, n, r) {
|
|
5723
|
+
let i = Ur();
|
|
5724
|
+
for (let a of qr(n)) {
|
|
5725
|
+
let n = a[0], { file: o, readError: s } = await br(r, n.src);
|
|
5713
5726
|
if (!o) {
|
|
5714
5727
|
s ? (console.warn(`本地文件「${n.basename}」在所选文件夹中找到但读取失败:`, s), i.readFailed.push(n)) : (console.warn(`本地文件「${n.basename}」未在所选文件夹「${r.name}」中找到`), i.missing.push(n));
|
|
5715
5728
|
continue;
|
|
5716
5729
|
}
|
|
5717
|
-
let c = await
|
|
5730
|
+
let c = await Jr(e, t, a, o);
|
|
5718
5731
|
i[c]++;
|
|
5719
5732
|
}
|
|
5720
5733
|
return i;
|
|
5721
5734
|
}
|
|
5722
|
-
function
|
|
5735
|
+
function Zr(e) {
|
|
5723
5736
|
let t = e.map((e) => e.basename);
|
|
5724
5737
|
return t.length <= 3 ? t.join("、") : `${t.slice(0, 3).join("、")} 等 ${t.length} 个文件`;
|
|
5725
5738
|
}
|
|
5726
|
-
function
|
|
5739
|
+
function Qr(e) {
|
|
5727
5740
|
let t = [];
|
|
5728
|
-
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} 个找到但读取失败:${
|
|
5741
|
+
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} 个找到但读取失败:${Zr(e.readFailed)}(若在 OneDrive / WPS 云盘等同步目录,请右键文件选择「始终保留在此设备」后重试)`), e.missing.length > 0 && t.push(`${e.missing.length} 个未能获取:${Zr(e.missing)}(可把文件直接拖进编辑器上传)`), t.length === 0) return;
|
|
5729
5742
|
let n = e.uploaded > 0 && e.renderFailed === 0 && e.missing.length === 0 && e.readFailed.length === 0;
|
|
5730
5743
|
Z(`本地文件解析完成:${t.join(";")}`, n ? "success" : "info");
|
|
5731
5744
|
}
|
|
5732
|
-
function
|
|
5745
|
+
function $r(e) {
|
|
5733
5746
|
return new Promise((t) => {
|
|
5734
5747
|
let n = document.createElement("div");
|
|
5735
5748
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5756,7 +5769,7 @@ function Qr(e) {
|
|
|
5756
5769
|
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);
|
|
5757
5770
|
});
|
|
5758
5771
|
}
|
|
5759
|
-
function
|
|
5772
|
+
function ei(e) {
|
|
5760
5773
|
let t = document.createElement("div");
|
|
5761
5774
|
t.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
5762
5775
|
let n = document.createElement("div");
|
|
@@ -5778,7 +5791,7 @@ function $r(e) {
|
|
|
5778
5791
|
let c = document.createElement("button");
|
|
5779
5792
|
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);
|
|
5780
5793
|
}
|
|
5781
|
-
function
|
|
5794
|
+
function ti(e) {
|
|
5782
5795
|
return new Promise((t) => {
|
|
5783
5796
|
let n = document.createElement("div");
|
|
5784
5797
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5804,8 +5817,8 @@ function ei(e) {
|
|
|
5804
5817
|
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);
|
|
5805
5818
|
});
|
|
5806
5819
|
}
|
|
5807
|
-
async function
|
|
5808
|
-
let r =
|
|
5820
|
+
async function ni(e, t, n) {
|
|
5821
|
+
let r = Ur(), i = qr(n), a = await _r();
|
|
5809
5822
|
if (!a) {
|
|
5810
5823
|
for (let e of i) r.missing.push(e[0]);
|
|
5811
5824
|
return r;
|
|
@@ -5818,14 +5831,14 @@ async function ti(e, t, n) {
|
|
|
5818
5831
|
continue;
|
|
5819
5832
|
}
|
|
5820
5833
|
o.delete(i.basename);
|
|
5821
|
-
let s = await
|
|
5834
|
+
let s = await Jr(e, t, n, a);
|
|
5822
5835
|
r[s]++;
|
|
5823
5836
|
}
|
|
5824
5837
|
return r;
|
|
5825
5838
|
}
|
|
5826
5839
|
//#endregion
|
|
5827
5840
|
//#region src/editor/extensions/relative-media.ts
|
|
5828
|
-
var
|
|
5841
|
+
var ri = R.create({
|
|
5829
5842
|
name: "relativeMedia",
|
|
5830
5843
|
addStorage() {
|
|
5831
5844
|
return {
|
|
@@ -5835,38 +5848,38 @@ var ni = R.create({
|
|
|
5835
5848
|
},
|
|
5836
5849
|
addProseMirrorPlugins() {
|
|
5837
5850
|
let e = this.editor, t = this.storage, n = !1, r = null, i = async (n, i) => {
|
|
5838
|
-
let a = e.view, o =
|
|
5851
|
+
let a = e.view, o = Ur(), { matched: s, unmatched: c } = Yr(n, t.clipboardFiles);
|
|
5839
5852
|
for (let { refs: t, file: n } of s) {
|
|
5840
|
-
let r = await
|
|
5853
|
+
let r = await Jr(a, e, t, n);
|
|
5841
5854
|
o[r]++;
|
|
5842
5855
|
}
|
|
5843
5856
|
if (c.length > 0) {
|
|
5844
|
-
let t =
|
|
5845
|
-
if (
|
|
5857
|
+
let t = qr(c).length;
|
|
5858
|
+
if (mr()) {
|
|
5846
5859
|
let n = i ?? null;
|
|
5847
|
-
if (n || (await
|
|
5848
|
-
r = n,
|
|
5860
|
+
if (n || (await $r(t) === "pick" ? (n = await hr(), n || Z("没有选择文件夹。本地文件暂以占位显示,稍后可直接把文件拖进编辑器上传", "info")) : Z("已选择稍后处理。本地文件暂以占位显示,可直接把文件拖进编辑器上传", "info")), n) {
|
|
5861
|
+
r = n, Wr(o, await Xr(a, e, c, n));
|
|
5849
5862
|
let t = [...o.missing, ...o.readFailed];
|
|
5850
|
-
if (t.length > 0 &&
|
|
5851
|
-
let n = await
|
|
5852
|
-
|
|
5863
|
+
if (t.length > 0 && gr() && await ti(t.map((e) => e.basename)) === "pick") {
|
|
5864
|
+
let n = await ni(a, e, t);
|
|
5865
|
+
Wr(o, n), o.missing = n.missing, o.readFailed = [];
|
|
5853
5866
|
}
|
|
5854
5867
|
}
|
|
5855
|
-
} else
|
|
5868
|
+
} else ei(t);
|
|
5856
5869
|
}
|
|
5857
|
-
|
|
5870
|
+
Qr(o);
|
|
5858
5871
|
}, o = () => {
|
|
5859
5872
|
if (!e || e.isDestroyed || t.pausedUntilPaste) return;
|
|
5860
|
-
let o = a(), s =
|
|
5873
|
+
let o = a(), s = Sr(e.state.doc, o);
|
|
5861
5874
|
if (s.length === 0 || n) return;
|
|
5862
5875
|
n = !0;
|
|
5863
5876
|
let c = new Set(s.map((e) => e.src));
|
|
5864
5877
|
i(s).then(() => {
|
|
5865
5878
|
if (e.isDestroyed) return;
|
|
5866
|
-
let t =
|
|
5879
|
+
let t = Sr(e.state.doc, o).filter((e) => !c.has(e.src));
|
|
5867
5880
|
if (t.length !== 0) return i(t, r);
|
|
5868
5881
|
}).finally(() => {
|
|
5869
|
-
n = !1, !(!e || e.isDestroyed) && (t.pausedUntilPaste =
|
|
5882
|
+
n = !1, !(!e || e.isDestroyed) && (t.pausedUntilPaste = Sr(e.state.doc, o).length > 0);
|
|
5870
5883
|
});
|
|
5871
5884
|
};
|
|
5872
5885
|
return [new z({
|
|
@@ -5880,14 +5893,14 @@ var ni = R.create({
|
|
|
5880
5893
|
}
|
|
5881
5894
|
})];
|
|
5882
5895
|
}
|
|
5883
|
-
}),
|
|
5884
|
-
function
|
|
5896
|
+
}), ii = new B("slashCommand");
|
|
5897
|
+
function ai(e) {
|
|
5885
5898
|
return R.create({
|
|
5886
5899
|
name: "slashCommand",
|
|
5887
5900
|
addProseMirrorPlugins() {
|
|
5888
5901
|
let t = {
|
|
5889
5902
|
char: "/",
|
|
5890
|
-
pluginKey:
|
|
5903
|
+
pluginKey: ii,
|
|
5891
5904
|
findSuggestionMatch: (e) => {
|
|
5892
5905
|
let { $position: t } = e;
|
|
5893
5906
|
for (let e = t.depth; e >= 0; e--) if (t.node(e).type.name === "codeBlock") return null;
|
|
@@ -5973,7 +5986,7 @@ function ii(e) {
|
|
|
5973
5986
|
if (e.key === "Escape") {
|
|
5974
5987
|
e.preventDefault();
|
|
5975
5988
|
let t = a?.view;
|
|
5976
|
-
t && Ce(t,
|
|
5989
|
+
t && Ce(t, ii);
|
|
5977
5990
|
}
|
|
5978
5991
|
});
|
|
5979
5992
|
}
|
|
@@ -5991,7 +6004,7 @@ function ii(e) {
|
|
|
5991
6004
|
if (!e || e.style.display === "none" || n.target instanceof Node && e.contains(n.target) || t) return;
|
|
5992
6005
|
let r = a?.view;
|
|
5993
6006
|
r && (t = !0, window.setTimeout(() => {
|
|
5994
|
-
t = !1, e?.style.display !== "none" && Ce(r,
|
|
6007
|
+
t = !1, e?.style.display !== "none" && Ce(r, ii);
|
|
5995
6008
|
}, 0));
|
|
5996
6009
|
}, document.addEventListener("mousedown", o, !0), document.addEventListener("touchstart", o, !0);
|
|
5997
6010
|
}
|
|
@@ -6027,14 +6040,14 @@ function ii(e) {
|
|
|
6027
6040
|
break;
|
|
6028
6041
|
}
|
|
6029
6042
|
if (!i && !r.marks().some((e) => e.type.name === "code")) return null;
|
|
6030
|
-
let a =
|
|
6031
|
-
return a && a.active ? n.tr.setMeta(
|
|
6043
|
+
let a = ii.getState(n);
|
|
6044
|
+
return a && a.active ? n.tr.setMeta(ii, { exit: !0 }) : null;
|
|
6032
6045
|
}
|
|
6033
6046
|
})];
|
|
6034
6047
|
}
|
|
6035
6048
|
});
|
|
6036
6049
|
}
|
|
6037
|
-
function
|
|
6050
|
+
function oi(e, t) {
|
|
6038
6051
|
return [
|
|
6039
6052
|
{
|
|
6040
6053
|
title: e("editor.slash.heading1"),
|
|
@@ -6133,7 +6146,7 @@ function ai(e, t) {
|
|
|
6133
6146
|
n.type = "file", n.accept = "audio/*", n.onchange = async () => {
|
|
6134
6147
|
let r = n.files?.[0];
|
|
6135
6148
|
if (!r) return;
|
|
6136
|
-
let i =
|
|
6149
|
+
let i = un(e) ?? t, a = i ? dn(e.state.doc, r, i) : null;
|
|
6137
6150
|
if (a) {
|
|
6138
6151
|
Z(a);
|
|
6139
6152
|
return;
|
|
@@ -6143,7 +6156,7 @@ function ai(e, t) {
|
|
|
6143
6156
|
name: r.name,
|
|
6144
6157
|
size: r.size
|
|
6145
6158
|
});
|
|
6146
|
-
s && (e.chain().focus().insertContent(s).run(), await
|
|
6159
|
+
s && (e.chain().focus().insertContent(s).run(), await Or(e.view, r, o));
|
|
6147
6160
|
}, n.click();
|
|
6148
6161
|
}
|
|
6149
6162
|
},
|
|
@@ -6156,7 +6169,7 @@ function ai(e, t) {
|
|
|
6156
6169
|
n.type = "file", n.accept = "*/*", n.multiple = !0, n.onchange = async () => {
|
|
6157
6170
|
let r = n.files;
|
|
6158
6171
|
if (!(!r || r.length === 0)) for (let n of Array.from(r)) {
|
|
6159
|
-
let r =
|
|
6172
|
+
let r = un(e) ?? t, i = r ? dn(e.state.doc, n, r) : null;
|
|
6160
6173
|
if (i) {
|
|
6161
6174
|
Z(i);
|
|
6162
6175
|
continue;
|
|
@@ -6173,7 +6186,7 @@ function ai(e, t) {
|
|
|
6173
6186
|
} catch {
|
|
6174
6187
|
continue;
|
|
6175
6188
|
}
|
|
6176
|
-
await
|
|
6189
|
+
await Or(e.view, n, a);
|
|
6177
6190
|
}
|
|
6178
6191
|
}
|
|
6179
6192
|
}, n.click();
|
|
@@ -6183,9 +6196,9 @@ function ai(e, t) {
|
|
|
6183
6196
|
}
|
|
6184
6197
|
//#endregion
|
|
6185
6198
|
//#region src/editor/extensions/index.ts
|
|
6186
|
-
var
|
|
6199
|
+
var si = oe.extend({
|
|
6187
6200
|
addNodeView() {
|
|
6188
|
-
return I(
|
|
6201
|
+
return I(Sn);
|
|
6189
6202
|
},
|
|
6190
6203
|
addAttributes() {
|
|
6191
6204
|
return {
|
|
@@ -6208,7 +6221,7 @@ var oi = oe.extend({
|
|
|
6208
6221
|
};
|
|
6209
6222
|
}
|
|
6210
6223
|
});
|
|
6211
|
-
function
|
|
6224
|
+
function ci(e = {}) {
|
|
6212
6225
|
return [
|
|
6213
6226
|
G.configure({
|
|
6214
6227
|
codeBlock: !1,
|
|
@@ -6224,7 +6237,7 @@ function si(e = {}) {
|
|
|
6224
6237
|
target: "_blank"
|
|
6225
6238
|
}
|
|
6226
6239
|
}),
|
|
6227
|
-
|
|
6240
|
+
si.configure({
|
|
6228
6241
|
inline: !1,
|
|
6229
6242
|
allowBase64: !0
|
|
6230
6243
|
}),
|
|
@@ -6235,7 +6248,7 @@ function si(e = {}) {
|
|
|
6235
6248
|
q,
|
|
6236
6249
|
K.configure(e.maxLength ? { limit: e.maxLength } : {}),
|
|
6237
6250
|
ce,
|
|
6238
|
-
|
|
6251
|
+
or,
|
|
6239
6252
|
ue.configure({ resizable: !0 }),
|
|
6240
6253
|
pe,
|
|
6241
6254
|
de,
|
|
@@ -6246,74 +6259,74 @@ function si(e = {}) {
|
|
|
6246
6259
|
transformCopiedText: !1
|
|
6247
6260
|
}),
|
|
6248
6261
|
le.configure({ placeholder: e.placeholder || "输入 '/' 打开菜单…" }),
|
|
6249
|
-
|
|
6262
|
+
ai(() => oi((e) => f(e), {
|
|
6250
6263
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
6251
6264
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
6252
6265
|
})),
|
|
6253
|
-
|
|
6266
|
+
Ar.configure({
|
|
6254
6267
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
6255
6268
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
6256
6269
|
}),
|
|
6257
|
-
|
|
6258
|
-
Rr,
|
|
6259
|
-
Et,
|
|
6260
|
-
jr,
|
|
6270
|
+
ri,
|
|
6261
6271
|
zr,
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6272
|
+
Dt,
|
|
6273
|
+
Mr,
|
|
6274
|
+
Br,
|
|
6275
|
+
qn,
|
|
6276
|
+
Bn,
|
|
6277
|
+
Ln
|
|
6265
6278
|
];
|
|
6266
6279
|
}
|
|
6267
6280
|
//#endregion
|
|
6268
6281
|
//#region src/editor/extensions/bubble-menu.tsx
|
|
6269
|
-
var
|
|
6270
|
-
function
|
|
6271
|
-
|
|
6282
|
+
var li = "https://www.bing.com/search?q={query}";
|
|
6283
|
+
function ui(e) {
|
|
6284
|
+
li = e;
|
|
6272
6285
|
}
|
|
6273
|
-
function
|
|
6274
|
-
return
|
|
6286
|
+
function di() {
|
|
6287
|
+
return li;
|
|
6275
6288
|
}
|
|
6276
|
-
function
|
|
6289
|
+
function fi(e) {
|
|
6277
6290
|
return [
|
|
6278
6291
|
{
|
|
6279
6292
|
key: "bold",
|
|
6280
6293
|
label: e("editor.bubble.bold"),
|
|
6281
|
-
icon: /* @__PURE__ */ D(
|
|
6294
|
+
icon: /* @__PURE__ */ D(At, {}),
|
|
6282
6295
|
isActive: (e) => e.isActive("bold"),
|
|
6283
6296
|
command: (e) => e.isEditable && e.chain().focus().toggleBold().run()
|
|
6284
6297
|
},
|
|
6285
6298
|
{
|
|
6286
6299
|
key: "italic",
|
|
6287
6300
|
label: e("editor.bubble.italic"),
|
|
6288
|
-
icon: /* @__PURE__ */ D(
|
|
6301
|
+
icon: /* @__PURE__ */ D(jt, {}),
|
|
6289
6302
|
isActive: (e) => e.isActive("italic"),
|
|
6290
6303
|
command: (e) => e.isEditable && e.chain().focus().toggleItalic().run()
|
|
6291
6304
|
},
|
|
6292
6305
|
{
|
|
6293
6306
|
key: "underline",
|
|
6294
6307
|
label: e("editor.bubble.underline"),
|
|
6295
|
-
icon: /* @__PURE__ */ D(
|
|
6308
|
+
icon: /* @__PURE__ */ D(Mt, {}),
|
|
6296
6309
|
isActive: (e) => e.isActive("underline"),
|
|
6297
6310
|
command: (e) => e.isEditable && e.chain().focus().toggleUnderline().run()
|
|
6298
6311
|
},
|
|
6299
6312
|
{
|
|
6300
6313
|
key: "strikethrough",
|
|
6301
6314
|
label: e("editor.bubble.strikethrough"),
|
|
6302
|
-
icon: /* @__PURE__ */ D(
|
|
6315
|
+
icon: /* @__PURE__ */ D(Nt, {}),
|
|
6303
6316
|
isActive: (e) => e.isActive("strike"),
|
|
6304
6317
|
command: (e) => e.isEditable && e.chain().focus().toggleStrike().run()
|
|
6305
6318
|
},
|
|
6306
6319
|
{
|
|
6307
6320
|
key: "code",
|
|
6308
6321
|
label: e("editor.bubble.emphasis"),
|
|
6309
|
-
icon: /* @__PURE__ */ D(
|
|
6322
|
+
icon: /* @__PURE__ */ D(Pt, {}),
|
|
6310
6323
|
isActive: (e) => e.isActive("code"),
|
|
6311
6324
|
command: (e) => e.isEditable && e.chain().focus().toggleCode().run()
|
|
6312
6325
|
},
|
|
6313
6326
|
{
|
|
6314
6327
|
key: "highlight",
|
|
6315
6328
|
label: e("editor.bubble.highlight"),
|
|
6316
|
-
icon: /* @__PURE__ */ D(
|
|
6329
|
+
icon: /* @__PURE__ */ D(Ft, {}),
|
|
6317
6330
|
more: !0,
|
|
6318
6331
|
isActive: (e) => e.isActive("highlight"),
|
|
6319
6332
|
command: () => {}
|
|
@@ -6321,7 +6334,7 @@ function di(e) {
|
|
|
6321
6334
|
{
|
|
6322
6335
|
key: "link",
|
|
6323
6336
|
label: e("editor.bubble.link"),
|
|
6324
|
-
icon: /* @__PURE__ */ D(
|
|
6337
|
+
icon: /* @__PURE__ */ D(It, {}),
|
|
6325
6338
|
more: !0,
|
|
6326
6339
|
isActive: (e) => e.isActive("link"),
|
|
6327
6340
|
command: () => {}
|
|
@@ -6329,7 +6342,7 @@ function di(e) {
|
|
|
6329
6342
|
{
|
|
6330
6343
|
key: "copy",
|
|
6331
6344
|
label: e("editor.bubble.copy"),
|
|
6332
|
-
icon: /* @__PURE__ */ D(
|
|
6345
|
+
icon: /* @__PURE__ */ D(Rt, {}),
|
|
6333
6346
|
more: !0,
|
|
6334
6347
|
isActive: () => !1,
|
|
6335
6348
|
command: (e) => {
|
|
@@ -6340,21 +6353,21 @@ function di(e) {
|
|
|
6340
6353
|
{
|
|
6341
6354
|
key: "search",
|
|
6342
6355
|
label: e("editor.bubble.search"),
|
|
6343
|
-
icon: /* @__PURE__ */ D(
|
|
6356
|
+
icon: /* @__PURE__ */ D(zt, {}),
|
|
6344
6357
|
more: !0,
|
|
6345
6358
|
isActive: () => !1,
|
|
6346
6359
|
command: (e) => {
|
|
6347
6360
|
if (e.isActive("table")) return;
|
|
6348
6361
|
let { from: t, to: n } = e.state.selection, r = e.state.doc.textBetween(t, n, " ").trim();
|
|
6349
6362
|
if (!r) return;
|
|
6350
|
-
let i =
|
|
6363
|
+
let i = li.replace("{query}", encodeURIComponent(r));
|
|
6351
6364
|
window.open(i, "_blank", "noopener,noreferrer");
|
|
6352
6365
|
}
|
|
6353
6366
|
},
|
|
6354
6367
|
{
|
|
6355
6368
|
key: "table",
|
|
6356
6369
|
label: e("editor.bubble.table"),
|
|
6357
|
-
icon: /* @__PURE__ */ D(
|
|
6370
|
+
icon: /* @__PURE__ */ D(Lt, {}),
|
|
6358
6371
|
more: !0,
|
|
6359
6372
|
isActive: (e) => e.isActive("table"),
|
|
6360
6373
|
command: (e) => {
|
|
@@ -6370,7 +6383,7 @@ function di(e) {
|
|
|
6370
6383
|
{
|
|
6371
6384
|
key: "ai",
|
|
6372
6385
|
label: e("editor.ai.trigger"),
|
|
6373
|
-
icon: /* @__PURE__ */ D(
|
|
6386
|
+
icon: /* @__PURE__ */ D(Bt, {}),
|
|
6374
6387
|
isActive: () => !1,
|
|
6375
6388
|
command: (e) => {
|
|
6376
6389
|
e.isEditable && e.storage.qingwuUI?.openAI?.();
|
|
@@ -6381,7 +6394,7 @@ function di(e) {
|
|
|
6381
6394
|
R.create({ name: "bubbleMenu" });
|
|
6382
6395
|
//#endregion
|
|
6383
6396
|
//#region src/editor/extensions/table-toolbar.tsx
|
|
6384
|
-
function
|
|
6397
|
+
function pi(e) {
|
|
6385
6398
|
let { $from: t } = e.state.selection;
|
|
6386
6399
|
for (let e = t.depth; e > 0; e--) {
|
|
6387
6400
|
let n = t.node(e);
|
|
@@ -6392,7 +6405,7 @@ function fi(e) {
|
|
|
6392
6405
|
}
|
|
6393
6406
|
return null;
|
|
6394
6407
|
}
|
|
6395
|
-
function
|
|
6408
|
+
function mi(e) {
|
|
6396
6409
|
let t = [];
|
|
6397
6410
|
return e.forEach((e) => {
|
|
6398
6411
|
let n = [];
|
|
@@ -6401,7 +6414,7 @@ function pi(e) {
|
|
|
6401
6414
|
}), t.push(n);
|
|
6402
6415
|
}), t;
|
|
6403
6416
|
}
|
|
6404
|
-
function
|
|
6417
|
+
function hi(e) {
|
|
6405
6418
|
if (e.length === 0) return "";
|
|
6406
6419
|
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(" | ")} |`;
|
|
6407
6420
|
return [
|
|
@@ -6410,11 +6423,11 @@ function mi(e) {
|
|
|
6410
6423
|
...i.map(a)
|
|
6411
6424
|
].join("\n");
|
|
6412
6425
|
}
|
|
6413
|
-
function
|
|
6426
|
+
function gi(e) {
|
|
6414
6427
|
let t = (e) => /[",\n]/.test(e) ? `"${e.replace(/"/g, "\"\"")}"` : e;
|
|
6415
6428
|
return e.map((e) => e.map(t).join(",")).join("\n");
|
|
6416
6429
|
}
|
|
6417
|
-
function
|
|
6430
|
+
function _i(e) {
|
|
6418
6431
|
let t = e.trim();
|
|
6419
6432
|
if (!t) return null;
|
|
6420
6433
|
let n = t.split(/\r?\n/);
|
|
@@ -6428,7 +6441,7 @@ function gi(e) {
|
|
|
6428
6441
|
}
|
|
6429
6442
|
return null;
|
|
6430
6443
|
}
|
|
6431
|
-
function
|
|
6444
|
+
function vi({ editor: e }) {
|
|
6432
6445
|
let [t, n] = T(null), [r, i] = T(!1), [a, o] = T(!1), s = w(null), c = w(null), l = e.isEditable, u = b(() => {
|
|
6433
6446
|
c.current != null && cancelAnimationFrame(c.current), c.current = requestAnimationFrame(() => {
|
|
6434
6447
|
c.current = null;
|
|
@@ -6444,7 +6457,7 @@ function _i({ editor: e }) {
|
|
|
6444
6457
|
n(null);
|
|
6445
6458
|
return;
|
|
6446
6459
|
}
|
|
6447
|
-
let t =
|
|
6460
|
+
let t = pi(e);
|
|
6448
6461
|
if (!t) {
|
|
6449
6462
|
n(null);
|
|
6450
6463
|
return;
|
|
@@ -6473,24 +6486,24 @@ function _i({ editor: e }) {
|
|
|
6473
6486
|
});
|
|
6474
6487
|
return n.nodes.table.create(null, i);
|
|
6475
6488
|
}, p = () => {
|
|
6476
|
-
let t =
|
|
6489
|
+
let t = pi(e);
|
|
6477
6490
|
if (!t) return;
|
|
6478
|
-
let n = mi(
|
|
6491
|
+
let n = hi(mi(t.node));
|
|
6479
6492
|
navigator.clipboard?.writeText(n), i(!0), setTimeout(() => i(!1), 1500);
|
|
6480
6493
|
}, m = () => {
|
|
6481
|
-
let t =
|
|
6494
|
+
let t = pi(e);
|
|
6482
6495
|
if (!t) return;
|
|
6483
|
-
let n =
|
|
6496
|
+
let n = gi(mi(t.node)), r = new Blob([`\ufeff${n}`], { type: "text/csv;charset=utf-8" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
6484
6497
|
a.href = i, a.download = "table.csv", document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
6485
6498
|
}, h = async () => {
|
|
6486
6499
|
if (l) try {
|
|
6487
6500
|
let t = await navigator.clipboard?.readText();
|
|
6488
6501
|
if (!t) return;
|
|
6489
|
-
let n =
|
|
6502
|
+
let n = _i(t);
|
|
6490
6503
|
if (!n || n.length === 0) return;
|
|
6491
6504
|
let r = f(n);
|
|
6492
6505
|
if (!r) return;
|
|
6493
|
-
let i =
|
|
6506
|
+
let i = pi(e), a = e.chain().focus();
|
|
6494
6507
|
if (i) {
|
|
6495
6508
|
let t = Math.min(i.pos + i.node.nodeSize, e.state.doc.content.size);
|
|
6496
6509
|
a.setTextSelection(t);
|
|
@@ -6610,7 +6623,7 @@ function _i({ editor: e }) {
|
|
|
6610
6623
|
type: "button",
|
|
6611
6624
|
className: "tbl-btn tbl-btn--del",
|
|
6612
6625
|
onClick: () => {
|
|
6613
|
-
!l ||
|
|
6626
|
+
!l || hn() || ($(!0), o(!0));
|
|
6614
6627
|
},
|
|
6615
6628
|
title: "删除",
|
|
6616
6629
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -6628,7 +6641,7 @@ function _i({ editor: e }) {
|
|
|
6628
6641
|
})
|
|
6629
6642
|
})
|
|
6630
6643
|
}),
|
|
6631
|
-
/* @__PURE__ */ D(
|
|
6644
|
+
/* @__PURE__ */ D(bn, {
|
|
6632
6645
|
open: a,
|
|
6633
6646
|
title: "确认删除表格",
|
|
6634
6647
|
message: "此操作不可撤销。",
|
|
@@ -6644,7 +6657,7 @@ function _i({ editor: e }) {
|
|
|
6644
6657
|
}
|
|
6645
6658
|
//#endregion
|
|
6646
6659
|
//#region src/editor/ai-editor.tsx
|
|
6647
|
-
var
|
|
6660
|
+
var yi = [
|
|
6648
6661
|
{
|
|
6649
6662
|
color: "#fef08a",
|
|
6650
6663
|
name: "黄"
|
|
@@ -6669,9 +6682,9 @@ var vi = [
|
|
|
6669
6682
|
color: "#ddd6fe",
|
|
6670
6683
|
name: "紫"
|
|
6671
6684
|
}
|
|
6672
|
-
],
|
|
6673
|
-
function
|
|
6674
|
-
let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth ||
|
|
6685
|
+
], bi = 288, xi = 480, Si = 320;
|
|
6686
|
+
function Ci(e, t, n = {}) {
|
|
6687
|
+
let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth || bi, xi, r - 32), o = Math.max(t || Si, 160);
|
|
6675
6688
|
if (r < 640) {
|
|
6676
6689
|
let t = Math.max(8, Math.min(e.top + 10, i - 420));
|
|
6677
6690
|
return {
|
|
@@ -6712,10 +6725,10 @@ function Si(e, t, n = {}) {
|
|
|
6712
6725
|
arrowLeft: p
|
|
6713
6726
|
};
|
|
6714
6727
|
}
|
|
6715
|
-
function
|
|
6728
|
+
function wi(e) {
|
|
6716
6729
|
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*\|.+\|/i.test(e);
|
|
6717
6730
|
}
|
|
6718
|
-
function
|
|
6731
|
+
function Ti(e, t) {
|
|
6719
6732
|
try {
|
|
6720
6733
|
let n = e.storage?.markdown?.parser;
|
|
6721
6734
|
if (!n) return null;
|
|
@@ -6725,14 +6738,14 @@ function wi(e, t) {
|
|
|
6725
6738
|
return null;
|
|
6726
6739
|
}
|
|
6727
6740
|
}
|
|
6728
|
-
var
|
|
6741
|
+
var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.ImageUploadDialog }))), Di = y(() => import("./storage-settings-dialog-DZqqDAiO.js").then((e) => ({ default: e.StorageSettingsDialog }))), Oi = y(() => import("./export-dialog-CL7ie13Z.js").then((e) => ({ default: e.ExportDialog }))), ki = y(() => import("./video-embed-dialog-AeGcMb4X.js").then((e) => ({ default: e.VideoEmbedDialog }))), Ai = y(() => import("./md-import-dialog-Cf3ZOwA_.js").then((e) => ({ default: e.MdImportDialog }))), ji = () => /* @__PURE__ */ O("div", {
|
|
6729
6742
|
className: "fixed inset-0 z-[9999] flex items-center justify-center",
|
|
6730
6743
|
children: [/* @__PURE__ */ D("div", { className: "absolute inset-0 bg-black/40 backdrop-blur-sm" }), /* @__PURE__ */ D("div", {
|
|
6731
6744
|
className: "relative bg-background rounded-2xl border border-default-200 p-8 flex items-center justify-center",
|
|
6732
6745
|
children: /* @__PURE__ */ D("div", { className: "w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin" })
|
|
6733
6746
|
})]
|
|
6734
|
-
}),
|
|
6735
|
-
let k = r === "view" || i, A = C(() => typeof e == "object" && e ||
|
|
6747
|
+
}), Mi = ({ initialContent: e = "", onChange: t, placeholder: n, mode: r, readonly: i = !1, maxLength: a, maxAttachmentSize: o, maxTotalAttachmentSize: s, className: c = "", borderless: l = !1, style: u, showToolbar: p = !0, showToc: m = !0, showSearch: h = !0, onEditorReady: g, immediatelyRender: _, onToast: y }) => {
|
|
6748
|
+
let k = r === "view" || i, A = C(() => typeof e == "object" && e || wi(e) ? e : d(e), [e]), [j, M] = T(!1), [F, I] = T({}), [L, R] = T("below"), [re, ie] = T(50), z = w(null), [B, V] = T(!1), [H, ae] = T(!1), [oe, U] = T(!1), [W, G] = T(!1), [K, q] = T("none"), [se, ce] = T({}), [le, ue] = T(""), [de, fe] = T(null), [pe, me] = T(m), [he, ge] = T(!1);
|
|
6736
6749
|
x(() => {
|
|
6737
6750
|
me(m);
|
|
6738
6751
|
}, [m]);
|
|
@@ -6807,7 +6820,7 @@ var Ti = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6807
6820
|
return Se(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
6808
6821
|
}, []);
|
|
6809
6822
|
let X = ee({
|
|
6810
|
-
extensions:
|
|
6823
|
+
extensions: ci({
|
|
6811
6824
|
placeholder: n || f("editor.placeholder"),
|
|
6812
6825
|
maxLength: a,
|
|
6813
6826
|
maxAttachmentSize: o,
|
|
@@ -6835,7 +6848,7 @@ var Ti = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6835
6848
|
t.preventDefault();
|
|
6836
6849
|
let i = Oe.current?.storage?.relativeMedia;
|
|
6837
6850
|
i && (i.clipboardFiles = new Map(Array.from(n.files ?? []).map((e) => [e.name.toLowerCase(), e])), i.pausedUntilPaste = !1);
|
|
6838
|
-
let a = Oe.current ?
|
|
6851
|
+
let a = Oe.current ? Ti(Oe.current, r) : null;
|
|
6839
6852
|
if (a) {
|
|
6840
6853
|
let t = new N(a, 0, 0);
|
|
6841
6854
|
e.dispatch(e.state.tr.replaceSelection(t).scrollIntoView());
|
|
@@ -6847,7 +6860,7 @@ var Ti = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6847
6860
|
x(() => {
|
|
6848
6861
|
Oe.current = X, window.__editor = X;
|
|
6849
6862
|
}, [X]), x(() => {
|
|
6850
|
-
if (X) return () =>
|
|
6863
|
+
if (X) return () => Xt(X);
|
|
6851
6864
|
}, [X]), x(() => {
|
|
6852
6865
|
!X || !g || g(X);
|
|
6853
6866
|
}, [X, g]), x(() => {
|
|
@@ -6859,7 +6872,7 @@ var Ti = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6859
6872
|
X.off("selectionUpdate", e);
|
|
6860
6873
|
};
|
|
6861
6874
|
}, [X]), x(() => {
|
|
6862
|
-
X && X.setOptions({ extensions:
|
|
6875
|
+
X && X.setOptions({ extensions: ci({
|
|
6863
6876
|
placeholder: n || f("editor.placeholder"),
|
|
6864
6877
|
maxLength: a,
|
|
6865
6878
|
maxAttachmentSize: o,
|
|
@@ -6875,7 +6888,7 @@ var Ti = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6875
6888
|
x(() => {
|
|
6876
6889
|
if (!X || e === Re.current) return;
|
|
6877
6890
|
Re.current = e;
|
|
6878
|
-
let t = typeof e == "object" && e ||
|
|
6891
|
+
let t = typeof e == "object" && e || wi(e) ? e : d(e);
|
|
6879
6892
|
X.commands.setContent(t, { emitUpdate: !1 });
|
|
6880
6893
|
}, [X, e]), x(() => {
|
|
6881
6894
|
X && X.setEditable(!k, !1);
|
|
@@ -6883,8 +6896,8 @@ var Ti = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6883
6896
|
if (y) return Qe(y);
|
|
6884
6897
|
}, [y]), x(() => {
|
|
6885
6898
|
if (!X) return;
|
|
6886
|
-
let e =
|
|
6887
|
-
e > s && Z(`文档内附件总大小 ${
|
|
6899
|
+
let e = cn(X.state.doc);
|
|
6900
|
+
e > s && Z(`文档内附件总大小 ${ln(e)} 已超过限制 ${ln(s)}`, "info");
|
|
6888
6901
|
}, [X, s]), x(() => {
|
|
6889
6902
|
if (!X) return;
|
|
6890
6903
|
let e = X.storage.qingwuUI;
|
|
@@ -6905,7 +6918,7 @@ var Ti = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6905
6918
|
left: t ? Math.max(8, Math.min(t.left, window.innerWidth - 240)) : 8,
|
|
6906
6919
|
zIndex: 9999
|
|
6907
6920
|
});
|
|
6908
|
-
}, []), Be =
|
|
6921
|
+
}, []), Be = fi((e) => f(e)), Ve = Be.filter((e) => !e.more), He = Be.filter((e) => e.more), Ue = Ve.filter((e) => e.key !== "ai"), We = Ve.find((e) => e.key === "ai"), Ge = b((e) => {
|
|
6909
6922
|
if (X) if (Me(!1), e.key === "link") if (X.isActive("link")) X.chain().focus().unsetLink().run();
|
|
6910
6923
|
else {
|
|
6911
6924
|
let e = X.getAttributes("link").href || "";
|
|
@@ -6969,7 +6982,7 @@ var Ti = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6969
6982
|
};
|
|
6970
6983
|
}
|
|
6971
6984
|
De.current = n;
|
|
6972
|
-
let r = we.current?.getBoundingClientRect(), i =
|
|
6985
|
+
let r = we.current?.getBoundingClientRect(), i = Ci(n, void 0, {
|
|
6973
6986
|
panelWidth: r?.width,
|
|
6974
6987
|
editorLeft: r?.left
|
|
6975
6988
|
});
|
|
@@ -6983,14 +6996,14 @@ var Ti = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6983
6996
|
filename: e,
|
|
6984
6997
|
resolve: t
|
|
6985
6998
|
});
|
|
6986
|
-
}, e.openAI = et, e.parseMd = (e, t) => X ?
|
|
6999
|
+
}, e.openAI = et, e.parseMd = (e, t) => X ? Ti(X, t) : null, () => {
|
|
6987
7000
|
delete e.openImageDialog, delete e.openVideoDialog, delete e.openAI, delete e.parseMd, delete e.chooseMd;
|
|
6988
7001
|
};
|
|
6989
7002
|
}, [X, et]), S(() => {
|
|
6990
7003
|
if (!j || !X) return;
|
|
6991
7004
|
let e = De.current;
|
|
6992
7005
|
if (!e) return;
|
|
6993
|
-
let t = z.current, n = we.current?.getBoundingClientRect(), r =
|
|
7006
|
+
let t = z.current, n = we.current?.getBoundingClientRect(), r = Ci(e, t?.offsetHeight || void 0, {
|
|
6994
7007
|
panelWidth: n?.width,
|
|
6995
7008
|
editorLeft: n?.left
|
|
6996
7009
|
});
|
|
@@ -7000,7 +7013,7 @@ var Ti = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7000
7013
|
let e = () => {
|
|
7001
7014
|
let e = De.current;
|
|
7002
7015
|
if (!e) return;
|
|
7003
|
-
let t = z.current, n = we.current?.getBoundingClientRect(), r =
|
|
7016
|
+
let t = z.current, n = we.current?.getBoundingClientRect(), r = Ci(e, t?.offsetHeight || void 0, {
|
|
7004
7017
|
panelWidth: n?.width,
|
|
7005
7018
|
editorLeft: n?.left
|
|
7006
7019
|
});
|
|
@@ -7040,9 +7053,9 @@ var Ti = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7040
7053
|
e.scrollTop += n, t.preventDefault(), t.stopPropagation();
|
|
7041
7054
|
return;
|
|
7042
7055
|
}
|
|
7043
|
-
let a =
|
|
7044
|
-
if (
|
|
7045
|
-
|
|
7056
|
+
let a = st(X), o = a ? ot(a) : null;
|
|
7057
|
+
if (o) {
|
|
7058
|
+
o.scrollTop += n, t.preventDefault(), t.stopPropagation();
|
|
7046
7059
|
return;
|
|
7047
7060
|
}
|
|
7048
7061
|
};
|
|
@@ -7231,7 +7244,7 @@ var Ti = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7231
7244
|
},
|
|
7232
7245
|
title: We?.label,
|
|
7233
7246
|
"aria-label": We?.label,
|
|
7234
|
-
children: /* @__PURE__ */ D(
|
|
7247
|
+
children: /* @__PURE__ */ D(Bt, {})
|
|
7235
7248
|
}),
|
|
7236
7249
|
/* @__PURE__ */ D("span", {
|
|
7237
7250
|
className: "w-px h-4 bg-default-200 mx-0.5 shrink-0",
|
|
@@ -7246,7 +7259,7 @@ var Ti = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7246
7259
|
},
|
|
7247
7260
|
title: f("editor.bubble.more"),
|
|
7248
7261
|
"aria-label": f("editor.bubble.more"),
|
|
7249
|
-
children: /* @__PURE__ */ D(
|
|
7262
|
+
children: /* @__PURE__ */ D(Vt, {})
|
|
7250
7263
|
}),
|
|
7251
7264
|
je && /* @__PURE__ */ D("div", {
|
|
7252
7265
|
role: "menu",
|
|
@@ -7283,7 +7296,7 @@ var Ti = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7283
7296
|
onClick: (e) => e.stopPropagation(),
|
|
7284
7297
|
children: K === "highlight" ? /* @__PURE__ */ O("div", {
|
|
7285
7298
|
className: "flex items-center gap-1 p-1.5 flex-wrap",
|
|
7286
|
-
children: [
|
|
7299
|
+
children: [yi.map((e) => /* @__PURE__ */ D("button", {
|
|
7287
7300
|
type: "button",
|
|
7288
7301
|
className: "w-5 h-5 rounded-full border border-default-200 hover:scale-110 transition-transform",
|
|
7289
7302
|
style: { background: e.color },
|
|
@@ -7334,49 +7347,49 @@ var Ti = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7334
7347
|
className: "ai-panel__arrow",
|
|
7335
7348
|
style: { left: `${re}%` },
|
|
7336
7349
|
"aria-hidden": "true"
|
|
7337
|
-
}), /* @__PURE__ */ D(
|
|
7350
|
+
}), /* @__PURE__ */ D(on, {
|
|
7338
7351
|
editor: X,
|
|
7339
7352
|
onClose: () => M(!1)
|
|
7340
7353
|
})]
|
|
7341
7354
|
})] }), document.body),
|
|
7342
7355
|
B && /* @__PURE__ */ D(v, {
|
|
7343
|
-
fallback: /* @__PURE__ */ D(
|
|
7344
|
-
children: /* @__PURE__ */ D(
|
|
7356
|
+
fallback: /* @__PURE__ */ D(ji, {}),
|
|
7357
|
+
children: /* @__PURE__ */ D(Ei, {
|
|
7345
7358
|
open: B,
|
|
7346
7359
|
onClose: () => V(!1),
|
|
7347
7360
|
onInsert: tt,
|
|
7348
|
-
validate: (e) => X ?
|
|
7361
|
+
validate: (e) => X ? dn(X.state.doc, e, {
|
|
7349
7362
|
maxAttachmentSize: o,
|
|
7350
7363
|
maxTotalAttachmentSize: s
|
|
7351
7364
|
}) : null
|
|
7352
7365
|
})
|
|
7353
7366
|
}),
|
|
7354
7367
|
H && /* @__PURE__ */ D(v, {
|
|
7355
|
-
fallback: /* @__PURE__ */ D(
|
|
7356
|
-
children: /* @__PURE__ */ D(
|
|
7368
|
+
fallback: /* @__PURE__ */ D(ji, {}),
|
|
7369
|
+
children: /* @__PURE__ */ D(ki, {
|
|
7357
7370
|
open: H,
|
|
7358
7371
|
onClose: () => ae(!1),
|
|
7359
7372
|
onInsert: nt
|
|
7360
7373
|
})
|
|
7361
7374
|
}),
|
|
7362
7375
|
oe && /* @__PURE__ */ D(v, {
|
|
7363
|
-
fallback: /* @__PURE__ */ D(
|
|
7364
|
-
children: /* @__PURE__ */ D(
|
|
7376
|
+
fallback: /* @__PURE__ */ D(ji, {}),
|
|
7377
|
+
children: /* @__PURE__ */ D(Di, {
|
|
7365
7378
|
open: oe,
|
|
7366
7379
|
onClose: () => U(!1)
|
|
7367
7380
|
})
|
|
7368
7381
|
}),
|
|
7369
7382
|
W && /* @__PURE__ */ D(v, {
|
|
7370
|
-
fallback: /* @__PURE__ */ D(
|
|
7371
|
-
children: /* @__PURE__ */ D(
|
|
7383
|
+
fallback: /* @__PURE__ */ D(ji, {}),
|
|
7384
|
+
children: /* @__PURE__ */ D(Oi, {
|
|
7372
7385
|
open: W,
|
|
7373
7386
|
onClose: () => G(!1),
|
|
7374
7387
|
editor: X
|
|
7375
7388
|
})
|
|
7376
7389
|
}),
|
|
7377
7390
|
de && /* @__PURE__ */ D(v, {
|
|
7378
|
-
fallback: /* @__PURE__ */ D(
|
|
7379
|
-
children: /* @__PURE__ */ D(
|
|
7391
|
+
fallback: /* @__PURE__ */ D(ji, {}),
|
|
7392
|
+
children: /* @__PURE__ */ D(Ai, {
|
|
7380
7393
|
open: !!de,
|
|
7381
7394
|
filename: de.filename,
|
|
7382
7395
|
onRender: () => {
|
|
@@ -7397,7 +7410,7 @@ var Ti = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7397
7410
|
className: "relative min-w-0 flex-1",
|
|
7398
7411
|
children: [
|
|
7399
7412
|
/* @__PURE__ */ D(P, { editor: X }),
|
|
7400
|
-
!k && /* @__PURE__ */ D(
|
|
7413
|
+
!k && /* @__PURE__ */ D(vi, { editor: X }),
|
|
7401
7414
|
/* @__PURE__ */ D("div", {
|
|
7402
7415
|
className: `${J || Y ? "fixed" : "absolute"} bottom-2 right-4 z-10 pointer-events-none select-none`,
|
|
7403
7416
|
children: /* @__PURE__ */ O("span", {
|
|
@@ -7412,7 +7425,7 @@ var Ti = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7412
7425
|
]
|
|
7413
7426
|
})
|
|
7414
7427
|
}),
|
|
7415
|
-
h && _e && /* @__PURE__ */ D(
|
|
7428
|
+
h && _e && /* @__PURE__ */ D(kt, {
|
|
7416
7429
|
editor: X,
|
|
7417
7430
|
onClose: () => ve(!1)
|
|
7418
7431
|
}),
|
|
@@ -7462,7 +7475,7 @@ var Ti = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7462
7475
|
})
|
|
7463
7476
|
})
|
|
7464
7477
|
})]
|
|
7465
|
-
}), /* @__PURE__ */ D(
|
|
7478
|
+
}), /* @__PURE__ */ D(dt, {
|
|
7466
7479
|
editor: X,
|
|
7467
7480
|
className: "!p-3",
|
|
7468
7481
|
onClose: () => {
|
|
@@ -7474,7 +7487,7 @@ var Ti = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7474
7487
|
}), rt && ne(/* @__PURE__ */ D("aside", {
|
|
7475
7488
|
ref: ke,
|
|
7476
7489
|
className: "qingwu-toc-desktop toc-scroll",
|
|
7477
|
-
children: /* @__PURE__ */ D(
|
|
7490
|
+
children: /* @__PURE__ */ D(dt, {
|
|
7478
7491
|
editor: X,
|
|
7479
7492
|
onClose: () => me(!1)
|
|
7480
7493
|
})
|
|
@@ -7486,7 +7499,7 @@ var Ti = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7486
7499
|
};
|
|
7487
7500
|
//#endregion
|
|
7488
7501
|
//#region src/editor/clipper/receiver-browser.ts
|
|
7489
|
-
function
|
|
7502
|
+
function Ni(e) {
|
|
7490
7503
|
let t = async (t) => {
|
|
7491
7504
|
let n = t.data;
|
|
7492
7505
|
if (!n || typeof n != "object" || n.kind !== "qingwu-clip") return;
|
|
@@ -7503,7 +7516,7 @@ function Mi(e) {
|
|
|
7503
7516
|
}
|
|
7504
7517
|
//#endregion
|
|
7505
7518
|
//#region src/editor/storage/providers/cos.ts
|
|
7506
|
-
function
|
|
7519
|
+
function Pi(e) {
|
|
7507
7520
|
return g({
|
|
7508
7521
|
endpoint: `https://cos.${e.region}.myqcloud.com`,
|
|
7509
7522
|
bucket: e.bucket,
|
|
@@ -7517,7 +7530,7 @@ function Ni(e) {
|
|
|
7517
7530
|
}
|
|
7518
7531
|
//#endregion
|
|
7519
7532
|
//#region src/editor/storage/providers/oss.ts
|
|
7520
|
-
function
|
|
7533
|
+
function Fi(e) {
|
|
7521
7534
|
return g({
|
|
7522
7535
|
endpoint: `https://${e.bucket}.${e.region}.aliyuncs.com`,
|
|
7523
7536
|
bucket: e.bucket,
|
|
@@ -7530,4 +7543,4 @@ function Pi(e) {
|
|
|
7530
7543
|
});
|
|
7531
7544
|
}
|
|
7532
7545
|
//#endregion
|
|
7533
|
-
export {
|
|
7546
|
+
export { er as CODE_LANGUAGES, or as CodeBlock, Ar as ImageUpload, et as ImageUploadDialog, Mi as QingWuAIEditor, ri as RelativeMedia, Dt as SearchHighlight, dt as TocPanel, qn as VideoEmbed, ft as buildSystemPrompt, mt as createAILanguageModelProvider, Pi as createCOSStorage, vt as createDeepSeekProvider, _ as createLocalStorage, Fi as createOSSStorage, _t as createOpenAICompatProvider, yt as createOpenAIProvider, bt as createQwenProvider, g as createS3Storage, ai as createSlashCommandExtension, h as escapeHtml, ln as formatBytes, gt as getAIProvider, fi as getBubbleMenuActions, oi as getDefaultSlashCommands, cn as getDocAttachmentTotal, ci as getEditorExtensions, u as getLocale, di as getSearchEngine, Ot as getSearchState, c as getStorageInfo, o as getStorageProvider, s as loadStorageConfig, r as registerS3PreviewConfig, d as sanitizeHtml, p as sanitizeSvg, ht as setAIProvider, _n as setConfirmProvider, l as setLocale, ui as setSearchEngine, i as setStorageProvider, Ze as setToastProvider, n as signPreviewUrlHeaders, Ni as startBrowserClipperReceiver, Qe as subscribeToast, f as t, m as tf, Z as toast, dn as validateAttachmentFile };
|