@vscode/markdown-editor 0.0.2-2 → 0.0.2-20

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.
@@ -1,3 +1,5 @@
1
+ @import '@vscode/codicons/dist/codicon.css';
2
+
1
3
  /*
2
4
  * Base editor styles — ABSOLUTE MINIMUM.
3
5
  *
@@ -12,32 +14,82 @@
12
14
  * theme files (`themes/default.css`, `themes/github.css`) applied via the
13
15
  * `classNames` editor option; those selectors only ever match inside their
14
16
  * own theme class and never style the global scope.
17
+ *
18
+ * NO `--vscode-*` variables may be referenced here. This base file must stay
19
+ * theme-agnostic and know nothing about VS Code. Where a value needs to vary
20
+ * per theme, expose a local `--md-*` custom property WITH a sensible literal
21
+ * fallback (e.g. `var(--md-cursor-background, #000)`) and let a theme file set
22
+ * it. Only the `themes/vscode-*.css` themes are permitted to read `--vscode-*`
23
+ * variables and map them onto these `--md-*` properties.
15
24
  */
16
25
 
17
26
  .md-editor {
18
- position: relative;
27
+ display: flow-root;
19
28
  outline: none;
20
29
  /* The editor paints its own cursor (`.md-cursor`); hide the native caret. */
21
30
  caret-color: transparent;
22
- padding: 48px;
31
+ }
32
+
33
+ /*
34
+ * The transient empty paragraph — the blank line conjured by pressing Enter at
35
+ * the end of a paragraph (see `PendingParagraph` in the model). It is not part
36
+ * of the document (Markdown has no empty-paragraph node); it holds a single
37
+ * `<br>` so it occupies one line's height, and the caret is painted over it.
38
+ */
39
+ .md-pending-paragraph {
40
+ min-height: 1em;
41
+ }
42
+
43
+ /*
44
+ * Inner content container. Holds the rendered document and the cursor/selection
45
+ * overlays, which position themselves relative to this box, so it is the
46
+ * positioning context. In limited-width mode the editor sets an inline
47
+ * `max-width` here and the auto inline margins center it within the full-width
48
+ * `.md-editor`.
49
+ */
50
+ .md-editor-content {
51
+ position: relative;
52
+ margin-inline: auto;
53
+ padding: 0 48px;
23
54
  }
24
55
 
25
56
  .md-block-active {
26
- background: #f8f8f8;
57
+ background: var(--md-block-active-background, #f8f8f8);
27
58
  border-radius: 4px;
28
- box-shadow: 0 0 0 8px #f8f8f8;
59
+ box-shadow: 0 0 0 8px var(--md-block-active-background, #f8f8f8);
29
60
  }
30
61
 
31
62
  /*
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.
63
+ * Cursor mirrors the same open affordance as the underline below: the anchor's
64
+ * pointer cursor appears exactly when a click would open the link. An inactive
65
+ * (rendered) link opens on a plain click, so it keeps the browser's default
66
+ * anchor pointer. Once its block is active a plain click places the caret, so
67
+ * the link shows the normal editing cursor — except while Ctrl/Cmd is held
68
+ * (`.md-mod-down`), when a click opens it and the pointer returns.
36
69
  */
37
70
  .md-block-active a {
38
71
  cursor: inherit;
39
72
  }
40
73
 
74
+ .md-editor.md-mod-down .md-block-active a[href] {
75
+ cursor: pointer;
76
+ }
77
+
78
+ /*
79
+ * Link underline is an "open affordance": show it only while a click on the
80
+ * link right now would actually open it. An inactive (rendered) link opens on
81
+ * a plain click, so hovering it underlines. An active link's plain click edits
82
+ * its source — it only opens with Ctrl/Cmd — so it underlines on hover only
83
+ * while that modifier is held (`.md-mod-down`, set live by the view).
84
+ */
85
+ .md-editor a[href]:hover {
86
+ text-decoration: underline;
87
+ }
88
+
89
+ .md-editor:not(.md-mod-down) .md-block-active a[href]:hover {
90
+ text-decoration: none;
91
+ }
92
+
41
93
  .md-fence-spacer {
42
94
  visibility: hidden;
43
95
  font-family: 'Cascadia Code', 'Fira Code', monospace;
@@ -73,6 +125,55 @@
73
125
  white-space: pre-wrap;
74
126
  }
75
127
 
128
+ /*
129
+ * An unhandled block: a construct the parser does not model (setext heading,
130
+ * frontmatter fence, an extension token). Its raw source is shown verbatim,
131
+ * styled like a code block but visibly flagged as "not understood" — a dashed
132
+ * warning border and a small badge naming the originating token type (from the
133
+ * `data-unhandled-token` attribute) — so the content is preserved and editable
134
+ * rather than silently dropped.
135
+ *
136
+ * The wrapper is the non-scrolling box (border + block spacing + the badge); the
137
+ * inner `.md-unhandled-scroll` <pre> is the horizontal scroller. Keeping the
138
+ * badge on the wrapper (not the scroller) pins it to the visible top-right
139
+ * corner instead of letting it drift with the scrolled content.
140
+ */
141
+ .md-unhandled-block {
142
+ position: relative;
143
+ margin: 0.5em 0;
144
+ border: 1px dashed #d0a000;
145
+ border-radius: 4px;
146
+ }
147
+
148
+ /*
149
+ * Inner scroller. Beats the per-theme `.md-theme-* .md-code-block` box rules
150
+ * (same class count) via the extra `pre` type selector: no margin/border of its
151
+ * own (those live on the wrapper), and top padding that reserves room for the
152
+ * pinned badge so it never overlaps the first source line.
153
+ */
154
+ pre.md-unhandled-scroll.md-code-block {
155
+ margin: 0;
156
+ border: 0;
157
+ border-radius: 4px;
158
+ padding-top: 1.7em;
159
+ }
160
+
161
+ .md-unhandled-block::after {
162
+ content: 'unhandled: ' attr(data-unhandled-token);
163
+ position: absolute;
164
+ top: 0;
165
+ right: 0;
166
+ padding: 1px 6px;
167
+ font-family: system-ui, sans-serif;
168
+ font-size: 10px;
169
+ line-height: 1.4;
170
+ color: #6b5200;
171
+ background: #f5e5a8;
172
+ border-bottom-left-radius: 4px;
173
+ pointer-events: none;
174
+ user-select: none;
175
+ }
176
+
76
177
  /*
77
178
  * Visible whitespace indicators, shown only in the active/source view. The real
78
179
  * whitespace character stays in the DOM (so source ↔ DOM mapping and selection
@@ -172,15 +273,28 @@
172
273
  }
173
274
 
174
275
  /*
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.
276
+ * Glue normally keeps its inline footprint when hidden so source padding and
277
+ * widget gutters stay identical between active and inactive states. Hidden
278
+ * table-cell glue is the exception below: leaving it in inline flow lets its
279
+ * invisible spaces wrap around long cell content.
178
280
  */
179
281
  .md-glue-hidden {
180
282
  display: inline;
181
283
  visibility: hidden;
182
284
  }
183
285
 
286
+ /*
287
+ * Inactive table pipes stay in the DOM/source tree, but leave layout and
288
+ * hit-testing entirely. Keeping an invisible rect either in the content flow or
289
+ * over the cell padding can create phantom lines or steal clicks from visible
290
+ * text. Hidden source offsets therefore collapse to the neighboring semantic
291
+ * seam, matching other display-none markers. Visible pipes retain the per-theme
292
+ * active/source layout.
293
+ */
294
+ .md-table td>.md-glue-tableCellGlue.md-glue-hidden {
295
+ display: none;
296
+ }
297
+
184
298
  /*
185
299
  * Inter-block glue: the run of blank lines between two top-level blocks. It is
186
300
  * mounted as the last inline child of the block that precedes it, so it sits at
@@ -217,15 +331,6 @@
217
331
  visibility: hidden;
218
332
  }
219
333
 
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
334
  /*
230
335
  * The code-block fences (```lang / ```) each sit on their own source line. When
231
336
  * hidden they keep their vertical footprint (visibility hidden, not display
@@ -260,6 +365,48 @@
260
365
  height: 16px;
261
366
  }
262
367
 
368
+ /*
369
+ * A wide table scrolls horizontally inside its wrapper (the block box) instead
370
+ * of overflowing the page and scrolling the editor's fixed left gutter away.
371
+ * The wrapper is the scroll viewport the selection/caret clipping measures (see
372
+ * `BlockViewNode.scrollElement` / `blockViewportClip`); the inner `<table>`
373
+ * keeps `width: auto` (theme-defined) so it sizes to its content and overflows.
374
+ *
375
+ * `width: fit-content` keeps the wrapper hugging the table's intrinsic width, so
376
+ * a narrow table — and the active-block glow redirected onto the wrapper below —
377
+ * stays as wide as the table (unchanged from before this wrapper existed).
378
+ * `max-width: 100%` caps it at the content column, past which the table
379
+ * overflows and scrolls locally. This is the standard responsive-table pattern
380
+ * (cf. GitHub's own `width: max-content; max-width: 100%`).
381
+ */
382
+ .md-table-wrapper {
383
+ overflow-x: auto;
384
+ width: fit-content;
385
+ max-width: 100%;
386
+ }
387
+
388
+ /*
389
+ * The active-block highlight is an *outset* glow (`box-shadow: 0 0 0 8px`).
390
+ * Making the wrapper a scroll box (`overflow-x: auto`, which also forces
391
+ * `overflow-y: auto`) clips descendant paint to its padding box, so the glow on
392
+ * the inner active `<table>` would be cut off (the table has no horizontal
393
+ * margin to give the shadow room). Render the generic active chrome on the
394
+ * wrapper instead — a scroll box's own shadow is never clipped by its own
395
+ * overflow, exactly like a code block carries the glow on its own scroller —
396
+ * and drop it from the table, which keeps `md-block-active` purely for the
397
+ * per-theme source-pipe styling.
398
+ */
399
+ .md-table-wrapper:has(> .md-table.md-block-active) {
400
+ background: var(--md-block-active-background, #f8f8f8);
401
+ border-radius: 4px;
402
+ box-shadow: 0 0 0 8px var(--md-block-active-background, #f8f8f8);
403
+ }
404
+
405
+ .md-table.md-block-active {
406
+ background: none;
407
+ box-shadow: none;
408
+ }
409
+
263
410
  .md-selection-layer {
264
411
  position: absolute;
265
412
  top: 0;
@@ -274,6 +421,54 @@
274
421
  fill: rgba(59, 130, 246, 0.25);
275
422
  }
276
423
 
424
+ /*
425
+ * Gutter markers (source-control style change indicators). The layer fills the
426
+ * content box; each marker is an absolutely-positioned bar pinned to the left
427
+ * gutter (inside `.md-editor-content`'s 48px padding). The view sets only
428
+ * `top`/`height`; horizontal placement, width and color live here so themes can
429
+ * tune them without touching layout. Like the other overlays it never eats
430
+ * pointer events.
431
+ */
432
+ .md-gutter-layer {
433
+ position: absolute;
434
+ top: 0;
435
+ left: 0;
436
+ width: 100%;
437
+ height: 100%;
438
+ pointer-events: none;
439
+ overflow: visible;
440
+ }
441
+
442
+ .md-gutter-marker {
443
+ position: absolute;
444
+ left: var(--md-gutter-marker-left, 18px);
445
+ width: var(--md-gutter-marker-width, 3px);
446
+ border-radius: 2px;
447
+ }
448
+
449
+ .md-gutter-marker-added {
450
+ background: var(--md-gutter-added, #2ea043);
451
+ }
452
+
453
+ .md-gutter-marker-modified {
454
+ background: var(--md-gutter-modified, #0969da);
455
+ }
456
+
457
+ /*
458
+ * A deletion has no lines to span, so it is drawn as a downward-pointing
459
+ * triangle centered on the seam where the removed text used to be (the top of
460
+ * the line that now follows it), matching the git deleted-lines affordance.
461
+ */
462
+ .md-gutter-marker-deleted {
463
+ width: 0;
464
+ height: 0;
465
+ border-radius: 0;
466
+ border-left: var(--md-gutter-marker-width, 3px) solid var(--md-gutter-deleted, #cf222e);
467
+ border-top: 4px solid transparent;
468
+ border-bottom: 4px solid transparent;
469
+ transform: translateY(-4px);
470
+ }
471
+
277
472
  /* Source markers occupy the gutter so toggling them never shifts content. */
278
473
  .md-heading {
279
474
  position: relative;
@@ -346,14 +541,7 @@
346
541
  overflow-x: auto;
347
542
  }
348
543
 
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
544
  .md-list li>.md-paragraph {
356
- display: inline;
357
545
  margin: 0;
358
546
  }
359
547
 
@@ -433,20 +621,57 @@
433
621
  white-space: pre;
434
622
  }
435
623
 
624
+ /*
625
+ * A loose list item's later block (its second paragraph etc.) owns the source
626
+ * continuation indent that precedes it as its `leadingTrivia`. Like a nested
627
+ * list's gutter, that indent glue is pulled out of flow to the left so it never
628
+ * widens the line: the block's text stays aligned with the first paragraph
629
+ * above it, and the indent dots only appear in the left margin when the block is
630
+ * active (the footprint is identical in both states, so the text never shifts).
631
+ */
632
+ .md-list li>.md-block,
633
+ .md-task-list-item>.md-block {
634
+ position: relative;
635
+ }
636
+
637
+ .md-list li>.md-block>.md-glue-indent:first-child,
638
+ .md-task-list-item>.md-block>.md-glue-indent:first-child {
639
+ position: absolute;
640
+ right: 100%;
641
+ top: 0;
642
+ }
643
+
436
644
  .md-task-list-item {
437
645
  list-style: none;
438
646
  position: relative;
647
+ /*
648
+ * Width of the checkbox / `[x]` source column. Single-sourced so the marker
649
+ * reservation on the first paragraph and the left indent of any following
650
+ * block (loose task items) stay in lockstep — keeping every block's text in
651
+ * one vertical column under the marker.
652
+ */
653
+ --md-task-marker-width: 1.75em;
439
654
  }
440
655
 
441
656
  /*
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
657
+ * Reserve the marker column after the `[x]`/`[ ]` source marker (the first glue
658
+ * in a task item's paragraph) so the rendered checkbox widget overlaid on it has
659
+ * a comfortable gap before the text. The fixed width applies in both active and
445
660
  * inactive states, so the first text character does not drift horizontally when
446
661
  * markers toggle (see the compare fixture's `checkMarkedTextX` assertion).
447
662
  */
448
663
  .md-task-list-item .md-paragraph>.md-glue:first-child {
449
- padding-right: 0.7em;
664
+ display: inline-block;
665
+ width: var(--md-task-marker-width);
666
+ }
667
+
668
+ /*
669
+ * Following blocks in a loose task item (the second paragraph etc.) carry no
670
+ * marker glue, so indent them by the marker column to line their text up under
671
+ * the first paragraph's text rather than under the checkbox.
672
+ */
673
+ .md-task-list-item>.md-block+.md-block {
674
+ padding-left: var(--md-task-marker-width);
450
675
  }
451
676
 
452
677
  .md-checkbox {
@@ -499,11 +724,19 @@
499
724
  .md-cursor {
500
725
  position: absolute;
501
726
  width: 2px;
502
- background: #000;
727
+ background: var(--md-cursor-background, #000);
503
728
  pointer-events: none;
504
729
  animation: md-cursor-blink 1s step-end infinite;
505
730
  }
506
731
 
732
+ /*
733
+ * Read-only mode retains the logical caret for selection and comment anchoring.
734
+ * Hide only its painted element so unlocking can restore it in place.
735
+ */
736
+ .md-editor.md-readonly .md-cursor {
737
+ visibility: hidden;
738
+ }
739
+
507
740
  @keyframes md-cursor-blink {
508
741
 
509
742
  0%,
@@ -514,4 +747,138 @@
514
747
  50% {
515
748
  opacity: 0;
516
749
  }
750
+ }
751
+
752
+ /*
753
+ * Edit / read-only lock toggle.
754
+ *
755
+ * The host is a zero-height sticky strip pinned to the top of the scroll
756
+ * viewport, so the control stays in the top-right corner as the document
757
+ * scrolls. Being height-0 it never participates in the document's vertical
758
+ * flow. Colors use local `--md-readonly-*` custom properties with literal
759
+ * fallbacks so this base file stays theme-agnostic (themes may override them).
760
+ */
761
+ .md-readonly-toggle-host {
762
+ position: sticky;
763
+ top: 0;
764
+ height: 0;
765
+ z-index: 10;
766
+ pointer-events: none;
767
+ }
768
+
769
+ .md-readonly-toggle {
770
+ position: absolute;
771
+ top: 4px;
772
+ right: 4px;
773
+ pointer-events: auto;
774
+ display: inline-grid;
775
+ grid-template-columns: repeat(2, 24px);
776
+ align-items: center;
777
+ justify-items: center;
778
+ gap: 2px;
779
+ box-sizing: border-box;
780
+ width: 58px;
781
+ height: 32px;
782
+ padding: 3px;
783
+ overflow: hidden;
784
+ direction: ltr;
785
+ appearance: none;
786
+ border-radius: 999px;
787
+ border: 1px solid var(--md-readonly-border, #b8b8b8);
788
+ background: var(--md-readonly-background, #f3f3f3);
789
+ color: var(--md-readonly-foreground, #444444);
790
+ font-size: 16px;
791
+ line-height: 1;
792
+ cursor: pointer;
793
+ box-shadow: 0 0 12px rgba(0, 0, 0, 0.14);
794
+ transition: background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
795
+ }
796
+
797
+ .md-readonly-toggle:hover {
798
+ border-color: var(--md-readonly-border-hover, #8d8d8d);
799
+ background: var(--md-readonly-background-hover, #e9e9e9);
800
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.16);
801
+ }
802
+
803
+ .md-readonly-toggle:focus-visible {
804
+ outline: 2px solid var(--md-readonly-accent, #4c8bf5);
805
+ outline-offset: 1px;
806
+ }
807
+
808
+ .md-readonly-toggle .md-readonly-toggle-indicator {
809
+ position: absolute;
810
+ top: 50%;
811
+ left: 3px;
812
+ width: 24px;
813
+ height: 24px;
814
+ border-radius: 50%;
815
+ background: var(--md-readonly-accent, #4c8bf5);
816
+ box-shadow: 0 0 3px rgba(0, 0, 0, 0.25);
817
+ transform: translate(26px, -50%);
818
+ transition: background-color 0.12s ease, transform 0.16s ease;
819
+ }
820
+
821
+ .md-readonly-toggle .md-readonly-toggle-icon {
822
+ position: relative;
823
+ z-index: 1;
824
+ display: block;
825
+ width: 16px;
826
+ height: 16px;
827
+ color: var(--md-readonly-foreground, #444444);
828
+ opacity: 0.62;
829
+ pointer-events: none;
830
+ transition: color 0.12s ease, opacity 0.12s ease;
831
+ }
832
+
833
+ .md-readonly-toggle:not(.md-readonly-toggle-locked) .md-readonly-toggle-icon-editing,
834
+ .md-readonly-toggle.md-readonly-toggle-locked .md-readonly-toggle-icon-locked {
835
+ color: var(--md-readonly-accent-foreground, #ffffff);
836
+ opacity: 1;
837
+ }
838
+
839
+ .md-readonly-toggle.md-readonly-toggle-locked .md-readonly-toggle-indicator {
840
+ transform: translate(0, -50%);
841
+ }
842
+
843
+ @media (prefers-reduced-motion: reduce) {
844
+ .md-readonly-toggle,
845
+ .md-readonly-toggle .md-readonly-toggle-indicator,
846
+ .md-readonly-toggle .md-readonly-toggle-icon {
847
+ transition: none;
848
+ }
849
+ }
850
+
851
+ @media (forced-colors: active) {
852
+ .md-readonly-toggle {
853
+ forced-color-adjust: none;
854
+ border-color: ButtonText;
855
+ background: ButtonFace;
856
+ color: ButtonText;
857
+ box-shadow: none;
858
+ }
859
+
860
+ .md-readonly-toggle:hover {
861
+ border-color: Highlight;
862
+ background: ButtonFace;
863
+ box-shadow: none;
864
+ }
865
+
866
+ .md-readonly-toggle:focus-visible {
867
+ outline-color: Highlight;
868
+ }
869
+
870
+ .md-readonly-toggle .md-readonly-toggle-indicator {
871
+ background: Highlight;
872
+ box-shadow: none;
873
+ }
874
+
875
+ .md-readonly-toggle .md-readonly-toggle-icon {
876
+ color: ButtonText;
877
+ opacity: 1;
878
+ }
879
+
880
+ .md-readonly-toggle:not(.md-readonly-toggle-locked) .md-readonly-toggle-icon-editing,
881
+ .md-readonly-toggle.md-readonly-toggle-locked .md-readonly-toggle-icon-locked {
882
+ color: HighlightText;
883
+ }
517
884
  }
@@ -121,9 +121,14 @@
121
121
  --md-list-indent-step: 24px;
122
122
  }
123
123
 
124
+ .md-theme-default .md-table-wrapper {
125
+ /* Block spacing lives on the wrapper (the scroll/BFC box) so it collapses
126
+ with siblings as before; the inner table has no margin of its own. */
127
+ margin: 0.5em 0;
128
+ }
129
+
124
130
  .md-theme-default .md-table {
125
131
  border-collapse: collapse;
126
- margin: 0.5em 0;
127
132
  width: auto;
128
133
  }
129
134
 
@@ -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;
@@ -202,10 +197,15 @@
202
197
  line-height: 1;
203
198
  }
204
199
 
205
- .github-markdown-theme .md-table {
206
- border-collapse: collapse;
200
+ .github-markdown-theme .md-table-wrapper {
201
+ /* Block spacing lives on the wrapper (the scroll/BFC box) so it collapses
202
+ with siblings as before; the inner table has no margin of its own. */
207
203
  margin-top: 0;
208
204
  margin-bottom: 16px;
205
+ }
206
+
207
+ .github-markdown-theme .md-table {
208
+ border-collapse: collapse;
209
209
  width: auto;
210
210
  }
211
211