nieuws: fix block replacement of variable contents
[minimedit.git] / edit / page.js
index 9997e293c7615a3af4c6b29945f56583503a49e5..ac2288a07fceb1ef132958ef22e44fad7f57f409 100644 (file)
@@ -161,8 +161,14 @@ if (pagebody) {
                editlink.href = '';
                editlink.onclick = undefined;
                pagebody.setAttribute('contenteditable', true);
-               pagebody.innerHTML = pagebody.innerHTML
-                       .replace(/<!--BLOCK:(.*?)-->[^]*?<!--\/-->/g, '$1');
+               pagebody.querySelectorAll('[data-dyn]').forEach(function (el) {
+                       let blockname = el.getAttribute('data-dyn');
+                       if (!blockname) {
+                               el.remove();
+                               return;
+                       }
+                       el.outerHTML = '[[' + blockname + ']]';
+               });
                CKEDITOR.inline(pagebody, { customConfig: '' });
                document.body.className = 'edit';
                return false;