Support automatically appended (not replaced) contents.
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;
{
$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());
}