X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/b49b76d0bd617a2d155540cd099515f48255b50c..b3c4c38b834b8647f7c93f8326cce55b0ea47d28:/edit.js diff --git a/edit.js b/edit.js index 974def4..b97ed87 100644 --- a/edit.js +++ b/edit.js @@ -3,7 +3,14 @@ CKEDITOR.plugins.add('inlinesave', { editor.addCommand( 'inlinesave', { exec: function (editor) { var pagename = window.location.pathname.replace(/\/$/, '/index'); - var data = 'body='+encodeURIComponent(editor.getData()); + var body = editor.getData().replace(/^(\t*).{73,}/mg, function (line, indent) { + // wrap long line after each sentence + var dot = '(?:[^<]|<[^>]*>)'; // one character + var dots = '(?:'+dot+'{24,72}|'+dot+'{73,}?)'; // chars before punctuation + var wrap = new RegExp('('+dots+'[.;:!?]) (?=[A-Z])', 'g'); // separate lines + return line.replace(wrap, '$1\n'+indent+'\t'); + }); + var data = 'body='+encodeURIComponent(body); ajaxpost = new XMLHttpRequest(); ajaxpost.open('POST', '/edit'+pagename, true); ajaxpost.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); @@ -42,7 +49,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 +61,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; @@ -66,16 +73,6 @@ CKEDITOR.on('instanceCreated', function (event) { }); }); - CKEDITOR.on('instanceReady', function (event) { - var editor = event.editor; - var writer = editor.dataProcessor.writer; - writer.selfClosingEnd = '>'; - writer.setRules( 'p', { - breakAfterOpen: true, - breakBeforeClose: true, - }); - }); - CKEDITOR.disableAutoInline = true; // add edit link to menu @@ -91,7 +88,7 @@ if (pagebody) { editlink.onclick = undefined; pagebody.setAttribute('contenteditable', true); pagebody.innerHTML = pagebody.innerHTML - .replace(/[^]*?/g, '[[$1]]'); + .replace(/[^]*?/g, '$1'); CKEDITOR.inline(pagebody); document.body.className = 'edit'; return false;