fix: sync global theme on construct when theme option is explicitly provided
This commit is contained in:
+8
-1
@@ -11,7 +11,7 @@ import { injectStyles } from './styles.js';
|
||||
import { t as i18nT, getCurrentLocale, getLocaleDirection } from './i18n.js';
|
||||
import { parseMarkdown } from './parser.js';
|
||||
import { presetPlugins } from './plugins.js';
|
||||
import { getTheme } from './themes.js';
|
||||
import { getTheme, applyTheme, saveTheme } from './themes.js';
|
||||
|
||||
const MODES = ['edit', 'split', 'preview'];
|
||||
|
||||
@@ -97,6 +97,13 @@ class MarkdownEditor {
|
||||
|
||||
injectStyles();
|
||||
this._buildDOM();
|
||||
|
||||
// 主题同步:用户显式传 theme 时覆盖全局 CSS 变量并持久化,否则尊重 localStorage
|
||||
if (options.theme) {
|
||||
applyTheme(this.config.theme);
|
||||
saveTheme(this.config.theme);
|
||||
}
|
||||
|
||||
this._buildToolbar();
|
||||
this._bindEvents();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user