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

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-21",
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/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",
@@ -26,6 +26,7 @@
26
26
  .md-editor {
27
27
  display: flow-root;
28
28
  outline: none;
29
+ container: md-editor / inline-size;
29
30
  /* The editor paints its own cursor (`.md-cursor`); hide the native caret. */
30
31
  caret-color: transparent;
31
32
  }
@@ -48,9 +49,27 @@
48
49
  * `.md-editor`.
49
50
  */
50
51
  .md-editor-content {
52
+ --md-editor-content-inline-start-padding: 48px;
53
+ --md-readonly-toggle-width: 58px;
54
+ --md-readonly-toggle-height: 32px;
55
+ /* Leaves 16px of optical separation beyond the active block's 8px outset glow. */
56
+ --md-readonly-toggle-gap: 24px;
57
+ --md-readonly-toggle-inset: 4px;
58
+ --md-editor-content-inline-end-padding: var(--md-editor-content-inline-start-padding);
51
59
  position: relative;
52
60
  margin-inline: auto;
53
- padding: 0 48px;
61
+ padding-block: 0;
62
+ padding-inline: var(--md-editor-content-inline-start-padding) var(--md-editor-content-inline-end-padding);
63
+ }
64
+
65
+ .md-editor-content-with-readonly-toggle {
66
+ --md-editor-content-inline-end-padding: calc(
67
+ var(--md-readonly-toggle-width) + var(--md-readonly-toggle-gap) + var(--md-readonly-toggle-inset)
68
+ );
69
+ }
70
+
71
+ .md-editor-content-with-readonly-toggle>.md-document :is(.md-heading, .md-paragraph) {
72
+ overflow-wrap: anywhere;
54
73
  }
55
74
 
56
75
  .md-block-active {
@@ -295,6 +314,39 @@ pre.md-unhandled-scroll.md-code-block {
295
314
  display: none;
296
315
  }
297
316
 
317
+ /*
318
+ * Active table: take each cell's TRAILING structural glue (the source space
319
+ * after the cell text, and — via the per-theme `right: 0` rule — the last
320
+ * column's closing `|`) out of the cell's inline flow. Left in flow, that glue
321
+ * wraps below long cell content (the same wrapping the hidden-glue note above
322
+ * describes), which makes the cell two lines tall: the browser's default
323
+ * `vertical-align: middle` then re-centres the other cells' single-line content
324
+ * in Y, their runs merge into one oversized VisualLine, and the caret — sized
325
+ * directly from that line box — grows far past the line height while the
326
+ * visible pipes drift apart row-to-row. Positioning the trailing glue
327
+ * absolutely removes it from wrapping flow while keeping its real client rects
328
+ * at the static (content-line) position, so caret placement, hit-testing,
329
+ * source mapping and injectivity are unchanged. `top`/`bottom: auto` keep it on
330
+ * that content line rather than the cell's top edge. This mirrors the inactive
331
+ * `display: none` above; the leading `| ` glue deliberately stays in flow (a
332
+ * relative glyph shift, per theme) so first-text X is preserved.
333
+ *
334
+ * `:not(:first-child)` restricts this to a genuine trailing glue: a non-empty
335
+ * cell emits leading + trailing glue, but an EMPTY cell parses to a single glue
336
+ * node that is simultaneously first and last child. That lone node is the
337
+ * cell's leading pipe, so it must stay in flow like every other leading pipe;
338
+ * excluding it keeps empty cells identical to their previous (base) behaviour.
339
+ */
340
+ .md-table.md-block-active td {
341
+ position: relative;
342
+ }
343
+
344
+ .md-table.md-block-active td>.md-glue-tableCellGlue:last-child:not(:first-child) {
345
+ position: absolute;
346
+ top: auto;
347
+ bottom: auto;
348
+ }
349
+
298
350
  /*
299
351
  * Inter-block glue: the run of blank lines between two top-level blocks. It is
300
352
  * mounted as the last inline child of the block that precedes it, so it sits at
@@ -621,6 +673,16 @@ pre.md-unhandled-scroll.md-code-block {
621
673
  white-space: pre;
622
674
  }
623
675
 
676
+ /*
677
+ * A continuation-line indent inside a paragraph is source-only padding. When
678
+ * inactive, the preceding soft-break newline already collapses to the single
679
+ * rendered space Markdown requires; retaining the hidden indent would add the
680
+ * tab/space run's width on top of it.
681
+ */
682
+ .md-paragraph>.md-glue-indent.md-glue-hidden {
683
+ display: none;
684
+ }
685
+
624
686
  /*
625
687
  * A loose list item's later block (its second paragraph etc.) owns the source
626
688
  * continuation indent that precedes it as its `leadingTrivia`. Like a nested
@@ -752,15 +814,17 @@ pre.md-unhandled-scroll.md-code-block {
752
814
  /*
753
815
  * Edit / read-only lock toggle.
754
816
  *
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).
817
+ * The asymmetric content padding reserves a real rail for the control:
818
+ * button width + gap + edge inset. The zero-height sticky host spans the
819
+ * document column and that rail, keeping the button beside (never over) the
820
+ * rendered document as it scrolls. Colors use local `--md-readonly-*` custom
821
+ * properties with literal fallbacks so this base file stays theme-agnostic
822
+ * (themes may override them).
760
823
  */
761
824
  .md-readonly-toggle-host {
762
825
  position: sticky;
763
826
  top: 0;
827
+ width: calc(100% + var(--md-editor-content-inline-end-padding));
764
828
  height: 0;
765
829
  z-index: 10;
766
830
  pointer-events: none;
@@ -769,7 +833,7 @@ pre.md-unhandled-scroll.md-code-block {
769
833
  .md-readonly-toggle {
770
834
  position: absolute;
771
835
  top: 4px;
772
- right: 4px;
836
+ right: var(--md-readonly-toggle-inset);
773
837
  pointer-events: auto;
774
838
  display: inline-grid;
775
839
  grid-template-columns: repeat(2, 24px);
@@ -777,8 +841,8 @@ pre.md-unhandled-scroll.md-code-block {
777
841
  justify-items: center;
778
842
  gap: 2px;
779
843
  box-sizing: border-box;
780
- width: 58px;
781
- height: 32px;
844
+ width: var(--md-readonly-toggle-width);
845
+ height: var(--md-readonly-toggle-height);
782
846
  padding: 3px;
783
847
  overflow: hidden;
784
848
  direction: ltr;
@@ -790,14 +854,71 @@ pre.md-unhandled-scroll.md-code-block {
790
854
  font-size: 16px;
791
855
  line-height: 1;
792
856
  cursor: pointer;
793
- box-shadow: 0 0 12px rgba(0, 0, 0, 0.14);
857
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.08);
794
858
  transition: background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
795
859
  }
796
860
 
861
+ /*
862
+ * Below this width there is not enough document column for the side rail to be
863
+ * useful. Give the host its own row and stop it from sticking, so neither long
864
+ * unbreakable content nor later content scrolled through the viewport can ever
865
+ * pass underneath the button.
866
+ */
867
+ @container md-editor (max-width: 320px) {
868
+ .md-readonly-toggle-host {
869
+ position: relative;
870
+ height: calc(
871
+ var(--md-readonly-toggle-height) + var(--md-readonly-toggle-inset) + var(--md-readonly-toggle-inset)
872
+ );
873
+ }
874
+ }
875
+
876
+ .md-readonly-toggle::after {
877
+ content: '';
878
+ position: absolute;
879
+ z-index: 2;
880
+ top: -8px;
881
+ bottom: -8px;
882
+ left: -30px;
883
+ width: 24px;
884
+ background: linear-gradient(90deg,
885
+ transparent,
886
+ var(--md-readonly-shine-edge, rgba(255, 255, 255, 0.16)) 24%,
887
+ var(--md-readonly-shine, #ffffff) 50%,
888
+ var(--md-readonly-shine-edge, rgba(255, 255, 255, 0.16)) 76%,
889
+ transparent);
890
+ box-shadow: 0 0 8px 2px var(--md-readonly-shine-glow, rgba(255, 255, 255, 0.58));
891
+ opacity: 0;
892
+ pointer-events: none;
893
+ transform: skewX(-20deg);
894
+ }
895
+
896
+ .md-readonly-toggle.md-readonly-toggle-shine::after {
897
+ animation: md-readonly-toggle-shine 2s linear;
898
+ will-change: transform, opacity;
899
+ }
900
+
901
+ @keyframes md-readonly-toggle-shine {
902
+ 0% {
903
+ opacity: 0;
904
+ transform: translateX(0) skewX(-20deg);
905
+ }
906
+
907
+ 12%,
908
+ 88% {
909
+ opacity: 1;
910
+ }
911
+
912
+ 100% {
913
+ opacity: 0;
914
+ transform: translateX(122px) skewX(-20deg);
915
+ }
916
+ }
917
+
797
918
  .md-readonly-toggle:hover {
798
919
  border-color: var(--md-readonly-border-hover, #8d8d8d);
799
920
  background: var(--md-readonly-background-hover, #e9e9e9);
800
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.16);
921
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 6px 16px rgba(0, 0, 0, 0.1);
801
922
  }
802
923
 
803
924
  .md-readonly-toggle:focus-visible {
@@ -843,7 +964,9 @@ pre.md-unhandled-scroll.md-code-block {
843
964
  @media (prefers-reduced-motion: reduce) {
844
965
  .md-readonly-toggle,
845
966
  .md-readonly-toggle .md-readonly-toggle-indicator,
846
- .md-readonly-toggle .md-readonly-toggle-icon {
967
+ .md-readonly-toggle .md-readonly-toggle-icon,
968
+ .md-readonly-toggle.md-readonly-toggle-shine::after {
969
+ animation: none;
847
970
  transition: none;
848
971
  }
849
972
  }
@@ -857,6 +980,10 @@ pre.md-unhandled-scroll.md-code-block {
857
980
  box-shadow: none;
858
981
  }
859
982
 
983
+ .md-readonly-toggle::after {
984
+ display: none;
985
+ }
986
+
860
987
  .md-readonly-toggle:hover {
861
988
  border-color: Highlight;
862
989
  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
  }