Relative and Absolute URLs

Use this example to compare how RichTextEditor handles relative and absolute URLs when content is inserted, saved, or rendered. Both editors start from identical markup; only urlType differs.

urlType: "relative"

Insert or edit a link and an image, then read the saved HTML below.

A link to /docs/quick-start

Sample

Saved HTML

Loading…

urlType: "absolute"

Insert or edit a link and an image, then read the saved HTML below.

A link to /docs/quick-start

Sample

Saved HTML

Loading…

Example code

<div id="div_editor1"> ... </div>

<script>
    // "relative" keeps /docs/quick-start as written.
    // "absolute" rewrites it to https://your-host/docs/quick-start on save.
    var cfg = {};
    cfg.urlType = "relative";   // or "absolute"
    var editor1 = new RichTextEditor("#div_editor1", cfg);
</script>

Choose relative when content is served from the same origin that authored it, and absolute when the HTML will be emailed, syndicated, or rendered on another host.

Configuration reference