URL Handling
These options control how the editor converts and processes URLs in content, including whether they are stored as relative or absolute paths.
Options
| Option | Type | Default | Description |
|---|---|---|---|
convert_urls | boolean | true | Convert URLs to relative or absolute form when content is set or inserted. Set to false to leave URLs exactly as entered. |
relative_urls | boolean | true | Convert URLs to relative paths based on document_base_url. When false, URLs are converted to absolute form instead. Only applies when convert_urls is true. |
remove_script_host | boolean | true | Remove the protocol and hostname from URLs when converting to relative form, producing paths like /images/logo.png instead of https://example.com/images/logo.png. |
document_base_url | string | — | Base URL used for relative URL resolution. Defaults to the directory of the current page. |
url_converter | function | — | Custom function that converts URLs. Receives the URL, the attribute name, and the element tag. Must return the converted URL string. |
url_converter_scope | object | — | Object used as this scope when calling the url_converter function. |
urlconverter_callback | function | — | Callback invoked during URL conversion. |
typeahead_urls | boolean | true | Enable URL autocompletion in link and image dialogs. |
Example
editor42.init({
selector: 'textarea',
convert_urls: true,
relative_urls: false,
remove_script_host: false,
document_base_url: 'https://example.com/content/',
url_converter: (url, name, tag) => {
// Custom URL conversion logic
return url;
}
});