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
#f6f8fabackground while the surrounding text flips to near-white in dark mode: light on light, unreadable. Measured with a 3 s settle,.cm-codeblock-linebackground isrgb(246, 248, 250)in both themes while the text colour goesrgb(26,26,28)torgb(234,234,238). The text flips only becausecolor: var(--obsmd-text, inherit)degrades toinheritand picks up the shell. - Every
&darkrule in the editor theme (roughly 15 of them,theme.ts212-246) is inert as well, because no host puts the view into the dark mode of CodeMirror: the class list on.cm-editoriscm-editorplus 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:
- Resolve the
--obsmd-*variables at:rootas well as.obsidian-md, so a consumer of either engine inherits them wherever it mounts. - 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.