Integration and Setup
These options control how Editor42 initializes, which element it targets, which plugins it loads, and how it communicates back to your application.
Options
| Option | Type | Default | Description |
|---|---|---|---|
selector | string | — | CSS selector matching the element(s) to replace with an editor instance. |
target | HTMLElement | — | Direct DOM element reference to convert into an editor. Use instead of selector when you already have a reference. |
inline | boolean | false | Enable inline editing mode. The editor appears inside the target element itself rather than in an iframe. |
base_url | string | — | Base URL for loading Editor42 resource files (skins, themes, plugins). |
suffix | string | — | Suffix appended to script filenames, e.g. '.min' for minified builds. |
cache_suffix | string | — | Query string appended to resource URLs for cache busting, e.g. '?v=1.0'. |
setup | function | — | Callback invoked before the editor is fully initialized. Receives the editor instance as its argument. Use this to bind events or configure the editor early. |
init_instance_callback | function | — | Callback invoked after the editor has fully initialized. Receives the editor instance. |
plugins | string[] | [] | List of plugins to load. Each entry is a plugin alias name — see the available plugins. |
external_plugins | object | — | Map of plugin names to their script URLs, for loading plugins hosted outside the Editor42 package. |
model | string | 'dom' | Content model the editor uses internally. |
referrer_policy | string | '' | Referrer policy applied to resource requests made by the editor. |
language | string | 'en' | Language code for the editor UI. |
language_url | string | '' | URL to a custom language pack file. |
language_load | boolean | true | Whether the editor should load its language pack automatically. |
readonly | boolean | false | Start the editor in read-only mode. Content is displayed but not editable. |
editable_root | boolean | true | Whether the root element of the editor body is editable. Set to false to make only specific child elements editable. |
auto_focus | string/true | — | Automatically focus an editor on page load. Pass true to focus the last initialized editor, or an editor id string to focus a specific one. |
id | string | — | Explicit id for the editor instance. If omitted, the id of the target element is used. |
api_key | string | — | API key field. Not used in Editor42. |
deprecation_warnings | boolean | true | Log deprecation warnings to the browser console when deprecated options are used. |
Example
editor42.init({
selector: 'textarea#content',
plugins: ['lists', 'link', 'image', 'code'],
language: 'de',
setup: (editor) => {
editor.on('init', () => {
console.log('Editor ready');
});
},
init_instance_callback: (editor) => {
console.log('Fully initialized:', editor.id);
}
});