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