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