bridgerte 0.9.10 → 0.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +864 -864
- package/dist/bridge.cjs.map +1 -1
- package/dist/bridge.js.map +1 -1
- package/dist/dom.cjs +1 -1
- package/dist/dom.js +2 -2
- package/dist/index-BBzHVrSi.cjs +4 -0
- package/dist/index-BBzHVrSi.cjs.map +1 -0
- package/dist/index-CQie9v_I.js +296 -0
- package/dist/index-CQie9v_I.js.map +1 -0
- package/dist/index-CuNKUHed.js.map +1 -1
- package/dist/{index-DNqqQycS.js → index-DDfgjstx.js} +963 -901
- package/dist/index-DDfgjstx.js.map +1 -0
- package/dist/index-DF8OhKI4.cjs.map +1 -1
- package/dist/index-DIJtCo91.cjs +36 -0
- package/dist/index-DIJtCo91.cjs.map +1 -0
- package/dist/index-GaS65GL0.cjs.map +1 -1
- package/dist/index-sbZNOcCB.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/native-spec.cjs.map +1 -1
- package/dist/native-spec.js.map +1 -1
- package/dist/webview.cjs +1 -1
- package/dist/webview.js +1 -1
- package/package.json +1 -1
- package/dist/index-B5xR6zve.cjs +0 -4
- package/dist/index-B5xR6zve.cjs.map +0 -1
- package/dist/index-DH5duOs3.js +0 -346
- package/dist/index-DH5duOs3.js.map +0 -1
- package/dist/index-DNqqQycS.js.map +0 -1
- package/dist/index-D_3O19qd.cjs +0 -36
- package/dist/index-D_3O19qd.cjs.map +0 -1
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { BRIDGE_CONTENT_CHANGE_DEBOUNCE_MS as
|
|
5
|
-
import { B as
|
|
6
|
-
import { DecoratorNode as tn, $applyNodeReplacement as et, $getRoot as H, $isElementNode as
|
|
7
|
-
import { $isHeadingNode as
|
|
8
|
-
import { $isCodeNode as K, $createCodeNode as
|
|
9
|
-
import { $isListNode as
|
|
10
|
-
import { $isTableSelection as
|
|
11
|
-
import { $isLinkNode as
|
|
12
|
-
import { registerHistory as
|
|
13
|
-
import { $generateNodesFromDOM as
|
|
14
|
-
import { $getSelectionStyleValueForProperty as
|
|
15
|
-
import { $getNearestNodeOfType as
|
|
16
|
-
import { codeBlockLanguagePanel as qe, isCommandStateForCommand as
|
|
17
|
-
import { r as
|
|
18
|
-
import { normalizeCodeLanguage as
|
|
19
|
-
import { autoUpdate as
|
|
20
|
-
const bt = "bridgerte-media",
|
|
1
|
+
var Jn = Object.defineProperty;
|
|
2
|
+
var Qn = (e, t, n) => t in e ? Jn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var De = (e, t, n) => Qn(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { BRIDGE_CONTENT_CHANGE_DEBOUNCE_MS as Zn, isBridgeMessage as er, BRIDGE_HEIGHT_CHANGE_THROTTLE_MS as tr, defaultBridgeEventTiming as nr } from "./bridge.js";
|
|
5
|
+
import { B as Pe, b as Zt, a as en } from "./index-CuNKUHed.js";
|
|
6
|
+
import { DecoratorNode as tn, $applyNodeReplacement as et, $getRoot as H, $isElementNode as ge, $createParagraphNode as F, KEY_BACKSPACE_COMMAND as nn, COMMAND_PRIORITY_HIGH as se, KEY_DELETE_COMMAND as rn, DELETE_CHARACTER_COMMAND as on, $getSelection as R, $isNodeSelection as rr, $isRangeSelection as D, TextNode as G, $isParagraphNode as or, $insertNodes as z, FORMAT_ELEMENT_COMMAND as ar, $createTextNode as Ie, FORMAT_TEXT_COMMAND as sr, REDO_COMMAND as ir, UNDO_COMMAND as lr, OUTDENT_CONTENT_COMMAND as cr, INDENT_CONTENT_COMMAND as dr, SKIP_SCROLL_INTO_VIEW_TAG as ur, $getNodeByKey as he, $setSelection as mr, SELECTION_CHANGE_COMMAND as an, COMMAND_PRIORITY_LOW as U, KEY_ESCAPE_COMMAND as sn, KEY_ARROW_DOWN_COMMAND as gr, KEY_ARROW_UP_COMMAND as hr, KEY_ENTER_COMMAND as pr, mergeRegister as ln, $getNearestNodeFromDOMNode as fr, CAN_UNDO_COMMAND as br, CAN_REDO_COMMAND as yr, createEditor as vr, CLEAR_HISTORY_COMMAND as wr } from "lexical";
|
|
7
|
+
import { $isHeadingNode as Cr, $isQuoteNode as _r, $createQuoteNode as kr, $createHeadingNode as Er, registerRichText as xr, HeadingNode as Mr, QuoteNode as Tr } from "@lexical/rich-text";
|
|
8
|
+
import { $isCodeNode as K, $createCodeNode as Lr, $isCodeHighlightNode as Nr, $createCodeHighlightNode as Sr, CodeNode as cn, CodeHighlightNode as Pr } from "@lexical/code";
|
|
9
|
+
import { $isListNode as Ir, ListNode as dn, INSERT_CHECK_LIST_COMMAND as Rr, INSERT_UNORDERED_LIST_COMMAND as Ar, INSERT_ORDERED_LIST_COMMAND as Br, $isListItemNode as Dr, registerList as Or, registerCheckList as Hr, ListItemNode as $r } from "@lexical/list";
|
|
10
|
+
import { $isTableSelection as un, $findTableNode as Fr, $deleteTableColumnAtSelection as zr, $deleteTableRowAtSelection as Vr, $insertTableColumnAtSelection as Wr, $insertTableRowAtSelection as Ur, INSERT_TABLE_COMMAND as jr, $findCellNode as qr, TableNode as je, $isTableRowNode as Kr, $isTableCellNode as Gr, registerTablePlugin as Xr, TableRowNode as Yr, TableCellNode as Jr, setScrollableTablesActive as Qr } from "@lexical/table";
|
|
11
|
+
import { $isLinkNode as Te, $toggleLink as mt, formatUrl as Zr, $createLinkNode as eo, registerAutoLink as to, createLinkMatcherWithRegExp as gt, LinkNode as no, AutoLinkNode as ro } from "@lexical/link";
|
|
12
|
+
import { registerHistory as oo, createEmptyHistoryState as ao } from "@lexical/history";
|
|
13
|
+
import { $generateNodesFromDOM as mn, $generateHtmlFromNodes as so } from "@lexical/html";
|
|
14
|
+
import { $getSelectionStyleValueForProperty as io, $setBlocksType as Oe, $patchStyleText as ht, $trimTextContentFromAnchor as pt } from "@lexical/selection";
|
|
15
|
+
import { $getNearestNodeOfType as lo, $findMatchingParent as co, $insertNodeToNearestRoot as gn } from "@lexical/utils";
|
|
16
|
+
import { codeBlockLanguagePanel as qe, isCommandStateForCommand as uo, resolveToolbarMenu as tt, defaultMenuSchema as Re, tableHeaderMenuItems as mo } from "./native-spec.js";
|
|
17
|
+
import { r as hn } from "./index-sbZNOcCB.js";
|
|
18
|
+
import { normalizeCodeLanguage as go, getCodeLanguageOptions as ho, ShikiTokenizer as ft, isCodeLanguageLoaded as pn, loadCodeLanguage as po, loadCodeTheme as fo, registerCodeHighlighting as bo } from "@lexical/code-shiki";
|
|
19
|
+
import { autoUpdate as yo, computePosition as vo, platform as wo, offset as Co, flip as _o, shift as ko } from "@floating-ui/dom";
|
|
20
|
+
const bt = "bridgerte-media", fn = "Loading", yt = (e, t) => `${e}:${t}`, ne = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? Math.floor(e) : void 0, vt = (e) => typeof e == "number" && Number.isFinite(e) ? Math.min(Math.max(e, 0), 100) : void 0, Eo = (e) => e === 20 || e === 50 || e === 100, wt = (e) => Eo(e) ? e : void 0, Ct = (e) => e === "center" || e === "right" ? e : void 0, xo = (e) => e.status === "error" ? e.errorMessage ?? "媒体加载失败" : fn, Mo = (e, t) => !t || e.status === void 0 || e.status === "success", He = (e, t, n) => {
|
|
21
21
|
n && e.setAttribute(t, n);
|
|
22
22
|
}, _t = (e, t, n) => {
|
|
23
23
|
n !== void 0 && e.setAttribute(t, String(n));
|
|
24
24
|
};
|
|
25
|
-
class
|
|
25
|
+
class ie extends tn {
|
|
26
26
|
constructor(n, r) {
|
|
27
27
|
super(r);
|
|
28
|
-
|
|
28
|
+
De(this, "__payload");
|
|
29
29
|
this.__payload = {
|
|
30
30
|
...n,
|
|
31
31
|
assetId: n.assetId ?? yt(n.mediaType, n.url),
|
|
@@ -41,7 +41,7 @@ class se extends tn {
|
|
|
41
41
|
return bt;
|
|
42
42
|
}
|
|
43
43
|
static clone(n) {
|
|
44
|
-
return new
|
|
44
|
+
return new ie(n.__payload, n.__key);
|
|
45
45
|
}
|
|
46
46
|
createDOM(n) {
|
|
47
47
|
return this.createMediaElement(!0);
|
|
@@ -57,17 +57,17 @@ class se extends tn {
|
|
|
57
57
|
static importDOM() {
|
|
58
58
|
return {
|
|
59
59
|
img: () => ({
|
|
60
|
-
conversion:
|
|
60
|
+
conversion: To,
|
|
61
61
|
priority: 1
|
|
62
62
|
}),
|
|
63
63
|
video: () => ({
|
|
64
|
-
conversion:
|
|
64
|
+
conversion: Lo,
|
|
65
65
|
priority: 1
|
|
66
66
|
})
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
static importJSON(n) {
|
|
70
|
-
return
|
|
70
|
+
return le(n).updateFromJSON(n);
|
|
71
71
|
}
|
|
72
72
|
exportJSON() {
|
|
73
73
|
return {
|
|
@@ -133,26 +133,26 @@ class se extends tn {
|
|
|
133
133
|
), a.addEventListener("error", () => {
|
|
134
134
|
o.dataset.loadState = "error";
|
|
135
135
|
}, { once: !0 }));
|
|
136
|
-
const c =
|
|
137
|
-
if (r.mediaType === "image" ? (c && a.setAttribute("src", r.url), a.setAttribute("loading", "lazy"),
|
|
136
|
+
const c = Mo(r, n);
|
|
137
|
+
if (r.mediaType === "image" ? (c && a.setAttribute("src", r.url), a.setAttribute("loading", "lazy"), He(a, "alt", r.alt ?? r.title)) : (c && a.setAttribute("src", r.url), a.setAttribute("controls", "true"), a.setAttribute("preload", "metadata"), He(a, "poster", r.poster)), He(a, "title", r.title), _t(a, "width", r.width), _t(a, "height", r.height), n) {
|
|
138
138
|
const d = document.createElement("div"), l = document.createElement("span"), h = document.createElement("span");
|
|
139
|
-
d.className = "bridgerte__media-placeholder", d.setAttribute("aria-hidden", "true"), l.className = "bridgerte__media-placeholder-icon", l.textContent = r.mediaType === "image" ? "IMG" : "VIDEO", h.className = "bridgerte__media-placeholder-text", h.textContent =
|
|
139
|
+
d.className = "bridgerte__media-placeholder", d.setAttribute("aria-hidden", "true"), l.className = "bridgerte__media-placeholder-icon", l.textContent = r.mediaType === "image" ? "IMG" : "VIDEO", h.className = "bridgerte__media-placeholder-text", h.textContent = xo(r), d.append(l, h), o.append(d);
|
|
140
140
|
}
|
|
141
141
|
if (o.append(a), r.status === "uploading" || r.status === "error") {
|
|
142
142
|
const d = document.createElement("figcaption");
|
|
143
|
-
d.className = "bridgerte__media-status", d.textContent = r.status === "error" ? r.errorMessage ?? "上传失败" :
|
|
143
|
+
d.className = "bridgerte__media-status", d.textContent = r.status === "error" ? r.errorMessage ?? "上传失败" : fn, o.append(d);
|
|
144
144
|
}
|
|
145
145
|
return o;
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
const
|
|
148
|
+
const To = (e) => {
|
|
149
149
|
const t = e instanceof HTMLImageElement ? e : null;
|
|
150
150
|
return {
|
|
151
151
|
/*
|
|
152
152
|
* 外部 HTML 粘贴或 setContent 导入 img 时,只认带 src 的真实媒体。
|
|
153
153
|
* 状态统一设为 success,因为浏览器 DOM 不包含 BridgeRTE 上传任务信息。
|
|
154
154
|
*/
|
|
155
|
-
node: t != null && t.src ?
|
|
155
|
+
node: t != null && t.src ? le({
|
|
156
156
|
mediaType: "image",
|
|
157
157
|
url: t.src,
|
|
158
158
|
alt: t.alt,
|
|
@@ -162,13 +162,13 @@ const Eo = (e) => {
|
|
|
162
162
|
status: "success"
|
|
163
163
|
}) : null
|
|
164
164
|
};
|
|
165
|
-
},
|
|
165
|
+
}, Lo = (e) => {
|
|
166
166
|
const t = e instanceof HTMLVideoElement ? e : null;
|
|
167
167
|
return {
|
|
168
168
|
/*
|
|
169
169
|
* video 导入只保留可序列化的展示元信息;controls、preload 等播放属性由 createDOM 重建。
|
|
170
170
|
*/
|
|
171
|
-
node: t != null && t.src ?
|
|
171
|
+
node: t != null && t.src ? le({
|
|
172
172
|
mediaType: "video",
|
|
173
173
|
url: t.src,
|
|
174
174
|
poster: t.poster,
|
|
@@ -178,7 +178,7 @@ const Eo = (e) => {
|
|
|
178
178
|
status: "success"
|
|
179
179
|
}) : null
|
|
180
180
|
};
|
|
181
|
-
},
|
|
181
|
+
}, le = (e) => et(new ie(e)), No = (e) => le({
|
|
182
182
|
mediaType: "image",
|
|
183
183
|
url: e.url,
|
|
184
184
|
alt: e.alt,
|
|
@@ -189,7 +189,7 @@ const Eo = (e) => {
|
|
|
189
189
|
align: e.align,
|
|
190
190
|
assetId: e.assetId,
|
|
191
191
|
status: "success"
|
|
192
|
-
}),
|
|
192
|
+
}), So = (e) => le({
|
|
193
193
|
mediaType: "video",
|
|
194
194
|
url: e.url,
|
|
195
195
|
poster: e.poster,
|
|
@@ -200,10 +200,10 @@ const Eo = (e) => {
|
|
|
200
200
|
align: e.align,
|
|
201
201
|
assetId: e.assetId,
|
|
202
202
|
status: "success"
|
|
203
|
-
}),
|
|
203
|
+
}), bn = (e) => e instanceof ie, me = (e) => {
|
|
204
204
|
const t = (n) => {
|
|
205
|
-
if (
|
|
206
|
-
if (!
|
|
205
|
+
if (bn(n) && n.getAsset().id === e) return n;
|
|
206
|
+
if (!ge(n)) return null;
|
|
207
207
|
for (const r of n.getChildren()) {
|
|
208
208
|
const o = t(r);
|
|
209
209
|
if (o) return o;
|
|
@@ -211,7 +211,7 @@ const Eo = (e) => {
|
|
|
211
211
|
return null;
|
|
212
212
|
};
|
|
213
213
|
return t(H());
|
|
214
|
-
},
|
|
214
|
+
}, yn = {
|
|
215
215
|
root: {
|
|
216
216
|
type: "root",
|
|
217
217
|
version: 1,
|
|
@@ -221,41 +221,41 @@ const Eo = (e) => {
|
|
|
221
221
|
function Ke(e = {}) {
|
|
222
222
|
return {
|
|
223
223
|
html: e.html ?? "",
|
|
224
|
-
json: e.json ??
|
|
224
|
+
json: e.json ?? yn,
|
|
225
225
|
plainText: e.plainText ?? "",
|
|
226
226
|
assets: e.assets ?? [],
|
|
227
|
-
version: e.version ??
|
|
227
|
+
version: e.version ?? Pe
|
|
228
228
|
};
|
|
229
229
|
}
|
|
230
|
-
const
|
|
230
|
+
const Po = (e) => e.toJSON(), Io = (e) => {
|
|
231
231
|
var t;
|
|
232
232
|
return ((t = e.root.children) == null ? void 0 : t.length) === 0;
|
|
233
|
-
},
|
|
233
|
+
}, Ro = (e) => e.read(() => {
|
|
234
234
|
const t = /* @__PURE__ */ new Map(), n = (r) => {
|
|
235
|
-
|
|
236
|
-
if (
|
|
235
|
+
ge(r) && r.getChildren().forEach((o) => {
|
|
236
|
+
if (bn(o)) {
|
|
237
237
|
const a = o.getAsset();
|
|
238
238
|
t.set(a.id, a);
|
|
239
239
|
return;
|
|
240
240
|
}
|
|
241
|
-
|
|
241
|
+
ge(o) && n(o);
|
|
242
242
|
});
|
|
243
243
|
};
|
|
244
244
|
return n(H()), [...t.values()];
|
|
245
|
-
}),
|
|
246
|
-
const n = t.read(() =>
|
|
245
|
+
}), vn = (e, t) => {
|
|
246
|
+
const n = t.read(() => so(t)), r = e.read(() => H().getTextContent()), o = Ro(e);
|
|
247
247
|
return {
|
|
248
248
|
html: n,
|
|
249
|
-
json:
|
|
249
|
+
json: Po(e),
|
|
250
250
|
plainText: r,
|
|
251
251
|
assets: o,
|
|
252
|
-
version:
|
|
252
|
+
version: Pe
|
|
253
253
|
};
|
|
254
|
-
},
|
|
254
|
+
}, Ao = (e, t) => {
|
|
255
255
|
const n = Ke(t);
|
|
256
|
-
return
|
|
257
|
-
},
|
|
258
|
-
if (t.json !==
|
|
256
|
+
return wn(e, n), vn(e.getEditorState(), e);
|
|
257
|
+
}, wn = (e, t) => {
|
|
258
|
+
if (t.json !== yn && !Io(t.json)) {
|
|
259
259
|
const o = t.json;
|
|
260
260
|
e.setEditorState(e.parseEditorState(o));
|
|
261
261
|
return;
|
|
@@ -273,18 +273,79 @@ const So = (e) => e.toJSON(), No = (e) => {
|
|
|
273
273
|
const r = new DOMParser().parseFromString(t.html, "text/html");
|
|
274
274
|
e.update(
|
|
275
275
|
() => {
|
|
276
|
-
const o = H(), a =
|
|
276
|
+
const o = H(), a = mn(e, r);
|
|
277
277
|
o.clear(), o.append(...a);
|
|
278
278
|
},
|
|
279
279
|
{ discrete: !0 }
|
|
280
280
|
);
|
|
281
|
+
}, Bo = "bridgerte-divider", Cn = (e) => (e == null ? void 0 : e.getType()) === Bo, Do = (e, t, n) => {
|
|
282
|
+
const r = H();
|
|
283
|
+
if (r.getChildrenSize() === 0) {
|
|
284
|
+
const o = F();
|
|
285
|
+
r.append(o), o.selectStart();
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
if (n) {
|
|
289
|
+
e == null || e.selectEnd(), e || t == null || t.selectStart();
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
t == null || t.selectStart(), t || e == null || e.selectEnd();
|
|
293
|
+
}, Oo = (e, t) => {
|
|
294
|
+
const n = e.getPreviousSibling(), r = e.getNextSibling();
|
|
295
|
+
e.remove(), Do(n, r, t);
|
|
296
|
+
}, Ho = () => {
|
|
297
|
+
const e = R();
|
|
298
|
+
if (!rr(e)) return null;
|
|
299
|
+
const t = e.getNodes();
|
|
300
|
+
return t.length === 1 && Cn(t[0]) ? t[0] : null;
|
|
301
|
+
}, $o = (e) => e.getKey() === "root" ? null : e.getTopLevelElement(), Fo = (e) => {
|
|
302
|
+
const t = R();
|
|
303
|
+
if (!D(t) || !t.isCollapsed()) return null;
|
|
304
|
+
const n = t.anchor, r = n.getNode(), o = $o(r);
|
|
305
|
+
if (!o || !ge(o)) return null;
|
|
306
|
+
if (ge(r)) {
|
|
307
|
+
const c = r.isEmpty() && n.offset === 0, d = r === o && n.offset === 0, l = r === o && n.offset === o.getChildrenSize();
|
|
308
|
+
return c || (e ? d : l) ? o : null;
|
|
309
|
+
}
|
|
310
|
+
if (!(r instanceof G)) return null;
|
|
311
|
+
const a = e ? o.getFirstDescendant() : o.getLastDescendant(), s = e ? 0 : r.getTextContentSize();
|
|
312
|
+
return a === r && n.offset === s ? o : null;
|
|
313
|
+
}, zo = (e) => {
|
|
314
|
+
const t = Fo(e), n = e ? t == null ? void 0 : t.getPreviousSibling() : t == null ? void 0 : t.getNextSibling();
|
|
315
|
+
return Cn(n) ? n : null;
|
|
316
|
+
}, Vo = (e, t) => {
|
|
317
|
+
const n = (o) => {
|
|
318
|
+
if (t()) return !1;
|
|
319
|
+
const a = Ho() ?? zo(o);
|
|
320
|
+
return a ? (Oo(a, o), !0) : !1;
|
|
321
|
+
}, r = (o, a) => {
|
|
322
|
+
const s = n(a);
|
|
323
|
+
return s && o.preventDefault(), s;
|
|
324
|
+
};
|
|
325
|
+
return [
|
|
326
|
+
e.registerCommand(
|
|
327
|
+
nn,
|
|
328
|
+
(o) => r(o, !0),
|
|
329
|
+
se
|
|
330
|
+
),
|
|
331
|
+
e.registerCommand(
|
|
332
|
+
rn,
|
|
333
|
+
(o) => r(o, !1),
|
|
334
|
+
se
|
|
335
|
+
),
|
|
336
|
+
e.registerCommand(
|
|
337
|
+
on,
|
|
338
|
+
(o) => n(o),
|
|
339
|
+
se
|
|
340
|
+
)
|
|
341
|
+
];
|
|
281
342
|
};
|
|
282
|
-
class
|
|
343
|
+
class pe extends tn {
|
|
283
344
|
static getType() {
|
|
284
345
|
return "bridgerte-divider";
|
|
285
346
|
}
|
|
286
347
|
static clone(t) {
|
|
287
|
-
return new
|
|
348
|
+
return new pe(t.__key);
|
|
288
349
|
}
|
|
289
350
|
constructor(t) {
|
|
290
351
|
super(t);
|
|
@@ -303,7 +364,7 @@ class ge extends tn {
|
|
|
303
364
|
static importDOM() {
|
|
304
365
|
return {
|
|
305
366
|
hr: () => ({
|
|
306
|
-
conversion:
|
|
367
|
+
conversion: Wo,
|
|
307
368
|
priority: 0
|
|
308
369
|
})
|
|
309
370
|
};
|
|
@@ -314,7 +375,7 @@ class ge extends tn {
|
|
|
314
375
|
exportJSON() {
|
|
315
376
|
return {
|
|
316
377
|
...super.exportJSON(),
|
|
317
|
-
type:
|
|
378
|
+
type: pe.getType()
|
|
318
379
|
};
|
|
319
380
|
}
|
|
320
381
|
getTextContent() {
|
|
@@ -325,23 +386,23 @@ class ge extends tn {
|
|
|
325
386
|
return !1;
|
|
326
387
|
}
|
|
327
388
|
}
|
|
328
|
-
const
|
|
389
|
+
const Wo = (e) => ({
|
|
329
390
|
node: nt()
|
|
330
|
-
}), nt = () => et(new
|
|
391
|
+
}), nt = () => et(new pe()), kt = "bridgerte-mention", rt = "mention", _n = (e) => e.label.startsWith("@") ? e.label : `@${e.label}`, Uo = (e) => {
|
|
331
392
|
const t = document.createElement("span");
|
|
332
|
-
return t.className = "bridgerte__mention", t.dataset.type = rt, t.dataset.id = e.id, t.dataset.value = e.value, t.contentEditable = "false", t.textContent =
|
|
393
|
+
return t.className = "bridgerte__mention", t.dataset.type = rt, t.dataset.id = e.id, t.dataset.value = e.value, t.contentEditable = "false", t.textContent = _n(e), e.description && (t.dataset.description = e.description), t;
|
|
333
394
|
};
|
|
334
|
-
class
|
|
335
|
-
constructor(n, r =
|
|
395
|
+
class ye extends G {
|
|
396
|
+
constructor(n, r = _n(n), o) {
|
|
336
397
|
super(r, o);
|
|
337
|
-
|
|
398
|
+
De(this, "__item");
|
|
338
399
|
this.__item = n;
|
|
339
400
|
}
|
|
340
401
|
static getType() {
|
|
341
402
|
return kt;
|
|
342
403
|
}
|
|
343
404
|
static clone(n) {
|
|
344
|
-
return new
|
|
405
|
+
return new ye(n.__item, n.__text, n.__key);
|
|
345
406
|
}
|
|
346
407
|
createDOM(n) {
|
|
347
408
|
const r = super.createDOM(n);
|
|
@@ -351,12 +412,12 @@ class fe extends ee {
|
|
|
351
412
|
return super.updateDOM(n, r, o) ? !0 : (r.dataset.id = this.__item.id, r.dataset.value = this.__item.value, this.__item.description ? r.dataset.description = this.__item.description : delete r.dataset.description, !1);
|
|
352
413
|
}
|
|
353
414
|
exportDOM(n) {
|
|
354
|
-
return { element:
|
|
415
|
+
return { element: Uo(this.__item) };
|
|
355
416
|
}
|
|
356
417
|
static importDOM() {
|
|
357
418
|
return {
|
|
358
419
|
span: () => ({
|
|
359
|
-
conversion:
|
|
420
|
+
conversion: jo,
|
|
360
421
|
priority: 2
|
|
361
422
|
})
|
|
362
423
|
};
|
|
@@ -381,7 +442,7 @@ class fe extends ee {
|
|
|
381
442
|
return this.__item;
|
|
382
443
|
}
|
|
383
444
|
}
|
|
384
|
-
const
|
|
445
|
+
const jo = (e) => {
|
|
385
446
|
var a;
|
|
386
447
|
const t = e instanceof HTMLElement ? e : null;
|
|
387
448
|
if (!t || t.dataset.type !== rt)
|
|
@@ -395,19 +456,19 @@ const Bo = (e) => {
|
|
|
395
456
|
description: t.dataset.description
|
|
396
457
|
})
|
|
397
458
|
};
|
|
398
|
-
}, ot = (e) => et(new
|
|
459
|
+
}, ot = (e) => et(new ye(e).setMode("token")), Et = (e) => e instanceof ye, qo = "请输入内容", Ko = () => {
|
|
399
460
|
const t = H().getChildren();
|
|
400
461
|
if (t.length === 0) return !0;
|
|
401
462
|
if (t.length > 1) return !1;
|
|
402
463
|
const n = t[0];
|
|
403
|
-
return
|
|
404
|
-
},
|
|
464
|
+
return or(n) && n.getChildrenSize() === 0;
|
|
465
|
+
}, Go = ({
|
|
405
466
|
editor: e,
|
|
406
467
|
contentElement: t
|
|
407
468
|
}) => {
|
|
408
|
-
const n = e.getEditorState().read(
|
|
469
|
+
const n = e.getEditorState().read(Ko);
|
|
409
470
|
t.dataset.empty = String(n);
|
|
410
|
-
},
|
|
471
|
+
}, Xo = ({
|
|
411
472
|
editor: e,
|
|
412
473
|
contentElement: t,
|
|
413
474
|
isReadonly: n
|
|
@@ -422,7 +483,7 @@ const Bo = (e) => {
|
|
|
422
483
|
return t.addEventListener("pointerdown", r), () => {
|
|
423
484
|
t.removeEventListener("pointerdown", r);
|
|
424
485
|
};
|
|
425
|
-
},
|
|
486
|
+
}, Yo = [
|
|
426
487
|
{ command: "format.bold", format: "bold" },
|
|
427
488
|
{ command: "format.italic", format: "italic" },
|
|
428
489
|
{ command: "format.underline", format: "underline" },
|
|
@@ -430,35 +491,35 @@ const Bo = (e) => {
|
|
|
430
491
|
{ command: "format.inlineCode", format: "code" },
|
|
431
492
|
{ command: "format.superscript", format: "superscript" },
|
|
432
493
|
{ command: "format.subscript", format: "subscript" }
|
|
433
|
-
],
|
|
494
|
+
], Jo = [
|
|
434
495
|
{ command: "format.color", property: "color" },
|
|
435
496
|
{ command: "format.backgroundColor", property: "background-color" },
|
|
436
497
|
{ command: "format.fontSize", property: "font-size" },
|
|
437
498
|
{ command: "format.fontFamily", property: "font-family" },
|
|
438
499
|
{ command: "format.lineHeight", property: "line-height" }
|
|
439
|
-
],
|
|
500
|
+
], Qo = [
|
|
440
501
|
{ command: "list.ordered", listType: "ordered" },
|
|
441
502
|
{ command: "list.unordered", listType: "unordered" },
|
|
442
503
|
{ command: "list.todo", listType: "todo" }
|
|
443
|
-
],
|
|
504
|
+
], Zo = [
|
|
444
505
|
"media.pickImage",
|
|
445
506
|
"media.pickVideo"
|
|
446
|
-
],
|
|
507
|
+
], kn = () => {
|
|
447
508
|
const e = R();
|
|
448
509
|
if (!D(e)) return null;
|
|
449
510
|
const t = e.anchor.getNode();
|
|
450
511
|
return t.getKey() === "root" ? t : t.getTopLevelElementOrThrow();
|
|
451
|
-
},
|
|
452
|
-
const e =
|
|
512
|
+
}, ea = () => {
|
|
513
|
+
const e = kn();
|
|
453
514
|
if (!e) return null;
|
|
454
|
-
if (
|
|
515
|
+
if (Cr(e)) {
|
|
455
516
|
const t = Number(e.getTag().replace("h", ""));
|
|
456
517
|
return {
|
|
457
518
|
command: "block.heading",
|
|
458
519
|
value: Number.isNaN(t) ? void 0 : t
|
|
459
520
|
};
|
|
460
521
|
}
|
|
461
|
-
if (
|
|
522
|
+
if (_r(e))
|
|
462
523
|
return {
|
|
463
524
|
command: "block.quote"
|
|
464
525
|
};
|
|
@@ -472,44 +533,44 @@ const Bo = (e) => {
|
|
|
472
533
|
return {
|
|
473
534
|
command: "block.paragraph"
|
|
474
535
|
};
|
|
475
|
-
},
|
|
476
|
-
const e =
|
|
536
|
+
}, ta = () => {
|
|
537
|
+
const e = kn();
|
|
477
538
|
if (!e || !("getFormatType" in e)) return;
|
|
478
539
|
const t = e.getFormatType();
|
|
479
540
|
return t === "" ? void 0 : t;
|
|
480
|
-
},
|
|
541
|
+
}, na = () => {
|
|
481
542
|
const e = R();
|
|
482
543
|
if (!D(e)) return null;
|
|
483
|
-
const t = e.anchor.getNode(), n =
|
|
544
|
+
const t = e.anchor.getNode(), n = Ir(t) ? t : lo(t, dn);
|
|
484
545
|
return n ? n.getListType() === "check" ? "todo" : n.getTag() === "ol" ? "ordered" : "unordered" : null;
|
|
485
|
-
},
|
|
546
|
+
}, ra = (e) => {
|
|
486
547
|
const t = R();
|
|
487
548
|
if (!D(t)) return;
|
|
488
|
-
const n =
|
|
549
|
+
const n = io(t, e);
|
|
489
550
|
return n === "" ? void 0 : n;
|
|
490
|
-
},
|
|
551
|
+
}, oa = () => {
|
|
491
552
|
const e = R();
|
|
492
553
|
if (!D(e)) return !1;
|
|
493
554
|
const t = e.anchor.getNode(), n = t.getParent();
|
|
494
|
-
return
|
|
495
|
-
},
|
|
496
|
-
const t = R(), n = D(t), r =
|
|
555
|
+
return Te(t) || Te(n);
|
|
556
|
+
}, aa = (e) => {
|
|
557
|
+
const t = R(), n = D(t), r = ea(), o = na(), a = ta(), s = oa(), c = e.readonly || !n, d = Yo.map((w) => ({
|
|
497
558
|
command: w.command,
|
|
498
559
|
active: n && t.hasFormat(w.format),
|
|
499
560
|
disabled: c
|
|
500
|
-
})), l =
|
|
501
|
-
const T =
|
|
561
|
+
})), l = Jo.map((w) => {
|
|
562
|
+
const T = ra(w.property);
|
|
502
563
|
return {
|
|
503
564
|
command: w.command,
|
|
504
565
|
active: T !== void 0,
|
|
505
566
|
disabled: c,
|
|
506
567
|
value: T
|
|
507
568
|
};
|
|
508
|
-
}), h =
|
|
569
|
+
}), h = Qo.map((w) => ({
|
|
509
570
|
command: w.command,
|
|
510
571
|
active: o === w.listType,
|
|
511
572
|
disabled: c
|
|
512
|
-
})), v =
|
|
573
|
+
})), v = Zo.map((w) => ({
|
|
513
574
|
command: w,
|
|
514
575
|
active: !1,
|
|
515
576
|
disabled: e.readonly || !e.canUploadMedia
|
|
@@ -608,7 +669,7 @@ const Bo = (e) => {
|
|
|
608
669
|
disabled: !1
|
|
609
670
|
}
|
|
610
671
|
];
|
|
611
|
-
},
|
|
672
|
+
}, sa = (e, t) => e.length === t.length && e.every((n, r) => {
|
|
612
673
|
const o = t[r];
|
|
613
674
|
return o !== void 0 && n.command === o.command && n.active === o.active && n.disabled === o.disabled && n.value === o.value;
|
|
614
675
|
}), j = (e, t, n, r) => {
|
|
@@ -618,14 +679,14 @@ const Bo = (e) => {
|
|
|
618
679
|
} catch (a) {
|
|
619
680
|
console.error("[BridgeRTE] onError callback failed.", a);
|
|
620
681
|
}
|
|
621
|
-
},
|
|
682
|
+
}, ia = (e, t) => {
|
|
622
683
|
var n;
|
|
623
684
|
try {
|
|
624
685
|
(n = e.onChange) == null || n.call(e, t);
|
|
625
686
|
} catch (r) {
|
|
626
687
|
j(e, "callback.onChange", "onChange callback failed.", r);
|
|
627
688
|
}
|
|
628
|
-
},
|
|
689
|
+
}, la = (e, t) => {
|
|
629
690
|
var n;
|
|
630
691
|
try {
|
|
631
692
|
(n = e.onContentChange) == null || n.call(e, t);
|
|
@@ -637,7 +698,7 @@ const Bo = (e) => {
|
|
|
637
698
|
r
|
|
638
699
|
);
|
|
639
700
|
}
|
|
640
|
-
},
|
|
701
|
+
}, ca = (e, t) => {
|
|
641
702
|
var n;
|
|
642
703
|
try {
|
|
643
704
|
(n = e.onCommandStateChange) == null || n.call(e, [...t]);
|
|
@@ -649,28 +710,28 @@ const Bo = (e) => {
|
|
|
649
710
|
r
|
|
650
711
|
);
|
|
651
712
|
}
|
|
652
|
-
},
|
|
713
|
+
}, da = (e) => {
|
|
653
714
|
var t;
|
|
654
715
|
try {
|
|
655
716
|
(t = e.onFocus) == null || t.call(e);
|
|
656
717
|
} catch (n) {
|
|
657
718
|
j(e, "callback.onFocus", "onFocus callback failed.", n);
|
|
658
719
|
}
|
|
659
|
-
},
|
|
720
|
+
}, ua = (e) => {
|
|
660
721
|
var t;
|
|
661
722
|
try {
|
|
662
723
|
(t = e.onBlur) == null || t.call(e);
|
|
663
724
|
} catch (n) {
|
|
664
725
|
j(e, "callback.onBlur", "onBlur callback failed.", n);
|
|
665
726
|
}
|
|
666
|
-
},
|
|
727
|
+
}, ma = (e, t) => {
|
|
667
728
|
var n;
|
|
668
729
|
try {
|
|
669
730
|
(n = e.onReady) == null || n.call(e, t);
|
|
670
731
|
} catch (r) {
|
|
671
732
|
j(e, "callback.onReady", "onReady callback failed.", r);
|
|
672
733
|
}
|
|
673
|
-
},
|
|
734
|
+
}, ga = ({
|
|
674
735
|
lexicalEditor: e,
|
|
675
736
|
options: t,
|
|
676
737
|
isDestroyed: n,
|
|
@@ -696,13 +757,13 @@ const Bo = (e) => {
|
|
|
696
757
|
if (n()) return;
|
|
697
758
|
const w = c;
|
|
698
759
|
e.getEditorState().read(() => {
|
|
699
|
-
c =
|
|
760
|
+
c = aa({
|
|
700
761
|
canUndo: a,
|
|
701
762
|
canRedo: s,
|
|
702
763
|
readonly: o(),
|
|
703
764
|
canUploadMedia: r()
|
|
704
765
|
});
|
|
705
|
-
}), v && !
|
|
766
|
+
}), v && !sa(w, c) && (ca(t, c), l());
|
|
706
767
|
};
|
|
707
768
|
return {
|
|
708
769
|
refreshCommandStates: h,
|
|
@@ -728,14 +789,14 @@ const Bo = (e) => {
|
|
|
728
789
|
d.clear();
|
|
729
790
|
}
|
|
730
791
|
};
|
|
731
|
-
},
|
|
792
|
+
}, ha = (e) => `upload:${e}:${Date.now()}:${Math.random().toString(36).slice(2)}`, pa = (e) => typeof URL.createObjectURL == "function" ? URL.createObjectURL(e) : e.name, ve = (e) => {
|
|
732
793
|
typeof URL.revokeObjectURL == "function" && e.startsWith("blob:") && URL.revokeObjectURL(e);
|
|
733
|
-
},
|
|
794
|
+
}, xt = (e) => ({
|
|
734
795
|
name: e.name,
|
|
735
796
|
mimeType: e.type || void 0,
|
|
736
797
|
size: e.size,
|
|
737
798
|
data: e
|
|
738
|
-
}),
|
|
799
|
+
}), fa = (e) => typeof DOMException < "u" && e instanceof DOMException && e.name === "AbortError", ba = (e) => new Promise((t) => {
|
|
739
800
|
const n = new Image(), r = () => {
|
|
740
801
|
n.onload = null, n.onerror = null;
|
|
741
802
|
};
|
|
@@ -748,7 +809,7 @@ const Bo = (e) => {
|
|
|
748
809
|
}, n.onerror = () => {
|
|
749
810
|
r(), t({});
|
|
750
811
|
}, n.src = e;
|
|
751
|
-
}),
|
|
812
|
+
}), ya = (e) => new Promise((t) => {
|
|
752
813
|
const n = document.createElement("video"), r = () => {
|
|
753
814
|
n.removeAttribute("src"), n.load(), n.onloadedmetadata = null, n.onerror = null;
|
|
754
815
|
};
|
|
@@ -762,12 +823,12 @@ const Bo = (e) => {
|
|
|
762
823
|
}, n.onerror = () => {
|
|
763
824
|
r(), t({});
|
|
764
825
|
}, n.src = e, n.load();
|
|
765
|
-
}),
|
|
826
|
+
}), va = (e, t) => t.startsWith("blob:") ? e === "image" ? ba(t) : ya(t) : Promise.resolve({}), wa = (e, t) => ({
|
|
766
827
|
...e,
|
|
767
828
|
width: e.width ?? t.width,
|
|
768
829
|
height: e.height ?? t.height,
|
|
769
830
|
duration: e.duration ?? t.duration
|
|
770
|
-
}),
|
|
831
|
+
}), Ca = ({
|
|
771
832
|
container: e,
|
|
772
833
|
lexicalEditor: t,
|
|
773
834
|
options: n,
|
|
@@ -778,12 +839,12 @@ const Bo = (e) => {
|
|
|
778
839
|
const s = (m, p) => {
|
|
779
840
|
t.update(() => {
|
|
780
841
|
var k;
|
|
781
|
-
(k =
|
|
842
|
+
(k = me(m)) == null || k.updatePayload(p);
|
|
782
843
|
});
|
|
783
844
|
}, c = (m) => {
|
|
784
845
|
let p = null;
|
|
785
846
|
return t.update(() => {
|
|
786
|
-
const k =
|
|
847
|
+
const k = me(m);
|
|
787
848
|
if (!k) return;
|
|
788
849
|
const _ = k.getAsset();
|
|
789
850
|
p = {
|
|
@@ -811,11 +872,11 @@ const Bo = (e) => {
|
|
|
811
872
|
(p = m.abortController) == null || p.abort();
|
|
812
873
|
}, h = (m, p) => {
|
|
813
874
|
const k = o.get(m);
|
|
814
|
-
return k ? (l(k),
|
|
875
|
+
return k ? (l(k), ve(k.previewUrl), o.delete(m), !0) : !1;
|
|
815
876
|
}, v = (m, p, k, _) => {
|
|
816
877
|
t.update(
|
|
817
878
|
() => {
|
|
818
|
-
const P =
|
|
879
|
+
const P = le({
|
|
819
880
|
mediaType: m,
|
|
820
881
|
url: _,
|
|
821
882
|
assetId: k,
|
|
@@ -842,10 +903,10 @@ const Bo = (e) => {
|
|
|
842
903
|
status: "success",
|
|
843
904
|
progress: 100,
|
|
844
905
|
errorMessage: void 0
|
|
845
|
-
}),
|
|
906
|
+
}), ve(k);
|
|
846
907
|
}, T = (m, p, k) => {
|
|
847
908
|
var _;
|
|
848
|
-
|
|
909
|
+
fa(k) || (s(p, {
|
|
849
910
|
mediaType: m,
|
|
850
911
|
status: "error",
|
|
851
912
|
errorMessage: "上传失败"
|
|
@@ -871,10 +932,10 @@ const Bo = (e) => {
|
|
|
871
932
|
}
|
|
872
933
|
};
|
|
873
934
|
let I = {};
|
|
874
|
-
const L =
|
|
935
|
+
const L = va(m.type, m.previewUrl);
|
|
875
936
|
let C;
|
|
876
937
|
try {
|
|
877
|
-
C = m.type === "image" ? p.uploadImage(
|
|
938
|
+
C = m.type === "image" ? p.uploadImage(xt(m.file), P) : p.uploadVideo(xt(m.file), P);
|
|
878
939
|
} catch (i) {
|
|
879
940
|
d(m.assetId, _) && T(m.type, m.assetId, i);
|
|
880
941
|
return;
|
|
@@ -891,14 +952,14 @@ const Bo = (e) => {
|
|
|
891
952
|
m.type,
|
|
892
953
|
m.assetId,
|
|
893
954
|
m.previewUrl,
|
|
894
|
-
|
|
955
|
+
wa(i, I)
|
|
895
956
|
), o.delete(m.assetId));
|
|
896
957
|
}).catch((i) => {
|
|
897
958
|
r() || !d(m.assetId, _) || T(m.type, m.assetId, i);
|
|
898
959
|
});
|
|
899
960
|
}, y = (m, p) => {
|
|
900
961
|
if (!n.uploadAdapter) return;
|
|
901
|
-
const k =
|
|
962
|
+
const k = ha(m), _ = pa(p), P = {
|
|
902
963
|
assetId: k,
|
|
903
964
|
type: m,
|
|
904
965
|
file: p,
|
|
@@ -921,7 +982,7 @@ const Bo = (e) => {
|
|
|
921
982
|
uploadMediaFile: y,
|
|
922
983
|
removeMedia(m) {
|
|
923
984
|
const p = c(m);
|
|
924
|
-
!h(m) && (p != null && p.url.startsWith("blob:")) &&
|
|
985
|
+
!h(m) && (p != null && p.url.startsWith("blob:")) && ve(p.url);
|
|
925
986
|
},
|
|
926
987
|
retryMedia(m) {
|
|
927
988
|
const p = o.get(m);
|
|
@@ -935,18 +996,18 @@ const Bo = (e) => {
|
|
|
935
996
|
},
|
|
936
997
|
destroy() {
|
|
937
998
|
o.forEach((m) => {
|
|
938
|
-
l(m),
|
|
999
|
+
l(m), ve(m.previewUrl);
|
|
939
1000
|
}), o.clear();
|
|
940
1001
|
}
|
|
941
1002
|
};
|
|
942
|
-
},
|
|
1003
|
+
}, En = (e) => Lr(e), _a = {
|
|
943
1004
|
1: "h1",
|
|
944
1005
|
2: "h2",
|
|
945
1006
|
3: "h3",
|
|
946
1007
|
4: "h4",
|
|
947
1008
|
5: "h5",
|
|
948
1009
|
6: "h6"
|
|
949
|
-
},
|
|
1010
|
+
}, ka = {
|
|
950
1011
|
code: "bridgerte__code-block",
|
|
951
1012
|
codeHighlight: {
|
|
952
1013
|
attr: "bridgerte__code-token bridgerte__code-token--attr",
|
|
@@ -1007,23 +1068,23 @@ const Bo = (e) => {
|
|
|
1007
1068
|
tableCellHeader: "bridgerte__table-cell bridgerte__table-cell--header",
|
|
1008
1069
|
tableRow: "bridgerte__table-row",
|
|
1009
1070
|
tableScrollableWrapper: "bridgerte__table-wrapper"
|
|
1010
|
-
},
|
|
1071
|
+
}, Ea = (e) => ({
|
|
1011
1072
|
setBlockHeading: (l) => {
|
|
1012
1073
|
e.update(() => {
|
|
1013
1074
|
const h = R();
|
|
1014
|
-
D(h) &&
|
|
1075
|
+
D(h) && Oe(h, () => Er(_a[l]));
|
|
1015
1076
|
});
|
|
1016
1077
|
},
|
|
1017
1078
|
setParagraphBlock: () => {
|
|
1018
1079
|
e.update(() => {
|
|
1019
1080
|
const l = R();
|
|
1020
|
-
D(l) &&
|
|
1081
|
+
D(l) && Oe(l, () => F());
|
|
1021
1082
|
});
|
|
1022
1083
|
},
|
|
1023
1084
|
setQuoteBlock: () => {
|
|
1024
1085
|
e.update(() => {
|
|
1025
1086
|
const l = R();
|
|
1026
|
-
D(l) &&
|
|
1087
|
+
D(l) && Oe(l, () => kr());
|
|
1027
1088
|
});
|
|
1028
1089
|
},
|
|
1029
1090
|
insertDividerBlock: () => {
|
|
@@ -1034,7 +1095,7 @@ const Bo = (e) => {
|
|
|
1034
1095
|
},
|
|
1035
1096
|
insertCodeBlock: (l) => {
|
|
1036
1097
|
e.update(() => {
|
|
1037
|
-
const h =
|
|
1098
|
+
const h = En(l), v = F();
|
|
1038
1099
|
z([h, v]), h.selectEnd();
|
|
1039
1100
|
});
|
|
1040
1101
|
},
|
|
@@ -1053,19 +1114,19 @@ const Bo = (e) => {
|
|
|
1053
1114
|
});
|
|
1054
1115
|
},
|
|
1055
1116
|
formatAlign: (l) => {
|
|
1056
|
-
e.dispatchCommand(
|
|
1117
|
+
e.dispatchCommand(ar, l);
|
|
1057
1118
|
}
|
|
1058
|
-
}),
|
|
1119
|
+
}), xa = (e) => ({
|
|
1059
1120
|
setLink: (o, a) => {
|
|
1060
1121
|
e.update(() => {
|
|
1061
|
-
const s = R(), c =
|
|
1122
|
+
const s = R(), c = Zr(o), d = (a == null ? void 0 : a.trim()) || o.trim();
|
|
1062
1123
|
if (!(!D(s) || !o.trim())) {
|
|
1063
1124
|
if (s.isCollapsed()) {
|
|
1064
|
-
const l =
|
|
1125
|
+
const l = eo(c, {
|
|
1065
1126
|
rel: "noreferrer noopener",
|
|
1066
1127
|
target: "_blank"
|
|
1067
1128
|
});
|
|
1068
|
-
l.append(
|
|
1129
|
+
l.append(Ie(d)), z([l]);
|
|
1069
1130
|
return;
|
|
1070
1131
|
}
|
|
1071
1132
|
mt(c, {
|
|
@@ -1085,7 +1146,7 @@ const Bo = (e) => {
|
|
|
1085
1146
|
const o = e.getEditorState().read(() => {
|
|
1086
1147
|
const a = R();
|
|
1087
1148
|
if (!D(a)) return null;
|
|
1088
|
-
const s = a.anchor.getNode(), c =
|
|
1149
|
+
const s = a.anchor.getNode(), c = Te(s) ? s : co(s, Te);
|
|
1089
1150
|
return c ? {
|
|
1090
1151
|
target: c.getTarget() ?? "_blank",
|
|
1091
1152
|
url: c.sanitizeUrl(c.getURL())
|
|
@@ -1093,23 +1154,23 @@ const Bo = (e) => {
|
|
|
1093
1154
|
});
|
|
1094
1155
|
o && window.open(o.url, o.target, "noopener,noreferrer");
|
|
1095
1156
|
}
|
|
1096
|
-
}),
|
|
1157
|
+
}), Ma = (e) => ({
|
|
1097
1158
|
insertImage: (s) => {
|
|
1098
1159
|
s.url.trim() && e.update(() => {
|
|
1099
1160
|
const c = F();
|
|
1100
|
-
z([
|
|
1161
|
+
z([No(s), c]), c.selectStart();
|
|
1101
1162
|
});
|
|
1102
1163
|
},
|
|
1103
1164
|
insertVideo: (s) => {
|
|
1104
1165
|
s.url.trim() && e.update(() => {
|
|
1105
1166
|
const c = F();
|
|
1106
|
-
z([
|
|
1167
|
+
z([So(s), c]), c.selectStart();
|
|
1107
1168
|
});
|
|
1108
1169
|
},
|
|
1109
1170
|
resizeMedia: (s) => {
|
|
1110
1171
|
e.update(() => {
|
|
1111
1172
|
var c;
|
|
1112
|
-
(c =
|
|
1173
|
+
(c = me(s.assetId)) == null || c.updatePayload({
|
|
1113
1174
|
displayWidthPercent: s.widthPercent
|
|
1114
1175
|
});
|
|
1115
1176
|
});
|
|
@@ -1117,7 +1178,7 @@ const Bo = (e) => {
|
|
|
1117
1178
|
resetMediaSize: (s) => {
|
|
1118
1179
|
e.update(() => {
|
|
1119
1180
|
var c;
|
|
1120
|
-
(c =
|
|
1181
|
+
(c = me(s)) == null || c.updatePayload({
|
|
1121
1182
|
displayWidthPercent: void 0
|
|
1122
1183
|
});
|
|
1123
1184
|
});
|
|
@@ -1125,22 +1186,22 @@ const Bo = (e) => {
|
|
|
1125
1186
|
alignMedia: (s) => {
|
|
1126
1187
|
e.update(() => {
|
|
1127
1188
|
var c;
|
|
1128
|
-
(c =
|
|
1189
|
+
(c = me(s.assetId)) == null || c.updatePayload({
|
|
1129
1190
|
align: s.value === "left" ? void 0 : s.value
|
|
1130
1191
|
});
|
|
1131
1192
|
});
|
|
1132
1193
|
}
|
|
1133
|
-
}),
|
|
1194
|
+
}), Ta = (e) => ({
|
|
1134
1195
|
insertMention: (n) => {
|
|
1135
1196
|
e.update(() => {
|
|
1136
1197
|
const r = R();
|
|
1137
1198
|
D(r) && z([
|
|
1138
1199
|
ot(n),
|
|
1139
|
-
|
|
1200
|
+
Ie(" ")
|
|
1140
1201
|
]);
|
|
1141
1202
|
});
|
|
1142
1203
|
}
|
|
1143
|
-
}),
|
|
1204
|
+
}), La = (e) => ({
|
|
1144
1205
|
clearSelectionFormat: () => {
|
|
1145
1206
|
e.update(() => {
|
|
1146
1207
|
const r = R();
|
|
@@ -1161,13 +1222,13 @@ const Bo = (e) => {
|
|
|
1161
1222
|
});
|
|
1162
1223
|
});
|
|
1163
1224
|
}
|
|
1164
|
-
}),
|
|
1225
|
+
}), Na = 20, Mt = (e, t) => Number.isFinite(e) && e > 0 ? Math.min(Math.floor(e), t) : 1, we = (e) => Number.isFinite(e) && (e ?? 0) > 0 ? Math.min(Math.floor(e ?? 1), Na) : 1, Ce = () => {
|
|
1165
1226
|
const e = R();
|
|
1166
|
-
return !D(e) && !
|
|
1167
|
-
},
|
|
1227
|
+
return !D(e) && !un(e) ? !1 : qr(e.anchor.getNode()) !== null;
|
|
1228
|
+
}, Sa = (e) => ({
|
|
1168
1229
|
insertTable: (c, d) => {
|
|
1169
1230
|
const l = Mt(c, Zt), h = Mt(d, en);
|
|
1170
|
-
e.dispatchCommand(
|
|
1231
|
+
e.dispatchCommand(jr, {
|
|
1171
1232
|
rows: String(l),
|
|
1172
1233
|
columns: String(h),
|
|
1173
1234
|
/*
|
|
@@ -1182,50 +1243,50 @@ const Bo = (e) => {
|
|
|
1182
1243
|
},
|
|
1183
1244
|
insertTableRow: (c) => {
|
|
1184
1245
|
e.update(() => {
|
|
1185
|
-
if (!
|
|
1186
|
-
const d =
|
|
1246
|
+
if (!Ce()) return;
|
|
1247
|
+
const d = we(c.count);
|
|
1187
1248
|
for (let l = 0; l < d; l += 1)
|
|
1188
|
-
|
|
1249
|
+
Ur(c.direction !== "before");
|
|
1189
1250
|
});
|
|
1190
1251
|
},
|
|
1191
1252
|
insertTableColumn: (c) => {
|
|
1192
1253
|
e.update(() => {
|
|
1193
|
-
if (!
|
|
1194
|
-
const d =
|
|
1254
|
+
if (!Ce()) return;
|
|
1255
|
+
const d = we(c.count);
|
|
1195
1256
|
for (let l = 0; l < d; l += 1)
|
|
1196
|
-
|
|
1257
|
+
Wr(c.direction !== "before");
|
|
1197
1258
|
});
|
|
1198
1259
|
},
|
|
1199
1260
|
deleteTableRow: (c) => {
|
|
1200
1261
|
e.update(() => {
|
|
1201
|
-
const d =
|
|
1262
|
+
const d = we(c.count);
|
|
1202
1263
|
for (let l = 0; l < d; l += 1) {
|
|
1203
|
-
if (!
|
|
1204
|
-
|
|
1264
|
+
if (!Ce()) return;
|
|
1265
|
+
Vr();
|
|
1205
1266
|
}
|
|
1206
1267
|
});
|
|
1207
1268
|
},
|
|
1208
1269
|
deleteTableColumn: (c) => {
|
|
1209
1270
|
e.update(() => {
|
|
1210
|
-
const d =
|
|
1271
|
+
const d = we(c.count);
|
|
1211
1272
|
for (let l = 0; l < d; l += 1) {
|
|
1212
|
-
if (!
|
|
1213
|
-
|
|
1273
|
+
if (!Ce()) return;
|
|
1274
|
+
zr();
|
|
1214
1275
|
}
|
|
1215
1276
|
});
|
|
1216
1277
|
},
|
|
1217
1278
|
deleteTable: () => {
|
|
1218
1279
|
e.update(() => {
|
|
1219
1280
|
const c = R();
|
|
1220
|
-
if (!D(c) && !
|
|
1221
|
-
const d =
|
|
1281
|
+
if (!D(c) && !un(c)) return;
|
|
1282
|
+
const d = Fr(c.anchor.getNode());
|
|
1222
1283
|
if (!d) return;
|
|
1223
1284
|
const l = F();
|
|
1224
1285
|
d.insertAfter(l), d.remove(), l.selectStart();
|
|
1225
1286
|
});
|
|
1226
1287
|
}
|
|
1227
|
-
}),
|
|
1228
|
-
const t =
|
|
1288
|
+
}), Pa = (e) => {
|
|
1289
|
+
const t = Sa(e);
|
|
1229
1290
|
return {
|
|
1230
1291
|
insertTable: (n) => {
|
|
1231
1292
|
t.insertTable(n.rows, n.cols);
|
|
@@ -1246,7 +1307,7 @@ const Bo = (e) => {
|
|
|
1246
1307
|
t.deleteTable();
|
|
1247
1308
|
}
|
|
1248
1309
|
};
|
|
1249
|
-
},
|
|
1310
|
+
}, Ia = {
|
|
1250
1311
|
"format.bold": "bold",
|
|
1251
1312
|
"format.italic": "italic",
|
|
1252
1313
|
"format.underline": "underline",
|
|
@@ -1254,22 +1315,22 @@ const Bo = (e) => {
|
|
|
1254
1315
|
"format.inlineCode": "code",
|
|
1255
1316
|
"format.superscript": "superscript",
|
|
1256
1317
|
"format.subscript": "subscript"
|
|
1257
|
-
},
|
|
1258
|
-
"list.ordered":
|
|
1259
|
-
"list.unordered":
|
|
1260
|
-
"list.todo":
|
|
1261
|
-
},
|
|
1262
|
-
"indent.increase":
|
|
1263
|
-
"indent.decrease":
|
|
1264
|
-
"history.undo":
|
|
1265
|
-
"history.redo":
|
|
1266
|
-
},
|
|
1318
|
+
}, Ra = {
|
|
1319
|
+
"list.ordered": Br,
|
|
1320
|
+
"list.unordered": Ar,
|
|
1321
|
+
"list.todo": Rr
|
|
1322
|
+
}, Aa = {
|
|
1323
|
+
"indent.increase": dr,
|
|
1324
|
+
"indent.decrease": cr,
|
|
1325
|
+
"history.undo": lr,
|
|
1326
|
+
"history.redo": ir
|
|
1327
|
+
}, Ba = {
|
|
1267
1328
|
"format.color": "color",
|
|
1268
1329
|
"format.backgroundColor": "background-color",
|
|
1269
1330
|
"format.fontSize": "font-size",
|
|
1270
1331
|
"format.fontFamily": "font-family",
|
|
1271
1332
|
"format.lineHeight": "line-height"
|
|
1272
|
-
},
|
|
1333
|
+
}, Da = ({
|
|
1273
1334
|
container: e,
|
|
1274
1335
|
lexicalEditor: t,
|
|
1275
1336
|
options: n,
|
|
@@ -1277,15 +1338,15 @@ const Bo = (e) => {
|
|
|
1277
1338
|
isReadonly: o,
|
|
1278
1339
|
reportError: a
|
|
1279
1340
|
}) => {
|
|
1280
|
-
const s =
|
|
1341
|
+
const s = Ca({
|
|
1281
1342
|
container: e,
|
|
1282
1343
|
lexicalEditor: t,
|
|
1283
1344
|
options: n,
|
|
1284
1345
|
isDestroyed: r
|
|
1285
|
-
}), c =
|
|
1286
|
-
var
|
|
1346
|
+
}), c = Ea(t), d = xa(t), l = Ma(t), h = Ta(t), v = La(t), w = Pa(t), T = () => {
|
|
1347
|
+
var x, m;
|
|
1287
1348
|
if (document.fullscreenElement) {
|
|
1288
|
-
(
|
|
1349
|
+
(x = document.exitFullscreen) == null || x.call(document).catch((p) => {
|
|
1289
1350
|
a(n, "fullscreen.exit", "Exit fullscreen failed.", p);
|
|
1290
1351
|
});
|
|
1291
1352
|
return;
|
|
@@ -1295,22 +1356,22 @@ const Bo = (e) => {
|
|
|
1295
1356
|
});
|
|
1296
1357
|
}, f = ((y) => {
|
|
1297
1358
|
if (r() || o()) return;
|
|
1298
|
-
const
|
|
1299
|
-
if (
|
|
1300
|
-
t.dispatchCommand(
|
|
1359
|
+
const x = Ia[y.type];
|
|
1360
|
+
if (x) {
|
|
1361
|
+
t.dispatchCommand(sr, x);
|
|
1301
1362
|
return;
|
|
1302
1363
|
}
|
|
1303
|
-
const m =
|
|
1364
|
+
const m = Ra[y.type];
|
|
1304
1365
|
if (m) {
|
|
1305
1366
|
t.dispatchCommand(m, void 0);
|
|
1306
1367
|
return;
|
|
1307
1368
|
}
|
|
1308
|
-
const p =
|
|
1369
|
+
const p = Aa[y.type];
|
|
1309
1370
|
if (p) {
|
|
1310
1371
|
t.dispatchCommand(p, void 0);
|
|
1311
1372
|
return;
|
|
1312
1373
|
}
|
|
1313
|
-
const k =
|
|
1374
|
+
const k = Ba[y.type];
|
|
1314
1375
|
if (k && "value" in y) {
|
|
1315
1376
|
v.setSelectionStyle(k, y.value);
|
|
1316
1377
|
return;
|
|
@@ -1408,7 +1469,7 @@ const Bo = (e) => {
|
|
|
1408
1469
|
return f.uploadMediaFile = s.uploadMediaFile, f.destroy = () => {
|
|
1409
1470
|
s.destroy();
|
|
1410
1471
|
}, f;
|
|
1411
|
-
},
|
|
1472
|
+
}, Oa = 300, Ha = "BridgeRTE", Tt = ({
|
|
1412
1473
|
editor: e,
|
|
1413
1474
|
overflowLength: t
|
|
1414
1475
|
}) => {
|
|
@@ -1419,7 +1480,7 @@ const Bo = (e) => {
|
|
|
1419
1480
|
H().selectEnd();
|
|
1420
1481
|
const r = R();
|
|
1421
1482
|
return D(r) ? (pt(e, r.anchor, t), !0) : !1;
|
|
1422
|
-
},
|
|
1483
|
+
}, $a = ({
|
|
1423
1484
|
lexicalEditor: e,
|
|
1424
1485
|
options: t,
|
|
1425
1486
|
isDestroyed: n,
|
|
@@ -1431,23 +1492,23 @@ const Bo = (e) => {
|
|
|
1431
1492
|
s && (clearTimeout(s), s = null);
|
|
1432
1493
|
}, d = (m) => {
|
|
1433
1494
|
if (n()) return;
|
|
1434
|
-
const p =
|
|
1435
|
-
r(p), m &&
|
|
1495
|
+
const p = vn(e.getEditorState(), e);
|
|
1496
|
+
r(p), m && ia(t, p);
|
|
1436
1497
|
}, l = (m) => {
|
|
1437
1498
|
const p = t.maxLength !== void 0 && t.maxLength >= 0 ? t.maxLength : void 0;
|
|
1438
1499
|
return {
|
|
1439
1500
|
dirty: !0,
|
|
1440
1501
|
plainTextLength: m,
|
|
1441
|
-
version:
|
|
1502
|
+
version: Pe,
|
|
1442
1503
|
maxLength: p,
|
|
1443
1504
|
isOverMaxLength: p === void 0 ? !1 : m > p
|
|
1444
1505
|
};
|
|
1445
1506
|
}, h = (m) => {
|
|
1446
|
-
|
|
1507
|
+
la(t, l(m));
|
|
1447
1508
|
}, v = () => {
|
|
1448
1509
|
t.onChange && (c(), s = setTimeout(() => {
|
|
1449
1510
|
d(!0);
|
|
1450
|
-
},
|
|
1511
|
+
}, Zn));
|
|
1451
1512
|
}, w = (m) => {
|
|
1452
1513
|
if (a > 0) {
|
|
1453
1514
|
a -= 1;
|
|
@@ -1478,14 +1539,14 @@ const Bo = (e) => {
|
|
|
1478
1539
|
o(), w(m);
|
|
1479
1540
|
}
|
|
1480
1541
|
};
|
|
1481
|
-
},
|
|
1482
|
-
|
|
1542
|
+
}, Ae = "data-language", xn = "纯文本", Fa = "language", za = /* @__PURE__ */ new Set(["plain", "plaintext", "text", "txt"]), Va = new Set(ho().map(([e]) => e)), Wa = [
|
|
1543
|
+
Ae,
|
|
1483
1544
|
"data-lang",
|
|
1484
1545
|
"data-code-language",
|
|
1485
1546
|
"data-highlight-language",
|
|
1486
1547
|
"lang",
|
|
1487
1548
|
"language"
|
|
1488
|
-
],
|
|
1549
|
+
], Ua = /^[a-z][a-z0-9_+#.-]{0,31}$/i, ja = /^(?:language|lang)-([a-z][a-z0-9_+#.-]{0,31})$/i, qa = /^brush:\s*([a-z][a-z0-9_+#.-]{0,31})$/i, Ka = /* @__PURE__ */ new Map([
|
|
1489
1550
|
["dockerfile", "docker"],
|
|
1490
1551
|
["shell", "shellscript"],
|
|
1491
1552
|
["sh", "shellscript"],
|
|
@@ -1498,56 +1559,56 @@ const Bo = (e) => {
|
|
|
1498
1559
|
["ts", "typescript"],
|
|
1499
1560
|
["tsx", "tsx"],
|
|
1500
1561
|
["yml", "yaml"]
|
|
1501
|
-
]),
|
|
1562
|
+
]), Ga = (e) => e.type === "select", Lt = (e) => e.find((t) => t.name === Fa && Ga(t)), ee = (e) => {
|
|
1502
1563
|
const t = e == null ? void 0 : e.trim().toLowerCase();
|
|
1503
|
-
if (!t || !
|
|
1504
|
-
if (
|
|
1505
|
-
const n =
|
|
1506
|
-
return
|
|
1507
|
-
},
|
|
1508
|
-
for (const t of
|
|
1509
|
-
const n =
|
|
1564
|
+
if (!t || !Ua.test(t)) return null;
|
|
1565
|
+
if (za.has(t)) return "";
|
|
1566
|
+
const n = Ka.get(t) ?? go(t);
|
|
1567
|
+
return Va.has(n) ? n : null;
|
|
1568
|
+
}, Xa = (e) => {
|
|
1569
|
+
for (const t of Wa) {
|
|
1570
|
+
const n = ee(e.getAttribute(t));
|
|
1510
1571
|
if (n) return n;
|
|
1511
1572
|
}
|
|
1512
1573
|
return null;
|
|
1513
|
-
},
|
|
1514
|
-
const [, t] = e.match(
|
|
1574
|
+
}, Ya = (e) => {
|
|
1575
|
+
const [, t] = e.match(qa) ?? [], n = ee(t);
|
|
1515
1576
|
if (n) return n;
|
|
1516
1577
|
for (const r of e.split(/\s+/)) {
|
|
1517
|
-
const [, o] = r.match(
|
|
1578
|
+
const [, o] = r.match(ja) ?? [], a = ee(o);
|
|
1518
1579
|
if (a) return a;
|
|
1519
1580
|
}
|
|
1520
1581
|
return null;
|
|
1521
|
-
},
|
|
1582
|
+
}, Mn = (e = qe) => {
|
|
1522
1583
|
var t, n;
|
|
1523
|
-
return ((t = Lt(e.fields)) == null ? void 0 : t.options) ?? ((n = Lt(qe.fields)) == null ? void 0 : n.options) ?? [{ label:
|
|
1524
|
-
},
|
|
1584
|
+
return ((t = Lt(e.fields)) == null ? void 0 : t.options) ?? ((n = Lt(qe.fields)) == null ? void 0 : n.options) ?? [{ label: xn, value: "" }];
|
|
1585
|
+
}, Tn = (e, t) => {
|
|
1525
1586
|
var n, r, o;
|
|
1526
|
-
return ((n = e.find((a) => a.value === t)) == null ? void 0 : n.label) ?? ((r = e.find((a) =>
|
|
1587
|
+
return ((n = e.find((a) => a.value === t)) == null ? void 0 : n.label) ?? ((r = e.find((a) => ee(a.value) === ee(t))) == null ? void 0 : r.label) ?? ((o = e[0]) == null ? void 0 : o.label) ?? xn;
|
|
1527
1588
|
};
|
|
1528
|
-
|
|
1529
|
-
const
|
|
1589
|
+
Mn();
|
|
1590
|
+
const Ja = (e) => {
|
|
1530
1591
|
[...e.querySelectorAll("pre,code")].forEach((t) => {
|
|
1531
|
-
const n =
|
|
1532
|
-
r && n && r.setAttribute(
|
|
1592
|
+
const n = Xa(t) ?? Ya(t.className), r = t.tagName === "PRE" ? t : t.closest("pre");
|
|
1593
|
+
r && n && r.setAttribute(Ae, n);
|
|
1533
1594
|
});
|
|
1534
|
-
},
|
|
1595
|
+
}, Qa = (e) => {
|
|
1535
1596
|
e.querySelectorAll("pre").forEach((t) => {
|
|
1536
1597
|
[...t.children].forEach((r) => {
|
|
1537
1598
|
r.tagName === "CODE" && r.replaceWith(...r.childNodes);
|
|
1538
1599
|
});
|
|
1539
1600
|
});
|
|
1540
|
-
},
|
|
1601
|
+
}, Za = (e, t) => {
|
|
1541
1602
|
const n = [...t.querySelectorAll("pre[data-language]")];
|
|
1542
1603
|
let r = 0;
|
|
1543
1604
|
e.forEach((o) => {
|
|
1544
1605
|
if (!K(o)) return;
|
|
1545
1606
|
const a = n[r];
|
|
1546
1607
|
if (r += 1, !a) return;
|
|
1547
|
-
const s = a.getAttribute(
|
|
1608
|
+
const s = a.getAttribute(Ae);
|
|
1548
1609
|
s && !o.getLanguage() && o.setLanguage(s);
|
|
1549
1610
|
});
|
|
1550
|
-
},
|
|
1611
|
+
}, Ln = "one-light", Y = {
|
|
1551
1612
|
keyword: "#a626a4",
|
|
1552
1613
|
function: "#4078f2",
|
|
1553
1614
|
operator: "#0184bc",
|
|
@@ -1555,33 +1616,33 @@ const za = (e) => {
|
|
|
1555
1616
|
property: "#e45649",
|
|
1556
1617
|
string: "#50a14f",
|
|
1557
1618
|
attrName: "#986801"
|
|
1558
|
-
},
|
|
1559
|
-
[
|
|
1560
|
-
[
|
|
1561
|
-
[
|
|
1562
|
-
[
|
|
1563
|
-
[
|
|
1564
|
-
[
|
|
1565
|
-
[
|
|
1566
|
-
},
|
|
1619
|
+
}, es = {
|
|
1620
|
+
[Y.keyword]: "keyword",
|
|
1621
|
+
[Y.function]: "function",
|
|
1622
|
+
[Y.operator]: "operator",
|
|
1623
|
+
[Y.tag]: "tag",
|
|
1624
|
+
[Y.property]: "property",
|
|
1625
|
+
[Y.string]: "string",
|
|
1626
|
+
[Y.attrName]: "attr-name"
|
|
1627
|
+
}, ts = (e) => {
|
|
1567
1628
|
const [, t] = e.match(/(?:^|;)color:\s*(#[0-9a-f]{3,8})/i) ?? [];
|
|
1568
|
-
return t ?
|
|
1569
|
-
},
|
|
1629
|
+
return t ? es[t.toLowerCase()] : void 0;
|
|
1630
|
+
}, ns = {
|
|
1570
1631
|
...ft,
|
|
1571
1632
|
defaultLanguage: null,
|
|
1572
|
-
defaultTheme:
|
|
1633
|
+
defaultTheme: Ln,
|
|
1573
1634
|
$tokenize(e, t) {
|
|
1574
1635
|
const n = ft.$tokenize.call(this, e, t);
|
|
1575
|
-
return e.getStyle() && e.setStyle(""), n.map((r) =>
|
|
1636
|
+
return e.getStyle() && e.setStyle(""), n.map((r) => Nr(r) ? Sr(
|
|
1576
1637
|
r.getTextContent(),
|
|
1577
|
-
|
|
1638
|
+
ts(r.getStyle())
|
|
1578
1639
|
) : r);
|
|
1579
1640
|
}
|
|
1580
|
-
},
|
|
1581
|
-
let J = 0, re = null,
|
|
1582
|
-
const
|
|
1641
|
+
}, rs = 1200, fe = /* @__PURE__ */ new Set(), Le = /* @__PURE__ */ new Set(), Ge = /* @__PURE__ */ new Set(), Ne = [];
|
|
1642
|
+
let J = 0, re = null, _e = !1, ke = null, Nt = !1;
|
|
1643
|
+
const os = (e) => "requestIdleCallback" in window ? {
|
|
1583
1644
|
id: window.requestIdleCallback(e, {
|
|
1584
|
-
timeout:
|
|
1645
|
+
timeout: rs
|
|
1585
1646
|
}),
|
|
1586
1647
|
kind: "idle"
|
|
1587
1648
|
} : {
|
|
@@ -1592,72 +1653,72 @@ const Ga = (e) => "requestIdleCallback" in window ? {
|
|
|
1592
1653
|
});
|
|
1593
1654
|
}, 0),
|
|
1594
1655
|
kind: "timeout"
|
|
1595
|
-
},
|
|
1656
|
+
}, as = (e) => {
|
|
1596
1657
|
if (e.kind === "idle") {
|
|
1597
1658
|
window.cancelIdleCallback(e.id);
|
|
1598
1659
|
return;
|
|
1599
1660
|
}
|
|
1600
1661
|
globalThis.clearTimeout(e.id);
|
|
1601
|
-
},
|
|
1602
|
-
|
|
1603
|
-
if (
|
|
1604
|
-
|
|
1662
|
+
}, ss = (e) => e.map((t) => t.value).filter((t) => t !== ""), is = (e) => {
|
|
1663
|
+
ss(e).forEach((t) => {
|
|
1664
|
+
if (fe.has(t) || Le.has(t) || Ge.has(t) || pn(t)) {
|
|
1665
|
+
fe.add(t);
|
|
1605
1666
|
return;
|
|
1606
1667
|
}
|
|
1607
|
-
Ge.add(t),
|
|
1668
|
+
Ge.add(t), Ne.push(t);
|
|
1608
1669
|
});
|
|
1609
|
-
},
|
|
1610
|
-
for (;
|
|
1611
|
-
const e =
|
|
1612
|
-
if (e && (Ge.delete(e), !(
|
|
1613
|
-
if (
|
|
1614
|
-
|
|
1670
|
+
}, ls = () => {
|
|
1671
|
+
for (; Ne.length > 0; ) {
|
|
1672
|
+
const e = Ne.shift();
|
|
1673
|
+
if (e && (Ge.delete(e), !(fe.has(e) || Le.has(e)))) {
|
|
1674
|
+
if (pn(e)) {
|
|
1675
|
+
fe.add(e);
|
|
1615
1676
|
continue;
|
|
1616
1677
|
}
|
|
1617
1678
|
return e;
|
|
1618
1679
|
}
|
|
1619
1680
|
}
|
|
1620
|
-
},
|
|
1621
|
-
if (!
|
|
1622
|
-
if (!
|
|
1623
|
-
const e =
|
|
1624
|
-
|
|
1625
|
-
|
|
1681
|
+
}, cs = async () => {
|
|
1682
|
+
if (!Nt) {
|
|
1683
|
+
if (!ke) {
|
|
1684
|
+
const e = fo(Ln);
|
|
1685
|
+
ke = Promise.resolve(e ?? void 0).then(() => {
|
|
1686
|
+
Nt = !0;
|
|
1626
1687
|
}).catch(() => {
|
|
1627
1688
|
}).finally(() => {
|
|
1628
|
-
|
|
1689
|
+
ke = null;
|
|
1629
1690
|
});
|
|
1630
1691
|
}
|
|
1631
|
-
await
|
|
1692
|
+
await ke;
|
|
1632
1693
|
}
|
|
1633
|
-
},
|
|
1634
|
-
J += 1,
|
|
1694
|
+
}, ds = (e) => {
|
|
1695
|
+
J += 1, is(e);
|
|
1635
1696
|
const t = async () => {
|
|
1636
|
-
if (!(J <= 0 ||
|
|
1637
|
-
|
|
1697
|
+
if (!(J <= 0 || _e)) {
|
|
1698
|
+
_e = !0;
|
|
1638
1699
|
try {
|
|
1639
|
-
if (await
|
|
1640
|
-
const r =
|
|
1700
|
+
if (await cs(), J <= 0) return;
|
|
1701
|
+
const r = ls();
|
|
1641
1702
|
if (!r) return;
|
|
1642
|
-
|
|
1643
|
-
|
|
1703
|
+
Le.add(r), await Promise.resolve(po(r) ?? void 0).then(() => {
|
|
1704
|
+
fe.add(r);
|
|
1644
1705
|
}).catch(() => {
|
|
1645
1706
|
}).finally(() => {
|
|
1646
|
-
|
|
1707
|
+
Le.delete(r);
|
|
1647
1708
|
});
|
|
1648
1709
|
} finally {
|
|
1649
|
-
|
|
1710
|
+
_e = !1, n();
|
|
1650
1711
|
}
|
|
1651
1712
|
}
|
|
1652
1713
|
}, n = () => {
|
|
1653
|
-
J <= 0 || re !== null ||
|
|
1714
|
+
J <= 0 || re !== null || _e || Ne.length === 0 || (re = os(() => {
|
|
1654
1715
|
re = null, t();
|
|
1655
1716
|
}));
|
|
1656
1717
|
};
|
|
1657
1718
|
return n(), () => {
|
|
1658
|
-
J = Math.max(0, J - 1), J === 0 && re !== null && (
|
|
1719
|
+
J = Math.max(0, J - 1), J === 0 && re !== null && (as(re), re = null);
|
|
1659
1720
|
};
|
|
1660
|
-
}, oe = 12,
|
|
1721
|
+
}, oe = 12, St = 6, Pt = (e, t, n) => Math.min(Math.max(e, t), Math.max(t, n)), us = () => {
|
|
1661
1722
|
const e = window.visualViewport;
|
|
1662
1723
|
return {
|
|
1663
1724
|
left: (e == null ? void 0 : e.offsetLeft) ?? 0,
|
|
@@ -1665,26 +1726,26 @@ const Ga = (e) => "requestIdleCallback" in window ? {
|
|
|
1665
1726
|
width: (e == null ? void 0 : e.width) ?? window.innerWidth,
|
|
1666
1727
|
height: (e == null ? void 0 : e.height) ?? window.innerHeight
|
|
1667
1728
|
};
|
|
1668
|
-
},
|
|
1729
|
+
}, ms = (e) => {
|
|
1669
1730
|
const t = e.style.visibility, n = e.style.pointerEvents, r = e.style.display;
|
|
1670
1731
|
e.style.visibility = "hidden", e.style.pointerEvents = "none", e.style.display = "grid";
|
|
1671
1732
|
const o = e.getBoundingClientRect();
|
|
1672
1733
|
return e.style.visibility = t, e.style.pointerEvents = n, e.style.display = r, o;
|
|
1673
|
-
},
|
|
1674
|
-
const r =
|
|
1734
|
+
}, gs = (e, t, n) => {
|
|
1735
|
+
const r = ms(e), o = us(), a = t.getBoundingClientRect(), s = a.left + oe, c = a.top + oe, d = n ? n.x : s, l = n ? n.y + n.height + St : c, h = n ? n.y - r.height - St : l, v = o.left + oe, w = o.top + oe, T = o.left + o.width - r.width - oe, f = o.top + o.height - r.height - oe, y = l > f ? h : l;
|
|
1675
1736
|
return {
|
|
1676
1737
|
left: Pt(d, v, T),
|
|
1677
1738
|
top: Pt(y, w, f),
|
|
1678
1739
|
viewportHeight: o.height
|
|
1679
1740
|
};
|
|
1680
|
-
},
|
|
1741
|
+
}, Nn = (e) => {
|
|
1681
1742
|
var d, l;
|
|
1682
1743
|
const t = document.createElement("div"), n = document.createElement("div"), r = document.createElement("div");
|
|
1683
1744
|
let o;
|
|
1684
1745
|
const a = () => {
|
|
1685
1746
|
t.dataset.visible = "false", n.dataset.visible = "false", o = void 0;
|
|
1686
1747
|
}, s = () => {
|
|
1687
|
-
const h =
|
|
1748
|
+
const h = gs(n, e.root, o);
|
|
1688
1749
|
n.style.left = `${h.left}px`, n.style.top = `${h.top}px`, n.style.setProperty(
|
|
1689
1750
|
"--bridgerte-dialog-visible-height",
|
|
1690
1751
|
`${h.viewportHeight}px`
|
|
@@ -1705,13 +1766,13 @@ const Ga = (e) => "requestIdleCallback" in window ? {
|
|
|
1705
1766
|
a(), (h = window.visualViewport) == null || h.removeEventListener("resize", s), (v = window.visualViewport) == null || v.removeEventListener("scroll", s), window.removeEventListener("resize", s), t.remove(), n.remove();
|
|
1706
1767
|
}
|
|
1707
1768
|
};
|
|
1708
|
-
},
|
|
1769
|
+
}, Se = (e) => typeof requestAnimationFrame == "function" ? requestAnimationFrame(e) : window.setTimeout(e, 0), at = (e) => {
|
|
1709
1770
|
if (typeof cancelAnimationFrame == "function") {
|
|
1710
1771
|
cancelAnimationFrame(e);
|
|
1711
1772
|
return;
|
|
1712
1773
|
}
|
|
1713
1774
|
window.clearTimeout(e);
|
|
1714
|
-
},
|
|
1775
|
+
}, V = (e, t = {}) => {
|
|
1715
1776
|
let n = null;
|
|
1716
1777
|
const r = (s) => {
|
|
1717
1778
|
const c = n ?? e;
|
|
@@ -1732,45 +1793,45 @@ const Ga = (e) => "requestIdleCallback" in window ? {
|
|
|
1732
1793
|
return e.addEventListener("pointerdown", o), e.addEventListener("pointerup", a), e.addEventListener("pointercancel", a), e.addEventListener("lostpointercapture", a), () => {
|
|
1733
1794
|
a(), e.removeEventListener("pointerdown", o), e.removeEventListener("pointerup", a), e.removeEventListener("pointercancel", a), e.removeEventListener("lostpointercapture", a);
|
|
1734
1795
|
};
|
|
1735
|
-
},
|
|
1796
|
+
}, hs = (e, t, n) => {
|
|
1736
1797
|
e.update(
|
|
1737
1798
|
t,
|
|
1738
1799
|
{
|
|
1739
|
-
tag:
|
|
1800
|
+
tag: ur,
|
|
1740
1801
|
onUpdate: n
|
|
1741
1802
|
}
|
|
1742
1803
|
);
|
|
1743
|
-
}, It = "language",
|
|
1804
|
+
}, It = "language", ps = "bridgerte-code-block-language", Rt = 8;
|
|
1744
1805
|
let At = 0;
|
|
1745
|
-
const
|
|
1806
|
+
const fs = () => (At += 1, `${ps}-${At}`), bs = (e, t, n) => {
|
|
1746
1807
|
const r = e.querySelector(".bridgerte__code-block-control-label");
|
|
1747
|
-
e.dataset.language = n ?? "", r && (r.textContent =
|
|
1748
|
-
},
|
|
1808
|
+
e.dataset.language = n ?? "", r && (r.textContent = Tn(t, n));
|
|
1809
|
+
}, ys = (e, t) => {
|
|
1749
1810
|
const n = document.createElement("button"), r = document.createElement("span"), o = document.createElement("span");
|
|
1750
|
-
return n.type = "button", n.className = "bridgerte__code-block-control", n.contentEditable = "false", n.dataset.language = t ?? "", n.setAttribute("aria-label", "选择代码块语言"), r.className = "bridgerte__code-block-control-label", r.textContent =
|
|
1751
|
-
},
|
|
1752
|
-
const t = document.createElement("div"), n = e.root.querySelector(".bridgerte__content") ?? e.root, r =
|
|
1811
|
+
return n.type = "button", n.className = "bridgerte__code-block-control", n.contentEditable = "false", n.dataset.language = t ?? "", n.setAttribute("aria-label", "选择代码块语言"), r.className = "bridgerte__code-block-control-label", r.textContent = Tn(e, t), o.className = "bridgerte__code-block-control-arrow", n.append(r, o), n;
|
|
1812
|
+
}, vs = (e) => {
|
|
1813
|
+
const t = document.createElement("div"), n = e.root.querySelector(".bridgerte__content") ?? e.root, r = hn(
|
|
1753
1814
|
e.languagePanel ?? qe,
|
|
1754
1815
|
e.payloadPanelConfig
|
|
1755
|
-
), o =
|
|
1816
|
+
), o = Mn(r);
|
|
1756
1817
|
let a = null, s = null, c = null;
|
|
1757
1818
|
const d = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), h = () => {
|
|
1758
|
-
c ?? (c =
|
|
1819
|
+
c ?? (c = ds(o));
|
|
1759
1820
|
}, v = () => {
|
|
1760
1821
|
a == null || a.close();
|
|
1761
1822
|
}, w = (i, u) => {
|
|
1762
|
-
e.isReadonly() ||
|
|
1763
|
-
const g =
|
|
1823
|
+
e.isReadonly() || hs(e.editor, () => {
|
|
1824
|
+
const g = he(i);
|
|
1764
1825
|
K(g) && g.setLanguage(u);
|
|
1765
1826
|
});
|
|
1766
1827
|
}, T = (i, u) => {
|
|
1767
|
-
|
|
1828
|
+
Se(() => {
|
|
1768
1829
|
w(i, u);
|
|
1769
1830
|
});
|
|
1770
1831
|
}, f = (i, u, g) => {
|
|
1771
1832
|
var b;
|
|
1772
1833
|
return ((b = e.onRequest) == null ? void 0 : b.call(e, {
|
|
1773
|
-
id:
|
|
1834
|
+
id: fs(),
|
|
1774
1835
|
readonly: e.isReadonly(),
|
|
1775
1836
|
menuId: "code-block-language",
|
|
1776
1837
|
command: { type: "block.setCodeLanguage", language: g },
|
|
@@ -1792,7 +1853,7 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
1792
1853
|
}, y = (i, u) => {
|
|
1793
1854
|
const g = e.root.getBoundingClientRect(), b = u.getBoundingClientRect(), M = b.bottom < g.top || b.top > g.bottom;
|
|
1794
1855
|
i.hidden = M, i.style.transform = `translate(${b.left - g.left + Rt}px, ${b.top - g.top + Rt}px)`;
|
|
1795
|
-
},
|
|
1856
|
+
}, x = (i) => {
|
|
1796
1857
|
var A;
|
|
1797
1858
|
const u = e.editor.getElementByKey(i);
|
|
1798
1859
|
if (!u) {
|
|
@@ -1802,17 +1863,17 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
1802
1863
|
h(), u.dataset.lexicalKey = i;
|
|
1803
1864
|
const g = u.getAttribute("data-language"), b = d.get(i);
|
|
1804
1865
|
if (b) {
|
|
1805
|
-
|
|
1866
|
+
bs(b, o, g), y(b, u);
|
|
1806
1867
|
return;
|
|
1807
1868
|
}
|
|
1808
|
-
const M =
|
|
1809
|
-
M.dataset.lexicalKey = i, d.set(i, M), l.set(M,
|
|
1869
|
+
const M = ys(o, g), S = V(M);
|
|
1870
|
+
M.dataset.lexicalKey = i, d.set(i, M), l.set(M, S), t.append(M), y(M, u);
|
|
1810
1871
|
}, m = () => {
|
|
1811
1872
|
s = null, d.forEach((i, u) => {
|
|
1812
|
-
|
|
1873
|
+
x(u);
|
|
1813
1874
|
});
|
|
1814
1875
|
}, p = () => {
|
|
1815
|
-
s === null && (s =
|
|
1876
|
+
s === null && (s = Se(m));
|
|
1816
1877
|
}, k = (i, u) => {
|
|
1817
1878
|
const g = i.getBoundingClientRect(), b = i.dataset.language ?? "";
|
|
1818
1879
|
if (f(u, g, b)) return;
|
|
@@ -1820,18 +1881,18 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
1820
1881
|
v();
|
|
1821
1882
|
return;
|
|
1822
1883
|
}
|
|
1823
|
-
a || (a =
|
|
1884
|
+
a || (a = Nn({
|
|
1824
1885
|
root: e.root,
|
|
1825
1886
|
className: "bridgerte__code-block-menu",
|
|
1826
1887
|
onBackdropClick: v
|
|
1827
1888
|
}));
|
|
1828
1889
|
const M = document.createElement("div");
|
|
1829
|
-
a.content.replaceChildren(), a.element.style.minWidth = "180px", M.className = "bridgerte__code-block-menu-list", o.forEach((
|
|
1890
|
+
a.content.replaceChildren(), a.element.style.minWidth = "180px", M.className = "bridgerte__code-block-menu-list", o.forEach((S) => {
|
|
1830
1891
|
const A = document.createElement("button");
|
|
1831
|
-
A.type = "button", A.className = "bridgerte__menu-item bridgerte__code-block-menu-item", A.textContent =
|
|
1892
|
+
A.type = "button", A.className = "bridgerte__menu-item bridgerte__code-block-menu-item", A.textContent = S.label, V(A), A.addEventListener("pointerdown", (O) => {
|
|
1832
1893
|
O.preventDefault();
|
|
1833
1894
|
}), A.addEventListener("click", () => {
|
|
1834
|
-
v(), T(u,
|
|
1895
|
+
v(), T(u, S.value);
|
|
1835
1896
|
}), M.append(A);
|
|
1836
1897
|
}), a.content.append(M), a.open({
|
|
1837
1898
|
x: g.left,
|
|
@@ -1842,7 +1903,7 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
1842
1903
|
};
|
|
1843
1904
|
t.className = "bridgerte__code-block-controls-layer", e.root.append(t);
|
|
1844
1905
|
const _ = e.editor.registerMutationListener(
|
|
1845
|
-
|
|
1906
|
+
cn,
|
|
1846
1907
|
(i) => {
|
|
1847
1908
|
i.forEach((u, g) => {
|
|
1848
1909
|
if (u === "destroyed") {
|
|
@@ -1854,7 +1915,7 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
1854
1915
|
d.delete(g);
|
|
1855
1916
|
return;
|
|
1856
1917
|
}
|
|
1857
|
-
|
|
1918
|
+
x(g);
|
|
1858
1919
|
});
|
|
1859
1920
|
}
|
|
1860
1921
|
), P = e.editor.registerUpdateListener(p), I = (i) => {
|
|
@@ -1878,7 +1939,7 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
1878
1939
|
if (!g || g.textContent) return;
|
|
1879
1940
|
const b = g.dataset.lexicalKey;
|
|
1880
1941
|
b && (e.editor.update(() => {
|
|
1881
|
-
const M =
|
|
1942
|
+
const M = he(b);
|
|
1882
1943
|
K(M) && M.selectEnd();
|
|
1883
1944
|
}), e.editor.focus());
|
|
1884
1945
|
};
|
|
@@ -1890,7 +1951,7 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
1890
1951
|
}), d.clear(), l.clear(), t.remove(), a == null || a.destroy(), a = null;
|
|
1891
1952
|
}
|
|
1892
1953
|
};
|
|
1893
|
-
},
|
|
1954
|
+
}, Sn = (e) => {
|
|
1894
1955
|
const t = (o) => {
|
|
1895
1956
|
const a = e.getBlockFromTarget(o.target);
|
|
1896
1957
|
if (a) {
|
|
@@ -1912,38 +1973,38 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
1912
1973
|
};
|
|
1913
1974
|
}, st = (e, t = {}) => e.map((n) => {
|
|
1914
1975
|
var a;
|
|
1915
|
-
const r = (a = t.menuLabels) == null ? void 0 : a[n.id], o = n.payloadPanel ?
|
|
1976
|
+
const r = (a = t.menuLabels) == null ? void 0 : a[n.id], o = n.payloadPanel ? hn(n.payloadPanel, t.payloadPanelConfig) : void 0;
|
|
1916
1977
|
return {
|
|
1917
1978
|
...n,
|
|
1918
1979
|
...r === void 0 ? {} : { label: r },
|
|
1919
1980
|
...o === void 0 ? {} : { payloadPanel: o }
|
|
1920
1981
|
};
|
|
1921
|
-
}),
|
|
1982
|
+
}), ws = (e, t) => {
|
|
1922
1983
|
const n = t.find((r) => r.command === e.command.type);
|
|
1923
1984
|
return (n == null ? void 0 : n.value) === void 0 ? void 0 : { value: String(n.value) };
|
|
1924
|
-
},
|
|
1925
|
-
const n = t.find((o) =>
|
|
1985
|
+
}, Cs = (e, t) => {
|
|
1986
|
+
const n = t.find((o) => uo(e.command, o)), r = t.find((o) => o.command === e.command.type);
|
|
1926
1987
|
return {
|
|
1927
1988
|
active: (n == null ? void 0 : n.active) === !0,
|
|
1928
1989
|
disabled: e.payloadPanel ? (r == null ? void 0 : r.disabled) === !0 : (n == null ? void 0 : n.disabled) === !0 || (r == null ? void 0 : r.disabled) === !0
|
|
1929
1990
|
};
|
|
1930
|
-
},
|
|
1991
|
+
}, be = [
|
|
1931
1992
|
"media-resize-20",
|
|
1932
1993
|
"media-resize-50",
|
|
1933
1994
|
"media-resize-100"
|
|
1934
|
-
],
|
|
1995
|
+
], _s = [
|
|
1935
1996
|
"media-align-left",
|
|
1936
1997
|
"media-align-center",
|
|
1937
1998
|
"media-align-right",
|
|
1938
1999
|
"|",
|
|
1939
|
-
...
|
|
2000
|
+
...be,
|
|
1940
2001
|
"|",
|
|
1941
2002
|
"media-remove"
|
|
1942
|
-
],
|
|
2003
|
+
], ks = [
|
|
1943
2004
|
"media-retry",
|
|
1944
2005
|
"|",
|
|
1945
2006
|
"media-remove"
|
|
1946
|
-
],
|
|
2007
|
+
], Es = [
|
|
1947
2008
|
{
|
|
1948
2009
|
id: "media-align-left",
|
|
1949
2010
|
command: { type: "media.align", assetId: "", value: "left" },
|
|
@@ -1992,33 +2053,33 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
1992
2053
|
label: "删除",
|
|
1993
2054
|
icon: "trash-2"
|
|
1994
2055
|
}
|
|
1995
|
-
],
|
|
2056
|
+
], Pn = (e) => be.includes(e), xs = (e) => typeof e == "object" && Array.isArray(e.menuKeys), Ms = (e) => new Set(e.flatMap((t) => t === "|" ? [] : typeof t == "string" ? [t] : xs(t) ? [t.key, ...t.menuKeys] : [])), $e = (e) => typeof e == "string" && Pn(e), Ts = (e) => {
|
|
1996
2057
|
const t = e.findIndex((r) => r === "media-remove"), n = t === -1 ? e.length : t;
|
|
1997
2058
|
return [
|
|
1998
2059
|
...e.slice(0, n),
|
|
1999
2060
|
"|",
|
|
2000
|
-
...
|
|
2061
|
+
...be,
|
|
2001
2062
|
"|",
|
|
2002
2063
|
...e.slice(n)
|
|
2003
2064
|
];
|
|
2004
|
-
},
|
|
2005
|
-
const t =
|
|
2006
|
-
if (
|
|
2007
|
-
const r = e.findIndex(
|
|
2008
|
-
return r === -1 ?
|
|
2009
|
-
...e.slice(0, r).filter((o) =>
|
|
2010
|
-
...
|
|
2011
|
-
...e.slice(r + 1).filter((o) =>
|
|
2065
|
+
}, Ls = (e) => {
|
|
2066
|
+
const t = Ms(e);
|
|
2067
|
+
if (be.filter((o) => !t.has(o)).length === 0) return e;
|
|
2068
|
+
const r = e.findIndex($e);
|
|
2069
|
+
return r === -1 ? Ts(e) : [
|
|
2070
|
+
...e.slice(0, r).filter((o) => !$e(o)),
|
|
2071
|
+
...be,
|
|
2072
|
+
...e.slice(r + 1).filter((o) => !$e(o))
|
|
2012
2073
|
];
|
|
2013
|
-
},
|
|
2074
|
+
}, Ns = (e) => {
|
|
2014
2075
|
var r;
|
|
2015
|
-
const t = (e == null ? void 0 : e.toolbarKeys) ??
|
|
2076
|
+
const t = (e == null ? void 0 : e.toolbarKeys) ?? _s;
|
|
2016
2077
|
return {
|
|
2017
2078
|
...e,
|
|
2018
|
-
toolbarKeys:
|
|
2019
|
-
excludeKeys: (r = e == null ? void 0 : e.excludeKeys) == null ? void 0 : r.filter((o) => !
|
|
2079
|
+
toolbarKeys: Ls(t),
|
|
2080
|
+
excludeKeys: (r = e == null ? void 0 : e.excludeKeys) == null ? void 0 : r.filter((o) => !Pn(o))
|
|
2020
2081
|
};
|
|
2021
|
-
},
|
|
2082
|
+
}, Ss = (e, t) => {
|
|
2022
2083
|
switch (e.command.type) {
|
|
2023
2084
|
case "media.retry":
|
|
2024
2085
|
return { ...e.command, assetId: t };
|
|
@@ -2031,50 +2092,50 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
2031
2092
|
default:
|
|
2032
2093
|
return null;
|
|
2033
2094
|
}
|
|
2034
|
-
},
|
|
2035
|
-
const n = st(
|
|
2095
|
+
}, Ps = (e, t, n) => e.command.type === "media.resize" ? e.command.widthPercent === t : e.command.type === "media.align" && e.command.value === n, In = (e, t = {}) => {
|
|
2096
|
+
const n = st(Es, {
|
|
2036
2097
|
menuLabels: t.menuLabels
|
|
2037
|
-
}), r = e === "error" ? { toolbarKeys:
|
|
2098
|
+
}), r = e === "error" ? { toolbarKeys: ks } : Ns(t.config);
|
|
2038
2099
|
return tt(r, n);
|
|
2039
|
-
}, ae = 8,
|
|
2100
|
+
}, ae = 8, ce = "bridgerte__media-controls-button", Is = (e) => e.querySelector(".bridgerte__content") ?? e, Rs = (e) => e instanceof Element ? e.closest(".bridgerte__media") : null, As = (e, t = !1) => {
|
|
2040
2101
|
const n = document.createElement("button");
|
|
2041
|
-
return n.type = "button", n.className =
|
|
2042
|
-
},
|
|
2102
|
+
return n.type = "button", n.className = ce, n.textContent = e.label, n.dataset.menuItemId = e.id, n.dataset.action = e.id.replace(/^media-/, ""), t && (n.dataset.active = "true"), n.setAttribute("aria-label", e.label), n;
|
|
2103
|
+
}, Rn = (e) => e.flatMap((t) => t.type === "button" ? [t.item] : t.type === "group" ? t.items : []), Bs = (e, t, n, r) => {
|
|
2043
2104
|
if (t.type === "separator") {
|
|
2044
2105
|
const a = document.createElement("span");
|
|
2045
2106
|
a.className = "bridgerte__media-controls-separator", a.dataset.separatorId = t.key, a.setAttribute("aria-hidden", "true"), e.append(a);
|
|
2046
2107
|
return;
|
|
2047
2108
|
}
|
|
2048
2109
|
(t.type === "button" ? [t.item] : t.items).forEach((a) => {
|
|
2049
|
-
e.append(
|
|
2110
|
+
e.append(As(
|
|
2050
2111
|
a,
|
|
2051
|
-
|
|
2112
|
+
Ps(a, n, r)
|
|
2052
2113
|
));
|
|
2053
2114
|
});
|
|
2054
|
-
},
|
|
2115
|
+
}, Ds = (e, t, n) => {
|
|
2055
2116
|
const r = document.createElement("div"), o = e.dataset.status, a = Number(
|
|
2056
2117
|
e.dataset.displayWidthPercent ?? t
|
|
2057
|
-
), s = e.dataset.align ?? "left", c =
|
|
2118
|
+
), s = e.dataset.align ?? "left", c = In(o, {
|
|
2058
2119
|
config: n.mediaControlsConfig,
|
|
2059
2120
|
menuLabels: n.menuLabels
|
|
2060
2121
|
});
|
|
2061
|
-
return r.className = "bridgerte__media-controls", r.contentEditable = "false", r.setAttribute("aria-label", "媒体操作"), r.dataset.status = o ?? "success", r.dataset.displayWidthPercent = e.dataset.displayWidthPercent ?? "", r.dataset.align = e.dataset.align ?? "", r.dataset.menuItemIds =
|
|
2062
|
-
|
|
2122
|
+
return r.className = "bridgerte__media-controls", r.contentEditable = "false", r.setAttribute("aria-label", "媒体操作"), r.dataset.status = o ?? "success", r.dataset.displayWidthPercent = e.dataset.displayWidthPercent ?? "", r.dataset.align = e.dataset.align ?? "", r.dataset.menuItemIds = Rn(c).map((d) => d.id).join("|"), c.forEach((d) => {
|
|
2123
|
+
Bs(r, d, a, s);
|
|
2063
2124
|
}), r;
|
|
2064
|
-
},
|
|
2065
|
-
const t = document.createElement("div"), n =
|
|
2125
|
+
}, Os = (e) => {
|
|
2126
|
+
const t = document.createElement("div"), n = Is(e.root), r = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
2066
2127
|
let s = null, c = null, d = !1, l = null;
|
|
2067
2128
|
const h = (i) => {
|
|
2068
2129
|
var g;
|
|
2069
2130
|
const u = r.get(i);
|
|
2070
2131
|
u && ((g = o.get(u)) == null || g(), o.delete(u), u.remove(), r.delete(i), l === i && (l = null));
|
|
2071
2132
|
}, v = (i, u) => u.dataset.status === "error" || l === i, w = (i, u) => {
|
|
2072
|
-
const g = e.root.getBoundingClientRect(), b = u.getBoundingClientRect(), M = b.bottom < g.top || b.top > g.bottom,
|
|
2133
|
+
const g = e.root.getBoundingClientRect(), b = u.getBoundingClientRect(), M = b.bottom < g.top || b.top > g.bottom, S = Math.max(
|
|
2073
2134
|
ae,
|
|
2074
2135
|
g.width - i.offsetWidth - ae
|
|
2075
2136
|
), A = Math.min(
|
|
2076
2137
|
Math.max(b.left - g.left + ae, ae),
|
|
2077
|
-
|
|
2138
|
+
S
|
|
2078
2139
|
), O = Math.max(
|
|
2079
2140
|
ae,
|
|
2080
2141
|
b.top - g.top - i.offsetHeight - ae
|
|
@@ -2093,15 +2154,15 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
2093
2154
|
return;
|
|
2094
2155
|
}
|
|
2095
2156
|
if (g) {
|
|
2096
|
-
const
|
|
2097
|
-
if (
|
|
2157
|
+
const S = u.dataset.status === "error", A = g.querySelector('[data-action="retry"]') !== null, O = u.dataset.displayWidthPercent ?? "", W = u.dataset.align ?? "";
|
|
2158
|
+
if (S === A && g.dataset.displayWidthPercent === O && g.dataset.align === W) {
|
|
2098
2159
|
w(g, u);
|
|
2099
2160
|
return;
|
|
2100
2161
|
}
|
|
2101
2162
|
h(i);
|
|
2102
2163
|
}
|
|
2103
|
-
const b =
|
|
2104
|
-
targetSelector: `.${
|
|
2164
|
+
const b = Ds(u, e.defaultWidthPercent, e), M = V(b, {
|
|
2165
|
+
targetSelector: `.${ce}`
|
|
2105
2166
|
});
|
|
2106
2167
|
b.dataset.lexicalKey = i, b.dataset.assetId = u.dataset.assetId, r.set(i, b), o.set(b, M), t.append(b), w(b, u);
|
|
2107
2168
|
}, f = () => {
|
|
@@ -2114,14 +2175,14 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
2114
2175
|
T(u);
|
|
2115
2176
|
}), l !== null && T(l);
|
|
2116
2177
|
}, y = () => {
|
|
2117
|
-
s === null && (s =
|
|
2118
|
-
},
|
|
2119
|
-
const g = u.dataset.assetId, b =
|
|
2178
|
+
s === null && (s = Se(f));
|
|
2179
|
+
}, x = (i, u) => {
|
|
2180
|
+
const g = u.dataset.assetId, b = Rn(In(u.dataset.status, {
|
|
2120
2181
|
config: e.mediaControlsConfig,
|
|
2121
2182
|
menuLabels: e.menuLabels
|
|
2122
|
-
})).find((
|
|
2183
|
+
})).find((S) => S.id === i.dataset.menuItemId);
|
|
2123
2184
|
if (!g || !b) return;
|
|
2124
|
-
const M =
|
|
2185
|
+
const M = Ss(b, g);
|
|
2125
2186
|
M && e.executeCommand(M);
|
|
2126
2187
|
}, m = (i) => {
|
|
2127
2188
|
if (!i) {
|
|
@@ -2136,12 +2197,12 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
2136
2197
|
}, p = (i) => {
|
|
2137
2198
|
const u = i.target;
|
|
2138
2199
|
if (!(u instanceof HTMLElement)) return;
|
|
2139
|
-
const g = u.closest(`.${
|
|
2200
|
+
const g = u.closest(`.${ce}`);
|
|
2140
2201
|
g && (i.preventDefault(), c = i.pointerType === "mouse" ? null : g);
|
|
2141
2202
|
}, k = (i) => {
|
|
2142
2203
|
if (i.pointerType === "mouse" || !c) return;
|
|
2143
|
-
const u = i.target, g = u instanceof HTMLElement ? u.closest(".bridgerte__media-controls") : null, b = u instanceof HTMLElement ? u.closest(`.${
|
|
2144
|
-
b === c && g && (i.preventDefault(), i.stopPropagation(),
|
|
2204
|
+
const u = i.target, g = u instanceof HTMLElement ? u.closest(".bridgerte__media-controls") : null, b = u instanceof HTMLElement ? u.closest(`.${ce}`) : null;
|
|
2205
|
+
b === c && g && (i.preventDefault(), i.stopPropagation(), x(b, g), d = !0), c = null;
|
|
2145
2206
|
}, _ = () => {
|
|
2146
2207
|
c = null;
|
|
2147
2208
|
}, P = (i) => {
|
|
@@ -2151,10 +2212,10 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
2151
2212
|
}
|
|
2152
2213
|
const u = i.target;
|
|
2153
2214
|
if (!(u instanceof HTMLElement)) return;
|
|
2154
|
-
const g = u.closest(`.${
|
|
2155
|
-
!g || !b || (i.preventDefault(), i.stopPropagation(),
|
|
2215
|
+
const g = u.closest(`.${ce}`), b = u.closest(".bridgerte__media-controls");
|
|
2216
|
+
!g || !b || (i.preventDefault(), i.stopPropagation(), x(g, b));
|
|
2156
2217
|
}, I = e.editor.registerMutationListener(
|
|
2157
|
-
|
|
2218
|
+
ie,
|
|
2158
2219
|
(i) => {
|
|
2159
2220
|
i.forEach((u, g) => {
|
|
2160
2221
|
if (u === "destroyed") {
|
|
@@ -2164,10 +2225,10 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
2164
2225
|
T(g);
|
|
2165
2226
|
});
|
|
2166
2227
|
}
|
|
2167
|
-
), L = e.editor.registerUpdateListener(y), C =
|
|
2228
|
+
), L = e.editor.registerUpdateListener(y), C = Sn({
|
|
2168
2229
|
root: e.root,
|
|
2169
2230
|
content: n,
|
|
2170
|
-
getBlockFromTarget:
|
|
2231
|
+
getBlockFromTarget: Rs,
|
|
2171
2232
|
activateBlock: m,
|
|
2172
2233
|
clearBlock: () => m(null)
|
|
2173
2234
|
});
|
|
@@ -2179,17 +2240,17 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
2179
2240
|
}), r.clear(), o.clear(), a.clear(), t.remove();
|
|
2180
2241
|
}
|
|
2181
2242
|
};
|
|
2182
|
-
},
|
|
2243
|
+
}, Hs = ["width", "height"], q = (e, t) => {
|
|
2183
2244
|
var r;
|
|
2184
2245
|
const n = (r = e[t]) == null ? void 0 : r.trim();
|
|
2185
2246
|
return n || void 0;
|
|
2186
2247
|
}, Xe = (e, t) => {
|
|
2187
2248
|
const n = Number.parseInt(e[t] ?? "", 10);
|
|
2188
2249
|
return Number.isFinite(n) && n > 0 ? n : void 0;
|
|
2189
|
-
}, Bt = (e, t) =>
|
|
2250
|
+
}, Bt = (e, t) => Hs.reduce((n, r) => {
|
|
2190
2251
|
const o = Xe(t, r);
|
|
2191
2252
|
return o === void 0 ? n : { ...n, [r]: o };
|
|
2192
|
-
}, e),
|
|
2253
|
+
}, e), $s = (e, t) => {
|
|
2193
2254
|
if (e.type === "format.color" || e.type === "format.backgroundColor" || e.type === "format.fontSize" || e.type === "format.fontFamily" || e.type === "format.lineHeight")
|
|
2194
2255
|
return t.value !== void 0 ? { ...e, value: t.value } : e;
|
|
2195
2256
|
if (e.type === "link.set") {
|
|
@@ -2223,7 +2284,7 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
2223
2284
|
}, t) : null;
|
|
2224
2285
|
}
|
|
2225
2286
|
return e;
|
|
2226
|
-
},
|
|
2287
|
+
}, Q = (e) => Math.min(Math.max(Math.round(e), 0), 255), Ye = ({ r: e, g: t, b: n }) => `#${[e, t, n].map((r) => Q(r).toString(16).padStart(2, "0")).join("")}`, An = (e) => {
|
|
2227
2288
|
const n = e.trim().match(/^#([0-9a-f]{6})$/i);
|
|
2228
2289
|
if (!n) return null;
|
|
2229
2290
|
const r = n[1] ?? "";
|
|
@@ -2232,18 +2293,18 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
2232
2293
|
g: Number.parseInt(r.slice(2, 4), 16),
|
|
2233
2294
|
b: Number.parseInt(r.slice(4, 6), 16)
|
|
2234
2295
|
};
|
|
2235
|
-
},
|
|
2296
|
+
}, Fs = (e) => {
|
|
2236
2297
|
const t = e.trim().match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i);
|
|
2237
2298
|
return t ? {
|
|
2238
|
-
r:
|
|
2239
|
-
g:
|
|
2240
|
-
b:
|
|
2299
|
+
r: Q(Number(t[1])),
|
|
2300
|
+
g: Q(Number(t[2])),
|
|
2301
|
+
b: Q(Number(t[3]))
|
|
2241
2302
|
} : null;
|
|
2242
|
-
},
|
|
2243
|
-
const t =
|
|
2244
|
-
return t ?
|
|
2245
|
-
},
|
|
2246
|
-
const r =
|
|
2303
|
+
}, Fe = (e) => {
|
|
2304
|
+
const t = An(e) ?? Fs(e);
|
|
2305
|
+
return t ? Ye(t) : null;
|
|
2306
|
+
}, Bn = (e) => Math.min(Math.max(e, 0), 1), zs = ({ r: e, g: t, b: n }) => {
|
|
2307
|
+
const r = Q(e) / 255, o = Q(t) / 255, a = Q(n) / 255, s = Math.max(r, o, a), c = Math.min(r, o, a), d = s - c;
|
|
2247
2308
|
let l = 0;
|
|
2248
2309
|
return d !== 0 && (s === r ? l = 60 * ((o - a) / d % 6) : s === o ? l = 60 * ((a - r) / d + 2) : l = 60 * ((r - o) / d + 4)), {
|
|
2249
2310
|
h: l < 0 ? l + 360 : l,
|
|
@@ -2262,8 +2323,8 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
2262
2323
|
g: (c + a) * 255,
|
|
2263
2324
|
b: (d + a) * 255
|
|
2264
2325
|
};
|
|
2265
|
-
},
|
|
2266
|
-
const n = e * Math.PI / 180, r =
|
|
2326
|
+
}, Vs = ({ h: e, s: t }) => {
|
|
2327
|
+
const n = e * Math.PI / 180, r = Bn(t) * 50;
|
|
2267
2328
|
return {
|
|
2268
2329
|
x: 50 + Math.cos(n) * r,
|
|
2269
2330
|
y: 50 + Math.sin(n) * r
|
|
@@ -2272,23 +2333,23 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
2272
2333
|
const n = t.getBoundingClientRect(), r = n.left + n.width / 2, o = n.top + n.height / 2, a = e.clientX - r, s = e.clientY - o, c = Math.min(Math.sqrt(a * a + s * s), n.width / 2), d = Math.atan2(s, a) * 180 / Math.PI;
|
|
2273
2334
|
return {
|
|
2274
2335
|
h: d < 0 ? d + 360 : d,
|
|
2275
|
-
s:
|
|
2336
|
+
s: Bn(c / (n.width / 2)),
|
|
2276
2337
|
v: 1
|
|
2277
2338
|
};
|
|
2278
|
-
},
|
|
2339
|
+
}, Ws = [
|
|
2279
2340
|
"#000000",
|
|
2280
2341
|
"#ffffff"
|
|
2281
|
-
],
|
|
2342
|
+
], Us = (e) => {
|
|
2282
2343
|
var t;
|
|
2283
|
-
return (t = e.options) != null && t.length ? e.options :
|
|
2284
|
-
},
|
|
2344
|
+
return (t = e.options) != null && t.length ? e.options : Ws.map((n) => ({ label: n, value: n }));
|
|
2345
|
+
}, Dn = () => {
|
|
2285
2346
|
const e = document.createElement("section");
|
|
2286
2347
|
return e.className = "bridgerte__payload-panel-field", e;
|
|
2287
|
-
},
|
|
2288
|
-
const r =
|
|
2348
|
+
}, js = (e, t, n) => {
|
|
2349
|
+
const r = Dn(), o = document.createElement("div");
|
|
2289
2350
|
return o.className = "bridgerte__payload-panel-option-list", e.options.forEach((a) => {
|
|
2290
2351
|
const s = document.createElement("button");
|
|
2291
|
-
s.type = "button", s.className = "bridgerte__payload-panel-option", s.textContent = a.label, s.dataset.bridgertePayloadOption = a.value, s.dataset.active = t[e.name] === a.value ? "true" : "false",
|
|
2352
|
+
s.type = "button", s.className = "bridgerte__payload-panel-option", s.textContent = a.label, s.dataset.bridgertePayloadOption = a.value, s.dataset.active = t[e.name] === a.value ? "true" : "false", V(s), s.addEventListener("pointerdown", (c) => {
|
|
2292
2353
|
c.preventDefault();
|
|
2293
2354
|
}), s.addEventListener("click", () => {
|
|
2294
2355
|
n({
|
|
@@ -2297,17 +2358,17 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
2297
2358
|
});
|
|
2298
2359
|
}), o.append(s);
|
|
2299
2360
|
}), r.append(o), r;
|
|
2300
|
-
},
|
|
2301
|
-
const r =
|
|
2361
|
+
}, qs = (e, t, n) => {
|
|
2362
|
+
const r = Dn(), o = document.createElement("div"), a = document.createElement("div"), s = document.createElement("span"), c = document.createElement("div"), d = document.createElement("div"), l = Us(e), h = l.length === 2;
|
|
2302
2363
|
let v = { h: 0, s: 0, v: 1 }, w = null;
|
|
2303
2364
|
const T = (m) => {
|
|
2304
|
-
const p =
|
|
2305
|
-
return !!(p && l.some((k) =>
|
|
2365
|
+
const p = Fe(m);
|
|
2366
|
+
return !!(p && l.some((k) => Fe(k.value) === p));
|
|
2306
2367
|
}, f = (m, p = !0) => {
|
|
2307
|
-
const k =
|
|
2368
|
+
const k = Fe(m);
|
|
2308
2369
|
if (!k) return;
|
|
2309
|
-
t[e.name] = k, d.style.background = k, v =
|
|
2310
|
-
const _ =
|
|
2370
|
+
t[e.name] = k, d.style.background = k, v = zs(An(k) ?? { r: 255, g: 255, b: 255 });
|
|
2371
|
+
const _ = Vs(v);
|
|
2311
2372
|
a.dataset.active = p ? "true" : "false", d.dataset.empty = "false", p && (s.style.left = `${_.x}%`, s.style.top = `${_.y}%`);
|
|
2312
2373
|
}, y = () => {
|
|
2313
2374
|
const m = t[e.name];
|
|
@@ -2318,75 +2379,75 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
2318
2379
|
};
|
|
2319
2380
|
r.className = "bridgerte__payload-panel-field", o.className = "bridgerte__payload-panel-color-picker", a.className = "bridgerte__payload-panel-color-wheel", a.setAttribute("aria-label", `${e.label}选择区域`), s.className = "bridgerte__payload-panel-color-wheel-handle", c.className = "bridgerte__payload-panel-color-actions", c.dataset.layout = h ? "sides" : "grid", d.className = "bridgerte__payload-panel-color-preview", d.dataset.empty = "true", a.append(s), l.forEach((m) => {
|
|
2320
2381
|
const p = document.createElement("button"), k = m.value;
|
|
2321
|
-
p.type = "button", p.className = "bridgerte__payload-panel-color-swatch", p.dataset.value = k, p.style.background = k, p.setAttribute("aria-label", `选择颜色 ${m.label}`),
|
|
2382
|
+
p.type = "button", p.className = "bridgerte__payload-panel-color-swatch", p.dataset.value = k, p.style.background = k, p.setAttribute("aria-label", `选择颜色 ${m.label}`), V(p), p.addEventListener("pointerdown", (_) => {
|
|
2322
2383
|
_.preventDefault();
|
|
2323
2384
|
}), p.addEventListener("click", () => {
|
|
2324
2385
|
f(k, !1), y();
|
|
2325
2386
|
}), c.append(p);
|
|
2326
2387
|
}), a.addEventListener("pointerdown", (m) => {
|
|
2327
|
-
w = m.pointerId, a.setPointerCapture(m.pointerId), v = Ot(m, a), f(
|
|
2388
|
+
w = m.pointerId, a.setPointerCapture(m.pointerId), v = Ot(m, a), f(Ye(Dt(v))), m.preventDefault();
|
|
2328
2389
|
}), a.addEventListener("pointermove", (m) => {
|
|
2329
|
-
w === m.pointerId && (v = Ot(m, a), f(
|
|
2390
|
+
w === m.pointerId && (v = Ot(m, a), f(Ye(Dt(v))));
|
|
2330
2391
|
}), a.addEventListener("pointerup", (m) => {
|
|
2331
2392
|
w === m.pointerId && (w = null, a.releasePointerCapture(m.pointerId), y());
|
|
2332
2393
|
}), a.addEventListener("pointercancel", (m) => {
|
|
2333
2394
|
w === m.pointerId && (w = null, a.releasePointerCapture(m.pointerId));
|
|
2334
2395
|
});
|
|
2335
|
-
const
|
|
2336
|
-
return
|
|
2337
|
-
},
|
|
2396
|
+
const x = t[e.name];
|
|
2397
|
+
return x && f(x, !(h && T(x))), o.append(a, c), r.append(o, d), r;
|
|
2398
|
+
}, Ks = (e, t, n) => {
|
|
2338
2399
|
const r = document.createElement("label"), o = document.createElement("input");
|
|
2339
2400
|
return r.className = "bridgerte__payload-panel-text-field", r.textContent = e.label, o.type = e.name === "href" || e.name === "url" ? "url" : "text", o.className = "bridgerte__payload-panel-text-input", o.value = t[e.name] ?? "", o.placeholder = e.placeholder ?? "", o.spellcheck = !1, o.addEventListener("input", () => {
|
|
2340
2401
|
t[e.name] = o.value;
|
|
2341
2402
|
}), o.addEventListener("keydown", (a) => {
|
|
2342
2403
|
a.key === "Enter" && (a.preventDefault(), n(t));
|
|
2343
2404
|
}), r.append(o), r;
|
|
2344
|
-
},
|
|
2405
|
+
}, Gs = (e, t, n) => {
|
|
2345
2406
|
const r = document.createElement("label"), o = document.createElement("input");
|
|
2346
2407
|
return r.className = "bridgerte__payload-panel-text-field", r.textContent = e.label, o.type = "number", o.className = "bridgerte__payload-panel-text-input", o.value = t[e.name] ?? "", o.placeholder = e.placeholder ?? "", e.min !== void 0 && (o.min = String(e.min)), e.max !== void 0 && (o.max = String(e.max)), e.step !== void 0 && (o.step = String(e.step)), o.addEventListener("input", () => {
|
|
2347
2408
|
t[e.name] = o.value;
|
|
2348
2409
|
}), o.addEventListener("keydown", (a) => {
|
|
2349
2410
|
a.key === "Enter" && (a.preventDefault(), n(t));
|
|
2350
2411
|
}), r.append(o), r;
|
|
2351
|
-
},
|
|
2412
|
+
}, Xs = ({
|
|
2352
2413
|
field: e,
|
|
2353
2414
|
values: t,
|
|
2354
2415
|
onSubmit: n
|
|
2355
|
-
}) => e.type === "color" ?
|
|
2416
|
+
}) => e.type === "color" ? qs(e, t, n) : e.type === "text" ? Ks(e, t, n) : e.type === "number" ? Gs(e, t, n) : js(e, t, n), Ys = (e) => {
|
|
2356
2417
|
var t, n, r;
|
|
2357
2418
|
return e.defaultValue ?? (e.type === "select" ? (t = e.options[0]) == null ? void 0 : t.value : void 0) ?? (e.type === "color" ? (r = (n = e.options) == null ? void 0 : n[0]) == null ? void 0 : r.value : void 0) ?? "";
|
|
2358
|
-
},
|
|
2419
|
+
}, Js = (e, t) => (t == null ? void 0 : t[e.name]) ?? (e.type === "color" ? "" : Ys(e)), Ht = (e) => e.some((t) => t.type === "text" || t.type === "number"), Qs = (e) => {
|
|
2359
2420
|
const t = e.querySelector(
|
|
2360
2421
|
".bridgerte__payload-panel-text-input"
|
|
2361
2422
|
);
|
|
2362
2423
|
queueMicrotask(() => {
|
|
2363
2424
|
t == null || t.focus(), t == null || t.select();
|
|
2364
2425
|
});
|
|
2365
|
-
},
|
|
2426
|
+
}, Zs = (e, t, n) => {
|
|
2366
2427
|
const r = document.createElement("div"), o = document.createElement("span"), a = (n == null ? void 0 : n(e)) ?? null;
|
|
2367
2428
|
if (r.className = "bridgerte__payload-panel-title", o.textContent = e.panel.title, r.append(o), a) {
|
|
2368
2429
|
const s = document.createElement("button");
|
|
2369
|
-
s.type = "button", s.className = "bridgerte__payload-panel-clear", s.textContent = "清除", s.setAttribute("aria-label", `清除${e.panel.title}`),
|
|
2430
|
+
s.type = "button", s.className = "bridgerte__payload-panel-clear", s.textContent = "清除", s.setAttribute("aria-label", `清除${e.panel.title}`), V(s), s.addEventListener("pointerdown", (c) => {
|
|
2370
2431
|
c.preventDefault();
|
|
2371
2432
|
}), s.addEventListener("click", () => {
|
|
2372
2433
|
t(a);
|
|
2373
2434
|
}), r.append(s);
|
|
2374
2435
|
}
|
|
2375
2436
|
return r;
|
|
2376
|
-
},
|
|
2437
|
+
}, ei = (e) => (
|
|
2377
2438
|
/*
|
|
2378
2439
|
* 字体类面板只需要紧凑候选列表,颜色面板需要保留一点横向空间给圆盘和黑白按钮。
|
|
2379
2440
|
* 输入型面板保留默认宽度;table-insert 会按 schema 网格列数单独计算。
|
|
2380
2441
|
*/
|
|
2381
2442
|
e === "font-size" || e === "font-family" || e === "line-height" ? "180px" : "220px"
|
|
2382
|
-
),
|
|
2443
|
+
), ti = 3, ni = 3, ri = 10, On = 10, oi = 16, ai = 2, si = 24, ii = () => {
|
|
2383
2444
|
var e;
|
|
2384
2445
|
return typeof window < "u" && ((e = window.matchMedia) == null ? void 0 : e.call(window, "(hover: hover) and (pointer: fine)").matches) === !0;
|
|
2385
|
-
},
|
|
2446
|
+
}, de = (e, t) => {
|
|
2386
2447
|
const n = Number.parseInt(e ?? "", 10);
|
|
2387
2448
|
return Number.isFinite(n) ? Math.min(Math.max(n, t.min), t.max) : t.defaultValue;
|
|
2388
|
-
},
|
|
2389
|
-
const o = e.find((h) =>
|
|
2449
|
+
}, li = (e, t) => e.type === "number" && e.name === t, $t = (e, t) => typeof e == "number" && Number.isFinite(e) && e > 0 ? Math.floor(e) : t, Ft = (e, t, n, r) => {
|
|
2450
|
+
const o = e.find((h) => li(h, t)), a = $t(o == null ? void 0 : o.min, 1), s = $t(o == null ? void 0 : o.max, n), c = Math.max(a, s), d = Math.min(Math.max(r, a), c), l = de(o == null ? void 0 : o.defaultValue, {
|
|
2390
2451
|
min: a,
|
|
2391
2452
|
max: c,
|
|
2392
2453
|
defaultValue: d
|
|
@@ -2396,28 +2457,28 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
2396
2457
|
max: c,
|
|
2397
2458
|
defaultValue: l
|
|
2398
2459
|
};
|
|
2399
|
-
},
|
|
2460
|
+
}, Hn = (e) => ({
|
|
2400
2461
|
rows: Ft(
|
|
2401
2462
|
e,
|
|
2402
2463
|
"rows",
|
|
2403
2464
|
Zt,
|
|
2404
|
-
|
|
2465
|
+
ti
|
|
2405
2466
|
),
|
|
2406
2467
|
cols: Ft(
|
|
2407
2468
|
e,
|
|
2408
2469
|
"cols",
|
|
2409
2470
|
en,
|
|
2410
|
-
|
|
2471
|
+
ni
|
|
2411
2472
|
)
|
|
2412
|
-
}),
|
|
2413
|
-
const t = Math.min(e.cols.max,
|
|
2414
|
-
return `${t *
|
|
2415
|
-
},
|
|
2473
|
+
}), ci = (e) => {
|
|
2474
|
+
const t = Math.min(e.cols.max, On);
|
|
2475
|
+
return `${t * oi + Math.max(t - 1, 0) * ai + si}px`;
|
|
2476
|
+
}, di = ({
|
|
2416
2477
|
fields: e,
|
|
2417
2478
|
values: t,
|
|
2418
2479
|
onSubmit: n
|
|
2419
2480
|
}) => {
|
|
2420
|
-
const r =
|
|
2481
|
+
const r = Hn(e), o = document.createElement("section"), a = document.createElement("div"), s = document.createElement("div"), c = [], d = ii(), l = Math.min(r.rows.max, ri), h = Math.min(r.cols.max, On), v = {
|
|
2421
2482
|
...r.rows,
|
|
2422
2483
|
max: l,
|
|
2423
2484
|
defaultValue: Math.min(r.rows.defaultValue, l)
|
|
@@ -2426,14 +2487,14 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
2426
2487
|
max: h,
|
|
2427
2488
|
defaultValue: Math.min(r.cols.defaultValue, h)
|
|
2428
2489
|
};
|
|
2429
|
-
let T =
|
|
2490
|
+
let T = de(
|
|
2430
2491
|
t.rows,
|
|
2431
2492
|
v
|
|
2432
|
-
), f =
|
|
2493
|
+
), f = de(
|
|
2433
2494
|
t.cols,
|
|
2434
2495
|
w
|
|
2435
2496
|
), y = null;
|
|
2436
|
-
const
|
|
2497
|
+
const x = (L, C) => {
|
|
2437
2498
|
T = L, f = C, t.rows = String(L), t.cols = String(C), s.textContent = `${L} x ${C}`, c.forEach((i) => {
|
|
2438
2499
|
const u = Number.parseInt(i.dataset.rows ?? "0", 10), g = Number.parseInt(i.dataset.cols ?? "0", 10);
|
|
2439
2500
|
i.dataset.active = String(u <= L && g <= C);
|
|
@@ -2443,14 +2504,14 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
2443
2504
|
return ((C = document.elementFromPoint(L.clientX, L.clientY)) == null ? void 0 : C.closest(".bridgerte__payload-panel-table-cell")) ?? null;
|
|
2444
2505
|
}, p = (L) => {
|
|
2445
2506
|
if (!L) return;
|
|
2446
|
-
const C =
|
|
2507
|
+
const C = de(
|
|
2447
2508
|
L.dataset.rows,
|
|
2448
2509
|
v
|
|
2449
|
-
), i =
|
|
2510
|
+
), i = de(
|
|
2450
2511
|
L.dataset.cols,
|
|
2451
2512
|
w
|
|
2452
2513
|
);
|
|
2453
|
-
|
|
2514
|
+
x(C, i);
|
|
2454
2515
|
}, k = () => {
|
|
2455
2516
|
n({
|
|
2456
2517
|
...t,
|
|
@@ -2471,7 +2532,7 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
2471
2532
|
for (let L = 1; L <= l; L += 1)
|
|
2472
2533
|
for (let C = 1; C <= h; C += 1) {
|
|
2473
2534
|
const i = document.createElement("button");
|
|
2474
|
-
i.type = "button", i.className = "bridgerte__payload-panel-table-cell", i.dataset.rows = String(L), i.dataset.cols = String(C), i.setAttribute("aria-label", `插入 ${L} 行 ${C} 列表格`),
|
|
2535
|
+
i.type = "button", i.className = "bridgerte__payload-panel-table-cell", i.dataset.rows = String(L), i.dataset.cols = String(C), i.setAttribute("aria-label", `插入 ${L} 行 ${C} 列表格`), V(i), i.addEventListener("pointerdown", (u) => {
|
|
2475
2536
|
y = i, p(i), u.preventDefault();
|
|
2476
2537
|
}), i.addEventListener("pointerup", P), i.addEventListener("pointercancel", _), i.addEventListener("click", (u) => {
|
|
2477
2538
|
I(u, i);
|
|
@@ -2484,19 +2545,19 @@ const ss = () => (At += 1, `${as}-${At}`), is = (e, t, n) => {
|
|
|
2484
2545
|
String(h)
|
|
2485
2546
|
), s.className = "bridgerte__payload-panel-table-status", s.setAttribute("aria-live", "polite"), a.addEventListener("pointermove", (L) => {
|
|
2486
2547
|
d || p(m(L));
|
|
2487
|
-
}),
|
|
2488
|
-
},
|
|
2548
|
+
}), x(T, f), o.append(a, s), o;
|
|
2549
|
+
}, ui = "bridgerte-payload-panel";
|
|
2489
2550
|
let zt = 0;
|
|
2490
|
-
const
|
|
2551
|
+
const mi = () => (zt += 1, `${ui}-${zt}`), Ee = (e) => e.panel.id === "table-insert", gi = (e, t) => {
|
|
2491
2552
|
const n = document.createElement("button");
|
|
2492
|
-
return n.type = "button", n.className = "bridgerte__payload-panel-submit", n.textContent = "应用",
|
|
2553
|
+
return n.type = "button", n.className = "bridgerte__payload-panel-submit", n.textContent = "应用", V(n), n.addEventListener("pointerdown", (r) => {
|
|
2493
2554
|
r.preventDefault();
|
|
2494
2555
|
}), n.addEventListener("click", () => {
|
|
2495
2556
|
t(e);
|
|
2496
2557
|
}), n;
|
|
2497
|
-
},
|
|
2558
|
+
}, hi = (e) => {
|
|
2498
2559
|
let t = null, n = {};
|
|
2499
|
-
const r =
|
|
2560
|
+
const r = Nn({
|
|
2500
2561
|
root: e.editorRoot,
|
|
2501
2562
|
className: "bridgerte__payload-panel",
|
|
2502
2563
|
onBackdropClick: () => {
|
|
@@ -2509,7 +2570,7 @@ const ni = () => (zt += 1, `${ti}-${zt}`), _e = (e) => e.panel.id === "table-ins
|
|
|
2509
2570
|
const a = (l) => {
|
|
2510
2571
|
var v;
|
|
2511
2572
|
if (!t || t.readonly || e.isReadonly()) return;
|
|
2512
|
-
const h =
|
|
2573
|
+
const h = $s(t.command, l);
|
|
2513
2574
|
h && ((v = e.restoreEditorFocus) == null || v.call(e, () => {
|
|
2514
2575
|
o(), e.isReadonly() || e.executeCommand(h);
|
|
2515
2576
|
}));
|
|
@@ -2519,19 +2580,19 @@ const ni = () => (zt += 1, `${ti}-${zt}`), _e = (e) => e.panel.id === "table-ins
|
|
|
2519
2580
|
o(), e.isReadonly() || e.executeCommand(l);
|
|
2520
2581
|
});
|
|
2521
2582
|
}, c = (l) => {
|
|
2522
|
-
n = l.panel.fields.reduce((v, w) => (v[w.name] =
|
|
2523
|
-
const h =
|
|
2524
|
-
r.element.style.width = `min(${h}, calc(100vw - 24px))`, r.content.append(
|
|
2583
|
+
n = l.panel.fields.reduce((v, w) => (v[w.name] = Js(w, l.currentValues), v), {});
|
|
2584
|
+
const h = Ee(l) ? ci(Hn(l.panel.fields)) : ei(l.panel.id);
|
|
2585
|
+
r.element.style.width = `min(${h}, calc(100vw - 24px))`, r.content.append(Zs(l, s, e.getClearCommand)), Ee(l) ? r.content.append(di({
|
|
2525
2586
|
fields: l.panel.fields,
|
|
2526
2587
|
values: n,
|
|
2527
2588
|
onSubmit: a
|
|
2528
2589
|
})) : l.panel.fields.forEach((v) => {
|
|
2529
|
-
r.content.append(
|
|
2590
|
+
r.content.append(Xs({
|
|
2530
2591
|
field: v,
|
|
2531
2592
|
values: n,
|
|
2532
2593
|
onSubmit: a
|
|
2533
2594
|
}));
|
|
2534
|
-
}), !
|
|
2595
|
+
}), !Ee(l) && Ht(l.panel.fields) && r.content.append(gi(n, a)), r.open(l.anchorRect), !Ee(l) && Ht(l.panel.fields) && Qs(r.content);
|
|
2535
2596
|
};
|
|
2536
2597
|
return {
|
|
2537
2598
|
open: (l) => {
|
|
@@ -2539,7 +2600,7 @@ const ni = () => (zt += 1, `${ti}-${zt}`), _e = (e) => e.panel.id === "table-ins
|
|
|
2539
2600
|
o();
|
|
2540
2601
|
const h = {
|
|
2541
2602
|
...l,
|
|
2542
|
-
id:
|
|
2603
|
+
id: mi(),
|
|
2543
2604
|
readonly: e.isReadonly(),
|
|
2544
2605
|
submit: a,
|
|
2545
2606
|
cancel: o
|
|
@@ -2557,46 +2618,46 @@ const ni = () => (zt += 1, `${ti}-${zt}`), _e = (e) => e.panel.id === "table-ins
|
|
|
2557
2618
|
o(), r.destroy();
|
|
2558
2619
|
}
|
|
2559
2620
|
};
|
|
2560
|
-
},
|
|
2621
|
+
}, ue = "bridgerte__table-controls-button", pi = [
|
|
2561
2622
|
"table-insert-row-after",
|
|
2562
2623
|
"table-delete-row",
|
|
2563
2624
|
"table-insert-column-after",
|
|
2564
2625
|
"table-delete-column",
|
|
2565
2626
|
"table-delete"
|
|
2566
|
-
],
|
|
2567
|
-
const e = new Map(
|
|
2568
|
-
return
|
|
2569
|
-
},
|
|
2627
|
+
], fi = () => {
|
|
2628
|
+
const e = new Map(Re.map((t) => [t.id, t]));
|
|
2629
|
+
return pi.map((t) => mo.find((n) => n.id === t) ?? e.get(t)).filter((t) => t !== void 0);
|
|
2630
|
+
}, $n = fi(), bi = new Map(
|
|
2570
2631
|
/*
|
|
2571
2632
|
* Controls 按钮用 MenuItem.id 查完整 command,同类命令的不同 payload 不能用 command.type 合并。
|
|
2572
2633
|
* 后续加入插入前/后、合并/拆分等表格菜单时,只要 id 稳定,就不会互相覆盖。
|
|
2573
2634
|
*/
|
|
2574
|
-
|
|
2575
|
-
),
|
|
2635
|
+
$n.map((e) => [e.id, e])
|
|
2636
|
+
), yi = (e) => e.matches(".bridgerte__table") ? e : e.querySelector(".bridgerte__table") ?? e, vi = (e, t) => e.classList.contains("bridgerte__table-wrapper") ? e : t.parentElement instanceof HTMLElement ? t.parentElement : t, wi = (e) => e.querySelector(".bridgerte__content") ?? e, Ci = (e) => e instanceof Element ? e.closest(".bridgerte__table-wrapper") : null, _i = (e) => {
|
|
2576
2637
|
const t = e.getFirstChild();
|
|
2577
|
-
if (!
|
|
2638
|
+
if (!Kr(t)) return null;
|
|
2578
2639
|
const n = t.getFirstChild();
|
|
2579
|
-
return
|
|
2580
|
-
},
|
|
2640
|
+
return Gr(n) ? n : null;
|
|
2641
|
+
}, ki = (e) => {
|
|
2581
2642
|
const t = document.createElement("button");
|
|
2582
|
-
return t.type = "button", t.className =
|
|
2583
|
-
},
|
|
2643
|
+
return t.type = "button", t.className = ue, t.textContent = e.label, t.dataset.menuItemId = e.id, t.setAttribute("aria-label", e.label), t;
|
|
2644
|
+
}, Ei = () => {
|
|
2584
2645
|
const e = document.createElement("div");
|
|
2585
|
-
return e.className = "bridgerte__table-controls", e.contentEditable = "false", e.setAttribute("aria-label", "表格操作"),
|
|
2586
|
-
e.append(
|
|
2646
|
+
return e.className = "bridgerte__table-controls", e.contentEditable = "false", e.setAttribute("aria-label", "表格操作"), $n.forEach((t) => {
|
|
2647
|
+
e.append(ki(t));
|
|
2587
2648
|
}), e;
|
|
2588
|
-
},
|
|
2589
|
-
const t = document.createElement("div"), n =
|
|
2649
|
+
}, xi = (e) => {
|
|
2650
|
+
const t = document.createElement("div"), n = wi(e.root), r = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
2590
2651
|
let s = null, c = null, d = !1, l = null;
|
|
2591
2652
|
const h = (g, b) => {
|
|
2592
|
-
const M = e.root.getBoundingClientRect(),
|
|
2653
|
+
const M = e.root.getBoundingClientRect(), S = b.getBoundingClientRect(), A = S.bottom < M.top || S.top > M.bottom, O = Math.max(
|
|
2593
2654
|
8,
|
|
2594
2655
|
M.width - g.offsetWidth - 8
|
|
2595
|
-
),
|
|
2596
|
-
Math.max(
|
|
2656
|
+
), W = Math.min(
|
|
2657
|
+
Math.max(S.left - M.left + 8, 8),
|
|
2597
2658
|
O
|
|
2598
|
-
),
|
|
2599
|
-
g.hidden = A, g.style.transform = `translate(${
|
|
2659
|
+
), N = Math.max(8, S.top - M.top - g.offsetHeight - 8);
|
|
2660
|
+
g.hidden = A, g.style.transform = `translate(${W}px, ${N}px)`;
|
|
2600
2661
|
}, v = (g) => l === g, w = (g) => {
|
|
2601
2662
|
const b = e.editor.getElementByKey(g);
|
|
2602
2663
|
if (!b) {
|
|
@@ -2604,21 +2665,21 @@ const ni = () => (zt += 1, `${ti}-${zt}`), _e = (e) => e.panel.id === "table-ins
|
|
|
2604
2665
|
return;
|
|
2605
2666
|
}
|
|
2606
2667
|
b.dataset.lexicalKey = g;
|
|
2607
|
-
const M =
|
|
2608
|
-
a.set(
|
|
2668
|
+
const M = yi(b), S = vi(b, M);
|
|
2669
|
+
a.set(S, g);
|
|
2609
2670
|
const A = r.get(g);
|
|
2610
2671
|
if (!v(g)) {
|
|
2611
2672
|
T(g);
|
|
2612
2673
|
return;
|
|
2613
2674
|
}
|
|
2614
2675
|
if (A) {
|
|
2615
|
-
h(A,
|
|
2676
|
+
h(A, S);
|
|
2616
2677
|
return;
|
|
2617
2678
|
}
|
|
2618
|
-
const O =
|
|
2619
|
-
targetSelector: `.${
|
|
2679
|
+
const O = Ei(), W = V(O, {
|
|
2680
|
+
targetSelector: `.${ue}`
|
|
2620
2681
|
});
|
|
2621
|
-
O.dataset.lexicalKey = g, r.set(g, O), o.set(O,
|
|
2682
|
+
O.dataset.lexicalKey = g, r.set(g, O), o.set(O, W), t.append(O), h(O, S);
|
|
2622
2683
|
}, T = (g) => {
|
|
2623
2684
|
var M;
|
|
2624
2685
|
const b = r.get(g);
|
|
@@ -2633,22 +2694,22 @@ const ni = () => (zt += 1, `${ti}-${zt}`), _e = (e) => e.panel.id === "table-ins
|
|
|
2633
2694
|
w(b);
|
|
2634
2695
|
}), l !== null && w(l);
|
|
2635
2696
|
}, y = () => {
|
|
2636
|
-
s === null && (s =
|
|
2637
|
-
},
|
|
2697
|
+
s === null && (s = Se(f));
|
|
2698
|
+
}, x = (g) => {
|
|
2638
2699
|
e.editor.update(() => {
|
|
2639
2700
|
var M;
|
|
2640
|
-
const b =
|
|
2641
|
-
b instanceof je && ((M =
|
|
2701
|
+
const b = he(g);
|
|
2702
|
+
b instanceof je && ((M = _i(b)) == null || M.selectStart());
|
|
2642
2703
|
}), e.editor.focus();
|
|
2643
2704
|
}, m = (g, b) => {
|
|
2644
|
-
|
|
2705
|
+
x(g), e.executeCommand(b);
|
|
2645
2706
|
}, p = (g, b) => {
|
|
2646
|
-
const M = b.dataset.lexicalKey,
|
|
2707
|
+
const M = b.dataset.lexicalKey, S = g.dataset.menuItemId, A = S ? bi.get(S) : void 0;
|
|
2647
2708
|
!M || !A || m(M, A.command);
|
|
2648
2709
|
}, k = (g) => {
|
|
2649
2710
|
if (!g) {
|
|
2650
|
-
const
|
|
2651
|
-
l = null,
|
|
2711
|
+
const S = l;
|
|
2712
|
+
l = null, S !== null && w(S);
|
|
2652
2713
|
return;
|
|
2653
2714
|
}
|
|
2654
2715
|
const b = g.dataset.lexicalKey ? g.dataset.lexicalKey : a.get(g) ?? null;
|
|
@@ -2658,12 +2719,12 @@ const ni = () => (zt += 1, `${ti}-${zt}`), _e = (e) => e.panel.id === "table-ins
|
|
|
2658
2719
|
}, _ = (g) => {
|
|
2659
2720
|
const b = g.target;
|
|
2660
2721
|
if (!(b instanceof HTMLElement)) return;
|
|
2661
|
-
const M = b.closest(`.${
|
|
2722
|
+
const M = b.closest(`.${ue}`);
|
|
2662
2723
|
M && (g.preventDefault(), c = g.pointerType === "mouse" ? null : M);
|
|
2663
2724
|
}, P = (g) => {
|
|
2664
2725
|
if (g.pointerType === "mouse" || !c) return;
|
|
2665
|
-
const b = g.target, M = b instanceof HTMLElement ? b.closest(".bridgerte__table-controls") : null,
|
|
2666
|
-
|
|
2726
|
+
const b = g.target, M = b instanceof HTMLElement ? b.closest(".bridgerte__table-controls") : null, S = b instanceof HTMLElement ? b.closest(`.${ue}`) : null;
|
|
2727
|
+
S === c && M && (g.preventDefault(), g.stopPropagation(), p(S, M), d = !0), c = null;
|
|
2667
2728
|
}, I = () => {
|
|
2668
2729
|
c = null;
|
|
2669
2730
|
}, L = (g) => {
|
|
@@ -2673,8 +2734,8 @@ const ni = () => (zt += 1, `${ti}-${zt}`), _e = (e) => e.panel.id === "table-ins
|
|
|
2673
2734
|
}
|
|
2674
2735
|
const b = g.target;
|
|
2675
2736
|
if (!(b instanceof HTMLElement)) return;
|
|
2676
|
-
const M = b.closest(`.${
|
|
2677
|
-
!M || !
|
|
2737
|
+
const M = b.closest(`.${ue}`), S = b.closest(".bridgerte__table-controls");
|
|
2738
|
+
!M || !S || (g.preventDefault(), g.stopPropagation(), p(M, S));
|
|
2678
2739
|
}, C = e.editor.registerMutationListener(
|
|
2679
2740
|
je,
|
|
2680
2741
|
(g) => {
|
|
@@ -2686,10 +2747,10 @@ const ni = () => (zt += 1, `${ti}-${zt}`), _e = (e) => e.panel.id === "table-ins
|
|
|
2686
2747
|
w(M);
|
|
2687
2748
|
});
|
|
2688
2749
|
}
|
|
2689
|
-
), i = e.editor.registerUpdateListener(y), u =
|
|
2750
|
+
), i = e.editor.registerUpdateListener(y), u = Sn({
|
|
2690
2751
|
root: e.root,
|
|
2691
2752
|
content: n,
|
|
2692
|
-
getBlockFromTarget:
|
|
2753
|
+
getBlockFromTarget: Ci,
|
|
2693
2754
|
activateBlock: k,
|
|
2694
2755
|
clearBlock: () => k(null)
|
|
2695
2756
|
});
|
|
@@ -2701,26 +2762,26 @@ const ni = () => (zt += 1, `${ti}-${zt}`), _e = (e) => e.panel.id === "table-ins
|
|
|
2701
2762
|
}), r.clear(), o.clear(), a.clear(), t.remove();
|
|
2702
2763
|
}
|
|
2703
2764
|
};
|
|
2704
|
-
},
|
|
2705
|
-
const t =
|
|
2765
|
+
}, Mi = (e) => {
|
|
2766
|
+
const t = hi({
|
|
2706
2767
|
editorRoot: e.editorRoot,
|
|
2707
2768
|
isReadonly: e.isReadonly,
|
|
2708
2769
|
restoreEditorFocus: e.restoreEditorFocus,
|
|
2709
2770
|
executeCommand: e.executeCommand,
|
|
2710
2771
|
getClearCommand: e.getClearCommand,
|
|
2711
2772
|
onRequest: e.onRequest
|
|
2712
|
-
}), n =
|
|
2773
|
+
}), n = vs({
|
|
2713
2774
|
editor: e.lexicalEditor,
|
|
2714
2775
|
root: e.editorRoot,
|
|
2715
2776
|
isReadonly: e.isReadonly,
|
|
2716
2777
|
languagePanel: e.codeBlockLanguagePanel,
|
|
2717
2778
|
payloadPanelConfig: e.payloadPanelConfig,
|
|
2718
2779
|
onRequest: e.onRequest
|
|
2719
|
-
}), r =
|
|
2780
|
+
}), r = xi({
|
|
2720
2781
|
editor: e.lexicalEditor,
|
|
2721
2782
|
root: e.editorRoot,
|
|
2722
2783
|
executeCommand: e.executeCommand
|
|
2723
|
-
}), o =
|
|
2784
|
+
}), o = Os({
|
|
2724
2785
|
editor: e.lexicalEditor,
|
|
2725
2786
|
root: e.editorRoot,
|
|
2726
2787
|
defaultWidthPercent: e.defaultMediaWidthPercent,
|
|
@@ -2737,14 +2798,14 @@ const ni = () => (zt += 1, `${ti}-${zt}`), _e = (e) => e.panel.id === "table-ins
|
|
|
2737
2798
|
t.destroy(), n.destroy(), r.destroy(), o.destroy();
|
|
2738
2799
|
}
|
|
2739
2800
|
};
|
|
2740
|
-
},
|
|
2801
|
+
}, Ti = (e, t) => {
|
|
2741
2802
|
const n = document.createElement("div"), r = document.createElement("div"), o = document.createElement("div");
|
|
2742
2803
|
return e.classList.add("bridgerte"), e.textContent = "", n.className = "bridgerte__editor", r.className = "bridgerte__body", o.className = "bridgerte__content", o.dataset.placeholder = t.placeholder, o.setAttribute("role", "textbox"), o.setAttribute("aria-multiline", "true"), r.append(o), n.append(r), e.append(n), {
|
|
2743
2804
|
rootElement: n,
|
|
2744
2805
|
bodyElement: r,
|
|
2745
2806
|
contentElement: o
|
|
2746
2807
|
};
|
|
2747
|
-
},
|
|
2808
|
+
}, Li = ({
|
|
2748
2809
|
editor: e
|
|
2749
2810
|
}) => {
|
|
2750
2811
|
let t = null;
|
|
@@ -2757,23 +2818,23 @@ const ni = () => (zt += 1, `${ti}-${zt}`), _e = (e) => e.panel.id === "table-ins
|
|
|
2757
2818
|
},
|
|
2758
2819
|
restore() {
|
|
2759
2820
|
t && e.update(() => {
|
|
2760
|
-
|
|
2821
|
+
mr((t == null ? void 0 : t.clone()) ?? null);
|
|
2761
2822
|
});
|
|
2762
2823
|
},
|
|
2763
2824
|
clear() {
|
|
2764
2825
|
t = null;
|
|
2765
2826
|
}
|
|
2766
2827
|
};
|
|
2767
|
-
},
|
|
2828
|
+
}, Ni = /((https?:\/\/|www\.)[^\s<>()]+[^\s<>().,;:!?])/i, Si = /([A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,})/i, Pi = {
|
|
2768
2829
|
changeHandlers: [],
|
|
2769
2830
|
excludeParents: [],
|
|
2770
2831
|
matchers: [
|
|
2771
|
-
gt(
|
|
2772
|
-
gt(
|
|
2832
|
+
gt(Ni, (e) => e.startsWith("http://") || e.startsWith("https://") ? e : `https://${e}`),
|
|
2833
|
+
gt(Si, (e) => `mailto:${e}`)
|
|
2773
2834
|
]
|
|
2774
|
-
},
|
|
2835
|
+
}, Ii = ({
|
|
2775
2836
|
editor: e
|
|
2776
|
-
}) =>
|
|
2837
|
+
}) => to(e, Pi), Ri = [
|
|
2777
2838
|
".bridgerte__code-header",
|
|
2778
2839
|
".bridgerte__code-block-control",
|
|
2779
2840
|
".bridgerte__code-block-controls-layer",
|
|
@@ -2785,32 +2846,32 @@ const ni = () => (zt += 1, `${ti}-${zt}`), _e = (e) => e.panel.id === "table-ins
|
|
|
2785
2846
|
".bridgerte__dialog-backdrop",
|
|
2786
2847
|
".bridgerte__dialog",
|
|
2787
2848
|
".bridgerte__payload-panel"
|
|
2788
|
-
].join(","),
|
|
2849
|
+
].join(","), Ai = (e, t) => {
|
|
2789
2850
|
const n = e.anchorNode, r = e.focusNode;
|
|
2790
2851
|
return n !== null && r !== null && t.contains(n) && t.contains(r);
|
|
2791
|
-
},
|
|
2792
|
-
e.querySelectorAll(
|
|
2852
|
+
}, Bi = (e) => {
|
|
2853
|
+
e.querySelectorAll(Ri).forEach((t) => {
|
|
2793
2854
|
t.remove();
|
|
2794
2855
|
}), e.querySelectorAll('[contenteditable="false"]').forEach((t) => {
|
|
2795
2856
|
t.classList.contains("bridgerte__media") || t.remove();
|
|
2796
2857
|
});
|
|
2797
|
-
},
|
|
2858
|
+
}, Di = (e) => {
|
|
2798
2859
|
const t = e.ownerDocument.getSelection();
|
|
2799
|
-
if (!t || t.rangeCount === 0 || !
|
|
2860
|
+
if (!t || t.rangeCount === 0 || !Ai(t, e))
|
|
2800
2861
|
return null;
|
|
2801
2862
|
const n = t.getRangeAt(0).cloneContents();
|
|
2802
|
-
|
|
2863
|
+
Bi(n);
|
|
2803
2864
|
const r = e.ownerDocument.createElement("div");
|
|
2804
2865
|
return r.append(n), {
|
|
2805
2866
|
html: r.innerHTML,
|
|
2806
2867
|
text: r.textContent ?? ""
|
|
2807
2868
|
};
|
|
2808
|
-
},
|
|
2869
|
+
}, Oi = ({
|
|
2809
2870
|
target: e,
|
|
2810
2871
|
isReadonly: t
|
|
2811
2872
|
}) => {
|
|
2812
2873
|
const n = (o) => {
|
|
2813
|
-
const a =
|
|
2874
|
+
const a = Di(e);
|
|
2814
2875
|
!a || !o.clipboardData || (o.clipboardData.setData("text/html", a.html), o.clipboardData.setData("text/plain", a.text), o.preventDefault(), o.stopImmediatePropagation());
|
|
2815
2876
|
}, r = (o) => {
|
|
2816
2877
|
if (t()) {
|
|
@@ -2822,7 +2883,7 @@ const ni = () => (zt += 1, `${ti}-${zt}`), _e = (e) => e.panel.id === "table-ins
|
|
|
2822
2883
|
return e.addEventListener("copy", n, { capture: !0 }), e.addEventListener("cut", r, { capture: !0 }), () => {
|
|
2823
2884
|
e.removeEventListener("copy", n, { capture: !0 }), e.removeEventListener("cut", r, { capture: !0 });
|
|
2824
2885
|
};
|
|
2825
|
-
},
|
|
2886
|
+
}, xe = 8, Hi = () => {
|
|
2826
2887
|
const e = window.visualViewport;
|
|
2827
2888
|
return {
|
|
2828
2889
|
left: (e == null ? void 0 : e.offsetLeft) ?? 0,
|
|
@@ -2830,24 +2891,24 @@ const ni = () => (zt += 1, `${ti}-${zt}`), _e = (e) => e.panel.id === "table-ins
|
|
|
2830
2891
|
width: (e == null ? void 0 : e.width) ?? window.innerWidth,
|
|
2831
2892
|
height: (e == null ? void 0 : e.height) ?? window.innerHeight
|
|
2832
2893
|
};
|
|
2833
|
-
},
|
|
2834
|
-
function
|
|
2894
|
+
}, Vt = (e, t, n) => Math.min(Math.max(e, t), Math.max(t, n));
|
|
2895
|
+
function Fn(e, t, n = {}) {
|
|
2835
2896
|
const r = n.placement ?? "bottom-start", o = n.offset ?? 8, a = n.shiftPadding ?? 8, s = n.strategy ?? "absolute";
|
|
2836
2897
|
let c = null, d = !1;
|
|
2837
2898
|
const l = () => {
|
|
2838
2899
|
t.style.position = s, t.style.left = "0px", t.style.top = "0px", t.style.opacity = "0", t.style.pointerEvents = "none";
|
|
2839
2900
|
}, h = (f, y) => {
|
|
2840
|
-
const
|
|
2841
|
-
t.style.left = `${
|
|
2901
|
+
const x = Hi(), m = t.getBoundingClientRect(), p = x.left + xe, k = x.top + xe, _ = x.left + x.width - m.width - xe, P = x.top + x.height - m.height - xe;
|
|
2902
|
+
t.style.left = `${Vt(f, p, _)}px`, t.style.top = `${Vt(y, k, P)}px`, t.style.opacity = "", t.style.pointerEvents = "";
|
|
2842
2903
|
}, v = async () => {
|
|
2843
|
-
const f = await
|
|
2904
|
+
const f = await vo(e, t, {
|
|
2844
2905
|
placement: r,
|
|
2845
2906
|
strategy: s,
|
|
2846
|
-
platform:
|
|
2907
|
+
platform: wo,
|
|
2847
2908
|
middleware: [
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2909
|
+
Co(o),
|
|
2910
|
+
_o(),
|
|
2911
|
+
ko({ padding: a })
|
|
2851
2912
|
]
|
|
2852
2913
|
});
|
|
2853
2914
|
h(f.x, f.y);
|
|
@@ -2856,7 +2917,7 @@ function Dn(e, t, n = {}) {
|
|
|
2856
2917
|
}, T = (f) => {
|
|
2857
2918
|
if (d !== f) {
|
|
2858
2919
|
if (d = f, w(), d) {
|
|
2859
|
-
l(), t.hidden = !1, c =
|
|
2920
|
+
l(), t.hidden = !1, c = yo(e, t, v), v();
|
|
2860
2921
|
return;
|
|
2861
2922
|
}
|
|
2862
2923
|
t.hidden = !0, t.style.opacity = "", t.style.pointerEvents = "";
|
|
@@ -2870,7 +2931,7 @@ function Dn(e, t, n = {}) {
|
|
|
2870
2931
|
}
|
|
2871
2932
|
};
|
|
2872
2933
|
}
|
|
2873
|
-
const
|
|
2934
|
+
const zn = {
|
|
2874
2935
|
// 居中对齐菜单使用,和 align 命令的 center value 对应。
|
|
2875
2936
|
"align-center": '<svg aria-hidden="true" class="lucide lucide-align-center" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M21 5H3" /> <path d="M17 12H7" /> <path d="M19 19H5" /> </svg>',
|
|
2876
2937
|
// 两端对齐菜单使用,保留段落排版语义,不和普通居中/左右对齐混用。
|
|
@@ -2963,19 +3024,19 @@ const On = {
|
|
|
2963
3024
|
"upload-video": '<svg aria-hidden="true" class="lucide lucide-video" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5" /> <rect x="2" y="6" width="14" height="12" rx="2" /> </svg>',
|
|
2964
3025
|
// 行高菜单使用,表示 format.lineHeight。
|
|
2965
3026
|
"wrap-text": '<svg aria-hidden="true" class="lucide lucide-wrap-text" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="m16 16-3 3 3 3" /> <path d="M3 12h14.5a1 1 0 0 1 0 7H13" /> <path d="M3 19h6" /> <path d="M3 5h18" /> </svg>'
|
|
2966
|
-
},
|
|
3027
|
+
}, $i = (e) => {
|
|
2967
3028
|
const t = document.createElement("span");
|
|
2968
3029
|
return t.className = "bridgerte__menu-icon-text", t.textContent = e, t;
|
|
2969
|
-
},
|
|
3030
|
+
}, Vn = (e, t, n) => {
|
|
2970
3031
|
if (t) {
|
|
2971
3032
|
e.innerHTML = t;
|
|
2972
3033
|
return;
|
|
2973
3034
|
}
|
|
2974
|
-
e.append(
|
|
2975
|
-
},
|
|
3035
|
+
e.append($i(n));
|
|
3036
|
+
}, Je = () => {
|
|
2976
3037
|
const e = window.getSelection(), t = e != null && e.rangeCount ? e.getRangeAt(0) : null, n = t == null ? void 0 : t.getBoundingClientRect();
|
|
2977
3038
|
return !n || n.width === 0 && n.height === 0 ? null : n;
|
|
2978
|
-
},
|
|
3039
|
+
}, Fi = 160, zi = {
|
|
2979
3040
|
toolbarKeys: [
|
|
2980
3041
|
"bold",
|
|
2981
3042
|
"italic",
|
|
@@ -2990,16 +3051,16 @@ const On = {
|
|
|
2990
3051
|
"font-family",
|
|
2991
3052
|
"line-height"
|
|
2992
3053
|
]
|
|
2993
|
-
},
|
|
3054
|
+
}, Vi = () => {
|
|
2994
3055
|
const e = R();
|
|
2995
3056
|
return D(e) && !e.isCollapsed();
|
|
2996
|
-
},
|
|
3057
|
+
}, Wt = (e, t) => e.target instanceof Node && t.contains(e.target), Ut = (e) => e instanceof Element ? e.closest(".bridgerte__hoverbar-button") : null, Wi = (e) => e.flatMap((t) => t.type === "button" ? [t.item] : t.type === "group" ? t.items : []), Ui = (e) => {
|
|
2997
3058
|
const t = document.createElement("span");
|
|
2998
3059
|
return t.className = "bridgerte__hoverbar-separator", t.dataset.separatorId = e.key, t.setAttribute("aria-hidden", "true"), t;
|
|
2999
|
-
},
|
|
3000
|
-
const r =
|
|
3001
|
-
return o.type = "button", o.className = "bridgerte__hoverbar-button", o.dataset.hoverbarItemId = e.id, o.dataset.active = String(r.active), o.disabled = r.disabled, o.setAttribute("aria-label", e.label), o.setAttribute("aria-pressed", String(r.active)),
|
|
3002
|
-
},
|
|
3060
|
+
}, ji = (e, t, n) => {
|
|
3061
|
+
const r = Cs(e, t), o = document.createElement("button");
|
|
3062
|
+
return o.type = "button", o.className = "bridgerte__hoverbar-button", o.dataset.hoverbarItemId = e.id, o.dataset.active = String(r.active), o.disabled = r.disabled, o.setAttribute("aria-label", e.label), o.setAttribute("aria-pressed", String(r.active)), Vn(o, n[e.icon] ?? zn[e.icon], e.label), o;
|
|
3063
|
+
}, qi = ({
|
|
3003
3064
|
editorRoot: e,
|
|
3004
3065
|
contentElement: t,
|
|
3005
3066
|
editor: n,
|
|
@@ -3013,15 +3074,15 @@ const On = {
|
|
|
3013
3074
|
payloadPanelConfig: h,
|
|
3014
3075
|
icons: v = {}
|
|
3015
3076
|
}) => {
|
|
3016
|
-
const w = st(c ??
|
|
3077
|
+
const w = st(c ?? Re, {
|
|
3017
3078
|
menuLabels: l,
|
|
3018
3079
|
payloadPanelConfig: h
|
|
3019
|
-
}), T = tt(d ??
|
|
3080
|
+
}), T = tt(d ?? zi, w), f = Wi(T), y = document.createElement("span"), x = document.createElement("div");
|
|
3020
3081
|
let m = null, p = !1, k = null;
|
|
3021
|
-
const _ =
|
|
3082
|
+
const _ = V(x, {
|
|
3022
3083
|
targetSelector: ".bridgerte__hoverbar-button"
|
|
3023
3084
|
});
|
|
3024
|
-
y.className = "bridgerte__hoverbar-anchor", y.setAttribute("aria-hidden", "true"),
|
|
3085
|
+
y.className = "bridgerte__hoverbar-anchor", y.setAttribute("aria-hidden", "true"), x.className = "bridgerte__floating-menu bridgerte__hoverbar", x.setAttribute("role", "toolbar"), x.setAttribute("aria-label", "BridgeRTE hoverbar"), e.append(y, x), m = Fn(y, x, {
|
|
3025
3086
|
placement: "top",
|
|
3026
3087
|
offset: 8,
|
|
3027
3088
|
strategy: "fixed"
|
|
@@ -3029,35 +3090,35 @@ const On = {
|
|
|
3029
3090
|
const P = () => {
|
|
3030
3091
|
k && (window.clearTimeout(k), k = null);
|
|
3031
3092
|
}, I = () => {
|
|
3032
|
-
P(), p = !1,
|
|
3093
|
+
P(), p = !1, x.replaceChildren(), x.dataset.visible = "false", m == null || m.setOpen(!1);
|
|
3033
3094
|
}, L = () => {
|
|
3034
|
-
const
|
|
3035
|
-
y.style.left = `${(
|
|
3095
|
+
const N = Je(), E = t.getBoundingClientRect();
|
|
3096
|
+
y.style.left = `${(N == null ? void 0 : N.left) ?? E.left}px`, y.style.top = `${(N == null ? void 0 : N.top) ?? E.top}px`, y.style.width = `${(N == null ? void 0 : N.width) || 1}px`, y.style.height = `${(N == null ? void 0 : N.height) || 1}px`;
|
|
3036
3097
|
}, C = () => {
|
|
3037
|
-
const
|
|
3038
|
-
|
|
3039
|
-
}, i = () => r() ? !1 : n.getEditorState().read(
|
|
3098
|
+
const N = s();
|
|
3099
|
+
x.replaceChildren(...T.flatMap((E) => E.type === "separator" ? [Ui(E)] : (E.type === "button" ? [E.item] : E.items).map(($) => ji($, N, v)))), L(), p = !0, x.dataset.visible = "true", m == null || m.setOpen(!0), m == null || m.update();
|
|
3100
|
+
}, i = () => r() ? !1 : n.getEditorState().read(Vi), u = (N = !1) => {
|
|
3040
3101
|
if (P(), !i()) {
|
|
3041
3102
|
I();
|
|
3042
3103
|
return;
|
|
3043
3104
|
}
|
|
3044
|
-
if (
|
|
3105
|
+
if (N) {
|
|
3045
3106
|
C();
|
|
3046
3107
|
return;
|
|
3047
3108
|
}
|
|
3048
3109
|
p && I(), k = window.setTimeout(() => {
|
|
3049
3110
|
k = null, i() && C();
|
|
3050
|
-
},
|
|
3051
|
-
}, g = (
|
|
3052
|
-
const
|
|
3053
|
-
if (!(!
|
|
3054
|
-
if (
|
|
3055
|
-
const B =
|
|
3111
|
+
}, Fi);
|
|
3112
|
+
}, g = (N) => {
|
|
3113
|
+
const E = f.find((B) => B.id === N.dataset.hoverbarItemId);
|
|
3114
|
+
if (!(!E || N.disabled)) {
|
|
3115
|
+
if (E.payloadPanel) {
|
|
3116
|
+
const B = N.getBoundingClientRect();
|
|
3056
3117
|
a({
|
|
3057
|
-
menuId:
|
|
3058
|
-
command:
|
|
3059
|
-
panel:
|
|
3060
|
-
currentValues:
|
|
3118
|
+
menuId: E.id,
|
|
3119
|
+
command: E.command,
|
|
3120
|
+
panel: E.payloadPanel,
|
|
3121
|
+
currentValues: ws(E, s()),
|
|
3061
3122
|
anchorRect: {
|
|
3062
3123
|
x: B.left,
|
|
3063
3124
|
y: B.top,
|
|
@@ -3067,41 +3128,41 @@ const On = {
|
|
|
3067
3128
|
}), u(!0);
|
|
3068
3129
|
return;
|
|
3069
3130
|
}
|
|
3070
|
-
o(
|
|
3131
|
+
o(E.command), u(!0);
|
|
3071
3132
|
}
|
|
3072
|
-
}, b = (
|
|
3073
|
-
Ut(
|
|
3074
|
-
}, M = (
|
|
3075
|
-
const
|
|
3076
|
-
|
|
3077
|
-
},
|
|
3078
|
-
!p ||
|
|
3133
|
+
}, b = (N) => {
|
|
3134
|
+
Ut(N.target) && N.preventDefault();
|
|
3135
|
+
}, M = (N) => {
|
|
3136
|
+
const E = Ut(N.target);
|
|
3137
|
+
E && (N.preventDefault(), g(E));
|
|
3138
|
+
}, S = (N) => {
|
|
3139
|
+
!p || Wt(N, x) || Wt(N, t) || I();
|
|
3079
3140
|
}, A = n.registerCommand(
|
|
3080
|
-
|
|
3141
|
+
an,
|
|
3081
3142
|
() => (u(), !1),
|
|
3082
3143
|
U
|
|
3083
3144
|
), O = n.registerUpdateListener(() => {
|
|
3084
3145
|
u();
|
|
3085
|
-
}),
|
|
3086
|
-
|
|
3087
|
-
(
|
|
3146
|
+
}), W = n.registerCommand(
|
|
3147
|
+
sn,
|
|
3148
|
+
(N) => p ? (N == null || N.preventDefault(), I(), !0) : !1,
|
|
3088
3149
|
U
|
|
3089
3150
|
);
|
|
3090
|
-
return
|
|
3091
|
-
P(), A(), O(),
|
|
3151
|
+
return x.addEventListener("pointerdown", b), x.addEventListener("click", M), document.addEventListener("pointerdown", S, !0), () => {
|
|
3152
|
+
P(), A(), O(), W(), x.removeEventListener("pointerdown", b), x.removeEventListener("click", M), document.removeEventListener("pointerdown", S, !0), _(), m == null || m.destroy(), y.remove(), x.remove();
|
|
3092
3153
|
};
|
|
3093
|
-
},
|
|
3154
|
+
}, Ki = (e) => e.metaKey || e.ctrlKey, Gi = {
|
|
3094
3155
|
b: { type: "format.bold" },
|
|
3095
3156
|
i: { type: "format.italic" },
|
|
3096
3157
|
u: { type: "format.underline" },
|
|
3097
3158
|
"\\": { type: "format.clear" }
|
|
3098
|
-
},
|
|
3159
|
+
}, Xi = {
|
|
3099
3160
|
x: { type: "format.strike" },
|
|
3100
3161
|
l: { type: "align", value: "left" },
|
|
3101
3162
|
e: { type: "align", value: "center" },
|
|
3102
3163
|
r: { type: "align", value: "right" },
|
|
3103
3164
|
j: { type: "align", value: "justify" }
|
|
3104
|
-
},
|
|
3165
|
+
}, Yi = {
|
|
3105
3166
|
0: { type: "block.paragraph" },
|
|
3106
3167
|
1: { type: "block.heading", level: 1 },
|
|
3107
3168
|
2: { type: "block.heading", level: 2 },
|
|
@@ -3109,30 +3170,30 @@ const On = {
|
|
|
3109
3170
|
4: { type: "block.heading", level: 4 },
|
|
3110
3171
|
5: { type: "block.heading", level: 5 },
|
|
3111
3172
|
6: { type: "block.heading", level: 6 }
|
|
3112
|
-
},
|
|
3173
|
+
}, Ji = (e) => {
|
|
3113
3174
|
const t = e.key.toLowerCase(), n = e.code;
|
|
3114
|
-
if (!e.metaKey && !e.ctrlKey && !e.altKey && !e.shiftKey || !
|
|
3175
|
+
if (!e.metaKey && !e.ctrlKey && !e.altKey && !e.shiftKey || !Ki(e)) return null;
|
|
3115
3176
|
if (e.altKey) {
|
|
3116
3177
|
if (e.shiftKey) return null;
|
|
3117
3178
|
if (t === "c" || n === "KeyC") return { type: "block.code" };
|
|
3118
3179
|
const r = n.startsWith("Digit") ? n.slice(5) : t;
|
|
3119
|
-
return
|
|
3180
|
+
return Yi[r] ?? null;
|
|
3120
3181
|
}
|
|
3121
|
-
return e.shiftKey ? t === "z" ? { type: "history.redo" } : t === "." || t === ">" || n === "Period" ? { type: "block.quote" } : t === "7" || t === "&" || n === "Digit7" ? { type: "list.ordered" } : t === "8" || t === "*" || n === "Digit8" ? { type: "list.unordered" } : t === "9" || t === "(" || n === "Digit9" ? { type: "list.todo" } : t === "-" || t === "_" || n === "Minus" ? { type: "block.divider" } :
|
|
3122
|
-
},
|
|
3182
|
+
return e.shiftKey ? t === "z" ? { type: "history.redo" } : t === "." || t === ">" || n === "Period" ? { type: "block.quote" } : t === "7" || t === "&" || n === "Digit7" ? { type: "list.ordered" } : t === "8" || t === "*" || n === "Digit8" ? { type: "list.unordered" } : t === "9" || t === "(" || n === "Digit9" ? { type: "list.todo" } : t === "-" || t === "_" || n === "Minus" ? { type: "block.divider" } : Xi[t] ?? null : t === "z" ? { type: "history.undo" } : t === "y" && e.ctrlKey && !e.metaKey ? { type: "history.redo" } : t === "`" || t === "~" || n === "Backquote" ? { type: "format.inlineCode" } : Gi[t] ?? null;
|
|
3183
|
+
}, Qi = ({
|
|
3123
3184
|
target: e,
|
|
3124
3185
|
isReadonly: t,
|
|
3125
3186
|
executeCommand: n
|
|
3126
3187
|
}) => {
|
|
3127
3188
|
const r = (o) => {
|
|
3128
3189
|
if (t()) return;
|
|
3129
|
-
const a =
|
|
3190
|
+
const a = Ji(o);
|
|
3130
3191
|
a && (o.preventDefault(), n(a));
|
|
3131
3192
|
};
|
|
3132
3193
|
return e.addEventListener("keydown", r), () => {
|
|
3133
3194
|
e.removeEventListener("keydown", r);
|
|
3134
3195
|
};
|
|
3135
|
-
},
|
|
3196
|
+
}, Zi = (e, t) => {
|
|
3136
3197
|
const n = t.offsetTop, r = n + t.offsetHeight, o = e.scrollTop, a = o + e.clientHeight;
|
|
3137
3198
|
if (n < o) {
|
|
3138
3199
|
e.scrollTop = n;
|
|
@@ -3147,7 +3208,7 @@ const On = {
|
|
|
3147
3208
|
if (o) return o;
|
|
3148
3209
|
}
|
|
3149
3210
|
return null;
|
|
3150
|
-
},
|
|
3211
|
+
}, Wn = ({
|
|
3151
3212
|
editorRoot: e,
|
|
3152
3213
|
contentElement: t,
|
|
3153
3214
|
editor: n,
|
|
@@ -3164,66 +3225,66 @@ const On = {
|
|
|
3164
3225
|
onSelect: T
|
|
3165
3226
|
}) => {
|
|
3166
3227
|
let f = null, y = 0;
|
|
3167
|
-
const
|
|
3228
|
+
const x = V(o, {
|
|
3168
3229
|
targetSelector: s
|
|
3169
|
-
}), m =
|
|
3230
|
+
}), m = Fn(a, o, {
|
|
3170
3231
|
placement: "bottom-start",
|
|
3171
3232
|
offset: 2,
|
|
3172
3233
|
strategy: "fixed"
|
|
3173
3234
|
});
|
|
3174
3235
|
e.append(a, o);
|
|
3175
3236
|
const p = () => {
|
|
3176
|
-
const
|
|
3177
|
-
return
|
|
3237
|
+
const E = f ? d(f.trigger) ?? Je() : Je(), B = t.getBoundingClientRect();
|
|
3238
|
+
return E ?? B;
|
|
3178
3239
|
}, k = () => {
|
|
3179
|
-
const
|
|
3180
|
-
a.style.left = `${
|
|
3181
|
-
}, _ = (
|
|
3182
|
-
f = null, o.dataset.visible = "false",
|
|
3240
|
+
const E = p();
|
|
3241
|
+
a.style.left = `${E.left}px`, a.style.top = `${E.top}px`, a.style.height = `${E.height || 1}px`;
|
|
3242
|
+
}, _ = (E = !0) => {
|
|
3243
|
+
f = null, o.dataset.visible = "false", E && o.replaceChildren(), m.setOpen(!1);
|
|
3183
3244
|
}, P = () => {
|
|
3184
|
-
const
|
|
3185
|
-
|
|
3186
|
-
}, I = (
|
|
3187
|
-
!f || f.requestId !== B.requestId || (_(), T(
|
|
3245
|
+
const E = o.querySelector(`${s}[data-active="true"]`);
|
|
3246
|
+
E && Zi(o, E);
|
|
3247
|
+
}, I = (E, B) => {
|
|
3248
|
+
!f || f.requestId !== B.requestId || (_(), T(E, B.trigger));
|
|
3188
3249
|
}, L = () => {
|
|
3189
3250
|
if (!f) {
|
|
3190
3251
|
_();
|
|
3191
3252
|
return;
|
|
3192
3253
|
}
|
|
3193
|
-
const
|
|
3194
|
-
if ((w == null ? void 0 : w(
|
|
3254
|
+
const E = f, B = p();
|
|
3255
|
+
if ((w == null ? void 0 : w(E, {
|
|
3195
3256
|
anchorRect: B,
|
|
3196
3257
|
close: _,
|
|
3197
|
-
selectItem: (te) => I(te,
|
|
3258
|
+
selectItem: (te) => I(te, E)
|
|
3198
3259
|
})) === !0) {
|
|
3199
3260
|
o.replaceChildren(), o.dataset.visible = "false", m.setOpen(!1);
|
|
3200
3261
|
return;
|
|
3201
3262
|
}
|
|
3202
|
-
if (
|
|
3263
|
+
if (E.status === "success")
|
|
3203
3264
|
o.replaceChildren(
|
|
3204
|
-
...
|
|
3265
|
+
...E.items.map((te, ut) => h(te, ut, ut === E.activeIndex))
|
|
3205
3266
|
);
|
|
3206
3267
|
else {
|
|
3207
3268
|
const te = v == null ? void 0 : v(
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3269
|
+
E.status,
|
|
3270
|
+
E.trigger.query,
|
|
3271
|
+
E.error
|
|
3211
3272
|
);
|
|
3212
3273
|
o.replaceChildren(...te ? [te] : []);
|
|
3213
3274
|
}
|
|
3214
|
-
const
|
|
3215
|
-
o.dataset.visible = String(
|
|
3216
|
-
}, C = async (
|
|
3275
|
+
const X = o.children.length > 0;
|
|
3276
|
+
o.dataset.visible = String(X), k(), m.setOpen(X), P(), m.update();
|
|
3277
|
+
}, C = async (E, B) => {
|
|
3217
3278
|
let $;
|
|
3218
3279
|
try {
|
|
3219
|
-
$ = await Promise.resolve(l(
|
|
3220
|
-
} catch (
|
|
3280
|
+
$ = await Promise.resolve(l(E));
|
|
3281
|
+
} catch (X) {
|
|
3221
3282
|
(f == null ? void 0 : f.requestId) === B && (f = {
|
|
3222
3283
|
...f,
|
|
3223
3284
|
items: [],
|
|
3224
3285
|
activeIndex: 0,
|
|
3225
3286
|
status: "error",
|
|
3226
|
-
error:
|
|
3287
|
+
error: X
|
|
3227
3288
|
}, L());
|
|
3228
3289
|
return;
|
|
3229
3290
|
}
|
|
@@ -3239,58 +3300,58 @@ const On = {
|
|
|
3239
3300
|
_();
|
|
3240
3301
|
return;
|
|
3241
3302
|
}
|
|
3242
|
-
const
|
|
3243
|
-
if (!
|
|
3303
|
+
const E = n.getEditorState().read(c);
|
|
3304
|
+
if (!E) {
|
|
3244
3305
|
_(!1);
|
|
3245
3306
|
return;
|
|
3246
3307
|
}
|
|
3247
3308
|
y += 1, f = {
|
|
3248
|
-
trigger:
|
|
3309
|
+
trigger: E,
|
|
3249
3310
|
items: [],
|
|
3250
3311
|
activeIndex: 0,
|
|
3251
3312
|
requestId: y,
|
|
3252
3313
|
status: "loading",
|
|
3253
3314
|
error: void 0
|
|
3254
|
-
}, L(), C(
|
|
3315
|
+
}, L(), C(E.query, y);
|
|
3255
3316
|
}, u = () => {
|
|
3256
3317
|
if (!f || f.status !== "success") return !1;
|
|
3257
|
-
const
|
|
3258
|
-
return
|
|
3259
|
-
}, g = (
|
|
3318
|
+
const E = f.items[f.activeIndex], B = f.trigger;
|
|
3319
|
+
return E ? (_(), T(E, B), !0) : !1;
|
|
3320
|
+
}, g = (E) => !f || f.status !== "success" || f.items.length === 0 ? !1 : (f = {
|
|
3260
3321
|
...f,
|
|
3261
|
-
activeIndex: (f.activeIndex +
|
|
3262
|
-
}, L(), !0), b = (
|
|
3263
|
-
const B =
|
|
3264
|
-
!f || f.status !== "success" || Number.isNaN(
|
|
3265
|
-
}, M = (
|
|
3266
|
-
const B =
|
|
3267
|
-
B instanceof HTMLElement && B.closest(s) &&
|
|
3268
|
-
},
|
|
3322
|
+
activeIndex: (f.activeIndex + E + f.items.length) % f.items.length
|
|
3323
|
+
}, L(), !0), b = (E) => {
|
|
3324
|
+
const B = E.target, $ = B instanceof HTMLElement ? B.closest(s) : null, X = $ != null && $.dataset.index ? Number.parseInt($.dataset.index, 10) : Number.NaN;
|
|
3325
|
+
!f || f.status !== "success" || Number.isNaN(X) || (f = { ...f, activeIndex: X }, E.preventDefault(), u());
|
|
3326
|
+
}, M = (E) => {
|
|
3327
|
+
const B = E.target;
|
|
3328
|
+
B instanceof HTMLElement && B.closest(s) && E.preventDefault();
|
|
3329
|
+
}, S = n.registerUpdateListener(() => {
|
|
3269
3330
|
i();
|
|
3270
3331
|
}), A = n.registerCommand(
|
|
3271
|
-
|
|
3272
|
-
(
|
|
3332
|
+
gr,
|
|
3333
|
+
(E) => g(1) ? (E == null || E.preventDefault(), !0) : !1,
|
|
3273
3334
|
U
|
|
3274
3335
|
), O = n.registerCommand(
|
|
3275
|
-
|
|
3276
|
-
(
|
|
3336
|
+
hr,
|
|
3337
|
+
(E) => g(-1) ? (E == null || E.preventDefault(), !0) : !1,
|
|
3277
3338
|
U
|
|
3278
|
-
),
|
|
3279
|
-
|
|
3280
|
-
(
|
|
3339
|
+
), W = n.registerCommand(
|
|
3340
|
+
pr,
|
|
3341
|
+
(E) => u() ? (E == null || E.preventDefault(), !0) : !1,
|
|
3281
3342
|
U
|
|
3282
|
-
),
|
|
3283
|
-
|
|
3284
|
-
(
|
|
3343
|
+
), N = n.registerCommand(
|
|
3344
|
+
sn,
|
|
3345
|
+
(E) => f ? (E == null || E.preventDefault(), _(), !0) : !1,
|
|
3285
3346
|
U
|
|
3286
3347
|
);
|
|
3287
3348
|
return o.addEventListener("click", b), o.addEventListener("pointerdown", M), {
|
|
3288
3349
|
close: _,
|
|
3289
3350
|
destroy() {
|
|
3290
|
-
|
|
3351
|
+
S(), A(), O(), W(), N(), o.removeEventListener("click", b), o.removeEventListener("pointerdown", M), x(), m.destroy(), a.remove(), o.remove();
|
|
3291
3352
|
}
|
|
3292
3353
|
};
|
|
3293
|
-
},
|
|
3354
|
+
}, el = {
|
|
3294
3355
|
labelField: "label",
|
|
3295
3356
|
descriptionField: "description",
|
|
3296
3357
|
avatarField: "avatar",
|
|
@@ -3301,87 +3362,87 @@ const On = {
|
|
|
3301
3362
|
loadingText: "加载中",
|
|
3302
3363
|
emptyText: "没有匹配的提及",
|
|
3303
3364
|
errorText: "提及加载失败"
|
|
3304
|
-
},
|
|
3305
|
-
...
|
|
3365
|
+
}, tl = (e) => ({
|
|
3366
|
+
...el,
|
|
3306
3367
|
...e
|
|
3307
|
-
}),
|
|
3368
|
+
}), nl = (e, t) => {
|
|
3308
3369
|
var o;
|
|
3309
3370
|
const n = t.slice(5), r = (o = e.data) == null ? void 0 : o[n];
|
|
3310
3371
|
return typeof r == "string" && r ? r : void 0;
|
|
3311
|
-
},
|
|
3312
|
-
if (t.startsWith("data.")) return
|
|
3372
|
+
}, Me = (e, t) => {
|
|
3373
|
+
if (t.startsWith("data.")) return nl(e, t);
|
|
3313
3374
|
const n = t === "id" ? e.id : t === "label" ? e.label : t === "value" ? e.value : t === "avatar" ? e.avatar : e.description;
|
|
3314
3375
|
return typeof n == "string" && n ? n : void 0;
|
|
3315
|
-
},
|
|
3316
|
-
const n =
|
|
3376
|
+
}, rl = (e) => e.startsWith("@") ? e : `@${e}`, Un = (e, t) => {
|
|
3377
|
+
const n = Me(e, t.labelField) ?? e.label ?? e.value ?? e.id, r = t.showDescription ? Me(e, t.descriptionField) ?? e.description : void 0, o = t.showAvatar ? Me(e, t.avatarField) ?? e.avatar : void 0, a = t.showIcon && !o ? Me(e, t.iconField) : void 0;
|
|
3317
3378
|
return {
|
|
3318
3379
|
item: e,
|
|
3319
|
-
label:
|
|
3380
|
+
label: rl(n),
|
|
3320
3381
|
...r ? { description: r } : {},
|
|
3321
3382
|
...o ? { avatar: o } : {},
|
|
3322
3383
|
...a ? { icon: a } : {}
|
|
3323
3384
|
};
|
|
3324
|
-
},
|
|
3385
|
+
}, ol = (e, t) => e.map((n) => Un(n, t)), Qe = (e) => e instanceof G && e.getTextContent().startsWith(" "), al = (e) => {
|
|
3325
3386
|
const n = e.getTextContent().slice(1);
|
|
3326
3387
|
if (!n) {
|
|
3327
3388
|
e.remove();
|
|
3328
3389
|
return;
|
|
3329
3390
|
}
|
|
3330
3391
|
e.setTextContent(n);
|
|
3331
|
-
},
|
|
3392
|
+
}, sl = (e, t) => {
|
|
3332
3393
|
const n = e.getPreviousSibling(), r = e.getNextSibling(), o = Qe(r) ? r.getNextSibling() : r;
|
|
3333
|
-
if (Qe(r) &&
|
|
3394
|
+
if (Qe(r) && al(r), e.remove(), t) {
|
|
3334
3395
|
n == null || n.selectEnd();
|
|
3335
3396
|
return;
|
|
3336
3397
|
}
|
|
3337
3398
|
o == null || o.selectStart();
|
|
3338
|
-
},
|
|
3399
|
+
}, il = (e) => {
|
|
3339
3400
|
const t = R();
|
|
3340
3401
|
if (!D(t) || !t.isCollapsed()) return null;
|
|
3341
3402
|
const n = t.anchor, r = n.getNode();
|
|
3342
|
-
if (
|
|
3343
|
-
if (!(r instanceof
|
|
3403
|
+
if (Et(r)) return r;
|
|
3404
|
+
if (!(r instanceof G)) return null;
|
|
3344
3405
|
const o = r.getTextContentSize(), a = r.getPreviousSibling(), s = r.getNextSibling(), c = Qe(r) && n.offset === 1, d = e ? n.offset === 0 || c ? a : null : n.offset === o ? s : null;
|
|
3345
|
-
return
|
|
3346
|
-
},
|
|
3406
|
+
return Et(d) ? d : null;
|
|
3407
|
+
}, ll = (e, t, n) => {
|
|
3347
3408
|
const r = (a) => {
|
|
3348
3409
|
if (t()) return !1;
|
|
3349
|
-
const s =
|
|
3350
|
-
return s ? (
|
|
3410
|
+
const s = il(a);
|
|
3411
|
+
return s ? (sl(s, a), n(), !0) : !1;
|
|
3351
3412
|
}, o = (a, s) => {
|
|
3352
3413
|
const c = r(s);
|
|
3353
3414
|
return c && a.preventDefault(), c;
|
|
3354
3415
|
};
|
|
3355
3416
|
return [
|
|
3356
3417
|
e.registerCommand(
|
|
3357
|
-
|
|
3418
|
+
nn,
|
|
3358
3419
|
(a) => o(a, !0),
|
|
3359
|
-
|
|
3420
|
+
se
|
|
3360
3421
|
),
|
|
3361
3422
|
e.registerCommand(
|
|
3362
|
-
|
|
3423
|
+
rn,
|
|
3363
3424
|
(a) => o(a, !1),
|
|
3364
|
-
|
|
3425
|
+
se
|
|
3365
3426
|
),
|
|
3366
3427
|
e.registerCommand(
|
|
3367
|
-
|
|
3428
|
+
on,
|
|
3368
3429
|
(a) => r(a),
|
|
3369
|
-
|
|
3430
|
+
se
|
|
3370
3431
|
)
|
|
3371
3432
|
];
|
|
3372
|
-
},
|
|
3433
|
+
}, cl = /(?:^|\s)@([\p{L}\p{N}_-]*)$/u, jt = [
|
|
3373
3434
|
{ id: "bridgerte-team", label: "BridgeRTE Team", value: "bridgerte-team" },
|
|
3374
3435
|
{ id: "frontend", label: "Frontend", value: "frontend" },
|
|
3375
3436
|
{ id: "designer", label: "Designer", value: "designer" }
|
|
3376
|
-
],
|
|
3377
|
-
const t =
|
|
3378
|
-
return t ? jt.filter((n) =>
|
|
3379
|
-
},
|
|
3437
|
+
], dl = (e) => e.trim().toLowerCase(), ul = (e) => [e.label, e.value, e.description].filter(Boolean).join(" ").toLowerCase(), ml = (e) => {
|
|
3438
|
+
const t = dl(e);
|
|
3439
|
+
return t ? jt.filter((n) => ul(n).includes(t)) : jt;
|
|
3440
|
+
}, gl = () => {
|
|
3380
3441
|
const e = R();
|
|
3381
3442
|
if (!D(e) || !e.isCollapsed()) return null;
|
|
3382
3443
|
const t = e.anchor, n = t.getNode();
|
|
3383
|
-
if (!(n instanceof
|
|
3384
|
-
const o = n.getTextContent().slice(0, t.offset).match(
|
|
3444
|
+
if (!(n instanceof G)) return null;
|
|
3445
|
+
const o = n.getTextContent().slice(0, t.offset).match(cl);
|
|
3385
3446
|
if (!o) return null;
|
|
3386
3447
|
const a = o[1] ?? "", s = o[0] ?? "", c = s.startsWith("@") ? 0 : 1, d = t.offset - s.length + c;
|
|
3387
3448
|
return {
|
|
@@ -3390,19 +3451,19 @@ const On = {
|
|
|
3390
3451
|
startOffset: d,
|
|
3391
3452
|
endOffset: t.offset
|
|
3392
3453
|
};
|
|
3393
|
-
},
|
|
3454
|
+
}, hl = () => {
|
|
3394
3455
|
const e = document.createElement("div");
|
|
3395
3456
|
return e.className = "bridgerte__floating-menu bridgerte__mention-menu", e.dataset.visible = "false", e;
|
|
3396
|
-
},
|
|
3457
|
+
}, pl = () => {
|
|
3397
3458
|
const e = document.createElement("span");
|
|
3398
3459
|
return e.className = "bridgerte__mention-anchor", e.setAttribute("aria-hidden", "true"), e;
|
|
3399
|
-
},
|
|
3460
|
+
}, fl = (e, t) => {
|
|
3400
3461
|
var s;
|
|
3401
3462
|
const n = e.getElementByKey(t.nodeKey), r = it(n, t.startOffset + 1);
|
|
3402
3463
|
if (!(r instanceof Text)) return null;
|
|
3403
3464
|
const o = document.createRange(), a = Math.min(t.startOffset + 1, ((s = r.textContent) == null ? void 0 : s.length) ?? 0);
|
|
3404
3465
|
return a <= t.startOffset ? null : (o.setStart(r, t.startOffset), o.setEnd(r, a), o.getBoundingClientRect());
|
|
3405
|
-
},
|
|
3466
|
+
}, bl = (e, t, n) => {
|
|
3406
3467
|
const r = document.createElement("button"), o = document.createElement("span");
|
|
3407
3468
|
if (r.type = "button", r.className = "bridgerte__menu-item bridgerte__mention-item", r.dataset.mentionId = e.item.id, r.dataset.index = String(t), r.dataset.active = String(n), e.avatar) {
|
|
3408
3469
|
const a = document.createElement("img");
|
|
@@ -3416,10 +3477,10 @@ const On = {
|
|
|
3416
3477
|
a.className = "bridgerte__mention-item-description", a.textContent = e.description, r.append(a);
|
|
3417
3478
|
}
|
|
3418
3479
|
return r;
|
|
3419
|
-
},
|
|
3480
|
+
}, yl = (e, t) => {
|
|
3420
3481
|
const n = document.createElement("div");
|
|
3421
3482
|
return n.className = "bridgerte__mention-status", n.dataset.status = e, n.textContent = t, n;
|
|
3422
|
-
},
|
|
3483
|
+
}, vl = (e, t) => {
|
|
3423
3484
|
switch (e) {
|
|
3424
3485
|
case "loading":
|
|
3425
3486
|
return t.loadingText;
|
|
@@ -3428,12 +3489,12 @@ const On = {
|
|
|
3428
3489
|
case "error":
|
|
3429
3490
|
return t.errorText;
|
|
3430
3491
|
}
|
|
3431
|
-
},
|
|
3492
|
+
}, wl = (e) => e ? {
|
|
3432
3493
|
x: e.x,
|
|
3433
3494
|
y: e.y,
|
|
3434
3495
|
width: e.width,
|
|
3435
3496
|
height: e.height
|
|
3436
|
-
} : void 0,
|
|
3497
|
+
} : void 0, Cl = ({
|
|
3437
3498
|
editorRoot: e,
|
|
3438
3499
|
contentElement: t,
|
|
3439
3500
|
editor: n,
|
|
@@ -3443,12 +3504,12 @@ const On = {
|
|
|
3443
3504
|
mentionMenuConfig: s,
|
|
3444
3505
|
onMentionMenuRequest: c
|
|
3445
3506
|
}) => {
|
|
3446
|
-
const d =
|
|
3507
|
+
const d = hl(), l = pl(), h = tl(s), v = (f, y) => {
|
|
3447
3508
|
n.update(() => {
|
|
3448
|
-
const
|
|
3449
|
-
|
|
3509
|
+
const x = he(y.nodeKey);
|
|
3510
|
+
x instanceof G && (x.spliceText(y.startOffset, y.endOffset - y.startOffset, ""), x.select(y.startOffset, y.startOffset));
|
|
3450
3511
|
}), o({ type: "mention.insert", item: f });
|
|
3451
|
-
}, w =
|
|
3512
|
+
}, w = Wn({
|
|
3452
3513
|
editorRoot: e,
|
|
3453
3514
|
contentElement: t,
|
|
3454
3515
|
editor: n,
|
|
@@ -3456,18 +3517,18 @@ const On = {
|
|
|
3456
3517
|
menu: d,
|
|
3457
3518
|
anchor: l,
|
|
3458
3519
|
itemSelector: ".bridgerte__mention-item",
|
|
3459
|
-
getCurrentTrigger:
|
|
3460
|
-
getTriggerRect: (f) =>
|
|
3520
|
+
getCurrentTrigger: gl,
|
|
3521
|
+
getTriggerRect: (f) => fl(n, f),
|
|
3461
3522
|
resolveItems: async (f) => {
|
|
3462
3523
|
const y = await Promise.resolve(
|
|
3463
|
-
a ? a(f) :
|
|
3524
|
+
a ? a(f) : ml(f)
|
|
3464
3525
|
);
|
|
3465
|
-
return
|
|
3526
|
+
return ol(y, h);
|
|
3466
3527
|
},
|
|
3467
|
-
renderItem:
|
|
3468
|
-
renderStatus: (f) =>
|
|
3528
|
+
renderItem: bl,
|
|
3529
|
+
renderStatus: (f) => yl(
|
|
3469
3530
|
f,
|
|
3470
|
-
|
|
3531
|
+
vl(f, h)
|
|
3471
3532
|
),
|
|
3472
3533
|
onStateChange: c ? (f, y) => c({
|
|
3473
3534
|
id: `bridgerte-mention-menu-${f.requestId}`,
|
|
@@ -3476,21 +3537,21 @@ const On = {
|
|
|
3476
3537
|
items: f.items,
|
|
3477
3538
|
config: h,
|
|
3478
3539
|
readonly: r(),
|
|
3479
|
-
anchorRect:
|
|
3540
|
+
anchorRect: wl(y.anchorRect),
|
|
3480
3541
|
...f.error ? { error: f.error } : {},
|
|
3481
|
-
submit: (
|
|
3482
|
-
|
|
3542
|
+
submit: (x) => y.selectItem(
|
|
3543
|
+
Un(x, h)
|
|
3483
3544
|
),
|
|
3484
3545
|
cancel: y.close
|
|
3485
3546
|
}) : void 0,
|
|
3486
3547
|
onSelect: (f, y) => v(f.item, y)
|
|
3487
|
-
}), T =
|
|
3488
|
-
...
|
|
3548
|
+
}), T = ln(
|
|
3549
|
+
...ll(n, r, () => w.close(!1))
|
|
3489
3550
|
);
|
|
3490
3551
|
return () => {
|
|
3491
3552
|
T(), w.destroy();
|
|
3492
3553
|
};
|
|
3493
|
-
},
|
|
3554
|
+
}, _l = [
|
|
3494
3555
|
"script",
|
|
3495
3556
|
"style",
|
|
3496
3557
|
"iframe",
|
|
@@ -3507,7 +3568,7 @@ const On = {
|
|
|
3507
3568
|
"button",
|
|
3508
3569
|
"select",
|
|
3509
3570
|
"textarea"
|
|
3510
|
-
].join(","),
|
|
3571
|
+
].join(","), kl = [
|
|
3511
3572
|
".bridgerte__code-header",
|
|
3512
3573
|
".bridgerte__code-block-control",
|
|
3513
3574
|
".bridgerte__code-block-controls-layer",
|
|
@@ -3520,7 +3581,7 @@ const On = {
|
|
|
3520
3581
|
".bridgerte__dialog",
|
|
3521
3582
|
".bridgerte__payload-panel",
|
|
3522
3583
|
'[data-bridgerte-clipboard-ui="true"]'
|
|
3523
|
-
].join(","),
|
|
3584
|
+
].join(","), El = /* @__PURE__ */ new Set([
|
|
3524
3585
|
"A",
|
|
3525
3586
|
"B",
|
|
3526
3587
|
"BLOCKQUOTE",
|
|
@@ -3557,16 +3618,16 @@ const On = {
|
|
|
3557
3618
|
"TT",
|
|
3558
3619
|
"U",
|
|
3559
3620
|
"UL"
|
|
3560
|
-
]),
|
|
3621
|
+
]), xl = /* @__PURE__ */ new Set(["http:", "https:", "mailto:"]), Ml = "p,div,blockquote,pre,h1,h2,h3,h4,h5,h6,ul,ol,table", Tl = "p,blockquote,pre,h1,h2,h3,h4,h5,h6,ul,ol,table", Ll = /* @__PURE__ */ new Set(["colspan", "rowspan"]), Nl = /* @__PURE__ */ new Set(["TD", "TH"]), Sl = /* @__PURE__ */ new Set(["M", "O", "V", "W"]), Pl = /* @__PURE__ */ new Set(["SPAN"]), Il = /* @__PURE__ */ new Set(["color", "background-color"]), Rl = /^#([\da-f]{3}|[\da-f]{6}|[\da-f]{8})$/i, qt = /* @__PURE__ */ new Map([
|
|
3561
3622
|
["B", "strong"],
|
|
3562
3623
|
["DEL", "s"],
|
|
3563
3624
|
["I", "em"],
|
|
3564
3625
|
["STRIKE", "s"],
|
|
3565
3626
|
["TT", "code"]
|
|
3566
|
-
]),
|
|
3627
|
+
]), Al = (e) => {
|
|
3567
3628
|
try {
|
|
3568
3629
|
const t = new URL(e, window.location.href);
|
|
3569
|
-
return
|
|
3630
|
+
return xl.has(t.protocol);
|
|
3570
3631
|
} catch {
|
|
3571
3632
|
return !1;
|
|
3572
3633
|
}
|
|
@@ -3575,18 +3636,18 @@ const On = {
|
|
|
3575
3636
|
}, ct = (e, t) => {
|
|
3576
3637
|
const n = e.ownerDocument.createElement(t);
|
|
3577
3638
|
return n.append(...e.childNodes), e.replaceWith(n), n;
|
|
3578
|
-
},
|
|
3639
|
+
}, Bl = (e) => {
|
|
3579
3640
|
const t = e.tagName.split(":")[0] ?? "";
|
|
3580
|
-
return e.tagName.includes(":") &&
|
|
3581
|
-
},
|
|
3641
|
+
return e.tagName.includes(":") && Sl.has(t);
|
|
3642
|
+
}, jn = (e) => {
|
|
3582
3643
|
[...e.childNodes].forEach((t) => {
|
|
3583
3644
|
if (t.nodeType === Node.COMMENT_NODE) {
|
|
3584
3645
|
t.remove();
|
|
3585
3646
|
return;
|
|
3586
3647
|
}
|
|
3587
|
-
|
|
3648
|
+
jn(t);
|
|
3588
3649
|
});
|
|
3589
|
-
},
|
|
3650
|
+
}, qn = (e) => {
|
|
3590
3651
|
[...e.childNodes].forEach((t) => {
|
|
3591
3652
|
if (t.nodeType === Node.TEXT_NODE) {
|
|
3592
3653
|
const n = t.parentElement, r = !!(n != null && n.closest("pre,code,textarea")), o = (t.textContent ?? "").replace(/[\u200B-\u200D\uFEFF]/g, "").replace(/\u00A0/g, r ? " " : " ");
|
|
@@ -3598,24 +3659,24 @@ const On = {
|
|
|
3598
3659
|
t.previousSibling || (a = a.trimStart()), t.nextSibling || (a = a.trimEnd()), t.textContent = a;
|
|
3599
3660
|
return;
|
|
3600
3661
|
}
|
|
3601
|
-
|
|
3662
|
+
qn(t);
|
|
3602
3663
|
});
|
|
3603
|
-
},
|
|
3604
|
-
const t = e.trim().toLowerCase(), [, n] = t.match(
|
|
3664
|
+
}, Dl = (e) => /^[1-9]\d*$/.test(e.trim()), dt = (e) => {
|
|
3665
|
+
const t = e.trim().toLowerCase(), [, n] = t.match(Rl) ?? [];
|
|
3605
3666
|
return n ? n.length === 8 ? `#${n.slice(2)}` : t : null;
|
|
3606
|
-
},
|
|
3607
|
-
if (!
|
|
3667
|
+
}, Ol = (e, t) => {
|
|
3668
|
+
if (!Pl.has(e)) return null;
|
|
3608
3669
|
const n = t.split(";").flatMap((r) => {
|
|
3609
3670
|
const [o, ...a] = r.split(":"), s = o == null ? void 0 : o.trim().toLowerCase(), c = dt(a.join(":"));
|
|
3610
|
-
return !s || !c || !
|
|
3671
|
+
return !s || !c || !Il.has(s) ? [] : [`${s}: ${c}`];
|
|
3611
3672
|
});
|
|
3612
3673
|
return n.length > 0 ? `${n.join("; ")};` : null;
|
|
3613
|
-
},
|
|
3614
|
-
if (
|
|
3674
|
+
}, Hl = (e) => {
|
|
3675
|
+
if (Bl(e)) {
|
|
3615
3676
|
e.remove();
|
|
3616
3677
|
return;
|
|
3617
3678
|
}
|
|
3618
|
-
if (!
|
|
3679
|
+
if (!El.has(e.tagName)) {
|
|
3619
3680
|
lt(e);
|
|
3620
3681
|
return;
|
|
3621
3682
|
}
|
|
@@ -3626,7 +3687,7 @@ const On = {
|
|
|
3626
3687
|
return;
|
|
3627
3688
|
}
|
|
3628
3689
|
if (n === "style") {
|
|
3629
|
-
const r =
|
|
3690
|
+
const r = Ol(e.tagName, t.value);
|
|
3630
3691
|
if (r) {
|
|
3631
3692
|
e.setAttribute(t.name, r);
|
|
3632
3693
|
return;
|
|
@@ -3635,13 +3696,13 @@ const On = {
|
|
|
3635
3696
|
return;
|
|
3636
3697
|
}
|
|
3637
3698
|
if (e.tagName === "A" && n === "href") {
|
|
3638
|
-
if (
|
|
3699
|
+
if (Al(t.value)) return;
|
|
3639
3700
|
e.removeAttribute(t.name);
|
|
3640
3701
|
return;
|
|
3641
3702
|
}
|
|
3642
3703
|
if (!(e.tagName === "A" && ["target", "rel", "title"].includes(n))) {
|
|
3643
|
-
if (e.tagName === "PRE" && n ===
|
|
3644
|
-
const r =
|
|
3704
|
+
if (e.tagName === "PRE" && n === Ae) {
|
|
3705
|
+
const r = ee(t.value);
|
|
3645
3706
|
if (r) {
|
|
3646
3707
|
e.setAttribute(t.name, r);
|
|
3647
3708
|
return;
|
|
@@ -3654,39 +3715,39 @@ const On = {
|
|
|
3654
3715
|
e.removeAttribute(t.name);
|
|
3655
3716
|
return;
|
|
3656
3717
|
}
|
|
3657
|
-
|
|
3718
|
+
Nl.has(e.tagName) && Ll.has(n) && Dl(t.value) || e.removeAttribute(t.name);
|
|
3658
3719
|
}
|
|
3659
3720
|
});
|
|
3660
|
-
},
|
|
3721
|
+
}, $l = (e) => {
|
|
3661
3722
|
[...e.querySelectorAll("font")].forEach((t) => {
|
|
3662
3723
|
const n = t.getAttribute("color"), r = n ? dt(n) : null, o = ct(t, "span");
|
|
3663
3724
|
r && o.setAttribute("style", `color: ${r};`);
|
|
3664
3725
|
});
|
|
3665
|
-
},
|
|
3726
|
+
}, Fl = (e) => {
|
|
3666
3727
|
[...e.querySelectorAll([...qt.keys()].join(","))].forEach((t) => {
|
|
3667
3728
|
const n = qt.get(t.tagName);
|
|
3668
3729
|
n && ct(t, n);
|
|
3669
3730
|
});
|
|
3670
|
-
},
|
|
3731
|
+
}, zl = (e) => {
|
|
3671
3732
|
[...e.querySelectorAll("div")].reverse().forEach((t) => {
|
|
3672
|
-
if (t.querySelector(
|
|
3733
|
+
if (t.querySelector(Tl)) {
|
|
3673
3734
|
lt(t);
|
|
3674
3735
|
return;
|
|
3675
3736
|
}
|
|
3676
3737
|
ct(t, "p");
|
|
3677
3738
|
});
|
|
3678
|
-
},
|
|
3739
|
+
}, Vl = (e) => {
|
|
3679
3740
|
[...e.querySelectorAll("span")].forEach((t) => {
|
|
3680
3741
|
t.attributes.length === 0 && lt(t);
|
|
3681
3742
|
});
|
|
3682
|
-
},
|
|
3743
|
+
}, Wl = (e) => !["P", "DIV", "SPAN"].includes(e.tagName) || e.querySelector("br,table,ul,ol") ? !1 : !(e.textContent ?? "").trim(), Kt = (e) => {
|
|
3683
3744
|
[...e.querySelectorAll("p,div,span")].reverse().forEach((t) => {
|
|
3684
|
-
|
|
3745
|
+
Wl(t) && t.remove();
|
|
3685
3746
|
});
|
|
3686
|
-
},
|
|
3747
|
+
}, Ul = (e) => {
|
|
3687
3748
|
var t;
|
|
3688
|
-
return e.nodeType === Node.TEXT_NODE ? !!((t = e.textContent) != null && t.trim()) : e.nodeType !== Node.ELEMENT_NODE ? !1 : !e.matches(
|
|
3689
|
-
},
|
|
3749
|
+
return e.nodeType === Node.TEXT_NODE ? !!((t = e.textContent) != null && t.trim()) : e.nodeType !== Node.ELEMENT_NODE ? !1 : !e.matches(Ml);
|
|
3750
|
+
}, jl = (e) => {
|
|
3690
3751
|
let t = [];
|
|
3691
3752
|
const n = () => {
|
|
3692
3753
|
if (t.length === 0) return;
|
|
@@ -3701,47 +3762,47 @@ const On = {
|
|
|
3701
3762
|
r.remove();
|
|
3702
3763
|
return;
|
|
3703
3764
|
}
|
|
3704
|
-
if (
|
|
3765
|
+
if (Ul(r)) {
|
|
3705
3766
|
t.push(r);
|
|
3706
3767
|
return;
|
|
3707
3768
|
}
|
|
3708
3769
|
n();
|
|
3709
3770
|
}), n();
|
|
3710
|
-
},
|
|
3771
|
+
}, ql = (e) => {
|
|
3711
3772
|
const t = document.createElement("template");
|
|
3712
|
-
t.innerHTML = e, t.content.querySelectorAll(
|
|
3773
|
+
t.innerHTML = e, t.content.querySelectorAll(_l).forEach((r) => {
|
|
3713
3774
|
r.remove();
|
|
3714
|
-
}), t.content.querySelectorAll(
|
|
3775
|
+
}), t.content.querySelectorAll(kl).forEach((r) => {
|
|
3715
3776
|
r.remove();
|
|
3716
|
-
}),
|
|
3777
|
+
}), jn(t.content), Ja(t.content), [...t.content.querySelectorAll("*")].forEach(Hl), qn(t.content), $l(t.content), Fl(t.content), zl(t.content), Vl(t.content), Kt(t.content);
|
|
3717
3778
|
const n = document.createElement("div");
|
|
3718
|
-
return n.append(t.content.cloneNode(!0)),
|
|
3719
|
-
},
|
|
3779
|
+
return n.append(t.content.cloneNode(!0)), jl(n), Kt(n), n.innerHTML;
|
|
3780
|
+
}, Kl = /^https?:\/\/[^\s<>"']+\.[^\s<>"']+$/i, Gl = /^www\.[^\s<>"']+\.[^\s<>"']+$/i, Xl = new RegExp(
|
|
3720
3781
|
`^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+(?:/[^\\s<>"']*)?$`,
|
|
3721
3782
|
"i"
|
|
3722
|
-
),
|
|
3723
|
-
const n =
|
|
3783
|
+
), Yl = /^[^\s@]+@[^\s@]+\.[^\s@]+$/i, Jl = /^\s*```([a-z0-9_+#.-]+)\s*\n([\s\S]*?)\n?```\s*$/i, Ql = (e) => e.type.startsWith("image/") ? "image" : e.type.startsWith("video/") ? "video" : null, Kn = (e) => e ? [...e].flatMap((t) => {
|
|
3784
|
+
const n = Ql(t);
|
|
3724
3785
|
return n ? [{ type: n, file: t }] : [];
|
|
3725
|
-
}) : [],
|
|
3786
|
+
}) : [], Be = (e) => ({
|
|
3726
3787
|
text: (e == null ? void 0 : e.getData("text/plain")) ?? "",
|
|
3727
3788
|
html: (e == null ? void 0 : e.getData("text/html")) ?? "",
|
|
3728
3789
|
files: e != null && e.files ? [...e.files] : []
|
|
3729
|
-
}),
|
|
3790
|
+
}), Zl = (e) => ({
|
|
3730
3791
|
name: e.name,
|
|
3731
3792
|
mimeType: e.type || void 0,
|
|
3732
3793
|
size: e.size,
|
|
3733
3794
|
data: e
|
|
3734
|
-
}),
|
|
3795
|
+
}), ec = (e) => {
|
|
3735
3796
|
const [, t, n] = e.replace(/\r\n/g, `
|
|
3736
|
-
`).match(
|
|
3797
|
+
`).match(Jl) ?? [], r = ee(t);
|
|
3737
3798
|
return n !== void 0 && r !== null ? { code: n, language: r } : null;
|
|
3738
|
-
},
|
|
3799
|
+
}, tc = (e) => {
|
|
3739
3800
|
const t = e.trim();
|
|
3740
|
-
return !t || /\s/.test(t) || t.includes("<") || t.includes(">") || /^[a-z][a-z0-9+.-]*:/i.test(t) && !/^https?:\/\//i.test(t) ||
|
|
3741
|
-
},
|
|
3801
|
+
return !t || /\s/.test(t) || t.includes("<") || t.includes(">") || /^[a-z][a-z0-9+.-]*:/i.test(t) && !/^https?:\/\//i.test(t) || Yl.test(t) ? !1 : Kl.test(t) || Gl.test(t) || Xl.test(t);
|
|
3802
|
+
}, Gn = (e, {
|
|
3742
3803
|
isReadonly: t,
|
|
3743
3804
|
executeCommand: n
|
|
3744
|
-
}) => t() || !
|
|
3805
|
+
}) => t() || !tc(e.text) ? !1 : (n({
|
|
3745
3806
|
type: "link.set",
|
|
3746
3807
|
href: e.text.trim()
|
|
3747
3808
|
}), !0), Ze = (e, {
|
|
@@ -3750,86 +3811,86 @@ const On = {
|
|
|
3750
3811
|
uploadMediaFile: r
|
|
3751
3812
|
}) => {
|
|
3752
3813
|
if (t() || !n()) return !1;
|
|
3753
|
-
const o =
|
|
3814
|
+
const o = Kn(e.files);
|
|
3754
3815
|
return o.length === 0 ? !1 : (o.forEach(({ type: a, file: s }) => {
|
|
3755
3816
|
r(a, s);
|
|
3756
3817
|
}), !0);
|
|
3757
|
-
},
|
|
3818
|
+
}, nc = (e, t) => {
|
|
3758
3819
|
const r = new DOMParser().parseFromString(t, "text/html");
|
|
3759
|
-
|
|
3760
|
-
const o =
|
|
3761
|
-
return
|
|
3762
|
-
},
|
|
3763
|
-
const n =
|
|
3820
|
+
Qa(r.body);
|
|
3821
|
+
const o = mn(e, r);
|
|
3822
|
+
return Za(o, r.body), o;
|
|
3823
|
+
}, rc = (e, t) => {
|
|
3824
|
+
const n = nc(e, t);
|
|
3764
3825
|
if (n.length === 0) return !1;
|
|
3765
3826
|
if (R() || H().selectEnd(), n.some(K)) {
|
|
3766
3827
|
n.forEach((o) => {
|
|
3767
|
-
|
|
3828
|
+
gn(o);
|
|
3768
3829
|
});
|
|
3769
3830
|
const r = n[n.length - 1];
|
|
3770
3831
|
return r && K(r) && z([F()]), !0;
|
|
3771
3832
|
}
|
|
3772
3833
|
return z(n), !0;
|
|
3773
|
-
},
|
|
3834
|
+
}, oc = (e, {
|
|
3774
3835
|
editor: t,
|
|
3775
3836
|
isReadonly: n
|
|
3776
3837
|
}) => {
|
|
3777
3838
|
if (n()) return !1;
|
|
3778
|
-
if (!e.html.trim()) return
|
|
3779
|
-
const r =
|
|
3839
|
+
if (!e.html.trim()) return sc(e, { editor: t, isReadonly: n });
|
|
3840
|
+
const r = ql(e.html);
|
|
3780
3841
|
return r.trim() ? (t.update(() => {
|
|
3781
|
-
|
|
3842
|
+
rc(t, r);
|
|
3782
3843
|
}), !0) : !1;
|
|
3783
|
-
},
|
|
3844
|
+
}, ac = (e, {
|
|
3784
3845
|
editor: t,
|
|
3785
3846
|
isReadonly: n
|
|
3786
3847
|
}) => {
|
|
3787
3848
|
if (n() || e.html.trim() || !e.text.trim()) return !1;
|
|
3788
|
-
const r =
|
|
3849
|
+
const r = ec(e.text);
|
|
3789
3850
|
return r ? (t.update(() => {
|
|
3790
|
-
const o =
|
|
3791
|
-
R() || H().selectEnd(), o.append(
|
|
3851
|
+
const o = En(r.language || void 0), a = F();
|
|
3852
|
+
R() || H().selectEnd(), o.append(Ie(r.code)), gn(o), z([a]), a.selectStart();
|
|
3792
3853
|
}), !0) : !1;
|
|
3793
|
-
},
|
|
3854
|
+
}, sc = (e, {
|
|
3794
3855
|
editor: t,
|
|
3795
3856
|
isReadonly: n
|
|
3796
3857
|
}) => n() || e.html.trim() || !e.text ? !1 : (t.update(() => {
|
|
3797
|
-
R() || H().selectEnd(), z([
|
|
3798
|
-
}), !0),
|
|
3858
|
+
R() || H().selectEnd(), z([Ie(e.text)]);
|
|
3859
|
+
}), !0), Xn = (e, t) => ac(e, t) || oc(e, t), Z = (e) => {
|
|
3799
3860
|
e.preventDefault(), e.stopImmediatePropagation();
|
|
3800
|
-
},
|
|
3861
|
+
}, ic = (e, t) => Ze(e, t) || Gn(e, t) || Xn(e, t), lc = (e) => {
|
|
3801
3862
|
const t = (n) => {
|
|
3802
|
-
n.defaultPrevented ||
|
|
3863
|
+
n.defaultPrevented || Gn(Be(n.clipboardData), e) && Z(n);
|
|
3803
3864
|
};
|
|
3804
3865
|
return e.target.addEventListener("paste", t, { capture: !0 }), () => {
|
|
3805
3866
|
e.target.removeEventListener("paste", t, { capture: !0 });
|
|
3806
3867
|
};
|
|
3807
|
-
},
|
|
3868
|
+
}, cc = (e) => {
|
|
3808
3869
|
const t = (o) => {
|
|
3809
|
-
o.defaultPrevented || Ze(
|
|
3870
|
+
o.defaultPrevented || Ze(Be(o.clipboardData), e) && Z(o);
|
|
3810
3871
|
}, n = (o) => {
|
|
3811
3872
|
var s;
|
|
3812
3873
|
if (e.isReadonly() || !e.canUploadMedia()) return;
|
|
3813
3874
|
const a = (s = o.dataTransfer) != null && s.files ? [...o.dataTransfer.files] : [];
|
|
3814
|
-
|
|
3875
|
+
Kn(a).length !== 0 && (o.preventDefault(), o.dataTransfer && (o.dataTransfer.dropEffect = "copy"));
|
|
3815
3876
|
}, r = (o) => {
|
|
3816
3877
|
var s;
|
|
3817
3878
|
const a = {
|
|
3818
3879
|
files: (s = o.dataTransfer) != null && s.files ? [...o.dataTransfer.files] : []
|
|
3819
3880
|
};
|
|
3820
|
-
Ze(a, e) &&
|
|
3881
|
+
Ze(a, e) && Z(o);
|
|
3821
3882
|
};
|
|
3822
3883
|
return e.target.addEventListener("paste", t, { capture: !0 }), e.target.addEventListener("dragover", n), e.target.addEventListener("drop", r), () => {
|
|
3823
3884
|
e.target.removeEventListener("paste", t, { capture: !0 }), e.target.removeEventListener("dragover", n), e.target.removeEventListener("drop", r);
|
|
3824
3885
|
};
|
|
3825
|
-
},
|
|
3886
|
+
}, dc = (e) => {
|
|
3826
3887
|
const t = (n) => {
|
|
3827
|
-
n.defaultPrevented || !
|
|
3888
|
+
n.defaultPrevented || !Xn(Be(n.clipboardData), e) || Z(n);
|
|
3828
3889
|
};
|
|
3829
3890
|
return e.target.addEventListener("paste", t, { capture: !0 }), () => {
|
|
3830
3891
|
e.target.removeEventListener("paste", t, { capture: !0 });
|
|
3831
3892
|
};
|
|
3832
|
-
},
|
|
3893
|
+
}, uc = ({
|
|
3833
3894
|
target: e,
|
|
3834
3895
|
isReadonly: t,
|
|
3835
3896
|
onPaste: n,
|
|
@@ -3838,7 +3899,7 @@ const On = {
|
|
|
3838
3899
|
executeCommand: a,
|
|
3839
3900
|
editor: s
|
|
3840
3901
|
}) => {
|
|
3841
|
-
const c = (l, h) =>
|
|
3902
|
+
const c = (l, h) => ic({
|
|
3842
3903
|
text: h.text ?? l.text,
|
|
3843
3904
|
html: h.html ?? l.html,
|
|
3844
3905
|
files: l.files
|
|
@@ -3850,27 +3911,27 @@ const On = {
|
|
|
3850
3911
|
editor: s
|
|
3851
3912
|
}), d = (l) => {
|
|
3852
3913
|
if (t() || !n) return;
|
|
3853
|
-
const h =
|
|
3914
|
+
const h = Be(l.clipboardData), v = n({
|
|
3854
3915
|
text: h.text,
|
|
3855
3916
|
html: h.html,
|
|
3856
|
-
files: h.files.map(
|
|
3917
|
+
files: h.files.map(Zl)
|
|
3857
3918
|
});
|
|
3858
3919
|
if (v instanceof Promise) {
|
|
3859
|
-
|
|
3920
|
+
Z(l), v.then((w) => {
|
|
3860
3921
|
w !== !0 && w && c(h, w);
|
|
3861
3922
|
});
|
|
3862
3923
|
return;
|
|
3863
3924
|
}
|
|
3864
3925
|
if (v === !0) {
|
|
3865
|
-
|
|
3926
|
+
Z(l);
|
|
3866
3927
|
return;
|
|
3867
3928
|
}
|
|
3868
|
-
v && (
|
|
3929
|
+
v && (Z(l), c(h, v));
|
|
3869
3930
|
};
|
|
3870
3931
|
return e.addEventListener("paste", d, { capture: !0 }), () => {
|
|
3871
3932
|
e.removeEventListener("paste", d, { capture: !0 });
|
|
3872
3933
|
};
|
|
3873
|
-
},
|
|
3934
|
+
}, mc = [
|
|
3874
3935
|
"paragraph",
|
|
3875
3936
|
"heading-1",
|
|
3876
3937
|
"heading-2",
|
|
@@ -3884,18 +3945,18 @@ const On = {
|
|
|
3884
3945
|
"upload-image",
|
|
3885
3946
|
"upload-video",
|
|
3886
3947
|
"table"
|
|
3887
|
-
],
|
|
3948
|
+
], gc = {
|
|
3888
3949
|
showIcon: !0,
|
|
3889
3950
|
loadingText: "加载中",
|
|
3890
3951
|
emptyText: "没有匹配的命令",
|
|
3891
3952
|
errorText: "命令加载失败"
|
|
3892
|
-
},
|
|
3893
|
-
...
|
|
3953
|
+
}, hc = (e) => ({
|
|
3954
|
+
...gc,
|
|
3894
3955
|
...e
|
|
3895
|
-
}),
|
|
3956
|
+
}), pc = (e) => e.flatMap((t) => t.type === "button" ? [t.item] : t.type === "group" ? t.items : []), fc = (e) => ({
|
|
3896
3957
|
...e,
|
|
3897
|
-
toolbarKeys: (e == null ? void 0 : e.toolbarKeys) ??
|
|
3898
|
-
}),
|
|
3958
|
+
toolbarKeys: (e == null ? void 0 : e.toolbarKeys) ?? mc
|
|
3959
|
+
}), bc = (e) => ({
|
|
3899
3960
|
id: e.id,
|
|
3900
3961
|
label: e.label,
|
|
3901
3962
|
command: e.command,
|
|
@@ -3903,24 +3964,24 @@ const On = {
|
|
|
3903
3964
|
requiresPayload: e.requiresPayload,
|
|
3904
3965
|
payloadPanel: e.payloadPanel,
|
|
3905
3966
|
source: "schema"
|
|
3906
|
-
}),
|
|
3907
|
-
|
|
3967
|
+
}), yc = (e, t) => pc(tt(
|
|
3968
|
+
fc(t),
|
|
3908
3969
|
e
|
|
3909
|
-
)).map(
|
|
3970
|
+
)).map(bc), Yn = (e) => ({
|
|
3910
3971
|
...e,
|
|
3911
3972
|
source: "provider"
|
|
3912
|
-
}),
|
|
3913
|
-
const n =
|
|
3914
|
-
return n ? e.filter((r) =>
|
|
3915
|
-
},
|
|
3973
|
+
}), vc = /(?:^|\s)\/([\p{L}\p{N}_-]*)$/u, wc = (e) => e.trim().toLowerCase(), Cc = (e) => [e.label, e.id, e.description, ...e.keywords ?? []].filter(Boolean).join(" ").toLowerCase(), _c = (e, t) => {
|
|
3974
|
+
const n = wc(t);
|
|
3975
|
+
return n ? e.filter((r) => Cc(r).includes(n)) : e;
|
|
3976
|
+
}, kc = async (e, t) => (await Promise.resolve((t == null ? void 0 : t(e)) ?? [])).map(Yn), Ec = (e) => "source" in e ? e : Yn(e), xc = ({
|
|
3916
3977
|
menuSchema: e,
|
|
3917
3978
|
slashCommandConfig: t
|
|
3918
|
-
}) => e !== void 0 || t !== void 0,
|
|
3979
|
+
}) => e !== void 0 || t !== void 0, Mc = () => {
|
|
3919
3980
|
const e = R();
|
|
3920
3981
|
if (!D(e) || !e.isCollapsed()) return null;
|
|
3921
3982
|
const t = e.anchor, n = t.getNode();
|
|
3922
|
-
if (!(n instanceof
|
|
3923
|
-
const o = n.getTextContent().slice(0, t.offset).match(
|
|
3983
|
+
if (!(n instanceof G)) return null;
|
|
3984
|
+
const o = n.getTextContent().slice(0, t.offset).match(vc);
|
|
3924
3985
|
if (!o) return null;
|
|
3925
3986
|
const a = o[1] ?? "", s = o[0] ?? "", c = s.startsWith("/") ? 0 : 1, d = t.offset - s.length + c;
|
|
3926
3987
|
return {
|
|
@@ -3929,10 +3990,10 @@ const On = {
|
|
|
3929
3990
|
startOffset: d,
|
|
3930
3991
|
endOffset: t.offset
|
|
3931
3992
|
};
|
|
3932
|
-
},
|
|
3993
|
+
}, Tc = () => {
|
|
3933
3994
|
const e = document.createElement("div");
|
|
3934
3995
|
return e.className = "bridgerte__floating-menu bridgerte__slash-command-menu", e.dataset.visible = "false", e;
|
|
3935
|
-
},
|
|
3996
|
+
}, Lc = () => {
|
|
3936
3997
|
const e = document.createElement("span");
|
|
3937
3998
|
return e.className = "bridgerte__slash-command-anchor", e.setAttribute("aria-hidden", "true"), e;
|
|
3938
3999
|
}, Gt = (e, t) => {
|
|
@@ -3941,21 +4002,21 @@ const On = {
|
|
|
3941
4002
|
if (!(r instanceof Text)) return null;
|
|
3942
4003
|
const o = document.createRange(), a = Math.min(t.startOffset + 1, ((s = r.textContent) == null ? void 0 : s.length) ?? 0);
|
|
3943
4004
|
return a <= t.startOffset ? null : (o.setStart(r, t.startOffset), o.setEnd(r, a), o.getBoundingClientRect());
|
|
3944
|
-
},
|
|
4005
|
+
}, Nc = (e, t, n, r, o) => {
|
|
3945
4006
|
const a = document.createElement("button"), s = document.createElement("span");
|
|
3946
4007
|
if (a.type = "button", a.className = "bridgerte__menu-item bridgerte__slash-command-item", a.dataset.commandId = e.id, a.dataset.index = String(t), a.dataset.active = String(n), r.showIcon && e.icon) {
|
|
3947
4008
|
const c = document.createElement("span");
|
|
3948
|
-
c.className = "bridgerte__slash-command-item-icon", c.setAttribute("aria-hidden", "true"),
|
|
4009
|
+
c.className = "bridgerte__slash-command-item-icon", c.setAttribute("aria-hidden", "true"), Vn(c, o[e.icon] ?? zn[e.icon], e.label), a.append(c);
|
|
3949
4010
|
}
|
|
3950
4011
|
if (s.className = "bridgerte__slash-command-item-title", s.textContent = e.label, a.append(s), e.description) {
|
|
3951
4012
|
const c = document.createElement("span");
|
|
3952
4013
|
c.className = "bridgerte__slash-command-item-description", c.textContent = e.description, a.append(c);
|
|
3953
4014
|
}
|
|
3954
4015
|
return a;
|
|
3955
|
-
},
|
|
4016
|
+
}, Sc = (e, t) => {
|
|
3956
4017
|
const n = document.createElement("div");
|
|
3957
4018
|
return n.className = "bridgerte__slash-command-status", n.dataset.status = e, n.textContent = t, n;
|
|
3958
|
-
},
|
|
4019
|
+
}, Pc = (e, t) => {
|
|
3959
4020
|
switch (e) {
|
|
3960
4021
|
case "loading":
|
|
3961
4022
|
return t.loadingText;
|
|
@@ -3969,7 +4030,7 @@ const On = {
|
|
|
3969
4030
|
y: e.y,
|
|
3970
4031
|
width: e.width,
|
|
3971
4032
|
height: e.height
|
|
3972
|
-
} : void 0,
|
|
4033
|
+
} : void 0, Ic = ({
|
|
3973
4034
|
editorRoot: e,
|
|
3974
4035
|
contentElement: t,
|
|
3975
4036
|
editor: n,
|
|
@@ -3985,19 +4046,19 @@ const On = {
|
|
|
3985
4046
|
onSlashCommandMenuRequest: w,
|
|
3986
4047
|
slashCommandProvider: T
|
|
3987
4048
|
}) => {
|
|
3988
|
-
const f =
|
|
4049
|
+
const f = Tc(), y = Lc(), x = hc(v), m = st(s ?? Re, {
|
|
3989
4050
|
menuLabels: l,
|
|
3990
4051
|
payloadPanelConfig: h
|
|
3991
|
-
}), p =
|
|
4052
|
+
}), p = yc(m, c), k = new Map(m.map((i) => [i.id, i])), _ = xc({
|
|
3992
4053
|
menuSchema: s,
|
|
3993
4054
|
slashCommandConfig: c
|
|
3994
4055
|
}), P = (i) => {
|
|
3995
4056
|
n.update(() => {
|
|
3996
|
-
const u =
|
|
3997
|
-
u instanceof
|
|
4057
|
+
const u = he(i.nodeKey);
|
|
4058
|
+
u instanceof G && (u.spliceText(i.startOffset, i.endOffset - i.startOffset, ""), u.select(i.startOffset, i.startOffset));
|
|
3998
4059
|
});
|
|
3999
4060
|
};
|
|
4000
|
-
return
|
|
4061
|
+
return Wn({
|
|
4001
4062
|
editorRoot: e,
|
|
4002
4063
|
contentElement: t,
|
|
4003
4064
|
editor: n,
|
|
@@ -4005,39 +4066,39 @@ const On = {
|
|
|
4005
4066
|
menu: f,
|
|
4006
4067
|
anchor: y,
|
|
4007
4068
|
itemSelector: ".bridgerte__slash-command-item",
|
|
4008
|
-
getCurrentTrigger:
|
|
4069
|
+
getCurrentTrigger: Mc,
|
|
4009
4070
|
getTriggerRect: (i) => Gt(n, i),
|
|
4010
4071
|
resolveItems: async (i) => {
|
|
4011
|
-
const u = _ || !T ?
|
|
4072
|
+
const u = _ || !T ? _c(p, i) : [];
|
|
4012
4073
|
try {
|
|
4013
|
-
const g = await
|
|
4074
|
+
const g = await kc(i, T);
|
|
4014
4075
|
return [...u, ...g];
|
|
4015
4076
|
} catch (g) {
|
|
4016
4077
|
if (u.length > 0) return u;
|
|
4017
4078
|
throw g;
|
|
4018
4079
|
}
|
|
4019
4080
|
},
|
|
4020
|
-
renderItem: (i, u, g) =>
|
|
4081
|
+
renderItem: (i, u, g) => Nc(
|
|
4021
4082
|
i,
|
|
4022
4083
|
u,
|
|
4023
4084
|
g,
|
|
4024
|
-
|
|
4085
|
+
x,
|
|
4025
4086
|
d
|
|
4026
4087
|
),
|
|
4027
|
-
renderStatus: (i) =>
|
|
4088
|
+
renderStatus: (i) => Sc(
|
|
4028
4089
|
i,
|
|
4029
|
-
|
|
4090
|
+
Pc(i, x)
|
|
4030
4091
|
),
|
|
4031
4092
|
onStateChange: w ? (i, u) => w({
|
|
4032
4093
|
id: `bridgerte-slash-command-menu-${i.requestId}`,
|
|
4033
4094
|
query: i.trigger.query,
|
|
4034
4095
|
status: i.status,
|
|
4035
4096
|
items: i.items,
|
|
4036
|
-
config:
|
|
4097
|
+
config: x,
|
|
4037
4098
|
readonly: r(),
|
|
4038
4099
|
anchorRect: Xt(u.anchorRect),
|
|
4039
4100
|
...i.error ? { error: i.error } : {},
|
|
4040
|
-
submit: (g) => u.selectItem(
|
|
4101
|
+
submit: (g) => u.selectItem(Ec(g)),
|
|
4041
4102
|
cancel: u.close
|
|
4042
4103
|
}) : void 0,
|
|
4043
4104
|
onSelect: (i, u) => {
|
|
@@ -4056,45 +4117,45 @@ const On = {
|
|
|
4056
4117
|
o(i.command);
|
|
4057
4118
|
}
|
|
4058
4119
|
}).destroy;
|
|
4059
|
-
},
|
|
4120
|
+
}, Yt = 32, ze = (e) => {
|
|
4060
4121
|
var t;
|
|
4061
4122
|
return e instanceof HTMLElement && e.getAttribute("role") === "checkbox" && ((t = e.parentElement) == null ? void 0 : t.classList.contains("bridgerte__list--todo")) === !0;
|
|
4062
|
-
},
|
|
4123
|
+
}, Ve = (e) => e instanceof HTMLElement ? e.closest('[role="checkbox"]') : null, Rc = (e) => fr(e), Jt = (e) => e.button === 0, We = (e, t) => {
|
|
4063
4124
|
const n = t.getBoundingClientRect();
|
|
4064
|
-
return t.dir === "rtl" ? e.clientX >= n.right -
|
|
4125
|
+
return t.dir === "rtl" ? e.clientX >= n.right - Yt && e.clientX <= n.right : e.clientX >= n.left && e.clientX <= n.left + Yt;
|
|
4065
4126
|
}, Qt = (e) => {
|
|
4066
4127
|
e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation();
|
|
4067
|
-
},
|
|
4128
|
+
}, Ac = ({
|
|
4068
4129
|
contentElement: e,
|
|
4069
4130
|
editor: t,
|
|
4070
4131
|
isReadonly: n
|
|
4071
4132
|
}) => {
|
|
4072
4133
|
let r = 0;
|
|
4073
4134
|
const o = (d) => {
|
|
4074
|
-
if (n() || !
|
|
4075
|
-
const l =
|
|
4076
|
-
!l || !
|
|
4135
|
+
if (n() || !Jt(d)) return;
|
|
4136
|
+
const l = Ve(d.target);
|
|
4137
|
+
!l || !ze(l) || We(d, l) && Qt(d);
|
|
4077
4138
|
}, a = (d, l) => {
|
|
4078
4139
|
Qt(d), t.update(() => {
|
|
4079
|
-
const h =
|
|
4080
|
-
|
|
4140
|
+
const h = Rc(l);
|
|
4141
|
+
Dr(h) && h.toggleChecked();
|
|
4081
4142
|
});
|
|
4082
4143
|
}, s = (d) => {
|
|
4083
|
-
if (n() || !
|
|
4084
|
-
const l =
|
|
4085
|
-
!l || !
|
|
4144
|
+
if (n() || !Jt(d) || Date.now() - r < 700) return;
|
|
4145
|
+
const l = Ve(d.target);
|
|
4146
|
+
!l || !ze(l) || We(d, l) && a(d, l);
|
|
4086
4147
|
}, c = (d) => {
|
|
4087
4148
|
if (n() || d.pointerType !== "touch") return;
|
|
4088
|
-
const l =
|
|
4089
|
-
!l || !
|
|
4149
|
+
const l = Ve(d.target);
|
|
4150
|
+
!l || !ze(l) || We(d, l) && (r = Date.now(), a(d, l));
|
|
4090
4151
|
};
|
|
4091
4152
|
return e.addEventListener("pointerdown", o, !0), e.addEventListener("pointerup", c, !0), e.addEventListener("click", s, !0), () => {
|
|
4092
4153
|
e.removeEventListener("pointerdown", o, !0), e.removeEventListener("pointerup", c, !0), e.removeEventListener("click", s, !0);
|
|
4093
4154
|
};
|
|
4094
|
-
},
|
|
4155
|
+
}, Ue = (e, t) => {
|
|
4095
4156
|
var n;
|
|
4096
4157
|
return ((n = e.floatingMenus) == null ? void 0 : n[t]) !== !1;
|
|
4097
|
-
},
|
|
4158
|
+
}, Bc = ({
|
|
4098
4159
|
options: e,
|
|
4099
4160
|
lexicalEditor: t,
|
|
4100
4161
|
editorRoot: n,
|
|
@@ -4112,12 +4173,12 @@ const On = {
|
|
|
4112
4173
|
setCanRedo: f,
|
|
4113
4174
|
enableKeyboardShortcuts: y
|
|
4114
4175
|
}) => {
|
|
4115
|
-
const
|
|
4176
|
+
const x = Ue(e, "mention"), m = Ue(e, "slash"), p = Ue(e, "hoverbar"), k = ln(
|
|
4116
4177
|
/*
|
|
4117
4178
|
* 业务自定义 paste hook 最先看到原始剪贴板摘要;返回 undefined 时完全不拦截,
|
|
4118
4179
|
* 继续走 BridgeRTE 内置媒体、URL 和 HTML 清洗链路。
|
|
4119
4180
|
*/
|
|
4120
|
-
|
|
4181
|
+
uc({
|
|
4121
4182
|
target: r,
|
|
4122
4183
|
isReadonly: a,
|
|
4123
4184
|
onPaste: e.onPaste,
|
|
@@ -4130,7 +4191,7 @@ const On = {
|
|
|
4130
4191
|
* 媒体文件粘贴/拖拽优先于 URL 粘贴快速路径;剪贴板里有文件时直接进入上传管线,
|
|
4131
4192
|
* 没有文件再交给纯文本 URL 链接处理或 Lexical 默认粘贴。
|
|
4132
4193
|
*/
|
|
4133
|
-
|
|
4194
|
+
cc({
|
|
4134
4195
|
target: r,
|
|
4135
4196
|
isReadonly: a,
|
|
4136
4197
|
canUploadMedia: l,
|
|
@@ -4140,7 +4201,7 @@ const On = {
|
|
|
4140
4201
|
* URL 粘贴是 BridgeRTE 的高意图快捷路径,必须先于 Lexical 默认 paste 监听注册。
|
|
4141
4202
|
* 否则 Lexical 会先把 URL 当普通文本插入,后续就失去“选区变链接”的语义。
|
|
4142
4203
|
*/
|
|
4143
|
-
|
|
4204
|
+
lc({
|
|
4144
4205
|
target: r,
|
|
4145
4206
|
isReadonly: a,
|
|
4146
4207
|
executeCommand: s
|
|
@@ -4149,30 +4210,31 @@ const On = {
|
|
|
4149
4210
|
* HTML 清洗放在媒体和纯文本 URL 之后、Lexical 默认 rich text paste 之前。
|
|
4150
4211
|
* 这样外部网页/办公软件片段会先进入 BridgeRTE 白名单清洗,再转成 Lexical 节点。
|
|
4151
4212
|
*/
|
|
4152
|
-
|
|
4213
|
+
dc({
|
|
4153
4214
|
target: r,
|
|
4154
4215
|
editor: t,
|
|
4155
4216
|
isReadonly: a
|
|
4156
4217
|
}),
|
|
4157
|
-
|
|
4218
|
+
Oi({
|
|
4158
4219
|
target: r,
|
|
4159
4220
|
isReadonly: a
|
|
4160
4221
|
}),
|
|
4161
|
-
|
|
4222
|
+
xr(t),
|
|
4162
4223
|
/*
|
|
4163
4224
|
* 代码块高亮一刀切使用 Lexical 官方 Shiki 管线。BridgeRTE tokenizer 只保留稳定 class,
|
|
4164
4225
|
* 不把 Shiki theme 的 inline style 写进内容 HTML。
|
|
4165
4226
|
*/
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4227
|
+
bo(t, ns),
|
|
4228
|
+
oo(t, o, Oa),
|
|
4229
|
+
Or(t),
|
|
4230
|
+
Hr(t),
|
|
4231
|
+
...Vo(t, a),
|
|
4232
|
+
Ac({
|
|
4171
4233
|
contentElement: r,
|
|
4172
4234
|
editor: t,
|
|
4173
4235
|
isReadonly: a
|
|
4174
4236
|
}),
|
|
4175
|
-
|
|
4237
|
+
x ? Cl({
|
|
4176
4238
|
editorRoot: n,
|
|
4177
4239
|
contentElement: r,
|
|
4178
4240
|
editor: t,
|
|
@@ -4183,7 +4245,7 @@ const On = {
|
|
|
4183
4245
|
onMentionMenuRequest: e.onMentionMenuRequest
|
|
4184
4246
|
}) : () => {
|
|
4185
4247
|
},
|
|
4186
|
-
p ?
|
|
4248
|
+
p ? qi({
|
|
4187
4249
|
editorRoot: n,
|
|
4188
4250
|
contentElement: r,
|
|
4189
4251
|
editor: t,
|
|
@@ -4198,9 +4260,9 @@ const On = {
|
|
|
4198
4260
|
payloadPanelConfig: e.payloadPanelConfig
|
|
4199
4261
|
}) : () => {
|
|
4200
4262
|
},
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
m ?
|
|
4263
|
+
Xr(t),
|
|
4264
|
+
Ii({ editor: t }),
|
|
4265
|
+
m ? Ic({
|
|
4204
4266
|
editorRoot: n,
|
|
4205
4267
|
contentElement: r,
|
|
4206
4268
|
editor: t,
|
|
@@ -4217,12 +4279,12 @@ const On = {
|
|
|
4217
4279
|
slashCommandProvider: e.slashCommandProvider
|
|
4218
4280
|
}) : () => {
|
|
4219
4281
|
},
|
|
4220
|
-
|
|
4282
|
+
Xo({
|
|
4221
4283
|
editor: t,
|
|
4222
4284
|
contentElement: r,
|
|
4223
4285
|
isReadonly: a
|
|
4224
4286
|
}),
|
|
4225
|
-
y ?
|
|
4287
|
+
y ? Qi({
|
|
4226
4288
|
target: r,
|
|
4227
4289
|
isReadonly: a,
|
|
4228
4290
|
executeCommand: s
|
|
@@ -4232,17 +4294,17 @@ const On = {
|
|
|
4232
4294
|
h(), v();
|
|
4233
4295
|
}),
|
|
4234
4296
|
t.registerCommand(
|
|
4235
|
-
|
|
4297
|
+
an,
|
|
4236
4298
|
() => (v(), !1),
|
|
4237
4299
|
U
|
|
4238
4300
|
),
|
|
4239
4301
|
t.registerCommand(
|
|
4240
|
-
|
|
4302
|
+
br,
|
|
4241
4303
|
(_) => (T(_), !1),
|
|
4242
4304
|
U
|
|
4243
4305
|
),
|
|
4244
4306
|
t.registerCommand(
|
|
4245
|
-
|
|
4307
|
+
yr,
|
|
4246
4308
|
(_) => (f(_), !1),
|
|
4247
4309
|
U
|
|
4248
4310
|
)
|
|
@@ -4253,39 +4315,39 @@ const On = {
|
|
|
4253
4315
|
}
|
|
4254
4316
|
};
|
|
4255
4317
|
};
|
|
4256
|
-
function
|
|
4257
|
-
const n =
|
|
4258
|
-
placeholder: t.placeholder ??
|
|
4318
|
+
function Dc(e, t = {}) {
|
|
4319
|
+
const n = ao(), r = t.mediaDefaultWidthPercent ?? 50, { contentElement: o } = Ti(e, {
|
|
4320
|
+
placeholder: t.placeholder ?? qo
|
|
4259
4321
|
}), a = t.keyboardShortcuts === !0;
|
|
4260
4322
|
let s = t.readonly ?? !1, c = !1, d = Ke(t.value);
|
|
4261
|
-
const l =
|
|
4262
|
-
namespace:
|
|
4323
|
+
const l = vr({
|
|
4324
|
+
namespace: Ha,
|
|
4263
4325
|
editable: !s,
|
|
4264
4326
|
nodes: [
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4327
|
+
Mr,
|
|
4328
|
+
Tr,
|
|
4329
|
+
cn,
|
|
4330
|
+
Pr,
|
|
4331
|
+
dn,
|
|
4332
|
+
$r,
|
|
4271
4333
|
je,
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4334
|
+
Yr,
|
|
4335
|
+
Jr,
|
|
4336
|
+
no,
|
|
4337
|
+
ro,
|
|
4338
|
+
pe,
|
|
4339
|
+
ie,
|
|
4340
|
+
ye
|
|
4279
4341
|
],
|
|
4280
|
-
theme:
|
|
4342
|
+
theme: ka,
|
|
4281
4343
|
onError: (i) => {
|
|
4282
4344
|
j(t, "lexical.runtime", "Lexical runtime error.", i);
|
|
4283
4345
|
}
|
|
4284
4346
|
});
|
|
4285
|
-
|
|
4347
|
+
Qr(l, !0);
|
|
4286
4348
|
const h = () => c, v = () => s, w = () => {
|
|
4287
|
-
h() ||
|
|
4288
|
-
}, T =
|
|
4349
|
+
h() || Go({ editor: l, contentElement: o });
|
|
4350
|
+
}, T = Li({ editor: l }), f = $a({
|
|
4289
4351
|
lexicalEditor: l,
|
|
4290
4352
|
options: t,
|
|
4291
4353
|
isDestroyed: h,
|
|
@@ -4293,13 +4355,13 @@ function Mc(e, t = {}) {
|
|
|
4293
4355
|
d = i;
|
|
4294
4356
|
},
|
|
4295
4357
|
syncPlaceholder: w
|
|
4296
|
-
}), y =
|
|
4358
|
+
}), y = ga({
|
|
4297
4359
|
lexicalEditor: l,
|
|
4298
4360
|
options: t,
|
|
4299
4361
|
isDestroyed: h,
|
|
4300
4362
|
canUploadMedia: () => t.uploadAdapter !== void 0,
|
|
4301
4363
|
isReadonly: v
|
|
4302
|
-
}),
|
|
4364
|
+
}), x = Da({
|
|
4303
4365
|
container: e,
|
|
4304
4366
|
lexicalEditor: l,
|
|
4305
4367
|
options: t,
|
|
@@ -4308,14 +4370,14 @@ function Mc(e, t = {}) {
|
|
|
4308
4370
|
reportError: j
|
|
4309
4371
|
}), m = () => {
|
|
4310
4372
|
o.contentEditable = String(!s), l.setEditable(!s);
|
|
4311
|
-
}, k =
|
|
4373
|
+
}, k = Mi({
|
|
4312
4374
|
editorRoot: e,
|
|
4313
4375
|
lexicalEditor: l,
|
|
4314
4376
|
isReadonly: v,
|
|
4315
4377
|
restoreEditorFocus: (i) => {
|
|
4316
4378
|
T.restore(), l.focus(i);
|
|
4317
4379
|
},
|
|
4318
|
-
executeCommand:
|
|
4380
|
+
executeCommand: x,
|
|
4319
4381
|
getClearCommand: (i) => {
|
|
4320
4382
|
switch (i.command.type) {
|
|
4321
4383
|
case "format.color":
|
|
@@ -4334,23 +4396,23 @@ function Mc(e, t = {}) {
|
|
|
4334
4396
|
menuLabels: t.menuLabels,
|
|
4335
4397
|
onRequest: t.onPayloadPanelRequest,
|
|
4336
4398
|
defaultMediaWidthPercent: r
|
|
4337
|
-
}), _ = () =>
|
|
4399
|
+
}), _ = () => da(t), P = () => ua(t), I = (i) => {
|
|
4338
4400
|
h() || (T.capture(), k.payloadPanelController.open(i));
|
|
4339
4401
|
};
|
|
4340
4402
|
e.dataset.readonly = String(s), e.addEventListener("focusin", _), e.addEventListener("focusout", P), e.style.setProperty(
|
|
4341
4403
|
"--bridgerte-media-display-width",
|
|
4342
4404
|
`${r}%`
|
|
4343
4405
|
);
|
|
4344
|
-
const L =
|
|
4406
|
+
const L = Bc({
|
|
4345
4407
|
options: t,
|
|
4346
4408
|
lexicalEditor: l,
|
|
4347
4409
|
editorRoot: e,
|
|
4348
4410
|
contentElement: o,
|
|
4349
4411
|
historyState: n,
|
|
4350
4412
|
isReadonly: v,
|
|
4351
|
-
executeCommand:
|
|
4413
|
+
executeCommand: x,
|
|
4352
4414
|
requestPayloadPanel: I,
|
|
4353
|
-
uploadMediaFile:
|
|
4415
|
+
uploadMediaFile: x.uploadMediaFile,
|
|
4354
4416
|
canUploadMedia: () => t.uploadAdapter !== void 0,
|
|
4355
4417
|
syncAfterEditorUpdate: f.syncAfterEditorUpdate,
|
|
4356
4418
|
refreshCommandStates: y.refreshCommandStates,
|
|
@@ -4359,16 +4421,16 @@ function Mc(e, t = {}) {
|
|
|
4359
4421
|
setCanRedo: y.setCanRedo,
|
|
4360
4422
|
enableKeyboardShortcuts: a
|
|
4361
4423
|
});
|
|
4362
|
-
l.setRootElement(o), f.suppressNextChange(), d =
|
|
4424
|
+
l.setRootElement(o), f.suppressNextChange(), d = Ao(l, t.value), m();
|
|
4363
4425
|
const C = {
|
|
4364
4426
|
getContent() {
|
|
4365
4427
|
return h() || (f.clearContentChangeTimer(), f.syncContent(!1)), d;
|
|
4366
4428
|
},
|
|
4367
4429
|
setContent(i) {
|
|
4368
|
-
h() || (f.clearContentChangeTimer(), d = Ke(i), f.suppressNextChange(),
|
|
4430
|
+
h() || (f.clearContentChangeTimer(), d = Ke(i), f.suppressNextChange(), wn(l, d), f.enforceCurrentMaxLength(), w(), l.dispatchCommand(wr, void 0), y.setHistoryAvailability(!1, !1), f.syncContent(!0));
|
|
4369
4431
|
},
|
|
4370
4432
|
executeCommand(i) {
|
|
4371
|
-
|
|
4433
|
+
x(i);
|
|
4372
4434
|
},
|
|
4373
4435
|
requestPayloadPanel: I,
|
|
4374
4436
|
getCommandStates: y.getCommandStates,
|
|
@@ -4383,20 +4445,20 @@ function Mc(e, t = {}) {
|
|
|
4383
4445
|
h() || o.blur();
|
|
4384
4446
|
},
|
|
4385
4447
|
destroy() {
|
|
4386
|
-
h() || (c = !0, f.clearContentChangeTimer(), k.destroy(),
|
|
4448
|
+
h() || (c = !0, f.clearContentChangeTimer(), k.destroy(), x.destroy(), y.destroy(), T.clear(), L.destroy(), l.setRootElement(null), e.removeEventListener("focusin", _), e.removeEventListener("focusout", P), e.classList.remove("bridgerte"), e.textContent = "", delete e.dataset.readonly);
|
|
4387
4449
|
}
|
|
4388
4450
|
};
|
|
4389
|
-
return f.syncContent(!1), w(), y.refreshCommandStates(),
|
|
4451
|
+
return f.syncContent(!1), w(), y.refreshCommandStates(), ma(t, C), C;
|
|
4390
4452
|
}
|
|
4391
|
-
const
|
|
4453
|
+
const Oc = (e) => !er(e) || !("id" in e) ? !1 : e.type === "editor.init" || e.type === "editor.executeCommand" || e.type === "editor.setContent" || e.type === "editor.setReadonly" || e.type === "editor.requestContent" || e.type === "editor.payloadPanelResolved" || e.type === "editor.payloadPanelCanceled" || e.type === "editor.uploadResolved" || e.type === "editor.uploadRejected", Hc = (e) => ({
|
|
4392
4454
|
id: e,
|
|
4393
4455
|
type: "editor.ready",
|
|
4394
4456
|
payload: {
|
|
4395
|
-
menuSchema:
|
|
4396
|
-
eventTiming:
|
|
4397
|
-
version:
|
|
4457
|
+
menuSchema: Re,
|
|
4458
|
+
eventTiming: nr,
|
|
4459
|
+
version: Pe
|
|
4398
4460
|
}
|
|
4399
|
-
}),
|
|
4461
|
+
}), $c = (e) => `native-upload:${e}:${Date.now()}:${Math.random().toString(36).slice(2)}`, rd = ({
|
|
4400
4462
|
container: e,
|
|
4401
4463
|
transport: t
|
|
4402
4464
|
}) => {
|
|
@@ -4414,7 +4476,7 @@ const Tc = (e) => !Jn(e) || !("id" in e) ? !1 : e.type === "editor.init" || e.ty
|
|
|
4414
4476
|
type: "editor.heightChange",
|
|
4415
4477
|
payload: { height: C }
|
|
4416
4478
|
}));
|
|
4417
|
-
},
|
|
4479
|
+
}, tr);
|
|
4418
4480
|
}, T = (C) => {
|
|
4419
4481
|
if (!n) return;
|
|
4420
4482
|
const i = n.getContent();
|
|
@@ -4460,7 +4522,7 @@ const Tc = (e) => !Jn(e) || !("id" in e) ? !1 : e.type === "editor.init" || e.ty
|
|
|
4460
4522
|
}
|
|
4461
4523
|
});
|
|
4462
4524
|
}
|
|
4463
|
-
},
|
|
4525
|
+
}, x = (C, i) => new Promise((u, g) => {
|
|
4464
4526
|
d.set(i, {
|
|
4465
4527
|
type: C,
|
|
4466
4528
|
assetId: i,
|
|
@@ -4476,7 +4538,7 @@ const Tc = (e) => !Jn(e) || !("id" in e) ? !1 : e.type === "editor.init" || e.ty
|
|
|
4476
4538
|
}
|
|
4477
4539
|
});
|
|
4478
4540
|
}), m = (C) => {
|
|
4479
|
-
const i =
|
|
4541
|
+
const i = $c(C);
|
|
4480
4542
|
d.set(i, {
|
|
4481
4543
|
type: C,
|
|
4482
4544
|
assetId: i,
|
|
@@ -4496,14 +4558,14 @@ const Tc = (e) => !Jn(e) || !("id" in e) ? !1 : e.type === "editor.init" || e.ty
|
|
|
4496
4558
|
const i = l.get(C.payload.requestId);
|
|
4497
4559
|
i && (l.delete(C.payload.requestId), i.request.cancel());
|
|
4498
4560
|
}, _ = (C, i) => {
|
|
4499
|
-
n == null || n.destroy(), o == null || o(), d.clear(), l.clear(), n =
|
|
4561
|
+
n == null || n.destroy(), o == null || o(), d.clear(), l.clear(), n = Dc(e, {
|
|
4500
4562
|
...i,
|
|
4501
4563
|
uploadAdapter: {
|
|
4502
4564
|
uploadImage(u, g) {
|
|
4503
|
-
return
|
|
4565
|
+
return x("image", g.assetId);
|
|
4504
4566
|
},
|
|
4505
4567
|
uploadVideo(u, g) {
|
|
4506
|
-
return
|
|
4568
|
+
return x("video", g.assetId);
|
|
4507
4569
|
}
|
|
4508
4570
|
},
|
|
4509
4571
|
onContentChange: (u) => {
|
|
@@ -4541,7 +4603,7 @@ const Tc = (e) => !Jn(e) || !("id" in e) ? !1 : e.type === "editor.init" || e.ty
|
|
|
4541
4603
|
type: "editor.commandStateChange",
|
|
4542
4604
|
payload: u
|
|
4543
4605
|
});
|
|
4544
|
-
}), h(
|
|
4606
|
+
}), h(Hc(C)), w();
|
|
4545
4607
|
}, P = (C) => {
|
|
4546
4608
|
if (C.type === "media.pickImage") {
|
|
4547
4609
|
m("image");
|
|
@@ -4553,7 +4615,7 @@ const Tc = (e) => !Jn(e) || !("id" in e) ? !1 : e.type === "editor.init" || e.ty
|
|
|
4553
4615
|
}
|
|
4554
4616
|
n == null || n.executeCommand(C);
|
|
4555
4617
|
}, I = (C) => {
|
|
4556
|
-
if (!(r || !
|
|
4618
|
+
if (!(r || !Oc(C)))
|
|
4557
4619
|
switch (C.type) {
|
|
4558
4620
|
case "editor.init":
|
|
4559
4621
|
_(C.id, C.payload);
|
|
@@ -4592,14 +4654,14 @@ const Tc = (e) => !Jn(e) || !("id" in e) ? !1 : e.type === "editor.init" || e.ty
|
|
|
4592
4654
|
};
|
|
4593
4655
|
};
|
|
4594
4656
|
export {
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4657
|
+
Dc as a,
|
|
4658
|
+
rd as b,
|
|
4659
|
+
Fn as c,
|
|
4660
|
+
zn as d,
|
|
4661
|
+
Vn as e,
|
|
4662
|
+
V as f,
|
|
4663
|
+
Cs as g,
|
|
4664
|
+
ws as h,
|
|
4603
4665
|
st as r
|
|
4604
4666
|
};
|
|
4605
|
-
//# sourceMappingURL=index-
|
|
4667
|
+
//# sourceMappingURL=index-DDfgjstx.js.map
|