@vscode/markdown-editor 0.0.2-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/commands/cursorCommands.d.ts +13 -0
  2. package/dist/commands/editCommands.d.ts +14 -0
  3. package/dist/commands/index.d.ts +4 -0
  4. package/dist/commands/selectionCommands.d.ts +6 -0
  5. package/dist/commands/types.d.ts +26 -0
  6. package/dist/core/geometry.d.ts +37 -0
  7. package/dist/core/index.d.ts +8 -0
  8. package/dist/core/lengthEdit.d.ts +38 -0
  9. package/dist/core/offsetRange.d.ts +26 -0
  10. package/dist/core/selection.d.ts +13 -0
  11. package/dist/core/sourceOffset.d.ts +1 -0
  12. package/dist/core/stringEdit.d.ts +27 -0
  13. package/dist/core/stringValue.d.ts +8 -0
  14. package/dist/core/wordUtils.d.ts +6 -0
  15. package/dist/highlighter/defaultMonacoSyntaxHighlighter.d.ts +20 -0
  16. package/dist/highlighter/index.d.ts +3 -0
  17. package/dist/highlighter/monacoSyntaxHighlighter.d.ts +38 -0
  18. package/dist/highlighter/syntaxHighlighter.d.ts +67 -0
  19. package/dist/index.d.ts +6 -0
  20. package/dist/index.js +4274 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/model/cursorNavigation.d.ts +7 -0
  23. package/dist/model/editorModel.d.ts +54 -0
  24. package/dist/model/index.d.ts +4 -0
  25. package/dist/model/measuredLayoutModel.d.ts +50 -0
  26. package/dist/observables.d.ts +1 -0
  27. package/dist/observables.js +463 -0
  28. package/dist/observables.js.map +1 -0
  29. package/dist/parser/_micromarkAdapter.d.ts +7 -0
  30. package/dist/parser/ast.d.ts +274 -0
  31. package/dist/parser/index.d.ts +4 -0
  32. package/dist/parser/parse.d.ts +2 -0
  33. package/dist/parser/parser.d.ts +14 -0
  34. package/dist/parser/reconcile.d.ts +33 -0
  35. package/dist/parser/test/getAnnotatedSource.d.ts +2 -0
  36. package/dist/parser/test/snapshot.d.ts +9 -0
  37. package/dist/parser/visualizeAst.d.ts +33 -0
  38. package/dist/runOnChange-owE1SMC0.js +1514 -0
  39. package/dist/runOnChange-owE1SMC0.js.map +1 -0
  40. package/dist/test/random.d.ts +16 -0
  41. package/dist/view/content/blockView.d.ts +179 -0
  42. package/dist/view/content/documentView.d.ts +41 -0
  43. package/dist/view/content/dom.d.ts +16 -0
  44. package/dist/view/content/katexEditableIdentifiers.d.ts +36 -0
  45. package/dist/view/content/viewNode.d.ts +93 -0
  46. package/dist/view/editorController.d.ts +34 -0
  47. package/dist/view/editorView.d.ts +100 -0
  48. package/dist/view/fixture/astViewerView.d.ts +27 -0
  49. package/dist/view/fixture/cyclingTsHighlighter.d.ts +17 -0
  50. package/dist/view/fixture/debugColors.d.ts +26 -0
  51. package/dist/view/fixture/monacoDebugPanel.d.ts +7 -0
  52. package/dist/view/index.d.ts +9 -0
  53. package/dist/view/measuredLayoutDebugView.d.ts +70 -0
  54. package/dist/view/parts/cursorView.d.ts +29 -0
  55. package/dist/view/parts/selectionView.d.ts +57 -0
  56. package/dist/view/viewData.d.ts +251 -0
  57. package/dist/view/visualLineMap.d.ts +157 -0
  58. package/dist/view/visualizeViewTree.d.ts +5 -0
  59. package/package.json +68 -0
  60. package/src/view/editor.css +517 -0
  61. package/src/view/themes/default.css +235 -0
  62. package/src/view/themes/github.css +308 -0
@@ -0,0 +1,517 @@
1
+ /*
2
+ * Base editor styles — ABSOLUTE MINIMUM.
3
+ *
4
+ * Only the *functional* chrome the editor needs regardless of theme:
5
+ * positioning, source markers, the rendered cursor/selection, the
6
+ * active-block highlight, the task-list checkbox widget, and the structural
7
+ * layout that keeps active/inactive rendering identical (markers in the
8
+ * gutter, list paragraphs inline).
9
+ *
10
+ * NO markdown-content typography lives here (fonts, sizes, colors,
11
+ * heading/paragraph/blockquote/table spacing). That lives in opt-in, scoped
12
+ * theme files (`themes/default.css`, `themes/github.css`) applied via the
13
+ * `classNames` editor option; those selectors only ever match inside their
14
+ * own theme class and never style the global scope.
15
+ */
16
+
17
+ .md-editor {
18
+ position: relative;
19
+ outline: none;
20
+ /* The editor paints its own cursor (`.md-cursor`); hide the native caret. */
21
+ caret-color: transparent;
22
+ padding: 48px;
23
+ }
24
+
25
+ .md-block-active {
26
+ background: #f8f8f8;
27
+ border-radius: 4px;
28
+ box-shadow: 0 0 0 8px #f8f8f8;
29
+ }
30
+
31
+ /*
32
+ * A rendered (inactive) link opens on a plain click, so it keeps the anchor's
33
+ * pointer cursor. Once its block is active the link is editable source and a
34
+ * plain click places the caret (Ctrl/Cmd+click still opens), so it shows the
35
+ * normal editing cursor like the surrounding text.
36
+ */
37
+ .md-block-active a {
38
+ cursor: inherit;
39
+ }
40
+
41
+ .md-fence-spacer {
42
+ visibility: hidden;
43
+ font-family: 'Cascadia Code', 'Fira Code', monospace;
44
+ font-size: 0.85em;
45
+ }
46
+
47
+ .md-marker {
48
+ color: #999;
49
+ font-family: 'Cascadia Code', 'Fira Code', monospace;
50
+ font-size: 0.85em;
51
+ display: inline;
52
+ overflow: hidden;
53
+ max-width: 100px;
54
+ opacity: 1;
55
+ line-height: 1;
56
+ }
57
+
58
+ .md-marker-hidden {
59
+ display: none;
60
+ }
61
+
62
+ /*
63
+ * Active thematic break: the source markup (`---`) shown in place of the
64
+ * rendered rule, in the muted monospace used for all revealed source. Rendered
65
+ * inline-block so the hostless trailing gap (its `\n\n`, revealed as `↵`
66
+ * glyphs) flows on the same line, to the right of the `---`.
67
+ */
68
+ .md-thematic-break-source {
69
+ display: inline-block;
70
+ color: #999;
71
+ font-family: 'Cascadia Code', 'Fira Code', monospace;
72
+ font-size: 0.85em;
73
+ white-space: pre-wrap;
74
+ }
75
+
76
+ /*
77
+ * Visible whitespace indicators, shown only in the active/source view. The real
78
+ * whitespace character stays in the DOM (so source ↔ DOM mapping and selection
79
+ * are unaffected); the glyph is a pure CSS overlay. Spaces and tabs overlay
80
+ * their glyph (keeping the character's own width), while a newline shows its
81
+ * glyph inline since the line ending collapses to zero/again width.
82
+ */
83
+ .md-ws-space,
84
+ .md-ws-tab {
85
+ position: relative;
86
+ /*
87
+ * Each decorated whitespace span wraps a single space/tab and is made
88
+ * non-collapsing, so adjacent dots in a run like `foo bar` each keep their
89
+ * own width (two dots, not one). Scoping this to the span — rather than
90
+ * preserving whitespace on the whole leaf — leaves a literal `\n` in the
91
+ * source (e.g. a hard break's holder) collapsible, so only the `<br>`
92
+ * breaks the line and no stray empty line appears.
93
+ */
94
+ white-space: pre;
95
+ }
96
+
97
+ /*
98
+ * A decorated text leaf needs no special whitespace handling of its own: its
99
+ * non-obvious whitespace is kept from collapsing by the `white-space: pre` on
100
+ * the individual indicator spans (see `.md-ws-space`), and plain runs between
101
+ * them never contain consecutive spaces.
102
+ */
103
+ .md-ws-space::before,
104
+ .md-ws-tab::before {
105
+ position: absolute;
106
+ left: 0;
107
+ right: 0;
108
+ text-align: center;
109
+ color: #b0b0b0;
110
+ pointer-events: none;
111
+ }
112
+
113
+ .md-ws-space::before {
114
+ content: '·';
115
+ }
116
+
117
+ .md-ws-tab::before {
118
+ content: '⇥';
119
+ }
120
+
121
+ .md-ws-newline::before {
122
+ content: '↵';
123
+ color: #b0b0b0;
124
+ pointer-events: none;
125
+ }
126
+
127
+ /*
128
+ * Inter-block gap newline rendered as a real `↵` glyph character (see the
129
+ * `newlineGlyph` whitespace mode). Unlike `.md-ws-newline` it has no `::before`
130
+ * overlay — the glyph is the character's own text, so it keeps its own width and
131
+ * its selection box coincides exactly with the glyph (every newline is
132
+ * individually selectable). It is not whitespace, so it never collapses.
133
+ */
134
+ .md-ws-newline-glyph {
135
+ color: #b0b0b0;
136
+ }
137
+
138
+ /*
139
+ * The structural block break: the leading newline of an inter-block gap (a
140
+ * `blockBreak` glue) — the `\n` that starts the next block. Painted as a real
141
+ * `↵` glyph like `.md-ws-newline-glyph`, but blue, to distinguish "this newline
142
+ * splits two blocks" (delete it and they merge) from the neutral blank-line
143
+ * glyphs that follow. A soft break inside a single block stays neutral.
144
+ */
145
+ .md-ws-blockbreak-glyph {
146
+ color: #4a90d9;
147
+ }
148
+
149
+ /*
150
+ * Hard line break: the `<br>` always renders so the line breaks in both views;
151
+ * the break's source characters are revealed only while the block is active.
152
+ * The holder keeps default whitespace handling so its literal `\n` collapses
153
+ * (only the `<br>` breaks the line); the trailing spaces stay visible because
154
+ * each decorated dot span is non-collapsing (see `.md-ws-space`).
155
+ *
156
+ * The break's source markers are painted in the same blue as the structural
157
+ * block break (`.md-ws-blockbreak-glyph`) to signal a deliberate, structural
158
+ * line break rather than incidental whitespace: both trailing-space dots (drawn
159
+ * via `.md-ws-space::before`, so their colour is overridden there) and the
160
+ * escape backslash (the holder's own text).
161
+ */
162
+ .md-hardbreak-src {
163
+ color: #4a90d9;
164
+ }
165
+
166
+ .md-hardbreak-src .md-ws-space::before {
167
+ color: #4a90d9;
168
+ }
169
+
170
+ .md-hardbreak-src-hidden {
171
+ display: none;
172
+ }
173
+
174
+ /*
175
+ * Glue (table cell pipes, the task `[x] ` source, source padding) keeps its
176
+ * inline footprint when hidden so column widths and the checkbox gutter stay
177
+ * identical between active and inactive states.
178
+ */
179
+ .md-glue-hidden {
180
+ display: inline;
181
+ visibility: hidden;
182
+ }
183
+
184
+ /*
185
+ * Inter-block glue: the run of blank lines between two top-level blocks. It is
186
+ * mounted as the last inline child of the block that precedes it, so it sits at
187
+ * the end of that block's last line rather than on its own lines between the
188
+ * blocks. When a neighbouring block is active it is revealed: each blank-line
189
+ * newline shows a real `↵` glyph character (`.md-ws-newline-glyph`) while the
190
+ * trailing line-terminator `\n` collapses (`white-space: normal`) so the run
191
+ * adds no line break and no height — active and inactive therefore have the
192
+ * same height. When hidden it collapses to nothing.
193
+ */
194
+ .md-glue-blockGap {
195
+ white-space: normal;
196
+ }
197
+
198
+ /*
199
+ * The structural block break between two top-level blocks. Like `.md-glue-blockGap`
200
+ * its trailing line-terminator `\n` collapses (`white-space: normal`) so the run
201
+ * adds no height; its leading newline is painted as the blue break glyph
202
+ * (`.md-ws-blockbreak-glyph`).
203
+ */
204
+ .md-glue-blockBreak {
205
+ white-space: normal;
206
+ }
207
+
208
+ /*
209
+ * The task-list checkbox marker (`[x]`/`[ ]`) is special: instead of being
210
+ * removed from layout when hidden, it keeps its inline width (visibility
211
+ * hidden) and the rendered checkbox is overlaid on top of it. This keeps the
212
+ * inline flow identical in active and inactive mode, so the text following
213
+ * the marker does not drift horizontally when markers are toggled.
214
+ */
215
+ .md-marker-checkbox.md-marker-hidden {
216
+ display: inline;
217
+ visibility: hidden;
218
+ }
219
+
220
+ /*
221
+ * Table cell-glue pipes (`| `) keep their inline footprint when hidden so the
222
+ * column widths stay identical active and inactive.
223
+ */
224
+ .md-marker-tableCellGlue.md-marker-hidden {
225
+ display: inline;
226
+ visibility: hidden;
227
+ }
228
+
229
+ /*
230
+ * The code-block fences (```lang / ```) each sit on their own source line. When
231
+ * hidden they keep their vertical footprint (visibility hidden, not display
232
+ * none) so the inactive block reserves the same two fence lines the active
233
+ * block shows. This keeps the code block's height identical between active and
234
+ * inactive, avoiding a layout shift on focus.
235
+ */
236
+ .md-marker-openFence.md-marker-hidden,
237
+ .md-marker-closeFence.md-marker-hidden {
238
+ display: inline;
239
+ visibility: hidden;
240
+ }
241
+
242
+ /*
243
+ * The table delimiter (`| --- | --- |`) row is collapsed entirely while the
244
+ * table is inactive and revealed — compact, small font — while active. The
245
+ * header reserves the matching vertical space when inactive (in the theme
246
+ * files), so the total table height is unchanged between the two states.
247
+ */
248
+ .md-table-delimiter-row {
249
+ display: none;
250
+ }
251
+
252
+ .md-block-active .md-table-delimiter-row {
253
+ display: table-row;
254
+ }
255
+
256
+ .md-table-delimiter-row td {
257
+ padding: 0;
258
+ font-size: 11px;
259
+ line-height: 1;
260
+ height: 16px;
261
+ }
262
+
263
+ .md-selection-layer {
264
+ position: absolute;
265
+ top: 0;
266
+ left: 0;
267
+ width: 100%;
268
+ height: 100%;
269
+ pointer-events: none;
270
+ overflow: visible;
271
+ }
272
+
273
+ .md-selection-path {
274
+ fill: rgba(59, 130, 246, 0.25);
275
+ }
276
+
277
+ /* Source markers occupy the gutter so toggling them never shifts content. */
278
+ .md-heading {
279
+ position: relative;
280
+ }
281
+
282
+ .md-heading>.md-marker:first-child {
283
+ position: absolute;
284
+ right: 100%;
285
+ white-space: pre;
286
+ top: 0;
287
+ /* Match the heading's line box (font-size + line-height inherited) so the
288
+ * marker box equals the first text line at every heading level; then center
289
+ * the glyph vertically and shrink it back to the muted marker size. */
290
+ font-size: inherit;
291
+ line-height: inherit;
292
+ height: 1lh;
293
+ display: inline-flex;
294
+ align-items: center;
295
+ justify-content: flex-end;
296
+ transform: scale(0.85);
297
+ transform-origin: right center;
298
+ }
299
+
300
+ /*
301
+ * The gutter rule above sets `display: inline-flex`, which outranks the plain
302
+ * `.md-marker-hidden { display: none }` (more specific), so the marker must be
303
+ * re-hidden here for the inactive heading — otherwise the `#` would always show.
304
+ */
305
+ .md-heading>.md-marker-hidden:first-child {
306
+ display: none;
307
+ }
308
+
309
+ /*
310
+ * Block-quote prefixes (`> `, one per quoted source line) are real
311
+ * `blockQuoteMarker` markers, siblings of the quote's child blocks. Each hangs
312
+ * in the quote's left padding instead of taking inline width: its right edge is
313
+ * pulled to the content edge (`right: 100% - pad`) so the `>` sits just left of
314
+ * the quoted text, and `top: auto` keeps it on its own source line. Because the
315
+ * markers add no inline width, the quoted text keeps the exact same x in active
316
+ * and inactive mode (toggling the prefix never shifts content); because every
317
+ * marker measures from the same content edge, the markers of one quote stack in
318
+ * a single vertical column, and a nested quote — itself inset by the outer
319
+ * quote's padding — forms its own column one level in.
320
+ *
321
+ * `--md-blockquote-pad` is the quote's own left padding, published by the theme
322
+ * so this functional rule can find the content edge without hard-coding it.
323
+ */
324
+ .md-blockquote {
325
+ position: relative;
326
+ }
327
+
328
+ .md-blockquote>.md-marker-blockQuoteMarker {
329
+ position: absolute;
330
+ right: calc(100% - var(--md-blockquote-pad, 0px));
331
+ top: auto;
332
+ white-space: pre;
333
+ }
334
+
335
+ /* Inactive: gone entirely (the gutter is empty, the text stays put). */
336
+ .md-blockquote>.md-marker-blockQuoteMarker.md-marker-hidden {
337
+ display: none;
338
+ }
339
+
340
+ /* Code/math blocks scroll horizontally; their look is theme-defined. */
341
+ .md-code-block {
342
+ overflow-x: auto;
343
+ }
344
+
345
+ .md-math-block {
346
+ overflow-x: auto;
347
+ }
348
+
349
+ /*
350
+ * Paragraphs inside list items render inline so the item's content sits on
351
+ * the same line as the list counter / source marker instead of wrapping
352
+ * below it. Block-level <p> here would push the text down even with zero
353
+ * margin, because the counter sits at the start of the principal box.
354
+ */
355
+ .md-list li>.md-paragraph {
356
+ display: inline;
357
+ margin: 0;
358
+ }
359
+
360
+ .md-list li>.md-block {
361
+ margin: 0;
362
+ }
363
+
364
+ .md-list li>.md-block+.md-block {
365
+ margin-top: 0.25em;
366
+ }
367
+
368
+ .md-list-item-active {
369
+ list-style: none;
370
+ position: relative;
371
+ }
372
+
373
+ /*
374
+ * The list marker is pulled into the gutter by markerKind (not `:first-child`),
375
+ * because a nested item may carry its source indentation as a leading glue
376
+ * before the marker. Gutter-positioning keeps the marker out of the inline
377
+ * flow so toggling it never shifts the item's text horizontally.
378
+ *
379
+ * `line-height: inherit` makes the marker share the item's line box (its own
380
+ * `.md-marker` rule shrinks it to `line-height: 1`, which floats the glyph to
381
+ * the top of the taller text line); matching the line box vertically centres
382
+ * the `-` with the rendered text.
383
+ */
384
+ .md-list-item-active>.md-marker-listItemMarker {
385
+ position: absolute;
386
+ right: 100%;
387
+ top: 0;
388
+ line-height: inherit;
389
+ white-space: pre;
390
+ }
391
+
392
+ /*
393
+ * A nested item's source indentation precedes its bullet (`␣␣- text`). The
394
+ * indent glue and the bullet are mounted together in this gutter span, which is
395
+ * pulled out of flow with its right edge at the content edge. The gutter itself
396
+ * is shrink-to-fit: the dot run gets a fixed *structural* width of `(level − 1)`
397
+ * indent steps and the bullet contributes its own intrinsic width on top, so the
398
+ * gutter's left edge lands exactly one bullet-width left of the root content
399
+ * column — i.e. aligned with the root bullet. The dot run's width is driven by
400
+ * the nesting level rather than the literal source glyphs, so the dots fill the
401
+ * whole indentation column, every level lines up in a vertical track aligned to
402
+ * the root bullet, and a leading tab lands on the same column as the equivalent
403
+ * spaces. The glue's revealed dots are spread across the column; the bullet sits
404
+ * flush against the text. It is absolute in both states (not just active) so the
405
+ * hidden indentation never widens the line.
406
+ */
407
+ .md-list-gutter {
408
+ position: absolute;
409
+ right: 100%;
410
+ display: flex;
411
+ white-space: pre;
412
+ }
413
+
414
+ .md-list-gutter>.md-glue-indent {
415
+ flex: 0 0 calc((var(--md-list-level, 1) - 1) * var(--md-list-indent-step, 2em));
416
+ display: flex;
417
+ justify-content: space-between;
418
+ }
419
+
420
+ .md-list-gutter>.md-marker-listItemMarker {
421
+ flex: 0 0 auto;
422
+ }
423
+
424
+
425
+ /*
426
+ * Re-attributed source indentation (the spaces after a line break that precede
427
+ * a nested list) keeps its exact width in both states: `white-space: pre` so
428
+ * the run does not collapse, paired with the hidden footprint of
429
+ * `.md-glue-hidden` when inactive. This keeps the nested item's text at the
430
+ * same horizontal position whether or not the indentation dots are shown.
431
+ */
432
+ .md-glue-indent {
433
+ white-space: pre;
434
+ }
435
+
436
+ .md-task-list-item {
437
+ list-style: none;
438
+ position: relative;
439
+ }
440
+
441
+ /*
442
+ * Reserve extra width after the `[x]`/`[ ]` source marker (the first glue in a
443
+ * task item's paragraph) so the rendered checkbox widget overlaid on it has a
444
+ * comfortable gap before the text. The padding applies in both active and
445
+ * inactive states, so the first text character does not drift horizontally when
446
+ * markers toggle (see the compare fixture's `checkMarkedTextX` assertion).
447
+ */
448
+ .md-task-list-item .md-paragraph>.md-glue:first-child {
449
+ padding-right: 0.7em;
450
+ }
451
+
452
+ .md-checkbox {
453
+ /* The rendered task-list widget — editor chrome, not markdown typography. */
454
+ appearance: none;
455
+ -webkit-appearance: none;
456
+ margin: 0;
457
+ width: 16px;
458
+ height: 16px;
459
+ border: 2px solid #bbb;
460
+ border-radius: 3px;
461
+ position: absolute;
462
+ left: 0;
463
+ top: 0.25em;
464
+ cursor: pointer;
465
+ transition: background-color 0.15s ease, border-color 0.15s ease;
466
+ }
467
+
468
+ .md-checkbox:checked {
469
+ background-color: #4c8bf5;
470
+ border-color: #4c8bf5;
471
+ }
472
+
473
+ .md-checkbox:checked::after {
474
+ content: '';
475
+ position: absolute;
476
+ left: 3px;
477
+ top: 0px;
478
+ width: 5px;
479
+ height: 9px;
480
+ border: solid white;
481
+ border-width: 0 2px 2px 0;
482
+ transform: rotate(45deg);
483
+ }
484
+
485
+ .md-checkbox:hover {
486
+ border-color: #888;
487
+ }
488
+
489
+ .md-checkbox:checked:hover {
490
+ background-color: #3a73d4;
491
+ border-color: #3a73d4;
492
+ }
493
+
494
+ .md-checkbox:disabled {
495
+ cursor: default;
496
+ opacity: 0.6;
497
+ }
498
+
499
+ .md-cursor {
500
+ position: absolute;
501
+ width: 2px;
502
+ background: #000;
503
+ pointer-events: none;
504
+ animation: md-cursor-blink 1s step-end infinite;
505
+ }
506
+
507
+ @keyframes md-cursor-blink {
508
+
509
+ 0%,
510
+ 100% {
511
+ opacity: 1;
512
+ }
513
+
514
+ 50% {
515
+ opacity: 0;
516
+ }
517
+ }