X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/e533b4e9662636f565f6e487b0ab99e768858370..5424adb82922a3e91606e7b1cc42f3a8536c2816:/edit/page.js diff --git a/edit/page.js b/edit/page.js index 4e389db..ecf5204 100644 --- a/edit/page.js +++ b/edit/page.js @@ -1,3 +1,7 @@ +function editorsetup() { + +CKEDITOR.disableAutoInline = true; + CKEDITOR.plugins.add('inlinesave', { init: function(editor) { editor.addCommand( 'inlinesave', { @@ -8,6 +12,8 @@ CKEDITOR.plugins.add('inlinesave', { body = body.replace(/((?!

).{3})(?:\s|\u200B)+(?=<\/p>)/g, '$1'); // empty line is equivalent to a paragraph break body = body.replace(/
\s*
/g, '

'); + // keep names and preceding abbreviations together + body = body.replace(/\b((?:dhr|mw|me?vr|mr?s?)\.)\s+(?=[A-Z])/ig, '$1 '); // wrap long line after each sentence body = body.replace(/^(\t*).{73,}/mg, function (line, indent) { var dots = '(?:.{24,72}|.{73,}?)'; // chars before punctuation @@ -151,11 +157,9 @@ CKEDITOR.on('instanceCreated', function (event) { }; }); - CKEDITOR.disableAutoInline = true; - -// add edit link to menu var pagebody = document.getElementsByClassName('static')[0]; if (pagebody) { + // add edit link to menu var editlink = document.querySelector('a[href="#edit"]'); if (editlink) editlink.onclick = function (e) { @@ -180,3 +184,11 @@ if (pagebody) { } } +} + +document.addEventListener('DOMContentLoaded', function (e) { + var editorinc = document.createElement('script'); + editorinc.addEventListener('load', editorsetup); + editorinc.src = ckesrc; + document.getElementsByTagName('head')[0].appendChild(editorinc); +});