@vscode/markdown-editor 0.0.2-1 → 0.0.2-11

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.
@@ -12,32 +12,81 @@
12
12
  * theme files (`themes/default.css`, `themes/github.css`) applied via the
13
13
  * `classNames` editor option; those selectors only ever match inside their
14
14
  * own theme class and never style the global scope.
15
+ *
16
+ * NO `--vscode-*` variables may be referenced here. This base file must stay
17
+ * theme-agnostic and know nothing about VS Code. Where a value needs to vary
18
+ * per theme, expose a local `--md-*` custom property WITH a sensible literal
19
+ * fallback (e.g. `var(--md-cursor-background, #000)`) and let a theme file set
20
+ * it. Only `themes/vscode.css` is permitted to read `--vscode-*` variables and
21
+ * map them onto these `--md-*` properties.
15
22
  */
16
23
 
17
24
  .md-editor {
18
- position: relative;
19
25
  outline: none;
20
26
  /* The editor paints its own cursor (`.md-cursor`); hide the native caret. */
21
27
  caret-color: transparent;
28
+ }
29
+
30
+ /*
31
+ * The transient empty paragraph — the blank line conjured by pressing Enter at
32
+ * the end of a paragraph (see `PendingParagraph` in the model). It is not part
33
+ * of the document (Markdown has no empty-paragraph node); it holds a single
34
+ * `<br>` so it occupies one line's height, and the caret is painted over it.
35
+ */
36
+ .md-pending-paragraph {
37
+ min-height: 1em;
38
+ }
39
+
40
+ /*
41
+ * Inner content container. Holds the rendered document and the cursor/selection
42
+ * overlays, which position themselves relative to this box, so it is the
43
+ * positioning context. In limited-width mode the editor sets an inline
44
+ * `max-width` here and the auto inline margins center it within the full-width
45
+ * `.md-editor`.
46
+ */
47
+ .md-editor-content {
48
+ position: relative;
49
+ margin-inline: auto;
22
50
  padding: 48px;
23
51
  }
24
52
 
25
53
  .md-block-active {
26
- background: #f8f8f8;
54
+ background: var(--md-block-active-background, #f8f8f8);
27
55
  border-radius: 4px;
28
- box-shadow: 0 0 0 8px #f8f8f8;
56
+ box-shadow: 0 0 0 8px var(--md-block-active-background, #f8f8f8);
29
57
  }
30
58
 
31
59
  /*
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.
60
+ * Cursor mirrors the same open affordance as the underline below: the anchor's
61
+ * pointer cursor appears exactly when a click would open the link. An inactive
62
+ * (rendered) link opens on a plain click, so it keeps the browser's default
63
+ * anchor pointer. Once its block is active a plain click places the caret, so
64
+ * the link shows the normal editing cursor — except while Ctrl/Cmd is held
65
+ * (`.md-mod-down`), when a click opens it and the pointer returns.
36
66
  */
37
67
  .md-block-active a {
38
68
  cursor: inherit;
39
69
  }
40
70
 
71
+ .md-editor.md-mod-down .md-block-active a[href] {
72
+ cursor: pointer;
73
+ }
74
+
75
+ /*
76
+ * Link underline is an "open affordance": show it only while a click on the
77
+ * link right now would actually open it. An inactive (rendered) link opens on
78
+ * a plain click, so hovering it underlines. An active link's plain click edits
79
+ * its source — it only opens with Ctrl/Cmd — so it underlines on hover only
80
+ * while that modifier is held (`.md-mod-down`, set live by the view).
81
+ */
82
+ .md-editor a[href]:hover {
83
+ text-decoration: underline;
84
+ }
85
+
86
+ .md-editor:not(.md-mod-down) .md-block-active a[href]:hover {
87
+ text-decoration: none;
88
+ }
89
+
41
90
  .md-fence-spacer {
42
91
  visibility: hidden;
43
92
  font-family: 'Cascadia Code', 'Fira Code', monospace;
@@ -274,6 +323,54 @@
274
323
  fill: rgba(59, 130, 246, 0.25);
275
324
  }
276
325
 
326
+ /*
327
+ * Gutter markers (source-control style change indicators). The layer fills the
328
+ * content box; each marker is an absolutely-positioned bar pinned to the left
329
+ * gutter (inside `.md-editor-content`'s 48px padding). The view sets only
330
+ * `top`/`height`; horizontal placement, width and color live here so themes can
331
+ * tune them without touching layout. Like the other overlays it never eats
332
+ * pointer events.
333
+ */
334
+ .md-gutter-layer {
335
+ position: absolute;
336
+ top: 0;
337
+ left: 0;
338
+ width: 100%;
339
+ height: 100%;
340
+ pointer-events: none;
341
+ overflow: visible;
342
+ }
343
+
344
+ .md-gutter-marker {
345
+ position: absolute;
346
+ left: var(--md-gutter-marker-left, 18px);
347
+ width: var(--md-gutter-marker-width, 3px);
348
+ border-radius: 2px;
349
+ }
350
+
351
+ .md-gutter-marker-added {
352
+ background: var(--md-gutter-added, #2ea043);
353
+ }
354
+
355
+ .md-gutter-marker-modified {
356
+ background: var(--md-gutter-modified, #0969da);
357
+ }
358
+
359
+ /*
360
+ * A deletion has no lines to span, so it is drawn as a downward-pointing
361
+ * triangle centered on the seam where the removed text used to be (the top of
362
+ * the line that now follows it), matching the git deleted-lines affordance.
363
+ */
364
+ .md-gutter-marker-deleted {
365
+ width: 0;
366
+ height: 0;
367
+ border-radius: 0;
368
+ border-left: var(--md-gutter-marker-width, 3px) solid var(--md-gutter-deleted, #cf222e);
369
+ border-top: 4px solid transparent;
370
+ border-bottom: 4px solid transparent;
371
+ transform: translateY(-4px);
372
+ }
373
+
277
374
  /* Source markers occupy the gutter so toggling them never shifts content. */
278
375
  .md-heading {
279
376
  position: relative;
@@ -346,14 +443,7 @@
346
443
  overflow-x: auto;
347
444
  }
348
445
 
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
446
  .md-list li>.md-paragraph {
356
- display: inline;
357
447
  margin: 0;
358
448
  }
359
449
 
@@ -433,20 +523,57 @@
433
523
  white-space: pre;
434
524
  }
435
525
 
526
+ /*
527
+ * A loose list item's later block (its second paragraph etc.) owns the source
528
+ * continuation indent that precedes it as its `leadingTrivia`. Like a nested
529
+ * list's gutter, that indent glue is pulled out of flow to the left so it never
530
+ * widens the line: the block's text stays aligned with the first paragraph
531
+ * above it, and the indent dots only appear in the left margin when the block is
532
+ * active (the footprint is identical in both states, so the text never shifts).
533
+ */
534
+ .md-list li>.md-block,
535
+ .md-task-list-item>.md-block {
536
+ position: relative;
537
+ }
538
+
539
+ .md-list li>.md-block>.md-glue-indent:first-child,
540
+ .md-task-list-item>.md-block>.md-glue-indent:first-child {
541
+ position: absolute;
542
+ right: 100%;
543
+ top: 0;
544
+ }
545
+
436
546
  .md-task-list-item {
437
547
  list-style: none;
438
548
  position: relative;
549
+ /*
550
+ * Width of the checkbox / `[x]` source column. Single-sourced so the marker
551
+ * reservation on the first paragraph and the left indent of any following
552
+ * block (loose task items) stay in lockstep — keeping every block's text in
553
+ * one vertical column under the marker.
554
+ */
555
+ --md-task-marker-width: 1.75em;
439
556
  }
440
557
 
441
558
  /*
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
559
+ * Reserve the marker column after the `[x]`/`[ ]` source marker (the first glue
560
+ * in a task item's paragraph) so the rendered checkbox widget overlaid on it has
561
+ * a comfortable gap before the text. The fixed width applies in both active and
445
562
  * inactive states, so the first text character does not drift horizontally when
446
563
  * markers toggle (see the compare fixture's `checkMarkedTextX` assertion).
447
564
  */
448
565
  .md-task-list-item .md-paragraph>.md-glue:first-child {
449
- padding-right: 0.7em;
566
+ display: inline-block;
567
+ width: var(--md-task-marker-width);
568
+ }
569
+
570
+ /*
571
+ * Following blocks in a loose task item (the second paragraph etc.) carry no
572
+ * marker glue, so indent them by the marker column to line their text up under
573
+ * the first paragraph's text rather than under the checkbox.
574
+ */
575
+ .md-task-list-item>.md-block+.md-block {
576
+ padding-left: var(--md-task-marker-width);
450
577
  }
451
578
 
452
579
  .md-checkbox {
@@ -499,7 +626,7 @@
499
626
  .md-cursor {
500
627
  position: absolute;
501
628
  width: 2px;
502
- background: #000;
629
+ background: var(--md-cursor-background, #000);
503
630
  pointer-events: none;
504
631
  animation: md-cursor-blink 1s step-end infinite;
505
632
  }
@@ -19,7 +19,6 @@
19
19
  font-size: 16px;
20
20
  line-height: 1.5;
21
21
  color: #1f2328;
22
- max-width: 800px;
23
22
  word-wrap: break-word;
24
23
  }
25
24
 
@@ -100,10 +99,6 @@
100
99
  text-decoration: none;
101
100
  }
102
101
 
103
- .github-markdown-theme a:hover {
104
- text-decoration: underline;
105
- }
106
-
107
102
  /* GitHub uses a 600 weight for bold, not the browser default 700. */
108
103
  .github-markdown-theme strong {
109
104
  font-weight: 600;
@@ -0,0 +1,331 @@
1
+ /*
2
+ * VS Code markdown theme.
3
+ *
4
+ * A *variable-driven* theme: every color is expressed as `var(--vscode-*, …)`
5
+ * so the editor adopts whatever VS Code color theme is active (dark, light,
6
+ * high-contrast, or any custom theme) WITHOUT the editor knowing anything
7
+ * about VS Code. The editor only references variable NAMES — a documented
8
+ * contract — and bundles no VS Code CSS.
9
+ *
10
+ * Apply it via the editor `classNames` option:
11
+ *
12
+ * new EditorView(model, { classNames: ['md-theme-vscode'] });
13
+ *
14
+ * In a real webview VS Code injects the `--vscode-*` custom properties onto
15
+ * the document root and sets a body theme class, so this theme just works. In
16
+ * the Component Explorer the same variables are supplied by a snapshot
17
+ * stylesheet scoped under a `.vscode-theme.<id>` wrapper (see
18
+ * `fixture/vscodeThemes`). Either way the cascade reaches this theme's rules.
19
+ *
20
+ * Fallbacks: each `var()` carries a light-palette fallback so the theme stays
21
+ * legible even with no `--vscode-*` variables present at all.
22
+ *
23
+ * Layout/typography mirrors the GitHub theme (the basis of the production VS
24
+ * Code markdown editor); only the colors are swapped for variables. Every
25
+ * selector is scoped under the theme class, so importing this file never
26
+ * affects the global page or any editor that did not opt in.
27
+ *
28
+ * Syntax-token colors are exposed as `--md-tok-*` custom properties (with
29
+ * light-palette fallbacks). Real VS Code derives token colors from the live
30
+ * tokenizer's color map (baked in per token), NOT from `--vscode-*`; the
31
+ * Component Explorer supplies a matching `--md-tok-*` palette per color theme.
32
+ */
33
+
34
+ .md-editor.md-theme-vscode {
35
+ font-family: var(--markdown-font-family, -apple-system, BlinkMacSystemFont,
36
+ 'Segoe WPC', 'Segoe UI', system-ui, 'Ubuntu', 'Droid Sans', sans-serif);
37
+ font-size: var(--markdown-font-size, 16px);
38
+ line-height: var(--markdown-line-height, 1.5);
39
+ color: var(--vscode-editor-foreground, #1f2328);
40
+ word-wrap: break-word;
41
+ /*
42
+ * Active-block highlight (defined theme-agnostically in editor.css) follows
43
+ * the VS Code surface color so it stays a subtle inset on both light and
44
+ * dark color themes instead of a fixed light-grey box.
45
+ */
46
+ --md-block-active-background: var(--vscode-editorWidget-background, #f8f8f8);
47
+ /*
48
+ * Cursor color: editor.css paints `.md-cursor` with `--md-cursor-background`
49
+ * (theme-agnostic, black fallback); map it to the VS Code cursor color so it
50
+ * stays visible on dark color themes.
51
+ */
52
+ --md-cursor-background: var(--vscode-editorCursor-foreground, #000);
53
+ }
54
+
55
+ .md-theme-vscode .md-heading {
56
+ margin-top: 24px;
57
+ margin-bottom: 16px;
58
+ font-weight: 600;
59
+ line-height: 1.25;
60
+ }
61
+
62
+ .md-theme-vscode h1.md-heading {
63
+ font-size: 2em;
64
+ padding-bottom: 0.3em;
65
+ border-bottom: 1px solid var(--vscode-textSeparator-foreground, #d1d9e0b3);
66
+ }
67
+
68
+ .md-theme-vscode h2.md-heading {
69
+ font-size: 1.5em;
70
+ padding-bottom: 0.3em;
71
+ border-bottom: 1px solid var(--vscode-textSeparator-foreground, #d1d9e0b3);
72
+ }
73
+
74
+ .md-theme-vscode h3.md-heading {
75
+ font-size: 1.25em;
76
+ }
77
+
78
+ .md-theme-vscode h4.md-heading {
79
+ font-size: 1em;
80
+ }
81
+
82
+ .md-theme-vscode h5.md-heading {
83
+ font-size: 0.875em;
84
+ }
85
+
86
+ .md-theme-vscode h6.md-heading {
87
+ font-size: 0.85em;
88
+ color: var(--vscode-descriptionForeground, #59636e);
89
+ }
90
+
91
+ .md-theme-vscode .md-paragraph {
92
+ margin-top: 0;
93
+ margin-bottom: 16px;
94
+ }
95
+
96
+ .md-theme-vscode .md-blockquote {
97
+ margin: 0 0 16px 0;
98
+ padding: 0 1em;
99
+ /*
100
+ * The left padding the `>` gutter hangs in (matches padding-left: 1em at
101
+ * the base font). Must be an absolute length, not `1em`: the marker
102
+ * positions itself with this var inside its own (smaller, 0.85em) font
103
+ * context, so an `em` value would resolve against the marker's font-size
104
+ * and pull the `>` out of alignment with the text.
105
+ */
106
+ --md-blockquote-pad: 16px;
107
+ color: var(--vscode-descriptionForeground, #59636e);
108
+ border-left: 0.25em solid var(--vscode-textBlockQuote-border, #d1d9e0);
109
+ }
110
+
111
+ .md-theme-vscode .md-list {
112
+ margin-top: 0;
113
+ margin-bottom: 16px;
114
+ padding-left: 2em;
115
+ /* The per-level indentation step the list gutter fills (matches padding-left). */
116
+ --md-list-indent-step: 2em;
117
+ }
118
+
119
+ .md-theme-vscode .md-thematic-break {
120
+ height: 0.25em;
121
+ padding: 0;
122
+ margin: 24px 0;
123
+ background-color: var(--vscode-textSeparator-foreground, #d1d9e0);
124
+ border: 0;
125
+ }
126
+
127
+ .md-theme-vscode a {
128
+ color: var(--vscode-textLink-foreground, #0969da);
129
+ text-decoration: none;
130
+ }
131
+
132
+ .md-theme-vscode a:hover {
133
+ text-decoration: underline;
134
+ }
135
+
136
+ .md-theme-vscode strong {
137
+ font-weight: 600;
138
+ }
139
+
140
+ /* Inline code. */
141
+ .md-theme-vscode :not(pre)>code {
142
+ font-family: var(--vscode-editor-font-family, ui-monospace, SFMono-Regular,
143
+ 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace);
144
+ font-size: 85%;
145
+ padding: 0.2em 0.4em;
146
+ margin: 0;
147
+ color: var(--vscode-textPreformat-foreground, inherit);
148
+ background-color: var(--vscode-textPreformat-background, #818b981f);
149
+ border-radius: 6px;
150
+ white-space: break-spaces;
151
+ }
152
+
153
+ /* Fenced code block. */
154
+ .md-theme-vscode .md-code-block {
155
+ margin-top: 0;
156
+ margin-bottom: 16px;
157
+ padding: 10px 16px;
158
+ font-size: 85%;
159
+ line-height: 1.45;
160
+ background-color: var(--vscode-textCodeBlock-background, #f6f8fa);
161
+ border-radius: 6px;
162
+ }
163
+
164
+ .md-theme-vscode .md-code-block code {
165
+ font-family: var(--vscode-editor-font-family, ui-monospace, SFMono-Regular,
166
+ 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace);
167
+ padding: 0;
168
+ background-color: transparent;
169
+ border-radius: 0;
170
+ }
171
+
172
+ /*
173
+ * Syntax-highlight token colors. Driven by `--md-tok-*` custom properties so
174
+ * the explorer (or any embedder) can supply a palette matched to the active
175
+ * color theme. Fallbacks are the VS Code light theme palette.
176
+ */
177
+ .md-theme-vscode .md-code-block .tok-keyword {
178
+ color: var(--md-tok-keyword, #0000ff);
179
+ }
180
+
181
+ .md-theme-vscode .md-code-block .tok-string {
182
+ color: var(--md-tok-string, #a31515);
183
+ }
184
+
185
+ .md-theme-vscode .md-code-block .tok-comment {
186
+ color: var(--md-tok-comment, #008000);
187
+ }
188
+
189
+ .md-theme-vscode .md-code-block .tok-number {
190
+ color: var(--md-tok-number, #098658);
191
+ }
192
+
193
+ .md-theme-vscode .md-code-block .tok-regexp {
194
+ color: var(--md-tok-regexp, #811f3f);
195
+ }
196
+
197
+ .md-theme-vscode .md-code-block .tok-type {
198
+ color: var(--md-tok-type, #267f99);
199
+ }
200
+
201
+ .md-theme-vscode .md-code-block .tok-annotation {
202
+ color: var(--md-tok-annotation, #267f99);
203
+ }
204
+
205
+ .md-theme-vscode .md-code-block .tok-tag {
206
+ color: var(--md-tok-tag, #800000);
207
+ }
208
+
209
+ .md-theme-vscode .md-code-block .tok-attribute {
210
+ color: var(--md-tok-attribute, #e50000);
211
+ }
212
+
213
+ .md-theme-vscode .md-code-block .tok-delimiter {
214
+ color: var(--md-tok-delimiter, inherit);
215
+ }
216
+
217
+ /*
218
+ * Display math has no container styling (KaTeX renders it inline-centered).
219
+ * Keep only the block spacing; horizontal scroll comes from the base sheet.
220
+ */
221
+ .md-theme-vscode .md-math-block {
222
+ margin-top: 0;
223
+ margin-bottom: 16px;
224
+ }
225
+
226
+ /*
227
+ * KaTeX renders inline math at 1.21em with its own (larger) line-height, which
228
+ * would inflate the surrounding line box. Collapse it so the rendered math fits
229
+ * the text line and the paragraph height stays identical active vs inactive.
230
+ */
231
+ .md-theme-vscode .md-inline-math .katex {
232
+ line-height: 1;
233
+ }
234
+
235
+ .md-theme-vscode .md-table {
236
+ border-collapse: collapse;
237
+ margin-top: 0;
238
+ margin-bottom: 16px;
239
+ width: auto;
240
+ }
241
+
242
+ .md-theme-vscode .md-table th,
243
+ .md-theme-vscode .md-table td {
244
+ padding: 6px 13px;
245
+ border: 1px solid var(--vscode-editorWidget-border, #d1d9e0);
246
+ text-align: left;
247
+ }
248
+
249
+ /*
250
+ * The editor renders every cell as <td> in a flat <table> of <tr> (no
251
+ * <thead>/<tbody>/<th>). Row order is: header, delimiter row, body rows.
252
+ */
253
+ .md-theme-vscode .md-table tr:first-child td {
254
+ font-weight: 600;
255
+ padding-top: 11px;
256
+ padding-bottom: 11px;
257
+ }
258
+
259
+ /* Active: reclaim the header's extra spacing to host the delimiter row. */
260
+ .md-theme-vscode .md-table.md-block-active tr:first-child td {
261
+ padding-top: 3px;
262
+ padding-bottom: 3px;
263
+ }
264
+
265
+ .md-theme-vscode .md-table tr:nth-child(even):not(.md-table-delimiter-row) {
266
+ background-color: var(--vscode-textCodeBlock-background, #f6f8fa);
267
+ }
268
+
269
+ /*
270
+ * The delimiter row (`| --- | --- |`) is editor source shown only while
271
+ * editing; render it borderless with no vertical padding so it occupies just
272
+ * the compact 10px reclaimed from the header.
273
+ */
274
+ .md-theme-vscode .md-table-delimiter-row td {
275
+ border: 0;
276
+ padding: 0 13px;
277
+ background: transparent;
278
+ }
279
+
280
+ /*
281
+ * Active table: the source `|` pipes ARE the outline. Drop the HTML cell
282
+ * borders (kept as transparent so the 1px box geometry — and thus the table's
283
+ * height and first-text X — is unchanged) and clear the zebra fill so the
284
+ * table reads as plain source.
285
+ */
286
+ .md-theme-vscode .md-table.md-block-active td {
287
+ border-color: transparent;
288
+ }
289
+
290
+ .md-theme-vscode .md-table.md-block-active tr:nth-child(even):not(.md-table-delimiter-row) td {
291
+ background-color: transparent;
292
+ }
293
+
294
+ /*
295
+ * Shift each cell's leading pipe onto its left gridline (where the border was)
296
+ * and the last cell's closing pipe onto the right gridline. `position:
297
+ * relative` moves only the painted glyph by the cell's horizontal padding;
298
+ * siblings and the glue's reserved width are untouched, so active/inactive
299
+ * height and first-text X stay pixel-identical.
300
+ */
301
+ .md-theme-vscode .md-table.md-block-active td>.md-glue-tableCellGlue:first-child,
302
+ .md-theme-vscode .md-table.md-block-active .md-table-delimiter-row td>.md-marker-tableDelimiter {
303
+ position: relative;
304
+ left: -13px;
305
+ }
306
+
307
+ /*
308
+ * The last cell's closing `|` floats right after the (left-aligned) cell text.
309
+ * Pin it to the column's right gridline (the cell's border edge, 13px past the
310
+ * content box) so the right outline is a straight line.
311
+ */
312
+ .md-theme-vscode .md-table.md-block-active td:last-child {
313
+ position: relative;
314
+ }
315
+
316
+ .md-theme-vscode .md-table.md-block-active td:last-child>.md-glue-tableCellGlue:last-child {
317
+ position: absolute;
318
+ right: 0;
319
+ top: 0;
320
+ }
321
+
322
+ /*
323
+ * The delimiter row's last cell carries its closing `|` as a separate
324
+ * `tableDelimiterClose` marker; pin it to the same right gridline as the body
325
+ * rows' closing pipe so the last column's outline stays straight.
326
+ */
327
+ .md-theme-vscode .md-table.md-block-active .md-table-delimiter-row td:last-child>.md-marker-tableDelimiterClose {
328
+ position: absolute;
329
+ right: 0;
330
+ top: 0;
331
+ }