All demos ↓← All 93 demos

Full Page Editing

Edit the document body and assemble a complete HTML page on export.

How it works

RichTextEditor edits the body of a document. Head-level markup — <style>, <link>, <meta>, <title>, <base>— is removed on the way in, deliberately: a stylesheet or <base> smuggled through an editor restyles or re-targets the whole page hosting it. Feed it a complete document below and watch which half survives.

What the editor saved

Loading…

The document you actually publish

Build it where you control it — on the server, around the body the editor gives you. That keeps the title, canonical URL, and stylesheet under your application’s control rather than an author’s.

// The editor owns the body. Compose the document around it:
var body = editor.getHTMLCode();

var page =
    "<!DOCTYPE html><html><head>" +
    "<meta charset=\"utf-8\">" +
    "<title>" + escapeHtml(title) + "</title>" +
    "<link rel=\"stylesheet\" href=\"/site.css\">" +
    "</head><body>" + body + "</body></html>";

For a full-viewport editing surface (a different meaning of “full page”), use the fullscreen toolbar button or execCommand("fullscreenenter").

Getting HTML content from the editor

Use this in your app

This demo runs the same editor you get for every framework. See how to add it to yours: