Added custom, More consistent hr insertion
Since the previous hr plugin caused large empty p tags
Showing
2 changed files
with
25 additions
and
1 deletions
| ... | @@ -198,6 +198,30 @@ module.exports = function (ngApp, events) { | ... | @@ -198,6 +198,30 @@ module.exports = function (ngApp, events) { |
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | scope.tinymce.extraSetups.push(tinyMceSetup); | 200 | scope.tinymce.extraSetups.push(tinyMceSetup); |
| 201 | + | ||
| 202 | + // Custom tinyMCE plugins | ||
| 203 | + tinymce.PluginManager.add('customhr', function(editor) { | ||
| 204 | + editor.addCommand('InsertHorizontalRule', function() { | ||
| 205 | + var hrElem = document.createElement('hr'); | ||
| 206 | + var cNode = editor.selection.getNode(); | ||
| 207 | + var parentNode = cNode.parentNode; | ||
| 208 | + parentNode.insertBefore(hrElem, cNode); | ||
| 209 | + }); | ||
| 210 | + | ||
| 211 | + editor.addButton('hr', { | ||
| 212 | + icon: 'hr', | ||
| 213 | + tooltip: 'Horizontal line', | ||
| 214 | + cmd: 'InsertHorizontalRule' | ||
| 215 | + }); | ||
| 216 | + | ||
| 217 | + editor.addMenuItem('hr', { | ||
| 218 | + icon: 'hr', | ||
| 219 | + text: 'Horizontal line', | ||
| 220 | + cmd: 'InsertHorizontalRule', | ||
| 221 | + context: 'insert' | ||
| 222 | + }); | ||
| 223 | + }); | ||
| 224 | + | ||
| 201 | tinymce.init(scope.tinymce); | 225 | tinymce.init(scope.tinymce); |
| 202 | } | 226 | } |
| 203 | } | 227 | } | ... | ... |
| ... | @@ -11,7 +11,7 @@ var mceOptions = module.exports = { | ... | @@ -11,7 +11,7 @@ var mceOptions = module.exports = { |
| 11 | extended_valid_elements: 'pre[*]', | 11 | extended_valid_elements: 'pre[*]', |
| 12 | automatic_uploads: false, | 12 | automatic_uploads: false, |
| 13 | valid_children: "-div[p|pre|h1|h2|h3|h4|h5|h6|blockquote]", | 13 | valid_children: "-div[p|pre|h1|h2|h3|h4|h5|h6|blockquote]", |
| 14 | - plugins: "image table textcolor paste link fullscreen imagetools code hr autosave lists", | 14 | + plugins: "image table textcolor paste link fullscreen imagetools code customhr autosave lists", |
| 15 | imagetools_toolbar: 'imageoptions', | 15 | imagetools_toolbar: 'imageoptions', |
| 16 | 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", | 16 | 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", |
| 17 | content_style: "body {padding-left: 15px !important; padding-right: 15px !important; margin:0!important; margin-left:auto!important;margin-right:auto!important;}", | 17 | content_style: "body {padding-left: 15px !important; padding-right: 15px !important; margin:0!important; margin-left:auto!important;margin-right:auto!important;}", | ... | ... |
-
Please register or sign in to post a comment