From 4bf9341c044f4081ac80317d758435d2d537e006 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Fri, 10 Jan 2020 22:16:11 +0100 Subject: [PATCH] edit/page: copy static contents before dynamic alterations Revert javascript alterations before starting edits, preventing them being saved on lijtweg.nl/doc/splitsing and various Excelsior pages. --- edit/page.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/edit/page.js b/edit/page.js index ecf5204..0566bcf 100644 --- a/edit/page.js +++ b/edit/page.js @@ -1,3 +1,5 @@ +var pagebody; + function editorsetup() { CKEDITOR.disableAutoInline = true; @@ -157,7 +159,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 +167,8 @@ if (pagebody) { editlink.style.fontWeight = 'bold'; editlink.href = ''; editlink.onclick = undefined; + var dynpage = document.getElementsByClassName('static')[0]; + document.body.replaceChild(pagebody, dynpage); pagebody.setAttribute('contenteditable', true); pagebody.querySelectorAll('[data-dyn]').forEach(function (el) { let blockname = el.getAttribute('data-dyn'); @@ -187,6 +190,7 @@ if (pagebody) { } document.addEventListener('DOMContentLoaded', function (e) { + pagebody = document.getElementsByClassName('static')[0].cloneNode(true); var editorinc = document.createElement('script'); editorinc.addEventListener('load', editorsetup); editorinc.src = ckesrc; -- 2.30.0