From 16ab8c830325d36cb532e3e8701d9f6c59c683a6 Mon Sep 17 00:00:00 2001 From: Dotta Date: Sun, 15 Mar 2026 14:39:09 -0500 Subject: [PATCH] Dark theme for CodeMirror code blocks in MDXEditor The code blocks users see in issue documents are rendered by CodeMirror (via MDXEditor's codeMirrorPlugin), not by MarkdownBody. MDXEditor bundles cm6-theme-basic-light which gives them a white background. Added dark overrides for all CodeMirror elements: - .cm-editor: dark background (#1e1e2e), light text (#cdd6f4) - .cm-gutters: darker gutter with muted line numbers - .cm-activeLine, .cm-selectionBackground: subtle dark highlights - .cm-cursor: light cursor for visibility - Language selector dropdown: dark-themed to match - Reduced pre padding to 0 since CodeMirror handles its own spacing Uses \!important to beat CodeMirror's programmatically-injected theme styles (EditorView.theme generates high-specificity scoped selectors). Co-Authored-By: Paperclip --- ui/src/index.css | 50 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/ui/src/index.css b/ui/src/index.css index 1172f103..c9ee652f 100644 --- a/ui/src/index.css +++ b/ui/src/index.css @@ -417,7 +417,7 @@ .paperclip-mdxeditor-content pre { margin: 0.4rem 0; - padding: 0.5rem 0.65rem; + padding: 0; border: 1px solid color-mix(in oklab, var(--foreground) 12%, transparent); border-radius: calc(var(--radius) - 3px); background: #1e1e2e; @@ -425,7 +425,46 @@ overflow-x: auto; } -/* MDXEditor code block language selector – keep it out of the way on small screens */ +/* Dark theme for CodeMirror code blocks inside the MDXEditor. + Overrides the default cm6-theme-basic-light that MDXEditor bundles. */ +.paperclip-mdxeditor .cm-editor { + background-color: #1e1e2e !important; + color: #cdd6f4 !important; + font-size: 0.78em; +} + +.paperclip-mdxeditor .cm-gutters { + background-color: #181825 !important; + color: #585b70 !important; + border-right: 1px solid #313244 !important; +} + +.paperclip-mdxeditor .cm-activeLineGutter { + background-color: #1e1e2e !important; +} + +.paperclip-mdxeditor .cm-activeLine { + background-color: color-mix(in oklab, #cdd6f4 5%, transparent) !important; +} + +.paperclip-mdxeditor .cm-cursor, +.paperclip-mdxeditor .cm-dropCursor { + border-left-color: #cdd6f4 !important; +} + +.paperclip-mdxeditor .cm-selectionBackground { + background-color: color-mix(in oklab, #89b4fa 25%, transparent) !important; +} + +.paperclip-mdxeditor .cm-focused .cm-selectionBackground { + background-color: color-mix(in oklab, #89b4fa 30%, transparent) !important; +} + +.paperclip-mdxeditor .cm-content { + caret-color: #cdd6f4; +} + +/* MDXEditor code block language selector – show on hover only */ .paperclip-mdxeditor-content [class*="_codeMirrorWrapper_"] { position: relative; } @@ -440,6 +479,13 @@ transition: opacity 150ms ease; } +.paperclip-mdxeditor-content [class*="_codeMirrorToolbar_"] select, +.paperclip-mdxeditor-content [class*="_codeBlockToolbar_"] select { + background-color: #313244; + color: #cdd6f4; + border-color: #45475a; +} + .paperclip-mdxeditor-content [class*="_codeMirrorWrapper_"]:hover [class*="_codeMirrorToolbar_"], .paperclip-mdxeditor-content [class*="_codeMirrorWrapper_"]:hover [class*="_codeBlockToolbar_"], .paperclip-mdxeditor-content [class*="_codeMirrorWrapper_"]:focus-within [class*="_codeMirrorToolbar_"],