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