/** * Theme Manager for Markdown Viewer Extension * Handles loading, applying, and managing themes */ import type { Theme } from '../types/theme'; /** * Font configuration for a single font */ interface FontConfig { webFallback: string; docx?: { ascii: string; eastAsia: string; }; } /** * Font configuration file structure */ export interface FontConfigFile { fonts: Record; } /** * DOCX font configuration */ interface DocxFont { ascii: string; eastAsia: string; hAnsi: string; cs: string; } /** * Category info in registry */ interface CategoryInfo { name: string; name_en?: string; description?: string; } /** * Theme metadata */ interface ThemeMetadata { id: string; name: string; name_en?: string; description?: string; description_en?: string; category: string; featured: boolean; } /** * Category with themes */ interface CategoryWithThemes extends CategoryInfo { themes: ThemeMetadata[]; } /** * Theme Manager Class */ declare class ThemeManager { private currentTheme; private fontConfig; private registry; private initialized; constructor(); /** * Initialize theme manager with data from Flutter * Used on mobile platform where Flutter loads assets and sends to WebView * @param fontConfig - Font configuration object * @param theme - Theme object */ initializeWithData(fontConfig: FontConfigFile, theme?: Theme | null): void; /** * Initialize theme manager by loading font config and registry */ initialize(): Promise; /** * Get font config for a given font name * @param fontName - Font name (e.g., 'SimSun', 'Times New Roman') * @returns Font fallback chain (CSS font-family string) */ getFontFallback(fontName: string): string; /** * Build complete font family stack * @param fontName - Font name * @returns Complete CSS font-family string */ buildFontFamily(fontName: string): string; /** * Get DOCX font configuration for a given font name * @param fontName - Font name * @returns Complete DOCX font object with ascii, eastAsia, hAnsi, cs properties */ getDocxFont(fontName: string): DocxFont; /** * Load a theme configuration from a JSON file * @param themeId - Theme ID (e.g., 'default', 'academic') * @returns Theme configuration object */ loadTheme(themeId: string): Promise; /** * Load theme from storage * @returns Theme ID */ loadSelectedTheme(): Promise; /** * Save selected theme to storage * @param themeId - Theme ID to save */ saveSelectedTheme(themeId: string): Promise; /** * Get current theme configuration * @returns Current theme object */ getCurrentTheme(): Theme | null; /** * Convert point size to pixels (for CSS) * @param ptSize - Size in points (e.g., '12pt') * @returns Size in pixels (e.g., '16px') */ ptToPx(ptSize: string): string; /** * Convert point size to half-points (for DOCX) * @param ptSize - Size in points (e.g., '12pt') * @returns Size in half-points (e.g., 24) */ ptToHalfPt(ptSize: string): number; /** * Convert point size to twips (for DOCX spacing) * @param ptSize - Size in points (e.g., '13pt') * @returns Size in twips (e.g., 260) */ ptToTwips(ptSize: string): number; /** * Get all available themes from registry * @returns List of theme metadata */ getAvailableThemes(): Promise; /** * Get themes grouped by category * @returns Themes grouped by category */ getThemesByCategory(): Promise>; /** * Switch to a different theme * @param themeId - Theme ID to switch to * @returns The loaded theme */ switchTheme(themeId: string): Promise; } declare const themeManager: ThemeManager; export default themeManager;