X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/6bf2e9ba6bd29e744d0e205dc9cb88fa15a3f575..769e3ba9e234db9019a096e1d6590f902b5560e0:/edit.js diff --git a/edit.js b/edit.js index 164cc1e..c32bd5b 100644 --- a/edit.js +++ b/edit.js @@ -42,7 +42,7 @@ CKEDITOR.on('instanceCreated', function (event) { editor.on('configLoaded', function () { var config = editor.config; config.language = 'nl'; - config.extraPlugins = 'sourcedialog,inlinesave'; + config.extraPlugins = 'sourcedialog,inlinesave,placeholder'; config.format_tags = 'h2;h3;h4;p'; config.allowedContent = true; config.entities = false; // keep unicode @@ -54,7 +54,7 @@ CKEDITOR.on('instanceCreated', function (event) { ['Format'], ['BulletedList', 'NumberedList', '-', 'Blockquote'], ['Bold', 'Italic', 'Underline', 'Strike', 'RemoveFormat', '-', 'Anchor', 'Link'], - ['HorizontalRule', 'Table', 'Image'], + ['HorizontalRule', 'Table', 'Image', 'CreatePlaceholder'], ]; config.toolbarCanCollapse = true; config.floatSpacePreferRight = true; @@ -69,7 +69,7 @@ CKEDITOR.on('instanceCreated', function (event) { CKEDITOR.on('instanceReady', function (event) { var editor = event.editor; var writer = editor.dataProcessor.writer; - writer.selfClosingEnd = '>'; + writer.selfClosingEnd = ' />'; writer.setRules( 'p', { breakAfterOpen: true, breakBeforeClose: true, @@ -84,19 +84,16 @@ if (pagebody) { 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(/[^]*?/g, '$1'); + CKEDITOR.inline(pagebody); + document.body.className = 'edit'; return false; }; if (window.location.hash == '#edit') {