]> BookStack Code Mirror - bookstack/commitdiff
Added custom, More consistent hr insertion
authorDan Brown <redacted>
Sat, 23 Apr 2016 18:15:49 +0000 (19:15 +0100)
committerDan Brown <redacted>
Sat, 23 Apr 2016 18:15:49 +0000 (19:15 +0100)
Since the previous hr plugin caused large empty p tags

resources/assets/js/directives.js
resources/assets/js/pages/page-form.js

index de87950dc6662fa55dfdc88a17e51b655fd21885..e5c390ad22074ebc97246ea1b161359ede593b38 100644 (file)
@@ -198,6 +198,30 @@ module.exports = function (ngApp, events) {
                 }
 
                 scope.tinymce.extraSetups.push(tinyMceSetup);
+
+                // Custom tinyMCE plugins
+                tinymce.PluginManager.add('customhr', function(editor) {
+                    editor.addCommand('InsertHorizontalRule', function() {
+                        var hrElem = document.createElement('hr');
+                        var cNode = editor.selection.getNode();
+                        var parentNode = cNode.parentNode;
+                        parentNode.insertBefore(hrElem, cNode);
+                    });
+
+                    editor.addButton('hr', {
+                        icon: 'hr',
+                        tooltip: 'Horizontal line',
+                        cmd: 'InsertHorizontalRule'
+                    });
+
+                    editor.addMenuItem('hr', {
+                        icon: 'hr',
+                        text: 'Horizontal line',
+                        cmd: 'InsertHorizontalRule',
+                        context: 'insert'
+                    });
+                });
+
                 tinymce.init(scope.tinymce);
             }
         }
index de7b3e687f181d6833669d45ccec1d8e6ebbaabd..5617fa5be98b6ce8b8d2d448b1c1e1a151cfaccd 100644 (file)
@@ -11,7 +11,7 @@ var mceOptions = module.exports = {
     extended_valid_elements: 'pre[*]',
     automatic_uploads: false,
     valid_children: "-div[p|pre|h1|h2|h3|h4|h5|h6|blockquote]",
-    plugins: "image table textcolor paste link fullscreen imagetools code hr autosave lists",
+    plugins: "image table textcolor paste link fullscreen imagetools code customhr autosave lists",
     imagetools_toolbar: 'imageoptions',
     toolbar: "undo redo | styleselect | bold italic underline strikethrough superscript subscript | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image-insert link hr | removeformat code fullscreen",
     content_style: "body {padding-left: 15px !important; padding-right: 15px !important; margin:0!important; margin-left:auto!important;margin-right:auto!important;}",