release: v0.1.5 — theme system usability, extensibility, external theme following

feat(themes): comprehensive theme system enhancement
- Fix resolveTheme('auto') always resolves to system theme (no stale override)
- Add per-instance theme isolation via createInstanceTheme()
- Add MarkdownEditor.setTheme()/getTheme()/getThemeContext() instance methods
- Add 'themeChange' instance event with { theme, resolved, config } payload
- Multi-instance independent themes (no cross-contamination)

feat(themes): external theme following (v0.1.5)
- followExternalTheme() — follow theme via data attr, CSS class, or callback
- adoptFromParent() — inherit theme from parent container
- watch() — watch external theme source (function or selector)

feat(themes): extensibility (v0.1.5)
- registerTheme() supports 'extends' option for theme inheritance
- exportCSSVars() — export all CSS variable values from element
- getCSSVariable() — query single CSS variable
- applyThemeToElement() — apply theme to any DOM element

chore: bump version 0.1.4 → 0.1.5 across all files
test(themes): 30 new tests covering all v0.1.5 theme APIs (499 total)
This commit is contained in:
2026-07-24 09:53:20 +08:00
parent f8b9f4a761
commit 517dc34435
16 changed files with 1087 additions and 277 deletions
+25 -2
View File
@@ -1,4 +1,4 @@
// Type definitions for MetonaEditor v0.1.4
// Type definitions for MetonaEditor v0.1.5
// Project: https://git.metona.cn/MetonaTeam/MetonaEditor
// Author: thzxx
@@ -201,6 +201,21 @@ export class MarkdownEditor {
getStats(): EditorStats;
getStatus(): EditorStatus;
// 主题(v0.1.5: 实例级主题管理)
setTheme(theme: ThemeName): this;
getTheme(): string;
getThemeContext(): {
get(): string;
set(theme: string): string;
toggle(): string;
getResolved(): string;
getConfig(): object;
getVars(): object;
syncWithElement(element: HTMLElement, opts?: object): () => void;
adopt(): () => void;
watch(source: Function | string): () => void;
} | null;
// 插件
use(plugin: string | PluginObject, options?: object): this;
getPlugins(): PluginObject[];
@@ -307,7 +322,7 @@ export const themeUtils: {
getCurrentTheme(): string;
getResolvedTheme(): string;
applyTheme(theme: ThemeName): void;
registerTheme(name: string, config: object): void;
registerTheme(name: string, config: { extends?: string; [key: string]: any }): void;
unregisterTheme(name: string): void;
getAllThemes(): object;
getThemeNames(): string[];
@@ -317,6 +332,14 @@ export const themeUtils: {
addThemeListener(fn: (theme: string, resolved: string) => void): () => void;
removeThemeListener(fn: (theme: string, resolved: string) => void): void;
clearThemeListeners(): void;
// v0.1.5 新增
exportCSSVars(el?: HTMLElement): Record<string, string>;
getCSSVariable(name: string, el?: HTMLElement): string;
applyThemeToElement(theme: string, target: HTMLElement): void;
followExternalTheme(opts: object, onChange: (theme: string) => void): () => void;
adoptFromParent(container: HTMLElement, onDetected: (theme: string) => void): () => void;
watch(source: Function | string, onChange: (theme: string) => void): () => void;
createInstanceTheme(editor: object): object;
[key: string]: any;
};