import { HotkeyId } from "../types/hotkey.js"; import { IBeforeEditorInitLifecycle, IDecorator, IDocumentOptions, IEditor, IEditorKernel, IEditorPluginConstructor, INodeRegistrationTransform, IPlugin, ISelectionObject, IServiceID } from "../types/kernel.js"; import { ILocaleKeys } from "../types/locale.js"; import { HotkeyOptions, HotkeysEvent } from "../utils/hotkey/registerHotkey.js"; import DataSource, { IWriteOptions } from "./data-source.js"; import { HistoryState } from "@lexical/history"; import EventEmitter from "eventemitter3"; import { CommandListener, CommandListenerPriority, CommandPayloadType, LexicalCommand, LexicalEditor, LexicalNodeConfig } from "lexical"; declare class Kernel extends EventEmitter implements IEditorKernel { private static globalHotReloadMode; private dataTypeMap; private plugins; private pluginsConfig; private pluginsInstances; private beforeEditorInitHooks; private nodeTransforms; private rootClassNames; private nodes; private themes; private decorators; private serviceMap; private localeMap; private hotReloadMode; private logger; private historyState; /** * Root-scoped resources are attached to the Lexical editor's root listener * so direct Lexical setRootElement(null) calls are safe as well. */ private unregisterRootLifecycle?; private editor?; private headlessEditor; constructor(); cloneNodeEditor(): IEditorKernel; getHistoryState(): HistoryState; isEditable(): boolean; private detectDevelopmentMode; /** * Globally enable or disable hot reload mode for all kernel instances * @param enabled Whether to enable hot reload mode globally */ static setGlobalHotReloadMode(enabled: boolean): void; /** * Reset global hot reload mode to automatic detection */ static resetGlobalHotReloadMode(): void; getLexicalEditor(): LexicalEditor | null; destroy(): void; getRootElement(): HTMLElement | null; setRootElement(dom: HTMLElement, editable?: boolean): LexicalEditor; setRootElement(dom: null, editable?: boolean): LexicalEditor | null; setEditable(editable: boolean): void; initNodeEditor(): LexicalEditor; initHeadlessEditor(): LexicalEditor; setDocument(type: string, content: any, options?: IDocumentOptions): void; setSelection(selection: ISelectionObject, opt?: { collapseToEnd?: boolean; collapseToStart?: boolean; }): Promise; getSelection(): ISelectionObject | null; focus(): void; blur(): void; getDocument(type: string, options?: IWriteOptions): DataSource | undefined; getSelectionDocument(type: string): unknown | null; registerDecorator(name: string, decorator: IDecorator): this; getDecorator(name: string): IDecorator | undefined; /** * Unregister a decorator * @param name Decorator name */ unregisterDecorator(name: string): boolean; /** * Get all registered decorator names */ getRegisteredDecorators(): string[]; /** * Support registering target data source * @param dataSource Data source */ registerDataSource(dataSource: DataSource): void; registerThemes(themes: Record): void; registerPlugin(plugin: IEditorPluginConstructor, config?: T): IEditor; registerPlugins(plugins: Array): IEditor; registerNodes(nodes: Array): void; registerNodeTransform(transform: INodeRegistrationTransform): () => void; registerBeforeEditorInit(hook: IBeforeEditorInitLifecycle): () => void; registerRootClassName(className: string): () => void; registerRootListener(listener: (rootElement: HTMLElement | null) => void): () => void; private getEditorId; private registerRootLifecycle; private runBeforeEditorInitLifecycle; private applyRootClassNames; private resolveNodesForInitialization; registerService(serviceId: IServiceID, service: T): void; /** * Register service with hot reload support - allows overriding existing services * @param serviceId Service identifier * @param service Service instance */ registerServiceHotReload(serviceId: IServiceID, service: T): void; /** * Enable or disable hot reload mode * @param enabled Whether to enable hot reload mode */ setHotReloadMode(enabled: boolean): void; /** * Check if hot reload mode is enabled */ isHotReloadMode(): boolean; /** * Get service * @param serviceId Service ID */ requireService(serviceId: IServiceID): T | null; dispatchCommand>(type: TCommand, payload: CommandPayloadType): boolean; getTheme(): Record; updateTheme(key: string, value: string | Record): void; registerLocale(locale: Partial>): void; t(key: K, params?: Record): string; get isEmpty(): boolean; get isSelected(): boolean; cleanDocument(): void; private _commands; private _commandsClean; registerHotkey(hotkeyId: HotkeyId, callback: (event: KeyboardEvent, handler: HotkeysEvent) => void, options?: HotkeyOptions): () => void; registerHighCommand

(command: LexicalCommand

, listener: CommandListener

, priority: CommandListenerPriority): () => void; } export { Kernel };