Conversation
cyanzhong
reviewed
Aug 18, 2026
| * With `"themeName": "auto"`, the css depends on the app's current theme, | ||
| * which can change at runtime; refresh it whenever the preview updates. | ||
| */ | ||
| function refreshThemeStyles() { |
Contributor
There was a problem hiding this comment.
The way we refresh doesn't seem to be optimal, I can add a new onEditorThemeChange event to markedit-api so we safely refresh the theme.
Author
There was a problem hiding this comment.
Agreed — an official onEditorThemeChange in markedit-api would be much cleaner than refreshing on render. If you add it, I'll switch this PR to subscribe to the event (keeping the render-time refresh only as a fallback for older app versions, or dropping it entirely if you prefer a minimum-version requirement).
Contributor
There was a problem hiding this comment.
@akurach I've added onEditorConfigChange: MarkEdit-app/MarkEdit-api@501a167 The main branch of this repo integrated the new types. MarkEdit.editorConfig is also strictly typed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements #167.
With
"themeName": "auto", the preview resolves its theme from the app's current theme (MarkEdit.editorConfig.theme) instead of a fixed name:-light/-dark/-dawnsuffix is stripped to get the preview theme name — every built-in app theme maps onto an existing preview theme, so no new CSS is needed.coreCss/previewThemeCss/alertsCss/hljsCss), soxcode-darkkeeps the preview dark under a light system appearance. Suffix-less app themes (dracula,cobalt,night-owl,synthwave84,rose-pine) are treated as dark.rose-pine-dawnmaps to rose-pine light.prefers-color-schemechanges. Explicitly configured theme names behave exactly as before.Default behavior is unchanged:
themeNamestill defaults togithub,"none"still renders raw HTML.Tests: added
tests/theme.auto.test.tscovering the mapping (suffixed, suffix-less,rose-pine-dawn, missing config).yarn lintpasses; the full test suite shows the same 15 pre-existing failures asmainin my environment (Node 26, localStorage-related), with no new ones.