Other Options
These options cover iframe settings, undo history, form integration, spellcheck, content editability controls, and various other editor behaviors.
Iframe
| Option | Type | Default | Description |
|---|---|---|---|
iframe_attrs | object | {} | Additional HTML attributes applied to the editor iframe element. |
doctype | string | '<!DOCTYPE html>' | Doctype declaration used inside the editor iframe document. |
content_security_policy | string | '' | Content Security Policy applied to the editor iframe via a <meta> tag. |
iframe_aria_text | string | 'Rich Text Area. Press ALT-0 for help.' | ARIA label text for the editor iframe, read by screen readers. |
UI
| Option | Type | Default | Description |
|---|---|---|---|
custom_ui_selector | string | '' | CSS selector matching elements that are part of the editor UI. Prevents the editor from treating clicks on these elements as a blur event. |
draggable_modal | boolean | false | Allow dialog windows to be dragged by their title bar. |
sidebar_show | string | — | Name of a sidebar panel to open automatically when the editor initializes. |
help_accessibility | boolean | true | Show a keyboard shortcut hint for opening the help dialog. |
Undo and history
| Option | Type | Default | Description |
|---|---|---|---|
custom_undo_redo_levels | number | 0 (unlimited) | Maximum number of undo levels to keep. Set to 0 for unlimited history. |
Events
| Option | Type | Default | Description |
|---|---|---|---|
disable_nodechange | boolean | false | Disable the NodeChange event that fires when the cursor moves to a different node. Can improve performance in very large documents. |
Form integration
| Option | Type | Default | Description |
|---|---|---|---|
hidden_input | boolean | true | Create a hidden input element that mirrors the editor content, enabling standard form submission. |
submit_patch | boolean | true | Patch the parent form's submit method to save editor content to the hidden input before submission. |
add_form_submit_trigger | boolean | true | Automatically save editor content when the parent form is submitted. |
add_unload_trigger | boolean | true | Save editor content to the hidden input before the page unloads. |
Spellcheck and input
| Option | Type | Default | Description |
|---|---|---|---|
browser_spellcheck | boolean | false | Enable the browser's built-in spellcheck on the editor content. |
Object and image resizing
| Option | Type | Default | Description |
|---|---|---|---|
object_resizing | boolean/string | true | Enable resize handles on images and other objects. Pass a CSS selector string to restrict which elements are resizable. |
resize_img_proportional | boolean | true | Maintain aspect ratio when resizing images with drag handles. |
Inline boundaries
| Option | Type | Default | Description |
|---|---|---|---|
inline_boundaries | boolean | true | Show visual caret indicators at the edges of inline elements like links, allowing the user to type before or after them. |
inline_boundaries_selector | string | 'a[href],code,span.editor42-m-annotation' | CSS selector for inline elements that display boundary indicators. |
Directionality
| Option | Type | Default | Description |
|---|---|---|---|
directionality | string | — | Text direction for the editor content. Typically 'ltr' or 'rtl'. Auto-detected from the editor's language setting when omitted. |
Non-editable content
| Option | Type | Default | Description |
|---|---|---|---|
noneditable_class | string | 'editor42NonEditable' | CSS class that marks an element as non-editable within the editor. |
editable_class | string | 'editor42Editable' | CSS class that marks an element as editable inside a non-editable parent. |
noneditable_regexp | RegExp/RegExp[] | [] | Regular expression patterns matching content that should be rendered as non-editable. |
Accordion defaults
| Option | Type | Default | Description |
|---|---|---|---|
details_initial_state | string | 'inherited' | Initial open/closed state of accordion (<details>) elements when inserted. |
details_serialized_state | string | 'inherited' | Open/closed state of accordion elements in the serialized (saved) output. |
Content initialization
| Option | Type | Default | Description |
|---|---|---|---|
init_content_sync | boolean | false | Initialize content synchronously instead of asynchronously. May block the main thread for large documents. |
Color output
| Option | Type | Default | Description |
|---|---|---|---|
force_hex_color | string | 'off' | Force color values to hex format. 'always' converts all colors, 'rgb_only' converts only RGB values, 'off' leaves colors as-is. |
Anchors
| Option | Type | Default | Description |
|---|---|---|---|
anchor_top | string/false | '#top' | Anchor value used for "top of page" links. Set to false to remove from the anchor list. |
anchor_bottom | string/false | '#bottom' | Anchor value used for "bottom of page" links. Set to false to remove from the anchor list. |
Example
editor42.init({
selector: 'textarea',
browser_spellcheck: true,
custom_undo_redo_levels: 50,
draggable_modal: true,
directionality: 'ltr',
object_resizing: 'img',
resize_img_proportional: true,
iframe_attrs: { loading: 'lazy' },
content_security_policy: "default-src 'self'"
});