edit: replace double linebreaks by paragraphs
authorMischa POSLAWSKY <perl@shiar.org>
Fri, 29 Sep 2017 11:11:10 +0000 (13:11 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Fri, 29 Sep 2017 13:56:31 +0000 (15:56 +0200)
Works within lists, so currently the only workaround in CKEditor to create
multiple paragraphs for a list item.

edit.js

diff --git a/edit.js b/edit.js
index 6dcb705cee1c72e649530d8b508ce518889338cc..439fb97908675a02e92629569889f6b1a8b7473c 100644 (file)
--- a/edit.js
+++ b/edit.js
@@ -3,7 +3,9 @@ CKEDITOR.plugins.add('inlinesave', {
                editor.addCommand( 'inlinesave', {
                        exec: function (editor) {
                                var pagename = window.location.pathname.replace(/\/$/, '/index');
-                               var body = editor.getData().replace(/^(\t*).{73,}/mg, function (line, indent) {
+                               var body = editor.getData();
+                               body = body.replace(/<br \/>\s*<br \/>/g, '<p>');
+                               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