X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/86c2b19f372b3d7d4556d60586215ccf3d72a6c7..1801380d62ab693e819f17706a9530679a1add1e:/edit/page.js diff --git a/edit/page.js b/edit/page.js index ecf5204..35497c1 100644 --- a/edit/page.js +++ b/edit/page.js @@ -1,3 +1,9 @@ +var pagebody; + +function editorcontents() { + return document.getElementsByClassName('static')[0]; +} + function editorsetup() { CKEDITOR.disableAutoInline = true; @@ -157,7 +163,6 @@ CKEDITOR.on('instanceCreated', function (event) { }; }); -var pagebody = document.getElementsByClassName('static')[0]; if (pagebody) { // add edit link to menu var editlink = document.querySelector('a[href="#edit"]'); @@ -166,6 +171,7 @@ if (pagebody) { editlink.style.fontWeight = 'bold'; editlink.href = ''; editlink.onclick = undefined; + document.body.replaceChild(pagebody, editorcontents()); pagebody.setAttribute('contenteditable', true); pagebody.querySelectorAll('[data-dyn]').forEach(function (el) { let blockname = el.getAttribute('data-dyn'); @@ -187,6 +193,7 @@ if (pagebody) { } document.addEventListener('DOMContentLoaded', function (e) { + pagebody = editorcontents().cloneNode(true); var editorinc = document.createElement('script'); editorinc.addEventListener('load', editorsetup); editorinc.src = ckesrc;