login/pass: error messages below page title
[minimedit.git] / edit / page.js
index 1896c056c5a93cf058f5345d36c500db894f012a..8aa2890b8d3c426c1155a0264ad7a04fb44e68b7 100644 (file)
@@ -19,9 +19,10 @@ CKEDITOR.plugins.add('inlinesave', {
                                // empty line is equivalent to a paragraph break
                                body = body.replace(/<br \/>\s*<br \/>/g, '<p>');
                                // keep names and preceding abbreviations together
-                               body = body.replace(/\b((?:dhr|mw|me?vr|mr?s?)\.)\s+(?=[A-Z])/ig, '$1&nbsp;');
+                               body = body.replace(/\b((?:[Dd]hr|[Mm](?:w|e?vr|r|r?ss?)|[A-Z])\.)\s+(?=[A-Zdtv])/g, '$1&nbsp;');
                                // wrap long line after each sentence
                                body = body.replace(/^(\t*).{73,}/mg, function (line, indent) {
+                                       if (/^<meta /.test(line)) return line; // ignore metadata headers
                                        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');
@@ -57,7 +58,7 @@ CKEDITOR.plugins.add('inlinesave', {
                                ajaxpost.send(data);
                        },
                });
-               editor.setKeystroke(CKEDITOR.CTRL + 83 /*S*/, 'inlinesave');
+               editor.setKeystroke(CKEDITOR.CTRL + 'S'.charCodeAt(0), 'inlinesave');
                editor.ui.addButton( 'Inlinesave', {
                        command: 'inlinesave',
                        label: editor.lang.save.toolbar,
@@ -119,11 +120,20 @@ CKEDITOR.on('instanceCreated', function (event) {
                var config = editor.config;
                config.language = 'nl';
                config.extraPlugins = 'inlinesave,placeholder,image2,uploadimage';
-               config.allowedContent = true;
+               config.removePlugins = 'image,exportpdf'; // conflicts with imag2
+               config.allowedContent = {
+                       $1: {
+                               elements: CKEDITOR.dtd,
+                               attributes: true,
+                               styles: true,
+                               classes: true,
+                       },
+               };
+               config.disallowedContent = 'img[width,height]';
                config.entities = false; // keep unicode
-               config.filebrowserImageUploadUrl = '/edit/page?output=ckescript';
-               config.uploadUrl = '/edit/page?output=ckjson';
+               config.filebrowserImageUploadUrl = '/edit/page?output=ckjson';
                config.image2_alignClasses = ['left', 'center', 'right'];
+               config.image2_prefillDimensions = false;
                config.image2_disableResizer = true;
                config.stylesSet = [
                        { name: 'Paginakop', element: 'h2' },
@@ -146,7 +156,7 @@ CKEDITOR.on('instanceCreated', function (event) {
                        { name: 'Uitgelogd', element: 'span', attributes: { 'class': 'logout' } },
                ];
                config.pasteFilter = pastefilter;
-               config.contentsCss = document.styleSheets[0].href;
+               config.contentsCss = [...document.styleSheets].map(e => e.href).filter(Boolean);
                config.toolbar = [
                        ['Inlinesave', '-', 'Undo', 'Redo'],
                        ['Styles', 'Bold', 'Italic', 'Link'],
@@ -208,7 +218,9 @@ if (pagebody) {
 
 var ckesrc = document.currentScript.getAttribute('data-ckesrc');
 document.addEventListener('DOMContentLoaded', function (e) {
-       pagebody = editorcontents().cloneNode(true);
+       pagebody = editorcontents();
+       if (!pagebody) return;
+       pagebody = pagebody.cloneNode(true);
        var editorinc = document.createElement('script');
        editorinc.addEventListener('load', editorsetup);
        editorinc.src = ckesrc;