var editlink = document.createElement('a');
editlink.style.cursor = 'pointer';
editlink.appendChild(document.createTextNode('Wijzig'));
+ editlink.href = '#edit';
editlink.onclick = function (e) {
- var toggled = editlink.style.fontWeight;
- editlink.style.fontWeight = toggled ? '' : 'bold';
- pagebody.setAttribute('contenteditable', !toggled);
- if (toggled) {
- for (name in CKEDITOR.instances) {
- CKEDITOR.instances[name].destroy()
- }
- }
- else {
- CKEDITOR.inline(pagebody);
- }
- document.body.className = toggled ? '' : 'edit';
+ editlink.style.fontWeight = 'bold';
+ editlink.href = '';
+ editlink.onclick = undefined;
+ pagebody.setAttribute('contenteditable', true);
+ pagebody.innerHTML = pagebody.innerHTML
+ .replace(/<!--BLOCK ([a-z]*)-->[^]*?<!--\/-->/g, '[[$1]]');
+ CKEDITOR.inline(pagebody);
+ document.body.className = 'edit';
return false;
};
if (window.location.hash == '#edit') {
{
$rep = [];
foreach ($blocks as $name => $html) {
- $rep["[[$name]]"] = $html;
+ $rep["[[$name]]"] = "<!--BLOCK $name-->$html<!--/-->";
}
return str_replace(array_keys($rep), array_values($rep), ob_get_clean());
}