Skip to main content

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​

OptionTypeDefaultDescription
convert_urlsbooleantrueConvert URLs to relative or absolute form when content is set or inserted. Set to false to leave URLs exactly as entered.
relative_urlsbooleantrueConvert 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_hostbooleantrueRemove 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_urlstring—Base URL used for relative URL resolution. Defaults to the directory of the current page.
url_converterfunction—Custom function that converts URLs. Receives the URL, the attribute name, and the element tag. Must return the converted URL string.
url_converter_scopeobject—Object used as this scope when calling the url_converter function.
urlconverter_callbackfunction—Callback invoked during URL conversion.
typeahead_urlsbooleantrueEnable 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;
}
});