#2476·milkdown

[Bug] Crepe code block CSS overrides the default CodeMirror One Dark background

Author: RedlnnCreated Sep 14, 2026Updated Sep 14, 2026
Labelsbug

Initial checklist

Affected packages and versions

"@milkdown/crepe": "^7.22.1", "@milkdown/vue": "^7.22.1"

Link to runnable example

https://stackblitz.com/edit/crepe-coremirror-bug?file=src%2Fcomponents%2FMilkdownEditor.vue

Steps to reproduce

  1. Create a Crepe editor with the starter.
  2. Replace the markdown text in MilkdownEditor.vue by follow text:
    typescript
    const markdown = `\
    \`\`\`
    def foo():
        print('Hello Crepe')
        return
    \`\`\``;
  3. Observe the code block in the preview on the right. Its background color is rendered incorrectly, as shown below:Image
  4. Add the following styles to change Crepe’s default styling to match the One Dark theme, which is the default CodeMirror theme used by Crepe. These styles are adapted from @milkdown/crepe/theme/common/code-mirror.css
    xml
    <style>
    .milkdown .milkdown-code-block .cm-editor {
      background: #2d3139;
    }
    .milkdown .milkdown-code-block .cm-gutters {
      background: #2d3139;
    }
    </style>
  5. Observe the code block in the preview on the right again. The styling now appears correctly, as shown below:Image

Expected behavior

The default CodeMirror One Dark theme should be applied consistently to the entire code editor, including:

  • the editor background;
  • the gutter background;
  • the active line background.

The One Dark background should remain visible:

css
background-color: #282e34;

Actual behavior

The CodeMirror One Dark theme is only partially applied.

The text and the first gutter colors use the One Dark theme, but the editor background is overridden by the Crepe rule.

This selector has higher specificity than the generated CodeMirror theme selector, so the One Dark background declaration is crossed out in DevTools.

As a result, the code block displays a light background with One Dark foreground colors instead of a consistent One Dark theme.

Runtime

Chrome

OS

Windows

Build and bundle tools

Vite