@tempots/beatui 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +2 -2
- package/dist/index.es.js +2146 -2145
- package/dist/lexical/index.cjs.js +2 -2
- package/dist/lexical/index.es.js +1408 -1410
- package/dist/menu-B60Q9j3-.cjs +1 -0
- package/dist/menu-BkqFGcXg.js +366 -0
- package/dist/types/components/navigation/flyout.d.ts +15 -5
- package/package.json +1 -1
- package/dist/menu-B8yoDMRS.js +0 -373
- package/dist/menu-B92oSDct.cjs +0 -1
package/dist/lexical/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HeadingNode as ht, QuoteNode as bt, registerRichText as Pt, $createHeadingNode as
|
|
1
|
+
import { HeadingNode as ht, QuoteNode as bt, registerRichText as Pt, $createHeadingNode as W, $createQuoteNode as Be } from "@lexical/rich-text";
|
|
2
2
|
import { ListNode as Bt, ListItemNode as $t, registerList as _e, registerCheckList as dt, INSERT_ORDERED_LIST_COMMAND as ke, insertList as Ae, INSERT_UNORDERED_LIST_COMMAND as Ee, INSERT_CHECK_LIST_COMMAND as yt, REMOVE_LIST_COMMAND as Ut, removeList as zt, $isListNode as jt } from "@lexical/list";
|
|
3
3
|
import { INSERT_CHECK_LIST_COMMAND as Mi, INSERT_ORDERED_LIST_COMMAND as Li, INSERT_UNORDERED_LIST_COMMAND as _i, REMOVE_LIST_COMMAND as Ai } from "@lexical/list";
|
|
4
4
|
import * as Ce from "@lexical/table";
|
|
@@ -10,14 +10,14 @@ import { HashtagNode as ze } from "@lexical/hashtag";
|
|
|
10
10
|
import { MarkNode as oo, $wrapSelectionInMarkNode as no, $isMarkNode as pt, $getMarkIDs as io, $unwrapMarkNode as ro } from "@lexical/mark";
|
|
11
11
|
import { OverflowNode as lo } from "@lexical/overflow";
|
|
12
12
|
import * as ao from "lexical";
|
|
13
|
-
import { $applyNodeReplacement as so, DecoratorNode as co, COMMAND_PRIORITY_LOW as K, TextNode as
|
|
13
|
+
import { $applyNodeReplacement as so, DecoratorNode as co, COMMAND_PRIORITY_LOW as K, TextNode as xt, KEY_ARROW_DOWN_COMMAND as uo, KEY_ARROW_UP_COMMAND as fo, KEY_ENTER_COMMAND as mo, KEY_ESCAPE_COMMAND as po, $getSelection as A, $isRangeSelection as R, $isTextNode as me, createCommand as je, $createParagraphNode as de, $getRoot as be, $insertNodes as go, CLICK_COMMAND as vt, $getNodeByKey as Ct, ParagraphNode as ho, $isElementNode as Te, $isRootNode as bo, createEditor as Ge, BLUR_COMMAND as Je, FORMAT_TEXT_COMMAND as te, INDENT_CONTENT_COMMAND as yo, OUTDENT_CONTENT_COMMAND as xo, UNDO_COMMAND as vo, REDO_COMMAND as Co, SELECTION_CHANGE_COMMAND as kt } from "lexical";
|
|
14
14
|
import { BLUR_COMMAND as Ii, CLEAR_EDITOR_COMMAND as Di, CLICK_COMMAND as Fi, COMMAND_PRIORITY_CRITICAL as Hi, COMMAND_PRIORITY_EDITOR as Pi, COMMAND_PRIORITY_HIGH as Bi, COMMAND_PRIORITY_LOW as $i, COMMAND_PRIORITY_NORMAL as Ui, COPY_COMMAND as zi, CUT_COMMAND as ji, DecoratorNode as Gi, ElementNode as Ji, FOCUS_COMMAND as Ki, FORMAT_ELEMENT_COMMAND as qi, FORMAT_TEXT_COMMAND as Yi, INDENT_CONTENT_COMMAND as Wi, INSERT_PARAGRAPH_COMMAND as Vi, KEY_ENTER_COMMAND as Zi, KEY_ESCAPE_COMMAND as Xi, KEY_TAB_COMMAND as Qi, OUTDENT_CONTENT_COMMAND as er, PASTE_COMMAND as tr, REDO_COMMAND as or, SELECTION_CHANGE_COMMAND as nr, TextNode as ir, UNDO_COMMAND as rr, createCommand as lr } from "lexical";
|
|
15
15
|
import { registerPlainText as ko } from "@lexical/plain-text";
|
|
16
16
|
import { createEmptyHistoryState as Eo, registerHistory as To } from "@lexical/history";
|
|
17
17
|
import "@lexical/clipboard";
|
|
18
18
|
import { $convertToMarkdownString as So, TRANSFORMERS as No, $convertFromMarkdownString as Oo } from "@lexical/markdown";
|
|
19
19
|
import { $generateHtmlFromNodes as wo, $generateNodesFromDOM as Mo } from "@lexical/html";
|
|
20
|
-
import { $setBlocksType as
|
|
20
|
+
import { $setBlocksType as q, $getSelectionStyleValueForProperty as xe, $patchStyleText as ve } from "@lexical/selection";
|
|
21
21
|
import { registerLexicalTextEntity as Lo } from "@lexical/text";
|
|
22
22
|
import { mergeRegister as He, isHTMLElement as _o } from "@lexical/utils";
|
|
23
23
|
import * as Ao from "@lexical/offset";
|
|
@@ -25,10 +25,10 @@ import * as Ie from "@lexical/dragon";
|
|
|
25
25
|
import "@lexical/file";
|
|
26
26
|
import { createBinding as Ro } from "@lexical/yjs";
|
|
27
27
|
import "@lexical/headless";
|
|
28
|
-
import { Use as ue, html as D, Task as Ke, attr as
|
|
28
|
+
import { Use as ue, html as D, Task as Ke, attr as f, Value as U, WithElement as oe, OnDispose as ne, Ensure as Se, signal as z, on as ee, prop as j, When as pe, style as Y, aria as Pe, ForEach as Io, computedOf as Do } from "@tempots/dom";
|
|
29
29
|
import { L as qe } from "../link-portal-Cr2l9f3k.js";
|
|
30
30
|
import { T as Ye } from "../theme-kQZEeusG.js";
|
|
31
|
-
import { M as Et, a as le, b as Fo } from "../menu-
|
|
31
|
+
import { M as Et, a as le, b as Fo } from "../menu-BkqFGcXg.js";
|
|
32
32
|
import { B as ye, I as Z } from "../translations-B1_yyDUK.js";
|
|
33
33
|
import { E as Ho, a as gt } from "../editor-toolbar-group-Crlu1QJw.js";
|
|
34
34
|
import { delayedAnimationFrame as Po } from "@tempots/std";
|
|
@@ -144,8 +144,8 @@ async function Xe(e) {
|
|
|
144
144
|
return ko(e);
|
|
145
145
|
}
|
|
146
146
|
async function Qe(e, t) {
|
|
147
|
-
const
|
|
148
|
-
return To(e,
|
|
147
|
+
const r = Eo(), l = t?.delay ?? 300;
|
|
148
|
+
return To(e, r, l);
|
|
149
149
|
}
|
|
150
150
|
async function et(e) {
|
|
151
151
|
return () => {
|
|
@@ -182,103 +182,103 @@ async function ot(e) {
|
|
|
182
182
|
K
|
|
183
183
|
);
|
|
184
184
|
}
|
|
185
|
-
async function Zn(e, t,
|
|
186
|
-
const
|
|
187
|
-
let
|
|
188
|
-
const
|
|
189
|
-
const
|
|
190
|
-
if (!R(
|
|
185
|
+
async function Zn(e, t, r) {
|
|
186
|
+
const l = t?.trigger || "/";
|
|
187
|
+
let n = !1, s = null, g = 0;
|
|
188
|
+
const v = () => e.getEditorState().read(() => {
|
|
189
|
+
const y = A();
|
|
190
|
+
if (!R(y) || !y.isCollapsed())
|
|
191
191
|
return !1;
|
|
192
|
-
const
|
|
193
|
-
if (!me(
|
|
192
|
+
const x = y.anchor, T = x.getNode();
|
|
193
|
+
if (!me(T))
|
|
194
194
|
return !1;
|
|
195
|
-
const
|
|
196
|
-
if (
|
|
195
|
+
const O = T.getTextContent(), I = x.offset;
|
|
196
|
+
if (I === 0 || O[I - 1] !== l)
|
|
197
197
|
return !1;
|
|
198
|
-
if (
|
|
198
|
+
if (I === 1)
|
|
199
199
|
return !0;
|
|
200
|
-
const
|
|
201
|
-
return !!/\s/.test(
|
|
202
|
-
}),
|
|
200
|
+
const b = O[I - 2];
|
|
201
|
+
return !!/\s/.test(b);
|
|
202
|
+
}), L = () => s ? e.getEditorState().read(() => {
|
|
203
203
|
if (!s) return "";
|
|
204
|
-
const
|
|
205
|
-
if (
|
|
206
|
-
const
|
|
207
|
-
if (!R(
|
|
208
|
-
const
|
|
209
|
-
if (
|
|
204
|
+
const y = s.getTextContent(), x = y.indexOf(l, g);
|
|
205
|
+
if (x === -1) return "";
|
|
206
|
+
const T = A();
|
|
207
|
+
if (!R(T)) return "";
|
|
208
|
+
const O = T.anchor;
|
|
209
|
+
if (O.getNode().getKey() !== s.getKey())
|
|
210
210
|
return "";
|
|
211
|
-
const
|
|
212
|
-
return
|
|
213
|
-
}) : "",
|
|
211
|
+
const k = O.offset;
|
|
212
|
+
return k <= x ? "" : y.slice(x + 1, k);
|
|
213
|
+
}) : "", M = () => {
|
|
214
214
|
e.getEditorState().read(() => {
|
|
215
|
-
const
|
|
216
|
-
if (R(
|
|
217
|
-
const
|
|
218
|
-
if (me(
|
|
219
|
-
s =
|
|
220
|
-
const
|
|
215
|
+
const y = A();
|
|
216
|
+
if (R(y)) {
|
|
217
|
+
const x = y.anchor, T = x.getNode();
|
|
218
|
+
if (me(T)) {
|
|
219
|
+
s = T, g = x.offset - 1, n = !0;
|
|
220
|
+
const O = {
|
|
221
221
|
isActive: !0,
|
|
222
222
|
filterText: "",
|
|
223
223
|
anchorNode: s,
|
|
224
|
-
anchorOffset:
|
|
224
|
+
anchorOffset: g
|
|
225
225
|
};
|
|
226
|
-
|
|
226
|
+
r?.onTrigger?.(O, N), r?.onUpdate?.(O, N);
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
});
|
|
230
|
-
},
|
|
231
|
-
|
|
230
|
+
}, h = () => {
|
|
231
|
+
n && (n = !1, s = null, g = 0, r?.onClose?.());
|
|
232
232
|
}, N = () => {
|
|
233
233
|
s && e.update(() => {
|
|
234
234
|
if (!s) return;
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
237
|
-
const
|
|
238
|
-
if (!R(
|
|
239
|
-
const
|
|
240
|
-
if (
|
|
241
|
-
const
|
|
242
|
-
s.setTextContent(
|
|
243
|
-
const
|
|
244
|
-
R(
|
|
235
|
+
const y = s.getTextContent(), x = y.indexOf(l, g);
|
|
236
|
+
if (x === -1) return;
|
|
237
|
+
const T = A();
|
|
238
|
+
if (!R(T)) return;
|
|
239
|
+
const O = T.anchor;
|
|
240
|
+
if (O.getNode().getKey() !== s.getKey()) return;
|
|
241
|
+
const k = O.offset, b = y.slice(0, x), w = y.slice(k);
|
|
242
|
+
s.setTextContent(b + w);
|
|
243
|
+
const a = A();
|
|
244
|
+
R(a) && (a.anchor.set(s.getKey(), x, "text"), a.focus.set(s.getKey(), x, "text"));
|
|
245
245
|
});
|
|
246
|
-
},
|
|
247
|
-
if (!
|
|
248
|
-
const
|
|
246
|
+
}, E = () => {
|
|
247
|
+
if (!n) return;
|
|
248
|
+
const x = {
|
|
249
249
|
isActive: !0,
|
|
250
|
-
filterText:
|
|
250
|
+
filterText: L(),
|
|
251
251
|
anchorNode: s,
|
|
252
|
-
anchorOffset:
|
|
252
|
+
anchorOffset: g
|
|
253
253
|
};
|
|
254
|
-
|
|
255
|
-
},
|
|
256
|
-
|
|
257
|
-
(
|
|
258
|
-
if (!
|
|
259
|
-
|
|
254
|
+
r?.onUpdate?.(x, N);
|
|
255
|
+
}, m = e.registerMutationListener(
|
|
256
|
+
xt,
|
|
257
|
+
(y) => {
|
|
258
|
+
if (!n && v()) {
|
|
259
|
+
M();
|
|
260
260
|
return;
|
|
261
261
|
}
|
|
262
|
-
|
|
262
|
+
n && (s && !y.has(s.getKey()) ? E() : h());
|
|
263
263
|
}
|
|
264
|
-
),
|
|
264
|
+
), C = He(
|
|
265
265
|
// Handle selection changes - deactivate if selection moves away
|
|
266
|
-
e.registerUpdateListener(({ editorState:
|
|
267
|
-
|
|
268
|
-
if (!
|
|
269
|
-
const
|
|
270
|
-
if (!R(
|
|
271
|
-
|
|
266
|
+
e.registerUpdateListener(({ editorState: y }) => {
|
|
267
|
+
y.read(() => {
|
|
268
|
+
if (!n) return;
|
|
269
|
+
const x = A();
|
|
270
|
+
if (!R(x)) {
|
|
271
|
+
h();
|
|
272
272
|
return;
|
|
273
273
|
}
|
|
274
|
-
const
|
|
275
|
-
if (!s ||
|
|
276
|
-
|
|
274
|
+
const T = x.anchor, O = T.getNode();
|
|
275
|
+
if (!s || O.getKey() !== s.getKey()) {
|
|
276
|
+
h();
|
|
277
277
|
return;
|
|
278
278
|
}
|
|
279
|
-
const
|
|
280
|
-
if (
|
|
281
|
-
|
|
279
|
+
const k = s.getTextContent().indexOf(l, g);
|
|
280
|
+
if (k === -1 || T.offset <= k) {
|
|
281
|
+
h();
|
|
282
282
|
return;
|
|
283
283
|
}
|
|
284
284
|
});
|
|
@@ -286,33 +286,33 @@ async function Zn(e, t, l) {
|
|
|
286
286
|
// Prevent default arrow key behavior when palette is active
|
|
287
287
|
e.registerCommand(
|
|
288
288
|
uo,
|
|
289
|
-
(
|
|
289
|
+
(y) => n ? (y.preventDefault(), !0) : !1,
|
|
290
290
|
K
|
|
291
291
|
),
|
|
292
292
|
e.registerCommand(
|
|
293
293
|
fo,
|
|
294
|
-
(
|
|
294
|
+
(y) => n ? (y.preventDefault(), !0) : !1,
|
|
295
295
|
K
|
|
296
296
|
),
|
|
297
297
|
// Prevent default enter behavior when palette is active
|
|
298
298
|
e.registerCommand(
|
|
299
299
|
mo,
|
|
300
|
-
(
|
|
300
|
+
(y) => n ? (y?.preventDefault(), !0) : !1,
|
|
301
301
|
K
|
|
302
302
|
),
|
|
303
303
|
// Handle escape to close palette
|
|
304
304
|
e.registerCommand(
|
|
305
305
|
po,
|
|
306
|
-
(
|
|
306
|
+
(y) => n ? (y?.preventDefault(), h(), !0) : !1,
|
|
307
307
|
K
|
|
308
308
|
)
|
|
309
309
|
);
|
|
310
310
|
return () => {
|
|
311
|
-
|
|
311
|
+
h(), m(), C();
|
|
312
312
|
};
|
|
313
313
|
}
|
|
314
|
-
function Xn(e, t,
|
|
315
|
-
|
|
314
|
+
function Xn(e, t, r) {
|
|
315
|
+
r(), t.handler(e), e.focus();
|
|
316
316
|
}
|
|
317
317
|
const Qn = je(
|
|
318
318
|
"TOGGLE_SLASH_COMMAND_PALETTE"
|
|
@@ -326,10 +326,10 @@ function nt(e) {
|
|
|
326
326
|
const t = A();
|
|
327
327
|
if (!R(t)) return !1;
|
|
328
328
|
if (t.focus.getNode() !== null) {
|
|
329
|
-
const
|
|
330
|
-
t.insertNodes([
|
|
331
|
-
const
|
|
332
|
-
|
|
329
|
+
const l = Ne();
|
|
330
|
+
t.insertNodes([l]);
|
|
331
|
+
const n = de();
|
|
332
|
+
l.insertAfter(n), n.selectStart();
|
|
333
333
|
}
|
|
334
334
|
return !0;
|
|
335
335
|
},
|
|
@@ -340,19 +340,19 @@ const Jo = {
|
|
|
340
340
|
dependencies: [ge],
|
|
341
341
|
export: (e) => jo(e) ? "---" : null,
|
|
342
342
|
regExp: /^(---|\*\*\*|___)\s?$/,
|
|
343
|
-
replace: (e, t,
|
|
344
|
-
const
|
|
345
|
-
if (
|
|
346
|
-
e.replace(
|
|
343
|
+
replace: (e, t, r, l) => {
|
|
344
|
+
const n = Ne();
|
|
345
|
+
if (l)
|
|
346
|
+
e.replace(n);
|
|
347
347
|
else {
|
|
348
|
-
e.replace(
|
|
348
|
+
e.replace(n);
|
|
349
349
|
const s = de();
|
|
350
|
-
|
|
350
|
+
n.insertAfter(s), s.selectStart();
|
|
351
351
|
}
|
|
352
352
|
},
|
|
353
353
|
type: "element"
|
|
354
354
|
}, it = [...No, Jo];
|
|
355
|
-
async function
|
|
355
|
+
async function X(e) {
|
|
356
356
|
let t = "";
|
|
357
357
|
return e.getEditorState().read(() => {
|
|
358
358
|
t = So(it);
|
|
@@ -366,7 +366,7 @@ async function ae(e, t) {
|
|
|
366
366
|
async function ti() {
|
|
367
367
|
return it;
|
|
368
368
|
}
|
|
369
|
-
async function
|
|
369
|
+
async function Q(e) {
|
|
370
370
|
let t = "";
|
|
371
371
|
return e.getEditorState().read(() => {
|
|
372
372
|
t = wo(e);
|
|
@@ -374,42 +374,42 @@ async function ee(e) {
|
|
|
374
374
|
}
|
|
375
375
|
async function se(e, t) {
|
|
376
376
|
e.update(() => {
|
|
377
|
-
const
|
|
378
|
-
be().clear(), go(
|
|
377
|
+
const l = new DOMParser().parseFromString(t, "text/html"), n = Mo(e, l);
|
|
378
|
+
be().clear(), go(n);
|
|
379
379
|
});
|
|
380
380
|
}
|
|
381
|
-
async function oi(e, t,
|
|
382
|
-
let
|
|
381
|
+
async function oi(e, t, r) {
|
|
382
|
+
let l, n, s;
|
|
383
383
|
switch (t) {
|
|
384
384
|
case "markdown":
|
|
385
|
-
|
|
385
|
+
l = await X(e), n = "text/markdown", s = "md";
|
|
386
386
|
break;
|
|
387
387
|
case "html":
|
|
388
|
-
|
|
388
|
+
l = await Q(e), n = "text/html", s = "html";
|
|
389
389
|
break;
|
|
390
390
|
case "json":
|
|
391
|
-
|
|
391
|
+
l = JSON.stringify(e.getEditorState().toJSON(), null, 2), n = "application/json", s = "json";
|
|
392
392
|
break;
|
|
393
393
|
}
|
|
394
|
-
const
|
|
395
|
-
|
|
394
|
+
const g = new Blob([l], { type: n }), v = URL.createObjectURL(g), L = document.createElement("a");
|
|
395
|
+
L.href = v, L.download = r ?? `document.${s}`, L.click(), URL.revokeObjectURL(v);
|
|
396
396
|
}
|
|
397
|
-
async function ni(e, t,
|
|
398
|
-
const
|
|
399
|
-
const
|
|
400
|
-
|
|
397
|
+
async function ni(e, t, r) {
|
|
398
|
+
const l = await new Promise((s, g) => {
|
|
399
|
+
const v = new FileReader();
|
|
400
|
+
v.onload = () => s(v.result), v.onerror = () => g(v.error), v.readAsText(t);
|
|
401
401
|
});
|
|
402
|
-
switch (
|
|
402
|
+
switch (r ?? Ko(t.name)) {
|
|
403
403
|
case "markdown": {
|
|
404
|
-
await ae(e,
|
|
404
|
+
await ae(e, l);
|
|
405
405
|
break;
|
|
406
406
|
}
|
|
407
407
|
case "html": {
|
|
408
|
-
await se(e,
|
|
408
|
+
await se(e, l);
|
|
409
409
|
break;
|
|
410
410
|
}
|
|
411
411
|
case "json": {
|
|
412
|
-
const s = e.parseEditorState(
|
|
412
|
+
const s = e.parseEditorState(l);
|
|
413
413
|
e.setEditorState(s);
|
|
414
414
|
break;
|
|
415
415
|
}
|
|
@@ -423,10 +423,10 @@ async function rt(e, t) {
|
|
|
423
423
|
typeof Ce.registerTablePlugin == "function" ? Ce.registerTablePlugin(e) : () => {
|
|
424
424
|
};
|
|
425
425
|
}
|
|
426
|
-
async function ii(e, t = 3,
|
|
426
|
+
async function ii(e, t = 3, r = 3) {
|
|
427
427
|
e.dispatchCommand(Ce.INSERT_TABLE_COMMAND, {
|
|
428
428
|
rows: String(t),
|
|
429
|
-
columns: String(
|
|
429
|
+
columns: String(r),
|
|
430
430
|
includeHeaders: !0
|
|
431
431
|
});
|
|
432
432
|
}
|
|
@@ -443,33 +443,33 @@ function Yo(e) {
|
|
|
443
443
|
return new ze(e);
|
|
444
444
|
}
|
|
445
445
|
async function ai(e, t) {
|
|
446
|
-
const
|
|
446
|
+
const r = [], l = Lo(
|
|
447
447
|
e,
|
|
448
|
-
(
|
|
449
|
-
const s = qo.exec(
|
|
448
|
+
(n) => {
|
|
449
|
+
const s = qo.exec(n);
|
|
450
450
|
return s ? { start: s.index, end: s.index + s[0].length } : null;
|
|
451
451
|
},
|
|
452
452
|
ze,
|
|
453
453
|
Yo
|
|
454
454
|
);
|
|
455
|
-
if (Array.isArray(
|
|
456
|
-
const
|
|
457
|
-
|
|
455
|
+
if (Array.isArray(l) ? r.push(...l) : typeof l == "function" && r.push(l), t?.onHashtagClick) {
|
|
456
|
+
const n = e.registerCommand(
|
|
457
|
+
vt,
|
|
458
458
|
(s) => {
|
|
459
|
-
const
|
|
460
|
-
if (
|
|
461
|
-
const
|
|
462
|
-
if (
|
|
463
|
-
return t.onHashtagClick(
|
|
459
|
+
const g = s.target;
|
|
460
|
+
if (g.classList.contains("bc-lexical-hashtag")) {
|
|
461
|
+
const v = g.textContent;
|
|
462
|
+
if (v)
|
|
463
|
+
return t.onHashtagClick(v.replace("#", "")), !0;
|
|
464
464
|
}
|
|
465
465
|
return !1;
|
|
466
466
|
},
|
|
467
467
|
K
|
|
468
468
|
);
|
|
469
|
-
|
|
469
|
+
r.push(n);
|
|
470
470
|
}
|
|
471
471
|
return () => {
|
|
472
|
-
|
|
472
|
+
r.forEach((n) => n());
|
|
473
473
|
};
|
|
474
474
|
}
|
|
475
475
|
const Wo = /((https?:\/\/(www\.)?|www\.)[^\s<>]+)/g, Vo = /([a-zA-Z0-9._+-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/g, Zo = [
|
|
@@ -483,40 +483,40 @@ const Wo = /((https?:\/\/(www\.)?|www\.)[^\s<>]+)/g, Vo = /([a-zA-Z0-9._+-]+@[a-
|
|
|
483
483
|
}
|
|
484
484
|
];
|
|
485
485
|
async function si(e, t) {
|
|
486
|
-
const
|
|
487
|
-
return e.registerMutationListener(
|
|
486
|
+
const r = t?.matchers ?? Zo;
|
|
487
|
+
return e.registerMutationListener(xt, (l) => {
|
|
488
488
|
e.update(() => {
|
|
489
|
-
for (const [
|
|
489
|
+
for (const [n, s] of l) {
|
|
490
490
|
if (s !== "created" && s !== "updated") continue;
|
|
491
|
-
const
|
|
492
|
-
if (!
|
|
493
|
-
const
|
|
494
|
-
for (const
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
|
|
491
|
+
const g = Ct(n);
|
|
492
|
+
if (!g || !me(g)) continue;
|
|
493
|
+
const v = g.getTextContent();
|
|
494
|
+
for (const L of r) {
|
|
495
|
+
const M = new RegExp(
|
|
496
|
+
L.pattern.source,
|
|
497
|
+
L.pattern.flags
|
|
498
498
|
);
|
|
499
|
-
let
|
|
500
|
-
for (; (
|
|
501
|
-
|
|
499
|
+
let h;
|
|
500
|
+
for (; (h = M.exec(v)) !== null; )
|
|
501
|
+
L.urlTransformer(h[0]);
|
|
502
502
|
}
|
|
503
503
|
}
|
|
504
504
|
});
|
|
505
505
|
});
|
|
506
506
|
}
|
|
507
507
|
async function ci(e, t) {
|
|
508
|
-
const
|
|
509
|
-
return t?.onMarkClick &&
|
|
508
|
+
const r = [];
|
|
509
|
+
return t?.onMarkClick && r.push(
|
|
510
510
|
e.registerCommand(
|
|
511
|
-
|
|
512
|
-
(
|
|
513
|
-
const
|
|
514
|
-
if (
|
|
515
|
-
const s =
|
|
511
|
+
vt,
|
|
512
|
+
(l) => {
|
|
513
|
+
const n = l.target;
|
|
514
|
+
if (n.classList.contains("bc-lexical-mark")) {
|
|
515
|
+
const s = n.dataset.markId;
|
|
516
516
|
if (s)
|
|
517
517
|
return t.onMarkClick(s, {
|
|
518
518
|
id: s,
|
|
519
|
-
type:
|
|
519
|
+
type: n.dataset.markType || "annotation",
|
|
520
520
|
data: {}
|
|
521
521
|
}), !0;
|
|
522
522
|
}
|
|
@@ -524,32 +524,32 @@ async function ci(e, t) {
|
|
|
524
524
|
},
|
|
525
525
|
K
|
|
526
526
|
)
|
|
527
|
-
), () =>
|
|
527
|
+
), () => r.forEach((l) => l());
|
|
528
528
|
}
|
|
529
|
-
async function ui(e, t,
|
|
529
|
+
async function ui(e, t, r) {
|
|
530
530
|
e.update(() => {
|
|
531
|
-
const
|
|
532
|
-
R(
|
|
531
|
+
const l = A();
|
|
532
|
+
R(l) && no(l, l.isBackward(), t);
|
|
533
533
|
});
|
|
534
534
|
}
|
|
535
535
|
async function di(e, t) {
|
|
536
536
|
e.update(() => {
|
|
537
|
-
const
|
|
538
|
-
const s =
|
|
539
|
-
return pt(s) ? io(
|
|
537
|
+
const l = be().getAllTextNodes().filter((n) => {
|
|
538
|
+
const s = n.getParent();
|
|
539
|
+
return pt(s) ? io(n, 0)?.includes(t) ?? !1 : !1;
|
|
540
540
|
});
|
|
541
|
-
for (const
|
|
542
|
-
const s =
|
|
541
|
+
for (const n of l) {
|
|
542
|
+
const s = n.getParent();
|
|
543
543
|
pt(s) && ro(s);
|
|
544
544
|
}
|
|
545
545
|
});
|
|
546
546
|
}
|
|
547
547
|
async function fi(e, t) {
|
|
548
|
-
const { maxLength:
|
|
549
|
-
return e.registerUpdateListener(({ editorState:
|
|
550
|
-
|
|
551
|
-
const
|
|
552
|
-
|
|
548
|
+
const { maxLength: r, onOverflow: l } = t;
|
|
549
|
+
return e.registerUpdateListener(({ editorState: n }) => {
|
|
550
|
+
n.read(() => {
|
|
551
|
+
const v = be().getTextContent().length, L = v > r;
|
|
552
|
+
l && l(L, v);
|
|
553
553
|
});
|
|
554
554
|
});
|
|
555
555
|
}
|
|
@@ -558,16 +558,16 @@ async function lt(e) {
|
|
|
558
558
|
};
|
|
559
559
|
}
|
|
560
560
|
async function at(e, t) {
|
|
561
|
-
const
|
|
561
|
+
const r = t.docMap ?? /* @__PURE__ */ new Map(), l = t.id ?? "lexical", n = t.doc.getText(l), s = Ro(
|
|
562
562
|
e,
|
|
563
563
|
t.provider,
|
|
564
|
-
|
|
564
|
+
n,
|
|
565
565
|
t.doc,
|
|
566
|
-
|
|
567
|
-
),
|
|
566
|
+
r
|
|
567
|
+
), g = e.registerUpdateListener(() => {
|
|
568
568
|
});
|
|
569
569
|
return () => {
|
|
570
|
-
|
|
570
|
+
g(), s && typeof s.destroy == "function" && s.destroy();
|
|
571
571
|
};
|
|
572
572
|
}
|
|
573
573
|
function mi(e) {
|
|
@@ -578,12 +578,12 @@ function mi(e) {
|
|
|
578
578
|
focusOffset: 0
|
|
579
579
|
};
|
|
580
580
|
return e.getEditorState().read(() => {
|
|
581
|
-
const
|
|
582
|
-
R(
|
|
583
|
-
hasSelection: !
|
|
584
|
-
selectedText:
|
|
585
|
-
anchorOffset:
|
|
586
|
-
focusOffset:
|
|
581
|
+
const r = A();
|
|
582
|
+
R(r) && (t = {
|
|
583
|
+
hasSelection: !r.isCollapsed(),
|
|
584
|
+
selectedText: r.getTextContent(),
|
|
585
|
+
anchorOffset: r.anchor.offset,
|
|
586
|
+
focusOffset: r.focus.offset
|
|
587
587
|
});
|
|
588
588
|
}), t;
|
|
589
589
|
}
|
|
@@ -602,78 +602,78 @@ function gi(e) {
|
|
|
602
602
|
}
|
|
603
603
|
function hi(e, t) {
|
|
604
604
|
e.update(() => {
|
|
605
|
-
const
|
|
606
|
-
R(
|
|
605
|
+
const r = A();
|
|
606
|
+
R(r) && r.insertText(t);
|
|
607
607
|
}), e.focus();
|
|
608
608
|
}
|
|
609
609
|
async function bi() {
|
|
610
610
|
return Ao;
|
|
611
611
|
}
|
|
612
|
-
function he(e, t,
|
|
613
|
-
const
|
|
612
|
+
function he(e, t, r) {
|
|
613
|
+
const l = /* @__PURE__ */ new Map();
|
|
614
614
|
if (e)
|
|
615
|
-
for (const
|
|
616
|
-
const s =
|
|
615
|
+
for (const n of e.split(";")) {
|
|
616
|
+
const s = n.trim();
|
|
617
617
|
if (!s) continue;
|
|
618
|
-
const
|
|
619
|
-
if (
|
|
620
|
-
const
|
|
621
|
-
|
|
618
|
+
const g = s.indexOf(":");
|
|
619
|
+
if (g === -1) continue;
|
|
620
|
+
const v = s.slice(0, g).trim(), L = s.slice(g + 1).trim();
|
|
621
|
+
l.set(v, L);
|
|
622
622
|
}
|
|
623
|
-
return
|
|
623
|
+
return r ? l.set(t, r) : l.delete(t), l.size === 0 ? "" : Array.from(l.entries()).map(([n, s]) => `${n}: ${s}`).join("; ");
|
|
624
624
|
}
|
|
625
625
|
function ce(e, t) {
|
|
626
626
|
if (!e) return "";
|
|
627
|
-
const
|
|
627
|
+
const r = new RegExp(
|
|
628
628
|
`(?:^|;)\\s*${t.replace(/-/g, "\\-")}:\\s*([^;]+)`
|
|
629
|
-
),
|
|
630
|
-
return
|
|
629
|
+
), l = e.match(r);
|
|
630
|
+
return l ? l[1].trim() : "";
|
|
631
631
|
}
|
|
632
632
|
function Xo(e, t) {
|
|
633
|
-
const
|
|
634
|
-
|
|
635
|
-
const
|
|
636
|
-
if (!Te(
|
|
637
|
-
const
|
|
638
|
-
|
|
639
|
-
const
|
|
640
|
-
|
|
633
|
+
const r = e.getElementByKey(t);
|
|
634
|
+
r && e.getEditorState().read(() => {
|
|
635
|
+
const l = Ct(t);
|
|
636
|
+
if (!Te(l) || bo(l)) return;
|
|
637
|
+
const n = l.getStyle(), s = ce(n, "background-color");
|
|
638
|
+
r.style.backgroundColor = s || "";
|
|
639
|
+
const g = ce(n, "line-height");
|
|
640
|
+
r.style.lineHeight = g || "";
|
|
641
641
|
});
|
|
642
642
|
}
|
|
643
643
|
function st(e) {
|
|
644
644
|
const t = e.registerUpdateListener(
|
|
645
|
-
({ dirtyElements:
|
|
646
|
-
if (
|
|
647
|
-
for (const [
|
|
648
|
-
Xo(e,
|
|
645
|
+
({ dirtyElements: r }) => {
|
|
646
|
+
if (r.size !== 0)
|
|
647
|
+
for (const [l] of r)
|
|
648
|
+
Xo(e, l);
|
|
649
649
|
}
|
|
650
650
|
);
|
|
651
651
|
return e.getEditorState().read(() => {
|
|
652
|
-
const
|
|
653
|
-
for (const
|
|
654
|
-
if (Te(
|
|
655
|
-
const
|
|
656
|
-
if (
|
|
657
|
-
const s = e.getElementByKey(
|
|
652
|
+
const r = be();
|
|
653
|
+
for (const l of r.getChildren())
|
|
654
|
+
if (Te(l)) {
|
|
655
|
+
const n = l.getStyle();
|
|
656
|
+
if (n) {
|
|
657
|
+
const s = e.getElementByKey(l.getKey());
|
|
658
658
|
if (s) {
|
|
659
|
-
const
|
|
660
|
-
|
|
661
|
-
const
|
|
662
|
-
|
|
659
|
+
const g = ce(n, "background-color");
|
|
660
|
+
g && (s.style.backgroundColor = g);
|
|
661
|
+
const v = ce(n, "line-height");
|
|
662
|
+
v && (s.style.lineHeight = v);
|
|
663
663
|
}
|
|
664
664
|
}
|
|
665
665
|
}
|
|
666
666
|
}), t;
|
|
667
667
|
}
|
|
668
668
|
function De(e, t) {
|
|
669
|
-
const
|
|
670
|
-
if (
|
|
671
|
-
const
|
|
672
|
-
|
|
673
|
-
const s = ce(
|
|
674
|
-
s && (
|
|
669
|
+
const r = t.exportDOM(e);
|
|
670
|
+
if (r.element && _o(r.element) && Te(t)) {
|
|
671
|
+
const l = t.getStyle(), n = ce(l, "background-color");
|
|
672
|
+
n && (r.element.style.backgroundColor = n);
|
|
673
|
+
const s = ce(l, "line-height");
|
|
674
|
+
s && (r.element.style.lineHeight = s);
|
|
675
675
|
}
|
|
676
|
-
return
|
|
676
|
+
return r;
|
|
677
677
|
}
|
|
678
678
|
function we() {
|
|
679
679
|
const e = /* @__PURE__ */ new Map();
|
|
@@ -681,33 +681,33 @@ function we() {
|
|
|
681
681
|
}
|
|
682
682
|
function Qo() {
|
|
683
683
|
const e = (t) => () => ({
|
|
684
|
-
conversion: (
|
|
685
|
-
const
|
|
686
|
-
if (
|
|
687
|
-
|
|
688
|
-
let
|
|
689
|
-
|
|
690
|
-
|
|
684
|
+
conversion: (r) => {
|
|
685
|
+
const l = t(r);
|
|
686
|
+
if (l && Te(l)) {
|
|
687
|
+
r.style?.textAlign && l.setFormat(r.style.textAlign);
|
|
688
|
+
let n = "";
|
|
689
|
+
r.style?.backgroundColor && (n = he(
|
|
690
|
+
n,
|
|
691
691
|
"background-color",
|
|
692
|
-
|
|
693
|
-
)),
|
|
694
|
-
|
|
692
|
+
r.style.backgroundColor
|
|
693
|
+
)), r.style?.lineHeight && (n = he(
|
|
694
|
+
n,
|
|
695
695
|
"line-height",
|
|
696
|
-
|
|
697
|
-
)),
|
|
696
|
+
r.style.lineHeight
|
|
697
|
+
)), n && l.setStyle(n);
|
|
698
698
|
}
|
|
699
|
-
return { node:
|
|
699
|
+
return { node: l };
|
|
700
700
|
},
|
|
701
701
|
priority: 1
|
|
702
702
|
});
|
|
703
703
|
return {
|
|
704
704
|
p: e(() => de()),
|
|
705
|
-
h1: e(() =>
|
|
706
|
-
h2: e(() =>
|
|
707
|
-
h3: e(() =>
|
|
708
|
-
h4: e(() =>
|
|
709
|
-
h5: e(() =>
|
|
710
|
-
h6: e(() =>
|
|
705
|
+
h1: e(() => W("h1")),
|
|
706
|
+
h2: e(() => W("h2")),
|
|
707
|
+
h3: e(() => W("h3")),
|
|
708
|
+
h4: e(() => W("h4")),
|
|
709
|
+
h5: e(() => W("h5")),
|
|
710
|
+
h6: e(() => W("h6"))
|
|
711
711
|
};
|
|
712
712
|
}
|
|
713
713
|
const en = [
|
|
@@ -745,29 +745,29 @@ const en = [
|
|
|
745
745
|
"code",
|
|
746
746
|
"mark"
|
|
747
747
|
];
|
|
748
|
-
function rn(e, t,
|
|
748
|
+
function rn(e, t, r) {
|
|
749
749
|
if (!me(t)) return;
|
|
750
|
-
const
|
|
751
|
-
(
|
|
750
|
+
const l = e.fontWeight, n = e.textDecoration.split(" ");
|
|
751
|
+
(l === "700" || l === "bold") && !t.hasFormat("bold") && t.toggleFormat("bold"), e.fontStyle === "italic" && !t.hasFormat("italic") && t.toggleFormat("italic"), n.includes("line-through") && !t.hasFormat("strikethrough") && t.toggleFormat("strikethrough"), n.includes("underline") && !t.hasFormat("underline") && t.toggleFormat("underline"), e.verticalAlign === "sub" && !t.hasFormat("subscript") && t.toggleFormat("subscript"), e.verticalAlign === "super" && !t.hasFormat("superscript") && t.toggleFormat("superscript"), r && !t.hasFormat(r) && t.toggleFormat(r);
|
|
752
752
|
}
|
|
753
753
|
function ln(e = en) {
|
|
754
754
|
const t = {};
|
|
755
|
-
for (const
|
|
756
|
-
t[
|
|
757
|
-
const
|
|
755
|
+
for (const r of nn)
|
|
756
|
+
t[r] = (l) => {
|
|
757
|
+
const n = l.style, s = on[r], g = r === "b" ? n.fontWeight !== "normal" ? "bold" : void 0 : s;
|
|
758
758
|
return {
|
|
759
759
|
conversion: () => ({
|
|
760
760
|
node: null,
|
|
761
|
-
forChild: (
|
|
762
|
-
if (!me(
|
|
763
|
-
rn(
|
|
764
|
-
let
|
|
765
|
-
for (const
|
|
766
|
-
if (tn.has(
|
|
767
|
-
const
|
|
768
|
-
|
|
761
|
+
forChild: (v) => {
|
|
762
|
+
if (!me(v)) return v;
|
|
763
|
+
rn(n, v, g);
|
|
764
|
+
let L = v.getStyle();
|
|
765
|
+
for (const M of e) {
|
|
766
|
+
if (tn.has(M)) continue;
|
|
767
|
+
const h = n.getPropertyValue(M);
|
|
768
|
+
h && (L = he(L, M, h));
|
|
769
769
|
}
|
|
770
|
-
return
|
|
770
|
+
return L && v.setStyle(L), v;
|
|
771
771
|
}
|
|
772
772
|
}),
|
|
773
773
|
priority: 1
|
|
@@ -782,11 +782,11 @@ function Me(e) {
|
|
|
782
782
|
};
|
|
783
783
|
}
|
|
784
784
|
async function Le(e = {}) {
|
|
785
|
-
const { nodes: t = [], plugins:
|
|
785
|
+
const { nodes: t = [], plugins: r = [], onError: l } = e, s = (await Go()).createEditor({
|
|
786
786
|
namespace: "BeatUIHeadless",
|
|
787
787
|
nodes: t,
|
|
788
|
-
onError: (
|
|
789
|
-
|
|
788
|
+
onError: (g) => {
|
|
789
|
+
l ? l(g, s) : console.error("[BeatUI Headless]", g);
|
|
790
790
|
},
|
|
791
791
|
editable: !1,
|
|
792
792
|
// Headless editors are typically not editable
|
|
@@ -795,79 +795,79 @@ async function Le(e = {}) {
|
|
|
795
795
|
import: Me()
|
|
796
796
|
}
|
|
797
797
|
});
|
|
798
|
-
if (
|
|
799
|
-
for (const
|
|
800
|
-
|
|
798
|
+
if (r.length > 0)
|
|
799
|
+
for (const g of r)
|
|
800
|
+
g.register(s);
|
|
801
801
|
return s;
|
|
802
802
|
}
|
|
803
803
|
async function yi(e) {
|
|
804
804
|
const t = await Le();
|
|
805
805
|
return await ae(t, e), t.getEditorState().toJSON();
|
|
806
806
|
}
|
|
807
|
-
async function vi(e) {
|
|
808
|
-
const t = await Le(), l = t.parseEditorState(JSON.stringify(e));
|
|
809
|
-
return t.setEditorState(l), await Q(t);
|
|
810
|
-
}
|
|
811
807
|
async function xi(e) {
|
|
808
|
+
const t = await Le(), r = t.parseEditorState(JSON.stringify(e));
|
|
809
|
+
return t.setEditorState(r), await X(t);
|
|
810
|
+
}
|
|
811
|
+
async function vi(e) {
|
|
812
812
|
const t = await Le();
|
|
813
813
|
return await se(t, e), t.getEditorState().toJSON();
|
|
814
814
|
}
|
|
815
815
|
async function Ci(e) {
|
|
816
|
-
const t = await Le(),
|
|
817
|
-
return t.setEditorState(
|
|
816
|
+
const t = await Le(), r = t.parseEditorState(JSON.stringify(e));
|
|
817
|
+
return t.setEditorState(r), await Q(t);
|
|
818
818
|
}
|
|
819
819
|
const an = (e) => {
|
|
820
820
|
const {
|
|
821
821
|
value: t,
|
|
822
|
-
format:
|
|
823
|
-
plugins:
|
|
824
|
-
readOnly:
|
|
822
|
+
format: r,
|
|
823
|
+
plugins: l,
|
|
824
|
+
readOnly: n,
|
|
825
825
|
placeholder: s,
|
|
826
|
-
class:
|
|
827
|
-
namespace:
|
|
828
|
-
heightMode:
|
|
829
|
-
autoFocus:
|
|
830
|
-
onError:
|
|
826
|
+
class: g,
|
|
827
|
+
namespace: v = "BeatUILexical",
|
|
828
|
+
heightMode: L = "auto",
|
|
829
|
+
autoFocus: M = !1,
|
|
830
|
+
onError: h,
|
|
831
831
|
onInput: N,
|
|
832
|
-
onChange:
|
|
833
|
-
onBlur:
|
|
834
|
-
onReady:
|
|
832
|
+
onChange: E,
|
|
833
|
+
onBlur: m,
|
|
834
|
+
onReady: C
|
|
835
835
|
} = e;
|
|
836
836
|
return ue(
|
|
837
837
|
Ye,
|
|
838
|
-
({ appearance:
|
|
838
|
+
({ appearance: y }) => D.div(
|
|
839
839
|
// CSS injection via LinkPortal
|
|
840
840
|
Ke(
|
|
841
841
|
() => import("../styles-url-BIeImEjl.js"),
|
|
842
|
-
({ default:
|
|
842
|
+
({ default: x }) => qe({ id: "beatui-lexical-css", href: x })
|
|
843
843
|
),
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
844
|
+
f.class("bc-lexical-editor-container"),
|
|
845
|
+
L === "fixed" ? f.class("bc-lexical-editor-container--fixed") : null,
|
|
846
|
+
f.class(g),
|
|
847
847
|
// The editable surface
|
|
848
848
|
D.div(
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
849
|
+
f.class("bc-lexical-editor"),
|
|
850
|
+
f.class(`bc-lexical-editor--${L}`),
|
|
851
|
+
f.contenteditable(
|
|
852
852
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
853
|
-
|
|
853
|
+
n != null ? U.map(n, (x) => !x) : !0
|
|
854
854
|
),
|
|
855
|
-
|
|
855
|
+
n != null ? f.class(
|
|
856
856
|
U.map(
|
|
857
|
-
|
|
858
|
-
(
|
|
857
|
+
n,
|
|
858
|
+
(x) => x ? "bc-lexical-editor--readonly" : ""
|
|
859
859
|
)
|
|
860
860
|
) : null,
|
|
861
|
-
oe((
|
|
862
|
-
let
|
|
863
|
-
const
|
|
861
|
+
oe((x) => {
|
|
862
|
+
let T = null;
|
|
863
|
+
const O = [];
|
|
864
864
|
return (async () => {
|
|
865
865
|
try {
|
|
866
|
-
const
|
|
867
|
-
|
|
868
|
-
),
|
|
869
|
-
namespace:
|
|
870
|
-
nodes:
|
|
866
|
+
const k = l ?? Ve("bare"), b = We(k), w = U.get(
|
|
867
|
+
r ?? "markdown"
|
|
868
|
+
), a = Ge({
|
|
869
|
+
namespace: v,
|
|
870
|
+
nodes: b,
|
|
871
871
|
theme: {
|
|
872
872
|
// Lexical theme classNames map — these are applied to rendered nodes
|
|
873
873
|
heading: {
|
|
@@ -904,135 +904,135 @@ const an = (e) => {
|
|
|
904
904
|
mark: "bc-lexical-mark",
|
|
905
905
|
paragraph: "bc-lexical-paragraph"
|
|
906
906
|
},
|
|
907
|
-
onError: (
|
|
908
|
-
|
|
907
|
+
onError: (u) => {
|
|
908
|
+
h ? h(u, a) : console.error("[BeatUI Lexical]", u);
|
|
909
909
|
},
|
|
910
|
-
editable:
|
|
910
|
+
editable: n ? !U.get(n) : !0,
|
|
911
911
|
html: {
|
|
912
912
|
export: we(),
|
|
913
913
|
import: Me()
|
|
914
914
|
}
|
|
915
915
|
});
|
|
916
|
-
|
|
917
|
-
const
|
|
918
|
-
if (
|
|
919
|
-
const
|
|
920
|
-
|
|
916
|
+
T = a, a.setRootElement(x);
|
|
917
|
+
const F = [];
|
|
918
|
+
if (k.richText ? F.push(Ze(a)) : k.plainText && F.push(Xe(a)), k.history) {
|
|
919
|
+
const u = typeof k.history == "object" ? k.history : void 0;
|
|
920
|
+
F.push(Qe(a, u));
|
|
921
921
|
}
|
|
922
|
-
if (
|
|
923
|
-
at(
|
|
924
|
-
),
|
|
925
|
-
|
|
926
|
-
}),
|
|
927
|
-
const
|
|
922
|
+
if (k.clipboard && F.push(et(a)), k.list && F.push(tt(a)), k.link && F.push(ot(a)), k.yjs && F.push(
|
|
923
|
+
at(a, k.yjs)
|
|
924
|
+
), k.dragon && F.push(lt(a)), k.table && F.push(rt(a)), (await Promise.all(F)).forEach((u) => {
|
|
925
|
+
u && O.push(u);
|
|
926
|
+
}), O.push(nt(a)), O.push(st(a)), t != null) {
|
|
927
|
+
const u = U.get(
|
|
928
928
|
t
|
|
929
929
|
);
|
|
930
|
-
if (
|
|
931
|
-
if (
|
|
932
|
-
await ae(
|
|
933
|
-
else if (
|
|
934
|
-
await se(
|
|
935
|
-
else if (
|
|
930
|
+
if (u != null && (u !== "" || w === "json" && typeof u == "object")) {
|
|
931
|
+
if (w === "markdown" && typeof u == "string")
|
|
932
|
+
await ae(a, u);
|
|
933
|
+
else if (w === "html" && typeof u == "string")
|
|
934
|
+
await se(a, u);
|
|
935
|
+
else if (w === "json" && typeof u == "object")
|
|
936
936
|
try {
|
|
937
|
-
const
|
|
938
|
-
|
|
939
|
-
} catch (
|
|
937
|
+
const i = JSON.stringify(u), _ = a.parseEditorState(i);
|
|
938
|
+
a.setEditorState(_);
|
|
939
|
+
} catch (i) {
|
|
940
940
|
console.error(
|
|
941
941
|
"[BeatUI] Failed to parse JSON editor state:",
|
|
942
|
-
|
|
943
|
-
),
|
|
944
|
-
|
|
945
|
-
|
|
942
|
+
i
|
|
943
|
+
), h && h(
|
|
944
|
+
i instanceof Error ? i : new Error(String(i)),
|
|
945
|
+
a
|
|
946
946
|
);
|
|
947
947
|
}
|
|
948
948
|
}
|
|
949
949
|
}
|
|
950
|
-
if (
|
|
951
|
-
|
|
952
|
-
({ editorState:
|
|
953
|
-
|
|
954
|
-
if (
|
|
955
|
-
const
|
|
956
|
-
N(
|
|
957
|
-
} else if (
|
|
958
|
-
const
|
|
959
|
-
N(
|
|
960
|
-
} else
|
|
961
|
-
|
|
962
|
-
|
|
950
|
+
if (O.push(
|
|
951
|
+
a.registerUpdateListener(
|
|
952
|
+
({ editorState: u, dirtyElements: c, dirtyLeaves: i }) => {
|
|
953
|
+
c.size === 0 && i.size === 0 || N && u.read(async () => {
|
|
954
|
+
if (w === "markdown") {
|
|
955
|
+
const _ = await X(a);
|
|
956
|
+
N(_, a);
|
|
957
|
+
} else if (w === "html") {
|
|
958
|
+
const _ = await Q(a);
|
|
959
|
+
N(_, a);
|
|
960
|
+
} else w === "json" && N(
|
|
961
|
+
u.toJSON(),
|
|
962
|
+
a
|
|
963
963
|
);
|
|
964
964
|
});
|
|
965
965
|
}
|
|
966
966
|
)
|
|
967
|
-
), t != null &&
|
|
968
|
-
U.on(t, async (
|
|
969
|
-
if (
|
|
970
|
-
if (
|
|
971
|
-
const
|
|
972
|
-
|
|
973
|
-
} else if (
|
|
974
|
-
const
|
|
975
|
-
|
|
976
|
-
} else if (
|
|
977
|
-
const
|
|
978
|
-
|
|
979
|
-
),
|
|
980
|
-
if (
|
|
981
|
-
const
|
|
982
|
-
|
|
967
|
+
), t != null && O.push(
|
|
968
|
+
U.on(t, async (u) => {
|
|
969
|
+
if (u != null) {
|
|
970
|
+
if (w === "markdown" && typeof u == "string") {
|
|
971
|
+
const c = await X(a);
|
|
972
|
+
u !== c && await ae(a, u);
|
|
973
|
+
} else if (w === "html" && typeof u == "string") {
|
|
974
|
+
const c = await Q(a);
|
|
975
|
+
u !== c && await se(a, u);
|
|
976
|
+
} else if (w === "json" && typeof u == "object") {
|
|
977
|
+
const c = JSON.stringify(
|
|
978
|
+
a.getEditorState().toJSON()
|
|
979
|
+
), i = JSON.stringify(u);
|
|
980
|
+
if (c !== i) {
|
|
981
|
+
const _ = a.parseEditorState(i);
|
|
982
|
+
a.setEditorState(_);
|
|
983
983
|
}
|
|
984
984
|
}
|
|
985
985
|
}
|
|
986
986
|
})
|
|
987
|
-
),
|
|
988
|
-
U.on(
|
|
989
|
-
|
|
987
|
+
), n != null && O.push(
|
|
988
|
+
U.on(n, (u) => {
|
|
989
|
+
a.setEditable(!u);
|
|
990
990
|
})
|
|
991
|
-
),
|
|
992
|
-
|
|
991
|
+
), O.push(
|
|
992
|
+
a.registerCommand(
|
|
993
993
|
// Use BLUR_COMMAND from lexical
|
|
994
994
|
Je,
|
|
995
|
-
() => (
|
|
996
|
-
if (
|
|
997
|
-
const
|
|
998
|
-
|
|
999
|
-
} else if (
|
|
1000
|
-
const
|
|
1001
|
-
|
|
1002
|
-
} else
|
|
1003
|
-
|
|
1004
|
-
|
|
995
|
+
() => (m && m(a), E && a.getEditorState().read(async () => {
|
|
996
|
+
if (w === "markdown") {
|
|
997
|
+
const u = await X(a);
|
|
998
|
+
E(u, a);
|
|
999
|
+
} else if (w === "html") {
|
|
1000
|
+
const u = await Q(a);
|
|
1001
|
+
E(u, a);
|
|
1002
|
+
} else w === "json" && E(
|
|
1003
|
+
a.getEditorState().toJSON(),
|
|
1004
|
+
a
|
|
1005
1005
|
);
|
|
1006
1006
|
}), !1),
|
|
1007
1007
|
K
|
|
1008
1008
|
)
|
|
1009
|
-
),
|
|
1010
|
-
|
|
1011
|
-
const
|
|
1012
|
-
|
|
1009
|
+
), O.push(
|
|
1010
|
+
y.on((u) => {
|
|
1011
|
+
const c = a.getRootElement();
|
|
1012
|
+
c && (c.dataset.theme = u);
|
|
1013
1013
|
})
|
|
1014
|
-
),
|
|
1015
|
-
|
|
1014
|
+
), M)
|
|
1015
|
+
a.focus();
|
|
1016
1016
|
else {
|
|
1017
|
-
const
|
|
1018
|
-
|
|
1017
|
+
const u = a.getRootElement();
|
|
1018
|
+
u && u === document.activeElement && u.blur();
|
|
1019
1019
|
}
|
|
1020
|
-
|
|
1021
|
-
} catch (
|
|
1020
|
+
C && C(a);
|
|
1021
|
+
} catch (k) {
|
|
1022
1022
|
console.error(
|
|
1023
1023
|
"[BeatUI] Failed to initialize Lexical editor:",
|
|
1024
|
-
|
|
1024
|
+
k
|
|
1025
1025
|
);
|
|
1026
|
-
const
|
|
1027
|
-
|
|
1026
|
+
const b = x;
|
|
1027
|
+
b.textContent = "Failed to load Lexical editor.";
|
|
1028
1028
|
}
|
|
1029
1029
|
})(), ne(() => {
|
|
1030
1030
|
try {
|
|
1031
|
-
|
|
1031
|
+
O.forEach((k) => k());
|
|
1032
1032
|
} catch {
|
|
1033
1033
|
}
|
|
1034
1034
|
try {
|
|
1035
|
-
|
|
1035
|
+
T?.setRootElement(null);
|
|
1036
1036
|
} catch {
|
|
1037
1037
|
}
|
|
1038
1038
|
});
|
|
@@ -1041,80 +1041,80 @@ const an = (e) => {
|
|
|
1041
1041
|
)
|
|
1042
1042
|
);
|
|
1043
1043
|
};
|
|
1044
|
-
function St(e, t,
|
|
1045
|
-
const
|
|
1046
|
-
const
|
|
1047
|
-
return
|
|
1048
|
-
const
|
|
1049
|
-
return R(
|
|
1050
|
-
}) :
|
|
1051
|
-
}),
|
|
1052
|
-
const
|
|
1053
|
-
return
|
|
1044
|
+
function St(e, t, r) {
|
|
1045
|
+
const l = (m, C) => t.map(() => {
|
|
1046
|
+
const y = e.value;
|
|
1047
|
+
return y ? y.getEditorState().read(() => {
|
|
1048
|
+
const x = A();
|
|
1049
|
+
return R(x) ? m(x) : C;
|
|
1050
|
+
}) : C;
|
|
1051
|
+
}), n = (m) => {
|
|
1052
|
+
const C = m.anchor.getNode();
|
|
1053
|
+
return C.getKey() === "root" ? C : C.getTopLevelElementOrThrow();
|
|
1054
1054
|
};
|
|
1055
1055
|
return {
|
|
1056
|
-
withSelection:
|
|
1057
|
-
getAnchorElement:
|
|
1058
|
-
textFormatActive: (
|
|
1059
|
-
blockTypeActive: (
|
|
1060
|
-
listTypeActive: (
|
|
1061
|
-
const
|
|
1062
|
-
return jt(
|
|
1056
|
+
withSelection: l,
|
|
1057
|
+
getAnchorElement: n,
|
|
1058
|
+
textFormatActive: (m) => l((C) => C.hasFormat(m), !1),
|
|
1059
|
+
blockTypeActive: (m) => l((C) => n(C).getType() === m, !1),
|
|
1060
|
+
listTypeActive: (m) => l((C) => {
|
|
1061
|
+
const y = n(C).getParent();
|
|
1062
|
+
return jt(y) && y.getListType() === m;
|
|
1063
1063
|
}, !1),
|
|
1064
|
-
headingActive: (
|
|
1065
|
-
const
|
|
1066
|
-
return
|
|
1067
|
-
const
|
|
1068
|
-
if (R(
|
|
1069
|
-
const
|
|
1070
|
-
if (
|
|
1071
|
-
return
|
|
1064
|
+
headingActive: (m) => t.map(() => {
|
|
1065
|
+
const C = e.value;
|
|
1066
|
+
return C ? C.getEditorState().read(() => {
|
|
1067
|
+
const y = A();
|
|
1068
|
+
if (R(y)) {
|
|
1069
|
+
const x = n(y);
|
|
1070
|
+
if (x.getType() === "heading")
|
|
1071
|
+
return C.getElementByKey(x.getKey())?.tagName === `H${m}`;
|
|
1072
1072
|
}
|
|
1073
1073
|
return !1;
|
|
1074
1074
|
}) : !1;
|
|
1075
1075
|
}),
|
|
1076
|
-
linkActive: () =>
|
|
1077
|
-
const
|
|
1078
|
-
return
|
|
1076
|
+
linkActive: () => l((m) => {
|
|
1077
|
+
const C = m.anchor.getNode();
|
|
1078
|
+
return C.getParent()?.getType() === "link" || C.getType() === "link";
|
|
1079
1079
|
}, !1),
|
|
1080
|
-
dispatch: (
|
|
1081
|
-
const
|
|
1082
|
-
|
|
1080
|
+
dispatch: (m, C) => () => {
|
|
1081
|
+
const y = e.value;
|
|
1082
|
+
y && (y.dispatchCommand(m, C), y.focus());
|
|
1083
1083
|
},
|
|
1084
|
-
toggleBlock: (
|
|
1085
|
-
const
|
|
1086
|
-
|
|
1087
|
-
const
|
|
1088
|
-
if (R(
|
|
1089
|
-
const
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
() =>
|
|
1084
|
+
toggleBlock: (m, C) => () => {
|
|
1085
|
+
const y = e.value;
|
|
1086
|
+
y && (y.update(() => {
|
|
1087
|
+
const x = A();
|
|
1088
|
+
if (R(x)) {
|
|
1089
|
+
const T = n(x);
|
|
1090
|
+
q(
|
|
1091
|
+
x,
|
|
1092
|
+
() => T.getType() === m ? de() : C()
|
|
1093
1093
|
);
|
|
1094
1094
|
}
|
|
1095
|
-
}),
|
|
1095
|
+
}), y.focus());
|
|
1096
1096
|
},
|
|
1097
1097
|
toggleLink: () => {
|
|
1098
|
-
const
|
|
1099
|
-
|
|
1100
|
-
const
|
|
1101
|
-
if (R(
|
|
1102
|
-
const
|
|
1103
|
-
if (
|
|
1104
|
-
|
|
1098
|
+
const m = e.value;
|
|
1099
|
+
m && (m.getEditorState().read(() => {
|
|
1100
|
+
const C = A();
|
|
1101
|
+
if (R(C)) {
|
|
1102
|
+
const y = C.anchor.getNode();
|
|
1103
|
+
if (y.getParent()?.getType() === "link" || y.getType() === "link")
|
|
1104
|
+
m.dispatchCommand(Fe, null);
|
|
1105
1105
|
else {
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1106
|
+
const O = prompt(r?.enterUrlMessage?.() ?? "Enter URL:");
|
|
1107
|
+
O && m.dispatchCommand(Fe, O);
|
|
1108
1108
|
}
|
|
1109
1109
|
}
|
|
1110
|
-
}),
|
|
1110
|
+
}), m.focus());
|
|
1111
1111
|
}
|
|
1112
1112
|
};
|
|
1113
1113
|
}
|
|
1114
1114
|
function Nt(e, t) {
|
|
1115
|
-
return (
|
|
1116
|
-
...
|
|
1117
|
-
display:
|
|
1115
|
+
return (r) => (l) => Ho({
|
|
1116
|
+
...l,
|
|
1117
|
+
display: r,
|
|
1118
1118
|
disabled: e,
|
|
1119
1119
|
size: t
|
|
1120
1120
|
});
|
|
@@ -1160,16 +1160,16 @@ function un() {
|
|
|
1160
1160
|
function dn(e) {
|
|
1161
1161
|
if (e.layout)
|
|
1162
1162
|
return e.layout;
|
|
1163
|
-
const { visibleGroups: t, hiddenGroups:
|
|
1164
|
-
let
|
|
1165
|
-
if ((t ||
|
|
1163
|
+
const { visibleGroups: t, hiddenGroups: r, customGroups: l } = e;
|
|
1164
|
+
let n = un();
|
|
1165
|
+
if ((t || r) && (n = n.filter((s) => {
|
|
1166
1166
|
if ("separator" in s || "customGroup" in s) return !0;
|
|
1167
|
-
const
|
|
1168
|
-
return !(
|
|
1169
|
-
})),
|
|
1170
|
-
for (const s of
|
|
1171
|
-
|
|
1172
|
-
return
|
|
1167
|
+
const g = s.group;
|
|
1168
|
+
return !(r?.includes(g) || t && !t.includes(g));
|
|
1169
|
+
})), l && l.length > 0)
|
|
1170
|
+
for (const s of l)
|
|
1171
|
+
n.push({ customGroup: s.id });
|
|
1172
|
+
return n;
|
|
1173
1173
|
}
|
|
1174
1174
|
const fn = [
|
|
1175
1175
|
{ value: "Arial", label: "Arial" },
|
|
@@ -1199,444 +1199,444 @@ const fn = [
|
|
|
1199
1199
|
function gn({
|
|
1200
1200
|
editor: e,
|
|
1201
1201
|
stateUpdate: t,
|
|
1202
|
-
toolbar:
|
|
1203
|
-
readOnly:
|
|
1204
|
-
size:
|
|
1202
|
+
toolbar: r = {},
|
|
1203
|
+
readOnly: l = z(!1),
|
|
1204
|
+
size: n = "sm"
|
|
1205
1205
|
}) {
|
|
1206
|
-
const { maxHeadingLevel: s = 3 } =
|
|
1206
|
+
const { maxHeadingLevel: s = 3 } = r, g = dn(r);
|
|
1207
1207
|
return ue(
|
|
1208
1208
|
ye,
|
|
1209
|
-
(
|
|
1210
|
-
const
|
|
1209
|
+
(v) => Se(e, (L) => {
|
|
1210
|
+
const M = L, h = v.$.lexical, {
|
|
1211
1211
|
getAnchorElement: N,
|
|
1212
|
-
textFormatActive:
|
|
1213
|
-
blockTypeActive:
|
|
1214
|
-
listTypeActive:
|
|
1215
|
-
headingActive:
|
|
1216
|
-
linkActive:
|
|
1217
|
-
dispatch:
|
|
1218
|
-
toggleBlock:
|
|
1219
|
-
toggleLink:
|
|
1220
|
-
} = St(
|
|
1221
|
-
enterUrlMessage: () =>
|
|
1222
|
-
}),
|
|
1223
|
-
const
|
|
1224
|
-
|
|
1225
|
-
const
|
|
1226
|
-
R(
|
|
1227
|
-
}),
|
|
1228
|
-
},
|
|
1229
|
-
const
|
|
1230
|
-
|
|
1212
|
+
textFormatActive: E,
|
|
1213
|
+
blockTypeActive: m,
|
|
1214
|
+
listTypeActive: C,
|
|
1215
|
+
headingActive: y,
|
|
1216
|
+
linkActive: x,
|
|
1217
|
+
dispatch: T,
|
|
1218
|
+
toggleBlock: O,
|
|
1219
|
+
toggleLink: I
|
|
1220
|
+
} = St(M, t, {
|
|
1221
|
+
enterUrlMessage: () => v.value.lexical.enterUrl
|
|
1222
|
+
}), b = Nt(l, n)(z(!0)), w = () => {
|
|
1223
|
+
const o = M.value;
|
|
1224
|
+
o && (o.update(() => {
|
|
1225
|
+
const p = A();
|
|
1226
|
+
R(p) && q(p, () => de());
|
|
1227
|
+
}), o.focus());
|
|
1228
|
+
}, a = (o) => {
|
|
1229
|
+
const p = M.value;
|
|
1230
|
+
p && (p.update(() => {
|
|
1231
1231
|
const H = A();
|
|
1232
1232
|
if (R(H)) {
|
|
1233
|
-
const J = N(H), ie = `h${
|
|
1234
|
-
J.getType() === "heading" && re?.tagName === `H${
|
|
1233
|
+
const J = N(H), ie = `h${o}`, re = p.getElementByKey(J.getKey());
|
|
1234
|
+
J.getType() === "heading" && re?.tagName === `H${o}` ? q(H, () => de()) : q(H, () => W(ie));
|
|
1235
1235
|
}
|
|
1236
|
-
}),
|
|
1237
|
-
},
|
|
1238
|
-
const
|
|
1239
|
-
if (!
|
|
1240
|
-
const
|
|
1241
|
-
|
|
1242
|
-
},
|
|
1243
|
-
const
|
|
1244
|
-
if (!
|
|
1245
|
-
const
|
|
1246
|
-
|
|
1247
|
-
},
|
|
1248
|
-
const
|
|
1249
|
-
|
|
1250
|
-
|
|
1236
|
+
}), p.focus());
|
|
1237
|
+
}, F = () => {
|
|
1238
|
+
const o = M.value;
|
|
1239
|
+
if (!o) return;
|
|
1240
|
+
const p = o.getRootElement();
|
|
1241
|
+
p && (p.focus(), document.execCommand("copy"));
|
|
1242
|
+
}, S = () => {
|
|
1243
|
+
const o = M.value;
|
|
1244
|
+
if (!o) return;
|
|
1245
|
+
const p = o.getRootElement();
|
|
1246
|
+
p && (p.focus(), document.execCommand("cut"));
|
|
1247
|
+
}, u = () => {
|
|
1248
|
+
const o = M.value;
|
|
1249
|
+
o && navigator.clipboard.readText().then((p) => {
|
|
1250
|
+
o.update(() => {
|
|
1251
1251
|
const H = A();
|
|
1252
|
-
R(H) && H.insertText(
|
|
1253
|
-
}),
|
|
1252
|
+
R(H) && H.insertText(p);
|
|
1253
|
+
}), o.focus();
|
|
1254
1254
|
}).catch(() => {
|
|
1255
1255
|
});
|
|
1256
|
-
},
|
|
1257
|
-
const
|
|
1258
|
-
|
|
1259
|
-
const
|
|
1260
|
-
if (R(
|
|
1261
|
-
for (const H of
|
|
1256
|
+
}, c = () => {
|
|
1257
|
+
const o = M.value;
|
|
1258
|
+
o && (o.update(() => {
|
|
1259
|
+
const p = A();
|
|
1260
|
+
if (R(p))
|
|
1261
|
+
for (const H of p.getNodes())
|
|
1262
1262
|
me(H) && (H.setFormat(0), H.setStyle(""));
|
|
1263
|
-
}),
|
|
1264
|
-
},
|
|
1265
|
-
const
|
|
1266
|
-
|
|
1263
|
+
}), o.focus());
|
|
1264
|
+
}, i = () => {
|
|
1265
|
+
const o = M.value;
|
|
1266
|
+
o && (o.dispatchCommand($e, {
|
|
1267
1267
|
rows: "3",
|
|
1268
1268
|
columns: "3",
|
|
1269
1269
|
includeHeaders: !0
|
|
1270
|
-
}),
|
|
1271
|
-
},
|
|
1270
|
+
}), o.focus());
|
|
1271
|
+
}, _ = {
|
|
1272
1272
|
value: "",
|
|
1273
|
-
label:
|
|
1274
|
-
},
|
|
1275
|
-
|
|
1276
|
-
...
|
|
1277
|
-
],
|
|
1278
|
-
|
|
1279
|
-
...
|
|
1280
|
-
],
|
|
1281
|
-
|
|
1282
|
-
...
|
|
1273
|
+
label: v.value.lexical.defaultOption
|
|
1274
|
+
}, V = [
|
|
1275
|
+
_,
|
|
1276
|
+
...r.fontFamilies ?? fn
|
|
1277
|
+
], d = [
|
|
1278
|
+
_,
|
|
1279
|
+
...r.fontSizes ?? mn
|
|
1280
|
+
], B = [
|
|
1281
|
+
_,
|
|
1282
|
+
...r.lineHeights ?? pn
|
|
1283
1283
|
], $ = t.map(() => {
|
|
1284
|
-
const
|
|
1285
|
-
return
|
|
1286
|
-
const
|
|
1287
|
-
return R(
|
|
1284
|
+
const o = M.value;
|
|
1285
|
+
return o ? o.getEditorState().read(() => {
|
|
1286
|
+
const p = A();
|
|
1287
|
+
return R(p) ? xe(p, "font-family", "") : "";
|
|
1288
1288
|
}) : "";
|
|
1289
1289
|
}), G = t.map(() => {
|
|
1290
|
-
const
|
|
1291
|
-
return
|
|
1292
|
-
const
|
|
1293
|
-
return R(
|
|
1290
|
+
const o = M.value;
|
|
1291
|
+
return o ? o.getEditorState().read(() => {
|
|
1292
|
+
const p = A();
|
|
1293
|
+
return R(p) ? xe(p, "font-size", "") : "";
|
|
1294
1294
|
}) : "";
|
|
1295
|
-
}), wt = (
|
|
1296
|
-
const
|
|
1297
|
-
|
|
1295
|
+
}), wt = (o) => {
|
|
1296
|
+
const p = M.value;
|
|
1297
|
+
p && (p.update(() => {
|
|
1298
1298
|
const H = A();
|
|
1299
|
-
R(H) &&
|
|
1300
|
-
}),
|
|
1301
|
-
}, Mt = (
|
|
1302
|
-
const
|
|
1303
|
-
|
|
1299
|
+
R(H) && ve(H, { "font-family": o || null });
|
|
1300
|
+
}), p.focus());
|
|
1301
|
+
}, Mt = (o) => {
|
|
1302
|
+
const p = M.value;
|
|
1303
|
+
p && (p.update(() => {
|
|
1304
1304
|
const H = A();
|
|
1305
|
-
R(H) &&
|
|
1306
|
-
}),
|
|
1305
|
+
R(H) && ve(H, { "font-size": o || null });
|
|
1306
|
+
}), p.focus());
|
|
1307
1307
|
}, Lt = t.map(() => {
|
|
1308
|
-
const
|
|
1309
|
-
return
|
|
1310
|
-
const
|
|
1311
|
-
return R(
|
|
1308
|
+
const o = M.value;
|
|
1309
|
+
return o ? o.getEditorState().read(() => {
|
|
1310
|
+
const p = A();
|
|
1311
|
+
return R(p) && xe(p, "color", "") || "#000000";
|
|
1312
1312
|
}) : "#000000";
|
|
1313
1313
|
}), _t = t.map(() => {
|
|
1314
|
-
const
|
|
1315
|
-
return
|
|
1316
|
-
const
|
|
1317
|
-
return R(
|
|
1314
|
+
const o = M.value;
|
|
1315
|
+
return o ? o.getEditorState().read(() => {
|
|
1316
|
+
const p = A();
|
|
1317
|
+
return R(p) && xe(p, "background-color", "") || "#ffffff";
|
|
1318
1318
|
}) : "#ffffff";
|
|
1319
1319
|
}), At = t.map(() => {
|
|
1320
|
-
const
|
|
1321
|
-
return
|
|
1322
|
-
const
|
|
1323
|
-
if (R(
|
|
1324
|
-
const J = N(
|
|
1320
|
+
const o = M.value;
|
|
1321
|
+
return o ? o.getEditorState().read(() => {
|
|
1322
|
+
const p = A();
|
|
1323
|
+
if (R(p)) {
|
|
1324
|
+
const J = N(p).getStyle();
|
|
1325
1325
|
return ce(J, "background-color") || "#ffffff";
|
|
1326
1326
|
}
|
|
1327
1327
|
return "#ffffff";
|
|
1328
1328
|
}) : "#ffffff";
|
|
1329
1329
|
}), Rt = t.map(() => {
|
|
1330
|
-
const
|
|
1331
|
-
return
|
|
1332
|
-
const
|
|
1333
|
-
if (R(
|
|
1334
|
-
const J = N(
|
|
1330
|
+
const o = M.value;
|
|
1331
|
+
return o ? o.getEditorState().read(() => {
|
|
1332
|
+
const p = A();
|
|
1333
|
+
if (R(p)) {
|
|
1334
|
+
const J = N(p).getStyle();
|
|
1335
1335
|
return ce(J, "line-height") || "";
|
|
1336
1336
|
}
|
|
1337
1337
|
return "";
|
|
1338
1338
|
}) : "";
|
|
1339
|
-
}), It = (
|
|
1340
|
-
const
|
|
1341
|
-
|
|
1339
|
+
}), It = (o) => {
|
|
1340
|
+
const p = M.value;
|
|
1341
|
+
p && (p.update(() => {
|
|
1342
1342
|
const H = A();
|
|
1343
|
-
R(H) &&
|
|
1344
|
-
}),
|
|
1345
|
-
}, Dt = (
|
|
1346
|
-
const
|
|
1347
|
-
|
|
1343
|
+
R(H) && ve(H, { color: o });
|
|
1344
|
+
}), p.focus());
|
|
1345
|
+
}, Dt = (o) => {
|
|
1346
|
+
const p = M.value;
|
|
1347
|
+
p && (p.update(() => {
|
|
1348
1348
|
const H = A();
|
|
1349
|
-
R(H) &&
|
|
1350
|
-
}),
|
|
1351
|
-
}, Ft = (
|
|
1352
|
-
const
|
|
1353
|
-
|
|
1349
|
+
R(H) && ve(H, { "background-color": o });
|
|
1350
|
+
}), p.focus());
|
|
1351
|
+
}, Ft = (o) => {
|
|
1352
|
+
const p = M.value;
|
|
1353
|
+
p && (p.update(() => {
|
|
1354
1354
|
const H = A();
|
|
1355
1355
|
if (R(H)) {
|
|
1356
1356
|
const J = N(H), ie = J.getStyle(), re = he(
|
|
1357
1357
|
ie,
|
|
1358
1358
|
"background-color",
|
|
1359
|
-
|
|
1359
|
+
o
|
|
1360
1360
|
);
|
|
1361
1361
|
J.setStyle(re);
|
|
1362
1362
|
}
|
|
1363
|
-
}),
|
|
1364
|
-
}, Ht = (
|
|
1365
|
-
const
|
|
1366
|
-
|
|
1363
|
+
}), p.focus());
|
|
1364
|
+
}, Ht = (o) => {
|
|
1365
|
+
const p = M.value;
|
|
1366
|
+
p && (p.update(() => {
|
|
1367
1367
|
const H = A();
|
|
1368
1368
|
if (R(H)) {
|
|
1369
1369
|
const J = N(H), ie = J.getStyle(), re = he(
|
|
1370
1370
|
ie,
|
|
1371
1371
|
"line-height",
|
|
1372
|
-
|
|
1372
|
+
o
|
|
1373
1373
|
);
|
|
1374
1374
|
J.setStyle(re);
|
|
1375
1375
|
}
|
|
1376
|
-
}),
|
|
1376
|
+
}), p.focus());
|
|
1377
1377
|
}, P = /* @__PURE__ */ new Map();
|
|
1378
1378
|
P.set(
|
|
1379
1379
|
"bold",
|
|
1380
|
-
() =>
|
|
1381
|
-
active:
|
|
1382
|
-
onClick:
|
|
1383
|
-
label:
|
|
1380
|
+
() => b({
|
|
1381
|
+
active: E("bold"),
|
|
1382
|
+
onClick: T(te, "bold"),
|
|
1383
|
+
label: h.map((o) => o.bold),
|
|
1384
1384
|
icon: "mdi:format-bold"
|
|
1385
1385
|
})
|
|
1386
1386
|
), P.set(
|
|
1387
1387
|
"italic",
|
|
1388
|
-
() =>
|
|
1389
|
-
active:
|
|
1390
|
-
onClick:
|
|
1391
|
-
label:
|
|
1388
|
+
() => b({
|
|
1389
|
+
active: E("italic"),
|
|
1390
|
+
onClick: T(te, "italic"),
|
|
1391
|
+
label: h.map((o) => o.italic),
|
|
1392
1392
|
icon: "mdi:format-italic"
|
|
1393
1393
|
})
|
|
1394
1394
|
), P.set(
|
|
1395
1395
|
"underline",
|
|
1396
|
-
() =>
|
|
1397
|
-
active:
|
|
1398
|
-
onClick:
|
|
1399
|
-
label:
|
|
1396
|
+
() => b({
|
|
1397
|
+
active: E("underline"),
|
|
1398
|
+
onClick: T(te, "underline"),
|
|
1399
|
+
label: h.map((o) => o.underline),
|
|
1400
1400
|
icon: "mdi:format-underline"
|
|
1401
1401
|
})
|
|
1402
1402
|
), P.set(
|
|
1403
1403
|
"strikethrough",
|
|
1404
|
-
() =>
|
|
1405
|
-
active:
|
|
1406
|
-
onClick:
|
|
1407
|
-
label:
|
|
1404
|
+
() => b({
|
|
1405
|
+
active: E("strikethrough"),
|
|
1406
|
+
onClick: T(te, "strikethrough"),
|
|
1407
|
+
label: h.map((o) => o.strikethrough),
|
|
1408
1408
|
icon: "mdi:format-strikethrough"
|
|
1409
1409
|
})
|
|
1410
1410
|
), P.set(
|
|
1411
1411
|
"code",
|
|
1412
|
-
() =>
|
|
1413
|
-
active:
|
|
1414
|
-
onClick:
|
|
1415
|
-
label:
|
|
1412
|
+
() => b({
|
|
1413
|
+
active: E("code"),
|
|
1414
|
+
onClick: T(te, "code"),
|
|
1415
|
+
label: h.map((o) => o.code),
|
|
1416
1416
|
icon: "mdi:code-tags"
|
|
1417
1417
|
})
|
|
1418
1418
|
), P.set(
|
|
1419
1419
|
"clear-formatting",
|
|
1420
|
-
() =>
|
|
1420
|
+
() => b({
|
|
1421
1421
|
active: z(!1),
|
|
1422
|
-
onClick:
|
|
1423
|
-
label:
|
|
1422
|
+
onClick: c,
|
|
1423
|
+
label: h.map((o) => o.clearFormatting),
|
|
1424
1424
|
icon: "mdi:format-clear"
|
|
1425
1425
|
})
|
|
1426
1426
|
), P.set(
|
|
1427
1427
|
"paragraph",
|
|
1428
|
-
() =>
|
|
1429
|
-
active:
|
|
1430
|
-
onClick:
|
|
1431
|
-
label:
|
|
1428
|
+
() => b({
|
|
1429
|
+
active: m("paragraph"),
|
|
1430
|
+
onClick: w,
|
|
1431
|
+
label: h.map((o) => o.normal),
|
|
1432
1432
|
icon: "mdi:format-paragraph"
|
|
1433
1433
|
})
|
|
1434
1434
|
);
|
|
1435
|
-
for (let
|
|
1435
|
+
for (let o = 1; o <= s; o++)
|
|
1436
1436
|
P.set(
|
|
1437
|
-
`heading-${
|
|
1438
|
-
() =>
|
|
1439
|
-
active:
|
|
1440
|
-
onClick: () =>
|
|
1441
|
-
label:
|
|
1442
|
-
icon: `mdi:format-header-${
|
|
1437
|
+
`heading-${o}`,
|
|
1438
|
+
() => b({
|
|
1439
|
+
active: y(o),
|
|
1440
|
+
onClick: () => a(o),
|
|
1441
|
+
label: h.map((p) => p.heading(o)),
|
|
1442
|
+
icon: `mdi:format-header-${o}`
|
|
1443
1443
|
})
|
|
1444
1444
|
);
|
|
1445
1445
|
P.set(
|
|
1446
1446
|
"bullet-list",
|
|
1447
|
-
() =>
|
|
1448
|
-
active:
|
|
1449
|
-
onClick:
|
|
1450
|
-
label:
|
|
1447
|
+
() => b({
|
|
1448
|
+
active: C("bullet"),
|
|
1449
|
+
onClick: T(Ee, void 0),
|
|
1450
|
+
label: h.map((o) => o.bulletList),
|
|
1451
1451
|
icon: "mdi:format-list-bulleted"
|
|
1452
1452
|
})
|
|
1453
1453
|
), P.set(
|
|
1454
1454
|
"ordered-list",
|
|
1455
|
-
() =>
|
|
1456
|
-
active:
|
|
1457
|
-
onClick:
|
|
1458
|
-
label:
|
|
1455
|
+
() => b({
|
|
1456
|
+
active: C("number"),
|
|
1457
|
+
onClick: T(ke, void 0),
|
|
1458
|
+
label: h.map((o) => o.orderedList),
|
|
1459
1459
|
icon: "mdi:format-list-numbered"
|
|
1460
1460
|
})
|
|
1461
1461
|
), P.set(
|
|
1462
1462
|
"check-list",
|
|
1463
|
-
() =>
|
|
1464
|
-
active:
|
|
1465
|
-
onClick:
|
|
1466
|
-
label:
|
|
1463
|
+
() => b({
|
|
1464
|
+
active: C("check"),
|
|
1465
|
+
onClick: T(yt, void 0),
|
|
1466
|
+
label: h.map((o) => o.checkList),
|
|
1467
1467
|
icon: "mdi:format-list-checks"
|
|
1468
1468
|
})
|
|
1469
1469
|
), P.set(
|
|
1470
1470
|
"indent",
|
|
1471
|
-
() =>
|
|
1471
|
+
() => b({
|
|
1472
1472
|
active: z(!1),
|
|
1473
|
-
onClick:
|
|
1474
|
-
label:
|
|
1473
|
+
onClick: T(yo, void 0),
|
|
1474
|
+
label: h.map((o) => o.indent),
|
|
1475
1475
|
icon: "mdi:format-indent-increase"
|
|
1476
1476
|
})
|
|
1477
1477
|
), P.set(
|
|
1478
1478
|
"outdent",
|
|
1479
|
-
() =>
|
|
1479
|
+
() => b({
|
|
1480
1480
|
active: z(!1),
|
|
1481
|
-
onClick:
|
|
1482
|
-
label:
|
|
1481
|
+
onClick: T(xo, void 0),
|
|
1482
|
+
label: h.map((o) => o.outdent),
|
|
1483
1483
|
icon: "mdi:format-indent-decrease"
|
|
1484
1484
|
})
|
|
1485
1485
|
), P.set(
|
|
1486
1486
|
"blockquote",
|
|
1487
|
-
() =>
|
|
1488
|
-
active:
|
|
1489
|
-
onClick:
|
|
1490
|
-
label:
|
|
1487
|
+
() => b({
|
|
1488
|
+
active: m("quote"),
|
|
1489
|
+
onClick: O("quote", Be),
|
|
1490
|
+
label: h.map((o) => o.blockquote),
|
|
1491
1491
|
icon: "mdi:format-quote-close"
|
|
1492
1492
|
})
|
|
1493
1493
|
), P.set(
|
|
1494
1494
|
"code-block",
|
|
1495
|
-
() =>
|
|
1496
|
-
active:
|
|
1497
|
-
onClick:
|
|
1498
|
-
label:
|
|
1495
|
+
() => b({
|
|
1496
|
+
active: m("code"),
|
|
1497
|
+
onClick: O("code", Ue),
|
|
1498
|
+
label: h.map((o) => o.codeBlock),
|
|
1499
1499
|
icon: "mdi:code-braces"
|
|
1500
1500
|
})
|
|
1501
1501
|
), P.set(
|
|
1502
1502
|
"horizontal-rule",
|
|
1503
|
-
() =>
|
|
1503
|
+
() => b({
|
|
1504
1504
|
active: z(!1),
|
|
1505
|
-
onClick:
|
|
1506
|
-
label:
|
|
1505
|
+
onClick: T(Oe, void 0),
|
|
1506
|
+
label: h.map((o) => o.horizontalRule),
|
|
1507
1507
|
icon: "mdi:minus"
|
|
1508
1508
|
})
|
|
1509
1509
|
), P.set(
|
|
1510
1510
|
"insert-table",
|
|
1511
|
-
() =>
|
|
1511
|
+
() => b({
|
|
1512
1512
|
active: z(!1),
|
|
1513
|
-
onClick:
|
|
1514
|
-
label:
|
|
1513
|
+
onClick: i,
|
|
1514
|
+
label: h.map((o) => o.insertTable),
|
|
1515
1515
|
icon: "mdi:table-plus"
|
|
1516
1516
|
})
|
|
1517
1517
|
), P.set(
|
|
1518
1518
|
"link",
|
|
1519
|
-
() =>
|
|
1520
|
-
active:
|
|
1521
|
-
onClick:
|
|
1522
|
-
label:
|
|
1519
|
+
() => b({
|
|
1520
|
+
active: x(),
|
|
1521
|
+
onClick: I,
|
|
1522
|
+
label: h.map((o) => o.link),
|
|
1523
1523
|
icon: "mdi:link"
|
|
1524
1524
|
})
|
|
1525
1525
|
), P.set(
|
|
1526
1526
|
"undo",
|
|
1527
|
-
() =>
|
|
1527
|
+
() => b({
|
|
1528
1528
|
active: z(!1),
|
|
1529
|
-
onClick:
|
|
1530
|
-
label:
|
|
1529
|
+
onClick: T(vo, void 0),
|
|
1530
|
+
label: h.map((o) => o.undo),
|
|
1531
1531
|
icon: "mdi:undo"
|
|
1532
1532
|
})
|
|
1533
1533
|
), P.set(
|
|
1534
1534
|
"redo",
|
|
1535
|
-
() =>
|
|
1535
|
+
() => b({
|
|
1536
1536
|
active: z(!1),
|
|
1537
|
-
onClick:
|
|
1538
|
-
label:
|
|
1537
|
+
onClick: T(Co, void 0),
|
|
1538
|
+
label: h.map((o) => o.redo),
|
|
1539
1539
|
icon: "mdi:redo"
|
|
1540
1540
|
})
|
|
1541
1541
|
), P.set(
|
|
1542
1542
|
"cut",
|
|
1543
|
-
() =>
|
|
1543
|
+
() => b({
|
|
1544
1544
|
active: z(!1),
|
|
1545
|
-
onClick:
|
|
1546
|
-
label:
|
|
1545
|
+
onClick: S,
|
|
1546
|
+
label: h.map((o) => o.cut),
|
|
1547
1547
|
icon: "mdi:content-cut"
|
|
1548
1548
|
})
|
|
1549
1549
|
), P.set(
|
|
1550
1550
|
"copy",
|
|
1551
|
-
() =>
|
|
1551
|
+
() => b({
|
|
1552
1552
|
active: z(!1),
|
|
1553
|
-
onClick:
|
|
1554
|
-
label:
|
|
1553
|
+
onClick: F,
|
|
1554
|
+
label: h.map((o) => o.copy),
|
|
1555
1555
|
icon: "mdi:content-copy"
|
|
1556
1556
|
})
|
|
1557
1557
|
), P.set(
|
|
1558
1558
|
"paste",
|
|
1559
|
-
() =>
|
|
1559
|
+
() => b({
|
|
1560
1560
|
active: z(!1),
|
|
1561
|
-
onClick:
|
|
1562
|
-
label:
|
|
1561
|
+
onClick: u,
|
|
1562
|
+
label: h.map((o) => o.paste),
|
|
1563
1563
|
icon: "mdi:content-paste"
|
|
1564
1564
|
})
|
|
1565
1565
|
), P.set(
|
|
1566
1566
|
"font-family",
|
|
1567
1567
|
() => D.select(
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
(
|
|
1568
|
+
f.class("bc-lexical-toolbar-select"),
|
|
1569
|
+
f.title(h.map((o) => o.fontFamily)),
|
|
1570
|
+
f.disabled(l),
|
|
1571
|
+
ee.change(
|
|
1572
|
+
(o) => wt(o.target.value)
|
|
1573
1573
|
),
|
|
1574
|
-
...
|
|
1575
|
-
(
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1574
|
+
...V.map(
|
|
1575
|
+
(o) => D.option(
|
|
1576
|
+
f.value(o.value),
|
|
1577
|
+
f.selected($.map((p) => p === o.value)),
|
|
1578
|
+
o.label
|
|
1579
1579
|
)
|
|
1580
1580
|
)
|
|
1581
1581
|
)
|
|
1582
1582
|
), P.set(
|
|
1583
1583
|
"font-size",
|
|
1584
1584
|
() => D.select(
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
...
|
|
1590
|
-
(
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1585
|
+
f.class("bc-lexical-toolbar-select"),
|
|
1586
|
+
f.title(h.map((o) => o.fontSize)),
|
|
1587
|
+
f.disabled(l),
|
|
1588
|
+
ee.change((o) => Mt(o.target.value)),
|
|
1589
|
+
...d.map(
|
|
1590
|
+
(o) => D.option(
|
|
1591
|
+
f.value(o.value),
|
|
1592
|
+
f.selected(G.map((p) => p === o.value)),
|
|
1593
|
+
o.label
|
|
1594
1594
|
)
|
|
1595
1595
|
)
|
|
1596
1596
|
)
|
|
1597
1597
|
), P.set(
|
|
1598
1598
|
"line-height",
|
|
1599
1599
|
() => D.select(
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
(
|
|
1600
|
+
f.class("bc-lexical-toolbar-select"),
|
|
1601
|
+
f.title(h.map((o) => o.lineHeight)),
|
|
1602
|
+
f.disabled(l),
|
|
1603
|
+
ee.change(
|
|
1604
|
+
(o) => Ht(o.target.value)
|
|
1605
1605
|
),
|
|
1606
|
-
...
|
|
1607
|
-
(
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1606
|
+
...B.map(
|
|
1607
|
+
(o) => D.option(
|
|
1608
|
+
f.value(o.value),
|
|
1609
|
+
f.selected(Rt.map((p) => p === o.value)),
|
|
1610
|
+
o.label
|
|
1611
1611
|
)
|
|
1612
1612
|
)
|
|
1613
1613
|
)
|
|
1614
1614
|
), P.set(
|
|
1615
1615
|
"font-color",
|
|
1616
1616
|
() => D.label(
|
|
1617
|
-
|
|
1618
|
-
|
|
1617
|
+
f.class("bc-lexical-toolbar-color"),
|
|
1618
|
+
f.title(h.map((o) => o.fontColor)),
|
|
1619
1619
|
D.input(
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1620
|
+
f.type("color"),
|
|
1621
|
+
f.value(Lt),
|
|
1622
|
+
f.disabled(l),
|
|
1623
|
+
ee.input((o) => It(o.target.value))
|
|
1624
1624
|
),
|
|
1625
|
-
D.span(
|
|
1625
|
+
D.span(f.class("bc-lexical-toolbar-color-icon"), "A")
|
|
1626
1626
|
)
|
|
1627
1627
|
), P.set(
|
|
1628
1628
|
"highlight-color",
|
|
1629
1629
|
() => D.label(
|
|
1630
|
-
|
|
1631
|
-
|
|
1630
|
+
f.class("bc-lexical-toolbar-color"),
|
|
1631
|
+
f.title(h.map((o) => o.highlightColor)),
|
|
1632
1632
|
D.input(
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1633
|
+
f.type("color"),
|
|
1634
|
+
f.value(_t),
|
|
1635
|
+
f.disabled(l),
|
|
1636
|
+
ee.input((o) => Dt(o.target.value))
|
|
1637
1637
|
),
|
|
1638
1638
|
D.span(
|
|
1639
|
-
|
|
1639
|
+
f.class(
|
|
1640
1640
|
"bc-lexical-toolbar-color-icon bc-lexical-toolbar-color-icon--highlight"
|
|
1641
1641
|
),
|
|
1642
1642
|
"A"
|
|
@@ -1645,16 +1645,16 @@ function gn({
|
|
|
1645
1645
|
), P.set(
|
|
1646
1646
|
"background-color",
|
|
1647
1647
|
() => D.label(
|
|
1648
|
-
|
|
1649
|
-
|
|
1648
|
+
f.class("bc-lexical-toolbar-color"),
|
|
1649
|
+
f.title(h.map((o) => o.backgroundColor)),
|
|
1650
1650
|
D.input(
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1651
|
+
f.type("color"),
|
|
1652
|
+
f.value(At),
|
|
1653
|
+
f.disabled(l),
|
|
1654
|
+
ee.input((o) => Ft(o.target.value))
|
|
1655
1655
|
),
|
|
1656
1656
|
D.span(
|
|
1657
|
-
|
|
1657
|
+
f.class(
|
|
1658
1658
|
"bc-lexical-toolbar-color-icon bc-lexical-toolbar-color-icon--bg"
|
|
1659
1659
|
),
|
|
1660
1660
|
"■"
|
|
@@ -1662,297 +1662,297 @@ function gn({
|
|
|
1662
1662
|
)
|
|
1663
1663
|
);
|
|
1664
1664
|
const ct = {
|
|
1665
|
-
editor:
|
|
1665
|
+
editor: M,
|
|
1666
1666
|
stateUpdate: t,
|
|
1667
|
-
readOnly:
|
|
1668
|
-
size:
|
|
1669
|
-
button: (
|
|
1670
|
-
active:
|
|
1671
|
-
onClick:
|
|
1672
|
-
label:
|
|
1673
|
-
icon:
|
|
1667
|
+
readOnly: l,
|
|
1668
|
+
size: n,
|
|
1669
|
+
button: (o) => b({
|
|
1670
|
+
active: o.active ?? z(!1),
|
|
1671
|
+
onClick: o.onClick,
|
|
1672
|
+
label: o.label,
|
|
1673
|
+
icon: o.icon
|
|
1674
1674
|
})
|
|
1675
|
-
}, ut = (
|
|
1676
|
-
if (
|
|
1677
|
-
const
|
|
1675
|
+
}, ut = (o) => {
|
|
1676
|
+
if (o.type === "button") {
|
|
1677
|
+
const p = o;
|
|
1678
1678
|
P.set(
|
|
1679
|
-
|
|
1680
|
-
() =>
|
|
1681
|
-
active:
|
|
1682
|
-
onClick: () =>
|
|
1683
|
-
label:
|
|
1684
|
-
icon:
|
|
1679
|
+
o.id,
|
|
1680
|
+
() => b({
|
|
1681
|
+
active: p.active?.(ct) ?? z(!1),
|
|
1682
|
+
onClick: () => p.onClick(M.value),
|
|
1683
|
+
label: p.label,
|
|
1684
|
+
icon: p.icon
|
|
1685
1685
|
})
|
|
1686
1686
|
);
|
|
1687
|
-
} else if (
|
|
1688
|
-
const
|
|
1687
|
+
} else if (o.type === "select") {
|
|
1688
|
+
const p = o, H = p.resetOnSelect !== !1;
|
|
1689
1689
|
P.set(
|
|
1690
|
-
|
|
1690
|
+
o.id,
|
|
1691
1691
|
() => D.select(
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1692
|
+
f.class("bc-lexical-toolbar-select"),
|
|
1693
|
+
f.title(p.label),
|
|
1694
|
+
f.disabled(l),
|
|
1695
|
+
ee.change((J) => {
|
|
1696
1696
|
const ie = J.target, re = ie.value;
|
|
1697
|
-
re !== "" && (
|
|
1697
|
+
re !== "" && (p.onSelect(re, M.value), H && (ie.value = ""));
|
|
1698
1698
|
}),
|
|
1699
1699
|
D.option(
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1700
|
+
f.value(""),
|
|
1701
|
+
f.disabled(H),
|
|
1702
|
+
f.selected(!0),
|
|
1703
|
+
p.label
|
|
1704
1704
|
),
|
|
1705
|
-
...
|
|
1706
|
-
(J) => D.option(
|
|
1705
|
+
...p.options.map(
|
|
1706
|
+
(J) => D.option(f.value(J.value), J.label)
|
|
1707
1707
|
)
|
|
1708
1708
|
)
|
|
1709
1709
|
);
|
|
1710
|
-
} else if (
|
|
1711
|
-
const
|
|
1712
|
-
P.set(
|
|
1710
|
+
} else if (o.type === "custom") {
|
|
1711
|
+
const p = o;
|
|
1712
|
+
P.set(o.id, () => p.render(ct));
|
|
1713
1713
|
}
|
|
1714
1714
|
};
|
|
1715
|
-
if (
|
|
1716
|
-
for (const
|
|
1717
|
-
ut(
|
|
1718
|
-
if (
|
|
1719
|
-
for (const
|
|
1720
|
-
for (const
|
|
1721
|
-
ut(
|
|
1715
|
+
if (r.customItems)
|
|
1716
|
+
for (const o of r.customItems)
|
|
1717
|
+
ut(o);
|
|
1718
|
+
if (r.customGroups)
|
|
1719
|
+
for (const o of r.customGroups)
|
|
1720
|
+
for (const p of o.items)
|
|
1721
|
+
ut(p);
|
|
1722
1722
|
return Bo(
|
|
1723
1723
|
{},
|
|
1724
|
-
|
|
1725
|
-
...hn(
|
|
1724
|
+
f.class("bc-lexical-toolbar"),
|
|
1725
|
+
...hn(g, P, s, r.customGroups)
|
|
1726
1726
|
);
|
|
1727
1727
|
})
|
|
1728
1728
|
);
|
|
1729
1729
|
}
|
|
1730
|
-
function hn(e, t,
|
|
1731
|
-
const
|
|
1732
|
-
if (
|
|
1733
|
-
for (const
|
|
1734
|
-
|
|
1730
|
+
function hn(e, t, r, l) {
|
|
1731
|
+
const n = /* @__PURE__ */ new Map();
|
|
1732
|
+
if (l)
|
|
1733
|
+
for (const g of l)
|
|
1734
|
+
n.set(g.id, g);
|
|
1735
1735
|
const s = [];
|
|
1736
|
-
for (const
|
|
1737
|
-
if ("separator" in
|
|
1736
|
+
for (const g of e) {
|
|
1737
|
+
if ("separator" in g) {
|
|
1738
1738
|
s.push($o());
|
|
1739
1739
|
continue;
|
|
1740
1740
|
}
|
|
1741
|
-
if ("customGroup" in
|
|
1742
|
-
const
|
|
1743
|
-
if (!
|
|
1741
|
+
if ("customGroup" in g) {
|
|
1742
|
+
const h = n.get(g.customGroup);
|
|
1743
|
+
if (!h) continue;
|
|
1744
1744
|
const N = [];
|
|
1745
|
-
for (const
|
|
1746
|
-
const
|
|
1747
|
-
|
|
1745
|
+
for (const m of h.items) {
|
|
1746
|
+
const C = t.get(m.id);
|
|
1747
|
+
C && N.push(C());
|
|
1748
1748
|
}
|
|
1749
1749
|
if (N.length === 0) continue;
|
|
1750
|
-
const
|
|
1751
|
-
s.push(gt({ display:
|
|
1750
|
+
const E = N.map(() => z(!0));
|
|
1751
|
+
s.push(gt({ display: E }, ...N));
|
|
1752
1752
|
continue;
|
|
1753
1753
|
}
|
|
1754
|
-
let
|
|
1755
|
-
|
|
1756
|
-
const
|
|
1757
|
-
for (const
|
|
1758
|
-
const N = t.get(
|
|
1759
|
-
N &&
|
|
1754
|
+
let v = g.items ?? sn[g.group] ?? [];
|
|
1755
|
+
g.group === "headings" && !g.items && (v = v.filter((h) => h.startsWith("heading-") ? parseInt(h.split("-")[1], 10) <= r : !0));
|
|
1756
|
+
const L = [];
|
|
1757
|
+
for (const h of v) {
|
|
1758
|
+
const N = t.get(h);
|
|
1759
|
+
N && L.push(N());
|
|
1760
1760
|
}
|
|
1761
|
-
if (
|
|
1762
|
-
const
|
|
1763
|
-
s.push(gt({ display:
|
|
1761
|
+
if (L.length === 0) continue;
|
|
1762
|
+
const M = L.map(() => z(!0));
|
|
1763
|
+
s.push(gt({ display: M }, ...L));
|
|
1764
1764
|
}
|
|
1765
1765
|
return s;
|
|
1766
1766
|
}
|
|
1767
1767
|
function Ot({
|
|
1768
1768
|
editor: e,
|
|
1769
1769
|
stateUpdate: t,
|
|
1770
|
-
readOnly:
|
|
1770
|
+
readOnly: r = z(!1)
|
|
1771
1771
|
}) {
|
|
1772
|
-
const
|
|
1773
|
-
let
|
|
1774
|
-
const
|
|
1775
|
-
let
|
|
1776
|
-
return
|
|
1777
|
-
const
|
|
1778
|
-
if (!R(
|
|
1779
|
-
let
|
|
1780
|
-
for (;
|
|
1781
|
-
if (qt(
|
|
1782
|
-
|
|
1772
|
+
const l = j(!1), n = j(0), s = j(0);
|
|
1773
|
+
let g = null;
|
|
1774
|
+
const v = j(!1), L = (I) => {
|
|
1775
|
+
let k = null;
|
|
1776
|
+
return I.getEditorState().read(() => {
|
|
1777
|
+
const b = A();
|
|
1778
|
+
if (!R(b)) return;
|
|
1779
|
+
let w = b.anchor.getNode();
|
|
1780
|
+
for (; w; ) {
|
|
1781
|
+
if (qt(w)) {
|
|
1782
|
+
k = w;
|
|
1783
1783
|
break;
|
|
1784
1784
|
}
|
|
1785
|
-
if (
|
|
1785
|
+
if (w = w.getParent(), !w || w.getKey() === "root") break;
|
|
1786
1786
|
}
|
|
1787
|
-
}),
|
|
1788
|
-
},
|
|
1789
|
-
const
|
|
1790
|
-
return
|
|
1791
|
-
},
|
|
1792
|
-
const
|
|
1793
|
-
if (!
|
|
1794
|
-
|
|
1787
|
+
}), k;
|
|
1788
|
+
}, M = (I, k) => {
|
|
1789
|
+
const b = I.getBoundingClientRect(), w = k.closest(".bc-lexical-editor-container"), a = w ? w.getBoundingClientRect() : k.getBoundingClientRect();
|
|
1790
|
+
return n.value = b.top - a.top + 2, s.value = a.right - b.right + 2, !0;
|
|
1791
|
+
}, h = () => {
|
|
1792
|
+
const I = e.value;
|
|
1793
|
+
if (!I) {
|
|
1794
|
+
l.value = !1;
|
|
1795
1795
|
return;
|
|
1796
1796
|
}
|
|
1797
|
-
const
|
|
1798
|
-
if (!
|
|
1799
|
-
|
|
1797
|
+
const k = L(I);
|
|
1798
|
+
if (!k) {
|
|
1799
|
+
v.value || (l.value = !1);
|
|
1800
1800
|
return;
|
|
1801
1801
|
}
|
|
1802
|
-
const
|
|
1803
|
-
|
|
1802
|
+
const b = I.getElementByKey(k.getKey()), w = I.getRootElement();
|
|
1803
|
+
b && w ? (M(b, w), l.value = !0) : l.value = !1;
|
|
1804
1804
|
};
|
|
1805
|
-
t.onChange(
|
|
1806
|
-
const
|
|
1807
|
-
const
|
|
1808
|
-
|
|
1809
|
-
},
|
|
1805
|
+
t.onChange(h);
|
|
1806
|
+
const N = (I) => () => {
|
|
1807
|
+
const k = e.value;
|
|
1808
|
+
k && (k.update(I), g?.set(!1), k.focus());
|
|
1809
|
+
}, E = N(() => ft(!1)), m = N(() => ft(!0)), C = N(
|
|
1810
1810
|
() => mt(!1)
|
|
1811
|
-
),
|
|
1811
|
+
), y = N(
|
|
1812
1812
|
() => mt(!0)
|
|
1813
|
-
),
|
|
1814
|
-
const
|
|
1815
|
-
if (!R(
|
|
1816
|
-
const
|
|
1817
|
-
if (!
|
|
1818
|
-
Zt(
|
|
1813
|
+
), x = N(() => Yt()), T = N(() => Wt()), O = N(() => {
|
|
1814
|
+
const I = A();
|
|
1815
|
+
if (!R(I)) return;
|
|
1816
|
+
const k = I.anchor.getNode(), b = Vt(k);
|
|
1817
|
+
if (!b) return;
|
|
1818
|
+
Zt(b).remove();
|
|
1819
1819
|
});
|
|
1820
1820
|
return ue(
|
|
1821
1821
|
ye,
|
|
1822
|
-
(
|
|
1823
|
-
const
|
|
1824
|
-
const
|
|
1825
|
-
if (!
|
|
1826
|
-
const
|
|
1827
|
-
if (!
|
|
1828
|
-
const
|
|
1829
|
-
|
|
1830
|
-
|
|
1822
|
+
(I) => Se(e, (k) => {
|
|
1823
|
+
const b = k, w = I.$.lexical, a = (c) => {
|
|
1824
|
+
const i = b.value;
|
|
1825
|
+
if (!i || r.value) return;
|
|
1826
|
+
const _ = i.getRootElement();
|
|
1827
|
+
if (!_) return;
|
|
1828
|
+
const d = c.target.closest("td, th");
|
|
1829
|
+
d && _.contains(d) && (c.preventDefault(), M(d, _) && (l.value = !0), Po(() => {
|
|
1830
|
+
g?.set(!0);
|
|
1831
1831
|
}));
|
|
1832
|
-
},
|
|
1832
|
+
}, F = b.value?.getRootElement(), u = F?.closest(
|
|
1833
1833
|
".bc-lexical-editor-container"
|
|
1834
|
-
) ??
|
|
1835
|
-
return u.addEventListener("contextmenu",
|
|
1834
|
+
) ?? F ?? document;
|
|
1835
|
+
return u.addEventListener("contextmenu", a), [
|
|
1836
1836
|
ne(() => {
|
|
1837
|
-
u.removeEventListener("contextmenu",
|
|
1837
|
+
u.removeEventListener("contextmenu", a);
|
|
1838
1838
|
}),
|
|
1839
1839
|
pe(
|
|
1840
|
-
|
|
1840
|
+
l,
|
|
1841
1841
|
() => D.div(
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1842
|
+
f.class("bc-table-cell-marker"),
|
|
1843
|
+
Y.position("absolute"),
|
|
1844
|
+
Y.top(n.map((c) => `${c}px`)),
|
|
1845
|
+
Y.right(s.map((c) => `${c}px`)),
|
|
1846
|
+
Y.zIndex("10"),
|
|
1847
1847
|
// Prevent mousedown from stealing focus from editor
|
|
1848
|
-
oe((
|
|
1849
|
-
|
|
1850
|
-
|
|
1848
|
+
oe((c) => {
|
|
1849
|
+
c.addEventListener("mousedown", (i) => {
|
|
1850
|
+
i.preventDefault();
|
|
1851
1851
|
});
|
|
1852
1852
|
}),
|
|
1853
1853
|
D.button(
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1854
|
+
f.class("bc-table-cell-marker__button"),
|
|
1855
|
+
f.type("button"),
|
|
1856
|
+
f.title(w.map((c) => c.tableActions)),
|
|
1857
|
+
f.disabled(r),
|
|
1858
1858
|
Z({ icon: "lucide:chevron-down", size: "xs" }),
|
|
1859
1859
|
// Track menu open state via aria-expanded
|
|
1860
|
-
oe((
|
|
1861
|
-
const
|
|
1862
|
-
const
|
|
1863
|
-
|
|
1860
|
+
oe((c) => {
|
|
1861
|
+
const i = new MutationObserver(() => {
|
|
1862
|
+
const _ = c.getAttribute("aria-expanded") === "true";
|
|
1863
|
+
v.value = _;
|
|
1864
1864
|
});
|
|
1865
|
-
return
|
|
1865
|
+
return i.observe(c, {
|
|
1866
1866
|
attributes: !0,
|
|
1867
1867
|
attributeFilter: ["aria-expanded"]
|
|
1868
|
-
}), ne(() =>
|
|
1868
|
+
}), ne(() => i.disconnect());
|
|
1869
1869
|
}),
|
|
1870
1870
|
Et({
|
|
1871
1871
|
items: () => [
|
|
1872
1872
|
le({
|
|
1873
1873
|
key: "insert-row-above",
|
|
1874
|
-
content:
|
|
1874
|
+
content: w.map((c) => c.insertRowAbove),
|
|
1875
1875
|
before: Z({
|
|
1876
1876
|
icon: "lucide:arrow-up",
|
|
1877
1877
|
size: "sm"
|
|
1878
1878
|
}),
|
|
1879
|
-
onClick:
|
|
1880
|
-
disabled:
|
|
1879
|
+
onClick: E,
|
|
1880
|
+
disabled: r
|
|
1881
1881
|
}),
|
|
1882
1882
|
le({
|
|
1883
1883
|
key: "insert-row-below",
|
|
1884
|
-
content:
|
|
1884
|
+
content: w.map((c) => c.insertRowBelow),
|
|
1885
1885
|
before: Z({
|
|
1886
1886
|
icon: "lucide:arrow-down",
|
|
1887
1887
|
size: "sm"
|
|
1888
1888
|
}),
|
|
1889
|
-
onClick:
|
|
1890
|
-
disabled:
|
|
1889
|
+
onClick: m,
|
|
1890
|
+
disabled: r
|
|
1891
1891
|
}),
|
|
1892
1892
|
le({
|
|
1893
1893
|
key: "insert-column-left",
|
|
1894
|
-
content:
|
|
1894
|
+
content: w.map((c) => c.insertColumnLeft),
|
|
1895
1895
|
before: Z({
|
|
1896
1896
|
icon: "lucide:arrow-left",
|
|
1897
1897
|
size: "sm"
|
|
1898
1898
|
}),
|
|
1899
|
-
onClick:
|
|
1900
|
-
disabled:
|
|
1899
|
+
onClick: C,
|
|
1900
|
+
disabled: r
|
|
1901
1901
|
}),
|
|
1902
1902
|
le({
|
|
1903
1903
|
key: "insert-column-right",
|
|
1904
|
-
content:
|
|
1904
|
+
content: w.map((c) => c.insertColumnRight),
|
|
1905
1905
|
before: Z({
|
|
1906
1906
|
icon: "lucide:arrow-right",
|
|
1907
1907
|
size: "sm"
|
|
1908
1908
|
}),
|
|
1909
|
-
onClick:
|
|
1910
|
-
disabled:
|
|
1909
|
+
onClick: y,
|
|
1910
|
+
disabled: r
|
|
1911
1911
|
}),
|
|
1912
1912
|
Fo(),
|
|
1913
1913
|
le({
|
|
1914
1914
|
key: "delete-row",
|
|
1915
|
-
content:
|
|
1915
|
+
content: w.map((c) => c.deleteRow),
|
|
1916
1916
|
before: Z({
|
|
1917
1917
|
icon: "lucide:trash-2",
|
|
1918
1918
|
size: "sm"
|
|
1919
1919
|
}),
|
|
1920
|
-
onClick:
|
|
1921
|
-
disabled:
|
|
1920
|
+
onClick: x,
|
|
1921
|
+
disabled: r
|
|
1922
1922
|
}),
|
|
1923
1923
|
le({
|
|
1924
1924
|
key: "delete-column",
|
|
1925
|
-
content:
|
|
1925
|
+
content: w.map((c) => c.deleteColumn),
|
|
1926
1926
|
before: Z({
|
|
1927
1927
|
icon: "lucide:trash-2",
|
|
1928
1928
|
size: "sm"
|
|
1929
1929
|
}),
|
|
1930
|
-
onClick:
|
|
1931
|
-
disabled:
|
|
1930
|
+
onClick: T,
|
|
1931
|
+
disabled: r
|
|
1932
1932
|
}),
|
|
1933
1933
|
le({
|
|
1934
1934
|
key: "delete-table",
|
|
1935
|
-
content:
|
|
1935
|
+
content: w.map((c) => c.deleteTable),
|
|
1936
1936
|
before: Z({
|
|
1937
1937
|
icon: "lucide:trash-2",
|
|
1938
1938
|
size: "sm"
|
|
1939
1939
|
}),
|
|
1940
|
-
onClick:
|
|
1941
|
-
disabled:
|
|
1940
|
+
onClick: O,
|
|
1941
|
+
disabled: r
|
|
1942
1942
|
})
|
|
1943
1943
|
],
|
|
1944
1944
|
placement: "bottom-end",
|
|
1945
|
-
showOn: (
|
|
1946
|
-
|
|
1945
|
+
showOn: (c) => (g = c, ee.click(() => {
|
|
1946
|
+
c.set(!c.value);
|
|
1947
1947
|
})),
|
|
1948
1948
|
showDelay: 0,
|
|
1949
1949
|
hideDelay: 0,
|
|
1950
1950
|
mainAxisOffset: 4,
|
|
1951
1951
|
onClose: () => {
|
|
1952
|
-
const
|
|
1953
|
-
|
|
1952
|
+
const c = b.value;
|
|
1953
|
+
c && c.focus();
|
|
1954
1954
|
},
|
|
1955
|
-
ariaLabel:
|
|
1955
|
+
ariaLabel: w.map((c) => c.tableActions)
|
|
1956
1956
|
})
|
|
1957
1957
|
)
|
|
1958
1958
|
)
|
|
@@ -1964,75 +1964,75 @@ function Ot({
|
|
|
1964
1964
|
const ki = (e) => {
|
|
1965
1965
|
const {
|
|
1966
1966
|
value: t,
|
|
1967
|
-
format:
|
|
1968
|
-
plugins:
|
|
1969
|
-
readOnly:
|
|
1967
|
+
format: r,
|
|
1968
|
+
plugins: l,
|
|
1969
|
+
readOnly: n,
|
|
1970
1970
|
placeholder: s,
|
|
1971
|
-
class:
|
|
1972
|
-
namespace:
|
|
1973
|
-
heightMode:
|
|
1974
|
-
toolbar:
|
|
1975
|
-
autoFocus:
|
|
1971
|
+
class: g,
|
|
1972
|
+
namespace: v = "BeatUILexical",
|
|
1973
|
+
heightMode: L = "fixed",
|
|
1974
|
+
toolbar: M,
|
|
1975
|
+
autoFocus: h = !1,
|
|
1976
1976
|
onError: N,
|
|
1977
|
-
onInput:
|
|
1978
|
-
onChange:
|
|
1979
|
-
onBlur:
|
|
1980
|
-
onReady:
|
|
1981
|
-
} = e,
|
|
1977
|
+
onInput: E,
|
|
1978
|
+
onChange: m,
|
|
1979
|
+
onBlur: C,
|
|
1980
|
+
onReady: y
|
|
1981
|
+
} = e, x = j(null), T = j(0), O = (k) => typeof k == "object" && k !== null && "map" in k && typeof k.map == "function", I = n != null ? O(n) ? n : j(U.get(n)) : j(!1);
|
|
1982
1982
|
return ue(
|
|
1983
1983
|
Ye,
|
|
1984
|
-
({ appearance:
|
|
1984
|
+
({ appearance: k }) => D.div(
|
|
1985
1985
|
// CSS injection via LinkPortal
|
|
1986
1986
|
Ke(
|
|
1987
1987
|
() => import("../styles-url-BIeImEjl.js"),
|
|
1988
|
-
({ default:
|
|
1988
|
+
({ default: b }) => qe({ id: "beatui-lexical-css", href: b })
|
|
1989
1989
|
),
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1990
|
+
f.class("bc-lexical-editor-container"),
|
|
1991
|
+
L === "fixed" ? f.class("bc-lexical-editor-container--fixed") : null,
|
|
1992
|
+
f.class(g),
|
|
1993
1993
|
// Toolbar (hidden in readOnly mode)
|
|
1994
1994
|
pe(
|
|
1995
|
-
|
|
1995
|
+
I.map((b) => !b),
|
|
1996
1996
|
() => gn({
|
|
1997
|
-
editor:
|
|
1998
|
-
stateUpdate:
|
|
1999
|
-
toolbar:
|
|
2000
|
-
readOnly:
|
|
1997
|
+
editor: x,
|
|
1998
|
+
stateUpdate: T,
|
|
1999
|
+
toolbar: M,
|
|
2000
|
+
readOnly: I,
|
|
2001
2001
|
size: "sm"
|
|
2002
2002
|
})
|
|
2003
2003
|
),
|
|
2004
2004
|
// Table context menu (appears when cursor is in a table cell)
|
|
2005
2005
|
Ot({
|
|
2006
|
-
editor:
|
|
2007
|
-
stateUpdate:
|
|
2008
|
-
readOnly:
|
|
2006
|
+
editor: x,
|
|
2007
|
+
stateUpdate: T,
|
|
2008
|
+
readOnly: I
|
|
2009
2009
|
}),
|
|
2010
2010
|
// The editable surface
|
|
2011
2011
|
D.div(
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2012
|
+
f.class("bc-lexical-editor"),
|
|
2013
|
+
f.class(`bc-lexical-editor--${L}`),
|
|
2014
|
+
f.contenteditable(
|
|
2015
|
+
n != null ? (
|
|
2016
2016
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2017
|
-
U.map(
|
|
2017
|
+
U.map(n, (b) => !b)
|
|
2018
2018
|
) : !0
|
|
2019
2019
|
),
|
|
2020
|
-
|
|
2020
|
+
n != null ? f.class(
|
|
2021
2021
|
U.map(
|
|
2022
|
-
|
|
2023
|
-
(
|
|
2022
|
+
n,
|
|
2023
|
+
(b) => b ? "bc-lexical-editor--readonly" : ""
|
|
2024
2024
|
)
|
|
2025
2025
|
) : null,
|
|
2026
|
-
oe((
|
|
2027
|
-
let
|
|
2028
|
-
const
|
|
2026
|
+
oe((b) => {
|
|
2027
|
+
let w = null;
|
|
2028
|
+
const a = [];
|
|
2029
2029
|
return (async () => {
|
|
2030
2030
|
try {
|
|
2031
|
-
const
|
|
2032
|
-
|
|
2033
|
-
),
|
|
2034
|
-
namespace:
|
|
2035
|
-
nodes:
|
|
2031
|
+
const S = l ?? Ve("docked"), u = We(S), c = U.get(
|
|
2032
|
+
r ?? "markdown"
|
|
2033
|
+
), i = Ge({
|
|
2034
|
+
namespace: v,
|
|
2035
|
+
nodes: u,
|
|
2036
2036
|
theme: {
|
|
2037
2037
|
heading: {
|
|
2038
2038
|
h1: "bc-lexical-h1",
|
|
@@ -2068,143 +2068,143 @@ const ki = (e) => {
|
|
|
2068
2068
|
mark: "bc-lexical-mark",
|
|
2069
2069
|
paragraph: "bc-lexical-paragraph"
|
|
2070
2070
|
},
|
|
2071
|
-
onError: (
|
|
2072
|
-
N ? N(
|
|
2071
|
+
onError: (d) => {
|
|
2072
|
+
N ? N(d, i) : console.error("[BeatUI Lexical]", d);
|
|
2073
2073
|
},
|
|
2074
|
-
editable:
|
|
2074
|
+
editable: n ? !U.get(n) : !0,
|
|
2075
2075
|
html: {
|
|
2076
2076
|
export: we(),
|
|
2077
2077
|
import: Me()
|
|
2078
2078
|
}
|
|
2079
2079
|
});
|
|
2080
|
-
|
|
2081
|
-
const
|
|
2082
|
-
if (
|
|
2083
|
-
const
|
|
2084
|
-
|
|
2080
|
+
w = i, x.set(i), i.setRootElement(b);
|
|
2081
|
+
const _ = [];
|
|
2082
|
+
if (S.richText ? _.push(Ze(i)) : S.plainText && _.push(Xe(i)), S.history) {
|
|
2083
|
+
const d = typeof S.history == "object" ? S.history : void 0;
|
|
2084
|
+
_.push(Qe(i, d));
|
|
2085
2085
|
}
|
|
2086
|
-
if (
|
|
2087
|
-
at(
|
|
2088
|
-
),
|
|
2089
|
-
|
|
2090
|
-
}),
|
|
2091
|
-
|
|
2086
|
+
if (S.clipboard && _.push(et(i)), S.list && _.push(tt(i)), S.link && _.push(ot(i)), S.yjs && _.push(
|
|
2087
|
+
at(i, S.yjs)
|
|
2088
|
+
), S.dragon && _.push(lt(i)), S.table && _.push(rt(i)), (await Promise.all(_)).forEach((d) => {
|
|
2089
|
+
d && a.push(d);
|
|
2090
|
+
}), a.push(nt(i)), a.push(st(i)), a.push(
|
|
2091
|
+
i.registerCommand(
|
|
2092
2092
|
kt,
|
|
2093
|
-
() => (
|
|
2093
|
+
() => (T.set(T.value + 1), !1),
|
|
2094
2094
|
K
|
|
2095
2095
|
)
|
|
2096
|
-
),
|
|
2097
|
-
|
|
2098
|
-
({ editorState:
|
|
2099
|
-
(
|
|
2100
|
-
if (
|
|
2101
|
-
const G = await
|
|
2102
|
-
|
|
2103
|
-
} else if (
|
|
2104
|
-
const G = await
|
|
2105
|
-
|
|
2106
|
-
} else
|
|
2107
|
-
|
|
2108
|
-
|
|
2096
|
+
), a.push(
|
|
2097
|
+
i.registerUpdateListener(
|
|
2098
|
+
({ editorState: d, dirtyElements: B, dirtyLeaves: $ }) => {
|
|
2099
|
+
(B.size > 0 || $.size > 0) && T.set(T.value + 1), E && (B.size > 0 || $.size > 0) && d.read(async () => {
|
|
2100
|
+
if (c === "markdown") {
|
|
2101
|
+
const G = await X(i);
|
|
2102
|
+
E(G, i);
|
|
2103
|
+
} else if (c === "html") {
|
|
2104
|
+
const G = await Q(i);
|
|
2105
|
+
E(G, i);
|
|
2106
|
+
} else c === "json" && E(
|
|
2107
|
+
d.toJSON(),
|
|
2108
|
+
i
|
|
2109
2109
|
);
|
|
2110
2110
|
});
|
|
2111
2111
|
}
|
|
2112
2112
|
)
|
|
2113
2113
|
), t != null) {
|
|
2114
|
-
const
|
|
2114
|
+
const d = U.get(
|
|
2115
2115
|
t
|
|
2116
2116
|
);
|
|
2117
|
-
if (
|
|
2118
|
-
if (
|
|
2119
|
-
await ae(
|
|
2120
|
-
else if (
|
|
2121
|
-
await se(
|
|
2122
|
-
else if (
|
|
2117
|
+
if (d != null && (d !== "" || c === "json" && typeof d == "object")) {
|
|
2118
|
+
if (c === "markdown" && typeof d == "string")
|
|
2119
|
+
await ae(i, d);
|
|
2120
|
+
else if (c === "html" && typeof d == "string")
|
|
2121
|
+
await se(i, d);
|
|
2122
|
+
else if (c === "json" && typeof d == "object")
|
|
2123
2123
|
try {
|
|
2124
|
-
const $ = JSON.stringify(
|
|
2125
|
-
|
|
2124
|
+
const $ = JSON.stringify(d), G = i.parseEditorState($);
|
|
2125
|
+
i.setEditorState(G);
|
|
2126
2126
|
} catch ($) {
|
|
2127
2127
|
console.error(
|
|
2128
2128
|
"[BeatUI] Failed to parse JSON editor state:",
|
|
2129
2129
|
$
|
|
2130
2130
|
), N && N(
|
|
2131
2131
|
$ instanceof Error ? $ : new Error(String($)),
|
|
2132
|
-
|
|
2132
|
+
i
|
|
2133
2133
|
);
|
|
2134
2134
|
}
|
|
2135
2135
|
}
|
|
2136
2136
|
}
|
|
2137
|
-
if (t != null &&
|
|
2138
|
-
U.on(t, async (
|
|
2139
|
-
if (
|
|
2140
|
-
if (
|
|
2141
|
-
const
|
|
2142
|
-
|
|
2143
|
-
} else if (
|
|
2144
|
-
const
|
|
2145
|
-
|
|
2146
|
-
} else if (
|
|
2147
|
-
const
|
|
2148
|
-
|
|
2149
|
-
), $ = JSON.stringify(
|
|
2150
|
-
if (
|
|
2151
|
-
const G =
|
|
2152
|
-
|
|
2137
|
+
if (t != null && a.push(
|
|
2138
|
+
U.on(t, async (d) => {
|
|
2139
|
+
if (d != null) {
|
|
2140
|
+
if (c === "markdown" && typeof d == "string") {
|
|
2141
|
+
const B = await X(i);
|
|
2142
|
+
d !== B && await ae(i, d);
|
|
2143
|
+
} else if (c === "html" && typeof d == "string") {
|
|
2144
|
+
const B = await Q(i);
|
|
2145
|
+
d !== B && await se(i, d);
|
|
2146
|
+
} else if (c === "json" && typeof d == "object") {
|
|
2147
|
+
const B = JSON.stringify(
|
|
2148
|
+
i.getEditorState().toJSON()
|
|
2149
|
+
), $ = JSON.stringify(d);
|
|
2150
|
+
if (B !== $) {
|
|
2151
|
+
const G = i.parseEditorState($);
|
|
2152
|
+
i.setEditorState(G);
|
|
2153
2153
|
}
|
|
2154
2154
|
}
|
|
2155
2155
|
}
|
|
2156
2156
|
})
|
|
2157
|
-
),
|
|
2158
|
-
U.on(
|
|
2159
|
-
|
|
2157
|
+
), n != null && a.push(
|
|
2158
|
+
U.on(n, (d) => {
|
|
2159
|
+
i.setEditable(!d);
|
|
2160
2160
|
})
|
|
2161
|
-
),
|
|
2162
|
-
|
|
2161
|
+
), a.push(
|
|
2162
|
+
i.registerCommand(
|
|
2163
2163
|
Je,
|
|
2164
|
-
() => (
|
|
2165
|
-
if (
|
|
2166
|
-
const
|
|
2167
|
-
|
|
2168
|
-
} else if (
|
|
2169
|
-
const
|
|
2170
|
-
|
|
2171
|
-
} else
|
|
2172
|
-
|
|
2173
|
-
|
|
2164
|
+
() => (C && C(i), m && i.getEditorState().read(async () => {
|
|
2165
|
+
if (c === "markdown") {
|
|
2166
|
+
const d = await X(i);
|
|
2167
|
+
m(d, i);
|
|
2168
|
+
} else if (c === "html") {
|
|
2169
|
+
const d = await Q(i);
|
|
2170
|
+
m(d, i);
|
|
2171
|
+
} else c === "json" && m(
|
|
2172
|
+
i.getEditorState().toJSON(),
|
|
2173
|
+
i
|
|
2174
2174
|
);
|
|
2175
2175
|
}), !1),
|
|
2176
2176
|
K
|
|
2177
2177
|
)
|
|
2178
|
-
),
|
|
2179
|
-
|
|
2180
|
-
const
|
|
2181
|
-
|
|
2178
|
+
), a.push(
|
|
2179
|
+
k.on((d) => {
|
|
2180
|
+
const B = i.getRootElement();
|
|
2181
|
+
B && (B.dataset.theme = d);
|
|
2182
2182
|
})
|
|
2183
|
-
),
|
|
2184
|
-
|
|
2183
|
+
), h)
|
|
2184
|
+
i.focus();
|
|
2185
2185
|
else {
|
|
2186
|
-
const
|
|
2187
|
-
|
|
2186
|
+
const d = i.getRootElement();
|
|
2187
|
+
d && d === document.activeElement && d.blur();
|
|
2188
2188
|
}
|
|
2189
|
-
|
|
2190
|
-
} catch (
|
|
2189
|
+
y && y(i);
|
|
2190
|
+
} catch (S) {
|
|
2191
2191
|
console.error(
|
|
2192
2192
|
"[BeatUI] Failed to initialize Lexical editor:",
|
|
2193
|
-
|
|
2193
|
+
S
|
|
2194
2194
|
);
|
|
2195
|
-
const
|
|
2196
|
-
|
|
2195
|
+
const u = b;
|
|
2196
|
+
u.textContent = "Failed to load Lexical editor.";
|
|
2197
2197
|
}
|
|
2198
2198
|
})(), ne(() => {
|
|
2199
2199
|
try {
|
|
2200
|
-
|
|
2200
|
+
a.forEach((S) => S());
|
|
2201
2201
|
} catch {
|
|
2202
2202
|
}
|
|
2203
2203
|
try {
|
|
2204
|
-
|
|
2204
|
+
w?.setRootElement(null);
|
|
2205
2205
|
} catch {
|
|
2206
2206
|
}
|
|
2207
|
-
|
|
2207
|
+
x.set(null);
|
|
2208
2208
|
});
|
|
2209
2209
|
})
|
|
2210
2210
|
)
|
|
@@ -2214,163 +2214,163 @@ const ki = (e) => {
|
|
|
2214
2214
|
function bn({
|
|
2215
2215
|
editor: e,
|
|
2216
2216
|
stateUpdate: t,
|
|
2217
|
-
groups:
|
|
2218
|
-
readOnly:
|
|
2219
|
-
size:
|
|
2217
|
+
groups: r = ["text-formatting"],
|
|
2218
|
+
readOnly: l = z(!1),
|
|
2219
|
+
size: n = "sm"
|
|
2220
2220
|
}) {
|
|
2221
|
-
const s = j(!1),
|
|
2221
|
+
const s = j(!1), g = j(0), v = j(0);
|
|
2222
2222
|
return ue(
|
|
2223
2223
|
ye,
|
|
2224
|
-
(
|
|
2225
|
-
const
|
|
2226
|
-
enterUrlMessage: () =>
|
|
2227
|
-
}),
|
|
2228
|
-
const
|
|
2229
|
-
if (!
|
|
2224
|
+
(L) => Se(e, (M) => {
|
|
2225
|
+
const h = M, N = L.$.lexical, E = (a) => r.includes(a), { textFormatActive: m, linkActive: C, dispatch: y, toggleLink: x } = St(h, t, {
|
|
2226
|
+
enterUrlMessage: () => L.value.lexical.enterUrl
|
|
2227
|
+
}), O = Nt(l, n)(z(!0)), I = () => {
|
|
2228
|
+
const a = h.value;
|
|
2229
|
+
if (!a) {
|
|
2230
2230
|
s.value = !1;
|
|
2231
2231
|
return;
|
|
2232
2232
|
}
|
|
2233
|
-
const
|
|
2234
|
-
if (!
|
|
2233
|
+
const F = a.getRootElement();
|
|
2234
|
+
if (!F) {
|
|
2235
2235
|
s.value = !1;
|
|
2236
2236
|
return;
|
|
2237
2237
|
}
|
|
2238
|
-
const
|
|
2239
|
-
if (!
|
|
2238
|
+
const S = window.getSelection();
|
|
2239
|
+
if (!S || S.rangeCount === 0 || S.isCollapsed) {
|
|
2240
2240
|
s.value = !1;
|
|
2241
2241
|
return;
|
|
2242
2242
|
}
|
|
2243
|
-
const
|
|
2244
|
-
if (
|
|
2243
|
+
const u = S.anchorNode;
|
|
2244
|
+
if (u && !F.contains(u)) {
|
|
2245
2245
|
s.value = !1;
|
|
2246
2246
|
return;
|
|
2247
2247
|
}
|
|
2248
|
-
const
|
|
2249
|
-
if (
|
|
2248
|
+
const i = S.getRangeAt(0).getBoundingClientRect();
|
|
2249
|
+
if (i.width === 0 && i.height === 0) {
|
|
2250
2250
|
s.value = !1;
|
|
2251
2251
|
return;
|
|
2252
2252
|
}
|
|
2253
|
-
const
|
|
2254
|
-
let
|
|
2255
|
-
const
|
|
2256
|
-
|
|
2257
|
-
},
|
|
2258
|
-
|
|
2253
|
+
const _ = 40, V = 8;
|
|
2254
|
+
let d = i.top - _ - V;
|
|
2255
|
+
const B = i.left + i.width / 2;
|
|
2256
|
+
d < 0 && (d = i.bottom + V), g.value = d, v.value = B, s.value = !0;
|
|
2257
|
+
}, k = t.onChange(I), b = () => {
|
|
2258
|
+
I();
|
|
2259
2259
|
};
|
|
2260
|
-
document.addEventListener("selectionchange",
|
|
2261
|
-
const
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2260
|
+
document.addEventListener("selectionchange", b);
|
|
2261
|
+
const w = D.div(
|
|
2262
|
+
f.class("bc-floating-toolbar"),
|
|
2263
|
+
Y.position("fixed"),
|
|
2264
|
+
Y.top(g.map((a) => `${a}px`)),
|
|
2265
|
+
Y.left(v.map((a) => `${a}px`)),
|
|
2266
|
+
Y.transform("translateX(-50%)"),
|
|
2267
2267
|
// Escape key handler
|
|
2268
|
-
oe((
|
|
2269
|
-
const
|
|
2270
|
-
if (
|
|
2268
|
+
oe((a) => {
|
|
2269
|
+
const F = (u) => {
|
|
2270
|
+
if (u.key === "Escape" && s.value) {
|
|
2271
2271
|
s.value = !1;
|
|
2272
|
-
const
|
|
2273
|
-
|
|
2272
|
+
const c = h.value;
|
|
2273
|
+
c && c.focus();
|
|
2274
2274
|
}
|
|
2275
|
-
},
|
|
2276
|
-
if (s.value && !
|
|
2277
|
-
const
|
|
2278
|
-
if (
|
|
2279
|
-
const
|
|
2280
|
-
if (
|
|
2275
|
+
}, S = (u) => {
|
|
2276
|
+
if (s.value && !a.contains(u.target)) {
|
|
2277
|
+
const c = h.value;
|
|
2278
|
+
if (c) {
|
|
2279
|
+
const i = c.getRootElement();
|
|
2280
|
+
if (i && i.contains(u.target))
|
|
2281
2281
|
return;
|
|
2282
2282
|
}
|
|
2283
2283
|
s.value = !1;
|
|
2284
2284
|
}
|
|
2285
2285
|
};
|
|
2286
|
-
return document.addEventListener("keydown",
|
|
2287
|
-
|
|
2286
|
+
return document.addEventListener("keydown", F), document.addEventListener("mousedown", S), ne(() => {
|
|
2287
|
+
k(), document.removeEventListener("keydown", F), document.removeEventListener("mousedown", S), document.removeEventListener(
|
|
2288
2288
|
"selectionchange",
|
|
2289
|
-
|
|
2289
|
+
b
|
|
2290
2290
|
);
|
|
2291
2291
|
});
|
|
2292
2292
|
}),
|
|
2293
|
-
...
|
|
2294
|
-
|
|
2295
|
-
active:
|
|
2296
|
-
onClick:
|
|
2297
|
-
label: N.map((
|
|
2293
|
+
...E("text-formatting") ? [
|
|
2294
|
+
O({
|
|
2295
|
+
active: m("bold"),
|
|
2296
|
+
onClick: y(te, "bold"),
|
|
2297
|
+
label: N.map((a) => a.bold),
|
|
2298
2298
|
icon: "mdi:format-bold"
|
|
2299
2299
|
}),
|
|
2300
|
-
|
|
2301
|
-
active:
|
|
2302
|
-
onClick:
|
|
2303
|
-
label: N.map((
|
|
2300
|
+
O({
|
|
2301
|
+
active: m("italic"),
|
|
2302
|
+
onClick: y(te, "italic"),
|
|
2303
|
+
label: N.map((a) => a.italic),
|
|
2304
2304
|
icon: "mdi:format-italic"
|
|
2305
2305
|
}),
|
|
2306
|
-
|
|
2307
|
-
active:
|
|
2308
|
-
onClick:
|
|
2309
|
-
label: N.map((
|
|
2306
|
+
O({
|
|
2307
|
+
active: m("underline"),
|
|
2308
|
+
onClick: y(te, "underline"),
|
|
2309
|
+
label: N.map((a) => a.underline),
|
|
2310
2310
|
icon: "mdi:format-underline"
|
|
2311
2311
|
}),
|
|
2312
|
-
|
|
2313
|
-
active:
|
|
2314
|
-
onClick:
|
|
2315
|
-
label: N.map((
|
|
2312
|
+
O({
|
|
2313
|
+
active: m("strikethrough"),
|
|
2314
|
+
onClick: y(te, "strikethrough"),
|
|
2315
|
+
label: N.map((a) => a.strikethrough),
|
|
2316
2316
|
icon: "mdi:format-strikethrough"
|
|
2317
2317
|
}),
|
|
2318
|
-
|
|
2319
|
-
active:
|
|
2320
|
-
onClick:
|
|
2321
|
-
label: N.map((
|
|
2318
|
+
O({
|
|
2319
|
+
active: m("code"),
|
|
2320
|
+
onClick: y(te, "code"),
|
|
2321
|
+
label: N.map((a) => a.code),
|
|
2322
2322
|
icon: "mdi:code-tags"
|
|
2323
2323
|
})
|
|
2324
2324
|
] : [],
|
|
2325
|
-
...
|
|
2326
|
-
|
|
2327
|
-
active:
|
|
2328
|
-
onClick:
|
|
2329
|
-
label: N.map((
|
|
2325
|
+
...E("links") ? [
|
|
2326
|
+
O({
|
|
2327
|
+
active: C(),
|
|
2328
|
+
onClick: x,
|
|
2329
|
+
label: N.map((a) => a.link),
|
|
2330
2330
|
icon: "mdi:link"
|
|
2331
2331
|
})
|
|
2332
2332
|
] : [],
|
|
2333
|
-
...
|
|
2334
|
-
|
|
2333
|
+
...E("clipboard") ? [
|
|
2334
|
+
O({
|
|
2335
2335
|
active: z(!1),
|
|
2336
2336
|
onClick: () => {
|
|
2337
|
-
const
|
|
2338
|
-
if (!
|
|
2339
|
-
const
|
|
2340
|
-
|
|
2337
|
+
const a = h.value;
|
|
2338
|
+
if (!a) return;
|
|
2339
|
+
const F = a.getRootElement();
|
|
2340
|
+
F && (F.focus(), document.execCommand("cut"));
|
|
2341
2341
|
},
|
|
2342
|
-
label: N.map((
|
|
2342
|
+
label: N.map((a) => a.cut),
|
|
2343
2343
|
icon: "mdi:content-cut"
|
|
2344
2344
|
}),
|
|
2345
|
-
|
|
2345
|
+
O({
|
|
2346
2346
|
active: z(!1),
|
|
2347
2347
|
onClick: () => {
|
|
2348
|
-
const
|
|
2349
|
-
if (!
|
|
2350
|
-
const
|
|
2351
|
-
|
|
2348
|
+
const a = h.value;
|
|
2349
|
+
if (!a) return;
|
|
2350
|
+
const F = a.getRootElement();
|
|
2351
|
+
F && (F.focus(), document.execCommand("copy"));
|
|
2352
2352
|
},
|
|
2353
|
-
label: N.map((
|
|
2353
|
+
label: N.map((a) => a.copy),
|
|
2354
2354
|
icon: "mdi:content-copy"
|
|
2355
2355
|
}),
|
|
2356
|
-
|
|
2356
|
+
O({
|
|
2357
2357
|
active: z(!1),
|
|
2358
2358
|
onClick: () => {
|
|
2359
|
-
const
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
const
|
|
2363
|
-
R(
|
|
2364
|
-
}),
|
|
2359
|
+
const a = h.value;
|
|
2360
|
+
a && navigator.clipboard.readText().then((F) => {
|
|
2361
|
+
a.update(() => {
|
|
2362
|
+
const S = A();
|
|
2363
|
+
R(S) && S.insertText(F);
|
|
2364
|
+
}), a.focus();
|
|
2365
2365
|
}).catch(() => {
|
|
2366
2366
|
});
|
|
2367
2367
|
},
|
|
2368
|
-
label: N.map((
|
|
2368
|
+
label: N.map((a) => a.paste),
|
|
2369
2369
|
icon: "mdi:content-paste"
|
|
2370
2370
|
})
|
|
2371
2371
|
] : []
|
|
2372
2372
|
);
|
|
2373
|
-
return pe(s, () =>
|
|
2373
|
+
return pe(s, () => w);
|
|
2374
2374
|
})
|
|
2375
2375
|
);
|
|
2376
2376
|
}
|
|
@@ -2385,7 +2385,7 @@ const Ei = [
|
|
|
2385
2385
|
handler: (e) => {
|
|
2386
2386
|
e.update(() => {
|
|
2387
2387
|
const t = A();
|
|
2388
|
-
R(t) &&
|
|
2388
|
+
R(t) && q(t, () => W("h1"));
|
|
2389
2389
|
});
|
|
2390
2390
|
}
|
|
2391
2391
|
},
|
|
@@ -2399,7 +2399,7 @@ const Ei = [
|
|
|
2399
2399
|
handler: (e) => {
|
|
2400
2400
|
e.update(() => {
|
|
2401
2401
|
const t = A();
|
|
2402
|
-
R(t) &&
|
|
2402
|
+
R(t) && q(t, () => W("h2"));
|
|
2403
2403
|
});
|
|
2404
2404
|
}
|
|
2405
2405
|
},
|
|
@@ -2413,7 +2413,7 @@ const Ei = [
|
|
|
2413
2413
|
handler: (e) => {
|
|
2414
2414
|
e.update(() => {
|
|
2415
2415
|
const t = A();
|
|
2416
|
-
R(t) &&
|
|
2416
|
+
R(t) && q(t, () => W("h3"));
|
|
2417
2417
|
});
|
|
2418
2418
|
}
|
|
2419
2419
|
},
|
|
@@ -2449,7 +2449,7 @@ const Ei = [
|
|
|
2449
2449
|
handler: (e) => {
|
|
2450
2450
|
e.update(() => {
|
|
2451
2451
|
const t = A();
|
|
2452
|
-
R(t) &&
|
|
2452
|
+
R(t) && q(t, () => Be());
|
|
2453
2453
|
});
|
|
2454
2454
|
}
|
|
2455
2455
|
},
|
|
@@ -2463,7 +2463,7 @@ const Ei = [
|
|
|
2463
2463
|
handler: (e) => {
|
|
2464
2464
|
e.update(() => {
|
|
2465
2465
|
const t = A();
|
|
2466
|
-
R(t) &&
|
|
2466
|
+
R(t) && q(t, () => Ue());
|
|
2467
2467
|
});
|
|
2468
2468
|
}
|
|
2469
2469
|
},
|
|
@@ -2497,108 +2497,108 @@ const Ei = [
|
|
|
2497
2497
|
function Ti({
|
|
2498
2498
|
commands: e,
|
|
2499
2499
|
isVisible: t,
|
|
2500
|
-
filterText:
|
|
2501
|
-
position:
|
|
2502
|
-
onSelect:
|
|
2500
|
+
filterText: r,
|
|
2501
|
+
position: l,
|
|
2502
|
+
onSelect: n,
|
|
2503
2503
|
onClose: s
|
|
2504
2504
|
}) {
|
|
2505
|
-
const
|
|
2506
|
-
const
|
|
2507
|
-
return
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
...
|
|
2511
|
-
].join(" ").includes(
|
|
2505
|
+
const g = j(0), v = r.map((E) => {
|
|
2506
|
+
const m = E.toLowerCase().trim();
|
|
2507
|
+
return m ? e.filter((C) => [
|
|
2508
|
+
C.label.toLowerCase(),
|
|
2509
|
+
C.description?.toLowerCase() || "",
|
|
2510
|
+
...C.keywords?.map((x) => x.toLowerCase()) || []
|
|
2511
|
+
].join(" ").includes(m)) : e;
|
|
2512
2512
|
});
|
|
2513
|
-
|
|
2514
|
-
|
|
2513
|
+
v.onChange(() => {
|
|
2514
|
+
g.value = 0;
|
|
2515
2515
|
});
|
|
2516
|
-
const
|
|
2517
|
-
const
|
|
2518
|
-
if (
|
|
2519
|
-
const
|
|
2520
|
-
|
|
2516
|
+
const L = (E) => {
|
|
2517
|
+
const m = v.value;
|
|
2518
|
+
if (E >= 0 && E < m.length) {
|
|
2519
|
+
const C = m[E];
|
|
2520
|
+
n(C);
|
|
2521
2521
|
}
|
|
2522
|
-
},
|
|
2522
|
+
}, M = (E) => {
|
|
2523
2523
|
if (!t.value) return;
|
|
2524
|
-
const
|
|
2525
|
-
switch (
|
|
2524
|
+
const C = v.value.length - 1;
|
|
2525
|
+
switch (E.key) {
|
|
2526
2526
|
case "ArrowDown":
|
|
2527
|
-
|
|
2527
|
+
E.preventDefault(), g.value = Math.min(g.value + 1, C);
|
|
2528
2528
|
break;
|
|
2529
2529
|
case "ArrowUp":
|
|
2530
|
-
|
|
2530
|
+
E.preventDefault(), g.value = Math.max(g.value - 1, 0);
|
|
2531
2531
|
break;
|
|
2532
2532
|
case "Enter":
|
|
2533
|
-
|
|
2533
|
+
E.preventDefault(), L(g.value);
|
|
2534
2534
|
break;
|
|
2535
2535
|
case "Escape":
|
|
2536
|
-
|
|
2536
|
+
E.preventDefault(), s();
|
|
2537
2537
|
break;
|
|
2538
2538
|
}
|
|
2539
|
-
},
|
|
2540
|
-
const
|
|
2539
|
+
}, h = (E, m) => {
|
|
2540
|
+
const C = g.map((x) => x === m), y = `slash-cmd-${E.id}`;
|
|
2541
2541
|
return D.div(
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2542
|
+
f.class("bc-slash-command-palette__item"),
|
|
2543
|
+
f.id(y),
|
|
2544
|
+
f.role("option"),
|
|
2545
2545
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2546
|
-
Pe.selected(
|
|
2546
|
+
Pe.selected(C),
|
|
2547
2547
|
// Mouse hover handlers
|
|
2548
|
-
oe((
|
|
2549
|
-
const
|
|
2550
|
-
|
|
2551
|
-
},
|
|
2552
|
-
|
|
2548
|
+
oe((x) => {
|
|
2549
|
+
const T = () => {
|
|
2550
|
+
g.value = m;
|
|
2551
|
+
}, O = () => {
|
|
2552
|
+
L(m);
|
|
2553
2553
|
};
|
|
2554
|
-
return
|
|
2555
|
-
|
|
2554
|
+
return x.addEventListener("mouseenter", T), x.addEventListener("click", O), ne(() => {
|
|
2555
|
+
x.removeEventListener("mouseenter", T), x.removeEventListener("click", O);
|
|
2556
2556
|
});
|
|
2557
2557
|
}),
|
|
2558
2558
|
// Icon
|
|
2559
|
-
typeof
|
|
2560
|
-
|
|
2561
|
-
Z({ icon:
|
|
2562
|
-
) :
|
|
2559
|
+
typeof E.icon == "string" ? D.div(
|
|
2560
|
+
f.class("bc-slash-command-palette__icon"),
|
|
2561
|
+
Z({ icon: E.icon, size: "sm" })
|
|
2562
|
+
) : E.icon,
|
|
2563
2563
|
// Label and description
|
|
2564
2564
|
D.div(
|
|
2565
|
-
|
|
2566
|
-
D.div(
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2565
|
+
f.class("bc-slash-command-palette__content"),
|
|
2566
|
+
D.div(f.class("bc-slash-command-palette__label"), E.label),
|
|
2567
|
+
E.description ? D.div(
|
|
2568
|
+
f.class("bc-slash-command-palette__description"),
|
|
2569
|
+
E.description
|
|
2570
2570
|
) : void 0
|
|
2571
2571
|
),
|
|
2572
2572
|
// Category badge (optional)
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2573
|
+
E.category ? D.div(
|
|
2574
|
+
f.class("bc-slash-command-palette__category"),
|
|
2575
|
+
E.category
|
|
2576
2576
|
) : void 0
|
|
2577
2577
|
);
|
|
2578
2578
|
}, N = ue(
|
|
2579
2579
|
ye,
|
|
2580
|
-
(
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
Pe.label(
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
oe(() => (document.addEventListener("keydown",
|
|
2588
|
-
document.removeEventListener("keydown",
|
|
2580
|
+
(E) => D.div(
|
|
2581
|
+
f.class("bc-slash-command-palette"),
|
|
2582
|
+
f.role("listbox"),
|
|
2583
|
+
Pe.label(E.$.lexical.map((m) => m.slashCommands)),
|
|
2584
|
+
Y.position("absolute"),
|
|
2585
|
+
Y.top(l.map((m) => `${m.top}px`)),
|
|
2586
|
+
Y.left(l.map((m) => `${m.left}px`)),
|
|
2587
|
+
oe(() => (document.addEventListener("keydown", M), ne(() => {
|
|
2588
|
+
document.removeEventListener("keydown", M);
|
|
2589
2589
|
}))),
|
|
2590
2590
|
// Empty state
|
|
2591
2591
|
pe(
|
|
2592
|
-
|
|
2592
|
+
v.map((m) => m.length === 0),
|
|
2593
2593
|
() => D.div(
|
|
2594
|
-
|
|
2595
|
-
|
|
2594
|
+
f.class("bc-slash-command-palette__empty"),
|
|
2595
|
+
E.$.lexical.map((m) => m.noCommandsFound)
|
|
2596
2596
|
)
|
|
2597
2597
|
),
|
|
2598
2598
|
// Command list using ForEach for proper Tempo dynamic list rendering
|
|
2599
|
-
Io(
|
|
2600
|
-
const
|
|
2601
|
-
return
|
|
2599
|
+
Io(v, (m, C) => {
|
|
2600
|
+
const y = m.value;
|
|
2601
|
+
return h(y, C.index);
|
|
2602
2602
|
})
|
|
2603
2603
|
)
|
|
2604
2604
|
);
|
|
@@ -2612,7 +2612,7 @@ const yn = [
|
|
|
2612
2612
|
handler: (e) => {
|
|
2613
2613
|
e.update(() => {
|
|
2614
2614
|
const t = A();
|
|
2615
|
-
R(t) &&
|
|
2615
|
+
R(t) && q(t, () => de());
|
|
2616
2616
|
});
|
|
2617
2617
|
}
|
|
2618
2618
|
},
|
|
@@ -2623,7 +2623,7 @@ const yn = [
|
|
|
2623
2623
|
handler: (e) => {
|
|
2624
2624
|
e.update(() => {
|
|
2625
2625
|
const t = A();
|
|
2626
|
-
R(t) &&
|
|
2626
|
+
R(t) && q(t, () => W("h1"));
|
|
2627
2627
|
});
|
|
2628
2628
|
}
|
|
2629
2629
|
},
|
|
@@ -2634,7 +2634,7 @@ const yn = [
|
|
|
2634
2634
|
handler: (e) => {
|
|
2635
2635
|
e.update(() => {
|
|
2636
2636
|
const t = A();
|
|
2637
|
-
R(t) &&
|
|
2637
|
+
R(t) && q(t, () => W("h2"));
|
|
2638
2638
|
});
|
|
2639
2639
|
}
|
|
2640
2640
|
},
|
|
@@ -2645,7 +2645,7 @@ const yn = [
|
|
|
2645
2645
|
handler: (e) => {
|
|
2646
2646
|
e.update(() => {
|
|
2647
2647
|
const t = A();
|
|
2648
|
-
R(t) &&
|
|
2648
|
+
R(t) && q(t, () => W("h3"));
|
|
2649
2649
|
});
|
|
2650
2650
|
}
|
|
2651
2651
|
},
|
|
@@ -2672,7 +2672,7 @@ const yn = [
|
|
|
2672
2672
|
handler: (e) => {
|
|
2673
2673
|
e.update(() => {
|
|
2674
2674
|
const t = A();
|
|
2675
|
-
R(t) &&
|
|
2675
|
+
R(t) && q(t, () => Be());
|
|
2676
2676
|
});
|
|
2677
2677
|
}
|
|
2678
2678
|
},
|
|
@@ -2683,7 +2683,7 @@ const yn = [
|
|
|
2683
2683
|
handler: (e) => {
|
|
2684
2684
|
e.update(() => {
|
|
2685
2685
|
const t = A();
|
|
2686
|
-
R(t) &&
|
|
2686
|
+
R(t) && q(t, () => Ue());
|
|
2687
2687
|
});
|
|
2688
2688
|
}
|
|
2689
2689
|
},
|
|
@@ -2708,128 +2708,126 @@ const yn = [
|
|
|
2708
2708
|
}
|
|
2709
2709
|
}
|
|
2710
2710
|
];
|
|
2711
|
-
function
|
|
2711
|
+
function xn({
|
|
2712
2712
|
editor: e,
|
|
2713
2713
|
stateUpdate: t,
|
|
2714
|
-
readOnly:
|
|
2715
|
-
commands:
|
|
2714
|
+
readOnly: r = z(!1),
|
|
2715
|
+
commands: l = yn
|
|
2716
2716
|
}) {
|
|
2717
|
-
const
|
|
2717
|
+
const n = j(!1), s = j(!1), g = j(0), v = j(0);
|
|
2718
2718
|
return ue(
|
|
2719
2719
|
ye,
|
|
2720
|
-
(
|
|
2721
|
-
const
|
|
2722
|
-
let N = null,
|
|
2723
|
-
const
|
|
2724
|
-
if (u === N &&
|
|
2720
|
+
(L) => Se(e, (M) => {
|
|
2721
|
+
const h = M;
|
|
2722
|
+
let N = null, E = !1, m = null;
|
|
2723
|
+
const C = 24, y = 4, x = 200, T = (u) => {
|
|
2724
|
+
if (u === N && n.value) return;
|
|
2725
2725
|
N = u;
|
|
2726
|
-
const
|
|
2727
|
-
|
|
2728
|
-
},
|
|
2729
|
-
|
|
2730
|
-
},
|
|
2731
|
-
s.value || (
|
|
2732
|
-
|
|
2733
|
-
},
|
|
2734
|
-
},
|
|
2735
|
-
const u =
|
|
2726
|
+
const c = u.getBoundingClientRect();
|
|
2727
|
+
g.value = c.top, v.value = c.left - C - y, n.value = !0;
|
|
2728
|
+
}, O = () => {
|
|
2729
|
+
m != null && (clearTimeout(m), m = null);
|
|
2730
|
+
}, I = () => {
|
|
2731
|
+
s.value || (O(), m = setTimeout(() => {
|
|
2732
|
+
m = null, s.value || (n.value = !1, N = null);
|
|
2733
|
+
}, x));
|
|
2734
|
+
}, k = () => {
|
|
2735
|
+
const u = h.value;
|
|
2736
2736
|
if (!u) return;
|
|
2737
|
-
const
|
|
2738
|
-
|
|
2739
|
-
const
|
|
2740
|
-
if (R(
|
|
2737
|
+
const c = u.getRootElement();
|
|
2738
|
+
c && (a(c), u.getEditorState().read(() => {
|
|
2739
|
+
const i = A();
|
|
2740
|
+
if (R(i))
|
|
2741
2741
|
try {
|
|
2742
|
-
const
|
|
2743
|
-
|
|
2742
|
+
const V = i.anchor.getNode().getTopLevelElementOrThrow(), d = u.getElementByKey(V.getKey());
|
|
2743
|
+
d && T(d);
|
|
2744
2744
|
} catch {
|
|
2745
2745
|
}
|
|
2746
2746
|
}));
|
|
2747
|
-
},
|
|
2747
|
+
}, b = (u) => {
|
|
2748
2748
|
if (s.value) return;
|
|
2749
|
-
const
|
|
2750
|
-
if (!
|
|
2751
|
-
const
|
|
2752
|
-
if (
|
|
2753
|
-
for (const
|
|
2754
|
-
const
|
|
2755
|
-
if (u.clientY >=
|
|
2756
|
-
|
|
2749
|
+
const c = h.value;
|
|
2750
|
+
if (!c) return;
|
|
2751
|
+
const i = c.getRootElement();
|
|
2752
|
+
if (i)
|
|
2753
|
+
for (const _ of Array.from(i.children)) {
|
|
2754
|
+
const V = _.getBoundingClientRect();
|
|
2755
|
+
if (u.clientY >= V.top && u.clientY <= V.bottom) {
|
|
2756
|
+
O(), T(_);
|
|
2757
2757
|
return;
|
|
2758
2758
|
}
|
|
2759
2759
|
}
|
|
2760
|
-
},
|
|
2761
|
-
|
|
2762
|
-
},
|
|
2763
|
-
|
|
2764
|
-
},
|
|
2760
|
+
}, w = () => {
|
|
2761
|
+
I();
|
|
2762
|
+
}, a = (u) => {
|
|
2763
|
+
E || (E = !0, u.addEventListener("mousemove", b), u.addEventListener("mouseleave", w));
|
|
2764
|
+
}, F = t.onChange(k);
|
|
2765
2765
|
return [
|
|
2766
2766
|
ne(() => {
|
|
2767
|
-
|
|
2768
|
-
const u =
|
|
2767
|
+
F(), O();
|
|
2768
|
+
const u = h.value;
|
|
2769
2769
|
if (u) {
|
|
2770
|
-
const
|
|
2771
|
-
|
|
2770
|
+
const c = u.getRootElement();
|
|
2771
|
+
c && E && (c.removeEventListener("mousemove", b), c.removeEventListener("mouseleave", w));
|
|
2772
2772
|
}
|
|
2773
2773
|
}),
|
|
2774
2774
|
pe(
|
|
2775
|
-
|
|
2775
|
+
n,
|
|
2776
2776
|
() => D.div(
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2777
|
+
f.class("bc-block-handle"),
|
|
2778
|
+
Y.position("fixed"),
|
|
2779
|
+
Y.top(g.map((u) => `${u}px`)),
|
|
2780
|
+
Y.left(v.map((u) => `${u}px`)),
|
|
2781
2781
|
// Cancel hide when mouse enters handle area
|
|
2782
|
-
|
|
2782
|
+
ee.mouseenter(O),
|
|
2783
2783
|
// Schedule hide when mouse leaves handle (unless menu is open)
|
|
2784
|
-
|
|
2784
|
+
ee.mouseleave(() => I()),
|
|
2785
2785
|
// Prevent mousedown from stealing focus from editor
|
|
2786
2786
|
oe((u) => {
|
|
2787
|
-
u.addEventListener("mousedown", (
|
|
2788
|
-
|
|
2787
|
+
u.addEventListener("mousedown", (c) => {
|
|
2788
|
+
c.preventDefault();
|
|
2789
2789
|
});
|
|
2790
2790
|
}),
|
|
2791
2791
|
D.button(
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2792
|
+
f.class("bc-block-handle__button"),
|
|
2793
|
+
f.type("button"),
|
|
2794
|
+
f.title(L.$.lexical.map((u) => u.changeBlockType)),
|
|
2795
|
+
f.disabled(r),
|
|
2796
2796
|
Z({ icon: "mdi:drag-horizontal-variant", size: "sm" }),
|
|
2797
2797
|
// Track menu open state via aria-expanded (set by Flyout)
|
|
2798
2798
|
oe((u) => {
|
|
2799
|
-
const
|
|
2800
|
-
const
|
|
2801
|
-
s.value =
|
|
2799
|
+
const c = new MutationObserver(() => {
|
|
2800
|
+
const i = u.getAttribute("aria-expanded") === "true";
|
|
2801
|
+
s.value = i;
|
|
2802
2802
|
});
|
|
2803
|
-
return
|
|
2803
|
+
return c.observe(u, {
|
|
2804
2804
|
attributes: !0,
|
|
2805
2805
|
attributeFilter: ["aria-expanded"]
|
|
2806
|
-
}), ne(() =>
|
|
2806
|
+
}), ne(() => c.disconnect());
|
|
2807
2807
|
}),
|
|
2808
2808
|
// Block type menu (uses BeatUI Menu + MenuItem)
|
|
2809
2809
|
Et({
|
|
2810
|
-
items: () =>
|
|
2810
|
+
items: () => l.map(
|
|
2811
2811
|
(u) => le({
|
|
2812
2812
|
key: u.id,
|
|
2813
2813
|
content: u.label,
|
|
2814
2814
|
before: Z({ icon: u.icon, size: "sm" }),
|
|
2815
2815
|
onClick: () => {
|
|
2816
|
-
const
|
|
2817
|
-
|
|
2816
|
+
const c = h.value;
|
|
2817
|
+
c && (u.handler(c), c.focus());
|
|
2818
2818
|
}
|
|
2819
2819
|
})
|
|
2820
2820
|
),
|
|
2821
2821
|
placement: "bottom-start",
|
|
2822
|
-
showOn:
|
|
2823
|
-
s.value ? o() : (u(), s.value = !0);
|
|
2824
|
-
})),
|
|
2822
|
+
showOn: "click",
|
|
2825
2823
|
showDelay: 0,
|
|
2826
2824
|
hideDelay: 0,
|
|
2827
2825
|
mainAxisOffset: 4,
|
|
2828
2826
|
onClose: () => {
|
|
2829
|
-
const u =
|
|
2827
|
+
const u = h.value;
|
|
2830
2828
|
u && u.focus();
|
|
2831
2829
|
},
|
|
2832
|
-
ariaLabel:
|
|
2830
|
+
ariaLabel: L.value.lexical.blockTypes
|
|
2833
2831
|
})
|
|
2834
2832
|
)
|
|
2835
2833
|
)
|
|
@@ -2841,77 +2839,77 @@ function vn({
|
|
|
2841
2839
|
const Si = (e) => {
|
|
2842
2840
|
const {
|
|
2843
2841
|
value: t,
|
|
2844
|
-
format:
|
|
2845
|
-
plugins:
|
|
2846
|
-
readOnly:
|
|
2842
|
+
format: r,
|
|
2843
|
+
plugins: l,
|
|
2844
|
+
readOnly: n,
|
|
2847
2845
|
placeholder: s,
|
|
2848
|
-
class:
|
|
2849
|
-
namespace:
|
|
2850
|
-
heightMode:
|
|
2851
|
-
floatingToolbarGroups:
|
|
2852
|
-
autoFocus:
|
|
2846
|
+
class: g,
|
|
2847
|
+
namespace: v = "BeatUILexical",
|
|
2848
|
+
heightMode: L = "auto",
|
|
2849
|
+
floatingToolbarGroups: M,
|
|
2850
|
+
autoFocus: h = !1,
|
|
2853
2851
|
onError: N,
|
|
2854
|
-
onInput:
|
|
2855
|
-
onChange:
|
|
2856
|
-
onBlur:
|
|
2857
|
-
onReady:
|
|
2858
|
-
} = e,
|
|
2852
|
+
onInput: E,
|
|
2853
|
+
onChange: m,
|
|
2854
|
+
onBlur: C,
|
|
2855
|
+
onReady: y
|
|
2856
|
+
} = e, x = j(null), T = j(0), O = (k) => typeof k == "object" && k !== null && "map" in k && typeof k.map == "function", I = n != null ? O(n) ? n : j(U.get(n)) : j(!1);
|
|
2859
2857
|
return ue(
|
|
2860
2858
|
Ye,
|
|
2861
|
-
({ appearance:
|
|
2859
|
+
({ appearance: k }) => D.div(
|
|
2862
2860
|
// CSS injection via LinkPortal
|
|
2863
2861
|
Ke(
|
|
2864
2862
|
() => import("../styles-url-BIeImEjl.js"),
|
|
2865
|
-
({ default:
|
|
2863
|
+
({ default: b }) => qe({ id: "beatui-lexical-css", href: b })
|
|
2866
2864
|
),
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2865
|
+
f.class("bc-lexical-editor-container"),
|
|
2866
|
+
L === "fixed" ? f.class("bc-lexical-editor-container--fixed") : null,
|
|
2867
|
+
f.class(g),
|
|
2870
2868
|
// Floating toolbar (appears on text selection)
|
|
2871
2869
|
bn({
|
|
2872
|
-
editor:
|
|
2873
|
-
stateUpdate:
|
|
2874
|
-
groups:
|
|
2875
|
-
readOnly:
|
|
2870
|
+
editor: x,
|
|
2871
|
+
stateUpdate: T,
|
|
2872
|
+
groups: M ?? ["text-formatting", "links"],
|
|
2873
|
+
readOnly: I
|
|
2876
2874
|
}),
|
|
2877
2875
|
// Block handle (appears at the left of each block on hover/cursor)
|
|
2878
|
-
|
|
2879
|
-
editor:
|
|
2880
|
-
stateUpdate:
|
|
2881
|
-
readOnly:
|
|
2876
|
+
xn({
|
|
2877
|
+
editor: x,
|
|
2878
|
+
stateUpdate: T,
|
|
2879
|
+
readOnly: I
|
|
2882
2880
|
}),
|
|
2883
2881
|
// Table context menu (appears when cursor is in a table cell)
|
|
2884
2882
|
Ot({
|
|
2885
|
-
editor:
|
|
2886
|
-
stateUpdate:
|
|
2887
|
-
readOnly:
|
|
2883
|
+
editor: x,
|
|
2884
|
+
stateUpdate: T,
|
|
2885
|
+
readOnly: I
|
|
2888
2886
|
}),
|
|
2889
2887
|
// The editable surface
|
|
2890
2888
|
D.div(
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2889
|
+
f.class("bc-lexical-editor"),
|
|
2890
|
+
f.class(`bc-lexical-editor--${L}`),
|
|
2891
|
+
f.contenteditable(
|
|
2892
|
+
n != null ? (
|
|
2895
2893
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2896
|
-
U.map(
|
|
2894
|
+
U.map(n, (b) => !b)
|
|
2897
2895
|
) : !0
|
|
2898
2896
|
),
|
|
2899
|
-
|
|
2897
|
+
n != null ? f.class(
|
|
2900
2898
|
U.map(
|
|
2901
|
-
|
|
2902
|
-
(
|
|
2899
|
+
n,
|
|
2900
|
+
(b) => b ? "bc-lexical-editor--readonly" : ""
|
|
2903
2901
|
)
|
|
2904
2902
|
) : null,
|
|
2905
|
-
oe((
|
|
2906
|
-
let
|
|
2907
|
-
const
|
|
2903
|
+
oe((b) => {
|
|
2904
|
+
let w = null;
|
|
2905
|
+
const a = [];
|
|
2908
2906
|
return (async () => {
|
|
2909
2907
|
try {
|
|
2910
|
-
const
|
|
2911
|
-
|
|
2912
|
-
),
|
|
2913
|
-
namespace:
|
|
2914
|
-
nodes:
|
|
2908
|
+
const S = l ?? Ve("contextual"), u = We(S), c = U.get(
|
|
2909
|
+
r ?? "markdown"
|
|
2910
|
+
), i = Ge({
|
|
2911
|
+
namespace: v,
|
|
2912
|
+
nodes: u,
|
|
2915
2913
|
theme: {
|
|
2916
2914
|
heading: {
|
|
2917
2915
|
h1: "bc-lexical-h1",
|
|
@@ -2947,143 +2945,143 @@ const Si = (e) => {
|
|
|
2947
2945
|
mark: "bc-lexical-mark",
|
|
2948
2946
|
paragraph: "bc-lexical-paragraph"
|
|
2949
2947
|
},
|
|
2950
|
-
onError: (
|
|
2951
|
-
N ? N(
|
|
2948
|
+
onError: (d) => {
|
|
2949
|
+
N ? N(d, i) : console.error("[BeatUI Lexical]", d);
|
|
2952
2950
|
},
|
|
2953
|
-
editable:
|
|
2951
|
+
editable: n ? !U.get(n) : !0,
|
|
2954
2952
|
html: {
|
|
2955
2953
|
export: we(),
|
|
2956
2954
|
import: Me()
|
|
2957
2955
|
}
|
|
2958
2956
|
});
|
|
2959
|
-
|
|
2960
|
-
const
|
|
2961
|
-
if (
|
|
2962
|
-
const
|
|
2963
|
-
|
|
2957
|
+
w = i, x.set(i), i.setRootElement(b);
|
|
2958
|
+
const _ = [];
|
|
2959
|
+
if (S.richText ? _.push(Ze(i)) : S.plainText && _.push(Xe(i)), S.history) {
|
|
2960
|
+
const d = typeof S.history == "object" ? S.history : void 0;
|
|
2961
|
+
_.push(Qe(i, d));
|
|
2964
2962
|
}
|
|
2965
|
-
if (
|
|
2966
|
-
at(
|
|
2967
|
-
),
|
|
2968
|
-
|
|
2969
|
-
}),
|
|
2970
|
-
|
|
2963
|
+
if (S.clipboard && _.push(et(i)), S.list && _.push(tt(i)), S.link && _.push(ot(i)), S.yjs && _.push(
|
|
2964
|
+
at(i, S.yjs)
|
|
2965
|
+
), S.dragon && _.push(lt(i)), S.table && _.push(rt(i)), (await Promise.all(_)).forEach((d) => {
|
|
2966
|
+
d && a.push(d);
|
|
2967
|
+
}), a.push(nt(i)), a.push(st(i)), a.push(
|
|
2968
|
+
i.registerCommand(
|
|
2971
2969
|
kt,
|
|
2972
|
-
() => (
|
|
2970
|
+
() => (T.set(T.value + 1), !1),
|
|
2973
2971
|
K
|
|
2974
2972
|
)
|
|
2975
|
-
),
|
|
2976
|
-
|
|
2977
|
-
({ editorState:
|
|
2978
|
-
(
|
|
2979
|
-
if (
|
|
2980
|
-
const G = await
|
|
2981
|
-
|
|
2982
|
-
} else if (
|
|
2983
|
-
const G = await
|
|
2984
|
-
|
|
2985
|
-
} else
|
|
2986
|
-
|
|
2987
|
-
|
|
2973
|
+
), a.push(
|
|
2974
|
+
i.registerUpdateListener(
|
|
2975
|
+
({ editorState: d, dirtyElements: B, dirtyLeaves: $ }) => {
|
|
2976
|
+
(B.size > 0 || $.size > 0) && T.set(T.value + 1), E && (B.size > 0 || $.size > 0) && d.read(async () => {
|
|
2977
|
+
if (c === "markdown") {
|
|
2978
|
+
const G = await X(i);
|
|
2979
|
+
E(G, i);
|
|
2980
|
+
} else if (c === "html") {
|
|
2981
|
+
const G = await Q(i);
|
|
2982
|
+
E(G, i);
|
|
2983
|
+
} else c === "json" && E(
|
|
2984
|
+
d.toJSON(),
|
|
2985
|
+
i
|
|
2988
2986
|
);
|
|
2989
2987
|
});
|
|
2990
2988
|
}
|
|
2991
2989
|
)
|
|
2992
2990
|
), t != null) {
|
|
2993
|
-
const
|
|
2991
|
+
const d = U.get(
|
|
2994
2992
|
t
|
|
2995
2993
|
);
|
|
2996
|
-
if (
|
|
2997
|
-
if (
|
|
2998
|
-
await ae(
|
|
2999
|
-
else if (
|
|
3000
|
-
await se(
|
|
3001
|
-
else if (
|
|
2994
|
+
if (d != null && (d !== "" || c === "json" && typeof d == "object")) {
|
|
2995
|
+
if (c === "markdown" && typeof d == "string")
|
|
2996
|
+
await ae(i, d);
|
|
2997
|
+
else if (c === "html" && typeof d == "string")
|
|
2998
|
+
await se(i, d);
|
|
2999
|
+
else if (c === "json" && typeof d == "object")
|
|
3002
3000
|
try {
|
|
3003
|
-
const $ = JSON.stringify(
|
|
3004
|
-
|
|
3001
|
+
const $ = JSON.stringify(d), G = i.parseEditorState($);
|
|
3002
|
+
i.setEditorState(G);
|
|
3005
3003
|
} catch ($) {
|
|
3006
3004
|
console.error(
|
|
3007
3005
|
"[BeatUI] Failed to parse JSON editor state:",
|
|
3008
3006
|
$
|
|
3009
3007
|
), N && N(
|
|
3010
3008
|
$ instanceof Error ? $ : new Error(String($)),
|
|
3011
|
-
|
|
3009
|
+
i
|
|
3012
3010
|
);
|
|
3013
3011
|
}
|
|
3014
3012
|
}
|
|
3015
3013
|
}
|
|
3016
|
-
if (t != null &&
|
|
3017
|
-
U.on(t, async (
|
|
3018
|
-
if (
|
|
3019
|
-
if (
|
|
3020
|
-
const
|
|
3021
|
-
|
|
3022
|
-
} else if (
|
|
3023
|
-
const
|
|
3024
|
-
|
|
3025
|
-
} else if (
|
|
3026
|
-
const
|
|
3027
|
-
|
|
3028
|
-
), $ = JSON.stringify(
|
|
3029
|
-
if (
|
|
3030
|
-
const G =
|
|
3031
|
-
|
|
3014
|
+
if (t != null && a.push(
|
|
3015
|
+
U.on(t, async (d) => {
|
|
3016
|
+
if (d != null) {
|
|
3017
|
+
if (c === "markdown" && typeof d == "string") {
|
|
3018
|
+
const B = await X(i);
|
|
3019
|
+
d !== B && await ae(i, d);
|
|
3020
|
+
} else if (c === "html" && typeof d == "string") {
|
|
3021
|
+
const B = await Q(i);
|
|
3022
|
+
d !== B && await se(i, d);
|
|
3023
|
+
} else if (c === "json" && typeof d == "object") {
|
|
3024
|
+
const B = JSON.stringify(
|
|
3025
|
+
i.getEditorState().toJSON()
|
|
3026
|
+
), $ = JSON.stringify(d);
|
|
3027
|
+
if (B !== $) {
|
|
3028
|
+
const G = i.parseEditorState($);
|
|
3029
|
+
i.setEditorState(G);
|
|
3032
3030
|
}
|
|
3033
3031
|
}
|
|
3034
3032
|
}
|
|
3035
3033
|
})
|
|
3036
|
-
),
|
|
3037
|
-
U.on(
|
|
3038
|
-
|
|
3034
|
+
), n != null && a.push(
|
|
3035
|
+
U.on(n, (d) => {
|
|
3036
|
+
i.setEditable(!d);
|
|
3039
3037
|
})
|
|
3040
|
-
),
|
|
3041
|
-
|
|
3038
|
+
), a.push(
|
|
3039
|
+
i.registerCommand(
|
|
3042
3040
|
Je,
|
|
3043
|
-
() => (
|
|
3044
|
-
if (
|
|
3045
|
-
const
|
|
3046
|
-
|
|
3047
|
-
} else if (
|
|
3048
|
-
const
|
|
3049
|
-
|
|
3050
|
-
} else
|
|
3051
|
-
|
|
3052
|
-
|
|
3041
|
+
() => (C && C(i), m && i.getEditorState().read(async () => {
|
|
3042
|
+
if (c === "markdown") {
|
|
3043
|
+
const d = await X(i);
|
|
3044
|
+
m(d, i);
|
|
3045
|
+
} else if (c === "html") {
|
|
3046
|
+
const d = await Q(i);
|
|
3047
|
+
m(d, i);
|
|
3048
|
+
} else c === "json" && m(
|
|
3049
|
+
i.getEditorState().toJSON(),
|
|
3050
|
+
i
|
|
3053
3051
|
);
|
|
3054
3052
|
}), !1),
|
|
3055
3053
|
K
|
|
3056
3054
|
)
|
|
3057
|
-
),
|
|
3058
|
-
|
|
3059
|
-
const
|
|
3060
|
-
|
|
3055
|
+
), a.push(
|
|
3056
|
+
k.on((d) => {
|
|
3057
|
+
const B = i.getRootElement();
|
|
3058
|
+
B && (B.dataset.theme = d);
|
|
3061
3059
|
})
|
|
3062
|
-
),
|
|
3063
|
-
|
|
3060
|
+
), h)
|
|
3061
|
+
i.focus();
|
|
3064
3062
|
else {
|
|
3065
|
-
const
|
|
3066
|
-
|
|
3063
|
+
const d = i.getRootElement();
|
|
3064
|
+
d && d === document.activeElement && d.blur();
|
|
3067
3065
|
}
|
|
3068
|
-
|
|
3069
|
-
} catch (
|
|
3066
|
+
y && y(i);
|
|
3067
|
+
} catch (S) {
|
|
3070
3068
|
console.error(
|
|
3071
3069
|
"[BeatUI] Failed to initialize Lexical editor:",
|
|
3072
|
-
|
|
3070
|
+
S
|
|
3073
3071
|
);
|
|
3074
|
-
const
|
|
3075
|
-
|
|
3072
|
+
const u = b;
|
|
3073
|
+
u.textContent = "Failed to load Lexical editor.";
|
|
3076
3074
|
}
|
|
3077
3075
|
})(), ne(() => {
|
|
3078
3076
|
try {
|
|
3079
|
-
|
|
3077
|
+
a.forEach((S) => S());
|
|
3080
3078
|
} catch {
|
|
3081
3079
|
}
|
|
3082
3080
|
try {
|
|
3083
|
-
|
|
3081
|
+
w?.setRootElement(null);
|
|
3084
3082
|
} catch {
|
|
3085
3083
|
}
|
|
3086
|
-
|
|
3084
|
+
x.set(null);
|
|
3087
3085
|
});
|
|
3088
3086
|
})
|
|
3089
3087
|
)
|
|
@@ -3093,73 +3091,73 @@ const Si = (e) => {
|
|
|
3093
3091
|
const {
|
|
3094
3092
|
// InputOptions fields
|
|
3095
3093
|
value: t,
|
|
3096
|
-
before:
|
|
3097
|
-
after:
|
|
3098
|
-
onChange:
|
|
3094
|
+
before: r,
|
|
3095
|
+
after: l,
|
|
3096
|
+
onChange: n,
|
|
3099
3097
|
onInput: s,
|
|
3100
|
-
onBlur:
|
|
3101
|
-
disabled:
|
|
3102
|
-
hasError:
|
|
3103
|
-
name:
|
|
3104
|
-
placeholder:
|
|
3098
|
+
onBlur: g,
|
|
3099
|
+
disabled: v,
|
|
3100
|
+
hasError: L,
|
|
3101
|
+
name: M,
|
|
3102
|
+
placeholder: h,
|
|
3105
3103
|
id: N,
|
|
3106
|
-
required:
|
|
3107
|
-
tabIndex:
|
|
3108
|
-
size:
|
|
3109
|
-
class:
|
|
3104
|
+
required: E,
|
|
3105
|
+
tabIndex: m,
|
|
3106
|
+
size: C,
|
|
3107
|
+
class: y,
|
|
3110
3108
|
// LexicalEditorBaseOptions fields
|
|
3111
|
-
namespace:
|
|
3112
|
-
format:
|
|
3113
|
-
plugins:
|
|
3114
|
-
readOnly:
|
|
3115
|
-
onError:
|
|
3116
|
-
onReady:
|
|
3117
|
-
marks:
|
|
3118
|
-
autoFocus:
|
|
3109
|
+
namespace: x,
|
|
3110
|
+
format: T,
|
|
3111
|
+
plugins: O,
|
|
3112
|
+
readOnly: I,
|
|
3113
|
+
onError: k,
|
|
3114
|
+
onReady: b,
|
|
3115
|
+
marks: w,
|
|
3116
|
+
autoFocus: a
|
|
3119
3117
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3120
|
-
} = e,
|
|
3118
|
+
} = e, F = v != null && I != null ? Do(v, I)((S, u) => (S ?? !1) || (u ?? !1)) : v ?? I;
|
|
3121
3119
|
return Uo({
|
|
3122
|
-
disabled:
|
|
3123
|
-
hasError:
|
|
3124
|
-
size:
|
|
3120
|
+
disabled: v,
|
|
3121
|
+
hasError: L,
|
|
3122
|
+
size: C,
|
|
3125
3123
|
baseContainer: !0,
|
|
3126
3124
|
growInput: !0,
|
|
3127
3125
|
focusableSelector: "[contenteditable]",
|
|
3128
|
-
before:
|
|
3129
|
-
after:
|
|
3126
|
+
before: r,
|
|
3127
|
+
after: l,
|
|
3130
3128
|
input: D.div(
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3129
|
+
f.class("bc-lexical-editor-input"),
|
|
3130
|
+
f.name(M),
|
|
3131
|
+
f.id(N),
|
|
3132
|
+
E != null ? Pe.required(E) : null,
|
|
3133
|
+
m != null ? f.tabindex(m) : null,
|
|
3134
|
+
L != null ? f.class(
|
|
3137
3135
|
U.map(
|
|
3138
|
-
|
|
3139
|
-
(
|
|
3136
|
+
L,
|
|
3137
|
+
(S) => S ? "bc-lexical-editor-input--error" : ""
|
|
3140
3138
|
)
|
|
3141
3139
|
) : null,
|
|
3142
3140
|
an({
|
|
3143
3141
|
value: t,
|
|
3144
|
-
format:
|
|
3145
|
-
plugins:
|
|
3146
|
-
readOnly:
|
|
3147
|
-
placeholder:
|
|
3148
|
-
namespace:
|
|
3149
|
-
class:
|
|
3150
|
-
autoFocus:
|
|
3151
|
-
onError:
|
|
3152
|
-
onReady:
|
|
3153
|
-
onInput: s ? (
|
|
3154
|
-
s(
|
|
3142
|
+
format: T ?? "markdown",
|
|
3143
|
+
plugins: O,
|
|
3144
|
+
readOnly: F,
|
|
3145
|
+
placeholder: h,
|
|
3146
|
+
namespace: x,
|
|
3147
|
+
class: y,
|
|
3148
|
+
autoFocus: a,
|
|
3149
|
+
onError: k,
|
|
3150
|
+
onReady: b,
|
|
3151
|
+
onInput: s ? (S, u) => {
|
|
3152
|
+
s(S);
|
|
3155
3153
|
} : void 0,
|
|
3156
|
-
onChange:
|
|
3157
|
-
|
|
3158
|
-
|
|
3154
|
+
onChange: n ? (S, u) => {
|
|
3155
|
+
n(
|
|
3156
|
+
S
|
|
3159
3157
|
);
|
|
3160
3158
|
} : void 0,
|
|
3161
|
-
onBlur:
|
|
3162
|
-
|
|
3159
|
+
onBlur: g ? (S) => {
|
|
3160
|
+
g();
|
|
3163
3161
|
} : void 0
|
|
3164
3162
|
})
|
|
3165
3163
|
)
|
|
@@ -3170,7 +3168,7 @@ export {
|
|
|
3170
3168
|
jo as $isHorizontalRuleNode,
|
|
3171
3169
|
Ii as BLUR_COMMAND,
|
|
3172
3170
|
an as BareEditor,
|
|
3173
|
-
|
|
3171
|
+
xn as BlockHandle,
|
|
3174
3172
|
Di as CLEAR_EDITOR_COMMAND,
|
|
3175
3173
|
Fi as CLICK_COMMAND,
|
|
3176
3174
|
Hi as COMMAND_PRIORITY_CRITICAL,
|
|
@@ -3223,22 +3221,22 @@ export {
|
|
|
3223
3221
|
Le as createHeadlessEditor,
|
|
3224
3222
|
Xn as executeSlashCommand,
|
|
3225
3223
|
oi as exportEditorToFile,
|
|
3226
|
-
|
|
3227
|
-
|
|
3224
|
+
Q as exportToHtml,
|
|
3225
|
+
X as exportToMarkdown,
|
|
3228
3226
|
pi as getCharacterCount,
|
|
3229
3227
|
ti as getMarkdownTransformers,
|
|
3230
3228
|
We as getNodesForPlugins,
|
|
3231
3229
|
mi as getSelectionInfo,
|
|
3232
3230
|
Tt as getTextContent,
|
|
3233
3231
|
gi as getWordCount,
|
|
3234
|
-
|
|
3232
|
+
vi as htmlToLexicalJson,
|
|
3235
3233
|
ni as importFileToEditor,
|
|
3236
3234
|
se as importFromHtml,
|
|
3237
3235
|
ae as importFromMarkdown,
|
|
3238
3236
|
ii as insertTable,
|
|
3239
3237
|
hi as insertTextAtCursor,
|
|
3240
3238
|
Ci as lexicalJsonToHtml,
|
|
3241
|
-
|
|
3239
|
+
xi as lexicalJsonToMarkdown,
|
|
3242
3240
|
Go as loadLexicalCore,
|
|
3243
3241
|
bi as loadOffsetUtils,
|
|
3244
3242
|
yi as markdownToLexicalJson,
|