@futaba-soft/mbox 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +80 -2
- package/dist/create-editor-BKTpQ8TK.js +2866 -0
- package/dist/editor/create-editor.d.ts +100 -0
- package/dist/editor/document-cache.d.ts +20 -0
- package/dist/editor/focused-line.d.ts +14 -0
- package/dist/editor/plugin.d.ts +191 -0
- package/dist/editor/test-context.d.ts +28 -0
- package/dist/gfm.d.ts +34 -0
- package/dist/gfm.js +1719 -0
- package/dist/hatena.d.ts +32 -0
- package/dist/hatena.js +856 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +77 -0
- package/dist/plugin-DI0ubB-M.js +297 -0
- package/dist/plugins/bracket-pair-kit.d.ts +9 -0
- package/dist/plugins/code-block-kit.d.ts +77 -0
- package/dist/plugins/code-block-language-loader.d.ts +33 -0
- package/dist/plugins/gfm/active-lines.d.ts +11 -0
- package/dist/plugins/gfm/code-block.d.ts +28 -0
- package/dist/plugins/gfm/footnote.d.ts +17 -0
- package/dist/plugins/gfm/heading.d.ts +12 -0
- package/dist/plugins/gfm/image.d.ts +30 -0
- package/dist/plugins/gfm/index.d.ts +19 -0
- package/dist/plugins/gfm/inline-code.d.ts +4 -0
- package/dist/plugins/gfm/inline.d.ts +4 -0
- package/dist/plugins/gfm/link.d.ts +34 -0
- package/dist/plugins/gfm/list.d.ts +32 -0
- package/dist/plugins/gfm/math.d.ts +39 -0
- package/dist/plugins/gfm/parser-cache.d.ts +3 -0
- package/dist/plugins/gfm/parser.d.ts +355 -0
- package/dist/plugins/gfm/quote.d.ts +3 -0
- package/dist/plugins/gfm/table.d.ts +34 -0
- package/dist/plugins/gfm/thematic-break.d.ts +9 -0
- package/dist/plugins/hatena/blockquote.d.ts +12 -0
- package/dist/plugins/hatena/definition.d.ts +5 -0
- package/dist/plugins/hatena/footnote.d.ts +15 -0
- package/dist/plugins/hatena/heading.d.ts +8 -0
- package/dist/plugins/hatena/index.d.ts +12 -0
- package/dist/plugins/hatena/link.d.ts +16 -0
- package/dist/plugins/hatena/list.d.ts +24 -0
- package/dist/plugins/hatena/parser-cache.d.ts +5 -0
- package/dist/plugins/hatena/parser.d.ts +129 -0
- package/dist/plugins/hatena/pre.d.ts +3 -0
- package/dist/plugins/hatena/shared.d.ts +31 -0
- package/dist/plugins/hatena/super-pre.d.ts +23 -0
- package/dist/plugins/hatena/table.d.ts +12 -0
- package/dist/plugins/image-kit.d.ts +84 -0
- package/dist/plugins/inline-notation-kit.d.ts +39 -0
- package/dist/plugins/inline-style-kit.d.ts +38 -0
- package/dist/plugins/link-url.d.ts +1 -0
- package/dist/plugins/logical-lines.d.ts +18 -0
- package/dist/plugins/mbox/bracket.d.ts +4 -0
- package/dist/plugins/mbox/code-block.d.ts +32 -0
- package/dist/plugins/mbox/complete.d.ts +33 -0
- package/dist/plugins/mbox/default.d.ts +13 -0
- package/dist/plugins/mbox/emoji.d.ts +3 -0
- package/dist/plugins/mbox/footnote.d.ts +14 -0
- package/dist/plugins/mbox/heading.d.ts +10 -0
- package/dist/plugins/mbox/inline-code.d.ts +6 -0
- package/dist/plugins/mbox/inline-style.d.ts +7 -0
- package/dist/plugins/mbox/inline-visitor.d.ts +8 -0
- package/dist/plugins/mbox/list.d.ts +13 -0
- package/dist/plugins/mbox/markdown-image.d.ts +13 -0
- package/dist/plugins/mbox/page-link.d.ts +19 -0
- package/dist/plugins/mbox/paragraph.d.ts +6 -0
- package/dist/plugins/mbox/parser-cache.d.ts +3 -0
- package/dist/plugins/mbox/parser.d.ts +2 -0
- package/dist/plugins/mbox/quote.d.ts +5 -0
- package/dist/plugins/mbox/table.d.ts +13 -0
- package/dist/plugins/mbox/task-list.d.ts +19 -0
- package/dist/plugins/mbox/types.d.ts +172 -0
- package/dist/plugins/mbox/url-link.d.ts +3 -0
- package/dist/plugins/mbox/vertical-motion.d.ts +3 -0
- package/dist/plugins/pipe-table-row.d.ts +18 -0
- package/dist/plugins/scrapbox/bracket.d.ts +20 -0
- package/dist/plugins/scrapbox/code-block.d.ts +37 -0
- package/dist/plugins/scrapbox/command-line.d.ts +9 -0
- package/dist/plugins/scrapbox/complete.d.ts +58 -0
- package/dist/plugins/scrapbox/decoration.d.ts +16 -0
- package/dist/plugins/scrapbox/formula.d.ts +43 -0
- package/dist/plugins/scrapbox/image.d.ts +62 -0
- package/dist/plugins/scrapbox/indent.d.ts +40 -0
- package/dist/plugins/scrapbox/index.d.ts +41 -0
- package/dist/plugins/scrapbox/inline-code-highlight.d.ts +16 -0
- package/dist/plugins/scrapbox/inline-code.d.ts +7 -0
- package/dist/plugins/scrapbox/inline-scanner-kit.d.ts +66 -0
- package/dist/plugins/scrapbox/inline-walker.d.ts +2 -0
- package/dist/plugins/scrapbox/inline.d.ts +86 -0
- package/dist/plugins/scrapbox/link.d.ts +110 -0
- package/dist/plugins/scrapbox/list.d.ts +21 -0
- package/dist/plugins/scrapbox/parser-cache.d.ts +5 -0
- package/dist/plugins/scrapbox/parser.d.ts +65 -0
- package/dist/plugins/scrapbox/quote.d.ts +7 -0
- package/dist/plugins/scrapbox/table.d.ts +22 -0
- package/dist/plugins/scrapbox/title.d.ts +3 -0
- package/dist/plugins/scrapbox/visible-lines.d.ts +34 -0
- package/dist/plugins/table-kit.d.ts +142 -0
- package/dist/plugins/task-checkbox-kit.d.ts +18 -0
- package/dist/scrapbox.d.ts +42 -0
- package/dist/scrapbox.js +1903 -0
- package/dist/testing.d.ts +2 -0
- package/dist/testing.js +13 -0
- package/dist/themes/code-token-presentation.d.ts +6 -0
- package/dist/themes/default-presentation.d.ts +4 -0
- package/dist/themes/gfm-presentation.d.ts +15 -0
- package/dist/themes/hatena-presentation.d.ts +10 -0
- package/dist/themes/heading-presentation.d.ts +18 -0
- package/dist/themes/scrapbox-presentation.d.ts +10 -0
- package/docs/guide.md +297 -0
- package/package.json +121 -4
|
@@ -0,0 +1,2866 @@
|
|
|
1
|
+
import { EditorSelection as F, EditorState as U } from "@codemirror/state";
|
|
2
|
+
import { history as ot, defaultKeymap as rt, historyKeymap as at } from "@codemirror/commands";
|
|
3
|
+
import { LanguageDescription as E, indentOnInput as st } from "@codemirror/language";
|
|
4
|
+
import { EditorView as y, WidgetType as b, ViewPlugin as it, highlightActiveLineGutter as lt, highlightActiveLine as ct, highlightSpecialChars as ut, drawSelection as mt, dropCursor as ft, keymap as dt } from "@codemirror/view";
|
|
5
|
+
import { c as G, a as ht } from "./plugin-DI0ubB-M.js";
|
|
6
|
+
import { javascriptLanguage as pt, typescriptLanguage as gt } from "@codemirror/lang-javascript";
|
|
7
|
+
import { highlightTree as bt, classHighlighter as yt } from "@lezer/highlight";
|
|
8
|
+
import { languages as O } from "@codemirror/language-data";
|
|
9
|
+
import { completionKeymap as kt, autocompletion as xt, moveCompletionSelection as Nt, completionStatus as Ct } from "@codemirror/autocomplete";
|
|
10
|
+
function Fe(t, e) {
|
|
11
|
+
return t.changeByRange((n) => ({
|
|
12
|
+
changes: [
|
|
13
|
+
{ from: n.from, insert: e.open },
|
|
14
|
+
{ from: n.to, insert: e.close }
|
|
15
|
+
],
|
|
16
|
+
range: F.range(n.from + e.open.length, n.to + e.open.length)
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
function vt(t) {
|
|
20
|
+
return {
|
|
21
|
+
extensions: [
|
|
22
|
+
y.inputHandler.of((e, n, o, r) => r !== t.open || e.state.readOnly || t.requireNonEmptySelection && e.state.selection.ranges.every((a) => a.empty) ? !1 : (e.dispatch(Fe(e.state, t), {
|
|
23
|
+
userEvent: "input.type",
|
|
24
|
+
scrollIntoView: !0
|
|
25
|
+
}), !0))
|
|
26
|
+
]
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const Ie = { open: "[", close: "]" };
|
|
30
|
+
function Pr(t) {
|
|
31
|
+
return Fe(t, Ie);
|
|
32
|
+
}
|
|
33
|
+
function Lt() {
|
|
34
|
+
return vt(Ie);
|
|
35
|
+
}
|
|
36
|
+
function wt(t) {
|
|
37
|
+
const e = /* @__PURE__ */ new WeakMap();
|
|
38
|
+
return {
|
|
39
|
+
getEntry(n) {
|
|
40
|
+
const o = e.get(n.doc);
|
|
41
|
+
if (o)
|
|
42
|
+
return o;
|
|
43
|
+
const r = n.doc.toString(), a = { input: r, document: t(r) };
|
|
44
|
+
return e.set(n.doc, a), a;
|
|
45
|
+
},
|
|
46
|
+
get(n) {
|
|
47
|
+
return this.getEntry(n).document;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function St(t) {
|
|
52
|
+
const e = [];
|
|
53
|
+
for (let n = 0; n < t.length; n += 1)
|
|
54
|
+
t[n] === "|" && e.push(n);
|
|
55
|
+
return e;
|
|
56
|
+
}
|
|
57
|
+
function Ft(t) {
|
|
58
|
+
const e = t.split(`
|
|
59
|
+
`);
|
|
60
|
+
let n = 0;
|
|
61
|
+
return e.map((o, r) => {
|
|
62
|
+
const a = n, s = a + o.length;
|
|
63
|
+
n = s + 1;
|
|
64
|
+
const l = r < e.length - 1 && o.endsWith("\r") ? s - 1 : s;
|
|
65
|
+
return { text: t.slice(a, l), line: r + 1, from: a, to: s, logicalTo: l };
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function It(t) {
|
|
69
|
+
if (t.length === 0)
|
|
70
|
+
return { blocks: [] };
|
|
71
|
+
const e = [], n = [Et, At], o = Ft(t);
|
|
72
|
+
for (let r = 0; r < o.length; r += 1) {
|
|
73
|
+
const a = o[r], s = $t(n, t, o, r);
|
|
74
|
+
if (s) {
|
|
75
|
+
e.push(s.block), r = s.nextLineIndex;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
e.push(Ot(a.text, a.from, a.line));
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
blocks: e
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function $t(t, e, n, o) {
|
|
85
|
+
for (const r of t) {
|
|
86
|
+
const a = r({ input: e, lines: n, lineIndex: o });
|
|
87
|
+
if (a)
|
|
88
|
+
return a;
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
const Et = ({ input: t, lines: e, lineIndex: n }) => {
|
|
93
|
+
const o = e[n], r = o.text;
|
|
94
|
+
if (!Mt(r))
|
|
95
|
+
return null;
|
|
96
|
+
const a = o.from, s = o.to, i = s < t.length ? s + 1 : s;
|
|
97
|
+
let l = -1;
|
|
98
|
+
for (let u = n + 1; u < e.length; u += 1)
|
|
99
|
+
if (Bt(e[u].text)) {
|
|
100
|
+
l = u;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
const m = l >= 0 ? {
|
|
104
|
+
from: e[l].from,
|
|
105
|
+
to: e[l].to
|
|
106
|
+
} : null, c = m?.from ?? t.length;
|
|
107
|
+
return {
|
|
108
|
+
block: {
|
|
109
|
+
type: "codeBlock",
|
|
110
|
+
from: a,
|
|
111
|
+
to: m?.to ?? t.length,
|
|
112
|
+
line: n + 1,
|
|
113
|
+
openingFence: {
|
|
114
|
+
from: a,
|
|
115
|
+
to: s
|
|
116
|
+
},
|
|
117
|
+
info: {
|
|
118
|
+
from: a + 3,
|
|
119
|
+
to: a + r.length
|
|
120
|
+
},
|
|
121
|
+
infoValue: r.slice(3),
|
|
122
|
+
content: {
|
|
123
|
+
from: i,
|
|
124
|
+
to: c
|
|
125
|
+
},
|
|
126
|
+
closingFence: m,
|
|
127
|
+
value: t.slice(i, c)
|
|
128
|
+
},
|
|
129
|
+
nextLineIndex: l >= 0 ? l : e.length
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
function Mt(t) {
|
|
133
|
+
return t.startsWith("```");
|
|
134
|
+
}
|
|
135
|
+
function Bt(t) {
|
|
136
|
+
return /^```\s*$/.test(t);
|
|
137
|
+
}
|
|
138
|
+
const At = ({ lines: t, lineIndex: e }) => {
|
|
139
|
+
const n = t[e].text, o = t[e + 1]?.text;
|
|
140
|
+
if (o == null || !ue(n) || !Tt(o))
|
|
141
|
+
return null;
|
|
142
|
+
const r = M(n, t[e].from);
|
|
143
|
+
if (!r || r.cells.length === 0)
|
|
144
|
+
return null;
|
|
145
|
+
const a = Pt(o, t[e + 1].from);
|
|
146
|
+
if (!a || a.cells.length !== r.cells.length)
|
|
147
|
+
return null;
|
|
148
|
+
const s = [];
|
|
149
|
+
let i = e + 1;
|
|
150
|
+
for (let l = e + 2; l < t.length && ue(t[l].text); l += 1) {
|
|
151
|
+
const m = M(t[l].text, t[l].from);
|
|
152
|
+
if (!m)
|
|
153
|
+
break;
|
|
154
|
+
s.push(m), i = l;
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
block: {
|
|
158
|
+
type: "table",
|
|
159
|
+
from: t[e].from,
|
|
160
|
+
to: t[i].to,
|
|
161
|
+
line: e + 1,
|
|
162
|
+
header: r,
|
|
163
|
+
delimiter: a,
|
|
164
|
+
rows: s
|
|
165
|
+
},
|
|
166
|
+
nextLineIndex: i
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
function ue(t) {
|
|
170
|
+
return t.includes("|") && t.trim().length > 0;
|
|
171
|
+
}
|
|
172
|
+
function Tt(t) {
|
|
173
|
+
const e = M(t, 0);
|
|
174
|
+
return !!(e && e.cells.length > 0 && e.cells.every((n) => /^:?-{3,}:?$/.test(n.value)));
|
|
175
|
+
}
|
|
176
|
+
function Pt(t, e) {
|
|
177
|
+
const n = M(t, e);
|
|
178
|
+
return n && n.cells.length > 0 && n.cells.every((o) => /^:?-{3,}:?$/.test(o.value)) ? n : null;
|
|
179
|
+
}
|
|
180
|
+
function M(t, e) {
|
|
181
|
+
const n = St(t);
|
|
182
|
+
if (n.length === 0)
|
|
183
|
+
return null;
|
|
184
|
+
const o = t.trimStart().startsWith("|"), r = t.trimEnd().endsWith("|"), a = [
|
|
185
|
+
o ? n[0] : -1,
|
|
186
|
+
...n.slice(o ? 1 : 0, r ? -1 : void 0),
|
|
187
|
+
r ? n[n.length - 1] : t.length
|
|
188
|
+
], s = [];
|
|
189
|
+
for (let i = 0; i < a.length - 1; i += 1) {
|
|
190
|
+
const l = a[i] + 1, m = a[i + 1], c = t.slice(l, m), u = c.length - c.trimStart().length, f = c.length - c.trimEnd().length, d = l + u, p = m - f;
|
|
191
|
+
s.push({
|
|
192
|
+
from: e + l,
|
|
193
|
+
to: e + m,
|
|
194
|
+
content: {
|
|
195
|
+
from: e + d,
|
|
196
|
+
to: e + p
|
|
197
|
+
},
|
|
198
|
+
value: t.slice(d, p)
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
from: e,
|
|
203
|
+
to: e + t.length,
|
|
204
|
+
cells: s
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function Ot(t, e, n) {
|
|
208
|
+
const o = /^(#{1,6})(\s+)(?=\S)/.exec(t);
|
|
209
|
+
if (o) {
|
|
210
|
+
const u = o[1].length, f = e + o[0].length;
|
|
211
|
+
return {
|
|
212
|
+
type: "heading",
|
|
213
|
+
from: e,
|
|
214
|
+
to: e + t.length,
|
|
215
|
+
line: n,
|
|
216
|
+
level: u,
|
|
217
|
+
marker: {
|
|
218
|
+
from: e,
|
|
219
|
+
to: e + u
|
|
220
|
+
},
|
|
221
|
+
syntax: {
|
|
222
|
+
from: e,
|
|
223
|
+
to: f
|
|
224
|
+
},
|
|
225
|
+
content: {
|
|
226
|
+
from: f,
|
|
227
|
+
to: e + t.length
|
|
228
|
+
},
|
|
229
|
+
inline: S(t, f - e, e)
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
const r = /^(#{1,6})(\s+)$/.exec(t);
|
|
233
|
+
if (r) {
|
|
234
|
+
const u = r[1].length, f = e + t.length;
|
|
235
|
+
return {
|
|
236
|
+
type: "heading",
|
|
237
|
+
from: e,
|
|
238
|
+
to: f,
|
|
239
|
+
line: n,
|
|
240
|
+
level: u,
|
|
241
|
+
marker: {
|
|
242
|
+
from: e,
|
|
243
|
+
to: e + u
|
|
244
|
+
},
|
|
245
|
+
syntax: {
|
|
246
|
+
from: e,
|
|
247
|
+
to: f
|
|
248
|
+
},
|
|
249
|
+
content: {
|
|
250
|
+
from: f,
|
|
251
|
+
to: f
|
|
252
|
+
},
|
|
253
|
+
inline: []
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
const a = /^(\s*)-(\s+)\[([ xX])\]\s+(?=\S)/.exec(t);
|
|
257
|
+
if (a) {
|
|
258
|
+
const u = a[1].length, f = e + u, d = f + 1 + a[2].length, p = e + a[0].length;
|
|
259
|
+
return {
|
|
260
|
+
type: "taskListItem",
|
|
261
|
+
from: e,
|
|
262
|
+
to: e + t.length,
|
|
263
|
+
line: n,
|
|
264
|
+
depth: u,
|
|
265
|
+
checked: a[3].toLowerCase() === "x",
|
|
266
|
+
marker: {
|
|
267
|
+
from: f,
|
|
268
|
+
to: f + 1
|
|
269
|
+
},
|
|
270
|
+
checkbox: {
|
|
271
|
+
from: d,
|
|
272
|
+
to: d + 3
|
|
273
|
+
},
|
|
274
|
+
syntax: {
|
|
275
|
+
from: f,
|
|
276
|
+
to: p
|
|
277
|
+
},
|
|
278
|
+
content: {
|
|
279
|
+
from: p,
|
|
280
|
+
to: e + t.length
|
|
281
|
+
},
|
|
282
|
+
inline: S(t, a[0].length, e)
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
const s = /^(\s*)-(\s+)\[([ xX])\]\s*$/.exec(t);
|
|
286
|
+
if (s) {
|
|
287
|
+
const u = s[1].length, f = e + u, d = f + 1 + s[2].length, p = e + t.length;
|
|
288
|
+
return {
|
|
289
|
+
type: "taskListItem",
|
|
290
|
+
from: e,
|
|
291
|
+
to: p,
|
|
292
|
+
line: n,
|
|
293
|
+
depth: u,
|
|
294
|
+
checked: s[3].toLowerCase() === "x",
|
|
295
|
+
marker: {
|
|
296
|
+
from: f,
|
|
297
|
+
to: f + 1
|
|
298
|
+
},
|
|
299
|
+
checkbox: {
|
|
300
|
+
from: d,
|
|
301
|
+
to: d + 3
|
|
302
|
+
},
|
|
303
|
+
syntax: {
|
|
304
|
+
from: f,
|
|
305
|
+
to: p
|
|
306
|
+
},
|
|
307
|
+
content: {
|
|
308
|
+
from: p,
|
|
309
|
+
to: p
|
|
310
|
+
},
|
|
311
|
+
inline: []
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
const i = /^(\s*)-\s+(?=\S|$)/.exec(t);
|
|
315
|
+
if (i) {
|
|
316
|
+
const u = i[1].length, f = e + u;
|
|
317
|
+
return {
|
|
318
|
+
type: "listItem",
|
|
319
|
+
from: e,
|
|
320
|
+
to: e + t.length,
|
|
321
|
+
line: n,
|
|
322
|
+
depth: u,
|
|
323
|
+
marker: {
|
|
324
|
+
from: f,
|
|
325
|
+
to: f + 1
|
|
326
|
+
},
|
|
327
|
+
syntax: {
|
|
328
|
+
from: f,
|
|
329
|
+
to: e + i[0].length
|
|
330
|
+
},
|
|
331
|
+
content: {
|
|
332
|
+
from: e + i[0].length,
|
|
333
|
+
to: e + t.length
|
|
334
|
+
},
|
|
335
|
+
inline: S(t, i[0].length, e)
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
const l = /^>\s+(?=\S)/.exec(t);
|
|
339
|
+
if (l) {
|
|
340
|
+
const u = e + l[0].length;
|
|
341
|
+
return {
|
|
342
|
+
type: "quote",
|
|
343
|
+
from: e,
|
|
344
|
+
to: e + t.length,
|
|
345
|
+
line: n,
|
|
346
|
+
marker: {
|
|
347
|
+
from: e,
|
|
348
|
+
to: e + 1
|
|
349
|
+
},
|
|
350
|
+
syntax: {
|
|
351
|
+
from: e,
|
|
352
|
+
to: u
|
|
353
|
+
},
|
|
354
|
+
content: {
|
|
355
|
+
from: u,
|
|
356
|
+
to: e + t.length
|
|
357
|
+
},
|
|
358
|
+
inline: S(t, l[0].length, e)
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
const m = /^\[\^([^[\]]+)\]:(\s+)(?=\S)/.exec(t);
|
|
362
|
+
if (m) {
|
|
363
|
+
const u = m[1], f = m[0].length - m[2].length, d = e + m[0].length, p = t.slice(m[0].length).trimEnd();
|
|
364
|
+
return {
|
|
365
|
+
type: "footnoteDefinition",
|
|
366
|
+
from: e,
|
|
367
|
+
to: e + t.length,
|
|
368
|
+
line: n,
|
|
369
|
+
label: u,
|
|
370
|
+
identifier: u.toLowerCase(),
|
|
371
|
+
marker: {
|
|
372
|
+
from: e,
|
|
373
|
+
to: e + f
|
|
374
|
+
},
|
|
375
|
+
syntax: {
|
|
376
|
+
from: e,
|
|
377
|
+
to: d
|
|
378
|
+
},
|
|
379
|
+
content: {
|
|
380
|
+
from: d,
|
|
381
|
+
to: d + p.length
|
|
382
|
+
},
|
|
383
|
+
value: p
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
const c = {
|
|
387
|
+
from: e,
|
|
388
|
+
to: e + t.length
|
|
389
|
+
};
|
|
390
|
+
return {
|
|
391
|
+
type: "paragraph",
|
|
392
|
+
from: e,
|
|
393
|
+
to: e + t.length,
|
|
394
|
+
line: n,
|
|
395
|
+
content: c,
|
|
396
|
+
inline: S(t, 0, e)
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
class Wt {
|
|
400
|
+
constructor(e) {
|
|
401
|
+
this.text = e;
|
|
402
|
+
}
|
|
403
|
+
text;
|
|
404
|
+
nextRawOpenBrackets;
|
|
405
|
+
nextRawCloseBrackets;
|
|
406
|
+
nextRawCloseParens;
|
|
407
|
+
nextUnescapedCloseBrackets;
|
|
408
|
+
nextUnescapedCloseParens;
|
|
409
|
+
nextWhitespaces;
|
|
410
|
+
nextDots;
|
|
411
|
+
autoLinkRunEnds;
|
|
412
|
+
nextRawOpenBracket(e) {
|
|
413
|
+
return this.nextRawOpenBrackets ??= this.buildNextIndex((n) => n === "["), this.nextRawOpenBrackets[e];
|
|
414
|
+
}
|
|
415
|
+
nextRawCloseBracket(e) {
|
|
416
|
+
return this.nextRawCloseBrackets ??= this.buildNextIndex((n) => n === "]"), this.nextRawCloseBrackets[e];
|
|
417
|
+
}
|
|
418
|
+
nextRawCloseParen(e) {
|
|
419
|
+
return this.nextRawCloseParens ??= this.buildNextIndex((n) => n === ")"), this.nextRawCloseParens[e];
|
|
420
|
+
}
|
|
421
|
+
nextUnescapedCloseBracket(e) {
|
|
422
|
+
return this.nextUnescapedCloseBrackets ??= this.buildNextUnescapedIndex("]"), this.nextUnescapedCloseBrackets[e];
|
|
423
|
+
}
|
|
424
|
+
nextUnescapedCloseParen(e) {
|
|
425
|
+
return this.nextUnescapedCloseParens ??= this.buildNextUnescapedIndex(")"), this.nextUnescapedCloseParens[e];
|
|
426
|
+
}
|
|
427
|
+
nextWhitespace(e) {
|
|
428
|
+
return this.nextWhitespaces ??= this.buildNextIndex((n) => /\s/.test(n)), this.nextWhitespaces[e];
|
|
429
|
+
}
|
|
430
|
+
nextDot(e) {
|
|
431
|
+
return this.nextDots ??= this.buildNextIndex((n) => n === "."), this.nextDots[e];
|
|
432
|
+
}
|
|
433
|
+
punctuationTrimmedAutoLinkRunEnd(e) {
|
|
434
|
+
const n = this.nextWhitespace(e), o = n < 0 ? this.text.length : n;
|
|
435
|
+
this.autoLinkRunEnds ??= new Int32Array(this.text.length + 1);
|
|
436
|
+
const r = this.autoLinkRunEnds[o];
|
|
437
|
+
if (r === 0) {
|
|
438
|
+
let a = o;
|
|
439
|
+
for (; a > 0 && /[.,:;!?]/.test(this.text[a - 1]); )
|
|
440
|
+
a -= 1;
|
|
441
|
+
return this.autoLinkRunEnds[o] = a + 1, a;
|
|
442
|
+
}
|
|
443
|
+
return r - 1;
|
|
444
|
+
}
|
|
445
|
+
buildNextIndex(e) {
|
|
446
|
+
const n = new Int32Array(this.text.length + 1);
|
|
447
|
+
let o = -1;
|
|
448
|
+
n[this.text.length] = o;
|
|
449
|
+
for (let r = this.text.length - 1; r >= 0; r -= 1)
|
|
450
|
+
e(this.text[r]) && (o = r), n[r] = o;
|
|
451
|
+
return n;
|
|
452
|
+
}
|
|
453
|
+
buildNextUnescapedIndex(e) {
|
|
454
|
+
const n = new Uint8Array(this.text.length);
|
|
455
|
+
let o = 0;
|
|
456
|
+
for (let s = 0; s < this.text.length; s += 1)
|
|
457
|
+
this.text[s] === e && o % 2 === 0 && (n[s] = 1), o = this.text[s] === "\\" ? o + 1 : 0;
|
|
458
|
+
const r = new Int32Array(this.text.length + 1);
|
|
459
|
+
let a = -1;
|
|
460
|
+
r[this.text.length] = a;
|
|
461
|
+
for (let s = this.text.length - 1; s >= 0; s -= 1)
|
|
462
|
+
n[s] && (a = s), r[s] = a;
|
|
463
|
+
return r;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
function S(t, e, n) {
|
|
467
|
+
if (e >= t.length)
|
|
468
|
+
return [];
|
|
469
|
+
const o = [];
|
|
470
|
+
let r = e, a = e, s;
|
|
471
|
+
const i = () => s ??= new Wt(t);
|
|
472
|
+
for (; a < t.length; ) {
|
|
473
|
+
const l = Rt(t, a, n, i);
|
|
474
|
+
if (!l) {
|
|
475
|
+
a += 1;
|
|
476
|
+
continue;
|
|
477
|
+
}
|
|
478
|
+
a > r && o.push(fe(t, r, a, n)), o.push(l), r = l.to - n, a = r;
|
|
479
|
+
}
|
|
480
|
+
return r < t.length && o.push(fe(t, r, t.length, n)), o;
|
|
481
|
+
}
|
|
482
|
+
function Rt(t, e, n, o) {
|
|
483
|
+
return t[e] === "`" ? Dt(t, e, n) : t[e] === "*" ? Ut(t, e, n) ?? qt(t, e, n) : t[e] === "~" ? zt(t, e, n) : t[e] === "!" ? Ht(t, e, n, o) : t[e] === "[" ? Vt(t, e, n, o) ?? Gt(t, e, n, o) ?? Jt(t, e, n, o) ?? Kt(t, e, n, o) : t[e] === ":" ? Qt(t, e, n) : t[e] === "h" ? Xt(t, e, n, o) : null;
|
|
484
|
+
}
|
|
485
|
+
function Dt(t, e, n) {
|
|
486
|
+
const o = t.indexOf("`", e + 1);
|
|
487
|
+
if (o < 0 || o === e + 1)
|
|
488
|
+
return null;
|
|
489
|
+
const r = n + e, a = n + o + 1, s = r + 1, i = n + o;
|
|
490
|
+
return {
|
|
491
|
+
type: "inlineCode",
|
|
492
|
+
from: r,
|
|
493
|
+
to: a,
|
|
494
|
+
openingMarker: {
|
|
495
|
+
from: r,
|
|
496
|
+
to: r + 1
|
|
497
|
+
},
|
|
498
|
+
closingMarker: {
|
|
499
|
+
from: i,
|
|
500
|
+
to: a
|
|
501
|
+
},
|
|
502
|
+
content: {
|
|
503
|
+
from: s,
|
|
504
|
+
to: i
|
|
505
|
+
},
|
|
506
|
+
value: t.slice(e + 1, o)
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
function Ut(t, e, n) {
|
|
510
|
+
return t.startsWith("**", e) ? J(t, e, n, "**", "strong") : null;
|
|
511
|
+
}
|
|
512
|
+
function qt(t, e, n) {
|
|
513
|
+
return t[e + 1] === "*" ? null : J(t, e, n, "*", "emphasis");
|
|
514
|
+
}
|
|
515
|
+
function zt(t, e, n) {
|
|
516
|
+
return t.startsWith("~~", e) ? J(t, e, n, "~~", "strikethrough") : null;
|
|
517
|
+
}
|
|
518
|
+
function J(t, e, n, o, r) {
|
|
519
|
+
const a = t.indexOf(o, e + o.length);
|
|
520
|
+
if (a < 0 || a === e + o.length)
|
|
521
|
+
return null;
|
|
522
|
+
const s = n + e, i = n + a + o.length, l = s + o.length, m = n + a;
|
|
523
|
+
return {
|
|
524
|
+
type: r,
|
|
525
|
+
from: s,
|
|
526
|
+
to: i,
|
|
527
|
+
openingMarker: {
|
|
528
|
+
from: s,
|
|
529
|
+
to: l
|
|
530
|
+
},
|
|
531
|
+
closingMarker: {
|
|
532
|
+
from: m,
|
|
533
|
+
to: i
|
|
534
|
+
},
|
|
535
|
+
content: {
|
|
536
|
+
from: l,
|
|
537
|
+
to: m
|
|
538
|
+
},
|
|
539
|
+
value: t.slice(e + o.length, a)
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
function Vt(t, e, n, o) {
|
|
543
|
+
const r = o().nextRawCloseBracket(e + 1);
|
|
544
|
+
if (r < 0 || t[r + 1] !== "(")
|
|
545
|
+
return null;
|
|
546
|
+
const a = o().nextRawCloseParen(r + 2);
|
|
547
|
+
if (a < 0)
|
|
548
|
+
return null;
|
|
549
|
+
const s = n + e, i = n + a + 1, l = s + 1, m = n + r, c = n + r + 2, u = n + a;
|
|
550
|
+
return {
|
|
551
|
+
type: "markdownLink",
|
|
552
|
+
from: s,
|
|
553
|
+
to: i,
|
|
554
|
+
label: {
|
|
555
|
+
from: l,
|
|
556
|
+
to: m
|
|
557
|
+
},
|
|
558
|
+
url: {
|
|
559
|
+
from: c,
|
|
560
|
+
to: u
|
|
561
|
+
},
|
|
562
|
+
markers: {
|
|
563
|
+
labelOpen: {
|
|
564
|
+
from: s,
|
|
565
|
+
to: s + 1
|
|
566
|
+
},
|
|
567
|
+
labelClose: {
|
|
568
|
+
from: n + r,
|
|
569
|
+
to: n + r + 1
|
|
570
|
+
},
|
|
571
|
+
urlOpen: {
|
|
572
|
+
from: n + r + 1,
|
|
573
|
+
to: n + r + 2
|
|
574
|
+
},
|
|
575
|
+
urlClose: {
|
|
576
|
+
from: n + a,
|
|
577
|
+
to: n + a + 1
|
|
578
|
+
}
|
|
579
|
+
},
|
|
580
|
+
labelValue: t.slice(e + 1, r),
|
|
581
|
+
urlValue: t.slice(r + 2, a)
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
function Ht(t, e, n, o) {
|
|
585
|
+
if (t[e + 1] !== "[")
|
|
586
|
+
return null;
|
|
587
|
+
const r = o().nextUnescapedCloseBracket(e + 2);
|
|
588
|
+
if (r < 0 || t[r + 1] !== "(")
|
|
589
|
+
return null;
|
|
590
|
+
const a = o().nextUnescapedCloseParen(r + 2);
|
|
591
|
+
if (a < 0)
|
|
592
|
+
return null;
|
|
593
|
+
const s = n + e, i = n + a + 1, l = s + 2, m = n + r, c = r + 2, u = jt(t, c, a), f = n + c, d = n + u;
|
|
594
|
+
return {
|
|
595
|
+
type: "markdownImage",
|
|
596
|
+
from: s,
|
|
597
|
+
to: i,
|
|
598
|
+
alt: {
|
|
599
|
+
from: l,
|
|
600
|
+
to: m
|
|
601
|
+
},
|
|
602
|
+
url: {
|
|
603
|
+
from: f,
|
|
604
|
+
to: d
|
|
605
|
+
},
|
|
606
|
+
markers: {
|
|
607
|
+
image: {
|
|
608
|
+
from: s,
|
|
609
|
+
to: s + 1
|
|
610
|
+
},
|
|
611
|
+
labelOpen: {
|
|
612
|
+
from: s + 1,
|
|
613
|
+
to: s + 2
|
|
614
|
+
},
|
|
615
|
+
labelClose: {
|
|
616
|
+
from: n + r,
|
|
617
|
+
to: n + r + 1
|
|
618
|
+
},
|
|
619
|
+
urlOpen: {
|
|
620
|
+
from: n + r + 1,
|
|
621
|
+
to: n + r + 2
|
|
622
|
+
},
|
|
623
|
+
urlClose: {
|
|
624
|
+
from: n + a,
|
|
625
|
+
to: n + a + 1
|
|
626
|
+
}
|
|
627
|
+
},
|
|
628
|
+
altValue: me(t.slice(e + 2, r)),
|
|
629
|
+
urlValue: me(t.slice(c, u))
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
function me(t) {
|
|
633
|
+
return t.replace(/\\([\\\]\)])/g, "$1");
|
|
634
|
+
}
|
|
635
|
+
function Q(t, e, n, o) {
|
|
636
|
+
const r = o.nextRawCloseBracket(n);
|
|
637
|
+
if (r < 0 || r === n) return null;
|
|
638
|
+
const a = o.nextRawOpenBracket(n);
|
|
639
|
+
return a >= 0 && a < r ? null : { content: t.slice(n, r), closeIndex: r };
|
|
640
|
+
}
|
|
641
|
+
function jt(t, e, n) {
|
|
642
|
+
let o = e;
|
|
643
|
+
for (; o < n && t[o] !== " " && t[o] !== " " && t[o] !== `
|
|
644
|
+
`; )
|
|
645
|
+
o += 1;
|
|
646
|
+
return o;
|
|
647
|
+
}
|
|
648
|
+
function Kt(t, e, n, o) {
|
|
649
|
+
const r = Q(t, e, e + 1, o());
|
|
650
|
+
if (!r)
|
|
651
|
+
return null;
|
|
652
|
+
const { content: a, closeIndex: s } = r;
|
|
653
|
+
if (X(t, e, s + 1))
|
|
654
|
+
return null;
|
|
655
|
+
const i = n + e, l = n + s + 1, m = i + 1, c = n + s;
|
|
656
|
+
return {
|
|
657
|
+
type: "wikiLink",
|
|
658
|
+
from: i,
|
|
659
|
+
to: l,
|
|
660
|
+
marker: {
|
|
661
|
+
from: i,
|
|
662
|
+
to: i + 1
|
|
663
|
+
},
|
|
664
|
+
target: {
|
|
665
|
+
from: m,
|
|
666
|
+
to: c
|
|
667
|
+
},
|
|
668
|
+
value: a
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
function Gt(t, e, n, o) {
|
|
672
|
+
if (t[e + 1] !== "^")
|
|
673
|
+
return null;
|
|
674
|
+
const r = Q(t, e, e + 2, o());
|
|
675
|
+
if (!r)
|
|
676
|
+
return null;
|
|
677
|
+
const { content: a, closeIndex: s } = r;
|
|
678
|
+
if (X(t, e, s + 1))
|
|
679
|
+
return null;
|
|
680
|
+
const i = n + e, l = n + s + 1, m = i + 2, c = n + s;
|
|
681
|
+
return {
|
|
682
|
+
type: "footnoteRef",
|
|
683
|
+
from: i,
|
|
684
|
+
to: l,
|
|
685
|
+
marker: {
|
|
686
|
+
from: i,
|
|
687
|
+
to: i + 2
|
|
688
|
+
},
|
|
689
|
+
label: {
|
|
690
|
+
from: m,
|
|
691
|
+
to: c
|
|
692
|
+
},
|
|
693
|
+
identifier: a.toLowerCase(),
|
|
694
|
+
value: a
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
function Jt(t, e, n, o) {
|
|
698
|
+
const r = Q(t, e, e + 1, o());
|
|
699
|
+
if (!r)
|
|
700
|
+
return null;
|
|
701
|
+
const { content: a, closeIndex: s } = r;
|
|
702
|
+
if (X(t, e, s + 1))
|
|
703
|
+
return null;
|
|
704
|
+
const i = ".icon";
|
|
705
|
+
if (!a.toLowerCase().endsWith(i) || a.length === i.length)
|
|
706
|
+
return null;
|
|
707
|
+
const l = n + e, m = n + s + 1, c = l + 1, u = n + s - i.length;
|
|
708
|
+
return {
|
|
709
|
+
type: "icon",
|
|
710
|
+
from: l,
|
|
711
|
+
to: m,
|
|
712
|
+
marker: {
|
|
713
|
+
from: l,
|
|
714
|
+
to: l + 1
|
|
715
|
+
},
|
|
716
|
+
name: {
|
|
717
|
+
from: c,
|
|
718
|
+
to: u
|
|
719
|
+
},
|
|
720
|
+
value: a.slice(0, -i.length)
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
function Qt(t, e, n) {
|
|
724
|
+
const o = /^:([A-Za-z0-9_+-]+):/.exec(t.slice(e));
|
|
725
|
+
if (!o)
|
|
726
|
+
return null;
|
|
727
|
+
const r = n + e, a = r + o[0].length, s = r + 1, i = s + o[1].length;
|
|
728
|
+
return {
|
|
729
|
+
type: "emoji",
|
|
730
|
+
from: r,
|
|
731
|
+
to: a,
|
|
732
|
+
marker: {
|
|
733
|
+
from: r,
|
|
734
|
+
to: a
|
|
735
|
+
},
|
|
736
|
+
name: {
|
|
737
|
+
from: s,
|
|
738
|
+
to: i
|
|
739
|
+
},
|
|
740
|
+
value: o[1]
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
function Xt(t, e, n, o) {
|
|
744
|
+
if (!Zt(t, e) || !Yt(t, e))
|
|
745
|
+
return null;
|
|
746
|
+
const r = o(), a = r.punctuationTrimmedAutoLinkRunEnd(e), s = r.nextDot(e);
|
|
747
|
+
if (s < 0 || s >= a)
|
|
748
|
+
return null;
|
|
749
|
+
const i = r.nextWhitespace(e), l = i < 0 ? t.length : i, m = _t(t, e, l);
|
|
750
|
+
if (m <= e)
|
|
751
|
+
return null;
|
|
752
|
+
const c = n + e, u = n + m;
|
|
753
|
+
return {
|
|
754
|
+
type: "autoLink",
|
|
755
|
+
from: c,
|
|
756
|
+
to: u,
|
|
757
|
+
url: {
|
|
758
|
+
from: c,
|
|
759
|
+
to: u
|
|
760
|
+
},
|
|
761
|
+
urlValue: t.slice(e, m)
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
function Zt(t, e) {
|
|
765
|
+
return t.startsWith("https://", e) || t.startsWith("http://", e);
|
|
766
|
+
}
|
|
767
|
+
function Yt(t, e) {
|
|
768
|
+
return e === 0 || /\s|[([{"']/.test(t[e - 1]);
|
|
769
|
+
}
|
|
770
|
+
function _t(t, e, n) {
|
|
771
|
+
let o = n;
|
|
772
|
+
for (; o > e && /[.,:;!?]/.test(t[o - 1]); )
|
|
773
|
+
o -= 1;
|
|
774
|
+
let r = 0, a = 0;
|
|
775
|
+
for (let s = e; s < o; s += 1)
|
|
776
|
+
t[s] === "(" && (r += 1), t[s] === ")" && (a += 1);
|
|
777
|
+
for (; o > e && t[o - 1] === ")" && a > r; )
|
|
778
|
+
o -= 1, a -= 1;
|
|
779
|
+
return o;
|
|
780
|
+
}
|
|
781
|
+
function X(t, e, n) {
|
|
782
|
+
return t[e - 1] === "!" || t[n] === "(";
|
|
783
|
+
}
|
|
784
|
+
function fe(t, e, n, o) {
|
|
785
|
+
return {
|
|
786
|
+
type: "text",
|
|
787
|
+
from: o + e,
|
|
788
|
+
to: o + n,
|
|
789
|
+
value: t.slice(e, n)
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
const en = wt((t) => It(t));
|
|
793
|
+
function h(t) {
|
|
794
|
+
return en.get(t);
|
|
795
|
+
}
|
|
796
|
+
function T(t) {
|
|
797
|
+
const e = /^[ \t]*([^ \t\r\n]+)(?:[ \t]+.*)?$/.exec(t);
|
|
798
|
+
if (!e?.[1])
|
|
799
|
+
return null;
|
|
800
|
+
const n = e.index + e[0].indexOf(e[1]);
|
|
801
|
+
return { value: e[1], from: n, to: n + e[1].length };
|
|
802
|
+
}
|
|
803
|
+
function $e(t) {
|
|
804
|
+
return /[\r\n]/.test(t) ? null : (/^[ \t]*(.*?)[ \t]*$/.exec(t)?.[1] ?? "") || null;
|
|
805
|
+
}
|
|
806
|
+
class Z extends b {
|
|
807
|
+
constructor(e, n) {
|
|
808
|
+
super(), this.code = e, this.className = n;
|
|
809
|
+
}
|
|
810
|
+
code;
|
|
811
|
+
className;
|
|
812
|
+
eq(e) {
|
|
813
|
+
return e instanceof Z && this.code === e.code && this.className === e.className;
|
|
814
|
+
}
|
|
815
|
+
toDOM() {
|
|
816
|
+
const e = document.createElement("button");
|
|
817
|
+
let n;
|
|
818
|
+
return e.type = "button", e.className = this.className, e.textContent = "Copy", e.setAttribute("aria-label", "Copy code block"), e.addEventListener("click", async (o) => {
|
|
819
|
+
o.preventDefault(), o.stopPropagation();
|
|
820
|
+
try {
|
|
821
|
+
await navigator.clipboard.writeText(this.code), n !== void 0 && window.clearTimeout(n), e.textContent = "Copied", e.dataset.copied = "true", delete e.dataset.copyFailed, n = window.setTimeout(() => {
|
|
822
|
+
e.textContent = "Copy", delete e.dataset.copied, n = void 0;
|
|
823
|
+
}, 1e3);
|
|
824
|
+
} catch {
|
|
825
|
+
e.dataset.copyFailed = "true";
|
|
826
|
+
}
|
|
827
|
+
}), e;
|
|
828
|
+
}
|
|
829
|
+
ignoreEvent() {
|
|
830
|
+
return !0;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
const tn = ["js", "javascript", "jsx", "ts", "typescript", "tsx"];
|
|
834
|
+
function de(t) {
|
|
835
|
+
return tn.includes(t);
|
|
836
|
+
}
|
|
837
|
+
function Ee(t) {
|
|
838
|
+
const e = t.toLowerCase();
|
|
839
|
+
if (!e)
|
|
840
|
+
return null;
|
|
841
|
+
if (de(e))
|
|
842
|
+
return e;
|
|
843
|
+
const n = /\.([a-z0-9]+)$/i.exec(e)?.[1]?.toLowerCase();
|
|
844
|
+
return n && de(n) ? n : e;
|
|
845
|
+
}
|
|
846
|
+
function Me(t) {
|
|
847
|
+
return t ? ["js", "javascript", "jsx"].includes(t) ? pt : ["ts", "typescript", "tsx"].includes(t) ? gt : null : null;
|
|
848
|
+
}
|
|
849
|
+
function nn(t) {
|
|
850
|
+
const e = T(t);
|
|
851
|
+
return Me(e ? Ee(e.value) : null);
|
|
852
|
+
}
|
|
853
|
+
function Or(t) {
|
|
854
|
+
const e = $e(t);
|
|
855
|
+
return Me(e ? Ee(e) : null);
|
|
856
|
+
}
|
|
857
|
+
function on(t, e, n) {
|
|
858
|
+
const o = t.map((l) => l.text).join(`
|
|
859
|
+
`), r = e.parser.parse(o), a = [];
|
|
860
|
+
let s = 0;
|
|
861
|
+
const i = t.map((l) => {
|
|
862
|
+
const m = { ...l, virtualFrom: s, virtualTo: s + l.text.length };
|
|
863
|
+
return s = m.virtualTo + 1, m;
|
|
864
|
+
});
|
|
865
|
+
return bt(r, yt, (l, m, c) => {
|
|
866
|
+
for (const u of i) {
|
|
867
|
+
const f = Math.max(l, u.virtualFrom), d = Math.min(m, u.virtualTo);
|
|
868
|
+
f >= d || a.push({
|
|
869
|
+
from: u.from + (f - u.virtualFrom),
|
|
870
|
+
to: u.from + (d - u.virtualFrom),
|
|
871
|
+
className: `${n} ${c}`
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
}), a;
|
|
875
|
+
}
|
|
876
|
+
function rn(t, e, n, o) {
|
|
877
|
+
return on(
|
|
878
|
+
[{ from: e, to: e + t.length, text: t }],
|
|
879
|
+
n,
|
|
880
|
+
o
|
|
881
|
+
);
|
|
882
|
+
}
|
|
883
|
+
function an(t, e) {
|
|
884
|
+
const n = T(t);
|
|
885
|
+
return n ? { from: e + n.from, to: e + n.to } : null;
|
|
886
|
+
}
|
|
887
|
+
function sn(t, e) {
|
|
888
|
+
const n = [];
|
|
889
|
+
let o = t.from;
|
|
890
|
+
for (; o < t.to; ) {
|
|
891
|
+
n.push(o);
|
|
892
|
+
const r = e.indexOf(`
|
|
893
|
+
`, o - t.from);
|
|
894
|
+
if (r < 0)
|
|
895
|
+
break;
|
|
896
|
+
o = t.from + r + 1;
|
|
897
|
+
}
|
|
898
|
+
return [...new Set(n)];
|
|
899
|
+
}
|
|
900
|
+
function ln(t) {
|
|
901
|
+
return /\r|\n/.test(t) ? null : t.trim().toLowerCase();
|
|
902
|
+
}
|
|
903
|
+
function cn(t) {
|
|
904
|
+
return t.toLowerCase();
|
|
905
|
+
}
|
|
906
|
+
function q(t) {
|
|
907
|
+
return t.name.toLowerCase();
|
|
908
|
+
}
|
|
909
|
+
function un(t) {
|
|
910
|
+
if (!t)
|
|
911
|
+
return [...O];
|
|
912
|
+
const e = /* @__PURE__ */ new Map();
|
|
913
|
+
for (const n of t) {
|
|
914
|
+
const o = ln(n);
|
|
915
|
+
if (!o)
|
|
916
|
+
continue;
|
|
917
|
+
const r = E.matchLanguageName(O, o, !1) ?? E.matchFilename(O, o);
|
|
918
|
+
r && e.set(q(r), r);
|
|
919
|
+
}
|
|
920
|
+
return [...e.values()];
|
|
921
|
+
}
|
|
922
|
+
function he(t, e, n) {
|
|
923
|
+
const o = n === "fileName" ? $e(e) : T(e)?.value;
|
|
924
|
+
if (!o)
|
|
925
|
+
return null;
|
|
926
|
+
const r = cn(o), a = E.matchLanguageName(t, r, !1) ?? E.matchFilename(t, o);
|
|
927
|
+
return a ? { languageId: r, description: a } : null;
|
|
928
|
+
}
|
|
929
|
+
function mn(t, e = {}) {
|
|
930
|
+
const n = un(e.languages), o = e.infoValueKind ?? "infoString", r = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set();
|
|
931
|
+
function s(m) {
|
|
932
|
+
const c = he(n, m, o);
|
|
933
|
+
if (!c)
|
|
934
|
+
return null;
|
|
935
|
+
const u = r.get(q(c.description));
|
|
936
|
+
return u?.status === "loaded" ? u.language : null;
|
|
937
|
+
}
|
|
938
|
+
function i(m) {
|
|
939
|
+
const c = he(n, m, o);
|
|
940
|
+
if (!c)
|
|
941
|
+
return Promise.resolve();
|
|
942
|
+
const { languageId: u, description: f } = c, d = q(f), p = r.get(d);
|
|
943
|
+
if (p)
|
|
944
|
+
return p.status === "loading" ? p.promise.then(() => {
|
|
945
|
+
}, () => {
|
|
946
|
+
}) : Promise.resolve();
|
|
947
|
+
const x = f.load().then((v) => v.language);
|
|
948
|
+
return r.set(d, { status: "loading", promise: x }), x.then(
|
|
949
|
+
(v) => {
|
|
950
|
+
r.set(d, { status: "loaded", language: v });
|
|
951
|
+
for (const nt of a)
|
|
952
|
+
nt.dispatch({});
|
|
953
|
+
},
|
|
954
|
+
(v) => {
|
|
955
|
+
r.set(d, { status: "failed", error: v }), e.onLoadError?.(u, v);
|
|
956
|
+
}
|
|
957
|
+
);
|
|
958
|
+
}
|
|
959
|
+
class l {
|
|
960
|
+
view;
|
|
961
|
+
constructor(c) {
|
|
962
|
+
this.view = c, a.add(c), this.scan(c.state);
|
|
963
|
+
}
|
|
964
|
+
update(c) {
|
|
965
|
+
c.docChanged && this.scan(c.state);
|
|
966
|
+
}
|
|
967
|
+
scan(c) {
|
|
968
|
+
for (const u of t(c))
|
|
969
|
+
i(u);
|
|
970
|
+
}
|
|
971
|
+
destroy() {
|
|
972
|
+
a.delete(this.view);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
return {
|
|
976
|
+
getLanguage: s,
|
|
977
|
+
ensureLanguageLoaded: i,
|
|
978
|
+
extension: it.fromClass(l)
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
const W = "mbox-code-block-line", fn = "mbox-code-opening-fence", dn = "mbox-code-closing-fence", g = {
|
|
982
|
+
block: "mbox-code-block",
|
|
983
|
+
fenceLine: "mbox-code-fence-line",
|
|
984
|
+
headerLine: "mbox-code-header-line",
|
|
985
|
+
openingFenceLine: "mbox-code-opening-fence-line",
|
|
986
|
+
closingFenceLine: "mbox-code-closing-fence-line",
|
|
987
|
+
contentLine: "mbox-code-content-line",
|
|
988
|
+
copyButton: "mbox-code-copy-button",
|
|
989
|
+
info: "mbox-code-info",
|
|
990
|
+
languageLabel: "mbox-code-language-label",
|
|
991
|
+
text: "mbox-code-text"
|
|
992
|
+
}, Be = {
|
|
993
|
+
token: "mbox-code-token"
|
|
994
|
+
};
|
|
995
|
+
function hn(t, e = /* @__PURE__ */ new Set()) {
|
|
996
|
+
return t.blocks.flatMap(
|
|
997
|
+
(n) => n.type === "codeBlock" ? yn(n, e) : []
|
|
998
|
+
);
|
|
999
|
+
}
|
|
1000
|
+
function pn() {
|
|
1001
|
+
return {
|
|
1002
|
+
theme: {
|
|
1003
|
+
[`.${g.block}`]: {
|
|
1004
|
+
fontFamily: 'var(--mbox-code-block-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace)'
|
|
1005
|
+
}
|
|
1006
|
+
},
|
|
1007
|
+
name: "mbox/code-block",
|
|
1008
|
+
decorations: (t) => [
|
|
1009
|
+
...hn(h(t.state), t.activeLineNumbers),
|
|
1010
|
+
...bn(h(t.state), t.activeLineNumbers)
|
|
1011
|
+
]
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
function gn(t = {}) {
|
|
1015
|
+
if (!t.languages)
|
|
1016
|
+
return {
|
|
1017
|
+
name: "mbox/code-block-highlight",
|
|
1018
|
+
decorations: (n) => pe(h(n.state), nn)
|
|
1019
|
+
};
|
|
1020
|
+
const e = mn(
|
|
1021
|
+
(n) => h(n).blocks.filter((o) => o.type === "codeBlock").map((o) => o.infoValue),
|
|
1022
|
+
{
|
|
1023
|
+
...t.languages === "all" ? {} : { languages: t.languages },
|
|
1024
|
+
onLoadError: t.onLoadError
|
|
1025
|
+
}
|
|
1026
|
+
);
|
|
1027
|
+
return {
|
|
1028
|
+
extensions: [e.extension],
|
|
1029
|
+
name: "mbox/code-block-highlight",
|
|
1030
|
+
decorations: (n) => pe(h(n.state), e.getLanguage)
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
function Wr(t) {
|
|
1034
|
+
return t?.type !== "codeBlock" ? null : T(t.infoValue)?.value.toLowerCase() ?? null;
|
|
1035
|
+
}
|
|
1036
|
+
function pe(t, e) {
|
|
1037
|
+
return t.blocks.flatMap((n) => {
|
|
1038
|
+
if (n.type !== "codeBlock")
|
|
1039
|
+
return [];
|
|
1040
|
+
const o = e(n.infoValue);
|
|
1041
|
+
return o ? rn(n.value, n.content.from, o, Be.token) : [];
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
function bn(t, e) {
|
|
1045
|
+
return t.blocks.flatMap((n) => {
|
|
1046
|
+
if (n.type !== "codeBlock")
|
|
1047
|
+
return [];
|
|
1048
|
+
const o = [];
|
|
1049
|
+
e.has(n.line) || o.push({
|
|
1050
|
+
type: "replace",
|
|
1051
|
+
from: n.openingFence.from,
|
|
1052
|
+
to: n.openingFence.from + 3
|
|
1053
|
+
});
|
|
1054
|
+
const r = vn(n);
|
|
1055
|
+
return n.closingFence && !e.has(r) && o.push({
|
|
1056
|
+
type: "replace",
|
|
1057
|
+
from: n.closingFence.from,
|
|
1058
|
+
to: n.closingFence.from + 3
|
|
1059
|
+
}), o;
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
function yn(t, e) {
|
|
1063
|
+
const n = e.has(t.line);
|
|
1064
|
+
return [
|
|
1065
|
+
...kn(t, n),
|
|
1066
|
+
{ ...t.openingFence, className: fn },
|
|
1067
|
+
{ ...t.info, className: g.info },
|
|
1068
|
+
...n ? [] : Nn(t),
|
|
1069
|
+
...n ? [] : xn(t),
|
|
1070
|
+
...Cn(t),
|
|
1071
|
+
...t.closingFence ? [{ ...t.closingFence, className: dn }] : []
|
|
1072
|
+
];
|
|
1073
|
+
}
|
|
1074
|
+
function kn(t, e) {
|
|
1075
|
+
return [
|
|
1076
|
+
{
|
|
1077
|
+
type: "line",
|
|
1078
|
+
from: t.openingFence.from,
|
|
1079
|
+
className: [
|
|
1080
|
+
W,
|
|
1081
|
+
g.block,
|
|
1082
|
+
g.fenceLine,
|
|
1083
|
+
g.openingFenceLine,
|
|
1084
|
+
e ? "" : g.headerLine
|
|
1085
|
+
].filter(Boolean).join(" ")
|
|
1086
|
+
},
|
|
1087
|
+
...sn(t.content, t.value).map((n) => ({
|
|
1088
|
+
type: "line",
|
|
1089
|
+
from: n,
|
|
1090
|
+
className: `${W} ${g.block} ${g.contentLine}`
|
|
1091
|
+
})),
|
|
1092
|
+
...t.closingFence ? [
|
|
1093
|
+
{
|
|
1094
|
+
type: "line",
|
|
1095
|
+
from: t.closingFence.from,
|
|
1096
|
+
className: `${W} ${g.block} ${g.fenceLine} ${g.closingFenceLine}`
|
|
1097
|
+
}
|
|
1098
|
+
] : []
|
|
1099
|
+
];
|
|
1100
|
+
}
|
|
1101
|
+
function xn(t) {
|
|
1102
|
+
return [
|
|
1103
|
+
{
|
|
1104
|
+
type: "widget",
|
|
1105
|
+
from: t.openingFence.to,
|
|
1106
|
+
widget: new Z(t.value, g.copyButton),
|
|
1107
|
+
side: 1
|
|
1108
|
+
}
|
|
1109
|
+
];
|
|
1110
|
+
}
|
|
1111
|
+
function Nn(t) {
|
|
1112
|
+
const e = an(t.infoValue, t.info.from);
|
|
1113
|
+
return e ? [{ ...e, className: g.languageLabel }] : [];
|
|
1114
|
+
}
|
|
1115
|
+
function Cn(t) {
|
|
1116
|
+
return Ln(t).map((e) => ({
|
|
1117
|
+
...e,
|
|
1118
|
+
className: g.text
|
|
1119
|
+
}));
|
|
1120
|
+
}
|
|
1121
|
+
function vn(t) {
|
|
1122
|
+
return t.line + t.value.split(`
|
|
1123
|
+
`).length;
|
|
1124
|
+
}
|
|
1125
|
+
function Ln(t) {
|
|
1126
|
+
const e = [];
|
|
1127
|
+
let n = t.content.from;
|
|
1128
|
+
for (let o = 0; o < t.value.length; o += 1) {
|
|
1129
|
+
if (t.value[o] !== `
|
|
1130
|
+
`)
|
|
1131
|
+
continue;
|
|
1132
|
+
const r = t.content.from + o + 1;
|
|
1133
|
+
n < r && e.push({ from: n, to: r }), n = r;
|
|
1134
|
+
}
|
|
1135
|
+
return n < t.content.to && e.push({ from: n, to: t.content.to }), e;
|
|
1136
|
+
}
|
|
1137
|
+
const z = "mbox-completion-option", Y = "mbox-completion-option-with-preview", _ = "mbox-completion-preview", ee = "mbox-completion-preview-image", Rr = {
|
|
1138
|
+
option: z,
|
|
1139
|
+
optionWithPreview: Y,
|
|
1140
|
+
preview: _,
|
|
1141
|
+
previewImage: ee
|
|
1142
|
+
}, wn = /\[[^[\]]*$/, Sn = {
|
|
1143
|
+
[`.cm-tooltip-autocomplete ul li.${Y}`]: {
|
|
1144
|
+
alignItems: "center",
|
|
1145
|
+
display: "flex",
|
|
1146
|
+
gap: "8px"
|
|
1147
|
+
},
|
|
1148
|
+
[`.${_}`]: {
|
|
1149
|
+
display: "inline-flex",
|
|
1150
|
+
flex: "0 0 auto",
|
|
1151
|
+
marginLeft: "auto"
|
|
1152
|
+
},
|
|
1153
|
+
[`.${ee}`]: {
|
|
1154
|
+
borderRadius: "2px",
|
|
1155
|
+
width: "24px",
|
|
1156
|
+
height: "24px",
|
|
1157
|
+
objectFit: "contain"
|
|
1158
|
+
}
|
|
1159
|
+
};
|
|
1160
|
+
function Fn(t, e) {
|
|
1161
|
+
const n = t.slice(0, e), o = wn.exec(n);
|
|
1162
|
+
if (!o) return null;
|
|
1163
|
+
const r = o.index, a = n.slice(r + 1);
|
|
1164
|
+
if (a.startsWith("^")) return null;
|
|
1165
|
+
const s = t[e] === "]" ? e + 1 : e;
|
|
1166
|
+
return { query: a, from: r, to: s };
|
|
1167
|
+
}
|
|
1168
|
+
function In(t) {
|
|
1169
|
+
return t.type === "icon" ? `[${t.title}.icon]` : `[${t.title}]`;
|
|
1170
|
+
}
|
|
1171
|
+
function $n(t) {
|
|
1172
|
+
return (e) => {
|
|
1173
|
+
const n = e.state.doc.lineAt(e.pos);
|
|
1174
|
+
if (Bn(e.state, n.number)) return null;
|
|
1175
|
+
const o = Fn(n.text, e.pos - n.from);
|
|
1176
|
+
if (!o || o.query.length === 0) return null;
|
|
1177
|
+
const r = t(o.query);
|
|
1178
|
+
return r.length === 0 ? null : {
|
|
1179
|
+
from: n.from + o.from,
|
|
1180
|
+
to: n.from + o.to,
|
|
1181
|
+
filter: !1,
|
|
1182
|
+
options: r.map((a) => ({
|
|
1183
|
+
label: a.title,
|
|
1184
|
+
apply: a.apply ?? In(a),
|
|
1185
|
+
type: "text",
|
|
1186
|
+
iconUrl: a.iconUrl
|
|
1187
|
+
}))
|
|
1188
|
+
};
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1191
|
+
function En(t) {
|
|
1192
|
+
const { iconUrl: e } = t;
|
|
1193
|
+
if (!e) return null;
|
|
1194
|
+
const n = document.createElement("span");
|
|
1195
|
+
n.className = _;
|
|
1196
|
+
const o = document.createElement("img");
|
|
1197
|
+
return o.className = ee, o.src = e, o.alt = "", o.setAttribute("aria-hidden", "true"), n.appendChild(o), n;
|
|
1198
|
+
}
|
|
1199
|
+
function Mn(t) {
|
|
1200
|
+
const { iconUrl: e } = t;
|
|
1201
|
+
return e ? `${z} ${Y}` : z;
|
|
1202
|
+
}
|
|
1203
|
+
function Bn(t, e) {
|
|
1204
|
+
return h(t).blocks.some((o) => {
|
|
1205
|
+
if (o.type !== "codeBlock" && o.type !== "table")
|
|
1206
|
+
return !1;
|
|
1207
|
+
const r = t.doc.lineAt(o.from).number, a = t.doc.lineAt(o.to).number;
|
|
1208
|
+
return r <= e && e <= a;
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
function ge(t, e) {
|
|
1212
|
+
return Nt(e)(t) || Ct(t.state) !== null;
|
|
1213
|
+
}
|
|
1214
|
+
function An(t = {}) {
|
|
1215
|
+
const { recommend: e } = t;
|
|
1216
|
+
return {
|
|
1217
|
+
extensions: e ? [
|
|
1218
|
+
xt({
|
|
1219
|
+
icons: !1,
|
|
1220
|
+
override: [$n(e)],
|
|
1221
|
+
addToOptions: [{ position: 90, render: En }],
|
|
1222
|
+
optionClass: Mn
|
|
1223
|
+
})
|
|
1224
|
+
] : [],
|
|
1225
|
+
keymap: [
|
|
1226
|
+
{ key: "Tab", run: (n) => ge(n, !0) },
|
|
1227
|
+
{ key: "Shift-Tab", run: (n) => ge(n, !1) },
|
|
1228
|
+
...kt
|
|
1229
|
+
],
|
|
1230
|
+
theme: Sn
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
function L(t, e, n) {
|
|
1234
|
+
return t.blocks.flatMap(
|
|
1235
|
+
(o) => e.has(o.line) || !("inline" in o) ? [] : o.inline.flatMap((r) => n(r, o))
|
|
1236
|
+
);
|
|
1237
|
+
}
|
|
1238
|
+
const Tn = "mbox-emoji";
|
|
1239
|
+
class te extends b {
|
|
1240
|
+
constructor(e, n) {
|
|
1241
|
+
super(), this.value = e, this.className = n;
|
|
1242
|
+
}
|
|
1243
|
+
value;
|
|
1244
|
+
className;
|
|
1245
|
+
eq(e) {
|
|
1246
|
+
return e instanceof te && this.value === e.value && this.className === e.className;
|
|
1247
|
+
}
|
|
1248
|
+
toDOM() {
|
|
1249
|
+
const e = document.createElement("span");
|
|
1250
|
+
return e.className = this.className, e.textContent = this.value, e;
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
function Pn() {
|
|
1254
|
+
return {
|
|
1255
|
+
name: "mbox/emoji",
|
|
1256
|
+
decorations: (t) => L(
|
|
1257
|
+
h(t.state),
|
|
1258
|
+
t.activeLineNumbers,
|
|
1259
|
+
(e) => e.type === "emoji" ? [
|
|
1260
|
+
{
|
|
1261
|
+
type: "replace",
|
|
1262
|
+
from: e.from,
|
|
1263
|
+
to: e.to,
|
|
1264
|
+
widget: new te(e.value, Tn)
|
|
1265
|
+
}
|
|
1266
|
+
] : []
|
|
1267
|
+
)
|
|
1268
|
+
};
|
|
1269
|
+
}
|
|
1270
|
+
const Ae = "mbox-footnote", Te = "mbox-footnote-marker", Pe = "mbox-footnote-ref";
|
|
1271
|
+
class On extends b {
|
|
1272
|
+
constructor(e, n, o) {
|
|
1273
|
+
super(), this.label = e, this.note = n, this.targetId = o;
|
|
1274
|
+
}
|
|
1275
|
+
label;
|
|
1276
|
+
note;
|
|
1277
|
+
targetId;
|
|
1278
|
+
eq(e) {
|
|
1279
|
+
const n = e;
|
|
1280
|
+
return this.constructor === e.constructor && this.label === n.label && this.note === n.note && this.targetId === n.targetId;
|
|
1281
|
+
}
|
|
1282
|
+
toDOM() {
|
|
1283
|
+
const e = document.createElement(this.targetId ? "a" : "span");
|
|
1284
|
+
return e.className = Pe, e.textContent = this.label, this.targetId && (e.setAttribute("href", `#${this.targetId}`), e.setAttribute("role", "doc-noteref"), e.setAttribute("aria-label", `Footnote ${this.label}`)), this.note && (e.title = this.note), e;
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
function Wn(t, e) {
|
|
1288
|
+
const n = t.blocks.filter(
|
|
1289
|
+
(s) => s.type === "footnoteDefinition"
|
|
1290
|
+
), o = new Map(n.map((s) => [s.identifier, s])), r = L(
|
|
1291
|
+
t,
|
|
1292
|
+
e,
|
|
1293
|
+
(s) => s.type === "footnoteRef" ? (() => {
|
|
1294
|
+
const i = o.get(s.identifier), l = i && !e.has(i.line) ? `mbox-footnote-${i.from}` : void 0;
|
|
1295
|
+
return [{
|
|
1296
|
+
type: "replace",
|
|
1297
|
+
from: s.from,
|
|
1298
|
+
to: s.to,
|
|
1299
|
+
widget: new On(s.value, i?.value ?? "", l)
|
|
1300
|
+
}];
|
|
1301
|
+
})() : []
|
|
1302
|
+
), a = n.flatMap((s) => {
|
|
1303
|
+
const i = !e.has(s.line), l = i ? { id: `mbox-footnote-${s.from}`, role: "doc-footnote", "aria-label": `Footnote ${s.label}` } : void 0, m = i ? { "aria-hidden": "true" } : void 0;
|
|
1304
|
+
return [
|
|
1305
|
+
{
|
|
1306
|
+
type: "lineRange",
|
|
1307
|
+
from: s.from,
|
|
1308
|
+
to: s.to,
|
|
1309
|
+
className: Ae,
|
|
1310
|
+
...l ? { attributes: l } : {}
|
|
1311
|
+
},
|
|
1312
|
+
{
|
|
1313
|
+
type: "mark",
|
|
1314
|
+
from: s.marker.from,
|
|
1315
|
+
to: s.marker.to,
|
|
1316
|
+
className: Te,
|
|
1317
|
+
...m ? { attributes: m } : {}
|
|
1318
|
+
}
|
|
1319
|
+
];
|
|
1320
|
+
});
|
|
1321
|
+
return [...r, ...a];
|
|
1322
|
+
}
|
|
1323
|
+
const Rn = {
|
|
1324
|
+
[`.${Pe}`]: {
|
|
1325
|
+
display: "inline-block",
|
|
1326
|
+
fontSize: "0.72em",
|
|
1327
|
+
verticalAlign: "text-top",
|
|
1328
|
+
background: "rgba(80, 100, 120, 0.14)",
|
|
1329
|
+
borderRadius: "3px",
|
|
1330
|
+
padding: "0 0.35em",
|
|
1331
|
+
color: "#4d5a66",
|
|
1332
|
+
cursor: "default"
|
|
1333
|
+
},
|
|
1334
|
+
[`.${Ae}`]: {
|
|
1335
|
+
fontSize: "0.86em",
|
|
1336
|
+
color: "#5f6872"
|
|
1337
|
+
},
|
|
1338
|
+
[`.${Te}`]: {
|
|
1339
|
+
color: "#8a949e"
|
|
1340
|
+
}
|
|
1341
|
+
};
|
|
1342
|
+
function Dn() {
|
|
1343
|
+
return {
|
|
1344
|
+
theme: Rn,
|
|
1345
|
+
name: "mbox/footnote",
|
|
1346
|
+
decorations: (t) => Wn(h(t.state), t.activeLineNumbers)
|
|
1347
|
+
};
|
|
1348
|
+
}
|
|
1349
|
+
function Oe(t, e) {
|
|
1350
|
+
const n = t.state.selection.main;
|
|
1351
|
+
if (!n.empty)
|
|
1352
|
+
return !1;
|
|
1353
|
+
const o = t.state.doc.lineAt(n.head);
|
|
1354
|
+
if (n.head !== o.from || o.number <= 1)
|
|
1355
|
+
return !1;
|
|
1356
|
+
const r = o.number - 1, a = h(t.state).blocks.find(
|
|
1357
|
+
(s) => s.line === r && e.includes(s.type)
|
|
1358
|
+
);
|
|
1359
|
+
return a ? (t.dispatch({
|
|
1360
|
+
selection: F.cursor(a.from),
|
|
1361
|
+
scrollIntoView: !0,
|
|
1362
|
+
userEvent: "select"
|
|
1363
|
+
}), !0) : !1;
|
|
1364
|
+
}
|
|
1365
|
+
const Un = "mbox-heading-line", qn = "--mbox-heading-level", N = {
|
|
1366
|
+
h1: "mbox-h1",
|
|
1367
|
+
h2: "mbox-h2",
|
|
1368
|
+
h3: "mbox-h3",
|
|
1369
|
+
h4: "mbox-h4",
|
|
1370
|
+
h5: "mbox-h5",
|
|
1371
|
+
h6: "mbox-h6"
|
|
1372
|
+
};
|
|
1373
|
+
function zn(t) {
|
|
1374
|
+
return N[`h${t}`];
|
|
1375
|
+
}
|
|
1376
|
+
function Vn(t, e) {
|
|
1377
|
+
return t.blocks.flatMap(
|
|
1378
|
+
(n) => n.type === "heading" && !e.has(n.line) && n.content.from !== n.content.to ? [{ type: "replace", from: n.syntax.from, to: n.syntax.to }] : []
|
|
1379
|
+
);
|
|
1380
|
+
}
|
|
1381
|
+
function Hn(t, e) {
|
|
1382
|
+
return t.blocks.flatMap(
|
|
1383
|
+
(n) => n.type === "heading" ? [
|
|
1384
|
+
{
|
|
1385
|
+
type: "line",
|
|
1386
|
+
from: n.from,
|
|
1387
|
+
className: `${e} ${zn(n.level)}`,
|
|
1388
|
+
attributes: {
|
|
1389
|
+
style: `${qn}: ${n.level}`
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
] : []
|
|
1393
|
+
);
|
|
1394
|
+
}
|
|
1395
|
+
function jn() {
|
|
1396
|
+
return {
|
|
1397
|
+
keymap: [
|
|
1398
|
+
{
|
|
1399
|
+
key: "ArrowUp",
|
|
1400
|
+
run: (t) => Oe(t, ["heading"])
|
|
1401
|
+
}
|
|
1402
|
+
],
|
|
1403
|
+
name: "mbox/heading",
|
|
1404
|
+
decorations: (t) => {
|
|
1405
|
+
const e = h(t.state);
|
|
1406
|
+
return [
|
|
1407
|
+
...Hn(e, Un),
|
|
1408
|
+
...Vn(e, t.activeLineNumbers)
|
|
1409
|
+
];
|
|
1410
|
+
}
|
|
1411
|
+
};
|
|
1412
|
+
}
|
|
1413
|
+
function We(t, e) {
|
|
1414
|
+
const n = [G(t.content.from, t.content.to, t.className, t.tagName)];
|
|
1415
|
+
return e && (n.push({ type: "replace", ...t.openMarker }), n.push({ type: "replace", ...t.closeMarker })), n;
|
|
1416
|
+
}
|
|
1417
|
+
const ne = "mbox-inline-code", Dr = {
|
|
1418
|
+
code: ne
|
|
1419
|
+
};
|
|
1420
|
+
function Kn(t, e, n) {
|
|
1421
|
+
return L(
|
|
1422
|
+
t,
|
|
1423
|
+
e,
|
|
1424
|
+
(o) => o.type === "inlineCode" ? We(
|
|
1425
|
+
{ openMarker: o.openingMarker, content: o.content, closeMarker: o.closingMarker, className: n },
|
|
1426
|
+
!0
|
|
1427
|
+
) : []
|
|
1428
|
+
);
|
|
1429
|
+
}
|
|
1430
|
+
function Gn() {
|
|
1431
|
+
return {
|
|
1432
|
+
name: "mbox/inline-code",
|
|
1433
|
+
decorations: (t) => Kn(h(t.state), t.activeLineNumbers, ne)
|
|
1434
|
+
};
|
|
1435
|
+
}
|
|
1436
|
+
const $ = {
|
|
1437
|
+
em: "mbox-em",
|
|
1438
|
+
strong: "mbox-strong",
|
|
1439
|
+
strike: "mbox-strike"
|
|
1440
|
+
};
|
|
1441
|
+
function Jn(t, e, n) {
|
|
1442
|
+
return L(t, e, (o) => Qn(o, n));
|
|
1443
|
+
}
|
|
1444
|
+
function Qn(t, e) {
|
|
1445
|
+
if (!Xn(t))
|
|
1446
|
+
return [];
|
|
1447
|
+
const n = Zn(t, e);
|
|
1448
|
+
return We(
|
|
1449
|
+
{ openMarker: t.openingMarker, content: t.content, closeMarker: t.closingMarker, className: n },
|
|
1450
|
+
!0
|
|
1451
|
+
);
|
|
1452
|
+
}
|
|
1453
|
+
function Xn(t) {
|
|
1454
|
+
return t.type === "emphasis" || t.type === "strong" || t.type === "strikethrough";
|
|
1455
|
+
}
|
|
1456
|
+
function Zn(t, e) {
|
|
1457
|
+
return t.type === "emphasis" ? e.em : t.type === "strong" ? e.strong : t.type === "strikethrough" ? e.strike : e.em;
|
|
1458
|
+
}
|
|
1459
|
+
function Yn() {
|
|
1460
|
+
return {
|
|
1461
|
+
name: "mbox/inline-style",
|
|
1462
|
+
decorations: (t) => Jn(h(t.state), t.activeLineNumbers, $)
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
const R = "mbox-list-syntax-hide", be = "mbox-list-unfocused-line", ye = "mbox-list-focused-line", V = "mbox-list-focused-syntax", Re = "mbox-list-indent", De = "mbox-list-content", ke = "1ch", _n = {
|
|
1466
|
+
ul: "mbox-ul"
|
|
1467
|
+
};
|
|
1468
|
+
class eo extends b {
|
|
1469
|
+
eq() {
|
|
1470
|
+
return !0;
|
|
1471
|
+
}
|
|
1472
|
+
toDOM() {
|
|
1473
|
+
const e = document.createElement("span");
|
|
1474
|
+
return e.className = V, e;
|
|
1475
|
+
}
|
|
1476
|
+
ignoreEvent() {
|
|
1477
|
+
return !1;
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
function to(t, e, n) {
|
|
1481
|
+
return t.blocks.flatMap(
|
|
1482
|
+
(o) => o.type === "listItem" && !e.has(o.line) ? [
|
|
1483
|
+
{
|
|
1484
|
+
type: "line",
|
|
1485
|
+
from: o.from,
|
|
1486
|
+
className: `${n} ${_n.ul}`
|
|
1487
|
+
},
|
|
1488
|
+
{
|
|
1489
|
+
type: "mark",
|
|
1490
|
+
from: o.from,
|
|
1491
|
+
to: o.marker.from,
|
|
1492
|
+
className: Re
|
|
1493
|
+
},
|
|
1494
|
+
G(o.content.from, o.content.to, De)
|
|
1495
|
+
] : []
|
|
1496
|
+
);
|
|
1497
|
+
}
|
|
1498
|
+
function no(t, e, n) {
|
|
1499
|
+
return t.blocks.flatMap(
|
|
1500
|
+
(o) => o.type === "listItem" && !e.has(o.line) ? [{ ...o.syntax, className: n }] : []
|
|
1501
|
+
);
|
|
1502
|
+
}
|
|
1503
|
+
function oo(t, e, n) {
|
|
1504
|
+
return t.blocks.flatMap(
|
|
1505
|
+
(o) => o.type === "listItem" && e.has(o.line) ? [
|
|
1506
|
+
{
|
|
1507
|
+
type: "line",
|
|
1508
|
+
from: o.from,
|
|
1509
|
+
className: n,
|
|
1510
|
+
attributes: {
|
|
1511
|
+
style: `--mbox-list-focused-marker-width: ${o.content.from - o.from}ch; --mbox-list-focused-marker-offset: ${o.marker.from - o.from}ch`
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
] : []
|
|
1515
|
+
);
|
|
1516
|
+
}
|
|
1517
|
+
function ro(t, e) {
|
|
1518
|
+
return t.blocks.flatMap(
|
|
1519
|
+
(n) => n.type === "listItem" && e.has(n.line) ? [
|
|
1520
|
+
{
|
|
1521
|
+
type: "replace",
|
|
1522
|
+
from: n.from,
|
|
1523
|
+
to: n.content.from,
|
|
1524
|
+
widget: new eo()
|
|
1525
|
+
}
|
|
1526
|
+
] : []
|
|
1527
|
+
);
|
|
1528
|
+
}
|
|
1529
|
+
function ao(t) {
|
|
1530
|
+
const e = t.selection.main;
|
|
1531
|
+
if (!e.empty)
|
|
1532
|
+
return null;
|
|
1533
|
+
const n = t.doc.lineAt(e.head);
|
|
1534
|
+
if (e.head !== n.to)
|
|
1535
|
+
return null;
|
|
1536
|
+
const o = h(t);
|
|
1537
|
+
if (w(t, o, n.number))
|
|
1538
|
+
return null;
|
|
1539
|
+
if (/^(\s*)-\s*$/.exec(n.text))
|
|
1540
|
+
return {
|
|
1541
|
+
changes: [{ from: n.from, to: n.to, insert: `
|
|
1542
|
+
` }],
|
|
1543
|
+
selection: n.from + 1
|
|
1544
|
+
};
|
|
1545
|
+
const a = C(o, n.number);
|
|
1546
|
+
if (!a || a.content.from === a.content.to)
|
|
1547
|
+
return null;
|
|
1548
|
+
const s = `${" ".repeat(a.depth)}${a.type === "taskListItem" ? "- [ ] " : "- "}`;
|
|
1549
|
+
return {
|
|
1550
|
+
changes: [{ from: e.head, insert: `
|
|
1551
|
+
${s}` }],
|
|
1552
|
+
selection: e.head + s.length + 1
|
|
1553
|
+
};
|
|
1554
|
+
}
|
|
1555
|
+
function Ue(t, e) {
|
|
1556
|
+
const n = h(t), o = yo(t), r = [];
|
|
1557
|
+
let a;
|
|
1558
|
+
for (const s of o) {
|
|
1559
|
+
const i = t.doc.line(s), l = C(n, s);
|
|
1560
|
+
if (e === "indent") {
|
|
1561
|
+
if (l)
|
|
1562
|
+
r.push({ from: i.from, insert: " " });
|
|
1563
|
+
else if (!w(t, n, s)) {
|
|
1564
|
+
const m = i.text.trim().length > 0 ? " - " : "- ";
|
|
1565
|
+
r.push({ from: i.from, insert: m }), i.text.length === 0 && t.selection.ranges.length === 1 && t.selection.main.empty && (a = i.from + m.length);
|
|
1566
|
+
}
|
|
1567
|
+
continue;
|
|
1568
|
+
}
|
|
1569
|
+
l && (l.depth > 0 ? r.push({ from: i.from, to: i.from + 1, insert: "" }) : r.push({ from: i.from, to: l.content.from, insert: "" }));
|
|
1570
|
+
}
|
|
1571
|
+
return r.length > 0 ? { changes: r, selection: a } : null;
|
|
1572
|
+
}
|
|
1573
|
+
function so(t) {
|
|
1574
|
+
return lo(t) ?? qe(t) ?? ze(t);
|
|
1575
|
+
}
|
|
1576
|
+
function io(t) {
|
|
1577
|
+
return qe(t) ?? ze(t);
|
|
1578
|
+
}
|
|
1579
|
+
function lo(t) {
|
|
1580
|
+
const e = t.selection.main;
|
|
1581
|
+
if (!e.empty || t.selection.ranges.length !== 1)
|
|
1582
|
+
return null;
|
|
1583
|
+
const n = t.doc.lineAt(e.head), o = h(t);
|
|
1584
|
+
if (w(t, o, n.number))
|
|
1585
|
+
return null;
|
|
1586
|
+
const r = C(o, n.number);
|
|
1587
|
+
return !r || r.type !== "listItem" || e.head !== r.content.from ? null : r.depth > 0 ? {
|
|
1588
|
+
changes: [{ from: n.from, to: n.from + 1, insert: "" }],
|
|
1589
|
+
selection: e.head - 1
|
|
1590
|
+
} : {
|
|
1591
|
+
changes: [{ from: n.from, to: r.content.from, insert: "" }],
|
|
1592
|
+
selection: n.from
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
function qe(t) {
|
|
1596
|
+
const e = t.selection.main;
|
|
1597
|
+
if (!e.empty || t.selection.ranges.length !== 1)
|
|
1598
|
+
return null;
|
|
1599
|
+
const n = t.doc.lineAt(e.head), o = h(t);
|
|
1600
|
+
if (w(t, o, n.number))
|
|
1601
|
+
return null;
|
|
1602
|
+
const r = C(o, n.number);
|
|
1603
|
+
return !r || r.type !== "listItem" || r.depth <= 0 || e.head <= r.from || e.head > r.marker.from ? null : {
|
|
1604
|
+
changes: [{ from: e.head - 1, to: e.head, insert: "" }],
|
|
1605
|
+
selection: e.head - 1
|
|
1606
|
+
};
|
|
1607
|
+
}
|
|
1608
|
+
function ze(t) {
|
|
1609
|
+
const e = t.selection.main;
|
|
1610
|
+
if (!e.empty || t.selection.ranges.length !== 1)
|
|
1611
|
+
return null;
|
|
1612
|
+
const n = t.doc.lineAt(e.head), o = h(t);
|
|
1613
|
+
if (w(t, o, n.number))
|
|
1614
|
+
return null;
|
|
1615
|
+
const r = C(o, n.number);
|
|
1616
|
+
return !r || r.type !== "listItem" || r.content.from !== r.content.to || e.head !== r.content.from ? null : r.depth > 0 ? {
|
|
1617
|
+
changes: [{ from: n.from, to: n.from + 1, insert: "" }],
|
|
1618
|
+
selection: e.head - 1
|
|
1619
|
+
} : {
|
|
1620
|
+
changes: [{ from: n.from, to: r.content.from, insert: "" }],
|
|
1621
|
+
selection: n.from
|
|
1622
|
+
};
|
|
1623
|
+
}
|
|
1624
|
+
function co(t) {
|
|
1625
|
+
const e = t.selection.main;
|
|
1626
|
+
if (!e.empty || t.selection.ranges.length !== 1)
|
|
1627
|
+
return null;
|
|
1628
|
+
const n = t.doc.lineAt(e.head), o = h(t);
|
|
1629
|
+
if (w(t, o, n.number))
|
|
1630
|
+
return null;
|
|
1631
|
+
const r = C(o, n.number);
|
|
1632
|
+
return r?.type === "listItem" && r.content.from === r.content.to && e.head === r.content.from ? {
|
|
1633
|
+
changes: [{ from: n.from, insert: " " }],
|
|
1634
|
+
selection: e.head + 1
|
|
1635
|
+
} : null;
|
|
1636
|
+
}
|
|
1637
|
+
function uo(t) {
|
|
1638
|
+
const e = h(t);
|
|
1639
|
+
let n = !1;
|
|
1640
|
+
const o = F.create(
|
|
1641
|
+
t.selection.ranges.map((r) => {
|
|
1642
|
+
const a = t.doc.lineAt(r.head), s = C(e, a.number);
|
|
1643
|
+
return !s || s.type !== "listItem" ? F.cursor(r.head) : (n = !0, F.cursor(s.content.from));
|
|
1644
|
+
}),
|
|
1645
|
+
t.selection.mainIndex
|
|
1646
|
+
);
|
|
1647
|
+
return !n || o.eq(t.selection) ? null : o.main.head;
|
|
1648
|
+
}
|
|
1649
|
+
function mo(t) {
|
|
1650
|
+
const e = ao(t.state);
|
|
1651
|
+
return e ? (t.dispatch({
|
|
1652
|
+
changes: e.changes,
|
|
1653
|
+
selection: { anchor: e.selection }
|
|
1654
|
+
}), !0) : !1;
|
|
1655
|
+
}
|
|
1656
|
+
function fo(t) {
|
|
1657
|
+
const e = Ue(t.state, "indent");
|
|
1658
|
+
return e ? (t.dispatch({
|
|
1659
|
+
changes: e.changes,
|
|
1660
|
+
selection: e.selection == null ? void 0 : { anchor: e.selection }
|
|
1661
|
+
}), !0) : !1;
|
|
1662
|
+
}
|
|
1663
|
+
function ho(t) {
|
|
1664
|
+
const e = Ue(t.state, "outdent");
|
|
1665
|
+
return e ? (t.dispatch({ changes: e.changes }), !0) : !1;
|
|
1666
|
+
}
|
|
1667
|
+
function xe(t) {
|
|
1668
|
+
const e = so(t.state);
|
|
1669
|
+
return e ? (t.dispatch({
|
|
1670
|
+
changes: e.changes,
|
|
1671
|
+
selection: { anchor: e.selection }
|
|
1672
|
+
}), !0) : !1;
|
|
1673
|
+
}
|
|
1674
|
+
function po(t) {
|
|
1675
|
+
const e = io(t.state);
|
|
1676
|
+
return e ? (t.dispatch({
|
|
1677
|
+
changes: e.changes,
|
|
1678
|
+
selection: { anchor: e.selection }
|
|
1679
|
+
}), !0) : !1;
|
|
1680
|
+
}
|
|
1681
|
+
function go(t) {
|
|
1682
|
+
const e = co(t.state);
|
|
1683
|
+
return e ? (t.dispatch({
|
|
1684
|
+
changes: e.changes,
|
|
1685
|
+
selection: { anchor: e.selection }
|
|
1686
|
+
}), !0) : !1;
|
|
1687
|
+
}
|
|
1688
|
+
function bo(t) {
|
|
1689
|
+
const e = uo(t.state);
|
|
1690
|
+
return e == null ? !1 : (t.dispatch({
|
|
1691
|
+
selection: { anchor: e },
|
|
1692
|
+
scrollIntoView: !0
|
|
1693
|
+
}), !0);
|
|
1694
|
+
}
|
|
1695
|
+
function yo(t) {
|
|
1696
|
+
const e = /* @__PURE__ */ new Set();
|
|
1697
|
+
for (const n of t.selection.ranges) {
|
|
1698
|
+
const o = t.doc.lineAt(n.from), r = t.doc.lineAt(ko(n));
|
|
1699
|
+
for (let a = o.number; a <= r.number; a += 1)
|
|
1700
|
+
e.add(a);
|
|
1701
|
+
}
|
|
1702
|
+
return [...e].sort((n, o) => n - o);
|
|
1703
|
+
}
|
|
1704
|
+
function ko(t) {
|
|
1705
|
+
return t.empty ? t.to : Math.max(t.from, t.to - 1);
|
|
1706
|
+
}
|
|
1707
|
+
function C(t, e) {
|
|
1708
|
+
return t.blocks.find(
|
|
1709
|
+
(n) => (n.type === "listItem" || n.type === "taskListItem") && n.line === e
|
|
1710
|
+
) ?? null;
|
|
1711
|
+
}
|
|
1712
|
+
function w(t, e, n) {
|
|
1713
|
+
return e.blocks.some((o) => {
|
|
1714
|
+
if (o.type !== "codeBlock")
|
|
1715
|
+
return !1;
|
|
1716
|
+
const r = t.doc.lineAt(o.from).number, a = t.doc.lineAt(o.to).number;
|
|
1717
|
+
return r <= n && n <= a;
|
|
1718
|
+
});
|
|
1719
|
+
}
|
|
1720
|
+
function xo() {
|
|
1721
|
+
return {
|
|
1722
|
+
theme: {
|
|
1723
|
+
[`.${ye}`]: {
|
|
1724
|
+
boxSizing: "border-box",
|
|
1725
|
+
paddingLeft: "calc(6px + var(--mbox-list-focused-marker-width))",
|
|
1726
|
+
textIndent: "calc(-1 * var(--mbox-list-focused-marker-width))"
|
|
1727
|
+
},
|
|
1728
|
+
[`.${V}`]: {
|
|
1729
|
+
display: "inline-block",
|
|
1730
|
+
flexShrink: "0",
|
|
1731
|
+
height: "0.6em",
|
|
1732
|
+
position: "relative",
|
|
1733
|
+
verticalAlign: "baseline",
|
|
1734
|
+
whiteSpace: "pre",
|
|
1735
|
+
width: "var(--mbox-list-focused-marker-width)"
|
|
1736
|
+
},
|
|
1737
|
+
[`.${V}::after`]: {
|
|
1738
|
+
content: '""',
|
|
1739
|
+
position: "absolute",
|
|
1740
|
+
left: "var(--mbox-list-focused-marker-offset)",
|
|
1741
|
+
top: "calc(50% - 1px)",
|
|
1742
|
+
width: ke,
|
|
1743
|
+
height: "2px",
|
|
1744
|
+
borderRadius: "999px",
|
|
1745
|
+
background: "var(--mbox-list-marker-color, #222)",
|
|
1746
|
+
pointerEvents: "none"
|
|
1747
|
+
},
|
|
1748
|
+
[`.${be}`]: {
|
|
1749
|
+
alignItems: "start",
|
|
1750
|
+
display: "flex"
|
|
1751
|
+
},
|
|
1752
|
+
[`.${Re}`]: {
|
|
1753
|
+
flexShrink: "0",
|
|
1754
|
+
whiteSpace: "pre"
|
|
1755
|
+
},
|
|
1756
|
+
[`.${De}`]: {
|
|
1757
|
+
display: "block",
|
|
1758
|
+
minWidth: "0",
|
|
1759
|
+
overflowWrap: "anywhere"
|
|
1760
|
+
},
|
|
1761
|
+
[`.${R}`]: {
|
|
1762
|
+
flexShrink: "0",
|
|
1763
|
+
position: "relative",
|
|
1764
|
+
visibility: "hidden",
|
|
1765
|
+
whiteSpace: "pre"
|
|
1766
|
+
},
|
|
1767
|
+
[`.${R}::after`]: {
|
|
1768
|
+
content: '""',
|
|
1769
|
+
position: "absolute",
|
|
1770
|
+
left: "0",
|
|
1771
|
+
top: "0",
|
|
1772
|
+
width: ke,
|
|
1773
|
+
height: "100%",
|
|
1774
|
+
clipPath: "circle(0.2em at center)",
|
|
1775
|
+
background: "var(--mbox-list-bullet-color, #222)",
|
|
1776
|
+
pointerEvents: "none",
|
|
1777
|
+
visibility: "visible"
|
|
1778
|
+
}
|
|
1779
|
+
},
|
|
1780
|
+
keymap: [
|
|
1781
|
+
{ key: "Enter", run: mo },
|
|
1782
|
+
{ key: "Tab", run: fo },
|
|
1783
|
+
{ key: "Shift-Tab", run: ho },
|
|
1784
|
+
{ key: "Backspace", run: xe },
|
|
1785
|
+
{ key: "Ctrl-h", run: xe },
|
|
1786
|
+
{ key: "Ctrl-a", run: bo },
|
|
1787
|
+
{ key: "Delete", run: po },
|
|
1788
|
+
{ key: "Space", run: go }
|
|
1789
|
+
],
|
|
1790
|
+
name: "mbox/list",
|
|
1791
|
+
decorations: (t) => {
|
|
1792
|
+
const e = h(t.state);
|
|
1793
|
+
return [
|
|
1794
|
+
...oo(e, t.activeLineNumbers, ye),
|
|
1795
|
+
...ro(e, t.activeLineNumbers),
|
|
1796
|
+
...to(e, t.activeLineNumbers, be),
|
|
1797
|
+
...no(e, t.activeLineNumbers, R)
|
|
1798
|
+
];
|
|
1799
|
+
}
|
|
1800
|
+
};
|
|
1801
|
+
}
|
|
1802
|
+
function Ve(t, e) {
|
|
1803
|
+
return !(typeof e == "string" ? e.slice(t.from, t.to) : e.sliceString(t.from, t.to)).includes(`
|
|
1804
|
+
`);
|
|
1805
|
+
}
|
|
1806
|
+
function Ur(t, e, n, o) {
|
|
1807
|
+
return e || !Ve(t, n) ? [] : [{ type: "replace", from: t.from, to: t.to, widget: o() }];
|
|
1808
|
+
}
|
|
1809
|
+
function He(t) {
|
|
1810
|
+
const e = document.createElement("a");
|
|
1811
|
+
e.className = t.className, e.setAttribute("href", t.href), e.textContent = t.text;
|
|
1812
|
+
for (const [n, o] of Object.entries(t.attributes ?? {}))
|
|
1813
|
+
o !== void 0 && e.setAttribute(n, o);
|
|
1814
|
+
return e;
|
|
1815
|
+
}
|
|
1816
|
+
function oe(t) {
|
|
1817
|
+
return t.className ? ` ${t.className}` : "";
|
|
1818
|
+
}
|
|
1819
|
+
function je(t, e, n) {
|
|
1820
|
+
const o = document.createElement("img");
|
|
1821
|
+
return o.className = n, o.src = t, o.alt = e, o.loading = "lazy", o.decoding = "async", o;
|
|
1822
|
+
}
|
|
1823
|
+
class re extends b {
|
|
1824
|
+
constructor(e, n) {
|
|
1825
|
+
super(), this.image = e, this.classNames = n;
|
|
1826
|
+
}
|
|
1827
|
+
image;
|
|
1828
|
+
classNames;
|
|
1829
|
+
eq(e) {
|
|
1830
|
+
return e instanceof re && this.constructor === e.constructor && this.image.src === e.image.src && this.image.alt === e.image.alt && this.image.text === e.image.text && this.image.link === e.image.link && this.image.className === e.image.className && this.classNames === e.classNames;
|
|
1831
|
+
}
|
|
1832
|
+
toDOM() {
|
|
1833
|
+
const e = document.createElement("span");
|
|
1834
|
+
return e.className = `${this.classNames.image} ${this.classNames.token}${oe(this.image)}`, e.dataset.src = this.image.src, this.image.alt !== void 0 && (e.dataset.alt = this.image.alt), this.image.link && (e.dataset.link = this.image.link), e.textContent = this.image.text ?? this.image.alt ?? this.image.src, e;
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
class ae extends b {
|
|
1838
|
+
constructor(e, n) {
|
|
1839
|
+
super(), this.image = e, this.classNames = n;
|
|
1840
|
+
}
|
|
1841
|
+
image;
|
|
1842
|
+
classNames;
|
|
1843
|
+
eq(e) {
|
|
1844
|
+
return e instanceof ae && this.constructor === e.constructor && this.image.src === e.image.src && this.image.alt === e.image.alt && this.image.link === e.image.link && this.image.className === e.image.className && this.classNames === e.classNames;
|
|
1845
|
+
}
|
|
1846
|
+
toDOM() {
|
|
1847
|
+
const e = document.createElement("figure");
|
|
1848
|
+
e.className = `${this.classNames.image} ${this.classNames.preview}${oe(this.image)}`, e.dataset.src = this.image.src, this.image.alt !== void 0 && (e.dataset.alt = this.image.alt), e.setAttribute("role", "figure");
|
|
1849
|
+
const n = je(this.image.src, this.image.alt ?? "", this.classNames.element);
|
|
1850
|
+
if (this.image.link) {
|
|
1851
|
+
const o = document.createElement("a");
|
|
1852
|
+
o.setAttribute("href", this.image.link), o.setAttribute("target", "_blank"), o.setAttribute("rel", "noreferrer"), o.appendChild(n), e.appendChild(o);
|
|
1853
|
+
} else
|
|
1854
|
+
e.appendChild(n);
|
|
1855
|
+
return e;
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
class P extends b {
|
|
1859
|
+
constructor(e, n, o) {
|
|
1860
|
+
super(), this.image = e, this.classNames = n, this.measureClassNames = o;
|
|
1861
|
+
}
|
|
1862
|
+
image;
|
|
1863
|
+
classNames;
|
|
1864
|
+
measureClassNames;
|
|
1865
|
+
eq(e) {
|
|
1866
|
+
return e instanceof P && this.constructor === e.constructor && this.image.src === e.image.src && this.image.alt === e.image.alt && this.image.className === e.image.className && this.classNames === e.classNames && this.measureClassNames === e.measureClassNames;
|
|
1867
|
+
}
|
|
1868
|
+
toDOM() {
|
|
1869
|
+
return this.renderFigure();
|
|
1870
|
+
}
|
|
1871
|
+
/**
|
|
1872
|
+
* The hidden, correctly-sized preview figure whose intrinsic size reserves the
|
|
1873
|
+
* space the visible preview would occupy. Exposed so a subclass can reuse or
|
|
1874
|
+
* customize it (e.g. to reserve only its height, not its width) without
|
|
1875
|
+
* re-deriving the class list and image attributes.
|
|
1876
|
+
*/
|
|
1877
|
+
renderFigure() {
|
|
1878
|
+
const e = document.createElement("figure");
|
|
1879
|
+
return e.className = `${this.classNames.image} ${this.classNames.preview} ${this.measureClassNames.measure}${oe(this.image)}`, e.dataset.src = this.image.src, this.image.alt !== void 0 && (e.dataset.alt = this.image.alt), e.setAttribute("aria-hidden", "true"), e.appendChild(je(this.image.src, "", this.classNames.element)), e;
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
function No(t) {
|
|
1883
|
+
const { from: e, to: n, ...o } = t;
|
|
1884
|
+
return o;
|
|
1885
|
+
}
|
|
1886
|
+
const Ne = /* @__PURE__ */ Symbol("mboxMeasureObserver");
|
|
1887
|
+
class qr extends P {
|
|
1888
|
+
toDOM() {
|
|
1889
|
+
const e = this.renderFigure();
|
|
1890
|
+
if (e.style.marginInlineEnd = "0px", typeof ResizeObserver < "u") {
|
|
1891
|
+
const n = new ResizeObserver(([o]) => {
|
|
1892
|
+
const a = `-${o?.borderBoxSize?.[0]?.inlineSize ?? e.offsetWidth}px`;
|
|
1893
|
+
e.style.marginInlineEnd !== a && (e.style.marginInlineEnd = a);
|
|
1894
|
+
});
|
|
1895
|
+
n.observe(e), e[Ne] = n;
|
|
1896
|
+
}
|
|
1897
|
+
return e;
|
|
1898
|
+
}
|
|
1899
|
+
destroy(e) {
|
|
1900
|
+
e[Ne]?.disconnect();
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
function Co(t, e, n, o, r, a, s = {}) {
|
|
1904
|
+
const i = s.token ?? ((c, u) => new re(c, u)), l = s.preview ?? ((c, u) => new ae(c, u)), m = s.measure ?? ((c, u, f) => new P(c, u, f));
|
|
1905
|
+
return t.flatMap((c) => {
|
|
1906
|
+
const u = No(c);
|
|
1907
|
+
return Ve(c, n) ? e ? a === "preview" ? [
|
|
1908
|
+
{
|
|
1909
|
+
type: "widget",
|
|
1910
|
+
from: c.from,
|
|
1911
|
+
widget: m(u, o, r),
|
|
1912
|
+
side: -1
|
|
1913
|
+
}
|
|
1914
|
+
] : [] : [
|
|
1915
|
+
{
|
|
1916
|
+
type: "replace",
|
|
1917
|
+
from: c.from,
|
|
1918
|
+
to: c.to,
|
|
1919
|
+
widget: a === "preview" ? l(u, o) : i(u, o)
|
|
1920
|
+
}
|
|
1921
|
+
] : [];
|
|
1922
|
+
});
|
|
1923
|
+
}
|
|
1924
|
+
function vo(t, e) {
|
|
1925
|
+
return {
|
|
1926
|
+
[`.${t.preview}`]: {
|
|
1927
|
+
display: "inline-block",
|
|
1928
|
+
margin: "0",
|
|
1929
|
+
verticalAlign: "top"
|
|
1930
|
+
},
|
|
1931
|
+
[`.${e.measure}`]: {
|
|
1932
|
+
display: "inline-block",
|
|
1933
|
+
margin: "0",
|
|
1934
|
+
verticalAlign: "top",
|
|
1935
|
+
visibility: "hidden",
|
|
1936
|
+
pointerEvents: "none"
|
|
1937
|
+
},
|
|
1938
|
+
[`.${t.element}`]: {
|
|
1939
|
+
display: "block",
|
|
1940
|
+
height: "auto"
|
|
1941
|
+
}
|
|
1942
|
+
};
|
|
1943
|
+
}
|
|
1944
|
+
const Lo = "mbox-image", wo = "mbox-image-token", So = "mbox-image-preview", Fo = "mbox-image-element", Io = "mbox-image-measure", Ce = {
|
|
1945
|
+
image: Lo,
|
|
1946
|
+
token: wo,
|
|
1947
|
+
preview: So,
|
|
1948
|
+
element: Fo
|
|
1949
|
+
}, Ke = {
|
|
1950
|
+
measure: Io
|
|
1951
|
+
}, ve = {
|
|
1952
|
+
renderMode: "token"
|
|
1953
|
+
};
|
|
1954
|
+
function $o(t, e, n, o, r = ve) {
|
|
1955
|
+
const a = r.renderMode ?? ve.renderMode;
|
|
1956
|
+
return t.blocks.flatMap(
|
|
1957
|
+
(s) => "inline" in s ? Co(
|
|
1958
|
+
s.inline.flatMap(
|
|
1959
|
+
(i) => i.type === "markdownImage" ? [{ from: i.from, to: i.to, src: i.urlValue, alt: i.altValue, text: i.altValue || i.urlValue }] : []
|
|
1960
|
+
),
|
|
1961
|
+
n.has(s.line),
|
|
1962
|
+
e,
|
|
1963
|
+
o,
|
|
1964
|
+
Ke,
|
|
1965
|
+
a
|
|
1966
|
+
) : []
|
|
1967
|
+
);
|
|
1968
|
+
}
|
|
1969
|
+
function Eo(t = {}) {
|
|
1970
|
+
return {
|
|
1971
|
+
theme: vo(Ce, Ke),
|
|
1972
|
+
name: "mbox/markdown-image",
|
|
1973
|
+
decorations: (e) => $o(h(e.state), e.state.doc, e.activeLineNumbers, Ce, t)
|
|
1974
|
+
};
|
|
1975
|
+
}
|
|
1976
|
+
const Ge = "mbox-page-link", Je = "mbox-icon", Qe = "mbox-icon-image", Mo = (t) => `./${t}`;
|
|
1977
|
+
class se extends b {
|
|
1978
|
+
constructor(e, n, o) {
|
|
1979
|
+
super(), this.href = e, this.value = n, this.className = o;
|
|
1980
|
+
}
|
|
1981
|
+
href;
|
|
1982
|
+
value;
|
|
1983
|
+
className;
|
|
1984
|
+
eq(e) {
|
|
1985
|
+
return e instanceof se && this.href === e.href && this.value === e.value && this.className === e.className;
|
|
1986
|
+
}
|
|
1987
|
+
toDOM() {
|
|
1988
|
+
return He({ href: this.href, text: this.value, className: this.className });
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
class ie extends b {
|
|
1992
|
+
constructor(e, n, o) {
|
|
1993
|
+
super(), this.href = e, this.name = n, this.iconUrl = o;
|
|
1994
|
+
}
|
|
1995
|
+
href;
|
|
1996
|
+
name;
|
|
1997
|
+
iconUrl;
|
|
1998
|
+
eq(e) {
|
|
1999
|
+
return e instanceof ie && this.href === e.href && this.name === e.name && this.iconUrl === e.iconUrl;
|
|
2000
|
+
}
|
|
2001
|
+
toDOM() {
|
|
2002
|
+
const e = document.createElement("a");
|
|
2003
|
+
if (e.className = Je, e.setAttribute("href", this.href), e.setAttribute("title", this.name), this.iconUrl) {
|
|
2004
|
+
const n = document.createElement("img");
|
|
2005
|
+
n.className = Qe, n.src = this.iconUrl, n.alt = this.name, e.appendChild(n);
|
|
2006
|
+
} else
|
|
2007
|
+
e.textContent = this.name;
|
|
2008
|
+
return e;
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
function Bo(t, e, n, o, r, a) {
|
|
2012
|
+
const s = [];
|
|
2013
|
+
for (const i of t.blocks)
|
|
2014
|
+
if ("inline" in i)
|
|
2015
|
+
for (const l of i.inline)
|
|
2016
|
+
l.type === "wikiLink" && e.has(i.line) && s.push({
|
|
2017
|
+
type: "mark",
|
|
2018
|
+
from: l.from,
|
|
2019
|
+
to: l.to,
|
|
2020
|
+
className: n
|
|
2021
|
+
});
|
|
2022
|
+
return s.push(...L(t, e, (i) => i.type === "wikiLink" ? [
|
|
2023
|
+
{
|
|
2024
|
+
type: "replace",
|
|
2025
|
+
from: i.from,
|
|
2026
|
+
to: i.to,
|
|
2027
|
+
widget: new se(o(i.value), i.value, n)
|
|
2028
|
+
}
|
|
2029
|
+
] : a && i.type === "icon" ? [
|
|
2030
|
+
{
|
|
2031
|
+
type: "replace",
|
|
2032
|
+
from: i.from,
|
|
2033
|
+
to: i.to,
|
|
2034
|
+
widget: new ie(o(i.value), i.value, r?.(i.value))
|
|
2035
|
+
}
|
|
2036
|
+
] : [])), s;
|
|
2037
|
+
}
|
|
2038
|
+
function Ao(t = {}) {
|
|
2039
|
+
const e = t.pageUrl ?? Mo, n = t.icons ?? !0;
|
|
2040
|
+
return {
|
|
2041
|
+
theme: {
|
|
2042
|
+
[`.${Je}`]: {
|
|
2043
|
+
textDecoration: "none"
|
|
2044
|
+
},
|
|
2045
|
+
[`.${Qe}`]: {
|
|
2046
|
+
height: "1em",
|
|
2047
|
+
width: "auto",
|
|
2048
|
+
verticalAlign: "text-bottom"
|
|
2049
|
+
}
|
|
2050
|
+
},
|
|
2051
|
+
name: "mbox/page-link",
|
|
2052
|
+
decorations: (o) => Bo(
|
|
2053
|
+
h(o.state),
|
|
2054
|
+
o.activeLineNumbers,
|
|
2055
|
+
Ge,
|
|
2056
|
+
e,
|
|
2057
|
+
t.iconUrl,
|
|
2058
|
+
n
|
|
2059
|
+
)
|
|
2060
|
+
};
|
|
2061
|
+
}
|
|
2062
|
+
const D = {
|
|
2063
|
+
paragraph: "mbox-paragraph",
|
|
2064
|
+
emptyLine: "mbox-empty-line"
|
|
2065
|
+
};
|
|
2066
|
+
function To(t) {
|
|
2067
|
+
return t.blocks.flatMap((e) => {
|
|
2068
|
+
if (e.type !== "paragraph")
|
|
2069
|
+
return [];
|
|
2070
|
+
const n = e.content.from === e.content.to;
|
|
2071
|
+
return [
|
|
2072
|
+
{
|
|
2073
|
+
type: "line",
|
|
2074
|
+
from: e.from,
|
|
2075
|
+
className: n ? `${D.paragraph} ${D.emptyLine}` : D.paragraph
|
|
2076
|
+
}
|
|
2077
|
+
];
|
|
2078
|
+
});
|
|
2079
|
+
}
|
|
2080
|
+
function Po() {
|
|
2081
|
+
return {
|
|
2082
|
+
name: "mbox/paragraph",
|
|
2083
|
+
decorations: (t) => To(h(t.state))
|
|
2084
|
+
};
|
|
2085
|
+
}
|
|
2086
|
+
const Oo = "mbox-quote-line", Xe = {
|
|
2087
|
+
quote: "mbox-quote"
|
|
2088
|
+
};
|
|
2089
|
+
function Wo(t, e) {
|
|
2090
|
+
return t.blocks.flatMap(
|
|
2091
|
+
(n) => n.type === "quote" && !e.has(n.line) ? [{ ...n.syntax, type: "replace" }] : []
|
|
2092
|
+
);
|
|
2093
|
+
}
|
|
2094
|
+
function Ro(t, e) {
|
|
2095
|
+
return t.blocks.flatMap(
|
|
2096
|
+
(n) => n.type === "quote" ? [
|
|
2097
|
+
{
|
|
2098
|
+
type: "line",
|
|
2099
|
+
from: n.from,
|
|
2100
|
+
className: `${e} ${Xe.quote}`
|
|
2101
|
+
}
|
|
2102
|
+
] : []
|
|
2103
|
+
);
|
|
2104
|
+
}
|
|
2105
|
+
function Do() {
|
|
2106
|
+
return {
|
|
2107
|
+
keymap: [
|
|
2108
|
+
{
|
|
2109
|
+
key: "ArrowUp",
|
|
2110
|
+
run: (t) => Oe(t, ["quote"])
|
|
2111
|
+
}
|
|
2112
|
+
],
|
|
2113
|
+
name: "mbox/quote",
|
|
2114
|
+
decorations: (t) => {
|
|
2115
|
+
const e = h(t.state);
|
|
2116
|
+
return [
|
|
2117
|
+
...Ro(e, Oo),
|
|
2118
|
+
...Wo(e, t.activeLineNumbers)
|
|
2119
|
+
];
|
|
2120
|
+
}
|
|
2121
|
+
};
|
|
2122
|
+
}
|
|
2123
|
+
const Uo = "--mbox-table-kit-column-width", qo = "--mbox-table-kit-cell-max-width", zo = new RegExp(
|
|
2124
|
+
"[" + [
|
|
2125
|
+
"\\u1100-\\u115F",
|
|
2126
|
+
// Hangul Jamo
|
|
2127
|
+
"\\u2E80-\\u303E",
|
|
2128
|
+
// CJK Radicals Supplement through CJK Symbols and Punctuation
|
|
2129
|
+
"\\u3041-\\u33FF",
|
|
2130
|
+
// Hiragana, Katakana, Bopomofo, and CJK Compatibility
|
|
2131
|
+
"\\u3400-\\u4DBF",
|
|
2132
|
+
// CJK Unified Ideographs Extension A
|
|
2133
|
+
"\\u4E00-\\u9FFF",
|
|
2134
|
+
// CJK Unified Ideographs
|
|
2135
|
+
"\\uA000-\\uA4CF",
|
|
2136
|
+
// Yi Syllables and Yi Radicals
|
|
2137
|
+
"\\uA960-\\uA97C",
|
|
2138
|
+
// Hangul Jamo Extended-A
|
|
2139
|
+
"\\uAC00-\\uD7A3",
|
|
2140
|
+
// Hangul Syllables
|
|
2141
|
+
"\\uF900-\\uFAFF",
|
|
2142
|
+
// CJK Compatibility Ideographs
|
|
2143
|
+
"\\uFE30-\\uFE4F",
|
|
2144
|
+
// CJK Compatibility Forms
|
|
2145
|
+
"\\uFF01-\\uFF60",
|
|
2146
|
+
// Fullwidth ASCII variants and halfwidth punctuation
|
|
2147
|
+
"\\uFFE0-\\uFFE6",
|
|
2148
|
+
// Fullwidth symbol variants
|
|
2149
|
+
"\\u{20000}-\\u{2FFFD}",
|
|
2150
|
+
// CJK Unified Ideographs Extensions B–F
|
|
2151
|
+
"\\u{30000}-\\u{3FFFD}",
|
|
2152
|
+
// CJK Unified Ideographs Extensions G and later
|
|
2153
|
+
"\\u{1F300}-\\u{1FAFF}"
|
|
2154
|
+
// emoji pictographs and symbols
|
|
2155
|
+
].join("") + "]",
|
|
2156
|
+
"u"
|
|
2157
|
+
);
|
|
2158
|
+
function Vo(t) {
|
|
2159
|
+
let e = 0;
|
|
2160
|
+
for (const n of t)
|
|
2161
|
+
e += zo.test(n) ? 2 : 1;
|
|
2162
|
+
return e;
|
|
2163
|
+
}
|
|
2164
|
+
function Ze(t) {
|
|
2165
|
+
return t.content.from < t.content.to ? t.content : t;
|
|
2166
|
+
}
|
|
2167
|
+
function Ho(t, e, n, o) {
|
|
2168
|
+
const r = o && !t.some((l) => e.has(l.line)) ? t.filter((l) => l.includeInColumnWidths !== !1) : [], a = o ? r[o.headerRowIndex ?? 0] : void 0, s = new Map(r.map((l, m) => [l, `${o.tableId}-row-${m}`])), i = r.filter((l) => l !== a).map((l) => s.get(l));
|
|
2169
|
+
return t.map((l) => {
|
|
2170
|
+
const m = Math.max(l.cells.length, 1), c = !e.has(l.line), u = l.className ? `${n.table} ${l.className}` : n.table, f = { style: `${qo}: ${100 / m}%`, ...l.attributes };
|
|
2171
|
+
return l === a ? Object.assign(f, {
|
|
2172
|
+
id: o.tableId,
|
|
2173
|
+
role: "table",
|
|
2174
|
+
"aria-rowcount": String(r.length),
|
|
2175
|
+
"aria-colcount": String(o.columnCount ?? Math.max(...r.map((d) => d.cells.length), 1)),
|
|
2176
|
+
...i.length > 0 ? { "aria-owns": i.join(" ") } : {}
|
|
2177
|
+
}) : s.has(l) && Object.assign(f, { id: s.get(l), role: "row" }), (l === a || s.has(l)) && (f.style += "; display: flex !important"), {
|
|
2178
|
+
type: "line",
|
|
2179
|
+
from: l.from,
|
|
2180
|
+
className: c ? `${u} ${n.renderedLine}` : u,
|
|
2181
|
+
attributes: f
|
|
2182
|
+
};
|
|
2183
|
+
});
|
|
2184
|
+
}
|
|
2185
|
+
function jo(t, e) {
|
|
2186
|
+
const n = [];
|
|
2187
|
+
for (const o of t)
|
|
2188
|
+
o.includeInColumnWidths !== !1 && o.cells.forEach((r, a) => {
|
|
2189
|
+
const s = r.displayValue ?? r.value.trim();
|
|
2190
|
+
n[a] = Math.max(n[a] ?? 0, e(s), r.minimumColumnWidth ?? 0);
|
|
2191
|
+
});
|
|
2192
|
+
return n;
|
|
2193
|
+
}
|
|
2194
|
+
class I extends b {
|
|
2195
|
+
constructor(e, n, o) {
|
|
2196
|
+
super(), this.className = e, this.style = n, this.attributes = o;
|
|
2197
|
+
}
|
|
2198
|
+
className;
|
|
2199
|
+
style;
|
|
2200
|
+
attributes;
|
|
2201
|
+
eq(e) {
|
|
2202
|
+
return e instanceof I && this.className === e.className && this.style === e.style && JSON.stringify(this.attributes) === JSON.stringify(e.attributes);
|
|
2203
|
+
}
|
|
2204
|
+
toDOM() {
|
|
2205
|
+
const e = document.createElement("span");
|
|
2206
|
+
e.className = this.className, this.style !== void 0 && e.setAttribute("style", this.style);
|
|
2207
|
+
for (const [n, o] of Object.entries(this.attributes ?? {}))
|
|
2208
|
+
e.setAttribute(n, o);
|
|
2209
|
+
return e;
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
function Ko(t, e, n, o, r, a, s) {
|
|
2213
|
+
const i = t.className ? `${n.cell} ${t.className}` : n.cell, l = Go(t, e, !o && r);
|
|
2214
|
+
if (t.virtual)
|
|
2215
|
+
return { type: "widget", from: t.from, side: a, widget: new I(i, l, s) };
|
|
2216
|
+
if (o) {
|
|
2217
|
+
const c = `${i} ${n.rawCell}`;
|
|
2218
|
+
return t.from === t.to ? { type: "widget", from: t.from, widget: new I(c) } : { from: t.from, to: t.to, className: c };
|
|
2219
|
+
}
|
|
2220
|
+
const m = Ze(t);
|
|
2221
|
+
return m.from === m.to ? { type: "widget", from: m.from, widget: new I(i, l, s) } : {
|
|
2222
|
+
from: m.from,
|
|
2223
|
+
to: m.to,
|
|
2224
|
+
className: i,
|
|
2225
|
+
// A whole-run inline widget (such as a GFM link or image) can occupy this
|
|
2226
|
+
// exact range. Claim both shared boundaries so CodeMirror nests that
|
|
2227
|
+
// widget in the cell mark instead of rendering it as the mark's sibling
|
|
2228
|
+
// and dropping the cell element altogether. This is the same lowering
|
|
2229
|
+
// contract as createContentMarkSpec: table-kit remains agnostic about
|
|
2230
|
+
// which notation supplied the widget.
|
|
2231
|
+
inclusiveStart: !0,
|
|
2232
|
+
inclusiveEnd: !0,
|
|
2233
|
+
attributes: {
|
|
2234
|
+
style: l,
|
|
2235
|
+
...s
|
|
2236
|
+
}
|
|
2237
|
+
};
|
|
2238
|
+
}
|
|
2239
|
+
function Go(t, e, n) {
|
|
2240
|
+
const o = t.align ? `; text-align: ${t.align}` : "";
|
|
2241
|
+
return `${Uo}: ${e}ch${o}${n ? "; display: inline-block !important;" : ""}`;
|
|
2242
|
+
}
|
|
2243
|
+
function Jo(t, e, n, o = {}, r) {
|
|
2244
|
+
const a = o.measureWidth ?? ((c) => c.length), s = jo(t, a), i = r && !t.some((c) => e.has(c.line)) ? t.filter((c) => c.includeInColumnWidths !== !1) : [], l = r ? i[r.headerRowIndex ?? 0] : void 0, m = new Set(i);
|
|
2245
|
+
return t.flatMap((c, u) => {
|
|
2246
|
+
const f = e.has(c.line), d = m.has(c);
|
|
2247
|
+
return c.cells.flatMap((p, x) => f && p.virtual ? [] : [Ko(
|
|
2248
|
+
p,
|
|
2249
|
+
s[x] ?? 0,
|
|
2250
|
+
n,
|
|
2251
|
+
f,
|
|
2252
|
+
d,
|
|
2253
|
+
x + 1,
|
|
2254
|
+
d && !p.excludeFromSemantics ? {
|
|
2255
|
+
role: r.isHeaderCell?.(c, u, x) ?? c === l ? "columnheader" : "cell",
|
|
2256
|
+
"aria-colindex": String(x + 1)
|
|
2257
|
+
} : void 0
|
|
2258
|
+
)]);
|
|
2259
|
+
});
|
|
2260
|
+
}
|
|
2261
|
+
function Qo(t, e, n) {
|
|
2262
|
+
if (!n || t.some((s) => e.has(s.line))) return [];
|
|
2263
|
+
const o = t.filter((s) => s.includeInColumnWidths !== !1), r = n.headerRowIndex ?? 0, a = o[r];
|
|
2264
|
+
return a ? [{
|
|
2265
|
+
from: a.from,
|
|
2266
|
+
to: a.to,
|
|
2267
|
+
className: "",
|
|
2268
|
+
attributes: { id: `${n.tableId}-row-${r}`, role: "row", style: "display: contents !important" }
|
|
2269
|
+
}] : [];
|
|
2270
|
+
}
|
|
2271
|
+
function Xo(t, e) {
|
|
2272
|
+
return t.flatMap((n) => e.has(n.line) ? [] : n.cells.filter((o) => !o.virtual).flatMap((o) => {
|
|
2273
|
+
const r = Ze(o);
|
|
2274
|
+
return [
|
|
2275
|
+
{ type: "replace", from: o.from, to: r.from },
|
|
2276
|
+
{ type: "replace", from: r.to, to: o.to }
|
|
2277
|
+
];
|
|
2278
|
+
}));
|
|
2279
|
+
}
|
|
2280
|
+
function Zo(t, e) {
|
|
2281
|
+
return t.flatMap((n) => {
|
|
2282
|
+
const o = n.cells.filter((a) => !a.virtual);
|
|
2283
|
+
return e.has(n.line) || o.length === 0 ? [] : [
|
|
2284
|
+
{ from: n.from, to: o[0].from },
|
|
2285
|
+
...o.slice(1).map((a, s) => ({ from: o[s].to, to: a.from })),
|
|
2286
|
+
{ from: o[o.length - 1].to, to: n.to }
|
|
2287
|
+
].map((a) => ({ ...a, type: "replace" }));
|
|
2288
|
+
});
|
|
2289
|
+
}
|
|
2290
|
+
const Ye = "mbox-table-rendered", le = "mbox-table-raw-cell", k = {
|
|
2291
|
+
table: "mbox-table",
|
|
2292
|
+
header: "mbox-table-header",
|
|
2293
|
+
delimiter: "mbox-table-delimiter",
|
|
2294
|
+
row: "mbox-table-row",
|
|
2295
|
+
cell: "mbox-table-cell",
|
|
2296
|
+
rendered: Ye,
|
|
2297
|
+
rawCell: le
|
|
2298
|
+
}, Le = {
|
|
2299
|
+
table: k.table,
|
|
2300
|
+
renderedLine: Ye,
|
|
2301
|
+
cell: k.cell,
|
|
2302
|
+
rawCell: le
|
|
2303
|
+
};
|
|
2304
|
+
function Yo(t) {
|
|
2305
|
+
return [
|
|
2306
|
+
{
|
|
2307
|
+
className: k.header,
|
|
2308
|
+
line: t.line,
|
|
2309
|
+
from: t.header.from,
|
|
2310
|
+
to: t.header.to,
|
|
2311
|
+
cells: t.header.cells
|
|
2312
|
+
},
|
|
2313
|
+
{
|
|
2314
|
+
className: k.delimiter,
|
|
2315
|
+
includeInColumnWidths: !1,
|
|
2316
|
+
line: t.line + 1,
|
|
2317
|
+
from: t.delimiter.from,
|
|
2318
|
+
to: t.delimiter.to,
|
|
2319
|
+
cells: t.delimiter.cells.map((e) => ({ ...e, className: "mbox-table-delimiter-cell" }))
|
|
2320
|
+
},
|
|
2321
|
+
...t.rows.map((e, n) => ({
|
|
2322
|
+
className: k.row,
|
|
2323
|
+
line: t.line + 2 + n,
|
|
2324
|
+
from: e.from,
|
|
2325
|
+
to: e.to,
|
|
2326
|
+
cells: e.cells
|
|
2327
|
+
}))
|
|
2328
|
+
];
|
|
2329
|
+
}
|
|
2330
|
+
function _o(t, e = /* @__PURE__ */ new Set()) {
|
|
2331
|
+
return t.blocks.flatMap((n) => n.type === "table" ? tr(n, e) : []);
|
|
2332
|
+
}
|
|
2333
|
+
function er() {
|
|
2334
|
+
return {
|
|
2335
|
+
theme: {
|
|
2336
|
+
[`.${k.table}`]: {
|
|
2337
|
+
fontFamily: 'var(--mbox-table-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace)'
|
|
2338
|
+
},
|
|
2339
|
+
[`.${k.cell}`]: {
|
|
2340
|
+
width: "var(--mbox-table-cell-width, var(--mbox-table-kit-column-width))",
|
|
2341
|
+
maxWidth: "var(--mbox-table-kit-cell-max-width, 100%)",
|
|
2342
|
+
minWidth: 0,
|
|
2343
|
+
overflowWrap: "anywhere"
|
|
2344
|
+
},
|
|
2345
|
+
// Both classes: a raw cell carries the base cell class too, so a
|
|
2346
|
+
// single-class rule would only win by being written second.
|
|
2347
|
+
[`.${k.cell}.${le}`]: {
|
|
2348
|
+
width: "auto",
|
|
2349
|
+
maxWidth: "none",
|
|
2350
|
+
minWidth: "auto"
|
|
2351
|
+
}
|
|
2352
|
+
},
|
|
2353
|
+
name: "mbox/table",
|
|
2354
|
+
decorations: (t) => _o(h(t.state), t.activeLineNumbers)
|
|
2355
|
+
};
|
|
2356
|
+
}
|
|
2357
|
+
function tr(t, e) {
|
|
2358
|
+
let n = Yo(t);
|
|
2359
|
+
const o = n.some((r) => e.has(r.line)) ? void 0 : { tableId: `mbox-table-${t.from}` };
|
|
2360
|
+
return o && (n = n.map((r, a) => a === 1 ? { ...r, attributes: { "aria-hidden": "true" } } : r)), [
|
|
2361
|
+
...Ho(n, e, Le, o),
|
|
2362
|
+
...Qo(n, e, o),
|
|
2363
|
+
...Jo(n, e, Le, { measureWidth: Vo }, o),
|
|
2364
|
+
...Xo(n, e),
|
|
2365
|
+
...Zo(n, e)
|
|
2366
|
+
];
|
|
2367
|
+
}
|
|
2368
|
+
const H = /* @__PURE__ */ new WeakMap();
|
|
2369
|
+
function j(t, e, n) {
|
|
2370
|
+
t.checked = n.checked, t.disabled = e.state.readOnly, t.className = n.className ?? "", t.setAttribute("aria-label", n.checked ? "checked task" : "unchecked task");
|
|
2371
|
+
}
|
|
2372
|
+
function nr(t, e, n) {
|
|
2373
|
+
const o = H.get(t);
|
|
2374
|
+
return o === void 0 ? !1 : (o.view = e, o.options = n, j(t, e, n), !0);
|
|
2375
|
+
}
|
|
2376
|
+
function or(t, e) {
|
|
2377
|
+
const n = document.createElement("input");
|
|
2378
|
+
n.type = "checkbox";
|
|
2379
|
+
const o = { view: t, options: e, pointerStartedFocused: void 0 };
|
|
2380
|
+
return H.set(n, o), j(n, t, e), n.addEventListener("mousedown", (r) => {
|
|
2381
|
+
o.pointerStartedFocused = document.activeElement === n, o.pointerStartedFocused && r.preventDefault();
|
|
2382
|
+
}), n.addEventListener("click", (r) => {
|
|
2383
|
+
const a = o.pointerStartedFocused ?? document.activeElement === n, s = o.pointerStartedFocused === !1;
|
|
2384
|
+
o.pointerStartedFocused = void 0, a && r.preventDefault(), r.stopPropagation(), !o.view.state.readOnly && (o.view.dispatch({
|
|
2385
|
+
changes: {
|
|
2386
|
+
from: o.options.from,
|
|
2387
|
+
to: o.options.to,
|
|
2388
|
+
insert: o.options.checked ? "[ ]" : "[x]"
|
|
2389
|
+
}
|
|
2390
|
+
}), setTimeout(() => {
|
|
2391
|
+
const i = H.get(n);
|
|
2392
|
+
i !== void 0 && (j(n, i.view, i.options), s && n.focus());
|
|
2393
|
+
}, 0));
|
|
2394
|
+
}), n;
|
|
2395
|
+
}
|
|
2396
|
+
const _e = "mbox-task-list-indent", et = "mbox-task-list-content", K = "mbox-task-checkbox-slot", tt = "mbox-task-list-focused-line", B = {
|
|
2397
|
+
item: "mbox-task-list",
|
|
2398
|
+
checkbox: "mbox-task-checkbox"
|
|
2399
|
+
};
|
|
2400
|
+
class ce extends b {
|
|
2401
|
+
constructor(e, n, o, r, a = !1) {
|
|
2402
|
+
super(), this.checked = e, this.className = n, this.from = o, this.to = r, this.readOnly = a;
|
|
2403
|
+
}
|
|
2404
|
+
checked;
|
|
2405
|
+
className;
|
|
2406
|
+
from;
|
|
2407
|
+
to;
|
|
2408
|
+
readOnly;
|
|
2409
|
+
eq(e) {
|
|
2410
|
+
return e instanceof ce && this.checked === e.checked && this.className === e.className && this.from === e.from && this.to === e.to && this.readOnly === e.readOnly;
|
|
2411
|
+
}
|
|
2412
|
+
updateDOM(e, n) {
|
|
2413
|
+
if (e.className !== K || e.childElementCount !== 1)
|
|
2414
|
+
return !1;
|
|
2415
|
+
const o = e.firstElementChild;
|
|
2416
|
+
return o instanceof HTMLInputElement && o.type === "checkbox" ? nr(o, n, {
|
|
2417
|
+
checked: this.checked,
|
|
2418
|
+
className: this.className,
|
|
2419
|
+
from: this.from,
|
|
2420
|
+
to: this.to
|
|
2421
|
+
}) : !1;
|
|
2422
|
+
}
|
|
2423
|
+
toDOM(e) {
|
|
2424
|
+
const n = document.createElement("span");
|
|
2425
|
+
return n.className = K, n.appendChild(
|
|
2426
|
+
or(e, { checked: this.checked, className: this.className, from: this.from, to: this.to })
|
|
2427
|
+
), n;
|
|
2428
|
+
}
|
|
2429
|
+
ignoreEvent() {
|
|
2430
|
+
return !0;
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
function rr(t, e, n) {
|
|
2434
|
+
return t.blocks.flatMap(
|
|
2435
|
+
(o) => o.type === "taskListItem" ? e.has(o.line) ? [
|
|
2436
|
+
{
|
|
2437
|
+
type: "line",
|
|
2438
|
+
from: o.from,
|
|
2439
|
+
className: tt,
|
|
2440
|
+
attributes: {
|
|
2441
|
+
style: `--mbox-task-list-focused-marker-width: ${o.content.from - o.from}ch`
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
] : [
|
|
2445
|
+
{
|
|
2446
|
+
type: "line",
|
|
2447
|
+
from: o.from,
|
|
2448
|
+
className: B.item
|
|
2449
|
+
},
|
|
2450
|
+
...o.from < o.marker.from ? [
|
|
2451
|
+
{
|
|
2452
|
+
type: "mark",
|
|
2453
|
+
from: o.from,
|
|
2454
|
+
to: o.marker.from,
|
|
2455
|
+
className: _e
|
|
2456
|
+
}
|
|
2457
|
+
] : [],
|
|
2458
|
+
{
|
|
2459
|
+
type: "replace",
|
|
2460
|
+
from: o.syntax.from,
|
|
2461
|
+
to: o.syntax.to,
|
|
2462
|
+
widget: new ce(
|
|
2463
|
+
o.checked,
|
|
2464
|
+
B.checkbox,
|
|
2465
|
+
o.checkbox.from,
|
|
2466
|
+
o.checkbox.to,
|
|
2467
|
+
n.readOnly
|
|
2468
|
+
)
|
|
2469
|
+
},
|
|
2470
|
+
G(o.content.from, o.content.to, et)
|
|
2471
|
+
] : []
|
|
2472
|
+
);
|
|
2473
|
+
}
|
|
2474
|
+
function ar() {
|
|
2475
|
+
return {
|
|
2476
|
+
theme: {
|
|
2477
|
+
[`.${tt}`]: {
|
|
2478
|
+
boxSizing: "border-box",
|
|
2479
|
+
paddingLeft: "var(--mbox-task-list-focused-marker-width)",
|
|
2480
|
+
textIndent: "calc(-1 * var(--mbox-task-list-focused-marker-width))"
|
|
2481
|
+
},
|
|
2482
|
+
[`.${B.item}`]: {
|
|
2483
|
+
alignItems: "start",
|
|
2484
|
+
display: "flex"
|
|
2485
|
+
},
|
|
2486
|
+
[`.${_e}`]: {
|
|
2487
|
+
flexShrink: "0",
|
|
2488
|
+
whiteSpace: "pre"
|
|
2489
|
+
},
|
|
2490
|
+
[`.${et}`]: {
|
|
2491
|
+
display: "block",
|
|
2492
|
+
minWidth: "0",
|
|
2493
|
+
overflowWrap: "anywhere"
|
|
2494
|
+
},
|
|
2495
|
+
[`.${K}`]: {
|
|
2496
|
+
alignItems: "center",
|
|
2497
|
+
display: "inline-flex",
|
|
2498
|
+
flexShrink: "0",
|
|
2499
|
+
blockSize: "1lh",
|
|
2500
|
+
inlineSize: "2ch",
|
|
2501
|
+
justifyContent: "flex-start"
|
|
2502
|
+
},
|
|
2503
|
+
[`.${B.checkbox}`]: {
|
|
2504
|
+
blockSize: "1em",
|
|
2505
|
+
boxSizing: "border-box",
|
|
2506
|
+
font: "inherit",
|
|
2507
|
+
inlineSize: "1em",
|
|
2508
|
+
margin: "0 0 0 calc(0.5ch - 0.5em)",
|
|
2509
|
+
verticalAlign: "-0.125em"
|
|
2510
|
+
}
|
|
2511
|
+
},
|
|
2512
|
+
name: "mbox/task-list",
|
|
2513
|
+
decorations: (t) => rr(h(t.state), t.activeLineNumbers, t.state)
|
|
2514
|
+
};
|
|
2515
|
+
}
|
|
2516
|
+
function we(t) {
|
|
2517
|
+
try {
|
|
2518
|
+
const e = new URL(t);
|
|
2519
|
+
return e.protocol === "http:" || e.protocol === "https:";
|
|
2520
|
+
} catch {
|
|
2521
|
+
return !1;
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
const sr = "mbox-url-link";
|
|
2525
|
+
class A extends b {
|
|
2526
|
+
constructor(e, n, o) {
|
|
2527
|
+
super(), this.href = e, this.label = n, this.className = o;
|
|
2528
|
+
}
|
|
2529
|
+
href;
|
|
2530
|
+
label;
|
|
2531
|
+
className;
|
|
2532
|
+
eq(e) {
|
|
2533
|
+
return e instanceof A && this.href === e.href && this.label === e.label && this.className === e.className;
|
|
2534
|
+
}
|
|
2535
|
+
toDOM() {
|
|
2536
|
+
return He({
|
|
2537
|
+
href: this.href,
|
|
2538
|
+
text: this.label,
|
|
2539
|
+
className: this.className,
|
|
2540
|
+
attributes: { target: "_blank", rel: "noreferrer" }
|
|
2541
|
+
});
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
function ir(t, e, n) {
|
|
2545
|
+
return L(t, e, (o) => o.type === "markdownLink" && we(o.urlValue) ? [
|
|
2546
|
+
{
|
|
2547
|
+
type: "replace",
|
|
2548
|
+
from: o.from,
|
|
2549
|
+
to: o.to,
|
|
2550
|
+
widget: new A(o.urlValue, o.labelValue, n)
|
|
2551
|
+
}
|
|
2552
|
+
] : o.type === "autoLink" && we(o.urlValue) ? [
|
|
2553
|
+
{
|
|
2554
|
+
type: "replace",
|
|
2555
|
+
from: o.from,
|
|
2556
|
+
to: o.to,
|
|
2557
|
+
widget: new A(o.urlValue, o.urlValue, n)
|
|
2558
|
+
}
|
|
2559
|
+
] : []);
|
|
2560
|
+
}
|
|
2561
|
+
function lr() {
|
|
2562
|
+
return {
|
|
2563
|
+
name: "mbox/url-link",
|
|
2564
|
+
decorations: (t) => ir(h(t.state), t.activeLineNumbers, sr)
|
|
2565
|
+
};
|
|
2566
|
+
}
|
|
2567
|
+
function cr(t) {
|
|
2568
|
+
return t === !0 ? void 0 : t || void 0;
|
|
2569
|
+
}
|
|
2570
|
+
function ur(t = {}) {
|
|
2571
|
+
return [
|
|
2572
|
+
Lt(),
|
|
2573
|
+
An(t.complete),
|
|
2574
|
+
Po(),
|
|
2575
|
+
jn(),
|
|
2576
|
+
xo(),
|
|
2577
|
+
ar(),
|
|
2578
|
+
Do(),
|
|
2579
|
+
Ao(t.link),
|
|
2580
|
+
Dn(),
|
|
2581
|
+
Pn(),
|
|
2582
|
+
lr(),
|
|
2583
|
+
Eo(t.image),
|
|
2584
|
+
Gn(),
|
|
2585
|
+
Yn(),
|
|
2586
|
+
pn(),
|
|
2587
|
+
...t.codeHighlight ? [gn(cr(t.codeHighlight))] : [],
|
|
2588
|
+
er()
|
|
2589
|
+
];
|
|
2590
|
+
}
|
|
2591
|
+
const mr = [
|
|
2592
|
+
{ tokenNames: ["keyword"], variableName: "keyword", defaultColor: "#a626a4" },
|
|
2593
|
+
{ tokenNames: ["string", "inserted"], variableName: "string", defaultColor: "#50a14f" },
|
|
2594
|
+
{ tokenNames: ["number", "bool", "atom", "literal"], variableName: "literal", defaultColor: "#986801" },
|
|
2595
|
+
{ tokenNames: ["variableName", "propertyName"], variableName: "name", defaultColor: "#005cc5" },
|
|
2596
|
+
{ tokenNames: ["variableName2", "labelName", "macroName"], variableName: "name-alt", defaultColor: "#4078f2" },
|
|
2597
|
+
{ tokenNames: ["typeName", "className", "namespace"], variableName: "type", defaultColor: "#c18401" },
|
|
2598
|
+
{ tokenNames: ["comment", "meta"], variableName: "comment", defaultColor: "#6a737d" },
|
|
2599
|
+
{ tokenNames: ["punctuation", "operator"], variableName: "punctuation", defaultColor: "#5c6370" },
|
|
2600
|
+
{ tokenNames: ["string2", "url", "link"], variableName: "link", defaultColor: "#0184bc" },
|
|
2601
|
+
{ tokenNames: ["deleted", "invalid"], variableName: "invalid", defaultColor: "#e45649" }
|
|
2602
|
+
];
|
|
2603
|
+
function Se(t, e) {
|
|
2604
|
+
return t.flatMap((n) => e.map((o) => `.${n}.tok-${o}`)).join(", ");
|
|
2605
|
+
}
|
|
2606
|
+
function fr(t) {
|
|
2607
|
+
const e = {};
|
|
2608
|
+
for (const n of mr)
|
|
2609
|
+
e[Se(t, n.tokenNames)] = {
|
|
2610
|
+
color: `var(--mbox-code-token-${n.variableName}-color, ${n.defaultColor})`
|
|
2611
|
+
};
|
|
2612
|
+
return e[Se(t, ["url", "link"])] = { textDecoration: "underline" }, e;
|
|
2613
|
+
}
|
|
2614
|
+
const dr = {
|
|
2615
|
+
1: "1.45rem",
|
|
2616
|
+
2: "1.33rem",
|
|
2617
|
+
3: "1.21rem",
|
|
2618
|
+
4: "1.09rem",
|
|
2619
|
+
5: "1rem",
|
|
2620
|
+
6: "0.93rem"
|
|
2621
|
+
};
|
|
2622
|
+
function hr(t) {
|
|
2623
|
+
if (t.length === 0)
|
|
2624
|
+
return {};
|
|
2625
|
+
const n = {
|
|
2626
|
+
[t.map((o) => `.${o.className}`).join(", ")]: {
|
|
2627
|
+
fontWeight: "var(--mbox-heading-font-weight, 700)"
|
|
2628
|
+
}
|
|
2629
|
+
};
|
|
2630
|
+
for (const o of t) {
|
|
2631
|
+
const r = dr[o.level];
|
|
2632
|
+
r && (n[`.${o.className}`] = {
|
|
2633
|
+
fontSize: `var(--mbox-h${o.level}-font-size, ${r})`
|
|
2634
|
+
});
|
|
2635
|
+
}
|
|
2636
|
+
return n;
|
|
2637
|
+
}
|
|
2638
|
+
const pr = {
|
|
2639
|
+
...fr([Be.token]),
|
|
2640
|
+
...hr([
|
|
2641
|
+
{ level: 1, className: N.h1 },
|
|
2642
|
+
{ level: 2, className: N.h2 },
|
|
2643
|
+
{ level: 3, className: N.h3 },
|
|
2644
|
+
{ level: 4, className: N.h4 },
|
|
2645
|
+
{ level: 5, className: N.h5 },
|
|
2646
|
+
{ level: 6, className: N.h6 }
|
|
2647
|
+
]),
|
|
2648
|
+
[`.${Ge}`]: {
|
|
2649
|
+
color: "var(--mbox-page-link-color, #0969da)",
|
|
2650
|
+
textDecoration: "underline",
|
|
2651
|
+
textUnderlineOffset: "2px"
|
|
2652
|
+
},
|
|
2653
|
+
[`.${ne}`]: {
|
|
2654
|
+
fontFamily: 'var(--mbox-inline-code-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace)'
|
|
2655
|
+
},
|
|
2656
|
+
[`.${$.em}`]: {
|
|
2657
|
+
fontStyle: "var(--mbox-emphasis-font-style, italic)"
|
|
2658
|
+
},
|
|
2659
|
+
[`.${$.strong}`]: {
|
|
2660
|
+
fontWeight: "var(--mbox-strong-font-weight, 700)"
|
|
2661
|
+
},
|
|
2662
|
+
[`.${$.strike}`]: {
|
|
2663
|
+
textDecoration: "var(--mbox-strike-text-decoration, line-through)"
|
|
2664
|
+
},
|
|
2665
|
+
[`.${Xe.quote}`]: {
|
|
2666
|
+
borderLeft: "var(--mbox-quote-border, 3px solid #d0d7de)",
|
|
2667
|
+
paddingLeft: "var(--mbox-quote-padding, 0.6em)",
|
|
2668
|
+
color: "var(--mbox-quote-color, #57606a)"
|
|
2669
|
+
}
|
|
2670
|
+
};
|
|
2671
|
+
function gr() {
|
|
2672
|
+
return y.theme(pr);
|
|
2673
|
+
}
|
|
2674
|
+
function br(t = {}) {
|
|
2675
|
+
const { activeLine: e = !1, ariaLabel: n, doc: o = "", extensions: r = [], readOnly: a = !1, selection: s } = t, i = n?.trim() ? n : "Text editor";
|
|
2676
|
+
return U.create({
|
|
2677
|
+
doc: o,
|
|
2678
|
+
selection: s,
|
|
2679
|
+
extensions: [
|
|
2680
|
+
e ? lt() : [],
|
|
2681
|
+
wr,
|
|
2682
|
+
e ? ct() : [],
|
|
2683
|
+
a ? [U.readOnly.of(!0), y.editable.of(!1)] : [],
|
|
2684
|
+
y.lineWrapping,
|
|
2685
|
+
Nr,
|
|
2686
|
+
...r,
|
|
2687
|
+
y.contentAttributes.of({ "aria-label": i })
|
|
2688
|
+
]
|
|
2689
|
+
});
|
|
2690
|
+
}
|
|
2691
|
+
function yr(t) {
|
|
2692
|
+
return new y({
|
|
2693
|
+
parent: t.parent,
|
|
2694
|
+
state: t.state
|
|
2695
|
+
});
|
|
2696
|
+
}
|
|
2697
|
+
function kr(t, e, n) {
|
|
2698
|
+
const { activeLine: o, ariaLabel: r, doc: a, selection: s, extraPlugins: i = [], extensions: l = [], onDecorationError: m, presentation: c, readOnly: u } = t, f = [...e, ...i], d = Lr(c, n);
|
|
2699
|
+
return br({
|
|
2700
|
+
activeLine: o,
|
|
2701
|
+
ariaLabel: r,
|
|
2702
|
+
doc: a,
|
|
2703
|
+
readOnly: u,
|
|
2704
|
+
selection: s,
|
|
2705
|
+
extensions: [
|
|
2706
|
+
ht({
|
|
2707
|
+
plugins: f,
|
|
2708
|
+
onDecorationError: m
|
|
2709
|
+
}),
|
|
2710
|
+
...d,
|
|
2711
|
+
...l
|
|
2712
|
+
]
|
|
2713
|
+
});
|
|
2714
|
+
}
|
|
2715
|
+
function xr(t = {}) {
|
|
2716
|
+
return kr(t, ur(t), gr);
|
|
2717
|
+
}
|
|
2718
|
+
function zr(t) {
|
|
2719
|
+
const { parent: e, ...n } = t;
|
|
2720
|
+
return yr({
|
|
2721
|
+
parent: e,
|
|
2722
|
+
state: xr(n)
|
|
2723
|
+
});
|
|
2724
|
+
}
|
|
2725
|
+
const Nr = y.theme({
|
|
2726
|
+
".cm-content": {
|
|
2727
|
+
boxSizing: "border-box",
|
|
2728
|
+
flex: "1 1 0",
|
|
2729
|
+
minWidth: "0"
|
|
2730
|
+
}
|
|
2731
|
+
}), Vr = {
|
|
2732
|
+
"&": {
|
|
2733
|
+
fontSize: "var(--mbox-editor-font-size, 15px)",
|
|
2734
|
+
minHeight: "var(--mbox-editor-min-height, 100%)"
|
|
2735
|
+
},
|
|
2736
|
+
".cm-content": {
|
|
2737
|
+
padding: "var(--mbox-editor-padding, 18px)"
|
|
2738
|
+
}
|
|
2739
|
+
};
|
|
2740
|
+
function Cr(t = {}) {
|
|
2741
|
+
const { fontSize: e, padding: n, minHeight: o } = t, r = {
|
|
2742
|
+
"&": {
|
|
2743
|
+
fontSize: e ?? "var(--mbox-editor-font-size, 15px)",
|
|
2744
|
+
minHeight: "var(--mbox-editor-min-height, 100%)"
|
|
2745
|
+
},
|
|
2746
|
+
".cm-content": { padding: n ?? "var(--mbox-editor-padding, 18px)" }
|
|
2747
|
+
};
|
|
2748
|
+
return o !== void 0 && (r[".cm-scroller"] = { minHeight: o }, r[".cm-gutters"] = { minHeight: o }), r;
|
|
2749
|
+
}
|
|
2750
|
+
function vr(t = {}) {
|
|
2751
|
+
return y.theme(Cr(t));
|
|
2752
|
+
}
|
|
2753
|
+
function Lr(t, e) {
|
|
2754
|
+
if (t === !1)
|
|
2755
|
+
return [];
|
|
2756
|
+
const n = t ?? {}, o = [];
|
|
2757
|
+
return n.container !== !1 && o.push(vr(n.container)), n.notation !== !1 && o.push(e()), o;
|
|
2758
|
+
}
|
|
2759
|
+
const wr = [
|
|
2760
|
+
ut(),
|
|
2761
|
+
ot(),
|
|
2762
|
+
mt(),
|
|
2763
|
+
ft(),
|
|
2764
|
+
U.allowMultipleSelections.of(!0),
|
|
2765
|
+
st(),
|
|
2766
|
+
dt.of([...rt, ...at])
|
|
2767
|
+
];
|
|
2768
|
+
export {
|
|
2769
|
+
It as $,
|
|
2770
|
+
ne as A,
|
|
2771
|
+
Dr as B,
|
|
2772
|
+
Z as C,
|
|
2773
|
+
Gn as D,
|
|
2774
|
+
$ as E,
|
|
2775
|
+
Yn as F,
|
|
2776
|
+
Pr as G,
|
|
2777
|
+
_n as H,
|
|
2778
|
+
P as I,
|
|
2779
|
+
xo as J,
|
|
2780
|
+
Lo as K,
|
|
2781
|
+
Ce as L,
|
|
2782
|
+
On as M,
|
|
2783
|
+
Eo as N,
|
|
2784
|
+
Lt as O,
|
|
2785
|
+
An as P,
|
|
2786
|
+
gr as Q,
|
|
2787
|
+
pr as R,
|
|
2788
|
+
Ae as S,
|
|
2789
|
+
Te as T,
|
|
2790
|
+
Dn as U,
|
|
2791
|
+
Pe as V,
|
|
2792
|
+
ur as W,
|
|
2793
|
+
Ge as X,
|
|
2794
|
+
Ao as Y,
|
|
2795
|
+
D as Z,
|
|
2796
|
+
Po as _,
|
|
2797
|
+
ae as a,
|
|
2798
|
+
Xe as a0,
|
|
2799
|
+
Do as a1,
|
|
2800
|
+
xe as a2,
|
|
2801
|
+
po as a3,
|
|
2802
|
+
mo as a4,
|
|
2803
|
+
fo as a5,
|
|
2804
|
+
bo as a6,
|
|
2805
|
+
ho as a7,
|
|
2806
|
+
go as a8,
|
|
2807
|
+
k as a9,
|
|
2808
|
+
We as aA,
|
|
2809
|
+
or as aB,
|
|
2810
|
+
nr as aC,
|
|
2811
|
+
Xo as aD,
|
|
2812
|
+
vt as aE,
|
|
2813
|
+
Or as aF,
|
|
2814
|
+
rn as aG,
|
|
2815
|
+
er as aa,
|
|
2816
|
+
le as ab,
|
|
2817
|
+
Ye as ac,
|
|
2818
|
+
B as ad,
|
|
2819
|
+
ar as ae,
|
|
2820
|
+
sr as af,
|
|
2821
|
+
lr as ag,
|
|
2822
|
+
Ft as ah,
|
|
2823
|
+
St as ai,
|
|
2824
|
+
wt as aj,
|
|
2825
|
+
Ur as ak,
|
|
2826
|
+
He as al,
|
|
2827
|
+
mn as am,
|
|
2828
|
+
on as an,
|
|
2829
|
+
nn as ao,
|
|
2830
|
+
Ho as ap,
|
|
2831
|
+
Qo as aq,
|
|
2832
|
+
Jo as ar,
|
|
2833
|
+
Vo as as,
|
|
2834
|
+
Zo as at,
|
|
2835
|
+
hr as au,
|
|
2836
|
+
fr as av,
|
|
2837
|
+
kr as aw,
|
|
2838
|
+
vo as ax,
|
|
2839
|
+
Co as ay,
|
|
2840
|
+
qr as az,
|
|
2841
|
+
re as b,
|
|
2842
|
+
ie as c,
|
|
2843
|
+
g as d,
|
|
2844
|
+
Be as e,
|
|
2845
|
+
gn as f,
|
|
2846
|
+
pn as g,
|
|
2847
|
+
Rr as h,
|
|
2848
|
+
z as i,
|
|
2849
|
+
Y as j,
|
|
2850
|
+
_ as k,
|
|
2851
|
+
ee as l,
|
|
2852
|
+
br as m,
|
|
2853
|
+
yr as n,
|
|
2854
|
+
zr as o,
|
|
2855
|
+
xr as p,
|
|
2856
|
+
Vr as q,
|
|
2857
|
+
vr as r,
|
|
2858
|
+
Tn as s,
|
|
2859
|
+
Pn as t,
|
|
2860
|
+
Wr as u,
|
|
2861
|
+
h as v,
|
|
2862
|
+
N as w,
|
|
2863
|
+
jn as x,
|
|
2864
|
+
Je as y,
|
|
2865
|
+
Qe as z
|
|
2866
|
+
};
|