X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/86c2b19f372b3d7d4556d60586215ccf3d72a6c7..229b6a2dc688e92570dd7f8b766adec3e1ee01ed:/edit/page.js diff --git a/edit/page.js b/edit/page.js index ecf5204..ccc1115 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; @@ -122,6 +128,8 @@ CKEDITOR.on('instanceCreated', function (event) { { name: 'Attributie', element: 'em', attributes: { 'class': 'right' } }, { name: 'Quote', element: 'q' }, { name: 'Gemarkeerd', element: 'span', styles: { 'background-color': 'Yellow' } }, + { name: 'Ingelogd', element: 'span', attributes: { 'class': 'login' } }, + { name: 'Uitgelogd', element: 'span', attributes: { 'class': 'logout' } }, { name: 'Kadertekst', element: 'aside' }, { name: 'Uitgelijnd', element: 'div', attributes: { 'class': 'right' } }, @@ -157,7 +165,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 +173,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 +195,7 @@ if (pagebody) { } document.addEventListener('DOMContentLoaded', function (e) { + pagebody = editorcontents().cloneNode(true); var editorinc = document.createElement('script'); editorinc.addEventListener('load', editorsetup); editorinc.src = ckesrc;