supamde 0.1.0 → 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/README.md +19 -16
- package/dist/commands/code-indent.d.ts +38 -0
- package/dist/commands/indent.d.ts +10 -0
- package/dist/options.d.ts +3 -0
- package/dist/supamde.mjs +544 -483
- package/dist/supamde.mjs.map +1 -1
- package/package.json +1 -1
package/dist/supamde.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Decoration as e, EditorView as t, ViewPlugin as n, keymap as r, placeholder as i } from "@codemirror/view";
|
|
2
2
|
import { Compartment as a, EditorState as o, Facet as s, RangeSet as c, StateEffect as l, StateField as u } from "@codemirror/state";
|
|
3
|
-
import { HighlightStyle as d,
|
|
3
|
+
import { HighlightStyle as d, ensureSyntaxTree as f, getIndentUnit as p, indentUnit as m, syntaxHighlighting as ee, syntaxTree as h } from "@codemirror/language";
|
|
4
4
|
import { copyLineDown as te, copyLineUp as ne, defaultKeymap as re, deleteLine as ie, history as ae, historyKeymap as oe, moveLineDown as se, moveLineUp as ce, redo as le, undo as ue } from "@codemirror/commands";
|
|
5
5
|
import { deleteMarkupBackward as de, markdown as fe } from "@codemirror/lang-markdown";
|
|
6
6
|
import { GFM as pe } from "@lezer/markdown";
|
|
7
|
-
import { tags as
|
|
7
|
+
import { tags as g } from "@lezer/highlight";
|
|
8
8
|
//#region src/version.ts
|
|
9
9
|
var me = "0.1.0";
|
|
10
10
|
//#endregion
|
|
@@ -40,7 +40,7 @@ function ye(e, t, n) {
|
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
function be(e, t, n = _e) {
|
|
43
|
-
let r = e.selection.ranges, i = [], a =
|
|
43
|
+
let r = e.selection.ranges, i = [], a = h(e);
|
|
44
44
|
for (let o of t) a.iterate({
|
|
45
45
|
from: o.from,
|
|
46
46
|
to: o.to,
|
|
@@ -91,154 +91,198 @@ function De(e) {
|
|
|
91
91
|
function Oe(e) {
|
|
92
92
|
return e === void 0 ? "source" : we.includes(e) ? e : (console.warn(`SupaMDE: unknown editorMode "${String(e)}" — using "source".`), "source");
|
|
93
93
|
}
|
|
94
|
-
function ke(e) {
|
|
94
|
+
function ke(e, t) {
|
|
95
|
+
return e === void 0 ? t : e === "tab" || Number.isInteger(e) && e > 0 ? e : (console.warn(`SupaMDE: invalid codeIndentUnit "${String(e)}" — using indentUnit (${t}).`), t);
|
|
96
|
+
}
|
|
97
|
+
function Ae(e) {
|
|
98
|
+
let t = e.indentUnit ?? 2;
|
|
95
99
|
return {
|
|
96
100
|
lineWrapping: e.lineWrapping ?? !0,
|
|
97
101
|
placeholder: e.placeholder ?? null,
|
|
98
102
|
autofocus: e.autofocus ?? !1,
|
|
99
103
|
tabSize: e.tabSize ?? 2,
|
|
100
|
-
indentUnit:
|
|
104
|
+
indentUnit: t,
|
|
105
|
+
codeIndentUnit: ke(e.codeIndentUnit, t),
|
|
101
106
|
extraKeys: e.extraKeys ?? [],
|
|
102
107
|
editorMode: Oe(e.editorMode)
|
|
103
108
|
};
|
|
104
109
|
}
|
|
105
110
|
//#endregion
|
|
111
|
+
//#region src/commands/code-indent.ts
|
|
112
|
+
var je = s.define({ combine: (e) => e[0] ?? null });
|
|
113
|
+
function Me(e, t, n = h(e)) {
|
|
114
|
+
let r = !1;
|
|
115
|
+
return n.iterate({
|
|
116
|
+
from: t.from,
|
|
117
|
+
to: t.to,
|
|
118
|
+
enter: (e) => {
|
|
119
|
+
if (r) return !1;
|
|
120
|
+
if (e.name === "CodeBlock") return r = !0, !1;
|
|
121
|
+
if (e.name !== "FencedCode") return;
|
|
122
|
+
if (e.from >= t.from) return !1;
|
|
123
|
+
let n = e.node.firstChild, i = e.node.lastChild;
|
|
124
|
+
return i !== null && i.name === "CodeMark" && i.from !== n?.from && i.from >= t.from && i.from <= t.to || (r = !0), !1;
|
|
125
|
+
}
|
|
126
|
+
}), r;
|
|
127
|
+
}
|
|
128
|
+
function Ne(e, t) {
|
|
129
|
+
return f(e, t, 200) ?? h(e);
|
|
130
|
+
}
|
|
131
|
+
function Pe(e, t, n) {
|
|
132
|
+
let r = -1;
|
|
133
|
+
if (n.iterate({
|
|
134
|
+
from: t.from,
|
|
135
|
+
to: t.to,
|
|
136
|
+
enter: (e) => {
|
|
137
|
+
e.name === "QuoteMark" && e.from >= t.from && e.to <= t.to && (r = Math.max(r, e.to));
|
|
138
|
+
}
|
|
139
|
+
}), r < 0) return {
|
|
140
|
+
at: t.from,
|
|
141
|
+
missingSpace: !1
|
|
142
|
+
};
|
|
143
|
+
let i = e.doc.sliceString(r, r + 1) === " " && r < t.to;
|
|
144
|
+
return {
|
|
145
|
+
at: i ? r + 1 : r,
|
|
146
|
+
missingSpace: !i
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
106
150
|
//#region src/editor/tokens.ts
|
|
107
|
-
var
|
|
151
|
+
var Fe = {
|
|
108
152
|
quote: "#6a737d",
|
|
109
153
|
link: "#0366d6",
|
|
110
154
|
border: "#ddd"
|
|
111
|
-
},
|
|
155
|
+
}, Ie = "system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif", Le = d.define([
|
|
112
156
|
{
|
|
113
|
-
tag:
|
|
157
|
+
tag: g.heading1,
|
|
114
158
|
fontSize: "1.6em",
|
|
115
159
|
fontWeight: "bold"
|
|
116
160
|
},
|
|
117
161
|
{
|
|
118
|
-
tag:
|
|
162
|
+
tag: g.heading2,
|
|
119
163
|
fontSize: "1.4em",
|
|
120
164
|
fontWeight: "bold"
|
|
121
165
|
},
|
|
122
166
|
{
|
|
123
|
-
tag:
|
|
167
|
+
tag: g.heading3,
|
|
124
168
|
fontSize: "1.25em",
|
|
125
169
|
fontWeight: "bold"
|
|
126
170
|
},
|
|
127
171
|
{
|
|
128
|
-
tag:
|
|
172
|
+
tag: g.heading4,
|
|
129
173
|
fontSize: "1.15em",
|
|
130
174
|
fontWeight: "bold"
|
|
131
175
|
},
|
|
132
176
|
{
|
|
133
|
-
tag: [
|
|
177
|
+
tag: [g.heading5, g.heading6],
|
|
134
178
|
fontWeight: "bold"
|
|
135
179
|
},
|
|
136
180
|
{
|
|
137
|
-
tag:
|
|
181
|
+
tag: g.strong,
|
|
138
182
|
fontWeight: "bold"
|
|
139
183
|
},
|
|
140
184
|
{
|
|
141
|
-
tag:
|
|
185
|
+
tag: g.emphasis,
|
|
142
186
|
fontStyle: "italic"
|
|
143
187
|
},
|
|
144
188
|
{
|
|
145
|
-
tag:
|
|
189
|
+
tag: g.strikethrough,
|
|
146
190
|
textDecoration: "line-through"
|
|
147
191
|
},
|
|
148
192
|
{
|
|
149
|
-
tag:
|
|
193
|
+
tag: g.monospace,
|
|
150
194
|
fontFamily: "monospace"
|
|
151
195
|
},
|
|
152
196
|
{
|
|
153
|
-
tag:
|
|
154
|
-
color:
|
|
197
|
+
tag: g.quote,
|
|
198
|
+
color: Fe.quote,
|
|
155
199
|
fontStyle: "italic"
|
|
156
200
|
},
|
|
157
201
|
{
|
|
158
|
-
tag:
|
|
159
|
-
color:
|
|
202
|
+
tag: g.link,
|
|
203
|
+
color: Fe.link,
|
|
160
204
|
textDecoration: "underline"
|
|
161
205
|
},
|
|
162
206
|
{
|
|
163
|
-
tag:
|
|
164
|
-
color:
|
|
207
|
+
tag: g.url,
|
|
208
|
+
color: Fe.link
|
|
165
209
|
}
|
|
166
|
-
]),
|
|
167
|
-
function
|
|
168
|
-
if (t !=
|
|
210
|
+
]), Re = ee(Le), ze = 36;
|
|
211
|
+
function Be(e, t, n) {
|
|
212
|
+
if (t != ze || e.char(n + 1) != ze) return -1;
|
|
169
213
|
let r = e.text.indexOf("$$", n + 2 - e.offset);
|
|
170
214
|
if (r < 0) return -1;
|
|
171
215
|
let i = r + e.offset + 2;
|
|
172
216
|
return e.addElement(e.elt("BlockMath", n, i));
|
|
173
217
|
}
|
|
174
|
-
function
|
|
175
|
-
if (t !=
|
|
218
|
+
function Ve(e, t, n) {
|
|
219
|
+
if (t != ze) return -1;
|
|
176
220
|
let r = e.text.indexOf("$", n + 1 - e.offset);
|
|
177
221
|
if (r < 0) return -1;
|
|
178
222
|
let i = r + e.offset + 1;
|
|
179
223
|
return i == n + 2 ? -1 : e.addElement(e.elt("InlineMath", n, i));
|
|
180
224
|
}
|
|
181
|
-
var
|
|
225
|
+
var He = {
|
|
182
226
|
defineNodes: ["InlineMath", "BlockMath"],
|
|
183
227
|
parseInline: [{
|
|
184
228
|
name: "BlockMath",
|
|
185
229
|
before: "Escape",
|
|
186
|
-
parse:
|
|
230
|
+
parse: Be
|
|
187
231
|
}, {
|
|
188
232
|
name: "InlineMath",
|
|
189
233
|
before: "Escape",
|
|
190
|
-
parse:
|
|
234
|
+
parse: Ve
|
|
191
235
|
}]
|
|
192
|
-
},
|
|
236
|
+
}, Ue = /^(https?:\/\/|mailto:)/i, We = /^[^\s@]+@[^\s@]+$/, Ge = /^www\./i, Ke = /* @__PURE__ */ new Set([
|
|
193
237
|
"/",
|
|
194
238
|
":",
|
|
195
239
|
"@",
|
|
196
240
|
"."
|
|
197
241
|
]);
|
|
198
|
-
function
|
|
199
|
-
return
|
|
242
|
+
function qe(e, t) {
|
|
243
|
+
return Ue.test(e) ? e : Ge.test(e) ? `https://${e}` : We.test(e) ? t !== void 0 && Ke.has(t) ? null : `mailto:${e}` : e;
|
|
200
244
|
}
|
|
201
|
-
function
|
|
245
|
+
function Je(e) {
|
|
202
246
|
for (let t = e; t; t = t.parent) if (t.name === "Link" || t.name === "Autolink") return t;
|
|
203
247
|
return null;
|
|
204
248
|
}
|
|
205
|
-
function
|
|
249
|
+
function Ye(e) {
|
|
206
250
|
for (let t = e; t; t = t.parent) {
|
|
207
251
|
if (t.name === "URL") return t;
|
|
208
252
|
if (t.name === "Link" || t.name === "Autolink") return null;
|
|
209
253
|
}
|
|
210
254
|
return null;
|
|
211
255
|
}
|
|
212
|
-
function
|
|
213
|
-
let n =
|
|
256
|
+
function Xe(e, t) {
|
|
257
|
+
let n = h(e).resolveInner(t, 0), r = Je(n);
|
|
214
258
|
if (r) {
|
|
215
259
|
let t = r.getChild("URL");
|
|
216
260
|
if (!t) return null;
|
|
217
261
|
let n = e.doc.sliceString(t.from, t.to);
|
|
218
|
-
return
|
|
262
|
+
return Ue.test(n) ? n : null;
|
|
219
263
|
}
|
|
220
|
-
let i =
|
|
264
|
+
let i = Ye(n);
|
|
221
265
|
if (i) {
|
|
222
|
-
let t = i.from > 0 ? e.doc.sliceString(i.from - 1, i.from) : void 0, n =
|
|
223
|
-
return n === null ? null :
|
|
266
|
+
let t = i.from > 0 ? e.doc.sliceString(i.from - 1, i.from) : void 0, n = qe(e.doc.sliceString(i.from, i.to), t);
|
|
267
|
+
return n === null ? null : Ue.test(n) ? n : null;
|
|
224
268
|
}
|
|
225
269
|
return null;
|
|
226
270
|
}
|
|
227
|
-
function
|
|
271
|
+
function Ze(e, t) {
|
|
228
272
|
if (!e.metaKey && !e.ctrlKey) return !1;
|
|
229
273
|
let n = t.posAtCoords({
|
|
230
274
|
x: e.clientX,
|
|
231
275
|
y: e.clientY
|
|
232
276
|
});
|
|
233
277
|
if (n === null) return !1;
|
|
234
|
-
let r =
|
|
278
|
+
let r = Xe(t.state, n);
|
|
235
279
|
return r ? (window.open(r, "_blank", "noopener,noreferrer"), e.preventDefault(), !0) : !1;
|
|
236
280
|
}
|
|
237
|
-
var
|
|
238
|
-
function
|
|
281
|
+
var Qe = t.domEventHandlers({ mousedown: Ze }), $e = "supamde-link-hover";
|
|
282
|
+
function et(e) {
|
|
239
283
|
return e.ctrlKey || e.metaKey;
|
|
240
284
|
}
|
|
241
|
-
var
|
|
285
|
+
var tt = class {
|
|
242
286
|
view;
|
|
243
287
|
lastX = 0;
|
|
244
288
|
lastY = 0;
|
|
@@ -248,7 +292,7 @@ var Xe = class {
|
|
|
248
292
|
this.lastX = e.clientX, this.lastY = e.clientY, this.hasMousePosition = !0, this.updateState();
|
|
249
293
|
};
|
|
250
294
|
onKeyDown = (e) => {
|
|
251
|
-
|
|
295
|
+
et(e) && (this.modifierDown = !0, this.updateState());
|
|
252
296
|
};
|
|
253
297
|
onKeyUp = (e) => {
|
|
254
298
|
(e.key === "Control" || e.key === "Meta") && (this.modifierDown = e.ctrlKey || e.metaKey, this.updateState());
|
|
@@ -267,18 +311,18 @@ var Xe = class {
|
|
|
267
311
|
}
|
|
268
312
|
updateState() {
|
|
269
313
|
let e = this.modifierDown && this.hasMousePosition && this.pointerIsOverLink();
|
|
270
|
-
this.view.contentDOM.classList.toggle(
|
|
314
|
+
this.view.contentDOM.classList.toggle($e, e);
|
|
271
315
|
}
|
|
272
316
|
pointerIsOverLink() {
|
|
273
317
|
let e = this.view.posAtCoords({
|
|
274
318
|
x: this.lastX,
|
|
275
319
|
y: this.lastY
|
|
276
320
|
});
|
|
277
|
-
return e !== null &&
|
|
321
|
+
return e !== null && Xe(this.view.state, e) !== null;
|
|
278
322
|
}
|
|
279
|
-
},
|
|
323
|
+
}, nt = n.fromClass(tt), rt = t.theme({
|
|
280
324
|
"&": {
|
|
281
|
-
fontFamily:
|
|
325
|
+
fontFamily: Ie,
|
|
282
326
|
fontSize: "16px"
|
|
283
327
|
},
|
|
284
328
|
".cm-content": {
|
|
@@ -286,17 +330,17 @@ var Xe = class {
|
|
|
286
330
|
lineHeight: "1.5"
|
|
287
331
|
},
|
|
288
332
|
".cm-scroller": { fontFamily: "inherit" },
|
|
289
|
-
[`.cm-content.${
|
|
290
|
-
}),
|
|
333
|
+
[`.cm-content.${$e}`]: { cursor: "pointer" }
|
|
334
|
+
}), it = [
|
|
291
335
|
/^#{1,6} /,
|
|
292
336
|
/^> /,
|
|
293
337
|
/^- \[[ xX]\] /,
|
|
294
338
|
/^\d+\. /,
|
|
295
339
|
/^[-*] /
|
|
296
340
|
];
|
|
297
|
-
function
|
|
341
|
+
function _(e) {
|
|
298
342
|
let t = /^[ \t]*/.exec(e)[0], n = e.slice(t.length);
|
|
299
|
-
for (let e of
|
|
343
|
+
for (let e of it) {
|
|
300
344
|
let r = e.exec(n);
|
|
301
345
|
if (r) return {
|
|
302
346
|
indent: t,
|
|
@@ -306,7 +350,7 @@ function et(e) {
|
|
|
306
350
|
}
|
|
307
351
|
return null;
|
|
308
352
|
}
|
|
309
|
-
function
|
|
353
|
+
function at(e, t) {
|
|
310
354
|
if (e.startsWith(" ")) return 1;
|
|
311
355
|
let n = 0;
|
|
312
356
|
for (; n < t && e[n] === " ";) n++;
|
|
@@ -314,14 +358,14 @@ function tt(e, t) {
|
|
|
314
358
|
}
|
|
315
359
|
//#endregion
|
|
316
360
|
//#region src/utils/text.ts
|
|
317
|
-
function
|
|
361
|
+
function v(e, t) {
|
|
318
362
|
let n = e.state.changes(t);
|
|
319
363
|
e.dispatch({
|
|
320
364
|
changes: n,
|
|
321
365
|
selection: e.state.selection.map(n, 1)
|
|
322
366
|
});
|
|
323
367
|
}
|
|
324
|
-
function
|
|
368
|
+
function y(e) {
|
|
325
369
|
let t = e.selection.main, n = e.doc.lineAt(t.from), r = e.doc.lineAt(t.to);
|
|
326
370
|
return {
|
|
327
371
|
from: n.from,
|
|
@@ -330,16 +374,16 @@ function _(e) {
|
|
|
330
374
|
lastLine: r.number
|
|
331
375
|
};
|
|
332
376
|
}
|
|
333
|
-
function
|
|
334
|
-
let n =
|
|
377
|
+
function ot(e, t) {
|
|
378
|
+
let n = y(e.state), r = [];
|
|
335
379
|
for (let i = n.firstLine; i <= n.lastLine; i++) {
|
|
336
380
|
let n = t(e.state.doc.line(i));
|
|
337
381
|
n !== null && r.push(n);
|
|
338
382
|
}
|
|
339
|
-
return r.length !== 0 && (
|
|
383
|
+
return r.length !== 0 && (v(e, r), !0);
|
|
340
384
|
}
|
|
341
|
-
function
|
|
342
|
-
let { state: n } = e, r =
|
|
385
|
+
function st(e, t) {
|
|
386
|
+
let { state: n } = e, r = y(n), i = [], a = !0;
|
|
343
387
|
for (let e = r.firstLine; e <= r.lastLine; e++) if (!n.doc.line(e).text.startsWith(t)) {
|
|
344
388
|
a = !1;
|
|
345
389
|
break;
|
|
@@ -356,9 +400,9 @@ function rt(e, t) {
|
|
|
356
400
|
insert: t
|
|
357
401
|
});
|
|
358
402
|
}
|
|
359
|
-
return i.length !== 0 && (
|
|
403
|
+
return i.length !== 0 && (v(e, i), !0);
|
|
360
404
|
}
|
|
361
|
-
function
|
|
405
|
+
function ct(e, t, n) {
|
|
362
406
|
let r = e.state.selection.main;
|
|
363
407
|
return e.dispatch({
|
|
364
408
|
changes: [{
|
|
@@ -376,51 +420,51 @@ function it(e, t, n) {
|
|
|
376
420
|
}
|
|
377
421
|
//#endregion
|
|
378
422
|
//#region src/commands/queries.ts
|
|
379
|
-
function
|
|
380
|
-
let n = e.selection.main, r =
|
|
423
|
+
function b(e, t) {
|
|
424
|
+
let n = e.selection.main, r = h(e).resolveInner(n.from, 1);
|
|
381
425
|
for (; r;) {
|
|
382
426
|
if (r.name === t && r.from <= n.from && r.to >= n.to) return r;
|
|
383
427
|
r = r.parent;
|
|
384
428
|
}
|
|
385
429
|
return null;
|
|
386
430
|
}
|
|
387
|
-
function
|
|
388
|
-
let { firstLine: t } =
|
|
431
|
+
function x(e) {
|
|
432
|
+
let { firstLine: t } = y(e);
|
|
389
433
|
return e.doc.line(t).text;
|
|
390
434
|
}
|
|
391
|
-
function
|
|
392
|
-
return
|
|
435
|
+
function lt(e) {
|
|
436
|
+
return b(e, "StrongEmphasis") !== null;
|
|
393
437
|
}
|
|
394
|
-
function
|
|
395
|
-
return
|
|
438
|
+
function ut(e) {
|
|
439
|
+
return b(e, "Emphasis") !== null;
|
|
396
440
|
}
|
|
397
|
-
function
|
|
398
|
-
return
|
|
441
|
+
function dt(e) {
|
|
442
|
+
return b(e, "Strikethrough") !== null;
|
|
399
443
|
}
|
|
400
|
-
function
|
|
401
|
-
return
|
|
444
|
+
function ft(e) {
|
|
445
|
+
return b(e, "InlineCode") !== null;
|
|
402
446
|
}
|
|
403
|
-
function
|
|
404
|
-
let t = /^(#{1,6}) /.exec(
|
|
447
|
+
function S(e) {
|
|
448
|
+
let t = /^(#{1,6}) /.exec(x(e));
|
|
405
449
|
return t ? t[0].length - 1 : 0;
|
|
406
450
|
}
|
|
407
|
-
function
|
|
408
|
-
return
|
|
451
|
+
function pt(e) {
|
|
452
|
+
return x(e).startsWith("> ");
|
|
409
453
|
}
|
|
410
|
-
function
|
|
411
|
-
let t =
|
|
454
|
+
function mt(e) {
|
|
455
|
+
let t = x(e);
|
|
412
456
|
return /^[-*] /.test(t) && !/^- \[[ xX]\] /.test(t);
|
|
413
457
|
}
|
|
414
|
-
function
|
|
415
|
-
return /^\d+\. /.test(
|
|
458
|
+
function ht(e) {
|
|
459
|
+
return /^\d+\. /.test(x(e));
|
|
416
460
|
}
|
|
417
|
-
function
|
|
418
|
-
return /^- \[[ xX]\] /.test(
|
|
461
|
+
function gt(e) {
|
|
462
|
+
return /^- \[[ xX]\] /.test(x(e));
|
|
419
463
|
}
|
|
420
464
|
//#endregion
|
|
421
465
|
//#region src/commands/block.ts
|
|
422
|
-
function
|
|
423
|
-
let n =
|
|
466
|
+
function _t(e, t) {
|
|
467
|
+
let n = y(e.state), r = [];
|
|
424
468
|
for (let i = n.firstLine; i <= n.lastLine; i++) {
|
|
425
469
|
let n = e.state.doc.line(i), a = /^(#{1,6}) /.exec(n.text), o = a ? a[0].length : 0, s = t === 0 ? "" : "#".repeat(t) + " ";
|
|
426
470
|
r.push({
|
|
@@ -431,10 +475,10 @@ function x(e, t) {
|
|
|
431
475
|
}
|
|
432
476
|
return r.some((e) => e.from !== e.to || e.insert !== "") ? (e.dispatch({ changes: r }), !0) : !1;
|
|
433
477
|
}
|
|
434
|
-
function
|
|
435
|
-
return (t) =>
|
|
478
|
+
function C(e) {
|
|
479
|
+
return (t) => _t(t, S(t.state) === e ? 0 : e);
|
|
436
480
|
}
|
|
437
|
-
var
|
|
481
|
+
var vt = (e) => _t(e, Math.min(S(e.state) + 1, 6)), yt = (e) => _t(e, Math.max(S(e.state) - 1, 0)), bt = (e) => st(e, "> "), xt = (e) => {
|
|
438
482
|
let t = e.state.selection.main, n = "```\n", r = "\n```", i = e.state.sliceDoc(Math.max(0, t.from - 4), t.from), a = e.state.sliceDoc(t.to, Math.min(e.state.doc.length, t.to + 4));
|
|
439
483
|
return i === n && a === r ? (e.dispatch({ changes: [{
|
|
440
484
|
from: t.from - 4,
|
|
@@ -444,17 +488,17 @@ var pt = (e) => x(e, Math.min(b(e.state) + 1, 6)), mt = (e) => x(e, Math.max(b(e
|
|
|
444
488
|
from: t.to,
|
|
445
489
|
to: t.to + 4,
|
|
446
490
|
insert: ""
|
|
447
|
-
}] }), !0) :
|
|
448
|
-
},
|
|
491
|
+
}] }), !0) : ct(e, n, r);
|
|
492
|
+
}, St = (e) => {
|
|
449
493
|
let t = e.state.doc.lineAt(e.state.selection.main.head);
|
|
450
494
|
return e.dispatch({ changes: {
|
|
451
495
|
from: t.to,
|
|
452
496
|
insert: "\n---\n"
|
|
453
497
|
} }), !0;
|
|
454
|
-
},
|
|
455
|
-
let t =
|
|
498
|
+
}, Ct = (e) => {
|
|
499
|
+
let t = y(e.state), n = [];
|
|
456
500
|
for (let r = t.firstLine; r <= t.lastLine; r++) {
|
|
457
|
-
let t = e.state.doc.line(r), i =
|
|
501
|
+
let t = e.state.doc.line(r), i = _(t.text);
|
|
458
502
|
if (i) {
|
|
459
503
|
let e = t.from + i.indent.length;
|
|
460
504
|
n.push({
|
|
@@ -465,28 +509,28 @@ var pt = (e) => x(e, Math.min(b(e.state) + 1, 6)), mt = (e) => x(e, Math.max(b(e
|
|
|
465
509
|
}
|
|
466
510
|
}
|
|
467
511
|
return n.length !== 0 && (e.dispatch({ changes: n }), !0);
|
|
468
|
-
},
|
|
469
|
-
function
|
|
470
|
-
let t =
|
|
512
|
+
}, wt = /^[-*] $/;
|
|
513
|
+
function Tt(e) {
|
|
514
|
+
let t = _(e);
|
|
471
515
|
if (t === null) return {
|
|
472
516
|
indent: /^[ \t]*/.exec(e)[0],
|
|
473
517
|
bullet: null,
|
|
474
518
|
hasPrefix: !1
|
|
475
519
|
};
|
|
476
|
-
let n =
|
|
520
|
+
let n = wt.test(t.prefix);
|
|
477
521
|
return {
|
|
478
522
|
indent: t.indent,
|
|
479
523
|
bullet: n ? t.prefix : null,
|
|
480
524
|
hasPrefix: !0
|
|
481
525
|
};
|
|
482
526
|
}
|
|
483
|
-
function
|
|
484
|
-
let n =
|
|
527
|
+
function Et(e, t) {
|
|
528
|
+
let n = y(e.state), r = [];
|
|
485
529
|
for (let t = n.firstLine; t <= n.lastLine; t++) {
|
|
486
530
|
let n = e.state.doc.line(t);
|
|
487
531
|
r.push({
|
|
488
532
|
from: n.from,
|
|
489
|
-
...
|
|
533
|
+
...Tt(n.text)
|
|
490
534
|
});
|
|
491
535
|
}
|
|
492
536
|
let i = r.every((e) => e.bullet === t), a = [];
|
|
@@ -506,10 +550,10 @@ function xt(e, t) {
|
|
|
506
550
|
insert: t
|
|
507
551
|
});
|
|
508
552
|
}
|
|
509
|
-
return a.length !== 0 && (
|
|
553
|
+
return a.length !== 0 && (v(e, a), !0);
|
|
510
554
|
}
|
|
511
|
-
var
|
|
512
|
-
let t =
|
|
555
|
+
var Dt = (e) => Et(e, "- "), Ot = (e) => Et(e, "* "), kt = (e) => st(e, "- [ ] "), At = (e) => {
|
|
556
|
+
let t = y(e.state), n = !0;
|
|
513
557
|
for (let r = t.firstLine; r <= t.lastLine; r++) if (!/^\d+\. /.test(e.state.doc.line(r).text)) {
|
|
514
558
|
n = !1;
|
|
515
559
|
break;
|
|
@@ -530,17 +574,17 @@ var St = (e) => xt(e, "- "), Ct = (e) => xt(e, "* "), wt = (e) => rt(e, "- [ ] "
|
|
|
530
574
|
insert: `${i}. `
|
|
531
575
|
}), i++;
|
|
532
576
|
}
|
|
533
|
-
return
|
|
577
|
+
return v(e, r), !0;
|
|
534
578
|
};
|
|
535
|
-
function
|
|
579
|
+
function jt(e) {
|
|
536
580
|
if (/^- \[[ xX]\] $/.test(e)) return "- [ ] ";
|
|
537
581
|
let t = /^(\d+)\. $/.exec(e);
|
|
538
582
|
return t ? `${Number(t[1]) + 1}. ` : e === "* " || e === "- " ? e : null;
|
|
539
583
|
}
|
|
540
|
-
function
|
|
541
|
-
let t = e.state.selection.main, n = e.state.doc.lineAt(t.head), r =
|
|
584
|
+
function Mt(e) {
|
|
585
|
+
let t = e.state.selection.main, n = e.state.doc.lineAt(t.head), r = _(n.text);
|
|
542
586
|
if (r === null) return !1;
|
|
543
|
-
let i =
|
|
587
|
+
let i = jt(r.prefix);
|
|
544
588
|
if (i === null) return !1;
|
|
545
589
|
let a = n.from + r.indent.length + r.prefix.length;
|
|
546
590
|
if (t.from < a) return !1;
|
|
@@ -563,30 +607,46 @@ function Dt(e) {
|
|
|
563
607
|
}
|
|
564
608
|
//#endregion
|
|
565
609
|
//#region src/commands/indent.ts
|
|
566
|
-
var
|
|
567
|
-
let t = " ".repeat(
|
|
568
|
-
return
|
|
569
|
-
|
|
570
|
-
to: e.from,
|
|
571
|
-
insert: t
|
|
572
|
-
})), !0;
|
|
573
|
-
}, kt = (e) => {
|
|
574
|
-
let t = f(e.state);
|
|
575
|
-
return nt(e, (e) => {
|
|
576
|
-
let n = tt(e.text, t);
|
|
577
|
-
return n > 0 ? {
|
|
610
|
+
var Nt = (e) => {
|
|
611
|
+
let { state: t } = e, n = " ".repeat(p(t)), r = t.facet(je), i = r !== null && r !== n ? Ne(t, t.doc.lineAt(t.selection.main.to).to) : null;
|
|
612
|
+
return ot(e, (e) => {
|
|
613
|
+
if (i === null || r === null || !Me(t, e, i)) return {
|
|
578
614
|
from: e.from,
|
|
579
|
-
to: e.from
|
|
615
|
+
to: e.from,
|
|
616
|
+
insert: n
|
|
617
|
+
};
|
|
618
|
+
let { at: a, missingSpace: o } = Pe(t, e, i);
|
|
619
|
+
return {
|
|
620
|
+
from: a,
|
|
621
|
+
to: a,
|
|
622
|
+
insert: (o ? " " : "") + r
|
|
623
|
+
};
|
|
624
|
+
}), !0;
|
|
625
|
+
}, Pt = (e) => {
|
|
626
|
+
let { state: t } = e, n = p(t), r = t.facet(je), i = r === null ? n : r === " " ? t.tabSize : r.length, a = i === n ? null : Ne(t, t.doc.lineAt(t.selection.main.to).to);
|
|
627
|
+
return ot(e, (e) => {
|
|
628
|
+
if (a === null || !Me(t, e, a)) {
|
|
629
|
+
let t = at(e.text, n);
|
|
630
|
+
return t > 0 ? {
|
|
631
|
+
from: e.from,
|
|
632
|
+
to: e.from + t,
|
|
633
|
+
insert: ""
|
|
634
|
+
} : null;
|
|
635
|
+
}
|
|
636
|
+
let { at: r } = Pe(t, e, a), o = at(t.doc.sliceString(r, e.to), i);
|
|
637
|
+
return o > 0 ? {
|
|
638
|
+
from: r,
|
|
639
|
+
to: r + o,
|
|
580
640
|
insert: ""
|
|
581
641
|
} : null;
|
|
582
642
|
}), !0;
|
|
583
643
|
};
|
|
584
644
|
//#endregion
|
|
585
645
|
//#region src/commands/inline.ts
|
|
586
|
-
function
|
|
587
|
-
return
|
|
646
|
+
function Ft(e, t) {
|
|
647
|
+
return b(e.state, t.node);
|
|
588
648
|
}
|
|
589
|
-
function
|
|
649
|
+
function It(e, t, n) {
|
|
590
650
|
let r = [];
|
|
591
651
|
for (let e = t.firstChild; e; e = e.nextSibling) e.name === n && r.push({
|
|
592
652
|
from: e.from,
|
|
@@ -598,33 +658,33 @@ function jt(e, t, n) {
|
|
|
598
658
|
insert: ""
|
|
599
659
|
})) }), !0);
|
|
600
660
|
}
|
|
601
|
-
function
|
|
661
|
+
function w(e) {
|
|
602
662
|
return (t) => {
|
|
603
|
-
let n =
|
|
604
|
-
return n ?
|
|
663
|
+
let n = Ft(t, e);
|
|
664
|
+
return n ? It(t, n, e.mark) : ct(t, e.before, e.after);
|
|
605
665
|
};
|
|
606
666
|
}
|
|
607
|
-
var
|
|
667
|
+
var Lt = w({
|
|
608
668
|
node: "StrongEmphasis",
|
|
609
669
|
mark: "EmphasisMark",
|
|
610
670
|
before: "**",
|
|
611
671
|
after: "**"
|
|
612
|
-
}),
|
|
672
|
+
}), Rt = w({
|
|
613
673
|
node: "Emphasis",
|
|
614
674
|
mark: "EmphasisMark",
|
|
615
675
|
before: "*",
|
|
616
676
|
after: "*"
|
|
617
|
-
}),
|
|
677
|
+
}), zt = w({
|
|
618
678
|
node: "Strikethrough",
|
|
619
679
|
mark: "StrikethroughMark",
|
|
620
680
|
before: "~~",
|
|
621
681
|
after: "~~"
|
|
622
|
-
}),
|
|
682
|
+
}), Bt = w({
|
|
623
683
|
node: "InlineCode",
|
|
624
684
|
mark: "CodeMark",
|
|
625
685
|
before: "`",
|
|
626
686
|
after: "`"
|
|
627
|
-
}),
|
|
687
|
+
}), T = {
|
|
628
688
|
code: "en",
|
|
629
689
|
texts: {
|
|
630
690
|
"toolbar.bold": "Bold",
|
|
@@ -679,54 +739,54 @@ var Mt = C({
|
|
|
679
739
|
};
|
|
680
740
|
//#endregion
|
|
681
741
|
//#region src/util/text-format.ts
|
|
682
|
-
function
|
|
742
|
+
function Vt(e, t) {
|
|
683
743
|
return e.replace(/\{(\w+)\}/g, (e, n) => Object.prototype.hasOwnProperty.call(t, n) ? t[n] : e);
|
|
684
744
|
}
|
|
685
|
-
function
|
|
745
|
+
function Ht(e) {
|
|
686
746
|
return e >= 1048576 ? `${Math.round(e / 1048576)} MB` : e >= 1024 ? `${Math.round(e / 1024)} KB` : `${e} B`;
|
|
687
747
|
}
|
|
688
748
|
//#endregion
|
|
689
749
|
//#region src/i18n/translator.ts
|
|
690
|
-
var
|
|
750
|
+
var E = "en", Ut = {
|
|
691
751
|
hour: "2-digit",
|
|
692
752
|
minute: "2-digit"
|
|
693
753
|
};
|
|
694
|
-
function
|
|
754
|
+
function Wt(e, t) {
|
|
695
755
|
return typeof e == "string" ? typeof t == "string" : typeof t == "object" && !!t && typeof t.other == "string";
|
|
696
756
|
}
|
|
697
|
-
function
|
|
698
|
-
let t = { ...
|
|
699
|
-
for (let n of e) if (typeof n == "object" && n) for (let e of Object.keys(
|
|
757
|
+
function Gt(e) {
|
|
758
|
+
let t = { ...T.texts };
|
|
759
|
+
for (let n of e) if (typeof n == "object" && n) for (let e of Object.keys(T.texts)) {
|
|
700
760
|
let r = n[e];
|
|
701
|
-
|
|
761
|
+
Wt(T.texts[e], r) && (t[e] = r);
|
|
702
762
|
}
|
|
703
763
|
return t;
|
|
704
764
|
}
|
|
705
|
-
function
|
|
765
|
+
function Kt(e) {
|
|
706
766
|
if (typeof e == "string") try {
|
|
707
767
|
return {
|
|
708
768
|
code: e,
|
|
709
769
|
rules: new Intl.PluralRules(e),
|
|
710
|
-
time: new Intl.DateTimeFormat(e,
|
|
770
|
+
time: new Intl.DateTimeFormat(e, Ut)
|
|
711
771
|
};
|
|
712
772
|
} catch {}
|
|
713
|
-
return console.warn(`SupaMDE: invalid locale code "${String(e)}" — using "${
|
|
714
|
-
code:
|
|
715
|
-
rules: new Intl.PluralRules(
|
|
716
|
-
time: new Intl.DateTimeFormat(
|
|
773
|
+
return console.warn(`SupaMDE: invalid locale code "${String(e)}" — using "${E}" for plural rules and time format.`), {
|
|
774
|
+
code: E,
|
|
775
|
+
rules: new Intl.PluralRules(E),
|
|
776
|
+
time: new Intl.DateTimeFormat(E, Ut)
|
|
717
777
|
};
|
|
718
778
|
}
|
|
719
|
-
function
|
|
720
|
-
let n =
|
|
779
|
+
function D(e, t) {
|
|
780
|
+
let n = Gt([e?.texts, t]), r = Kt(e == null ? E : e.code), i = n;
|
|
721
781
|
return {
|
|
722
782
|
code: r.code,
|
|
723
783
|
t(e, t = {}) {
|
|
724
784
|
let n = i[e];
|
|
725
|
-
return typeof n == "string" ?
|
|
785
|
+
return typeof n == "string" ? Vt(n, t) : e;
|
|
726
786
|
},
|
|
727
787
|
plural(e, t, i = {}) {
|
|
728
788
|
let a = n[e], o = a[r.rules.select(t)];
|
|
729
|
-
return
|
|
789
|
+
return Vt(typeof o == "string" ? o : a.other, {
|
|
730
790
|
...i,
|
|
731
791
|
count: String(t)
|
|
732
792
|
});
|
|
@@ -738,10 +798,10 @@ function E(e, t) {
|
|
|
738
798
|
}
|
|
739
799
|
//#endregion
|
|
740
800
|
//#region src/i18n/facet.ts
|
|
741
|
-
var
|
|
801
|
+
var qt = D(), O = s.define({ combine: (e) => e[0] ?? qt });
|
|
742
802
|
//#endregion
|
|
743
803
|
//#region src/commands/link-image.ts
|
|
744
|
-
function
|
|
804
|
+
function Jt(e, t) {
|
|
745
805
|
return (n) => {
|
|
746
806
|
if (!e) return !1;
|
|
747
807
|
let r = n.state.selection.main, i = `[${t ?? n.state.sliceDoc(r.from, r.to)}](${e})`;
|
|
@@ -755,7 +815,7 @@ function Ut(e, t) {
|
|
|
755
815
|
}), !0;
|
|
756
816
|
};
|
|
757
817
|
}
|
|
758
|
-
function
|
|
818
|
+
function Yt(e, t) {
|
|
759
819
|
return (n) => {
|
|
760
820
|
if (!e) return !1;
|
|
761
821
|
let r = n.state.selection.main, i = ``;
|
|
@@ -769,18 +829,18 @@ function Wt(e, t) {
|
|
|
769
829
|
}), !0;
|
|
770
830
|
};
|
|
771
831
|
}
|
|
772
|
-
function
|
|
773
|
-
let t = window.prompt(e.state.facet(
|
|
774
|
-
return t ?
|
|
832
|
+
function Xt(e) {
|
|
833
|
+
let t = window.prompt(e.state.facet(O).t("prompt.linkUrl"), "https://");
|
|
834
|
+
return t ? Jt(t)(e) : !1;
|
|
775
835
|
}
|
|
776
|
-
function
|
|
777
|
-
let t = window.prompt(e.state.facet(
|
|
778
|
-
return t ?
|
|
836
|
+
function Zt(e) {
|
|
837
|
+
let t = window.prompt(e.state.facet(O).t("prompt.imageUrl"), "https://");
|
|
838
|
+
return t ? Yt(t)(e) : !1;
|
|
779
839
|
}
|
|
780
840
|
//#endregion
|
|
781
841
|
//#region src/commands/table.ts
|
|
782
|
-
var
|
|
783
|
-
let t = e.state.facet(
|
|
842
|
+
var Qt = (e) => {
|
|
843
|
+
let t = e.state.facet(O), n = `| ${t.t("table.column", { n: "1" })} | ${t.t("table.column", { n: "2" })} |\n| --- | --- |\n| | |\n`, r = e.state.selection.main;
|
|
784
844
|
return e.dispatch({
|
|
785
845
|
changes: {
|
|
786
846
|
from: r.from,
|
|
@@ -792,150 +852,150 @@ var qt = (e) => {
|
|
|
792
852
|
};
|
|
793
853
|
//#endregion
|
|
794
854
|
//#region src/ui/actions.ts
|
|
795
|
-
function
|
|
796
|
-
return (t) =>
|
|
855
|
+
function k(e) {
|
|
856
|
+
return (t) => S(t) === e;
|
|
797
857
|
}
|
|
798
|
-
var
|
|
858
|
+
var $t = {
|
|
799
859
|
bold: {
|
|
800
860
|
kind: "command",
|
|
801
|
-
command:
|
|
802
|
-
query:
|
|
861
|
+
command: Lt,
|
|
862
|
+
query: lt,
|
|
803
863
|
icon: "bold",
|
|
804
864
|
shortcut: "Mod-b"
|
|
805
865
|
},
|
|
806
866
|
italic: {
|
|
807
867
|
kind: "command",
|
|
808
|
-
command:
|
|
809
|
-
query:
|
|
868
|
+
command: Rt,
|
|
869
|
+
query: ut,
|
|
810
870
|
icon: "italic",
|
|
811
871
|
shortcut: "Mod-i"
|
|
812
872
|
},
|
|
813
873
|
strikethrough: {
|
|
814
874
|
kind: "command",
|
|
815
|
-
command:
|
|
816
|
-
query:
|
|
875
|
+
command: zt,
|
|
876
|
+
query: dt,
|
|
817
877
|
icon: "strikethrough"
|
|
818
878
|
},
|
|
819
879
|
code: {
|
|
820
880
|
kind: "command",
|
|
821
|
-
command:
|
|
822
|
-
query:
|
|
881
|
+
command: Bt,
|
|
882
|
+
query: ft,
|
|
823
883
|
icon: "code"
|
|
824
884
|
},
|
|
825
885
|
"heading-smaller": {
|
|
826
886
|
kind: "command",
|
|
827
|
-
command:
|
|
887
|
+
command: vt,
|
|
828
888
|
icon: "heading",
|
|
829
889
|
shortcut: "Mod-h"
|
|
830
890
|
},
|
|
831
891
|
"heading-bigger": {
|
|
832
892
|
kind: "command",
|
|
833
|
-
command:
|
|
893
|
+
command: yt,
|
|
834
894
|
icon: "heading",
|
|
835
895
|
shortcut: "Shift-Mod-h"
|
|
836
896
|
},
|
|
837
897
|
"heading-1": {
|
|
838
898
|
kind: "command",
|
|
839
|
-
command:
|
|
840
|
-
query:
|
|
899
|
+
command: C(1),
|
|
900
|
+
query: k(1),
|
|
841
901
|
icon: "heading",
|
|
842
902
|
shortcut: "Ctrl-Alt-1"
|
|
843
903
|
},
|
|
844
904
|
"heading-2": {
|
|
845
905
|
kind: "command",
|
|
846
|
-
command:
|
|
847
|
-
query:
|
|
906
|
+
command: C(2),
|
|
907
|
+
query: k(2),
|
|
848
908
|
icon: "heading",
|
|
849
909
|
shortcut: "Ctrl-Alt-2"
|
|
850
910
|
},
|
|
851
911
|
"heading-3": {
|
|
852
912
|
kind: "command",
|
|
853
|
-
command:
|
|
854
|
-
query:
|
|
913
|
+
command: C(3),
|
|
914
|
+
query: k(3),
|
|
855
915
|
icon: "heading",
|
|
856
916
|
shortcut: "Ctrl-Alt-3"
|
|
857
917
|
},
|
|
858
918
|
"heading-4": {
|
|
859
919
|
kind: "command",
|
|
860
|
-
command:
|
|
861
|
-
query:
|
|
920
|
+
command: C(4),
|
|
921
|
+
query: k(4),
|
|
862
922
|
icon: "heading",
|
|
863
923
|
shortcut: "Ctrl-Alt-4"
|
|
864
924
|
},
|
|
865
925
|
"heading-5": {
|
|
866
926
|
kind: "command",
|
|
867
|
-
command:
|
|
868
|
-
query:
|
|
927
|
+
command: C(5),
|
|
928
|
+
query: k(5),
|
|
869
929
|
icon: "heading",
|
|
870
930
|
shortcut: "Ctrl-Alt-5"
|
|
871
931
|
},
|
|
872
932
|
"heading-6": {
|
|
873
933
|
kind: "command",
|
|
874
|
-
command:
|
|
875
|
-
query:
|
|
934
|
+
command: C(6),
|
|
935
|
+
query: k(6),
|
|
876
936
|
icon: "heading",
|
|
877
937
|
shortcut: "Ctrl-Alt-6"
|
|
878
938
|
},
|
|
879
939
|
quote: {
|
|
880
940
|
kind: "command",
|
|
881
|
-
command:
|
|
882
|
-
query:
|
|
941
|
+
command: bt,
|
|
942
|
+
query: pt,
|
|
883
943
|
icon: "quote",
|
|
884
944
|
shortcut: "Mod-'"
|
|
885
945
|
},
|
|
886
946
|
"code-block": {
|
|
887
947
|
kind: "command",
|
|
888
|
-
command:
|
|
948
|
+
command: xt,
|
|
889
949
|
icon: "code-block",
|
|
890
950
|
shortcut: "Mod-Alt-c"
|
|
891
951
|
},
|
|
892
952
|
"horizontal-rule": {
|
|
893
953
|
kind: "command",
|
|
894
|
-
command:
|
|
954
|
+
command: St,
|
|
895
955
|
icon: "horizontal-rule"
|
|
896
956
|
},
|
|
897
957
|
"clean-block": {
|
|
898
958
|
kind: "command",
|
|
899
|
-
command:
|
|
959
|
+
command: Ct,
|
|
900
960
|
icon: "clean-block",
|
|
901
961
|
shortcut: "Mod-e"
|
|
902
962
|
},
|
|
903
963
|
"unordered-list": {
|
|
904
964
|
kind: "command",
|
|
905
|
-
command:
|
|
906
|
-
query:
|
|
965
|
+
command: Dt,
|
|
966
|
+
query: mt,
|
|
907
967
|
icon: "unordered-list",
|
|
908
968
|
shortcut: "Mod-l"
|
|
909
969
|
},
|
|
910
970
|
"ordered-list": {
|
|
911
971
|
kind: "command",
|
|
912
|
-
command:
|
|
913
|
-
query:
|
|
972
|
+
command: At,
|
|
973
|
+
query: ht,
|
|
914
974
|
icon: "ordered-list",
|
|
915
975
|
shortcut: "Mod-Alt-l"
|
|
916
976
|
},
|
|
917
977
|
"check-list": {
|
|
918
978
|
kind: "command",
|
|
919
|
-
command:
|
|
920
|
-
query:
|
|
979
|
+
command: kt,
|
|
980
|
+
query: gt,
|
|
921
981
|
icon: "check-list",
|
|
922
982
|
shortcut: "Shift-Mod-l"
|
|
923
983
|
},
|
|
924
984
|
link: {
|
|
925
985
|
kind: "command",
|
|
926
|
-
command:
|
|
986
|
+
command: Xt,
|
|
927
987
|
icon: "link",
|
|
928
988
|
shortcut: "Mod-k"
|
|
929
989
|
},
|
|
930
990
|
image: {
|
|
931
991
|
kind: "command",
|
|
932
|
-
command:
|
|
992
|
+
command: Zt,
|
|
933
993
|
icon: "image",
|
|
934
994
|
shortcut: "Mod-Alt-i"
|
|
935
995
|
},
|
|
936
996
|
table: {
|
|
937
997
|
kind: "command",
|
|
938
|
-
command:
|
|
998
|
+
command: Qt,
|
|
939
999
|
icon: "table"
|
|
940
1000
|
},
|
|
941
1001
|
undo: {
|
|
@@ -990,33 +1050,33 @@ var Jt = {
|
|
|
990
1050
|
icon: "upload-image"
|
|
991
1051
|
}
|
|
992
1052
|
};
|
|
993
|
-
function
|
|
994
|
-
return
|
|
1053
|
+
function en(e) {
|
|
1054
|
+
return $t[e];
|
|
995
1055
|
}
|
|
996
1056
|
//#endregion
|
|
997
1057
|
//#region src/commands/keymap.ts
|
|
998
|
-
var
|
|
999
|
-
function
|
|
1058
|
+
var tn = /* @__PURE__ */ new Set(["undo", "redo"]);
|
|
1059
|
+
function nn(e) {
|
|
1000
1060
|
return typeof e == "string" ? e : e.default;
|
|
1001
1061
|
}
|
|
1002
|
-
var
|
|
1003
|
-
key:
|
|
1062
|
+
var rn = Object.entries($t).filter((e) => e[1].kind === "command" && !!e[1].shortcut && !tn.has(e[0])).map(([, e]) => ({
|
|
1063
|
+
key: nn(e.shortcut),
|
|
1004
1064
|
run: e.command,
|
|
1005
1065
|
preventDefault: !0
|
|
1006
|
-
})),
|
|
1066
|
+
})), an = [
|
|
1007
1067
|
{
|
|
1008
1068
|
key: "Ctrl-Alt-q",
|
|
1009
|
-
run:
|
|
1069
|
+
run: bt,
|
|
1010
1070
|
preventDefault: !0
|
|
1011
1071
|
},
|
|
1012
1072
|
{
|
|
1013
1073
|
key: "Shift-Alt-Mod-l",
|
|
1014
|
-
run:
|
|
1074
|
+
run: Ot,
|
|
1015
1075
|
preventDefault: !0
|
|
1016
1076
|
},
|
|
1017
1077
|
{
|
|
1018
1078
|
key: "Enter",
|
|
1019
|
-
run:
|
|
1079
|
+
run: Mt
|
|
1020
1080
|
},
|
|
1021
1081
|
{
|
|
1022
1082
|
key: "Backspace",
|
|
@@ -1024,12 +1084,12 @@ var Qt = Object.entries(Jt).filter((e) => e[1].kind === "command" && !!e[1].shor
|
|
|
1024
1084
|
},
|
|
1025
1085
|
{
|
|
1026
1086
|
key: "Tab",
|
|
1027
|
-
run:
|
|
1087
|
+
run: Nt,
|
|
1028
1088
|
preventDefault: !0
|
|
1029
1089
|
},
|
|
1030
1090
|
{
|
|
1031
1091
|
key: "Shift-Tab",
|
|
1032
|
-
run:
|
|
1092
|
+
run: Pt,
|
|
1033
1093
|
preventDefault: !0
|
|
1034
1094
|
},
|
|
1035
1095
|
{
|
|
@@ -1057,10 +1117,10 @@ var Qt = Object.entries(Jt).filter((e) => e[1].kind === "command" && !!e[1].shor
|
|
|
1057
1117
|
run: ce,
|
|
1058
1118
|
preventDefault: !0
|
|
1059
1119
|
}
|
|
1060
|
-
],
|
|
1120
|
+
], on = [...rn, ...an];
|
|
1061
1121
|
//#endregion
|
|
1062
1122
|
//#region src/ui/update-listener.ts
|
|
1063
|
-
function
|
|
1123
|
+
function sn(e) {
|
|
1064
1124
|
return t.updateListener.of((t) => {
|
|
1065
1125
|
(t.docChanged || t.selectionSet) && e.onUpdate({
|
|
1066
1126
|
state: t.state,
|
|
@@ -1071,38 +1131,39 @@ function tn(e) {
|
|
|
1071
1131
|
}
|
|
1072
1132
|
//#endregion
|
|
1073
1133
|
//#region src/editor/extensions.ts
|
|
1074
|
-
function
|
|
1134
|
+
function cn(e, n, a) {
|
|
1075
1135
|
let s = [
|
|
1076
1136
|
fe({
|
|
1077
|
-
extensions: [pe,
|
|
1137
|
+
extensions: [pe, He],
|
|
1078
1138
|
addKeymap: !1
|
|
1079
1139
|
}),
|
|
1080
|
-
|
|
1140
|
+
Re,
|
|
1081
1141
|
Ee.of(De(e.editorMode)),
|
|
1082
|
-
|
|
1083
|
-
|
|
1142
|
+
Qe,
|
|
1143
|
+
nt,
|
|
1084
1144
|
ae(),
|
|
1085
1145
|
r.of([
|
|
1086
1146
|
...e.extraKeys,
|
|
1087
|
-
...
|
|
1147
|
+
...on,
|
|
1088
1148
|
...oe,
|
|
1089
1149
|
...re
|
|
1090
1150
|
]),
|
|
1091
|
-
|
|
1151
|
+
rt,
|
|
1092
1152
|
o.tabSize.of(e.tabSize),
|
|
1093
|
-
|
|
1153
|
+
m.of(" ".repeat(e.indentUnit)),
|
|
1154
|
+
je.of(e.codeIndentUnit === "tab" ? " " : " ".repeat(e.codeIndentUnit))
|
|
1094
1155
|
];
|
|
1095
|
-
return e.lineWrapping && s.push(t.lineWrapping), e.placeholder !== null && s.push(i(e.placeholder)), n && s.push(
|
|
1156
|
+
return e.lineWrapping && s.push(t.lineWrapping), e.placeholder !== null && s.push(i(e.placeholder)), n && s.push(sn(n)), a && s.push(...a), s;
|
|
1096
1157
|
}
|
|
1097
1158
|
//#endregion
|
|
1098
1159
|
//#region src/editor/setup.ts
|
|
1099
|
-
function
|
|
1160
|
+
function ln(e, n, r) {
|
|
1100
1161
|
let i = e.element;
|
|
1101
1162
|
if (!i) throw Error("SupaMDE: `element` is required (a <textarea>).");
|
|
1102
1163
|
if (!(i instanceof HTMLTextAreaElement)) throw Error("SupaMDE: `element` must be a <textarea>.");
|
|
1103
|
-
let a = i, o =
|
|
1164
|
+
let a = i, o = Ae(e), s = e.initialValue ?? a.value, c = new t({
|
|
1104
1165
|
doc: s,
|
|
1105
|
-
extensions:
|
|
1166
|
+
extensions: cn(o, n, r)
|
|
1106
1167
|
});
|
|
1107
1168
|
a.parentNode?.insertBefore(c.dom, a);
|
|
1108
1169
|
let l = a.style.display;
|
|
@@ -1119,10 +1180,10 @@ function rn(e, n, r) {
|
|
|
1119
1180
|
}
|
|
1120
1181
|
//#endregion
|
|
1121
1182
|
//#region src/editor/value.ts
|
|
1122
|
-
function
|
|
1183
|
+
function un(e) {
|
|
1123
1184
|
return e.state.doc.toString();
|
|
1124
1185
|
}
|
|
1125
|
-
function
|
|
1186
|
+
function dn(e, t) {
|
|
1126
1187
|
e.dispatch({ changes: {
|
|
1127
1188
|
from: 0,
|
|
1128
1189
|
to: e.state.doc.length,
|
|
@@ -1131,16 +1192,16 @@ function on(e, t) {
|
|
|
1131
1192
|
}
|
|
1132
1193
|
//#endregion
|
|
1133
1194
|
//#region src/ui/toolbar-config.ts
|
|
1134
|
-
var
|
|
1135
|
-
function
|
|
1195
|
+
var fn = /* @__PURE__ */ "bold.italic.strikethrough.code.|.heading-smaller.heading-bigger.|.quote.unordered-list.ordered-list.check-list.|.code-block.horizontal-rule.|.link.image.table.|.clean-block.|.undo.redo.|.preview-fullscreen".split(".");
|
|
1196
|
+
function pn(e) {
|
|
1136
1197
|
if (e === !1) return null;
|
|
1137
|
-
let t = e ??
|
|
1198
|
+
let t = e ?? fn, n = [];
|
|
1138
1199
|
for (let e of t) if (typeof e == "string") {
|
|
1139
1200
|
if (e === "|") {
|
|
1140
1201
|
n.push({ kind: "separator" });
|
|
1141
1202
|
continue;
|
|
1142
1203
|
}
|
|
1143
|
-
let t =
|
|
1204
|
+
let t = en(e);
|
|
1144
1205
|
if (!t) {
|
|
1145
1206
|
console.warn(`SupaMDE: unknown toolbar action "${e}" is skipped.`);
|
|
1146
1207
|
continue;
|
|
@@ -1158,7 +1219,7 @@ function cn(e) {
|
|
|
1158
1219
|
}
|
|
1159
1220
|
//#endregion
|
|
1160
1221
|
//#region node_modules/lucide/dist/esm/defaultAttributes.mjs
|
|
1161
|
-
var
|
|
1222
|
+
var mn = {
|
|
1162
1223
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1163
1224
|
width: 24,
|
|
1164
1225
|
height: 24,
|
|
@@ -1168,22 +1229,22 @@ var ln = {
|
|
|
1168
1229
|
"stroke-width": 2,
|
|
1169
1230
|
"stroke-linecap": "round",
|
|
1170
1231
|
"stroke-linejoin": "round"
|
|
1171
|
-
},
|
|
1232
|
+
}, hn = ([e, t, n]) => {
|
|
1172
1233
|
let r = document.createElementNS("http://www.w3.org/2000/svg", e);
|
|
1173
1234
|
return Object.keys(t).forEach((e) => {
|
|
1174
1235
|
r.setAttribute(e, String(t[e]));
|
|
1175
1236
|
}), n?.length && n.forEach((e) => {
|
|
1176
|
-
let t =
|
|
1237
|
+
let t = hn(e);
|
|
1177
1238
|
r.appendChild(t);
|
|
1178
1239
|
}), r;
|
|
1179
|
-
},
|
|
1240
|
+
}, gn = (e, t = {}) => hn([
|
|
1180
1241
|
"svg",
|
|
1181
1242
|
{
|
|
1182
|
-
...
|
|
1243
|
+
...mn,
|
|
1183
1244
|
...t
|
|
1184
1245
|
},
|
|
1185
1246
|
e
|
|
1186
|
-
]),
|
|
1247
|
+
]), _n = {
|
|
1187
1248
|
bold: [["path", { d: "M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" }]],
|
|
1188
1249
|
italic: [
|
|
1189
1250
|
["line", {
|
|
@@ -1331,14 +1392,14 @@ var ln = {
|
|
|
1331
1392
|
}]
|
|
1332
1393
|
]
|
|
1333
1394
|
};
|
|
1334
|
-
function
|
|
1335
|
-
let t =
|
|
1395
|
+
function vn(e) {
|
|
1396
|
+
let t = _n[e];
|
|
1336
1397
|
if (!t) throw Error(`SupaMDE: unknown icon "${e}".`);
|
|
1337
|
-
return
|
|
1398
|
+
return gn(t);
|
|
1338
1399
|
}
|
|
1339
1400
|
//#endregion
|
|
1340
1401
|
//#region src/ui/shortcut-label.ts
|
|
1341
|
-
function
|
|
1402
|
+
function yn() {
|
|
1342
1403
|
try {
|
|
1343
1404
|
let e = navigator;
|
|
1344
1405
|
if (typeof navigator < "u" && e.userAgentData?.platform) return e.userAgentData.platform.toLowerCase().includes("mac");
|
|
@@ -1346,22 +1407,22 @@ function mn() {
|
|
|
1346
1407
|
} catch {}
|
|
1347
1408
|
return !1;
|
|
1348
1409
|
}
|
|
1349
|
-
function
|
|
1350
|
-
let n = t ??
|
|
1410
|
+
function bn(e, t) {
|
|
1411
|
+
let n = t ?? yn(), r = typeof e == "string" ? e : n ? e.mac : e.default, i = r.split("-");
|
|
1351
1412
|
if (i.length === 0) return r;
|
|
1352
1413
|
let a = i[i.length - 1];
|
|
1353
1414
|
if (!a) return r;
|
|
1354
1415
|
let o = a, s = i.slice(0, -1);
|
|
1355
|
-
return n ?
|
|
1416
|
+
return n ? xn(s, o) : Sn(s, o);
|
|
1356
1417
|
}
|
|
1357
|
-
function
|
|
1418
|
+
function xn(e, t) {
|
|
1358
1419
|
let n = [], r = !1, i = !1, a = !1, o = !1, s = !1;
|
|
1359
1420
|
for (let t of e) t === "Mod" ? r = !0 : t === "Cmd" ? i = !0 : t === "Ctrl" ? a = !0 : t === "Alt" ? o = !0 : t === "Shift" && (s = !0);
|
|
1360
1421
|
r && n.push("⌘"), i && n.push("⌘"), a && n.push("⌃"), o && n.push("⌥"), s && n.push("⇧");
|
|
1361
1422
|
let c = t.length === 1 ? t.toUpperCase() : t;
|
|
1362
1423
|
return n.join("") + c;
|
|
1363
1424
|
}
|
|
1364
|
-
function
|
|
1425
|
+
function Sn(e, t) {
|
|
1365
1426
|
let n = [], r = !1, i = !1, a = !1;
|
|
1366
1427
|
for (let t of e) t === "Mod" || t === "Ctrl" ? r = !0 : t === "Alt" ? i = !0 : t === "Shift" && (a = !0);
|
|
1367
1428
|
r && n.push("Ctrl"), i && n.push("Alt"), a && n.push("Shift");
|
|
@@ -1370,18 +1431,18 @@ function _n(e, t) {
|
|
|
1370
1431
|
}
|
|
1371
1432
|
//#endregion
|
|
1372
1433
|
//#region src/ui/toolbar.ts
|
|
1373
|
-
function
|
|
1434
|
+
function Cn(e) {
|
|
1374
1435
|
return typeof e == "object" && !!e && typeof e.toggleSideBySide == "function" && typeof e.toggleFullScreen == "function" && typeof e.isSideBySideActive == "function" && typeof e.isFullscreenActive == "function";
|
|
1375
1436
|
}
|
|
1376
|
-
function
|
|
1437
|
+
function wn(e, t, n, r, i, a) {
|
|
1377
1438
|
if (t.kind === "separator") {
|
|
1378
1439
|
let e = document.createElement("i");
|
|
1379
1440
|
return e.className = "supamde-separator", e;
|
|
1380
1441
|
}
|
|
1381
1442
|
let o = document.createElement("button");
|
|
1382
1443
|
if (o.type = "button", t.kind === "builtin") {
|
|
1383
|
-
let { action: s, name: c } = t, l = r.t(`toolbar.${c}`), u = s.shortcut ? `${l} (${
|
|
1384
|
-
if (o.title = u, o.setAttribute("aria-label", u), o.dataset.action = c, o.appendChild(
|
|
1444
|
+
let { action: s, name: c } = t, l = r.t(`toolbar.${c}`), u = s.shortcut ? `${l} (${bn(s.shortcut)})` : l;
|
|
1445
|
+
if (o.title = u, o.setAttribute("aria-label", u), o.dataset.action = c, o.appendChild(vn(s.icon)), s.kind === "command") {
|
|
1385
1446
|
let t = s.command;
|
|
1386
1447
|
o.addEventListener("click", () => {
|
|
1387
1448
|
e.focus(), t(e);
|
|
@@ -1406,20 +1467,20 @@ function yn(e, t, n, r, i, a) {
|
|
|
1406
1467
|
}
|
|
1407
1468
|
return o;
|
|
1408
1469
|
}
|
|
1409
|
-
function
|
|
1410
|
-
let i =
|
|
1470
|
+
function Tn(e, t, n, r = D()) {
|
|
1471
|
+
let i = pn(t);
|
|
1411
1472
|
if (i === null) return null;
|
|
1412
1473
|
let a = document.createElement("div");
|
|
1413
1474
|
a.className = "supamde-toolbar";
|
|
1414
1475
|
let o = [], s = [];
|
|
1415
|
-
for (let t of i) a.appendChild(
|
|
1476
|
+
for (let t of i) a.appendChild(wn(e, t, n, r, o, s));
|
|
1416
1477
|
let c = !1;
|
|
1417
1478
|
return {
|
|
1418
1479
|
dom: a,
|
|
1419
1480
|
update: (e) => {
|
|
1420
1481
|
for (let { el: t, query: n } of o) t.classList.toggle("active", n(e));
|
|
1421
1482
|
if (s.length > 0) {
|
|
1422
|
-
if (
|
|
1483
|
+
if (Cn(n)) for (let { el: e, active: t } of s) e.classList.toggle("active", t(n));
|
|
1423
1484
|
else c || (c = !0, console.warn("SupaMDE: toolbar contains view buttons (preview-fullscreen/side-by-side/fullscreen/editor-mode), but the given editor instance does not satisfy SupaLike (toggleSideBySide/toggleFullScreen/isSideBySideActive/isFullscreenActive) — the active state of these buttons is not updated."));
|
|
1424
1485
|
}
|
|
1425
1486
|
},
|
|
@@ -1430,27 +1491,27 @@ function bn(e, t, n, r = E()) {
|
|
|
1430
1491
|
}
|
|
1431
1492
|
//#endregion
|
|
1432
1493
|
//#region src/features/word-count.ts
|
|
1433
|
-
function
|
|
1494
|
+
function En(e) {
|
|
1434
1495
|
let t = e.trim();
|
|
1435
1496
|
return t.length === 0 ? 0 : t.split(/\s+/).length;
|
|
1436
1497
|
}
|
|
1437
1498
|
//#endregion
|
|
1438
1499
|
//#region src/ui/statusbar.ts
|
|
1439
|
-
var
|
|
1500
|
+
var Dn = [
|
|
1440
1501
|
"lines",
|
|
1441
1502
|
"words",
|
|
1442
1503
|
"cursor"
|
|
1443
|
-
],
|
|
1504
|
+
], On = /* @__PURE__ */ new Set([
|
|
1444
1505
|
"lines",
|
|
1445
1506
|
"words",
|
|
1446
1507
|
"cursor",
|
|
1447
1508
|
"autosave",
|
|
1448
1509
|
"upload-image"
|
|
1449
|
-
]),
|
|
1450
|
-
function
|
|
1510
|
+
]), kn = /* @__PURE__ */ new Set(["autosave", "upload-image"]);
|
|
1511
|
+
function An(e, t, n) {
|
|
1451
1512
|
switch (e) {
|
|
1452
1513
|
case "lines": return n.plural("status.lines", t.doc.lines);
|
|
1453
|
-
case "words": return n.plural("status.words",
|
|
1514
|
+
case "words": return n.plural("status.words", En(t.doc.toString()));
|
|
1454
1515
|
case "cursor": {
|
|
1455
1516
|
let e = t.selection.main.head, n = t.doc.lineAt(e);
|
|
1456
1517
|
return `${n.number}:${e - n.from + 1}`;
|
|
@@ -1460,14 +1521,14 @@ function Tn(e, t, n) {
|
|
|
1460
1521
|
default: return "";
|
|
1461
1522
|
}
|
|
1462
1523
|
}
|
|
1463
|
-
function
|
|
1524
|
+
function jn(e, t = D()) {
|
|
1464
1525
|
if (e === !1) return null;
|
|
1465
|
-
let n = e ??
|
|
1526
|
+
let n = e ?? Dn, r = document.createElement("div");
|
|
1466
1527
|
r.className = "supamde-statusbar";
|
|
1467
1528
|
let i = [], a = [];
|
|
1468
1529
|
for (let e of n) {
|
|
1469
1530
|
let t = document.createElement("span");
|
|
1470
|
-
typeof e == "string" ? (t.className = `supamde-status-${e}`, r.appendChild(t),
|
|
1531
|
+
typeof e == "string" ? (t.className = `supamde-status-${e}`, r.appendChild(t), On.has(e) && i.push({
|
|
1471
1532
|
name: e,
|
|
1472
1533
|
el: t
|
|
1473
1534
|
})) : (t.className = `supamde-status-custom ${e.className}`, t.textContent = e.defaultValue ?? "", r.appendChild(t), a.push({
|
|
@@ -1478,7 +1539,7 @@ function En(e, t = E()) {
|
|
|
1478
1539
|
return {
|
|
1479
1540
|
dom: r,
|
|
1480
1541
|
update: (e, n) => {
|
|
1481
|
-
for (let { name: n, el: r } of i)
|
|
1542
|
+
for (let { name: n, el: r } of i) kn.has(n) || (r.textContent = An(n, e, t));
|
|
1482
1543
|
for (let { item: e, el: t } of a) n.docChanged && e.onUpdate?.(t), n.selectionSet && e.onActivity?.(t);
|
|
1483
1544
|
},
|
|
1484
1545
|
setItem: (e, t) => {
|
|
@@ -1492,7 +1553,7 @@ function En(e, t = E()) {
|
|
|
1492
1553
|
}
|
|
1493
1554
|
//#endregion
|
|
1494
1555
|
//#region src/ui/preview.ts
|
|
1495
|
-
function
|
|
1556
|
+
function Mn(e, t) {
|
|
1496
1557
|
let n = document.createElement("div");
|
|
1497
1558
|
if (n.className = "supamde-preview-side", t.previewClass) {
|
|
1498
1559
|
let e = Array.isArray(t.previewClass) ? t.previewClass : [t.previewClass];
|
|
@@ -1544,10 +1605,10 @@ function Dn(e, t) {
|
|
|
1544
1605
|
}
|
|
1545
1606
|
//#endregion
|
|
1546
1607
|
//#region src/ui/fullscreen.ts
|
|
1547
|
-
var
|
|
1548
|
-
function
|
|
1608
|
+
var A = 0, Nn = "";
|
|
1609
|
+
function Pn(e, t = {}) {
|
|
1549
1610
|
let n = !1, r = (r) => {
|
|
1550
|
-
r !== n && (n = r, e.classList.toggle("supamde-fullscreen", n), n ? (
|
|
1611
|
+
r !== n && (n = r, e.classList.toggle("supamde-fullscreen", n), n ? (A === 0 && (Nn = document.body.style.overflow), A += 1, document.body.style.overflow = "hidden") : (A = Math.max(0, A - 1), A === 0 && (document.body.style.overflow = Nn)), t.onToggleFullScreen?.(n));
|
|
1551
1612
|
}, i = (e) => {
|
|
1552
1613
|
e.key === "Escape" && n && r(!1);
|
|
1553
1614
|
};
|
|
@@ -1562,21 +1623,21 @@ function kn(e, t = {}) {
|
|
|
1562
1623
|
}
|
|
1563
1624
|
//#endregion
|
|
1564
1625
|
//#region src/ui/toolbar.css?inline
|
|
1565
|
-
var
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1626
|
+
var Fn = ".supamde-container{--supamde-border-color:#d0d0d0;--supamde-border-width:1px;--supamde-border-top-width:var(--supamde-border-width);--supamde-border-right-width:var(--supamde-border-width);--supamde-border-bottom-width:var(--supamde-border-width);--supamde-border-left-width:var(--supamde-border-width);--supamde-radius:4px;--supamde-divider-toolbar-width:1px;--supamde-divider-statusbar-width:1px;--supamde-divider-preview-width:1px;--supamde-toolbar-bg:#f7f7f7;--supamde-btn-hover:#e6e6e6;--supamde-btn-active:#d8e6ff;--supamde-btn-text:#333;border-style:solid;border-color:var(--supamde-border-color);border-top-width:var(--supamde-border-top-width);border-right-width:var(--supamde-border-right-width);border-bottom-width:var(--supamde-border-bottom-width);border-left-width:var(--supamde-border-left-width);border-radius:var(--supamde-radius);overflow:hidden}.supamde-toolbar{border-bottom:var(--supamde-divider-toolbar-width) solid var(--supamde-border-color);background:var(--supamde-toolbar-bg);flex-wrap:wrap;align-items:center;gap:2px;padding:4px;display:flex}.supamde-toolbar button{width:28px;height:28px;color:var(--supamde-btn-text);cursor:pointer;background:0 0;border:1px solid #0000;border-radius:3px;justify-content:center;align-items:center;padding:0;display:inline-flex}.supamde-toolbar button:hover{background:var(--supamde-btn-hover)}.supamde-toolbar button.active{background:var(--supamde-btn-active)}.supamde-toolbar button svg{width:16px;height:16px}.supamde-separator{background:var(--supamde-border-color);width:1px;height:20px;margin:0 4px;display:inline-block}", In = ".supamde-statusbar{border-top:var(--supamde-divider-statusbar-width,1px) solid var(--supamde-border-color,#d0d0d0);background:var(--supamde-statusbar-bg,#f7f7f7);color:#666;gap:12px;padding:4px 8px;font-size:12px;display:flex}.supamde-statusbar span{white-space:nowrap}", Ln = ".supamde-editor-row{flex-direction:row;align-items:stretch;display:flex}.supamde-editor-row .cm-editor{flex:1;min-width:0}.supamde-container.supamde-sided .supamde-editor-row .cm-editor{flex:0 0 50%;width:50%}.supamde-preview-side{border-left:var(--supamde-divider-preview-width,1px) solid var(--supamde-border-color,#ddd);box-sizing:border-box;width:50%;padding:.5rem 1rem;overflow-y:auto}", Rn = ".supamde-container.supamde-fullscreen{z-index:1000;background:var(--supamde-bg,#fff);flex-direction:column;max-width:none;display:flex;position:fixed;inset:0}.supamde-container.supamde-fullscreen .supamde-editor-row{flex:1;min-height:0}.supamde-container.supamde-fullscreen .supamde-editor-row .cm-editor{height:100%}", zn = "data-supamde-styles", Bn = [
|
|
1627
|
+
Fn,
|
|
1628
|
+
In,
|
|
1629
|
+
Ln,
|
|
1630
|
+
Rn
|
|
1570
1631
|
].join("\n");
|
|
1571
|
-
function
|
|
1632
|
+
function Vn(e = document) {
|
|
1572
1633
|
let t = e.head;
|
|
1573
|
-
if (!t || t.querySelector(`style[${
|
|
1634
|
+
if (!t || t.querySelector(`style[${zn}]`)) return;
|
|
1574
1635
|
let n = e.createElement("style");
|
|
1575
|
-
n.setAttribute(
|
|
1636
|
+
n.setAttribute(zn, ""), n.textContent = Bn, t.insertBefore(n, t.firstChild);
|
|
1576
1637
|
}
|
|
1577
1638
|
//#endregion
|
|
1578
1639
|
//#region node_modules/marked/lib/marked.esm.js
|
|
1579
|
-
function
|
|
1640
|
+
function Hn() {
|
|
1580
1641
|
return {
|
|
1581
1642
|
async: !1,
|
|
1582
1643
|
breaks: !1,
|
|
@@ -1590,35 +1651,35 @@ function Ln() {
|
|
|
1590
1651
|
walkTokens: null
|
|
1591
1652
|
};
|
|
1592
1653
|
}
|
|
1593
|
-
var
|
|
1594
|
-
function
|
|
1595
|
-
|
|
1654
|
+
var j = Hn();
|
|
1655
|
+
function Un(e) {
|
|
1656
|
+
j = e;
|
|
1596
1657
|
}
|
|
1597
|
-
var
|
|
1598
|
-
function
|
|
1658
|
+
var M = { exec: () => null };
|
|
1659
|
+
function N(e) {
|
|
1599
1660
|
let t = [];
|
|
1600
1661
|
return (n) => {
|
|
1601
1662
|
let r = Math.max(0, Math.min(3, n - 1)), i = t[r];
|
|
1602
1663
|
return i || (i = e(r), t[r] = i), i;
|
|
1603
1664
|
};
|
|
1604
1665
|
}
|
|
1605
|
-
function
|
|
1666
|
+
function P(e, t = "") {
|
|
1606
1667
|
let n = typeof e == "string" ? e : e.source, r = {
|
|
1607
1668
|
replace: (e, t) => {
|
|
1608
1669
|
let i = typeof t == "string" ? t : t.source;
|
|
1609
|
-
return i = i.replace(
|
|
1670
|
+
return i = i.replace(F.caret, "$1"), n = n.replace(e, i), r;
|
|
1610
1671
|
},
|
|
1611
1672
|
getRegex: () => new RegExp(n, t)
|
|
1612
1673
|
};
|
|
1613
1674
|
return r;
|
|
1614
1675
|
}
|
|
1615
|
-
var
|
|
1676
|
+
var Wn = ((e = "") => {
|
|
1616
1677
|
try {
|
|
1617
1678
|
return !!RegExp("(?<=1)(?<!1)" + e);
|
|
1618
1679
|
} catch {
|
|
1619
1680
|
return !1;
|
|
1620
1681
|
}
|
|
1621
|
-
})(),
|
|
1682
|
+
})(), F = {
|
|
1622
1683
|
codeRemoveIndent: /^(?: {0,3}\t| {1,4})/gm,
|
|
1623
1684
|
outputLinkReplace: /\\([\[\]])/g,
|
|
1624
1685
|
indentCodeCompensation: /^(\s+)(?:```)/,
|
|
@@ -1672,129 +1733,129 @@ var zn = ((e = "") => {
|
|
|
1672
1733
|
notSpaceStart: /^\S*/,
|
|
1673
1734
|
endingNewline: /\n$/,
|
|
1674
1735
|
listItemRegex: (e) => RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),
|
|
1675
|
-
nextBulletRegex:
|
|
1676
|
-
hrRegex:
|
|
1677
|
-
fencesBeginRegex:
|
|
1678
|
-
headingBeginRegex:
|
|
1679
|
-
htmlBeginRegex:
|
|
1680
|
-
blockquoteBeginRegex:
|
|
1681
|
-
},
|
|
1682
|
-
blockquote:
|
|
1683
|
-
code:
|
|
1684
|
-
def:
|
|
1685
|
-
fences:
|
|
1686
|
-
heading:
|
|
1687
|
-
hr:
|
|
1688
|
-
html:
|
|
1689
|
-
lheading:
|
|
1690
|
-
list:
|
|
1691
|
-
newline:
|
|
1692
|
-
paragraph:
|
|
1693
|
-
table:
|
|
1694
|
-
text:
|
|
1695
|
-
},
|
|
1696
|
-
...
|
|
1697
|
-
lheading:
|
|
1698
|
-
table:
|
|
1699
|
-
paragraph:
|
|
1700
|
-
},
|
|
1701
|
-
...
|
|
1702
|
-
html:
|
|
1736
|
+
nextBulletRegex: N((e) => RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),
|
|
1737
|
+
hrRegex: N((e) => RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),
|
|
1738
|
+
fencesBeginRegex: N((e) => RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),
|
|
1739
|
+
headingBeginRegex: N((e) => RegExp(`^ {0,${e}}#`)),
|
|
1740
|
+
htmlBeginRegex: N((e) => RegExp(`^ {0,${e}}(?:</?(?:${L})(?: +|$|/?>)|<(?:script|pre|style|textarea|!--))`, "i")),
|
|
1741
|
+
blockquoteBeginRegex: N((e) => RegExp(`^ {0,${e}}>`))
|
|
1742
|
+
}, Gn = /^(?:[ \t]*(?:\n|$))+/, Kn = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, qn = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, I = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Jn = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, Yn = / {0,3}(?:[*+-]|\d{1,9}[.)])/, Xn = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, Zn = P(Xn).replace(/bull/g, Yn).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex(), Qn = P(Xn).replace(/bull/g, Yn).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(), $n = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/, er = /^[^\n]+/, tr = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/, nr = P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", tr).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), rr = P(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, Yn).getRegex(), L = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul", ir = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, ar = P("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", ir).replace("tag", L).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), or = (e) => P($n).replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", e).replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", L).getRegex(), sr = or(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/), cr = or(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/), lr = {
|
|
1743
|
+
blockquote: P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", cr).getRegex(),
|
|
1744
|
+
code: Kn,
|
|
1745
|
+
def: nr,
|
|
1746
|
+
fences: qn,
|
|
1747
|
+
heading: Jn,
|
|
1748
|
+
hr: I,
|
|
1749
|
+
html: ar,
|
|
1750
|
+
lheading: Zn,
|
|
1751
|
+
list: rr,
|
|
1752
|
+
newline: Gn,
|
|
1753
|
+
paragraph: sr,
|
|
1754
|
+
table: M,
|
|
1755
|
+
text: er
|
|
1756
|
+
}, ur = P("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", L).getRegex(), dr = {
|
|
1757
|
+
...lr,
|
|
1758
|
+
lheading: Qn,
|
|
1759
|
+
table: ur,
|
|
1760
|
+
paragraph: P($n).replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", ur).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", L).getRegex()
|
|
1761
|
+
}, fr = {
|
|
1762
|
+
...lr,
|
|
1763
|
+
html: P("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment", ir).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
|
|
1703
1764
|
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
1704
1765
|
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
1705
|
-
fences:
|
|
1766
|
+
fences: M,
|
|
1706
1767
|
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
1707
|
-
paragraph:
|
|
1708
|
-
},
|
|
1709
|
-
_backpedal:
|
|
1710
|
-
anyPunctuation:
|
|
1711
|
-
autolink:
|
|
1712
|
-
blockSkip:
|
|
1713
|
-
br:
|
|
1714
|
-
code:
|
|
1715
|
-
del:
|
|
1716
|
-
delLDelim:
|
|
1717
|
-
delRDelim:
|
|
1718
|
-
emStrongLDelim:
|
|
1719
|
-
emStrongRDelimAst:
|
|
1720
|
-
emStrongRDelimUnd:
|
|
1721
|
-
escape:
|
|
1722
|
-
link:
|
|
1723
|
-
nolink:
|
|
1724
|
-
punctuation:
|
|
1725
|
-
reflink:
|
|
1726
|
-
reflinkSearch:
|
|
1727
|
-
tag:
|
|
1728
|
-
text:
|
|
1729
|
-
url:
|
|
1730
|
-
},
|
|
1731
|
-
...
|
|
1732
|
-
emStrongLDelim:
|
|
1733
|
-
emStrongRDelimAst:
|
|
1734
|
-
emStrongRDelimUnd:
|
|
1735
|
-
link:
|
|
1736
|
-
reflink:
|
|
1737
|
-
},
|
|
1738
|
-
...
|
|
1739
|
-
emStrongRDelimAst:
|
|
1740
|
-
emStrongLDelim:
|
|
1741
|
-
delLDelim:
|
|
1742
|
-
delRDelim:
|
|
1743
|
-
url:
|
|
1768
|
+
paragraph: P($n).replace("hr", I).replace("heading", " *#{1,6} *[^\n]").replace("lheading", Zn).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
|
|
1769
|
+
}, pr = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, mr = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, hr = /^( {2,}|\\)\n(?!\s*$)[ \t]*/, gr = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, R = /[\p{P}\p{S}]/u, z = /[\s\p{P}\p{S}]/u, B = /[^\s\p{P}\p{S}]/u, _r = P(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, z).getRegex(), vr = /[\p{Pi}\p{Ps}"']/u, yr = /(?!~)[\p{P}\p{S}]/u, br = /(?!~)[\s\p{P}\p{S}]/u, xr = /(?:[^\s\p{P}\p{S}]|~)/u, Sr = P(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Wn ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex(), Cr = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/, wr = P(Cr, "u").replace(/punct/g, R).getRegex(), Tr = P(Cr, "u").replace(/punct/g, yr).getRegex(), Er = P(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/, "u").replace(/openQuote/g, vr).replace(/punct/g, R).getRegex(), Dr = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", Or = P(Dr, "gu").replace(/notPunctSpace/g, B).replace(/punctSpace/g, z).replace(/punct/g, R).getRegex(), kr = P(Dr, "gu").replace(/notPunctSpace/g, xr).replace(/punctSpace/g, br).replace(/punct/g, yr).getRegex(), Ar = P("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)", "gu").replace(/notPunctSpace/g, B).replace(/punctSpace/g, z).replace(/punct/g, R).getRegex(), jr = P("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, B).replace(/punctSpace/g, z).replace(/punct/g, R).getRegex(), Mr = P("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)", "gu").replace(/notPunctSpace/g, B).replace(/punctSpace/g, z).replace(/punct/g, R).getRegex(), Nr = P(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, R).getRegex(), Pr = P("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)", "gu").replace(/notPunctSpace/g, B).replace(/punctSpace/g, z).replace(/punct/g, R).getRegex(), Fr = P(/\\(punct)/, "gu").replace(/punct/g, R).getRegex(), Ir = P(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(), Lr = P(ir).replace("(?:-->|$)", "-->").getRegex(), Rr = P("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", Lr).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), zr = /\[(?:\\[\s\S]|[^\[\]\\])*\]/, V = P(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets", zr).getRegex(), Br = P(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace("label", V).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), Vr = P(/^!?\[(label)\]\[(ref)\]/).replace("label", V).replace("ref", tr).getRegex(), Hr = P(/^!?\[(ref)\](?:\[\])?/).replace("ref", tr).getRegex(), Ur = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/, Wr = P(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets", zr).getRegex(), Gr = P("reflink|nolink(?!\\()", "g").replace("reflink", P(/^!?\[(label)\]\[(ref)\]/).replace("label", Wr).replace("ref", Ur).getRegex()).replace("nolink", P(/^!?\[(ref)\](?:\[\])?/).replace("ref", Ur).getRegex()).getRegex(), Kr = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/, qr = P(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g, /[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(), Jr = {
|
|
1770
|
+
_backpedal: M,
|
|
1771
|
+
anyPunctuation: Fr,
|
|
1772
|
+
autolink: Ir,
|
|
1773
|
+
blockSkip: Sr,
|
|
1774
|
+
br: hr,
|
|
1775
|
+
code: mr,
|
|
1776
|
+
del: M,
|
|
1777
|
+
delLDelim: M,
|
|
1778
|
+
delRDelim: M,
|
|
1779
|
+
emStrongLDelim: wr,
|
|
1780
|
+
emStrongRDelimAst: Or,
|
|
1781
|
+
emStrongRDelimUnd: jr,
|
|
1782
|
+
escape: pr,
|
|
1783
|
+
link: Br,
|
|
1784
|
+
nolink: Hr,
|
|
1785
|
+
punctuation: _r,
|
|
1786
|
+
reflink: Vr,
|
|
1787
|
+
reflinkSearch: Gr,
|
|
1788
|
+
tag: Rr,
|
|
1789
|
+
text: gr,
|
|
1790
|
+
url: M
|
|
1791
|
+
}, Yr = {
|
|
1792
|
+
...Jr,
|
|
1793
|
+
emStrongLDelim: Er,
|
|
1794
|
+
emStrongRDelimAst: Ar,
|
|
1795
|
+
emStrongRDelimUnd: Mr,
|
|
1796
|
+
link: P(/^!?\[(label)\]\((.*?)\)/).replace("label", V).getRegex(),
|
|
1797
|
+
reflink: P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", V).getRegex()
|
|
1798
|
+
}, Xr = {
|
|
1799
|
+
...Jr,
|
|
1800
|
+
emStrongRDelimAst: kr,
|
|
1801
|
+
emStrongLDelim: Tr,
|
|
1802
|
+
delLDelim: Nr,
|
|
1803
|
+
delRDelim: Pr,
|
|
1804
|
+
url: P(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("emailProtocol", qr).replace("protocol", Kr).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),
|
|
1744
1805
|
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
|
1745
1806
|
del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,
|
|
1746
|
-
text:
|
|
1747
|
-
},
|
|
1748
|
-
...
|
|
1749
|
-
br:
|
|
1750
|
-
text:
|
|
1807
|
+
text: P(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace("protocol", Kr).replace(/emailProtocol/g, /(?:mailto|xmpp):/).getRegex()
|
|
1808
|
+
}, Zr = {
|
|
1809
|
+
...Xr,
|
|
1810
|
+
br: P(hr).replace("{2,}", "*").getRegex(),
|
|
1811
|
+
text: P(Xr.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
|
|
1751
1812
|
}, H = {
|
|
1752
|
-
normal:
|
|
1753
|
-
gfm:
|
|
1754
|
-
pedantic:
|
|
1813
|
+
normal: lr,
|
|
1814
|
+
gfm: dr,
|
|
1815
|
+
pedantic: fr
|
|
1755
1816
|
}, U = {
|
|
1756
|
-
normal:
|
|
1757
|
-
gfm:
|
|
1758
|
-
breaks:
|
|
1759
|
-
pedantic:
|
|
1760
|
-
},
|
|
1817
|
+
normal: Jr,
|
|
1818
|
+
gfm: Xr,
|
|
1819
|
+
breaks: Zr,
|
|
1820
|
+
pedantic: Yr
|
|
1821
|
+
}, Qr = {
|
|
1761
1822
|
"&": "&",
|
|
1762
1823
|
"<": "<",
|
|
1763
1824
|
">": ">",
|
|
1764
1825
|
"\"": """,
|
|
1765
1826
|
"'": "'"
|
|
1766
|
-
},
|
|
1827
|
+
}, $r = (e) => Qr[e];
|
|
1767
1828
|
function W(e, t) {
|
|
1768
1829
|
if (t) {
|
|
1769
|
-
if (
|
|
1770
|
-
} else if (
|
|
1830
|
+
if (F.escapeTest.test(e)) return e.replace(F.escapeReplace, $r);
|
|
1831
|
+
} else if (F.escapeTestNoEncode.test(e)) return e.replace(F.escapeReplaceNoEncode, $r);
|
|
1771
1832
|
return e;
|
|
1772
1833
|
}
|
|
1773
|
-
function
|
|
1774
|
-
return e.replace(
|
|
1834
|
+
function ei(e) {
|
|
1835
|
+
return e.replace(F.numericCharacterReference, (e, t, n) => {
|
|
1775
1836
|
let r = t === void 0 ? Number.parseInt(n, 16) : Number.parseInt(t, 10);
|
|
1776
1837
|
return r === 0 || r > 1114111 || r >= 55296 && r <= 57343 ? "�" : String.fromCodePoint(r);
|
|
1777
1838
|
});
|
|
1778
1839
|
}
|
|
1779
|
-
function
|
|
1840
|
+
function ti(e) {
|
|
1780
1841
|
try {
|
|
1781
|
-
e = encodeURI(e).replace(
|
|
1842
|
+
e = encodeURI(e).replace(F.percentDecode, "%");
|
|
1782
1843
|
} catch {
|
|
1783
1844
|
return null;
|
|
1784
1845
|
}
|
|
1785
1846
|
return e;
|
|
1786
1847
|
}
|
|
1787
|
-
function
|
|
1788
|
-
let n = e.replace(
|
|
1848
|
+
function ni(e, t) {
|
|
1849
|
+
let n = e.replace(F.findPipe, (e, t, n) => {
|
|
1789
1850
|
let r = !1, i = t;
|
|
1790
1851
|
for (; --i >= 0 && n[i] === "\\";) r = !r;
|
|
1791
1852
|
return r ? "|" : " |";
|
|
1792
|
-
}).split(
|
|
1853
|
+
}).split(F.splitPipe), r = 0;
|
|
1793
1854
|
if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), t) {
|
|
1794
1855
|
if (n.length > t) n.splice(t);
|
|
1795
1856
|
else for (; n.length < t;) n.push("");
|
|
1796
1857
|
}
|
|
1797
|
-
for (; r < n.length; r++) n[r] = n[r].trim().replace(
|
|
1858
|
+
for (; r < n.length; r++) n[r] = n[r].trim().replace(F.slashPipe, "|");
|
|
1798
1859
|
return n;
|
|
1799
1860
|
}
|
|
1800
1861
|
function G(e, t, n) {
|
|
@@ -1809,15 +1870,15 @@ function G(e, t, n) {
|
|
|
1809
1870
|
}
|
|
1810
1871
|
return e.slice(0, r - i);
|
|
1811
1872
|
}
|
|
1812
|
-
function
|
|
1873
|
+
function ri(e) {
|
|
1813
1874
|
let t = e.split("\n"), n = t.length - 1;
|
|
1814
|
-
for (; n >= 0 &&
|
|
1875
|
+
for (; n >= 0 && F.blankLine.test(t[n]);) n--;
|
|
1815
1876
|
return t.length - n <= 2 ? e : t.slice(0, n + 1).join("\n");
|
|
1816
1877
|
}
|
|
1817
1878
|
function K(e) {
|
|
1818
1879
|
return e.trim().toLowerCase().toUpperCase().toLowerCase();
|
|
1819
1880
|
}
|
|
1820
|
-
function
|
|
1881
|
+
function ii(e, t) {
|
|
1821
1882
|
if (e.indexOf(t[0]) === -1 && e.indexOf(t[1]) === -1) return -1;
|
|
1822
1883
|
let n = 0;
|
|
1823
1884
|
for (let r = 0; r < e.length; r++) if (e[r] === "\\") r++;
|
|
@@ -1825,7 +1886,7 @@ function Qr(e, t) {
|
|
|
1825
1886
|
else if (e[r] === t[1] && (n--, n < 0)) return r;
|
|
1826
1887
|
return n > 0 ? -2 : -1;
|
|
1827
1888
|
}
|
|
1828
|
-
function
|
|
1889
|
+
function ai(e, t = 0) {
|
|
1829
1890
|
let n = t, r = "";
|
|
1830
1891
|
for (let t of e) if (t === " ") {
|
|
1831
1892
|
let e = 4 - n % 4;
|
|
@@ -1833,7 +1894,7 @@ function $r(e, t = 0) {
|
|
|
1833
1894
|
} else r += t, n++;
|
|
1834
1895
|
return r;
|
|
1835
1896
|
}
|
|
1836
|
-
function
|
|
1897
|
+
function oi(e, t, n, r, i) {
|
|
1837
1898
|
let a = t.href, o = t.title || null, s = e[1].replace(i.other.outputLinkReplace, "$1"), c = e[0].charAt(0) === "!";
|
|
1838
1899
|
r.state.inLink = !0;
|
|
1839
1900
|
let l = r.state.linkEmitted, u = r.state.inRawBlock;
|
|
@@ -1855,7 +1916,7 @@ function ei(e, t, n, r, i) {
|
|
|
1855
1916
|
tokens: d
|
|
1856
1917
|
};
|
|
1857
1918
|
}
|
|
1858
|
-
function
|
|
1919
|
+
function si(e, t, n) {
|
|
1859
1920
|
let r = e.match(n.other.indentCodeCompensation);
|
|
1860
1921
|
if (r === null) return t;
|
|
1861
1922
|
let i = r[1];
|
|
@@ -1866,7 +1927,7 @@ function ti(e, t, n) {
|
|
|
1866
1927
|
return e.slice(Math.min(r.length, i.length));
|
|
1867
1928
|
}).join("\n");
|
|
1868
1929
|
}
|
|
1869
|
-
function
|
|
1930
|
+
function ci(e, t, n, r) {
|
|
1870
1931
|
if (!t.includes("<")) return !1;
|
|
1871
1932
|
for (let i = 0; i < t.length; i++) {
|
|
1872
1933
|
if (t[i] === "\\") {
|
|
@@ -1894,7 +1955,7 @@ var q = class {
|
|
|
1894
1955
|
rules;
|
|
1895
1956
|
lexer;
|
|
1896
1957
|
constructor(e) {
|
|
1897
|
-
this.options = e ||
|
|
1958
|
+
this.options = e || j;
|
|
1898
1959
|
}
|
|
1899
1960
|
space(e) {
|
|
1900
1961
|
let t = this.rules.block.newline.exec(e);
|
|
@@ -1906,7 +1967,7 @@ var q = class {
|
|
|
1906
1967
|
code(e) {
|
|
1907
1968
|
let t = this.rules.block.code.exec(e);
|
|
1908
1969
|
if (t) {
|
|
1909
|
-
let e = this.options.pedantic ? t[0] :
|
|
1970
|
+
let e = this.options.pedantic ? t[0] : ri(t[0]);
|
|
1910
1971
|
return {
|
|
1911
1972
|
type: "code",
|
|
1912
1973
|
raw: e,
|
|
@@ -1918,7 +1979,7 @@ var q = class {
|
|
|
1918
1979
|
fences(e) {
|
|
1919
1980
|
let t = this.rules.block.fences.exec(e);
|
|
1920
1981
|
if (t) {
|
|
1921
|
-
let e = t[0], n =
|
|
1982
|
+
let e = t[0], n = si(e, t[3] || "", this.rules);
|
|
1922
1983
|
return {
|
|
1923
1984
|
type: "code",
|
|
1924
1985
|
raw: e,
|
|
@@ -2007,7 +2068,7 @@ ${d.join("\n")}`), r = r.substring(0, r.length - t.text.length) + s.text;
|
|
|
2007
2068
|
let n = !1, r = "", s = "";
|
|
2008
2069
|
if (!(t = a.exec(e)) || this.rules.block.hr.test(e)) break;
|
|
2009
2070
|
r = t[0], e = e.substring(r.length);
|
|
2010
|
-
let c = t[2].split("\n", 1)[0], l = t[1].length, u = this.options.pedantic ?
|
|
2071
|
+
let c = t[2].split("\n", 1)[0], l = t[1].length, u = this.options.pedantic ? ai(c, l) : c.replace(this.rules.other.leadingSpaceTab, (e) => ai(e, l)), d = e.split("\n", 1)[0], f = !u.trim(), p = 0;
|
|
2011
2072
|
if (this.options.pedantic ? (p = 2, s = u.trimStart()) : f ? p = l + 1 : (p = u.search(this.rules.other.nonSpaceChar), p = p > 4 ? 1 : p, s = u.slice(p), p += l), f && this.rules.other.blankLine.test(d) && (r += d + "\n", e = e.substring(d.length + 1), n = !0), !n) {
|
|
2012
2073
|
let t = this.rules.other.nextBulletRegex(p), n = this.rules.other.hrRegex(p), i = this.rules.other.fencesBeginRegex(p), a = this.rules.other.headingBeginRegex(p), o = this.rules.other.htmlBeginRegex(p), c = this.rules.other.blockquoteBeginRegex(p);
|
|
2013
2074
|
for (; e;) {
|
|
@@ -2072,7 +2133,7 @@ ${d.join("\n")}`), r = r.substring(0, r.length - t.text.length) + s.text;
|
|
|
2072
2133
|
html(e) {
|
|
2073
2134
|
let t = this.rules.block.html.exec(e);
|
|
2074
2135
|
if (t) {
|
|
2075
|
-
let e =
|
|
2136
|
+
let e = ri(t[0]);
|
|
2076
2137
|
return {
|
|
2077
2138
|
type: "html",
|
|
2078
2139
|
block: !0,
|
|
@@ -2085,7 +2146,7 @@ ${d.join("\n")}`), r = r.substring(0, r.length - t.text.length) + s.text;
|
|
|
2085
2146
|
def(e) {
|
|
2086
2147
|
let t = this.rules.block.def.exec(e);
|
|
2087
2148
|
if (t) {
|
|
2088
|
-
if (!this.rules.other.startAngleBracket.test(t[2]) &&
|
|
2149
|
+
if (!this.rules.other.startAngleBracket.test(t[2]) && ii(t[2], "()") !== -1) return;
|
|
2089
2150
|
let e = K(t[1]).replace(this.rules.other.multipleSpaceGlobal, " "), n = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
|
|
2090
2151
|
return {
|
|
2091
2152
|
type: "def",
|
|
@@ -2099,7 +2160,7 @@ ${d.join("\n")}`), r = r.substring(0, r.length - t.text.length) + s.text;
|
|
|
2099
2160
|
table(e) {
|
|
2100
2161
|
let t = this.rules.block.table.exec(e);
|
|
2101
2162
|
if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
|
|
2102
|
-
let n =
|
|
2163
|
+
let n = ni(t[1]), r = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), i = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split("\n") : [], a = {
|
|
2103
2164
|
type: "table",
|
|
2104
2165
|
raw: G(t[0], "\n"),
|
|
2105
2166
|
header: [],
|
|
@@ -2114,7 +2175,7 @@ ${d.join("\n")}`), r = r.substring(0, r.length - t.text.length) + s.text;
|
|
|
2114
2175
|
header: !0,
|
|
2115
2176
|
align: a.align[e]
|
|
2116
2177
|
});
|
|
2117
|
-
for (let e of i) a.rows.push(
|
|
2178
|
+
for (let e of i) a.rows.push(ni(e, a.header.length).map((e, t) => ({
|
|
2118
2179
|
text: e,
|
|
2119
2180
|
tokens: this.lexer.inline(e),
|
|
2120
2181
|
header: !1,
|
|
@@ -2181,14 +2242,14 @@ ${d.join("\n")}`), r = r.substring(0, r.length - t.text.length) + s.text;
|
|
|
2181
2242
|
let t = this.rules.inline.link.exec(e);
|
|
2182
2243
|
if (t) {
|
|
2183
2244
|
let n = t[0].charAt(0) === "!" ? 2 : 1;
|
|
2184
|
-
if (!this.options.pedantic &&
|
|
2245
|
+
if (!this.options.pedantic && ci(e, t[1], n, this.rules)) return;
|
|
2185
2246
|
let r = t[2].trim();
|
|
2186
2247
|
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(r)) {
|
|
2187
2248
|
if (!this.rules.other.endAngleBracket.test(r)) return;
|
|
2188
2249
|
let e = G(r.slice(0, -1), "\\");
|
|
2189
2250
|
if ((r.length - e.length) % 2 == 0) return;
|
|
2190
2251
|
} else {
|
|
2191
|
-
let e =
|
|
2252
|
+
let e = ii(t[2], "()");
|
|
2192
2253
|
if (e === -2) return;
|
|
2193
2254
|
if (e > -1) {
|
|
2194
2255
|
let n = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + e;
|
|
@@ -2200,7 +2261,7 @@ ${d.join("\n")}`), r = r.substring(0, r.length - t.text.length) + s.text;
|
|
|
2200
2261
|
let e = this.rules.other.pedanticHrefTitle.exec(i);
|
|
2201
2262
|
e && (i = e[1], a = e[3]);
|
|
2202
2263
|
} else a = t[3] ? t[3].slice(1, -1) : "";
|
|
2203
|
-
return i = i.trim(), this.rules.other.startAngleBracket.test(i) && (i = this.options.pedantic && !this.rules.other.endAngleBracket.test(r) ? i.slice(1) : i.slice(1, -1)),
|
|
2264
|
+
return i = i.trim(), this.rules.other.startAngleBracket.test(i) && (i = this.options.pedantic && !this.rules.other.endAngleBracket.test(r) ? i.slice(1) : i.slice(1, -1)), oi(t, {
|
|
2204
2265
|
href: i && i.replace(this.rules.inline.anyPunctuation, "$1"),
|
|
2205
2266
|
title: a && a.replace(this.rules.inline.anyPunctuation, "$1")
|
|
2206
2267
|
}, t[0], this.lexer, this.rules);
|
|
@@ -2210,7 +2271,7 @@ ${d.join("\n")}`), r = r.substring(0, r.length - t.text.length) + s.text;
|
|
|
2210
2271
|
let n;
|
|
2211
2272
|
if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
|
|
2212
2273
|
let r = n[0].charAt(0) === "!" ? 2 : 1;
|
|
2213
|
-
if (!this.options.pedantic &&
|
|
2274
|
+
if (!this.options.pedantic && ci(e, n[1], r, this.rules)) return;
|
|
2214
2275
|
let i = t[K((n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "))];
|
|
2215
2276
|
if (!i) {
|
|
2216
2277
|
let e = n[0].charAt(0);
|
|
@@ -2220,7 +2281,7 @@ ${d.join("\n")}`), r = r.substring(0, r.length - t.text.length) + s.text;
|
|
|
2220
2281
|
text: e
|
|
2221
2282
|
};
|
|
2222
2283
|
}
|
|
2223
|
-
return
|
|
2284
|
+
return oi(n, i, n[0], this.lexer, this.rules);
|
|
2224
2285
|
}
|
|
2225
2286
|
}
|
|
2226
2287
|
emStrong(e, t, n = "") {
|
|
@@ -2353,7 +2414,7 @@ ${d.join("\n")}`), r = r.substring(0, r.length - t.text.length) + s.text;
|
|
|
2353
2414
|
return {
|
|
2354
2415
|
type: "text",
|
|
2355
2416
|
raw: t[0],
|
|
2356
|
-
text: e ? t[0] :
|
|
2417
|
+
text: e ? t[0] : ei(t[0]),
|
|
2357
2418
|
escaped: e
|
|
2358
2419
|
};
|
|
2359
2420
|
}
|
|
@@ -2365,7 +2426,7 @@ ${d.join("\n")}`), r = r.substring(0, r.length - t.text.length) + s.text;
|
|
|
2365
2426
|
inlineQueue;
|
|
2366
2427
|
tokenizer;
|
|
2367
2428
|
constructor(e) {
|
|
2368
|
-
this.tokens = [], this.tokens.links = Object.create(null), this.options = e ||
|
|
2429
|
+
this.tokens = [], this.tokens.links = Object.create(null), this.options = e || j, this.options.tokenizer = this.options.tokenizer || new q(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
|
|
2369
2430
|
inLink: !1,
|
|
2370
2431
|
inRawBlock: !1,
|
|
2371
2432
|
linkEmitted: !1,
|
|
@@ -2373,7 +2434,7 @@ ${d.join("\n")}`), r = r.substring(0, r.length - t.text.length) + s.text;
|
|
|
2373
2434
|
top: !0
|
|
2374
2435
|
};
|
|
2375
2436
|
let t = {
|
|
2376
|
-
other:
|
|
2437
|
+
other: F,
|
|
2377
2438
|
block: H.normal,
|
|
2378
2439
|
inline: U.normal
|
|
2379
2440
|
};
|
|
@@ -2392,7 +2453,7 @@ ${d.join("\n")}`), r = r.substring(0, r.length - t.text.length) + s.text;
|
|
|
2392
2453
|
return new e(n).inlineTokens(t);
|
|
2393
2454
|
}
|
|
2394
2455
|
lex(e) {
|
|
2395
|
-
e = e.replace(
|
|
2456
|
+
e = e.replace(F.carriageReturn, "\n"), this.blockTokens(e, this.tokens);
|
|
2396
2457
|
for (let e = 0; e < this.inlineQueue.length; e++) {
|
|
2397
2458
|
let t = this.inlineQueue[e];
|
|
2398
2459
|
this.inlineTokens(t.src, t.tokens);
|
|
@@ -2400,7 +2461,7 @@ ${d.join("\n")}`), r = r.substring(0, r.length - t.text.length) + s.text;
|
|
|
2400
2461
|
return this.inlineQueue = [], this.tokens;
|
|
2401
2462
|
}
|
|
2402
2463
|
blockTokens(e, t = [], n = !1) {
|
|
2403
|
-
this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(
|
|
2464
|
+
this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(F.tabCharGlobal, " ").replace(F.spaceLine, ""));
|
|
2404
2465
|
let r = 1 / 0;
|
|
2405
2466
|
for (; e;) {
|
|
2406
2467
|
if (e.length < r) r = e.length;
|
|
@@ -2555,13 +2616,13 @@ ${d.join("\n")}`), r = r.substring(0, r.length - t.text.length) + s.text;
|
|
|
2555
2616
|
options;
|
|
2556
2617
|
parser;
|
|
2557
2618
|
constructor(e) {
|
|
2558
|
-
this.options = e ||
|
|
2619
|
+
this.options = e || j;
|
|
2559
2620
|
}
|
|
2560
2621
|
space(e) {
|
|
2561
2622
|
return "";
|
|
2562
2623
|
}
|
|
2563
2624
|
code({ text: e, lang: t, escaped: n }) {
|
|
2564
|
-
let r = (t || "").match(
|
|
2625
|
+
let r = (t || "").match(F.notSpaceStart)?.[0], i = e ? e.replace(F.endingNewline, "") + "\n" : "";
|
|
2565
2626
|
return r ? "<pre><code class=\"language-" + W(r) + "\">" + (n ? i : W(i, !0)) + "</code></pre>\n" : "<pre><code>" + (n ? i : W(i, !0)) + "</code></pre>\n";
|
|
2566
2627
|
}
|
|
2567
2628
|
blockquote({ tokens: e }) {
|
|
@@ -2641,7 +2702,7 @@ ${e}</tr>
|
|
|
2641
2702
|
return `<del>${this.parser.parseInline(e)}</del>`;
|
|
2642
2703
|
}
|
|
2643
2704
|
link({ href: e, title: t, text: n, tokens: r, autolink: i }) {
|
|
2644
|
-
let a = i ? W(n, !0) : this.parser.parseInline(r), o =
|
|
2705
|
+
let a = i ? W(n, !0) : this.parser.parseInline(r), o = ti(e);
|
|
2645
2706
|
if (o === null) return a;
|
|
2646
2707
|
e = W(o, i);
|
|
2647
2708
|
let s = "<a href=\"" + e + "\"";
|
|
@@ -2649,7 +2710,7 @@ ${e}</tr>
|
|
|
2649
2710
|
}
|
|
2650
2711
|
image({ href: e, title: t, text: n, tokens: r }) {
|
|
2651
2712
|
r && (n = this.parser.parseInline(r, this.parser.textRenderer));
|
|
2652
|
-
let i =
|
|
2713
|
+
let i = ti(e);
|
|
2653
2714
|
if (i === null) return W(n);
|
|
2654
2715
|
e = i;
|
|
2655
2716
|
let a = `<img src="${W(e)}" alt="${W(n)}"`;
|
|
@@ -2658,7 +2719,7 @@ ${e}</tr>
|
|
|
2658
2719
|
text(e) {
|
|
2659
2720
|
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : W(e.text);
|
|
2660
2721
|
}
|
|
2661
|
-
},
|
|
2722
|
+
}, li = class {
|
|
2662
2723
|
strong({ text: e }) {
|
|
2663
2724
|
return e;
|
|
2664
2725
|
}
|
|
@@ -2694,7 +2755,7 @@ ${e}</tr>
|
|
|
2694
2755
|
renderer;
|
|
2695
2756
|
textRenderer;
|
|
2696
2757
|
constructor(e) {
|
|
2697
|
-
this.options = e ||
|
|
2758
|
+
this.options = e || j, this.options.renderer = this.options.renderer || new Y(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new li();
|
|
2698
2759
|
}
|
|
2699
2760
|
static parse(t, n) {
|
|
2700
2761
|
return new e(n).parse(t);
|
|
@@ -2846,7 +2907,7 @@ ${e}</tr>
|
|
|
2846
2907
|
options;
|
|
2847
2908
|
block;
|
|
2848
2909
|
constructor(e) {
|
|
2849
|
-
this.options = e ||
|
|
2910
|
+
this.options = e || j;
|
|
2850
2911
|
}
|
|
2851
2912
|
static passThroughHooks = /* @__PURE__ */ new Set([
|
|
2852
2913
|
"preprocess",
|
|
@@ -2877,14 +2938,14 @@ ${e}</tr>
|
|
|
2877
2938
|
provideParser(e = this.block) {
|
|
2878
2939
|
return e ? X.parse : X.parseInline;
|
|
2879
2940
|
}
|
|
2880
|
-
},
|
|
2881
|
-
defaults =
|
|
2941
|
+
}, ui = class {
|
|
2942
|
+
defaults = Hn();
|
|
2882
2943
|
options = this.setOptions;
|
|
2883
2944
|
parse = this.parseMarkdown(!0);
|
|
2884
2945
|
parseInline = this.parseMarkdown(!1);
|
|
2885
2946
|
Parser = X;
|
|
2886
2947
|
Renderer = Y;
|
|
2887
|
-
TextRenderer =
|
|
2948
|
+
TextRenderer = li;
|
|
2888
2949
|
Lexer = J;
|
|
2889
2950
|
Tokenizer = q;
|
|
2890
2951
|
Hooks = Z;
|
|
@@ -3052,35 +3113,35 @@ ${e}</tr>
|
|
|
3052
3113
|
throw n;
|
|
3053
3114
|
};
|
|
3054
3115
|
}
|
|
3055
|
-
}, Q = new
|
|
3116
|
+
}, Q = new ui();
|
|
3056
3117
|
function $(e, t) {
|
|
3057
3118
|
return Q.parse(e, t);
|
|
3058
3119
|
}
|
|
3059
3120
|
$.options = $.setOptions = function(e) {
|
|
3060
|
-
return Q.setOptions(e), $.defaults = Q.defaults,
|
|
3061
|
-
}, $.getDefaults =
|
|
3062
|
-
function
|
|
3063
|
-
return Q.use(...e), $.defaults = Q.defaults,
|
|
3121
|
+
return Q.setOptions(e), $.defaults = Q.defaults, Un($.defaults), $;
|
|
3122
|
+
}, $.getDefaults = Hn, $.defaults = j;
|
|
3123
|
+
function di(...e) {
|
|
3124
|
+
return Q.use(...e), $.defaults = Q.defaults, Un($.defaults), $;
|
|
3064
3125
|
}
|
|
3065
|
-
$.use =
|
|
3126
|
+
$.use = di, $.walkTokens = function(e, t) {
|
|
3066
3127
|
return Q.walkTokens(e, t);
|
|
3067
|
-
}, $.parseInline = Q.parseInline, $.Parser = X, $.parser = X.parse, $.Renderer = Y, $.TextRenderer =
|
|
3128
|
+
}, $.parseInline = Q.parseInline, $.Parser = X, $.parser = X.parse, $.Renderer = Y, $.TextRenderer = li, $.Lexer = J, $.lexer = J.lex, $.Tokenizer = q, $.Hooks = Z, $.parse = $, $.options, $.setOptions, $.walkTokens, $.parseInline, X.parse, J.lex;
|
|
3068
3129
|
//#endregion
|
|
3069
3130
|
//#region src/utils/html.ts
|
|
3070
|
-
function
|
|
3131
|
+
function fi(e) {
|
|
3071
3132
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
3072
3133
|
}
|
|
3073
|
-
function
|
|
3134
|
+
function pi() {
|
|
3074
3135
|
return globalThis.katex ?? null;
|
|
3075
3136
|
}
|
|
3076
|
-
function
|
|
3077
|
-
let r =
|
|
3137
|
+
function mi(e, t, n) {
|
|
3138
|
+
let r = pi();
|
|
3078
3139
|
return r ? r.renderToString(e, {
|
|
3079
3140
|
displayMode: t,
|
|
3080
3141
|
throwOnError: !1
|
|
3081
|
-
}) :
|
|
3142
|
+
}) : fi(n);
|
|
3082
3143
|
}
|
|
3083
|
-
var
|
|
3144
|
+
var hi = { extensions: [{
|
|
3084
3145
|
name: "blockMath",
|
|
3085
3146
|
level: "block",
|
|
3086
3147
|
start(e) {
|
|
@@ -3096,7 +3157,7 @@ var li = { extensions: [{
|
|
|
3096
3157
|
},
|
|
3097
3158
|
renderer(e) {
|
|
3098
3159
|
let t = e;
|
|
3099
|
-
return
|
|
3160
|
+
return mi(t.text, !0, t.raw);
|
|
3100
3161
|
}
|
|
3101
3162
|
}, {
|
|
3102
3163
|
name: "inlineMath",
|
|
@@ -3114,34 +3175,34 @@ var li = { extensions: [{
|
|
|
3114
3175
|
},
|
|
3115
3176
|
renderer(e) {
|
|
3116
3177
|
let t = e;
|
|
3117
|
-
return
|
|
3178
|
+
return mi(t.text, !1, t.raw);
|
|
3118
3179
|
}
|
|
3119
3180
|
}] };
|
|
3120
3181
|
//#endregion
|
|
3121
3182
|
//#region src/markdown/sanitize.ts
|
|
3122
|
-
function
|
|
3183
|
+
function gi(e) {
|
|
3123
3184
|
return e.replace(/<a\b(?![^>]*\btarget=)([^>]*)>/gi, "<a target=\"_blank\" rel=\"noopener noreferrer\"$1>");
|
|
3124
3185
|
}
|
|
3125
3186
|
//#endregion
|
|
3126
3187
|
//#region src/markdown/parse.ts
|
|
3127
|
-
function
|
|
3188
|
+
function _i(e) {
|
|
3128
3189
|
return {
|
|
3129
3190
|
singleLineBreaks: e.renderingConfig?.singleLineBreaks,
|
|
3130
3191
|
previewRender: e.previewRender
|
|
3131
3192
|
};
|
|
3132
3193
|
}
|
|
3133
|
-
function
|
|
3194
|
+
function vi(e, t = {}) {
|
|
3134
3195
|
if (t.previewRender) return t.previewRender(e);
|
|
3135
|
-
let n = new
|
|
3196
|
+
let n = new ui({
|
|
3136
3197
|
gfm: !0,
|
|
3137
3198
|
breaks: t.singleLineBreaks ?? !0
|
|
3138
3199
|
});
|
|
3139
|
-
return n.use(
|
|
3200
|
+
return n.use(hi), gi(n.parse(e, { async: !1 }));
|
|
3140
3201
|
}
|
|
3141
3202
|
//#endregion
|
|
3142
3203
|
//#region src/features/storage.ts
|
|
3143
|
-
var
|
|
3144
|
-
function
|
|
3204
|
+
var yi = "supamde:";
|
|
3205
|
+
function bi(e = yi) {
|
|
3145
3206
|
let t = (t) => `${e}${t}`;
|
|
3146
3207
|
return {
|
|
3147
3208
|
load: (e) => localStorage.getItem(t(e)),
|
|
@@ -3153,7 +3214,7 @@ function mi(e = pi) {
|
|
|
3153
3214
|
}
|
|
3154
3215
|
};
|
|
3155
3216
|
}
|
|
3156
|
-
async function
|
|
3217
|
+
async function xi(e) {
|
|
3157
3218
|
let t = "__supamde_probe__";
|
|
3158
3219
|
try {
|
|
3159
3220
|
await e.save(t, "1");
|
|
@@ -3163,8 +3224,8 @@ async function hi(e) {
|
|
|
3163
3224
|
return !1;
|
|
3164
3225
|
}
|
|
3165
3226
|
}
|
|
3166
|
-
function
|
|
3167
|
-
let n = e.enabled ?? !1, r = e.delay ?? 1e3, i = e.storage ??
|
|
3227
|
+
function Si(e, t) {
|
|
3228
|
+
let n = e.enabled ?? !1, r = e.delay ?? 1e3, i = e.storage ?? bi(), a = e.key, o = t.getValue(), s = !1, c = null, l = !1, u = (e) => {
|
|
3168
3229
|
l || (l = !0, console.warn(`SupaMDE: ${e}`));
|
|
3169
3230
|
}, d = () => {
|
|
3170
3231
|
c !== null && (clearTimeout(c), c = null);
|
|
@@ -3184,7 +3245,7 @@ function gi(e, t) {
|
|
|
3184
3245
|
u("autosave.key is required — autosave stays off.");
|
|
3185
3246
|
return;
|
|
3186
3247
|
}
|
|
3187
|
-
if (!await
|
|
3248
|
+
if (!await xi(i)) {
|
|
3188
3249
|
u("autosave storage is not available — autosave is disabled.");
|
|
3189
3250
|
return;
|
|
3190
3251
|
}
|
|
@@ -3218,7 +3279,7 @@ function gi(e, t) {
|
|
|
3218
3279
|
}
|
|
3219
3280
|
//#endregion
|
|
3220
3281
|
//#region src/features/upload-placeholder.ts
|
|
3221
|
-
var
|
|
3282
|
+
var Ci = l.define(), wi = l.define(), Ti = u.define({
|
|
3222
3283
|
create() {
|
|
3223
3284
|
return /* @__PURE__ */ new Map();
|
|
3224
3285
|
},
|
|
@@ -3235,61 +3296,61 @@ var _i = l.define(), vi = l.define(), yi = u.define({
|
|
|
3235
3296
|
}
|
|
3236
3297
|
n = e;
|
|
3237
3298
|
}
|
|
3238
|
-
for (let e of t.effects) if (e.is(
|
|
3299
|
+
for (let e of t.effects) if (e.is(Ci)) {
|
|
3239
3300
|
let t = new Map(n);
|
|
3240
3301
|
t.set(e.value.id, {
|
|
3241
3302
|
from: e.value.from,
|
|
3242
3303
|
to: e.value.to
|
|
3243
3304
|
}), n = t;
|
|
3244
|
-
} else if (e.is(
|
|
3305
|
+
} else if (e.is(wi) && n.has(e.value)) {
|
|
3245
3306
|
let t = new Map(n);
|
|
3246
3307
|
t.delete(e.value), n = t;
|
|
3247
3308
|
}
|
|
3248
3309
|
return n;
|
|
3249
3310
|
}
|
|
3250
3311
|
});
|
|
3251
|
-
function
|
|
3252
|
-
return e.field(
|
|
3312
|
+
function Ei(e, t) {
|
|
3313
|
+
return e.field(Ti, !1)?.get(t) ?? null;
|
|
3253
3314
|
}
|
|
3254
|
-
function
|
|
3315
|
+
function Di() {
|
|
3255
3316
|
let e = 0;
|
|
3256
3317
|
return () => (e += 1, e);
|
|
3257
3318
|
}
|
|
3258
|
-
var
|
|
3319
|
+
var Oi = [
|
|
3259
3320
|
"image/png",
|
|
3260
3321
|
"image/jpeg",
|
|
3261
3322
|
"image/gif",
|
|
3262
3323
|
"image/webp",
|
|
3263
3324
|
"image/avif",
|
|
3264
3325
|
"image/svg+xml"
|
|
3265
|
-
],
|
|
3326
|
+
], ki = 2e3, Ai = 6e3, ji = {
|
|
3266
3327
|
"too-large": "upload.errorTooLarge",
|
|
3267
3328
|
"type-not-allowed": "upload.errorType",
|
|
3268
3329
|
"upload-failed": "upload.errorFailed"
|
|
3269
3330
|
};
|
|
3270
|
-
function
|
|
3331
|
+
function Mi(e, t) {
|
|
3271
3332
|
return `![${e.replace(/([[\]\\])/g, "\\$1")}](${/[\s()<>]/.test(t) ? `<${t.replace(/([<>\\])/g, "\\$1")}>` : t})`;
|
|
3272
3333
|
}
|
|
3273
|
-
function
|
|
3334
|
+
function Ni(e, t) {
|
|
3274
3335
|
return e.size > t.maxSize ? "too-large" : t.accept.includes(e.type) ? null : "type-not-allowed";
|
|
3275
3336
|
}
|
|
3276
|
-
function
|
|
3277
|
-
let i = t.enabled ?? !1, a = t.maxSize ?? 2097152, o = t.accept ??
|
|
3337
|
+
function Pi(e, t, n, r = D()) {
|
|
3338
|
+
let i = t.enabled ?? !1, a = t.maxSize ?? 2097152, o = t.accept ?? Oi, s = Di(), c = 0, l = null, u = (e, t) => {
|
|
3278
3339
|
n.setStatus(e), l !== null && (clearTimeout(l), l = null), t !== void 0 && (l = setTimeout(() => {
|
|
3279
3340
|
l = null, c === 0 && n.setStatus(r.t("upload.statusInit"));
|
|
3280
3341
|
}, t));
|
|
3281
3342
|
}, d = (e, n, i) => {
|
|
3282
3343
|
let o = {
|
|
3283
3344
|
name: n.name,
|
|
3284
|
-
maxSize:
|
|
3345
|
+
maxSize: Ht(a)
|
|
3285
3346
|
};
|
|
3286
|
-
u(r.t(
|
|
3347
|
+
u(r.t(ji[e], o), Ai), t.onError?.({
|
|
3287
3348
|
kind: e,
|
|
3288
3349
|
file: n,
|
|
3289
3350
|
cause: i
|
|
3290
3351
|
});
|
|
3291
3352
|
}, f = (n) => {
|
|
3292
|
-
let i =
|
|
3353
|
+
let i = Ni(n, {
|
|
3293
3354
|
maxSize: a,
|
|
3294
3355
|
accept: o
|
|
3295
3356
|
});
|
|
@@ -3304,7 +3365,7 @@ function Oi(e, t, n, r = E()) {
|
|
|
3304
3365
|
to: p.to,
|
|
3305
3366
|
insert: f
|
|
3306
3367
|
},
|
|
3307
|
-
effects:
|
|
3368
|
+
effects: Ci.of({
|
|
3308
3369
|
id: l,
|
|
3309
3370
|
from: p.from,
|
|
3310
3371
|
to: p.from + f.length
|
|
@@ -3312,25 +3373,25 @@ function Oi(e, t, n, r = E()) {
|
|
|
3312
3373
|
selection: { anchor: p.from + f.length }
|
|
3313
3374
|
}), c += 1, u(r.t("upload.statusUploading", { name: n.name })), Promise.resolve().then(() => t.upload(n)).then((t) => {
|
|
3314
3375
|
--c;
|
|
3315
|
-
let i =
|
|
3376
|
+
let i = Ei(e.state, l);
|
|
3316
3377
|
i && (e.dispatch({
|
|
3317
3378
|
changes: {
|
|
3318
3379
|
from: i.from,
|
|
3319
3380
|
to: i.to,
|
|
3320
|
-
insert:
|
|
3381
|
+
insert: Mi(n.name, t)
|
|
3321
3382
|
},
|
|
3322
|
-
effects:
|
|
3323
|
-
}), u(r.t("upload.statusDone", { name: n.name }),
|
|
3383
|
+
effects: wi.of(l)
|
|
3384
|
+
}), u(r.t("upload.statusDone", { name: n.name }), ki));
|
|
3324
3385
|
}, (t) => {
|
|
3325
3386
|
--c;
|
|
3326
|
-
let r =
|
|
3387
|
+
let r = Ei(e.state, l);
|
|
3327
3388
|
r && e.dispatch({
|
|
3328
3389
|
changes: {
|
|
3329
3390
|
from: r.from,
|
|
3330
3391
|
to: r.to,
|
|
3331
3392
|
insert: ""
|
|
3332
3393
|
},
|
|
3333
|
-
effects:
|
|
3394
|
+
effects: wi.of(l)
|
|
3334
3395
|
}), d("upload-failed", n, t);
|
|
3335
3396
|
});
|
|
3336
3397
|
};
|
|
@@ -3347,24 +3408,24 @@ function Oi(e, t, n, r = E()) {
|
|
|
3347
3408
|
}
|
|
3348
3409
|
//#endregion
|
|
3349
3410
|
//#region src/features/upload-dom.ts
|
|
3350
|
-
function
|
|
3411
|
+
function Fi(e) {
|
|
3351
3412
|
if (!e) return [];
|
|
3352
3413
|
let t = e.files;
|
|
3353
3414
|
return !t || t.length === 0 ? [] : Array.from(t).filter((e) => e.type.startsWith("image/"));
|
|
3354
3415
|
}
|
|
3355
|
-
function
|
|
3416
|
+
function Ii(e) {
|
|
3356
3417
|
return t.domEventHandlers({
|
|
3357
3418
|
drop(t) {
|
|
3358
|
-
let n =
|
|
3419
|
+
let n = Fi(t.dataTransfer);
|
|
3359
3420
|
return n.length !== 0 && (t.preventDefault(), e(n), !0);
|
|
3360
3421
|
},
|
|
3361
3422
|
paste(t) {
|
|
3362
|
-
let n =
|
|
3423
|
+
let n = Fi(t.clipboardData);
|
|
3363
3424
|
return n.length !== 0 && (t.preventDefault(), e(n), !0);
|
|
3364
3425
|
}
|
|
3365
3426
|
});
|
|
3366
3427
|
}
|
|
3367
|
-
function
|
|
3428
|
+
function Li(e, t) {
|
|
3368
3429
|
let n = document.createElement("input");
|
|
3369
3430
|
n.type = "file", n.multiple = !0, n.accept = e.join(","), n.style.display = "none";
|
|
3370
3431
|
let r = () => {
|
|
@@ -3377,7 +3438,7 @@ function ji(e, t) {
|
|
|
3377
3438
|
}
|
|
3378
3439
|
//#endregion
|
|
3379
3440
|
//#region src/i18n/de.ts
|
|
3380
|
-
var
|
|
3441
|
+
var Ri = {
|
|
3381
3442
|
code: "de",
|
|
3382
3443
|
texts: {
|
|
3383
3444
|
"toolbar.bold": "Fett",
|
|
@@ -3429,7 +3490,7 @@ var Mi = {
|
|
|
3429
3490
|
"prompt.imageUrl": "Bild-URL:",
|
|
3430
3491
|
"table.column": "Spalte {n}"
|
|
3431
3492
|
}
|
|
3432
|
-
},
|
|
3493
|
+
}, zi = class {
|
|
3433
3494
|
static version = me;
|
|
3434
3495
|
options;
|
|
3435
3496
|
codemirror;
|
|
@@ -3447,16 +3508,16 @@ var Mi = {
|
|
|
3447
3508
|
editorMode;
|
|
3448
3509
|
translator;
|
|
3449
3510
|
constructor(e = {}) {
|
|
3450
|
-
this.options = e, e.injectStyles !== !1 &&
|
|
3511
|
+
this.options = e, e.injectStyles !== !1 && Vn(), this.translator = D(e.locale, e.texts);
|
|
3451
3512
|
let t = { onUpdate: (e) => {
|
|
3452
3513
|
this.toolbar?.update(e.state), this.statusbar?.update(e.state, {
|
|
3453
3514
|
docChanged: e.docChanged,
|
|
3454
3515
|
selectionSet: e.selectionSet
|
|
3455
3516
|
}), this.preview?.update(e.state), e.docChanged && this.autosave.schedule();
|
|
3456
|
-
} }, n = e.uploadImage?.enabled === !0, r = n ? [
|
|
3457
|
-
this.handle =
|
|
3517
|
+
} }, n = e.uploadImage?.enabled === !0, r = n ? [Ti, Ii((e) => this.uploader?.uploadFiles(e))] : [];
|
|
3518
|
+
this.handle = ln(e, t, [O.of(this.translator), ...r]), this.codemirror = this.handle.view, this.editorMode = this.handle.resolved.editorMode;
|
|
3458
3519
|
let i = !n && Array.isArray(e.toolbar) ? e.toolbar.filter((e) => e !== "upload-image") : e.toolbar;
|
|
3459
|
-
this.toolbar =
|
|
3520
|
+
this.toolbar = Tn(this.codemirror, i, this, this.translator), this.statusbar = jn(e.status, this.translator), this.autosave = Si(e.autosave ?? {
|
|
3460
3521
|
enabled: !1,
|
|
3461
3522
|
key: ""
|
|
3462
3523
|
}, {
|
|
@@ -3465,13 +3526,13 @@ var Mi = {
|
|
|
3465
3526
|
onSaved: (e) => {
|
|
3466
3527
|
this.statusbar?.setItem("autosave", this.translator.t("status.autosaved", { time: this.translator.formatTime(e) }));
|
|
3467
3528
|
}
|
|
3468
|
-
}), n && e.uploadImage && (typeof e.uploadImage.upload == "function" ? (this.uploader =
|
|
3469
|
-
render: (e) =>
|
|
3529
|
+
}), n && e.uploadImage && (typeof e.uploadImage.upload == "function" ? (this.uploader = Pi(this.codemirror, e.uploadImage, { setStatus: (e) => this.statusbar?.setItem("upload-image", e) }, this.translator), !(Array.isArray(e.status) && e.status.includes("upload-image")) && !e.uploadImage.onError && console.warn("SupaMDE: uploadImage is enabled, but neither the status bar item 'upload-image' (status option) nor uploadImage.onError is set — upload progress and errors stay invisible."), this.statusbar?.setItem("upload-image", this.translator.t("upload.statusInit"))) : console.warn("SupaMDE: uploadImage.enabled is true, but uploadImage.upload is not a function — image upload stays off.")), this.renderOpts = _i(e), this.preview = Mn(this.codemirror, {
|
|
3530
|
+
render: (e) => vi(e, this.renderOpts),
|
|
3470
3531
|
previewClass: e.previewClass,
|
|
3471
3532
|
syncScroll: e.syncSideBySidePreviewScroll
|
|
3472
3533
|
}), this.container = document.createElement("div"), this.container.className = "supamde-container";
|
|
3473
3534
|
let a = this.codemirror.dom;
|
|
3474
|
-
a.parentNode?.insertBefore(this.container, a), this.toolbar && this.container.appendChild(this.toolbar.dom), this.editorRow = document.createElement("div"), this.editorRow.className = "supamde-editor-row", this.editorRow.appendChild(a), this.editorRow.appendChild(this.preview.dom), this.container.appendChild(this.editorRow), this.statusbar && this.container.appendChild(this.statusbar.dom), this.fullscreen =
|
|
3535
|
+
a.parentNode?.insertBefore(this.container, a), this.toolbar && this.container.appendChild(this.toolbar.dom), this.editorRow = document.createElement("div"), this.editorRow.className = "supamde-editor-row", this.editorRow.appendChild(a), this.editorRow.appendChild(this.preview.dom), this.container.appendChild(this.editorRow), this.statusbar && this.container.appendChild(this.statusbar.dom), this.fullscreen = Pn(this.container, { onToggleFullScreen: (t) => {
|
|
3475
3536
|
this.toolbar?.update(this.codemirror.state), e.onToggleFullScreen?.(t);
|
|
3476
3537
|
} }), this.onViewShortcuts = (e) => {
|
|
3477
3538
|
e.key === "F8" ? (e.preventDefault(), this.togglePreviewFullScreen()) : e.key === "F9" ? (e.preventDefault(), this.toggleSideBySide()) : e.key === "F10" ? (e.preventDefault(), this.toggleEditorMode()) : (e.key === "F11" || (e.metaKey || e.ctrlKey) && e.shiftKey && !e.altKey && (e.key === "F" || e.key === "f")) && (e.preventDefault(), this.toggleFullScreen());
|
|
@@ -3487,16 +3548,16 @@ var Mi = {
|
|
|
3487
3548
|
this.setValue(e);
|
|
3488
3549
|
}
|
|
3489
3550
|
getValue() {
|
|
3490
|
-
return
|
|
3551
|
+
return un(this.codemirror);
|
|
3491
3552
|
}
|
|
3492
3553
|
setValue(e) {
|
|
3493
|
-
|
|
3554
|
+
dn(this.codemirror, e);
|
|
3494
3555
|
}
|
|
3495
3556
|
updateStatusBar(e, t) {
|
|
3496
3557
|
this.statusbar?.setItem(e, t);
|
|
3497
3558
|
}
|
|
3498
3559
|
markdown(e) {
|
|
3499
|
-
return
|
|
3560
|
+
return vi(e, this.renderOpts);
|
|
3500
3561
|
}
|
|
3501
3562
|
setSideBySide(e) {
|
|
3502
3563
|
this.preview?.set(e), this.container.classList.toggle("supamde-sided", this.isSideBySideActive()), this.toolbar?.update(this.codemirror.state);
|
|
@@ -3542,7 +3603,7 @@ var Mi = {
|
|
|
3542
3603
|
this.uploader?.uploadFiles(e);
|
|
3543
3604
|
}
|
|
3544
3605
|
openBrowseFileWindow() {
|
|
3545
|
-
this.uploader &&
|
|
3606
|
+
this.uploader && Li(this.uploader.accept(), (e) => this.uploader?.uploadFiles(e));
|
|
3546
3607
|
}
|
|
3547
3608
|
toTextArea() {
|
|
3548
3609
|
this.autosave.stop(), this.uploader?.destroy(), this.container.removeEventListener("keydown", this.onViewShortcuts), this.toolbar?.destroy(), this.statusbar?.destroy(), this.preview?.destroy(), this.fullscreen.destroy();
|
|
@@ -3551,6 +3612,6 @@ var Mi = {
|
|
|
3551
3612
|
}
|
|
3552
3613
|
};
|
|
3553
3614
|
//#endregion
|
|
3554
|
-
export {
|
|
3615
|
+
export { zi as SupaMDE, zi as default, me as VERSION, Ri as de, T as en };
|
|
3555
3616
|
|
|
3556
3617
|
//# sourceMappingURL=supamde.mjs.map
|