page: retain conditional login elements in editor
[minimedit.git] / edit / page.js
index 0566bcf819b0cc628192c6754076cb463eeb4a38..ccc1115eaeda6798426c0266cb06c3e2ed727555 100644 (file)
@@ -1,5 +1,9 @@
 var pagebody;
 
+function editorcontents() {
+       return document.getElementsByClassName('static')[0];
+}
+
 function editorsetup() {
 
 CKEDITOR.disableAutoInline = true;
@@ -124,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' } },
@@ -167,8 +173,7 @@ if (pagebody) {
                editlink.style.fontWeight = 'bold';
                editlink.href = '';
                editlink.onclick = undefined;
-               var dynpage = document.getElementsByClassName('static')[0];
-               document.body.replaceChild(pagebody, dynpage);
+               document.body.replaceChild(pagebody, editorcontents());
                pagebody.setAttribute('contenteditable', true);
                pagebody.querySelectorAll('[data-dyn]').forEach(function (el) {
                        let blockname = el.getAttribute('data-dyn');
@@ -190,7 +195,7 @@ if (pagebody) {
 }
 
 document.addEventListener('DOMContentLoaded', function (e) {
-       pagebody = document.getElementsByClassName('static')[0].cloneNode(true);
+       pagebody = editorcontents().cloneNode(true);
        var editorinc = document.createElement('script');
        editorinc.addEventListener('load', editorsetup);
        editorinc.src = ckesrc;