@vscode/markdown-editor 0.0.2-6 → 0.0.2-8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vscode/markdown-editor",
3
- "version": "0.0.2-6",
3
+ "version": "0.0.2-8",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -18,7 +18,8 @@
18
18
  "dist",
19
19
  "src/view/editor.css",
20
20
  "src/view/themes/default.css",
21
- "src/view/themes/github.css"
21
+ "src/view/themes/github.css",
22
+ "src/view/themes/vscode.css"
22
23
  ],
23
24
  "exports": {
24
25
  ".": {
@@ -31,7 +32,8 @@
31
32
  },
32
33
  "./editor.css": "./src/view/editor.css",
33
34
  "./themes/default.css": "./src/view/themes/default.css",
34
- "./themes/github.css": "./src/view/themes/github.css"
35
+ "./themes/github.css": "./src/view/themes/github.css",
36
+ "./themes/vscode.css": "./src/view/themes/vscode.css"
35
37
  },
36
38
  "scripts": {
37
39
  "build": "vite build",
@@ -55,9 +57,9 @@
55
57
  "@playwright/test": "^1.58.2",
56
58
  "@types/katex": "^0.16.8",
57
59
  "@types/markdown-it": "^14.1.2",
58
- "@vscode/component-explorer": "next",
59
- "@vscode/component-explorer-cli": "next",
60
- "@vscode/component-explorer-vite-plugin": "next",
60
+ "@vscode/component-explorer": "0.2.1-59",
61
+ "@vscode/component-explorer-cli": "0.2.1-60",
62
+ "@vscode/component-explorer-vite-plugin": "0.2.1-59",
61
63
  "@vscode/observables": "workspace:*",
62
64
  "github-markdown-css": "^5.9.0",
63
65
  "golden-layout": "^2.6.0",
@@ -67,6 +69,7 @@
67
69
  "typescript": "^5.7.0",
68
70
  "vite": "^6.0.0",
69
71
  "vite-plugin-dts": "^4.5.4",
70
- "vitest": "^4.1.0"
72
+ "vitest": "^4.1.0",
73
+ "zod": "^4.3.6"
71
74
  }
72
75
  }
@@ -12,6 +12,13 @@
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 {
@@ -44,9 +51,9 @@
44
51
  }
45
52
 
46
53
  .md-block-active {
47
- background: #f8f8f8;
54
+ background: var(--md-block-active-background, #f8f8f8);
48
55
  border-radius: 4px;
49
- box-shadow: 0 0 0 8px #f8f8f8;
56
+ box-shadow: 0 0 0 8px var(--md-block-active-background, #f8f8f8);
50
57
  }
51
58
 
52
59
  /*
@@ -60,6 +67,7 @@
60
67
  .md-block-active a {
61
68
  cursor: inherit;
62
69
  }
70
+
63
71
  .md-editor.md-mod-down .md-block-active a[href] {
64
72
  cursor: pointer;
65
73
  }
@@ -74,6 +82,7 @@
74
82
  .md-editor a[href]:hover {
75
83
  text-decoration: underline;
76
84
  }
85
+
77
86
  .md-editor:not(.md-mod-down) .md-block-active a[href]:hover {
78
87
  text-decoration: none;
79
88
  }
@@ -617,7 +626,7 @@
617
626
  .md-cursor {
618
627
  position: absolute;
619
628
  width: 2px;
620
- background: #000;
629
+ background: var(--md-cursor-background, #000);
621
630
  pointer-events: none;
622
631
  animation: md-cursor-blink 1s step-end infinite;
623
632
  }
@@ -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
+ }