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