Skip to content

B-015L-obsmd-vars-never-resolve-for-the-editor

State: closed/abandoned

The theme.css of @sksizer/obsidian-md declares every --obsmd-* variable scoped to .obsidian-md, with the dark set on .obsidian-md.dark. The CodeMirror editor from @sksizer/obsidian-editor has no .obsidian-md ancestor, so none of those variables reach it: getPropertyValue("--obsmd-code-bg") answers empty on both :root and .cm-editor, and every colour in obsidian-editor/src/theme.ts falls through to its literal fallback.

Two visible consequences.

  • A code fence in the edit modes keeps its light #f6f8fa background while the surrounding text flips to near-white in dark mode: light on light, unreadable. Measured with a 3 s settle, .cm-codeblock-line background is rgb(246, 248, 250) in both themes while the text colour goes rgb(26,26,28) to rgb(234,234,238). The text flips only because color: var(--obsmd-text, inherit) degrades to inherit and picks up the shell.
  • Every &dark rule in the editor theme (roughly 15 of them, theme.ts 212-246) is inert as well, because no host puts the view into the dark mode of CodeMirror: the class list on .cm-editor is cm-editor plus the generated style ids, with no dark marker.

Reading mode is unaffected. The reading root carries .obsidian-md, so the variables resolve there.

Two candidate fixes, neither chosen here:

  1. Resolve the --obsmd-* variables at :root as well as .obsidian-md, so a consumer of either engine inherits them wherever it mounts.
  2. Wrap the editor host in .obsidian-md, mirroring the dark marker onto it, so the existing scoped declarations reach the editor unchanged.

Each has blast radius across every host that mounts the editor, which is why this is a backlog entry rather than a fix inside a product PR.

Pre-existing on main, not a wave-1 regression: before the migration onto MdSurface the notes experience had the same shape, setting --obsmd-code-bg-override on :root and carrying no .cm-* colour rules of its own. Found while re-taking dark screenshots for #1700.

Evidence, under .sdlc/orchestration/markdown-editing/handoffs/04-wave1/evidence/notes/: live-dark.png and source-dark.png show the defect, read-dark.png shows reading mode rendering correctly beside it.


← Back to Backlog