/** * MetonaEditor Plugins — plugin system v2 * @module plugins * @version 0.2.0 */ interface Plugin { name: string; version?: string; description?: string; depends?: string[]; priority?: number; install?: (editor: any) => void | Promise; destroy?: (editor: any) => void; [key: string]: any; } interface PluginSchema { [key: string]: { type?: string; required?: boolean; default?: any; enum?: any[]; validator?: (val: any) => boolean | string; }; } declare class PluginManager { plugins: Map; register(name: string, plugin: Plugin): this; unregister(name: string): this; get(name: string): Plugin | null; has(name: string): boolean; getAll(): Plugin[]; getNames(): string[]; enable(name: string): this; disable(name: string): this; isEnabled(name: string): boolean; destroy(): void; } declare const topologicalSort: (plugins: Plugin[]) => Plugin[]; declare const validateConfig: (schema?: PluginSchema, config?: Record) => { valid: boolean; errors: string[]; patched: Record; }; declare const presetPlugins: Record; declare const pluginUtils: { createManager: () => PluginManager; manager: PluginManager; register: (name: string, plugin: Plugin) => PluginManager; unregister: (name: string) => PluginManager; get: (name: string) => Plugin | null; has: (name: string) => boolean; getAll: () => Plugin[]; getNames: () => string[]; enable: (name: string) => PluginManager; disable: (name: string) => PluginManager; isEnabled: (name: string) => boolean; getPreset: (name: string) => Plugin | null; getAllPresets: () => Record; createPlugin: (config?: Partial) => Plugin; validatePlugin: (plugin: any) => { valid: boolean; errors: string[]; }; topologicalSort: (plugins: Plugin[]) => Plugin[]; validateConfig: (schema?: PluginSchema, config?: Record) => { valid: boolean; errors: string[]; patched: Record; }; }; declare const loadRemote: (url: string, locale: string) => Promise; interface InstanceI18n { set: (locale: string) => string; get: () => string; getDirection: () => 'ltr' | 'rtl'; t: (key: string, params?: Record) => string; formatNumber: (n: number, opts?: Intl.NumberFormatOptions) => string; formatDate: (d: Date | string, opts?: Intl.DateTimeFormatOptions) => string; } declare const createInstanceI18n: (editor: any) => InstanceI18n; declare const i18nUtils: { t: (key: string, params?: Record, locale?: string) => string; getCurrentLocale: () => string; setCurrentLocale: (locale: string) => void; switchLocale: (locale: string) => void; getFallbackLocale: () => string; setFallbackLocale: (locale: string) => void; hasTranslation: (key: string) => boolean; getTranslations: (locale: string) => Record; addTranslations: (locale: string, translations: Record) => void; loadRemote: (url: string, locale: string) => Promise; getSupportedLocales: () => string[]; isLocaleSupported: (locale: string) => boolean; getLocaleName: (locale: string) => string; getLocaleDirection: (locale: string) => "ltr" | "rtl"; formatNumber: (number: number, options?: Intl.NumberFormatOptions) => string; formatCurrency: (amount: number, currency?: string, options?: Intl.NumberFormatOptions) => string; formatDate: (date: Date | string, options?: Intl.DateTimeFormatOptions) => string; addLocaleListener: (fn: (locale: string) => void) => () => void; removeLocaleListener: (fn: (locale: string) => void) => void; clearLocaleListeners: () => void; initI18n: () => void; saveLocale: (locale: string) => void; loadLocale: () => string; getDefaultLocale: () => string; createInstanceI18n: (editor: any) => InstanceI18n; }; /** * MetonaEditor Icons — SVG toolbar icons * @module icons * @version 0.2.0 */ declare const ICONS: Record; /** * MetonaEditor Constants — default configs, themes, animations * @module constants * @version 0.2.0 */ type EditMode = 'edit' | 'split' | 'preview'; type ThemeName = 'light' | 'dark' | 'auto' | 'warm' | string; type ToolbarItem = string | '|'; interface RenderEnv { highlight?: (code: string, lang: string) => string; locale?: string; refs?: Record; } interface EditorStyle { color?: string; backgroundColor?: string; [key: string]: string | undefined; } interface EditorOptions { value?: string; placeholder?: string; mode?: EditMode; height?: number | string; toolbar?: ToolbarItem[] | false; wordCount?: boolean; autofocus?: boolean; spellcheck?: boolean; historyLimit?: number; historyDebounce?: number; syncScroll?: boolean; tabSize?: number; readOnly?: boolean; lineNumbers?: boolean; outline?: boolean; autoBrackets?: boolean; zenMode?: boolean; wordWrap?: boolean; maxLength?: number; theme?: ThemeName; locale?: string; render?: ((markdown: string, env: RenderEnv) => string) | null; highlight?: ((code: string, lang: string) => string) | null; sanitize?: ((html: string) => string) | null; className?: string; style?: EditorStyle; plugins?: any[]; id?: string; onChange?: ((value: string, editor: any) => void) | null; onInput?: ((value: string, editor: any) => void) | null; onFocus?: ((editor: any) => void) | null; onBlur?: ((editor: any) => void) | null; onSave?: ((value: string, editor: any) => void) | null; onModeChange?: ((mode: string, editor: any) => void) | null; onFullscreen?: ((fullscreen: boolean, editor: any) => void) | null; onCreate?: ((editor: any) => void) | null; onDestroy?: ((editor: any) => void) | null; onLinkClick?: ((href: string, text: string, editor: any) => void) | null; floatingToolbar?: boolean; } interface ThemeConfig { bg: string; text: string; border: string; shadow: string; hoverShadow?: string; toolbarBg?: string; textareaBg?: string; previewBg?: string; codeBg?: string; codeText?: string; accent?: string; muted?: string; progressBg?: string; closeHoverBg?: string; } interface AnimationConfig { name?: string; enter: Record; leave: Record; duration: number; easing: string; } /** Default toolbar button sequence */ declare const DEFAULT_TOOLBAR: ToolbarItem[]; /** Default options */ declare const DEFAULTS: Readonly; declare const THEMES: Record; declare const EDIT_MODES: EditMode[]; declare const TOOLBAR_ACTIONS: string[]; /** * MetonaEditor Parser — lightweight Markdown parser (TypeScript) * @module parser * @version 0.2.0 */ interface Token { type: string; [key: string]: any; } interface ParseResult { tokens: Token[]; footnotes: Record; refs: Record; } interface BlockHandler { name: string; priority: number; test: (line: string, lines: string[], i: number) => any; parse: (lines: string[], i: number, match: any, tokens: Token[], footnotes: Record, refs?: Record) => { token: Token | null; newIndex: number; }; } declare const clearRenderCache: () => void; declare const safeUrl: (url: string | null | undefined) => string; declare const slugify: (text: string) => string; declare const registerBlockHandler: (handler: BlockHandler) => void; declare const parseTokens: (md: string | null | undefined) => ParseResult; declare const renderTokens: (tokens: Token[], env?: RenderEnv, footnotes?: Record) => string; declare const parseMarkdown: (md: string | null | undefined, env?: RenderEnv) => string; /** * MetonaEditor Core — MarkdownEditor class (TypeScript) * @module core * @version 0.2.0 */ declare class MarkdownEditor { static _hooks: Map void)[]>; static on(name: string, fn: (editor: MarkdownEditor) => void): () => void; static off(name: string, fn: (editor: MarkdownEditor) => void): void; static trigger(name: string, instance: MarkdownEditor): void; id: string; container: HTMLElement; config: EditorOptions; el: HTMLElement; toolbarEl: HTMLElement; bodyEl: HTMLElement; editorPane: HTMLElement; editorInner: HTMLElement; previewPane: HTMLElement; dividerEl: HTMLElement; textarea: HTMLTextAreaElement; previewEl: HTMLElement; gutter: HTMLElement; statusEl: HTMLElement | null; _value: string; _mode: EditMode; _history: string[]; _historyIndex: number; _cleanups: Array<() => void>; _plugins: any[]; _listeners: Record void>>; _renderRaf: number | null; _historyTimer: ReturnType | null; _fullscreen: boolean; _destroyed: boolean; _lastRenderedValue: string | null; _shortcuts: any[]; _contextMenuItems: any[]; _customActions: Record void>; _outlineTimer: ReturnType | null; _zenMode: boolean; _wordWrap: boolean; _syncing: boolean; _zenMouseHandler: ((e: MouseEvent) => void) | null; _ariaLive: HTMLElement; _renderFn: (md: string, env: RenderEnv) => string; _highlightFn: ((code: string, lang: string) => string) | null; _themeCtx: any; _i18nCtx: InstanceI18n; _floatingToolbar: HTMLElement | null; _selectionTimer: ReturnType | null; _floatingEnabled: boolean; constructor(container: string | HTMLElement, options?: EditorOptions); _buildDOM(): void; _buildToolbar(): void; _createBtn(item: string): HTMLButtonElement; _bindEvents(): void; _handleKeydown(e: KeyboardEvent): void; _handleTab(shift: boolean): void; _bindDividerDrag(e: PointerEvent): void; _saveDividerPosition(): void; _restoreDividerPosition(): void; _scheduleRender(): void; _render(): void; _renderGutter(): void; _updateCurrentLine(): void; _handleSmartEnter(e: KeyboardEvent): void; _handleBracketAutoClose(e: KeyboardEvent): void; _bindDragDrop(): void; _buildOutline(): void; _updateOutline(): void; _trackOutlineScroll(): void; _scheduleHistory(): void; _pushHistory(): void; undo(): this; redo(): this; canUndo(): boolean; canRedo(): boolean; _applyHistory(): void; exec(action: string, ...args: any[]): this; _wrapSelection(before: string, after: string): void; _toggleLinePrefix(prefix: string): void; _insertBlock(text: string): void; _insertLink(): void; _insertImage(): void; _insertTable(rows?: number, cols?: number): void; _formatTable(): void; setMode(mode: EditMode): this; getMode(): EditMode; _updateModeButtons(): void; toggleFullscreen(): this; isFullscreen(): boolean; exitFullscreen(): this; toggleZen(): this; isZen(): boolean; toggleWordWrap(): this; setWordWrap(on: boolean): this; isWordWrap(): boolean; _initFloatingToolbar(): void; toggleFloatingToolbar(): this; isFloatingToolbar(): boolean; _buildFloatingToolbar(): void; _hideFloatingToolbar(): void; _bindToolbarKeyboard(): void; _initAriaLive(): void; _announce(msg: string): void; _syncScroll(): void; _updateWordCount(): void; getStats(): { characters: number; words: number; chineseChars: number; englishWords: number; lines: number; readingTime: number; }; getSelectedText(): string; getCursorPosition(): { line: number; column: number; }; setCursorPosition(line: number, column?: number): this; scrollToLine(line: number): this; selectLine(line: number): this; selectAll(): this; replaceAll(search: string, replace: string, caseSensitive?: boolean): number; replaceAllRegex(pattern: RegExp, replace: string): number; lineCount(): number; getLine(line: number): string; getValue(): string; setValue(md: string, opts?: { silent?: boolean; }): this; getHTML(): string; refresh(): this; copyAsMarkdown(): this; copyAsHTML(): this; insert(text: string, opts?: { replace?: boolean; }): this; wrap(before: string, after: string): this; focus(): this; blur(): this; enable(): this; disable(): this; isDisabled(): boolean; setReadOnly(readOnly: boolean): this; isReadOnly(): boolean; on(name: string, fn: (...args: any[]) => void): () => void; off(name: string, fn: (...args: any[]) => void): this; _emit(name: string, ...args: any[]): void; use(plugin: string | any, options?: any): this; unuse(name: string): this; getPlugins(): any[]; addToolbarButton(config: any): this; registerShortcut(combo: string, handler: Function | string, description?: string): this; unregisterShortcut(combo: string): this; getShortcuts(): any[]; configureToolbar(tools: ToolbarItem[]): this; removeToolbarButton(action: string): this; registerContextMenu(items?: any[]): this; _bindContextMenu(): void; _showContextMenu(e: MouseEvent): void; _hideContextMenu(): void; _execContextAction(action: string): void; toast(message: string, opts?: { type?: string; duration?: number; animation?: string; }): this; setLocale(locale: string): this; getLocale(): string; t(key: string, params?: Record): string; setTheme(theme: ThemeName): this; getTheme(): string; getThemeContext(): any; getStatus(): { id: string; mode: EditMode; theme: string; locale: string; fullscreen: boolean; readOnly: boolean; disabled: boolean; destroyed: boolean; plugins: any[]; }; destroy(): void; isDestroyed(): boolean; } /** * MetonaEditor Themes — theme system * @module themes * @version 0.2.0 */ declare const exportCSSVars: (el?: HTMLElement) => Record; declare const getCSSVariable: (name: string, el?: HTMLElement) => string; declare const followExternalTheme: (options: { element?: HTMLElement; attr?: string; classMap?: Record; callback?: (el: HTMLElement) => string | null; }, onThemeChange: (theme: string) => void) => () => void; declare const adoptFromParent: (container: HTMLElement, onThemeDetected: (theme: string) => void) => () => void; declare const createInstanceTheme: (editor: any) => any; declare const themeUtils: { getSystemTheme: () => "light" | "dark"; resolveTheme: (theme: string) => string; getThemeConfig: (theme: string) => ThemeConfig; watchSystemTheme: () => void; unwatchSystemTheme: () => void; applyTheme: (theme: string) => void; getCurrentTheme: () => string; getResolvedTheme: () => string; switchTheme: (theme: string) => void; toggleTheme: () => void; resetToAuto: () => void; initTheme: () => void; saveTheme: (theme: string) => void; loadTheme: () => string; addThemeListener: (fn: (theme: string, resolved: string) => void) => () => void; removeThemeListener: (fn: (theme: string, resolved: string) => void) => void; clearThemeListeners: () => void; registerTheme: (name: string, config?: Partial & { extends?: string; }) => void; unregisterTheme: (name: string) => void; getAllThemes: () => Record; getThemeNames: () => string[]; hasTheme: (name: string) => boolean; setThemeVariables: (config: ThemeConfig, target?: HTMLElement) => void; exportCSSVars: (el?: HTMLElement) => Record; getCSSVariable: (name: string, el?: HTMLElement) => string; applyThemeToElement: (theme: string, target: HTMLElement) => void; followExternalTheme: (options: { element?: HTMLElement; attr?: string; classMap?: Record; callback?: (el: HTMLElement) => string | null; }, onThemeChange: (theme: string) => void) => () => void; adoptFromParent: (container: HTMLElement, onThemeDetected: (theme: string) => void) => () => void; watch: (source: Function | string, onChange: (theme: string) => void) => () => void; createInstanceTheme: (editor: any) => any; }; /** * MetonaEditor Animations — animation metadata * @module animations * @version 0.2.0 */ declare const animationUtils: { register(name: string, config: Partial & { enter?: Record; leave?: Record; }): void; unregister(name: string): void; get(name: string): AnimationConfig | null; getAnimationNames(): string[]; getActiveCount(): number; cancelAll(): void; reset(): void; destroy(): void; }; declare const VERSION = "0.2.3"; declare function create(container: string | HTMLElement, options?: EditorOptions): MarkdownEditor; declare function use(plugin: string | any, options?: any): typeof api; declare function on(name: string, fn: (editor: MarkdownEditor) => void): () => void; declare function off(name: string, fn: (editor: MarkdownEditor) => void): typeof api; declare function setTheme(theme: ThemeName, _options?: any): typeof api; declare function setLocale(locale: string): typeof api; declare function destroy(): void; declare function getStatus(): { version: string; theme: string; locale: string; globalPlugins: any[]; presetPlugins: string[]; }; declare const api: { VERSION: string; version: string; MarkdownEditor: typeof MarkdownEditor; Editor: typeof MarkdownEditor; create: typeof create; use: typeof use; on: typeof on; off: typeof off; setTheme: typeof setTheme; setLocale: typeof setLocale; destroy: typeof destroy; getStatus: typeof getStatus; parseMarkdown: (md: string | null | undefined, env?: RenderEnv) => string; parseTokens: (md: string | null | undefined) => ParseResult; renderTokens: (tokens: Token[], env?: RenderEnv, footnotes?: Record) => string; safeUrl: (url: string | null | undefined) => string; slugify: (text: string) => string; clearRenderCache: () => void; registerBlockHandler: (handler: BlockHandler) => void; themes: { getSystemTheme: () => "light" | "dark"; resolveTheme: (theme: string) => string; getThemeConfig: (theme: string) => ThemeConfig; watchSystemTheme: () => void; unwatchSystemTheme: () => void; applyTheme: (theme: string) => void; getCurrentTheme: () => string; getResolvedTheme: () => string; switchTheme: (theme: string) => void; toggleTheme: () => void; resetToAuto: () => void; initTheme: () => void; saveTheme: (theme: string) => void; loadTheme: () => string; addThemeListener: (fn: (theme: string, resolved: string) => void) => () => void; removeThemeListener: (fn: (theme: string, resolved: string) => void) => void; clearThemeListeners: () => void; registerTheme: (name: string, config?: Partial & { extends?: string; }) => void; unregisterTheme: (name: string) => void; getAllThemes: () => Record; getThemeNames: () => string[]; hasTheme: (name: string) => boolean; setThemeVariables: (config: ThemeConfig, target?: HTMLElement) => void; exportCSSVars: (el?: HTMLElement) => Record; getCSSVariable: (name: string, el?: HTMLElement) => string; applyThemeToElement: (theme: string, target: HTMLElement) => void; followExternalTheme: (options: { element?: HTMLElement; attr?: string; classMap?: Record; callback?: (el: HTMLElement) => string | null; }, onThemeChange: (theme: string) => void) => () => void; adoptFromParent: (container: HTMLElement, onThemeDetected: (theme: string) => void) => () => void; watch: (source: Function | string, onChange: (theme: string) => void) => () => void; createInstanceTheme: (editor: any) => any; }; i18n: { t: (key: string, params?: Record, locale?: string) => string; getCurrentLocale: () => string; setCurrentLocale: (locale: string) => void; switchLocale: (locale: string) => void; getFallbackLocale: () => string; setFallbackLocale: (locale: string) => void; hasTranslation: (key: string) => boolean; getTranslations: (locale: string) => Record; addTranslations: (locale: string, translations: Record) => void; loadRemote: (url: string, locale: string) => Promise; getSupportedLocales: () => string[]; isLocaleSupported: (locale: string) => boolean; getLocaleName: (locale: string) => string; getLocaleDirection: (locale: string) => "ltr" | "rtl"; formatNumber: (number: number, options?: Intl.NumberFormatOptions) => string; formatCurrency: (amount: number, currency?: string, options?: Intl.NumberFormatOptions) => string; formatDate: (date: Date | string, options?: Intl.DateTimeFormatOptions) => string; addLocaleListener: (fn: (locale: string) => void) => () => void; removeLocaleListener: (fn: (locale: string) => void) => void; clearLocaleListeners: () => void; initI18n: () => void; saveLocale: (locale: string) => void; loadLocale: () => string; getDefaultLocale: () => string; createInstanceI18n: (editor: any) => InstanceI18n; }; animations: { register(name: string, config: Partial & { enter?: Record; leave?: Record; }): void; unregister(name: string): void; get(name: string): AnimationConfig | null; getAnimationNames(): string[]; getActiveCount(): number; cancelAll(): void; reset(): void; destroy(): void; }; plugins: { createManager: () => PluginManager; manager: PluginManager; register: (name: string, plugin: Plugin) => PluginManager; unregister: (name: string) => PluginManager; get: (name: string) => Plugin | null; has: (name: string) => boolean; getAll: () => Plugin[]; getNames: () => string[]; enable: (name: string) => PluginManager; disable: (name: string) => PluginManager; isEnabled: (name: string) => boolean; getPreset: (name: string) => Plugin | null; getAllPresets: () => Record; createPlugin: (config?: Partial) => Plugin; validatePlugin: (plugin: any) => { valid: boolean; errors: string[]; }; topologicalSort: (plugins: Plugin[]) => Plugin[]; validateConfig: (schema?: PluginSchema, config?: Record) => { valid: boolean; errors: string[]; patched: Record; }; }; presetPlugins: Record; topologicalSort: (plugins: Plugin[]) => Plugin[]; validateConfig: (schema?: PluginSchema, config?: Record) => { valid: boolean; errors: string[]; patched: Record; }; createInstanceI18n: (editor: any) => InstanceI18n; loadRemote: (url: string, locale: string) => Promise; exportCSSVars: (el?: HTMLElement) => Record; getCSSVariable: (name: string, el?: HTMLElement) => string; followExternalTheme: (options: { element?: HTMLElement; attr?: string; classMap?: Record; callback?: (el: HTMLElement) => string | null; }, onThemeChange: (theme: string) => void) => () => void; adoptFromParent: (container: HTMLElement, onThemeDetected: (theme: string) => void) => () => void; createInstanceTheme: (editor: any) => any; DEFAULTS: Readonly; ICONS: Record; THEMES: Record; EDIT_MODES: EditMode[]; DEFAULT_TOOLBAR: string[]; TOOLBAR_ACTIONS: string[]; }; export { DEFAULTS, DEFAULT_TOOLBAR, EDIT_MODES, MarkdownEditor as Editor, ICONS, MarkdownEditor, api as MeEditor, THEMES, TOOLBAR_ACTIONS, VERSION, adoptFromParent, animationUtils, api, clearRenderCache, create, createInstanceI18n, createInstanceTheme, api as default, destroy, exportCSSVars, followExternalTheme, getCSSVariable, getStatus, i18nUtils, loadRemote, api as meEditor, off, on, parseMarkdown, parseTokens, pluginUtils, presetPlugins, registerBlockHandler, renderTokens, safeUrl, setLocale, setTheme, slugify, themeUtils, topologicalSort, use, validateConfig };