Skip to main content

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

OptionTypeDefaultDescription
selectorstringCSS selector matching the element(s) to replace with an editor instance.
targetHTMLElementDirect DOM element reference to convert into an editor. Use instead of selector when you already have a reference.
inlinebooleanfalseEnable inline editing mode. The editor appears inside the target element itself rather than in an iframe.
base_urlstringBase URL for loading Editor42 resource files (skins, themes, plugins).
suffixstringSuffix appended to script filenames, e.g. '.min' for minified builds.
cache_suffixstringQuery string appended to resource URLs for cache busting, e.g. '?v=1.0'.
setupfunctionCallback 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_callbackfunctionCallback invoked after the editor has fully initialized. Receives the editor instance.
pluginsstring[][]List of plugins to load. Each entry is a plugin alias name — see the available plugins.
external_pluginsobjectMap of plugin names to their script URLs, for loading plugins hosted outside the Editor42 package.
modelstring'dom'Content model the editor uses internally.
referrer_policystring''Referrer policy applied to resource requests made by the editor.
languagestring'en'Language code for the editor UI.
language_urlstring''URL to a custom language pack file.
language_loadbooleantrueWhether the editor should load its language pack automatically.
readonlybooleanfalseStart the editor in read-only mode. Content is displayed but not editable.
editable_rootbooleantrueWhether the root element of the editor body is editable. Set to false to make only specific child elements editable.
auto_focusstring/trueAutomatically focus an editor on page load. Pass true to focus the last initialized editor, or an editor id string to focus a specific one.
idstringExplicit id for the editor instance. If omitted, the id of the target element is used.
api_keystringAPI key field. Not used in Editor42.
deprecation_warningsbooleantrueLog 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);
}
});