lexical-medium-editor 1.2.13 → 1.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/index.es.js +478 -458
- package/dist-lib/index.es.js.map +1 -1
- package/package.json +1 -1
package/dist-lib/index.es.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
import './lexical-medium-editor.css';
|
|
2
|
-
import { jsxs as
|
|
2
|
+
import { jsxs as $, Fragment as be, jsx as l } from "react/jsx-runtime";
|
|
3
3
|
import { AutoFocusPlugin as we } from "@lexical/react/LexicalAutoFocusPlugin";
|
|
4
|
-
import { LexicalComposer as
|
|
5
|
-
import { RichTextPlugin as
|
|
4
|
+
import { LexicalComposer as Fe } from "@lexical/react/LexicalComposer";
|
|
5
|
+
import { RichTextPlugin as Ke } from "@lexical/react/LexicalRichTextPlugin";
|
|
6
6
|
import { HistoryPlugin as We } from "@lexical/react/LexicalHistoryPlugin";
|
|
7
7
|
import { LexicalErrorBoundary as Ge } from "@lexical/react/LexicalErrorBoundary";
|
|
8
|
-
import { useLexicalComposerContext as
|
|
9
|
-
import { createCommand as
|
|
10
|
-
import { useEffect as u, useState as
|
|
8
|
+
import { useLexicalComposerContext as T } from "@lexical/react/LexicalComposerContext";
|
|
9
|
+
import { createCommand as B, $getSelection as p, $isRangeSelection as C, $createParagraphNode as K, COMMAND_PRIORITY_HIGH as N, $getRoot as U, CLICK_COMMAND as ze, COMMAND_PRIORITY_LOW as Le, TextNode as W, $isParagraphNode as k, $getCharacterOffsets as qe, FORMAT_TEXT_COMMAND as ee, SELECTION_CHANGE_COMMAND as A, BLUR_COMMAND as X, $getNodeByKey as G, $isLineBreakNode as w, $getPreviousSelection as Y, KEY_BACKSPACE_COMMAND as se, $isNodeSelection as ae, PASTE_COMMAND as Ue, $setSelection as Me, KEY_ARROW_RIGHT_COMMAND as Ye, $getAdjacentNode as re, $createTextNode as Qe, COMMAND_PRIORITY_NORMAL as je, KEY_ENTER_COMMAND as Xe, $isTextNode as Ve, ParagraphNode as Ze, $createLineBreakNode as Je, KEY_TAB_COMMAND as et } from "lexical";
|
|
10
|
+
import { useEffect as u, useState as L, useRef as z, useLayoutEffect as tt } from "react";
|
|
11
11
|
import { createPortal as le } from "react-dom";
|
|
12
12
|
import { $findMatchingParent as E, $dfs as nt } from "@lexical/utils";
|
|
13
|
-
import { Toolbar as ce, TextField as ot, Input as Ie, Group as
|
|
13
|
+
import { Toolbar as ce, TextField as ot, Input as Ie, Group as F, Button as O, ToggleButton as H, Separator as ue, ComboBox as rt, Popover as $e, ListBox as it, ListBoxItem as st, DialogTrigger as at, FileTrigger as lt } from "react-aria-components";
|
|
14
14
|
import { IconCheck as ct, IconX as dt, IconBold as ut, IconItalic as gt, IconCode as ft, IconTextSize as mt, IconBlockquote as ht, IconLink as Nt, IconCaretDownFilled as Ct, IconPlus as pt, IconPhoto as Tt, IconCodePlus as Et, IconLineDashed as bt } from "@tabler/icons-react";
|
|
15
15
|
import { $isAtNodeEnd as ge, $setBlocksType as Se, createDOMRange as Lt } from "@lexical/selection";
|
|
16
|
-
import { $createHeadingNode as xe, HeadingNode as Mt, $createQuoteNode as It, $isHeadingNode as
|
|
16
|
+
import { $createHeadingNode as xe, HeadingNode as Mt, $createQuoteNode as It, $isHeadingNode as ie, $isQuoteNode as $t } from "@lexical/rich-text";
|
|
17
17
|
import { $toggleLink as St, $isLinkNode as xt } from "@lexical/link";
|
|
18
|
-
import { $isListNode as
|
|
19
|
-
import { $ as
|
|
20
|
-
import { $isCodeNode as j, getCodeLanguages as
|
|
18
|
+
import { $isListNode as vt, $isListItemNode as fe, $insertList as me } from "@lexical/list";
|
|
19
|
+
import { $ as _, a as R, b as D, H as yt, c as Ot, I as he, d as Ne, e as Pt, M as Q, f as Dt, g as te, h as y, i as At, j as ne } from "./ImageNode-BhH71HMX.js";
|
|
20
|
+
import { $isCodeNode as j, getCodeLanguages as Bt, getLanguageFriendlyName as oe, registerCodeHighlighting as _t, $createCodeNode as Ce } from "@lexical/code";
|
|
21
21
|
import { NodeEventPlugin as de } from "@lexical/react/LexicalNodeEventPlugin";
|
|
22
|
-
import { ListPlugin as
|
|
22
|
+
import { ListPlugin as kt } from "@lexical/react/LexicalListPlugin";
|
|
23
23
|
import { OnChangePlugin as Ht } from "@lexical/react/LexicalOnChangePlugin";
|
|
24
24
|
import { ContentEditable as Rt } from "@lexical/react/LexicalContentEditable";
|
|
25
25
|
import { ClearEditorPlugin as wt } from "@lexical/react/LexicalClearEditorPlugin";
|
|
26
|
-
const
|
|
27
|
-
function
|
|
26
|
+
const S = -1e3;
|
|
27
|
+
function Ft(e, s, t = 0) {
|
|
28
28
|
if (!s || !s.current)
|
|
29
29
|
return console.error("Invalid popover reference"), {
|
|
30
|
-
x:
|
|
31
|
-
y:
|
|
30
|
+
x: S,
|
|
31
|
+
y: S
|
|
32
32
|
};
|
|
33
|
-
const n = s.current, { x: i, y:
|
|
33
|
+
const n = s.current, { x: i, y: r } = e, { width: o, height: a } = n.getBoundingClientRect(), c = i - o / 2, d = r - a - t;
|
|
34
34
|
return {
|
|
35
|
-
x:
|
|
35
|
+
x: c,
|
|
36
36
|
y: d
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function Kt(e) {
|
|
40
40
|
if (!e || typeof e.getBoundingClientRect != "function")
|
|
41
41
|
return console.error("Invalid DOM range"), null;
|
|
42
42
|
const s = e.getBoundingClientRect(), t = s.left + s.width / 2, n = s.top + window.scrollY;
|
|
@@ -48,34 +48,34 @@ function Ft(e) {
|
|
|
48
48
|
function Wt(e, s, t = 0) {
|
|
49
49
|
if (!s || !s.current)
|
|
50
50
|
return console.error("Invalid popover reference"), {
|
|
51
|
-
x:
|
|
52
|
-
y:
|
|
51
|
+
x: S,
|
|
52
|
+
y: S
|
|
53
53
|
};
|
|
54
|
-
const { x: n, y: i } = e,
|
|
54
|
+
const { x: n, y: i } = e, r = s.current, { width: o, height: a } = r.getBoundingClientRect(), c = n - o - t, d = i - a / 2;
|
|
55
55
|
return {
|
|
56
|
-
x:
|
|
56
|
+
x: c,
|
|
57
57
|
y: d
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
function Gt(e, s, t = 16, n = 12) {
|
|
61
61
|
if (!s || !s.current)
|
|
62
62
|
return console.error("Invalid popover reference"), {
|
|
63
|
-
x:
|
|
64
|
-
y:
|
|
63
|
+
x: S,
|
|
64
|
+
y: S
|
|
65
65
|
};
|
|
66
|
-
const i = s.current, { x:
|
|
66
|
+
const i = s.current, { x: r, y: o } = e, { width: a } = i.getBoundingClientRect(), c = r - a - t, d = o + n;
|
|
67
67
|
return {
|
|
68
|
-
x:
|
|
68
|
+
x: c,
|
|
69
69
|
y: d
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
-
const
|
|
73
|
-
function
|
|
72
|
+
const ve = B("TOGGLE_HEADING_COMMAND"), ye = B("TOGGLE_QUOTE_COMMAND"), Oe = B("TOGGLE_LINK_COMMAND");
|
|
73
|
+
function V(e) {
|
|
74
74
|
const s = e.anchor, t = e.focus, n = e.anchor.getNode(), i = e.focus.getNode();
|
|
75
75
|
return n === i ? n : e.isBackward() ? ge(t) ? n : i : ge(s) ? n : i;
|
|
76
76
|
}
|
|
77
77
|
function pe(e) {
|
|
78
|
-
const s = E(e,
|
|
78
|
+
const s = E(e, ie);
|
|
79
79
|
return s ? s.getTag() : null;
|
|
80
80
|
}
|
|
81
81
|
function zt(e) {
|
|
@@ -88,37 +88,37 @@ function zt(e) {
|
|
|
88
88
|
const n = pe(t[0]);
|
|
89
89
|
if (!n) return s;
|
|
90
90
|
if (t.every(
|
|
91
|
-
(
|
|
91
|
+
(r) => pe(r) === n
|
|
92
92
|
)) {
|
|
93
|
-
const
|
|
93
|
+
const r = {
|
|
94
94
|
h1: "isHeadingOne",
|
|
95
95
|
h2: "isHeadingTwo",
|
|
96
96
|
h3: "isHeadingThree"
|
|
97
97
|
}[n];
|
|
98
|
-
|
|
98
|
+
r && (s[r] = !0);
|
|
99
99
|
}
|
|
100
100
|
return s;
|
|
101
101
|
}
|
|
102
102
|
function qt() {
|
|
103
|
-
const [e] =
|
|
103
|
+
const [e] = T();
|
|
104
104
|
return u(() => e.registerCommand(
|
|
105
|
-
|
|
105
|
+
ve,
|
|
106
106
|
(t) => {
|
|
107
|
-
const { isHeadingOne: n, isHeadingTwo: i, isHeadingThree:
|
|
108
|
-
if (
|
|
109
|
-
let
|
|
110
|
-
n || i ?
|
|
111
|
-
|
|
112
|
-
() =>
|
|
107
|
+
const { isHeadingOne: n, isHeadingTwo: i, isHeadingThree: r } = t, o = p();
|
|
108
|
+
if (C(o)) {
|
|
109
|
+
let a;
|
|
110
|
+
n || i ? a = "h3" : r ? a = null : a = "h2", Se(
|
|
111
|
+
o,
|
|
112
|
+
() => a ? xe(a) : K()
|
|
113
113
|
);
|
|
114
114
|
}
|
|
115
115
|
return !0;
|
|
116
116
|
},
|
|
117
|
-
|
|
117
|
+
N
|
|
118
118
|
), [e]), null;
|
|
119
119
|
}
|
|
120
120
|
function Ut() {
|
|
121
|
-
const [e] =
|
|
121
|
+
const [e] = T();
|
|
122
122
|
return u(() => {
|
|
123
123
|
const s = e.registerNodeTransform(
|
|
124
124
|
Mt,
|
|
@@ -127,8 +127,8 @@ function Ut() {
|
|
|
127
127
|
return;
|
|
128
128
|
const i = U().getFirstChild();
|
|
129
129
|
if (i !== null && t.is(i)) {
|
|
130
|
-
const
|
|
131
|
-
|
|
130
|
+
const r = t.getChildren(), o = xe("h1");
|
|
131
|
+
o.append(...r), t.replace(o);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
);
|
|
@@ -145,101 +145,101 @@ function Qt(e) {
|
|
|
145
145
|
return s.length ? s.length > 0 && s.every((t) => Yt(t)) : !1;
|
|
146
146
|
}
|
|
147
147
|
function jt() {
|
|
148
|
-
const [e] =
|
|
148
|
+
const [e] = T();
|
|
149
149
|
return u(() => e.registerCommand(
|
|
150
|
-
|
|
150
|
+
ye,
|
|
151
151
|
(t) => {
|
|
152
|
-
const n =
|
|
153
|
-
return
|
|
152
|
+
const n = p();
|
|
153
|
+
return C(n) && Se(
|
|
154
154
|
n,
|
|
155
|
-
() => t.isQuote ?
|
|
155
|
+
() => t.isQuote ? K() : It()
|
|
156
156
|
), !0;
|
|
157
157
|
},
|
|
158
|
-
|
|
158
|
+
N
|
|
159
159
|
), [e]), null;
|
|
160
160
|
}
|
|
161
161
|
function Pe(e) {
|
|
162
|
-
if (!
|
|
162
|
+
if (!C(e))
|
|
163
163
|
return null;
|
|
164
|
-
const s =
|
|
164
|
+
const s = V(e);
|
|
165
165
|
return E(s, xt);
|
|
166
166
|
}
|
|
167
167
|
function Xt() {
|
|
168
|
-
const [e] =
|
|
168
|
+
const [e] = T();
|
|
169
169
|
return u(() => e.registerCommand(
|
|
170
170
|
ze,
|
|
171
171
|
(t) => {
|
|
172
|
-
const n =
|
|
172
|
+
const n = p(), i = Pe(n);
|
|
173
173
|
return i && (t.metaKey || t.ctrlKey) ? (window.open(i.getURL(), "_blank"), !0) : !1;
|
|
174
174
|
},
|
|
175
175
|
Le
|
|
176
176
|
), [e]), u(() => e.registerCommand(
|
|
177
|
-
|
|
177
|
+
Oe,
|
|
178
178
|
(t) => (St(t), !0),
|
|
179
|
-
|
|
179
|
+
N
|
|
180
180
|
), [e]), null;
|
|
181
181
|
}
|
|
182
182
|
function Vt() {
|
|
183
|
-
const [e] =
|
|
183
|
+
const [e] = T(), s = "heading-above";
|
|
184
184
|
return u(() => e.registerNodeTransform(
|
|
185
185
|
W,
|
|
186
186
|
(n) => {
|
|
187
|
-
const i = E(n,
|
|
188
|
-
if (!i ||
|
|
187
|
+
const i = E(n, k) || E(n, vt);
|
|
188
|
+
if (!i || ie(i))
|
|
189
189
|
return;
|
|
190
|
-
const
|
|
191
|
-
if (!
|
|
190
|
+
const r = i, o = e.getElementByKey(r.getKey());
|
|
191
|
+
if (!o)
|
|
192
192
|
return;
|
|
193
|
-
const
|
|
194
|
-
|
|
193
|
+
const a = r.getPreviousSibling(), c = ie(a), d = o.classList.contains(s);
|
|
194
|
+
c && !d ? o.classList.add(s) : !c && d && o.classList.remove(s);
|
|
195
195
|
}
|
|
196
196
|
), [e]), null;
|
|
197
197
|
}
|
|
198
198
|
function Zt({ isHeadingOneFirst: e }) {
|
|
199
|
-
return /* @__PURE__ */
|
|
200
|
-
/* @__PURE__ */
|
|
201
|
-
e && /* @__PURE__ */
|
|
202
|
-
/* @__PURE__ */
|
|
203
|
-
/* @__PURE__ */
|
|
204
|
-
/* @__PURE__ */
|
|
199
|
+
return /* @__PURE__ */ $(be, { children: [
|
|
200
|
+
/* @__PURE__ */ l(qt, {}),
|
|
201
|
+
e && /* @__PURE__ */ l(Ut, {}),
|
|
202
|
+
/* @__PURE__ */ l(jt, {}),
|
|
203
|
+
/* @__PURE__ */ l(Xt, {}),
|
|
204
|
+
/* @__PURE__ */ l(Vt, {})
|
|
205
205
|
] });
|
|
206
206
|
}
|
|
207
207
|
function Jt({ style: e, closeToolbar: s, existingLinkURL: t }) {
|
|
208
|
-
const [n] =
|
|
209
|
-
return /* @__PURE__ */
|
|
210
|
-
/* @__PURE__ */
|
|
208
|
+
const [n] = T(), [i, r] = L(t);
|
|
209
|
+
return /* @__PURE__ */ $(ce, { style: e, "aria-details": "link toolbar", id: "link-toolbar", children: [
|
|
210
|
+
/* @__PURE__ */ l(
|
|
211
211
|
ot,
|
|
212
212
|
{
|
|
213
213
|
"aria-label": "url",
|
|
214
214
|
autoFocus: !0,
|
|
215
215
|
defaultValue: i,
|
|
216
|
-
onChange:
|
|
217
|
-
children: /* @__PURE__ */
|
|
216
|
+
onChange: r,
|
|
217
|
+
children: /* @__PURE__ */ l(Ie, { placeholder: "Enter Link" })
|
|
218
218
|
}
|
|
219
219
|
),
|
|
220
|
-
/* @__PURE__ */
|
|
221
|
-
/* @__PURE__ */
|
|
222
|
-
|
|
220
|
+
/* @__PURE__ */ $(F, { "aria-label": "edit link", children: [
|
|
221
|
+
/* @__PURE__ */ l(
|
|
222
|
+
O,
|
|
223
223
|
{
|
|
224
224
|
"aria-label": "Update link",
|
|
225
225
|
onPress: () => {
|
|
226
|
-
const
|
|
227
|
-
n.dispatchCommand(
|
|
226
|
+
const o = i === "" ? null : i;
|
|
227
|
+
n.dispatchCommand(Oe, o), s();
|
|
228
228
|
},
|
|
229
|
-
children: /* @__PURE__ */
|
|
229
|
+
children: /* @__PURE__ */ l(ct, { size: v })
|
|
230
230
|
}
|
|
231
231
|
),
|
|
232
|
-
/* @__PURE__ */
|
|
232
|
+
/* @__PURE__ */ l(O, { "aria-label": "Discard changes", onPress: s, children: /* @__PURE__ */ l(dt, { size: v }) })
|
|
233
233
|
] }),
|
|
234
|
-
/* @__PURE__ */
|
|
234
|
+
/* @__PURE__ */ l("div", { className: "inline-toolbar-pointer" })
|
|
235
235
|
] });
|
|
236
236
|
}
|
|
237
|
-
const
|
|
237
|
+
const v = 24, en = 16;
|
|
238
238
|
function tn({ editor: e }) {
|
|
239
|
-
const [s, t] =
|
|
240
|
-
x:
|
|
241
|
-
y:
|
|
242
|
-
}),
|
|
239
|
+
const [s, t] = L(null), [n, i] = L({
|
|
240
|
+
x: S,
|
|
241
|
+
y: S
|
|
242
|
+
}), r = z(null), [o, a] = L({
|
|
243
243
|
isBold: !1,
|
|
244
244
|
isItalic: !1,
|
|
245
245
|
isCode: !1,
|
|
@@ -247,84 +247,84 @@ function tn({ editor: e }) {
|
|
|
247
247
|
isHeadingTwo: !1,
|
|
248
248
|
isHeadingThree: !1,
|
|
249
249
|
isQuote: !1
|
|
250
|
-
}), [
|
|
251
|
-
if (
|
|
252
|
-
|
|
250
|
+
}), [c, d] = L(!1), [m, f] = L(0), [b, I] = L(""), h = (g) => {
|
|
251
|
+
if (C(g)) {
|
|
252
|
+
a({
|
|
253
253
|
isBold: g.hasFormat("bold"),
|
|
254
254
|
isItalic: g.hasFormat("italic"),
|
|
255
255
|
isCode: g.hasFormat("code"),
|
|
256
256
|
isQuote: Qt(g)
|
|
257
257
|
});
|
|
258
258
|
const M = zt(g);
|
|
259
|
-
|
|
259
|
+
a((P) => ({
|
|
260
260
|
...P,
|
|
261
261
|
...M
|
|
262
262
|
}));
|
|
263
|
-
const
|
|
264
|
-
x
|
|
263
|
+
const x = Pe(g);
|
|
264
|
+
I(x ? x.getURL() : "");
|
|
265
265
|
}
|
|
266
266
|
};
|
|
267
267
|
return u(() => {
|
|
268
268
|
e.read(() => {
|
|
269
|
-
const g =
|
|
270
|
-
|
|
269
|
+
const g = p();
|
|
270
|
+
h(g);
|
|
271
271
|
});
|
|
272
272
|
}, [e]), u(() => e.registerUpdateListener(
|
|
273
273
|
({ editorState: M }) => {
|
|
274
274
|
M.read(() => {
|
|
275
|
-
const
|
|
276
|
-
|
|
275
|
+
const x = p();
|
|
276
|
+
h(x);
|
|
277
277
|
});
|
|
278
278
|
}
|
|
279
279
|
), [e]), u(() => {
|
|
280
280
|
e.read(() => {
|
|
281
|
-
const g =
|
|
282
|
-
if (
|
|
283
|
-
const [M,
|
|
281
|
+
const g = p();
|
|
282
|
+
if (C(g)) {
|
|
283
|
+
const [M, x] = g.getStartEndPoints(), [P, Z] = [
|
|
284
284
|
M.getNode(),
|
|
285
|
-
|
|
286
|
-
], [
|
|
285
|
+
x.getNode()
|
|
286
|
+
], [J, He] = qe(g), Re = Lt(
|
|
287
287
|
e,
|
|
288
288
|
P,
|
|
289
|
+
J,
|
|
289
290
|
Z,
|
|
290
|
-
V,
|
|
291
291
|
He
|
|
292
292
|
);
|
|
293
|
-
t(
|
|
293
|
+
t(Kt(Re));
|
|
294
294
|
}
|
|
295
295
|
});
|
|
296
|
-
}, [e,
|
|
296
|
+
}, [e, o]), u(() => {
|
|
297
297
|
var g;
|
|
298
298
|
s ? (i(
|
|
299
|
-
|
|
299
|
+
Ft(
|
|
300
300
|
s,
|
|
301
|
-
|
|
301
|
+
r,
|
|
302
302
|
en
|
|
303
303
|
)
|
|
304
304
|
), setTimeout(() => {
|
|
305
305
|
var M;
|
|
306
|
-
(M =
|
|
307
|
-
}, 50)) : (g =
|
|
306
|
+
(M = r.current) == null || M.classList.add("visible");
|
|
307
|
+
}, 50)) : (g = r.current) == null || g.classList.remove("visible");
|
|
308
308
|
}, [s]), tt(() => {
|
|
309
|
-
if (
|
|
310
|
-
const g = window.getComputedStyle(
|
|
311
|
-
|
|
309
|
+
if (r.current) {
|
|
310
|
+
const g = window.getComputedStyle(r.current), M = parseFloat(g.width);
|
|
311
|
+
f(M);
|
|
312
312
|
}
|
|
313
|
-
}, [s]), s && (
|
|
313
|
+
}, [s]), s && (c ? /* @__PURE__ */ l(
|
|
314
314
|
Jt,
|
|
315
315
|
{
|
|
316
316
|
style: {
|
|
317
317
|
position: "absolute",
|
|
318
318
|
top: n.y,
|
|
319
319
|
left: n.x,
|
|
320
|
-
width:
|
|
320
|
+
width: m
|
|
321
321
|
},
|
|
322
322
|
closeToolbar: () => {
|
|
323
323
|
d(!1), t(null);
|
|
324
324
|
},
|
|
325
|
-
existingLinkURL:
|
|
325
|
+
existingLinkURL: b
|
|
326
326
|
}
|
|
327
|
-
) : /* @__PURE__ */
|
|
327
|
+
) : /* @__PURE__ */ $(
|
|
328
328
|
ce,
|
|
329
329
|
{
|
|
330
330
|
style: {
|
|
@@ -334,187 +334,207 @@ function tn({ editor: e }) {
|
|
|
334
334
|
},
|
|
335
335
|
"aria-label": "Text formatting",
|
|
336
336
|
id: "inline-toolbar",
|
|
337
|
-
ref:
|
|
337
|
+
ref: r,
|
|
338
338
|
children: [
|
|
339
|
-
/* @__PURE__ */
|
|
340
|
-
/* @__PURE__ */
|
|
339
|
+
/* @__PURE__ */ $(F, { "aria-label": "Style", children: [
|
|
340
|
+
/* @__PURE__ */ l(
|
|
341
341
|
H,
|
|
342
342
|
{
|
|
343
343
|
"aria-label": "Bold",
|
|
344
|
-
isSelected:
|
|
345
|
-
isDisabled:
|
|
346
|
-
onChange: () => e.dispatchCommand(
|
|
347
|
-
children: /* @__PURE__ */
|
|
344
|
+
isSelected: o.isBold,
|
|
345
|
+
isDisabled: o.isCode || o.isHeadingOne || o.isHeadingTwo || o.isHeadingThree,
|
|
346
|
+
onChange: () => e.dispatchCommand(ee, "bold"),
|
|
347
|
+
children: /* @__PURE__ */ l(ut, { size: v })
|
|
348
348
|
}
|
|
349
349
|
),
|
|
350
|
-
/* @__PURE__ */
|
|
350
|
+
/* @__PURE__ */ l(
|
|
351
351
|
H,
|
|
352
352
|
{
|
|
353
353
|
"aria-label": "Italic",
|
|
354
|
-
isSelected:
|
|
355
|
-
isDisabled:
|
|
356
|
-
onChange: () => e.dispatchCommand(
|
|
357
|
-
children: /* @__PURE__ */
|
|
354
|
+
isSelected: o.isItalic,
|
|
355
|
+
isDisabled: o.isCode || o.isHeadingOne,
|
|
356
|
+
onChange: () => e.dispatchCommand(ee, "italic"),
|
|
357
|
+
children: /* @__PURE__ */ l(gt, { size: v })
|
|
358
358
|
}
|
|
359
359
|
),
|
|
360
|
-
/* @__PURE__ */
|
|
360
|
+
/* @__PURE__ */ l(
|
|
361
361
|
H,
|
|
362
362
|
{
|
|
363
363
|
"aria-label": "inline-code",
|
|
364
|
-
isDisabled:
|
|
365
|
-
isSelected:
|
|
366
|
-
onChange: () => e.dispatchCommand(
|
|
367
|
-
children: /* @__PURE__ */
|
|
364
|
+
isDisabled: o.isHeadingOne,
|
|
365
|
+
isSelected: o.isCode,
|
|
366
|
+
onChange: () => e.dispatchCommand(ee, "code"),
|
|
367
|
+
children: /* @__PURE__ */ l(ft, { size: v })
|
|
368
368
|
}
|
|
369
369
|
)
|
|
370
370
|
] }),
|
|
371
|
-
/* @__PURE__ */
|
|
372
|
-
/* @__PURE__ */
|
|
373
|
-
/* @__PURE__ */
|
|
371
|
+
/* @__PURE__ */ l(ue, { orientation: "vertical" }),
|
|
372
|
+
/* @__PURE__ */ $(F, { "aria-label": "Text Blocks", children: [
|
|
373
|
+
/* @__PURE__ */ l(
|
|
374
374
|
H,
|
|
375
375
|
{
|
|
376
376
|
"aria-label": "Heading",
|
|
377
|
-
isSelected:
|
|
378
|
-
onChange: () => e.dispatchCommand(
|
|
379
|
-
children: /* @__PURE__ */
|
|
377
|
+
isSelected: o.isHeadingOne || o.isHeadingTwo || o.isHeadingThree,
|
|
378
|
+
onChange: () => e.dispatchCommand(ve, o),
|
|
379
|
+
children: /* @__PURE__ */ l(mt, { size: v })
|
|
380
380
|
}
|
|
381
381
|
),
|
|
382
|
-
/* @__PURE__ */
|
|
382
|
+
/* @__PURE__ */ l(
|
|
383
383
|
H,
|
|
384
384
|
{
|
|
385
385
|
"aria-label": "Quote",
|
|
386
|
-
isSelected:
|
|
387
|
-
onChange: () => e.dispatchCommand(
|
|
388
|
-
children: /* @__PURE__ */
|
|
386
|
+
isSelected: o.isQuote,
|
|
387
|
+
onChange: () => e.dispatchCommand(ye, o),
|
|
388
|
+
children: /* @__PURE__ */ l(ht, { size: v })
|
|
389
389
|
}
|
|
390
390
|
)
|
|
391
391
|
] }),
|
|
392
|
-
/* @__PURE__ */
|
|
393
|
-
/* @__PURE__ */
|
|
394
|
-
|
|
392
|
+
/* @__PURE__ */ l(ue, { orientation: "vertical" }),
|
|
393
|
+
/* @__PURE__ */ l(F, { "aria-label": "Links", children: /* @__PURE__ */ l(
|
|
394
|
+
O,
|
|
395
395
|
{
|
|
396
396
|
onPress: () => d(!0),
|
|
397
|
-
isDisabled:
|
|
398
|
-
children: /* @__PURE__ */
|
|
397
|
+
isDisabled: o.isHeadingOne,
|
|
398
|
+
children: /* @__PURE__ */ l(Nt, { size: v })
|
|
399
399
|
}
|
|
400
400
|
) }),
|
|
401
|
-
/* @__PURE__ */
|
|
401
|
+
/* @__PURE__ */ l("div", { className: "inline-toolbar-pointer" })
|
|
402
402
|
]
|
|
403
403
|
}
|
|
404
404
|
));
|
|
405
405
|
}
|
|
406
406
|
const nn = document.body;
|
|
407
407
|
function on() {
|
|
408
|
-
const [e, s] =
|
|
408
|
+
const [e, s] = L(!1), [t] = T();
|
|
409
409
|
return u(() => t.registerCommand(
|
|
410
410
|
A,
|
|
411
411
|
() => {
|
|
412
|
-
const i =
|
|
413
|
-
if (!
|
|
412
|
+
const i = p();
|
|
413
|
+
if (!C(i) || i.isCollapsed())
|
|
414
414
|
return s(!1), !1;
|
|
415
|
-
const
|
|
415
|
+
const r = i.getNodes(), o = r.some((d) => _(d)), a = r.length === 1 && (R(r[0]) || E(r[0], D)), c = r.some(
|
|
416
416
|
(d) => E(d, j)
|
|
417
417
|
);
|
|
418
|
-
return s(!
|
|
418
|
+
return s(!o && !a && !c), !1;
|
|
419
419
|
},
|
|
420
|
-
|
|
420
|
+
N
|
|
421
421
|
), [t]), u(() => t.registerCommand(
|
|
422
|
-
|
|
422
|
+
X,
|
|
423
423
|
() => (setTimeout(() => {
|
|
424
|
-
const i = document.getElementById("inline-toolbar"),
|
|
425
|
-
i && (i ===
|
|
424
|
+
const i = document.getElementById("inline-toolbar"), r = document.getElementById("link-toolbar"), o = document.activeElement;
|
|
425
|
+
i && (i === o || i.contains(o)) || r && (r === o || r.contains(o)) || s(!1);
|
|
426
426
|
}, 0), !1),
|
|
427
|
-
|
|
428
|
-
), [t]), e && le(/* @__PURE__ */
|
|
427
|
+
N
|
|
428
|
+
), [t]), e && le(/* @__PURE__ */ l(tn, { editor: t }), nn);
|
|
429
429
|
}
|
|
430
430
|
function rn({ codeBlockCoords: e, codeNodeKey: s }) {
|
|
431
|
-
const [t] =
|
|
432
|
-
x:
|
|
433
|
-
y:
|
|
434
|
-
}),
|
|
435
|
-
new Set(
|
|
436
|
-
),
|
|
437
|
-
return
|
|
438
|
-
const
|
|
439
|
-
|
|
431
|
+
const [t] = T(), [n, i] = L({
|
|
432
|
+
x: S,
|
|
433
|
+
y: S
|
|
434
|
+
}), r = z(null), [o, a] = L(""), c = Bt(), d = Array.from(
|
|
435
|
+
new Set(c.map((f) => oe(f)))
|
|
436
|
+
), m = {};
|
|
437
|
+
return c.forEach((f) => {
|
|
438
|
+
const b = oe(f);
|
|
439
|
+
m[b] || (m[b] = f);
|
|
440
440
|
}), u(() => {
|
|
441
|
-
i(Gt(e,
|
|
441
|
+
i(Gt(e, r));
|
|
442
442
|
}, [e]), u(() => {
|
|
443
443
|
t.read(() => {
|
|
444
444
|
if (s) {
|
|
445
|
-
const
|
|
446
|
-
|
|
445
|
+
const b = G(s).getLanguage();
|
|
446
|
+
a(oe(b));
|
|
447
447
|
}
|
|
448
448
|
});
|
|
449
|
-
}, [t, s]), /* @__PURE__ */
|
|
449
|
+
}, [t, s]), /* @__PURE__ */ $(
|
|
450
450
|
rt,
|
|
451
451
|
{
|
|
452
|
-
ref:
|
|
452
|
+
ref: r,
|
|
453
453
|
style: {
|
|
454
454
|
position: "absolute",
|
|
455
455
|
top: n.y,
|
|
456
456
|
left: n.x
|
|
457
457
|
},
|
|
458
458
|
"aria-label": "Code menu",
|
|
459
|
-
inputValue:
|
|
460
|
-
onInputChange: (
|
|
461
|
-
const
|
|
459
|
+
inputValue: o,
|
|
460
|
+
onInputChange: (f) => {
|
|
461
|
+
const b = m[f];
|
|
462
462
|
t.dispatchCommand(Ae, [
|
|
463
463
|
s,
|
|
464
|
-
|
|
465
|
-
]),
|
|
464
|
+
b
|
|
465
|
+
]), a(f);
|
|
466
466
|
},
|
|
467
467
|
children: [
|
|
468
|
-
/* @__PURE__ */
|
|
469
|
-
/* @__PURE__ */
|
|
470
|
-
/* @__PURE__ */
|
|
468
|
+
/* @__PURE__ */ $("div", { children: [
|
|
469
|
+
/* @__PURE__ */ l(Ie, {}),
|
|
470
|
+
/* @__PURE__ */ l(O, { children: /* @__PURE__ */ l(Ct, { size: 24 }) })
|
|
471
471
|
] }),
|
|
472
|
-
/* @__PURE__ */
|
|
472
|
+
/* @__PURE__ */ l($e, { children: /* @__PURE__ */ l(it, { children: d.map((f, b) => /* @__PURE__ */ l(st, { children: f }, b)) }) })
|
|
473
473
|
]
|
|
474
474
|
}
|
|
475
475
|
);
|
|
476
476
|
}
|
|
477
|
-
const sn = document.body, De =
|
|
477
|
+
const sn = document.body, De = B(
|
|
478
478
|
"INSERT_CODE_BLOCK_COMMAND"
|
|
479
|
-
), Ae =
|
|
479
|
+
), Ae = B(
|
|
480
480
|
"SET_CODE_LANGUAGE_COMMAND"
|
|
481
481
|
);
|
|
482
482
|
function an() {
|
|
483
|
-
const [e, s] =
|
|
484
|
-
|
|
483
|
+
const [e, s] = L(null), [t, n] = L(null), [i, r] = L(!1), [o] = T(), a = () => {
|
|
484
|
+
s(null), n(null);
|
|
485
|
+
};
|
|
486
|
+
return u(() => o.registerCommand(
|
|
485
487
|
A,
|
|
486
488
|
() => {
|
|
487
|
-
const
|
|
488
|
-
if (
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
489
|
+
const d = o.getRootElement();
|
|
490
|
+
if (d) {
|
|
491
|
+
const I = d === document.activeElement || d.contains(document.activeElement);
|
|
492
|
+
r((h) => h === I ? h : I);
|
|
493
|
+
}
|
|
494
|
+
const m = p();
|
|
495
|
+
if (!C(m))
|
|
496
|
+
return a(), !1;
|
|
497
|
+
const f = V(m), b = E(f, j);
|
|
498
|
+
if (b) {
|
|
499
|
+
const h = o.getElementByKey(b.getKey()).getBoundingClientRect(), g = h.right, M = h.top + window.scrollY;
|
|
500
|
+
s({ x: g, y: M }), n(b.getKey());
|
|
494
501
|
} else
|
|
495
|
-
|
|
502
|
+
a();
|
|
496
503
|
return !1;
|
|
497
504
|
},
|
|
498
|
-
|
|
499
|
-
), [
|
|
500
|
-
|
|
505
|
+
N
|
|
506
|
+
), [o]), u(() => o.registerCommand(
|
|
507
|
+
X,
|
|
508
|
+
() => (r(!1), a(), !1),
|
|
509
|
+
N
|
|
510
|
+
), [o]), u(() => {
|
|
511
|
+
const c = () => {
|
|
512
|
+
r(!0);
|
|
513
|
+
}, d = () => {
|
|
514
|
+
r(!1), a();
|
|
515
|
+
};
|
|
516
|
+
return o.registerRootListener((m, f) => {
|
|
517
|
+
m && (m.addEventListener("focus", c), m.addEventListener("blur", d)), f && (f.removeEventListener("focus", c), f.removeEventListener("blur", d));
|
|
518
|
+
});
|
|
519
|
+
}, [o]), e && i && le(
|
|
520
|
+
/* @__PURE__ */ l(rn, { codeBlockCoords: e, codeNodeKey: t }),
|
|
501
521
|
sn
|
|
502
522
|
);
|
|
503
523
|
}
|
|
504
524
|
function ln() {
|
|
505
|
-
const [e] =
|
|
506
|
-
return u(() =>
|
|
525
|
+
const [e] = T();
|
|
526
|
+
return u(() => _t(e), [e]), u(() => e.registerNodeTransform(W, (t) => {
|
|
507
527
|
if (!t.isSimpleText())
|
|
508
528
|
return;
|
|
509
529
|
const n = t.getTextContent();
|
|
510
530
|
if (n.startsWith("``` ")) {
|
|
511
|
-
const i = t.getPreviousSibling(),
|
|
512
|
-
if (
|
|
531
|
+
const i = t.getPreviousSibling(), r = E(t, k), o = r !== null && r.getChildrenSize() === 1, a = w(i);
|
|
532
|
+
if (o || a) {
|
|
513
533
|
if (n.length > 4)
|
|
514
534
|
return;
|
|
515
|
-
const
|
|
516
|
-
t.replace(
|
|
517
|
-
const d =
|
|
535
|
+
const c = Ce();
|
|
536
|
+
t.replace(c), c.select();
|
|
537
|
+
const d = c.getNextSibling();
|
|
518
538
|
w(d) && d.remove();
|
|
519
539
|
return;
|
|
520
540
|
}
|
|
@@ -523,7 +543,7 @@ function ln() {
|
|
|
523
543
|
De,
|
|
524
544
|
() => {
|
|
525
545
|
const t = Y();
|
|
526
|
-
if (
|
|
546
|
+
if (C(t)) {
|
|
527
547
|
const n = Ce();
|
|
528
548
|
return t.insertNodes([n]), n.selectStart(), setTimeout(() => {
|
|
529
549
|
e.focus();
|
|
@@ -531,91 +551,91 @@ function ln() {
|
|
|
531
551
|
}
|
|
532
552
|
return !1;
|
|
533
553
|
},
|
|
534
|
-
|
|
554
|
+
N
|
|
535
555
|
), [e]), u(() => e.registerCommand(
|
|
536
556
|
Ae,
|
|
537
557
|
(t) => {
|
|
538
|
-
const [n, i] = t,
|
|
539
|
-
return j(
|
|
558
|
+
const [n, i] = t, r = G(n);
|
|
559
|
+
return j(r) ? (r.setLanguage(i), !0) : !1;
|
|
540
560
|
},
|
|
541
|
-
|
|
561
|
+
N
|
|
542
562
|
), [e]), u(() => e.registerCommand(
|
|
543
563
|
se,
|
|
544
564
|
(t) => {
|
|
545
|
-
const n =
|
|
546
|
-
if (!
|
|
565
|
+
const n = p();
|
|
566
|
+
if (!C(n) || !n.isCollapsed())
|
|
547
567
|
return !1;
|
|
548
|
-
const i = n.anchor.getNode(),
|
|
549
|
-
return
|
|
568
|
+
const i = n.anchor.getNode(), r = E(i, j);
|
|
569
|
+
return r && n.anchor.offset === 0 && r.getTextContent() === "" ? (r.remove(), !0) : !1;
|
|
550
570
|
},
|
|
551
|
-
|
|
571
|
+
N
|
|
552
572
|
), [e]), null;
|
|
553
573
|
}
|
|
554
574
|
function cn() {
|
|
555
|
-
return /* @__PURE__ */
|
|
556
|
-
/* @__PURE__ */
|
|
557
|
-
/* @__PURE__ */
|
|
575
|
+
return /* @__PURE__ */ $(be, { children: [
|
|
576
|
+
/* @__PURE__ */ l(ln, {}),
|
|
577
|
+
/* @__PURE__ */ l(an, {})
|
|
558
578
|
] });
|
|
559
579
|
}
|
|
560
|
-
const
|
|
580
|
+
const Be = B(
|
|
561
581
|
"INSERT_HORIZONTAL_DIVIDER_COMMAND"
|
|
562
582
|
);
|
|
563
583
|
function dn() {
|
|
564
|
-
const [e] =
|
|
584
|
+
const [e] = T();
|
|
565
585
|
return u(() => {
|
|
566
|
-
if (!e.hasNodes([
|
|
586
|
+
if (!e.hasNodes([yt]))
|
|
567
587
|
throw new Error("HorizontalDividerNode not registered on editor");
|
|
568
588
|
return e.registerCommand(
|
|
569
|
-
|
|
589
|
+
Be,
|
|
570
590
|
() => {
|
|
571
591
|
const t = Y();
|
|
572
|
-
if (
|
|
573
|
-
const n =
|
|
592
|
+
if (C(t)) {
|
|
593
|
+
const n = Ot();
|
|
574
594
|
t.insertNodes([n]);
|
|
575
595
|
let i = n.getNextSibling() || n.getParent().getNextSibling();
|
|
576
|
-
return i || (i =
|
|
596
|
+
return i || (i = K(), n.insertAfter(i)), i.selectStart(), setTimeout(() => {
|
|
577
597
|
e.focus();
|
|
578
598
|
}, 0), !0;
|
|
579
599
|
}
|
|
580
600
|
return !1;
|
|
581
601
|
},
|
|
582
|
-
|
|
602
|
+
N
|
|
583
603
|
);
|
|
584
604
|
}, [e]), null;
|
|
585
605
|
}
|
|
586
|
-
const
|
|
606
|
+
const _e = B("INSERT_IMAGE_COMMAND"), Te = "selected";
|
|
587
607
|
function un(e) {
|
|
588
608
|
return e && e.type && e.type.startsWith("image/");
|
|
589
609
|
}
|
|
590
610
|
function gn() {
|
|
591
|
-
const [e] =
|
|
611
|
+
const [e] = T(), s = z(null);
|
|
592
612
|
return u(() => {
|
|
593
613
|
if (!e.hasNode(he))
|
|
594
614
|
throw new Error("ImagePlugin: ImageNode not registered on editor");
|
|
595
615
|
return e.registerCommand(
|
|
596
|
-
|
|
616
|
+
_e,
|
|
597
617
|
(n) => {
|
|
598
|
-
const i = n,
|
|
599
|
-
if (
|
|
600
|
-
const
|
|
601
|
-
|
|
602
|
-
let
|
|
603
|
-
return
|
|
618
|
+
const i = n, r = Y();
|
|
619
|
+
if (C(r)) {
|
|
620
|
+
const o = Ne(i);
|
|
621
|
+
r.insertNodes([o]);
|
|
622
|
+
let a = o.getNextSibling() || o.getParent().getNextSibling();
|
|
623
|
+
return a || (a = K(), o.insertAfter(a)), o.select(), !0;
|
|
604
624
|
}
|
|
605
625
|
return !1;
|
|
606
626
|
},
|
|
607
|
-
|
|
627
|
+
N
|
|
608
628
|
);
|
|
609
629
|
}, [e]), u(() => e.registerCommand(
|
|
610
630
|
A,
|
|
611
631
|
() => {
|
|
612
632
|
s.current && (s.current.classList.remove(Te), s.current = null);
|
|
613
|
-
const n =
|
|
633
|
+
const n = p();
|
|
614
634
|
if (ae(n) && n.getNodes().length === 1) {
|
|
615
635
|
const i = n.getNodes()[0];
|
|
616
636
|
if (Pt(i)) {
|
|
617
|
-
const
|
|
618
|
-
|
|
637
|
+
const r = e.getElementByKey(i.getKey());
|
|
638
|
+
r.classList.add(Te), s.current = r;
|
|
619
639
|
}
|
|
620
640
|
}
|
|
621
641
|
return !1;
|
|
@@ -627,22 +647,22 @@ function gn() {
|
|
|
627
647
|
const i = n.clipboardData;
|
|
628
648
|
if (!i)
|
|
629
649
|
return !1;
|
|
630
|
-
const
|
|
631
|
-
if (
|
|
650
|
+
const o = Array.from(i.files).filter(un);
|
|
651
|
+
if (o.length === 1) {
|
|
632
652
|
n.preventDefault();
|
|
633
|
-
const
|
|
634
|
-
if (!
|
|
653
|
+
const a = o[0], c = p() || Y();
|
|
654
|
+
if (!C(c))
|
|
635
655
|
return !1;
|
|
636
|
-
const d = URL.createObjectURL(
|
|
637
|
-
|
|
638
|
-
let
|
|
639
|
-
return
|
|
656
|
+
const d = URL.createObjectURL(a), m = Ne(d);
|
|
657
|
+
c.insertNodes([m]);
|
|
658
|
+
let f = m.getNextSibling() || m.getParent().getNextSibling();
|
|
659
|
+
return f || (f = K(), m.insertAfter(f)), m.select(), !0;
|
|
640
660
|
}
|
|
641
661
|
return !1;
|
|
642
662
|
},
|
|
643
|
-
|
|
663
|
+
N
|
|
644
664
|
), [e]), // Make the Image selectable
|
|
645
|
-
/* @__PURE__ */
|
|
665
|
+
/* @__PURE__ */ l(
|
|
646
666
|
de,
|
|
647
667
|
{
|
|
648
668
|
nodeType: he,
|
|
@@ -655,9 +675,9 @@ function gn() {
|
|
|
655
675
|
}
|
|
656
676
|
const q = 24;
|
|
657
677
|
function fn() {
|
|
658
|
-
const [e] =
|
|
659
|
-
return /* @__PURE__ */
|
|
660
|
-
/* @__PURE__ */
|
|
678
|
+
const [e] = T();
|
|
679
|
+
return /* @__PURE__ */ l(ce, { "aria-label": "Block toolbar", id: "block-toolbar", children: /* @__PURE__ */ $(F, { "aria-label": "Media", children: [
|
|
680
|
+
/* @__PURE__ */ l(
|
|
661
681
|
lt,
|
|
662
682
|
{
|
|
663
683
|
acceptedFileTypes: ["image/png", "image/jpeg", "image/gif"],
|
|
@@ -670,39 +690,39 @@ function fn() {
|
|
|
670
690
|
return;
|
|
671
691
|
}
|
|
672
692
|
const i = new FileReader();
|
|
673
|
-
i.onload = (
|
|
674
|
-
var
|
|
675
|
-
const
|
|
676
|
-
typeof
|
|
677
|
-
}, i.onerror = (
|
|
678
|
-
console.error("Error reading file:",
|
|
693
|
+
i.onload = (r) => {
|
|
694
|
+
var a;
|
|
695
|
+
const o = (a = r.target) == null ? void 0 : a.result;
|
|
696
|
+
typeof o == "string" ? e.dispatchCommand(_e, o) : alert("Failed to read file as Data URL.");
|
|
697
|
+
}, i.onerror = (r) => {
|
|
698
|
+
console.error("Error reading file:", r), alert("Error reading file.");
|
|
679
699
|
}, i.readAsDataURL(n);
|
|
680
700
|
},
|
|
681
701
|
allowsMultiple: !1,
|
|
682
|
-
children: /* @__PURE__ */
|
|
702
|
+
children: /* @__PURE__ */ l(O, { "aria-label": "image", children: /* @__PURE__ */ l(Tt, { size: q }) })
|
|
683
703
|
}
|
|
684
704
|
),
|
|
685
|
-
/* @__PURE__ */
|
|
686
|
-
|
|
705
|
+
/* @__PURE__ */ l(
|
|
706
|
+
O,
|
|
687
707
|
{
|
|
688
708
|
"aria-label": "code block",
|
|
689
709
|
onPress: () => {
|
|
690
710
|
e.dispatchCommand(De, void 0);
|
|
691
711
|
},
|
|
692
|
-
children: /* @__PURE__ */
|
|
712
|
+
children: /* @__PURE__ */ l(Et, { size: q })
|
|
693
713
|
}
|
|
694
714
|
),
|
|
695
|
-
/* @__PURE__ */
|
|
696
|
-
|
|
715
|
+
/* @__PURE__ */ l(
|
|
716
|
+
O,
|
|
697
717
|
{
|
|
698
718
|
"aria-label": "horizontal divider",
|
|
699
719
|
onPress: () => {
|
|
700
720
|
e.dispatchCommand(
|
|
701
|
-
|
|
721
|
+
Be,
|
|
702
722
|
void 0
|
|
703
723
|
);
|
|
704
724
|
},
|
|
705
|
-
children: /* @__PURE__ */
|
|
725
|
+
children: /* @__PURE__ */ l(bt, { size: q })
|
|
706
726
|
}
|
|
707
727
|
)
|
|
708
728
|
] }) });
|
|
@@ -713,35 +733,35 @@ function mn({
|
|
|
713
733
|
toolbarTriggerId: t,
|
|
714
734
|
toolbarPopoverId: n
|
|
715
735
|
}) {
|
|
716
|
-
const [i,
|
|
717
|
-
x:
|
|
718
|
-
y:
|
|
719
|
-
}),
|
|
736
|
+
const [i, r] = L({
|
|
737
|
+
x: S,
|
|
738
|
+
y: S
|
|
739
|
+
}), o = z(null);
|
|
720
740
|
return u(() => {
|
|
721
|
-
|
|
741
|
+
r(
|
|
722
742
|
Wt(
|
|
723
743
|
e,
|
|
724
|
-
|
|
744
|
+
o,
|
|
725
745
|
s
|
|
726
746
|
)
|
|
727
747
|
);
|
|
728
|
-
}, [e]), /* @__PURE__ */
|
|
729
|
-
/* @__PURE__ */
|
|
730
|
-
|
|
748
|
+
}, [e]), /* @__PURE__ */ $(at, { children: [
|
|
749
|
+
/* @__PURE__ */ l(
|
|
750
|
+
O,
|
|
731
751
|
{
|
|
732
752
|
"aria-label": "Block toolbar trigger",
|
|
733
753
|
className: "block-toolbar-trigger",
|
|
734
754
|
id: t,
|
|
735
|
-
ref:
|
|
755
|
+
ref: o,
|
|
736
756
|
style: {
|
|
737
757
|
position: "absolute",
|
|
738
758
|
top: i.y,
|
|
739
759
|
left: i.x
|
|
740
760
|
},
|
|
741
|
-
children: /* @__PURE__ */
|
|
761
|
+
children: /* @__PURE__ */ l(pt, { size: q })
|
|
742
762
|
}
|
|
743
763
|
),
|
|
744
|
-
/* @__PURE__ */
|
|
764
|
+
/* @__PURE__ */ l(
|
|
745
765
|
$e,
|
|
746
766
|
{
|
|
747
767
|
className: "block-toolbar-popover",
|
|
@@ -749,60 +769,60 @@ function mn({
|
|
|
749
769
|
placement: "end",
|
|
750
770
|
shouldFlip: !1,
|
|
751
771
|
offset: s,
|
|
752
|
-
children: /* @__PURE__ */
|
|
772
|
+
children: /* @__PURE__ */ l(fn, {})
|
|
753
773
|
}
|
|
754
774
|
)
|
|
755
775
|
] });
|
|
756
776
|
}
|
|
757
777
|
const hn = document.body;
|
|
758
778
|
function Nn({ toolbarGap: e }) {
|
|
759
|
-
const [s, t] =
|
|
779
|
+
const [s, t] = L(null), [n] = T(), [i, r] = L(!1), [o, a] = L(!1), c = z(Math.random().toString(36).substring(2, 9)), d = `block-toolbar-trigger-${c.current}`, m = `block-toolbar-popover-${c.current}`, f = () => r(!0), b = (I) => {
|
|
760
780
|
setTimeout(() => {
|
|
761
|
-
const
|
|
762
|
-
|
|
781
|
+
const h = document.getElementById(d);
|
|
782
|
+
h && (h === document.activeElement || h.contains(document.activeElement) || h.contains(I.relatedTarget)) || r(!1);
|
|
763
783
|
}, 10);
|
|
764
784
|
};
|
|
765
785
|
return u(() => {
|
|
766
|
-
const
|
|
767
|
-
const g = !!document.getElementById(
|
|
768
|
-
|
|
769
|
-
},
|
|
770
|
-
return
|
|
786
|
+
const I = () => {
|
|
787
|
+
const g = !!document.getElementById(m);
|
|
788
|
+
a(g);
|
|
789
|
+
}, h = new MutationObserver(I);
|
|
790
|
+
return h.observe(document.body, {
|
|
771
791
|
childList: !0,
|
|
772
792
|
subtree: !0
|
|
773
|
-
}),
|
|
793
|
+
}), I(), () => h.disconnect();
|
|
774
794
|
}, []), u(() => n.registerRootListener(
|
|
775
|
-
(
|
|
776
|
-
|
|
795
|
+
(h, g) => {
|
|
796
|
+
h && (h.addEventListener("focus", f), h.addEventListener("blur", b)), g && (g.removeEventListener("focus", f), g.removeEventListener("blur", b));
|
|
777
797
|
}
|
|
778
798
|
), [n]), u(() => n.registerCommand(
|
|
779
799
|
A,
|
|
780
800
|
() => {
|
|
781
|
-
const
|
|
782
|
-
if (
|
|
783
|
-
const
|
|
784
|
-
|
|
801
|
+
const h = n.getRootElement();
|
|
802
|
+
if (h) {
|
|
803
|
+
const x = h === document.activeElement || h.contains(document.activeElement);
|
|
804
|
+
x !== i && r(x);
|
|
785
805
|
}
|
|
786
|
-
const g =
|
|
787
|
-
if (!
|
|
806
|
+
const g = p();
|
|
807
|
+
if (!C(g) || !g.isCollapsed())
|
|
788
808
|
return t(null), !1;
|
|
789
|
-
const M =
|
|
790
|
-
if (
|
|
791
|
-
const P = n.getElementByKey(M.getKey()).getBoundingClientRect(),
|
|
792
|
-
t({ x:
|
|
809
|
+
const M = V(g);
|
|
810
|
+
if (k(M) && M.getTextContent() === "") {
|
|
811
|
+
const P = n.getElementByKey(M.getKey()).getBoundingClientRect(), Z = P.left, J = P.top + P.height / 2 + window.scrollY;
|
|
812
|
+
t({ x: Z, y: J });
|
|
793
813
|
} else
|
|
794
814
|
t(null);
|
|
795
815
|
return !1;
|
|
796
816
|
},
|
|
797
|
-
|
|
798
|
-
), [n]), s && (i ||
|
|
799
|
-
/* @__PURE__ */
|
|
817
|
+
N
|
|
818
|
+
), [n]), s && (i || o) && le(
|
|
819
|
+
/* @__PURE__ */ l(
|
|
800
820
|
mn,
|
|
801
821
|
{
|
|
802
822
|
selectionRectCoords: s,
|
|
803
823
|
TOOLBAR_OFFSET: e,
|
|
804
824
|
toolbarTriggerId: d,
|
|
805
|
-
toolbarPopoverId:
|
|
825
|
+
toolbarPopoverId: m
|
|
806
826
|
}
|
|
807
827
|
),
|
|
808
828
|
hn
|
|
@@ -814,21 +834,21 @@ const Cn = [
|
|
|
814
834
|
], pn = [
|
|
815
835
|
["$$", "$$"],
|
|
816
836
|
["\\[", "\\]"]
|
|
817
|
-
], Ee = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
837
|
+
], Ee = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), ke = (e, s) => {
|
|
818
838
|
let t = null;
|
|
819
839
|
for (const [n, i] of s) {
|
|
820
|
-
const
|
|
840
|
+
const o = new RegExp(
|
|
821
841
|
`(.*?)(${Ee(n)})(.*?)(${Ee(i)})`,
|
|
822
842
|
"g"
|
|
823
843
|
).exec(e);
|
|
824
|
-
if (
|
|
825
|
-
const
|
|
826
|
-
if (
|
|
827
|
-
const
|
|
828
|
-
(!t ||
|
|
829
|
-
start:
|
|
844
|
+
if (o) {
|
|
845
|
+
const a = o[3];
|
|
846
|
+
if (a && a.trim() !== "") {
|
|
847
|
+
const c = o.index + o[1].length, d = o.index + o[0].length;
|
|
848
|
+
(!t || c < t.start) && (t = {
|
|
849
|
+
start: c,
|
|
830
850
|
end: d,
|
|
831
|
-
content: n +
|
|
851
|
+
content: n + a + i
|
|
832
852
|
});
|
|
833
853
|
}
|
|
834
854
|
}
|
|
@@ -836,7 +856,7 @@ const Cn = [
|
|
|
836
856
|
return t;
|
|
837
857
|
};
|
|
838
858
|
function Tn() {
|
|
839
|
-
const [e] =
|
|
859
|
+
const [e] = T();
|
|
840
860
|
return u(() => {
|
|
841
861
|
if (!e.hasNodes([Q, Dt]))
|
|
842
862
|
throw new Error(
|
|
@@ -845,46 +865,46 @@ function Tn() {
|
|
|
845
865
|
}, [e]), u(() => e.registerNodeTransform(W, (t) => {
|
|
846
866
|
if (!t.isSimpleText() || R(t) || E(t, D))
|
|
847
867
|
return;
|
|
848
|
-
const n = t.getTextContent(), i =
|
|
868
|
+
const n = t.getTextContent(), i = ke(n, Cn);
|
|
849
869
|
if (i) {
|
|
850
|
-
const { start:
|
|
851
|
-
let
|
|
852
|
-
const d =
|
|
853
|
-
return
|
|
870
|
+
const { start: r, end: o, content: a } = i;
|
|
871
|
+
let c;
|
|
872
|
+
const d = y(a, !0);
|
|
873
|
+
return r === 0 ? ([c] = t.splitText(o), c.insertBefore(d), c.remove()) : ([, c] = t.splitText(r, o), c.replace(d)), d;
|
|
854
874
|
}
|
|
855
875
|
}), [e]), u(() => e.registerCommand(
|
|
856
876
|
A,
|
|
857
877
|
() => {
|
|
858
|
-
const t =
|
|
878
|
+
const t = p(), n = /* @__PURE__ */ new Set();
|
|
859
879
|
if (ae(t)) {
|
|
860
|
-
const
|
|
861
|
-
if (
|
|
862
|
-
const
|
|
863
|
-
if (
|
|
864
|
-
let
|
|
865
|
-
|
|
866
|
-
const d =
|
|
867
|
-
return
|
|
880
|
+
const o = t.getNodes();
|
|
881
|
+
if (o.length === 1 && _(o[0])) {
|
|
882
|
+
const a = o[0];
|
|
883
|
+
if (a.isInline()) {
|
|
884
|
+
let c = a.getEquation();
|
|
885
|
+
c.startsWith("$") && c.endsWith("$") ? c = c.slice(1, -1) : c.startsWith("\\(") && c.endsWith("\\)") && (c = c.slice(2, -2));
|
|
886
|
+
const d = te(c);
|
|
887
|
+
return a.replace(d), d.select(), !0;
|
|
868
888
|
}
|
|
869
889
|
}
|
|
870
|
-
} else
|
|
871
|
-
return U().getAllTextNodes().forEach((
|
|
872
|
-
if (R(
|
|
873
|
-
let
|
|
874
|
-
if (!
|
|
875
|
-
|
|
890
|
+
} else C(t) && t.getNodes().forEach((o) => n.add(o.getKey()));
|
|
891
|
+
return U().getAllTextNodes().forEach((o) => {
|
|
892
|
+
if (R(o) && !n.has(o.getKey())) {
|
|
893
|
+
let a = o.getTextContent();
|
|
894
|
+
if (!a) {
|
|
895
|
+
o.remove();
|
|
876
896
|
return;
|
|
877
897
|
}
|
|
878
|
-
let
|
|
879
|
-
|
|
880
|
-
const d =
|
|
881
|
-
|
|
898
|
+
let c = !1;
|
|
899
|
+
a.startsWith("$") && a.endsWith("$") && a.length >= 2 && (a = a.slice(1, -1), c = !0);
|
|
900
|
+
const d = c ? y(`$$${a}$$`, !1) : y(`$${a}$`, !0);
|
|
901
|
+
o.replace(d);
|
|
882
902
|
}
|
|
883
903
|
}), !1;
|
|
884
904
|
},
|
|
885
|
-
|
|
905
|
+
N
|
|
886
906
|
), [e]), u(() => e.registerCommand(
|
|
887
|
-
|
|
907
|
+
X,
|
|
888
908
|
() => (e.update(() => {
|
|
889
909
|
U().getAllTextNodes().forEach((n) => {
|
|
890
910
|
if (R(n)) {
|
|
@@ -893,58 +913,58 @@ function Tn() {
|
|
|
893
913
|
n.remove();
|
|
894
914
|
return;
|
|
895
915
|
}
|
|
896
|
-
let
|
|
897
|
-
i.startsWith("$") && i.endsWith("$") && i.length >= 2 && (i = i.slice(1, -1),
|
|
898
|
-
const
|
|
899
|
-
n.replace(
|
|
916
|
+
let r = !1;
|
|
917
|
+
i.startsWith("$") && i.endsWith("$") && i.length >= 2 && (i = i.slice(1, -1), r = !0);
|
|
918
|
+
const o = r ? y(`$$${i}$$`, !1) : y(`$${i}$`, !0);
|
|
919
|
+
n.replace(o), Me(null);
|
|
900
920
|
}
|
|
901
921
|
});
|
|
902
922
|
}), !1),
|
|
903
|
-
|
|
923
|
+
N
|
|
904
924
|
), [e]), u(() => e.registerCommand(
|
|
905
925
|
Ye,
|
|
906
926
|
(s) => {
|
|
907
|
-
const t =
|
|
908
|
-
if (!
|
|
927
|
+
const t = p();
|
|
928
|
+
if (!C(t) || !t.isCollapsed())
|
|
909
929
|
return !1;
|
|
910
|
-
const n =
|
|
911
|
-
if (
|
|
912
|
-
let
|
|
913
|
-
|
|
914
|
-
const
|
|
915
|
-
return n.replace(
|
|
930
|
+
const n = re(t.anchor, !1);
|
|
931
|
+
if (_(n) && n.isInline()) {
|
|
932
|
+
let r = n.getEquation();
|
|
933
|
+
r.startsWith("$") && r.endsWith("$") ? r = r.slice(1, -1) : r.startsWith("\\(") && r.endsWith("\\)") && (r = r.slice(2, -2));
|
|
934
|
+
const o = te(r);
|
|
935
|
+
return n.replace(o), o.select(0, 0), !0;
|
|
916
936
|
}
|
|
917
937
|
return !1;
|
|
918
938
|
},
|
|
919
|
-
|
|
939
|
+
N
|
|
920
940
|
), [e]), u(() => e.registerCommand(
|
|
921
941
|
se,
|
|
922
942
|
(s) => {
|
|
923
|
-
const t =
|
|
924
|
-
if (!
|
|
943
|
+
const t = p();
|
|
944
|
+
if (!C(t) || !t.isCollapsed())
|
|
925
945
|
return !1;
|
|
926
|
-
const n =
|
|
927
|
-
if (
|
|
928
|
-
let
|
|
929
|
-
|
|
930
|
-
const
|
|
931
|
-
return n.replace(
|
|
946
|
+
const n = re(t.anchor, !0);
|
|
947
|
+
if (_(n) && n.isInline()) {
|
|
948
|
+
let r = n.getEquation();
|
|
949
|
+
r.startsWith("$") && r.endsWith("$") ? r = r.slice(1, -1) : r.startsWith("\\(") && r.endsWith("\\)") && (r = r.slice(2, -2));
|
|
950
|
+
const o = te(r);
|
|
951
|
+
return n.replace(o), o.select(), !0;
|
|
932
952
|
}
|
|
933
953
|
return !1;
|
|
934
954
|
},
|
|
935
|
-
|
|
955
|
+
N
|
|
936
956
|
), [e]), u(() => e.registerCommand(
|
|
937
957
|
A,
|
|
938
958
|
() => {
|
|
939
|
-
const s =
|
|
940
|
-
if (!
|
|
959
|
+
const s = p();
|
|
960
|
+
if (!C(s) || !s.isCollapsed())
|
|
941
961
|
return !1;
|
|
942
962
|
const t = s.anchor.getNode();
|
|
943
963
|
return R(t) && (t.getNextSibling() || t.insertAfter(Qe(" "))), !1;
|
|
944
964
|
},
|
|
945
965
|
je
|
|
946
966
|
), [e]), // Register click event for MathNode
|
|
947
|
-
/* @__PURE__ */
|
|
967
|
+
/* @__PURE__ */ l(
|
|
948
968
|
de,
|
|
949
969
|
{
|
|
950
970
|
nodeType: Q,
|
|
@@ -957,7 +977,7 @@ function Tn() {
|
|
|
957
977
|
);
|
|
958
978
|
}
|
|
959
979
|
function En() {
|
|
960
|
-
const [e] =
|
|
980
|
+
const [e] = T();
|
|
961
981
|
return u(() => {
|
|
962
982
|
if (!e.hasNodes([Q, At]))
|
|
963
983
|
throw new Error(
|
|
@@ -968,60 +988,60 @@ function En() {
|
|
|
968
988
|
return;
|
|
969
989
|
const n = t.getTextContent();
|
|
970
990
|
if (n.startsWith("$$ ")) {
|
|
971
|
-
const
|
|
972
|
-
if (
|
|
991
|
+
const r = t.getPreviousSibling(), o = E(t, k), a = o !== null && o.getChildrenSize() === 1, c = w(r);
|
|
992
|
+
if (a || c) {
|
|
973
993
|
if (n.length > 3)
|
|
974
994
|
return;
|
|
975
|
-
const d =
|
|
995
|
+
const d = ne("");
|
|
976
996
|
t.replace(d), d.select();
|
|
977
|
-
const
|
|
978
|
-
w(
|
|
997
|
+
const m = d.getNextSibling();
|
|
998
|
+
w(m) && m.remove();
|
|
979
999
|
return;
|
|
980
1000
|
}
|
|
981
1001
|
}
|
|
982
|
-
const i =
|
|
1002
|
+
const i = ke(n, pn);
|
|
983
1003
|
if (i) {
|
|
984
|
-
const { start:
|
|
985
|
-
let
|
|
986
|
-
const d =
|
|
987
|
-
return
|
|
1004
|
+
const { start: r, end: o, content: a } = i;
|
|
1005
|
+
let c;
|
|
1006
|
+
const d = y(a, !1);
|
|
1007
|
+
return r === 0 ? ([c] = t.splitText(o), c.insertBefore(d), c.remove()) : ([, c] = t.splitText(r, o), c.replace(d)), d;
|
|
988
1008
|
}
|
|
989
1009
|
}), [e]), u(() => e.registerCommand(
|
|
990
1010
|
A,
|
|
991
1011
|
() => {
|
|
992
|
-
const t =
|
|
1012
|
+
const t = p(), n = /* @__PURE__ */ new Set();
|
|
993
1013
|
if (ae(t)) {
|
|
994
|
-
const
|
|
995
|
-
if (
|
|
996
|
-
const
|
|
997
|
-
if (!
|
|
998
|
-
let
|
|
999
|
-
(
|
|
1000
|
-
const d =
|
|
1001
|
-
return
|
|
1014
|
+
const o = t.getNodes();
|
|
1015
|
+
if (o.length === 1 && _(o[0])) {
|
|
1016
|
+
const a = o[0];
|
|
1017
|
+
if (!a.isInline()) {
|
|
1018
|
+
let c = a.getEquation();
|
|
1019
|
+
(c.startsWith("$$") && c.endsWith("$$") || c.startsWith("\\[") && c.endsWith("\\]")) && (c = c.slice(2, -2));
|
|
1020
|
+
const d = ne(c);
|
|
1021
|
+
return a.replace(d), d.select(), !0;
|
|
1002
1022
|
}
|
|
1003
1023
|
}
|
|
1004
|
-
} else
|
|
1005
|
-
n.add(
|
|
1006
|
-
const
|
|
1007
|
-
|
|
1024
|
+
} else C(t) && t.getNodes().forEach((o) => {
|
|
1025
|
+
n.add(o.getKey());
|
|
1026
|
+
const a = E(o, D);
|
|
1027
|
+
a && n.add(a.getKey());
|
|
1008
1028
|
});
|
|
1009
|
-
const
|
|
1010
|
-
for (const [,
|
|
1011
|
-
if (D(
|
|
1012
|
-
const
|
|
1013
|
-
if (!
|
|
1014
|
-
|
|
1029
|
+
const r = e.getEditorState()._nodeMap;
|
|
1030
|
+
for (const [, o] of r)
|
|
1031
|
+
if (D(o) && o.isAttached() && !n.has(o.getKey())) {
|
|
1032
|
+
const a = o.getTextContent();
|
|
1033
|
+
if (!a) {
|
|
1034
|
+
o.remove();
|
|
1015
1035
|
continue;
|
|
1016
1036
|
}
|
|
1017
|
-
const
|
|
1018
|
-
|
|
1037
|
+
const c = y(`$$${a}$$`, !1);
|
|
1038
|
+
o.replace(c);
|
|
1019
1039
|
}
|
|
1020
1040
|
return !1;
|
|
1021
1041
|
},
|
|
1022
|
-
|
|
1042
|
+
N
|
|
1023
1043
|
), [e]), u(() => e.registerCommand(
|
|
1024
|
-
|
|
1044
|
+
X,
|
|
1025
1045
|
() => (e.update(() => {
|
|
1026
1046
|
const s = U();
|
|
1027
1047
|
nt(s).forEach(({ node: n }) => {
|
|
@@ -1031,17 +1051,17 @@ function En() {
|
|
|
1031
1051
|
n.remove();
|
|
1032
1052
|
return;
|
|
1033
1053
|
}
|
|
1034
|
-
const
|
|
1035
|
-
n.replace(
|
|
1054
|
+
const r = y(`$$${i}$$`, !1);
|
|
1055
|
+
n.replace(r), Me(null);
|
|
1036
1056
|
}
|
|
1037
1057
|
});
|
|
1038
1058
|
}), !1),
|
|
1039
|
-
|
|
1059
|
+
N
|
|
1040
1060
|
), [e]), u(() => e.registerCommand(
|
|
1041
1061
|
Xe,
|
|
1042
1062
|
() => {
|
|
1043
|
-
const t =
|
|
1044
|
-
if (!
|
|
1063
|
+
const t = p();
|
|
1064
|
+
if (!C(t))
|
|
1045
1065
|
return !1;
|
|
1046
1066
|
const n = t.getNodes()[0], i = E(
|
|
1047
1067
|
n,
|
|
@@ -1049,27 +1069,27 @@ function En() {
|
|
|
1049
1069
|
);
|
|
1050
1070
|
if (!i)
|
|
1051
1071
|
return !1;
|
|
1052
|
-
const
|
|
1053
|
-
return t.isCollapsed() && (t.anchor.getNode().getKey() === i.getKey() && t.anchor.offset === 0 && i.getChildrenSize() === 0 ||
|
|
1072
|
+
const r = i.getLastChild();
|
|
1073
|
+
return t.isCollapsed() && (t.anchor.getNode().getKey() === i.getKey() && t.anchor.offset === 0 && i.getChildrenSize() === 0 || r && w(r) && t.anchor.getNode().getKey() === i.getKey() && t.anchor.offset === i.getChildrenSize() || r && Ve(r) && t.anchor.getNode().getKey() === r.getKey() && t.anchor.offset === r.getTextContent().length) ? !1 : (t.insertLineBreak(), !0);
|
|
1054
1074
|
},
|
|
1055
|
-
|
|
1075
|
+
N
|
|
1056
1076
|
), [e]), u(() => e.registerCommand(
|
|
1057
1077
|
se,
|
|
1058
1078
|
(s) => {
|
|
1059
|
-
const t =
|
|
1060
|
-
if (!
|
|
1079
|
+
const t = p();
|
|
1080
|
+
if (!C(t) || !t.isCollapsed())
|
|
1061
1081
|
return !1;
|
|
1062
|
-
const n =
|
|
1063
|
-
if (
|
|
1064
|
-
let
|
|
1065
|
-
(
|
|
1066
|
-
const
|
|
1067
|
-
return n.replace(
|
|
1082
|
+
const n = re(t.anchor, !0);
|
|
1083
|
+
if (_(n) && !n.isInline()) {
|
|
1084
|
+
let r = n.getEquation();
|
|
1085
|
+
(r.startsWith("$$") && r.endsWith("$$") || r.startsWith("\\[") && r.endsWith("\\]")) && (r = r.slice(2, -2));
|
|
1086
|
+
const o = ne(r);
|
|
1087
|
+
return n.replace(o), o.select(), !0;
|
|
1068
1088
|
}
|
|
1069
1089
|
return !1;
|
|
1070
1090
|
},
|
|
1071
|
-
|
|
1072
|
-
), [e]), /* @__PURE__ */
|
|
1091
|
+
N
|
|
1092
|
+
), [e]), /* @__PURE__ */ l(
|
|
1073
1093
|
de,
|
|
1074
1094
|
{
|
|
1075
1095
|
nodeType: Q,
|
|
@@ -1083,7 +1103,7 @@ function En() {
|
|
|
1083
1103
|
}
|
|
1084
1104
|
const bn = 3;
|
|
1085
1105
|
function Ln() {
|
|
1086
|
-
const [e] =
|
|
1106
|
+
const [e] = T();
|
|
1087
1107
|
return u(() => e.registerNodeTransform(
|
|
1088
1108
|
Ze,
|
|
1089
1109
|
(t) => {
|
|
@@ -1094,39 +1114,39 @@ function Ln() {
|
|
|
1094
1114
|
}
|
|
1095
1115
|
}
|
|
1096
1116
|
), [e]), u(() => e.registerNodeTransform(W, (t) => {
|
|
1097
|
-
if (!E(t,
|
|
1117
|
+
if (!E(t, k) || E(t, k).getFirstDescendant() !== t)
|
|
1098
1118
|
return;
|
|
1099
|
-
const i =
|
|
1100
|
-
if (
|
|
1101
|
-
const
|
|
1102
|
-
t.getTextContent() === "1. " &&
|
|
1119
|
+
const i = p();
|
|
1120
|
+
if (C(i) && i.isCollapsed()) {
|
|
1121
|
+
const o = i.anchor.offset;
|
|
1122
|
+
t.getTextContent() === "1. " && o === 3 ? (me("number"), t.setTextContent("")) : t.getTextContent() === "- " && o === 2 && (me("bullet"), t.setTextContent(""));
|
|
1103
1123
|
}
|
|
1104
1124
|
}), [e]), u(() => e.registerCommand(
|
|
1105
1125
|
et,
|
|
1106
1126
|
(t) => {
|
|
1107
|
-
const n =
|
|
1108
|
-
if (!
|
|
1127
|
+
const n = p();
|
|
1128
|
+
if (!C(n))
|
|
1109
1129
|
return !1;
|
|
1110
|
-
const i =
|
|
1111
|
-
if (!
|
|
1130
|
+
const i = V(n), r = E(i, fe);
|
|
1131
|
+
if (!r)
|
|
1112
1132
|
return !1;
|
|
1113
|
-
const
|
|
1133
|
+
const o = r.getIndent();
|
|
1114
1134
|
if (t.shiftKey) {
|
|
1115
|
-
if (
|
|
1135
|
+
if (o <= 0)
|
|
1116
1136
|
return !1;
|
|
1117
|
-
|
|
1137
|
+
r.setIndent(o - 1);
|
|
1118
1138
|
} else {
|
|
1119
|
-
if (
|
|
1139
|
+
if (o > bn)
|
|
1120
1140
|
return !1;
|
|
1121
|
-
|
|
1141
|
+
r.setIndent(o + 1);
|
|
1122
1142
|
}
|
|
1123
1143
|
return !0;
|
|
1124
1144
|
},
|
|
1125
|
-
|
|
1145
|
+
N
|
|
1126
1146
|
), [e]), null;
|
|
1127
1147
|
}
|
|
1128
1148
|
function Mn() {
|
|
1129
|
-
const [e] =
|
|
1149
|
+
const [e] = T(), s = (t) => {
|
|
1130
1150
|
t.key === "Tab" && t.preventDefault();
|
|
1131
1151
|
};
|
|
1132
1152
|
return u(() => e.registerRootListener(
|
|
@@ -1136,7 +1156,7 @@ function Mn() {
|
|
|
1136
1156
|
), [e]), null;
|
|
1137
1157
|
}
|
|
1138
1158
|
function In({ editorRef: e }) {
|
|
1139
|
-
const [s] =
|
|
1159
|
+
const [s] = T();
|
|
1140
1160
|
return u(() => {
|
|
1141
1161
|
if (e)
|
|
1142
1162
|
return e.current = s, () => {
|
|
@@ -1150,32 +1170,32 @@ function jn({
|
|
|
1150
1170
|
editorRef: t,
|
|
1151
1171
|
blockToolbarGap: n,
|
|
1152
1172
|
spellCheck: i,
|
|
1153
|
-
isHeadingOneFirst:
|
|
1173
|
+
isHeadingOneFirst: r
|
|
1154
1174
|
}) {
|
|
1155
|
-
return /* @__PURE__ */
|
|
1156
|
-
/* @__PURE__ */
|
|
1157
|
-
|
|
1175
|
+
return /* @__PURE__ */ $(Fe, { initialConfig: e, children: [
|
|
1176
|
+
/* @__PURE__ */ l(
|
|
1177
|
+
Ke,
|
|
1158
1178
|
{
|
|
1159
|
-
contentEditable: /* @__PURE__ */
|
|
1179
|
+
contentEditable: /* @__PURE__ */ l(Rt, { spellCheck: i, className: "editor-input" }),
|
|
1160
1180
|
ErrorBoundary: Ge
|
|
1161
1181
|
}
|
|
1162
1182
|
),
|
|
1163
|
-
/* @__PURE__ */
|
|
1164
|
-
/* @__PURE__ */
|
|
1165
|
-
/* @__PURE__ */
|
|
1166
|
-
/* @__PURE__ */
|
|
1167
|
-
/* @__PURE__ */
|
|
1168
|
-
/* @__PURE__ */
|
|
1169
|
-
/* @__PURE__ */
|
|
1170
|
-
/* @__PURE__ */
|
|
1171
|
-
/* @__PURE__ */
|
|
1172
|
-
/* @__PURE__ */
|
|
1173
|
-
/* @__PURE__ */
|
|
1174
|
-
/* @__PURE__ */
|
|
1175
|
-
/* @__PURE__ */
|
|
1176
|
-
/* @__PURE__ */
|
|
1177
|
-
/* @__PURE__ */
|
|
1178
|
-
/* @__PURE__ */
|
|
1183
|
+
/* @__PURE__ */ l(Zt, { isHeadingOneFirst: r }),
|
|
1184
|
+
/* @__PURE__ */ l(on, {}),
|
|
1185
|
+
/* @__PURE__ */ l(Nn, { toolbarGap: n }),
|
|
1186
|
+
/* @__PURE__ */ l(we, {}),
|
|
1187
|
+
/* @__PURE__ */ l(We, {}),
|
|
1188
|
+
/* @__PURE__ */ l(Tn, {}),
|
|
1189
|
+
/* @__PURE__ */ l(En, {}),
|
|
1190
|
+
/* @__PURE__ */ l(cn, {}),
|
|
1191
|
+
/* @__PURE__ */ l(dn, {}),
|
|
1192
|
+
/* @__PURE__ */ l(gn, {}),
|
|
1193
|
+
/* @__PURE__ */ l(kt, {}),
|
|
1194
|
+
/* @__PURE__ */ l(Ln, {}),
|
|
1195
|
+
/* @__PURE__ */ l(Mn, {}),
|
|
1196
|
+
/* @__PURE__ */ l(Ht, { onChange: s }),
|
|
1197
|
+
/* @__PURE__ */ l(In, { editorRef: t }),
|
|
1198
|
+
/* @__PURE__ */ l(wt, {})
|
|
1179
1199
|
] });
|
|
1180
1200
|
}
|
|
1181
1201
|
export {
|