@vscode/markdown-editor 0.0.2-2 → 0.0.2-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +143 -22
- package/dist/index.js +1066 -910
- package/dist/index.js.map +1 -1
- package/dist/observables.js +90 -114
- package/dist/observables.js.map +1 -1
- package/dist/{runOnChange-owE1SMC0.js → runOnChange-C00UIwqQ.js} +130 -106
- package/dist/runOnChange-C00UIwqQ.js.map +1 -0
- package/package.json +2 -1
- package/src/view/editor.css +53 -12
- package/src/view/themes/github.css +0 -1
- package/dist/runOnChange-owE1SMC0.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -3,24 +3,24 @@ import { math as sn } from "micromark-extension-math";
|
|
|
3
3
|
import { gfmTable as rn } from "micromark-extension-gfm-table";
|
|
4
4
|
import { gfmTaskListItem as on } from "micromark-extension-gfm-task-list-item";
|
|
5
5
|
import { gfmStrikethrough as cn } from "micromark-extension-gfm-strikethrough";
|
|
6
|
-
import { o as
|
|
7
|
-
import
|
|
8
|
-
class
|
|
6
|
+
import { o as U, d as V, D as le, t as ln, r as an, a as ee, c as hn } from "./runOnChange-C00UIwqQ.js";
|
|
7
|
+
import It from "katex";
|
|
8
|
+
class w {
|
|
9
9
|
constructor(e, t) {
|
|
10
10
|
if (this.start = e, this.endExclusive = t, e > t)
|
|
11
11
|
throw new Error(`Invalid range: [${e}, ${t})`);
|
|
12
12
|
}
|
|
13
13
|
static fromTo(e, t) {
|
|
14
|
-
return new
|
|
14
|
+
return new w(e, t);
|
|
15
15
|
}
|
|
16
16
|
static ofLength(e) {
|
|
17
|
-
return new
|
|
17
|
+
return new w(0, e);
|
|
18
18
|
}
|
|
19
19
|
static ofStartAndLength(e, t) {
|
|
20
|
-
return new
|
|
20
|
+
return new w(e, e + t);
|
|
21
21
|
}
|
|
22
22
|
static emptyAt(e) {
|
|
23
|
-
return new
|
|
23
|
+
return new w(e, e);
|
|
24
24
|
}
|
|
25
25
|
get isEmpty() {
|
|
26
26
|
return this.start === this.endExclusive;
|
|
@@ -29,13 +29,13 @@ class _ {
|
|
|
29
29
|
return this.endExclusive - this.start;
|
|
30
30
|
}
|
|
31
31
|
delta(e) {
|
|
32
|
-
return new
|
|
32
|
+
return new w(this.start + e, this.endExclusive + e);
|
|
33
33
|
}
|
|
34
34
|
deltaStart(e) {
|
|
35
|
-
return new
|
|
35
|
+
return new w(this.start + e, this.endExclusive);
|
|
36
36
|
}
|
|
37
37
|
deltaEnd(e) {
|
|
38
|
-
return new
|
|
38
|
+
return new w(this.start, this.endExclusive + e);
|
|
39
39
|
}
|
|
40
40
|
contains(e) {
|
|
41
41
|
return this.start <= e && e < this.endExclusive;
|
|
@@ -52,10 +52,10 @@ class _ {
|
|
|
52
52
|
intersect(e) {
|
|
53
53
|
const t = Math.max(this.start, e.start), s = Math.min(this.endExclusive, e.endExclusive);
|
|
54
54
|
if (t <= s)
|
|
55
|
-
return new
|
|
55
|
+
return new w(t, s);
|
|
56
56
|
}
|
|
57
57
|
join(e) {
|
|
58
|
-
return new
|
|
58
|
+
return new w(
|
|
59
59
|
Math.min(this.start, e.start),
|
|
60
60
|
Math.max(this.endExclusive, e.endExclusive)
|
|
61
61
|
);
|
|
@@ -79,18 +79,18 @@ class _ {
|
|
|
79
79
|
return `[${this.start}, ${this.endExclusive})`;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
class
|
|
82
|
+
class q {
|
|
83
83
|
constructor(e, t) {
|
|
84
84
|
this.replaceRange = e, this.newText = t;
|
|
85
85
|
}
|
|
86
86
|
static insert(e, t) {
|
|
87
|
-
return new
|
|
87
|
+
return new q(w.emptyAt(e), t);
|
|
88
88
|
}
|
|
89
89
|
static replace(e, t) {
|
|
90
|
-
return new
|
|
90
|
+
return new q(e, t);
|
|
91
91
|
}
|
|
92
92
|
static delete(e) {
|
|
93
|
-
return new
|
|
93
|
+
return new q(e, "");
|
|
94
94
|
}
|
|
95
95
|
get isEmpty() {
|
|
96
96
|
return this.replaceRange.isEmpty && this.newText.length === 0;
|
|
@@ -102,19 +102,19 @@ class V {
|
|
|
102
102
|
return `${this.replaceRange} -> ${JSON.stringify(this.newText)}`;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
class
|
|
106
|
-
static empty = new
|
|
105
|
+
class E {
|
|
106
|
+
static empty = new E([]);
|
|
107
107
|
static single(e) {
|
|
108
|
-
return new
|
|
108
|
+
return new E([e]);
|
|
109
109
|
}
|
|
110
110
|
static replace(e, t) {
|
|
111
|
-
return new
|
|
111
|
+
return new E([q.replace(e, t)]);
|
|
112
112
|
}
|
|
113
113
|
static insert(e, t) {
|
|
114
|
-
return new
|
|
114
|
+
return new E([q.insert(e, t)]);
|
|
115
115
|
}
|
|
116
116
|
static delete(e) {
|
|
117
|
-
return new
|
|
117
|
+
return new E([q.delete(e)]);
|
|
118
118
|
}
|
|
119
119
|
replacements;
|
|
120
120
|
constructor(e) {
|
|
@@ -144,13 +144,13 @@ class y {
|
|
|
144
144
|
for (const i of this.replacements) {
|
|
145
145
|
const r = e.substring(i.replaceRange.start, i.replaceRange.endExclusive);
|
|
146
146
|
t.push(
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
q.replace(
|
|
148
|
+
w.ofStartAndLength(i.replaceRange.start + s, i.newText.length),
|
|
149
149
|
r
|
|
150
150
|
)
|
|
151
151
|
), s += i.newText.length - i.replaceRange.length;
|
|
152
152
|
}
|
|
153
|
-
return new
|
|
153
|
+
return new E(t);
|
|
154
154
|
}
|
|
155
155
|
equals(e) {
|
|
156
156
|
if (this.replacements.length !== e.replacements.length)
|
|
@@ -176,13 +176,13 @@ class y {
|
|
|
176
176
|
return `[${this.replacements.map((e) => e.toString()).join(", ")}]`;
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
class
|
|
179
|
+
class Ae {
|
|
180
180
|
constructor(e, t) {
|
|
181
181
|
if (this.replaceRange = e, this.newLength = t, t < 0)
|
|
182
182
|
throw new Error(`newLength must be non-negative, got ${t}`);
|
|
183
183
|
}
|
|
184
184
|
static replace(e, t) {
|
|
185
|
-
return new
|
|
185
|
+
return new Ae(e, t);
|
|
186
186
|
}
|
|
187
187
|
get lengthDelta() {
|
|
188
188
|
return this.newLength - this.replaceRange.length;
|
|
@@ -194,13 +194,13 @@ class Ie {
|
|
|
194
194
|
return `${this.replaceRange} -> +${this.newLength}`;
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
|
-
class
|
|
198
|
-
static empty = new
|
|
197
|
+
class ie {
|
|
198
|
+
static empty = new ie([]);
|
|
199
199
|
static single(e) {
|
|
200
|
-
return new
|
|
200
|
+
return new ie([e]);
|
|
201
201
|
}
|
|
202
202
|
static replace(e, t) {
|
|
203
|
-
return new
|
|
203
|
+
return new ie([Ae.replace(e, t)]);
|
|
204
204
|
}
|
|
205
205
|
replacements;
|
|
206
206
|
constructor(e) {
|
|
@@ -227,7 +227,7 @@ class J {
|
|
|
227
227
|
return this.isEmpty ? "LengthEdit.empty" : this.replacements.join(", ");
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
|
-
class
|
|
230
|
+
class Le {
|
|
231
231
|
constructor(e) {
|
|
232
232
|
this.value = e;
|
|
233
233
|
}
|
|
@@ -255,7 +255,7 @@ class x {
|
|
|
255
255
|
return this.active >= this.anchor;
|
|
256
256
|
}
|
|
257
257
|
get range() {
|
|
258
|
-
return this.isForward ? new
|
|
258
|
+
return this.isForward ? new w(this.anchor, this.active) : new w(this.active, this.anchor);
|
|
259
259
|
}
|
|
260
260
|
collapseToActive() {
|
|
261
261
|
return x.collapsed(this.active);
|
|
@@ -264,25 +264,25 @@ class x {
|
|
|
264
264
|
return new x(this.anchor, e);
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
|
-
class
|
|
267
|
+
class re {
|
|
268
268
|
constructor(e, t) {
|
|
269
269
|
this.x = e, this.y = t;
|
|
270
270
|
}
|
|
271
|
-
static ZERO = new
|
|
271
|
+
static ZERO = new re(0, 0);
|
|
272
272
|
translate(e, t) {
|
|
273
|
-
return new
|
|
273
|
+
return new re(this.x + e, this.y + t);
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
|
-
class
|
|
276
|
+
class B {
|
|
277
277
|
constructor(e, t, s, i) {
|
|
278
278
|
this.x = e, this.y = t, this.width = s, this.height = i;
|
|
279
279
|
}
|
|
280
|
-
static EMPTY = new
|
|
280
|
+
static EMPTY = new B(0, 0, 0, 0);
|
|
281
281
|
static fromPointPoint(e, t, s, i) {
|
|
282
|
-
return new
|
|
282
|
+
return new B(e, t, s - e, i - t);
|
|
283
283
|
}
|
|
284
284
|
static fromPointSize(e, t, s, i) {
|
|
285
|
-
return new
|
|
285
|
+
return new B(e, t, s, i);
|
|
286
286
|
}
|
|
287
287
|
get left() {
|
|
288
288
|
return this.x;
|
|
@@ -297,7 +297,7 @@ class R {
|
|
|
297
297
|
return this.y + this.height;
|
|
298
298
|
}
|
|
299
299
|
get topLeft() {
|
|
300
|
-
return new
|
|
300
|
+
return new re(this.x, this.y);
|
|
301
301
|
}
|
|
302
302
|
containsX(e) {
|
|
303
303
|
return e >= this.left && e < this.right;
|
|
@@ -310,13 +310,13 @@ class R {
|
|
|
310
310
|
}
|
|
311
311
|
/** Same y/height, zero-width band at `x = this.left`. Useful for caret rects derived from a line. */
|
|
312
312
|
withZeroWidthAt(e) {
|
|
313
|
-
return new
|
|
313
|
+
return new B(e, this.y, 0, this.height);
|
|
314
314
|
}
|
|
315
315
|
translate(e, t) {
|
|
316
|
-
return new
|
|
316
|
+
return new B(this.x + e, this.y + t, this.width, this.height);
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
|
-
function
|
|
319
|
+
function Nt(n, e) {
|
|
320
320
|
if (e <= 0)
|
|
321
321
|
return 0;
|
|
322
322
|
let t = e - 1;
|
|
@@ -330,7 +330,7 @@ function It(n, e) {
|
|
|
330
330
|
t--;
|
|
331
331
|
return t;
|
|
332
332
|
}
|
|
333
|
-
function
|
|
333
|
+
function Rt(n, e) {
|
|
334
334
|
const t = n.length;
|
|
335
335
|
if (e >= t)
|
|
336
336
|
return t;
|
|
@@ -345,7 +345,7 @@ function Bt(n, e) {
|
|
|
345
345
|
s++;
|
|
346
346
|
return s;
|
|
347
347
|
}
|
|
348
|
-
function
|
|
348
|
+
function dn(n, e) {
|
|
349
349
|
if (e >= n.length)
|
|
350
350
|
return { start: n.length, end: n.length };
|
|
351
351
|
const t = n[e];
|
|
@@ -373,7 +373,7 @@ function hn(n, e) {
|
|
|
373
373
|
return { start: s, end: i };
|
|
374
374
|
}
|
|
375
375
|
let un = 1;
|
|
376
|
-
class
|
|
376
|
+
class N {
|
|
377
377
|
/**
|
|
378
378
|
* A stable identity. Every node has one: it is minted on construction and
|
|
379
379
|
* carried across edits by reconciliation, so a node that survives an edit
|
|
@@ -397,7 +397,7 @@ class E {
|
|
|
397
397
|
* instances — keeping this O(children), not O(subtree). Leaves have no
|
|
398
398
|
* children, so {@link _localEquals} is their whole comparison.
|
|
399
399
|
*/
|
|
400
|
-
|
|
400
|
+
equalsShallow(e) {
|
|
401
401
|
if (this === e)
|
|
402
402
|
return !0;
|
|
403
403
|
if (this.kind !== e.kind || this.length !== e.length || !this._localEquals(e))
|
|
@@ -424,7 +424,7 @@ class E {
|
|
|
424
424
|
return Object.assign(t, this), t.id = e, t;
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
|
-
const
|
|
427
|
+
const fn = [];
|
|
428
428
|
function O(n, e) {
|
|
429
429
|
let t;
|
|
430
430
|
for (let s = 0; s < e.length; s++) {
|
|
@@ -437,9 +437,12 @@ function P(n, e) {
|
|
|
437
437
|
const t = n.get(e);
|
|
438
438
|
return t && t !== e ? t : e;
|
|
439
439
|
}
|
|
440
|
-
|
|
440
|
+
function Z(n, e) {
|
|
441
|
+
return e ? P(n, e) : void 0;
|
|
442
|
+
}
|
|
443
|
+
class Te extends N {
|
|
441
444
|
get children() {
|
|
442
|
-
return
|
|
445
|
+
return fn;
|
|
443
446
|
}
|
|
444
447
|
get length() {
|
|
445
448
|
return this.content.length;
|
|
@@ -448,7 +451,7 @@ class Ee extends E {
|
|
|
448
451
|
return this;
|
|
449
452
|
}
|
|
450
453
|
}
|
|
451
|
-
class
|
|
454
|
+
class Ee extends Te {
|
|
452
455
|
constructor(e) {
|
|
453
456
|
super(), this.content = e;
|
|
454
457
|
}
|
|
@@ -457,7 +460,7 @@ class ve extends Ee {
|
|
|
457
460
|
return this.content === e.content;
|
|
458
461
|
}
|
|
459
462
|
}
|
|
460
|
-
class k extends
|
|
463
|
+
class k extends Te {
|
|
461
464
|
constructor(e, t) {
|
|
462
465
|
super(), this.markerKind = e, this.content = t;
|
|
463
466
|
}
|
|
@@ -466,7 +469,7 @@ class k extends Ee {
|
|
|
466
469
|
return this.markerKind === e.markerKind && this.content === e.content;
|
|
467
470
|
}
|
|
468
471
|
}
|
|
469
|
-
class
|
|
472
|
+
class R extends Te {
|
|
470
473
|
constructor(e, t) {
|
|
471
474
|
super(), this.content = e, this.glueKind = t;
|
|
472
475
|
}
|
|
@@ -475,25 +478,34 @@ class N extends Ee {
|
|
|
475
478
|
return this.content === e.content && this.glueKind === e.glueKind;
|
|
476
479
|
}
|
|
477
480
|
}
|
|
478
|
-
class
|
|
479
|
-
|
|
480
|
-
|
|
481
|
+
class z extends N {
|
|
482
|
+
/** Prepends {@link leadingTrivia}, if any, ahead of the block's own children. */
|
|
483
|
+
_withLeading(e) {
|
|
484
|
+
return this.leadingTrivia ? [this.leadingTrivia, ...e] : e;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
class te extends z {
|
|
488
|
+
constructor(e, t) {
|
|
489
|
+
super(), this.content = e, this.leadingTrivia = t;
|
|
481
490
|
}
|
|
482
491
|
kind = "thematicBreak";
|
|
483
492
|
get children() {
|
|
484
|
-
return this.content;
|
|
493
|
+
return this._withLeading(this.content);
|
|
485
494
|
}
|
|
486
495
|
get marker() {
|
|
487
|
-
return
|
|
496
|
+
return ue(this.content, "content");
|
|
488
497
|
}
|
|
489
498
|
mapChildren(e) {
|
|
490
|
-
return new
|
|
499
|
+
return new te(O(e, this.content), Z(e, this.leadingTrivia));
|
|
500
|
+
}
|
|
501
|
+
withLeadingTrivia(e) {
|
|
502
|
+
return new te(this.content, e);
|
|
491
503
|
}
|
|
492
504
|
}
|
|
493
|
-
function
|
|
505
|
+
function ue(n, e) {
|
|
494
506
|
return n.find((t) => t instanceof k && t.markerKind === e);
|
|
495
507
|
}
|
|
496
|
-
class
|
|
508
|
+
class $e extends N {
|
|
497
509
|
constructor(e, t, s) {
|
|
498
510
|
super(), this.openMarker = e, this.content = t, this.closeMarker = s;
|
|
499
511
|
}
|
|
@@ -502,10 +514,10 @@ class Be extends E {
|
|
|
502
514
|
return [this.openMarker, ...this.content, this.closeMarker];
|
|
503
515
|
}
|
|
504
516
|
mapChildren(e) {
|
|
505
|
-
return new
|
|
517
|
+
return new $e(P(e, this.openMarker), O(e, this.content), P(e, this.closeMarker));
|
|
506
518
|
}
|
|
507
519
|
}
|
|
508
|
-
class
|
|
520
|
+
class Fe extends N {
|
|
509
521
|
constructor(e, t, s) {
|
|
510
522
|
super(), this.openMarker = e, this.content = t, this.closeMarker = s;
|
|
511
523
|
}
|
|
@@ -514,10 +526,10 @@ class Re extends E {
|
|
|
514
526
|
return [this.openMarker, ...this.content, this.closeMarker];
|
|
515
527
|
}
|
|
516
528
|
mapChildren(e) {
|
|
517
|
-
return new
|
|
529
|
+
return new Fe(P(e, this.openMarker), O(e, this.content), P(e, this.closeMarker));
|
|
518
530
|
}
|
|
519
531
|
}
|
|
520
|
-
class
|
|
532
|
+
class Ve extends N {
|
|
521
533
|
constructor(e, t, s) {
|
|
522
534
|
super(), this.openMarker = e, this.content = t, this.closeMarker = s;
|
|
523
535
|
}
|
|
@@ -526,10 +538,10 @@ class De extends E {
|
|
|
526
538
|
return [this.openMarker, ...this.content, this.closeMarker];
|
|
527
539
|
}
|
|
528
540
|
mapChildren(e) {
|
|
529
|
-
return new
|
|
541
|
+
return new Ve(P(e, this.openMarker), O(e, this.content), P(e, this.closeMarker));
|
|
530
542
|
}
|
|
531
543
|
}
|
|
532
|
-
class
|
|
544
|
+
class Pe extends N {
|
|
533
545
|
constructor(e) {
|
|
534
546
|
super(), this.content = e;
|
|
535
547
|
}
|
|
@@ -538,10 +550,10 @@ class Ae extends E {
|
|
|
538
550
|
return this.content;
|
|
539
551
|
}
|
|
540
552
|
mapChildren(e) {
|
|
541
|
-
return new
|
|
553
|
+
return new Pe(O(e, this.content));
|
|
542
554
|
}
|
|
543
555
|
}
|
|
544
|
-
class
|
|
556
|
+
class Ke extends N {
|
|
545
557
|
constructor(e) {
|
|
546
558
|
super(), this.content = e;
|
|
547
559
|
}
|
|
@@ -550,10 +562,10 @@ class $e extends E {
|
|
|
550
562
|
return this.content;
|
|
551
563
|
}
|
|
552
564
|
mapChildren(e) {
|
|
553
|
-
return new
|
|
565
|
+
return new Ke(O(e, this.content));
|
|
554
566
|
}
|
|
555
567
|
}
|
|
556
|
-
class
|
|
568
|
+
class we extends N {
|
|
557
569
|
constructor(e, t) {
|
|
558
570
|
super(), this.url = e, this.content = t;
|
|
559
571
|
}
|
|
@@ -562,13 +574,13 @@ class fe extends E {
|
|
|
562
574
|
return this.content;
|
|
563
575
|
}
|
|
564
576
|
mapChildren(e) {
|
|
565
|
-
return new
|
|
577
|
+
return new we(this.url, O(e, this.content));
|
|
566
578
|
}
|
|
567
579
|
_localEquals(e) {
|
|
568
580
|
return this.url === e.url;
|
|
569
581
|
}
|
|
570
582
|
}
|
|
571
|
-
class
|
|
583
|
+
class _e extends N {
|
|
572
584
|
constructor(e, t, s) {
|
|
573
585
|
super(), this.alt = e, this.url = t, this.content = s;
|
|
574
586
|
}
|
|
@@ -577,61 +589,67 @@ class ge extends E {
|
|
|
577
589
|
return this.content;
|
|
578
590
|
}
|
|
579
591
|
mapChildren(e) {
|
|
580
|
-
return new
|
|
592
|
+
return new _e(this.alt, this.url, O(e, this.content));
|
|
581
593
|
}
|
|
582
594
|
_localEquals(e) {
|
|
583
595
|
return this.alt === e.alt && this.url === e.url;
|
|
584
596
|
}
|
|
585
597
|
}
|
|
586
|
-
class
|
|
587
|
-
constructor(e, t, s) {
|
|
588
|
-
super(), this.level = e, this.marker = t, this.content = s;
|
|
598
|
+
class J extends z {
|
|
599
|
+
constructor(e, t, s, i) {
|
|
600
|
+
super(), this.level = e, this.marker = t, this.content = s, this.leadingTrivia = i;
|
|
589
601
|
}
|
|
590
602
|
kind = "heading";
|
|
591
603
|
get children() {
|
|
592
|
-
return [this.marker, ...this.content];
|
|
604
|
+
return this._withLeading([this.marker, ...this.content]);
|
|
593
605
|
}
|
|
594
606
|
mapChildren(e) {
|
|
595
|
-
return new
|
|
607
|
+
return new J(this.level, P(e, this.marker), O(e, this.content), Z(e, this.leadingTrivia));
|
|
608
|
+
}
|
|
609
|
+
withLeadingTrivia(e) {
|
|
610
|
+
return new J(this.level, this.marker, this.content, e);
|
|
596
611
|
}
|
|
597
612
|
_localEquals(e) {
|
|
598
613
|
return this.level === e.level;
|
|
599
614
|
}
|
|
600
615
|
}
|
|
601
|
-
class
|
|
602
|
-
constructor(e) {
|
|
603
|
-
super(), this.content = e;
|
|
616
|
+
class j extends z {
|
|
617
|
+
constructor(e, t) {
|
|
618
|
+
super(), this.content = e, this.leadingTrivia = t;
|
|
604
619
|
}
|
|
605
620
|
kind = "paragraph";
|
|
606
621
|
get children() {
|
|
607
|
-
return this.content;
|
|
622
|
+
return this._withLeading(this.content);
|
|
608
623
|
}
|
|
609
624
|
mapChildren(e) {
|
|
610
|
-
return new
|
|
625
|
+
return new j(O(e, this.content), Z(e, this.leadingTrivia));
|
|
626
|
+
}
|
|
627
|
+
withLeadingTrivia(e) {
|
|
628
|
+
return new j(this.content, e);
|
|
611
629
|
}
|
|
612
630
|
}
|
|
613
|
-
class
|
|
614
|
-
constructor(e, t) {
|
|
615
|
-
super(), this.language = e, this.content = t;
|
|
631
|
+
class D extends z {
|
|
632
|
+
constructor(e, t, s) {
|
|
633
|
+
super(), this.language = e, this.content = t, this.leadingTrivia = s;
|
|
616
634
|
}
|
|
617
635
|
kind = "codeBlock";
|
|
618
636
|
_previous;
|
|
619
637
|
_contentEdit;
|
|
620
638
|
get children() {
|
|
621
|
-
return this.content;
|
|
639
|
+
return this._withLeading(this.content);
|
|
622
640
|
}
|
|
623
641
|
get openFence() {
|
|
624
|
-
return
|
|
642
|
+
return ue(this.content, "openFence");
|
|
625
643
|
}
|
|
626
644
|
get closeFence() {
|
|
627
|
-
return
|
|
645
|
+
return ue(this.content, "closeFence");
|
|
628
646
|
}
|
|
629
647
|
get code() {
|
|
630
|
-
return
|
|
648
|
+
return ue(this.content, "content");
|
|
631
649
|
}
|
|
632
650
|
/** Relative start offset of the {@link code} marker within this block. */
|
|
633
651
|
get codeOffset() {
|
|
634
|
-
let e = 0;
|
|
652
|
+
let e = this.leadingTrivia?.length ?? 0;
|
|
635
653
|
for (const t of this.content) {
|
|
636
654
|
if (t.kind === "marker" && t.markerKind === "content")
|
|
637
655
|
return e;
|
|
@@ -640,7 +658,10 @@ class K extends E {
|
|
|
640
658
|
return e;
|
|
641
659
|
}
|
|
642
660
|
mapChildren(e) {
|
|
643
|
-
return new
|
|
661
|
+
return new D(this.language, O(e, this.content), Z(e, this.leadingTrivia));
|
|
662
|
+
}
|
|
663
|
+
withLeadingTrivia(e) {
|
|
664
|
+
return new D(this.language, this.content, e);
|
|
644
665
|
}
|
|
645
666
|
_localEquals(e) {
|
|
646
667
|
return this.language === e.language;
|
|
@@ -665,55 +686,64 @@ class K extends E {
|
|
|
665
686
|
return { stringEdit: this._contentEdit };
|
|
666
687
|
}
|
|
667
688
|
}
|
|
668
|
-
class
|
|
669
|
-
constructor(e) {
|
|
670
|
-
super(), this.content = e;
|
|
689
|
+
class ne extends z {
|
|
690
|
+
constructor(e, t) {
|
|
691
|
+
super(), this.content = e, this.leadingTrivia = t;
|
|
671
692
|
}
|
|
672
693
|
kind = "mathBlock";
|
|
673
694
|
get children() {
|
|
674
|
-
return this.content;
|
|
695
|
+
return this._withLeading(this.content);
|
|
675
696
|
}
|
|
676
697
|
get code() {
|
|
677
|
-
return
|
|
698
|
+
return ue(this.content, "content");
|
|
678
699
|
}
|
|
679
700
|
mapChildren(e) {
|
|
680
|
-
return new
|
|
701
|
+
return new ne(O(e, this.content), Z(e, this.leadingTrivia));
|
|
702
|
+
}
|
|
703
|
+
withLeadingTrivia(e) {
|
|
704
|
+
return new ne(this.content, e);
|
|
681
705
|
}
|
|
682
706
|
}
|
|
683
|
-
class
|
|
684
|
-
constructor(e) {
|
|
685
|
-
super(), this.content = e;
|
|
707
|
+
class oe extends z {
|
|
708
|
+
constructor(e, t) {
|
|
709
|
+
super(), this.content = e, this.leadingTrivia = t;
|
|
686
710
|
}
|
|
687
711
|
kind = "blockQuote";
|
|
688
712
|
get children() {
|
|
689
|
-
return this.content;
|
|
713
|
+
return this._withLeading(this.content);
|
|
690
714
|
}
|
|
691
715
|
get blocks() {
|
|
692
|
-
return this.content.filter(
|
|
716
|
+
return this.content.filter(We);
|
|
693
717
|
}
|
|
694
718
|
mapChildren(e) {
|
|
695
|
-
return new
|
|
719
|
+
return new oe(O(e, this.content), Z(e, this.leadingTrivia));
|
|
720
|
+
}
|
|
721
|
+
withLeadingTrivia(e) {
|
|
722
|
+
return new oe(this.content, e);
|
|
696
723
|
}
|
|
697
724
|
}
|
|
698
|
-
class
|
|
699
|
-
constructor(e, t) {
|
|
700
|
-
super(), this.ordered = e, this.content = t;
|
|
725
|
+
class K extends z {
|
|
726
|
+
constructor(e, t, s) {
|
|
727
|
+
super(), this.ordered = e, this.content = t, this.leadingTrivia = s;
|
|
701
728
|
}
|
|
702
729
|
kind = "list";
|
|
703
730
|
get children() {
|
|
704
|
-
return this.content;
|
|
731
|
+
return this._withLeading(this.content);
|
|
705
732
|
}
|
|
706
733
|
get items() {
|
|
707
|
-
return this.content.filter((e) => e instanceof
|
|
734
|
+
return this.content.filter((e) => e instanceof H);
|
|
708
735
|
}
|
|
709
736
|
mapChildren(e) {
|
|
710
|
-
return new
|
|
737
|
+
return new K(this.ordered, O(e, this.content), Z(e, this.leadingTrivia));
|
|
738
|
+
}
|
|
739
|
+
withLeadingTrivia(e) {
|
|
740
|
+
return new K(this.ordered, this.content, e);
|
|
711
741
|
}
|
|
712
742
|
_localEquals(e) {
|
|
713
743
|
return this.ordered === e.ordered;
|
|
714
744
|
}
|
|
715
745
|
}
|
|
716
|
-
class
|
|
746
|
+
class H extends N {
|
|
717
747
|
constructor(e, t, s, i) {
|
|
718
748
|
super(), this.marker = e, this.content = t, this.checked = s, this.leadingTrivia = i;
|
|
719
749
|
}
|
|
@@ -722,30 +752,33 @@ class $ extends E {
|
|
|
722
752
|
return this.leadingTrivia ? [this.leadingTrivia, this.marker, ...this.content] : [this.marker, ...this.content];
|
|
723
753
|
}
|
|
724
754
|
get blocks() {
|
|
725
|
-
return this.content.filter(
|
|
755
|
+
return this.content.filter(We);
|
|
726
756
|
}
|
|
727
757
|
mapChildren(e) {
|
|
728
|
-
return new
|
|
758
|
+
return new H(
|
|
729
759
|
P(e, this.marker),
|
|
730
760
|
O(e, this.content),
|
|
731
761
|
this.checked,
|
|
732
762
|
this.leadingTrivia ? P(e, this.leadingTrivia) : void 0
|
|
733
763
|
);
|
|
734
764
|
}
|
|
765
|
+
withLeadingTrivia(e) {
|
|
766
|
+
return new H(this.marker, this.content, this.checked, e);
|
|
767
|
+
}
|
|
735
768
|
_localEquals(e) {
|
|
736
769
|
return this.checked === e.checked;
|
|
737
770
|
}
|
|
738
771
|
}
|
|
739
|
-
class
|
|
740
|
-
constructor(e) {
|
|
741
|
-
super(), this.content = e;
|
|
772
|
+
class ce extends z {
|
|
773
|
+
constructor(e, t) {
|
|
774
|
+
super(), this.content = e, this.leadingTrivia = t;
|
|
742
775
|
}
|
|
743
776
|
kind = "table";
|
|
744
777
|
get children() {
|
|
745
|
-
return this.content;
|
|
778
|
+
return this._withLeading(this.content);
|
|
746
779
|
}
|
|
747
780
|
get _rows() {
|
|
748
|
-
return this.content.filter((e) => e instanceof
|
|
781
|
+
return this.content.filter((e) => e instanceof ge);
|
|
749
782
|
}
|
|
750
783
|
get headerRow() {
|
|
751
784
|
return this._rows[0];
|
|
@@ -757,10 +790,13 @@ class me extends E {
|
|
|
757
790
|
return this._rows.slice(2);
|
|
758
791
|
}
|
|
759
792
|
mapChildren(e) {
|
|
760
|
-
return new
|
|
793
|
+
return new ce(O(e, this.content), Z(e, this.leadingTrivia));
|
|
794
|
+
}
|
|
795
|
+
withLeadingTrivia(e) {
|
|
796
|
+
return new ce(this.content, e);
|
|
761
797
|
}
|
|
762
798
|
}
|
|
763
|
-
class
|
|
799
|
+
class ge extends N {
|
|
764
800
|
constructor(e) {
|
|
765
801
|
super(), this.content = e;
|
|
766
802
|
}
|
|
@@ -769,13 +805,13 @@ class he extends E {
|
|
|
769
805
|
return this.content;
|
|
770
806
|
}
|
|
771
807
|
get cells() {
|
|
772
|
-
return this.content.filter((e) => e instanceof
|
|
808
|
+
return this.content.filter((e) => e instanceof pe);
|
|
773
809
|
}
|
|
774
810
|
mapChildren(e) {
|
|
775
|
-
return new
|
|
811
|
+
return new ge(O(e, this.content));
|
|
776
812
|
}
|
|
777
813
|
}
|
|
778
|
-
class
|
|
814
|
+
class pe extends N {
|
|
779
815
|
constructor(e) {
|
|
780
816
|
super(), this.content = e;
|
|
781
817
|
}
|
|
@@ -784,10 +820,10 @@ class ue extends E {
|
|
|
784
820
|
return this.content;
|
|
785
821
|
}
|
|
786
822
|
mapChildren(e) {
|
|
787
|
-
return new
|
|
823
|
+
return new pe(O(e, this.content));
|
|
788
824
|
}
|
|
789
825
|
}
|
|
790
|
-
class
|
|
826
|
+
class He extends N {
|
|
791
827
|
constructor(e) {
|
|
792
828
|
super(), this.content = e;
|
|
793
829
|
}
|
|
@@ -796,43 +832,43 @@ class Fe extends E {
|
|
|
796
832
|
return this.content;
|
|
797
833
|
}
|
|
798
834
|
get blocks() {
|
|
799
|
-
return this.content.filter(
|
|
835
|
+
return this.content.filter(We);
|
|
800
836
|
}
|
|
801
837
|
mapChildren(e) {
|
|
802
|
-
return new
|
|
838
|
+
return new He(O(e, this.content));
|
|
803
839
|
}
|
|
804
840
|
}
|
|
805
|
-
function
|
|
806
|
-
return n instanceof
|
|
841
|
+
function We(n) {
|
|
842
|
+
return n instanceof J || n instanceof j || n instanceof D || n instanceof ne || n instanceof te || n instanceof oe || n instanceof K || n instanceof ce;
|
|
807
843
|
}
|
|
808
|
-
function
|
|
844
|
+
function gn(n, e) {
|
|
809
845
|
if (n.id === e.id)
|
|
810
846
|
return 0;
|
|
811
847
|
let t = 0;
|
|
812
848
|
for (const s of n.children) {
|
|
813
|
-
const i =
|
|
849
|
+
const i = gn(s, e);
|
|
814
850
|
if (i !== void 0)
|
|
815
851
|
return t + i;
|
|
816
852
|
t += s.length;
|
|
817
853
|
}
|
|
818
854
|
}
|
|
819
|
-
const
|
|
820
|
-
function
|
|
855
|
+
const pn = /\[[ xX]\]/;
|
|
856
|
+
function Bi(n) {
|
|
821
857
|
if (n.checked === void 0)
|
|
822
858
|
return;
|
|
823
|
-
const e =
|
|
859
|
+
const e = pn.exec(Bt(n));
|
|
824
860
|
if (e)
|
|
825
|
-
return
|
|
861
|
+
return w.ofStartAndLength(e.index, e[0].length);
|
|
826
862
|
}
|
|
827
|
-
function
|
|
828
|
-
if (n instanceof
|
|
863
|
+
function Bt(n) {
|
|
864
|
+
if (n instanceof Te)
|
|
829
865
|
return n.content;
|
|
830
866
|
let e = "";
|
|
831
867
|
for (const t of n.children)
|
|
832
|
-
e +=
|
|
868
|
+
e += Bt(t);
|
|
833
869
|
return e;
|
|
834
870
|
}
|
|
835
|
-
function
|
|
871
|
+
function mn(n) {
|
|
836
872
|
const e = en({ extensions: [sn(), rn(), on(), cn()] }), t = tn()(n, void 0, !0);
|
|
837
873
|
return nn(e.document().write(t)).map(([i, r]) => ({
|
|
838
874
|
type: i,
|
|
@@ -841,46 +877,48 @@ function pn(n) {
|
|
|
841
877
|
endOffset: r.end.offset
|
|
842
878
|
}));
|
|
843
879
|
}
|
|
844
|
-
function
|
|
845
|
-
return new
|
|
880
|
+
function wn(n) {
|
|
881
|
+
return new xn(mn(n), n).build();
|
|
846
882
|
}
|
|
847
|
-
function
|
|
883
|
+
function ve(n) {
|
|
848
884
|
const e = [];
|
|
849
885
|
for (let t = 0; t < n.length; t++) {
|
|
850
886
|
const s = n[t], i = n[t + 1];
|
|
851
|
-
if (s instanceof
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
const c = i.content.map((l, a) => a === o ? Ye(l, s) : l);
|
|
856
|
-
e.push(new H(i.ordered, c)), t++;
|
|
857
|
-
continue;
|
|
858
|
-
}
|
|
859
|
-
} else if (i instanceof $) {
|
|
860
|
-
e.push(Ye(i, s)), t++;
|
|
887
|
+
if (s instanceof R && s.glueKind === "indent") {
|
|
888
|
+
const r = i !== void 0 ? _n(i, s) : void 0;
|
|
889
|
+
if (r) {
|
|
890
|
+
e.push(r), t++;
|
|
861
891
|
continue;
|
|
862
892
|
}
|
|
863
|
-
const
|
|
864
|
-
if (
|
|
865
|
-
e[e.length - 1] = new
|
|
893
|
+
const o = e[e.length - 1];
|
|
894
|
+
if (o instanceof R && o.glueKind === void 0) {
|
|
895
|
+
e[e.length - 1] = new R(o.content + s.content);
|
|
866
896
|
continue;
|
|
867
897
|
}
|
|
868
|
-
e.push(
|
|
898
|
+
e.push(s);
|
|
869
899
|
continue;
|
|
870
900
|
}
|
|
871
901
|
e.push(s);
|
|
872
902
|
}
|
|
873
903
|
return e;
|
|
874
904
|
}
|
|
875
|
-
function
|
|
876
|
-
|
|
905
|
+
function _n(n, e) {
|
|
906
|
+
if (n instanceof K) {
|
|
907
|
+
const t = n.content.findIndex((i) => i instanceof H);
|
|
908
|
+
if (t < 0)
|
|
909
|
+
return;
|
|
910
|
+
const s = n.content.map((i, r) => r === t ? i.withLeadingTrivia(e) : i);
|
|
911
|
+
return new K(n.ordered, s, n.leadingTrivia);
|
|
912
|
+
}
|
|
913
|
+
if (n instanceof H || n instanceof z)
|
|
914
|
+
return n.withLeadingTrivia(e);
|
|
877
915
|
}
|
|
878
|
-
function
|
|
916
|
+
function be(n) {
|
|
879
917
|
const e = [];
|
|
880
918
|
for (let t = 0; t < n.length; t++) {
|
|
881
919
|
const s = n[t];
|
|
882
|
-
if (s instanceof
|
|
883
|
-
const i = e[e.length - 1], r = n[t + 1], o = i instanceof
|
|
920
|
+
if (s instanceof R && s.glueKind === void 0) {
|
|
921
|
+
const i = e[e.length - 1], r = n[t + 1], o = i instanceof j && r instanceof j, c = new R(s.content, o ? "blockBreak" : "blockGap"), l = i !== void 0 ? Dt(i, c) : void 0;
|
|
884
922
|
l ? e[e.length - 1] = l : e.push(c);
|
|
885
923
|
continue;
|
|
886
924
|
}
|
|
@@ -890,37 +928,47 @@ function ke(n) {
|
|
|
890
928
|
}
|
|
891
929
|
function Dt(n, e) {
|
|
892
930
|
switch (n.kind) {
|
|
893
|
-
case "paragraph":
|
|
894
|
-
|
|
931
|
+
case "paragraph": {
|
|
932
|
+
const t = n;
|
|
933
|
+
return new j([...t.content, e], t.leadingTrivia);
|
|
934
|
+
}
|
|
895
935
|
case "heading": {
|
|
896
936
|
const t = n;
|
|
897
|
-
return new
|
|
937
|
+
return new J(t.level, t.marker, [...t.content, e], t.leadingTrivia);
|
|
898
938
|
}
|
|
899
939
|
case "codeBlock": {
|
|
900
940
|
const t = n;
|
|
901
|
-
return new
|
|
941
|
+
return new D(t.language, [...t.content, e], t.leadingTrivia);
|
|
942
|
+
}
|
|
943
|
+
case "mathBlock": {
|
|
944
|
+
const t = n;
|
|
945
|
+
return new ne([...t.content, e], t.leadingTrivia);
|
|
946
|
+
}
|
|
947
|
+
case "thematicBreak": {
|
|
948
|
+
const t = n;
|
|
949
|
+
return new te([...t.content, e], t.leadingTrivia);
|
|
950
|
+
}
|
|
951
|
+
case "table": {
|
|
952
|
+
const t = n;
|
|
953
|
+
return new ce([...t.content, e], t.leadingTrivia);
|
|
954
|
+
}
|
|
955
|
+
case "blockQuote": {
|
|
956
|
+
const t = n;
|
|
957
|
+
return new oe(Ie(t.content, e), t.leadingTrivia);
|
|
902
958
|
}
|
|
903
|
-
case "mathBlock":
|
|
904
|
-
return new se([...n.content, e]);
|
|
905
|
-
case "thematicBreak":
|
|
906
|
-
return new ne([...n.content, e]);
|
|
907
|
-
case "table":
|
|
908
|
-
return new me([...n.content, e]);
|
|
909
|
-
case "blockQuote":
|
|
910
|
-
return new pe(Me(n.content, e));
|
|
911
959
|
case "list": {
|
|
912
960
|
const t = n;
|
|
913
|
-
return new
|
|
961
|
+
return new K(t.ordered, Ie(t.content, e), t.leadingTrivia);
|
|
914
962
|
}
|
|
915
963
|
case "listItem": {
|
|
916
964
|
const t = n;
|
|
917
|
-
return new
|
|
965
|
+
return new H(t.marker, Ie(t.content, e), t.checked, t.leadingTrivia);
|
|
918
966
|
}
|
|
919
967
|
default:
|
|
920
968
|
return;
|
|
921
969
|
}
|
|
922
970
|
}
|
|
923
|
-
function
|
|
971
|
+
function Ie(n, e) {
|
|
924
972
|
const t = n[n.length - 1], s = t !== void 0 ? Dt(t, e) : void 0;
|
|
925
973
|
if (s) {
|
|
926
974
|
const i = n.slice();
|
|
@@ -928,8 +976,8 @@ function Me(n, e) {
|
|
|
928
976
|
}
|
|
929
977
|
return [...n, e];
|
|
930
978
|
}
|
|
931
|
-
function
|
|
932
|
-
return n.some((e) => !(e instanceof
|
|
979
|
+
function kn(n) {
|
|
980
|
+
return n.some((e) => !(e instanceof R)) ? n : [new j(n)];
|
|
933
981
|
}
|
|
934
982
|
class C {
|
|
935
983
|
constructor(e, t) {
|
|
@@ -946,18 +994,18 @@ class C {
|
|
|
946
994
|
const r = this._parentStart + e, o = (c, l) => {
|
|
947
995
|
const a = this._source.substring(c, l), h = t ? null : /\n[^\S\n]+$/.exec(a);
|
|
948
996
|
if (!h) {
|
|
949
|
-
s.push(new
|
|
997
|
+
s.push(new R(a, t));
|
|
950
998
|
return;
|
|
951
999
|
}
|
|
952
1000
|
const g = a.slice(h.index + 1);
|
|
953
|
-
s.push(new
|
|
1001
|
+
s.push(new R(a.slice(0, a.length - g.length))), s.push(new R(g, "indent"));
|
|
954
1002
|
};
|
|
955
1003
|
for (const { node: c, start: l } of this._entries)
|
|
956
1004
|
c.length !== 0 && (l > i && o(i, l), s.push(c), i = l + c.length);
|
|
957
1005
|
return i < r && o(i, r), s;
|
|
958
1006
|
}
|
|
959
1007
|
}
|
|
960
|
-
class
|
|
1008
|
+
class xn {
|
|
961
1009
|
constructor(e, t) {
|
|
962
1010
|
this._events = e, this._source = t;
|
|
963
1011
|
}
|
|
@@ -973,7 +1021,7 @@ class wn {
|
|
|
973
1021
|
} else
|
|
974
1022
|
this._idx++;
|
|
975
1023
|
}
|
|
976
|
-
return new
|
|
1024
|
+
return new He(kn(be(ve(e.build(this._source.length)))));
|
|
977
1025
|
}
|
|
978
1026
|
_tryParseBlock() {
|
|
979
1027
|
switch (this._events[this._idx].tokenType) {
|
|
@@ -983,6 +1031,8 @@ class wn {
|
|
|
983
1031
|
return this._parseParagraph();
|
|
984
1032
|
case "codeFenced":
|
|
985
1033
|
return this._parseCodeFenced();
|
|
1034
|
+
case "codeIndented":
|
|
1035
|
+
return this._parseCodeIndented();
|
|
986
1036
|
case "mathFlow":
|
|
987
1037
|
return this._parseMathFlow();
|
|
988
1038
|
case "thematicBreak":
|
|
@@ -1005,8 +1055,8 @@ class wn {
|
|
|
1005
1055
|
for (; this._notExit("atxHeading"); ) {
|
|
1006
1056
|
const h = this._events[this._idx];
|
|
1007
1057
|
if (h.type === "enter" && h.tokenType === "atxHeadingSequence") {
|
|
1008
|
-
const g = this._consume("enter", "atxHeadingSequence"),
|
|
1009
|
-
i === e.startOffset && (t = Math.min(6, Math.max(1,
|
|
1058
|
+
const g = this._consume("enter", "atxHeadingSequence"), d = this._consume("exit", "atxHeadingSequence");
|
|
1059
|
+
i === e.startOffset && (t = Math.min(6, Math.max(1, d.endOffset - g.startOffset)), s = g.startOffset, i = d.endOffset);
|
|
1010
1060
|
} else h.type === "enter" && h.tokenType === "atxHeadingText" ? (this._consume("enter", "atxHeadingText"), this._parseInlines(r, "atxHeadingText"), this._consume("exit", "atxHeadingText")) : this._idx++;
|
|
1011
1061
|
}
|
|
1012
1062
|
const o = this._consume("exit", "atxHeading");
|
|
@@ -1015,7 +1065,7 @@ class wn {
|
|
|
1015
1065
|
for (const h of r)
|
|
1016
1066
|
l.add(h.node, h.start);
|
|
1017
1067
|
const a = l.build(o.endOffset - i);
|
|
1018
|
-
return new
|
|
1068
|
+
return new J(t, c, a);
|
|
1019
1069
|
}
|
|
1020
1070
|
_parseParagraph() {
|
|
1021
1071
|
const e = this._consume("enter", "paragraph"), t = [];
|
|
@@ -1024,7 +1074,7 @@ class wn {
|
|
|
1024
1074
|
const s = this._consume("exit", "paragraph"), i = new C(e.startOffset, this._source);
|
|
1025
1075
|
for (const r of t)
|
|
1026
1076
|
i.add(r.node, r.start);
|
|
1027
|
-
return new
|
|
1077
|
+
return new j(i.build(s.endOffset - e.startOffset));
|
|
1028
1078
|
}
|
|
1029
1079
|
_parseCodeFenced() {
|
|
1030
1080
|
const e = this._consume("enter", "codeFenced");
|
|
@@ -1039,8 +1089,8 @@ class wn {
|
|
|
1039
1089
|
const g = this._events[this._idx];
|
|
1040
1090
|
if (g.type === "enter" && g.tokenType === "codeFencedFenceInfo") {
|
|
1041
1091
|
for (this._consume("enter", "codeFencedFenceInfo"); this._notExit("codeFencedFenceInfo"); ) {
|
|
1042
|
-
const
|
|
1043
|
-
|
|
1092
|
+
const d = this._events[this._idx];
|
|
1093
|
+
d.tokenType === "data" && (t = this._source.substring(d.startOffset, d.endOffset)), this._idx++;
|
|
1044
1094
|
}
|
|
1045
1095
|
this._consume("exit", "codeFencedFenceInfo");
|
|
1046
1096
|
} else
|
|
@@ -1054,7 +1104,33 @@ class wn {
|
|
|
1054
1104
|
} else l.tokenType === "codeFlowValue" || l.tokenType === "lineEnding" ? (r === void 0 && (r = l.startOffset), o = l.endOffset, this._idx++) : this._idx++;
|
|
1055
1105
|
}
|
|
1056
1106
|
const c = this._consume("exit", "codeFenced");
|
|
1057
|
-
return r !== void 0 && s.add(new k("content", this._source.substring(r, o)), r), new
|
|
1107
|
+
return r !== void 0 && s.add(new k("content", this._source.substring(r, o)), r), new D(t, s.build(c.endOffset - e.startOffset));
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
* An indented code block has no fences and no info string: micromark strips a
|
|
1111
|
+
* four-space `linePrefix` from each line and emits the rest as `codeFlowValue`.
|
|
1112
|
+
* Each line's `linePrefix` becomes a hideable `codeIndent` marker (so the
|
|
1113
|
+
* structural indentation can be dropped from the rendered block, like a
|
|
1114
|
+
* heading's `#`), while the actual code is kept verbatim as `content` markers
|
|
1115
|
+
* — one run per line — so the block round-trips the source.
|
|
1116
|
+
*/
|
|
1117
|
+
_parseCodeIndented() {
|
|
1118
|
+
const e = this._consume("enter", "codeIndented"), t = new C(e.startOffset, this._source);
|
|
1119
|
+
let s, i;
|
|
1120
|
+
const r = () => {
|
|
1121
|
+
s !== void 0 && (t.add(new k("content", this._source.substring(s, i)), s), s = void 0);
|
|
1122
|
+
};
|
|
1123
|
+
for (; this._notExit("codeIndented"); ) {
|
|
1124
|
+
const c = this._events[this._idx];
|
|
1125
|
+
if (c.type === "enter" && c.tokenType === "linePrefix") {
|
|
1126
|
+
r();
|
|
1127
|
+
const l = this._consume("enter", "linePrefix"), a = this._consume("exit", "linePrefix");
|
|
1128
|
+
t.add(new k("codeIndent", this._source.substring(l.startOffset, a.endOffset)), l.startOffset);
|
|
1129
|
+
} else c.tokenType === "codeFlowValue" || c.tokenType === "lineEnding" ? (s === void 0 && (s = c.startOffset), i = c.endOffset, this._idx++) : this._idx++;
|
|
1130
|
+
}
|
|
1131
|
+
r();
|
|
1132
|
+
const o = this._consume("exit", "codeIndented");
|
|
1133
|
+
return new D("", t.build(o.endOffset - e.startOffset));
|
|
1058
1134
|
}
|
|
1059
1135
|
_parseMathFlow() {
|
|
1060
1136
|
const e = this._consume("enter", "mathFlow"), t = new C(e.startOffset, this._source);
|
|
@@ -1073,14 +1149,14 @@ class wn {
|
|
|
1073
1149
|
} else c.tokenType === "mathFlowValue" || c.tokenType === "lineEnding" ? (i === void 0 && (i = c.startOffset), r = c.endOffset, this._idx++) : this._idx++;
|
|
1074
1150
|
}
|
|
1075
1151
|
const o = this._consume("exit", "mathFlow");
|
|
1076
|
-
return i !== void 0 && t.add(new k("content", this._source.substring(i, r)), i), new
|
|
1152
|
+
return i !== void 0 && t.add(new k("content", this._source.substring(i, r)), i), new ne(t.build(o.endOffset - e.startOffset));
|
|
1077
1153
|
}
|
|
1078
1154
|
_parseThematicBreak() {
|
|
1079
1155
|
const e = this._consume("enter", "thematicBreak");
|
|
1080
1156
|
for (; this._notExit("thematicBreak"); )
|
|
1081
1157
|
this._idx++;
|
|
1082
1158
|
const t = this._consume("exit", "thematicBreak"), s = new k("content", this._source.substring(e.startOffset, t.endOffset));
|
|
1083
|
-
return new
|
|
1159
|
+
return new te([s]);
|
|
1084
1160
|
}
|
|
1085
1161
|
_parseBlockQuote() {
|
|
1086
1162
|
const e = this._consume("enter", "blockQuote"), t = new C(e.startOffset, this._source);
|
|
@@ -1100,7 +1176,7 @@ class wn {
|
|
|
1100
1176
|
this._idx++;
|
|
1101
1177
|
}
|
|
1102
1178
|
const i = this._consume("exit", "blockQuote");
|
|
1103
|
-
return new
|
|
1179
|
+
return new oe(be(ve(t.build(i.endOffset - e.startOffset))));
|
|
1104
1180
|
}
|
|
1105
1181
|
_parseList() {
|
|
1106
1182
|
const e = this._events[this._idx].tokenType, t = e === "listOrdered", s = this._consume("enter", e), i = new C(s.startOffset, this._source);
|
|
@@ -1108,24 +1184,24 @@ class wn {
|
|
|
1108
1184
|
const g = () => {
|
|
1109
1185
|
if (r === void 0 || o === void 0 || l === void 0)
|
|
1110
1186
|
return;
|
|
1111
|
-
const
|
|
1112
|
-
i.add(new
|
|
1187
|
+
const u = new k("listItemMarker", this._source.substring(o, c)), f = h ?? c, p = l.build(f - c);
|
|
1188
|
+
i.add(new H(u, be(ve(p)), a), r);
|
|
1113
1189
|
};
|
|
1114
1190
|
for (; this._notExit(e); ) {
|
|
1115
|
-
const
|
|
1116
|
-
if (
|
|
1117
|
-
for (g(), this._consume("enter", "listItemPrefix"), r =
|
|
1191
|
+
const u = this._events[this._idx];
|
|
1192
|
+
if (u.type === "enter" && u.tokenType === "listItemPrefix") {
|
|
1193
|
+
for (g(), this._consume("enter", "listItemPrefix"), r = u.startOffset, o = u.startOffset, a = void 0, h = void 0, this._checkChecked = void 0; this._notExit("listItemPrefix"); )
|
|
1118
1194
|
this._idx++;
|
|
1119
1195
|
c = this._events[this._idx].endOffset, this._consume("exit", "listItemPrefix"), l = new C(c, this._source);
|
|
1120
|
-
} else if (
|
|
1121
|
-
const f =
|
|
1196
|
+
} else if (u.type === "enter") {
|
|
1197
|
+
const f = u.startOffset, p = this._tryParseBlock();
|
|
1122
1198
|
p && l ? (l.add(p, f), h = f + p.length, a === void 0 && this._checkChecked !== void 0 && (a = this._checkChecked)) : p || this._idx++;
|
|
1123
1199
|
} else
|
|
1124
1200
|
this._idx++;
|
|
1125
1201
|
}
|
|
1126
1202
|
g();
|
|
1127
|
-
const
|
|
1128
|
-
return new
|
|
1203
|
+
const d = this._consume("exit", e);
|
|
1204
|
+
return new K(t, be(ve(i.build(d.endOffset - s.startOffset))));
|
|
1129
1205
|
}
|
|
1130
1206
|
_parseTable() {
|
|
1131
1207
|
const e = this._consume("enter", "table"), t = new C(e.startOffset, this._source);
|
|
@@ -1158,7 +1234,7 @@ class wn {
|
|
|
1158
1234
|
this._idx++;
|
|
1159
1235
|
}
|
|
1160
1236
|
const i = this._consume("exit", "table");
|
|
1161
|
-
return new
|
|
1237
|
+
return new ce(t.build(i.endOffset - e.startOffset));
|
|
1162
1238
|
}
|
|
1163
1239
|
_buildDelimiterRow(e, t, s) {
|
|
1164
1240
|
const i = this._source.substring(e, t), r = [];
|
|
@@ -1175,10 +1251,10 @@ class wn {
|
|
|
1175
1251
|
}
|
|
1176
1252
|
const l = new C(e, this._source);
|
|
1177
1253
|
for (let a = 0; a < o.length; a++) {
|
|
1178
|
-
const h = o[a], g = a + 1 < o.length ? o[a + 1] : i.length,
|
|
1179
|
-
a === o.length - 1 &&
|
|
1254
|
+
const h = o[a], g = a + 1 < o.length ? o[a + 1] : i.length, d = new C(e + h, this._source), u = i.substring(h, g);
|
|
1255
|
+
a === o.length - 1 && u.length > 1 && u.endsWith("|") ? (d.add(new k("tableDelimiter", u.slice(0, -1)), e + h), d.add(new k("tableDelimiterClose", "|"), e + h + u.length - 1)) : d.add(new k("tableDelimiter", u), e + h), l.add(new pe(d.build(g - h)), e + h);
|
|
1180
1256
|
}
|
|
1181
|
-
return new
|
|
1257
|
+
return new ge(l.build(t - e));
|
|
1182
1258
|
}
|
|
1183
1259
|
_parseTableRow(e) {
|
|
1184
1260
|
const t = this._consume("enter", "tableRow"), s = new C(t.startOffset, this._source);
|
|
@@ -1198,12 +1274,12 @@ class wn {
|
|
|
1198
1274
|
const l = this._consume("exit", e), a = new C(o.startOffset, this._source);
|
|
1199
1275
|
for (const h of c)
|
|
1200
1276
|
a.add(h.node, h.start);
|
|
1201
|
-
s.add(new
|
|
1277
|
+
s.add(new pe(a.build(l.endOffset - o.startOffset, "tableCellGlue")), o.startOffset);
|
|
1202
1278
|
} else
|
|
1203
1279
|
this._idx++;
|
|
1204
1280
|
}
|
|
1205
1281
|
const i = this._consume("exit", "tableRow");
|
|
1206
|
-
return new
|
|
1282
|
+
return new ge(s.build(i.endOffset - t.startOffset));
|
|
1207
1283
|
}
|
|
1208
1284
|
_parseInlines(e, t) {
|
|
1209
1285
|
for (; this._idx < this._events.length; ) {
|
|
@@ -1241,7 +1317,7 @@ class wn {
|
|
|
1241
1317
|
e.push(this._parseHardBreak());
|
|
1242
1318
|
return;
|
|
1243
1319
|
}
|
|
1244
|
-
t.type === "exit" && (t.tokenType === "data" || t.tokenType === "codeTextData") && e.push({ node: new
|
|
1320
|
+
t.type === "exit" && (t.tokenType === "data" || t.tokenType === "codeTextData") && e.push({ node: new Ee(this._source.substring(t.startOffset, t.endOffset)), start: t.startOffset }), t.type === "exit" && t.tokenType === "taskListCheckValueChecked" ? this._checkChecked = !0 : t.type === "exit" && t.tokenType === "taskListCheckValueUnchecked" && (this._checkChecked = !1), this._idx++;
|
|
1245
1321
|
}
|
|
1246
1322
|
/**
|
|
1247
1323
|
* A GFM hard line break — either two-or-more trailing spaces
|
|
@@ -1264,16 +1340,16 @@ class wn {
|
|
|
1264
1340
|
for (; this._idx < this._events.length; ) {
|
|
1265
1341
|
const c = this._events[this._idx];
|
|
1266
1342
|
if (c.type === "enter" && c.tokenType === t) {
|
|
1267
|
-
const l = this._consume("enter", t), a = this._consume("exit", t), h = new k("openMarker", this._source.substring(i.startOffset, r.endOffset)), g = new k("closeMarker", this._source.substring(l.startOffset, a.endOffset)),
|
|
1343
|
+
const l = this._consume("enter", t), a = this._consume("exit", t), h = new k("openMarker", this._source.substring(i.startOffset, r.endOffset)), g = new k("closeMarker", this._source.substring(l.startOffset, a.endOffset)), d = new C(r.endOffset, this._source);
|
|
1268
1344
|
for (const p of o)
|
|
1269
|
-
|
|
1270
|
-
const
|
|
1345
|
+
d.add(p.node, p.start);
|
|
1346
|
+
const u = d.build(l.startOffset - r.endOffset), f = s ? new $e(h, u, g) : new Fe(h, u, g);
|
|
1271
1347
|
e.push({ node: f, start: i.startOffset });
|
|
1272
1348
|
return;
|
|
1273
1349
|
}
|
|
1274
1350
|
this._parseInlineEvent(o);
|
|
1275
1351
|
}
|
|
1276
|
-
e.push({ node: new
|
|
1352
|
+
e.push({ node: new Ee(this._source.substring(i.startOffset, r.endOffset)), start: i.startOffset });
|
|
1277
1353
|
}
|
|
1278
1354
|
_parseInlineCode() {
|
|
1279
1355
|
const e = this._consume("enter", "codeText"), t = new C(e.startOffset, this._source);
|
|
@@ -1283,7 +1359,7 @@ class wn {
|
|
|
1283
1359
|
c.type === "enter" && c.tokenType === "codeTextSequence" ? (t.add(new k(s ? "closeMarker" : "openMarker", this._source.substring(c.startOffset, c.endOffset)), c.startOffset), s = !0) : c.type === "enter" && c.tokenType === "codeTextData" && (i === void 0 && (i = c.startOffset), r = c.endOffset), this._idx++;
|
|
1284
1360
|
}
|
|
1285
1361
|
const o = this._consume("exit", "codeText");
|
|
1286
|
-
return i !== void 0 && t.add(new k("content", this._source.substring(i, r)), i), { node: new
|
|
1362
|
+
return i !== void 0 && t.add(new k("content", this._source.substring(i, r)), i), { node: new Pe(t.build(o.endOffset - e.startOffset)), start: e.startOffset };
|
|
1287
1363
|
}
|
|
1288
1364
|
_parseInlineMath() {
|
|
1289
1365
|
const e = this._consume("enter", "mathText"), t = new C(e.startOffset, this._source);
|
|
@@ -1293,7 +1369,7 @@ class wn {
|
|
|
1293
1369
|
c.type === "enter" && c.tokenType === "mathTextSequence" ? (t.add(new k(s ? "closeMarker" : "openMarker", this._source.substring(c.startOffset, c.endOffset)), c.startOffset), s = !0) : c.type === "enter" && c.tokenType === "mathTextData" && (i === void 0 && (i = c.startOffset), r = c.endOffset), this._idx++;
|
|
1294
1370
|
}
|
|
1295
1371
|
const o = this._consume("exit", "mathText");
|
|
1296
|
-
return i !== void 0 && t.add(new k("content", this._source.substring(i, r)), i), { node: new
|
|
1372
|
+
return i !== void 0 && t.add(new k("content", this._source.substring(i, r)), i), { node: new Ke(t.build(o.endOffset - e.startOffset)), start: e.startOffset };
|
|
1297
1373
|
}
|
|
1298
1374
|
_parseStrikethrough() {
|
|
1299
1375
|
const e = this._consume("enter", "strikethrough");
|
|
@@ -1311,7 +1387,7 @@ class wn {
|
|
|
1311
1387
|
for (const a of o)
|
|
1312
1388
|
c.add(a.node, a.start);
|
|
1313
1389
|
const l = c.build(r - i);
|
|
1314
|
-
return { node: new
|
|
1390
|
+
return { node: new Ve(t, l, s), start: e.startOffset };
|
|
1315
1391
|
}
|
|
1316
1392
|
_parseLink() {
|
|
1317
1393
|
const e = this._consume("enter", "link"), t = new C(e.startOffset, this._source), s = [];
|
|
@@ -1344,7 +1420,7 @@ class wn {
|
|
|
1344
1420
|
const o = this._consume("exit", "link");
|
|
1345
1421
|
for (const c of s)
|
|
1346
1422
|
t.add(c.node, c.start);
|
|
1347
|
-
return { node: new
|
|
1423
|
+
return { node: new we(i, t.build(o.endOffset - e.startOffset)), start: e.startOffset };
|
|
1348
1424
|
}
|
|
1349
1425
|
_parseImage() {
|
|
1350
1426
|
const e = this._consume("enter", "image"), t = new C(e.startOffset, this._source);
|
|
@@ -1369,7 +1445,7 @@ class wn {
|
|
|
1369
1445
|
this._idx++;
|
|
1370
1446
|
}
|
|
1371
1447
|
const o = this._consume("exit", "image");
|
|
1372
|
-
return { node: new
|
|
1448
|
+
return { node: new _e(s, i, t.build(o.endOffset - e.startOffset)), start: e.startOffset };
|
|
1373
1449
|
}
|
|
1374
1450
|
_notExit(e) {
|
|
1375
1451
|
if (this._idx >= this._events.length)
|
|
@@ -1384,7 +1460,7 @@ class wn {
|
|
|
1384
1460
|
return this._idx++, s;
|
|
1385
1461
|
}
|
|
1386
1462
|
}
|
|
1387
|
-
class
|
|
1463
|
+
class vn {
|
|
1388
1464
|
constructor(e) {
|
|
1389
1465
|
this._edit = e;
|
|
1390
1466
|
}
|
|
@@ -1419,7 +1495,7 @@ class kn {
|
|
|
1419
1495
|
return e - t;
|
|
1420
1496
|
}
|
|
1421
1497
|
}
|
|
1422
|
-
class
|
|
1498
|
+
class bn {
|
|
1423
1499
|
_byRange = /* @__PURE__ */ new Map();
|
|
1424
1500
|
_byId = /* @__PURE__ */ new Map();
|
|
1425
1501
|
constructor(e) {
|
|
@@ -1445,97 +1521,97 @@ class xn {
|
|
|
1445
1521
|
function At(n, e, t, s, i) {
|
|
1446
1522
|
let r, o = e;
|
|
1447
1523
|
for (const g of n.children) {
|
|
1448
|
-
const
|
|
1449
|
-
|
|
1524
|
+
const d = At(g, o, t, s, i);
|
|
1525
|
+
d !== g && (r ??= /* @__PURE__ */ new Map()).set(g, d), o += g.length;
|
|
1450
1526
|
}
|
|
1451
1527
|
let c = r ? n.mapChildren(r) : n;
|
|
1452
|
-
const l = t.getOriginalRange(
|
|
1528
|
+
const l = t.getOriginalRange(w.ofStartAndLength(e, n.length));
|
|
1453
1529
|
if (l) {
|
|
1454
1530
|
const g = s.lookupExact(l, c.kind);
|
|
1455
|
-
if (g && c.
|
|
1531
|
+
if (g && c.equalsShallow(g))
|
|
1456
1532
|
return g;
|
|
1457
1533
|
}
|
|
1458
1534
|
const a = t.getOriginalOffset(e), h = a !== void 0 ? s.lookupId(a, c.kind) : void 0;
|
|
1459
|
-
if (h && h.id !== c.id && (c = c.cloneWithId(h.id)), c instanceof
|
|
1460
|
-
const g =
|
|
1535
|
+
if (h && h.id !== c.id && (c = c.cloneWithId(h.id)), c instanceof D && h instanceof D && a !== void 0) {
|
|
1536
|
+
const g = yn(c, h, a, i);
|
|
1461
1537
|
if (g)
|
|
1462
1538
|
return g;
|
|
1463
1539
|
}
|
|
1464
1540
|
return c;
|
|
1465
1541
|
}
|
|
1466
|
-
function
|
|
1542
|
+
function yn(n, e, t, s) {
|
|
1467
1543
|
const i = e.code, r = n.code;
|
|
1468
1544
|
if (!i || !r || n.language !== e.language || n.openFence?.content !== e.openFence?.content || n.closeFence?.content !== e.closeFence?.content)
|
|
1469
1545
|
return;
|
|
1470
1546
|
const o = t + e.codeOffset, c = o + i.length;
|
|
1471
|
-
if (!
|
|
1547
|
+
if (!En(s, o, c))
|
|
1472
1548
|
return;
|
|
1473
|
-
const l =
|
|
1549
|
+
const l = Cn(s, -o);
|
|
1474
1550
|
if (l.apply(i.content) === r.content)
|
|
1475
1551
|
return n.withCodeDiff(e, l);
|
|
1476
1552
|
}
|
|
1477
|
-
function
|
|
1553
|
+
function En(n, e, t) {
|
|
1478
1554
|
for (const s of n.replacements)
|
|
1479
1555
|
if (s.replaceRange.start < e || s.replaceRange.endExclusive > t)
|
|
1480
1556
|
return !1;
|
|
1481
1557
|
return !0;
|
|
1482
1558
|
}
|
|
1483
|
-
function
|
|
1484
|
-
return new
|
|
1559
|
+
function Cn(n, e) {
|
|
1560
|
+
return new E(n.replacements.map((t) => q.replace(t.replaceRange.delta(e), t.newText)));
|
|
1485
1561
|
}
|
|
1486
|
-
function
|
|
1487
|
-
return At(n, 0, new
|
|
1562
|
+
function On(n, e, t) {
|
|
1563
|
+
return At(n, 0, new vn(t), new bn(e), t);
|
|
1488
1564
|
}
|
|
1489
|
-
function
|
|
1490
|
-
const s =
|
|
1491
|
-
return !e || !t ? s :
|
|
1565
|
+
function Tn(n, e, t) {
|
|
1566
|
+
const s = wn(n);
|
|
1567
|
+
return !e || !t ? s : On(s, e, t);
|
|
1492
1568
|
}
|
|
1493
|
-
class
|
|
1569
|
+
class Mn {
|
|
1494
1570
|
parse(e, t, s) {
|
|
1495
|
-
return
|
|
1571
|
+
return Tn(e.value, t, s);
|
|
1496
1572
|
}
|
|
1497
1573
|
}
|
|
1498
|
-
function
|
|
1574
|
+
function Sn(n, e, t = 0) {
|
|
1499
1575
|
if (n.children.length === 0) {
|
|
1500
1576
|
const r = $t(e.substring(t, t + n.length));
|
|
1501
|
-
if (n instanceof
|
|
1577
|
+
if (n instanceof Ee)
|
|
1502
1578
|
return r;
|
|
1503
1579
|
const o = n instanceof k ? n.markerKind : n.kind;
|
|
1504
|
-
return `<${o}${
|
|
1580
|
+
return `<${o}${Ze(n)}>${r}</${o}>`;
|
|
1505
1581
|
}
|
|
1506
1582
|
let s = "", i = t;
|
|
1507
1583
|
for (const r of n.children)
|
|
1508
|
-
s +=
|
|
1509
|
-
return `<${n.kind}${
|
|
1584
|
+
s += Sn(r, e, i), i += r.length;
|
|
1585
|
+
return `<${n.kind}${Ze(n)}>${s}</${n.kind}>`;
|
|
1510
1586
|
}
|
|
1511
|
-
function
|
|
1587
|
+
function Ze(n) {
|
|
1512
1588
|
const e = {};
|
|
1513
|
-
return n instanceof
|
|
1589
|
+
return n instanceof J ? e.level = String(n.level) : n instanceof K ? e.ordered = String(n.ordered) : n instanceof D ? n.language && (e.language = n.language) : n instanceof we ? e.url = n.url : n instanceof _e ? (e.alt = n.alt, e.url = n.url) : n instanceof H ? n.checked !== void 0 && (e.checked = String(n.checked)) : n instanceof R && n.glueKind && (e.kind = n.glueKind), Object.entries(e).map(([t, s]) => ` ${t}="${$t(s)}"`).join("");
|
|
1514
1590
|
}
|
|
1515
1591
|
function $t(n) {
|
|
1516
1592
|
return n.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
1517
1593
|
}
|
|
1518
|
-
function Tn(n) {
|
|
1519
|
-
return n instanceof ve ? `text ${JSON.stringify(n.content)}` : n instanceof N ? `glue${n.glueKind ? `(${n.glueKind})` : ""} ${JSON.stringify(n.content)}` : n instanceof k ? `marker(${n.markerKind}) ${JSON.stringify(n.content)}` : n instanceof ne ? `thematicBreak ${JSON.stringify(n.content)}` : n instanceof U ? `heading(level=${n.level})` : n instanceof H ? `list(ordered=${n.ordered})` : n instanceof $ ? n.checked === void 0 ? "listItem" : `listItem(checked=${n.checked})` : n instanceof K ? `codeBlock(language=${JSON.stringify(n.language)})` : n instanceof se ? "mathBlock" : n instanceof fe ? `link(url=${JSON.stringify(n.url)})` : n instanceof ge ? `image(alt=${JSON.stringify(n.alt)}, url=${JSON.stringify(n.url)})` : n.kind;
|
|
1520
|
-
}
|
|
1521
|
-
const Ze = /* @__PURE__ */ new WeakMap();
|
|
1522
|
-
let Sn = 0;
|
|
1523
1594
|
function Ln(n) {
|
|
1524
|
-
|
|
1525
|
-
|
|
1595
|
+
return n instanceof Ee ? `text ${JSON.stringify(n.content)}` : n instanceof R ? `glue${n.glueKind ? `(${n.glueKind})` : ""} ${JSON.stringify(n.content)}` : n instanceof k ? `marker(${n.markerKind}) ${JSON.stringify(n.content)}` : n instanceof te ? `thematicBreak ${JSON.stringify(n.content)}` : n instanceof J ? `heading(level=${n.level})` : n instanceof K ? `list(ordered=${n.ordered})` : n instanceof H ? n.checked === void 0 ? "listItem" : `listItem(checked=${n.checked})` : n instanceof D ? `codeBlock(language=${JSON.stringify(n.language)})` : n instanceof ne ? "mathBlock" : n instanceof we ? `link(url=${JSON.stringify(n.url)})` : n instanceof _e ? `image(alt=${JSON.stringify(n.alt)}, url=${JSON.stringify(n.url)})` : n.kind;
|
|
1596
|
+
}
|
|
1597
|
+
const et = /* @__PURE__ */ new WeakMap();
|
|
1598
|
+
let In = 0;
|
|
1599
|
+
function Nn(n) {
|
|
1600
|
+
let e = et.get(n);
|
|
1601
|
+
return e === void 0 && (e = In++, et.set(n, e)), e;
|
|
1526
1602
|
}
|
|
1527
|
-
function
|
|
1603
|
+
function Di(n, e) {
|
|
1528
1604
|
let t = 0;
|
|
1529
1605
|
function s(i) {
|
|
1530
1606
|
const r = t, o = i.children;
|
|
1531
1607
|
let c;
|
|
1532
|
-
return o.length === 0 ? t += i.length : c = o.map(s), { label: `${
|
|
1608
|
+
return o.length === 0 ? t += i.length : c = o.map(s), { label: `${Ln(i)} #${Nn(i)} nid=${i.id}`, range: [r, t], children: c };
|
|
1533
1609
|
}
|
|
1534
1610
|
return { $fileExtension: "ast.w", source: e, root: s(n) };
|
|
1535
1611
|
}
|
|
1536
|
-
const
|
|
1537
|
-
class
|
|
1538
|
-
_parser = new
|
|
1612
|
+
const Rn = Symbol("NO_ACTIVE_BLOCKS");
|
|
1613
|
+
class Ai {
|
|
1614
|
+
_parser = new Mn();
|
|
1539
1615
|
/**
|
|
1540
1616
|
* The most recent edit applied to {@link sourceText}, used by
|
|
1541
1617
|
* {@link document} to let the parser link incrementally edited code
|
|
@@ -1543,12 +1619,12 @@ class Ni {
|
|
|
1543
1619
|
* source text (see {@link document}).
|
|
1544
1620
|
*/
|
|
1545
1621
|
_pendingEdit;
|
|
1546
|
-
sourceText =
|
|
1622
|
+
sourceText = U(this, new Le(""));
|
|
1547
1623
|
/**
|
|
1548
1624
|
* The current selection, or `undefined` when the editor has no caret
|
|
1549
1625
|
* (e.g. an inactive/unfocused rendering).
|
|
1550
1626
|
*/
|
|
1551
|
-
selection =
|
|
1627
|
+
selection = U(this, x.collapsed(0));
|
|
1552
1628
|
/**
|
|
1553
1629
|
* Forces the rendered active-block set. `undefined` (the default)
|
|
1554
1630
|
* derives the set from the current selection range (see
|
|
@@ -1556,8 +1632,8 @@ class Ni {
|
|
|
1556
1632
|
* "no active block" — useful in fixtures that always want the
|
|
1557
1633
|
* collapsed/inactive rendering.
|
|
1558
1634
|
*/
|
|
1559
|
-
activeBlocksOverride =
|
|
1560
|
-
cursorOffset =
|
|
1635
|
+
activeBlocksOverride = U(this, void 0);
|
|
1636
|
+
cursorOffset = V(
|
|
1561
1637
|
this,
|
|
1562
1638
|
(e) => e.readObservable(this.selection)?.active
|
|
1563
1639
|
);
|
|
@@ -1570,7 +1646,7 @@ class Ni {
|
|
|
1570
1646
|
*/
|
|
1571
1647
|
document = (() => {
|
|
1572
1648
|
let e, t;
|
|
1573
|
-
return
|
|
1649
|
+
return V(this, (s) => {
|
|
1574
1650
|
const i = s.readObservable(this.sourceText), r = this._pendingEdit, o = r && r.baseText === t && r.newText === i.value ? r.edit : void 0, c = this._parser.parse(i, e, o);
|
|
1575
1651
|
return e = c, t = i.value, c;
|
|
1576
1652
|
});
|
|
@@ -1581,7 +1657,7 @@ class Ni {
|
|
|
1581
1657
|
* visible. Unaffected by {@link activeBlocksOverride} because
|
|
1582
1658
|
* navigation is independent of rendering.
|
|
1583
1659
|
*/
|
|
1584
|
-
activeBlock =
|
|
1660
|
+
activeBlock = V(this, (e) => {
|
|
1585
1661
|
const t = e.readObservable(this.document), s = e.readObservable(this.cursorOffset);
|
|
1586
1662
|
if (s !== void 0)
|
|
1587
1663
|
return Ft(t, s);
|
|
@@ -1592,21 +1668,21 @@ class Ni {
|
|
|
1592
1668
|
* their expanded (markers-visible) form. When the selection is
|
|
1593
1669
|
* collapsed this is a one-element set holding {@link activeBlock}.
|
|
1594
1670
|
*/
|
|
1595
|
-
activeBlocks =
|
|
1671
|
+
activeBlocks = V(this, (e) => {
|
|
1596
1672
|
const t = e.readObservable(this.activeBlocksOverride);
|
|
1597
|
-
if (t ===
|
|
1673
|
+
if (t === Rn)
|
|
1598
1674
|
return /* @__PURE__ */ new Set();
|
|
1599
1675
|
if (t !== void 0)
|
|
1600
1676
|
return new Set(t);
|
|
1601
1677
|
const s = e.readObservable(this.document), i = e.readObservable(this.selection);
|
|
1602
|
-
return i === void 0 ? /* @__PURE__ */ new Set() : new Set(
|
|
1678
|
+
return i === void 0 ? /* @__PURE__ */ new Set() : new Set(Bn(s, i.range.start, i.range.endExclusive));
|
|
1603
1679
|
});
|
|
1604
1680
|
applyEdit(e) {
|
|
1605
|
-
const t = this.sourceText.get(), s = new
|
|
1681
|
+
const t = this.sourceText.get(), s = new Le(e.apply(t.value)), i = this.selection.get() ?? x.collapsed(0), r = e.mapOffset(i.active);
|
|
1606
1682
|
this._pendingEdit = { baseText: t.value, newText: s.value, edit: e }, this.sourceText.set(s, void 0), this.selection.set(x.collapsed(r), void 0);
|
|
1607
1683
|
}
|
|
1608
1684
|
applyEditForSelection(e) {
|
|
1609
|
-
const t = this.sourceText.get(), s = new
|
|
1685
|
+
const t = this.sourceText.get(), s = new Le(e.apply(t.value)), i = this.selection.get() ?? x.collapsed(0), r = e.mapOffset(i.range.endExclusive);
|
|
1610
1686
|
this._pendingEdit = { baseText: t.value, newText: s.value, edit: e }, this.sourceText.set(s, void 0), this.selection.set(x.collapsed(r), void 0);
|
|
1611
1687
|
}
|
|
1612
1688
|
}
|
|
@@ -1623,7 +1699,7 @@ function Ft(n, e) {
|
|
|
1623
1699
|
}
|
|
1624
1700
|
return s;
|
|
1625
1701
|
}
|
|
1626
|
-
function
|
|
1702
|
+
function Bn(n, e, t) {
|
|
1627
1703
|
if (e === t) {
|
|
1628
1704
|
const r = Ft(n, e);
|
|
1629
1705
|
return r ? [r] : [];
|
|
@@ -1636,13 +1712,13 @@ function In(n, e, t) {
|
|
|
1636
1712
|
}
|
|
1637
1713
|
return s;
|
|
1638
1714
|
}
|
|
1639
|
-
class
|
|
1715
|
+
class ke {
|
|
1640
1716
|
constructor(e) {
|
|
1641
1717
|
this.lines = e;
|
|
1642
1718
|
}
|
|
1643
|
-
static EMPTY = new
|
|
1719
|
+
static EMPTY = new ke([]);
|
|
1644
1720
|
static measure(e) {
|
|
1645
|
-
return
|
|
1721
|
+
return Fn(e);
|
|
1646
1722
|
}
|
|
1647
1723
|
get lineCount() {
|
|
1648
1724
|
return this.lines.length;
|
|
@@ -1718,7 +1794,7 @@ class _e {
|
|
|
1718
1794
|
return e < 0 || e >= this.lines.length ? 0 : this.lines[e].offsetAtX(t);
|
|
1719
1795
|
}
|
|
1720
1796
|
}
|
|
1721
|
-
class
|
|
1797
|
+
class Dn {
|
|
1722
1798
|
constructor(e, t) {
|
|
1723
1799
|
this.rect = e, this.runs = t;
|
|
1724
1800
|
}
|
|
@@ -1789,7 +1865,7 @@ class Bn {
|
|
|
1789
1865
|
return e <= t.rect.left ? t.sourceRange.start : t.sourceRange.endExclusive;
|
|
1790
1866
|
}
|
|
1791
1867
|
}
|
|
1792
|
-
class
|
|
1868
|
+
class Be {
|
|
1793
1869
|
constructor(e, t, s) {
|
|
1794
1870
|
this.sourceRange = e, this.rect = t, this.source = s;
|
|
1795
1871
|
}
|
|
@@ -1812,7 +1888,7 @@ class Le {
|
|
|
1812
1888
|
if (this.sourceLength === 0)
|
|
1813
1889
|
return this.rect.left;
|
|
1814
1890
|
if (this.source)
|
|
1815
|
-
return
|
|
1891
|
+
return An(this.source.textNode, this.source.textNodeStart + (e - this.sourceStart), this.rect.left);
|
|
1816
1892
|
const t = (e - this.sourceStart) / this.sourceLength;
|
|
1817
1893
|
return this.rect.left + t * this.rect.width;
|
|
1818
1894
|
}
|
|
@@ -1820,14 +1896,14 @@ class Le {
|
|
|
1820
1896
|
if (this.rect.width <= 0)
|
|
1821
1897
|
return this.sourceStart;
|
|
1822
1898
|
if (this.source) {
|
|
1823
|
-
const s =
|
|
1899
|
+
const s = $n(this.source.textNode, this.source.textNodeStart, this.source.textNodeStart + this.sourceLength, e);
|
|
1824
1900
|
return this.sourceStart + (s - this.source.textNodeStart);
|
|
1825
1901
|
}
|
|
1826
1902
|
const t = (e - this.rect.left) / this.rect.width;
|
|
1827
1903
|
return this.sourceStart + Math.round(t * this.sourceLength);
|
|
1828
1904
|
}
|
|
1829
1905
|
}
|
|
1830
|
-
function
|
|
1906
|
+
function An(n, e, t) {
|
|
1831
1907
|
if (e <= 0)
|
|
1832
1908
|
return t;
|
|
1833
1909
|
const s = document.createRange();
|
|
@@ -1835,7 +1911,7 @@ function Rn(n, e, t) {
|
|
|
1835
1911
|
const i = s.getBoundingClientRect();
|
|
1836
1912
|
return i.width === 0 && i.height === 0 ? t : i.right;
|
|
1837
1913
|
}
|
|
1838
|
-
function
|
|
1914
|
+
function $n(n, e, t, s) {
|
|
1839
1915
|
const i = document.createRange();
|
|
1840
1916
|
let r = e, o = 1 / 0;
|
|
1841
1917
|
for (let c = e; c < t; c++) {
|
|
@@ -1849,45 +1925,45 @@ function Dn(n, e, t, s) {
|
|
|
1849
1925
|
}
|
|
1850
1926
|
return r;
|
|
1851
1927
|
}
|
|
1852
|
-
function
|
|
1928
|
+
function Fn(n) {
|
|
1853
1929
|
const e = [];
|
|
1854
1930
|
for (const a of n) {
|
|
1855
1931
|
const h = e.length;
|
|
1856
|
-
a.viewNode.forEachTextLeaf(a.absoluteStart, (g,
|
|
1857
|
-
const
|
|
1858
|
-
if (
|
|
1932
|
+
a.viewNode.forEachTextLeaf(a.absoluteStart, (g, d) => {
|
|
1933
|
+
const u = g.dom;
|
|
1934
|
+
if (u.length === 0)
|
|
1859
1935
|
return;
|
|
1860
1936
|
const f = document.createRange();
|
|
1861
|
-
f.selectNodeContents(
|
|
1937
|
+
f.selectNodeContents(u);
|
|
1862
1938
|
const p = f.getClientRects();
|
|
1863
1939
|
if (p.length === 0)
|
|
1864
1940
|
return;
|
|
1865
|
-
const m =
|
|
1941
|
+
const m = Pn(u);
|
|
1866
1942
|
if (p.length === 1)
|
|
1867
|
-
e.push(new
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
{ textNode:
|
|
1943
|
+
e.push(new Be(
|
|
1944
|
+
w.fromTo(d, d + u.length),
|
|
1945
|
+
tt(p[0], m),
|
|
1946
|
+
{ textNode: u, textNodeStart: 0 }
|
|
1871
1947
|
));
|
|
1872
1948
|
else {
|
|
1873
|
-
const
|
|
1949
|
+
const _ = Vn(u, p);
|
|
1874
1950
|
for (let v = 0; v < p.length; v++) {
|
|
1875
|
-
const
|
|
1876
|
-
e.push(new
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
{ textNode:
|
|
1951
|
+
const y = v === 0 ? 0 : _[v - 1], M = v < _.length ? _[v] : u.length;
|
|
1952
|
+
e.push(new Be(
|
|
1953
|
+
w.fromTo(d + y, d + M),
|
|
1954
|
+
tt(p[v], m),
|
|
1955
|
+
{ textNode: u, textNodeStart: y }
|
|
1880
1956
|
));
|
|
1881
1957
|
}
|
|
1882
1958
|
}
|
|
1883
|
-
}), e.length === h &&
|
|
1959
|
+
}), e.length === h && Kn(e, a.viewNode, a.absoluteStart);
|
|
1884
1960
|
}
|
|
1885
1961
|
e.sort((a, h) => a.rect.y - h.rect.y || a.rect.x - h.rect.x);
|
|
1886
1962
|
const t = [];
|
|
1887
1963
|
let s = [], i = -1 / 0, r = 0, o = 1 / 0, c = -1 / 0;
|
|
1888
1964
|
const l = () => {
|
|
1889
|
-
s.length !== 0 && t.push(new
|
|
1890
|
-
|
|
1965
|
+
s.length !== 0 && t.push(new Dn(
|
|
1966
|
+
B.fromPointPoint(o, i, c, i + r),
|
|
1891
1967
|
s
|
|
1892
1968
|
));
|
|
1893
1969
|
};
|
|
@@ -1895,9 +1971,9 @@ function An(n) {
|
|
|
1895
1971
|
const h = a.rect, g = Math.min(i + r, h.y + h.height) - Math.max(i, h.y);
|
|
1896
1972
|
s.length > 0 && g > Math.min(r, h.height) / 2 ? (s.push(a), r = Math.max(r, h.y + h.height - i), o = Math.min(o, h.left), c = Math.max(c, h.right)) : (l(), s = [a], i = h.y, r = h.height, o = h.left, c = h.right);
|
|
1897
1973
|
}
|
|
1898
|
-
return l(), new
|
|
1974
|
+
return l(), new ke(t);
|
|
1899
1975
|
}
|
|
1900
|
-
function
|
|
1976
|
+
function Vn(n, e) {
|
|
1901
1977
|
const t = [], s = document.createRange();
|
|
1902
1978
|
for (let i = 0; i < e.length - 1; i++) {
|
|
1903
1979
|
const r = e[i + 1].y;
|
|
@@ -1910,7 +1986,7 @@ function $n(n, e) {
|
|
|
1910
1986
|
}
|
|
1911
1987
|
return t;
|
|
1912
1988
|
}
|
|
1913
|
-
function
|
|
1989
|
+
function Pn(n) {
|
|
1914
1990
|
const e = n.parentElement;
|
|
1915
1991
|
if (!e)
|
|
1916
1992
|
return 0;
|
|
@@ -1918,56 +1994,56 @@ function Fn(n) {
|
|
|
1918
1994
|
let s = parseFloat(t.lineHeight);
|
|
1919
1995
|
return isFinite(s) || (s = parseFloat(t.fontSize) * 1.2), s;
|
|
1920
1996
|
}
|
|
1921
|
-
function
|
|
1997
|
+
function tt(n, e) {
|
|
1922
1998
|
if (e <= n.height)
|
|
1923
|
-
return
|
|
1999
|
+
return B.fromPointSize(n.x, n.y, n.width, n.height);
|
|
1924
2000
|
const t = (e - n.height) / 2;
|
|
1925
|
-
return
|
|
2001
|
+
return B.fromPointSize(n.x, n.y - t, n.width, e);
|
|
1926
2002
|
}
|
|
1927
|
-
function
|
|
2003
|
+
function Kn(n, e, t) {
|
|
1928
2004
|
const s = e.dom;
|
|
1929
2005
|
if (s.nodeType !== 1)
|
|
1930
2006
|
return;
|
|
1931
2007
|
const i = s.getBoundingClientRect();
|
|
1932
|
-
i.width === 0 && i.height === 0 || n.push(new
|
|
1933
|
-
|
|
1934
|
-
|
|
2008
|
+
i.width === 0 && i.height === 0 || n.push(new Be(
|
|
2009
|
+
w.fromTo(t, t + e.sourceLength),
|
|
2010
|
+
B.fromPointSize(i.x, i.y, i.width, i.height)
|
|
1935
2011
|
));
|
|
1936
2012
|
}
|
|
1937
|
-
class
|
|
1938
|
-
measurements =
|
|
2013
|
+
class Hn {
|
|
2014
|
+
measurements = U(this, []);
|
|
1939
2015
|
/**
|
|
1940
2016
|
* Concatenated visual line map across all mounted blocks. Lines are
|
|
1941
2017
|
* left in DOM (client-coordinate) y order — each per-block map already
|
|
1942
2018
|
* uses absolute client coordinates from `getClientRects()`, so the
|
|
1943
2019
|
* concatenation is well-formed without re-sorting.
|
|
1944
2020
|
*/
|
|
1945
|
-
visualLineMap =
|
|
2021
|
+
visualLineMap = V(this, (e) => {
|
|
1946
2022
|
const s = e.readObservable(this.measurements).flatMap((i) => i.visualLineMap?.lines ?? []);
|
|
1947
|
-
return new
|
|
2023
|
+
return new ke(s);
|
|
1948
2024
|
});
|
|
1949
2025
|
}
|
|
1950
2026
|
function Vt(n, e, t, s) {
|
|
1951
2027
|
let i = s === "right" ? t + 1 : t - 1, r = 0;
|
|
1952
2028
|
for (const o of n.children) {
|
|
1953
2029
|
if (n.blocks.includes(o)) {
|
|
1954
|
-
const l = o, a =
|
|
1955
|
-
i =
|
|
2030
|
+
const l = o, a = Wn(l, l === e, t - r);
|
|
2031
|
+
i = qn(i, r, a, s);
|
|
1956
2032
|
}
|
|
1957
2033
|
r += o.length;
|
|
1958
2034
|
}
|
|
1959
2035
|
return s === "right" ? Math.min(i, n.length) : Math.max(i, 0);
|
|
1960
2036
|
}
|
|
1961
|
-
function
|
|
2037
|
+
function Wn(n, e, t) {
|
|
1962
2038
|
if (!e)
|
|
1963
|
-
return
|
|
2039
|
+
return Gn(n);
|
|
1964
2040
|
if (n.kind === "list") {
|
|
1965
2041
|
const s = Pt(n, t);
|
|
1966
|
-
return
|
|
2042
|
+
return jn(n, s);
|
|
1967
2043
|
}
|
|
1968
2044
|
return [];
|
|
1969
2045
|
}
|
|
1970
|
-
function
|
|
2046
|
+
function qn(n, e, t, s) {
|
|
1971
2047
|
if (s === "right")
|
|
1972
2048
|
for (const i of t) {
|
|
1973
2049
|
const r = n - e;
|
|
@@ -1993,26 +2069,26 @@ function Pt(n, e) {
|
|
|
1993
2069
|
}
|
|
1994
2070
|
return s;
|
|
1995
2071
|
}
|
|
1996
|
-
function
|
|
2072
|
+
function jn(n, e) {
|
|
1997
2073
|
const t = [];
|
|
1998
2074
|
let s = 0;
|
|
1999
2075
|
for (const i of n.children) {
|
|
2000
2076
|
const r = n.items.indexOf(i);
|
|
2001
2077
|
if (r >= 0 && r !== e) {
|
|
2002
2078
|
const o = n.items[r];
|
|
2003
|
-
|
|
2079
|
+
qe(o, s, t);
|
|
2004
2080
|
}
|
|
2005
2081
|
s += i.length;
|
|
2006
2082
|
}
|
|
2007
2083
|
return t.sort((i, r) => i.start - r.start), t;
|
|
2008
2084
|
}
|
|
2009
|
-
function
|
|
2085
|
+
function Gn(n) {
|
|
2010
2086
|
const e = [];
|
|
2011
|
-
return
|
|
2087
|
+
return qe(n, 0, e), e.sort((t, s) => t.start - s.start), e;
|
|
2012
2088
|
}
|
|
2013
|
-
function
|
|
2089
|
+
function qe(n, e, t) {
|
|
2014
2090
|
if (n.children.length === 0) {
|
|
2015
|
-
n instanceof k && t.push(
|
|
2091
|
+
n instanceof k && t.push(w.ofStartAndLength(e, n.length));
|
|
2016
2092
|
return;
|
|
2017
2093
|
}
|
|
2018
2094
|
switch (n.kind) {
|
|
@@ -2020,143 +2096,143 @@ function Pe(n, e, t) {
|
|
|
2020
2096
|
case "mathBlock": {
|
|
2021
2097
|
let i = e;
|
|
2022
2098
|
for (const r of n.children)
|
|
2023
|
-
r instanceof k && (r.markerKind === "openFence" || r.markerKind === "closeFence") && t.push(
|
|
2099
|
+
r instanceof k && (r.markerKind === "openFence" || r.markerKind === "closeFence") && t.push(w.ofStartAndLength(i, r.length)), i += r.length;
|
|
2024
2100
|
return;
|
|
2025
2101
|
}
|
|
2026
2102
|
case "inlineCode":
|
|
2027
2103
|
case "inlineMath": {
|
|
2028
2104
|
let i = e;
|
|
2029
2105
|
for (const r of n.children)
|
|
2030
|
-
r instanceof k && (r.markerKind === "openMarker" || r.markerKind === "closeMarker") && t.push(
|
|
2106
|
+
r instanceof k && (r.markerKind === "openMarker" || r.markerKind === "closeMarker") && t.push(w.ofStartAndLength(i, r.length)), i += r.length;
|
|
2031
2107
|
return;
|
|
2032
2108
|
}
|
|
2033
2109
|
case "thematicBreak":
|
|
2034
2110
|
return;
|
|
2035
2111
|
case "image": {
|
|
2036
|
-
t.push(
|
|
2112
|
+
t.push(w.ofStartAndLength(e, n.length));
|
|
2037
2113
|
return;
|
|
2038
2114
|
}
|
|
2039
2115
|
}
|
|
2040
2116
|
let s = e;
|
|
2041
2117
|
for (const i of n.children)
|
|
2042
|
-
|
|
2118
|
+
qe(i, s, t), s += i.length;
|
|
2043
2119
|
}
|
|
2044
|
-
const
|
|
2045
|
-
`, n.selection.active - 1) + 1,
|
|
2120
|
+
const zn = (n) => n.selection.isCollapsed ? Math.min(n.selection.active + 1, n.text.length) : n.selection.range.endExclusive, Xn = (n) => n.selection.isCollapsed ? Math.max(n.selection.active - 1, 0) : n.selection.range.start, Qn = (n) => Math.min(n.selection.active + 1, n.text.length), Un = (n) => Math.max(n.selection.active - 1, 0), Yn = (n) => Rt(n.text, n.selection.active), nt = (n) => Nt(n.text, n.selection.active), Jn = (n) => n.text.lastIndexOf(`
|
|
2121
|
+
`, n.selection.active - 1) + 1, Zn = (n) => {
|
|
2046
2122
|
const e = n.text.indexOf(`
|
|
2047
2123
|
`, n.selection.active);
|
|
2048
2124
|
return e === -1 ? n.text.length : e;
|
|
2049
|
-
},
|
|
2125
|
+
}, es = () => 0, ts = (n) => n.text.length, st = (n) => {
|
|
2050
2126
|
const e = n.lineMap.lineIndexOfOffset(n.selection.active), t = n.desiredColumn ?? n.lineMap.xAtOffset(n.selection.active);
|
|
2051
2127
|
return e >= n.lineMap.lineCount - 1 ? { offset: n.selection.active, desiredColumn: t } : { offset: n.lineMap.offsetInLineAtX(e + 1, t), desiredColumn: t };
|
|
2052
|
-
},
|
|
2128
|
+
}, it = (n) => {
|
|
2053
2129
|
const e = n.lineMap.lineIndexOfOffset(n.selection.active), t = n.desiredColumn ?? n.lineMap.xAtOffset(n.selection.active);
|
|
2054
2130
|
return e <= 0 ? { offset: n.selection.active, desiredColumn: t } : { offset: n.lineMap.offsetInLineAtX(e - 1, t), desiredColumn: t };
|
|
2055
|
-
},
|
|
2131
|
+
}, rt = (n) => {
|
|
2056
2132
|
const e = n.selection;
|
|
2057
2133
|
if (!e.isCollapsed)
|
|
2058
2134
|
return {
|
|
2059
|
-
edit:
|
|
2135
|
+
edit: E.delete(e.range),
|
|
2060
2136
|
selection: x.collapsed(e.range.start)
|
|
2061
2137
|
};
|
|
2062
2138
|
if (e.active === 0)
|
|
2063
2139
|
return;
|
|
2064
|
-
const t = new
|
|
2140
|
+
const t = new w(Vt(n.document, n.activeBlock, e.active, "left"), e.active);
|
|
2065
2141
|
return {
|
|
2066
|
-
edit:
|
|
2142
|
+
edit: E.delete(t),
|
|
2067
2143
|
selection: x.collapsed(t.start)
|
|
2068
2144
|
};
|
|
2069
|
-
},
|
|
2145
|
+
}, ns = (n) => {
|
|
2070
2146
|
const e = n.selection;
|
|
2071
2147
|
if (!e.isCollapsed)
|
|
2072
2148
|
return {
|
|
2073
|
-
edit:
|
|
2149
|
+
edit: E.delete(e.range),
|
|
2074
2150
|
selection: x.collapsed(e.range.start)
|
|
2075
2151
|
};
|
|
2076
2152
|
if (e.active >= n.text.length)
|
|
2077
2153
|
return;
|
|
2078
|
-
const t = new
|
|
2154
|
+
const t = new w(e.active, Vt(n.document, n.activeBlock, e.active, "right"));
|
|
2079
2155
|
return {
|
|
2080
|
-
edit:
|
|
2156
|
+
edit: E.delete(t),
|
|
2081
2157
|
selection: x.collapsed(t.start)
|
|
2082
2158
|
};
|
|
2083
|
-
},
|
|
2159
|
+
}, ss = (n) => {
|
|
2084
2160
|
const e = n.selection;
|
|
2085
2161
|
if (!e.isCollapsed)
|
|
2086
2162
|
return {
|
|
2087
|
-
edit:
|
|
2163
|
+
edit: E.delete(e.range),
|
|
2088
2164
|
selection: x.collapsed(e.range.start)
|
|
2089
2165
|
};
|
|
2090
2166
|
if (e.active === 0)
|
|
2091
2167
|
return;
|
|
2092
|
-
const t =
|
|
2168
|
+
const t = Nt(n.text, e.active), s = new w(t, e.active);
|
|
2093
2169
|
return {
|
|
2094
|
-
edit:
|
|
2170
|
+
edit: E.delete(s),
|
|
2095
2171
|
selection: x.collapsed(t)
|
|
2096
2172
|
};
|
|
2097
|
-
},
|
|
2173
|
+
}, is = (n) => {
|
|
2098
2174
|
const e = n.selection;
|
|
2099
2175
|
if (!e.isCollapsed)
|
|
2100
2176
|
return {
|
|
2101
|
-
edit:
|
|
2177
|
+
edit: E.delete(e.range),
|
|
2102
2178
|
selection: x.collapsed(e.range.start)
|
|
2103
2179
|
};
|
|
2104
2180
|
if (e.active >= n.text.length)
|
|
2105
2181
|
return;
|
|
2106
|
-
const t =
|
|
2182
|
+
const t = Rt(n.text, e.active), s = new w(e.active, t);
|
|
2107
2183
|
return {
|
|
2108
|
-
edit:
|
|
2184
|
+
edit: E.delete(s),
|
|
2109
2185
|
selection: x.collapsed(e.active)
|
|
2110
2186
|
};
|
|
2111
2187
|
};
|
|
2112
|
-
function
|
|
2188
|
+
function rs(n) {
|
|
2113
2189
|
return (e) => {
|
|
2114
|
-
const t =
|
|
2190
|
+
const t = E.replace(e.selection.range, n), s = e.selection.range.start + n.length;
|
|
2115
2191
|
return {
|
|
2116
2192
|
edit: t,
|
|
2117
2193
|
selection: x.collapsed(s)
|
|
2118
2194
|
};
|
|
2119
2195
|
};
|
|
2120
2196
|
}
|
|
2121
|
-
const
|
|
2122
|
-
const e =
|
|
2197
|
+
const os = (n) => {
|
|
2198
|
+
const e = E.replace(n.selection.range, `
|
|
2123
2199
|
|
|
2124
2200
|
`), t = n.selection.range.start + 2;
|
|
2125
2201
|
return {
|
|
2126
2202
|
edit: e,
|
|
2127
2203
|
selection: x.collapsed(t)
|
|
2128
2204
|
};
|
|
2129
|
-
},
|
|
2130
|
-
const e =
|
|
2205
|
+
}, cs = (n) => {
|
|
2206
|
+
const e = E.replace(n.selection.range, `
|
|
2131
2207
|
`), t = n.selection.range.start + 1;
|
|
2132
2208
|
return {
|
|
2133
2209
|
edit: e,
|
|
2134
2210
|
selection: x.collapsed(t)
|
|
2135
2211
|
};
|
|
2136
|
-
},
|
|
2212
|
+
}, ls = (n) => {
|
|
2137
2213
|
const e = n.selection.range.start;
|
|
2138
2214
|
let t = 0;
|
|
2139
2215
|
for (; t < 2 && n.text[e - 1 - t] === " "; )
|
|
2140
2216
|
t++;
|
|
2141
2217
|
const i = " ".repeat(2 - t) + `
|
|
2142
|
-
`, r =
|
|
2218
|
+
`, r = E.replace(n.selection.range, i), o = e + i.length;
|
|
2143
2219
|
return {
|
|
2144
2220
|
edit: r,
|
|
2145
2221
|
selection: x.collapsed(o)
|
|
2146
2222
|
};
|
|
2147
|
-
},
|
|
2148
|
-
const t =
|
|
2223
|
+
}, as = (n) => new x(0, n.text.length), hs = (n, e) => {
|
|
2224
|
+
const t = dn(n.text, e);
|
|
2149
2225
|
return new x(t.start, t.end);
|
|
2150
2226
|
};
|
|
2151
|
-
function
|
|
2227
|
+
function ds(n, e) {
|
|
2152
2228
|
return new x(e.start, e.endExclusive);
|
|
2153
2229
|
}
|
|
2154
|
-
const
|
|
2155
|
-
class
|
|
2156
|
-
constructor(e, t, s =
|
|
2157
|
-
super(), this.ast = e, this.dom = t, this._children = s,
|
|
2230
|
+
const ot = /* @__PURE__ */ new WeakMap(), Ne = /* @__PURE__ */ new WeakMap();
|
|
2231
|
+
class ae extends le {
|
|
2232
|
+
constructor(e, t, s = us) {
|
|
2233
|
+
super(), this.ast = e, this.dom = t, this._children = s, ot.set(t, this);
|
|
2158
2234
|
for (const i of s)
|
|
2159
|
-
|
|
2235
|
+
Ne.set(i, this);
|
|
2160
2236
|
}
|
|
2161
2237
|
_children;
|
|
2162
2238
|
/** This node's view children (a mirror of `ast.children`). */
|
|
@@ -2177,7 +2253,7 @@ class ie extends te {
|
|
|
2177
2253
|
t.dispose();
|
|
2178
2254
|
this._children = e;
|
|
2179
2255
|
for (const t of e)
|
|
2180
|
-
|
|
2256
|
+
Ne.set(t, this);
|
|
2181
2257
|
}
|
|
2182
2258
|
dispose() {
|
|
2183
2259
|
for (const e of this._children)
|
|
@@ -2204,7 +2280,7 @@ class ie extends te {
|
|
|
2204
2280
|
}
|
|
2205
2281
|
/** The view node that rendered this node's parent, or `undefined` for a root. */
|
|
2206
2282
|
get parent() {
|
|
2207
|
-
return
|
|
2283
|
+
return Ne.get(this);
|
|
2208
2284
|
}
|
|
2209
2285
|
/**
|
|
2210
2286
|
* Closest view node owning `domNode`: the node itself if registered, else
|
|
@@ -2213,7 +2289,7 @@ class ie extends te {
|
|
|
2213
2289
|
*/
|
|
2214
2290
|
static forDom(e) {
|
|
2215
2291
|
for (let t = e; t; t = t.parentNode) {
|
|
2216
|
-
const s =
|
|
2292
|
+
const s = ot.get(t);
|
|
2217
2293
|
if (s)
|
|
2218
2294
|
return s;
|
|
2219
2295
|
}
|
|
@@ -2248,7 +2324,7 @@ class ie extends te {
|
|
|
2248
2324
|
* edge by x).
|
|
2249
2325
|
*/
|
|
2250
2326
|
getLocalSourceRange(e) {
|
|
2251
|
-
return this.dom === e.node && this.dom.nodeType === 3 ?
|
|
2327
|
+
return this.dom === e.node && this.dom.nodeType === 3 ? w.emptyAt(Math.max(0, Math.min(e.offset, this.sourceLength))) : w.emptyAt(0);
|
|
2252
2328
|
}
|
|
2253
2329
|
/**
|
|
2254
2330
|
* DOM hit (any node + offset within it) → source offset relative to THIS
|
|
@@ -2259,7 +2335,7 @@ class ie extends te {
|
|
|
2259
2335
|
* until it reaches this node.
|
|
2260
2336
|
*/
|
|
2261
2337
|
resolveSource(e) {
|
|
2262
|
-
let t =
|
|
2338
|
+
let t = ae.forDom(e.node);
|
|
2263
2339
|
if (!t)
|
|
2264
2340
|
return;
|
|
2265
2341
|
let s = t.getLocalSourceRange(e);
|
|
@@ -2303,8 +2379,8 @@ class ie extends te {
|
|
|
2303
2379
|
i.forEachTextLeaf(s, t), s += i.sourceLength;
|
|
2304
2380
|
}
|
|
2305
2381
|
}
|
|
2306
|
-
const
|
|
2307
|
-
class
|
|
2382
|
+
const us = [];
|
|
2383
|
+
class T extends ae {
|
|
2308
2384
|
constructor(e, t, s) {
|
|
2309
2385
|
super(e.ast, t, s), this.data = e;
|
|
2310
2386
|
}
|
|
@@ -2333,75 +2409,75 @@ class M extends ie {
|
|
|
2333
2409
|
recordMeasuredHeight(e) {
|
|
2334
2410
|
}
|
|
2335
2411
|
}
|
|
2336
|
-
function
|
|
2337
|
-
if (t instanceof
|
|
2412
|
+
function Y(n, e, t) {
|
|
2413
|
+
if (t instanceof T) {
|
|
2338
2414
|
if (t.canReuse(n))
|
|
2339
2415
|
return t;
|
|
2340
2416
|
} else if (t?.ast === n.ast)
|
|
2341
2417
|
return t;
|
|
2342
2418
|
switch (n.kind) {
|
|
2343
2419
|
case "text":
|
|
2344
|
-
return
|
|
2420
|
+
return ms(n, L(t, je));
|
|
2345
2421
|
case "marker":
|
|
2346
|
-
return n.ast.markerKind === "hardBreak" ? new
|
|
2422
|
+
return n.ast.markerKind === "hardBreak" ? new at(n, L(t, at)) : new lt(n, L(t, lt));
|
|
2347
2423
|
case "glue":
|
|
2348
|
-
return new
|
|
2424
|
+
return new Ce(n, L(t, Ce));
|
|
2349
2425
|
case "heading":
|
|
2350
|
-
return new
|
|
2426
|
+
return new ht(n, e, L(t, ht));
|
|
2351
2427
|
case "paragraph":
|
|
2352
|
-
return new
|
|
2428
|
+
return new W(n, "p", "md-block md-paragraph", e, Q(t));
|
|
2353
2429
|
case "codeBlock":
|
|
2354
|
-
return new
|
|
2430
|
+
return new Ge(n, e, t);
|
|
2355
2431
|
case "mathBlock":
|
|
2356
|
-
return new
|
|
2432
|
+
return new ft(n, e, L(t, ft));
|
|
2357
2433
|
case "thematicBreak":
|
|
2358
|
-
return new
|
|
2434
|
+
return new dt(n, e, L(t, dt));
|
|
2359
2435
|
case "blockQuote":
|
|
2360
|
-
return new
|
|
2436
|
+
return new W(n, "blockquote", "md-block md-blockquote", e, Q(t));
|
|
2361
2437
|
case "list":
|
|
2362
|
-
return new
|
|
2438
|
+
return new gt(n, e, L(t, gt));
|
|
2363
2439
|
case "listItem":
|
|
2364
|
-
return new
|
|
2440
|
+
return new pt(n, e, L(t, pt));
|
|
2365
2441
|
case "table":
|
|
2366
|
-
return new
|
|
2442
|
+
return new W(n, "table", "md-block md-table", e, Q(t));
|
|
2367
2443
|
case "tableRow":
|
|
2368
|
-
return new
|
|
2444
|
+
return new mt(n, e, L(t, mt));
|
|
2369
2445
|
case "tableCell":
|
|
2370
|
-
return new
|
|
2446
|
+
return new W(n, "td", "", e, Q(t));
|
|
2371
2447
|
case "strong":
|
|
2372
|
-
return new
|
|
2448
|
+
return new W(n, "strong", "", e, Q(t));
|
|
2373
2449
|
case "emphasis":
|
|
2374
|
-
return new
|
|
2450
|
+
return new W(n, "em", "", e, Q(t));
|
|
2375
2451
|
case "strikethrough":
|
|
2376
|
-
return new
|
|
2452
|
+
return new W(n, "del", "", e, Q(t));
|
|
2377
2453
|
case "inlineCode":
|
|
2378
|
-
return new
|
|
2454
|
+
return new wt(n, e, L(t, wt));
|
|
2379
2455
|
case "inlineMath":
|
|
2380
|
-
return new _t(n, e,
|
|
2456
|
+
return new _t(n, e, L(t, _t));
|
|
2381
2457
|
case "link":
|
|
2382
|
-
return new
|
|
2458
|
+
return new kt(n, e, L(t, kt));
|
|
2383
2459
|
case "image":
|
|
2384
|
-
return new
|
|
2460
|
+
return new xt(n, e, L(t, xt));
|
|
2385
2461
|
case "document":
|
|
2386
|
-
return new
|
|
2462
|
+
return new W(n, "div", "", e, Q(t));
|
|
2387
2463
|
}
|
|
2388
2464
|
}
|
|
2389
|
-
function
|
|
2465
|
+
function L(n, e) {
|
|
2390
2466
|
return n instanceof e ? n : void 0;
|
|
2391
2467
|
}
|
|
2392
|
-
function
|
|
2393
|
-
return n instanceof
|
|
2468
|
+
function Q(n) {
|
|
2469
|
+
return n instanceof W ? n : void 0;
|
|
2394
2470
|
}
|
|
2395
|
-
function
|
|
2396
|
-
const { paired: i, unused: r } =
|
|
2471
|
+
function X(n, e, t, s) {
|
|
2472
|
+
const { paired: i, unused: r } = ze(e, t ?? S), o = e.map((c) => s(c, i.get(c)));
|
|
2397
2473
|
for (const c of r)
|
|
2398
2474
|
c.dispose();
|
|
2399
|
-
return
|
|
2475
|
+
return fs(n, o), o;
|
|
2400
2476
|
}
|
|
2401
|
-
function
|
|
2402
|
-
|
|
2477
|
+
function fs(n, e) {
|
|
2478
|
+
fe(n, e.map((t) => t.mountNode));
|
|
2403
2479
|
}
|
|
2404
|
-
function
|
|
2480
|
+
function fe(n, e) {
|
|
2405
2481
|
let t = n.firstChild, s = 0;
|
|
2406
2482
|
for (; s < e.length && t === e[s]; s++)
|
|
2407
2483
|
t = t.nextSibling;
|
|
@@ -2416,18 +2492,18 @@ function ae(n, e) {
|
|
|
2416
2492
|
}
|
|
2417
2493
|
}
|
|
2418
2494
|
}
|
|
2419
|
-
function
|
|
2420
|
-
return (e, t) =>
|
|
2495
|
+
function se(n) {
|
|
2496
|
+
return (e, t) => Y(e, n, t);
|
|
2421
2497
|
}
|
|
2422
2498
|
function Kt(n) {
|
|
2423
|
-
return (e, t) => e.kind === "marker" && e.ast.markerKind === "content" ? new
|
|
2499
|
+
return (e, t) => e.kind === "marker" && e.ast.markerKind === "content" ? new je(e, document.createTextNode(e.ast.content)) : Y(e, n, t);
|
|
2424
2500
|
}
|
|
2425
|
-
const
|
|
2426
|
-
function
|
|
2427
|
-
return "content" in n ? n.content :
|
|
2501
|
+
const S = [];
|
|
2502
|
+
function gs(n) {
|
|
2503
|
+
return "content" in n ? n.content : ps;
|
|
2428
2504
|
}
|
|
2429
|
-
const
|
|
2430
|
-
function
|
|
2505
|
+
const ps = [];
|
|
2506
|
+
function ms(n, e) {
|
|
2431
2507
|
const t = n.ast.content, s = {
|
|
2432
2508
|
leftBoundary: n.leftWordBoundary,
|
|
2433
2509
|
rightBoundary: n.rightWordBoundary,
|
|
@@ -2436,19 +2512,19 @@ function gs(n, e) {
|
|
|
2436
2512
|
if (n.showWhitespace && Wt(t, s)) {
|
|
2437
2513
|
const o = document.createElement("span");
|
|
2438
2514
|
o.className = "md-text";
|
|
2439
|
-
const c =
|
|
2440
|
-
return new
|
|
2515
|
+
const c = Me(o, t, s, n.ast);
|
|
2516
|
+
return new T(n, o, c);
|
|
2441
2517
|
}
|
|
2442
2518
|
const i = e?.dom, r = i instanceof globalThis.Text && i.data === t ? i : document.createTextNode(t);
|
|
2443
|
-
return new
|
|
2519
|
+
return new je(n, r);
|
|
2444
2520
|
}
|
|
2445
|
-
function
|
|
2521
|
+
function ct(n) {
|
|
2446
2522
|
return n === " " || n === " " || n === `
|
|
2447
2523
|
` || n === "\r";
|
|
2448
2524
|
}
|
|
2449
|
-
const
|
|
2450
|
-
function
|
|
2451
|
-
const s = e > 0 ? !
|
|
2525
|
+
const ws = { leftBoundary: !1, rightBoundary: !1, decorateNewline: !1 }, _s = { leftBoundary: !1, rightBoundary: !1, decorateNewline: !1 };
|
|
2526
|
+
function ks(n, e, t) {
|
|
2527
|
+
const s = e > 0 ? !ct(n[e - 1]) : t.leftBoundary, i = e < n.length - 1 ? !ct(n[e + 1]) : t.rightBoundary;
|
|
2452
2528
|
return s && i;
|
|
2453
2529
|
}
|
|
2454
2530
|
function Ht(n, e, t) {
|
|
@@ -2458,16 +2534,19 @@ function Ht(n, e, t) {
|
|
|
2458
2534
|
if (s === `
|
|
2459
2535
|
` || s === "\r")
|
|
2460
2536
|
return t.decorateNewline ? "md-ws-newline" : void 0;
|
|
2461
|
-
if (s === " " && !
|
|
2537
|
+
if (s === " " && !ks(n, e, t))
|
|
2462
2538
|
return "md-ws-space";
|
|
2463
2539
|
}
|
|
2464
2540
|
function Wt(n, e) {
|
|
2465
|
-
for (let t = 0; t < n.length; t++)
|
|
2466
|
-
|
|
2541
|
+
for (let t = 0; t < n.length; t++) {
|
|
2542
|
+
const s = n[t];
|
|
2543
|
+
if (e.newlineGlyph && (s === `
|
|
2544
|
+
` || s === "\r") || Ht(n, t, e) !== void 0)
|
|
2467
2545
|
return !0;
|
|
2546
|
+
}
|
|
2468
2547
|
return !1;
|
|
2469
2548
|
}
|
|
2470
|
-
function
|
|
2549
|
+
function xs(n, e) {
|
|
2471
2550
|
const t = [];
|
|
2472
2551
|
let s = -1;
|
|
2473
2552
|
const i = (c) => {
|
|
@@ -2495,49 +2574,49 @@ function _s(n, e) {
|
|
|
2495
2574
|
}
|
|
2496
2575
|
return i(n.length), t;
|
|
2497
2576
|
}
|
|
2498
|
-
function
|
|
2577
|
+
function Me(n, e, t, s) {
|
|
2499
2578
|
const i = [];
|
|
2500
|
-
for (const r of
|
|
2579
|
+
for (const r of xs(e, t)) {
|
|
2501
2580
|
const o = document.createTextNode(r.display ?? r.text);
|
|
2502
2581
|
if (r.cls) {
|
|
2503
2582
|
const c = document.createElement("span");
|
|
2504
2583
|
c.className = r.cls, c.appendChild(o), n.appendChild(c);
|
|
2505
2584
|
} else
|
|
2506
2585
|
n.appendChild(o);
|
|
2507
|
-
i.push(new
|
|
2586
|
+
i.push(new G(s, o, S, r.text.length));
|
|
2508
2587
|
}
|
|
2509
2588
|
return i;
|
|
2510
2589
|
}
|
|
2511
|
-
class
|
|
2590
|
+
class je extends T {
|
|
2512
2591
|
constructor(e, t) {
|
|
2513
|
-
super(e, t,
|
|
2592
|
+
super(e, t, S);
|
|
2514
2593
|
}
|
|
2515
2594
|
}
|
|
2516
|
-
class
|
|
2595
|
+
class G extends ae {
|
|
2517
2596
|
_sourceLength;
|
|
2518
|
-
constructor(e, t, s =
|
|
2597
|
+
constructor(e, t, s = S, i = e.length) {
|
|
2519
2598
|
super(e, t, s), this._sourceLength = i;
|
|
2520
2599
|
}
|
|
2521
2600
|
get sourceLength() {
|
|
2522
2601
|
return this._sourceLength;
|
|
2523
2602
|
}
|
|
2524
2603
|
}
|
|
2525
|
-
class
|
|
2604
|
+
class lt extends T {
|
|
2526
2605
|
_span;
|
|
2527
2606
|
constructor(e, t) {
|
|
2528
2607
|
const s = e.ast, i = `md-marker md-marker-${s.markerKind}`, r = t && t.dom instanceof globalThis.Text && t.dom.data === s.content, o = r ? t._span : document.createElement("span");
|
|
2529
2608
|
o.className = e.visible ? i : `${i} md-marker-hidden`;
|
|
2530
2609
|
const c = r ? t.dom : document.createTextNode(s.content);
|
|
2531
|
-
r || o.appendChild(c), super(e, c,
|
|
2610
|
+
r || o.appendChild(c), super(e, c, S), this._span = o;
|
|
2532
2611
|
}
|
|
2533
2612
|
get mountNode() {
|
|
2534
2613
|
return this._span;
|
|
2535
2614
|
}
|
|
2536
2615
|
}
|
|
2537
|
-
class
|
|
2616
|
+
class Ce extends T {
|
|
2538
2617
|
_span;
|
|
2539
2618
|
constructor(e, t) {
|
|
2540
|
-
const s =
|
|
2619
|
+
const s = Ce._build(e, t);
|
|
2541
2620
|
super(e, s.dom, s.children), this._span = s.span;
|
|
2542
2621
|
}
|
|
2543
2622
|
get mountNode() {
|
|
@@ -2548,75 +2627,69 @@ class be extends M {
|
|
|
2548
2627
|
leftBoundary: !1,
|
|
2549
2628
|
rightBoundary: !1,
|
|
2550
2629
|
decorateNewline: e.decorateNewline,
|
|
2551
|
-
|
|
2552
|
-
// of a block's last line (inline flow, `decorateNewline`). The hostless
|
|
2553
|
-
// document-level gap (trailing a leaf thematic break, or leading the
|
|
2554
|
-
// first block) sits between block-level siblings where the break is
|
|
2555
|
-
// already visible, so it draws no glyph and simply collapses — making
|
|
2556
|
-
// e.g. `---\n\n…` and `---\n…` render identically.
|
|
2557
|
-
newlineGlyph: (s.glueKind === "blockGap" || r) && e.decorateNewline,
|
|
2630
|
+
newlineGlyph: s.glueKind === "blockGap" || r,
|
|
2558
2631
|
breakGlyphClass: r ? "md-ws-blockbreak-glyph" : void 0
|
|
2559
2632
|
};
|
|
2560
2633
|
if (e.visible && Wt(s.content, o)) {
|
|
2561
2634
|
const g = document.createElement("span");
|
|
2562
2635
|
g.className = i;
|
|
2563
|
-
const
|
|
2564
|
-
return { span: g, dom: g, children:
|
|
2636
|
+
const d = Me(g, s.content, o, s);
|
|
2637
|
+
return { span: g, dom: g, children: d };
|
|
2565
2638
|
}
|
|
2566
2639
|
const l = t && t.dom instanceof globalThis.Text && t.dom.data === s.content && t.children.length === 0, a = l ? t._span : document.createElement("span");
|
|
2567
2640
|
a.className = e.visible ? i : `${i} md-glue-hidden`;
|
|
2568
2641
|
const h = l ? t.dom : document.createTextNode(s.content);
|
|
2569
|
-
return l || a.appendChild(h), { span: a, dom: h, children:
|
|
2642
|
+
return l || a.appendChild(h), { span: a, dom: h, children: S };
|
|
2570
2643
|
}
|
|
2571
2644
|
}
|
|
2572
|
-
class
|
|
2645
|
+
class at extends T {
|
|
2573
2646
|
_span;
|
|
2574
2647
|
constructor(e, t) {
|
|
2575
2648
|
const s = e.ast.content, i = document.createElement("span");
|
|
2576
2649
|
i.className = "md-hardbreak";
|
|
2577
2650
|
const r = document.createElement("span");
|
|
2578
2651
|
r.className = e.visible ? "md-hardbreak-src" : "md-hardbreak-src md-hardbreak-src-hidden";
|
|
2579
|
-
const o = e.visible ?
|
|
2652
|
+
const o = e.visible ? Me(r, s, ws, e.ast) : vs(r, s, e.ast);
|
|
2580
2653
|
i.appendChild(r), i.appendChild(document.createElement("br")), super(e, i, o), this._span = i;
|
|
2581
2654
|
}
|
|
2582
2655
|
get mountNode() {
|
|
2583
2656
|
return this._span;
|
|
2584
2657
|
}
|
|
2585
2658
|
}
|
|
2586
|
-
function
|
|
2659
|
+
function vs(n, e, t) {
|
|
2587
2660
|
const s = document.createTextNode(e);
|
|
2588
|
-
return n.appendChild(s), [new
|
|
2661
|
+
return n.appendChild(s), [new G(t, s)];
|
|
2589
2662
|
}
|
|
2590
|
-
class
|
|
2663
|
+
class W extends T {
|
|
2591
2664
|
constructor(e, t, s, i, r) {
|
|
2592
2665
|
const o = r?.element ?? document.createElement(t);
|
|
2593
2666
|
!r && s && (o.className = s);
|
|
2594
|
-
const c =
|
|
2667
|
+
const c = X(o, gs(e), r?.children, se(i));
|
|
2595
2668
|
super(e, o, c);
|
|
2596
2669
|
}
|
|
2597
2670
|
}
|
|
2598
|
-
class
|
|
2671
|
+
class ht extends T {
|
|
2599
2672
|
constructor(e, t, s) {
|
|
2600
2673
|
const i = s && s.element.tagName === `H${e.ast.level}`, r = i ? s.element : document.createElement(`h${e.ast.level}`);
|
|
2601
2674
|
i || (r.className = "md-block md-heading");
|
|
2602
|
-
const o =
|
|
2675
|
+
const o = X(r, e.content, s?.children, se(t));
|
|
2603
2676
|
super(e, r, o);
|
|
2604
2677
|
}
|
|
2605
2678
|
}
|
|
2606
|
-
class
|
|
2679
|
+
class dt extends T {
|
|
2607
2680
|
constructor(e, t, s) {
|
|
2608
2681
|
if (e.showMarkup) {
|
|
2609
2682
|
const r = s?.dom instanceof HTMLDivElement ? s : void 0, o = r?.element ?? document.createElement("div");
|
|
2610
2683
|
r || (o.className = "md-block md-thematic-break-source");
|
|
2611
|
-
const c =
|
|
2684
|
+
const c = X(o, e.content, r?.children, se(t));
|
|
2612
2685
|
super(e, o, c);
|
|
2613
2686
|
return;
|
|
2614
2687
|
}
|
|
2615
2688
|
const i = document.createElement("hr");
|
|
2616
|
-
i.className = "md-block md-thematic-break", super(e, i,
|
|
2689
|
+
i.className = "md-block md-thematic-break", super(e, i, S);
|
|
2617
2690
|
}
|
|
2618
2691
|
}
|
|
2619
|
-
class
|
|
2692
|
+
class Ge extends T {
|
|
2620
2693
|
_session;
|
|
2621
2694
|
/**
|
|
2622
2695
|
* Subscription that re-tokenises the rendered `<code>` in place whenever the
|
|
@@ -2629,7 +2702,7 @@ class We extends M {
|
|
|
2629
2702
|
*/
|
|
2630
2703
|
_snapshotSub;
|
|
2631
2704
|
constructor(e, t, s) {
|
|
2632
|
-
const i = e.ast, r = i.code?.content ?? "", o = !e.showMarkup && i.language && t?.renderCustomCodeBlock ? t.renderCustomCodeBlock(i.language, r) ?? void 0 : void 0, c = t?.syntaxHighlighter, l = s instanceof
|
|
2705
|
+
const i = e.ast, r = i.code?.content ?? "", o = !e.showMarkup && i.language && t?.renderCustomCodeBlock ? t.renderCustomCodeBlock(i.language, r) ?? void 0 : void 0, c = t?.syntaxHighlighter, l = s instanceof Ge ? s : void 0;
|
|
2633
2706
|
let a;
|
|
2634
2707
|
if (!o && c && i.language) {
|
|
2635
2708
|
if (l?._session && i === l.ast)
|
|
@@ -2641,43 +2714,71 @@ class We extends M {
|
|
|
2641
2714
|
a || (a = c.create(i.language, r));
|
|
2642
2715
|
}
|
|
2643
2716
|
l?._session && (l._session.dispose(), l._session = void 0), l?._snapshotSub?.dispose(), l && (l._snapshotSub = void 0);
|
|
2644
|
-
const h = a ? a.snapshot.get().getTokens(
|
|
2645
|
-
let g,
|
|
2717
|
+
const h = a ? a.snapshot.get().getTokens(w.ofLength(r.length)).tokens : void 0;
|
|
2718
|
+
let g, d, u;
|
|
2646
2719
|
if (o)
|
|
2647
|
-
o.classList.add("md-block", "md-code-block"), g = o,
|
|
2648
|
-
else {
|
|
2720
|
+
o.classList.add("md-block", "md-code-block"), g = o, d = S;
|
|
2721
|
+
else if (i.openFence) {
|
|
2649
2722
|
const f = document.createElement("pre");
|
|
2650
2723
|
f.className = "md-block md-code-block";
|
|
2651
2724
|
const p = [];
|
|
2652
2725
|
for (const m of e.content)
|
|
2653
2726
|
if (m.ast === i.code) {
|
|
2654
|
-
const
|
|
2655
|
-
i.language && (
|
|
2656
|
-
const v =
|
|
2657
|
-
v instanceof qt && (
|
|
2727
|
+
const _ = document.createElement("code");
|
|
2728
|
+
i.language && (_.className = `language-${CSS.escape(i.language)}`);
|
|
2729
|
+
const v = bs(i.code, r, _, h);
|
|
2730
|
+
v instanceof qt && (u = v), p.push(v), f.appendChild(_);
|
|
2658
2731
|
} else {
|
|
2659
|
-
const
|
|
2660
|
-
f.appendChild(
|
|
2732
|
+
const _ = Y(m, t, void 0);
|
|
2733
|
+
f.appendChild(_.mountNode), p.push(_);
|
|
2661
2734
|
}
|
|
2662
|
-
g = f,
|
|
2735
|
+
g = f, d = p;
|
|
2736
|
+
} else {
|
|
2737
|
+
const f = document.createElement("pre");
|
|
2738
|
+
f.className = "md-block md-code-block";
|
|
2739
|
+
const p = document.createElement("code");
|
|
2740
|
+
f.appendChild(p);
|
|
2741
|
+
const m = [];
|
|
2742
|
+
for (const _ of e.content) {
|
|
2743
|
+
const v = _.ast;
|
|
2744
|
+
if (_.kind === "marker" && v.markerKind === "content") {
|
|
2745
|
+
const y = document.createTextNode(v.content);
|
|
2746
|
+
p.appendChild(y), m.push(new G(v, y));
|
|
2747
|
+
} else if (_.kind === "marker" && v.markerKind === "codeIndent") {
|
|
2748
|
+
const y = v;
|
|
2749
|
+
if (_.visible) {
|
|
2750
|
+
const M = document.createElement("span");
|
|
2751
|
+
M.className = "md-marker md-marker-codeIndent";
|
|
2752
|
+
const A = Me(M, y.content, _s, y);
|
|
2753
|
+
p.appendChild(M), m.push(new G(y, M, A));
|
|
2754
|
+
} else {
|
|
2755
|
+
const M = Y(_, t, void 0);
|
|
2756
|
+
p.appendChild(M.mountNode), m.push(M);
|
|
2757
|
+
}
|
|
2758
|
+
} else {
|
|
2759
|
+
const y = Y(_, t, void 0);
|
|
2760
|
+
f.appendChild(y.mountNode), m.push(y);
|
|
2761
|
+
}
|
|
2762
|
+
}
|
|
2763
|
+
g = f, d = m;
|
|
2663
2764
|
}
|
|
2664
|
-
super(e, g,
|
|
2765
|
+
super(e, g, d), this._session = a, a && u && (this._snapshotSub = an(a.snapshot, () => {
|
|
2665
2766
|
const f = a.snapshot.get();
|
|
2666
|
-
|
|
2767
|
+
u.refresh(r, f.getTokens(w.ofLength(r.length)).tokens);
|
|
2667
2768
|
}));
|
|
2668
2769
|
}
|
|
2669
2770
|
dispose() {
|
|
2670
2771
|
this._snapshotSub?.dispose(), this._snapshotSub = void 0, this._session?.dispose(), this._session = void 0, super.dispose();
|
|
2671
2772
|
}
|
|
2672
2773
|
}
|
|
2673
|
-
function
|
|
2774
|
+
function bs(n, e, t, s) {
|
|
2674
2775
|
if (!s) {
|
|
2675
2776
|
const i = document.createTextNode(e);
|
|
2676
|
-
return t.appendChild(i), new
|
|
2777
|
+
return t.appendChild(i), new G(n, i);
|
|
2677
2778
|
}
|
|
2678
2779
|
return new qt(n, t, e, s);
|
|
2679
2780
|
}
|
|
2680
|
-
class qt extends
|
|
2781
|
+
class qt extends ae {
|
|
2681
2782
|
constructor(e, t, s, i) {
|
|
2682
2783
|
super(e, t, ut(e, t, s, i));
|
|
2683
2784
|
}
|
|
@@ -2701,7 +2802,7 @@ function ut(n, e, t, s) {
|
|
|
2701
2802
|
a.appendChild(l), e.appendChild(a);
|
|
2702
2803
|
} else
|
|
2703
2804
|
e.appendChild(l);
|
|
2704
|
-
i.push(new
|
|
2805
|
+
i.push(new G(n, l, S, c.length));
|
|
2705
2806
|
}
|
|
2706
2807
|
return i;
|
|
2707
2808
|
}
|
|
@@ -2718,13 +2819,13 @@ function Gt(n, e, t) {
|
|
|
2718
2819
|
const s = e.filter((c) => c.length > 0 && c.start >= 0 && c.start + c.length <= t).slice().sort((c, l) => c.start - l.start), i = [];
|
|
2719
2820
|
let r = 0;
|
|
2720
2821
|
const o = (c) => {
|
|
2721
|
-
c > 0 && i.push(new
|
|
2822
|
+
c > 0 && i.push(new G(n, document.createTextNode(""), S, c));
|
|
2722
2823
|
};
|
|
2723
2824
|
for (const c of s)
|
|
2724
|
-
c.start < r || (o(c.start - r), i.push(new
|
|
2825
|
+
c.start < r || (o(c.start - r), i.push(new G(n, c.dom, S, c.length)), r = c.start + c.length);
|
|
2725
2826
|
return o(t - r), i;
|
|
2726
2827
|
}
|
|
2727
|
-
class
|
|
2828
|
+
class ft extends T {
|
|
2728
2829
|
/**
|
|
2729
2830
|
* The rendered (inactive, KaTeX) height in px, measured after mount and
|
|
2730
2831
|
* carried forward across rebuilds via `previous`. When the block becomes
|
|
@@ -2741,11 +2842,11 @@ class dt extends M {
|
|
|
2741
2842
|
const h = [];
|
|
2742
2843
|
for (const g of e.content)
|
|
2743
2844
|
if (g.ast === i.code) {
|
|
2744
|
-
const
|
|
2745
|
-
|
|
2845
|
+
const d = document.createElement("code"), u = document.createTextNode(i.code.content);
|
|
2846
|
+
d.appendChild(u), a.appendChild(d), h.push(new G(i.code, u));
|
|
2746
2847
|
} else {
|
|
2747
|
-
const
|
|
2748
|
-
a.appendChild(
|
|
2848
|
+
const d = Y(g, t, void 0);
|
|
2849
|
+
a.appendChild(d.mountNode), h.push(d);
|
|
2749
2850
|
}
|
|
2750
2851
|
super(e, a, h), this._renderedHeight = r;
|
|
2751
2852
|
return;
|
|
@@ -2764,29 +2865,29 @@ class dt extends M {
|
|
|
2764
2865
|
const l = document.createElement("div");
|
|
2765
2866
|
l.className = "md-block md-math-block";
|
|
2766
2867
|
try {
|
|
2767
|
-
|
|
2868
|
+
It.render(o, l, { displayMode: !0, throwOnError: !1 });
|
|
2768
2869
|
} catch {
|
|
2769
2870
|
l.textContent = o;
|
|
2770
2871
|
}
|
|
2771
|
-
super(e, l,
|
|
2872
|
+
super(e, l, S), this._renderedHeight = r;
|
|
2772
2873
|
}
|
|
2773
2874
|
recordMeasuredHeight(e) {
|
|
2774
2875
|
this.data.showMarkup || (this._renderedHeight = e);
|
|
2775
2876
|
}
|
|
2776
2877
|
}
|
|
2777
|
-
class
|
|
2878
|
+
class gt extends T {
|
|
2778
2879
|
constructor(e, t, s) {
|
|
2779
2880
|
const i = e.ast.ordered ? "ol" : "ul", r = s && s.element.tagName === i.toUpperCase(), o = r ? s.element : document.createElement(i);
|
|
2780
2881
|
r || (o.className = "md-block md-list");
|
|
2781
|
-
const c =
|
|
2882
|
+
const c = X(o, e.content, s?.children, se(t));
|
|
2782
2883
|
super(e, o, c);
|
|
2783
2884
|
}
|
|
2784
2885
|
}
|
|
2785
|
-
class
|
|
2886
|
+
class pt extends T {
|
|
2786
2887
|
constructor(e, t, s) {
|
|
2787
2888
|
const i = e.ast, r = document.createElement("li");
|
|
2788
2889
|
e.isActive && r.classList.add("md-list-item-active"), i.checked !== void 0 && r.classList.add("md-task-list-item"), e.isActive || r.classList.add("md-markers-hidden"), r.style.setProperty("--md-list-level", String(e.level));
|
|
2789
|
-
const o =
|
|
2890
|
+
const o = ys(r, e.content, s, t);
|
|
2790
2891
|
if (!e.isActive && i.checked !== void 0) {
|
|
2791
2892
|
const c = document.createElement("input");
|
|
2792
2893
|
c.type = "checkbox", c.checked = i.checked, c.className = "md-checkbox";
|
|
@@ -2803,37 +2904,37 @@ class gt extends M {
|
|
|
2803
2904
|
super(e, r, o);
|
|
2804
2905
|
}
|
|
2805
2906
|
}
|
|
2806
|
-
function
|
|
2807
|
-
const { paired: i, unused: r } =
|
|
2907
|
+
function ys(n, e, t, s) {
|
|
2908
|
+
const { paired: i, unused: r } = ze(e, t?.children ?? S), o = e.map((h) => Y(h, s, i.get(h)));
|
|
2808
2909
|
for (const h of r)
|
|
2809
2910
|
h.dispose();
|
|
2810
2911
|
if (!(e.length >= 2 && e[0].kind === "glue" && e[0].ast.glueKind === "indent" && e[1].kind === "marker" && e[1].ast.markerKind === "listItemMarker"))
|
|
2811
|
-
return
|
|
2912
|
+
return fe(n, o.map((h) => h.mountNode)), o;
|
|
2812
2913
|
const l = n.firstElementChild, a = l && l.classList.contains("md-list-gutter") ? l : document.createElement("span");
|
|
2813
|
-
return a.className = "md-list-gutter",
|
|
2914
|
+
return a.className = "md-list-gutter", fe(a, [o[0].mountNode, o[1].mountNode]), fe(n, [a, ...o.slice(2).map((h) => h.mountNode)]), o;
|
|
2814
2915
|
}
|
|
2815
|
-
class
|
|
2916
|
+
class mt extends T {
|
|
2816
2917
|
constructor(e, t, s) {
|
|
2817
2918
|
const i = s?.element ?? document.createElement("tr");
|
|
2818
2919
|
e.isDelimiter && i.classList.add("md-table-delimiter-row");
|
|
2819
|
-
const r =
|
|
2920
|
+
const r = X(i, e.content, s?.children, se(t));
|
|
2820
2921
|
e.isDelimiter || e.content.forEach((o, c) => {
|
|
2821
2922
|
o.kind === "tableCell" && o.isActive && r[c].element.classList.add("md-table-cell-active");
|
|
2822
2923
|
}), super(e, i, r);
|
|
2823
2924
|
}
|
|
2824
2925
|
}
|
|
2825
|
-
class
|
|
2926
|
+
class wt extends T {
|
|
2826
2927
|
constructor(e, t, s) {
|
|
2827
|
-
const i = s?.element ?? document.createElement("code"), r =
|
|
2928
|
+
const i = s?.element ?? document.createElement("code"), r = X(i, e.content, s?.children, Kt(t));
|
|
2828
2929
|
super(e, i, r);
|
|
2829
2930
|
}
|
|
2830
2931
|
}
|
|
2831
|
-
class _t extends
|
|
2932
|
+
class _t extends T {
|
|
2832
2933
|
constructor(e, t, s) {
|
|
2833
2934
|
if (e.showMarkup) {
|
|
2834
2935
|
const l = document.createElement("span");
|
|
2835
2936
|
l.className = "md-inline-math";
|
|
2836
|
-
const a =
|
|
2937
|
+
const a = X(l, e.content, s?.children, Kt(t));
|
|
2837
2938
|
super(e, l, a);
|
|
2838
2939
|
return;
|
|
2839
2940
|
}
|
|
@@ -2853,39 +2954,39 @@ class _t extends M {
|
|
|
2853
2954
|
const c = document.createElement("span");
|
|
2854
2955
|
c.className = "md-inline-math";
|
|
2855
2956
|
try {
|
|
2856
|
-
|
|
2957
|
+
It.render(r, c, { throwOnError: !1 });
|
|
2857
2958
|
} catch {
|
|
2858
2959
|
c.textContent = r;
|
|
2859
2960
|
}
|
|
2860
|
-
super(e, c,
|
|
2961
|
+
super(e, c, S);
|
|
2861
2962
|
}
|
|
2862
2963
|
}
|
|
2863
|
-
class
|
|
2964
|
+
class kt extends T {
|
|
2864
2965
|
constructor(e, t, s) {
|
|
2865
2966
|
const i = s?.element ?? document.createElement("a");
|
|
2866
2967
|
zt(e.ast.url) ? (i.href = e.ast.url, i.dataset.mdUrl = e.ast.url) : (i.removeAttribute("href"), delete i.dataset.mdUrl), s || i.addEventListener("mousedown", (o) => {
|
|
2867
2968
|
const c = i.dataset.mdUrl;
|
|
2868
2969
|
!c || i.closest(".md-block-active") !== null && !(o.ctrlKey || o.metaKey) || (o.preventDefault(), o.stopPropagation(), t?.onOpenLink ? t.onOpenLink(c, o) : window.open(c, "_blank", "noopener"));
|
|
2869
2970
|
});
|
|
2870
|
-
const r =
|
|
2971
|
+
const r = X(i, e.content, s?.children, se(t));
|
|
2871
2972
|
super(e, i, r);
|
|
2872
2973
|
}
|
|
2873
2974
|
}
|
|
2874
|
-
class
|
|
2975
|
+
class xt extends T {
|
|
2875
2976
|
constructor(e, t, s) {
|
|
2876
2977
|
const i = e.ast;
|
|
2877
2978
|
if (e.showMarkup) {
|
|
2878
2979
|
const o = document.createElement("span");
|
|
2879
2980
|
o.className = "md-image-source";
|
|
2880
|
-
const c =
|
|
2981
|
+
const c = X(o, e.content, s?.children, se(t));
|
|
2881
2982
|
super(e, o, c);
|
|
2882
2983
|
return;
|
|
2883
2984
|
}
|
|
2884
2985
|
const r = document.createElement("img");
|
|
2885
|
-
zt(i.url) && (r.src = i.url), r.alt = i.alt, super(e, r,
|
|
2986
|
+
zt(i.url) && (r.src = i.url), r.alt = i.alt, super(e, r, S);
|
|
2886
2987
|
}
|
|
2887
2988
|
}
|
|
2888
|
-
function
|
|
2989
|
+
function ze(n, e) {
|
|
2889
2990
|
const t = /* @__PURE__ */ new Map();
|
|
2890
2991
|
for (const i of e)
|
|
2891
2992
|
t.set(i.ast.id, i);
|
|
@@ -2899,36 +3000,36 @@ function qe(n, e) {
|
|
|
2899
3000
|
function zt(n) {
|
|
2900
3001
|
return !n.trim().toLowerCase().startsWith("javascript:");
|
|
2901
3002
|
}
|
|
2902
|
-
class
|
|
3003
|
+
class Xe extends ae {
|
|
2903
3004
|
constructor(e, t, s, i) {
|
|
2904
3005
|
super(e, t, i), this.blocks = s;
|
|
2905
3006
|
}
|
|
2906
3007
|
static create(e, t, s) {
|
|
2907
3008
|
const i = s?.contentDomNode ?? document.createElement("div"), r = new Map(
|
|
2908
|
-
e.children.filter((
|
|
2909
|
-
), o = s?.children, c = e.children.map((
|
|
2910
|
-
const f = l.get(
|
|
2911
|
-
if (e.children[
|
|
2912
|
-
const m = r.get(
|
|
3009
|
+
e.children.filter((d) => d.kind === "block").map((d) => [d.view, d.isActive])
|
|
3010
|
+
), o = s?.children, c = e.children.map((d) => d.view), { paired: l, unused: a } = ze(c, o ?? Es), h = c.map((d, u) => {
|
|
3011
|
+
const f = l.get(d), p = Y(d, t, f);
|
|
3012
|
+
if (e.children[u].kind === "block") {
|
|
3013
|
+
const m = r.get(d);
|
|
2913
3014
|
m !== void 0 && (p.element.classList.toggle("md-block-active", m), p.element.classList.toggle("md-markers-hidden", !m));
|
|
2914
3015
|
}
|
|
2915
3016
|
return p;
|
|
2916
3017
|
});
|
|
2917
|
-
for (const
|
|
2918
|
-
|
|
2919
|
-
|
|
3018
|
+
for (const d of a)
|
|
3019
|
+
d.dispose();
|
|
3020
|
+
fe(i, h.map((d) => d.mountNode));
|
|
2920
3021
|
const g = [];
|
|
2921
|
-
return e.children.forEach((
|
|
2922
|
-
|
|
2923
|
-
}), new
|
|
3022
|
+
return e.children.forEach((d, u) => {
|
|
3023
|
+
d.kind === "block" && g.push({ node: h[u], absoluteStart: d.absoluteStart });
|
|
3024
|
+
}), new Xe(e.ast, i, g, h);
|
|
2924
3025
|
}
|
|
2925
3026
|
/** The stable content element this document mounts its children into. */
|
|
2926
3027
|
get contentDomNode() {
|
|
2927
3028
|
return this.dom;
|
|
2928
3029
|
}
|
|
2929
3030
|
}
|
|
2930
|
-
const
|
|
2931
|
-
function
|
|
3031
|
+
const Es = [];
|
|
3032
|
+
function Cs(n) {
|
|
2932
3033
|
const e = document;
|
|
2933
3034
|
if (e.caretPositionFromPoint) {
|
|
2934
3035
|
const s = e.caretPositionFromPoint(n.x, n.y);
|
|
@@ -2938,115 +3039,115 @@ function bs(n) {
|
|
|
2938
3039
|
if (t)
|
|
2939
3040
|
return { node: t.startContainer, offset: t.startOffset };
|
|
2940
3041
|
}
|
|
2941
|
-
class
|
|
3042
|
+
class Os {
|
|
2942
3043
|
constructor(e, t, s) {
|
|
2943
3044
|
this.ast = e, this.blocks = t, this.children = s;
|
|
2944
3045
|
}
|
|
2945
3046
|
kind = "document";
|
|
2946
3047
|
}
|
|
2947
|
-
class
|
|
3048
|
+
class Ts {
|
|
2948
3049
|
constructor(e, t) {
|
|
2949
3050
|
this.ast = e, this.content = t;
|
|
2950
3051
|
}
|
|
2951
3052
|
kind = "heading";
|
|
2952
3053
|
}
|
|
2953
|
-
class
|
|
3054
|
+
class Ms {
|
|
2954
3055
|
constructor(e, t) {
|
|
2955
3056
|
this.ast = e, this.content = t;
|
|
2956
3057
|
}
|
|
2957
3058
|
kind = "paragraph";
|
|
2958
3059
|
}
|
|
2959
|
-
class
|
|
3060
|
+
class Ss {
|
|
2960
3061
|
constructor(e, t, s) {
|
|
2961
3062
|
this.ast = e, this.showMarkup = t, this.content = s;
|
|
2962
3063
|
}
|
|
2963
3064
|
kind = "codeBlock";
|
|
2964
3065
|
}
|
|
2965
|
-
class
|
|
3066
|
+
class Ls {
|
|
2966
3067
|
constructor(e, t, s) {
|
|
2967
3068
|
this.ast = e, this.showMarkup = t, this.content = s;
|
|
2968
3069
|
}
|
|
2969
3070
|
kind = "mathBlock";
|
|
2970
3071
|
}
|
|
2971
|
-
class
|
|
3072
|
+
class Is {
|
|
2972
3073
|
constructor(e, t) {
|
|
2973
3074
|
this.ast = e, this.content = t;
|
|
2974
3075
|
}
|
|
2975
3076
|
kind = "blockQuote";
|
|
2976
3077
|
}
|
|
2977
|
-
class
|
|
3078
|
+
class Ns {
|
|
2978
3079
|
constructor(e, t) {
|
|
2979
3080
|
this.ast = e, this.content = t;
|
|
2980
3081
|
}
|
|
2981
3082
|
kind = "list";
|
|
2982
3083
|
}
|
|
2983
|
-
class
|
|
3084
|
+
class Rs {
|
|
2984
3085
|
constructor(e, t) {
|
|
2985
3086
|
this.ast = e, this.content = t;
|
|
2986
3087
|
}
|
|
2987
3088
|
kind = "table";
|
|
2988
3089
|
}
|
|
2989
|
-
class
|
|
3090
|
+
class Bs {
|
|
2990
3091
|
constructor(e, t) {
|
|
2991
3092
|
this.ast = e, this.content = t;
|
|
2992
3093
|
}
|
|
2993
3094
|
kind = "strong";
|
|
2994
3095
|
}
|
|
2995
|
-
class
|
|
3096
|
+
class Ds {
|
|
2996
3097
|
constructor(e, t) {
|
|
2997
3098
|
this.ast = e, this.content = t;
|
|
2998
3099
|
}
|
|
2999
3100
|
kind = "emphasis";
|
|
3000
3101
|
}
|
|
3001
|
-
class
|
|
3102
|
+
class As {
|
|
3002
3103
|
constructor(e, t) {
|
|
3003
3104
|
this.ast = e, this.content = t;
|
|
3004
3105
|
}
|
|
3005
3106
|
kind = "strikethrough";
|
|
3006
3107
|
}
|
|
3007
|
-
class
|
|
3108
|
+
class $s {
|
|
3008
3109
|
constructor(e, t) {
|
|
3009
3110
|
this.ast = e, this.content = t;
|
|
3010
3111
|
}
|
|
3011
3112
|
kind = "inlineCode";
|
|
3012
3113
|
}
|
|
3013
|
-
class
|
|
3114
|
+
class Fs {
|
|
3014
3115
|
constructor(e, t, s) {
|
|
3015
3116
|
this.ast = e, this.showMarkup = t, this.content = s;
|
|
3016
3117
|
}
|
|
3017
3118
|
kind = "inlineMath";
|
|
3018
3119
|
}
|
|
3019
|
-
class
|
|
3120
|
+
class Vs {
|
|
3020
3121
|
constructor(e, t) {
|
|
3021
3122
|
this.ast = e, this.content = t;
|
|
3022
3123
|
}
|
|
3023
3124
|
kind = "link";
|
|
3024
3125
|
}
|
|
3025
|
-
class
|
|
3126
|
+
class Ps {
|
|
3026
3127
|
constructor(e, t, s) {
|
|
3027
3128
|
this.ast = e, this.showMarkup = t, this.content = s;
|
|
3028
3129
|
}
|
|
3029
3130
|
kind = "image";
|
|
3030
3131
|
}
|
|
3031
|
-
class
|
|
3132
|
+
class Ks {
|
|
3032
3133
|
constructor(e, t, s, i) {
|
|
3033
3134
|
this.ast = e, this.isActive = t, this.content = s, this.level = i;
|
|
3034
3135
|
}
|
|
3035
3136
|
kind = "listItem";
|
|
3036
3137
|
}
|
|
3037
|
-
class
|
|
3138
|
+
class Hs {
|
|
3038
3139
|
constructor(e, t, s) {
|
|
3039
3140
|
this.ast = e, this.isDelimiter = t, this.content = s;
|
|
3040
3141
|
}
|
|
3041
3142
|
kind = "tableRow";
|
|
3042
3143
|
}
|
|
3043
|
-
class
|
|
3144
|
+
class Ws {
|
|
3044
3145
|
constructor(e, t, s, i) {
|
|
3045
3146
|
this.ast = e, this.isActive = t, this.showTableGlue = s, this.content = i;
|
|
3046
3147
|
}
|
|
3047
3148
|
kind = "tableCell";
|
|
3048
3149
|
}
|
|
3049
|
-
class
|
|
3150
|
+
class qs {
|
|
3050
3151
|
/**
|
|
3051
3152
|
* Whether non-obvious whitespace in this text is revealed (block is active).
|
|
3052
3153
|
* `leftWordBoundary`/`rightWordBoundary` say whether the inline sibling on
|
|
@@ -3059,13 +3160,13 @@ class Ks {
|
|
|
3059
3160
|
}
|
|
3060
3161
|
kind = "text";
|
|
3061
3162
|
}
|
|
3062
|
-
class
|
|
3163
|
+
class js {
|
|
3063
3164
|
constructor(e, t, s) {
|
|
3064
3165
|
this.ast = e, this.showMarkup = t, this.content = s;
|
|
3065
3166
|
}
|
|
3066
3167
|
kind = "thematicBreak";
|
|
3067
3168
|
}
|
|
3068
|
-
class
|
|
3169
|
+
class Gs {
|
|
3069
3170
|
constructor(e, t) {
|
|
3070
3171
|
this.ast = e, this.visible = t;
|
|
3071
3172
|
}
|
|
@@ -3077,122 +3178,115 @@ class Xt {
|
|
|
3077
3178
|
}
|
|
3078
3179
|
kind = "glue";
|
|
3079
3180
|
}
|
|
3080
|
-
const
|
|
3081
|
-
function
|
|
3181
|
+
const zs = { showMarkup: !1, showTableGlue: !1, selectionInNode: void 0 };
|
|
3182
|
+
function F(n) {
|
|
3082
3183
|
return n.inlineFlow ? n : { ...n, inlineFlow: !0 };
|
|
3083
3184
|
}
|
|
3084
3185
|
function Qt(n, e, t, s) {
|
|
3085
3186
|
const i = /* @__PURE__ */ new Map();
|
|
3086
3187
|
if (s)
|
|
3087
|
-
for (const
|
|
3088
|
-
i.set(
|
|
3089
|
-
const r = n.content, o = new Set(n.blocks), c =
|
|
3090
|
-
let
|
|
3091
|
-
for (let
|
|
3092
|
-
const
|
|
3093
|
-
if (o.has(
|
|
3094
|
-
const
|
|
3095
|
-
let
|
|
3096
|
-
if (!
|
|
3097
|
-
|
|
3188
|
+
for (const h of s.children)
|
|
3189
|
+
i.set(h.view.ast, h);
|
|
3190
|
+
const r = n.content, o = new Set(n.blocks), c = [], l = [];
|
|
3191
|
+
let a = 0;
|
|
3192
|
+
for (let h = 0; h < r.length; h++) {
|
|
3193
|
+
const g = r[h];
|
|
3194
|
+
if (o.has(g)) {
|
|
3195
|
+
const d = g, u = e.has(d), f = i.get(d);
|
|
3196
|
+
let p;
|
|
3197
|
+
if (!u)
|
|
3198
|
+
p = f && !f.isActive ? f.view : vt(d, zs, f?.view);
|
|
3098
3199
|
else {
|
|
3099
|
-
const
|
|
3100
|
-
Math.max(0, t.start -
|
|
3101
|
-
Math.min(
|
|
3200
|
+
const m = t ? new w(
|
|
3201
|
+
Math.max(0, t.start - a),
|
|
3202
|
+
Math.min(d.length, t.endExclusive - a)
|
|
3102
3203
|
) : void 0;
|
|
3103
|
-
|
|
3204
|
+
p = vt(d, { showMarkup: !0, showTableGlue: !1, selectionInNode: m }, f?.view);
|
|
3104
3205
|
}
|
|
3105
|
-
|
|
3106
|
-
} else if (
|
|
3107
|
-
const
|
|
3108
|
-
|
|
3206
|
+
c.push({ ast: d, absoluteStart: a, isActive: u, view: p }), l.push({ absoluteStart: a, isActive: u, view: p, kind: "block" });
|
|
3207
|
+
} else if (g instanceof R) {
|
|
3208
|
+
const d = i.get(g), u = b(d?.view, new Xt(g, !1, !1));
|
|
3209
|
+
l.push({ absoluteStart: a, isActive: !1, view: u, kind: "glue" });
|
|
3109
3210
|
}
|
|
3110
|
-
|
|
3211
|
+
a += g.length;
|
|
3111
3212
|
}
|
|
3112
|
-
return new
|
|
3113
|
-
}
|
|
3114
|
-
function xt(n, e, t, s, i) {
|
|
3115
|
-
for (let r = s + i; r >= 0 && r < t; r += i)
|
|
3116
|
-
if (n(r))
|
|
3117
|
-
return e(r);
|
|
3118
|
-
return !1;
|
|
3213
|
+
return new Os(n, c, l);
|
|
3119
3214
|
}
|
|
3120
3215
|
function vt(n, e, t) {
|
|
3121
|
-
return
|
|
3216
|
+
return he(n, e, t);
|
|
3122
3217
|
}
|
|
3123
|
-
function
|
|
3218
|
+
function he(n, e, t, s) {
|
|
3124
3219
|
const i = n;
|
|
3125
3220
|
switch (i.kind) {
|
|
3126
3221
|
case "text":
|
|
3127
|
-
return b(t, new
|
|
3128
|
-
// The trailing gap
|
|
3129
|
-
//
|
|
3130
|
-
// raw `\n`s are zero-width and the caret can't tell them apart.
|
|
3222
|
+
return b(t, new qs(i, e.showMarkup, s?.left ?? !1, s?.right ?? !1));
|
|
3223
|
+
// The trailing gap is revealed as `↵` glyphs by virtue of its `blockGap`
|
|
3224
|
+
// kind (see `GlueViewNode`), so the break needs no inline-flow opt-in.
|
|
3131
3225
|
case "thematicBreak":
|
|
3132
|
-
return b(t, new
|
|
3226
|
+
return b(t, new js(i, e.showMarkup, I(i.children, e, t)));
|
|
3133
3227
|
case "marker":
|
|
3134
|
-
return b(t, new
|
|
3228
|
+
return b(t, new Gs(i, Us(i.markerKind, e)));
|
|
3135
3229
|
case "glue":
|
|
3136
|
-
return b(t, new Xt(i,
|
|
3230
|
+
return b(t, new Xt(i, Ys(i.glueKind, e), e.inlineFlow ?? !1));
|
|
3137
3231
|
case "heading":
|
|
3138
|
-
return b(t, new
|
|
3232
|
+
return b(t, new Ts(i, I(i.children, F(e), t)));
|
|
3139
3233
|
case "paragraph":
|
|
3140
|
-
return b(t, new
|
|
3234
|
+
return b(t, new Ms(i, I(i.children, F(e), t)));
|
|
3141
3235
|
case "codeBlock":
|
|
3142
|
-
return b(t, new
|
|
3236
|
+
return b(t, new Ss(i, e.showMarkup, I(i.children, e, t)));
|
|
3143
3237
|
case "mathBlock":
|
|
3144
|
-
return b(t, new
|
|
3238
|
+
return b(t, new Ls(i, e.showMarkup, I(i.children, e, t)));
|
|
3145
3239
|
case "blockQuote":
|
|
3146
|
-
return b(t, new
|
|
3240
|
+
return b(t, new Is(i, I(i.children, e, t)));
|
|
3147
3241
|
case "list":
|
|
3148
|
-
return b(t,
|
|
3242
|
+
return b(t, Js(i, e, t));
|
|
3149
3243
|
case "listItem":
|
|
3150
3244
|
return b(t, Ut(i, e, t));
|
|
3151
3245
|
case "table":
|
|
3152
|
-
return b(t,
|
|
3246
|
+
return b(t, Zs(i, e, t));
|
|
3153
3247
|
case "tableRow":
|
|
3154
3248
|
return b(t, Yt(i, e, !1, t));
|
|
3155
3249
|
case "tableCell":
|
|
3156
3250
|
return b(t, Jt(i, e.showMarkup, e.showTableGlue, e.selectionInNode, t));
|
|
3157
3251
|
case "strong":
|
|
3158
|
-
return b(t, new
|
|
3252
|
+
return b(t, new Bs(i, I(i.children, F(e), t)));
|
|
3159
3253
|
case "emphasis":
|
|
3160
|
-
return b(t, new
|
|
3254
|
+
return b(t, new Ds(i, I(i.children, F(e), t)));
|
|
3161
3255
|
case "strikethrough":
|
|
3162
|
-
return b(t, new
|
|
3256
|
+
return b(t, new As(i, I(i.children, F(e), t)));
|
|
3163
3257
|
case "inlineCode":
|
|
3164
|
-
return b(t, new
|
|
3258
|
+
return b(t, new $s(i, I(i.children, F(e), t)));
|
|
3165
3259
|
case "inlineMath":
|
|
3166
|
-
return b(t, new
|
|
3260
|
+
return b(t, new Fs(i, e.showMarkup, I(i.children, F(e), t)));
|
|
3167
3261
|
case "link":
|
|
3168
|
-
return b(t, new
|
|
3262
|
+
return b(t, new Vs(i, I(i.children, F(e), t)));
|
|
3169
3263
|
case "image":
|
|
3170
|
-
return b(t, new
|
|
3264
|
+
return b(t, new Ps(i, e.showMarkup, I(i.children, F(e), t)));
|
|
3171
3265
|
case "document":
|
|
3172
|
-
return Qt(i, /* @__PURE__ */ new Set(),
|
|
3266
|
+
return Qt(i, /* @__PURE__ */ new Set(), w.ofLength(0), void 0);
|
|
3173
3267
|
}
|
|
3174
3268
|
}
|
|
3175
|
-
function
|
|
3176
|
-
return n.kind === "document" ? n.blocks.map((e) => e.view) : "content" in n ? n.content :
|
|
3269
|
+
function De(n) {
|
|
3270
|
+
return n.kind === "document" ? n.blocks.map((e) => e.view) : "content" in n ? n.content : Xs;
|
|
3177
3271
|
}
|
|
3178
|
-
const
|
|
3179
|
-
function
|
|
3272
|
+
const Xs = [];
|
|
3273
|
+
function xe(n) {
|
|
3180
3274
|
if (!n)
|
|
3181
3275
|
return;
|
|
3182
3276
|
const e = /* @__PURE__ */ new Map();
|
|
3183
|
-
for (const t of
|
|
3277
|
+
for (const t of De(n))
|
|
3184
3278
|
e.set(t.ast, t);
|
|
3185
3279
|
return e;
|
|
3186
3280
|
}
|
|
3187
3281
|
function b(n, e) {
|
|
3188
|
-
if (n && n.kind === e.kind && n.ast === e.ast &&
|
|
3189
|
-
const t =
|
|
3282
|
+
if (n && n.kind === e.kind && n.ast === e.ast && Qs(n, e)) {
|
|
3283
|
+
const t = De(n), s = De(e);
|
|
3190
3284
|
if (t.length === s.length && t.every((i, r) => i === s[r]))
|
|
3191
3285
|
return n;
|
|
3192
3286
|
}
|
|
3193
3287
|
return e;
|
|
3194
3288
|
}
|
|
3195
|
-
function
|
|
3289
|
+
function Qs(n, e) {
|
|
3196
3290
|
switch (n.kind) {
|
|
3197
3291
|
case "text":
|
|
3198
3292
|
return n.showWhitespace === e.showWhitespace && n.leftWordBoundary === e.leftWordBoundary && n.rightWordBoundary === e.rightWordBoundary;
|
|
@@ -3222,14 +3316,14 @@ function Gs(n, e) {
|
|
|
3222
3316
|
return !0;
|
|
3223
3317
|
}
|
|
3224
3318
|
}
|
|
3225
|
-
function
|
|
3226
|
-
const s =
|
|
3319
|
+
function I(n, e, t) {
|
|
3320
|
+
const s = xe(t);
|
|
3227
3321
|
return n.map((i, r) => {
|
|
3228
3322
|
const o = i.kind === "text" ? {
|
|
3229
3323
|
left: r > 0 && bt(n[r - 1], "end"),
|
|
3230
3324
|
right: r < n.length - 1 && bt(n[r + 1], "start")
|
|
3231
3325
|
} : void 0;
|
|
3232
|
-
return
|
|
3326
|
+
return he(i, e, s?.get(i), o);
|
|
3233
3327
|
});
|
|
3234
3328
|
}
|
|
3235
3329
|
function bt(n, e) {
|
|
@@ -3251,83 +3345,83 @@ function bt(n, e) {
|
|
|
3251
3345
|
return !1;
|
|
3252
3346
|
}
|
|
3253
3347
|
}
|
|
3254
|
-
function
|
|
3348
|
+
function Us(n, e) {
|
|
3255
3349
|
return e.showMarkup || n === "tableCellGlue" && e.showTableGlue;
|
|
3256
3350
|
}
|
|
3257
|
-
function
|
|
3351
|
+
function Ys(n, e) {
|
|
3258
3352
|
return e.showMarkup || n === "tableCellGlue" && e.showTableGlue;
|
|
3259
3353
|
}
|
|
3260
|
-
function
|
|
3261
|
-
const s =
|
|
3354
|
+
function Js(n, e, t) {
|
|
3355
|
+
const s = xe(t), i = ei(n, e), r = new Set(n.items), o = (e.listLevel ?? 0) + 1, c = [];
|
|
3262
3356
|
let l = 0;
|
|
3263
3357
|
for (const a of n.children) {
|
|
3264
3358
|
if (r.has(a)) {
|
|
3265
|
-
const h = a, g = i.has(n.items.indexOf(h)),
|
|
3359
|
+
const h = a, g = i.has(n.items.indexOf(h)), d = {
|
|
3266
3360
|
showMarkup: g,
|
|
3267
3361
|
showTableGlue: !1,
|
|
3268
3362
|
selectionInNode: g && e.selectionInNode ? e.selectionInNode.delta(-l) : void 0,
|
|
3269
3363
|
listLevel: o
|
|
3270
3364
|
};
|
|
3271
|
-
c.push(b(s?.get(h), Ut(h,
|
|
3365
|
+
c.push(b(s?.get(h), Ut(h, d, s?.get(h))));
|
|
3272
3366
|
} else
|
|
3273
|
-
c.push(
|
|
3367
|
+
c.push(he(a, e, s?.get(a)));
|
|
3274
3368
|
l += a.length;
|
|
3275
3369
|
}
|
|
3276
|
-
return new
|
|
3370
|
+
return new Ns(n, c);
|
|
3277
3371
|
}
|
|
3278
3372
|
function Ut(n, e, t) {
|
|
3279
|
-
const s =
|
|
3373
|
+
const s = xe(t), i = [];
|
|
3280
3374
|
let r = 0;
|
|
3281
3375
|
for (const o of n.children) {
|
|
3282
3376
|
const c = e.selectionInNode ? { ...e, selectionInNode: e.selectionInNode.delta(-r) } : e;
|
|
3283
|
-
i.push(
|
|
3377
|
+
i.push(he(o, c, s?.get(o))), r += o.length;
|
|
3284
3378
|
}
|
|
3285
|
-
return new
|
|
3379
|
+
return new Ks(n, e.showMarkup, i, e.listLevel ?? 1);
|
|
3286
3380
|
}
|
|
3287
|
-
function
|
|
3288
|
-
const s =
|
|
3381
|
+
function Zs(n, e, t) {
|
|
3382
|
+
const s = xe(t), i = e.showMarkup, r = n.delimiterRow, o = new Set(
|
|
3289
3383
|
[n.headerRow, n.delimiterRow, ...n.bodyRows].filter((a) => a !== void 0)
|
|
3290
3384
|
), c = [];
|
|
3291
3385
|
let l = 0;
|
|
3292
3386
|
for (const a of n.children) {
|
|
3293
3387
|
if (o.has(a)) {
|
|
3294
|
-
const h = a, g = h === r,
|
|
3388
|
+
const h = a, g = h === r, d = {
|
|
3295
3389
|
showMarkup: i,
|
|
3296
3390
|
showTableGlue: i,
|
|
3297
3391
|
selectionInNode: !g && i && e.selectionInNode ? e.selectionInNode.delta(-l) : void 0
|
|
3298
3392
|
};
|
|
3299
|
-
c.push(b(s?.get(h), Yt(h,
|
|
3393
|
+
c.push(b(s?.get(h), Yt(h, d, g, s?.get(h))));
|
|
3300
3394
|
} else
|
|
3301
|
-
c.push(
|
|
3395
|
+
c.push(he(a, e, s?.get(a)));
|
|
3302
3396
|
l += a.length;
|
|
3303
3397
|
}
|
|
3304
|
-
return new
|
|
3398
|
+
return new Rs(n, c);
|
|
3305
3399
|
}
|
|
3306
3400
|
function Yt(n, e, t, s) {
|
|
3307
|
-
const i =
|
|
3401
|
+
const i = xe(s), r = e.showMarkup, o = t ? void 0 : ti(n, e), c = new Set(n.cells), l = [];
|
|
3308
3402
|
let a = 0;
|
|
3309
3403
|
for (const h of n.children) {
|
|
3310
3404
|
if (c.has(h)) {
|
|
3311
|
-
const g = h,
|
|
3312
|
-
l.push(Jt(g,
|
|
3405
|
+
const g = h, d = t ? r : o.has(n.cells.indexOf(g)), u = d && e.selectionInNode ? e.selectionInNode.delta(-a) : void 0;
|
|
3406
|
+
l.push(Jt(g, d, r, u, i?.get(g)));
|
|
3313
3407
|
} else
|
|
3314
|
-
l.push(
|
|
3408
|
+
l.push(he(h, e, i?.get(h)));
|
|
3315
3409
|
a += h.length;
|
|
3316
3410
|
}
|
|
3317
|
-
return new
|
|
3411
|
+
return new Hs(n, t, l);
|
|
3318
3412
|
}
|
|
3319
3413
|
function Jt(n, e, t, s, i) {
|
|
3320
3414
|
const r = { showMarkup: e, showTableGlue: t, selectionInNode: s };
|
|
3321
|
-
return new
|
|
3415
|
+
return new Ws(n, e, t, I(n.children, F(r), i));
|
|
3322
3416
|
}
|
|
3323
|
-
const
|
|
3324
|
-
function
|
|
3417
|
+
const Oe = /* @__PURE__ */ new Set();
|
|
3418
|
+
function ei(n, e) {
|
|
3325
3419
|
if (!e.showMarkup || !e.selectionInNode)
|
|
3326
|
-
return
|
|
3420
|
+
return Oe;
|
|
3327
3421
|
const t = e.selectionInNode;
|
|
3328
3422
|
if (t.isEmpty) {
|
|
3329
3423
|
const r = Pt(n, t.start);
|
|
3330
|
-
return r === void 0 ?
|
|
3424
|
+
return r === void 0 ? Oe : /* @__PURE__ */ new Set([r]);
|
|
3331
3425
|
}
|
|
3332
3426
|
const s = /* @__PURE__ */ new Set();
|
|
3333
3427
|
let i = 0;
|
|
@@ -3337,13 +3431,13 @@ function Ys(n, e) {
|
|
|
3337
3431
|
}
|
|
3338
3432
|
return s;
|
|
3339
3433
|
}
|
|
3340
|
-
function
|
|
3434
|
+
function ti(n, e) {
|
|
3341
3435
|
if (!e.showMarkup || !e.selectionInNode)
|
|
3342
|
-
return
|
|
3436
|
+
return Oe;
|
|
3343
3437
|
const t = e.selectionInNode;
|
|
3344
3438
|
if (t.isEmpty) {
|
|
3345
|
-
const r =
|
|
3346
|
-
return r === void 0 ?
|
|
3439
|
+
const r = ni(n, t.start);
|
|
3440
|
+
return r === void 0 ? Oe : /* @__PURE__ */ new Set([r]);
|
|
3347
3441
|
}
|
|
3348
3442
|
const s = /* @__PURE__ */ new Set();
|
|
3349
3443
|
let i = 0;
|
|
@@ -3353,7 +3447,7 @@ function Js(n, e) {
|
|
|
3353
3447
|
}
|
|
3354
3448
|
return s;
|
|
3355
3449
|
}
|
|
3356
|
-
function
|
|
3450
|
+
function ni(n, e) {
|
|
3357
3451
|
let t = 0;
|
|
3358
3452
|
for (const s of n.children) {
|
|
3359
3453
|
const i = t + s.length, r = n.cells.indexOf(s);
|
|
@@ -3362,17 +3456,17 @@ function Zs(n, e) {
|
|
|
3362
3456
|
t = i;
|
|
3363
3457
|
}
|
|
3364
3458
|
}
|
|
3365
|
-
class
|
|
3459
|
+
class si extends le {
|
|
3366
3460
|
constructor(e, t) {
|
|
3367
|
-
super(), this._parent = e, this.element = document.createElement("div"), this.element.className = "md-cursor", this.rendering =
|
|
3461
|
+
super(), this._parent = e, this.element = document.createElement("div"), this.element.className = "md-cursor", this.rendering = V(this, (s) => {
|
|
3368
3462
|
const i = s.readObservable(t.offset), r = s.readObservable(t.visualLineMap);
|
|
3369
3463
|
if (i === void 0 || r.isEmpty)
|
|
3370
|
-
return this.element.style.display = "none", new yt(i ?? 0, !1,
|
|
3464
|
+
return this.element.style.display = "none", new yt(i ?? 0, !1, B.EMPTY);
|
|
3371
3465
|
const o = r.lineIndexOfOffset(i), c = r.lineRect(o).withZeroWidthAt(r.xAtOffset(i)), l = this._parent.getBoundingClientRect(), a = c.translate(-l.left, -l.top);
|
|
3372
3466
|
return this.element.style.left = `${a.x}px`, this.element.style.top = `${a.y}px`, this.element.style.height = `${a.height}px`, this.element.style.display = "", new yt(i, !0, a);
|
|
3373
|
-
}), this._register(
|
|
3467
|
+
}), this._register(ee((s) => {
|
|
3374
3468
|
s.readObservable(this.rendering);
|
|
3375
|
-
})), this._register(
|
|
3469
|
+
})), this._register(ee((s) => {
|
|
3376
3470
|
s.readObservable(t.offset), this.element.style.animation = "none", this.element.offsetWidth, this.element.style.animation = "";
|
|
3377
3471
|
}));
|
|
3378
3472
|
}
|
|
@@ -3384,12 +3478,12 @@ class yt {
|
|
|
3384
3478
|
this.offset = e, this.visible = t, this.rect = s;
|
|
3385
3479
|
}
|
|
3386
3480
|
}
|
|
3387
|
-
class
|
|
3481
|
+
class ii extends le {
|
|
3388
3482
|
constructor(e, t) {
|
|
3389
|
-
super(), this._parent = e, this.element = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.element.setAttribute("class", "md-selection-layer"), this._path = document.createElementNS("http://www.w3.org/2000/svg", "path"), this._path.setAttribute("class", "md-selection-path"), this.element.appendChild(this._path), this.rendering =
|
|
3483
|
+
super(), this._parent = e, this.element = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.element.setAttribute("class", "md-selection-layer"), this._path = document.createElementNS("http://www.w3.org/2000/svg", "path"), this._path.setAttribute("class", "md-selection-path"), this.element.appendChild(this._path), this.rendering = V(this, (s) => {
|
|
3390
3484
|
const i = s.readObservable(t.selection), r = s.readObservable(t.visualLineMap), o = s.readObservable(t.blocks);
|
|
3391
|
-
return
|
|
3392
|
-
}), this._register(
|
|
3485
|
+
return ri(this._path, this._parent, i, r, o);
|
|
3486
|
+
}), this._register(ee((s) => {
|
|
3393
3487
|
s.readObservable(this.rendering);
|
|
3394
3488
|
}));
|
|
3395
3489
|
}
|
|
@@ -3402,75 +3496,75 @@ class Et {
|
|
|
3402
3496
|
this.rects = e;
|
|
3403
3497
|
}
|
|
3404
3498
|
}
|
|
3405
|
-
function
|
|
3499
|
+
function ri(n, e, t, s, i) {
|
|
3406
3500
|
if (!t || t.isCollapsed)
|
|
3407
3501
|
return n.setAttribute("d", ""), new Et([]);
|
|
3408
3502
|
const r = t.range, o = e.getBoundingClientRect(), c = [];
|
|
3409
|
-
for (const
|
|
3410
|
-
const f = Zt(
|
|
3503
|
+
for (const u of s.lines) {
|
|
3504
|
+
const f = Zt(u);
|
|
3411
3505
|
if (!f || !r.intersects(f))
|
|
3412
3506
|
continue;
|
|
3413
|
-
const p = i.find((m) =>
|
|
3414
|
-
c.push({ line:
|
|
3507
|
+
const p = i.find((m) => w.ofStartAndLength(m.absoluteStart, m.block.length).containsRange(f));
|
|
3508
|
+
c.push({ line: u, lineRange: f, block: p });
|
|
3415
3509
|
}
|
|
3416
3510
|
const l = [], a = [];
|
|
3417
|
-
for (let
|
|
3418
|
-
const { line: f, lineRange: p } = c[
|
|
3511
|
+
for (let u = 0; u < c.length; u++) {
|
|
3512
|
+
const { line: f, lineRange: p } = c[u], m = u === 0, _ = u === c.length - 1, v = m ? f.xAtOffset(Math.max(r.start, p.start)) : f.rect.left, y = _ ? f.xAtOffset(Math.min(r.endExclusive, p.endExclusive)) : f.rect.right;
|
|
3419
3513
|
l.push({
|
|
3420
3514
|
x: v - o.left,
|
|
3421
3515
|
y: f.rect.top - o.top,
|
|
3422
|
-
width: Math.max(0,
|
|
3516
|
+
width: Math.max(0, y - v),
|
|
3423
3517
|
height: f.rect.height
|
|
3424
|
-
}), a.push({ left: v, right:
|
|
3518
|
+
}), a.push({ left: v, right: y, top: f.rect.top, bottom: f.rect.top + f.rect.height });
|
|
3425
3519
|
}
|
|
3426
|
-
for (let
|
|
3427
|
-
const f = a[
|
|
3520
|
+
for (let u = 0; u < a.length - 1; u++) {
|
|
3521
|
+
const f = a[u], p = a[u + 1];
|
|
3428
3522
|
if (p.top <= f.bottom)
|
|
3429
3523
|
continue;
|
|
3430
|
-
const m = Math.max(f.left, p.left),
|
|
3431
|
-
|
|
3524
|
+
const m = Math.max(f.left, p.left), _ = Math.min(f.right, p.right);
|
|
3525
|
+
_ <= m || l.push({
|
|
3432
3526
|
x: m - o.left,
|
|
3433
3527
|
y: f.bottom - o.top,
|
|
3434
|
-
width:
|
|
3528
|
+
width: _ - m,
|
|
3435
3529
|
height: p.top - f.bottom
|
|
3436
3530
|
});
|
|
3437
3531
|
}
|
|
3438
3532
|
const h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
|
|
3439
|
-
for (let
|
|
3440
|
-
const f = c[
|
|
3441
|
-
f && (h.has(f) || h.set(f,
|
|
3533
|
+
for (let u = 0; u < c.length; u++) {
|
|
3534
|
+
const f = c[u].block;
|
|
3535
|
+
f && (h.has(f) || h.set(f, u), g.set(f, u));
|
|
3442
3536
|
}
|
|
3443
|
-
const
|
|
3444
|
-
(
|
|
3537
|
+
const d = i.map(
|
|
3538
|
+
(u) => r.intersects(w.ofStartAndLength(u.absoluteStart, u.block.length))
|
|
3445
3539
|
);
|
|
3446
|
-
for (let
|
|
3447
|
-
const f = i[
|
|
3448
|
-
if (m <
|
|
3540
|
+
for (let u = 0; u < i.length - 1; u++) {
|
|
3541
|
+
const f = i[u], p = i[u + 1], m = f.absoluteStart + f.block.length, _ = p.absoluteStart;
|
|
3542
|
+
if (m < _ && !r.containsRange(w.fromTo(m, _)) || m >= _ && !(d[u] && d[u + 1]))
|
|
3449
3543
|
continue;
|
|
3450
|
-
const v = f.element.getBoundingClientRect(),
|
|
3451
|
-
if (
|
|
3544
|
+
const v = f.element.getBoundingClientRect(), y = p.element.getBoundingClientRect(), M = oi(s, p, y.top), A = v.bottom;
|
|
3545
|
+
if (M <= A)
|
|
3452
3546
|
continue;
|
|
3453
|
-
const
|
|
3454
|
-
|
|
3455
|
-
x:
|
|
3456
|
-
y:
|
|
3457
|
-
width:
|
|
3458
|
-
height:
|
|
3547
|
+
const de = g.get(f), Qe = h.get(p), Ue = de !== void 0 ? a[de] : { left: v.left, right: v.right }, Ye = Qe !== void 0 ? a[Qe] : { left: y.left, right: y.right }, Se = Math.max(Ue.left, Ye.left), Je = Math.min(Ue.right, Ye.right);
|
|
3548
|
+
Je <= Se || l.push({
|
|
3549
|
+
x: Se - o.left,
|
|
3550
|
+
y: A - o.top,
|
|
3551
|
+
width: Je - Se,
|
|
3552
|
+
height: M - A
|
|
3459
3553
|
});
|
|
3460
3554
|
}
|
|
3461
|
-
for (const
|
|
3462
|
-
const f =
|
|
3555
|
+
for (const u of i) {
|
|
3556
|
+
const f = w.ofStartAndLength(u.absoluteStart, u.block.length);
|
|
3463
3557
|
if (!r.intersects(f))
|
|
3464
3558
|
continue;
|
|
3465
3559
|
let p = !1;
|
|
3466
|
-
for (const { lineRange:
|
|
3467
|
-
if (
|
|
3560
|
+
for (const { lineRange: _ } of c)
|
|
3561
|
+
if (_.intersects(f)) {
|
|
3468
3562
|
p = !0;
|
|
3469
3563
|
break;
|
|
3470
3564
|
}
|
|
3471
3565
|
if (p)
|
|
3472
3566
|
continue;
|
|
3473
|
-
const m =
|
|
3567
|
+
const m = u.element.getBoundingClientRect();
|
|
3474
3568
|
l.push({
|
|
3475
3569
|
x: m.left - o.left,
|
|
3476
3570
|
y: m.top - o.top,
|
|
@@ -3478,7 +3572,7 @@ function ni(n, e, t, s, i) {
|
|
|
3478
3572
|
height: m.height
|
|
3479
3573
|
});
|
|
3480
3574
|
}
|
|
3481
|
-
return n.setAttribute("d",
|
|
3575
|
+
return n.setAttribute("d", ci(l, 4)), new Et(l);
|
|
3482
3576
|
}
|
|
3483
3577
|
function Zt(n) {
|
|
3484
3578
|
if (n.runs.length === 0)
|
|
@@ -3486,10 +3580,10 @@ function Zt(n) {
|
|
|
3486
3580
|
let e = 1 / 0, t = -1 / 0;
|
|
3487
3581
|
for (const s of n.runs)
|
|
3488
3582
|
s.sourceStart < e && (e = s.sourceStart), s.sourceEndExclusive > t && (t = s.sourceEndExclusive);
|
|
3489
|
-
return
|
|
3583
|
+
return w.fromTo(e, t);
|
|
3490
3584
|
}
|
|
3491
|
-
function
|
|
3492
|
-
const s =
|
|
3585
|
+
function oi(n, e, t) {
|
|
3586
|
+
const s = w.ofStartAndLength(e.absoluteStart, e.block.length);
|
|
3493
3587
|
for (const i of n.lines) {
|
|
3494
3588
|
const r = Zt(i);
|
|
3495
3589
|
if (r && s.containsRange(r))
|
|
@@ -3497,7 +3591,7 @@ function si(n, e, t) {
|
|
|
3497
3591
|
}
|
|
3498
3592
|
return t;
|
|
3499
3593
|
}
|
|
3500
|
-
function
|
|
3594
|
+
function ci(n, e) {
|
|
3501
3595
|
if (n.length === 0)
|
|
3502
3596
|
return "";
|
|
3503
3597
|
const t = n.slice().sort((r, o) => r.y - o.y || r.x - o.x), s = [];
|
|
@@ -3506,9 +3600,9 @@ function ii(n, e) {
|
|
|
3506
3600
|
const o = i[i.length - 1], c = o !== void 0 && r.y <= o.y + o.height + 0.5, l = o !== void 0 && Math.max(o.x, r.x) < Math.min(o.x + o.width, r.x + r.width);
|
|
3507
3601
|
c && l ? i.push(r) : (i.length > 0 && s.push(i), i = [r]);
|
|
3508
3602
|
}
|
|
3509
|
-
return i.length > 0 && s.push(i), s.map((r) =>
|
|
3603
|
+
return i.length > 0 && s.push(i), s.map((r) => li(r, e)).filter(Boolean).join(" ");
|
|
3510
3604
|
}
|
|
3511
|
-
function
|
|
3605
|
+
function li(n, e) {
|
|
3512
3606
|
const t = [];
|
|
3513
3607
|
t.push({ x: n[0].x + n[0].width, y: n[0].y, convex: !0 });
|
|
3514
3608
|
for (let i = 0; i < n.length - 1; i++) {
|
|
@@ -3527,55 +3621,61 @@ function ri(n, e) {
|
|
|
3527
3621
|
t.push({ x: r.x, y: c, convex: l }), t.push({ x: o.x, y: c, convex: !l });
|
|
3528
3622
|
}
|
|
3529
3623
|
}
|
|
3530
|
-
return t.push({ x: n[0].x, y: n[0].y, convex: !0 }),
|
|
3624
|
+
return t.push({ x: n[0].x, y: n[0].y, convex: !0 }), ai(t, e);
|
|
3531
3625
|
}
|
|
3532
|
-
function
|
|
3626
|
+
function ai(n, e) {
|
|
3533
3627
|
const t = n.length;
|
|
3534
3628
|
if (t < 3)
|
|
3535
3629
|
return "";
|
|
3536
3630
|
const s = new Array(t);
|
|
3537
3631
|
for (let o = 0; o < t; o++) {
|
|
3538
|
-
const c = n[(o + t - 1) % t], l = n[(o + 1) % t], a =
|
|
3632
|
+
const c = n[(o + t - 1) % t], l = n[(o + 1) % t], a = ye(n[o], c), h = ye(n[o], l);
|
|
3539
3633
|
s[o] = Math.min(e, a / 2, h / 2);
|
|
3540
3634
|
}
|
|
3541
|
-
const i =
|
|
3635
|
+
const i = Re(n[t - 1], n[0], ye(n[t - 1], n[0]) - s[0]), r = [`M${$(i.x)},${$(i.y)}`];
|
|
3542
3636
|
for (let o = 0; o < t; o++) {
|
|
3543
|
-
const c = n[o], l = n[(o + 1) % t], a = s[o], h =
|
|
3544
|
-
a > 0 ? r.push(`A${
|
|
3545
|
-
const g = s[(o + 1) % t],
|
|
3546
|
-
r.push(`L${
|
|
3637
|
+
const c = n[o], l = n[(o + 1) % t], a = s[o], h = Re(c, l, a);
|
|
3638
|
+
a > 0 ? r.push(`A${$(a)},${$(a)} 0 0 ${c.convex ? 1 : 0} ${$(h.x)},${$(h.y)}`) : r.push(`L${$(h.x)},${$(h.y)}`);
|
|
3639
|
+
const g = s[(o + 1) % t], d = Re(c, l, ye(c, l) - g);
|
|
3640
|
+
r.push(`L${$(d.x)},${$(d.y)}`);
|
|
3547
3641
|
}
|
|
3548
3642
|
return r.push("Z"), r.join(" ");
|
|
3549
3643
|
}
|
|
3550
|
-
function
|
|
3644
|
+
function ye(n, e) {
|
|
3551
3645
|
return Math.hypot(n.x - e.x, n.y - e.y);
|
|
3552
3646
|
}
|
|
3553
|
-
function
|
|
3647
|
+
function Re(n, e, t) {
|
|
3554
3648
|
const s = e.x - n.x, i = e.y - n.y, r = Math.hypot(s, i);
|
|
3555
3649
|
if (r === 0)
|
|
3556
3650
|
return { x: n.x, y: n.y };
|
|
3557
3651
|
const o = t / r;
|
|
3558
3652
|
return { x: n.x + s * o, y: n.y + i * o };
|
|
3559
3653
|
}
|
|
3560
|
-
function
|
|
3654
|
+
function $(n) {
|
|
3561
3655
|
return n.toFixed(2);
|
|
3562
3656
|
}
|
|
3563
|
-
|
|
3657
|
+
const hi = 900;
|
|
3658
|
+
class $i extends le {
|
|
3564
3659
|
constructor(e, t) {
|
|
3565
|
-
super(), this._model = e, this._options = t, this.element = document.createElement("div"), this.element.className = "md-editor", this._options?.classNames && this.element.classList.add(...this._options.classNames), this.element.tabIndex = 0, this.
|
|
3660
|
+
super(), this._model = e, this._options = t, this.element = document.createElement("div"), this.element.className = "md-editor", this._options?.classNames && this.element.classList.add(...this._options.classNames), this.element.tabIndex = 0, this._contentContainer = document.createElement("div"), this._contentContainer.className = "md-editor-content", this.element.appendChild(this._contentContainer);
|
|
3661
|
+
const s = this._options?.limitedWidth ?? hn(hi);
|
|
3662
|
+
this._register(ee((i) => {
|
|
3663
|
+
const r = s.read(i);
|
|
3664
|
+
this._contentContainer.style.maxWidth = r === void 0 ? "" : `${r}px`;
|
|
3665
|
+
})), this.measuredLayout = new Hn(), this._selectionView = this._register(new ii(this._contentContainer, {
|
|
3566
3666
|
selection: this._model.selection,
|
|
3567
3667
|
visualLineMap: this.measuredLayout.visualLineMap,
|
|
3568
3668
|
blocks: this._selectionBlocksObs
|
|
3569
|
-
})), this.
|
|
3669
|
+
})), this._contentContainer.appendChild(this._selectionView.element), this._cursorView = this._register(new si(this._contentContainer, {
|
|
3570
3670
|
offset: this._model.cursorOffset,
|
|
3571
3671
|
visualLineMap: this.measuredLayout.visualLineMap
|
|
3572
|
-
})), this.
|
|
3672
|
+
})), this._contentContainer.appendChild(this._cursorView.element), this.editContext = new EditContext({
|
|
3573
3673
|
text: this._model.sourceText.get().value,
|
|
3574
3674
|
selectionStart: 0,
|
|
3575
3675
|
selectionEnd: 0
|
|
3576
|
-
}), this.element.editContext = this.editContext, this._register(
|
|
3577
|
-
const
|
|
3578
|
-
this.editContext.updateSelection(
|
|
3676
|
+
}), this.element.editContext = this.editContext, this._register(ee(this._renderAutorun)), this._register(ee((i) => {
|
|
3677
|
+
const r = i.readObservable(this._model.selection)?.range;
|
|
3678
|
+
this.editContext.updateSelection(r?.start ?? 0, r?.endExclusive ?? 0);
|
|
3579
3679
|
})), this._register({ dispose: () => {
|
|
3580
3680
|
this._document.get()?.dispose();
|
|
3581
3681
|
} });
|
|
@@ -3583,6 +3683,13 @@ class Ii extends te {
|
|
|
3583
3683
|
element;
|
|
3584
3684
|
editContext;
|
|
3585
3685
|
measuredLayout;
|
|
3686
|
+
/**
|
|
3687
|
+
* Inner container that holds the rendered document and the cursor/selection
|
|
3688
|
+
* overlays. The outer {@link element} spans the full width; this container
|
|
3689
|
+
* is what limited-width mode caps and centers, so the overlays (which anchor
|
|
3690
|
+
* to their parent's box) stay aligned with the content.
|
|
3691
|
+
*/
|
|
3692
|
+
_contentContainer;
|
|
3586
3693
|
_cursorView;
|
|
3587
3694
|
_selectionView;
|
|
3588
3695
|
/**
|
|
@@ -3591,7 +3698,7 @@ class Ii extends te {
|
|
|
3591
3698
|
* immutable node for the next. Never used for source-of-truth lookups
|
|
3592
3699
|
* (those go through the measured-layout model).
|
|
3593
3700
|
*/
|
|
3594
|
-
_document =
|
|
3701
|
+
_document = U(this, void 0);
|
|
3595
3702
|
/** The current view-node tree (AST overlaid with rendered DOM), for debugging. */
|
|
3596
3703
|
get documentViewNode() {
|
|
3597
3704
|
return this._document;
|
|
@@ -3604,7 +3711,7 @@ class Ii extends te {
|
|
|
3604
3711
|
*/
|
|
3605
3712
|
_previousViewData;
|
|
3606
3713
|
/** The current view-data tree (AST overlaid with selection flags), for debugging. */
|
|
3607
|
-
_viewData =
|
|
3714
|
+
_viewData = U(this, void 0);
|
|
3608
3715
|
get viewData() {
|
|
3609
3716
|
return this._viewData;
|
|
3610
3717
|
}
|
|
@@ -3613,7 +3720,7 @@ class Ii extends te {
|
|
|
3613
3720
|
* react to mount/unmount. Derived from {@link _document}, so it stays in
|
|
3614
3721
|
* lock-step without any manual bookkeeping.
|
|
3615
3722
|
*/
|
|
3616
|
-
_selectionBlocksObs =
|
|
3723
|
+
_selectionBlocksObs = V(this, (e) => {
|
|
3617
3724
|
const t = this._document.read(e);
|
|
3618
3725
|
return t ? t.blocks.map((s) => ({
|
|
3619
3726
|
block: s.node.block,
|
|
@@ -3631,7 +3738,7 @@ class Ii extends te {
|
|
|
3631
3738
|
* original block.
|
|
3632
3739
|
*/
|
|
3633
3740
|
resolveOffsetFromPoint(e) {
|
|
3634
|
-
const t =
|
|
3741
|
+
const t = Cs(e);
|
|
3635
3742
|
if (t)
|
|
3636
3743
|
return this._document.get()?.resolveSource(t);
|
|
3637
3744
|
}
|
|
@@ -3656,12 +3763,12 @@ class Ii extends te {
|
|
|
3656
3763
|
this.editContext.text !== s && this.editContext.updateText(0, this.editContext.text.length, s);
|
|
3657
3764
|
const o = this._document.get(), c = Qt(t, i, r?.range, this._previousViewData);
|
|
3658
3765
|
this._previousViewData = c, this._viewData.set(c, void 0);
|
|
3659
|
-
const l =
|
|
3766
|
+
const l = Xe.create(c, this._options, o);
|
|
3660
3767
|
if (o) {
|
|
3661
3768
|
if (l.contentDomNode !== o.contentDomNode)
|
|
3662
3769
|
throw new Error("DocumentViewNode.contentDomNode must be stable across rebuilds");
|
|
3663
3770
|
} else
|
|
3664
|
-
this.
|
|
3771
|
+
this._contentContainer.insertBefore(l.contentDomNode, this._contentContainer.firstChild);
|
|
3665
3772
|
this._document.set(l, void 0), this._publishMeasurements(l);
|
|
3666
3773
|
};
|
|
3667
3774
|
/** Current mounted blocks, or empty before the first render. */
|
|
@@ -3678,7 +3785,7 @@ class Ii extends te {
|
|
|
3678
3785
|
for (const s of e.blocks) {
|
|
3679
3786
|
const i = s.node.element.getBoundingClientRect();
|
|
3680
3787
|
s.node.recordMeasuredHeight(i.height);
|
|
3681
|
-
const r =
|
|
3788
|
+
const r = ke.measure([{
|
|
3682
3789
|
absoluteStart: s.absoluteStart,
|
|
3683
3790
|
viewNode: s.node
|
|
3684
3791
|
}]);
|
|
@@ -3694,31 +3801,91 @@ class Ii extends te {
|
|
|
3694
3801
|
this.measuredLayout.measurements.set(t, void 0);
|
|
3695
3802
|
}
|
|
3696
3803
|
}
|
|
3697
|
-
class
|
|
3698
|
-
|
|
3804
|
+
class di {
|
|
3805
|
+
connect(e) {
|
|
3806
|
+
const t = (o) => {
|
|
3807
|
+
const c = e.getSelectedText();
|
|
3808
|
+
c !== void 0 && (o.preventDefault(), o.clipboardData?.setData("text/plain", c));
|
|
3809
|
+
}, s = (o) => {
|
|
3810
|
+
const c = e.getSelectedText();
|
|
3811
|
+
c !== void 0 && (o.preventDefault(), o.clipboardData?.setData("text/plain", c), e.deleteSelection());
|
|
3812
|
+
}, i = (o) => {
|
|
3813
|
+
o.preventDefault();
|
|
3814
|
+
const c = o.clipboardData?.getData("text/plain");
|
|
3815
|
+
c && e.insertText(c);
|
|
3816
|
+
}, r = e.element;
|
|
3817
|
+
return r.addEventListener("copy", t), r.addEventListener("cut", s), r.addEventListener("paste", i), {
|
|
3818
|
+
dispose: () => {
|
|
3819
|
+
r.removeEventListener("copy", t), r.removeEventListener("cut", s), r.removeEventListener("paste", i);
|
|
3820
|
+
}
|
|
3821
|
+
};
|
|
3822
|
+
}
|
|
3823
|
+
}
|
|
3824
|
+
class Fi {
|
|
3825
|
+
constructor(e = navigator.clipboard) {
|
|
3826
|
+
this._clipboard = e;
|
|
3827
|
+
}
|
|
3828
|
+
connect(e) {
|
|
3829
|
+
const t = (i) => {
|
|
3830
|
+
if (!(!(i.ctrlKey || i.metaKey) || i.altKey))
|
|
3831
|
+
switch (i.key.toLowerCase()) {
|
|
3832
|
+
case "c": {
|
|
3833
|
+
const o = e.getSelectedText();
|
|
3834
|
+
if (o === void 0)
|
|
3835
|
+
return;
|
|
3836
|
+
i.preventDefault(), this._clipboard.writeText(o);
|
|
3837
|
+
break;
|
|
3838
|
+
}
|
|
3839
|
+
case "x": {
|
|
3840
|
+
const o = e.getSelectedText();
|
|
3841
|
+
if (o === void 0)
|
|
3842
|
+
return;
|
|
3843
|
+
i.preventDefault(), this._clipboard.writeText(o), e.deleteSelection();
|
|
3844
|
+
break;
|
|
3845
|
+
}
|
|
3846
|
+
case "v": {
|
|
3847
|
+
i.preventDefault(), this._clipboard.readText().then((o) => {
|
|
3848
|
+
o && e.insertText(o);
|
|
3849
|
+
});
|
|
3850
|
+
break;
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3853
|
+
}, s = e.element;
|
|
3854
|
+
return s.addEventListener("keydown", t), { dispose: () => s.removeEventListener("keydown", t) };
|
|
3855
|
+
}
|
|
3856
|
+
}
|
|
3857
|
+
class Vi extends le {
|
|
3858
|
+
constructor(e, t, s) {
|
|
3699
3859
|
super(), this._model = e, this._view = t;
|
|
3700
|
-
const
|
|
3701
|
-
|
|
3860
|
+
const i = this._view.element;
|
|
3861
|
+
i.addEventListener("mousedown", this._handleMouseDown), i.addEventListener("keydown", this._handleKeyDown), this._register({
|
|
3702
3862
|
dispose: () => {
|
|
3703
|
-
|
|
3863
|
+
i.removeEventListener("mousedown", this._handleMouseDown), i.removeEventListener("keydown", this._handleKeyDown);
|
|
3704
3864
|
}
|
|
3705
3865
|
});
|
|
3706
|
-
const
|
|
3707
|
-
|
|
3708
|
-
|
|
3866
|
+
const r = s?.clipboardStrategy ?? new di();
|
|
3867
|
+
this._register(r.connect({
|
|
3868
|
+
element: i,
|
|
3869
|
+
getSelectedText: () => this._selectedText(),
|
|
3870
|
+
deleteSelection: () => this._executeEditCommand(rt),
|
|
3871
|
+
insertText: (c) => this._executeEditCommand(rs(c))
|
|
3872
|
+
}));
|
|
3873
|
+
const o = this._view.editContext;
|
|
3874
|
+
o.addEventListener("textupdate", this._handleTextUpdate), this._register({
|
|
3875
|
+
dispose: () => o.removeEventListener("textupdate", this._handleTextUpdate)
|
|
3709
3876
|
});
|
|
3710
3877
|
}
|
|
3711
3878
|
_desiredColumn;
|
|
3712
3879
|
_handleTextUpdate = (e) => {
|
|
3713
|
-
const t =
|
|
3714
|
-
new
|
|
3880
|
+
const t = E.replace(
|
|
3881
|
+
new w(e.updateRangeStart, e.updateRangeEnd),
|
|
3715
3882
|
e.text
|
|
3716
3883
|
);
|
|
3717
3884
|
this._model.applyEdit(t);
|
|
3718
3885
|
};
|
|
3719
3886
|
_handleMouseDown = (e) => {
|
|
3720
3887
|
e.preventDefault(), this._view.focus(), this._desiredColumn = void 0;
|
|
3721
|
-
const t = new
|
|
3888
|
+
const t = new re(e.clientX, e.clientY);
|
|
3722
3889
|
if (!this._view.isPointInContent(t)) {
|
|
3723
3890
|
this._model.selection.set(void 0, void 0);
|
|
3724
3891
|
return;
|
|
@@ -3726,12 +3893,12 @@ class Bi extends te {
|
|
|
3726
3893
|
const s = this._view.resolveOffsetFromPoint(t) ?? this._model.sourceText.get().value.length;
|
|
3727
3894
|
if (e.detail === 2) {
|
|
3728
3895
|
const o = this._makeCursorContext();
|
|
3729
|
-
this._model.selection.set(
|
|
3896
|
+
this._model.selection.set(hs(o, s), void 0);
|
|
3730
3897
|
return;
|
|
3731
3898
|
}
|
|
3732
3899
|
if (e.detail === 3) {
|
|
3733
|
-
const o =
|
|
3734
|
-
o && this._model.selection.set(
|
|
3900
|
+
const o = ui(this._model.document.get(), s);
|
|
3901
|
+
o && this._model.selection.set(ds(this._makeCursorContext(), o), void 0);
|
|
3735
3902
|
return;
|
|
3736
3903
|
}
|
|
3737
3904
|
if (e.shiftKey) {
|
|
@@ -3740,7 +3907,7 @@ class Bi extends te {
|
|
|
3740
3907
|
} else
|
|
3741
3908
|
this._model.selection.set(x.collapsed(s), void 0);
|
|
3742
3909
|
const i = (o) => {
|
|
3743
|
-
const c = this._model.selection.get() ?? x.collapsed(s), l = this._view.resolveOffsetFromPoint(new
|
|
3910
|
+
const c = this._model.selection.get() ?? x.collapsed(s), l = this._view.resolveOffsetFromPoint(new re(o.clientX, o.clientY)) ?? c.active;
|
|
3744
3911
|
this._model.selection.set(new x(c.anchor, l), void 0);
|
|
3745
3912
|
}, r = () => {
|
|
3746
3913
|
document.removeEventListener("mousemove", i), document.removeEventListener("mouseup", r);
|
|
@@ -3782,25 +3949,12 @@ class Bi extends te {
|
|
|
3782
3949
|
}
|
|
3783
3950
|
/** Move the cursor down one visual line (Arrow Down). */
|
|
3784
3951
|
cursorDown(e = !1) {
|
|
3785
|
-
this._executeVisualCursorCommand(
|
|
3952
|
+
this._executeVisualCursorCommand(st, e);
|
|
3786
3953
|
}
|
|
3787
3954
|
/** Move the cursor up one visual line (Arrow Up). */
|
|
3788
3955
|
cursorUp(e = !1) {
|
|
3789
|
-
this._executeVisualCursorCommand(
|
|
3956
|
+
this._executeVisualCursorCommand(it, e);
|
|
3790
3957
|
}
|
|
3791
|
-
_handleCopy = (e) => {
|
|
3792
|
-
const t = this._selectedText();
|
|
3793
|
-
t !== void 0 && (e.preventDefault(), e.clipboardData?.setData("text/plain", t));
|
|
3794
|
-
};
|
|
3795
|
-
_handleCut = (e) => {
|
|
3796
|
-
const t = this._selectedText();
|
|
3797
|
-
t !== void 0 && (e.preventDefault(), e.clipboardData?.setData("text/plain", t), this._executeEditCommand(it));
|
|
3798
|
-
};
|
|
3799
|
-
_handlePaste = (e) => {
|
|
3800
|
-
e.preventDefault();
|
|
3801
|
-
const t = e.clipboardData?.getData("text/plain");
|
|
3802
|
-
t && this._executeEditCommand(ss(t));
|
|
3803
|
-
};
|
|
3804
3958
|
_selectedText() {
|
|
3805
3959
|
const e = this._model.selection.get();
|
|
3806
3960
|
if (!(!e || e.isCollapsed))
|
|
@@ -3809,29 +3963,29 @@ class Bi extends te {
|
|
|
3809
3963
|
_handleKeyDown = (e) => {
|
|
3810
3964
|
const t = e.ctrlKey || e.metaKey;
|
|
3811
3965
|
if (e.key === "ArrowLeft")
|
|
3812
|
-
e.preventDefault(), t ? this._executeCursorCommand((e.shiftKey,
|
|
3966
|
+
e.preventDefault(), t ? this._executeCursorCommand((e.shiftKey, nt), e.shiftKey) : e.shiftKey ? this._executeCursorCommand(Un, !0) : this._executeCursorCommand(Xn, !1);
|
|
3813
3967
|
else if (e.key === "ArrowRight")
|
|
3814
|
-
e.preventDefault(), t ? this._executeCursorCommand(
|
|
3968
|
+
e.preventDefault(), t ? this._executeCursorCommand(Yn, e.shiftKey) : e.shiftKey ? this._executeCursorCommand(Qn, !0) : this._executeCursorCommand(zn, !1);
|
|
3815
3969
|
else if (e.key === "ArrowUp")
|
|
3816
|
-
e.preventDefault(), this._executeVisualCursorCommand(
|
|
3970
|
+
e.preventDefault(), this._executeVisualCursorCommand(it, e.shiftKey);
|
|
3817
3971
|
else if (e.key === "ArrowDown")
|
|
3818
|
-
e.preventDefault(), this._executeVisualCursorCommand(
|
|
3972
|
+
e.preventDefault(), this._executeVisualCursorCommand(st, e.shiftKey);
|
|
3819
3973
|
else if (e.key === "Home")
|
|
3820
|
-
e.preventDefault(), t ? this._executeCursorCommand(
|
|
3974
|
+
e.preventDefault(), t ? this._executeCursorCommand(es, e.shiftKey) : this._executeCursorCommand(Jn, e.shiftKey);
|
|
3821
3975
|
else if (e.key === "End")
|
|
3822
|
-
e.preventDefault(), t ? this._executeCursorCommand(
|
|
3976
|
+
e.preventDefault(), t ? this._executeCursorCommand(ts, e.shiftKey) : this._executeCursorCommand(Zn, e.shiftKey);
|
|
3823
3977
|
else if (e.key === "a" && t) {
|
|
3824
3978
|
e.preventDefault();
|
|
3825
3979
|
const s = this._makeCursorContext();
|
|
3826
|
-
this._model.selection.set(
|
|
3827
|
-
} else e.key === "Backspace" ? (e.preventDefault(), this._executeEditCommand(t ?
|
|
3980
|
+
this._model.selection.set(as(s), void 0);
|
|
3981
|
+
} else e.key === "Backspace" ? (e.preventDefault(), this._executeEditCommand(t ? ss : rt)) : e.key === "Delete" ? (e.preventDefault(), this._executeEditCommand(t ? is : ns)) : e.key === "Enter" && (e.preventDefault(), this._executeEditCommand(t ? os : e.shiftKey ? ls : cs));
|
|
3828
3982
|
};
|
|
3829
3983
|
}
|
|
3830
|
-
function
|
|
3984
|
+
function ui(n, e) {
|
|
3831
3985
|
let t = 0;
|
|
3832
3986
|
for (const s of n.children) {
|
|
3833
3987
|
if (n.blocks.includes(s)) {
|
|
3834
|
-
const i =
|
|
3988
|
+
const i = w.ofStartAndLength(t, s.length);
|
|
3835
3989
|
if (i.contains(e) || i.endExclusive === e)
|
|
3836
3990
|
return i;
|
|
3837
3991
|
}
|
|
@@ -3839,7 +3993,7 @@ function ci(n, e) {
|
|
|
3839
3993
|
}
|
|
3840
3994
|
}
|
|
3841
3995
|
const Ct = "md-debug-show-line-rects";
|
|
3842
|
-
function
|
|
3996
|
+
function fi(n, e) {
|
|
3843
3997
|
try {
|
|
3844
3998
|
const t = localStorage.getItem(n);
|
|
3845
3999
|
return t === null ? e : t === "true";
|
|
@@ -3847,13 +4001,13 @@ function li(n, e) {
|
|
|
3847
4001
|
return e;
|
|
3848
4002
|
}
|
|
3849
4003
|
}
|
|
3850
|
-
function
|
|
4004
|
+
function gi(n, e) {
|
|
3851
4005
|
try {
|
|
3852
4006
|
localStorage.setItem(n, String(e));
|
|
3853
4007
|
} catch {
|
|
3854
4008
|
}
|
|
3855
4009
|
}
|
|
3856
|
-
class
|
|
4010
|
+
class Pi extends le {
|
|
3857
4011
|
constructor(e, t) {
|
|
3858
4012
|
super(), this._overlayParent = e, this.overlayElement = document.createElement("div"), this.overlayElement.className = "md-debug-layout-overlay", Object.assign(this.overlayElement.style, {
|
|
3859
4013
|
position: "absolute",
|
|
@@ -3882,16 +4036,16 @@ class Ri extends te {
|
|
|
3882
4036
|
});
|
|
3883
4037
|
const i = document.createElement("input");
|
|
3884
4038
|
i.type = "checkbox", i.checked = this._showLineRects.get(), i.addEventListener("change", () => {
|
|
3885
|
-
this._showLineRects.set(i.checked, void 0),
|
|
4039
|
+
this._showLineRects.set(i.checked, void 0), gi(Ct, i.checked);
|
|
3886
4040
|
}), s.appendChild(i), s.appendChild(document.createTextNode("show line rects")), this.infoElement.appendChild(s);
|
|
3887
4041
|
const r = document.createElement("pre");
|
|
3888
|
-
r.style.margin = "0", r.style.whiteSpace = "pre", this.infoElement.appendChild(r), this.rendering =
|
|
4042
|
+
r.style.margin = "0", r.style.whiteSpace = "pre", this.infoElement.appendChild(r), this.rendering = V(this, (o) => {
|
|
3889
4043
|
const c = o.readObservable(t.model.measurements), l = o.readObservable(this._showLineRects);
|
|
3890
|
-
return
|
|
3891
|
-
}), this.mappedOffsets =
|
|
4044
|
+
return mi(this.overlayElement, r, this._overlayParent, c, l, t.colorForOffset, t.hoveredOffset);
|
|
4045
|
+
}), this.mappedOffsets = V(this, (o) => o.readObservable(this.rendering).mappedOffsets), this._register(ee((o) => {
|
|
3892
4046
|
o.readObservable(this.rendering);
|
|
3893
4047
|
const c = t.hoveredOffset ? o.readObservable(t.hoveredOffset) : void 0;
|
|
3894
|
-
t.hoveredOffset &&
|
|
4048
|
+
t.hoveredOffset && _i(this.overlayElement, c);
|
|
3895
4049
|
}));
|
|
3896
4050
|
}
|
|
3897
4051
|
overlayElement;
|
|
@@ -3900,14 +4054,14 @@ class Ri extends te {
|
|
|
3900
4054
|
/** Absolute source offsets that map to a rendered DOM character. */
|
|
3901
4055
|
mappedOffsets;
|
|
3902
4056
|
/** Whether the dashed line-bands and run boxes are drawn (persisted). */
|
|
3903
|
-
_showLineRects =
|
|
4057
|
+
_showLineRects = U(this, fi(Ct, !0));
|
|
3904
4058
|
}
|
|
3905
|
-
class
|
|
4059
|
+
class pi {
|
|
3906
4060
|
constructor(e, t, s, i) {
|
|
3907
4061
|
this.blockCount = e, this.mountedCount = t, this.lineCount = s, this.mappedOffsets = i;
|
|
3908
4062
|
}
|
|
3909
4063
|
}
|
|
3910
|
-
function
|
|
4064
|
+
function mi(n, e, t, s, i, r, o) {
|
|
3911
4065
|
n.textContent = "";
|
|
3912
4066
|
const c = t.getBoundingClientRect();
|
|
3913
4067
|
let l = 0, a = 0, h = 0;
|
|
@@ -3915,53 +4069,53 @@ function ui(n, e, t, s, i, r, o) {
|
|
|
3915
4069
|
for (let f = 0; f < s.length; f++) {
|
|
3916
4070
|
const p = s[f], m = p.visualLineMap?.lines ?? [];
|
|
3917
4071
|
if (p.isMeasured && l++, a += m.length, i)
|
|
3918
|
-
for (let
|
|
3919
|
-
const v = m[
|
|
3920
|
-
Object.assign(
|
|
4072
|
+
for (let _ = 0; _ < m.length; _++) {
|
|
4073
|
+
const v = m[_], y = v.rect, M = document.createElement("div");
|
|
4074
|
+
Object.assign(M.style, {
|
|
3921
4075
|
position: "absolute",
|
|
3922
4076
|
left: "0",
|
|
3923
4077
|
right: "0",
|
|
3924
|
-
top: `${
|
|
3925
|
-
height: `${
|
|
4078
|
+
top: `${y.y - c.top}px`,
|
|
4079
|
+
height: `${y.height}px`,
|
|
3926
4080
|
border: "1px dashed rgba(180, 0, 200, 0.45)",
|
|
3927
4081
|
boxSizing: "border-box"
|
|
3928
|
-
}), n.appendChild(
|
|
3929
|
-
for (const
|
|
3930
|
-
const
|
|
3931
|
-
Object.assign(
|
|
4082
|
+
}), n.appendChild(M);
|
|
4083
|
+
for (const A of v.runs) {
|
|
4084
|
+
const de = document.createElement("div");
|
|
4085
|
+
Object.assign(de.style, {
|
|
3932
4086
|
position: "absolute",
|
|
3933
|
-
left: `${
|
|
3934
|
-
top: `${
|
|
3935
|
-
width: `${
|
|
3936
|
-
height: `${
|
|
4087
|
+
left: `${A.rect.x - c.left}px`,
|
|
4088
|
+
top: `${A.rect.y - c.top}px`,
|
|
4089
|
+
width: `${A.rect.width}px`,
|
|
4090
|
+
height: `${A.rect.height}px`,
|
|
3937
4091
|
outline: "1px solid rgba(255, 100, 0, 0.45)",
|
|
3938
4092
|
boxSizing: "border-box"
|
|
3939
|
-
}), n.appendChild(
|
|
4093
|
+
}), n.appendChild(de);
|
|
3940
4094
|
}
|
|
3941
4095
|
}
|
|
3942
|
-
p.viewNode && (h +=
|
|
4096
|
+
p.viewNode && (h += wi(n, c, p.viewNode, p.absoluteStart, g, r, o));
|
|
3943
4097
|
}
|
|
3944
|
-
const
|
|
3945
|
-
const m = f.isMeasured ? "M" : "e",
|
|
3946
|
-
return `${String(p).padStart(2)} ${m} start=${String(f.absoluteStart).padStart(4)} h=${f.height.toFixed(1).padStart(6)} lines=${
|
|
4098
|
+
const d = `blocks: ${s.length} mounted: ${l} lines: ${a} chars: ${h}`, u = s.map((f, p) => {
|
|
4099
|
+
const m = f.isMeasured ? "M" : "e", _ = f.visualLineMap?.lines.length ?? 0;
|
|
4100
|
+
return `${String(p).padStart(2)} ${m} start=${String(f.absoluteStart).padStart(4)} h=${f.height.toFixed(1).padStart(6)} lines=${_} kind=${f.block.kind}`;
|
|
3947
4101
|
});
|
|
3948
|
-
return e.textContent = [
|
|
3949
|
-
`), new
|
|
4102
|
+
return e.textContent = [d, ...u].join(`
|
|
4103
|
+
`), new pi(s.length, l, a, g);
|
|
3950
4104
|
}
|
|
3951
|
-
function
|
|
4105
|
+
function wi(n, e, t, s, i, r, o) {
|
|
3952
4106
|
let c = 0;
|
|
3953
4107
|
const l = document.createRange(), a = s + t.sourceLength, h = [];
|
|
3954
|
-
t.forEachTextLeaf(s, (
|
|
3955
|
-
h.push({ start:
|
|
4108
|
+
t.forEachTextLeaf(s, (d, u) => {
|
|
4109
|
+
h.push({ start: u, end: u + d.sourceLength });
|
|
3956
4110
|
});
|
|
3957
|
-
const g = (
|
|
3958
|
-
for (let
|
|
3959
|
-
if (!g(
|
|
4111
|
+
const g = (d) => h.some((u) => d >= u.start && d < u.end);
|
|
4112
|
+
for (let d = s; d < a; d++) {
|
|
4113
|
+
if (!g(d))
|
|
3960
4114
|
continue;
|
|
3961
|
-
const
|
|
3962
|
-
if (!
|
|
4115
|
+
const u = t.sourceToDom(d + 1, s);
|
|
4116
|
+
if (!u || u.offset < 1)
|
|
3963
4117
|
continue;
|
|
3964
|
-
l.setStart(
|
|
4118
|
+
l.setStart(u.node, u.offset - 1), l.setEnd(u.node, u.offset);
|
|
3965
4119
|
const f = l.getBoundingClientRect();
|
|
3966
4120
|
if (f.height === 0)
|
|
3967
4121
|
continue;
|
|
@@ -3972,16 +4126,16 @@ function di(n, e, t, s, i, r, o) {
|
|
|
3972
4126
|
top: `${f.y - e.top}px`,
|
|
3973
4127
|
width: `${p}px`,
|
|
3974
4128
|
height: `${f.height}px`,
|
|
3975
|
-
background: r?.(
|
|
4129
|
+
background: r?.(d) ?? "rgba(0, 120, 220, 0.30)",
|
|
3976
4130
|
boxSizing: "border-box",
|
|
3977
4131
|
pointerEvents: "auto"
|
|
3978
4132
|
});
|
|
3979
|
-
const
|
|
3980
|
-
m.title = `offset ${
|
|
4133
|
+
const _ = u.node.data?.[u.offset - 1] ?? "";
|
|
4134
|
+
m.title = `offset ${d}: ${JSON.stringify(_)}`, m.dataset.offset = String(d), o ? (m.addEventListener("mouseenter", () => o.set(d, void 0)), m.addEventListener("mouseleave", () => o.set(void 0, void 0))) : (m.addEventListener("mouseenter", () => Ot(n, m, !0)), m.addEventListener("mouseleave", () => Ot(n, m, !1))), n.appendChild(m), i.add(d), c++;
|
|
3981
4135
|
}
|
|
3982
4136
|
return c;
|
|
3983
4137
|
}
|
|
3984
|
-
function
|
|
4138
|
+
function _i(n, e) {
|
|
3985
4139
|
for (const t of Array.from(n.children)) {
|
|
3986
4140
|
if (!t.style)
|
|
3987
4141
|
continue;
|
|
@@ -3993,12 +4147,12 @@ function Ot(n, e, t) {
|
|
|
3993
4147
|
for (const s of Array.from(n.children))
|
|
3994
4148
|
s.style.visibility = t && s !== e ? "hidden" : "";
|
|
3995
4149
|
}
|
|
3996
|
-
class
|
|
4150
|
+
class me {
|
|
3997
4151
|
constructor(e, t) {
|
|
3998
4152
|
this.length = e, this.className = t;
|
|
3999
4153
|
}
|
|
4000
4154
|
}
|
|
4001
|
-
class
|
|
4155
|
+
class ki {
|
|
4002
4156
|
/**
|
|
4003
4157
|
* @param _monaco The Monarch runtime ({@link IMonarchApi}), injected so this
|
|
4004
4158
|
* package depends on `monaco-editor` for types only.
|
|
@@ -4009,7 +4163,7 @@ class gi {
|
|
|
4009
4163
|
}
|
|
4010
4164
|
_tokenizers = /* @__PURE__ */ new Map();
|
|
4011
4165
|
create(e, t) {
|
|
4012
|
-
return new
|
|
4166
|
+
return new xi(this._tokenizerFor(e), t);
|
|
4013
4167
|
}
|
|
4014
4168
|
dispose() {
|
|
4015
4169
|
for (const e of this._tokenizers.values())
|
|
@@ -4021,13 +4175,13 @@ class gi {
|
|
|
4021
4175
|
if (t === void 0)
|
|
4022
4176
|
return;
|
|
4023
4177
|
let s = this._tokenizers.get(e);
|
|
4024
|
-
return s || (s = new this._monaco.MonarchTokenizer(
|
|
4178
|
+
return s || (s = new this._monaco.MonarchTokenizer(Ei, Ci, e, this._monaco.compile(e, t), Oi), this._tokenizers.set(e, s)), s;
|
|
4025
4179
|
}
|
|
4026
4180
|
}
|
|
4027
|
-
class
|
|
4181
|
+
class xi {
|
|
4028
4182
|
constructor(e, t) {
|
|
4029
4183
|
this._tokenizer = e, this._initialState = e?.getInitialState(), this._text = t, this._lines = this._tokenizeFrom(0, [], this._initialState, t.split(`
|
|
4030
|
-
`)), this._lineStarts = this._computeLineStarts(), this._snapshotObs =
|
|
4184
|
+
`)), this._lineStarts = this._computeLineStarts(), this._snapshotObs = U("syntaxSnapshot", new Tt(this, this._version));
|
|
4031
4185
|
}
|
|
4032
4186
|
_text;
|
|
4033
4187
|
_lines;
|
|
@@ -4045,11 +4199,11 @@ class pi {
|
|
|
4045
4199
|
throw new Error("document is disposed");
|
|
4046
4200
|
if (e.isEmpty)
|
|
4047
4201
|
return;
|
|
4048
|
-
const s =
|
|
4202
|
+
const s = Mt(this._lines), i = e.apply(this._text), r = e.replacements[0].replaceRange.start, o = this._lineIndexAt(r), c = this._lines.slice(0, o), l = o === 0 ? this._initialState : this._lines[o - 1].endState;
|
|
4049
4203
|
this._text = i, this._lines = this._tokenizeFrom(o, c, l, i.split(`
|
|
4050
4204
|
`)), this._lineStarts = this._computeLineStarts(), this._version++;
|
|
4051
|
-
const a =
|
|
4052
|
-
this._snapshotObs.set(new
|
|
4205
|
+
const a = yi(s, Mt(this._lines));
|
|
4206
|
+
this._snapshotObs.set(new Tt(this, this._version), t, a);
|
|
4053
4207
|
}
|
|
4054
4208
|
dispose() {
|
|
4055
4209
|
this._disposed = !0;
|
|
@@ -4066,9 +4220,9 @@ class pi {
|
|
|
4066
4220
|
const l = i[c], a = c < i.length - 1;
|
|
4067
4221
|
if (this._tokenizer && o) {
|
|
4068
4222
|
const h = this._tokenizer.tokenize(l, a, o);
|
|
4069
|
-
r.push({ text: l, tokens:
|
|
4223
|
+
r.push({ text: l, tokens: bi(h.tokens, l.length), endState: h.endState }), o = h.endState;
|
|
4070
4224
|
} else
|
|
4071
|
-
r.push({ text: l, tokens: l.length === 0 ? [] : [new
|
|
4225
|
+
r.push({ text: l, tokens: l.length === 0 ? [] : [new me(l.length, void 0)], endState: o });
|
|
4072
4226
|
}
|
|
4073
4227
|
return r;
|
|
4074
4228
|
}
|
|
@@ -4091,19 +4245,19 @@ class pi {
|
|
|
4091
4245
|
throw new Error("stale snapshot");
|
|
4092
4246
|
const s = this._text.length, i = Math.max(0, Math.min(t.start, s)), r = Math.max(i, Math.min(t.endExclusive, s)), o = [];
|
|
4093
4247
|
let c = i, l = i, a = !1, h = 0;
|
|
4094
|
-
const g = (
|
|
4095
|
-
const f = h, p = h +
|
|
4096
|
-
h = p,
|
|
4248
|
+
const g = (d, u) => {
|
|
4249
|
+
const f = h, p = h + d;
|
|
4250
|
+
h = p, d !== 0 && f < r && p > i && (a || (c = f, a = !0), o.push(new me(d, u)), l = p);
|
|
4097
4251
|
};
|
|
4098
|
-
for (let
|
|
4099
|
-
for (const
|
|
4100
|
-
g(
|
|
4101
|
-
|
|
4252
|
+
for (let d = 0; d < this._lines.length && h < r; d++) {
|
|
4253
|
+
for (const u of this._lines[d].tokens)
|
|
4254
|
+
g(u.length, u.className);
|
|
4255
|
+
d < this._lines.length - 1 && g(1, void 0);
|
|
4102
4256
|
}
|
|
4103
|
-
return { range: new
|
|
4257
|
+
return { range: new w(c, a ? l : i), tokens: o };
|
|
4104
4258
|
}
|
|
4105
4259
|
}
|
|
4106
|
-
class
|
|
4260
|
+
class Tt {
|
|
4107
4261
|
constructor(e, t) {
|
|
4108
4262
|
this._doc = e, this._version = t;
|
|
4109
4263
|
}
|
|
@@ -4111,25 +4265,25 @@ class Mt {
|
|
|
4111
4265
|
return this._doc._getTokens(this._version, e);
|
|
4112
4266
|
}
|
|
4113
4267
|
}
|
|
4114
|
-
function
|
|
4268
|
+
function vi(n) {
|
|
4115
4269
|
return n === "" ? void 0 : n;
|
|
4116
4270
|
}
|
|
4117
|
-
function
|
|
4271
|
+
function bi(n, e) {
|
|
4118
4272
|
if (n.length === 0)
|
|
4119
|
-
return e === 0 ? [] : [new
|
|
4273
|
+
return e === 0 ? [] : [new me(e, void 0)];
|
|
4120
4274
|
const t = [];
|
|
4121
4275
|
for (let s = 0; s < n.length; s++) {
|
|
4122
4276
|
const i = n[s].offset, r = s + 1 < n.length ? n[s + 1].offset : e;
|
|
4123
|
-
r > i && t.push(new
|
|
4277
|
+
r > i && t.push(new me(r - i, vi(n[s].type)));
|
|
4124
4278
|
}
|
|
4125
4279
|
return t;
|
|
4126
4280
|
}
|
|
4127
|
-
function
|
|
4281
|
+
function Mt(n) {
|
|
4128
4282
|
const e = [];
|
|
4129
4283
|
for (let t = 0; t < n.length; t++) {
|
|
4130
4284
|
for (const s of n[t].tokens)
|
|
4131
4285
|
e.push(s);
|
|
4132
|
-
t < n.length - 1 && e.push(new
|
|
4286
|
+
t < n.length - 1 && e.push(new me(1, void 0));
|
|
4133
4287
|
}
|
|
4134
4288
|
return e;
|
|
4135
4289
|
}
|
|
@@ -4142,7 +4296,7 @@ function Lt(n) {
|
|
|
4142
4296
|
e += t.length;
|
|
4143
4297
|
return e;
|
|
4144
4298
|
}
|
|
4145
|
-
function
|
|
4299
|
+
function yi(n, e) {
|
|
4146
4300
|
const t = n.length, s = e.length;
|
|
4147
4301
|
let i = 0, r = 0;
|
|
4148
4302
|
for (; i < t && i < s && St(n[i], e[i]); )
|
|
@@ -4150,24 +4304,24 @@ function wi(n, e) {
|
|
|
4150
4304
|
let o = 0, c = 0;
|
|
4151
4305
|
for (; o < t - i && o < s - i && St(n[t - 1 - o], e[s - 1 - o]); )
|
|
4152
4306
|
c += n[t - 1 - o].length, o++;
|
|
4153
|
-
const l = Lt(n), a = Lt(e), h = new
|
|
4154
|
-
return h.isEmpty && g === 0 ?
|
|
4307
|
+
const l = Lt(n), a = Lt(e), h = new w(r, l - c), g = a - c - r;
|
|
4308
|
+
return h.isEmpty && g === 0 ? ie.empty : ie.replace(h, g);
|
|
4155
4309
|
}
|
|
4156
|
-
const
|
|
4310
|
+
const Ei = {
|
|
4157
4311
|
languageIdCodec: { encodeLanguageId: () => 0, decodeLanguageId: () => "" },
|
|
4158
4312
|
isRegisteredLanguageId: () => !1,
|
|
4159
4313
|
getLanguageIdByLanguageName: () => null,
|
|
4160
4314
|
getLanguageIdByMimeType: () => null,
|
|
4161
4315
|
requestBasicLanguageFeatures: () => {
|
|
4162
4316
|
}
|
|
4163
|
-
},
|
|
4317
|
+
}, Ci = {
|
|
4164
4318
|
getColorTheme: () => ({ tokenTheme: {} })
|
|
4165
|
-
},
|
|
4319
|
+
}, Oi = {
|
|
4166
4320
|
getValue: () => 2e4,
|
|
4167
4321
|
onDidChangeConfiguration: () => ({ dispose() {
|
|
4168
4322
|
} })
|
|
4169
4323
|
};
|
|
4170
|
-
function
|
|
4324
|
+
function Ki(n, e) {
|
|
4171
4325
|
const t = /* @__PURE__ */ new Map([
|
|
4172
4326
|
["typescript", e.typescript],
|
|
4173
4327
|
["ts", e.typescript],
|
|
@@ -4183,92 +4337,94 @@ function Di(n, e) {
|
|
|
4183
4337
|
["sh", e.shell],
|
|
4184
4338
|
["bash", e.shell]
|
|
4185
4339
|
]);
|
|
4186
|
-
return new
|
|
4340
|
+
return new ki(n, t);
|
|
4187
4341
|
}
|
|
4188
4342
|
export {
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4343
|
+
N as AstNode,
|
|
4344
|
+
Fi as AsyncClipboardStrategy,
|
|
4345
|
+
oe as BlockQuoteAstNode,
|
|
4346
|
+
T as BlockViewNode,
|
|
4347
|
+
D as CodeBlockAstNode,
|
|
4348
|
+
Ge as CodeBlockViewNode,
|
|
4349
|
+
si as CursorView,
|
|
4195
4350
|
yt as CursorViewRendering,
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4351
|
+
He as DocumentAstNode,
|
|
4352
|
+
Xe as DocumentViewNode,
|
|
4353
|
+
Vi as EditorController,
|
|
4354
|
+
Ai as EditorModel,
|
|
4355
|
+
$i as EditorView,
|
|
4356
|
+
Fe as EmphasisAstNode,
|
|
4357
|
+
R as GlueAstNode,
|
|
4358
|
+
J as HeadingAstNode,
|
|
4359
|
+
_e as ImageAstNode,
|
|
4360
|
+
Pe as InlineCodeAstNode,
|
|
4361
|
+
Ke as InlineMathAstNode,
|
|
4362
|
+
ie as LengthEdit,
|
|
4363
|
+
Ae as LengthReplacement,
|
|
4364
|
+
we as LinkAstNode,
|
|
4365
|
+
K as ListAstNode,
|
|
4366
|
+
H as ListItemAstNode,
|
|
4367
|
+
Mn as MarkdownParser,
|
|
4213
4368
|
k as MarkerAstNode,
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4369
|
+
ne as MathBlockAstNode,
|
|
4370
|
+
pi as MeasuredLayoutDebugRendering,
|
|
4371
|
+
Pi as MeasuredLayoutDebugView,
|
|
4372
|
+
Hn as MeasuredLayoutModel,
|
|
4373
|
+
ki as MonacoSyntaxHighlighter,
|
|
4374
|
+
di as NativeClipboardStrategy,
|
|
4375
|
+
w as OffsetRange,
|
|
4376
|
+
j as ParagraphAstNode,
|
|
4377
|
+
re as Point2D,
|
|
4378
|
+
B as Rect2D,
|
|
4223
4379
|
x as Selection,
|
|
4224
|
-
|
|
4380
|
+
ii as SelectionView,
|
|
4225
4381
|
Et as SelectionViewRendering,
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4382
|
+
Ve as StrikethroughAstNode,
|
|
4383
|
+
E as StringEdit,
|
|
4384
|
+
q as StringReplacement,
|
|
4385
|
+
Le as StringValue,
|
|
4386
|
+
$e as StrongAstNode,
|
|
4387
|
+
ce as TableAstNode,
|
|
4388
|
+
pe as TableCellAstNode,
|
|
4389
|
+
ge as TableRowAstNode,
|
|
4390
|
+
Ee as TextAstNode,
|
|
4391
|
+
te as ThematicBreakAstNode,
|
|
4392
|
+
me as Token,
|
|
4393
|
+
ae as ViewNode,
|
|
4394
|
+
Dn as VisualLine,
|
|
4395
|
+
ke as VisualLineMap,
|
|
4396
|
+
Be as VisualRun,
|
|
4397
|
+
Ki as createDefaultMonacoSyntaxHighlighter,
|
|
4398
|
+
ts as cursorDocumentEnd,
|
|
4399
|
+
es as cursorDocumentStart,
|
|
4400
|
+
st as cursorDown,
|
|
4401
|
+
Xn as cursorLeft,
|
|
4402
|
+
Zn as cursorLineEnd,
|
|
4403
|
+
Jn as cursorLineStart,
|
|
4404
|
+
Un as cursorMoveLeft,
|
|
4405
|
+
Qn as cursorMoveRight,
|
|
4406
|
+
zn as cursorRight,
|
|
4407
|
+
it as cursorUp,
|
|
4408
|
+
nt as cursorWordLeft,
|
|
4409
|
+
Yn as cursorWordRight,
|
|
4410
|
+
rt as deleteLeft,
|
|
4411
|
+
ns as deleteRight,
|
|
4412
|
+
ss as deleteWordLeft,
|
|
4413
|
+
is as deleteWordRight,
|
|
4414
|
+
gn as findNodeOffsetById,
|
|
4415
|
+
dn as findWordAt,
|
|
4416
|
+
Nt as findWordBoundaryLeft,
|
|
4417
|
+
Rt as findWordBoundaryRight,
|
|
4418
|
+
Sn as getAnnotatedSource,
|
|
4419
|
+
ls as insertHardLineBreak,
|
|
4420
|
+
cs as insertLineBreak,
|
|
4421
|
+
os as insertParagraph,
|
|
4422
|
+
rs as insertText,
|
|
4267
4423
|
Vt as nextCursorPosition,
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4424
|
+
as as selectAll,
|
|
4425
|
+
ds as selectBlock,
|
|
4426
|
+
hs as selectWord,
|
|
4427
|
+
Bi as taskCheckboxRange,
|
|
4428
|
+
Di as visualizeAst
|
|
4273
4429
|
};
|
|
4274
4430
|
//# sourceMappingURL=index.js.map
|