X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/87ae71d836e57d6952f4c11ee6ffc02a79d8bdf7..43a352bd08ac38800f6fa73d48d565f39bca4549:/edit.js diff --git a/edit.js b/edit.js index 049bbd0..1485394 100644 --- a/edit.js +++ b/edit.js @@ -4,13 +4,17 @@ CKEDITOR.plugins.add('inlinesave', { exec: function (editor) { var pagename = window.location.pathname.replace(/\/$/, '/index'); var body = editor.getData(); + // empty line is equivalent to a paragraph break body = body.replace(/
\s*
/g, '

'); + // wrap long line after each sentence body = body.replace(/^(\t*).{73,}/mg, function (line, indent) { - // wrap long line after each sentence var dots = '(?:.{24,72}|.{73,}?)'; // chars before punctuation var wrap = new RegExp('('+dots+'[.;:!?]) (?=[A-Z(<])', 'g'); // separate lines return line.replace(wrap, '$1\n'+indent+'\t'); }); + // treat standalone placeholders as block elements + body = body.replace(/

(\[\[.*\]\])<\/p>/g, '$1'); + var data = 'body='+encodeURIComponent(body); ajaxpost = new XMLHttpRequest(); ajaxpost.open('POST', '/edit'+pagename, true); @@ -35,13 +39,20 @@ CKEDITOR.plugins.add('inlinesave', { }); CKEDITOR.on('dialogDefinition', function (event) { - if (event.data.name === 'table') { + switch (event.data.name) { + case 'table': // override initial attribute values var infoTab = event.data.definition.getContents('info'); infoTab.get('txtWidth').default = ''; infoTab.get('txtBorder').default = '0'; infoTab.get('txtCellSpace').default = ''; infoTab.get('txtCellPad').default = ''; + break; + case 'link': + // remove unneeded widgets from the Link Info tab + var infotab = event.data.definition.getContents('info'); + infotab.remove('linkType'); + break; } }); @@ -65,19 +76,26 @@ CKEDITOR.on('instanceCreated', function (event) { editor.on('configLoaded', function () { var config = editor.config; config.language = 'nl'; - config.extraPlugins = 'sourcedialog,inlinesave,placeholder'; + config.extraPlugins = 'sourcedialog,inlinesave,placeholder,image2,uploadimage'; config.format_tags = 'h2;h3;h4;p'; config.allowedContent = true; config.entities = false; // keep unicode config.filebrowserImageUploadUrl = '/edit?output=ckescript'; + config.uploadUrl = '/edit?output=ckjson'; + config.image2_alignClasses = ['left', 'center', 'right']; + config.image2_disableResizer = true; + config.stylesSet = [ + { name: 'Kolom', element: 'div', attributes: { 'class': 'col' } }, + { name: 'Rechts', element: 'div', attributes: { 'class': 'right' } }, + ]; config.pasteFilter = pastefilter; config.contentsCss = document.styleSheets[0].href; config.toolbar = [ ['Inlinesave', '-', 'Undo', 'Redo'], - ['Format', 'BulletedList', 'NumberedList', 'Blockquote'], + ['Format', 'BulletedList', 'NumberedList', 'CreateDiv', 'Table', 'Blockquote'], + ['HorizontalRule', 'CreatePlaceholder', 'Image'], ['Bold', 'Italic', 'Link'], - ['HorizontalRule', 'Table', 'Image'], - ['CreatePlaceholder', 'Sourcedialog'], + ['Sourcedialog'], ]; config.toolbarCanCollapse = true; config.floatSpacePreferRight = true;