Modifying the CodeMirror style will cause the markdown editor to also be modified #3455

Closed
opened 2026-02-05 06:46:20 +03:00 by OVERLORD · 1 comment
Owner

Originally created by @liuhuanshuo on GitHub (Jan 15, 2023).

Describe the Bug

If I add a custom style like below in the background (according to the official documentation)

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.29.0/theme/seti.css"/>
<script>window.codeTheme='seti';</script>

The code box style of the page will be modified, it works fine

But the style of the markdown editor will also be modified synchronously, which is bad

Steps to Reproduce

It happens as long as you modify the relevant styles such as .cm-s-seti.CodeMirror, it seems that the code block and the editor use overlapping CSS

Expected Behaviour

fix it

Screenshots or Additional Context

No response

Browser Details

No response

Exact BookStack Version

V22.11.1

PHP Version

No response

Hosting Environment

docker compose

Originally created by @liuhuanshuo on GitHub (Jan 15, 2023). ### Describe the Bug If I add a custom style like below in the background (according to the official documentation) ```html <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.29.0/theme/seti.css"/> <script>window.codeTheme='seti';</script> ``` The code box style of the page will be modified, it works fine ![](https://pic.liuzaoqi.com/picgo/202301151137743.png) But the style of the markdown editor will also be modified synchronously, which is bad ![](https://pic.liuzaoqi.com/picgo/202301151138256.png) ### Steps to Reproduce It happens as long as you modify the relevant styles such as .cm-s-seti.CodeMirror, it seems that the code block and the editor use overlapping CSS ### Expected Behaviour fix it ### Screenshots or Additional Context _No response_ ### Browser Details _No response_ ### Exact BookStack Version V22.11.1 ### PHP Version _No response_ ### Hosting Environment docker compose
OVERLORD added the 🐛 Bug label 2026-02-05 06:46:20 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Jan 15, 2023):

Hi @liuhuanshuo, This is actually intended and not a bug in existing functionality.
The markdown editor is considered a code editor and is also a codemirror instance.

If you really don't want this, you may be able to work around this by resetting the theme for the markdown editor by adding the below to the "Custom HTML Head Content" setting:

<script>
window.addEventListener('editor-markdown-cm::pre-init', event => {
  const cmConfig = event.detail.config;
  cmConfig.theme = 'default';
});
</script>
@ssddanbrown commented on GitHub (Jan 15, 2023): Hi @liuhuanshuo, This is actually intended and not a bug in existing functionality. The markdown editor is considered a code editor and is also a codemirror instance. If you really don't want this, you may be able to work around this by resetting the theme for the markdown editor by adding the below to the "Custom HTML Head Content" setting: ```html <script> window.addEventListener('editor-markdown-cm::pre-init', event => { const cmConfig = event.detail.config; cmConfig.theme = 'default'; }); </script> ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#3455