@baishuyun/ui-base 6.17.0 → 6.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Amap/index.js +1 -1
- package/dist/Calendar/{Calendar-BlsUX2vX.js → Calendar-Dk6FVbJ2.js} +1 -1
- package/dist/Calendar/index.js +3 -3
- package/dist/Card/index.js +1 -1
- package/dist/CheckBox/index.js +1 -1
- package/dist/ColorPicker/index.js +1 -1
- package/dist/ConfigProvider/index.js +1 -1
- package/dist/DatePicker/{DatePicker-BRwPZeui.js → DatePicker-CItkTpdZ.js} +1 -1
- package/dist/DatePicker/{DatePickerPanel-UwjSXS-U.js → DatePickerPanel-DJXmFihs.js} +1 -1
- package/dist/DatePicker/index.js +2 -2
- package/dist/DropDown/index.js +1 -1
- package/dist/Editor/index.js +606 -587
- package/dist/Gantt/index.js +1 -1
- package/dist/Icon/index.js +1 -1
- package/dist/InputTag/index.js +1 -1
- package/dist/Loading/index.js +1 -1
- package/dist/Modal/index.js +1 -1
- package/dist/NotFoundContent/index.js +1 -1
- package/dist/Overlay/index.js +1 -1
- package/dist/Radio/index.js +1 -1
- package/dist/ScrollBar/index.js +1 -1
- package/dist/Segmented/index.js +1 -1
- package/dist/Select/index.js +1 -1
- package/dist/Table/index.js +1 -1
- package/dist/Tabs/index.js +1 -1
- package/dist/Tooltip/index.js +1 -1
- package/dist/Tree/index.js +1 -1
- package/dist/components/Editor/Preview/EditorPreview.d.ts +1 -1
- package/dist/components/Editor/Preview/PolishModal.d.ts +0 -1
- package/dist/components/Editor/Preview/TypesetModal.d.ts +0 -1
- package/dist/components/Editor/Preview/useAiPreviewHtml.d.ts +8 -0
- package/dist/components/Editor/commands/ImageCommands.d.ts +1 -0
- package/dist/components/Editor/context/EditorContainerContext.d.ts +3 -2
- package/dist/components/Editor/nodes/ImageComponent.d.ts +1 -0
- package/dist/components/Editor/nodes/ImageNode.d.ts +5 -2
- package/dist/index.js +3 -3
- package/dist/vendors/{version-CfjNx5v2.js → version-BucxnUKs.js} +1 -1
- package/package.json +1 -1
package/dist/Editor/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../vendors/version-
|
|
1
|
+
import "../vendors/version-BucxnUKs.js";
|
|
2
2
|
import "../ScrollBar/style-D26azwz6.js";
|
|
3
3
|
import { t as e } from "../Icon/Icon-DrdQOEJE.js";
|
|
4
4
|
import "../vendors/LocaleContext-DXQoOKM2.js";
|
|
@@ -57,22 +57,22 @@ var U = {
|
|
|
57
57
|
topRight: "_topRight_y06h3_49",
|
|
58
58
|
bottomLeft: "_bottomLeft_y06h3_54",
|
|
59
59
|
bottomRight: "_bottomRight_y06h3_59"
|
|
60
|
-
}, en = ({ src: e, altText: t, width: n, height: r, dataId: i,
|
|
61
|
-
let [
|
|
60
|
+
}, en = ({ src: e, altText: t, width: n, height: r, dataId: i, dataSrc: a, nodeKey: o }) => {
|
|
61
|
+
let [s] = B(), [c, l] = P(!1), [u, d] = P(null), f = N(null), [p, m] = P({
|
|
62
62
|
width: n || void 0,
|
|
63
63
|
height: r || void 0
|
|
64
|
-
}),
|
|
65
|
-
n && r &&
|
|
64
|
+
}), h = T(() => {
|
|
65
|
+
n && r && m({
|
|
66
66
|
width: n,
|
|
67
67
|
height: r
|
|
68
68
|
});
|
|
69
|
-
}, [n, r]),
|
|
70
|
-
if (e.preventDefault(), e.stopPropagation(), !
|
|
71
|
-
let n =
|
|
72
|
-
(!
|
|
69
|
+
}, [n, r]), g = T((e, t) => {
|
|
70
|
+
if (e.preventDefault(), e.stopPropagation(), !f.current) return;
|
|
71
|
+
let n = p.width || f.current.offsetWidth, r = p.height || f.current.offsetHeight, i = n / r;
|
|
72
|
+
(!p.width || !p.height) && m({
|
|
73
73
|
width: n,
|
|
74
74
|
height: r
|
|
75
|
-
}),
|
|
75
|
+
}), d({
|
|
76
76
|
isResizing: !0,
|
|
77
77
|
startX: e.clientX,
|
|
78
78
|
startY: e.clientY,
|
|
@@ -81,102 +81,103 @@ var U = {
|
|
|
81
81
|
aspectRatio: i,
|
|
82
82
|
direction: t
|
|
83
83
|
});
|
|
84
|
-
}, [
|
|
85
|
-
if (!
|
|
86
|
-
let t = e.clientX -
|
|
87
|
-
switch (
|
|
84
|
+
}, [p]), _ = T((e) => {
|
|
85
|
+
if (!u?.isResizing) return;
|
|
86
|
+
let t = e.clientX - u.startX, n;
|
|
87
|
+
switch (u.direction) {
|
|
88
88
|
case "bottom-right":
|
|
89
|
-
n = Math.max(50,
|
|
89
|
+
n = Math.max(50, u.startWidth + t);
|
|
90
90
|
break;
|
|
91
91
|
case "bottom-left":
|
|
92
|
-
n = Math.max(50,
|
|
92
|
+
n = Math.max(50, u.startWidth - t);
|
|
93
93
|
break;
|
|
94
94
|
case "top-right":
|
|
95
|
-
n = Math.max(50,
|
|
95
|
+
n = Math.max(50, u.startWidth + t);
|
|
96
96
|
break;
|
|
97
97
|
case "top-left":
|
|
98
|
-
n = Math.max(50,
|
|
98
|
+
n = Math.max(50, u.startWidth - t);
|
|
99
99
|
break;
|
|
100
|
-
default: n = Math.max(50,
|
|
100
|
+
default: n = Math.max(50, u.startWidth + t);
|
|
101
101
|
}
|
|
102
|
-
let r = n /
|
|
103
|
-
|
|
102
|
+
let r = n / u.aspectRatio;
|
|
103
|
+
m({
|
|
104
104
|
width: n,
|
|
105
105
|
height: r
|
|
106
106
|
});
|
|
107
|
-
}, [
|
|
108
|
-
|
|
109
|
-
let e = Ce(
|
|
110
|
-
rn(e) && e.setWidthAndHeight(
|
|
111
|
-
}),
|
|
107
|
+
}, [u]), S = T(() => {
|
|
108
|
+
u?.isResizing && (s.update(() => {
|
|
109
|
+
let e = Ce(o);
|
|
110
|
+
rn(e) && e.setWidthAndHeight(p.width, p.height);
|
|
111
|
+
}), d(null));
|
|
112
112
|
}, [
|
|
113
|
+
s,
|
|
113
114
|
o,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
l
|
|
115
|
+
p,
|
|
116
|
+
u
|
|
117
117
|
]);
|
|
118
118
|
x.useEffect(() => {
|
|
119
|
-
if (
|
|
120
|
-
document.removeEventListener("mousemove",
|
|
119
|
+
if (u?.isResizing) return document.addEventListener("mousemove", _), document.addEventListener("mouseup", S), () => {
|
|
120
|
+
document.removeEventListener("mousemove", _), document.removeEventListener("mouseup", S);
|
|
121
121
|
};
|
|
122
122
|
}, [
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
u,
|
|
124
|
+
_,
|
|
125
|
+
S
|
|
126
126
|
]);
|
|
127
|
-
let
|
|
128
|
-
|
|
127
|
+
let C = T(() => {
|
|
128
|
+
l(!0);
|
|
129
129
|
}, []);
|
|
130
|
-
return O(() =>
|
|
130
|
+
return O(() => s.registerUpdateListener(({ editorState: e }) => {
|
|
131
131
|
e.read(() => {
|
|
132
132
|
let e = R();
|
|
133
|
-
z(e) && !e.getNodes().some((e) => e.getKey() ===
|
|
133
|
+
z(e) && !e.getNodes().some((e) => e.getKey() === o || e.getParent() && e.getParent()?.getKey() === o) && c && l(!1);
|
|
134
134
|
});
|
|
135
135
|
}), [
|
|
136
|
+
s,
|
|
136
137
|
o,
|
|
137
|
-
|
|
138
|
-
s
|
|
138
|
+
c
|
|
139
139
|
]), O(() => {
|
|
140
140
|
let e = (e) => {
|
|
141
|
-
|
|
141
|
+
c && f.current && !f.current.contains(e.target) && l(!1);
|
|
142
142
|
};
|
|
143
|
-
if (
|
|
143
|
+
if (c) return document.addEventListener("mousedown", e), () => {
|
|
144
144
|
document.removeEventListener("mousedown", e);
|
|
145
145
|
};
|
|
146
|
-
}, [
|
|
146
|
+
}, [c]), /* @__PURE__ */ b("div", {
|
|
147
147
|
className: I(U.imageWrapper, {
|
|
148
|
-
[U.selected]:
|
|
149
|
-
[U.resizing]:
|
|
148
|
+
[U.selected]: c,
|
|
149
|
+
[U.resizing]: u?.isResizing
|
|
150
150
|
}),
|
|
151
151
|
children: [/* @__PURE__ */ y("img", {
|
|
152
|
-
ref:
|
|
152
|
+
ref: f,
|
|
153
153
|
src: e,
|
|
154
154
|
alt: t,
|
|
155
155
|
"data-id": i,
|
|
156
|
+
"data-src": a,
|
|
156
157
|
className: U.image,
|
|
157
158
|
style: {
|
|
158
|
-
width:
|
|
159
|
-
height:
|
|
159
|
+
width: p.width,
|
|
160
|
+
height: p.height
|
|
160
161
|
},
|
|
161
|
-
onLoad:
|
|
162
|
-
onClick:
|
|
162
|
+
onLoad: h,
|
|
163
|
+
onClick: C,
|
|
163
164
|
draggable: !1
|
|
164
|
-
}),
|
|
165
|
+
}), c && /* @__PURE__ */ b(v, { children: [
|
|
165
166
|
/* @__PURE__ */ y("div", {
|
|
166
167
|
className: I(U.resizeHandle, U.bottomRight),
|
|
167
|
-
onMouseDown: (e) =>
|
|
168
|
+
onMouseDown: (e) => g(e, "bottom-right")
|
|
168
169
|
}),
|
|
169
170
|
/* @__PURE__ */ y("div", {
|
|
170
171
|
className: I(U.resizeHandle, U.bottomLeft),
|
|
171
|
-
onMouseDown: (e) =>
|
|
172
|
+
onMouseDown: (e) => g(e, "bottom-left")
|
|
172
173
|
}),
|
|
173
174
|
/* @__PURE__ */ y("div", {
|
|
174
175
|
className: I(U.resizeHandle, U.topRight),
|
|
175
|
-
onMouseDown: (e) =>
|
|
176
|
+
onMouseDown: (e) => g(e, "top-right")
|
|
176
177
|
}),
|
|
177
178
|
/* @__PURE__ */ y("div", {
|
|
178
179
|
className: I(U.resizeHandle, U.topLeft),
|
|
179
|
-
onMouseDown: (e) =>
|
|
180
|
+
onMouseDown: (e) => g(e, "top-left")
|
|
180
181
|
})
|
|
181
182
|
] })]
|
|
182
183
|
});
|
|
@@ -186,14 +187,15 @@ var U = {
|
|
|
186
187
|
__width;
|
|
187
188
|
__height;
|
|
188
189
|
__dataId;
|
|
190
|
+
__dataSrc;
|
|
189
191
|
static getType() {
|
|
190
192
|
return "image";
|
|
191
193
|
}
|
|
192
194
|
static clone(t) {
|
|
193
|
-
return new e(t.__src, t.__altText, t.__width, t.__height, t.__key, t.__dataId);
|
|
195
|
+
return new e(t.__src, t.__altText, t.__width, t.__height, t.__key, t.__dataId, t.__dataSrc);
|
|
194
196
|
}
|
|
195
|
-
constructor(e, t, n, r, i, a) {
|
|
196
|
-
super(i), this.__src = e, this.__altText = t || "", this.__width = n, this.__height = r, this.__dataId = a;
|
|
197
|
+
constructor(e, t, n, r, i, a, o) {
|
|
198
|
+
super(i), this.__src = e, this.__altText = t || "", this.__width = n, this.__height = r, this.__dataId = a, this.__dataSrc = o;
|
|
197
199
|
}
|
|
198
200
|
createDOM() {
|
|
199
201
|
let e = document.createElement("div");
|
|
@@ -204,7 +206,7 @@ var U = {
|
|
|
204
206
|
}
|
|
205
207
|
exportDOM() {
|
|
206
208
|
let e = document.createElement("img");
|
|
207
|
-
return e.setAttribute("src", this.__src), e.setAttribute("alt", this.__altText), e.style.maxWidth = "100%", e.style.display = "inline", e.style.verticalAlign = "baseline", this.__width && e.setAttribute("width", this.__width.toString()), this.__height && e.setAttribute("height", this.__height.toString()), this.__dataId && e.setAttribute("data-id", this.__dataId), { element: e };
|
|
209
|
+
return e.setAttribute("src", this.__src), e.setAttribute("alt", this.__altText), e.style.maxWidth = "100%", e.style.display = "inline", e.style.verticalAlign = "baseline", this.__width && e.setAttribute("width", this.__width.toString()), this.__height && e.setAttribute("height", this.__height.toString()), this.__dataId && e.setAttribute("data-id", this.__dataId), this.__dataSrc && e.setAttribute("data-src", this.__dataSrc), { element: e };
|
|
208
210
|
}
|
|
209
211
|
getSrc() {
|
|
210
212
|
return this.__src;
|
|
@@ -240,6 +242,7 @@ var U = {
|
|
|
240
242
|
width: this.__width,
|
|
241
243
|
height: this.__height,
|
|
242
244
|
dataId: this.__dataId,
|
|
245
|
+
dataSrc: this.__dataSrc,
|
|
243
246
|
nodeKey: this.getKey()
|
|
244
247
|
});
|
|
245
248
|
}
|
|
@@ -250,13 +253,14 @@ var U = {
|
|
|
250
253
|
}) };
|
|
251
254
|
}
|
|
252
255
|
static importJSON(e) {
|
|
253
|
-
let { src: t, altText: n, width: r, height: i, dataId: a } = e;
|
|
256
|
+
let { src: t, altText: n, width: r, height: i, dataId: a, dataSrc: o } = e;
|
|
254
257
|
return nn({
|
|
255
258
|
src: t,
|
|
256
259
|
altText: n,
|
|
257
260
|
width: r,
|
|
258
261
|
height: i,
|
|
259
|
-
dataId: a
|
|
262
|
+
dataId: a,
|
|
263
|
+
dataSrc: o
|
|
260
264
|
});
|
|
261
265
|
}
|
|
262
266
|
exportJSON() {
|
|
@@ -266,6 +270,7 @@ var U = {
|
|
|
266
270
|
width: this.getWidth(),
|
|
267
271
|
height: this.getHeight(),
|
|
268
272
|
dataId: this.getDataId(),
|
|
273
|
+
dataSrc: this.__dataSrc,
|
|
269
274
|
type: "image",
|
|
270
275
|
version: 1
|
|
271
276
|
};
|
|
@@ -274,8 +279,8 @@ var U = {
|
|
|
274
279
|
return !0;
|
|
275
280
|
}
|
|
276
281
|
};
|
|
277
|
-
function nn({ src: e, altText: t, width: n, height: r, dataId: i,
|
|
278
|
-
return new tn(e, t, n, r,
|
|
282
|
+
function nn({ src: e, altText: t, width: n, height: r, dataId: i, dataSrc: a, key: o }) {
|
|
283
|
+
return new tn(e, t, n, r, o, i, a);
|
|
279
284
|
}
|
|
280
285
|
function rn(e) {
|
|
281
286
|
return e instanceof tn;
|
|
@@ -292,13 +297,14 @@ function an(e) {
|
|
|
292
297
|
isNaN(e) || (a = e);
|
|
293
298
|
}
|
|
294
299
|
i === void 0 && e.width && (i = e.width), a === void 0 && e.height && (a = e.height);
|
|
295
|
-
let o = e.getAttribute("data-id") || void 0;
|
|
300
|
+
let o = e.getAttribute("data-id") || void 0, s = e.getAttribute("data-src") || void 0;
|
|
296
301
|
return { node: nn({
|
|
297
302
|
src: t,
|
|
298
303
|
altText: n,
|
|
299
304
|
width: i,
|
|
300
305
|
height: a,
|
|
301
|
-
dataId: o
|
|
306
|
+
dataId: o,
|
|
307
|
+
dataSrc: s
|
|
302
308
|
}) };
|
|
303
309
|
}
|
|
304
310
|
return null;
|
|
@@ -1124,28 +1130,28 @@ var ur = "......", dr = (e, t, n) => {
|
|
|
1124
1130
|
display: l(c.slice(0, p)),
|
|
1125
1131
|
truncated: !0
|
|
1126
1132
|
};
|
|
1127
|
-
}, fr = S(null), pr = S({ text: "" }), mr = () => {
|
|
1133
|
+
}, fr = S(null), pr = S({ text: "" }), mr = S(void 0), hr = () => {
|
|
1128
1134
|
let e = E(fr);
|
|
1129
1135
|
if (!e) throw Error("useEditorContainer must be used within EditorContainerProvider");
|
|
1130
1136
|
return e;
|
|
1131
|
-
},
|
|
1132
|
-
function
|
|
1137
|
+
}, gr = () => E(pr), _r = () => E(mr), vr = "EditorImageUploadingError";
|
|
1138
|
+
function yr(e) {
|
|
1133
1139
|
if (!e || typeof e != "object" || !("name" in e)) return !1;
|
|
1134
1140
|
let t = String(e.name);
|
|
1135
1141
|
return t === "AbortError" || t === "CanceledError";
|
|
1136
1142
|
}
|
|
1137
|
-
function
|
|
1143
|
+
function br(e) {
|
|
1138
1144
|
return yn.includes(e.name.split(".").pop()?.toLowerCase() ?? "");
|
|
1139
1145
|
}
|
|
1140
|
-
function
|
|
1146
|
+
function xr(e) {
|
|
1141
1147
|
if (Number.isFinite(e)) return Math.min(100, Math.max(0, e));
|
|
1142
1148
|
}
|
|
1143
|
-
function
|
|
1149
|
+
function Sr(e) {
|
|
1144
1150
|
return e === void 0 ? .55 : .55 * (1 - e / 100);
|
|
1145
1151
|
}
|
|
1146
1152
|
//#endregion
|
|
1147
1153
|
//#region src/components/Editor/ToolbarPlugin/Buttons/PictureButton/UploadImage.tsx
|
|
1148
|
-
var
|
|
1154
|
+
var Cr = {
|
|
1149
1155
|
duration: .2,
|
|
1150
1156
|
ease: [
|
|
1151
1157
|
.4,
|
|
@@ -1153,7 +1159,7 @@ var xr = {
|
|
|
1153
1159
|
.2,
|
|
1154
1160
|
1
|
|
1155
1161
|
]
|
|
1156
|
-
},
|
|
1162
|
+
}, wr = ({ name: e, error: t }) => {
|
|
1157
1163
|
let n = N(null), [r, i] = P(e), [a, o] = P(!1);
|
|
1158
1164
|
return j(() => {
|
|
1159
1165
|
let t = n.current, r = document.createElement("canvas").getContext("2d");
|
|
@@ -1172,11 +1178,11 @@ var xr = {
|
|
|
1172
1178
|
title: a ? e : void 0,
|
|
1173
1179
|
children: r
|
|
1174
1180
|
});
|
|
1175
|
-
},
|
|
1181
|
+
}, Tr = (e) => new Promise((t, n) => {
|
|
1176
1182
|
let r = new FileReader();
|
|
1177
1183
|
r.onload = () => t(r.result), r.onerror = () => n(r.error), r.readAsDataURL(e);
|
|
1178
|
-
}),
|
|
1179
|
-
let { upload: r } =
|
|
1184
|
+
}), Er = C((t, n) => {
|
|
1185
|
+
let { upload: r } = hr(), [i, o] = P(!1), [s, c] = P([]), l = N(s);
|
|
1180
1186
|
l.current = s;
|
|
1181
1187
|
let u = N(null), d = N(/* @__PURE__ */ new Map()), f = r?.customRequest, [p, m] = ne.useMessage(), { t: h } = a(), g = (e) => (e / 1024).toFixed(1) + "kb", _ = (e, t) => {
|
|
1182
1188
|
c((n) => n.map((n) => n.id === e ? {
|
|
@@ -1192,7 +1198,7 @@ var xr = {
|
|
|
1192
1198
|
d.current.set(e, n), f(t, {
|
|
1193
1199
|
signal: n.signal,
|
|
1194
1200
|
onProgress: (t) => {
|
|
1195
|
-
let n =
|
|
1201
|
+
let n = xr(t);
|
|
1196
1202
|
n !== void 0 && _(e, { percent: n });
|
|
1197
1203
|
}
|
|
1198
1204
|
}).then((t) => {
|
|
@@ -1203,11 +1209,11 @@ var xr = {
|
|
|
1203
1209
|
attachment: typeof t == "string" ? void 0 : t.attachment
|
|
1204
1210
|
});
|
|
1205
1211
|
}).catch((t) => {
|
|
1206
|
-
n.signal.aborted ||
|
|
1212
|
+
n.signal.aborted || yr(t) || _(e, { status: "error" });
|
|
1207
1213
|
}).finally(() => {
|
|
1208
1214
|
d.current.delete(e);
|
|
1209
1215
|
});
|
|
1210
|
-
}, x = (e) =>
|
|
1216
|
+
}, x = (e) => br(e) ? e.size > 5242880 ? (p.warning(h("editor.imageSizeNote")), !1) : !0 : (p.warning(h("editor.onlyImageFormatsSupported")), !1), S = (e) => {
|
|
1211
1217
|
let t = 10 - l.current.length;
|
|
1212
1218
|
if (t <= 0) {
|
|
1213
1219
|
p.warning(h("editor.imageCountNote", { count: 10 }));
|
|
@@ -1239,13 +1245,13 @@ var xr = {
|
|
|
1239
1245
|
}, []), A(n, () => ({ getValue: async () => {
|
|
1240
1246
|
if (s.some((e) => e.status === "uploading")) {
|
|
1241
1247
|
let e = Error(h("editor.imageUploading"));
|
|
1242
|
-
throw e.name =
|
|
1248
|
+
throw e.name = vr, e;
|
|
1243
1249
|
}
|
|
1244
1250
|
let e = s.filter((e) => e.status === "success");
|
|
1245
1251
|
if (!e.length) throw p.warning(h("editor.pleaseUploadImageFirst")), Error(h("editor.pleaseUploadImageFirst"));
|
|
1246
1252
|
try {
|
|
1247
1253
|
return await Promise.all(e.map(async (e) => ({
|
|
1248
|
-
src: e.src ?? await
|
|
1254
|
+
src: e.src ?? await Tr(e.file),
|
|
1249
1255
|
fileName: e.file.name,
|
|
1250
1256
|
attachment: e.attachment
|
|
1251
1257
|
})));
|
|
@@ -1301,7 +1307,7 @@ var xr = {
|
|
|
1301
1307
|
opacity: 0,
|
|
1302
1308
|
y: -8
|
|
1303
1309
|
},
|
|
1304
|
-
transition:
|
|
1310
|
+
transition: Cr,
|
|
1305
1311
|
children: [
|
|
1306
1312
|
/* @__PURE__ */ b("div", {
|
|
1307
1313
|
className: Y["picture-modal__preview-image"],
|
|
@@ -1310,13 +1316,13 @@ var xr = {
|
|
|
1310
1316
|
alt: h("editor.previewImage")
|
|
1311
1317
|
}), t.status === "uploading" ? /* @__PURE__ */ y("div", {
|
|
1312
1318
|
className: Y["picture-modal__preview-mask"],
|
|
1313
|
-
style: { opacity:
|
|
1319
|
+
style: { opacity: Sr(t.percent) },
|
|
1314
1320
|
children: t.percent === void 0 ? /* @__PURE__ */ y("span", { className: Y["picture-modal__preview-spinner"] }) : null
|
|
1315
1321
|
}) : null]
|
|
1316
1322
|
}),
|
|
1317
1323
|
/* @__PURE__ */ b("div", {
|
|
1318
1324
|
className: Y["picture-modal__preview-info"],
|
|
1319
|
-
children: [/* @__PURE__ */ y(
|
|
1325
|
+
children: [/* @__PURE__ */ y(wr, {
|
|
1320
1326
|
name: t.file.name,
|
|
1321
1327
|
error: t.status === "error"
|
|
1322
1328
|
}), /* @__PURE__ */ y("div", {
|
|
@@ -1346,11 +1352,11 @@ var xr = {
|
|
|
1346
1352
|
]
|
|
1347
1353
|
});
|
|
1348
1354
|
});
|
|
1349
|
-
|
|
1355
|
+
Er.displayName = "UploadImage";
|
|
1350
1356
|
//#endregion
|
|
1351
1357
|
//#region src/components/Editor/commands/ImageCommands.ts
|
|
1352
|
-
var
|
|
1353
|
-
let { t: o } = a(), [s] = B(), { attachmentsBySrcRef: c } =
|
|
1358
|
+
var Dr = it("INSERT_INLINE_IMAGE_COMMAND"), Or = ({ disabled: t, tooltip: n, showDisabledTooltip: i }) => {
|
|
1359
|
+
let { t: o } = a(), [s] = B(), { attachmentsBySrcRef: c } = hr(), [l, d] = P(!1), f = N(null), p = N(null), m = [{
|
|
1354
1360
|
key: "upload",
|
|
1355
1361
|
title: o("editor.uploadImage"),
|
|
1356
1362
|
icon: /* @__PURE__ */ y(e, { name: "picture" })
|
|
@@ -1361,7 +1367,7 @@ var Tr = it("INSERT_INLINE_IMAGE_COMMAND"), Er = ({ disabled: t, tooltip: n, sho
|
|
|
1361
1367
|
}], [h, g] = P(m[0].key), _ = async () => {
|
|
1362
1368
|
try {
|
|
1363
1369
|
if (h === "upload" && p.current) (await p.current.getValue()).forEach((e) => {
|
|
1364
|
-
e.attachment !== void 0 && c.current.set(e.src, e.attachment), s.dispatchCommand(
|
|
1370
|
+
e.attachment !== void 0 && c.current.set(e.src, e.attachment), s.dispatchCommand(Dr, {
|
|
1365
1371
|
src: e.src,
|
|
1366
1372
|
altText: e.fileName,
|
|
1367
1373
|
dataId: e.attachment?._id
|
|
@@ -1369,9 +1375,9 @@ var Tr = it("INSERT_INLINE_IMAGE_COMMAND"), Er = ({ disabled: t, tooltip: n, sho
|
|
|
1369
1375
|
});
|
|
1370
1376
|
else if (f.current) {
|
|
1371
1377
|
let e = await f.current.getValue();
|
|
1372
|
-
s.dispatchCommand(
|
|
1378
|
+
s.dispatchCommand(Dr, {
|
|
1373
1379
|
src: e,
|
|
1374
|
-
|
|
1380
|
+
dataSrc: e
|
|
1375
1381
|
});
|
|
1376
1382
|
}
|
|
1377
1383
|
d(!1);
|
|
@@ -1384,7 +1390,7 @@ var Tr = it("INSERT_INLINE_IMAGE_COMMAND"), Er = ({ disabled: t, tooltip: n, sho
|
|
|
1384
1390
|
ne.error(t);
|
|
1385
1391
|
}
|
|
1386
1392
|
}, x = {
|
|
1387
|
-
upload: /* @__PURE__ */ y(
|
|
1393
|
+
upload: /* @__PURE__ */ y(Er, { ref: p }),
|
|
1388
1394
|
url: /* @__PURE__ */ y(lr, { ref: f })
|
|
1389
1395
|
};
|
|
1390
1396
|
return /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y(q, {
|
|
@@ -1430,7 +1436,7 @@ var Tr = it("INSERT_INLINE_IMAGE_COMMAND"), Er = ({ disabled: t, tooltip: n, sho
|
|
|
1430
1436
|
})]
|
|
1431
1437
|
})]
|
|
1432
1438
|
})] });
|
|
1433
|
-
},
|
|
1439
|
+
}, kr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1434
1440
|
let [r] = B(), { canUndo: i } = Rn(), { t: o } = a();
|
|
1435
1441
|
return /* @__PURE__ */ y(q, {
|
|
1436
1442
|
icon: "chexiao",
|
|
@@ -1441,7 +1447,7 @@ var Tr = it("INSERT_INLINE_IMAGE_COMMAND"), Er = ({ disabled: t, tooltip: n, sho
|
|
|
1441
1447
|
r.dispatchCommand(rt, void 0);
|
|
1442
1448
|
}
|
|
1443
1449
|
});
|
|
1444
|
-
},
|
|
1450
|
+
}, Ar = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1445
1451
|
let [r] = B(), { canRedo: i } = Rn(), { t: o } = a();
|
|
1446
1452
|
return /* @__PURE__ */ y(q, {
|
|
1447
1453
|
icon: "fanhui",
|
|
@@ -1450,7 +1456,7 @@ var Tr = it("INSERT_INLINE_IMAGE_COMMAND"), Er = ({ disabled: t, tooltip: n, sho
|
|
|
1450
1456
|
disabled: e || !i,
|
|
1451
1457
|
onClick: () => r.dispatchCommand(et, void 0)
|
|
1452
1458
|
});
|
|
1453
|
-
},
|
|
1459
|
+
}, jr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1454
1460
|
let [r] = B(), { strikethrough: i } = J(), { t: o } = a();
|
|
1455
1461
|
return /* @__PURE__ */ y(q, {
|
|
1456
1462
|
icon: "shanchuxian",
|
|
@@ -1462,7 +1468,7 @@ var Tr = it("INSERT_INLINE_IMAGE_COMMAND"), Er = ({ disabled: t, tooltip: n, sho
|
|
|
1462
1468
|
K(r), r.dispatchCommand(Ke, "strikethrough");
|
|
1463
1469
|
}
|
|
1464
1470
|
});
|
|
1465
|
-
},
|
|
1471
|
+
}, Mr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1466
1472
|
let [r] = B(), { superscript: i } = J(), { t: o } = a();
|
|
1467
1473
|
return /* @__PURE__ */ y(q, {
|
|
1468
1474
|
icon: "shangbiao",
|
|
@@ -1474,7 +1480,7 @@ var Tr = it("INSERT_INLINE_IMAGE_COMMAND"), Er = ({ disabled: t, tooltip: n, sho
|
|
|
1474
1480
|
K(r), r.dispatchCommand(Ke, "superscript");
|
|
1475
1481
|
}
|
|
1476
1482
|
});
|
|
1477
|
-
},
|
|
1483
|
+
}, Nr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1478
1484
|
let [r] = B(), { subscript: i } = J(), { t: o } = a();
|
|
1479
1485
|
return /* @__PURE__ */ y(q, {
|
|
1480
1486
|
icon: "xiabiao",
|
|
@@ -1486,7 +1492,7 @@ var Tr = it("INSERT_INLINE_IMAGE_COMMAND"), Er = ({ disabled: t, tooltip: n, sho
|
|
|
1486
1492
|
K(r), r.dispatchCommand(Ke, "subscript");
|
|
1487
1493
|
}
|
|
1488
1494
|
});
|
|
1489
|
-
},
|
|
1495
|
+
}, Pr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1490
1496
|
let [r] = B(), { t: i } = a();
|
|
1491
1497
|
return /* @__PURE__ */ y(q, {
|
|
1492
1498
|
icon: "zengjiasuojin",
|
|
@@ -1497,7 +1503,7 @@ var Tr = it("INSERT_INLINE_IMAGE_COMMAND"), Er = ({ disabled: t, tooltip: n, sho
|
|
|
1497
1503
|
K(r), r.dispatchCommand(Je, void 0);
|
|
1498
1504
|
}
|
|
1499
1505
|
});
|
|
1500
|
-
},
|
|
1506
|
+
}, Fr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1501
1507
|
let [r] = B(), { canOutdent: i } = J(), o = Pn(), { t: s } = a();
|
|
1502
1508
|
return /* @__PURE__ */ b("div", {
|
|
1503
1509
|
className: G["bsy-lexical__toolbar-with-divider"],
|
|
@@ -1511,7 +1517,7 @@ var Tr = it("INSERT_INLINE_IMAGE_COMMAND"), Er = ({ disabled: t, tooltip: n, sho
|
|
|
1511
1517
|
}
|
|
1512
1518
|
})]
|
|
1513
1519
|
});
|
|
1514
|
-
},
|
|
1520
|
+
}, Ir = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1515
1521
|
let [r] = B(), { listType: i } = J(), { t: o } = a(), s = i === "bullet";
|
|
1516
1522
|
return /* @__PURE__ */ y(q, {
|
|
1517
1523
|
icon: "xuhaoliebiao",
|
|
@@ -1524,7 +1530,7 @@ var Tr = it("INSERT_INLINE_IMAGE_COMMAND"), Er = ({ disabled: t, tooltip: n, sho
|
|
|
1524
1530
|
r.dispatchCommand(e.listType === "bullet" ? bt : _t, void 0);
|
|
1525
1531
|
}
|
|
1526
1532
|
});
|
|
1527
|
-
},
|
|
1533
|
+
}, Lr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1528
1534
|
let [r] = B(), { listType: i } = J(), { t: o } = a(), s = i === "number";
|
|
1529
1535
|
return /* @__PURE__ */ y(q, {
|
|
1530
1536
|
icon: "bianhaoliebiao",
|
|
@@ -1537,7 +1543,7 @@ var Tr = it("INSERT_INLINE_IMAGE_COMMAND"), Er = ({ disabled: t, tooltip: n, sho
|
|
|
1537
1543
|
r.dispatchCommand(e.listType === "number" ? bt : gt, void 0);
|
|
1538
1544
|
}
|
|
1539
1545
|
});
|
|
1540
|
-
},
|
|
1546
|
+
}, Rr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1541
1547
|
let [r] = B(), { isCodeBlock: i } = J(), { t: o } = a();
|
|
1542
1548
|
return /* @__PURE__ */ y(q, {
|
|
1543
1549
|
icon: "daima",
|
|
@@ -1551,13 +1557,13 @@ var Tr = it("INSERT_INLINE_IMAGE_COMMAND"), Er = ({ disabled: t, tooltip: n, sho
|
|
|
1551
1557
|
});
|
|
1552
1558
|
}
|
|
1553
1559
|
});
|
|
1554
|
-
},
|
|
1560
|
+
}, zr = {
|
|
1555
1561
|
"bsy-lexical__table-picker": "_bsy-lexical__table-picker_mv0nn_1",
|
|
1556
1562
|
"bsy-lexical__table-picker-grid": "_bsy-lexical__table-picker-grid_mv0nn_9",
|
|
1557
1563
|
"bsy-lexical__table-picker-cell": "_bsy-lexical__table-picker-cell_mv0nn_15",
|
|
1558
1564
|
"bsy-lexical__table-picker-cell--active": "_bsy-lexical__table-picker-cell--active_mv0nn_24",
|
|
1559
1565
|
"bsy-lexical__table-picker-label": "_bsy-lexical__table-picker-label_mv0nn_28"
|
|
1560
|
-
},
|
|
1566
|
+
}, Br = _(1, 11), Vr = ({ disabled: e, tooltip: r, showDisabledTooltip: i }) => {
|
|
1561
1567
|
let [s] = B(), { isInTable: c } = J(), { t: l } = a(), u = t(), [f, p] = P(!1), [m, h] = P({
|
|
1562
1568
|
rows: 0,
|
|
1563
1569
|
cols: 0
|
|
@@ -1604,17 +1610,17 @@ var Tr = it("INSERT_INLINE_IMAGE_COMMAND"), Er = ({ disabled: t, tooltip: n, sho
|
|
|
1604
1610
|
},
|
|
1605
1611
|
...o,
|
|
1606
1612
|
children: /* @__PURE__ */ b("div", {
|
|
1607
|
-
className:
|
|
1613
|
+
className: zr["bsy-lexical__table-picker"],
|
|
1608
1614
|
onMouseDown: (e) => e.preventDefault(),
|
|
1609
1615
|
onMouseLeave: () => h({
|
|
1610
1616
|
rows: 0,
|
|
1611
1617
|
cols: 0
|
|
1612
1618
|
}),
|
|
1613
1619
|
children: [/* @__PURE__ */ y("div", {
|
|
1614
|
-
className:
|
|
1615
|
-
children:
|
|
1620
|
+
className: zr["bsy-lexical__table-picker-grid"],
|
|
1621
|
+
children: Br.map((e) => Br.map((t) => /* @__PURE__ */ y("button", {
|
|
1616
1622
|
type: "button",
|
|
1617
|
-
className: I(
|
|
1623
|
+
className: I(zr["bsy-lexical__table-picker-cell"], m.rows >= e && m.cols >= t && zr["bsy-lexical__table-picker-cell--active"]),
|
|
1618
1624
|
onMouseEnter: () => h({
|
|
1619
1625
|
rows: e,
|
|
1620
1626
|
cols: t
|
|
@@ -1628,7 +1634,7 @@ var Tr = it("INSERT_INLINE_IMAGE_COMMAND"), Er = ({ disabled: t, tooltip: n, sho
|
|
|
1628
1634
|
}
|
|
1629
1635
|
}, `${e}-${t}`)))
|
|
1630
1636
|
}), /* @__PURE__ */ b("div", {
|
|
1631
|
-
className:
|
|
1637
|
+
className: zr["bsy-lexical__table-picker-label"],
|
|
1632
1638
|
children: [
|
|
1633
1639
|
m.rows,
|
|
1634
1640
|
" × ",
|
|
@@ -1638,12 +1644,12 @@ var Tr = it("INSERT_INLINE_IMAGE_COMMAND"), Er = ({ disabled: t, tooltip: n, sho
|
|
|
1638
1644
|
})
|
|
1639
1645
|
}, "bsy-lexical-table-picker") : null })
|
|
1640
1646
|
}) })] });
|
|
1641
|
-
},
|
|
1642
|
-
let e = E(
|
|
1647
|
+
}, Hr = S(null), Ur = () => {
|
|
1648
|
+
let e = E(Hr);
|
|
1643
1649
|
if (!e) throw Error("useSourceMode must be used within SourceModeProvider");
|
|
1644
1650
|
return e;
|
|
1645
|
-
},
|
|
1646
|
-
let { t: r } = a(), { isSourceMode: i, toggleSourceMode: o } =
|
|
1651
|
+
}, Wr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1652
|
+
let { t: r } = a(), { isSourceMode: i, toggleSourceMode: o } = Ur();
|
|
1647
1653
|
return /* @__PURE__ */ y(q, {
|
|
1648
1654
|
icon: "yuanmamoshi",
|
|
1649
1655
|
tooltip: t ?? r("editor.sourceMode"),
|
|
@@ -1652,7 +1658,7 @@ var Tr = it("INSERT_INLINE_IMAGE_COMMAND"), Er = ({ disabled: t, tooltip: n, sho
|
|
|
1652
1658
|
disabled: e,
|
|
1653
1659
|
onClick: o
|
|
1654
1660
|
});
|
|
1655
|
-
},
|
|
1661
|
+
}, Gr = ({ disabled: t, tooltip: n, showDisabledTooltip: r }) => {
|
|
1656
1662
|
let [i] = B(), { headingTag: o, isInTable: s } = J(), { t: c } = a(), { iconSize: l } = Hn(), u = o || "paragraph", d = [
|
|
1657
1663
|
{
|
|
1658
1664
|
key: "paragraph",
|
|
@@ -1707,7 +1713,7 @@ var Tr = it("INSERT_INLINE_IMAGE_COMMAND"), Er = ({ disabled: t, tooltip: n, sho
|
|
|
1707
1713
|
};
|
|
1708
1714
|
//#endregion
|
|
1709
1715
|
//#region src/components/Editor/utils/clearInlineTextFormat.ts
|
|
1710
|
-
function
|
|
1716
|
+
function Kr() {
|
|
1711
1717
|
let e = R();
|
|
1712
1718
|
if (z(e)) {
|
|
1713
1719
|
kt(e, {
|
|
@@ -1721,7 +1727,7 @@ function Wr() {
|
|
|
1721
1727
|
}
|
|
1722
1728
|
//#endregion
|
|
1723
1729
|
//#region src/components/Editor/ToolbarPlugin/Buttons/ClearFormatButton.tsx
|
|
1724
|
-
var
|
|
1730
|
+
var qr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1725
1731
|
let [r] = B(), { t: i } = a();
|
|
1726
1732
|
return /* @__PURE__ */ y(q, {
|
|
1727
1733
|
icon: "clearTree",
|
|
@@ -1730,18 +1736,18 @@ var Gr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
|
1730
1736
|
disabled: e,
|
|
1731
1737
|
onClick: () => {
|
|
1732
1738
|
K(r), r.update(() => {
|
|
1733
|
-
|
|
1739
|
+
Kr();
|
|
1734
1740
|
});
|
|
1735
1741
|
}
|
|
1736
1742
|
});
|
|
1737
|
-
},
|
|
1743
|
+
}, Jr = /<!--bsy-code-(\d+)-->/g, Yr = [
|
|
1738
1744
|
"quick",
|
|
1739
1745
|
"formal",
|
|
1740
1746
|
"colloquial",
|
|
1741
1747
|
"lively",
|
|
1742
1748
|
"literary",
|
|
1743
1749
|
"retro"
|
|
1744
|
-
],
|
|
1750
|
+
], Xr = {
|
|
1745
1751
|
quick: "editor.aiPresetQuick",
|
|
1746
1752
|
formal: "editor.aiPresetFormal",
|
|
1747
1753
|
colloquial: "editor.aiPresetColloquial",
|
|
@@ -1751,26 +1757,26 @@ var Gr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
|
1751
1757
|
};
|
|
1752
1758
|
//#endregion
|
|
1753
1759
|
//#region src/components/Editor/utils/htmlText.ts
|
|
1754
|
-
function
|
|
1760
|
+
function Zr(e) {
|
|
1755
1761
|
return /<[^>]*$/.test(e.trim());
|
|
1756
1762
|
}
|
|
1757
|
-
function
|
|
1763
|
+
function Qr(e) {
|
|
1758
1764
|
return e ? new DOMParser().parseFromString(e, "text/html").body.textContent ?? "" : "";
|
|
1759
1765
|
}
|
|
1760
1766
|
//#endregion
|
|
1761
1767
|
//#region src/components/Editor/utils/fillRootFromHtml.ts
|
|
1762
|
-
var
|
|
1768
|
+
var $r = [
|
|
1763
1769
|
"color",
|
|
1764
1770
|
"background-color",
|
|
1765
1771
|
"font-size",
|
|
1766
1772
|
"font-family",
|
|
1767
1773
|
"font-weight",
|
|
1768
1774
|
"text-decoration"
|
|
1769
|
-
],
|
|
1775
|
+
], ei = (e) => {
|
|
1770
1776
|
let t = e.body.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, td, th");
|
|
1771
1777
|
for (let n of Array.from(t)) {
|
|
1772
1778
|
let t = n, r = [];
|
|
1773
|
-
for (let e of
|
|
1779
|
+
for (let e of $r) {
|
|
1774
1780
|
let n = t.style.getPropertyValue(e);
|
|
1775
1781
|
n && (r.push(`${e}: ${n}`), t.style.removeProperty(e));
|
|
1776
1782
|
}
|
|
@@ -1788,11 +1794,11 @@ var Zr = [
|
|
|
1788
1794
|
}
|
|
1789
1795
|
}
|
|
1790
1796
|
}
|
|
1791
|
-
},
|
|
1797
|
+
}, ti = (e, t) => {
|
|
1792
1798
|
let n = L();
|
|
1793
1799
|
if (n.clear(), t.trim()) {
|
|
1794
1800
|
let r = new DOMParser().parseFromString(t, "text/html");
|
|
1795
|
-
|
|
1801
|
+
ei(r);
|
|
1796
1802
|
let i = ge(e, r);
|
|
1797
1803
|
if (i.length) {
|
|
1798
1804
|
n.select(), Te(i), Ne(null);
|
|
@@ -1804,12 +1810,12 @@ var Zr = [
|
|
|
1804
1810
|
};
|
|
1805
1811
|
//#endregion
|
|
1806
1812
|
//#region src/components/Editor/utils/isEmptyEditorHtml.ts
|
|
1807
|
-
function
|
|
1813
|
+
function ni(e, t) {
|
|
1808
1814
|
return !t.trim() && (e === "<p><br></p>" || e === "<p></p>" || e === "" || /^<p>\s*<br>\s*<\/p>$/.test(e));
|
|
1809
1815
|
}
|
|
1810
1816
|
//#endregion
|
|
1811
1817
|
//#region src/components/Editor/utils/sanitizeEditorHtml.ts
|
|
1812
|
-
var
|
|
1818
|
+
var ri = /* @__PURE__ */ "p.br.strong.em.b.i.u.s.span.sub.sup.ul.ol.li.a.img.pre.code.table.thead.tbody.tr.td.th.h1.h2.h3.h4.h5.h6".split("."), ii = [
|
|
1813
1819
|
"href",
|
|
1814
1820
|
"src",
|
|
1815
1821
|
"alt",
|
|
@@ -1820,16 +1826,17 @@ var ti = /* @__PURE__ */ "p.br.strong.em.b.i.u.s.span.sub.sup.ul.ol.li.a.img.pre
|
|
|
1820
1826
|
"rowspan",
|
|
1821
1827
|
"data-language",
|
|
1822
1828
|
"data-id",
|
|
1829
|
+
"data-src",
|
|
1823
1830
|
"class",
|
|
1824
1831
|
"style",
|
|
1825
1832
|
"width",
|
|
1826
1833
|
"height"
|
|
1827
|
-
],
|
|
1834
|
+
], ai = new Set(/* @__PURE__ */ "color.background-color.font-size.font-family.font-weight.font-style.text-decoration.text-align.max-width.display.vertical-align.width.height.border.margin.padding.padding-inline-start.line-height.list-style-type.list-style-position.list-style.border-collapse.table-layout.overflow-x.white-space.position.top.bottom.tab-size.border-radius.box-sizing.min-width.min-height.cursor".split(".")), oi = /^(?:(?:(?:f|ht)tps?|mailto|blob):|data:image\/[a-z0-9.+-]+[;,].*|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i, si = new Set([
|
|
1828
1835
|
"pre",
|
|
1829
1836
|
"code",
|
|
1830
1837
|
"td",
|
|
1831
1838
|
"th"
|
|
1832
|
-
]),
|
|
1839
|
+
]), ci = new Set(["pre", "code"]), li = new Set(["sup", "sub"]), ui = (e, t) => ai.has(e) ? e === "padding-inline-start" ? !0 : e === "padding" || e.startsWith("padding-") ? si.has(t) : e === "border-radius" ? ci.has(t) : e === "position" || e === "top" || e === "bottom" ? li.has(t) : !0 : !1, di = (e, t) => e.split(";").map((e) => e.trim()).filter(Boolean).map((e) => {
|
|
1833
1840
|
let n = e.indexOf(":");
|
|
1834
1841
|
if (n === -1) return null;
|
|
1835
1842
|
let r = e.slice(0, n).trim().toLowerCase(), i = e.slice(n + 1).trim();
|
|
@@ -1837,45 +1844,49 @@ var ti = /* @__PURE__ */ "p.br.strong.em.b.i.u.s.span.sub.sup.ul.ol.li.a.img.pre
|
|
|
1837
1844
|
if (/url\s*\(/i.test(i)) return null;
|
|
1838
1845
|
r = "background-color";
|
|
1839
1846
|
}
|
|
1840
|
-
return !
|
|
1841
|
-
}).filter((e) => e !== null).join("; "),
|
|
1842
|
-
|
|
1847
|
+
return !ui(r, t) || /expression|javascript:|url\s*\(\s*['"]?\s*javascript/i.test(i) ? null : `${r}: ${i}`;
|
|
1848
|
+
}).filter((e) => e !== null).join("; "), fi = !1, pi = () => {
|
|
1849
|
+
fi ||= (Xt.addHook("uponSanitizeAttribute", (e, t) => {
|
|
1843
1850
|
if (t.attrName === "href" && /^data:/i.test(t.attrValue)) {
|
|
1844
1851
|
t.keepAttr = !1;
|
|
1845
1852
|
return;
|
|
1846
1853
|
}
|
|
1847
|
-
t.attrName === "style" && (t.attrValue =
|
|
1854
|
+
t.attrName === "style" && (t.attrValue = di(t.attrValue, e.nodeName.toLowerCase()), t.attrValue || (t.keepAttr = !1));
|
|
1848
1855
|
}), !0);
|
|
1849
1856
|
};
|
|
1850
1857
|
function X(e) {
|
|
1851
|
-
return e ? (
|
|
1852
|
-
ALLOWED_TAGS:
|
|
1853
|
-
ALLOWED_ATTR:
|
|
1858
|
+
return e ? (pi(), Xt.sanitize(e, {
|
|
1859
|
+
ALLOWED_TAGS: ri,
|
|
1860
|
+
ALLOWED_ATTR: ii,
|
|
1854
1861
|
ALLOW_DATA_ATTR: !1,
|
|
1855
|
-
ADD_ATTR: [
|
|
1856
|
-
|
|
1862
|
+
ADD_ATTR: [
|
|
1863
|
+
"data-language",
|
|
1864
|
+
"data-id",
|
|
1865
|
+
"data-src"
|
|
1866
|
+
],
|
|
1867
|
+
ALLOWED_URI_REGEXP: oi
|
|
1857
1868
|
})) : "";
|
|
1858
1869
|
}
|
|
1859
1870
|
//#endregion
|
|
1860
1871
|
//#region src/components/Editor/utils/stitchCodePlaceholders.ts
|
|
1861
|
-
var
|
|
1862
|
-
function
|
|
1863
|
-
return new DOMParser().parseFromString(`<${
|
|
1872
|
+
var mi = "bsy-html-root";
|
|
1873
|
+
function hi(e) {
|
|
1874
|
+
return new DOMParser().parseFromString(`<${mi}>${e}</${mi}>`, "text/html").body.querySelector(mi);
|
|
1864
1875
|
}
|
|
1865
|
-
function
|
|
1876
|
+
function gi(e, t) {
|
|
1866
1877
|
if (!t.length) return e;
|
|
1867
|
-
let n = /* @__PURE__ */ new Set(), r = e.replace(
|
|
1878
|
+
let n = /* @__PURE__ */ new Set(), r = e.replace(Jr, (e, r) => {
|
|
1868
1879
|
let i = Number(r), a = t[i];
|
|
1869
1880
|
return a === void 0 ? "" : (n.add(i), a);
|
|
1870
1881
|
}), i = t.filter((e, t) => !n.has(t)).join("");
|
|
1871
1882
|
return i ? `${r}${i}` : r;
|
|
1872
1883
|
}
|
|
1873
|
-
function
|
|
1874
|
-
return
|
|
1884
|
+
function _i(e, t) {
|
|
1885
|
+
return gi(vi(e), t);
|
|
1875
1886
|
}
|
|
1876
|
-
function
|
|
1887
|
+
function vi(e) {
|
|
1877
1888
|
if (!/<pre[\s>/]/i.test(e)) return e;
|
|
1878
|
-
let t =
|
|
1889
|
+
let t = hi(e);
|
|
1879
1890
|
if (!t) return e;
|
|
1880
1891
|
let n = t.ownerDocument;
|
|
1881
1892
|
for (let e of Array.from(t.querySelectorAll("pre"))) {
|
|
@@ -1886,53 +1897,53 @@ function gi(e) {
|
|
|
1886
1897
|
}
|
|
1887
1898
|
//#endregion
|
|
1888
1899
|
//#region src/components/Editor/constants/portableEditorStyles.ts
|
|
1889
|
-
var
|
|
1900
|
+
var yi = {
|
|
1890
1901
|
margin: "0.6em 0 0.4em",
|
|
1891
1902
|
"font-weight": "600",
|
|
1892
1903
|
"line-height": "1.35"
|
|
1893
|
-
},
|
|
1904
|
+
}, bi = {
|
|
1894
1905
|
h1: {
|
|
1895
|
-
...
|
|
1906
|
+
...yi,
|
|
1896
1907
|
"font-size": "2em"
|
|
1897
1908
|
},
|
|
1898
1909
|
h2: {
|
|
1899
|
-
...
|
|
1910
|
+
...yi,
|
|
1900
1911
|
"font-size": "1.5em"
|
|
1901
1912
|
},
|
|
1902
1913
|
h3: {
|
|
1903
|
-
...
|
|
1914
|
+
...yi,
|
|
1904
1915
|
"font-size": "1.25em"
|
|
1905
1916
|
},
|
|
1906
1917
|
h4: {
|
|
1907
|
-
...
|
|
1918
|
+
...yi,
|
|
1908
1919
|
"font-size": "1.125em"
|
|
1909
1920
|
},
|
|
1910
1921
|
h5: {
|
|
1911
|
-
...
|
|
1922
|
+
...yi,
|
|
1912
1923
|
"font-size": "1em"
|
|
1913
1924
|
},
|
|
1914
1925
|
h6: {
|
|
1915
|
-
...
|
|
1926
|
+
...yi,
|
|
1916
1927
|
"font-size": "0.875em"
|
|
1917
1928
|
}
|
|
1918
|
-
},
|
|
1929
|
+
}, xi = {
|
|
1919
1930
|
color: "#0269ff",
|
|
1920
1931
|
cursor: "pointer"
|
|
1921
|
-
},
|
|
1932
|
+
}, Si = {
|
|
1922
1933
|
margin: "0",
|
|
1923
1934
|
"padding-inline-start": "24px",
|
|
1924
1935
|
"list-style-position": "outside"
|
|
1925
|
-
},
|
|
1936
|
+
}, Ci = [
|
|
1926
1937
|
"disc",
|
|
1927
1938
|
"circle",
|
|
1928
1939
|
"square"
|
|
1929
|
-
],
|
|
1940
|
+
], wi = {
|
|
1930
1941
|
margin: "0",
|
|
1931
1942
|
"list-style": "inherit"
|
|
1932
|
-
},
|
|
1943
|
+
}, Ti = {
|
|
1933
1944
|
margin: "0",
|
|
1934
1945
|
"list-style-type": "none"
|
|
1935
|
-
},
|
|
1946
|
+
}, Ei = {
|
|
1936
1947
|
display: "block",
|
|
1937
1948
|
"box-sizing": "border-box",
|
|
1938
1949
|
"max-width": "100%",
|
|
@@ -1947,23 +1958,23 @@ var _i = {
|
|
|
1947
1958
|
"border-radius": "4px",
|
|
1948
1959
|
"background-color": "rgb(240, 242, 245)",
|
|
1949
1960
|
color: "#1f2328"
|
|
1950
|
-
},
|
|
1961
|
+
}, Di = {
|
|
1951
1962
|
"border-collapse": "collapse",
|
|
1952
1963
|
"table-layout": "fixed",
|
|
1953
1964
|
width: "100%",
|
|
1954
1965
|
"overflow-x": "auto",
|
|
1955
1966
|
margin: "8px 0"
|
|
1956
|
-
},
|
|
1967
|
+
}, Oi = {
|
|
1957
1968
|
"box-sizing": "border-box",
|
|
1958
1969
|
"min-width": "75px",
|
|
1959
1970
|
"min-height": "32px",
|
|
1960
1971
|
padding: "4px 8px",
|
|
1961
1972
|
border: "1px solid #d9d9d9",
|
|
1962
1973
|
"vertical-align": "top"
|
|
1963
|
-
},
|
|
1974
|
+
}, ki = {
|
|
1964
1975
|
"font-weight": "600",
|
|
1965
1976
|
"background-color": "#f2f3f5"
|
|
1966
|
-
},
|
|
1977
|
+
}, Ai = {
|
|
1967
1978
|
display: "inline-block",
|
|
1968
1979
|
position: "static",
|
|
1969
1980
|
top: "auto",
|
|
@@ -1972,38 +1983,38 @@ var _i = {
|
|
|
1972
1983
|
"line-height": "1"
|
|
1973
1984
|
}, Z = (e, t) => {
|
|
1974
1985
|
for (let [n, r] of Object.entries(t)) e.style.getPropertyValue(n) || e.style.setProperty(n, r);
|
|
1975
|
-
},
|
|
1986
|
+
}, ji = (e) => {
|
|
1976
1987
|
let t = 0, n = e;
|
|
1977
1988
|
for (; n;) n.tagName === "UL" && (t += 1), n = n.parentElement;
|
|
1978
1989
|
return t;
|
|
1979
|
-
},
|
|
1990
|
+
}, Mi = (e) => {
|
|
1980
1991
|
for (let t of Array.from(e.querySelectorAll("*"))) {
|
|
1981
1992
|
if (!(t instanceof HTMLElement)) continue;
|
|
1982
|
-
let e = t.tagName.toLowerCase(), n =
|
|
1983
|
-
if (n && Z(t, n), e === "a" && Z(t,
|
|
1984
|
-
let e = Math.min(Math.max(
|
|
1993
|
+
let e = t.tagName.toLowerCase(), n = bi[e];
|
|
1994
|
+
if (n && Z(t, n), e === "a" && Z(t, xi), e === "ul") {
|
|
1995
|
+
let e = Math.min(Math.max(ji(t), 1), Ci.length);
|
|
1985
1996
|
Z(t, {
|
|
1986
|
-
...
|
|
1987
|
-
"list-style-type":
|
|
1997
|
+
...Si,
|
|
1998
|
+
"list-style-type": Ci[e - 1]
|
|
1988
1999
|
});
|
|
1989
2000
|
}
|
|
1990
2001
|
e === "ol" && Z(t, {
|
|
1991
|
-
...
|
|
2002
|
+
...Si,
|
|
1992
2003
|
"list-style-type": "decimal"
|
|
1993
|
-
}), e === "li" && Z(t, t.classList.contains("editor-nested-listitem") ?
|
|
1994
|
-
...
|
|
2004
|
+
}), e === "li" && Z(t, t.classList.contains("editor-nested-listitem") ? Ti : wi), e === "pre" && Z(t, Ei), (e === "sup" || e === "sub") && Z(t, {
|
|
2005
|
+
...Ai,
|
|
1995
2006
|
"vertical-align": e === "sup" ? "super" : "sub"
|
|
1996
|
-
}), e === "table" && Z(t,
|
|
2007
|
+
}), e === "table" && Z(t, Di), (e === "td" || e === "th") && (Z(t, Oi), (e === "th" || t.classList.contains("editor-table-cell-header")) && Z(t, ki)), t.classList.contains("editor-text-underline-strikethrough") ? Z(t, { "text-decoration": "underline line-through" }) : t.classList.contains("editor-text-underline") ? Z(t, { "text-decoration": "underline" }) : t.classList.contains("editor-text-strikethrough") && Z(t, { "text-decoration": "line-through" });
|
|
1997
2008
|
for (let e of Array.from(t.classList)) e.startsWith("editor-") && t.classList.remove(e);
|
|
1998
2009
|
t.classList.length === 0 && t.removeAttribute("class");
|
|
1999
2010
|
}
|
|
2000
|
-
},
|
|
2011
|
+
}, Ni = (e) => {
|
|
2001
2012
|
let t = e.parentNode;
|
|
2002
2013
|
if (t) {
|
|
2003
2014
|
for (; e.firstChild;) t.insertBefore(e.firstChild, e);
|
|
2004
2015
|
t.removeChild(e);
|
|
2005
2016
|
}
|
|
2006
|
-
},
|
|
2017
|
+
}, Pi = (e) => {
|
|
2007
2018
|
let t = !0;
|
|
2008
2019
|
for (; t;) {
|
|
2009
2020
|
t = !1;
|
|
@@ -2011,35 +2022,35 @@ var _i = {
|
|
|
2011
2022
|
if (n.attributes.length > 0) continue;
|
|
2012
2023
|
let e = n.tagName.toLowerCase();
|
|
2013
2024
|
if (e === "span") {
|
|
2014
|
-
|
|
2025
|
+
Ni(n), t = !0;
|
|
2015
2026
|
continue;
|
|
2016
2027
|
}
|
|
2017
2028
|
if (n.childElementCount !== 1 || n.childNodes.length !== 1) continue;
|
|
2018
2029
|
let r = n.firstElementChild;
|
|
2019
|
-
(e === "b" && r?.tagName === "STRONG" || e === "i" && r?.tagName === "EM") && (
|
|
2030
|
+
(e === "b" && r?.tagName === "STRONG" || e === "i" && r?.tagName === "EM") && (Ni(n), t = !0);
|
|
2020
2031
|
}
|
|
2021
2032
|
}
|
|
2022
2033
|
};
|
|
2023
|
-
function
|
|
2034
|
+
function Fi(e) {
|
|
2024
2035
|
if (!e.trim()) return e;
|
|
2025
2036
|
let t = new DOMParser().parseFromString(e, "text/html");
|
|
2026
|
-
|
|
2037
|
+
Mi(t.body), Pi(t.body);
|
|
2027
2038
|
for (let e of Array.from(t.body.querySelectorAll("pre"))) e.textContent?.trim() || e.remove();
|
|
2028
2039
|
return t.body.innerHTML;
|
|
2029
2040
|
}
|
|
2030
2041
|
//#endregion
|
|
2031
2042
|
//#region src/components/Editor/utils/applyAiPolish.ts
|
|
2032
|
-
var
|
|
2033
|
-
function
|
|
2034
|
-
return e.join(`\n\n${
|
|
2043
|
+
var Ii = "<!--bsy-block-->";
|
|
2044
|
+
function Li(e) {
|
|
2045
|
+
return e.join(`\n\n${Ii}\n\n`);
|
|
2035
2046
|
}
|
|
2036
|
-
function
|
|
2037
|
-
return e.includes("<!--bsy-block-->") ? e.split(
|
|
2047
|
+
function Ri(e) {
|
|
2048
|
+
return e.includes("<!--bsy-block-->") ? e.split(Ii).map((e) => e.trim()) : [e];
|
|
2038
2049
|
}
|
|
2039
|
-
function
|
|
2040
|
-
return e.split(
|
|
2050
|
+
function zi(e) {
|
|
2051
|
+
return e.split(Ii).join("").trim().length > 0;
|
|
2041
2052
|
}
|
|
2042
|
-
function
|
|
2053
|
+
function Bi(e, t) {
|
|
2043
2054
|
let n = e.map(() => "");
|
|
2044
2055
|
if (e.length === 0) return n;
|
|
2045
2056
|
let r = [], i = [];
|
|
@@ -2053,7 +2064,7 @@ function Ri(e, t) {
|
|
|
2053
2064
|
for (; d < c;) n[n.length - 1] += o[d], d += 1;
|
|
2054
2065
|
return n;
|
|
2055
2066
|
}
|
|
2056
|
-
var
|
|
2067
|
+
var Vi = new Set(["PRE"]), Hi = new Set([
|
|
2057
2068
|
"PRE",
|
|
2058
2069
|
"TABLE",
|
|
2059
2070
|
"THEAD",
|
|
@@ -2064,11 +2075,11 @@ var zi = new Set(["PRE"]), Bi = new Set([
|
|
|
2064
2075
|
"IMG",
|
|
2065
2076
|
"BR"
|
|
2066
2077
|
]);
|
|
2067
|
-
function
|
|
2078
|
+
function Ui(e) {
|
|
2068
2079
|
let t = [], n = (e) => {
|
|
2069
2080
|
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
2070
2081
|
let t = e.tagName;
|
|
2071
|
-
if (
|
|
2082
|
+
if (Vi.has(t)) return;
|
|
2072
2083
|
for (let t of Array.from(e.childNodes)) n(t);
|
|
2073
2084
|
return;
|
|
2074
2085
|
}
|
|
@@ -2076,31 +2087,31 @@ function Vi(e) {
|
|
|
2076
2087
|
};
|
|
2077
2088
|
return n(e), t;
|
|
2078
2089
|
}
|
|
2079
|
-
function
|
|
2090
|
+
function Wi(e, t) {
|
|
2080
2091
|
let n = e;
|
|
2081
|
-
for (; n && n !== t && !
|
|
2092
|
+
for (; n && n !== t && !Hi.has(n.tagName) && !(n.textContent ?? "").trim() && !n.querySelector("img, pre, table, br");) {
|
|
2082
2093
|
let e = n.parentElement;
|
|
2083
2094
|
n.remove(), n = e;
|
|
2084
2095
|
}
|
|
2085
2096
|
}
|
|
2086
|
-
function
|
|
2097
|
+
function Gi(e) {
|
|
2087
2098
|
let t = e.tagName;
|
|
2088
2099
|
return t === "PRE" || t === "IMG" || t === "TABLE";
|
|
2089
2100
|
}
|
|
2090
|
-
function
|
|
2091
|
-
let t =
|
|
2092
|
-
return t ? Array.from(t.children).filter((e) => !
|
|
2101
|
+
function Ki(e) {
|
|
2102
|
+
let t = hi(e);
|
|
2103
|
+
return t ? Array.from(t.children).filter((e) => !Gi(e)).map((e) => e.textContent ?? "") : [];
|
|
2093
2104
|
}
|
|
2094
|
-
function
|
|
2095
|
-
return e.includes("<!--bsy-block-->") ? e :
|
|
2105
|
+
function qi(e) {
|
|
2106
|
+
return e.includes("<!--bsy-block-->") ? e : Qr(e) || e;
|
|
2096
2107
|
}
|
|
2097
|
-
function
|
|
2098
|
-
let n =
|
|
2108
|
+
function Ji(e, t) {
|
|
2109
|
+
let n = Ui(e);
|
|
2099
2110
|
if (n.length === 0) {
|
|
2100
2111
|
t && (e.querySelector("br")?.remove(), e.append(e.ownerDocument.createTextNode(t)));
|
|
2101
2112
|
return;
|
|
2102
2113
|
}
|
|
2103
|
-
let r =
|
|
2114
|
+
let r = Bi(n.map((e) => e.textContent ?? ""), t);
|
|
2104
2115
|
for (let t = 0; t < n.length; t++) {
|
|
2105
2116
|
let i = r[t], a = n[t];
|
|
2106
2117
|
if (i) {
|
|
@@ -2108,33 +2119,33 @@ function Ki(e, t) {
|
|
|
2108
2119
|
continue;
|
|
2109
2120
|
}
|
|
2110
2121
|
let o = a.parentElement;
|
|
2111
|
-
a.remove(),
|
|
2122
|
+
a.remove(), Wi(o, e);
|
|
2112
2123
|
}
|
|
2113
2124
|
}
|
|
2114
|
-
function
|
|
2115
|
-
let n =
|
|
2116
|
-
if (!
|
|
2117
|
-
let r =
|
|
2125
|
+
function Yi(e, t) {
|
|
2126
|
+
let n = qi(t);
|
|
2127
|
+
if (!zi(n) || !e.trim()) return "";
|
|
2128
|
+
let r = hi(e);
|
|
2118
2129
|
if (!r) return "";
|
|
2119
|
-
let i = Array.from(r.children).filter((e) => !
|
|
2130
|
+
let i = Array.from(r.children).filter((e) => !Gi(e));
|
|
2120
2131
|
if (i.length === 0) return "";
|
|
2121
|
-
let a =
|
|
2122
|
-
for (let e = 0; e < i.length; e++)
|
|
2132
|
+
let a = Ri(n), o = a.length === i.length ? a : Bi(i.map((e) => e.textContent ?? ""), a.join(""));
|
|
2133
|
+
for (let e = 0; e < i.length; e++) Ji(i[e], o[e] ?? "");
|
|
2123
2134
|
return r.innerHTML;
|
|
2124
2135
|
}
|
|
2125
|
-
function
|
|
2136
|
+
function Xi(e, t) {
|
|
2126
2137
|
let n = "";
|
|
2127
2138
|
e.getEditorState().read(() => {
|
|
2128
|
-
n =
|
|
2139
|
+
n = Fi(X(he(e, null)));
|
|
2129
2140
|
}, { editor: e });
|
|
2130
|
-
let r = X(
|
|
2131
|
-
return !r.trim() ||
|
|
2132
|
-
|
|
2141
|
+
let r = X(Yi(n, t));
|
|
2142
|
+
return !r.trim() || ni(r, Qr(r)) ? !1 : (e.update(() => {
|
|
2143
|
+
ti(e, r), Dn(!0);
|
|
2133
2144
|
}, { discrete: !0 }), !0);
|
|
2134
2145
|
}
|
|
2135
2146
|
//#endregion
|
|
2136
2147
|
//#region src/components/Editor/utils/extractCodePlaceholders.ts
|
|
2137
|
-
function
|
|
2148
|
+
function Zi(e) {
|
|
2138
2149
|
if (!e.trim()) return {
|
|
2139
2150
|
html: e,
|
|
2140
2151
|
blocks: []
|
|
@@ -2152,12 +2163,12 @@ function Yi(e) {
|
|
|
2152
2163
|
}
|
|
2153
2164
|
//#endregion
|
|
2154
2165
|
//#region src/components/Editor/utils/readEditorAiSnapshot.ts
|
|
2155
|
-
function
|
|
2166
|
+
function Qi(e) {
|
|
2156
2167
|
let t = "", n = "", r = "";
|
|
2157
2168
|
e.getEditorState().read(() => {
|
|
2158
|
-
n = L().getTextContent(), t =
|
|
2169
|
+
n = L().getTextContent(), t = Fi(X(he(e, null))), r = Li(Ki(t));
|
|
2159
2170
|
}, { editor: e });
|
|
2160
|
-
let i =
|
|
2171
|
+
let i = Zi(t);
|
|
2161
2172
|
return {
|
|
2162
2173
|
html: t,
|
|
2163
2174
|
text: n,
|
|
@@ -2196,10 +2207,10 @@ var Q = {
|
|
|
2196
2207
|
"bsy-lexical-ai__footer": "_bsy-lexical-ai__footer_p7v4i_165",
|
|
2197
2208
|
"bsy-lexical-ai__error": "_bsy-lexical-ai__error_p7v4i_173",
|
|
2198
2209
|
"bsy-lexical-ai__preset": "_bsy-lexical-ai__preset_p7v4i_178"
|
|
2199
|
-
},
|
|
2200
|
-
let [i] = B(), { typeset: o, polish: s, canTypeset: c, canPolish: l, aiOpen: u, setAiOpen: d, aiSessionRef: p } =
|
|
2210
|
+
}, $i = "data:image/png;base64,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", ea = "data:image/png;base64,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", ta = 16, na = ({ disabled: t, tooltip: n, showDisabledTooltip: r }) => {
|
|
2211
|
+
let [i] = B(), { typeset: o, polish: s, canTypeset: c, canPolish: l, aiOpen: u, setAiOpen: d, aiSessionRef: p } = hr(), { hasEditorText: m } = J(), { t: h } = a(), { iconSize: g } = Hn(), _ = t || !c || !m, x = t || !l || !m, S = t || !!u, C = T(() => {
|
|
2201
2212
|
if (t || !c || !o) return;
|
|
2202
|
-
let e =
|
|
2213
|
+
let e = Qi(i);
|
|
2203
2214
|
e.text.trim() && (p.current = {
|
|
2204
2215
|
originalHtml: e.html,
|
|
2205
2216
|
codeBlocks: e.codeBlocks
|
|
@@ -2216,8 +2227,8 @@ var Q = {
|
|
|
2216
2227
|
o
|
|
2217
2228
|
]), w = T((e) => {
|
|
2218
2229
|
if (t || !l || !s) return;
|
|
2219
|
-
let n =
|
|
2220
|
-
|
|
2230
|
+
let n = Qi(i);
|
|
2231
|
+
zi(n.polishText) && (p.current = {
|
|
2221
2232
|
originalHtml: n.html,
|
|
2222
2233
|
originalText: n.polishText,
|
|
2223
2234
|
preset: e
|
|
@@ -2237,16 +2248,16 @@ var Q = {
|
|
|
2237
2248
|
C();
|
|
2238
2249
|
return;
|
|
2239
2250
|
}
|
|
2240
|
-
|
|
2251
|
+
Yr.includes(e.key) && w(e.key);
|
|
2241
2252
|
}, [w, C]), D = [{
|
|
2242
2253
|
key: "typeset",
|
|
2243
2254
|
label: h("editor.aiTypeset"),
|
|
2244
2255
|
disabled: _,
|
|
2245
2256
|
icon: /* @__PURE__ */ y("img", {
|
|
2246
|
-
src:
|
|
2257
|
+
src: $i,
|
|
2247
2258
|
alt: "",
|
|
2248
|
-
width:
|
|
2249
|
-
height:
|
|
2259
|
+
width: ta,
|
|
2260
|
+
height: ta,
|
|
2250
2261
|
className: Q["bsy-lexical-ai__icon"],
|
|
2251
2262
|
draggable: !1
|
|
2252
2263
|
})
|
|
@@ -2255,16 +2266,16 @@ var Q = {
|
|
|
2255
2266
|
label: h("editor.aiPolish"),
|
|
2256
2267
|
disabled: x,
|
|
2257
2268
|
icon: /* @__PURE__ */ y("img", {
|
|
2258
|
-
src:
|
|
2269
|
+
src: ea,
|
|
2259
2270
|
alt: "",
|
|
2260
|
-
width:
|
|
2261
|
-
height:
|
|
2271
|
+
width: ta,
|
|
2272
|
+
height: ta,
|
|
2262
2273
|
className: Q["bsy-lexical-ai__icon"],
|
|
2263
2274
|
draggable: !1
|
|
2264
2275
|
}),
|
|
2265
|
-
children:
|
|
2276
|
+
children: Yr.map((e) => ({
|
|
2266
2277
|
key: e,
|
|
2267
|
-
label: h(
|
|
2278
|
+
label: h(Xr[e])
|
|
2268
2279
|
}))
|
|
2269
2280
|
}], O = /* @__PURE__ */ y("div", {
|
|
2270
2281
|
className: I(G["bsy-lexical__toolbar-select"], G["bsy-lexical__toolbar-select--ai"], Q["bsy-lexical-ai__trigger"]),
|
|
@@ -2274,10 +2285,10 @@ var Q = {
|
|
|
2274
2285
|
disabled: S,
|
|
2275
2286
|
icon: /* @__PURE__ */ b(v, { children: [
|
|
2276
2287
|
/* @__PURE__ */ y("img", {
|
|
2277
|
-
src:
|
|
2288
|
+
src: $i,
|
|
2278
2289
|
alt: "",
|
|
2279
|
-
width:
|
|
2280
|
-
height:
|
|
2290
|
+
width: ta,
|
|
2291
|
+
height: ta,
|
|
2281
2292
|
className: Q["bsy-lexical-ai__icon"],
|
|
2282
2293
|
draggable: !1
|
|
2283
2294
|
}),
|
|
@@ -2304,44 +2315,44 @@ var Q = {
|
|
|
2304
2315
|
},
|
|
2305
2316
|
children: O
|
|
2306
2317
|
});
|
|
2307
|
-
},
|
|
2318
|
+
}, ra = /* @__PURE__ */ new Map(), ia = (e, t) => {
|
|
2308
2319
|
if (!e) throw Error("registerToolbarButton: name is required");
|
|
2309
|
-
|
|
2310
|
-
},
|
|
2311
|
-
|
|
2312
|
-
},
|
|
2320
|
+
ra.set(e, t);
|
|
2321
|
+
}, aa = (e) => {
|
|
2322
|
+
ra.delete(e);
|
|
2323
|
+
}, oa = (e) => ra.get(e), sa = () => Array.from(ra.keys());
|
|
2313
2324
|
Object.entries({
|
|
2314
|
-
undo:
|
|
2315
|
-
redo:
|
|
2325
|
+
undo: kr,
|
|
2326
|
+
redo: Ar,
|
|
2316
2327
|
bold: Wn,
|
|
2317
2328
|
underline: Gn,
|
|
2318
2329
|
italic: Kn,
|
|
2319
|
-
strikethrough:
|
|
2320
|
-
superscript:
|
|
2321
|
-
subscript:
|
|
2322
|
-
heading:
|
|
2330
|
+
strikethrough: jr,
|
|
2331
|
+
superscript: Mr,
|
|
2332
|
+
subscript: Nr,
|
|
2333
|
+
heading: Gr,
|
|
2323
2334
|
fontSize: qn,
|
|
2324
2335
|
fontColor: nr,
|
|
2325
2336
|
fill: rr,
|
|
2326
|
-
clearFormat:
|
|
2327
|
-
bullet:
|
|
2328
|
-
number:
|
|
2329
|
-
outdent:
|
|
2330
|
-
indent:
|
|
2337
|
+
clearFormat: qr,
|
|
2338
|
+
bullet: Ir,
|
|
2339
|
+
number: Lr,
|
|
2340
|
+
outdent: Fr,
|
|
2341
|
+
indent: Pr,
|
|
2331
2342
|
align: ar,
|
|
2332
2343
|
link: sr,
|
|
2333
2344
|
unLink: cr,
|
|
2334
|
-
picture:
|
|
2335
|
-
code:
|
|
2336
|
-
table:
|
|
2337
|
-
source:
|
|
2338
|
-
ai:
|
|
2345
|
+
picture: Or,
|
|
2346
|
+
code: Rr,
|
|
2347
|
+
table: Vr,
|
|
2348
|
+
source: Wr,
|
|
2349
|
+
ai: na
|
|
2339
2350
|
}).forEach(([e, t]) => {
|
|
2340
|
-
|
|
2351
|
+
ia(e, t);
|
|
2341
2352
|
});
|
|
2342
2353
|
//#endregion
|
|
2343
2354
|
//#region src/components/Editor/utils/getToolbarItems.ts
|
|
2344
|
-
var
|
|
2355
|
+
var ca = (e, t, n) => {
|
|
2345
2356
|
if (n) return [
|
|
2346
2357
|
{
|
|
2347
2358
|
kind: "button",
|
|
@@ -2399,10 +2410,10 @@ var oa = (e, t, n) => {
|
|
|
2399
2410
|
key: `divider-${t.key}`
|
|
2400
2411
|
});
|
|
2401
2412
|
}), r;
|
|
2402
|
-
},
|
|
2413
|
+
}, la = Cn.map((e) => ({
|
|
2403
2414
|
key: e.id,
|
|
2404
2415
|
label: e.label
|
|
2405
|
-
})),
|
|
2416
|
+
})), ua = () => {
|
|
2406
2417
|
let [t] = B(), { codeLanguage: n } = J(), { t: r } = a(), { iconSize: i } = Hn(), o = T((e) => {
|
|
2407
2418
|
let n = e.key;
|
|
2408
2419
|
K(t), t.update(() => {
|
|
@@ -2411,7 +2422,7 @@ var oa = (e, t, n) => {
|
|
|
2411
2422
|
});
|
|
2412
2423
|
}, [t]), s = wn[n].label;
|
|
2413
2424
|
return /* @__PURE__ */ y(f, {
|
|
2414
|
-
menus:
|
|
2425
|
+
menus: la,
|
|
2415
2426
|
onClick: o,
|
|
2416
2427
|
activeKey: [n],
|
|
2417
2428
|
showSearch: !1,
|
|
@@ -2436,7 +2447,7 @@ var oa = (e, t, n) => {
|
|
|
2436
2447
|
})
|
|
2437
2448
|
})
|
|
2438
2449
|
});
|
|
2439
|
-
},
|
|
2450
|
+
}, da = {
|
|
2440
2451
|
initial: {
|
|
2441
2452
|
opacity: 0,
|
|
2442
2453
|
x: 6
|
|
@@ -2449,13 +2460,13 @@ var oa = (e, t, n) => {
|
|
|
2449
2460
|
opacity: 0,
|
|
2450
2461
|
x: -6
|
|
2451
2462
|
}
|
|
2452
|
-
},
|
|
2463
|
+
}, fa = (e) => {
|
|
2453
2464
|
if (e.kind === "divider") return /* @__PURE__ */ y("div", { className: G["bsy-lexical__toolbar-divider"] });
|
|
2454
|
-
if (e.kind === "language") return /* @__PURE__ */ y(
|
|
2455
|
-
let t =
|
|
2465
|
+
if (e.kind === "language") return /* @__PURE__ */ y(ua, {});
|
|
2466
|
+
let t = oa(e.name);
|
|
2456
2467
|
return t ? /* @__PURE__ */ y(t, { ...e.props }) : (console.warn(`[ToolbarPlugin] Button "${e.name}" is not registered.`), null);
|
|
2457
|
-
},
|
|
2458
|
-
let i =
|
|
2468
|
+
}, pa = C(function({ item: e, motionProps: t, transition: n }, r) {
|
|
2469
|
+
let i = fa(e);
|
|
2459
2470
|
return i === null ? null : /* @__PURE__ */ y(oe.div, {
|
|
2460
2471
|
ref: r,
|
|
2461
2472
|
"data-toolbar-item-key": e.key,
|
|
@@ -2465,8 +2476,8 @@ var oa = (e, t, n) => {
|
|
|
2465
2476
|
...t,
|
|
2466
2477
|
children: i
|
|
2467
2478
|
}, e.key);
|
|
2468
|
-
}),
|
|
2469
|
-
let { isCodeBlock: n } = J(), { isSourceMode: r } =
|
|
2479
|
+
}), ma = ({ config: e, sizeToken: t }) => {
|
|
2480
|
+
let { isCodeBlock: n } = J(), { isSourceMode: r } = Ur(), i = se(), o = M(() => ca(e, n, r), [
|
|
2470
2481
|
e,
|
|
2471
2482
|
n,
|
|
2472
2483
|
r
|
|
@@ -2483,7 +2494,7 @@ var oa = (e, t, n) => {
|
|
|
2483
2494
|
let [_, v] = P(!1), x = {
|
|
2484
2495
|
duration: i ? 0 : .16,
|
|
2485
2496
|
ease: "easeOut"
|
|
2486
|
-
}, S = i ? {} :
|
|
2497
|
+
}, S = i ? {} : da, C = T(() => {
|
|
2487
2498
|
let e = l.current;
|
|
2488
2499
|
if (!e || f.current && g.current !== o.length) return;
|
|
2489
2500
|
let t = getComputedStyle(e), n = Number.parseFloat(t.columnGap || t.gap) || 0, r = e.clientWidth, i = new Set(o.map((e) => e.key));
|
|
@@ -2531,7 +2542,7 @@ var oa = (e, t, n) => {
|
|
|
2531
2542
|
/* @__PURE__ */ y(ae, {
|
|
2532
2543
|
initial: !1,
|
|
2533
2544
|
mode: "popLayout",
|
|
2534
|
-
children: w.map((e) => /* @__PURE__ */ y(
|
|
2545
|
+
children: w.map((e) => /* @__PURE__ */ y(pa, {
|
|
2535
2546
|
item: e,
|
|
2536
2547
|
motionProps: S,
|
|
2537
2548
|
transition: x
|
|
@@ -2560,7 +2571,7 @@ var oa = (e, t, n) => {
|
|
|
2560
2571
|
className: I(G["bsy-lexical__toolbar-overflow-row"], k && G["bsy-lexical__toolbar-overflow-row--open"], i && G["bsy-lexical__toolbar-overflow-row--instant"]),
|
|
2561
2572
|
children: /* @__PURE__ */ y("div", {
|
|
2562
2573
|
className: G["bsy-lexical__toolbar-overflow-inner"],
|
|
2563
|
-
children: F.map((e) => /* @__PURE__ */ y(
|
|
2574
|
+
children: F.map((e) => /* @__PURE__ */ y(pa, {
|
|
2564
2575
|
item: e,
|
|
2565
2576
|
motionProps: {},
|
|
2566
2577
|
transition: x
|
|
@@ -2568,8 +2579,8 @@ var oa = (e, t, n) => {
|
|
|
2568
2579
|
})
|
|
2569
2580
|
}) : null]
|
|
2570
2581
|
});
|
|
2571
|
-
},
|
|
2572
|
-
let { config: t = [], style: n, theme: r, mode: i, floating: a, stickyOffset: o, size: s = on } = e, { toolbarRef: c } =
|
|
2582
|
+
}, ha = (e) => {
|
|
2583
|
+
let { config: t = [], style: n, theme: r, mode: i, floating: a, stickyOffset: o, size: s = on } = e, { toolbarRef: c } = hr(), l = i === "floating", u = o !== void 0, d = se(), f = {
|
|
2573
2584
|
duration: d ? 0 : .16,
|
|
2574
2585
|
ease: "easeOut"
|
|
2575
2586
|
}, p = M(() => ln(r, s), [r, s]), m = M(() => ({ iconSize: un(r?.iconSize, s) }), [r?.iconSize, s]), h = l ? dn(a) : void 0, _ = l ? g(n, [
|
|
@@ -2596,7 +2607,7 @@ var oa = (e, t, n) => {
|
|
|
2596
2607
|
...h,
|
|
2597
2608
|
..._
|
|
2598
2609
|
},
|
|
2599
|
-
children: /* @__PURE__ */ y(
|
|
2610
|
+
children: /* @__PURE__ */ y(ma, {
|
|
2600
2611
|
config: t,
|
|
2601
2612
|
sizeToken: `${s}|${r?.itemHeight ?? ""}|${r?.iconSize ?? ""}`
|
|
2602
2613
|
})
|
|
@@ -2612,12 +2623,12 @@ var oa = (e, t, n) => {
|
|
|
2612
2623
|
"bsy-lexical-editor__content-editable": "_bsy-lexical-editor__content-editable_1l05x_28",
|
|
2613
2624
|
"bsy-lexical-editor__length-badge": "_bsy-lexical-editor__length-badge_1l05x_41",
|
|
2614
2625
|
"bsy-lexical-editor__length-badge--exceeded": "_bsy-lexical-editor__length-badge--exceeded_1l05x_53"
|
|
2615
|
-
},
|
|
2626
|
+
}, ga = (e) => {
|
|
2616
2627
|
if (!(e === void 0 || e === "")) return typeof e == "number" ? `${e}px` : e;
|
|
2617
|
-
},
|
|
2628
|
+
}, _a = (e) => {
|
|
2618
2629
|
let t = {};
|
|
2619
|
-
return e ? (s(t, "--bsy-editor-container-border-color", e.borderColor), s(t, "--bsy-editor-container-border-width",
|
|
2620
|
-
},
|
|
2630
|
+
return e ? (s(t, "--bsy-editor-container-border-color", e.borderColor), s(t, "--bsy-editor-container-border-width", ga(e.borderWidth)), s(t, "--bsy-editor-container-border-radius", ga(e.borderRadius)), t) : t;
|
|
2631
|
+
}, va = class e extends nt {
|
|
2621
2632
|
constructor(e, t) {
|
|
2622
2633
|
super(e, t);
|
|
2623
2634
|
}
|
|
@@ -2632,42 +2643,42 @@ var oa = (e, t, n) => {
|
|
|
2632
2643
|
return {
|
|
2633
2644
|
...e,
|
|
2634
2645
|
code: () => ({
|
|
2635
|
-
conversion:
|
|
2646
|
+
conversion: ba(e?.code),
|
|
2636
2647
|
priority: 1
|
|
2637
2648
|
}),
|
|
2638
2649
|
em: () => ({
|
|
2639
|
-
conversion:
|
|
2650
|
+
conversion: ba(e?.em),
|
|
2640
2651
|
priority: 1
|
|
2641
2652
|
}),
|
|
2642
2653
|
span: () => ({
|
|
2643
|
-
conversion:
|
|
2654
|
+
conversion: ba(e?.span),
|
|
2644
2655
|
priority: 1
|
|
2645
2656
|
}),
|
|
2646
2657
|
strong: () => ({
|
|
2647
|
-
conversion:
|
|
2658
|
+
conversion: ba(e?.strong),
|
|
2648
2659
|
priority: 1
|
|
2649
2660
|
}),
|
|
2650
2661
|
sub: () => ({
|
|
2651
|
-
conversion:
|
|
2662
|
+
conversion: ba(e?.sub),
|
|
2652
2663
|
priority: 1
|
|
2653
2664
|
}),
|
|
2654
2665
|
sup: () => ({
|
|
2655
|
-
conversion:
|
|
2666
|
+
conversion: ba(e?.sup),
|
|
2656
2667
|
priority: 1
|
|
2657
2668
|
})
|
|
2658
2669
|
};
|
|
2659
2670
|
}
|
|
2660
2671
|
static importJSON(e) {
|
|
2661
|
-
return
|
|
2672
|
+
return ya().updateFromJSON(e);
|
|
2662
2673
|
}
|
|
2663
2674
|
isSimpleText() {
|
|
2664
2675
|
return this.__type === "extended-text" && this.__mode === 0;
|
|
2665
2676
|
}
|
|
2666
2677
|
};
|
|
2667
|
-
function
|
|
2668
|
-
return _e(new
|
|
2678
|
+
function ya(e = "") {
|
|
2679
|
+
return _e(new va(e));
|
|
2669
2680
|
}
|
|
2670
|
-
function
|
|
2681
|
+
function ba(e) {
|
|
2671
2682
|
return (t) => {
|
|
2672
2683
|
let n = e?.(t);
|
|
2673
2684
|
if (!n) return null;
|
|
@@ -2696,52 +2707,52 @@ function va(e) {
|
|
|
2696
2707
|
}
|
|
2697
2708
|
//#endregion
|
|
2698
2709
|
//#region src/components/Editor/utils/stripInlineStyleProperty.ts
|
|
2699
|
-
function
|
|
2710
|
+
function xa(e, t) {
|
|
2700
2711
|
return e.split(";").map((e) => e.trim()).filter((e) => e && e.split(":")[0].trim().toLowerCase() !== t).join("; ");
|
|
2701
2712
|
}
|
|
2702
2713
|
//#endregion
|
|
2703
2714
|
//#region src/components/Editor/plugins/LinkColorPlugin.tsx
|
|
2704
|
-
function
|
|
2715
|
+
function Sa(e) {
|
|
2705
2716
|
if (!H(e, lt)) return;
|
|
2706
2717
|
let t = e.getStyle();
|
|
2707
2718
|
if (!t) return;
|
|
2708
|
-
let n =
|
|
2719
|
+
let n = xa(t, "color");
|
|
2709
2720
|
n !== t && e.setStyle(n);
|
|
2710
2721
|
}
|
|
2711
|
-
function
|
|
2722
|
+
function Ca() {
|
|
2712
2723
|
let [e] = B();
|
|
2713
|
-
return O(() => e.registerNodeTransform(
|
|
2724
|
+
return O(() => e.registerNodeTransform(va, Sa), [e]), null;
|
|
2714
2725
|
}
|
|
2715
2726
|
//#endregion
|
|
2716
2727
|
//#region src/components/Editor/plugins/ImagePlugin.tsx
|
|
2717
|
-
function
|
|
2728
|
+
function wa() {
|
|
2718
2729
|
let [e] = B();
|
|
2719
|
-
return O(() => e.registerCommand(
|
|
2730
|
+
return O(() => e.registerCommand(Dr, (e) => (Te([nn(e)]), !0), ze), [e]), null;
|
|
2720
2731
|
}
|
|
2721
2732
|
//#endregion
|
|
2722
2733
|
//#region src/components/Editor/utils/stripImagesFromHtml.ts
|
|
2723
|
-
function
|
|
2734
|
+
function Ta(e) {
|
|
2724
2735
|
let t = new DOMParser().parseFromString(e, "text/html");
|
|
2725
2736
|
return t.querySelectorAll("img, picture").forEach((e) => e.remove()), t.body.innerHTML;
|
|
2726
2737
|
}
|
|
2727
2738
|
//#endregion
|
|
2728
2739
|
//#region src/components/Editor/plugins/PasteStripImagePlugin.tsx
|
|
2729
|
-
var
|
|
2730
|
-
function
|
|
2731
|
-
let [e] = B(), { isSourceModeRef: t } =
|
|
2740
|
+
var Ea = /<img\b|<picture\b/i;
|
|
2741
|
+
function Da() {
|
|
2742
|
+
let [e] = B(), { isSourceModeRef: t } = Ur();
|
|
2732
2743
|
return O(() => {
|
|
2733
2744
|
let n = (n) => {
|
|
2734
2745
|
if (t.current) return !1;
|
|
2735
2746
|
let r = "clipboardData" in n ? n.clipboardData : "dataTransfer" in n ? n.dataTransfer : null;
|
|
2736
2747
|
if (!r || r.getData("application/x-lexical-editor") || r.getData("application/x-lexical-drag")) return !1;
|
|
2737
2748
|
let i = r.getData("text/html");
|
|
2738
|
-
if (!(Array.from(r.files).some((e) => e.type.startsWith("image/")) || Array.from(r.items).some((e) => e.type.startsWith("image/")) ||
|
|
2749
|
+
if (!(Array.from(r.files).some((e) => e.type.startsWith("image/")) || Array.from(r.items).some((e) => e.type.startsWith("image/")) || Ea.test(i))) return !1;
|
|
2739
2750
|
n.preventDefault();
|
|
2740
2751
|
let a = r.getData("text/plain");
|
|
2741
|
-
return !
|
|
2752
|
+
return !Ea.test(i) && !a || e.update(() => {
|
|
2742
2753
|
let t = R();
|
|
2743
2754
|
if (t === null) return;
|
|
2744
|
-
let n = i ?
|
|
2755
|
+
let n = i ? Ta(i) : "", r = document.createElement("div");
|
|
2745
2756
|
if (r.innerHTML = n, n && r.textContent?.trim()) {
|
|
2746
2757
|
let t = ge(e, new DOMParser().parseFromString(n, "text/html"));
|
|
2747
2758
|
if (t.length) {
|
|
@@ -2757,7 +2768,7 @@ function Ta() {
|
|
|
2757
2768
|
}
|
|
2758
2769
|
//#endregion
|
|
2759
2770
|
//#region src/components/Editor/plugins/EnterKeyPlugin.tsx
|
|
2760
|
-
function
|
|
2771
|
+
function Oa() {
|
|
2761
2772
|
let [e] = B(), t = N(0);
|
|
2762
2773
|
return O(() => e.registerCommand(Ye, (n) => {
|
|
2763
2774
|
let r = Date.now(), i = r - t.current;
|
|
@@ -2787,7 +2798,7 @@ function Ea() {
|
|
|
2787
2798
|
}
|
|
2788
2799
|
//#endregion
|
|
2789
2800
|
//#region src/components/Editor/utils/codeHighlighter.ts
|
|
2790
|
-
var
|
|
2801
|
+
var ka = {
|
|
2791
2802
|
css: () => import("@shikijs/langs/css"),
|
|
2792
2803
|
html: () => import("@shikijs/langs/html"),
|
|
2793
2804
|
xml: () => import("@shikijs/langs/xml"),
|
|
@@ -2808,36 +2819,36 @@ var Da = {
|
|
|
2808
2819
|
bash: () => import("@shikijs/langs/shellscript"),
|
|
2809
2820
|
lua: () => import("@shikijs/langs/lua"),
|
|
2810
2821
|
markdown: () => import("@shikijs/langs/markdown")
|
|
2811
|
-
},
|
|
2822
|
+
}, Aa = (e) => e === "bash" ? "shellscript" : e, ja = (e) => e in ka, Ma = null, Na = null, Pa = /* @__PURE__ */ new Map(), Fa = () => (Ma ||= Promise.all([import("@shikijs/core"), import("@shikijs/engine-javascript")]).then(([{ createHighlighterCoreSync: e }, { createJavaScriptRegexEngine: t }]) => e({
|
|
2812
2823
|
engine: t(),
|
|
2813
2824
|
langs: [],
|
|
2814
2825
|
themes: []
|
|
2815
2826
|
})).catch((e) => {
|
|
2816
|
-
throw
|
|
2817
|
-
}),
|
|
2818
|
-
let t =
|
|
2819
|
-
return t || (t =
|
|
2820
|
-
let n =
|
|
2827
|
+
throw Ma = null, e;
|
|
2828
|
+
}), Ma), Ia = (e, t) => ja(t) && e.getLoadedLanguages().includes(Aa(t)), La = (e) => {
|
|
2829
|
+
let t = Pa.get(e);
|
|
2830
|
+
return t || (t = Fa().then(async (t) => {
|
|
2831
|
+
let n = Aa(e);
|
|
2821
2832
|
if (!t.getLoadedLanguages().includes(n)) {
|
|
2822
|
-
let n = await
|
|
2833
|
+
let n = await ka[e]();
|
|
2823
2834
|
await t.loadLanguage(n.default);
|
|
2824
2835
|
}
|
|
2825
2836
|
return t;
|
|
2826
2837
|
}).catch((t) => {
|
|
2827
|
-
throw
|
|
2828
|
-
}),
|
|
2829
|
-
},
|
|
2838
|
+
throw Pa.delete(e), t;
|
|
2839
|
+
}), Pa.set(e, t)), t;
|
|
2840
|
+
}, Ra = () => (Na ||= Fa().then(async (e) => {
|
|
2830
2841
|
if (!e.getLoadedThemes().includes("github-light")) {
|
|
2831
2842
|
let t = await import("@shikijs/themes/github-light");
|
|
2832
2843
|
await e.loadTheme(t.default);
|
|
2833
2844
|
}
|
|
2834
2845
|
return e;
|
|
2835
2846
|
}).catch((e) => {
|
|
2836
|
-
throw
|
|
2837
|
-
}),
|
|
2847
|
+
throw Na = null, e;
|
|
2848
|
+
}), Na), za = (e, t, n) => {
|
|
2838
2849
|
let r = e.getTextContent();
|
|
2839
|
-
if (e.getStyle() && e.setStyle(""), !n || !
|
|
2840
|
-
let i =
|
|
2850
|
+
if (e.getStyle() && e.setStyle(""), !n || !Ia(n, t)) return wt(r);
|
|
2851
|
+
let i = Aa(t), a = n.codeToTokens(r, {
|
|
2841
2852
|
lang: i,
|
|
2842
2853
|
theme: Sn
|
|
2843
2854
|
}), o = [];
|
|
@@ -2850,7 +2861,7 @@ var Da = {
|
|
|
2850
2861
|
});
|
|
2851
2862
|
});
|
|
2852
2863
|
}), o;
|
|
2853
|
-
},
|
|
2864
|
+
}, Ba = (e, t) => {
|
|
2854
2865
|
let n = Ce(e);
|
|
2855
2866
|
if (!V(n) || !n.isAttached()) return;
|
|
2856
2867
|
let r = R();
|
|
@@ -2879,11 +2890,11 @@ var Da = {
|
|
|
2879
2890
|
return !1;
|
|
2880
2891
|
});
|
|
2881
2892
|
}
|
|
2882
|
-
},
|
|
2893
|
+
}, Va = (e, t) => Ct(e) && Ct(t) && e.__text === t.__text && e.__highlightType === t.__highlightType && e.__style === t.__style || ke(e) && ke(t) || De(e) && De(t), Ha = (e, t) => {
|
|
2883
2894
|
let n = 0;
|
|
2884
|
-
for (; n < e.length &&
|
|
2895
|
+
for (; n < e.length && Va(e[n], t[n]);) n++;
|
|
2885
2896
|
let r = e.length, i = t.length, a = Math.min(r, i) - n, o = 0;
|
|
2886
|
-
for (; o < a;) if (o++, !
|
|
2897
|
+
for (; o < a;) if (o++, !Va(e[r - o], t[i - o])) {
|
|
2887
2898
|
o--;
|
|
2888
2899
|
break;
|
|
2889
2900
|
}
|
|
@@ -2892,12 +2903,12 @@ var Da = {
|
|
|
2892
2903
|
to: r - o,
|
|
2893
2904
|
nodesForReplacement: t.slice(n, i - o)
|
|
2894
2905
|
};
|
|
2895
|
-
},
|
|
2906
|
+
}, Ua = (e, t, n, r, i) => {
|
|
2896
2907
|
let a = i.getKey(), o = Tn(i.getLanguage());
|
|
2897
2908
|
if (i.getLanguage() !== o && i.setLanguage(o), o === "plaintext") i.getIsSyntaxHighlightSupported() && i.setIsSyntaxHighlightSupported(!1);
|
|
2898
2909
|
else {
|
|
2899
2910
|
i.getTheme() !== "github-light" && i.setTheme(Sn);
|
|
2900
|
-
let s = t ? t.getLoadedThemes().includes("github-light") ?
|
|
2911
|
+
let s = t ? t.getLoadedThemes().includes("github-light") ? ja(o) && !Ia(t, o) ? La(o) : null : Ra() : Fa();
|
|
2901
2912
|
if (s) {
|
|
2902
2913
|
i.getIsSyntaxHighlightSupported() && i.setIsSyntaxHighlightSupported(!1), n.pendingKeys.add(a), n.loading !== s && (n.loading = s, s.then((t) => {
|
|
2903
2914
|
r(t);
|
|
@@ -2916,17 +2927,17 @@ var Da = {
|
|
|
2916
2927
|
}
|
|
2917
2928
|
n.nodesCurrentlyHighlighting.has(a) || (n.nodesCurrentlyHighlighting.add(a), n.didTransform || (n.didTransform = !0, Me(() => {
|
|
2918
2929
|
n.didTransform = !1, n.nodesCurrentlyHighlighting.clear();
|
|
2919
|
-
})),
|
|
2930
|
+
})), Ba(a, () => {
|
|
2920
2931
|
let e = Ce(a);
|
|
2921
2932
|
if (!V(e) || !e.isAttached()) return !1;
|
|
2922
|
-
let n =
|
|
2933
|
+
let n = za(e, Tn(e.getLanguage()), t), { from: r, to: i, nodesForReplacement: o } = Ha(e.getChildren(), n);
|
|
2923
2934
|
return r !== i || o.length ? (e.splice(r, i - r, o), !0) : !1;
|
|
2924
2935
|
}));
|
|
2925
|
-
},
|
|
2936
|
+
}, Wa = (e, t, n, r, i) => {
|
|
2926
2937
|
let a = i.getParent();
|
|
2927
|
-
V(a) ?
|
|
2938
|
+
V(a) ? Ua(e, t, n, r, a) : Ct(i) && i.replace(xe(i.__text));
|
|
2928
2939
|
};
|
|
2929
|
-
function
|
|
2940
|
+
function Ga() {
|
|
2930
2941
|
let [e] = B();
|
|
2931
2942
|
return O(() => {
|
|
2932
2943
|
if (!e.hasNodes([Et, Tt])) throw Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");
|
|
@@ -2970,11 +2981,11 @@ function Ua() {
|
|
|
2970
2981
|
t?.removeEventListener("mousedown", c, !0), t?.removeEventListener("mouseup", u, !0), t?.removeEventListener("dblclick", l, !0), e?.addEventListener("mousedown", c, !0), e?.addEventListener("mouseup", u, !0), e?.addEventListener("dblclick", l, !0);
|
|
2971
2982
|
};
|
|
2972
2983
|
return ot(Dt(e), e.registerNodeTransform(Et, (i) => {
|
|
2973
|
-
|
|
2984
|
+
Ua(e, t, n, r, i);
|
|
2974
2985
|
}), e.registerNodeTransform(nt, (i) => {
|
|
2975
|
-
|
|
2986
|
+
Wa(e, t, n, r, i);
|
|
2976
2987
|
}), e.registerNodeTransform(Tt, (i) => {
|
|
2977
|
-
|
|
2988
|
+
Wa(e, t, n, r, i);
|
|
2978
2989
|
}), e.registerRootListener(d), () => {
|
|
2979
2990
|
d(null, e.getRootElement());
|
|
2980
2991
|
});
|
|
@@ -2982,7 +2993,7 @@ function Ua() {
|
|
|
2982
2993
|
}
|
|
2983
2994
|
//#endregion
|
|
2984
2995
|
//#region src/components/Editor/plugins/TablePlugin.tsx
|
|
2985
|
-
function
|
|
2996
|
+
function Ka() {
|
|
2986
2997
|
let [e] = B();
|
|
2987
2998
|
return O(() => (Wt(e, !0), Yt(Ht(e), Ut(e, !1), Vt(e), e.registerNodeTransform(Rt, (e) => {
|
|
2988
2999
|
e.getBackgroundColor() !== null && e.setBackgroundColor(null);
|
|
@@ -3016,8 +3027,8 @@ function Wa() {
|
|
|
3016
3027
|
}
|
|
3017
3028
|
//#endregion
|
|
3018
3029
|
//#region src/components/Editor/plugins/TabIndentPlugin.tsx
|
|
3019
|
-
var
|
|
3020
|
-
function
|
|
3030
|
+
var qa = "\xA0".repeat(4);
|
|
3031
|
+
function Ja() {
|
|
3021
3032
|
let [e] = B();
|
|
3022
3033
|
return O(() => e.registerCommand(Xe, (t) => {
|
|
3023
3034
|
if (t.shiftKey) return !1;
|
|
@@ -3037,13 +3048,13 @@ function Ka() {
|
|
|
3037
3048
|
return !0;
|
|
3038
3049
|
}
|
|
3039
3050
|
let a = r.getTopLevelElement(), o = n.focus.getNode().getTopLevelElement();
|
|
3040
|
-
return !n.isCollapsed() && a && o && a !== o ? e.dispatchCommand(Je, void 0) : (n.insertText(
|
|
3051
|
+
return !n.isCollapsed() && a && o && a !== o ? e.dispatchCommand(Je, void 0) : (n.insertText(qa), !0);
|
|
3041
3052
|
}, ze), [e]), null;
|
|
3042
3053
|
}
|
|
3043
3054
|
//#endregion
|
|
3044
3055
|
//#region src/components/Editor/plugins/MaxLengthPlugin.tsx
|
|
3045
|
-
function
|
|
3046
|
-
let [n] = B(), { isSourceModeRef: r } =
|
|
3056
|
+
function Ya({ maxLength: e, onMaxLengthExceed: t }) {
|
|
3057
|
+
let [n] = B(), { isSourceModeRef: r } = Ur(), i = N(t);
|
|
3047
3058
|
return i.current = t, O(() => {
|
|
3048
3059
|
let t = null;
|
|
3049
3060
|
return n.registerNodeTransform(tt, (a) => {
|
|
@@ -3071,18 +3082,18 @@ function qa({ maxLength: e, onMaxLengthExceed: t }) {
|
|
|
3071
3082
|
}
|
|
3072
3083
|
//#endregion
|
|
3073
3084
|
//#region src/components/Editor/utils/textLength.ts
|
|
3074
|
-
function
|
|
3085
|
+
function Xa(e) {
|
|
3075
3086
|
return typeof e == "number" && Number.isFinite(e) && e > 0;
|
|
3076
3087
|
}
|
|
3077
|
-
function
|
|
3088
|
+
function Za(e, t) {
|
|
3078
3089
|
let n = L(), r = n.getTextContentSize();
|
|
3079
3090
|
if (r <= t) return !1;
|
|
3080
3091
|
let i = r - t;
|
|
3081
3092
|
n.selectEnd();
|
|
3082
3093
|
let a = R();
|
|
3083
|
-
return z(a) ? jt(e, a.anchor, i) :
|
|
3094
|
+
return z(a) ? jt(e, a.anchor, i) : Qa(i), !0;
|
|
3084
3095
|
}
|
|
3085
|
-
function
|
|
3096
|
+
function Qa(e) {
|
|
3086
3097
|
let t = e, n = L().getAllTextNodes();
|
|
3087
3098
|
for (let e = n.length - 1; e >= 0 && t > 0; e--) {
|
|
3088
3099
|
let r = n[e], i = r.getTextContent();
|
|
@@ -3091,7 +3102,7 @@ function Xa(e) {
|
|
|
3091
3102
|
}
|
|
3092
3103
|
//#endregion
|
|
3093
3104
|
//#region src/components/Editor/utils/formatEditorHtml.ts
|
|
3094
|
-
var
|
|
3105
|
+
var $a = new Set([
|
|
3095
3106
|
"area",
|
|
3096
3107
|
"base",
|
|
3097
3108
|
"br",
|
|
@@ -3106,37 +3117,37 @@ var Za = new Set([
|
|
|
3106
3117
|
"source",
|
|
3107
3118
|
"track",
|
|
3108
3119
|
"wbr"
|
|
3109
|
-
]),
|
|
3110
|
-
let r = e.tagName.toLowerCase(), i = `<${r}${
|
|
3111
|
-
if (
|
|
3112
|
-
let a = n || r === "pre", o =
|
|
3113
|
-
return a || !
|
|
3114
|
-
},
|
|
3120
|
+
]), eo = new Set(/* @__PURE__ */ "address.article.aside.blockquote.div.dl.dt.dd.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hr.li.main.nav.ol.p.pre.section.table.tbody.td.tfoot.th.thead.tr.ul".split(".")), to = 80, no = (e) => e.replace(/&/g, "&").replace(/"/g, """), ro = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), io = (e) => Array.from(e.attributes).map((e) => ` ${e.name}="${no(e.value)}"`).join(""), ao = (e) => " ".repeat(e), oo = (e, t, n) => {
|
|
3121
|
+
let r = e.tagName.toLowerCase(), i = `<${r}${io(e)}>`;
|
|
3122
|
+
if ($a.has(r)) return i;
|
|
3123
|
+
let a = n || r === "pre", o = so(e, t + 1, a), s = `</${r}>`;
|
|
3124
|
+
return a || !eo.has(r) ? `${i}${o}${s}` : Array.from(e.children).some((e) => eo.has(e.tagName.toLowerCase())) ? `${i}\n${so(e, t + 1, !1, !0)}\n${ao(t)}${s}` : i.length + o.length + s.length > to ? `${i}\n${ao(t + 1)}${o}\n${ao(t)}${s}` : `${i}${o}${s}`;
|
|
3125
|
+
}, so = (e, t, n, r = !1) => {
|
|
3115
3126
|
let i = [];
|
|
3116
3127
|
for (let r of Array.from(e.childNodes)) {
|
|
3117
3128
|
if (r.nodeType === Node.TEXT_NODE) {
|
|
3118
3129
|
let e = r.textContent ?? "";
|
|
3119
3130
|
if (n) {
|
|
3120
|
-
i.push(
|
|
3131
|
+
i.push(ro(e));
|
|
3121
3132
|
continue;
|
|
3122
3133
|
}
|
|
3123
|
-
e.trim() && i.push(
|
|
3134
|
+
e.trim() && i.push(ro(e));
|
|
3124
3135
|
continue;
|
|
3125
3136
|
}
|
|
3126
3137
|
if (r.nodeType === Node.COMMENT_NODE) {
|
|
3127
3138
|
i.push(`<!--${r.data}-->`);
|
|
3128
3139
|
continue;
|
|
3129
3140
|
}
|
|
3130
|
-
r.nodeType === Node.ELEMENT_NODE && i.push(
|
|
3141
|
+
r.nodeType === Node.ELEMENT_NODE && i.push(oo(r, t, n));
|
|
3131
3142
|
}
|
|
3132
|
-
return n || !r ? i.join("") : i.map((e) => `${
|
|
3143
|
+
return n || !r ? i.join("") : i.map((e) => `${ao(t)}${e}`).join("\n");
|
|
3133
3144
|
};
|
|
3134
|
-
function
|
|
3135
|
-
return e.trim() ?
|
|
3145
|
+
function co(e) {
|
|
3146
|
+
return e.trim() ? so(new DOMParser().parseFromString(Fi(e), "text/html").body, 0, !1, !0).trimEnd() : e;
|
|
3136
3147
|
}
|
|
3137
3148
|
//#endregion
|
|
3138
3149
|
//#region src/components/Editor/utils/writeHtmlSource.ts
|
|
3139
|
-
function
|
|
3150
|
+
function lo(e) {
|
|
3140
3151
|
L().clear();
|
|
3141
3152
|
let t = St("html");
|
|
3142
3153
|
if (L().append(t), !e) return;
|
|
@@ -3146,24 +3157,24 @@ function so(e) {
|
|
|
3146
3157
|
}
|
|
3147
3158
|
//#endregion
|
|
3148
3159
|
//#region src/components/Editor/plugins/SourceModePlugin.tsx
|
|
3149
|
-
function
|
|
3160
|
+
function uo({ children: e, maxLength: t, onMaxLengthExceed: n }) {
|
|
3150
3161
|
let [r] = B(), [i, a] = P(!1), o = N(!1), s = N(n);
|
|
3151
3162
|
s.current = n;
|
|
3152
|
-
let c =
|
|
3163
|
+
let c = Xa(t) ? t : void 0, l = T(() => {
|
|
3153
3164
|
if (o.current) return;
|
|
3154
3165
|
let e = "", t = "";
|
|
3155
3166
|
r.getEditorState().read(() => {
|
|
3156
3167
|
t = L().getTextContent(), e = he(r, null);
|
|
3157
3168
|
}, { editor: r });
|
|
3158
|
-
let n =
|
|
3169
|
+
let n = ni(e, t) ? "" : X(e);
|
|
3159
3170
|
o.current = !0, a(!0), r.update(() => {
|
|
3160
|
-
|
|
3171
|
+
lo(co(n));
|
|
3161
3172
|
}), r.dispatchCommand(Le, void 0);
|
|
3162
3173
|
}, [r]), u = T(() => {
|
|
3163
3174
|
if (!o.current) return;
|
|
3164
3175
|
let e = !1;
|
|
3165
3176
|
o.current = !1, r.update(() => {
|
|
3166
|
-
|
|
3177
|
+
ti(r, X(L().getTextContent())), c !== void 0 && (e = Za(r, c)), Dn(!0);
|
|
3167
3178
|
}), a(!1), r.dispatchCommand(Le, void 0), e && s.current?.();
|
|
3168
3179
|
}, [r, c]), d = T(() => {
|
|
3169
3180
|
if (o.current) {
|
|
@@ -3189,7 +3200,7 @@ function co({ children: e, maxLength: t, onMaxLengthExceed: n }) {
|
|
|
3189
3200
|
return Yt(r.registerNodeTransform(tt, () => {
|
|
3190
3201
|
if (!o.current) return;
|
|
3191
3202
|
let e = L(), t = e.getChildrenSize() === 1 ? e.getFirstChild() : null;
|
|
3192
|
-
V(t) && t.getLanguage() === "html" ||
|
|
3203
|
+
V(t) && t.getLanguage() === "html" || lo(e.getTextContent());
|
|
3193
3204
|
}), r.registerCommand(Qe, e, Re), r.registerCommand(He, e, Re));
|
|
3194
3205
|
}, [r]);
|
|
3195
3206
|
let f = M(() => ({
|
|
@@ -3197,14 +3208,14 @@ function co({ children: e, maxLength: t, onMaxLengthExceed: n }) {
|
|
|
3197
3208
|
isSourceModeRef: o,
|
|
3198
3209
|
toggleSourceMode: d
|
|
3199
3210
|
}), [i, d]);
|
|
3200
|
-
return /* @__PURE__ */ y(
|
|
3211
|
+
return /* @__PURE__ */ y(Hr.Provider, {
|
|
3201
3212
|
value: f,
|
|
3202
3213
|
children: e
|
|
3203
3214
|
});
|
|
3204
3215
|
}
|
|
3205
3216
|
//#endregion
|
|
3206
3217
|
//#region src/components/Editor/plugins/HeadingPlugin.tsx
|
|
3207
|
-
function
|
|
3218
|
+
function fo(e) {
|
|
3208
3219
|
let t = e.getTag();
|
|
3209
3220
|
if (t === "h4" || t === "h5" || t === "h6") {
|
|
3210
3221
|
e.replace(ye(), !0);
|
|
@@ -3213,17 +3224,17 @@ function lo(e) {
|
|
|
3213
3224
|
for (let t of e.getAllTextNodes()) {
|
|
3214
3225
|
let e = t.getStyle();
|
|
3215
3226
|
if (!e) continue;
|
|
3216
|
-
let n =
|
|
3227
|
+
let n = xa(e, "font-size");
|
|
3217
3228
|
n !== e && t.setStyle(n);
|
|
3218
3229
|
}
|
|
3219
3230
|
}
|
|
3220
|
-
function
|
|
3231
|
+
function po() {
|
|
3221
3232
|
let [e] = B();
|
|
3222
|
-
return O(() => e.registerNodeTransform(qt,
|
|
3233
|
+
return O(() => e.registerNodeTransform(qt, fo), [e]), null;
|
|
3223
3234
|
}
|
|
3224
3235
|
//#endregion
|
|
3225
3236
|
//#region src/components/Editor/LengthBadge.tsx
|
|
3226
|
-
var
|
|
3237
|
+
var mo = ({ current: e, maxLength: t }) => {
|
|
3227
3238
|
let n = e > t;
|
|
3228
3239
|
return /* @__PURE__ */ b("div", {
|
|
3229
3240
|
className: I($["bsy-lexical-editor__length-badge"], n && $["bsy-lexical-editor__length-badge--exceeded"]),
|
|
@@ -3235,33 +3246,33 @@ var fo = ({ current: e, maxLength: t }) => {
|
|
|
3235
3246
|
]
|
|
3236
3247
|
});
|
|
3237
3248
|
};
|
|
3238
|
-
|
|
3249
|
+
mo.displayName = "BsyLexicalEditorLengthBadge";
|
|
3239
3250
|
//#endregion
|
|
3240
3251
|
//#region src/components/Editor/utils/unwrapTypesetFence.ts
|
|
3241
|
-
var
|
|
3252
|
+
var ho = /^\uFEFF/, go = /^ {0,3}`{1,3}[A-Za-z]*$/, _o = /^( {0,3})([^`<]*?)```[ \t]*([A-Za-z0-9_-]*)[ \t]*(.*)$/, vo = /^ {0,3}```[ \t]*$/, yo = /<\/?[a-zA-Z]/, bo = /<[a-zA-Z!]/, xo = (e) => bo.test(e), So = (e) => yo.test(e), Co = (e) => e.replace(ho, "").replace(/\r\n/g, "\n"), wo = (e) => {
|
|
3242
3253
|
let t = e.replace(/\n+$/, ""), n = t.lastIndexOf("\n"), r = n === -1 ? t : t.slice(n + 1);
|
|
3243
|
-
return
|
|
3254
|
+
return go.test(r) ? {
|
|
3244
3255
|
text: n === -1 ? "" : t.slice(0, n),
|
|
3245
3256
|
withheld: !0
|
|
3246
3257
|
} : {
|
|
3247
3258
|
text: e,
|
|
3248
3259
|
withheld: !1
|
|
3249
3260
|
};
|
|
3250
|
-
},
|
|
3251
|
-
let t =
|
|
3261
|
+
}, To = (e) => {
|
|
3262
|
+
let t = _o.exec(e);
|
|
3252
3263
|
return t ? { sameLineBody: t[4] ?? "" } : null;
|
|
3253
|
-
},
|
|
3264
|
+
}, Eo = (e) => {
|
|
3254
3265
|
let t = e.replace(/[ \t]*```[ \t]*$/, "");
|
|
3255
3266
|
return t === e ? e : t;
|
|
3256
|
-
},
|
|
3267
|
+
}, Do = (e) => xo(e) ? e.replace(/^\n/, "") : "", Oo = (e) => {
|
|
3257
3268
|
let t = e.split("\n"), n = [], r = 0;
|
|
3258
3269
|
for (; r < t.length;) {
|
|
3259
|
-
let e = t[r], i =
|
|
3270
|
+
let e = t[r], i = To(e);
|
|
3260
3271
|
if (i) {
|
|
3261
3272
|
let e = i.sameLineBody;
|
|
3262
|
-
if (e !==
|
|
3263
|
-
e =
|
|
3264
|
-
let i =
|
|
3273
|
+
if (e !== Eo(e)) {
|
|
3274
|
+
e = Eo(e);
|
|
3275
|
+
let i = Do(t.slice(r + 1).join("\n"));
|
|
3265
3276
|
return [
|
|
3266
3277
|
...n,
|
|
3267
3278
|
e,
|
|
@@ -3269,38 +3280,38 @@ var po = /^\uFEFF/, mo = /^ {0,3}`{1,3}[A-Za-z]*$/, ho = /^( {0,3})([^`<]*?)```[
|
|
|
3269
3280
|
].filter(Boolean).join("\n");
|
|
3270
3281
|
}
|
|
3271
3282
|
let a = [];
|
|
3272
|
-
for (e && a.push(e), r += 1; r < t.length && !
|
|
3273
|
-
let o = r < t.length ?
|
|
3283
|
+
for (e && a.push(e), r += 1; r < t.length && !vo.test(t[r]);) a.push(t[r]), r += 1;
|
|
3284
|
+
let o = r < t.length ? Do(t.slice(r + 1).join("\n")) : "";
|
|
3274
3285
|
return [
|
|
3275
3286
|
...n,
|
|
3276
3287
|
a.join("\n"),
|
|
3277
3288
|
o
|
|
3278
3289
|
].filter(Boolean).join("\n");
|
|
3279
3290
|
}
|
|
3280
|
-
if (
|
|
3281
|
-
|
|
3291
|
+
if (So(e)) return ko([...n, ...t.slice(r)].join("\n"));
|
|
3292
|
+
xo(e) && n.push(e), r += 1;
|
|
3282
3293
|
}
|
|
3283
3294
|
return n.length ? n.join("\n") : null;
|
|
3284
|
-
},
|
|
3295
|
+
}, ko = (e) => {
|
|
3285
3296
|
let t = e.split("\n");
|
|
3286
3297
|
if (!t.length) return e;
|
|
3287
|
-
let n =
|
|
3288
|
-
return n && !
|
|
3298
|
+
let n = To(t[0]);
|
|
3299
|
+
return n && !So(t[0].slice(0, t[0].indexOf("```"))) && (t.shift(), n.sameLineBody && t.unshift(Eo(n.sameLineBody))), t.length && vo.test(t[t.length - 1] ?? "") && t.pop(), t.join("\n");
|
|
3289
3300
|
};
|
|
3290
|
-
function
|
|
3301
|
+
function Ao(e) {
|
|
3291
3302
|
if (!e) return {
|
|
3292
3303
|
html: "",
|
|
3293
3304
|
pending: !1
|
|
3294
3305
|
};
|
|
3295
|
-
let { text: t, withheld: n } =
|
|
3306
|
+
let { text: t, withheld: n } = wo(Co(e));
|
|
3296
3307
|
if (!t.trim()) return {
|
|
3297
3308
|
html: "",
|
|
3298
|
-
pending: n ||
|
|
3309
|
+
pending: n || go.test(Co(e).trim())
|
|
3299
3310
|
};
|
|
3300
|
-
let r =
|
|
3311
|
+
let r = Oo(t) ?? t, i = Oo(r);
|
|
3301
3312
|
i !== null && i !== r && (r = i);
|
|
3302
3313
|
let a = r.trim();
|
|
3303
|
-
return
|
|
3314
|
+
return xo(a) ? {
|
|
3304
3315
|
html: a,
|
|
3305
3316
|
pending: !1
|
|
3306
3317
|
} : {
|
|
@@ -3310,45 +3321,76 @@ function Oo(e) {
|
|
|
3310
3321
|
}
|
|
3311
3322
|
//#endregion
|
|
3312
3323
|
//#region src/components/Editor/utils/prepareTypesetProposed.ts
|
|
3313
|
-
var
|
|
3314
|
-
function
|
|
3315
|
-
if (!e.trim() || !
|
|
3316
|
-
let t =
|
|
3324
|
+
var jo = "p, h1, h2, h3, li", Mo = /background(-color)?\s*:/i;
|
|
3325
|
+
function No(e) {
|
|
3326
|
+
if (!e.trim() || !Mo.test(e)) return e;
|
|
3327
|
+
let t = hi(e);
|
|
3317
3328
|
if (!t) return e;
|
|
3318
|
-
for (let e of Array.from(t.querySelectorAll(
|
|
3329
|
+
for (let e of Array.from(t.querySelectorAll(jo))) {
|
|
3319
3330
|
let t = e;
|
|
3320
3331
|
t.style.removeProperty("background-color"), t.style.removeProperty("background"), t.getAttribute("style")?.trim() || t.removeAttribute("style");
|
|
3321
3332
|
}
|
|
3322
3333
|
return t.innerHTML;
|
|
3323
3334
|
}
|
|
3324
|
-
function
|
|
3325
|
-
let { html: n } =
|
|
3326
|
-
return n ?
|
|
3335
|
+
function Po(e, t) {
|
|
3336
|
+
let { html: n } = Ao(e);
|
|
3337
|
+
return n ? No(_i(n, t)) : "";
|
|
3327
3338
|
}
|
|
3328
3339
|
//#endregion
|
|
3329
3340
|
//#region src/components/Editor/utils/applyAiTypeset.ts
|
|
3330
|
-
function
|
|
3331
|
-
let i = X(
|
|
3332
|
-
if (!i.trim() ||
|
|
3341
|
+
function Fo(e, t, n, r) {
|
|
3342
|
+
let i = X(Po(t, n));
|
|
3343
|
+
if (!i.trim() || ni(i, "")) return {
|
|
3333
3344
|
applied: !1,
|
|
3334
3345
|
truncated: !1
|
|
3335
3346
|
};
|
|
3336
3347
|
let a = !1;
|
|
3337
3348
|
return e.update(() => {
|
|
3338
|
-
|
|
3349
|
+
ti(e, i), Xa(r) && (a = Za(e, r)), Dn(!0);
|
|
3339
3350
|
}, { discrete: !0 }), {
|
|
3340
3351
|
applied: !0,
|
|
3341
3352
|
truncated: a
|
|
3342
3353
|
};
|
|
3343
3354
|
}
|
|
3344
3355
|
//#endregion
|
|
3345
|
-
//#region src/components/Editor/Preview/
|
|
3346
|
-
var
|
|
3356
|
+
//#region src/components/Editor/Preview/useAiPreviewHtml.ts
|
|
3357
|
+
var Io = (e, t) => {
|
|
3358
|
+
if (!e || Zr(e)) return e;
|
|
3359
|
+
let n = X(e);
|
|
3360
|
+
return t === "ready" || t === "error" ? Fi(n) : n;
|
|
3361
|
+
}, Lo = ({ enabled: e, status: t, revision: n, compute: r }) => {
|
|
3362
|
+
let [i, a] = P(""), o = N(r);
|
|
3363
|
+
o.current = r;
|
|
3364
|
+
let s = N(null);
|
|
3365
|
+
return j(() => {
|
|
3366
|
+
let n = () => {
|
|
3367
|
+
s.current !== null && (cancelAnimationFrame(s.current), s.current = null);
|
|
3368
|
+
};
|
|
3369
|
+
if (!e) {
|
|
3370
|
+
n(), a("");
|
|
3371
|
+
return;
|
|
3372
|
+
}
|
|
3373
|
+
let r = () => {
|
|
3374
|
+
s.current = null, a(o.current());
|
|
3375
|
+
};
|
|
3376
|
+
if (t === "ready" || t === "error") {
|
|
3377
|
+
n(), r();
|
|
3378
|
+
return;
|
|
3379
|
+
}
|
|
3380
|
+
s.current === null && (s.current = requestAnimationFrame(r));
|
|
3381
|
+
}, [
|
|
3382
|
+
e,
|
|
3383
|
+
n,
|
|
3384
|
+
t
|
|
3385
|
+
]), O(() => () => {
|
|
3386
|
+
s.current !== null && cancelAnimationFrame(s.current);
|
|
3387
|
+
}, []), i;
|
|
3388
|
+
}, Ro = [
|
|
3347
3389
|
.26,
|
|
3348
3390
|
.02,
|
|
3349
3391
|
.23,
|
|
3350
3392
|
.94
|
|
3351
|
-
],
|
|
3393
|
+
], zo = () => {
|
|
3352
3394
|
let e = `${k().replace(/:/g, "")}g`;
|
|
3353
3395
|
return /* @__PURE__ */ y("span", {
|
|
3354
3396
|
className: Q["bsy-lexical-ai__think-icon"],
|
|
@@ -3388,7 +3430,7 @@ var Po = [
|
|
|
3388
3430
|
})
|
|
3389
3431
|
});
|
|
3390
3432
|
};
|
|
3391
|
-
function
|
|
3433
|
+
function Bo(e, t, n) {
|
|
3392
3434
|
let { t: r } = a(), i = e.status === "loading" && !t, [o, s] = P(!0), [c, l] = P(0), u = N(Date.now()), d = N(null), f = N(!1), p = N(!1), m = e.reasoning ?? "", h = i || o, g = (i || !!m) && !(e.status === "error" && !m), _ = (e) => {
|
|
3393
3435
|
!e || !p.current || (p.current = !1, e.scrollHeight - e.scrollTop - e.clientHeight > 8 && (f.current = !0));
|
|
3394
3436
|
}, v = T(() => n?.current ?? void 0, [n]), y = T(() => {
|
|
@@ -3446,12 +3488,12 @@ function Io(e, t, n) {
|
|
|
3446
3488
|
onViewportScroll: () => _(n?.current)
|
|
3447
3489
|
};
|
|
3448
3490
|
}
|
|
3449
|
-
var
|
|
3491
|
+
var Vo = ({ model: t }) => t.visible ? /* @__PURE__ */ b("button", {
|
|
3450
3492
|
type: "button",
|
|
3451
3493
|
className: Q["bsy-lexical-ai__think-head"],
|
|
3452
3494
|
disabled: t.thinking,
|
|
3453
3495
|
onClick: t.toggle,
|
|
3454
|
-
children: [t.thinking ? /* @__PURE__ */ y(
|
|
3496
|
+
children: [t.thinking ? /* @__PURE__ */ y(zo, {}) : /* @__PURE__ */ y(e, {
|
|
3455
3497
|
name: "arrow-down",
|
|
3456
3498
|
size: 12,
|
|
3457
3499
|
className: I(Q["bsy-lexical-ai__think-arrow"], t.open && Q["bsy-lexical-ai__think-arrow--open"])
|
|
@@ -3475,7 +3517,7 @@ var Lo = ({ model: t }) => t.visible ? /* @__PURE__ */ b("button", {
|
|
|
3475
3517
|
},
|
|
3476
3518
|
transition: {
|
|
3477
3519
|
duration: .22,
|
|
3478
|
-
ease:
|
|
3520
|
+
ease: Ro
|
|
3479
3521
|
},
|
|
3480
3522
|
children: /* @__PURE__ */ y("span", {
|
|
3481
3523
|
className: t.thinking ? Q["bsy-lexical-ai__think-label--shimmer"] : void 0,
|
|
@@ -3484,7 +3526,7 @@ var Lo = ({ model: t }) => t.visible ? /* @__PURE__ */ b("button", {
|
|
|
3484
3526
|
}, t.label)
|
|
3485
3527
|
})
|
|
3486
3528
|
})]
|
|
3487
|
-
}) : null,
|
|
3529
|
+
}) : null, Ho = ({ model: e }) => {
|
|
3488
3530
|
let [t, n] = P(!0), r = D(e.reasoning);
|
|
3489
3531
|
if (O(() => {
|
|
3490
3532
|
e.open || n(!0);
|
|
@@ -3526,7 +3568,7 @@ var Lo = ({ model: t }) => t.visible ? /* @__PURE__ */ b("button", {
|
|
|
3526
3568
|
children: i
|
|
3527
3569
|
}, "think-body") : null
|
|
3528
3570
|
});
|
|
3529
|
-
},
|
|
3571
|
+
}, Uo = "\n:host {\n all: initial;\n display: block;\n width: 100%;\n max-width: 100%;\n min-width: 0;\n}\n.bsy-editor-html-preview__body {\n color: #030303;\n font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', sans-serif;\n font-size: 15px;\n line-height: 1.6;\n word-break: break-word;\n}\n.bsy-editor-html-preview__body p {\n margin: 0;\n}\n.bsy-editor-html-preview__body .editor-text-bold {\n font-weight: 700;\n}\n.bsy-editor-html-preview__body .editor-text-italic {\n font-style: italic;\n}\n.bsy-editor-html-preview__body .editor-text-underline {\n text-decoration: underline;\n}\n.bsy-editor-html-preview__body .editor-text-strikethrough {\n text-decoration: line-through;\n}\n.bsy-editor-html-preview__body .editor-text-underline-strikethrough {\n text-decoration: underline line-through;\n}\n.bsy-editor-html-preview__body sup,\n.bsy-editor-html-preview__body sub {\n display: inline-block;\n position: static;\n top: auto;\n bottom: auto;\n font-size: 0.75em;\n line-height: 1;\n}\n.bsy-editor-html-preview__body sup {\n vertical-align: super;\n}\n.bsy-editor-html-preview__body sub {\n vertical-align: sub;\n}\n.bsy-editor-html-preview__body .editor-heading-h1,\n.bsy-editor-html-preview__body .editor-heading-h2,\n.bsy-editor-html-preview__body .editor-heading-h3,\n.bsy-editor-html-preview__body .editor-heading-h4,\n.bsy-editor-html-preview__body .editor-heading-h5,\n.bsy-editor-html-preview__body .editor-heading-h6 {\n margin: 0.6em 0 0.4em;\n font-weight: 600;\n line-height: 1.35;\n}\n.bsy-editor-html-preview__body .editor-heading-h1 {\n font-size: 2em;\n}\n.bsy-editor-html-preview__body .editor-heading-h2 {\n font-size: 1.5em;\n}\n.bsy-editor-html-preview__body .editor-heading-h3 {\n font-size: 1.25em;\n}\n.bsy-editor-html-preview__body .editor-heading-h4 {\n font-size: 1.125em;\n}\n.bsy-editor-html-preview__body .editor-heading-h5 {\n font-size: 1em;\n}\n.bsy-editor-html-preview__body .editor-heading-h6 {\n font-size: 0.875em;\n}\n.bsy-editor-html-preview__body .editor-list-ul,\n.bsy-editor-html-preview__body .editor-list-ol {\n margin: 0;\n padding-inline-start: 24px;\n list-style-position: outside;\n}\n.bsy-editor-html-preview__body .editor-list-ul {\n list-style-type: disc;\n}\n.bsy-editor-html-preview__body .editor-list-ol {\n list-style-type: decimal;\n}\n.bsy-editor-html-preview__body .editor-listitem {\n margin: 0;\n list-style: inherit;\n}\n.bsy-editor-html-preview__body .editor-nested-listitem {\n list-style-type: none;\n}\n.bsy-editor-html-preview__body .editor-list-ul .editor-list-ul {\n list-style-type: circle;\n}\n.bsy-editor-html-preview__body .editor-list-ul .editor-list-ul .editor-list-ul {\n list-style-type: square;\n}\n.bsy-editor-html-preview__body .editor-link,\n.bsy-editor-html-preview__body .editor-link:link,\n.bsy-editor-html-preview__body .editor-link:visited,\n.bsy-editor-html-preview__body .editor-link:hover,\n.bsy-editor-html-preview__body .editor-link:active,\n.bsy-editor-html-preview__body .editor-link:focus {\n color: #0269ff;\n cursor: pointer;\n}\n.bsy-editor-html-preview__body .editor-link * {\n color: #0269ff !important;\n}\n.bsy-editor-html-preview__body pre,\n.bsy-editor-html-preview__body .editor-code {\n display: block;\n box-sizing: border-box;\n max-width: 100%;\n margin: 8px 0;\n padding: 8px 12px;\n overflow-x: auto;\n border-radius: 4px;\n background: rgb(240, 242, 245);\n color: #1f2328;\n font-family: Menlo, Consolas, Monaco, monospace;\n font-size: 13px;\n line-height: 1.53;\n tab-size: 2;\n white-space: pre;\n}\n.bsy-editor-html-preview__body .editor-table-scrollable-wrapper {\n max-width: 100%;\n margin: 8px 0;\n overflow-x: auto;\n}\n.bsy-editor-html-preview__body table {\n width: max-content;\n min-width: 100%;\n margin: 0;\n border-collapse: collapse;\n table-layout: fixed;\n}\n.bsy-editor-html-preview__body td,\n.bsy-editor-html-preview__body th {\n box-sizing: border-box;\n min-width: 75px;\n min-height: 32px;\n padding: 4px 8px;\n border: 1px solid #d9d9d9;\n vertical-align: top;\n}\n.bsy-editor-html-preview__body th {\n background: #f2f3f5;\n font-weight: 600;\n}\n.bsy-editor-html-preview__body img {\n max-width: 100%;\n height: auto;\n vertical-align: baseline;\n}\n", Wo = ({ html: e }) => {
|
|
3530
3572
|
let t = N(null);
|
|
3531
3573
|
return j(() => {
|
|
3532
3574
|
let n = t.current;
|
|
@@ -3540,36 +3582,36 @@ var Lo = ({ model: t }) => t.visible ? /* @__PURE__ */ b("button", {
|
|
|
3540
3582
|
}
|
|
3541
3583
|
r.replaceChildren();
|
|
3542
3584
|
let a = document.createElement("style");
|
|
3543
|
-
a.textContent =
|
|
3585
|
+
a.textContent = Uo, r.append(a, i);
|
|
3544
3586
|
}, [e]), /* @__PURE__ */ y("div", {
|
|
3545
3587
|
ref: t,
|
|
3546
3588
|
className: "bsy-editor-html-preview"
|
|
3547
3589
|
});
|
|
3548
|
-
},
|
|
3549
|
-
let [t, n] = P(() => e && !
|
|
3590
|
+
}, Go = ({ html: e }) => {
|
|
3591
|
+
let [t, n] = P(() => e && !Zr(e) ? e : "");
|
|
3550
3592
|
return O(() => {
|
|
3551
|
-
!e ||
|
|
3552
|
-
}, [e]), t ? /* @__PURE__ */ y(
|
|
3553
|
-
},
|
|
3593
|
+
!e || Zr(e) || n(e);
|
|
3594
|
+
}, [e]), t ? /* @__PURE__ */ y(Wo, { html: t }) : null;
|
|
3595
|
+
}, Ko = {
|
|
3554
3596
|
paddingAbsolute: !0,
|
|
3555
3597
|
overflow: {
|
|
3556
3598
|
x: "hidden",
|
|
3557
3599
|
y: "scroll"
|
|
3558
3600
|
}
|
|
3559
|
-
},
|
|
3560
|
-
let { t:
|
|
3601
|
+
}, qo = ({ status: t, errorMessage: n, originalHtml: i, proposedHtml: o, preset: s, onPresetChange: c, onCancel: l, onApply: d }) => {
|
|
3602
|
+
let { t: p } = a(), m = _r(), [h, g] = P(!0), _ = N(null), v = !!o.trim(), x = t === "ready" && v, S = Bo({
|
|
3561
3603
|
status: t,
|
|
3562
|
-
reasoning:
|
|
3563
|
-
}, v, _), C =
|
|
3604
|
+
reasoning: m
|
|
3605
|
+
}, v, _), C = Yr.map((e) => ({
|
|
3564
3606
|
key: e,
|
|
3565
|
-
label:
|
|
3607
|
+
label: p(Xr[e])
|
|
3566
3608
|
}));
|
|
3567
3609
|
return /* @__PURE__ */ y(r, {
|
|
3568
|
-
title:
|
|
3610
|
+
title: p("editor.aiPolish"),
|
|
3569
3611
|
open: h,
|
|
3570
3612
|
width: "800px",
|
|
3571
3613
|
fullSwitch: !0,
|
|
3572
|
-
afterClose:
|
|
3614
|
+
afterClose: l,
|
|
3573
3615
|
onOpenChange: g,
|
|
3574
3616
|
children: /* @__PURE__ */ b("div", {
|
|
3575
3617
|
className: Q["bsy-lexical-ai__dialog"],
|
|
@@ -3579,11 +3621,11 @@ var Lo = ({ model: t }) => t.visible ? /* @__PURE__ */ b("button", {
|
|
|
3579
3621
|
className: Q["bsy-lexical-ai__column"],
|
|
3580
3622
|
children: [/* @__PURE__ */ b("div", {
|
|
3581
3623
|
className: I(Q["bsy-lexical-ai__column-title"], Q["bsy-lexical-ai__column-title--before"]),
|
|
3582
|
-
children: [/* @__PURE__ */ y("span", { className: Q["bsy-lexical-ai__column-dot"] }),
|
|
3624
|
+
children: [/* @__PURE__ */ y("span", { className: Q["bsy-lexical-ai__column-dot"] }), p("editor.aiOriginal")]
|
|
3583
3625
|
}), /* @__PURE__ */ y(u, {
|
|
3584
3626
|
className: Q["bsy-lexical-ai__column-body"],
|
|
3585
|
-
options:
|
|
3586
|
-
children: /* @__PURE__ */ y(
|
|
3627
|
+
options: Ko,
|
|
3628
|
+
children: /* @__PURE__ */ y(Go, { html: i })
|
|
3587
3629
|
})]
|
|
3588
3630
|
}), /* @__PURE__ */ b("div", {
|
|
3589
3631
|
className: Q["bsy-lexical-ai__column"],
|
|
@@ -3591,11 +3633,11 @@ var Lo = ({ model: t }) => t.visible ? /* @__PURE__ */ b("button", {
|
|
|
3591
3633
|
className: Q["bsy-lexical-ai__column-head"],
|
|
3592
3634
|
children: [/* @__PURE__ */ b("div", {
|
|
3593
3635
|
className: I(Q["bsy-lexical-ai__column-title"], Q["bsy-lexical-ai__column-title--after"]),
|
|
3594
|
-
children: [/* @__PURE__ */ y("span", { className: Q["bsy-lexical-ai__column-dot"] }),
|
|
3636
|
+
children: [/* @__PURE__ */ y("span", { className: Q["bsy-lexical-ai__column-dot"] }), p("editor.aiOptimized")]
|
|
3595
3637
|
}), /* @__PURE__ */ y(f, {
|
|
3596
3638
|
menus: C,
|
|
3597
3639
|
showSearch: !1,
|
|
3598
|
-
activeKey: [
|
|
3640
|
+
activeKey: [s],
|
|
3599
3641
|
offset: {
|
|
3600
3642
|
x: 0,
|
|
3601
3643
|
y: 4
|
|
@@ -3604,12 +3646,12 @@ var Lo = ({ model: t }) => t.visible ? /* @__PURE__ */ b("button", {
|
|
|
3604
3646
|
width: 90,
|
|
3605
3647
|
minWidth: 90
|
|
3606
3648
|
},
|
|
3607
|
-
onClick: (e) =>
|
|
3649
|
+
onClick: (e) => c(e.key),
|
|
3608
3650
|
children: /* @__PURE__ */ b("button", {
|
|
3609
3651
|
type: "button",
|
|
3610
3652
|
className: Q["bsy-lexical-ai__preset"],
|
|
3611
|
-
title:
|
|
3612
|
-
children: [
|
|
3653
|
+
title: p("editor.aiPolish"),
|
|
3654
|
+
children: [p(Xr[s]), /* @__PURE__ */ y(e, {
|
|
3613
3655
|
name: "arrow-down",
|
|
3614
3656
|
size: 16
|
|
3615
3657
|
})]
|
|
@@ -3619,16 +3661,16 @@ var Lo = ({ model: t }) => t.visible ? /* @__PURE__ */ b("button", {
|
|
|
3619
3661
|
className: Q["bsy-lexical-ai__column-stack"],
|
|
3620
3662
|
children: [S.visible ? /* @__PURE__ */ y("div", {
|
|
3621
3663
|
className: Q["bsy-lexical-ai__think-pin"],
|
|
3622
|
-
children: /* @__PURE__ */ y(
|
|
3664
|
+
children: /* @__PURE__ */ y(Vo, { model: S })
|
|
3623
3665
|
}) : null, /* @__PURE__ */ b(u, {
|
|
3624
3666
|
className: Q["bsy-lexical-ai__column-body"],
|
|
3625
|
-
options:
|
|
3667
|
+
options: Ko,
|
|
3626
3668
|
viewportRef: _,
|
|
3627
3669
|
onScroll: S.onViewportScroll,
|
|
3628
3670
|
children: [t === "error" ? /* @__PURE__ */ y("div", {
|
|
3629
3671
|
className: Q["bsy-lexical-ai__error"],
|
|
3630
|
-
children:
|
|
3631
|
-
}) : /* @__PURE__ */ y(
|
|
3672
|
+
children: n || p("editor.aiError")
|
|
3673
|
+
}) : /* @__PURE__ */ y(Ho, { model: S }), v ? /* @__PURE__ */ y(Go, { html: o }) : null]
|
|
3632
3674
|
})]
|
|
3633
3675
|
})]
|
|
3634
3676
|
})]
|
|
@@ -3636,33 +3678,33 @@ var Lo = ({ model: t }) => t.visible ? /* @__PURE__ */ b("button", {
|
|
|
3636
3678
|
className: Q["bsy-lexical-ai__footer"],
|
|
3637
3679
|
children: [/* @__PURE__ */ y(F, {
|
|
3638
3680
|
onClick: () => g(!1),
|
|
3639
|
-
children:
|
|
3681
|
+
children: p("editor.aiAbandon")
|
|
3640
3682
|
}), /* @__PURE__ */ y(F, {
|
|
3641
3683
|
type: "primary",
|
|
3642
3684
|
disabled: !x,
|
|
3643
|
-
onClick: () =>
|
|
3644
|
-
children:
|
|
3685
|
+
onClick: () => d() && g(!1),
|
|
3686
|
+
children: p("editor.aiApply")
|
|
3645
3687
|
})]
|
|
3646
3688
|
})]
|
|
3647
3689
|
})
|
|
3648
3690
|
});
|
|
3649
|
-
},
|
|
3691
|
+
}, Jo = {
|
|
3650
3692
|
paddingAbsolute: !0,
|
|
3651
3693
|
overflow: {
|
|
3652
3694
|
x: "hidden",
|
|
3653
3695
|
y: "scroll"
|
|
3654
3696
|
}
|
|
3655
|
-
},
|
|
3656
|
-
let { t:
|
|
3697
|
+
}, Yo = ({ status: e, errorMessage: t, originalHtml: n, proposedHtml: i, onCancel: o, onApply: s }) => {
|
|
3698
|
+
let { t: c } = a(), l = _r(), [d, f] = P(!0), p = N(null), m = !!i.trim(), h = e === "ready" && m, g = Bo({
|
|
3657
3699
|
status: e,
|
|
3658
|
-
reasoning:
|
|
3700
|
+
reasoning: l
|
|
3659
3701
|
}, m, p);
|
|
3660
3702
|
return /* @__PURE__ */ y(r, {
|
|
3661
|
-
title:
|
|
3703
|
+
title: c("editor.aiPreview"),
|
|
3662
3704
|
open: d,
|
|
3663
3705
|
width: "800px",
|
|
3664
3706
|
fullSwitch: !0,
|
|
3665
|
-
afterClose:
|
|
3707
|
+
afterClose: o,
|
|
3666
3708
|
onOpenChange: f,
|
|
3667
3709
|
children: /* @__PURE__ */ b("div", {
|
|
3668
3710
|
className: Q["bsy-lexical-ai__dialog"],
|
|
@@ -3672,31 +3714,31 @@ var Lo = ({ model: t }) => t.visible ? /* @__PURE__ */ b("button", {
|
|
|
3672
3714
|
className: Q["bsy-lexical-ai__column"],
|
|
3673
3715
|
children: [/* @__PURE__ */ b("div", {
|
|
3674
3716
|
className: I(Q["bsy-lexical-ai__column-title"], Q["bsy-lexical-ai__column-title--before"]),
|
|
3675
|
-
children: [/* @__PURE__ */ y("span", { className: Q["bsy-lexical-ai__column-dot"] }),
|
|
3717
|
+
children: [/* @__PURE__ */ y("span", { className: Q["bsy-lexical-ai__column-dot"] }), c("editor.aiOriginal")]
|
|
3676
3718
|
}), /* @__PURE__ */ y(u, {
|
|
3677
3719
|
className: Q["bsy-lexical-ai__column-body"],
|
|
3678
|
-
options:
|
|
3679
|
-
children: /* @__PURE__ */ y(
|
|
3720
|
+
options: Jo,
|
|
3721
|
+
children: /* @__PURE__ */ y(Go, { html: n })
|
|
3680
3722
|
})]
|
|
3681
3723
|
}), /* @__PURE__ */ b("div", {
|
|
3682
3724
|
className: Q["bsy-lexical-ai__column"],
|
|
3683
3725
|
children: [/* @__PURE__ */ b("div", {
|
|
3684
3726
|
className: I(Q["bsy-lexical-ai__column-title"], Q["bsy-lexical-ai__column-title--after"]),
|
|
3685
|
-
children: [/* @__PURE__ */ y("span", { className: Q["bsy-lexical-ai__column-dot"] }),
|
|
3727
|
+
children: [/* @__PURE__ */ y("span", { className: Q["bsy-lexical-ai__column-dot"] }), c("editor.aiOptimized")]
|
|
3686
3728
|
}), /* @__PURE__ */ b("div", {
|
|
3687
3729
|
className: Q["bsy-lexical-ai__column-stack"],
|
|
3688
3730
|
children: [g.visible ? /* @__PURE__ */ y("div", {
|
|
3689
3731
|
className: Q["bsy-lexical-ai__think-pin"],
|
|
3690
|
-
children: /* @__PURE__ */ y(
|
|
3732
|
+
children: /* @__PURE__ */ y(Vo, { model: g })
|
|
3691
3733
|
}) : null, /* @__PURE__ */ b(u, {
|
|
3692
3734
|
className: Q["bsy-lexical-ai__column-body"],
|
|
3693
|
-
options:
|
|
3735
|
+
options: Jo,
|
|
3694
3736
|
viewportRef: p,
|
|
3695
3737
|
onScroll: g.onViewportScroll,
|
|
3696
3738
|
children: [e === "error" ? /* @__PURE__ */ y("div", {
|
|
3697
3739
|
className: Q["bsy-lexical-ai__error"],
|
|
3698
|
-
children:
|
|
3699
|
-
}) : /* @__PURE__ */ y(
|
|
3740
|
+
children: t || c("editor.aiError")
|
|
3741
|
+
}) : /* @__PURE__ */ y(Ho, { model: g }), m ? /* @__PURE__ */ y(Go, { html: i }) : null]
|
|
3700
3742
|
})]
|
|
3701
3743
|
})]
|
|
3702
3744
|
})]
|
|
@@ -3704,56 +3746,34 @@ var Lo = ({ model: t }) => t.visible ? /* @__PURE__ */ b("button", {
|
|
|
3704
3746
|
className: Q["bsy-lexical-ai__footer"],
|
|
3705
3747
|
children: [/* @__PURE__ */ y(F, {
|
|
3706
3748
|
onClick: () => f(!1),
|
|
3707
|
-
children:
|
|
3749
|
+
children: c("editor.aiAbandon")
|
|
3708
3750
|
}), /* @__PURE__ */ y(F, {
|
|
3709
3751
|
type: "primary",
|
|
3710
3752
|
disabled: !h,
|
|
3711
|
-
onClick: () =>
|
|
3712
|
-
children:
|
|
3753
|
+
onClick: () => s() && f(!1),
|
|
3754
|
+
children: c("editor.aiApply")
|
|
3713
3755
|
})]
|
|
3714
3756
|
})]
|
|
3715
3757
|
})
|
|
3716
3758
|
});
|
|
3717
|
-
}
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3759
|
+
};
|
|
3760
|
+
//#endregion
|
|
3761
|
+
//#region src/components/Editor/Preview/EditorPreview.tsx
|
|
3762
|
+
function Xo(e, t, n, r) {
|
|
3763
|
+
return Lo({
|
|
3764
|
+
enabled: e,
|
|
3765
|
+
status: r,
|
|
3766
|
+
revision: n,
|
|
3767
|
+
compute: () => Io(Yi(t, n), r)
|
|
3722
3768
|
});
|
|
3723
|
-
o.current = {
|
|
3724
|
-
originalHtml: t,
|
|
3725
|
-
text: n
|
|
3726
|
-
};
|
|
3727
|
-
let s = N(null);
|
|
3728
|
-
return j(() => {
|
|
3729
|
-
let t = () => {
|
|
3730
|
-
s.current !== null && (cancelAnimationFrame(s.current), s.current = null);
|
|
3731
|
-
};
|
|
3732
|
-
if (!e) {
|
|
3733
|
-
t(), a("");
|
|
3734
|
-
return;
|
|
3735
|
-
}
|
|
3736
|
-
let n = () => {
|
|
3737
|
-
s.current = null;
|
|
3738
|
-
let e = o.current;
|
|
3739
|
-
a(Ko(qi(e.originalHtml, e.text)));
|
|
3740
|
-
};
|
|
3741
|
-
if (r === "ready" || r === "error") {
|
|
3742
|
-
t(), n();
|
|
3743
|
-
return;
|
|
3744
|
-
}
|
|
3745
|
-
s.current === null && (s.current = requestAnimationFrame(n));
|
|
3746
|
-
}, [
|
|
3747
|
-
e,
|
|
3748
|
-
t,
|
|
3749
|
-
r,
|
|
3750
|
-
n
|
|
3751
|
-
]), O(() => () => {
|
|
3752
|
-
s.current !== null && cancelAnimationFrame(s.current);
|
|
3753
|
-
}, []), i;
|
|
3754
3769
|
}
|
|
3755
|
-
var
|
|
3756
|
-
let [n] = B(), { aiOpen: r, setAiOpen: i, aiSessionRef: o, stop: s, polish: c } =
|
|
3770
|
+
var Zo = ({ maxLength: e, onMaxLengthExceed: t }) => {
|
|
3771
|
+
let [n] = B(), { aiOpen: r, setAiOpen: i, aiSessionRef: o, stop: s, polish: c } = hr(), { t: l } = a(), [u, d] = ne.useMessage(), f = o.current, { text: p, status: m, errorMessage: h } = gr(), g = !m || m === "idle" ? "loading" : m, _ = p, x = M(() => r ? Io(o.current?.originalHtml || "", "ready") : "", [r, o]), S = Lo({
|
|
3772
|
+
enabled: r === "typeset",
|
|
3773
|
+
status: g,
|
|
3774
|
+
revision: _,
|
|
3775
|
+
compute: () => Io(Po(_, f?.codeBlocks ?? []), g)
|
|
3776
|
+
}), C = Xo(r === "polish", f?.originalHtml || "", _, g);
|
|
3757
3777
|
O(() => {
|
|
3758
3778
|
if (r) return n.setEditable(!1), n.update(() => {
|
|
3759
3779
|
Ne(null);
|
|
@@ -3761,16 +3781,16 @@ var Jo = ({ maxLength: e, onMaxLengthExceed: t }) => {
|
|
|
3761
3781
|
n.setEditable(!0);
|
|
3762
3782
|
};
|
|
3763
3783
|
}, [r, n]);
|
|
3764
|
-
let
|
|
3784
|
+
let w = T(() => {
|
|
3765
3785
|
s?.(), o.current = null, i(null);
|
|
3766
3786
|
}, [
|
|
3767
3787
|
o,
|
|
3768
3788
|
i,
|
|
3769
3789
|
s
|
|
3770
|
-
]),
|
|
3771
|
-
if (r !== "typeset" ||
|
|
3790
|
+
]), E = T(() => {
|
|
3791
|
+
if (r !== "typeset" || g !== "ready") return !1;
|
|
3772
3792
|
n.setEditable(!0);
|
|
3773
|
-
let { applied: i, truncated: a } =
|
|
3793
|
+
let { applied: i, truncated: a } = Fo(n, _, o.current?.codeBlocks ?? [], e);
|
|
3774
3794
|
return i ? (a && t?.(), !0) : (n.setEditable(!1), u.warning(l("editor.aiApplyEmpty")), !1);
|
|
3775
3795
|
}, [
|
|
3776
3796
|
r,
|
|
@@ -3779,17 +3799,17 @@ var Jo = ({ maxLength: e, onMaxLengthExceed: t }) => {
|
|
|
3779
3799
|
e,
|
|
3780
3800
|
u,
|
|
3781
3801
|
t,
|
|
3782
|
-
|
|
3802
|
+
g,
|
|
3783
3803
|
l,
|
|
3784
|
-
|
|
3785
|
-
]),
|
|
3804
|
+
_
|
|
3805
|
+
]), D = T(() => r !== "polish" || g !== "ready" ? !1 : Xi(n, _) ? !0 : (u.warning(l("editor.aiApplyEmpty")), !1), [
|
|
3786
3806
|
r,
|
|
3787
3807
|
n,
|
|
3788
3808
|
u,
|
|
3789
|
-
|
|
3809
|
+
g,
|
|
3790
3810
|
l,
|
|
3791
|
-
|
|
3792
|
-
]),
|
|
3811
|
+
_
|
|
3812
|
+
]), k = T((e) => {
|
|
3793
3813
|
let t = o.current;
|
|
3794
3814
|
!t?.originalText || !c || (t.preset = e, s?.(), c({
|
|
3795
3815
|
text: t.originalText,
|
|
@@ -3800,29 +3820,27 @@ var Jo = ({ maxLength: e, onMaxLengthExceed: t }) => {
|
|
|
3800
3820
|
c,
|
|
3801
3821
|
s
|
|
3802
3822
|
]);
|
|
3803
|
-
return r ? /* @__PURE__ */ b(v, { children: [d, r === "typeset" ? /* @__PURE__ */ y(
|
|
3804
|
-
status:
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
originalHtml: C,
|
|
3823
|
+
return r ? /* @__PURE__ */ b(v, { children: [d, r === "typeset" ? /* @__PURE__ */ y(Yo, {
|
|
3824
|
+
status: g,
|
|
3825
|
+
errorMessage: h,
|
|
3826
|
+
originalHtml: x,
|
|
3808
3827
|
proposedHtml: S,
|
|
3809
|
-
onCancel:
|
|
3810
|
-
onApply:
|
|
3811
|
-
}) : /* @__PURE__ */ y(
|
|
3812
|
-
status:
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
proposedHtml: E,
|
|
3828
|
+
onCancel: w,
|
|
3829
|
+
onApply: E
|
|
3830
|
+
}) : /* @__PURE__ */ y(qo, {
|
|
3831
|
+
status: g,
|
|
3832
|
+
errorMessage: h,
|
|
3833
|
+
originalHtml: x,
|
|
3834
|
+
proposedHtml: C,
|
|
3817
3835
|
preset: f?.preset ?? "quick",
|
|
3818
|
-
onPresetChange:
|
|
3819
|
-
onCancel:
|
|
3820
|
-
onApply:
|
|
3836
|
+
onPresetChange: k,
|
|
3837
|
+
onCancel: w,
|
|
3838
|
+
onApply: D
|
|
3821
3839
|
})] }) : d;
|
|
3822
|
-
},
|
|
3823
|
-
let { height: t = "auto", minHeight: n, onChange: r, toolbar: i, theme: a, maxLength: o, onMaxLengthExceed: s, upload: c, ai: l } = e, [u] = B(), { isSourceMode: d, isSourceModeRef: f } =
|
|
3840
|
+
}, Qo = [], $o = (e) => {
|
|
3841
|
+
let { height: t = "auto", minHeight: n, onChange: r, toolbar: i, theme: a, maxLength: o, onMaxLengthExceed: s, upload: c, ai: l } = e, [u] = B(), { isSourceMode: d, isSourceModeRef: f } = Ur(), p = N(null), m = N(null), h = N(/* @__PURE__ */ new Map()), g = N(null), _ = N(null), v = N(s);
|
|
3824
3842
|
v.current = s;
|
|
3825
|
-
let x =
|
|
3843
|
+
let x = Xa(o) ? o : void 0, [S, C] = P(0), [w, E] = P(null), D = i?.mode === "floating", k = x !== void 0 && !d, A = N(l);
|
|
3826
3844
|
A.current = l;
|
|
3827
3845
|
let j = N(r);
|
|
3828
3846
|
j.current = r;
|
|
@@ -3855,17 +3873,15 @@ var Jo = ({ maxLength: e, onMaxLengthExceed: t }) => {
|
|
|
3855
3873
|
c
|
|
3856
3874
|
]), ie = M(() => ({
|
|
3857
3875
|
text: l?.text ?? "",
|
|
3858
|
-
reasoning: l?.reasoning,
|
|
3859
3876
|
status: l?.status,
|
|
3860
3877
|
errorMessage: l?.errorMessage
|
|
3861
3878
|
}), [
|
|
3862
3879
|
l?.text,
|
|
3863
|
-
l?.reasoning,
|
|
3864
3880
|
l?.status,
|
|
3865
3881
|
l?.errorMessage
|
|
3866
3882
|
]), ae = T((e) => {
|
|
3867
3883
|
f.current || e.read(() => {
|
|
3868
|
-
let t = L().getTextContent(), n =
|
|
3884
|
+
let t = L().getTextContent(), n = Fi(X(he(u, null))), r = ni(n, t) ? null : n;
|
|
3869
3885
|
_.current = r, x !== void 0 && C(t.length);
|
|
3870
3886
|
let i = je(tn).map((e) => h.current.get(e.getSrc())).filter((e) => e !== void 0);
|
|
3871
3887
|
j.current({
|
|
@@ -3892,13 +3908,13 @@ var Jo = ({ maxLength: e, onMaxLengthExceed: t }) => {
|
|
|
3892
3908
|
if (f.current) {
|
|
3893
3909
|
let t = e.value?.trim() ? X(e.value) : "";
|
|
3894
3910
|
_.current = e.value, u.update(() => {
|
|
3895
|
-
|
|
3911
|
+
lo(co(t));
|
|
3896
3912
|
});
|
|
3897
3913
|
return;
|
|
3898
3914
|
}
|
|
3899
3915
|
let t = !1, n = _.current === null;
|
|
3900
3916
|
u.update(() => {
|
|
3901
|
-
|
|
3917
|
+
ti(u, e.value?.trim() ? X(e.value) : ""), x !== void 0 && (t = Za(u, x)), On(u);
|
|
3902
3918
|
}), n && u.dispatchCommand(Le, void 0), t && v.current?.();
|
|
3903
3919
|
}, [
|
|
3904
3920
|
e.value,
|
|
@@ -3906,43 +3922,46 @@ var Jo = ({ maxLength: e, onMaxLengthExceed: t }) => {
|
|
|
3906
3922
|
x,
|
|
3907
3923
|
f
|
|
3908
3924
|
]);
|
|
3909
|
-
let oe = i?.config?.length ? i.config :
|
|
3925
|
+
let oe = i?.config?.length ? i.config : Qo, se = T(() => {
|
|
3910
3926
|
v.current?.();
|
|
3911
3927
|
}, []);
|
|
3912
3928
|
return /* @__PURE__ */ y(fr.Provider, {
|
|
3913
3929
|
value: re,
|
|
3914
|
-
children: /* @__PURE__ */
|
|
3930
|
+
children: /* @__PURE__ */ y(pr.Provider, {
|
|
3915
3931
|
value: ie,
|
|
3916
|
-
children:
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3932
|
+
children: /* @__PURE__ */ b(mr.Provider, {
|
|
3933
|
+
value: l?.reasoning,
|
|
3934
|
+
children: [/* @__PURE__ */ y(es, {
|
|
3935
|
+
containerRef: p,
|
|
3936
|
+
isFloating: D,
|
|
3937
|
+
toolbarConfig: oe,
|
|
3938
|
+
toolbarTheme: a?.toolbar,
|
|
3939
|
+
containerTheme: a?.container,
|
|
3940
|
+
toolbarStyle: i?.style,
|
|
3941
|
+
toolbarSize: i?.size,
|
|
3942
|
+
toolbarMode: i?.mode,
|
|
3943
|
+
toolbarFloating: i?.floating,
|
|
3944
|
+
toolbarStickyOffset: i?.stickyOffset,
|
|
3945
|
+
height: t,
|
|
3946
|
+
minHeight: n,
|
|
3947
|
+
showLengthBadge: k,
|
|
3948
|
+
textLength: S,
|
|
3949
|
+
validMaxLength: x,
|
|
3950
|
+
onMaxLengthExceed: se,
|
|
3951
|
+
onChange: ae
|
|
3952
|
+
}), /* @__PURE__ */ y(Zo, {
|
|
3953
|
+
maxLength: x,
|
|
3954
|
+
onMaxLengthExceed: se
|
|
3955
|
+
})]
|
|
3956
|
+
})
|
|
3938
3957
|
})
|
|
3939
3958
|
});
|
|
3940
|
-
},
|
|
3959
|
+
}, es = w(function({ containerRef: e, isFloating: t, toolbarConfig: n, toolbarTheme: r, containerTheme: i, toolbarStyle: a, toolbarSize: o, toolbarMode: s, toolbarFloating: c, toolbarStickyOffset: l, height: u, minHeight: d, showLengthBadge: f, textLength: p, validMaxLength: m, onMaxLengthExceed: h, onChange: g }) {
|
|
3941
3960
|
let [_] = B(), v = Zt(), x = typeof u == "number" ? u : void 0, S = !t && x === void 0 && l !== void 0, C = N(!1);
|
|
3942
3961
|
O(() => {
|
|
3943
3962
|
v && C.current && (C.current = !1, _.focus());
|
|
3944
3963
|
}, [v, _]);
|
|
3945
|
-
let w = M(() =>
|
|
3964
|
+
let w = M(() => _a(i), [i]);
|
|
3946
3965
|
return /* @__PURE__ */ b("div", {
|
|
3947
3966
|
ref: e,
|
|
3948
3967
|
className: I("bsy-lexical-editor", $["bsy-lexical-editor"], t && $["bsy-lexical-editor--floating"], S && $["bsy-lexical-editor--sticky-toolbar"]),
|
|
@@ -3952,7 +3971,7 @@ var Jo = ({ maxLength: e, onMaxLengthExceed: t }) => {
|
|
|
3952
3971
|
!t || !n || !t.contains(n) || _.isEditable() || (C.current = !0, _.setEditable(!0));
|
|
3953
3972
|
},
|
|
3954
3973
|
children: [
|
|
3955
|
-
n && n.length > 0 ? /* @__PURE__ */ y(
|
|
3974
|
+
n && n.length > 0 ? /* @__PURE__ */ y(ha, {
|
|
3956
3975
|
config: n,
|
|
3957
3976
|
theme: r,
|
|
3958
3977
|
style: a,
|
|
@@ -3976,22 +3995,22 @@ var Jo = ({ maxLength: e, onMaxLengthExceed: t }) => {
|
|
|
3976
3995
|
}),
|
|
3977
3996
|
ErrorBoundary: me
|
|
3978
3997
|
})
|
|
3979
|
-
}), f && m !== void 0 ? /* @__PURE__ */ y(
|
|
3998
|
+
}), f && m !== void 0 ? /* @__PURE__ */ y(mo, {
|
|
3980
3999
|
current: p,
|
|
3981
4000
|
maxLength: m
|
|
3982
4001
|
}) : null]
|
|
3983
4002
|
}),
|
|
3984
4003
|
/* @__PURE__ */ y(Qt, {}),
|
|
3985
4004
|
/* @__PURE__ */ y($t, {}),
|
|
3986
|
-
/* @__PURE__ */ y(
|
|
3987
|
-
/* @__PURE__ */ y(
|
|
3988
|
-
/* @__PURE__ */ y(
|
|
3989
|
-
/* @__PURE__ */ y(
|
|
3990
|
-
/* @__PURE__ */ y(
|
|
3991
|
-
/* @__PURE__ */ y(
|
|
3992
|
-
/* @__PURE__ */ y(Wa, {}),
|
|
4005
|
+
/* @__PURE__ */ y(Ca, {}),
|
|
4006
|
+
/* @__PURE__ */ y(po, {}),
|
|
4007
|
+
/* @__PURE__ */ y(wa, {}),
|
|
4008
|
+
/* @__PURE__ */ y(Da, {}),
|
|
4009
|
+
/* @__PURE__ */ y(Oa, {}),
|
|
4010
|
+
/* @__PURE__ */ y(Ga, {}),
|
|
3993
4011
|
/* @__PURE__ */ y(Ka, {}),
|
|
3994
|
-
|
|
4012
|
+
/* @__PURE__ */ y(Ja, {}),
|
|
4013
|
+
f && m !== void 0 ? /* @__PURE__ */ y(Ya, {
|
|
3995
4014
|
maxLength: m,
|
|
3996
4015
|
onMaxLengthExceed: h
|
|
3997
4016
|
}) : null,
|
|
@@ -4003,15 +4022,15 @@ var Jo = ({ maxLength: e, onMaxLengthExceed: t }) => {
|
|
|
4003
4022
|
})
|
|
4004
4023
|
]
|
|
4005
4024
|
});
|
|
4006
|
-
}),
|
|
4025
|
+
}), ts = (e) => /* @__PURE__ */ y(uo, {
|
|
4007
4026
|
maxLength: e.maxLength,
|
|
4008
4027
|
onMaxLengthExceed: e.onMaxLengthExceed,
|
|
4009
|
-
children: /* @__PURE__ */ y(
|
|
4028
|
+
children: /* @__PURE__ */ y($o, { ...e })
|
|
4010
4029
|
});
|
|
4011
|
-
|
|
4030
|
+
ts.displayName = "BsyLexicalEditorCore";
|
|
4012
4031
|
//#endregion
|
|
4013
4032
|
//#region src/components/Editor/nodes/ExtendedLinkNode.ts
|
|
4014
|
-
var
|
|
4033
|
+
var ns = class e extends ft {
|
|
4015
4034
|
constructor(e = "", t = {}, n) {
|
|
4016
4035
|
super(e, t, n);
|
|
4017
4036
|
}
|
|
@@ -4026,15 +4045,15 @@ var $o = class e extends ft {
|
|
|
4026
4045
|
}, t.__key);
|
|
4027
4046
|
}
|
|
4028
4047
|
static importJSON(e) {
|
|
4029
|
-
return
|
|
4048
|
+
return rs().updateFromJSON(e);
|
|
4030
4049
|
}
|
|
4031
4050
|
sanitizeUrl(e) {
|
|
4032
4051
|
return e.startsWith("@") ? e : super.sanitizeUrl(e);
|
|
4033
4052
|
}
|
|
4034
|
-
},
|
|
4053
|
+
}, rs = (e = "", t = {}) => _e(new ns(e, t)), is = "1px solid #d9d9d9", as = { export: new Map([[Rt, (e, t) => {
|
|
4035
4054
|
let n = t.exportDOM(e);
|
|
4036
|
-
return at(n.element) && (n.element.style.border =
|
|
4037
|
-
}]]) },
|
|
4055
|
+
return at(n.element) && (n.element.style.border = is), n;
|
|
4056
|
+
}]]) }, os = (e) => {
|
|
4038
4057
|
let { autoFocus: t = !1 } = e;
|
|
4039
4058
|
return /* @__PURE__ */ y(le, {
|
|
4040
4059
|
initialConfig: M(() => ({
|
|
@@ -4073,17 +4092,17 @@ var $o = class e extends ft {
|
|
|
4073
4092
|
tableRow: "editor-table-row",
|
|
4074
4093
|
tableScrollableWrapper: "editor-table-scrollable-wrapper"
|
|
4075
4094
|
},
|
|
4076
|
-
html:
|
|
4095
|
+
html: as,
|
|
4077
4096
|
nodes: [
|
|
4078
|
-
|
|
4097
|
+
ns,
|
|
4079
4098
|
{
|
|
4080
4099
|
replace: ft,
|
|
4081
|
-
with: (e) => new
|
|
4100
|
+
with: (e) => new ns(e.__url, {
|
|
4082
4101
|
rel: e.__rel,
|
|
4083
4102
|
target: e.__target,
|
|
4084
4103
|
title: e.__title
|
|
4085
4104
|
}),
|
|
4086
|
-
withKlass:
|
|
4105
|
+
withKlass: ns
|
|
4087
4106
|
},
|
|
4088
4107
|
dt,
|
|
4089
4108
|
yt,
|
|
@@ -4095,17 +4114,17 @@ var $o = class e extends ft {
|
|
|
4095
4114
|
Bt,
|
|
4096
4115
|
Rt,
|
|
4097
4116
|
tn,
|
|
4098
|
-
|
|
4117
|
+
va,
|
|
4099
4118
|
{
|
|
4100
4119
|
replace: nt,
|
|
4101
|
-
with: (e) => new
|
|
4102
|
-
withKlass:
|
|
4120
|
+
with: (e) => new va(e.__text),
|
|
4121
|
+
withKlass: va
|
|
4103
4122
|
}
|
|
4104
4123
|
]
|
|
4105
4124
|
}), [t]),
|
|
4106
|
-
children: /* @__PURE__ */ y(
|
|
4125
|
+
children: /* @__PURE__ */ y(ts, { ...e })
|
|
4107
4126
|
});
|
|
4108
4127
|
};
|
|
4109
|
-
|
|
4128
|
+
os.displayName = "BsyLexicalEditor";
|
|
4110
4129
|
//#endregion
|
|
4111
|
-
export { we as $getRoot, q as BaseButton,
|
|
4130
|
+
export { we as $getRoot, q as BaseButton, Wo as EditorHtmlPreview, os as default, sa as listRegisteredToolbarButtons, ia as registerToolbarButton, aa as unregisterToolbarButton, st as useLexicalComposerContext };
|