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

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-20",
3
+ "version": "0.0.2-22",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -14,6 +14,9 @@
14
14
  },
15
15
  "main": "./dist/index.js",
16
16
  "types": "./dist/index.d.ts",
17
+ "sideEffects": [
18
+ "**/*.css"
19
+ ],
17
20
  "files": [
18
21
  "dist",
19
22
  "src/view/editor.css",
@@ -34,6 +37,10 @@
34
37
  "types": "./dist/observables.d.ts",
35
38
  "import": "./dist/observables.js"
36
39
  },
40
+ "./web-editors": {
41
+ "types": "./dist/web-editors.d.ts",
42
+ "import": "./dist/web-editors.js"
43
+ },
37
44
  "./editor.css": "./src/view/editor.css",
38
45
  "./themes/default.css": "./src/view/themes/default.css",
39
46
  "./themes/github.css": "./src/view/themes/github.css",
@@ -44,8 +51,9 @@
44
51
  "./vscodeCommentWidgetV2.css": "./src/contrib/commentsVscode/vscodeCommentWidgetV2.css"
45
52
  },
46
53
  "scripts": {
47
- "build": "vite build",
48
- "build:explorer": "vite build --config vite.fixture.config.ts --outDir dist-explorer --emptyOutDir",
54
+ "build": "pnpm run build:dependencies && vite build",
55
+ "build:dependencies": "pnpm --filter @vscode/hubrpc build",
56
+ "build:explorer": "pnpm run build:dependencies && pnpm --filter @vscode/component-explorer-vite-plugin... build && pnpm --filter @vscode/sample-web-editor build && vite build --config vite.fixture.config.ts --outDir dist-explorer --emptyOutDir",
49
57
  "dev": "vite build --watch",
50
58
  "pack": "pnpm run build && pnpm pack",
51
59
  "test": "vitest --run",
@@ -67,12 +75,14 @@
67
75
  "@playwright/test": "^1.58.2",
68
76
  "@types/katex": "^0.16.8",
69
77
  "@types/markdown-it": "^14.1.2",
70
- "@vscode/component-explorer": "0.2.1-59",
71
- "@vscode/component-explorer-cli": "0.2.1-60",
72
- "@vscode/component-explorer-vite-plugin": "0.2.1-59",
78
+ "@vscode/component-explorer": "workspace:*",
79
+ "@vscode/component-explorer-cli": "workspace:*",
80
+ "@vscode/component-explorer-vite-plugin": "workspace:*",
81
+ "@vscode/hubrpc": "workspace:*",
73
82
  "@vscode/observables": "workspace:*",
83
+ "@vscode/sample-web-editor": "workspace:*",
84
+ "@vscode/web-editors": "workspace:*",
74
85
  "github-markdown-css": "^5.9.0",
75
- "golden-layout": "^2.6.0",
76
86
  "markdown-it": "^14.2.0",
77
87
  "mermaid": "^11.15.0",
78
88
  "monaco-editor": "^0.52.2",
@@ -48,9 +48,25 @@
48
48
  * `.md-editor`.
49
49
  */
50
50
  .md-editor-content {
51
+ --md-editor-content-inline-start-padding: 48px;
52
+ --md-readonly-toggle-width: 58px;
53
+ --md-readonly-toggle-height: 32px;
54
+ /* Leaves 16px of optical separation beyond the active block's 8px outset glow. */
55
+ --md-readonly-toggle-gap: 24px;
56
+ --md-readonly-toggle-inset: 4px;
57
+ --md-editor-content-inline-end-padding: var(--md-editor-content-inline-start-padding);
51
58
  position: relative;
52
59
  margin-inline: auto;
53
- padding: 0 48px;
60
+ padding-block: 0;
61
+ padding-inline: var(--md-editor-content-inline-start-padding) var(--md-editor-content-inline-end-padding);
62
+ }
63
+
64
+ .md-editor-content-with-readonly-toggle {
65
+ --md-editor-content-inline-end-padding: calc(var(--md-readonly-toggle-width) + var(--md-readonly-toggle-gap) + var(--md-readonly-toggle-inset));
66
+ }
67
+
68
+ .md-editor-content-with-readonly-toggle>.md-document :is(.md-heading, .md-paragraph) {
69
+ overflow-wrap: anywhere;
54
70
  }
55
71
 
56
72
  .md-block-active {
@@ -128,18 +144,14 @@
128
144
  /*
129
145
  * An unhandled block: a construct the parser does not model (setext heading,
130
146
  * 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.
147
+ * styled like a code block but visibly flagged as "not understood" by a dashed
148
+ * warning border, so the content is preserved and editable rather than silently
149
+ * dropped.
135
150
  *
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.
151
+ * The wrapper is the non-scrolling box (border + block spacing); the inner
152
+ * `.md-unhandled-scroll` <pre> is the horizontal scroller.
140
153
  */
141
154
  .md-unhandled-block {
142
- position: relative;
143
155
  margin: 0.5em 0;
144
156
  border: 1px dashed #d0a000;
145
157
  border-radius: 4px;
@@ -148,30 +160,12 @@
148
160
  /*
149
161
  * Inner scroller. Beats the per-theme `.md-theme-* .md-code-block` box rules
150
162
  * (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.
163
+ * own (those live on the wrapper).
153
164
  */
154
165
  pre.md-unhandled-scroll.md-code-block {
155
166
  margin: 0;
156
167
  border: 0;
157
168
  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
169
  }
176
170
 
177
171
  /*
@@ -295,6 +289,39 @@ pre.md-unhandled-scroll.md-code-block {
295
289
  display: none;
296
290
  }
297
291
 
292
+ /*
293
+ * Active table: take each cell's TRAILING structural glue (the source space
294
+ * after the cell text, and — via the per-theme `right: 0` rule — the last
295
+ * column's closing `|`) out of the cell's inline flow. Left in flow, that glue
296
+ * wraps below long cell content (the same wrapping the hidden-glue note above
297
+ * describes), which makes the cell two lines tall: the browser's default
298
+ * `vertical-align: middle` then re-centres the other cells' single-line content
299
+ * in Y, their runs merge into one oversized VisualLine, and the caret — sized
300
+ * directly from that line box — grows far past the line height while the
301
+ * visible pipes drift apart row-to-row. Positioning the trailing glue
302
+ * absolutely removes it from wrapping flow while keeping its real client rects
303
+ * at the static (content-line) position, so caret placement, hit-testing,
304
+ * source mapping and injectivity are unchanged. `top`/`bottom: auto` keep it on
305
+ * that content line rather than the cell's top edge. This mirrors the inactive
306
+ * `display: none` above; the leading `| ` glue deliberately stays in flow (a
307
+ * relative glyph shift, per theme) so first-text X is preserved.
308
+ *
309
+ * `:not(:first-child)` restricts this to a genuine trailing glue: a non-empty
310
+ * cell emits leading + trailing glue, but an EMPTY cell parses to a single glue
311
+ * node that is simultaneously first and last child. That lone node is the
312
+ * cell's leading pipe, so it must stay in flow like every other leading pipe;
313
+ * excluding it keeps empty cells identical to their previous (base) behaviour.
314
+ */
315
+ .md-table.md-block-active td {
316
+ position: relative;
317
+ }
318
+
319
+ .md-table.md-block-active td>.md-glue-tableCellGlue:last-child:not(:first-child) {
320
+ position: absolute;
321
+ top: auto;
322
+ bottom: auto;
323
+ }
324
+
298
325
  /*
299
326
  * Inter-block glue: the run of blank lines between two top-level blocks. It is
300
327
  * mounted as the last inline child of the block that precedes it, so it sits at
@@ -621,6 +648,16 @@ pre.md-unhandled-scroll.md-code-block {
621
648
  white-space: pre;
622
649
  }
623
650
 
651
+ /*
652
+ * A continuation-line indent inside a paragraph is source-only padding. When
653
+ * inactive, the preceding soft-break newline already collapses to the single
654
+ * rendered space Markdown requires; retaining the hidden indent would add the
655
+ * tab/space run's width on top of it.
656
+ */
657
+ .md-paragraph>.md-glue-indent.md-glue-hidden {
658
+ display: none;
659
+ }
660
+
624
661
  /*
625
662
  * A loose list item's later block (its second paragraph etc.) owns the source
626
663
  * continuation indent that precedes it as its `leadingTrivia`. Like a nested
@@ -752,15 +789,17 @@ pre.md-unhandled-scroll.md-code-block {
752
789
  /*
753
790
  * Edit / read-only lock toggle.
754
791
  *
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).
792
+ * The asymmetric content padding reserves a real rail for the control:
793
+ * button width + gap + edge inset. The zero-height sticky host spans the
794
+ * document column and that rail, keeping the button beside (never over) the
795
+ * rendered document as it scrolls. Colors use local `--md-readonly-*` custom
796
+ * properties with literal fallbacks so this base file stays theme-agnostic
797
+ * (themes may override them).
760
798
  */
761
799
  .md-readonly-toggle-host {
762
800
  position: sticky;
763
801
  top: 0;
802
+ width: calc(100% + var(--md-editor-content-inline-end-padding));
764
803
  height: 0;
765
804
  z-index: 10;
766
805
  pointer-events: none;
@@ -769,7 +808,7 @@ pre.md-unhandled-scroll.md-code-block {
769
808
  .md-readonly-toggle {
770
809
  position: absolute;
771
810
  top: 4px;
772
- right: 4px;
811
+ right: var(--md-readonly-toggle-inset);
773
812
  pointer-events: auto;
774
813
  display: inline-grid;
775
814
  grid-template-columns: repeat(2, 24px);
@@ -777,8 +816,8 @@ pre.md-unhandled-scroll.md-code-block {
777
816
  justify-items: center;
778
817
  gap: 2px;
779
818
  box-sizing: border-box;
780
- width: 58px;
781
- height: 32px;
819
+ width: var(--md-readonly-toggle-width);
820
+ height: var(--md-readonly-toggle-height);
782
821
  padding: 3px;
783
822
  overflow: hidden;
784
823
  direction: ltr;
@@ -790,14 +829,67 @@ pre.md-unhandled-scroll.md-code-block {
790
829
  font-size: 16px;
791
830
  line-height: 1;
792
831
  cursor: pointer;
793
- box-shadow: 0 0 12px rgba(0, 0, 0, 0.14);
832
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.08);
794
833
  transition: background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
795
834
  }
796
835
 
836
+ /*
837
+ * Below this width there is not enough document column for the side rail to be
838
+ * useful. Give the host its own row and stop it from sticking, so neither long
839
+ * unbreakable content nor later content scrolled through the viewport can ever
840
+ * pass underneath the button.
841
+ */
842
+ .md-editor-narrow .md-readonly-toggle-host {
843
+ position: relative;
844
+ height: calc(var(--md-readonly-toggle-height) + var(--md-readonly-toggle-inset) + var(--md-readonly-toggle-inset));
845
+ }
846
+
847
+ .md-readonly-toggle::after {
848
+ content: '';
849
+ position: absolute;
850
+ z-index: 2;
851
+ top: -8px;
852
+ bottom: -8px;
853
+ left: -30px;
854
+ width: 24px;
855
+ background: linear-gradient(90deg,
856
+ transparent,
857
+ var(--md-readonly-shine-edge, rgba(255, 255, 255, 0.16)) 24%,
858
+ var(--md-readonly-shine, #ffffff) 50%,
859
+ var(--md-readonly-shine-edge, rgba(255, 255, 255, 0.16)) 76%,
860
+ transparent);
861
+ box-shadow: 0 0 8px 2px var(--md-readonly-shine-glow, rgba(255, 255, 255, 0.58));
862
+ opacity: 0;
863
+ pointer-events: none;
864
+ transform: skewX(-20deg);
865
+ }
866
+
867
+ .md-readonly-toggle.md-readonly-toggle-shine::after {
868
+ animation: md-readonly-toggle-shine 2s linear;
869
+ will-change: transform, opacity;
870
+ }
871
+
872
+ @keyframes md-readonly-toggle-shine {
873
+ 0% {
874
+ opacity: 0;
875
+ transform: translateX(0) skewX(-20deg);
876
+ }
877
+
878
+ 12%,
879
+ 88% {
880
+ opacity: 1;
881
+ }
882
+
883
+ 100% {
884
+ opacity: 0;
885
+ transform: translateX(122px) skewX(-20deg);
886
+ }
887
+ }
888
+
797
889
  .md-readonly-toggle:hover {
798
890
  border-color: var(--md-readonly-border-hover, #8d8d8d);
799
891
  background: var(--md-readonly-background-hover, #e9e9e9);
800
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.16);
892
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 6px 16px rgba(0, 0, 0, 0.1);
801
893
  }
802
894
 
803
895
  .md-readonly-toggle:focus-visible {
@@ -841,9 +933,12 @@ pre.md-unhandled-scroll.md-code-block {
841
933
  }
842
934
 
843
935
  @media (prefers-reduced-motion: reduce) {
936
+
844
937
  .md-readonly-toggle,
845
938
  .md-readonly-toggle .md-readonly-toggle-indicator,
846
- .md-readonly-toggle .md-readonly-toggle-icon {
939
+ .md-readonly-toggle .md-readonly-toggle-icon,
940
+ .md-readonly-toggle.md-readonly-toggle-shine::after {
941
+ animation: none;
847
942
  transition: none;
848
943
  }
849
944
  }
@@ -857,6 +952,10 @@ pre.md-unhandled-scroll.md-code-block {
857
952
  box-shadow: none;
858
953
  }
859
954
 
955
+ .md-readonly-toggle::after {
956
+ display: none;
957
+ }
958
+
860
959
  .md-readonly-toggle:hover {
861
960
  border-color: Highlight;
862
961
  background: ButtonFace;
@@ -206,6 +206,9 @@
206
206
  * box) so the right outline is a straight line. Absolute removes it from flow,
207
207
  * but it is the trailing node so no text shifts; the leading pipe still fixes
208
208
  * first-text X and the row stays one line tall, keeping the compare invariants.
209
+ * `top: auto` keeps the pipe on the content line (the shared editor.css rule
210
+ * also takes trailing glue out of flow); the previous `top: 0` floated it to
211
+ * the cell's top edge, misaligning it with the leading pipes on wrapping rows.
209
212
  */
210
213
  .md-theme-default .md-table.md-block-active td:last-child {
211
214
  position: relative;
@@ -214,7 +217,7 @@
214
217
  .md-theme-default .md-table.md-block-active td:last-child>.md-glue-tableCellGlue:last-child {
215
218
  position: absolute;
216
219
  right: 0;
217
- top: 0;
220
+ top: auto;
218
221
  }
219
222
 
220
223
  /*
@@ -225,7 +228,7 @@
225
228
  .md-theme-default .md-table.md-block-active .md-table-delimiter-row td:last-child>.md-marker-tableDelimiterClose {
226
229
  position: absolute;
227
230
  right: 0;
228
- top: 0;
231
+ top: auto;
229
232
  }
230
233
 
231
234
  .md-theme-default code {
@@ -285,6 +285,9 @@
285
285
  * box) so the right outline is a straight line. Absolute removes it from flow,
286
286
  * but it is the trailing node so no text shifts; the leading pipe still fixes
287
287
  * first-text X and the row stays one line tall, keeping the compare invariants.
288
+ * `top: auto` keeps the pipe on the content line (the shared editor.css rule
289
+ * also takes trailing glue out of flow); the previous `top: 0` floated it to
290
+ * the cell's top edge, misaligning it with the leading pipes on wrapping rows.
288
291
  */
289
292
  .github-markdown-theme .md-table.md-block-active td:last-child {
290
293
  position: relative;
@@ -293,7 +296,7 @@
293
296
  .github-markdown-theme .md-table.md-block-active td:last-child>.md-glue-tableCellGlue:last-child {
294
297
  position: absolute;
295
298
  right: 0;
296
- top: 0;
299
+ top: auto;
297
300
  }
298
301
 
299
302
  /*
@@ -304,5 +307,5 @@
304
307
  .github-markdown-theme .md-table.md-block-active .md-table-delimiter-row td:last-child>.md-marker-tableDelimiterClose {
305
308
  position: absolute;
306
309
  right: 0;
307
- top: 0;
310
+ top: auto;
308
311
  }
@@ -320,7 +320,10 @@
320
320
  /*
321
321
  * The last cell's closing `|` floats right after the (left-aligned) cell text.
322
322
  * Pin it to the column's right gridline (the cell's border edge, 10px past the
323
- * content box) so the right outline is a straight line.
323
+ * content box) so the right outline is a straight line. `top: auto` keeps the
324
+ * pipe on the content line (the shared editor.css rule takes it out of flow);
325
+ * the previous `top: 0` floated it to the cell's top edge, so on tall/wrapping
326
+ * rows it no longer lined up with the in-flow leading pipes.
324
327
  */
325
328
  .md-theme-vscode-default .md-table.md-block-active td:last-child {
326
329
  position: relative;
@@ -329,7 +332,7 @@
329
332
  .md-theme-vscode-default .md-table.md-block-active td:last-child>.md-glue-tableCellGlue:last-child {
330
333
  position: absolute;
331
334
  right: 0;
332
- top: 0;
335
+ top: auto;
333
336
  }
334
337
 
335
338
  /*
@@ -340,5 +343,5 @@
340
343
  .md-theme-vscode-default .md-table.md-block-active .md-table-delimiter-row td:last-child>.md-marker-tableDelimiterClose {
341
344
  position: absolute;
342
345
  right: 0;
343
- top: 0;
346
+ top: auto;
344
347
  }
@@ -322,7 +322,10 @@
322
322
  /*
323
323
  * The last cell's closing `|` floats right after the (left-aligned) cell text.
324
324
  * Pin it to the column's right gridline (the cell's border edge, 13px past the
325
- * content box) so the right outline is a straight line.
325
+ * content box) so the right outline is a straight line. `top: auto` keeps the
326
+ * pipe on the content line (the shared editor.css rule takes it out of flow);
327
+ * the previous `top: 0` floated it to the cell's top edge, so on tall/wrapping
328
+ * rows it no longer lined up with the in-flow leading pipes.
326
329
  */
327
330
  .md-theme-vscode-github .md-table.md-block-active td:last-child {
328
331
  position: relative;
@@ -331,7 +334,7 @@
331
334
  .md-theme-vscode-github .md-table.md-block-active td:last-child>.md-glue-tableCellGlue:last-child {
332
335
  position: absolute;
333
336
  right: 0;
334
- top: 0;
337
+ top: auto;
335
338
  }
336
339
 
337
340
  /*
@@ -342,5 +345,5 @@
342
345
  .md-theme-vscode-github .md-table.md-block-active .md-table-delimiter-row td:last-child>.md-marker-tableDelimiterClose {
343
346
  position: absolute;
344
347
  right: 0;
345
- top: 0;
348
+ top: auto;
346
349
  }