page: omit numeric placeholders during edit
authorMischa POSLAWSKY <perl@shiar.org>
Fri, 15 Sep 2017 14:07:00 +0000 (16:07 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 18 Sep 2017 18:21:28 +0000 (20:21 +0200)
Support automatically appended (not replaced) contents.

edit.js
page.php

diff --git a/edit.js b/edit.js
index 8cc245c64beeaf907ac16d73c7e843492a9b562e..c32bd5b81ef3540a775a9dad36ea6b2485f56588 100644 (file)
--- a/edit.js
+++ b/edit.js
@@ -91,7 +91,7 @@ if (pagebody) {
                editlink.onclick = undefined;
                pagebody.setAttribute('contenteditable', true);
                pagebody.innerHTML = pagebody.innerHTML
-                       .replace(/<!--BLOCK ([a-z]*)-->[^]*?<!--\/-->/g, '[[$1]]');
+                       .replace(/<!--BLOCK:([^-]*)-->[^]*?<!--\/-->/g, '$1');
                CKEDITOR.inline(pagebody);
                document.body.className = 'edit';
                return false;
index 3c0977ebf776b78590b646b7b5107fc9f5159abf..c34b11c765c51425bb7f634b9921d7e003279c1a 100644 (file)
--- a/page.php
+++ b/page.php
@@ -65,7 +65,9 @@ if ($Page) {
        {
                $rep = [];
                foreach ($blocks as $name => $html) {
-                       $rep["[[$name]]"] = "<!--BLOCK $name-->$html<!--/-->";
+                       $rep["[[$name]]"] = sprintf('<!--BLOCK:%s-->%s<!--/-->',
+                               is_numeric($name) ? '' : "[[$name]]", $html
+                       );
                }
                return str_replace(array_keys($rep), array_values($rep), ob_get_clean());
        }