lexical-medium-editor 1.2.15 → 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 +550 -513
- 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 _, $getSelection 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 Z, getCodeLanguages 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
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,50 +45,50 @@ function Wt(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
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
68
|
x: a,
|
|
69
69
|
y: d
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
-
const Pe = _("TOGGLE_HEADING_COMMAND"), Be = _("TOGGLE_QUOTE_COMMAND"),
|
|
72
|
+
const Pe = _("TOGGLE_HEADING_COMMAND"), Be = _("TOGGLE_QUOTE_COMMAND"), ke = _("TOGGLE_LINK_COMMAND");
|
|
73
73
|
function ee(e) {
|
|
74
|
-
const s = e.anchor, t = e.focus, n = e.anchor.getNode(),
|
|
75
|
-
return n ===
|
|
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
|
-
(o) =>
|
|
91
|
+
(o) => Le(o) === n
|
|
92
92
|
)) {
|
|
93
93
|
const o = {
|
|
94
94
|
h1: "isHeadingOne",
|
|
@@ -99,36 +99,36 @@ function qt(e) {
|
|
|
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 (
|
|
107
|
+
const { isHeadingOne: n, isHeadingTwo: r, isHeadingThree: o } = t, i = N();
|
|
108
|
+
if (C(i)) {
|
|
109
109
|
let c;
|
|
110
|
-
n ||
|
|
111
|
-
|
|
112
|
-
() => 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 o = t.getChildren(),
|
|
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 Yt() {
|
|
|
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
|
|
152
|
+
const n = N();
|
|
153
|
+
return C(n) && Oe(
|
|
154
154
|
n,
|
|
155
|
-
() => t.isQuote ? G() :
|
|
155
|
+
() => t.isQuote ? G() : $t()
|
|
156
156
|
), !0;
|
|
157
157
|
},
|
|
158
|
-
|
|
158
|
+
m
|
|
159
159
|
), [e]), null;
|
|
160
160
|
}
|
|
161
|
-
function
|
|
162
|
-
if (!
|
|
161
|
+
function Ae(e) {
|
|
162
|
+
if (!C(e))
|
|
163
163
|
return null;
|
|
164
164
|
const s = ee(e);
|
|
165
|
-
return
|
|
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 o =
|
|
191
|
-
if (!
|
|
190
|
+
const o = r, i = e.getElementByKey(o.getKey());
|
|
191
|
+
if (!i)
|
|
192
192
|
return;
|
|
193
|
-
const c = o.getPreviousSibling(), a = le(c), d =
|
|
194
|
-
a && !d ?
|
|
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:
|
|
215
|
+
defaultValue: r,
|
|
216
216
|
onChange: o,
|
|
217
|
-
children: /* @__PURE__ */ l(
|
|
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(B, { "aria-label": "Discard changes", onPress: s, children: /* @__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
|
-
}), o = U(null), [
|
|
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,71 +247,71 @@ function nn({ editor: e }) {
|
|
|
247
247
|
isHeadingTwo: !1,
|
|
248
248
|
isHeadingThree: !1,
|
|
249
249
|
isQuote: !1
|
|
250
|
-
}), [a, d] =
|
|
251
|
-
if (
|
|
250
|
+
}), [a, d] = I(!1), [E, h] = I(0), [M, p] = I(""), f = (g) => {
|
|
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
|
-
c((
|
|
260
|
-
...
|
|
261
|
-
...
|
|
258
|
+
const T = Yt(g);
|
|
259
|
+
c((y) => ({
|
|
260
|
+
...y,
|
|
261
|
+
...T
|
|
262
262
|
}));
|
|
263
|
-
const
|
|
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 =
|
|
269
|
+
const g = N();
|
|
270
270
|
f(g);
|
|
271
271
|
});
|
|
272
272
|
}, [e]), u(() => e.registerUpdateListener(
|
|
273
|
-
({ editorState:
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
f(
|
|
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 =
|
|
282
|
-
if (
|
|
283
|
-
const [
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
], [
|
|
281
|
+
const g = N();
|
|
282
|
+
if (C(g)) {
|
|
283
|
+
const [T, x] = g.getStartEndPoints(), [y, k] = [
|
|
284
|
+
T.getNode(),
|
|
285
|
+
x.getNode()
|
|
286
|
+
], [v, te] = je(g), ne = xt(
|
|
287
287
|
e,
|
|
288
|
-
v,
|
|
289
288
|
y,
|
|
290
|
-
|
|
289
|
+
v,
|
|
290
|
+
k,
|
|
291
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
301
|
o,
|
|
302
|
-
|
|
302
|
+
on
|
|
303
303
|
)
|
|
304
304
|
), setTimeout(() => {
|
|
305
|
-
var
|
|
306
|
-
(
|
|
305
|
+
var T;
|
|
306
|
+
(T = o.current) == null || T.classList.add("visible");
|
|
307
307
|
}, 50)) : (g = o.current) == null || g.classList.remove("visible");
|
|
308
|
-
}, [s]),
|
|
308
|
+
}, [s]), rt(() => {
|
|
309
309
|
if (o.current) {
|
|
310
|
-
const g = window.getComputedStyle(o.current),
|
|
311
|
-
|
|
310
|
+
const g = window.getComputedStyle(o.current), T = parseFloat(g.width);
|
|
311
|
+
h(T);
|
|
312
312
|
}
|
|
313
313
|
}, [s]), s && (a ? /* @__PURE__ */ l(
|
|
314
|
-
|
|
314
|
+
nn,
|
|
315
315
|
{
|
|
316
316
|
style: {
|
|
317
317
|
position: "absolute",
|
|
@@ -322,10 +322,10 @@ function nn({ editor: e }) {
|
|
|
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",
|
|
@@ -336,66 +336,66 @@ function nn({ editor: e }) {
|
|
|
336
336
|
id: "inline-toolbar",
|
|
337
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:
|
|
344
|
+
isSelected: i.isBold,
|
|
345
|
+
isDisabled: i.isCode || i.isHeadingOne || i.isHeadingTwo || i.isHeadingThree,
|
|
346
346
|
onChange: () => e.dispatchCommand(oe, "bold"),
|
|
347
|
-
children: /* @__PURE__ */ l(
|
|
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:
|
|
354
|
+
isSelected: i.isItalic,
|
|
355
|
+
isDisabled: i.isCode || i.isHeadingOne,
|
|
356
356
|
onChange: () => e.dispatchCommand(oe, "italic"),
|
|
357
|
-
children: /* @__PURE__ */ l(
|
|
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:
|
|
364
|
+
isDisabled: i.isHeadingOne,
|
|
365
|
+
isSelected: i.isCode,
|
|
366
366
|
onChange: () => e.dispatchCommand(oe, "code"),
|
|
367
|
-
children: /* @__PURE__ */ l(
|
|
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(Pe,
|
|
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(Be,
|
|
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(
|
|
392
|
+
/* @__PURE__ */ l(he, { orientation: "vertical" }),
|
|
393
393
|
/* @__PURE__ */ l(W, { "aria-label": "Links", children: /* @__PURE__ */ l(
|
|
394
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,51 +403,51 @@ function nn({ 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 (!
|
|
412
|
+
const r = N();
|
|
413
|
+
if (!C(r) || r.isCollapsed())
|
|
414
414
|
return s(!1), !1;
|
|
415
|
-
const o =
|
|
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
|
-
}), o = U(null), [
|
|
435
|
-
new Set(a.map((
|
|
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
436
|
), E = {};
|
|
437
|
-
return a.forEach((
|
|
438
|
-
const
|
|
439
|
-
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
|
-
c(se(
|
|
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
453
|
ref: o,
|
|
@@ -457,90 +457,90 @@ function sn({ codeBlockCoords: e, codeNodeKey: s }) {
|
|
|
457
457
|
left: n.x
|
|
458
458
|
},
|
|
459
459
|
"aria-label": "Code menu",
|
|
460
|
-
inputValue:
|
|
461
|
-
onInputChange: (
|
|
462
|
-
const
|
|
463
|
-
t.dispatchCommand(
|
|
460
|
+
inputValue: i,
|
|
461
|
+
onInputChange: (h) => {
|
|
462
|
+
const M = E[h];
|
|
463
|
+
t.dispatchCommand(He, [
|
|
464
464
|
s,
|
|
465
|
-
|
|
466
|
-
]), c(
|
|
465
|
+
M
|
|
466
|
+
]), c(h);
|
|
467
467
|
},
|
|
468
468
|
children: [
|
|
469
|
-
/* @__PURE__ */
|
|
470
|
-
/* @__PURE__ */ l(
|
|
471
|
-
/* @__PURE__ */ l(B, { children: /* @__PURE__ */ l(
|
|
469
|
+
/* @__PURE__ */ S("div", { children: [
|
|
470
|
+
/* @__PURE__ */ l(ye, {}),
|
|
471
|
+
/* @__PURE__ */ l(B, { children: /* @__PURE__ */ l(Et, { size: 24 }) })
|
|
472
472
|
] }),
|
|
473
|
-
/* @__PURE__ */ l(ve, { children: /* @__PURE__ */ l(
|
|
473
|
+
/* @__PURE__ */ l(ve, { children: /* @__PURE__ */ l(lt, { children: d.map((h, M) => /* @__PURE__ */ l(ct, { children: h }, M)) }) })
|
|
474
474
|
]
|
|
475
475
|
}
|
|
476
476
|
);
|
|
477
477
|
}
|
|
478
|
-
const
|
|
478
|
+
const cn = document.body, _e = _(
|
|
479
479
|
"INSERT_CODE_BLOCK_COMMAND"
|
|
480
|
-
),
|
|
480
|
+
), He = _(
|
|
481
481
|
"SET_CODE_LANGUAGE_COMMAND"
|
|
482
482
|
);
|
|
483
|
-
function
|
|
484
|
-
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(() => {
|
|
485
485
|
s(null), n(null);
|
|
486
486
|
}, []), E = Y(() => {
|
|
487
|
-
const
|
|
488
|
-
return !!(
|
|
489
|
-
}, []),
|
|
490
|
-
const
|
|
491
|
-
return c(
|
|
492
|
-
}, [E]),
|
|
493
|
-
const
|
|
494
|
-
o(!1),
|
|
495
|
-
}, [d,
|
|
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
496
|
return u(() => a.registerCommand(
|
|
497
497
|
A,
|
|
498
498
|
() => {
|
|
499
|
-
const f =
|
|
499
|
+
const f = h(), g = a.getRootElement();
|
|
500
500
|
if (g) {
|
|
501
|
-
const
|
|
502
|
-
o((
|
|
501
|
+
const k = g === document.activeElement || g.contains(document.activeElement);
|
|
502
|
+
o((v) => v === k ? v : k);
|
|
503
503
|
}
|
|
504
|
-
const
|
|
505
|
-
if (!
|
|
504
|
+
const T = N();
|
|
505
|
+
if (!C(T))
|
|
506
506
|
return f || d(), !1;
|
|
507
|
-
const
|
|
508
|
-
if (
|
|
509
|
-
const
|
|
510
|
-
s({ x: te, y: ne }), n(
|
|
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());
|
|
511
511
|
} else
|
|
512
512
|
f || d();
|
|
513
513
|
return !1;
|
|
514
514
|
},
|
|
515
|
-
|
|
516
|
-
), [a,
|
|
515
|
+
m
|
|
516
|
+
), [a, h, d]), u(() => a.registerCommand(
|
|
517
517
|
J,
|
|
518
|
-
() => (setTimeout(
|
|
519
|
-
|
|
520
|
-
), [a,
|
|
521
|
-
const
|
|
518
|
+
() => (setTimeout(M, 0), !1),
|
|
519
|
+
m
|
|
520
|
+
), [a, M]), u(() => {
|
|
521
|
+
const p = () => {
|
|
522
522
|
o(!0), c(!1);
|
|
523
|
-
}, f = () => setTimeout(
|
|
524
|
-
return a.registerRootListener((g,
|
|
525
|
-
g && (g.addEventListener("focus",
|
|
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));
|
|
526
526
|
});
|
|
527
|
-
}, [a,
|
|
528
|
-
/* @__PURE__ */ l(
|
|
529
|
-
|
|
527
|
+
}, [a, M]), e && (r || i) && ge(
|
|
528
|
+
/* @__PURE__ */ l(ln, { codeBlockCoords: e, codeNodeKey: t }),
|
|
529
|
+
cn
|
|
530
530
|
);
|
|
531
531
|
}
|
|
532
|
-
function
|
|
533
|
-
const [e] =
|
|
534
|
-
return u(() =>
|
|
532
|
+
function un() {
|
|
533
|
+
const [e] = L();
|
|
534
|
+
return u(() => Rt(e), [e]), u(() => e.registerNodeTransform(z, (t) => {
|
|
535
535
|
if (!t.isSimpleText())
|
|
536
536
|
return;
|
|
537
537
|
const n = t.getTextContent();
|
|
538
538
|
if (n.startsWith("``` ")) {
|
|
539
|
-
const
|
|
540
|
-
if (
|
|
539
|
+
const r = t.getPreviousSibling(), o = b(t, w), i = o !== null && o.getChildrenSize() === 1, c = K(r);
|
|
540
|
+
if (i || c) {
|
|
541
541
|
if (n.length > 4)
|
|
542
542
|
return;
|
|
543
|
-
const a =
|
|
543
|
+
const a = be();
|
|
544
544
|
t.replace(a), a.select();
|
|
545
545
|
const d = a.getNextSibling();
|
|
546
546
|
K(d) && d.remove();
|
|
@@ -548,145 +548,145 @@ function cn() {
|
|
|
548
548
|
}
|
|
549
549
|
}
|
|
550
550
|
}), [e]), u(() => e.registerCommand(
|
|
551
|
-
|
|
551
|
+
_e,
|
|
552
552
|
() => {
|
|
553
553
|
const t = X();
|
|
554
|
-
if (
|
|
555
|
-
const n =
|
|
554
|
+
if (C(t)) {
|
|
555
|
+
const n = be();
|
|
556
556
|
return t.insertNodes([n]), n.selectStart(), setTimeout(() => {
|
|
557
557
|
e.focus();
|
|
558
558
|
}, 0), !0;
|
|
559
559
|
}
|
|
560
560
|
return !1;
|
|
561
561
|
},
|
|
562
|
-
|
|
562
|
+
m
|
|
563
563
|
), [e]), u(() => e.registerCommand(
|
|
564
|
-
|
|
564
|
+
He,
|
|
565
565
|
(t) => {
|
|
566
|
-
const [n,
|
|
567
|
-
return Z(o) ? (o.setLanguage(
|
|
566
|
+
const [n, r] = t, o = q(n);
|
|
567
|
+
return Z(o) ? (o.setLanguage(r), !0) : !1;
|
|
568
568
|
},
|
|
569
|
-
|
|
569
|
+
m
|
|
570
570
|
), [e]), u(() => e.registerCommand(
|
|
571
571
|
ce,
|
|
572
572
|
(t) => {
|
|
573
|
-
const n =
|
|
574
|
-
if (!
|
|
573
|
+
const n = N();
|
|
574
|
+
if (!C(n) || !n.isCollapsed())
|
|
575
575
|
return !1;
|
|
576
|
-
const
|
|
576
|
+
const r = n.anchor.getNode(), o = b(r, Z);
|
|
577
577
|
return o && n.anchor.offset === 0 && o.getTextContent() === "" ? (o.remove(), !0) : !1;
|
|
578
578
|
},
|
|
579
|
-
|
|
579
|
+
m
|
|
580
580
|
), [e]), null;
|
|
581
581
|
}
|
|
582
|
-
function
|
|
583
|
-
return /* @__PURE__ */
|
|
584
|
-
/* @__PURE__ */ l(
|
|
585
|
-
/* @__PURE__ */ l(
|
|
582
|
+
function gn() {
|
|
583
|
+
return /* @__PURE__ */ S(xe, { children: [
|
|
584
|
+
/* @__PURE__ */ l(un, {}),
|
|
585
|
+
/* @__PURE__ */ l(dn, {})
|
|
586
586
|
] });
|
|
587
587
|
}
|
|
588
|
-
const
|
|
588
|
+
const Re = _(
|
|
589
589
|
"INSERT_HORIZONTAL_DIVIDER_COMMAND"
|
|
590
590
|
);
|
|
591
|
-
function
|
|
592
|
-
const [e] =
|
|
591
|
+
function fn() {
|
|
592
|
+
const [e] = L();
|
|
593
593
|
return u(() => {
|
|
594
|
-
if (!e.hasNodes([
|
|
594
|
+
if (!e.hasNodes([Pt]))
|
|
595
595
|
throw new Error("HorizontalDividerNode not registered on editor");
|
|
596
596
|
return e.registerCommand(
|
|
597
|
-
|
|
597
|
+
Re,
|
|
598
598
|
() => {
|
|
599
599
|
const t = X();
|
|
600
|
-
if (
|
|
601
|
-
const n =
|
|
600
|
+
if (C(t)) {
|
|
601
|
+
const n = Bt();
|
|
602
602
|
t.insertNodes([n]);
|
|
603
|
-
let
|
|
604
|
-
return
|
|
603
|
+
let r = n.getNextSibling() || n.getParent().getNextSibling();
|
|
604
|
+
return r || (r = G(), n.insertAfter(r)), r.selectStart(), setTimeout(() => {
|
|
605
605
|
e.focus();
|
|
606
606
|
}, 0), !0;
|
|
607
607
|
}
|
|
608
608
|
return !1;
|
|
609
609
|
},
|
|
610
|
-
|
|
610
|
+
m
|
|
611
611
|
);
|
|
612
612
|
}, [e]), null;
|
|
613
613
|
}
|
|
614
|
-
const
|
|
615
|
-
function
|
|
614
|
+
const we = _("INSERT_IMAGE_COMMAND"), Me = "selected";
|
|
615
|
+
function mn(e) {
|
|
616
616
|
return e && e.type && e.type.startsWith("image/");
|
|
617
617
|
}
|
|
618
|
-
function
|
|
619
|
-
const [e] =
|
|
618
|
+
function hn() {
|
|
619
|
+
const [e] = L(), s = U(null);
|
|
620
620
|
return u(() => {
|
|
621
|
-
if (!e.hasNode(
|
|
621
|
+
if (!e.hasNode(Te))
|
|
622
622
|
throw new Error("ImagePlugin: ImageNode not registered on editor");
|
|
623
623
|
return e.registerCommand(
|
|
624
|
-
|
|
624
|
+
we,
|
|
625
625
|
(n) => {
|
|
626
|
-
const
|
|
627
|
-
if (
|
|
628
|
-
const
|
|
629
|
-
o.insertNodes([
|
|
630
|
-
let c =
|
|
631
|
-
return c || (c = G(),
|
|
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;
|
|
632
632
|
}
|
|
633
633
|
return !1;
|
|
634
634
|
},
|
|
635
|
-
|
|
635
|
+
m
|
|
636
636
|
);
|
|
637
637
|
}, [e]), u(() => e.registerCommand(
|
|
638
638
|
A,
|
|
639
639
|
() => {
|
|
640
|
-
s.current && (s.current.classList.remove(
|
|
641
|
-
const n =
|
|
640
|
+
s.current && (s.current.classList.remove(Me), s.current = null);
|
|
641
|
+
const n = N();
|
|
642
642
|
if (de(n) && n.getNodes().length === 1) {
|
|
643
|
-
const
|
|
644
|
-
if (
|
|
645
|
-
const o = e.getElementByKey(
|
|
646
|
-
o.classList.add(
|
|
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;
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
649
|
return !1;
|
|
650
650
|
},
|
|
651
651
|
Se
|
|
652
652
|
), [e]), u(() => e.registerCommand(
|
|
653
|
-
|
|
653
|
+
ue,
|
|
654
654
|
(n) => {
|
|
655
|
-
const
|
|
656
|
-
if (!
|
|
655
|
+
const r = n.clipboardData;
|
|
656
|
+
if (!r)
|
|
657
657
|
return !1;
|
|
658
|
-
const
|
|
659
|
-
if (
|
|
658
|
+
const i = Array.from(r.files).filter(mn);
|
|
659
|
+
if (i.length === 1) {
|
|
660
660
|
n.preventDefault();
|
|
661
|
-
const c =
|
|
662
|
-
if (!
|
|
661
|
+
const c = i[0], a = N() || X();
|
|
662
|
+
if (!C(a))
|
|
663
663
|
return !1;
|
|
664
|
-
const d = URL.createObjectURL(c), E =
|
|
664
|
+
const d = URL.createObjectURL(c), E = Ee(d);
|
|
665
665
|
a.insertNodes([E]);
|
|
666
|
-
let
|
|
667
|
-
return
|
|
666
|
+
let h = E.getNextSibling() || E.getParent().getNextSibling();
|
|
667
|
+
return h || (h = G(), E.insertAfter(h)), E.select(), !0;
|
|
668
668
|
}
|
|
669
669
|
return !1;
|
|
670
670
|
},
|
|
671
|
-
|
|
671
|
+
m
|
|
672
672
|
), [e]), // Make the Image selectable
|
|
673
673
|
/* @__PURE__ */ l(
|
|
674
|
-
|
|
674
|
+
me,
|
|
675
675
|
{
|
|
676
|
-
nodeType:
|
|
676
|
+
nodeType: Te,
|
|
677
677
|
eventType: "click",
|
|
678
|
-
eventListener: (t, n,
|
|
679
|
-
q(
|
|
678
|
+
eventListener: (t, n, r) => {
|
|
679
|
+
q(r).select();
|
|
680
680
|
}
|
|
681
681
|
}
|
|
682
682
|
);
|
|
683
683
|
}
|
|
684
684
|
const Q = 24;
|
|
685
|
-
function
|
|
686
|
-
const [e] =
|
|
687
|
-
return /* @__PURE__ */ l(
|
|
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: [
|
|
688
688
|
/* @__PURE__ */ l(
|
|
689
|
-
|
|
689
|
+
ut,
|
|
690
690
|
{
|
|
691
691
|
acceptedFileTypes: ["image/png", "image/jpeg", "image/gif"],
|
|
692
692
|
onSelect: (t) => {
|
|
@@ -697,17 +697,17 @@ function mn() {
|
|
|
697
697
|
alert("Please select an image file.");
|
|
698
698
|
return;
|
|
699
699
|
}
|
|
700
|
-
const
|
|
701
|
-
|
|
700
|
+
const r = new FileReader();
|
|
701
|
+
r.onload = (o) => {
|
|
702
702
|
var c;
|
|
703
|
-
const
|
|
704
|
-
typeof
|
|
705
|
-
},
|
|
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
706
|
console.error("Error reading file:", o), alert("Error reading file.");
|
|
707
|
-
},
|
|
707
|
+
}, r.readAsDataURL(n);
|
|
708
708
|
},
|
|
709
709
|
allowsMultiple: !1,
|
|
710
|
-
children: /* @__PURE__ */ l(B, { "aria-label": "image", children: /* @__PURE__ */ l(
|
|
710
|
+
children: /* @__PURE__ */ l(B, { "aria-label": "image", children: /* @__PURE__ */ l(Lt, { size: Q }) })
|
|
711
711
|
}
|
|
712
712
|
),
|
|
713
713
|
/* @__PURE__ */ l(
|
|
@@ -715,9 +715,9 @@ function mn() {
|
|
|
715
715
|
{
|
|
716
716
|
"aria-label": "code block",
|
|
717
717
|
onPress: () => {
|
|
718
|
-
e.dispatchCommand(
|
|
718
|
+
e.dispatchCommand(_e, void 0);
|
|
719
719
|
},
|
|
720
|
-
children: /* @__PURE__ */ l(
|
|
720
|
+
children: /* @__PURE__ */ l(Mt, { size: Q })
|
|
721
721
|
}
|
|
722
722
|
),
|
|
723
723
|
/* @__PURE__ */ l(
|
|
@@ -726,47 +726,47 @@ function mn() {
|
|
|
726
726
|
"aria-label": "horizontal divider",
|
|
727
727
|
onPress: () => {
|
|
728
728
|
e.dispatchCommand(
|
|
729
|
-
|
|
729
|
+
Re,
|
|
730
730
|
void 0
|
|
731
731
|
);
|
|
732
732
|
},
|
|
733
|
-
children: /* @__PURE__ */ l(
|
|
733
|
+
children: /* @__PURE__ */ l(It, { size: Q })
|
|
734
734
|
}
|
|
735
735
|
)
|
|
736
736
|
] }) });
|
|
737
737
|
}
|
|
738
|
-
function
|
|
738
|
+
function Cn({
|
|
739
739
|
selectionRectCoords: e,
|
|
740
740
|
TOOLBAR_OFFSET: s,
|
|
741
741
|
toolbarTriggerId: t,
|
|
742
742
|
toolbarPopoverId: n
|
|
743
743
|
}) {
|
|
744
|
-
const [
|
|
745
|
-
x
|
|
746
|
-
y:
|
|
747
|
-
}),
|
|
744
|
+
const [r, o] = I({
|
|
745
|
+
x: $,
|
|
746
|
+
y: $
|
|
747
|
+
}), i = U(null);
|
|
748
748
|
return u(() => {
|
|
749
749
|
o(
|
|
750
|
-
|
|
750
|
+
qt(
|
|
751
751
|
e,
|
|
752
|
-
|
|
752
|
+
i,
|
|
753
753
|
s
|
|
754
754
|
)
|
|
755
755
|
);
|
|
756
|
-
}, [e]), /* @__PURE__ */
|
|
756
|
+
}, [e]), /* @__PURE__ */ S(dt, { children: [
|
|
757
757
|
/* @__PURE__ */ l(
|
|
758
758
|
B,
|
|
759
759
|
{
|
|
760
760
|
"aria-label": "Block toolbar trigger",
|
|
761
761
|
className: "block-toolbar-trigger",
|
|
762
762
|
id: t,
|
|
763
|
-
ref:
|
|
763
|
+
ref: i,
|
|
764
764
|
style: {
|
|
765
765
|
position: "absolute",
|
|
766
|
-
top:
|
|
767
|
-
left:
|
|
766
|
+
top: r.y,
|
|
767
|
+
left: r.x
|
|
768
768
|
},
|
|
769
|
-
children: /* @__PURE__ */ l(
|
|
769
|
+
children: /* @__PURE__ */ l(bt, { size: Q })
|
|
770
770
|
}
|
|
771
771
|
),
|
|
772
772
|
/* @__PURE__ */ l(
|
|
@@ -777,55 +777,55 @@ function hn({
|
|
|
777
777
|
placement: "end",
|
|
778
778
|
shouldFlip: !1,
|
|
779
779
|
offset: s,
|
|
780
|
-
children: /* @__PURE__ */ l(
|
|
780
|
+
children: /* @__PURE__ */ l(Nn, {})
|
|
781
781
|
}
|
|
782
782
|
)
|
|
783
783
|
] });
|
|
784
784
|
}
|
|
785
|
-
const
|
|
786
|
-
function
|
|
787
|
-
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) => {
|
|
788
788
|
setTimeout(() => {
|
|
789
789
|
const f = document.getElementById(d);
|
|
790
|
-
f && (f === document.activeElement || f.contains(document.activeElement) || f.contains(
|
|
790
|
+
f && (f === document.activeElement || f.contains(document.activeElement) || f.contains(p.relatedTarget)) || o(!1);
|
|
791
791
|
}, 10);
|
|
792
792
|
};
|
|
793
793
|
return u(() => {
|
|
794
|
-
const
|
|
794
|
+
const p = () => {
|
|
795
795
|
const g = !!document.getElementById(E);
|
|
796
796
|
c(g);
|
|
797
|
-
}, f = new MutationObserver(
|
|
797
|
+
}, f = new MutationObserver(p);
|
|
798
798
|
return f.observe(document.body, {
|
|
799
799
|
childList: !0,
|
|
800
800
|
subtree: !0
|
|
801
|
-
}),
|
|
801
|
+
}), p(), () => f.disconnect();
|
|
802
802
|
}, []), u(() => n.registerRootListener(
|
|
803
803
|
(f, g) => {
|
|
804
|
-
f && (f.addEventListener("focus",
|
|
804
|
+
f && (f.addEventListener("focus", h), f.addEventListener("blur", M)), g && (g.removeEventListener("focus", h), g.removeEventListener("blur", M));
|
|
805
805
|
}
|
|
806
806
|
), [n]), u(() => n.registerCommand(
|
|
807
807
|
A,
|
|
808
808
|
() => {
|
|
809
809
|
const f = n.getRootElement();
|
|
810
810
|
if (f) {
|
|
811
|
-
const
|
|
812
|
-
|
|
811
|
+
const x = f === document.activeElement || f.contains(document.activeElement);
|
|
812
|
+
x !== r && o(x);
|
|
813
813
|
}
|
|
814
|
-
const g =
|
|
815
|
-
if (!
|
|
814
|
+
const g = N();
|
|
815
|
+
if (!C(g) || !g.isCollapsed())
|
|
816
816
|
return t(null), !1;
|
|
817
|
-
const
|
|
818
|
-
if (
|
|
819
|
-
const
|
|
820
|
-
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 });
|
|
821
821
|
} else
|
|
822
822
|
t(null);
|
|
823
823
|
return !1;
|
|
824
824
|
},
|
|
825
|
-
|
|
826
|
-
), [n]), s && (
|
|
825
|
+
m
|
|
826
|
+
), [n]), s && (r || i) && ge(
|
|
827
827
|
/* @__PURE__ */ l(
|
|
828
|
-
|
|
828
|
+
Cn,
|
|
829
829
|
{
|
|
830
830
|
selectionRectCoords: s,
|
|
831
831
|
TOOLBAR_OFFSET: e,
|
|
@@ -833,61 +833,66 @@ function Cn({ toolbarGap: e }) {
|
|
|
833
833
|
toolbarPopoverId: E
|
|
834
834
|
}
|
|
835
835
|
),
|
|
836
|
-
|
|
836
|
+
pn
|
|
837
837
|
);
|
|
838
838
|
}
|
|
839
|
-
const
|
|
839
|
+
const En = [
|
|
840
840
|
["$", "$"],
|
|
841
841
|
["\\(", "\\)"]
|
|
842
|
-
],
|
|
842
|
+
], bn = [
|
|
843
843
|
["$$", "$$"],
|
|
844
844
|
["\\[", "\\]"]
|
|
845
|
-
],
|
|
845
|
+
], Ie = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), Fe = (e, s) => {
|
|
846
846
|
let t = null;
|
|
847
|
-
for (const [n,
|
|
848
|
-
const
|
|
849
|
-
`(.*?)(${
|
|
847
|
+
for (const [n, r] of s) {
|
|
848
|
+
const i = new RegExp(
|
|
849
|
+
`(.*?)(${Ie(n)})(.*?)(${Ie(r)})`,
|
|
850
850
|
"g"
|
|
851
851
|
).exec(e);
|
|
852
|
-
if (
|
|
853
|
-
const c =
|
|
852
|
+
if (i) {
|
|
853
|
+
const c = i[3];
|
|
854
854
|
if (c && c.trim() !== "") {
|
|
855
|
-
const a =
|
|
855
|
+
const a = i.index + i[1].length, d = i.index + i[0].length;
|
|
856
856
|
(!t || a < t.start) && (t = {
|
|
857
857
|
start: a,
|
|
858
858
|
end: d,
|
|
859
|
-
content: n + c +
|
|
859
|
+
content: n + c + r
|
|
860
860
|
});
|
|
861
861
|
}
|
|
862
862
|
}
|
|
863
863
|
}
|
|
864
864
|
return t;
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
|
|
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();
|
|
868
873
|
return u(() => {
|
|
869
|
-
if (!e.hasNodes([V,
|
|
874
|
+
if (!e.hasNodes([V, At]))
|
|
870
875
|
throw new Error(
|
|
871
876
|
"MathInlinePlugin: MathNode or MathHighlightNodeInline not registered on editor"
|
|
872
877
|
);
|
|
873
878
|
}, [e]), u(() => e.registerNodeTransform(z, (t) => {
|
|
874
|
-
if (!t.isSimpleText() ||
|
|
879
|
+
if (!t.isSimpleText() || H(t) || b(t, O))
|
|
875
880
|
return;
|
|
876
|
-
const n = t.getTextContent(),
|
|
877
|
-
if (
|
|
878
|
-
const { start: o, end:
|
|
881
|
+
const n = t.getTextContent(), r = Fe(n, En);
|
|
882
|
+
if (r) {
|
|
883
|
+
const { start: o, end: i, content: c } = r;
|
|
879
884
|
let a;
|
|
880
885
|
const d = P(c, !0);
|
|
881
|
-
return o === 0 ? ([a] = t.splitText(
|
|
886
|
+
return o === 0 ? ([a] = t.splitText(i), a.insertBefore(d), a.remove()) : ([, a] = t.splitText(o, i), a.replace(d)), d;
|
|
882
887
|
}
|
|
883
888
|
}), [e]), u(() => e.registerCommand(
|
|
884
889
|
A,
|
|
885
890
|
() => {
|
|
886
|
-
const t =
|
|
891
|
+
const t = N(), n = /* @__PURE__ */ new Set();
|
|
887
892
|
if (de(t)) {
|
|
888
|
-
const
|
|
889
|
-
if (
|
|
890
|
-
const c =
|
|
893
|
+
const i = t.getNodes();
|
|
894
|
+
if (i.length === 1 && R(i[0])) {
|
|
895
|
+
const c = i[0];
|
|
891
896
|
if (c.isInline()) {
|
|
892
897
|
let a = c.getEquation();
|
|
893
898
|
a.startsWith("$") && a.endsWith("$") ? a = a.slice(1, -1) : a.startsWith("\\(") && a.endsWith("\\)") && (a = a.slice(2, -2));
|
|
@@ -895,108 +900,124 @@ function En() {
|
|
|
895
900
|
return c.replace(d), d.select(), !0;
|
|
896
901
|
}
|
|
897
902
|
}
|
|
898
|
-
} else
|
|
899
|
-
return j().getAllTextNodes().forEach((
|
|
900
|
-
if (
|
|
901
|
-
let c =
|
|
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();
|
|
902
907
|
if (!c) {
|
|
903
|
-
|
|
908
|
+
i.remove();
|
|
904
909
|
return;
|
|
905
910
|
}
|
|
906
911
|
let a = !1;
|
|
907
912
|
c.startsWith("$") && c.endsWith("$") && c.length >= 2 && (c = c.slice(1, -1), a = !0);
|
|
908
913
|
const d = a ? P(`$$${c}$$`, !1) : P(`$${c}$`, !0);
|
|
909
|
-
|
|
914
|
+
i.replace(d);
|
|
910
915
|
}
|
|
911
916
|
}), !1;
|
|
912
917
|
},
|
|
913
|
-
|
|
918
|
+
m
|
|
914
919
|
), [e]), u(() => e.registerCommand(
|
|
915
920
|
J,
|
|
916
921
|
() => (e.update(() => {
|
|
917
922
|
j().getAllTextNodes().forEach((n) => {
|
|
918
|
-
if (
|
|
919
|
-
let
|
|
920
|
-
if (!
|
|
923
|
+
if (H(n)) {
|
|
924
|
+
let r = n.getTextContent();
|
|
925
|
+
if (!r) {
|
|
921
926
|
n.remove();
|
|
922
927
|
return;
|
|
923
928
|
}
|
|
924
929
|
let o = !1;
|
|
925
|
-
|
|
926
|
-
const
|
|
927
|
-
n.replace(
|
|
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);
|
|
928
933
|
}
|
|
929
934
|
});
|
|
930
935
|
}), !1),
|
|
931
|
-
|
|
936
|
+
m
|
|
932
937
|
), [e]), u(() => e.registerCommand(
|
|
933
|
-
|
|
938
|
+
Xe,
|
|
934
939
|
(s) => {
|
|
935
|
-
const t =
|
|
936
|
-
if (!
|
|
940
|
+
const t = N();
|
|
941
|
+
if (!C(t) || !t.isCollapsed())
|
|
937
942
|
return !1;
|
|
938
943
|
const n = ae(t.anchor, !1);
|
|
939
|
-
if (
|
|
944
|
+
if (R(n) && n.isInline()) {
|
|
940
945
|
let o = n.getEquation();
|
|
941
946
|
o.startsWith("$") && o.endsWith("$") ? o = o.slice(1, -1) : o.startsWith("\\(") && o.endsWith("\\)") && (o = o.slice(2, -2));
|
|
942
|
-
const
|
|
943
|
-
return n.replace(
|
|
947
|
+
const i = re(o);
|
|
948
|
+
return n.replace(i), i.select(0, 0), !0;
|
|
944
949
|
}
|
|
945
950
|
return !1;
|
|
946
951
|
},
|
|
947
|
-
|
|
952
|
+
m
|
|
948
953
|
), [e]), u(() => e.registerCommand(
|
|
949
954
|
ce,
|
|
950
955
|
(s) => {
|
|
951
|
-
const t =
|
|
952
|
-
if (!
|
|
956
|
+
const t = N();
|
|
957
|
+
if (!C(t) || !t.isCollapsed())
|
|
953
958
|
return !1;
|
|
954
959
|
const n = ae(t.anchor, !0);
|
|
955
|
-
if (
|
|
960
|
+
if (R(n) && n.isInline()) {
|
|
956
961
|
let o = n.getEquation();
|
|
957
962
|
o.startsWith("$") && o.endsWith("$") ? o = o.slice(1, -1) : o.startsWith("\\(") && o.endsWith("\\)") && (o = o.slice(2, -2));
|
|
958
|
-
const
|
|
959
|
-
return n.replace(
|
|
963
|
+
const i = re(o);
|
|
964
|
+
return n.replace(i), i.select(), !0;
|
|
960
965
|
}
|
|
961
966
|
return !1;
|
|
962
967
|
},
|
|
963
|
-
|
|
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
|
|
964
985
|
), [e]), u(() => e.registerCommand(
|
|
965
986
|
A,
|
|
966
987
|
() => {
|
|
967
|
-
const s =
|
|
968
|
-
if (!
|
|
988
|
+
const s = N();
|
|
989
|
+
if (!C(s) || !s.isCollapsed())
|
|
969
990
|
return !1;
|
|
970
991
|
const t = s.anchor.getNode();
|
|
971
|
-
return
|
|
992
|
+
return H(t) && (t.getNextSibling() || t.insertAfter(Ve(" "))), !1;
|
|
972
993
|
},
|
|
973
|
-
|
|
994
|
+
Ze
|
|
974
995
|
), [e]), // Register click event for MathNode
|
|
975
996
|
/* @__PURE__ */ l(
|
|
976
|
-
|
|
997
|
+
me,
|
|
977
998
|
{
|
|
978
999
|
nodeType: V,
|
|
979
1000
|
eventType: "click",
|
|
980
1001
|
eventListener: (s, t, n) => {
|
|
981
|
-
const
|
|
982
|
-
|
|
1002
|
+
const r = q(n);
|
|
1003
|
+
r && r.isInline() && r.select();
|
|
983
1004
|
}
|
|
984
1005
|
}
|
|
985
1006
|
);
|
|
986
1007
|
}
|
|
987
|
-
function
|
|
988
|
-
const [e] =
|
|
1008
|
+
function Mn() {
|
|
1009
|
+
const [e] = L();
|
|
989
1010
|
return u(() => {
|
|
990
|
-
if (!e.hasNodes([V,
|
|
1011
|
+
if (!e.hasNodes([V, _t]))
|
|
991
1012
|
throw new Error(
|
|
992
1013
|
"MathBlockPlugin: MathNode or MathHighlightNodeBlock not registered on editor"
|
|
993
1014
|
);
|
|
994
1015
|
}, [e]), u(() => e.registerNodeTransform(z, (t) => {
|
|
995
|
-
if (!t.isSimpleText() ||
|
|
1016
|
+
if (!t.isSimpleText() || b(t, O))
|
|
996
1017
|
return;
|
|
997
1018
|
const n = t.getTextContent();
|
|
998
1019
|
if (n.startsWith("$$ ")) {
|
|
999
|
-
const o = t.getPreviousSibling(),
|
|
1020
|
+
const o = t.getPreviousSibling(), i = b(t, w), c = i !== null && i.getChildrenSize() === 1, a = K(o);
|
|
1000
1021
|
if (c || a) {
|
|
1001
1022
|
if (n.length > 3)
|
|
1002
1023
|
return;
|
|
@@ -1007,21 +1028,21 @@ function bn() {
|
|
|
1007
1028
|
return;
|
|
1008
1029
|
}
|
|
1009
1030
|
}
|
|
1010
|
-
const
|
|
1011
|
-
if (
|
|
1012
|
-
const { start: o, end:
|
|
1031
|
+
const r = Fe(n, bn);
|
|
1032
|
+
if (r) {
|
|
1033
|
+
const { start: o, end: i, content: c } = r;
|
|
1013
1034
|
let a;
|
|
1014
1035
|
const d = P(c, !1);
|
|
1015
|
-
return o === 0 ? ([a] = t.splitText(
|
|
1036
|
+
return o === 0 ? ([a] = t.splitText(i), a.insertBefore(d), a.remove()) : ([, a] = t.splitText(o, i), a.replace(d)), d;
|
|
1016
1037
|
}
|
|
1017
1038
|
}), [e]), u(() => e.registerCommand(
|
|
1018
1039
|
A,
|
|
1019
1040
|
() => {
|
|
1020
|
-
const t =
|
|
1041
|
+
const t = N(), n = /* @__PURE__ */ new Set();
|
|
1021
1042
|
if (de(t)) {
|
|
1022
|
-
const
|
|
1023
|
-
if (
|
|
1024
|
-
const c =
|
|
1043
|
+
const i = t.getNodes();
|
|
1044
|
+
if (i.length === 1 && R(i[0])) {
|
|
1045
|
+
const c = i[0];
|
|
1025
1046
|
if (!c.isInline()) {
|
|
1026
1047
|
let a = c.getEquation();
|
|
1027
1048
|
(a.startsWith("$$") && a.endsWith("$$") || a.startsWith("\\[") && a.endsWith("\\]")) && (a = a.slice(2, -2));
|
|
@@ -1029,142 +1050,158 @@ function bn() {
|
|
|
1029
1050
|
return c.replace(d), d.select(), !0;
|
|
1030
1051
|
}
|
|
1031
1052
|
}
|
|
1032
|
-
} else
|
|
1033
|
-
n.add(
|
|
1034
|
-
const c =
|
|
1053
|
+
} else C(t) && t.getNodes().forEach((i) => {
|
|
1054
|
+
n.add(i.getKey());
|
|
1055
|
+
const c = b(i, O);
|
|
1035
1056
|
c && n.add(c.getKey());
|
|
1036
1057
|
});
|
|
1037
1058
|
const o = e.getEditorState()._nodeMap;
|
|
1038
|
-
for (const [,
|
|
1039
|
-
if (
|
|
1040
|
-
const c =
|
|
1059
|
+
for (const [, i] of o)
|
|
1060
|
+
if (O(i) && i.isAttached() && !n.has(i.getKey())) {
|
|
1061
|
+
const c = i.getTextContent();
|
|
1041
1062
|
if (!c) {
|
|
1042
|
-
|
|
1063
|
+
i.remove();
|
|
1043
1064
|
continue;
|
|
1044
1065
|
}
|
|
1045
1066
|
const a = P(`$$${c}$$`, !1);
|
|
1046
|
-
|
|
1067
|
+
i.replace(a);
|
|
1047
1068
|
}
|
|
1048
1069
|
return !1;
|
|
1049
1070
|
},
|
|
1050
|
-
|
|
1071
|
+
m
|
|
1051
1072
|
), [e]), u(() => e.registerCommand(
|
|
1052
1073
|
J,
|
|
1053
1074
|
() => (e.update(() => {
|
|
1054
1075
|
const s = j();
|
|
1055
|
-
|
|
1056
|
-
if (
|
|
1057
|
-
const
|
|
1058
|
-
if (!
|
|
1076
|
+
it(s).forEach(({ node: n }) => {
|
|
1077
|
+
if (O(n)) {
|
|
1078
|
+
const r = n.getTextContent();
|
|
1079
|
+
if (!r) {
|
|
1059
1080
|
n.remove();
|
|
1060
1081
|
return;
|
|
1061
1082
|
}
|
|
1062
|
-
const o = P(`$$${
|
|
1083
|
+
const o = P(`$$${r}$$`, !1);
|
|
1063
1084
|
n.replace(o), $e(null);
|
|
1064
1085
|
}
|
|
1065
1086
|
});
|
|
1066
1087
|
}), !1),
|
|
1067
|
-
|
|
1088
|
+
m
|
|
1068
1089
|
), [e]), u(() => e.registerCommand(
|
|
1069
|
-
|
|
1090
|
+
Je,
|
|
1070
1091
|
() => {
|
|
1071
|
-
const t =
|
|
1072
|
-
if (!
|
|
1092
|
+
const t = N();
|
|
1093
|
+
if (!C(t))
|
|
1073
1094
|
return !1;
|
|
1074
|
-
const n = t.getNodes()[0],
|
|
1095
|
+
const n = t.getNodes()[0], r = b(
|
|
1075
1096
|
n,
|
|
1076
|
-
|
|
1097
|
+
O
|
|
1077
1098
|
);
|
|
1078
|
-
if (!
|
|
1099
|
+
if (!r)
|
|
1079
1100
|
return !1;
|
|
1080
|
-
const o =
|
|
1081
|
-
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);
|
|
1082
1103
|
},
|
|
1083
|
-
|
|
1104
|
+
m
|
|
1084
1105
|
), [e]), u(() => e.registerCommand(
|
|
1085
1106
|
ce,
|
|
1086
1107
|
(s) => {
|
|
1087
|
-
const t =
|
|
1088
|
-
if (!
|
|
1108
|
+
const t = N();
|
|
1109
|
+
if (!C(t) || !t.isCollapsed())
|
|
1089
1110
|
return !1;
|
|
1090
1111
|
const n = ae(t.anchor, !0);
|
|
1091
|
-
if (
|
|
1112
|
+
if (R(n) && !n.isInline()) {
|
|
1092
1113
|
let o = n.getEquation();
|
|
1093
1114
|
(o.startsWith("$$") && o.endsWith("$$") || o.startsWith("\\[") && o.endsWith("\\]")) && (o = o.slice(2, -2));
|
|
1094
|
-
const
|
|
1095
|
-
return n.replace(
|
|
1115
|
+
const i = ie(o);
|
|
1116
|
+
return n.replace(i), i.select(), !0;
|
|
1096
1117
|
}
|
|
1097
1118
|
return !1;
|
|
1098
1119
|
},
|
|
1099
|
-
|
|
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
|
|
1100
1137
|
), [e]), /* @__PURE__ */ l(
|
|
1101
|
-
|
|
1138
|
+
me,
|
|
1102
1139
|
{
|
|
1103
1140
|
nodeType: V,
|
|
1104
1141
|
eventType: "click",
|
|
1105
1142
|
eventListener: (s, t, n) => {
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1143
|
+
const r = q(n);
|
|
1144
|
+
r && !r.isInline() && r.select();
|
|
1108
1145
|
}
|
|
1109
1146
|
}
|
|
1110
1147
|
);
|
|
1111
1148
|
}
|
|
1112
|
-
const
|
|
1113
|
-
function
|
|
1114
|
-
const [e] =
|
|
1149
|
+
const In = 3;
|
|
1150
|
+
function xn() {
|
|
1151
|
+
const [e] = L();
|
|
1115
1152
|
return u(() => e.registerNodeTransform(
|
|
1116
|
-
|
|
1153
|
+
tt,
|
|
1117
1154
|
(t) => {
|
|
1118
1155
|
const n = t.getParent();
|
|
1119
|
-
if (
|
|
1120
|
-
const
|
|
1121
|
-
t.replace(
|
|
1156
|
+
if (Ce(n)) {
|
|
1157
|
+
const r = nt();
|
|
1158
|
+
t.replace(r), r.selectEnd();
|
|
1122
1159
|
}
|
|
1123
1160
|
}
|
|
1124
1161
|
), [e]), u(() => e.registerNodeTransform(z, (t) => {
|
|
1125
|
-
if (!
|
|
1162
|
+
if (!b(t, w) || b(t, w).getFirstDescendant() !== t)
|
|
1126
1163
|
return;
|
|
1127
|
-
const
|
|
1128
|
-
if (
|
|
1129
|
-
const
|
|
1130
|
-
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(""));
|
|
1131
1168
|
}
|
|
1132
1169
|
}), [e]), u(() => e.registerCommand(
|
|
1133
|
-
|
|
1170
|
+
ot,
|
|
1134
1171
|
(t) => {
|
|
1135
|
-
const n =
|
|
1136
|
-
if (!
|
|
1172
|
+
const n = N();
|
|
1173
|
+
if (!C(n))
|
|
1137
1174
|
return !1;
|
|
1138
|
-
const
|
|
1175
|
+
const r = ee(n), o = b(r, Ce);
|
|
1139
1176
|
if (!o)
|
|
1140
1177
|
return !1;
|
|
1141
|
-
const
|
|
1178
|
+
const i = o.getIndent();
|
|
1142
1179
|
if (t.shiftKey) {
|
|
1143
|
-
if (
|
|
1180
|
+
if (i <= 0)
|
|
1144
1181
|
return !1;
|
|
1145
|
-
o.setIndent(
|
|
1182
|
+
o.setIndent(i - 1);
|
|
1146
1183
|
} else {
|
|
1147
|
-
if (
|
|
1184
|
+
if (i > In)
|
|
1148
1185
|
return !1;
|
|
1149
|
-
o.setIndent(
|
|
1186
|
+
o.setIndent(i + 1);
|
|
1150
1187
|
}
|
|
1151
1188
|
return !0;
|
|
1152
1189
|
},
|
|
1153
|
-
|
|
1190
|
+
m
|
|
1154
1191
|
), [e]), null;
|
|
1155
1192
|
}
|
|
1156
|
-
function
|
|
1157
|
-
const [e] =
|
|
1193
|
+
function Sn() {
|
|
1194
|
+
const [e] = L(), s = (t) => {
|
|
1158
1195
|
t.key === "Tab" && t.preventDefault();
|
|
1159
1196
|
};
|
|
1160
1197
|
return u(() => e.registerRootListener(
|
|
1161
|
-
(n,
|
|
1162
|
-
n && n.addEventListener("keydown", s),
|
|
1198
|
+
(n, r) => {
|
|
1199
|
+
n && n.addEventListener("keydown", s), r && r.removeEventListener("keydown", s);
|
|
1163
1200
|
}
|
|
1164
1201
|
), [e]), null;
|
|
1165
1202
|
}
|
|
1166
|
-
function
|
|
1167
|
-
const [s] =
|
|
1203
|
+
function $n({ editorRef: e }) {
|
|
1204
|
+
const [s] = L();
|
|
1168
1205
|
return u(() => {
|
|
1169
1206
|
if (e)
|
|
1170
1207
|
return e.current = s, () => {
|
|
@@ -1172,41 +1209,41 @@ function Sn({ editorRef: e }) {
|
|
|
1172
1209
|
};
|
|
1173
1210
|
}, [s, e]), null;
|
|
1174
1211
|
}
|
|
1175
|
-
function
|
|
1212
|
+
function Zn({
|
|
1176
1213
|
initialConfig: e,
|
|
1177
1214
|
onChange: s,
|
|
1178
1215
|
editorRef: t,
|
|
1179
1216
|
blockToolbarGap: n,
|
|
1180
|
-
spellCheck:
|
|
1217
|
+
spellCheck: r,
|
|
1181
1218
|
isHeadingOneFirst: o
|
|
1182
1219
|
}) {
|
|
1183
|
-
return /* @__PURE__ */
|
|
1220
|
+
return /* @__PURE__ */ S(ze, { initialConfig: e, children: [
|
|
1184
1221
|
/* @__PURE__ */ l(
|
|
1185
|
-
|
|
1222
|
+
qe,
|
|
1186
1223
|
{
|
|
1187
|
-
contentEditable: /* @__PURE__ */ l(
|
|
1188
|
-
ErrorBoundary:
|
|
1224
|
+
contentEditable: /* @__PURE__ */ l(Kt, { spellCheck: r, className: "editor-input" }),
|
|
1225
|
+
ErrorBoundary: Ye
|
|
1189
1226
|
}
|
|
1190
1227
|
),
|
|
1191
|
-
/* @__PURE__ */ l(
|
|
1192
|
-
/* @__PURE__ */ l(
|
|
1193
|
-
/* @__PURE__ */ l(
|
|
1194
|
-
/* @__PURE__ */ l(Fe, {}),
|
|
1228
|
+
/* @__PURE__ */ l(tn, { isHeadingOneFirst: o }),
|
|
1229
|
+
/* @__PURE__ */ l(an, {}),
|
|
1230
|
+
/* @__PURE__ */ l(Tn, { toolbarGap: n }),
|
|
1195
1231
|
/* @__PURE__ */ l(Ge, {}),
|
|
1196
|
-
/* @__PURE__ */ l(
|
|
1197
|
-
/* @__PURE__ */ l(
|
|
1198
|
-
/* @__PURE__ */ l(dn, {}),
|
|
1199
|
-
/* @__PURE__ */ l(un, {}),
|
|
1200
|
-
/* @__PURE__ */ l(fn, {}),
|
|
1201
|
-
/* @__PURE__ */ l(Ht, {}),
|
|
1232
|
+
/* @__PURE__ */ l(Ue, {}),
|
|
1233
|
+
/* @__PURE__ */ l(Ln, {}),
|
|
1202
1234
|
/* @__PURE__ */ l(Mn, {}),
|
|
1203
|
-
/* @__PURE__ */ l(
|
|
1204
|
-
/* @__PURE__ */ l(
|
|
1205
|
-
/* @__PURE__ */ l(
|
|
1206
|
-
/* @__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, {})
|
|
1207
1244
|
] });
|
|
1208
1245
|
}
|
|
1209
1246
|
export {
|
|
1210
|
-
|
|
1247
|
+
Zn as default
|
|
1211
1248
|
};
|
|
1212
1249
|
//# sourceMappingURL=index.es.js.map
|