lexical-medium-editor 1.2.15 → 1.2.17
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 +1986 -783
- package/dist-lib/index.es.js.map +1 -1
- package/package.json +11 -1
package/dist-lib/index.es.js
CHANGED
|
@@ -1,245 +1,245 @@
|
|
|
1
1
|
import './lexical-medium-editor.css';
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { AutoFocusPlugin as
|
|
4
|
-
import { LexicalComposer as
|
|
5
|
-
import { RichTextPlugin as
|
|
6
|
-
import { HistoryPlugin as
|
|
7
|
-
import { LexicalErrorBoundary as
|
|
8
|
-
import { useLexicalComposerContext as
|
|
9
|
-
import { createCommand as
|
|
10
|
-
import { useEffect as
|
|
11
|
-
import { createPortal as
|
|
12
|
-
import { $findMatchingParent as I, $dfs 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
|
|
28
|
-
if (!
|
|
2
|
+
import { jsxs as D, Fragment as Xe, jsx as h } from "react/jsx-runtime";
|
|
3
|
+
import { AutoFocusPlugin as Ct } from "@lexical/react/LexicalAutoFocusPlugin";
|
|
4
|
+
import { LexicalComposer as yt } from "@lexical/react/LexicalComposer";
|
|
5
|
+
import { RichTextPlugin as Nt } from "@lexical/react/LexicalRichTextPlugin";
|
|
6
|
+
import { HistoryPlugin as xt } from "@lexical/react/LexicalHistoryPlugin";
|
|
7
|
+
import { LexicalErrorBoundary as Et } from "@lexical/react/LexicalErrorBoundary";
|
|
8
|
+
import { useLexicalComposerContext as M } from "@lexical/react/LexicalComposerContext";
|
|
9
|
+
import { createCommand as Y, $getSelection as L, $isRangeSelection as w, $createParagraphNode as re, COMMAND_PRIORITY_HIGH as $, $getRoot as fe, CLICK_COMMAND as Tt, COMMAND_PRIORITY_LOW as Ve, TextNode as ie, $isParagraphNode as V, $getCharacterOffsets as At, FORMAT_TEXT_COMMAND as xe, SELECTION_CHANGE_COMMAND as j, BLUR_COMMAND as be, $getNodeByKey as oe, $isLineBreakNode as te, $getPreviousSelection as he, KEY_BACKSPACE_COMMAND as Le, $isNodeSelection as we, PASTE_COMMAND as ke, $setSelection as Je, KEY_ARROW_RIGHT_COMMAND as St, $getAdjacentNode as Fe, $createTextNode as Ft, COMMAND_PRIORITY_NORMAL as $t, KEY_ENTER_COMMAND as Lt, $isTextNode as wt, ParagraphNode as kt, $createLineBreakNode as It, KEY_TAB_COMMAND as Mt } from "lexical";
|
|
10
|
+
import { useEffect as C, useState as O, useRef as se, useLayoutEffect as Ot, useCallback as de } from "react";
|
|
11
|
+
import { createPortal as Ie } from "react-dom";
|
|
12
|
+
import { $findMatchingParent as I, $dfs as Pt } from "@lexical/utils";
|
|
13
|
+
import { Toolbar as Me, TextField as _t, Input as et, Group as ne, Button as U, ToggleButton as ee, Separator as He, ComboBox as Dt, Popover as tt, ListBox as Bt, ListBoxItem as Ht, DialogTrigger as Rt, FileTrigger as zt } from "react-aria-components";
|
|
14
|
+
import { IconCheck as Wt, IconX as Gt, IconBold as Kt, IconItalic as qt, IconCode as Ut, IconTextSize as jt, IconBlockquote as Yt, IconLink as Zt, IconCaretDownFilled as Qt, IconPlus as Xt, IconPhoto as Vt, IconCodePlus as Jt, IconLineDashed as en } from "@tabler/icons-react";
|
|
15
|
+
import { $isAtNodeEnd as Re, $setBlocksType as nt, createDOMRange as tn } from "@lexical/selection";
|
|
16
|
+
import { $createHeadingNode as rt, HeadingNode as nn, $createQuoteNode as rn, $isHeadingNode as $e, $isQuoteNode as on } from "@lexical/rich-text";
|
|
17
|
+
import { $toggleLink as sn, $isLinkNode as an } from "@lexical/link";
|
|
18
|
+
import { $isListNode as ln, $isListItemNode as ze, $insertList as We } from "@lexical/list";
|
|
19
|
+
import { $ as X, a as Q, b as G, H as cn, c as un, I as Ge, d as Ke, e as dn, M as me, f as gn, g as Ee, h as q, i as fn, j as Te } from "./ImageNode-BhH71HMX.js";
|
|
20
|
+
import { $isCodeNode as pe, getCodeLanguages as hn, getLanguageFriendlyName as Ae, registerCodeHighlighting as mn, $createCodeNode as qe } from "@lexical/code";
|
|
21
|
+
import { NodeEventPlugin as Oe } from "@lexical/react/LexicalNodeEventPlugin";
|
|
22
|
+
import { ListPlugin as pn } from "@lexical/react/LexicalListPlugin";
|
|
23
|
+
import { OnChangePlugin as bn } from "@lexical/react/LexicalOnChangePlugin";
|
|
24
|
+
import { ContentEditable as vn } from "@lexical/react/LexicalContentEditable";
|
|
25
|
+
import { ClearEditorPlugin as Cn } from "@lexical/react/LexicalClearEditorPlugin";
|
|
26
|
+
const B = -1e3;
|
|
27
|
+
function yn(t, a, e = 0) {
|
|
28
|
+
if (!a || !a.current)
|
|
29
29
|
return console.error("Invalid popover reference"), {
|
|
30
|
-
x,
|
|
31
|
-
y:
|
|
30
|
+
x: B,
|
|
31
|
+
y: B
|
|
32
32
|
};
|
|
33
|
-
const n =
|
|
33
|
+
const n = a.current, { x: i, y: r } = t, { width: o, height: s } = n.getBoundingClientRect(), u = i - o / 2, m = r - s - e;
|
|
34
34
|
return {
|
|
35
|
-
x:
|
|
36
|
-
y:
|
|
35
|
+
x: u,
|
|
36
|
+
y: m
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
if (!
|
|
39
|
+
function Nn(t) {
|
|
40
|
+
if (!t || typeof t.getBoundingClientRect != "function")
|
|
41
41
|
return console.error("Invalid DOM range"), null;
|
|
42
|
-
const
|
|
42
|
+
const a = t.getBoundingClientRect(), e = a.left + a.width / 2, n = a.top + window.scrollY;
|
|
43
43
|
return {
|
|
44
|
-
x:
|
|
44
|
+
x: e,
|
|
45
45
|
y: n
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
if (!
|
|
48
|
+
function xn(t, a, e = 0) {
|
|
49
|
+
if (!a || !a.current)
|
|
50
50
|
return console.error("Invalid popover reference"), {
|
|
51
|
-
x,
|
|
52
|
-
y:
|
|
51
|
+
x: B,
|
|
52
|
+
y: B
|
|
53
53
|
};
|
|
54
|
-
const { x: n, y: i } =
|
|
54
|
+
const { x: n, y: i } = t, r = a.current, { width: o, height: s } = r.getBoundingClientRect(), u = n - o - e, m = i - s / 2;
|
|
55
55
|
return {
|
|
56
|
-
x:
|
|
57
|
-
y:
|
|
56
|
+
x: u,
|
|
57
|
+
y: m
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
if (!
|
|
60
|
+
function En(t, a, e = 16, n = 12) {
|
|
61
|
+
if (!a || !a.current)
|
|
62
62
|
return console.error("Invalid popover reference"), {
|
|
63
|
-
x,
|
|
64
|
-
y:
|
|
63
|
+
x: B,
|
|
64
|
+
y: B
|
|
65
65
|
};
|
|
66
|
-
const i =
|
|
66
|
+
const i = a.current, { x: r, y: o } = t, { width: s } = i.getBoundingClientRect(), u = r - s - e, m = o + n;
|
|
67
67
|
return {
|
|
68
|
-
x:
|
|
69
|
-
y:
|
|
68
|
+
x: u,
|
|
69
|
+
y: m
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
-
const
|
|
73
|
-
function
|
|
74
|
-
const
|
|
75
|
-
return n === i ? n :
|
|
72
|
+
const it = Y("TOGGLE_HEADING_COMMAND"), ot = Y("TOGGLE_QUOTE_COMMAND"), st = Y("TOGGLE_LINK_COMMAND");
|
|
73
|
+
function ve(t) {
|
|
74
|
+
const a = t.anchor, e = t.focus, n = t.anchor.getNode(), i = t.focus.getNode();
|
|
75
|
+
return n === i ? n : t.isBackward() ? Re(e) ? n : i : Re(a) ? n : i;
|
|
76
76
|
}
|
|
77
|
-
function
|
|
78
|
-
const
|
|
79
|
-
return
|
|
77
|
+
function Ue(t) {
|
|
78
|
+
const a = I(t, $e);
|
|
79
|
+
return a ? a.getTag() : null;
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
const
|
|
81
|
+
function Tn(t) {
|
|
82
|
+
const a = {
|
|
83
83
|
isHeadingOne: !1,
|
|
84
84
|
isHeadingTwo: !1,
|
|
85
85
|
isHeadingThree: !1
|
|
86
|
-
},
|
|
87
|
-
if (!
|
|
88
|
-
const n =
|
|
89
|
-
if (!n) return
|
|
90
|
-
if (
|
|
91
|
-
(
|
|
86
|
+
}, e = t.getNodes();
|
|
87
|
+
if (!e.length) return a;
|
|
88
|
+
const n = Ue(e[0]);
|
|
89
|
+
if (!n) return a;
|
|
90
|
+
if (e.every(
|
|
91
|
+
(r) => Ue(r) === n
|
|
92
92
|
)) {
|
|
93
|
-
const
|
|
93
|
+
const r = {
|
|
94
94
|
h1: "isHeadingOne",
|
|
95
95
|
h2: "isHeadingTwo",
|
|
96
96
|
h3: "isHeadingThree"
|
|
97
97
|
}[n];
|
|
98
|
-
|
|
98
|
+
r && (a[r] = !0);
|
|
99
99
|
}
|
|
100
|
-
return
|
|
100
|
+
return a;
|
|
101
101
|
}
|
|
102
|
-
function
|
|
103
|
-
const [
|
|
104
|
-
return
|
|
105
|
-
|
|
106
|
-
(
|
|
107
|
-
const { isHeadingOne: n, isHeadingTwo: i, isHeadingThree:
|
|
108
|
-
if (
|
|
109
|
-
let
|
|
110
|
-
n || i ?
|
|
111
|
-
|
|
112
|
-
() =>
|
|
102
|
+
function An() {
|
|
103
|
+
const [t] = M();
|
|
104
|
+
return C(() => t.registerCommand(
|
|
105
|
+
it,
|
|
106
|
+
(e) => {
|
|
107
|
+
const { isHeadingOne: n, isHeadingTwo: i, isHeadingThree: r } = e, o = L();
|
|
108
|
+
if (w(o)) {
|
|
109
|
+
let s;
|
|
110
|
+
n || i ? s = "h3" : r ? s = null : s = "h2", nt(
|
|
111
|
+
o,
|
|
112
|
+
() => s ? rt(s) : re()
|
|
113
113
|
);
|
|
114
114
|
}
|
|
115
115
|
return !0;
|
|
116
116
|
},
|
|
117
|
-
|
|
118
|
-
), [
|
|
117
|
+
$
|
|
118
|
+
), [t]), null;
|
|
119
119
|
}
|
|
120
|
-
function
|
|
121
|
-
const [
|
|
122
|
-
return
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
(
|
|
126
|
-
if (
|
|
120
|
+
function Sn() {
|
|
121
|
+
const [t] = M();
|
|
122
|
+
return C(() => {
|
|
123
|
+
const a = t.registerNodeTransform(
|
|
124
|
+
nn,
|
|
125
|
+
(e) => {
|
|
126
|
+
if (e.getTag() !== "h2")
|
|
127
127
|
return;
|
|
128
|
-
const i =
|
|
129
|
-
if (i !== null &&
|
|
130
|
-
const
|
|
131
|
-
|
|
128
|
+
const i = fe().getFirstChild();
|
|
129
|
+
if (i !== null && e.is(i)) {
|
|
130
|
+
const r = e.getChildren(), o = rt("h1");
|
|
131
|
+
o.append(...r), e.replace(o);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
);
|
|
135
135
|
return () => {
|
|
136
|
-
|
|
136
|
+
a();
|
|
137
137
|
};
|
|
138
|
-
}, [
|
|
138
|
+
}, [t]), null;
|
|
139
139
|
}
|
|
140
|
-
function
|
|
141
|
-
return I(
|
|
140
|
+
function Fn(t) {
|
|
141
|
+
return I(t, on);
|
|
142
142
|
}
|
|
143
|
-
function
|
|
144
|
-
const
|
|
145
|
-
return
|
|
143
|
+
function $n(t) {
|
|
144
|
+
const a = t.getNodes();
|
|
145
|
+
return a.length ? a.length > 0 && a.every((e) => Fn(e)) : !1;
|
|
146
146
|
}
|
|
147
|
-
function
|
|
148
|
-
const [
|
|
149
|
-
return
|
|
150
|
-
|
|
151
|
-
(
|
|
152
|
-
const n =
|
|
153
|
-
return
|
|
147
|
+
function Ln() {
|
|
148
|
+
const [t] = M();
|
|
149
|
+
return C(() => t.registerCommand(
|
|
150
|
+
ot,
|
|
151
|
+
(e) => {
|
|
152
|
+
const n = L();
|
|
153
|
+
return w(n) && nt(
|
|
154
154
|
n,
|
|
155
|
-
() =>
|
|
155
|
+
() => e.isQuote ? re() : rn()
|
|
156
156
|
), !0;
|
|
157
157
|
},
|
|
158
|
-
|
|
159
|
-
), [
|
|
158
|
+
$
|
|
159
|
+
), [t]), null;
|
|
160
160
|
}
|
|
161
|
-
function
|
|
162
|
-
if (!
|
|
161
|
+
function at(t) {
|
|
162
|
+
if (!w(t))
|
|
163
163
|
return null;
|
|
164
|
-
const
|
|
165
|
-
return I(
|
|
164
|
+
const a = ve(t);
|
|
165
|
+
return I(a, an);
|
|
166
166
|
}
|
|
167
|
-
function
|
|
168
|
-
const [
|
|
169
|
-
return
|
|
170
|
-
|
|
171
|
-
(
|
|
172
|
-
const n =
|
|
173
|
-
return i && (
|
|
167
|
+
function wn() {
|
|
168
|
+
const [t] = M();
|
|
169
|
+
return C(() => t.registerCommand(
|
|
170
|
+
Tt,
|
|
171
|
+
(e) => {
|
|
172
|
+
const n = L(), i = at(n);
|
|
173
|
+
return i && (e.metaKey || e.ctrlKey) ? (window.open(i.getURL(), "_blank"), !0) : !1;
|
|
174
174
|
},
|
|
175
|
-
|
|
176
|
-
), [
|
|
177
|
-
|
|
178
|
-
(
|
|
179
|
-
|
|
180
|
-
), [
|
|
175
|
+
Ve
|
|
176
|
+
), [t]), C(() => t.registerCommand(
|
|
177
|
+
st,
|
|
178
|
+
(e) => (sn(e), !0),
|
|
179
|
+
$
|
|
180
|
+
), [t]), null;
|
|
181
181
|
}
|
|
182
|
-
function
|
|
183
|
-
const [
|
|
184
|
-
return
|
|
185
|
-
|
|
182
|
+
function kn() {
|
|
183
|
+
const [t] = M(), a = "heading-above";
|
|
184
|
+
return C(() => t.registerNodeTransform(
|
|
185
|
+
ie,
|
|
186
186
|
(n) => {
|
|
187
|
-
const i = I(n,
|
|
188
|
-
if (!i ||
|
|
187
|
+
const i = I(n, V) || I(n, ln);
|
|
188
|
+
if (!i || $e(i))
|
|
189
189
|
return;
|
|
190
|
-
const
|
|
191
|
-
if (!
|
|
190
|
+
const r = i, o = t.getElementByKey(r.getKey());
|
|
191
|
+
if (!o)
|
|
192
192
|
return;
|
|
193
|
-
const
|
|
194
|
-
|
|
193
|
+
const s = r.getPreviousSibling(), u = $e(s), m = o.classList.contains(a);
|
|
194
|
+
u && !m ? o.classList.add(a) : !u && m && o.classList.remove(a);
|
|
195
195
|
}
|
|
196
|
-
), [
|
|
196
|
+
), [t]), null;
|
|
197
197
|
}
|
|
198
|
-
function
|
|
199
|
-
return /* @__PURE__ */
|
|
200
|
-
/* @__PURE__ */
|
|
201
|
-
|
|
202
|
-
/* @__PURE__ */
|
|
203
|
-
/* @__PURE__ */
|
|
204
|
-
/* @__PURE__ */
|
|
198
|
+
function In({ isHeadingOneFirst: t }) {
|
|
199
|
+
return /* @__PURE__ */ D(Xe, { children: [
|
|
200
|
+
/* @__PURE__ */ h(An, {}),
|
|
201
|
+
t && /* @__PURE__ */ h(Sn, {}),
|
|
202
|
+
/* @__PURE__ */ h(Ln, {}),
|
|
203
|
+
/* @__PURE__ */ h(wn, {}),
|
|
204
|
+
/* @__PURE__ */ h(kn, {})
|
|
205
205
|
] });
|
|
206
206
|
}
|
|
207
|
-
function
|
|
208
|
-
const [n] =
|
|
209
|
-
return /* @__PURE__ */
|
|
210
|
-
/* @__PURE__ */
|
|
211
|
-
|
|
207
|
+
function Mn({ style: t, closeToolbar: a, existingLinkURL: e }) {
|
|
208
|
+
const [n] = M(), [i, r] = O(e);
|
|
209
|
+
return /* @__PURE__ */ D(Me, { style: t, "aria-details": "link toolbar", id: "link-toolbar", children: [
|
|
210
|
+
/* @__PURE__ */ h(
|
|
211
|
+
_t,
|
|
212
212
|
{
|
|
213
213
|
"aria-label": "url",
|
|
214
214
|
autoFocus: !0,
|
|
215
215
|
defaultValue: i,
|
|
216
|
-
onChange:
|
|
217
|
-
children: /* @__PURE__ */
|
|
216
|
+
onChange: r,
|
|
217
|
+
children: /* @__PURE__ */ h(et, { placeholder: "Enter Link" })
|
|
218
218
|
}
|
|
219
219
|
),
|
|
220
|
-
/* @__PURE__ */
|
|
221
|
-
/* @__PURE__ */
|
|
222
|
-
|
|
220
|
+
/* @__PURE__ */ D(ne, { "aria-label": "edit link", children: [
|
|
221
|
+
/* @__PURE__ */ h(
|
|
222
|
+
U,
|
|
223
223
|
{
|
|
224
224
|
"aria-label": "Update link",
|
|
225
225
|
onPress: () => {
|
|
226
|
-
const
|
|
227
|
-
n.dispatchCommand(
|
|
226
|
+
const o = i === "" ? null : i;
|
|
227
|
+
n.dispatchCommand(st, o), a();
|
|
228
228
|
},
|
|
229
|
-
children: /* @__PURE__ */
|
|
229
|
+
children: /* @__PURE__ */ h(Wt, { size: K })
|
|
230
230
|
}
|
|
231
231
|
),
|
|
232
|
-
/* @__PURE__ */
|
|
232
|
+
/* @__PURE__ */ h(U, { "aria-label": "Discard changes", onPress: a, children: /* @__PURE__ */ h(Gt, { size: K }) })
|
|
233
233
|
] }),
|
|
234
|
-
/* @__PURE__ */
|
|
234
|
+
/* @__PURE__ */ h("div", { className: "inline-toolbar-pointer" })
|
|
235
235
|
] });
|
|
236
236
|
}
|
|
237
|
-
const
|
|
238
|
-
function
|
|
239
|
-
const [
|
|
240
|
-
x,
|
|
241
|
-
y:
|
|
242
|
-
}),
|
|
237
|
+
const K = 24, On = 16;
|
|
238
|
+
function Pn({ editor: t }) {
|
|
239
|
+
const [a, e] = O(null), [n, i] = O({
|
|
240
|
+
x: B,
|
|
241
|
+
y: B
|
|
242
|
+
}), r = se(null), [o, s] = O({
|
|
243
243
|
isBold: !1,
|
|
244
244
|
isItalic: !1,
|
|
245
245
|
isCode: !1,
|
|
@@ -247,85 +247,85 @@ function nn({ editor: e }) {
|
|
|
247
247
|
isHeadingTwo: !1,
|
|
248
248
|
isHeadingThree: !1,
|
|
249
249
|
isQuote: !1
|
|
250
|
-
}), [
|
|
251
|
-
if (
|
|
252
|
-
|
|
253
|
-
isBold:
|
|
254
|
-
isItalic:
|
|
255
|
-
isCode:
|
|
256
|
-
isQuote:
|
|
250
|
+
}), [u, m] = O(!1), [A, T] = O(0), [S, F] = O(""), N = (p) => {
|
|
251
|
+
if (w(p)) {
|
|
252
|
+
s({
|
|
253
|
+
isBold: p.hasFormat("bold"),
|
|
254
|
+
isItalic: p.hasFormat("italic"),
|
|
255
|
+
isCode: p.hasFormat("code"),
|
|
256
|
+
isQuote: $n(p)
|
|
257
257
|
});
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
...
|
|
261
|
-
...
|
|
258
|
+
const y = Tn(p);
|
|
259
|
+
s((l) => ({
|
|
260
|
+
...l,
|
|
261
|
+
...y
|
|
262
262
|
}));
|
|
263
|
-
const
|
|
264
|
-
|
|
263
|
+
const E = at(p);
|
|
264
|
+
F(E ? E.getURL() : "");
|
|
265
265
|
}
|
|
266
266
|
};
|
|
267
|
-
return
|
|
268
|
-
|
|
269
|
-
const
|
|
270
|
-
|
|
267
|
+
return C(() => {
|
|
268
|
+
t.read(() => {
|
|
269
|
+
const p = L();
|
|
270
|
+
N(p);
|
|
271
271
|
});
|
|
272
|
-
}, [
|
|
273
|
-
({ editorState:
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
|
|
272
|
+
}, [t]), C(() => t.registerUpdateListener(
|
|
273
|
+
({ editorState: y }) => {
|
|
274
|
+
y.read(() => {
|
|
275
|
+
const E = L();
|
|
276
|
+
N(E);
|
|
277
277
|
});
|
|
278
278
|
}
|
|
279
|
-
), [
|
|
280
|
-
|
|
281
|
-
const
|
|
282
|
-
if (
|
|
283
|
-
const [
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
], [
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
279
|
+
), [t]), C(() => {
|
|
280
|
+
t.read(() => {
|
|
281
|
+
const p = L();
|
|
282
|
+
if (w(p)) {
|
|
283
|
+
const [y, E] = p.getStartEndPoints(), [l, c] = [
|
|
284
|
+
y.getNode(),
|
|
285
|
+
E.getNode()
|
|
286
|
+
], [d, g] = At(p), f = tn(
|
|
287
|
+
t,
|
|
288
|
+
l,
|
|
289
|
+
d,
|
|
290
|
+
c,
|
|
291
|
+
g
|
|
292
292
|
);
|
|
293
|
-
|
|
293
|
+
e(Nn(f));
|
|
294
294
|
}
|
|
295
295
|
});
|
|
296
|
-
}, [
|
|
297
|
-
var
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
296
|
+
}, [t, o]), C(() => {
|
|
297
|
+
var p;
|
|
298
|
+
a ? (i(
|
|
299
|
+
yn(
|
|
300
|
+
a,
|
|
301
|
+
r,
|
|
302
|
+
On
|
|
303
303
|
)
|
|
304
304
|
), setTimeout(() => {
|
|
305
|
-
var
|
|
306
|
-
(
|
|
307
|
-
}, 50)) : (
|
|
308
|
-
}, [
|
|
309
|
-
if (
|
|
310
|
-
const
|
|
311
|
-
|
|
305
|
+
var y;
|
|
306
|
+
(y = r.current) == null || y.classList.add("visible");
|
|
307
|
+
}, 50)) : (p = r.current) == null || p.classList.remove("visible");
|
|
308
|
+
}, [a]), Ot(() => {
|
|
309
|
+
if (r.current) {
|
|
310
|
+
const p = window.getComputedStyle(r.current), y = parseFloat(p.width);
|
|
311
|
+
T(y);
|
|
312
312
|
}
|
|
313
|
-
}, [
|
|
314
|
-
|
|
313
|
+
}, [a]), a && (u ? /* @__PURE__ */ h(
|
|
314
|
+
Mn,
|
|
315
315
|
{
|
|
316
316
|
style: {
|
|
317
317
|
position: "absolute",
|
|
318
318
|
top: n.y,
|
|
319
319
|
left: n.x,
|
|
320
|
-
width:
|
|
320
|
+
width: A
|
|
321
321
|
},
|
|
322
322
|
closeToolbar: () => {
|
|
323
|
-
|
|
323
|
+
m(!1), e(null);
|
|
324
324
|
},
|
|
325
|
-
existingLinkURL:
|
|
325
|
+
existingLinkURL: S
|
|
326
326
|
}
|
|
327
|
-
) : /* @__PURE__ */
|
|
328
|
-
|
|
327
|
+
) : /* @__PURE__ */ D(
|
|
328
|
+
Me,
|
|
329
329
|
{
|
|
330
330
|
style: {
|
|
331
331
|
position: "absolute",
|
|
@@ -334,879 +334,2082 @@ function nn({ editor: e }) {
|
|
|
334
334
|
},
|
|
335
335
|
"aria-label": "Text formatting",
|
|
336
336
|
id: "inline-toolbar",
|
|
337
|
-
ref:
|
|
337
|
+
ref: r,
|
|
338
338
|
children: [
|
|
339
|
-
/* @__PURE__ */
|
|
340
|
-
/* @__PURE__ */
|
|
341
|
-
|
|
339
|
+
/* @__PURE__ */ D(ne, { "aria-label": "Style", children: [
|
|
340
|
+
/* @__PURE__ */ h(
|
|
341
|
+
ee,
|
|
342
342
|
{
|
|
343
343
|
"aria-label": "Bold",
|
|
344
|
-
isSelected:
|
|
345
|
-
isDisabled:
|
|
346
|
-
onChange: () =>
|
|
347
|
-
children: /* @__PURE__ */
|
|
344
|
+
isSelected: o.isBold,
|
|
345
|
+
isDisabled: o.isCode || o.isHeadingOne || o.isHeadingTwo || o.isHeadingThree,
|
|
346
|
+
onChange: () => t.dispatchCommand(xe, "bold"),
|
|
347
|
+
children: /* @__PURE__ */ h(Kt, { size: K })
|
|
348
348
|
}
|
|
349
349
|
),
|
|
350
|
-
/* @__PURE__ */
|
|
351
|
-
|
|
350
|
+
/* @__PURE__ */ h(
|
|
351
|
+
ee,
|
|
352
352
|
{
|
|
353
353
|
"aria-label": "Italic",
|
|
354
|
-
isSelected:
|
|
355
|
-
isDisabled:
|
|
356
|
-
onChange: () =>
|
|
357
|
-
children: /* @__PURE__ */
|
|
354
|
+
isSelected: o.isItalic,
|
|
355
|
+
isDisabled: o.isCode || o.isHeadingOne,
|
|
356
|
+
onChange: () => t.dispatchCommand(xe, "italic"),
|
|
357
|
+
children: /* @__PURE__ */ h(qt, { size: K })
|
|
358
358
|
}
|
|
359
359
|
),
|
|
360
|
-
/* @__PURE__ */
|
|
361
|
-
|
|
360
|
+
/* @__PURE__ */ h(
|
|
361
|
+
ee,
|
|
362
362
|
{
|
|
363
363
|
"aria-label": "inline-code",
|
|
364
|
-
isDisabled:
|
|
365
|
-
isSelected:
|
|
366
|
-
onChange: () =>
|
|
367
|
-
children: /* @__PURE__ */
|
|
364
|
+
isDisabled: o.isHeadingOne,
|
|
365
|
+
isSelected: o.isCode,
|
|
366
|
+
onChange: () => t.dispatchCommand(xe, "code"),
|
|
367
|
+
children: /* @__PURE__ */ h(Ut, { size: K })
|
|
368
368
|
}
|
|
369
369
|
)
|
|
370
370
|
] }),
|
|
371
|
-
/* @__PURE__ */
|
|
372
|
-
/* @__PURE__ */
|
|
373
|
-
/* @__PURE__ */
|
|
374
|
-
|
|
371
|
+
/* @__PURE__ */ h(He, { orientation: "vertical" }),
|
|
372
|
+
/* @__PURE__ */ D(ne, { "aria-label": "Text Blocks", children: [
|
|
373
|
+
/* @__PURE__ */ h(
|
|
374
|
+
ee,
|
|
375
375
|
{
|
|
376
376
|
"aria-label": "Heading",
|
|
377
|
-
isSelected:
|
|
378
|
-
onChange: () =>
|
|
379
|
-
children: /* @__PURE__ */
|
|
377
|
+
isSelected: o.isHeadingOne || o.isHeadingTwo || o.isHeadingThree,
|
|
378
|
+
onChange: () => t.dispatchCommand(it, o),
|
|
379
|
+
children: /* @__PURE__ */ h(jt, { size: K })
|
|
380
380
|
}
|
|
381
381
|
),
|
|
382
|
-
/* @__PURE__ */
|
|
383
|
-
|
|
382
|
+
/* @__PURE__ */ h(
|
|
383
|
+
ee,
|
|
384
384
|
{
|
|
385
385
|
"aria-label": "Quote",
|
|
386
|
-
isSelected:
|
|
387
|
-
onChange: () =>
|
|
388
|
-
children: /* @__PURE__ */
|
|
386
|
+
isSelected: o.isQuote,
|
|
387
|
+
onChange: () => t.dispatchCommand(ot, o),
|
|
388
|
+
children: /* @__PURE__ */ h(Yt, { size: K })
|
|
389
389
|
}
|
|
390
390
|
)
|
|
391
391
|
] }),
|
|
392
|
-
/* @__PURE__ */
|
|
393
|
-
/* @__PURE__ */
|
|
394
|
-
|
|
392
|
+
/* @__PURE__ */ h(He, { orientation: "vertical" }),
|
|
393
|
+
/* @__PURE__ */ h(ne, { "aria-label": "Links", children: /* @__PURE__ */ h(
|
|
394
|
+
U,
|
|
395
395
|
{
|
|
396
|
-
onPress: () =>
|
|
397
|
-
isDisabled:
|
|
398
|
-
children: /* @__PURE__ */
|
|
396
|
+
onPress: () => m(!0),
|
|
397
|
+
isDisabled: o.isHeadingOne,
|
|
398
|
+
children: /* @__PURE__ */ h(Zt, { size: K })
|
|
399
399
|
}
|
|
400
400
|
) }),
|
|
401
|
-
/* @__PURE__ */
|
|
401
|
+
/* @__PURE__ */ h("div", { className: "inline-toolbar-pointer" })
|
|
402
402
|
]
|
|
403
403
|
}
|
|
404
404
|
));
|
|
405
405
|
}
|
|
406
|
-
const
|
|
407
|
-
function
|
|
408
|
-
const [
|
|
409
|
-
return
|
|
410
|
-
|
|
406
|
+
const _n = document.body;
|
|
407
|
+
function Dn() {
|
|
408
|
+
const [t, a] = O(!1), [e] = M();
|
|
409
|
+
return C(() => e.registerCommand(
|
|
410
|
+
j,
|
|
411
411
|
() => {
|
|
412
|
-
const i =
|
|
413
|
-
if (!
|
|
414
|
-
return
|
|
415
|
-
const
|
|
416
|
-
(
|
|
412
|
+
const i = L();
|
|
413
|
+
if (!w(i) || i.isCollapsed())
|
|
414
|
+
return a(!1), !1;
|
|
415
|
+
const r = i.getNodes(), o = r.some((m) => X(m)), s = r.length === 1 && (Q(r[0]) || I(r[0], G)), u = r.some(
|
|
416
|
+
(m) => I(m, pe)
|
|
417
417
|
);
|
|
418
|
-
return
|
|
418
|
+
return a(!o && !s && !u), !1;
|
|
419
419
|
},
|
|
420
|
-
|
|
421
|
-
), [
|
|
422
|
-
|
|
420
|
+
$
|
|
421
|
+
), [e]), C(() => e.registerCommand(
|
|
422
|
+
be,
|
|
423
423
|
() => (setTimeout(() => {
|
|
424
|
-
const i = document.getElementById("inline-toolbar"),
|
|
425
|
-
i && (i ===
|
|
424
|
+
const i = document.getElementById("inline-toolbar"), r = document.getElementById("link-toolbar"), o = document.activeElement;
|
|
425
|
+
i && (i === o || i.contains(o)) || r && (r === o || r.contains(o)) || a(!1);
|
|
426
426
|
}, 0), !1),
|
|
427
|
-
|
|
428
|
-
), [
|
|
427
|
+
$
|
|
428
|
+
), [e]), t && Ie(/* @__PURE__ */ h(Pn, { editor: e }), _n);
|
|
429
429
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
430
|
+
var je = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
431
|
+
function Bn(t) {
|
|
432
|
+
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
433
|
+
}
|
|
434
|
+
var Se = { exports: {} }, Ye;
|
|
435
|
+
function Hn() {
|
|
436
|
+
return Ye || (Ye = 1, function(t) {
|
|
437
|
+
var a = typeof window < "u" ? window : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? self : {};
|
|
438
|
+
/**
|
|
439
|
+
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
440
|
+
*
|
|
441
|
+
* @license MIT <https://opensource.org/licenses/MIT>
|
|
442
|
+
* @author Lea Verou <https://lea.verou.me>
|
|
443
|
+
* @namespace
|
|
444
|
+
* @public
|
|
445
|
+
*/
|
|
446
|
+
var e = function(n) {
|
|
447
|
+
var i = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i, r = 0, o = {}, s = {
|
|
448
|
+
/**
|
|
449
|
+
* By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
|
|
450
|
+
* current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
|
|
451
|
+
* additional languages or plugins yourself.
|
|
452
|
+
*
|
|
453
|
+
* By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
|
|
454
|
+
*
|
|
455
|
+
* You obviously have to change this value before the automatic highlighting started. To do this, you can add an
|
|
456
|
+
* empty Prism object into the global scope before loading the Prism script like this:
|
|
457
|
+
*
|
|
458
|
+
* ```js
|
|
459
|
+
* window.Prism = window.Prism || {};
|
|
460
|
+
* Prism.manual = true;
|
|
461
|
+
* // add a new <script> to load Prism's script
|
|
462
|
+
* ```
|
|
463
|
+
*
|
|
464
|
+
* @default false
|
|
465
|
+
* @type {boolean}
|
|
466
|
+
* @memberof Prism
|
|
467
|
+
* @public
|
|
468
|
+
*/
|
|
469
|
+
manual: n.Prism && n.Prism.manual,
|
|
470
|
+
/**
|
|
471
|
+
* By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
|
|
472
|
+
* `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
|
|
473
|
+
* own worker, you don't want it to do this.
|
|
474
|
+
*
|
|
475
|
+
* By setting this value to `true`, Prism will not add its own listeners to the worker.
|
|
476
|
+
*
|
|
477
|
+
* You obviously have to change this value before Prism executes. To do this, you can add an
|
|
478
|
+
* empty Prism object into the global scope before loading the Prism script like this:
|
|
479
|
+
*
|
|
480
|
+
* ```js
|
|
481
|
+
* window.Prism = window.Prism || {};
|
|
482
|
+
* Prism.disableWorkerMessageHandler = true;
|
|
483
|
+
* // Load Prism's script
|
|
484
|
+
* ```
|
|
485
|
+
*
|
|
486
|
+
* @default false
|
|
487
|
+
* @type {boolean}
|
|
488
|
+
* @memberof Prism
|
|
489
|
+
* @public
|
|
490
|
+
*/
|
|
491
|
+
disableWorkerMessageHandler: n.Prism && n.Prism.disableWorkerMessageHandler,
|
|
492
|
+
/**
|
|
493
|
+
* A namespace for utility methods.
|
|
494
|
+
*
|
|
495
|
+
* All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
|
|
496
|
+
* change or disappear at any time.
|
|
497
|
+
*
|
|
498
|
+
* @namespace
|
|
499
|
+
* @memberof Prism
|
|
500
|
+
*/
|
|
501
|
+
util: {
|
|
502
|
+
encode: function l(c) {
|
|
503
|
+
return c instanceof u ? new u(c.type, l(c.content), c.alias) : Array.isArray(c) ? c.map(l) : c.replace(/&/g, "&").replace(/</g, "<").replace(/\u00a0/g, " ");
|
|
504
|
+
},
|
|
505
|
+
/**
|
|
506
|
+
* Returns the name of the type of the given value.
|
|
507
|
+
*
|
|
508
|
+
* @param {any} o
|
|
509
|
+
* @returns {string}
|
|
510
|
+
* @example
|
|
511
|
+
* type(null) === 'Null'
|
|
512
|
+
* type(undefined) === 'Undefined'
|
|
513
|
+
* type(123) === 'Number'
|
|
514
|
+
* type('foo') === 'String'
|
|
515
|
+
* type(true) === 'Boolean'
|
|
516
|
+
* type([1, 2]) === 'Array'
|
|
517
|
+
* type({}) === 'Object'
|
|
518
|
+
* type(String) === 'Function'
|
|
519
|
+
* type(/abc+/) === 'RegExp'
|
|
520
|
+
*/
|
|
521
|
+
type: function(l) {
|
|
522
|
+
return Object.prototype.toString.call(l).slice(8, -1);
|
|
523
|
+
},
|
|
524
|
+
/**
|
|
525
|
+
* Returns a unique number for the given object. Later calls will still return the same number.
|
|
526
|
+
*
|
|
527
|
+
* @param {Object} obj
|
|
528
|
+
* @returns {number}
|
|
529
|
+
*/
|
|
530
|
+
objId: function(l) {
|
|
531
|
+
return l.__id || Object.defineProperty(l, "__id", { value: ++r }), l.__id;
|
|
532
|
+
},
|
|
533
|
+
/**
|
|
534
|
+
* Creates a deep clone of the given object.
|
|
535
|
+
*
|
|
536
|
+
* The main intended use of this function is to clone language definitions.
|
|
537
|
+
*
|
|
538
|
+
* @param {T} o
|
|
539
|
+
* @param {Record<number, any>} [visited]
|
|
540
|
+
* @returns {T}
|
|
541
|
+
* @template T
|
|
542
|
+
*/
|
|
543
|
+
clone: function l(c, d) {
|
|
544
|
+
d = d || {};
|
|
545
|
+
var g, f;
|
|
546
|
+
switch (s.util.type(c)) {
|
|
547
|
+
case "Object":
|
|
548
|
+
if (f = s.util.objId(c), d[f])
|
|
549
|
+
return d[f];
|
|
550
|
+
g = /** @type {Record<string, any>} */
|
|
551
|
+
{}, d[f] = g;
|
|
552
|
+
for (var v in c)
|
|
553
|
+
c.hasOwnProperty(v) && (g[v] = l(c[v], d));
|
|
554
|
+
return (
|
|
555
|
+
/** @type {any} */
|
|
556
|
+
g
|
|
557
|
+
);
|
|
558
|
+
case "Array":
|
|
559
|
+
return f = s.util.objId(c), d[f] ? d[f] : (g = [], d[f] = g, /** @type {Array} */
|
|
560
|
+
/** @type {any} */
|
|
561
|
+
c.forEach(function(x, b) {
|
|
562
|
+
g[b] = l(x, d);
|
|
563
|
+
}), /** @type {any} */
|
|
564
|
+
g);
|
|
565
|
+
default:
|
|
566
|
+
return c;
|
|
567
|
+
}
|
|
568
|
+
},
|
|
569
|
+
/**
|
|
570
|
+
* Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
|
|
571
|
+
*
|
|
572
|
+
* If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
|
|
573
|
+
*
|
|
574
|
+
* @param {Element} element
|
|
575
|
+
* @returns {string}
|
|
576
|
+
*/
|
|
577
|
+
getLanguage: function(l) {
|
|
578
|
+
for (; l; ) {
|
|
579
|
+
var c = i.exec(l.className);
|
|
580
|
+
if (c)
|
|
581
|
+
return c[1].toLowerCase();
|
|
582
|
+
l = l.parentElement;
|
|
583
|
+
}
|
|
584
|
+
return "none";
|
|
585
|
+
},
|
|
586
|
+
/**
|
|
587
|
+
* Sets the Prism `language-xxxx` class of the given element.
|
|
588
|
+
*
|
|
589
|
+
* @param {Element} element
|
|
590
|
+
* @param {string} language
|
|
591
|
+
* @returns {void}
|
|
592
|
+
*/
|
|
593
|
+
setLanguage: function(l, c) {
|
|
594
|
+
l.className = l.className.replace(RegExp(i, "gi"), ""), l.classList.add("language-" + c);
|
|
595
|
+
},
|
|
596
|
+
/**
|
|
597
|
+
* Returns the script element that is currently executing.
|
|
598
|
+
*
|
|
599
|
+
* This does __not__ work for line script element.
|
|
600
|
+
*
|
|
601
|
+
* @returns {HTMLScriptElement | null}
|
|
602
|
+
*/
|
|
603
|
+
currentScript: function() {
|
|
604
|
+
if (typeof document > "u")
|
|
605
|
+
return null;
|
|
606
|
+
if (document.currentScript && document.currentScript.tagName === "SCRIPT")
|
|
607
|
+
return (
|
|
608
|
+
/** @type {any} */
|
|
609
|
+
document.currentScript
|
|
610
|
+
);
|
|
611
|
+
try {
|
|
612
|
+
throw new Error();
|
|
613
|
+
} catch (g) {
|
|
614
|
+
var l = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(g.stack) || [])[1];
|
|
615
|
+
if (l) {
|
|
616
|
+
var c = document.getElementsByTagName("script");
|
|
617
|
+
for (var d in c)
|
|
618
|
+
if (c[d].src == l)
|
|
619
|
+
return c[d];
|
|
620
|
+
}
|
|
621
|
+
return null;
|
|
622
|
+
}
|
|
623
|
+
},
|
|
624
|
+
/**
|
|
625
|
+
* Returns whether a given class is active for `element`.
|
|
626
|
+
*
|
|
627
|
+
* The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
|
|
628
|
+
* if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
|
|
629
|
+
* given class is just the given class with a `no-` prefix.
|
|
630
|
+
*
|
|
631
|
+
* Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
|
|
632
|
+
* closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
|
|
633
|
+
* ancestors have the given class or the negated version of it, then the default activation will be returned.
|
|
634
|
+
*
|
|
635
|
+
* In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
|
|
636
|
+
* version of it, the class is considered active.
|
|
637
|
+
*
|
|
638
|
+
* @param {Element} element
|
|
639
|
+
* @param {string} className
|
|
640
|
+
* @param {boolean} [defaultActivation=false]
|
|
641
|
+
* @returns {boolean}
|
|
642
|
+
*/
|
|
643
|
+
isActive: function(l, c, d) {
|
|
644
|
+
for (var g = "no-" + c; l; ) {
|
|
645
|
+
var f = l.classList;
|
|
646
|
+
if (f.contains(c))
|
|
647
|
+
return !0;
|
|
648
|
+
if (f.contains(g))
|
|
649
|
+
return !1;
|
|
650
|
+
l = l.parentElement;
|
|
651
|
+
}
|
|
652
|
+
return !!d;
|
|
653
|
+
}
|
|
654
|
+
},
|
|
655
|
+
/**
|
|
656
|
+
* This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
|
|
657
|
+
*
|
|
658
|
+
* @namespace
|
|
659
|
+
* @memberof Prism
|
|
660
|
+
* @public
|
|
661
|
+
*/
|
|
662
|
+
languages: {
|
|
663
|
+
/**
|
|
664
|
+
* The grammar for plain, unformatted text.
|
|
665
|
+
*/
|
|
666
|
+
plain: o,
|
|
667
|
+
plaintext: o,
|
|
668
|
+
text: o,
|
|
669
|
+
txt: o,
|
|
670
|
+
/**
|
|
671
|
+
* Creates a deep copy of the language with the given id and appends the given tokens.
|
|
672
|
+
*
|
|
673
|
+
* If a token in `redef` also appears in the copied language, then the existing token in the copied language
|
|
674
|
+
* will be overwritten at its original position.
|
|
675
|
+
*
|
|
676
|
+
* ## Best practices
|
|
677
|
+
*
|
|
678
|
+
* Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
|
|
679
|
+
* doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
|
|
680
|
+
* understand the language definition because, normally, the order of tokens matters in Prism grammars.
|
|
681
|
+
*
|
|
682
|
+
* Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
|
|
683
|
+
* Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
|
|
684
|
+
*
|
|
685
|
+
* @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
|
|
686
|
+
* @param {Grammar} redef The new tokens to append.
|
|
687
|
+
* @returns {Grammar} The new language created.
|
|
688
|
+
* @public
|
|
689
|
+
* @example
|
|
690
|
+
* Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
|
|
691
|
+
* // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
|
|
692
|
+
* // at its original position
|
|
693
|
+
* 'comment': { ... },
|
|
694
|
+
* // CSS doesn't have a 'color' token, so this token will be appended
|
|
695
|
+
* 'color': /\b(?:red|green|blue)\b/
|
|
696
|
+
* });
|
|
697
|
+
*/
|
|
698
|
+
extend: function(l, c) {
|
|
699
|
+
var d = s.util.clone(s.languages[l]);
|
|
700
|
+
for (var g in c)
|
|
701
|
+
d[g] = c[g];
|
|
702
|
+
return d;
|
|
703
|
+
},
|
|
704
|
+
/**
|
|
705
|
+
* Inserts tokens _before_ another token in a language definition or any other grammar.
|
|
706
|
+
*
|
|
707
|
+
* ## Usage
|
|
708
|
+
*
|
|
709
|
+
* This helper method makes it easy to modify existing languages. For example, the CSS language definition
|
|
710
|
+
* not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
|
|
711
|
+
* in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
|
|
712
|
+
* appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
|
|
713
|
+
* this:
|
|
714
|
+
*
|
|
715
|
+
* ```js
|
|
716
|
+
* Prism.languages.markup.style = {
|
|
717
|
+
* // token
|
|
718
|
+
* };
|
|
719
|
+
* ```
|
|
720
|
+
*
|
|
721
|
+
* then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
|
|
722
|
+
* before existing tokens. For the CSS example above, you would use it like this:
|
|
723
|
+
*
|
|
724
|
+
* ```js
|
|
725
|
+
* Prism.languages.insertBefore('markup', 'cdata', {
|
|
726
|
+
* 'style': {
|
|
727
|
+
* // token
|
|
728
|
+
* }
|
|
729
|
+
* });
|
|
730
|
+
* ```
|
|
731
|
+
*
|
|
732
|
+
* ## Special cases
|
|
733
|
+
*
|
|
734
|
+
* If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
|
|
735
|
+
* will be ignored.
|
|
736
|
+
*
|
|
737
|
+
* This behavior can be used to insert tokens after `before`:
|
|
738
|
+
*
|
|
739
|
+
* ```js
|
|
740
|
+
* Prism.languages.insertBefore('markup', 'comment', {
|
|
741
|
+
* 'comment': Prism.languages.markup.comment,
|
|
742
|
+
* // tokens after 'comment'
|
|
743
|
+
* });
|
|
744
|
+
* ```
|
|
745
|
+
*
|
|
746
|
+
* ## Limitations
|
|
747
|
+
*
|
|
748
|
+
* The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
|
|
749
|
+
* properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
|
|
750
|
+
* differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
|
|
751
|
+
* deleting properties which is necessary to insert at arbitrary positions.
|
|
752
|
+
*
|
|
753
|
+
* To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
|
|
754
|
+
* Instead, it will create a new object and replace all references to the target object with the new one. This
|
|
755
|
+
* can be done without temporarily deleting properties, so the iteration order is well-defined.
|
|
756
|
+
*
|
|
757
|
+
* However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
|
|
758
|
+
* you hold the target object in a variable, then the value of the variable will not change.
|
|
759
|
+
*
|
|
760
|
+
* ```js
|
|
761
|
+
* var oldMarkup = Prism.languages.markup;
|
|
762
|
+
* var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
|
|
763
|
+
*
|
|
764
|
+
* assert(oldMarkup !== Prism.languages.markup);
|
|
765
|
+
* assert(newMarkup === Prism.languages.markup);
|
|
766
|
+
* ```
|
|
767
|
+
*
|
|
768
|
+
* @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
|
|
769
|
+
* object to be modified.
|
|
770
|
+
* @param {string} before The key to insert before.
|
|
771
|
+
* @param {Grammar} insert An object containing the key-value pairs to be inserted.
|
|
772
|
+
* @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
|
|
773
|
+
* object to be modified.
|
|
774
|
+
*
|
|
775
|
+
* Defaults to `Prism.languages`.
|
|
776
|
+
* @returns {Grammar} The new grammar object.
|
|
777
|
+
* @public
|
|
778
|
+
*/
|
|
779
|
+
insertBefore: function(l, c, d, g) {
|
|
780
|
+
g = g || /** @type {any} */
|
|
781
|
+
s.languages;
|
|
782
|
+
var f = g[l], v = {};
|
|
783
|
+
for (var x in f)
|
|
784
|
+
if (f.hasOwnProperty(x)) {
|
|
785
|
+
if (x == c)
|
|
786
|
+
for (var b in d)
|
|
787
|
+
d.hasOwnProperty(b) && (v[b] = d[b]);
|
|
788
|
+
d.hasOwnProperty(x) || (v[x] = f[x]);
|
|
789
|
+
}
|
|
790
|
+
var k = g[l];
|
|
791
|
+
return g[l] = v, s.languages.DFS(s.languages, function(P, z) {
|
|
792
|
+
z === k && P != l && (this[P] = v);
|
|
793
|
+
}), v;
|
|
794
|
+
},
|
|
795
|
+
// Traverse a language definition with Depth First Search
|
|
796
|
+
DFS: function l(c, d, g, f) {
|
|
797
|
+
f = f || {};
|
|
798
|
+
var v = s.util.objId;
|
|
799
|
+
for (var x in c)
|
|
800
|
+
if (c.hasOwnProperty(x)) {
|
|
801
|
+
d.call(c, x, c[x], g || x);
|
|
802
|
+
var b = c[x], k = s.util.type(b);
|
|
803
|
+
k === "Object" && !f[v(b)] ? (f[v(b)] = !0, l(b, d, null, f)) : k === "Array" && !f[v(b)] && (f[v(b)] = !0, l(b, d, x, f));
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
},
|
|
807
|
+
plugins: {},
|
|
808
|
+
/**
|
|
809
|
+
* This is the most high-level function in Prism’s API.
|
|
810
|
+
* It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
|
|
811
|
+
* each one of them.
|
|
812
|
+
*
|
|
813
|
+
* This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
|
|
814
|
+
*
|
|
815
|
+
* @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
|
|
816
|
+
* @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
|
|
817
|
+
* @memberof Prism
|
|
818
|
+
* @public
|
|
819
|
+
*/
|
|
820
|
+
highlightAll: function(l, c) {
|
|
821
|
+
s.highlightAllUnder(document, l, c);
|
|
822
|
+
},
|
|
823
|
+
/**
|
|
824
|
+
* Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
|
|
825
|
+
* {@link Prism.highlightElement} on each one of them.
|
|
826
|
+
*
|
|
827
|
+
* The following hooks will be run:
|
|
828
|
+
* 1. `before-highlightall`
|
|
829
|
+
* 2. `before-all-elements-highlight`
|
|
830
|
+
* 3. All hooks of {@link Prism.highlightElement} for each element.
|
|
831
|
+
*
|
|
832
|
+
* @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
|
|
833
|
+
* @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
|
|
834
|
+
* @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
|
|
835
|
+
* @memberof Prism
|
|
836
|
+
* @public
|
|
837
|
+
*/
|
|
838
|
+
highlightAllUnder: function(l, c, d) {
|
|
839
|
+
var g = {
|
|
840
|
+
callback: d,
|
|
841
|
+
container: l,
|
|
842
|
+
selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
|
|
843
|
+
};
|
|
844
|
+
s.hooks.run("before-highlightall", g), g.elements = Array.prototype.slice.apply(g.container.querySelectorAll(g.selector)), s.hooks.run("before-all-elements-highlight", g);
|
|
845
|
+
for (var f = 0, v; v = g.elements[f++]; )
|
|
846
|
+
s.highlightElement(v, c === !0, g.callback);
|
|
847
|
+
},
|
|
848
|
+
/**
|
|
849
|
+
* Highlights the code inside a single element.
|
|
850
|
+
*
|
|
851
|
+
* The following hooks will be run:
|
|
852
|
+
* 1. `before-sanity-check`
|
|
853
|
+
* 2. `before-highlight`
|
|
854
|
+
* 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
|
|
855
|
+
* 4. `before-insert`
|
|
856
|
+
* 5. `after-highlight`
|
|
857
|
+
* 6. `complete`
|
|
858
|
+
*
|
|
859
|
+
* Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
|
|
860
|
+
* the element's language.
|
|
861
|
+
*
|
|
862
|
+
* @param {Element} element The element containing the code.
|
|
863
|
+
* It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
|
|
864
|
+
* @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
|
|
865
|
+
* to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
|
|
866
|
+
* [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
|
|
867
|
+
*
|
|
868
|
+
* Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
|
|
869
|
+
* asynchronous highlighting to work. You can build your own bundle on the
|
|
870
|
+
* [Download page](https://prismjs.com/download.html).
|
|
871
|
+
* @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
|
|
872
|
+
* Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
|
|
873
|
+
* @memberof Prism
|
|
874
|
+
* @public
|
|
875
|
+
*/
|
|
876
|
+
highlightElement: function(l, c, d) {
|
|
877
|
+
var g = s.util.getLanguage(l), f = s.languages[g];
|
|
878
|
+
s.util.setLanguage(l, g);
|
|
879
|
+
var v = l.parentElement;
|
|
880
|
+
v && v.nodeName.toLowerCase() === "pre" && s.util.setLanguage(v, g);
|
|
881
|
+
var x = l.textContent, b = {
|
|
882
|
+
element: l,
|
|
883
|
+
language: g,
|
|
884
|
+
grammar: f,
|
|
885
|
+
code: x
|
|
886
|
+
};
|
|
887
|
+
function k(z) {
|
|
888
|
+
b.highlightedCode = z, s.hooks.run("before-insert", b), b.element.innerHTML = b.highlightedCode, s.hooks.run("after-highlight", b), s.hooks.run("complete", b), d && d.call(b.element);
|
|
889
|
+
}
|
|
890
|
+
if (s.hooks.run("before-sanity-check", b), v = b.element.parentElement, v && v.nodeName.toLowerCase() === "pre" && !v.hasAttribute("tabindex") && v.setAttribute("tabindex", "0"), !b.code) {
|
|
891
|
+
s.hooks.run("complete", b), d && d.call(b.element);
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
if (s.hooks.run("before-highlight", b), !b.grammar) {
|
|
895
|
+
k(s.util.encode(b.code));
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
898
|
+
if (c && n.Worker) {
|
|
899
|
+
var P = new Worker(s.filename);
|
|
900
|
+
P.onmessage = function(z) {
|
|
901
|
+
k(z.data);
|
|
902
|
+
}, P.postMessage(JSON.stringify({
|
|
903
|
+
language: b.language,
|
|
904
|
+
code: b.code,
|
|
905
|
+
immediateClose: !0
|
|
906
|
+
}));
|
|
907
|
+
} else
|
|
908
|
+
k(s.highlight(b.code, b.grammar, b.language));
|
|
909
|
+
},
|
|
910
|
+
/**
|
|
911
|
+
* Low-level function, only use if you know what you’re doing. It accepts a string of text as input
|
|
912
|
+
* and the language definitions to use, and returns a string with the HTML produced.
|
|
913
|
+
*
|
|
914
|
+
* The following hooks will be run:
|
|
915
|
+
* 1. `before-tokenize`
|
|
916
|
+
* 2. `after-tokenize`
|
|
917
|
+
* 3. `wrap`: On each {@link Token}.
|
|
918
|
+
*
|
|
919
|
+
* @param {string} text A string with the code to be highlighted.
|
|
920
|
+
* @param {Grammar} grammar An object containing the tokens to use.
|
|
921
|
+
*
|
|
922
|
+
* Usually a language definition like `Prism.languages.markup`.
|
|
923
|
+
* @param {string} language The name of the language definition passed to `grammar`.
|
|
924
|
+
* @returns {string} The highlighted HTML.
|
|
925
|
+
* @memberof Prism
|
|
926
|
+
* @public
|
|
927
|
+
* @example
|
|
928
|
+
* Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
|
|
929
|
+
*/
|
|
930
|
+
highlight: function(l, c, d) {
|
|
931
|
+
var g = {
|
|
932
|
+
code: l,
|
|
933
|
+
grammar: c,
|
|
934
|
+
language: d
|
|
935
|
+
};
|
|
936
|
+
if (s.hooks.run("before-tokenize", g), !g.grammar)
|
|
937
|
+
throw new Error('The language "' + g.language + '" has no grammar.');
|
|
938
|
+
return g.tokens = s.tokenize(g.code, g.grammar), s.hooks.run("after-tokenize", g), u.stringify(s.util.encode(g.tokens), g.language);
|
|
939
|
+
},
|
|
940
|
+
/**
|
|
941
|
+
* This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
|
|
942
|
+
* and the language definitions to use, and returns an array with the tokenized code.
|
|
943
|
+
*
|
|
944
|
+
* When the language definition includes nested tokens, the function is called recursively on each of these tokens.
|
|
945
|
+
*
|
|
946
|
+
* This method could be useful in other contexts as well, as a very crude parser.
|
|
947
|
+
*
|
|
948
|
+
* @param {string} text A string with the code to be highlighted.
|
|
949
|
+
* @param {Grammar} grammar An object containing the tokens to use.
|
|
950
|
+
*
|
|
951
|
+
* Usually a language definition like `Prism.languages.markup`.
|
|
952
|
+
* @returns {TokenStream} An array of strings and tokens, a token stream.
|
|
953
|
+
* @memberof Prism
|
|
954
|
+
* @public
|
|
955
|
+
* @example
|
|
956
|
+
* let code = `var foo = 0;`;
|
|
957
|
+
* let tokens = Prism.tokenize(code, Prism.languages.javascript);
|
|
958
|
+
* tokens.forEach(token => {
|
|
959
|
+
* if (token instanceof Prism.Token && token.type === 'number') {
|
|
960
|
+
* console.log(`Found numeric literal: ${token.content}`);
|
|
961
|
+
* }
|
|
962
|
+
* });
|
|
963
|
+
*/
|
|
964
|
+
tokenize: function(l, c) {
|
|
965
|
+
var d = c.rest;
|
|
966
|
+
if (d) {
|
|
967
|
+
for (var g in d)
|
|
968
|
+
c[g] = d[g];
|
|
969
|
+
delete c.rest;
|
|
970
|
+
}
|
|
971
|
+
var f = new T();
|
|
972
|
+
return S(f, f.head, l), A(l, f, c, f.head, 0), N(f);
|
|
973
|
+
},
|
|
974
|
+
/**
|
|
975
|
+
* @namespace
|
|
976
|
+
* @memberof Prism
|
|
977
|
+
* @public
|
|
978
|
+
*/
|
|
979
|
+
hooks: {
|
|
980
|
+
all: {},
|
|
981
|
+
/**
|
|
982
|
+
* Adds the given callback to the list of callbacks for the given hook.
|
|
983
|
+
*
|
|
984
|
+
* The callback will be invoked when the hook it is registered for is run.
|
|
985
|
+
* Hooks are usually directly run by a highlight function but you can also run hooks yourself.
|
|
986
|
+
*
|
|
987
|
+
* One callback function can be registered to multiple hooks and the same hook multiple times.
|
|
988
|
+
*
|
|
989
|
+
* @param {string} name The name of the hook.
|
|
990
|
+
* @param {HookCallback} callback The callback function which is given environment variables.
|
|
991
|
+
* @public
|
|
992
|
+
*/
|
|
993
|
+
add: function(l, c) {
|
|
994
|
+
var d = s.hooks.all;
|
|
995
|
+
d[l] = d[l] || [], d[l].push(c);
|
|
996
|
+
},
|
|
997
|
+
/**
|
|
998
|
+
* Runs a hook invoking all registered callbacks with the given environment variables.
|
|
999
|
+
*
|
|
1000
|
+
* Callbacks will be invoked synchronously and in the order in which they were registered.
|
|
1001
|
+
*
|
|
1002
|
+
* @param {string} name The name of the hook.
|
|
1003
|
+
* @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
|
|
1004
|
+
* @public
|
|
1005
|
+
*/
|
|
1006
|
+
run: function(l, c) {
|
|
1007
|
+
var d = s.hooks.all[l];
|
|
1008
|
+
if (!(!d || !d.length))
|
|
1009
|
+
for (var g = 0, f; f = d[g++]; )
|
|
1010
|
+
f(c);
|
|
1011
|
+
}
|
|
1012
|
+
},
|
|
1013
|
+
Token: u
|
|
1014
|
+
};
|
|
1015
|
+
n.Prism = s;
|
|
1016
|
+
function u(l, c, d, g) {
|
|
1017
|
+
this.type = l, this.content = c, this.alias = d, this.length = (g || "").length | 0;
|
|
1018
|
+
}
|
|
1019
|
+
u.stringify = function l(c, d) {
|
|
1020
|
+
if (typeof c == "string")
|
|
1021
|
+
return c;
|
|
1022
|
+
if (Array.isArray(c)) {
|
|
1023
|
+
var g = "";
|
|
1024
|
+
return c.forEach(function(k) {
|
|
1025
|
+
g += l(k, d);
|
|
1026
|
+
}), g;
|
|
1027
|
+
}
|
|
1028
|
+
var f = {
|
|
1029
|
+
type: c.type,
|
|
1030
|
+
content: l(c.content, d),
|
|
1031
|
+
tag: "span",
|
|
1032
|
+
classes: ["token", c.type],
|
|
1033
|
+
attributes: {},
|
|
1034
|
+
language: d
|
|
1035
|
+
}, v = c.alias;
|
|
1036
|
+
v && (Array.isArray(v) ? Array.prototype.push.apply(f.classes, v) : f.classes.push(v)), s.hooks.run("wrap", f);
|
|
1037
|
+
var x = "";
|
|
1038
|
+
for (var b in f.attributes)
|
|
1039
|
+
x += " " + b + '="' + (f.attributes[b] || "").replace(/"/g, """) + '"';
|
|
1040
|
+
return "<" + f.tag + ' class="' + f.classes.join(" ") + '"' + x + ">" + f.content + "</" + f.tag + ">";
|
|
1041
|
+
};
|
|
1042
|
+
function m(l, c, d, g) {
|
|
1043
|
+
l.lastIndex = c;
|
|
1044
|
+
var f = l.exec(d);
|
|
1045
|
+
if (f && g && f[1]) {
|
|
1046
|
+
var v = f[1].length;
|
|
1047
|
+
f.index += v, f[0] = f[0].slice(v);
|
|
1048
|
+
}
|
|
1049
|
+
return f;
|
|
1050
|
+
}
|
|
1051
|
+
function A(l, c, d, g, f, v) {
|
|
1052
|
+
for (var x in d)
|
|
1053
|
+
if (!(!d.hasOwnProperty(x) || !d[x])) {
|
|
1054
|
+
var b = d[x];
|
|
1055
|
+
b = Array.isArray(b) ? b : [b];
|
|
1056
|
+
for (var k = 0; k < b.length; ++k) {
|
|
1057
|
+
if (v && v.cause == x + "," + k)
|
|
1058
|
+
return;
|
|
1059
|
+
var P = b[k], z = P.inside, Pe = !!P.lookbehind, _e = !!P.greedy, mt = P.alias;
|
|
1060
|
+
if (_e && !P.pattern.global) {
|
|
1061
|
+
var pt = P.pattern.toString().match(/[imsuy]*$/)[0];
|
|
1062
|
+
P.pattern = RegExp(P.pattern.source, pt + "g");
|
|
1063
|
+
}
|
|
1064
|
+
for (var De = P.pattern || P, _ = g.next, R = f; _ !== c.tail && !(v && R >= v.reach); R += _.value.length, _ = _.next) {
|
|
1065
|
+
var Z = _.value;
|
|
1066
|
+
if (c.length > l.length)
|
|
1067
|
+
return;
|
|
1068
|
+
if (!(Z instanceof u)) {
|
|
1069
|
+
var ae = 1, H;
|
|
1070
|
+
if (_e) {
|
|
1071
|
+
if (H = m(De, R, l, Pe), !H || H.index >= l.length)
|
|
1072
|
+
break;
|
|
1073
|
+
var le = H.index, bt = H.index + H[0].length, W = R;
|
|
1074
|
+
for (W += _.value.length; le >= W; )
|
|
1075
|
+
_ = _.next, W += _.value.length;
|
|
1076
|
+
if (W -= _.value.length, R = W, _.value instanceof u)
|
|
1077
|
+
continue;
|
|
1078
|
+
for (var J = _; J !== c.tail && (W < bt || typeof J.value == "string"); J = J.next)
|
|
1079
|
+
ae++, W += J.value.length;
|
|
1080
|
+
ae--, Z = l.slice(R, W), H.index -= R;
|
|
1081
|
+
} else if (H = m(De, 0, Z, Pe), !H)
|
|
1082
|
+
continue;
|
|
1083
|
+
var le = H.index, ce = H[0], Ce = Z.slice(0, le), Be = Z.slice(le + ce.length), ye = R + Z.length;
|
|
1084
|
+
v && ye > v.reach && (v.reach = ye);
|
|
1085
|
+
var ue = _.prev;
|
|
1086
|
+
Ce && (ue = S(c, ue, Ce), R += Ce.length), F(c, ue, ae);
|
|
1087
|
+
var vt = new u(x, z ? s.tokenize(ce, z) : ce, mt, ce);
|
|
1088
|
+
if (_ = S(c, ue, vt), Be && S(c, _, Be), ae > 1) {
|
|
1089
|
+
var Ne = {
|
|
1090
|
+
cause: x + "," + k,
|
|
1091
|
+
reach: ye
|
|
1092
|
+
};
|
|
1093
|
+
A(l, c, d, _.prev, R, Ne), v && Ne.reach > v.reach && (v.reach = Ne.reach);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
function T() {
|
|
1101
|
+
var l = { value: null, prev: null, next: null }, c = { value: null, prev: l, next: null };
|
|
1102
|
+
l.next = c, this.head = l, this.tail = c, this.length = 0;
|
|
1103
|
+
}
|
|
1104
|
+
function S(l, c, d) {
|
|
1105
|
+
var g = c.next, f = { value: d, prev: c, next: g };
|
|
1106
|
+
return c.next = f, g.prev = f, l.length++, f;
|
|
1107
|
+
}
|
|
1108
|
+
function F(l, c, d) {
|
|
1109
|
+
for (var g = c.next, f = 0; f < d && g !== l.tail; f++)
|
|
1110
|
+
g = g.next;
|
|
1111
|
+
c.next = g, g.prev = c, l.length -= f;
|
|
1112
|
+
}
|
|
1113
|
+
function N(l) {
|
|
1114
|
+
for (var c = [], d = l.head.next; d !== l.tail; )
|
|
1115
|
+
c.push(d.value), d = d.next;
|
|
1116
|
+
return c;
|
|
1117
|
+
}
|
|
1118
|
+
if (!n.document)
|
|
1119
|
+
return n.addEventListener && (s.disableWorkerMessageHandler || n.addEventListener("message", function(l) {
|
|
1120
|
+
var c = JSON.parse(l.data), d = c.language, g = c.code, f = c.immediateClose;
|
|
1121
|
+
n.postMessage(s.highlight(g, s.languages[d], d)), f && n.close();
|
|
1122
|
+
}, !1)), s;
|
|
1123
|
+
var p = s.util.currentScript();
|
|
1124
|
+
p && (s.filename = p.src, p.hasAttribute("data-manual") && (s.manual = !0));
|
|
1125
|
+
function y() {
|
|
1126
|
+
s.manual || s.highlightAll();
|
|
1127
|
+
}
|
|
1128
|
+
if (!s.manual) {
|
|
1129
|
+
var E = document.readyState;
|
|
1130
|
+
E === "loading" || E === "interactive" && p && p.defer ? document.addEventListener("DOMContentLoaded", y) : window.requestAnimationFrame ? window.requestAnimationFrame(y) : window.setTimeout(y, 16);
|
|
1131
|
+
}
|
|
1132
|
+
return s;
|
|
1133
|
+
}(a);
|
|
1134
|
+
t.exports && (t.exports = e), typeof je < "u" && (je.Prism = e), e.languages.markup = {
|
|
1135
|
+
comment: {
|
|
1136
|
+
pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
|
|
1137
|
+
greedy: !0
|
|
1138
|
+
},
|
|
1139
|
+
prolog: {
|
|
1140
|
+
pattern: /<\?[\s\S]+?\?>/,
|
|
1141
|
+
greedy: !0
|
|
1142
|
+
},
|
|
1143
|
+
doctype: {
|
|
1144
|
+
// https://www.w3.org/TR/xml/#NT-doctypedecl
|
|
1145
|
+
pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
|
|
1146
|
+
greedy: !0,
|
|
1147
|
+
inside: {
|
|
1148
|
+
"internal-subset": {
|
|
1149
|
+
pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
|
|
1150
|
+
lookbehind: !0,
|
|
1151
|
+
greedy: !0,
|
|
1152
|
+
inside: null
|
|
1153
|
+
// see below
|
|
1154
|
+
},
|
|
1155
|
+
string: {
|
|
1156
|
+
pattern: /"[^"]*"|'[^']*'/,
|
|
1157
|
+
greedy: !0
|
|
1158
|
+
},
|
|
1159
|
+
punctuation: /^<!|>$|[[\]]/,
|
|
1160
|
+
"doctype-tag": /^DOCTYPE/i,
|
|
1161
|
+
name: /[^\s<>'"]+/
|
|
1162
|
+
}
|
|
1163
|
+
},
|
|
1164
|
+
cdata: {
|
|
1165
|
+
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
1166
|
+
greedy: !0
|
|
1167
|
+
},
|
|
1168
|
+
tag: {
|
|
1169
|
+
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
|
|
1170
|
+
greedy: !0,
|
|
1171
|
+
inside: {
|
|
1172
|
+
tag: {
|
|
1173
|
+
pattern: /^<\/?[^\s>\/]+/,
|
|
1174
|
+
inside: {
|
|
1175
|
+
punctuation: /^<\/?/,
|
|
1176
|
+
namespace: /^[^\s>\/:]+:/
|
|
1177
|
+
}
|
|
1178
|
+
},
|
|
1179
|
+
"special-attr": [],
|
|
1180
|
+
"attr-value": {
|
|
1181
|
+
pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
|
|
1182
|
+
inside: {
|
|
1183
|
+
punctuation: [
|
|
1184
|
+
{
|
|
1185
|
+
pattern: /^=/,
|
|
1186
|
+
alias: "attr-equals"
|
|
1187
|
+
},
|
|
1188
|
+
{
|
|
1189
|
+
pattern: /^(\s*)["']|["']$/,
|
|
1190
|
+
lookbehind: !0
|
|
1191
|
+
}
|
|
1192
|
+
]
|
|
1193
|
+
}
|
|
1194
|
+
},
|
|
1195
|
+
punctuation: /\/?>/,
|
|
1196
|
+
"attr-name": {
|
|
1197
|
+
pattern: /[^\s>\/]+/,
|
|
1198
|
+
inside: {
|
|
1199
|
+
namespace: /^[^\s>\/:]+:/
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
},
|
|
1204
|
+
entity: [
|
|
1205
|
+
{
|
|
1206
|
+
pattern: /&[\da-z]{1,8};/i,
|
|
1207
|
+
alias: "named-entity"
|
|
1208
|
+
},
|
|
1209
|
+
/&#x?[\da-f]{1,8};/i
|
|
1210
|
+
]
|
|
1211
|
+
}, e.languages.markup.tag.inside["attr-value"].inside.entity = e.languages.markup.entity, e.languages.markup.doctype.inside["internal-subset"].inside = e.languages.markup, e.hooks.add("wrap", function(n) {
|
|
1212
|
+
n.type === "entity" && (n.attributes.title = n.content.replace(/&/, "&"));
|
|
1213
|
+
}), Object.defineProperty(e.languages.markup.tag, "addInlined", {
|
|
1214
|
+
/**
|
|
1215
|
+
* Adds an inlined language to markup.
|
|
1216
|
+
*
|
|
1217
|
+
* An example of an inlined language is CSS with `<style>` tags.
|
|
1218
|
+
*
|
|
1219
|
+
* @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
|
|
1220
|
+
* case insensitive.
|
|
1221
|
+
* @param {string} lang The language key.
|
|
1222
|
+
* @example
|
|
1223
|
+
* addInlined('style', 'css');
|
|
1224
|
+
*/
|
|
1225
|
+
value: function(i, r) {
|
|
1226
|
+
var o = {};
|
|
1227
|
+
o["language-" + r] = {
|
|
1228
|
+
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
|
1229
|
+
lookbehind: !0,
|
|
1230
|
+
inside: e.languages[r]
|
|
1231
|
+
}, o.cdata = /^<!\[CDATA\[|\]\]>$/i;
|
|
1232
|
+
var s = {
|
|
1233
|
+
"included-cdata": {
|
|
1234
|
+
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
1235
|
+
inside: o
|
|
1236
|
+
}
|
|
1237
|
+
};
|
|
1238
|
+
s["language-" + r] = {
|
|
1239
|
+
pattern: /[\s\S]+/,
|
|
1240
|
+
inside: e.languages[r]
|
|
1241
|
+
};
|
|
1242
|
+
var u = {};
|
|
1243
|
+
u[i] = {
|
|
1244
|
+
pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function() {
|
|
1245
|
+
return i;
|
|
1246
|
+
}), "i"),
|
|
1247
|
+
lookbehind: !0,
|
|
1248
|
+
greedy: !0,
|
|
1249
|
+
inside: s
|
|
1250
|
+
}, e.languages.insertBefore("markup", "cdata", u);
|
|
1251
|
+
}
|
|
1252
|
+
}), Object.defineProperty(e.languages.markup.tag, "addAttribute", {
|
|
1253
|
+
/**
|
|
1254
|
+
* Adds an pattern to highlight languages embedded in HTML attributes.
|
|
1255
|
+
*
|
|
1256
|
+
* An example of an inlined language is CSS with `style` attributes.
|
|
1257
|
+
*
|
|
1258
|
+
* @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
|
|
1259
|
+
* case insensitive.
|
|
1260
|
+
* @param {string} lang The language key.
|
|
1261
|
+
* @example
|
|
1262
|
+
* addAttribute('style', 'css');
|
|
1263
|
+
*/
|
|
1264
|
+
value: function(n, i) {
|
|
1265
|
+
e.languages.markup.tag.inside["special-attr"].push({
|
|
1266
|
+
pattern: RegExp(
|
|
1267
|
+
/(^|["'\s])/.source + "(?:" + n + ")" + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
|
|
1268
|
+
"i"
|
|
1269
|
+
),
|
|
1270
|
+
lookbehind: !0,
|
|
1271
|
+
inside: {
|
|
1272
|
+
"attr-name": /^[^\s=]+/,
|
|
1273
|
+
"attr-value": {
|
|
1274
|
+
pattern: /=[\s\S]+/,
|
|
1275
|
+
inside: {
|
|
1276
|
+
value: {
|
|
1277
|
+
pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
|
|
1278
|
+
lookbehind: !0,
|
|
1279
|
+
alias: [i, "language-" + i],
|
|
1280
|
+
inside: e.languages[i]
|
|
1281
|
+
},
|
|
1282
|
+
punctuation: [
|
|
1283
|
+
{
|
|
1284
|
+
pattern: /^=/,
|
|
1285
|
+
alias: "attr-equals"
|
|
1286
|
+
},
|
|
1287
|
+
/"|'/
|
|
1288
|
+
]
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
}), e.languages.html = e.languages.markup, e.languages.mathml = e.languages.markup, e.languages.svg = e.languages.markup, e.languages.xml = e.languages.extend("markup", {}), e.languages.ssml = e.languages.xml, e.languages.atom = e.languages.xml, e.languages.rss = e.languages.xml, function(n) {
|
|
1295
|
+
var i = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
|
|
1296
|
+
n.languages.css = {
|
|
1297
|
+
comment: /\/\*[\s\S]*?\*\//,
|
|
1298
|
+
atrule: {
|
|
1299
|
+
pattern: RegExp("@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" + i.source + ")*?" + /(?:;|(?=\s*\{))/.source),
|
|
1300
|
+
inside: {
|
|
1301
|
+
rule: /^@[\w-]+/,
|
|
1302
|
+
"selector-function-argument": {
|
|
1303
|
+
pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
|
|
1304
|
+
lookbehind: !0,
|
|
1305
|
+
alias: "selector"
|
|
1306
|
+
},
|
|
1307
|
+
keyword: {
|
|
1308
|
+
pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
|
|
1309
|
+
lookbehind: !0
|
|
1310
|
+
}
|
|
1311
|
+
// See rest below
|
|
1312
|
+
}
|
|
1313
|
+
},
|
|
1314
|
+
url: {
|
|
1315
|
+
// https://drafts.csswg.org/css-values-3/#urls
|
|
1316
|
+
pattern: RegExp("\\burl\\((?:" + i.source + "|" + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ")\\)", "i"),
|
|
1317
|
+
greedy: !0,
|
|
1318
|
+
inside: {
|
|
1319
|
+
function: /^url/i,
|
|
1320
|
+
punctuation: /^\(|\)$/,
|
|
1321
|
+
string: {
|
|
1322
|
+
pattern: RegExp("^" + i.source + "$"),
|
|
1323
|
+
alias: "url"
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
},
|
|
1327
|
+
selector: {
|
|
1328
|
+
pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` + i.source + ")*(?=\\s*\\{)"),
|
|
1329
|
+
lookbehind: !0
|
|
1330
|
+
},
|
|
1331
|
+
string: {
|
|
1332
|
+
pattern: i,
|
|
1333
|
+
greedy: !0
|
|
1334
|
+
},
|
|
1335
|
+
property: {
|
|
1336
|
+
pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
|
|
1337
|
+
lookbehind: !0
|
|
1338
|
+
},
|
|
1339
|
+
important: /!important\b/i,
|
|
1340
|
+
function: {
|
|
1341
|
+
pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
|
|
1342
|
+
lookbehind: !0
|
|
1343
|
+
},
|
|
1344
|
+
punctuation: /[(){};:,]/
|
|
1345
|
+
}, n.languages.css.atrule.inside.rest = n.languages.css;
|
|
1346
|
+
var r = n.languages.markup;
|
|
1347
|
+
r && (r.tag.addInlined("style", "css"), r.tag.addAttribute("style", "css"));
|
|
1348
|
+
}(e), e.languages.clike = {
|
|
1349
|
+
comment: [
|
|
1350
|
+
{
|
|
1351
|
+
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
|
1352
|
+
lookbehind: !0,
|
|
1353
|
+
greedy: !0
|
|
1354
|
+
},
|
|
1355
|
+
{
|
|
1356
|
+
pattern: /(^|[^\\:])\/\/.*/,
|
|
1357
|
+
lookbehind: !0,
|
|
1358
|
+
greedy: !0
|
|
1359
|
+
}
|
|
1360
|
+
],
|
|
1361
|
+
string: {
|
|
1362
|
+
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
|
1363
|
+
greedy: !0
|
|
1364
|
+
},
|
|
1365
|
+
"class-name": {
|
|
1366
|
+
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
|
|
1367
|
+
lookbehind: !0,
|
|
1368
|
+
inside: {
|
|
1369
|
+
punctuation: /[.\\]/
|
|
1370
|
+
}
|
|
1371
|
+
},
|
|
1372
|
+
keyword: /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
1373
|
+
boolean: /\b(?:false|true)\b/,
|
|
1374
|
+
function: /\b\w+(?=\()/,
|
|
1375
|
+
number: /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
1376
|
+
operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
1377
|
+
punctuation: /[{}[\];(),.:]/
|
|
1378
|
+
}, e.languages.javascript = e.languages.extend("clike", {
|
|
1379
|
+
"class-name": [
|
|
1380
|
+
e.languages.clike["class-name"],
|
|
1381
|
+
{
|
|
1382
|
+
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
|
|
1383
|
+
lookbehind: !0
|
|
1384
|
+
}
|
|
1385
|
+
],
|
|
1386
|
+
keyword: [
|
|
1387
|
+
{
|
|
1388
|
+
pattern: /((?:^|\})\s*)catch\b/,
|
|
1389
|
+
lookbehind: !0
|
|
1390
|
+
},
|
|
1391
|
+
{
|
|
1392
|
+
pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
|
|
1393
|
+
lookbehind: !0
|
|
1394
|
+
}
|
|
1395
|
+
],
|
|
1396
|
+
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
|
|
1397
|
+
function: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
1398
|
+
number: {
|
|
1399
|
+
pattern: RegExp(
|
|
1400
|
+
/(^|[^\w$])/.source + "(?:" + // constant
|
|
1401
|
+
(/NaN|Infinity/.source + "|" + // binary integer
|
|
1402
|
+
/0[bB][01]+(?:_[01]+)*n?/.source + "|" + // octal integer
|
|
1403
|
+
/0[oO][0-7]+(?:_[0-7]+)*n?/.source + "|" + // hexadecimal integer
|
|
1404
|
+
/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + "|" + // decimal bigint
|
|
1405
|
+
/\d+(?:_\d+)*n/.source + "|" + // decimal number (integer or float) but no bigint
|
|
1406
|
+
/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source) + ")" + /(?![\w$])/.source
|
|
1407
|
+
),
|
|
1408
|
+
lookbehind: !0
|
|
1409
|
+
},
|
|
1410
|
+
operator: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
1411
|
+
}), e.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/, e.languages.insertBefore("javascript", "keyword", {
|
|
1412
|
+
regex: {
|
|
1413
|
+
pattern: RegExp(
|
|
1414
|
+
// lookbehind
|
|
1415
|
+
// eslint-disable-next-line regexp/no-dupe-characters-character-class
|
|
1416
|
+
/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source + // Regex pattern:
|
|
1417
|
+
// There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
|
|
1418
|
+
// classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
|
|
1419
|
+
// with the only syntax, so we have to define 2 different regex patterns.
|
|
1420
|
+
/\//.source + "(?:" + /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source + "|" + // `v` flag syntax. This supports 3 levels of nested character classes.
|
|
1421
|
+
/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ")" + // lookahead
|
|
1422
|
+
/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
|
|
1423
|
+
),
|
|
1424
|
+
lookbehind: !0,
|
|
1425
|
+
greedy: !0,
|
|
1426
|
+
inside: {
|
|
1427
|
+
"regex-source": {
|
|
1428
|
+
pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
|
1429
|
+
lookbehind: !0,
|
|
1430
|
+
alias: "language-regex",
|
|
1431
|
+
inside: e.languages.regex
|
|
1432
|
+
},
|
|
1433
|
+
"regex-delimiter": /^\/|\/$/,
|
|
1434
|
+
"regex-flags": /^[a-z]+$/
|
|
1435
|
+
}
|
|
1436
|
+
},
|
|
1437
|
+
// This must be declared before keyword because we use "function" inside the look-forward
|
|
1438
|
+
"function-variable": {
|
|
1439
|
+
pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
|
|
1440
|
+
alias: "function"
|
|
1441
|
+
},
|
|
1442
|
+
parameter: [
|
|
1443
|
+
{
|
|
1444
|
+
pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
|
|
1445
|
+
lookbehind: !0,
|
|
1446
|
+
inside: e.languages.javascript
|
|
1447
|
+
},
|
|
1448
|
+
{
|
|
1449
|
+
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
|
|
1450
|
+
lookbehind: !0,
|
|
1451
|
+
inside: e.languages.javascript
|
|
1452
|
+
},
|
|
1453
|
+
{
|
|
1454
|
+
pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
|
|
1455
|
+
lookbehind: !0,
|
|
1456
|
+
inside: e.languages.javascript
|
|
1457
|
+
},
|
|
1458
|
+
{
|
|
1459
|
+
pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
|
|
1460
|
+
lookbehind: !0,
|
|
1461
|
+
inside: e.languages.javascript
|
|
1462
|
+
}
|
|
1463
|
+
],
|
|
1464
|
+
constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
1465
|
+
}), e.languages.insertBefore("javascript", "string", {
|
|
1466
|
+
hashbang: {
|
|
1467
|
+
pattern: /^#!.*/,
|
|
1468
|
+
greedy: !0,
|
|
1469
|
+
alias: "comment"
|
|
1470
|
+
},
|
|
1471
|
+
"template-string": {
|
|
1472
|
+
pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
|
|
1473
|
+
greedy: !0,
|
|
1474
|
+
inside: {
|
|
1475
|
+
"template-punctuation": {
|
|
1476
|
+
pattern: /^`|`$/,
|
|
1477
|
+
alias: "string"
|
|
1478
|
+
},
|
|
1479
|
+
interpolation: {
|
|
1480
|
+
pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
|
|
1481
|
+
lookbehind: !0,
|
|
1482
|
+
inside: {
|
|
1483
|
+
"interpolation-punctuation": {
|
|
1484
|
+
pattern: /^\$\{|\}$/,
|
|
1485
|
+
alias: "punctuation"
|
|
1486
|
+
},
|
|
1487
|
+
rest: e.languages.javascript
|
|
1488
|
+
}
|
|
1489
|
+
},
|
|
1490
|
+
string: /[\s\S]+/
|
|
1491
|
+
}
|
|
1492
|
+
},
|
|
1493
|
+
"string-property": {
|
|
1494
|
+
pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
|
|
1495
|
+
lookbehind: !0,
|
|
1496
|
+
greedy: !0,
|
|
1497
|
+
alias: "property"
|
|
1498
|
+
}
|
|
1499
|
+
}), e.languages.insertBefore("javascript", "operator", {
|
|
1500
|
+
"literal-property": {
|
|
1501
|
+
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
|
|
1502
|
+
lookbehind: !0,
|
|
1503
|
+
alias: "property"
|
|
1504
|
+
}
|
|
1505
|
+
}), e.languages.markup && (e.languages.markup.tag.addInlined("script", "javascript"), e.languages.markup.tag.addAttribute(
|
|
1506
|
+
/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
|
|
1507
|
+
"javascript"
|
|
1508
|
+
)), e.languages.js = e.languages.javascript, function() {
|
|
1509
|
+
if (typeof e > "u" || typeof document > "u")
|
|
1510
|
+
return;
|
|
1511
|
+
Element.prototype.matches || (Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector);
|
|
1512
|
+
var n = "Loading…", i = function(p, y) {
|
|
1513
|
+
return "✖ Error " + p + " while fetching file: " + y;
|
|
1514
|
+
}, r = "✖ Error: File does not exist or is empty", o = {
|
|
1515
|
+
js: "javascript",
|
|
1516
|
+
py: "python",
|
|
1517
|
+
rb: "ruby",
|
|
1518
|
+
ps1: "powershell",
|
|
1519
|
+
psm1: "powershell",
|
|
1520
|
+
sh: "bash",
|
|
1521
|
+
bat: "batch",
|
|
1522
|
+
h: "c",
|
|
1523
|
+
tex: "latex"
|
|
1524
|
+
}, s = "data-src-status", u = "loading", m = "loaded", A = "failed", T = "pre[data-src]:not([" + s + '="' + m + '"]):not([' + s + '="' + u + '"])';
|
|
1525
|
+
function S(p, y, E) {
|
|
1526
|
+
var l = new XMLHttpRequest();
|
|
1527
|
+
l.open("GET", p, !0), l.onreadystatechange = function() {
|
|
1528
|
+
l.readyState == 4 && (l.status < 400 && l.responseText ? y(l.responseText) : l.status >= 400 ? E(i(l.status, l.statusText)) : E(r));
|
|
1529
|
+
}, l.send(null);
|
|
1530
|
+
}
|
|
1531
|
+
function F(p) {
|
|
1532
|
+
var y = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(p || "");
|
|
1533
|
+
if (y) {
|
|
1534
|
+
var E = Number(y[1]), l = y[2], c = y[3];
|
|
1535
|
+
return l ? c ? [E, Number(c)] : [E, void 0] : [E, E];
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
e.hooks.add("before-highlightall", function(p) {
|
|
1539
|
+
p.selector += ", " + T;
|
|
1540
|
+
}), e.hooks.add("before-sanity-check", function(p) {
|
|
1541
|
+
var y = (
|
|
1542
|
+
/** @type {HTMLPreElement} */
|
|
1543
|
+
p.element
|
|
1544
|
+
);
|
|
1545
|
+
if (y.matches(T)) {
|
|
1546
|
+
p.code = "", y.setAttribute(s, u);
|
|
1547
|
+
var E = y.appendChild(document.createElement("CODE"));
|
|
1548
|
+
E.textContent = n;
|
|
1549
|
+
var l = y.getAttribute("data-src"), c = p.language;
|
|
1550
|
+
if (c === "none") {
|
|
1551
|
+
var d = (/\.(\w+)$/.exec(l) || [, "none"])[1];
|
|
1552
|
+
c = o[d] || d;
|
|
1553
|
+
}
|
|
1554
|
+
e.util.setLanguage(E, c), e.util.setLanguage(y, c);
|
|
1555
|
+
var g = e.plugins.autoloader;
|
|
1556
|
+
g && g.loadLanguages(c), S(
|
|
1557
|
+
l,
|
|
1558
|
+
function(f) {
|
|
1559
|
+
y.setAttribute(s, m);
|
|
1560
|
+
var v = F(y.getAttribute("data-range"));
|
|
1561
|
+
if (v) {
|
|
1562
|
+
var x = f.split(/\r\n?|\n/g), b = v[0], k = v[1] == null ? x.length : v[1];
|
|
1563
|
+
b < 0 && (b += x.length), b = Math.max(0, Math.min(b - 1, x.length)), k < 0 && (k += x.length), k = Math.max(0, Math.min(k, x.length)), f = x.slice(b, k).join(`
|
|
1564
|
+
`), y.hasAttribute("data-start") || y.setAttribute("data-start", String(b + 1));
|
|
1565
|
+
}
|
|
1566
|
+
E.textContent = f, e.highlightElement(E);
|
|
1567
|
+
},
|
|
1568
|
+
function(f) {
|
|
1569
|
+
y.setAttribute(s, A), E.textContent = f;
|
|
1570
|
+
}
|
|
1571
|
+
);
|
|
1572
|
+
}
|
|
1573
|
+
}), e.plugins.fileHighlight = {
|
|
1574
|
+
/**
|
|
1575
|
+
* Executes the File Highlight plugin for all matching `pre` elements under the given container.
|
|
1576
|
+
*
|
|
1577
|
+
* Note: Elements which are already loaded or currently loading will not be touched by this method.
|
|
1578
|
+
*
|
|
1579
|
+
* @param {ParentNode} [container=document]
|
|
1580
|
+
*/
|
|
1581
|
+
highlight: function(y) {
|
|
1582
|
+
for (var E = (y || document).querySelectorAll(T), l = 0, c; c = E[l++]; )
|
|
1583
|
+
e.highlightElement(c);
|
|
1584
|
+
}
|
|
1585
|
+
};
|
|
1586
|
+
var N = !1;
|
|
1587
|
+
e.fileHighlight = function() {
|
|
1588
|
+
N || (console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."), N = !0), e.plugins.fileHighlight.highlight.apply(this, arguments);
|
|
1589
|
+
};
|
|
1590
|
+
}();
|
|
1591
|
+
}(Se)), Se.exports;
|
|
1592
|
+
}
|
|
1593
|
+
var Rn = Hn();
|
|
1594
|
+
const zn = /* @__PURE__ */ Bn(Rn);
|
|
1595
|
+
typeof globalThis < "u" && (globalThis.Prism = zn);
|
|
1596
|
+
function Wn({ codeBlockCoords: t, codeNodeKey: a }) {
|
|
1597
|
+
const [e] = M(), [n, i] = O({
|
|
1598
|
+
x: B,
|
|
1599
|
+
y: B
|
|
1600
|
+
}), r = se(null), [o, s] = O(""), u = hn(), m = Array.from(
|
|
1601
|
+
new Set(u.map((T) => Ae(T)))
|
|
1602
|
+
), A = {};
|
|
1603
|
+
return u.forEach((T) => {
|
|
1604
|
+
const S = Ae(T);
|
|
1605
|
+
A[S] || (A[S] = T);
|
|
1606
|
+
}), C(() => {
|
|
1607
|
+
i(En(t, r));
|
|
1608
|
+
}, [t]), C(() => {
|
|
1609
|
+
e.read(() => {
|
|
1610
|
+
if (a) {
|
|
1611
|
+
const S = oe(a).getLanguage();
|
|
1612
|
+
s(Ae(S));
|
|
447
1613
|
}
|
|
448
1614
|
});
|
|
449
|
-
}, [
|
|
450
|
-
|
|
1615
|
+
}, [e, a]), /* @__PURE__ */ D(
|
|
1616
|
+
Dt,
|
|
451
1617
|
{
|
|
452
1618
|
id: "code-highlight-menu",
|
|
453
|
-
ref:
|
|
1619
|
+
ref: r,
|
|
454
1620
|
style: {
|
|
455
1621
|
position: "absolute",
|
|
456
1622
|
top: n.y,
|
|
457
1623
|
left: n.x
|
|
458
1624
|
},
|
|
459
1625
|
"aria-label": "Code menu",
|
|
460
|
-
inputValue:
|
|
461
|
-
onInputChange: (
|
|
462
|
-
const
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
]),
|
|
1626
|
+
inputValue: o,
|
|
1627
|
+
onInputChange: (T) => {
|
|
1628
|
+
const S = A[T];
|
|
1629
|
+
e.dispatchCommand(ct, [
|
|
1630
|
+
a,
|
|
1631
|
+
S
|
|
1632
|
+
]), s(T);
|
|
467
1633
|
},
|
|
468
1634
|
children: [
|
|
469
|
-
/* @__PURE__ */
|
|
470
|
-
/* @__PURE__ */
|
|
471
|
-
/* @__PURE__ */
|
|
1635
|
+
/* @__PURE__ */ D("div", { children: [
|
|
1636
|
+
/* @__PURE__ */ h(et, {}),
|
|
1637
|
+
/* @__PURE__ */ h(U, { children: /* @__PURE__ */ h(Qt, { size: 24 }) })
|
|
472
1638
|
] }),
|
|
473
|
-
/* @__PURE__ */
|
|
1639
|
+
/* @__PURE__ */ h(tt, { children: /* @__PURE__ */ h(Bt, { children: m.map((T, S) => /* @__PURE__ */ h(Ht, { children: T }, S)) }) })
|
|
474
1640
|
]
|
|
475
1641
|
}
|
|
476
1642
|
);
|
|
477
1643
|
}
|
|
478
|
-
const
|
|
1644
|
+
const Gn = document.body, lt = Y(
|
|
479
1645
|
"INSERT_CODE_BLOCK_COMMAND"
|
|
480
|
-
),
|
|
1646
|
+
), ct = Y(
|
|
481
1647
|
"SET_CODE_LANGUAGE_COMMAND"
|
|
482
1648
|
);
|
|
483
|
-
function
|
|
484
|
-
const [
|
|
485
|
-
|
|
486
|
-
}, []),
|
|
487
|
-
const
|
|
488
|
-
return !!(
|
|
489
|
-
}, []),
|
|
490
|
-
const
|
|
491
|
-
return
|
|
492
|
-
}, [
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
}, [
|
|
496
|
-
return
|
|
497
|
-
|
|
1649
|
+
function Kn() {
|
|
1650
|
+
const [t, a] = O(null), [e, n] = O(null), [i, r] = O(!1), [o, s] = O(!1), [u] = M(), m = de(() => {
|
|
1651
|
+
a(null), n(null);
|
|
1652
|
+
}, []), A = de(() => {
|
|
1653
|
+
const F = document.getElementById("code-highlight-menu"), N = document.activeElement;
|
|
1654
|
+
return !!(F && N && (F === N || F.contains(N)));
|
|
1655
|
+
}, []), T = de(() => {
|
|
1656
|
+
const F = A();
|
|
1657
|
+
return s(F), F;
|
|
1658
|
+
}, [A]), S = de(() => {
|
|
1659
|
+
const F = T();
|
|
1660
|
+
r(!1), F || m();
|
|
1661
|
+
}, [m, T]);
|
|
1662
|
+
return C(() => u.registerCommand(
|
|
1663
|
+
j,
|
|
498
1664
|
() => {
|
|
499
|
-
const
|
|
500
|
-
if (
|
|
501
|
-
const
|
|
502
|
-
|
|
1665
|
+
const N = T(), p = u.getRootElement();
|
|
1666
|
+
if (p) {
|
|
1667
|
+
const c = p === document.activeElement || p.contains(document.activeElement);
|
|
1668
|
+
r((d) => d === c ? d : c);
|
|
503
1669
|
}
|
|
504
|
-
const
|
|
505
|
-
if (!
|
|
506
|
-
return
|
|
507
|
-
const
|
|
508
|
-
if (
|
|
509
|
-
const
|
|
510
|
-
|
|
1670
|
+
const y = L();
|
|
1671
|
+
if (!w(y))
|
|
1672
|
+
return N || m(), !1;
|
|
1673
|
+
const E = ve(y), l = I(E, pe);
|
|
1674
|
+
if (l) {
|
|
1675
|
+
const d = u.getElementByKey(l.getKey()).getBoundingClientRect(), g = d.right, f = d.top + window.scrollY;
|
|
1676
|
+
a({ x: g, y: f }), n(l.getKey());
|
|
511
1677
|
} else
|
|
512
|
-
|
|
1678
|
+
N || m();
|
|
513
1679
|
return !1;
|
|
514
1680
|
},
|
|
515
|
-
|
|
516
|
-
), [
|
|
517
|
-
|
|
518
|
-
() => (setTimeout(
|
|
519
|
-
|
|
520
|
-
), [
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
},
|
|
524
|
-
return
|
|
525
|
-
|
|
1681
|
+
$
|
|
1682
|
+
), [u, T, m]), C(() => u.registerCommand(
|
|
1683
|
+
be,
|
|
1684
|
+
() => (setTimeout(S, 0), !1),
|
|
1685
|
+
$
|
|
1686
|
+
), [u, S]), C(() => {
|
|
1687
|
+
const F = () => {
|
|
1688
|
+
r(!0), s(!1);
|
|
1689
|
+
}, N = () => setTimeout(S, 0);
|
|
1690
|
+
return u.registerRootListener((p, y) => {
|
|
1691
|
+
p && (p.addEventListener("focus", F), p.addEventListener("blur", N)), y && (y.removeEventListener("focus", F), y.removeEventListener("blur", N));
|
|
526
1692
|
});
|
|
527
|
-
}, [
|
|
528
|
-
/* @__PURE__ */
|
|
529
|
-
|
|
1693
|
+
}, [u, S]), t && (i || o) && Ie(
|
|
1694
|
+
/* @__PURE__ */ h(Wn, { codeBlockCoords: t, codeNodeKey: e }),
|
|
1695
|
+
Gn
|
|
530
1696
|
);
|
|
531
1697
|
}
|
|
532
|
-
function
|
|
533
|
-
const [
|
|
534
|
-
return
|
|
535
|
-
if (!
|
|
1698
|
+
function qn() {
|
|
1699
|
+
const [t] = M();
|
|
1700
|
+
return C(() => mn(t), [t]), C(() => t.registerNodeTransform(ie, (e) => {
|
|
1701
|
+
if (!e.isSimpleText())
|
|
536
1702
|
return;
|
|
537
|
-
const n =
|
|
1703
|
+
const n = e.getTextContent();
|
|
538
1704
|
if (n.startsWith("``` ")) {
|
|
539
|
-
const i =
|
|
540
|
-
if (
|
|
1705
|
+
const i = e.getPreviousSibling(), r = I(e, V), o = r !== null && r.getChildrenSize() === 1, s = te(i);
|
|
1706
|
+
if (o || s) {
|
|
541
1707
|
if (n.length > 4)
|
|
542
1708
|
return;
|
|
543
|
-
const
|
|
544
|
-
|
|
545
|
-
const
|
|
546
|
-
|
|
1709
|
+
const u = qe();
|
|
1710
|
+
e.replace(u), u.select();
|
|
1711
|
+
const m = u.getNextSibling();
|
|
1712
|
+
te(m) && m.remove();
|
|
547
1713
|
return;
|
|
548
1714
|
}
|
|
549
1715
|
}
|
|
550
|
-
}), [
|
|
551
|
-
|
|
1716
|
+
}), [t]), C(() => t.registerCommand(
|
|
1717
|
+
lt,
|
|
552
1718
|
() => {
|
|
553
|
-
const
|
|
554
|
-
if (
|
|
555
|
-
const n =
|
|
556
|
-
return
|
|
557
|
-
|
|
1719
|
+
const e = he();
|
|
1720
|
+
if (w(e)) {
|
|
1721
|
+
const n = qe();
|
|
1722
|
+
return e.insertNodes([n]), n.selectStart(), setTimeout(() => {
|
|
1723
|
+
t.focus();
|
|
558
1724
|
}, 0), !0;
|
|
559
1725
|
}
|
|
560
1726
|
return !1;
|
|
561
1727
|
},
|
|
562
|
-
|
|
563
|
-
), [
|
|
564
|
-
|
|
565
|
-
(
|
|
566
|
-
const [n, i] =
|
|
567
|
-
return
|
|
1728
|
+
$
|
|
1729
|
+
), [t]), C(() => t.registerCommand(
|
|
1730
|
+
ct,
|
|
1731
|
+
(e) => {
|
|
1732
|
+
const [n, i] = e, r = oe(n);
|
|
1733
|
+
return pe(r) ? (r.setLanguage(i), !0) : !1;
|
|
568
1734
|
},
|
|
569
|
-
|
|
570
|
-
), [
|
|
571
|
-
|
|
572
|
-
(
|
|
573
|
-
const n =
|
|
574
|
-
if (!
|
|
1735
|
+
$
|
|
1736
|
+
), [t]), C(() => t.registerCommand(
|
|
1737
|
+
Le,
|
|
1738
|
+
(e) => {
|
|
1739
|
+
const n = L();
|
|
1740
|
+
if (!w(n) || !n.isCollapsed())
|
|
575
1741
|
return !1;
|
|
576
|
-
const i = n.anchor.getNode(),
|
|
577
|
-
return
|
|
1742
|
+
const i = n.anchor.getNode(), r = I(i, pe);
|
|
1743
|
+
return r && n.anchor.offset === 0 && r.getTextContent() === "" ? (r.remove(), !0) : !1;
|
|
578
1744
|
},
|
|
579
|
-
|
|
580
|
-
), [
|
|
1745
|
+
$
|
|
1746
|
+
), [t]), null;
|
|
581
1747
|
}
|
|
582
|
-
function
|
|
583
|
-
return /* @__PURE__ */
|
|
584
|
-
/* @__PURE__ */
|
|
585
|
-
/* @__PURE__ */
|
|
1748
|
+
function Un() {
|
|
1749
|
+
return /* @__PURE__ */ D(Xe, { children: [
|
|
1750
|
+
/* @__PURE__ */ h(qn, {}),
|
|
1751
|
+
/* @__PURE__ */ h(Kn, {})
|
|
586
1752
|
] });
|
|
587
1753
|
}
|
|
588
|
-
const
|
|
1754
|
+
const ut = Y(
|
|
589
1755
|
"INSERT_HORIZONTAL_DIVIDER_COMMAND"
|
|
590
1756
|
);
|
|
591
|
-
function
|
|
592
|
-
const [
|
|
593
|
-
return
|
|
594
|
-
if (!
|
|
1757
|
+
function jn() {
|
|
1758
|
+
const [t] = M();
|
|
1759
|
+
return C(() => {
|
|
1760
|
+
if (!t.hasNodes([cn]))
|
|
595
1761
|
throw new Error("HorizontalDividerNode not registered on editor");
|
|
596
|
-
return
|
|
597
|
-
|
|
1762
|
+
return t.registerCommand(
|
|
1763
|
+
ut,
|
|
598
1764
|
() => {
|
|
599
|
-
const
|
|
600
|
-
if (
|
|
601
|
-
const n =
|
|
602
|
-
|
|
1765
|
+
const e = he();
|
|
1766
|
+
if (w(e)) {
|
|
1767
|
+
const n = un();
|
|
1768
|
+
e.insertNodes([n]);
|
|
603
1769
|
let i = n.getNextSibling() || n.getParent().getNextSibling();
|
|
604
|
-
return i || (i =
|
|
605
|
-
|
|
1770
|
+
return i || (i = re(), n.insertAfter(i)), i.selectStart(), setTimeout(() => {
|
|
1771
|
+
t.focus();
|
|
606
1772
|
}, 0), !0;
|
|
607
1773
|
}
|
|
608
1774
|
return !1;
|
|
609
1775
|
},
|
|
610
|
-
|
|
1776
|
+
$
|
|
611
1777
|
);
|
|
612
|
-
}, [
|
|
1778
|
+
}, [t]), null;
|
|
613
1779
|
}
|
|
614
|
-
const
|
|
615
|
-
function
|
|
616
|
-
return
|
|
1780
|
+
const dt = Y("INSERT_IMAGE_COMMAND"), Ze = "selected";
|
|
1781
|
+
function Yn(t) {
|
|
1782
|
+
return t && t.type && t.type.startsWith("image/");
|
|
617
1783
|
}
|
|
618
|
-
function
|
|
619
|
-
const [
|
|
620
|
-
return
|
|
621
|
-
if (!
|
|
1784
|
+
function Zn() {
|
|
1785
|
+
const [t] = M(), a = se(null);
|
|
1786
|
+
return C(() => {
|
|
1787
|
+
if (!t.hasNode(Ge))
|
|
622
1788
|
throw new Error("ImagePlugin: ImageNode not registered on editor");
|
|
623
|
-
return
|
|
624
|
-
|
|
1789
|
+
return t.registerCommand(
|
|
1790
|
+
dt,
|
|
625
1791
|
(n) => {
|
|
626
|
-
const i = n,
|
|
627
|
-
if (
|
|
628
|
-
const
|
|
629
|
-
|
|
630
|
-
let
|
|
631
|
-
return
|
|
1792
|
+
const i = n, r = he();
|
|
1793
|
+
if (w(r)) {
|
|
1794
|
+
const o = Ke(i);
|
|
1795
|
+
r.insertNodes([o]);
|
|
1796
|
+
let s = o.getNextSibling() || o.getParent().getNextSibling();
|
|
1797
|
+
return s || (s = re(), o.insertAfter(s)), o.select(), !0;
|
|
632
1798
|
}
|
|
633
1799
|
return !1;
|
|
634
1800
|
},
|
|
635
|
-
|
|
1801
|
+
$
|
|
636
1802
|
);
|
|
637
|
-
}, [
|
|
638
|
-
|
|
1803
|
+
}, [t]), C(() => t.registerCommand(
|
|
1804
|
+
j,
|
|
639
1805
|
() => {
|
|
640
|
-
|
|
641
|
-
const n =
|
|
642
|
-
if (
|
|
1806
|
+
a.current && (a.current.classList.remove(Ze), a.current = null);
|
|
1807
|
+
const n = L();
|
|
1808
|
+
if (we(n) && n.getNodes().length === 1) {
|
|
643
1809
|
const i = n.getNodes()[0];
|
|
644
|
-
if (
|
|
645
|
-
const
|
|
646
|
-
|
|
1810
|
+
if (dn(i)) {
|
|
1811
|
+
const r = t.getElementByKey(i.getKey());
|
|
1812
|
+
r.classList.add(Ze), a.current = r;
|
|
647
1813
|
}
|
|
648
1814
|
}
|
|
649
1815
|
return !1;
|
|
650
1816
|
},
|
|
651
|
-
|
|
652
|
-
), [
|
|
653
|
-
|
|
1817
|
+
Ve
|
|
1818
|
+
), [t]), C(() => t.registerCommand(
|
|
1819
|
+
ke,
|
|
654
1820
|
(n) => {
|
|
655
1821
|
const i = n.clipboardData;
|
|
656
1822
|
if (!i)
|
|
657
1823
|
return !1;
|
|
658
|
-
const
|
|
659
|
-
if (
|
|
1824
|
+
const o = Array.from(i.files).filter(Yn);
|
|
1825
|
+
if (o.length === 1) {
|
|
660
1826
|
n.preventDefault();
|
|
661
|
-
const
|
|
662
|
-
if (!
|
|
1827
|
+
const s = o[0], u = L() || he();
|
|
1828
|
+
if (!w(u))
|
|
663
1829
|
return !1;
|
|
664
|
-
const
|
|
665
|
-
|
|
666
|
-
let
|
|
667
|
-
return
|
|
1830
|
+
const m = URL.createObjectURL(s), A = Ke(m);
|
|
1831
|
+
u.insertNodes([A]);
|
|
1832
|
+
let T = A.getNextSibling() || A.getParent().getNextSibling();
|
|
1833
|
+
return T || (T = re(), A.insertAfter(T)), A.select(), !0;
|
|
668
1834
|
}
|
|
669
1835
|
return !1;
|
|
670
1836
|
},
|
|
671
|
-
|
|
672
|
-
), [
|
|
673
|
-
/* @__PURE__ */
|
|
674
|
-
|
|
1837
|
+
$
|
|
1838
|
+
), [t]), // Make the Image selectable
|
|
1839
|
+
/* @__PURE__ */ h(
|
|
1840
|
+
Oe,
|
|
675
1841
|
{
|
|
676
|
-
nodeType:
|
|
1842
|
+
nodeType: Ge,
|
|
677
1843
|
eventType: "click",
|
|
678
|
-
eventListener: (
|
|
679
|
-
|
|
1844
|
+
eventListener: (e, n, i) => {
|
|
1845
|
+
oe(i).select();
|
|
680
1846
|
}
|
|
681
1847
|
}
|
|
682
1848
|
);
|
|
683
1849
|
}
|
|
684
|
-
const
|
|
685
|
-
function
|
|
686
|
-
const [
|
|
687
|
-
return /* @__PURE__ */
|
|
688
|
-
/* @__PURE__ */
|
|
689
|
-
|
|
1850
|
+
const ge = 24;
|
|
1851
|
+
function Qn() {
|
|
1852
|
+
const [t] = M();
|
|
1853
|
+
return /* @__PURE__ */ h(Me, { "aria-label": "Block toolbar", id: "block-toolbar", children: /* @__PURE__ */ D(ne, { "aria-label": "Media", children: [
|
|
1854
|
+
/* @__PURE__ */ h(
|
|
1855
|
+
zt,
|
|
690
1856
|
{
|
|
691
1857
|
acceptedFileTypes: ["image/png", "image/jpeg", "image/gif"],
|
|
692
|
-
onSelect: (
|
|
693
|
-
if (!
|
|
1858
|
+
onSelect: (e) => {
|
|
1859
|
+
if (!e || e.length === 0)
|
|
694
1860
|
return;
|
|
695
|
-
const n =
|
|
1861
|
+
const n = e[0];
|
|
696
1862
|
if (!n.type.startsWith("image/")) {
|
|
697
1863
|
alert("Please select an image file.");
|
|
698
1864
|
return;
|
|
699
1865
|
}
|
|
700
1866
|
const i = new FileReader();
|
|
701
|
-
i.onload = (
|
|
702
|
-
var
|
|
703
|
-
const
|
|
704
|
-
typeof
|
|
705
|
-
}, i.onerror = (
|
|
706
|
-
console.error("Error reading file:",
|
|
1867
|
+
i.onload = (r) => {
|
|
1868
|
+
var s;
|
|
1869
|
+
const o = (s = r.target) == null ? void 0 : s.result;
|
|
1870
|
+
typeof o == "string" ? t.dispatchCommand(dt, o) : alert("Failed to read file as Data URL.");
|
|
1871
|
+
}, i.onerror = (r) => {
|
|
1872
|
+
console.error("Error reading file:", r), alert("Error reading file.");
|
|
707
1873
|
}, i.readAsDataURL(n);
|
|
708
1874
|
},
|
|
709
1875
|
allowsMultiple: !1,
|
|
710
|
-
children: /* @__PURE__ */
|
|
1876
|
+
children: /* @__PURE__ */ h(U, { "aria-label": "image", children: /* @__PURE__ */ h(Vt, { size: ge }) })
|
|
711
1877
|
}
|
|
712
1878
|
),
|
|
713
|
-
/* @__PURE__ */
|
|
714
|
-
|
|
1879
|
+
/* @__PURE__ */ h(
|
|
1880
|
+
U,
|
|
715
1881
|
{
|
|
716
1882
|
"aria-label": "code block",
|
|
717
1883
|
onPress: () => {
|
|
718
|
-
|
|
1884
|
+
t.dispatchCommand(lt, void 0);
|
|
719
1885
|
},
|
|
720
|
-
children: /* @__PURE__ */
|
|
1886
|
+
children: /* @__PURE__ */ h(Jt, { size: ge })
|
|
721
1887
|
}
|
|
722
1888
|
),
|
|
723
|
-
/* @__PURE__ */
|
|
724
|
-
|
|
1889
|
+
/* @__PURE__ */ h(
|
|
1890
|
+
U,
|
|
725
1891
|
{
|
|
726
1892
|
"aria-label": "horizontal divider",
|
|
727
1893
|
onPress: () => {
|
|
728
|
-
|
|
729
|
-
|
|
1894
|
+
t.dispatchCommand(
|
|
1895
|
+
ut,
|
|
730
1896
|
void 0
|
|
731
1897
|
);
|
|
732
1898
|
},
|
|
733
|
-
children: /* @__PURE__ */
|
|
1899
|
+
children: /* @__PURE__ */ h(en, { size: ge })
|
|
734
1900
|
}
|
|
735
1901
|
)
|
|
736
1902
|
] }) });
|
|
737
1903
|
}
|
|
738
|
-
function
|
|
739
|
-
selectionRectCoords:
|
|
740
|
-
TOOLBAR_OFFSET:
|
|
741
|
-
toolbarTriggerId:
|
|
1904
|
+
function Xn({
|
|
1905
|
+
selectionRectCoords: t,
|
|
1906
|
+
TOOLBAR_OFFSET: a,
|
|
1907
|
+
toolbarTriggerId: e,
|
|
742
1908
|
toolbarPopoverId: n
|
|
743
1909
|
}) {
|
|
744
|
-
const [i,
|
|
745
|
-
x,
|
|
746
|
-
y:
|
|
747
|
-
}),
|
|
748
|
-
return
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
1910
|
+
const [i, r] = O({
|
|
1911
|
+
x: B,
|
|
1912
|
+
y: B
|
|
1913
|
+
}), o = se(null);
|
|
1914
|
+
return C(() => {
|
|
1915
|
+
r(
|
|
1916
|
+
xn(
|
|
1917
|
+
t,
|
|
1918
|
+
o,
|
|
1919
|
+
a
|
|
754
1920
|
)
|
|
755
1921
|
);
|
|
756
|
-
}, [
|
|
757
|
-
/* @__PURE__ */
|
|
758
|
-
|
|
1922
|
+
}, [t]), /* @__PURE__ */ D(Rt, { children: [
|
|
1923
|
+
/* @__PURE__ */ h(
|
|
1924
|
+
U,
|
|
759
1925
|
{
|
|
760
1926
|
"aria-label": "Block toolbar trigger",
|
|
761
1927
|
className: "block-toolbar-trigger",
|
|
762
|
-
id:
|
|
763
|
-
ref:
|
|
1928
|
+
id: e,
|
|
1929
|
+
ref: o,
|
|
764
1930
|
style: {
|
|
765
1931
|
position: "absolute",
|
|
766
1932
|
top: i.y,
|
|
767
1933
|
left: i.x
|
|
768
1934
|
},
|
|
769
|
-
children: /* @__PURE__ */
|
|
1935
|
+
children: /* @__PURE__ */ h(Xt, { size: ge })
|
|
770
1936
|
}
|
|
771
1937
|
),
|
|
772
|
-
/* @__PURE__ */
|
|
773
|
-
|
|
1938
|
+
/* @__PURE__ */ h(
|
|
1939
|
+
tt,
|
|
774
1940
|
{
|
|
775
1941
|
className: "block-toolbar-popover",
|
|
776
1942
|
id: n,
|
|
777
1943
|
placement: "end",
|
|
778
1944
|
shouldFlip: !1,
|
|
779
|
-
offset:
|
|
780
|
-
children: /* @__PURE__ */
|
|
1945
|
+
offset: a,
|
|
1946
|
+
children: /* @__PURE__ */ h(Qn, {})
|
|
781
1947
|
}
|
|
782
1948
|
)
|
|
783
1949
|
] });
|
|
784
1950
|
}
|
|
785
|
-
const
|
|
786
|
-
function
|
|
787
|
-
const [
|
|
1951
|
+
const Vn = document.body;
|
|
1952
|
+
function Jn({ toolbarGap: t }) {
|
|
1953
|
+
const [a, e] = O(null), [n] = M(), [i, r] = O(!1), [o, s] = O(!1), u = se(Math.random().toString(36).substring(2, 9)), m = `block-toolbar-trigger-${u.current}`, A = `block-toolbar-popover-${u.current}`, T = () => r(!0), S = (F) => {
|
|
788
1954
|
setTimeout(() => {
|
|
789
|
-
const
|
|
790
|
-
|
|
1955
|
+
const N = document.getElementById(m);
|
|
1956
|
+
N && (N === document.activeElement || N.contains(document.activeElement) || N.contains(F.relatedTarget)) || r(!1);
|
|
791
1957
|
}, 10);
|
|
792
1958
|
};
|
|
793
|
-
return
|
|
794
|
-
const
|
|
795
|
-
const
|
|
796
|
-
|
|
797
|
-
},
|
|
798
|
-
return
|
|
1959
|
+
return C(() => {
|
|
1960
|
+
const F = () => {
|
|
1961
|
+
const p = !!document.getElementById(A);
|
|
1962
|
+
s(p);
|
|
1963
|
+
}, N = new MutationObserver(F);
|
|
1964
|
+
return N.observe(document.body, {
|
|
799
1965
|
childList: !0,
|
|
800
1966
|
subtree: !0
|
|
801
|
-
}),
|
|
802
|
-
}, []),
|
|
803
|
-
(
|
|
804
|
-
|
|
1967
|
+
}), F(), () => N.disconnect();
|
|
1968
|
+
}, []), C(() => n.registerRootListener(
|
|
1969
|
+
(N, p) => {
|
|
1970
|
+
N && (N.addEventListener("focus", T), N.addEventListener("blur", S)), p && (p.removeEventListener("focus", T), p.removeEventListener("blur", S));
|
|
805
1971
|
}
|
|
806
|
-
), [n]),
|
|
807
|
-
|
|
1972
|
+
), [n]), C(() => n.registerCommand(
|
|
1973
|
+
j,
|
|
808
1974
|
() => {
|
|
809
|
-
const
|
|
810
|
-
if (
|
|
811
|
-
const
|
|
812
|
-
|
|
1975
|
+
const N = n.getRootElement();
|
|
1976
|
+
if (N) {
|
|
1977
|
+
const E = N === document.activeElement || N.contains(document.activeElement);
|
|
1978
|
+
E !== i && r(E);
|
|
813
1979
|
}
|
|
814
|
-
const
|
|
815
|
-
if (!
|
|
816
|
-
return
|
|
817
|
-
const
|
|
818
|
-
if (
|
|
819
|
-
const
|
|
820
|
-
|
|
1980
|
+
const p = L();
|
|
1981
|
+
if (!w(p) || !p.isCollapsed())
|
|
1982
|
+
return e(null), !1;
|
|
1983
|
+
const y = ve(p);
|
|
1984
|
+
if (V(y) && y.getTextContent() === "") {
|
|
1985
|
+
const l = n.getElementByKey(y.getKey()).getBoundingClientRect(), c = l.left, d = l.top + l.height / 2 + window.scrollY;
|
|
1986
|
+
e({ x: c, y: d });
|
|
821
1987
|
} else
|
|
822
|
-
|
|
1988
|
+
e(null);
|
|
823
1989
|
return !1;
|
|
824
1990
|
},
|
|
825
|
-
|
|
826
|
-
), [n]),
|
|
827
|
-
/* @__PURE__ */
|
|
828
|
-
|
|
1991
|
+
$
|
|
1992
|
+
), [n]), a && (i || o) && Ie(
|
|
1993
|
+
/* @__PURE__ */ h(
|
|
1994
|
+
Xn,
|
|
829
1995
|
{
|
|
830
|
-
selectionRectCoords:
|
|
831
|
-
TOOLBAR_OFFSET:
|
|
832
|
-
toolbarTriggerId:
|
|
833
|
-
toolbarPopoverId:
|
|
1996
|
+
selectionRectCoords: a,
|
|
1997
|
+
TOOLBAR_OFFSET: t,
|
|
1998
|
+
toolbarTriggerId: m,
|
|
1999
|
+
toolbarPopoverId: A
|
|
834
2000
|
}
|
|
835
2001
|
),
|
|
836
|
-
|
|
2002
|
+
Vn
|
|
837
2003
|
);
|
|
838
2004
|
}
|
|
839
|
-
const
|
|
2005
|
+
const er = [
|
|
840
2006
|
["$", "$"],
|
|
841
2007
|
["\\(", "\\)"]
|
|
842
|
-
],
|
|
2008
|
+
], tr = [
|
|
843
2009
|
["$$", "$$"],
|
|
844
2010
|
["\\[", "\\]"]
|
|
845
|
-
],
|
|
846
|
-
let
|
|
847
|
-
for (const [n, i] of
|
|
848
|
-
const
|
|
849
|
-
`(.*?)(${
|
|
2011
|
+
], Qe = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), gt = (t, a) => {
|
|
2012
|
+
let e = null;
|
|
2013
|
+
for (const [n, i] of a) {
|
|
2014
|
+
const o = new RegExp(
|
|
2015
|
+
`(.*?)(${Qe(n)})(.*?)(${Qe(i)})`,
|
|
850
2016
|
"g"
|
|
851
|
-
).exec(
|
|
852
|
-
if (
|
|
853
|
-
const
|
|
854
|
-
if (
|
|
855
|
-
const
|
|
856
|
-
(!
|
|
857
|
-
start:
|
|
858
|
-
end:
|
|
859
|
-
content: n +
|
|
2017
|
+
).exec(t);
|
|
2018
|
+
if (o) {
|
|
2019
|
+
const s = o[3];
|
|
2020
|
+
if (s && s.trim() !== "") {
|
|
2021
|
+
const u = o.index + o[1].length, m = o.index + o[0].length;
|
|
2022
|
+
(!e || u < e.start) && (e = {
|
|
2023
|
+
start: u,
|
|
2024
|
+
end: m,
|
|
2025
|
+
content: n + s + i
|
|
860
2026
|
});
|
|
861
2027
|
}
|
|
862
2028
|
}
|
|
863
2029
|
}
|
|
864
|
-
return
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
2030
|
+
return e;
|
|
2031
|
+
}, ft = (t, a) => {
|
|
2032
|
+
if (!w(t))
|
|
2033
|
+
return null;
|
|
2034
|
+
const e = t.anchor.getNode(), n = t.focus.getNode(), i = a(e) ? e : I(e, a), r = a(n) ? n : I(n, a);
|
|
2035
|
+
return !i || !r ? null : i.getKey() === r.getKey() ? i : null;
|
|
2036
|
+
}, ht = (t) => t.getData("text/plain") || t.getData("text") || t.getData("text/uri-list");
|
|
2037
|
+
function nr() {
|
|
2038
|
+
const [t] = M();
|
|
2039
|
+
return C(() => {
|
|
2040
|
+
if (!t.hasNodes([me, gn]))
|
|
870
2041
|
throw new Error(
|
|
871
2042
|
"MathInlinePlugin: MathNode or MathHighlightNodeInline not registered on editor"
|
|
872
2043
|
);
|
|
873
|
-
}, [
|
|
874
|
-
if (!
|
|
2044
|
+
}, [t]), C(() => t.registerNodeTransform(ie, (e) => {
|
|
2045
|
+
if (!e.isSimpleText() || Q(e) || I(e, G))
|
|
875
2046
|
return;
|
|
876
|
-
const n =
|
|
2047
|
+
const n = e.getTextContent(), i = gt(n, er);
|
|
877
2048
|
if (i) {
|
|
878
|
-
const { start:
|
|
879
|
-
let
|
|
880
|
-
const
|
|
881
|
-
return
|
|
2049
|
+
const { start: r, end: o, content: s } = i;
|
|
2050
|
+
let u;
|
|
2051
|
+
const m = q(s, !0);
|
|
2052
|
+
return r === 0 ? ([u] = e.splitText(o), u.insertBefore(m), u.remove()) : ([, u] = e.splitText(r, o), u.replace(m)), m;
|
|
882
2053
|
}
|
|
883
|
-
}), [
|
|
884
|
-
|
|
2054
|
+
}), [t]), C(() => t.registerCommand(
|
|
2055
|
+
j,
|
|
885
2056
|
() => {
|
|
886
|
-
const
|
|
887
|
-
if (
|
|
888
|
-
const
|
|
889
|
-
if (
|
|
890
|
-
const
|
|
891
|
-
if (
|
|
892
|
-
let
|
|
893
|
-
|
|
894
|
-
const
|
|
895
|
-
return
|
|
2057
|
+
const e = L(), n = /* @__PURE__ */ new Set();
|
|
2058
|
+
if (we(e)) {
|
|
2059
|
+
const o = e.getNodes();
|
|
2060
|
+
if (o.length === 1 && X(o[0])) {
|
|
2061
|
+
const s = o[0];
|
|
2062
|
+
if (s.isInline()) {
|
|
2063
|
+
let u = s.getEquation();
|
|
2064
|
+
u.startsWith("$") && u.endsWith("$") ? u = u.slice(1, -1) : u.startsWith("\\(") && u.endsWith("\\)") && (u = u.slice(2, -2));
|
|
2065
|
+
const m = Ee(u);
|
|
2066
|
+
return s.replace(m), m.select(), !0;
|
|
896
2067
|
}
|
|
897
2068
|
}
|
|
898
|
-
} else
|
|
899
|
-
return
|
|
900
|
-
if (
|
|
901
|
-
let
|
|
902
|
-
if (!
|
|
903
|
-
|
|
2069
|
+
} else w(e) && e.getNodes().forEach((o) => n.add(o.getKey()));
|
|
2070
|
+
return fe().getAllTextNodes().forEach((o) => {
|
|
2071
|
+
if (Q(o) && !n.has(o.getKey())) {
|
|
2072
|
+
let s = o.getTextContent();
|
|
2073
|
+
if (!s) {
|
|
2074
|
+
o.remove();
|
|
904
2075
|
return;
|
|
905
2076
|
}
|
|
906
|
-
let
|
|
907
|
-
|
|
908
|
-
const
|
|
909
|
-
|
|
2077
|
+
let u = !1;
|
|
2078
|
+
s.startsWith("$") && s.endsWith("$") && s.length >= 2 && (s = s.slice(1, -1), u = !0);
|
|
2079
|
+
const m = u ? q(`$$${s}$$`, !1) : q(`$${s}$`, !0);
|
|
2080
|
+
o.replace(m);
|
|
910
2081
|
}
|
|
911
2082
|
}), !1;
|
|
912
2083
|
},
|
|
913
|
-
|
|
914
|
-
), [
|
|
915
|
-
|
|
916
|
-
() => (
|
|
917
|
-
|
|
918
|
-
if (
|
|
2084
|
+
$
|
|
2085
|
+
), [t]), C(() => t.registerCommand(
|
|
2086
|
+
be,
|
|
2087
|
+
() => (t.update(() => {
|
|
2088
|
+
fe().getAllTextNodes().forEach((n) => {
|
|
2089
|
+
if (Q(n)) {
|
|
919
2090
|
let i = n.getTextContent();
|
|
920
2091
|
if (!i) {
|
|
921
2092
|
n.remove();
|
|
922
2093
|
return;
|
|
923
2094
|
}
|
|
924
|
-
let
|
|
925
|
-
i.startsWith("$") && i.endsWith("$") && i.length >= 2 && (i = i.slice(1, -1),
|
|
926
|
-
const
|
|
927
|
-
n.replace(
|
|
2095
|
+
let r = !1;
|
|
2096
|
+
i.startsWith("$") && i.endsWith("$") && i.length >= 2 && (i = i.slice(1, -1), r = !0);
|
|
2097
|
+
const o = r ? q(`$$${i}$$`, !1) : q(`$${i}$`, !0);
|
|
2098
|
+
n.replace(o), Je(null);
|
|
928
2099
|
}
|
|
929
2100
|
});
|
|
930
2101
|
}), !1),
|
|
931
|
-
|
|
932
|
-
), [
|
|
933
|
-
|
|
934
|
-
(
|
|
935
|
-
const
|
|
936
|
-
if (!
|
|
2102
|
+
$
|
|
2103
|
+
), [t]), C(() => t.registerCommand(
|
|
2104
|
+
St,
|
|
2105
|
+
(a) => {
|
|
2106
|
+
const e = L();
|
|
2107
|
+
if (!w(e) || !e.isCollapsed())
|
|
937
2108
|
return !1;
|
|
938
|
-
const n =
|
|
939
|
-
if (
|
|
940
|
-
let
|
|
941
|
-
|
|
942
|
-
const
|
|
943
|
-
return n.replace(
|
|
2109
|
+
const n = Fe(e.anchor, !1);
|
|
2110
|
+
if (X(n) && n.isInline()) {
|
|
2111
|
+
let r = n.getEquation();
|
|
2112
|
+
r.startsWith("$") && r.endsWith("$") ? r = r.slice(1, -1) : r.startsWith("\\(") && r.endsWith("\\)") && (r = r.slice(2, -2));
|
|
2113
|
+
const o = Ee(r);
|
|
2114
|
+
return n.replace(o), o.select(0, 0), !0;
|
|
944
2115
|
}
|
|
945
2116
|
return !1;
|
|
946
2117
|
},
|
|
947
|
-
|
|
948
|
-
), [
|
|
949
|
-
|
|
950
|
-
(
|
|
951
|
-
const
|
|
952
|
-
if (!
|
|
2118
|
+
$
|
|
2119
|
+
), [t]), C(() => t.registerCommand(
|
|
2120
|
+
Le,
|
|
2121
|
+
(a) => {
|
|
2122
|
+
const e = L();
|
|
2123
|
+
if (!w(e) || !e.isCollapsed())
|
|
953
2124
|
return !1;
|
|
954
|
-
const n =
|
|
955
|
-
if (
|
|
956
|
-
let
|
|
957
|
-
|
|
958
|
-
const
|
|
959
|
-
return n.replace(
|
|
2125
|
+
const n = Fe(e.anchor, !0);
|
|
2126
|
+
if (X(n) && n.isInline()) {
|
|
2127
|
+
let r = n.getEquation();
|
|
2128
|
+
r.startsWith("$") && r.endsWith("$") ? r = r.slice(1, -1) : r.startsWith("\\(") && r.endsWith("\\)") && (r = r.slice(2, -2));
|
|
2129
|
+
const o = Ee(r);
|
|
2130
|
+
return n.replace(o), o.select(), !0;
|
|
960
2131
|
}
|
|
961
2132
|
return !1;
|
|
962
2133
|
},
|
|
963
|
-
|
|
964
|
-
), [
|
|
965
|
-
|
|
2134
|
+
$
|
|
2135
|
+
), [t]), C(() => t.registerCommand(
|
|
2136
|
+
ke,
|
|
2137
|
+
(a) => {
|
|
2138
|
+
const e = a.clipboardData;
|
|
2139
|
+
if (!e)
|
|
2140
|
+
return !1;
|
|
2141
|
+
const n = L();
|
|
2142
|
+
if (!ft(
|
|
2143
|
+
n,
|
|
2144
|
+
Q
|
|
2145
|
+
))
|
|
2146
|
+
return !1;
|
|
2147
|
+
const r = ht(e);
|
|
2148
|
+
return r ? (a.preventDefault(), n.insertText(r), !0) : !1;
|
|
2149
|
+
},
|
|
2150
|
+
$
|
|
2151
|
+
), [t]), C(() => t.registerCommand(
|
|
2152
|
+
j,
|
|
966
2153
|
() => {
|
|
967
|
-
const
|
|
968
|
-
if (!
|
|
2154
|
+
const a = L();
|
|
2155
|
+
if (!w(a) || !a.isCollapsed())
|
|
969
2156
|
return !1;
|
|
970
|
-
const
|
|
971
|
-
return
|
|
2157
|
+
const e = a.anchor.getNode();
|
|
2158
|
+
return Q(e) && (e.getNextSibling() || e.insertAfter(Ft(" "))), !1;
|
|
972
2159
|
},
|
|
973
|
-
|
|
974
|
-
), [
|
|
975
|
-
/* @__PURE__ */
|
|
976
|
-
|
|
2160
|
+
$t
|
|
2161
|
+
), [t]), // Register click event for MathNode
|
|
2162
|
+
/* @__PURE__ */ h(
|
|
2163
|
+
Oe,
|
|
977
2164
|
{
|
|
978
|
-
nodeType:
|
|
2165
|
+
nodeType: me,
|
|
979
2166
|
eventType: "click",
|
|
980
|
-
eventListener: (
|
|
981
|
-
const i =
|
|
2167
|
+
eventListener: (a, e, n) => {
|
|
2168
|
+
const i = oe(n);
|
|
982
2169
|
i && i.isInline() && i.select();
|
|
983
2170
|
}
|
|
984
2171
|
}
|
|
985
2172
|
);
|
|
986
2173
|
}
|
|
987
|
-
function
|
|
988
|
-
const [
|
|
989
|
-
return
|
|
990
|
-
if (!
|
|
2174
|
+
function rr() {
|
|
2175
|
+
const [t] = M();
|
|
2176
|
+
return C(() => {
|
|
2177
|
+
if (!t.hasNodes([me, fn]))
|
|
991
2178
|
throw new Error(
|
|
992
2179
|
"MathBlockPlugin: MathNode or MathHighlightNodeBlock not registered on editor"
|
|
993
2180
|
);
|
|
994
|
-
}, [
|
|
995
|
-
if (!
|
|
2181
|
+
}, [t]), C(() => t.registerNodeTransform(ie, (e) => {
|
|
2182
|
+
if (!e.isSimpleText() || I(e, G))
|
|
996
2183
|
return;
|
|
997
|
-
const n =
|
|
2184
|
+
const n = e.getTextContent();
|
|
998
2185
|
if (n.startsWith("$$ ")) {
|
|
999
|
-
const
|
|
1000
|
-
if (
|
|
2186
|
+
const r = e.getPreviousSibling(), o = I(e, V), s = o !== null && o.getChildrenSize() === 1, u = te(r);
|
|
2187
|
+
if (s || u) {
|
|
1001
2188
|
if (n.length > 3)
|
|
1002
2189
|
return;
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1005
|
-
const
|
|
1006
|
-
|
|
2190
|
+
const m = Te("");
|
|
2191
|
+
e.replace(m), m.select();
|
|
2192
|
+
const A = m.getNextSibling();
|
|
2193
|
+
te(A) && A.remove();
|
|
1007
2194
|
return;
|
|
1008
2195
|
}
|
|
1009
2196
|
}
|
|
1010
|
-
const i =
|
|
2197
|
+
const i = gt(n, tr);
|
|
1011
2198
|
if (i) {
|
|
1012
|
-
const { start:
|
|
1013
|
-
let
|
|
1014
|
-
const
|
|
1015
|
-
return
|
|
2199
|
+
const { start: r, end: o, content: s } = i;
|
|
2200
|
+
let u;
|
|
2201
|
+
const m = q(s, !1);
|
|
2202
|
+
return r === 0 ? ([u] = e.splitText(o), u.insertBefore(m), u.remove()) : ([, u] = e.splitText(r, o), u.replace(m)), m;
|
|
1016
2203
|
}
|
|
1017
|
-
}), [
|
|
1018
|
-
|
|
2204
|
+
}), [t]), C(() => t.registerCommand(
|
|
2205
|
+
j,
|
|
1019
2206
|
() => {
|
|
1020
|
-
const
|
|
1021
|
-
if (
|
|
1022
|
-
const
|
|
1023
|
-
if (
|
|
1024
|
-
const
|
|
1025
|
-
if (!
|
|
1026
|
-
let
|
|
1027
|
-
(
|
|
1028
|
-
const
|
|
1029
|
-
return
|
|
2207
|
+
const e = L(), n = /* @__PURE__ */ new Set();
|
|
2208
|
+
if (we(e)) {
|
|
2209
|
+
const o = e.getNodes();
|
|
2210
|
+
if (o.length === 1 && X(o[0])) {
|
|
2211
|
+
const s = o[0];
|
|
2212
|
+
if (!s.isInline()) {
|
|
2213
|
+
let u = s.getEquation();
|
|
2214
|
+
(u.startsWith("$$") && u.endsWith("$$") || u.startsWith("\\[") && u.endsWith("\\]")) && (u = u.slice(2, -2));
|
|
2215
|
+
const m = Te(u);
|
|
2216
|
+
return s.replace(m), m.select(), !0;
|
|
1030
2217
|
}
|
|
1031
2218
|
}
|
|
1032
|
-
} else
|
|
1033
|
-
n.add(
|
|
1034
|
-
const
|
|
1035
|
-
|
|
2219
|
+
} else w(e) && e.getNodes().forEach((o) => {
|
|
2220
|
+
n.add(o.getKey());
|
|
2221
|
+
const s = I(o, G);
|
|
2222
|
+
s && n.add(s.getKey());
|
|
1036
2223
|
});
|
|
1037
|
-
const
|
|
1038
|
-
for (const [,
|
|
1039
|
-
if (
|
|
1040
|
-
const
|
|
1041
|
-
if (!
|
|
1042
|
-
|
|
2224
|
+
const r = t.getEditorState()._nodeMap;
|
|
2225
|
+
for (const [, o] of r)
|
|
2226
|
+
if (G(o) && o.isAttached() && !n.has(o.getKey())) {
|
|
2227
|
+
const s = o.getTextContent();
|
|
2228
|
+
if (!s) {
|
|
2229
|
+
o.remove();
|
|
1043
2230
|
continue;
|
|
1044
2231
|
}
|
|
1045
|
-
const
|
|
1046
|
-
|
|
2232
|
+
const u = q(`$$${s}$$`, !1);
|
|
2233
|
+
o.replace(u);
|
|
1047
2234
|
}
|
|
1048
2235
|
return !1;
|
|
1049
2236
|
},
|
|
1050
|
-
|
|
1051
|
-
), [
|
|
1052
|
-
|
|
1053
|
-
() => (
|
|
1054
|
-
const
|
|
1055
|
-
|
|
1056
|
-
if (
|
|
2237
|
+
$
|
|
2238
|
+
), [t]), C(() => t.registerCommand(
|
|
2239
|
+
be,
|
|
2240
|
+
() => (t.update(() => {
|
|
2241
|
+
const a = fe();
|
|
2242
|
+
Pt(a).forEach(({ node: n }) => {
|
|
2243
|
+
if (G(n)) {
|
|
1057
2244
|
const i = n.getTextContent();
|
|
1058
2245
|
if (!i) {
|
|
1059
2246
|
n.remove();
|
|
1060
2247
|
return;
|
|
1061
2248
|
}
|
|
1062
|
-
const
|
|
1063
|
-
n.replace(
|
|
2249
|
+
const r = q(`$$${i}$$`, !1);
|
|
2250
|
+
n.replace(r), Je(null);
|
|
1064
2251
|
}
|
|
1065
2252
|
});
|
|
1066
2253
|
}), !1),
|
|
1067
|
-
|
|
1068
|
-
), [
|
|
1069
|
-
|
|
2254
|
+
$
|
|
2255
|
+
), [t]), C(() => t.registerCommand(
|
|
2256
|
+
Lt,
|
|
1070
2257
|
() => {
|
|
1071
|
-
const
|
|
1072
|
-
if (!
|
|
2258
|
+
const e = L();
|
|
2259
|
+
if (!w(e))
|
|
1073
2260
|
return !1;
|
|
1074
|
-
const n =
|
|
2261
|
+
const n = e.getNodes()[0], i = I(
|
|
1075
2262
|
n,
|
|
1076
|
-
|
|
2263
|
+
G
|
|
1077
2264
|
);
|
|
1078
2265
|
if (!i)
|
|
1079
2266
|
return !1;
|
|
1080
|
-
const
|
|
1081
|
-
return
|
|
2267
|
+
const r = i.getLastChild();
|
|
2268
|
+
return e.isCollapsed() && (e.anchor.getNode().getKey() === i.getKey() && e.anchor.offset === 0 && i.getChildrenSize() === 0 || r && te(r) && e.anchor.getNode().getKey() === i.getKey() && e.anchor.offset === i.getChildrenSize() || r && wt(r) && e.anchor.getNode().getKey() === r.getKey() && e.anchor.offset === r.getTextContent().length) ? !1 : (e.insertLineBreak(), !0);
|
|
1082
2269
|
},
|
|
1083
|
-
|
|
1084
|
-
), [
|
|
1085
|
-
|
|
1086
|
-
(
|
|
1087
|
-
const
|
|
1088
|
-
if (!
|
|
2270
|
+
$
|
|
2271
|
+
), [t]), C(() => t.registerCommand(
|
|
2272
|
+
Le,
|
|
2273
|
+
(a) => {
|
|
2274
|
+
const e = L();
|
|
2275
|
+
if (!w(e) || !e.isCollapsed())
|
|
1089
2276
|
return !1;
|
|
1090
|
-
const n =
|
|
1091
|
-
if (
|
|
1092
|
-
let
|
|
1093
|
-
(
|
|
1094
|
-
const
|
|
1095
|
-
return n.replace(
|
|
2277
|
+
const n = Fe(e.anchor, !0);
|
|
2278
|
+
if (X(n) && !n.isInline()) {
|
|
2279
|
+
let r = n.getEquation();
|
|
2280
|
+
(r.startsWith("$$") && r.endsWith("$$") || r.startsWith("\\[") && r.endsWith("\\]")) && (r = r.slice(2, -2));
|
|
2281
|
+
const o = Te(r);
|
|
2282
|
+
return n.replace(o), o.select(), !0;
|
|
1096
2283
|
}
|
|
1097
2284
|
return !1;
|
|
1098
2285
|
},
|
|
1099
|
-
|
|
1100
|
-
), [
|
|
1101
|
-
|
|
2286
|
+
$
|
|
2287
|
+
), [t]), C(() => t.registerCommand(
|
|
2288
|
+
ke,
|
|
2289
|
+
(a) => {
|
|
2290
|
+
const e = a.clipboardData;
|
|
2291
|
+
if (!e)
|
|
2292
|
+
return !1;
|
|
2293
|
+
const n = L();
|
|
2294
|
+
if (!ft(
|
|
2295
|
+
n,
|
|
2296
|
+
G
|
|
2297
|
+
))
|
|
2298
|
+
return !1;
|
|
2299
|
+
const r = ht(e);
|
|
2300
|
+
return r ? (a.preventDefault(), n.insertRawText(r), !0) : !1;
|
|
2301
|
+
},
|
|
2302
|
+
$
|
|
2303
|
+
), [t]), /* @__PURE__ */ h(
|
|
2304
|
+
Oe,
|
|
1102
2305
|
{
|
|
1103
|
-
nodeType:
|
|
2306
|
+
nodeType: me,
|
|
1104
2307
|
eventType: "click",
|
|
1105
|
-
eventListener: (
|
|
1106
|
-
const i =
|
|
2308
|
+
eventListener: (a, e, n) => {
|
|
2309
|
+
const i = oe(n);
|
|
1107
2310
|
i && !i.isInline() && i.select();
|
|
1108
2311
|
}
|
|
1109
2312
|
}
|
|
1110
2313
|
);
|
|
1111
2314
|
}
|
|
1112
|
-
const
|
|
1113
|
-
function
|
|
1114
|
-
const [
|
|
1115
|
-
return
|
|
1116
|
-
|
|
1117
|
-
(
|
|
1118
|
-
const n =
|
|
1119
|
-
if (
|
|
1120
|
-
const i =
|
|
1121
|
-
|
|
2315
|
+
const ir = 3;
|
|
2316
|
+
function or() {
|
|
2317
|
+
const [t] = M();
|
|
2318
|
+
return C(() => t.registerNodeTransform(
|
|
2319
|
+
kt,
|
|
2320
|
+
(e) => {
|
|
2321
|
+
const n = e.getParent();
|
|
2322
|
+
if (ze(n)) {
|
|
2323
|
+
const i = It();
|
|
2324
|
+
e.replace(i), i.selectEnd();
|
|
1122
2325
|
}
|
|
1123
2326
|
}
|
|
1124
|
-
), [
|
|
1125
|
-
if (!I(
|
|
2327
|
+
), [t]), C(() => t.registerNodeTransform(ie, (e) => {
|
|
2328
|
+
if (!I(e, V) || I(e, V).getFirstDescendant() !== e)
|
|
1126
2329
|
return;
|
|
1127
|
-
const i =
|
|
1128
|
-
if (
|
|
1129
|
-
const
|
|
1130
|
-
|
|
2330
|
+
const i = L();
|
|
2331
|
+
if (w(i) && i.isCollapsed()) {
|
|
2332
|
+
const o = i.anchor.offset;
|
|
2333
|
+
e.getTextContent() === "1. " && o === 3 ? (We("number"), e.setTextContent("")) : e.getTextContent() === "- " && o === 2 && (We("bullet"), e.setTextContent(""));
|
|
1131
2334
|
}
|
|
1132
|
-
}), [
|
|
1133
|
-
|
|
1134
|
-
(
|
|
1135
|
-
const n =
|
|
1136
|
-
if (!
|
|
2335
|
+
}), [t]), C(() => t.registerCommand(
|
|
2336
|
+
Mt,
|
|
2337
|
+
(e) => {
|
|
2338
|
+
const n = L();
|
|
2339
|
+
if (!w(n))
|
|
1137
2340
|
return !1;
|
|
1138
|
-
const i =
|
|
1139
|
-
if (!
|
|
2341
|
+
const i = ve(n), r = I(i, ze);
|
|
2342
|
+
if (!r)
|
|
1140
2343
|
return !1;
|
|
1141
|
-
const
|
|
1142
|
-
if (
|
|
1143
|
-
if (
|
|
2344
|
+
const o = r.getIndent();
|
|
2345
|
+
if (e.shiftKey) {
|
|
2346
|
+
if (o <= 0)
|
|
1144
2347
|
return !1;
|
|
1145
|
-
|
|
2348
|
+
r.setIndent(o - 1);
|
|
1146
2349
|
} else {
|
|
1147
|
-
if (
|
|
2350
|
+
if (o > ir)
|
|
1148
2351
|
return !1;
|
|
1149
|
-
|
|
2352
|
+
r.setIndent(o + 1);
|
|
1150
2353
|
}
|
|
1151
2354
|
return !0;
|
|
1152
2355
|
},
|
|
1153
|
-
|
|
1154
|
-
), [
|
|
2356
|
+
$
|
|
2357
|
+
), [t]), null;
|
|
1155
2358
|
}
|
|
1156
|
-
function
|
|
1157
|
-
const [
|
|
1158
|
-
|
|
2359
|
+
function sr() {
|
|
2360
|
+
const [t] = M(), a = (e) => {
|
|
2361
|
+
e.key === "Tab" && e.preventDefault();
|
|
1159
2362
|
};
|
|
1160
|
-
return
|
|
2363
|
+
return C(() => t.registerRootListener(
|
|
1161
2364
|
(n, i) => {
|
|
1162
|
-
n && n.addEventListener("keydown",
|
|
2365
|
+
n && n.addEventListener("keydown", a), i && i.removeEventListener("keydown", a);
|
|
1163
2366
|
}
|
|
1164
|
-
), [
|
|
2367
|
+
), [t]), null;
|
|
1165
2368
|
}
|
|
1166
|
-
function
|
|
1167
|
-
const [
|
|
1168
|
-
return
|
|
1169
|
-
if (
|
|
1170
|
-
return
|
|
1171
|
-
|
|
2369
|
+
function ar({ editorRef: t }) {
|
|
2370
|
+
const [a] = M();
|
|
2371
|
+
return C(() => {
|
|
2372
|
+
if (t)
|
|
2373
|
+
return t.current = a, () => {
|
|
2374
|
+
t && (t.current = null);
|
|
1172
2375
|
};
|
|
1173
|
-
}, [
|
|
2376
|
+
}, [a, t]), null;
|
|
1174
2377
|
}
|
|
1175
|
-
function
|
|
1176
|
-
initialConfig:
|
|
1177
|
-
onChange:
|
|
1178
|
-
editorRef:
|
|
2378
|
+
function Ir({
|
|
2379
|
+
initialConfig: t,
|
|
2380
|
+
onChange: a,
|
|
2381
|
+
editorRef: e,
|
|
1179
2382
|
blockToolbarGap: n,
|
|
1180
2383
|
spellCheck: i,
|
|
1181
|
-
isHeadingOneFirst:
|
|
2384
|
+
isHeadingOneFirst: r
|
|
1182
2385
|
}) {
|
|
1183
|
-
return /* @__PURE__ */
|
|
1184
|
-
/* @__PURE__ */
|
|
1185
|
-
|
|
2386
|
+
return /* @__PURE__ */ D(yt, { initialConfig: t, children: [
|
|
2387
|
+
/* @__PURE__ */ h(
|
|
2388
|
+
Nt,
|
|
1186
2389
|
{
|
|
1187
|
-
contentEditable: /* @__PURE__ */
|
|
1188
|
-
ErrorBoundary:
|
|
2390
|
+
contentEditable: /* @__PURE__ */ h(vn, { spellCheck: i, className: "editor-input" }),
|
|
2391
|
+
ErrorBoundary: Et
|
|
1189
2392
|
}
|
|
1190
2393
|
),
|
|
1191
|
-
/* @__PURE__ */
|
|
1192
|
-
/* @__PURE__ */
|
|
1193
|
-
/* @__PURE__ */
|
|
1194
|
-
/* @__PURE__ */
|
|
1195
|
-
/* @__PURE__ */
|
|
1196
|
-
/* @__PURE__ */
|
|
1197
|
-
/* @__PURE__ */
|
|
1198
|
-
/* @__PURE__ */
|
|
1199
|
-
/* @__PURE__ */
|
|
1200
|
-
/* @__PURE__ */
|
|
1201
|
-
/* @__PURE__ */
|
|
1202
|
-
/* @__PURE__ */
|
|
1203
|
-
/* @__PURE__ */
|
|
1204
|
-
/* @__PURE__ */
|
|
1205
|
-
/* @__PURE__ */
|
|
1206
|
-
/* @__PURE__ */
|
|
2394
|
+
/* @__PURE__ */ h(In, { isHeadingOneFirst: r }),
|
|
2395
|
+
/* @__PURE__ */ h(Dn, {}),
|
|
2396
|
+
/* @__PURE__ */ h(Jn, { toolbarGap: n }),
|
|
2397
|
+
/* @__PURE__ */ h(Ct, {}),
|
|
2398
|
+
/* @__PURE__ */ h(xt, {}),
|
|
2399
|
+
/* @__PURE__ */ h(nr, {}),
|
|
2400
|
+
/* @__PURE__ */ h(rr, {}),
|
|
2401
|
+
/* @__PURE__ */ h(Un, {}),
|
|
2402
|
+
/* @__PURE__ */ h(jn, {}),
|
|
2403
|
+
/* @__PURE__ */ h(Zn, {}),
|
|
2404
|
+
/* @__PURE__ */ h(pn, {}),
|
|
2405
|
+
/* @__PURE__ */ h(or, {}),
|
|
2406
|
+
/* @__PURE__ */ h(sr, {}),
|
|
2407
|
+
/* @__PURE__ */ h(bn, { onChange: a }),
|
|
2408
|
+
/* @__PURE__ */ h(ar, { editorRef: e }),
|
|
2409
|
+
/* @__PURE__ */ h(Cn, {})
|
|
1207
2410
|
] });
|
|
1208
2411
|
}
|
|
1209
2412
|
export {
|
|
1210
|
-
|
|
2413
|
+
Ir as default
|
|
1211
2414
|
};
|
|
1212
2415
|
//# sourceMappingURL=index.es.js.map
|