Editor on Demand
Show content as a normal page, turn it into an editor when someone clicks Edit, and destroy the editor when they save.
- Pages with many editable blocks (comments, CMS sections, table cells) stay light: the editor is only created for the block being edited.
editor.destroy()removes the editor along with any dialog or dropdown it has open and stops its timers; a new editor can then be created in the same place, as often as you like.
Opening hours over the holidays
The office closes at 2 pm on 24 December and reopens on 2 January. Support by email continues every day except 25 December.
- Orders placed before 18 December arrive before Christmas.
- Returns are accepted until 31 January.
<div id="article">...the published content...</div>
<div id="editor_host"></div>
<button id="edit">Edit</button> <button id="save" hidden>Save</button>
<script>
var editor1 = null;
document.getElementById("edit").onclick = function () {
var article = document.getElementById("article");
var el = document.createElement("div");
document.getElementById("editor_host").appendChild(el);
editor1 = new RichTextEditor(el, { toolbar: "basic" });
editor1.setHTMLCode(article.innerHTML);
article.hidden = true;
// ...swap the buttons
};
document.getElementById("save").onclick = function () {
var html = editor1.getHTMLCode();
editor1.destroy(); // also closes its open dialogs and stops its timers
document.getElementById("editor_host").innerHTML = "";
editor1 = null;
var article = document.getElementById("article");
article.innerHTML = html; // sanitise on the server before you publish it
article.hidden = false;
};
</script>