Editor Configuration
A class for storing editor configurations.
Config
A class for working with the editor's configuration.
Config Methods
| Function | Signature | Description |
|---|---|---|
| get | get<K extends keyof ConfigOptions>(key: K, defaultValue?: ConfigOptions[K]): ConfigOptions[K] | unknown | Retrieves a configuration value by key. |
Config Interfaces
typescript
/**
* Interface for configuration options.
* @property handle - Unique identifier for the editor instance
* @property onReady - Callback function called when the editor is ready
* @property onChange - Callback function called when the content changes
* @property content - Initial data to populate the editor
* @property blocks - Array of block model constructors available in the editor
* @property maxBlocks - Maximum number of blocks allowed in the editor
* @property tools - Array of tool model constructors available in the editor
* @property defaultBlock - Default block type for insertion (e.g., "p", "h1")
* @property locale - Current locale for translations
* @property locales - Localizations
* @property defaultLocale - Default fallback locale
* @property actions - Array of action model constructors
* @property extensions - Array of extension model constructors
* @property extensionsFixed - Whether the extensions panel is fixed
* @property extensionsFixedStyle - Custom styles for the fixed extensions panel
* @property extensionVisibleTitle - Whether to show extension titles
* @property autofocus - Whether to autofocus on the editor during initialization
* @property autofocusDelay - Delay for autofocus
* @property selectionZoneElement - Zone for selecting virtual blocks
* @property historyShortcuts - Whether to use keyboard shortcuts for history
*/
export interface ConfigOptions {
handle?: string;
onReady?: (evt: TexditorEvent) => void;
onChange?: (evt: TexditorEvent) => void;
content?: object[] | string;
blocks?: BlockModelConstructor[];
maxBlocks?: number;
tools?: ToolModelConstructor[];
defaultBlock?: string;
locale?: string;
locales?: LocaleMap[];
defaultLocale?: string;
actions?: ActionModelConstructor[];
extensions?: ExtensionModelConstructor[];
extensionsFixed?: boolean;
extensionsFixedStyle?: false | Record<string, string>;
extensionVisibleTitle?: boolean;
autofocus?: boolean;
autofocusDelay?: number;
selectionZoneElement?: HTMLElement;
historyShortcuts?: boolean;
}
/**
* Interface for the configuration manager.
*/
export interface Config {
get: ConfigGetFunction;
}Example of Using Config
javascript
import Texditor from "texditor";
const editor = new Texditor({
handle: "my-editor"
});
const maxBlocks = editor.config.get('maxBlocks');