]> BookStack Code Mirror - bookstack/blob - resources/js/wysiwyg/plugins-customhr.js
Merge branch 'tinymce' into development
[bookstack] / resources / js / wysiwyg / plugins-customhr.js
1 /**
2  * @param {Editor} editor
3  * @param {String} url
4  */
5 function register(editor, url) {
6     editor.addCommand('InsertHorizontalRule', function () {
7         let hrElem = document.createElement('hr');
8         let cNode = editor.selection.getNode();
9         let parentNode = cNode.parentNode;
10         parentNode.insertBefore(hrElem, cNode);
11     });
12
13     editor.ui.registry.addButton('hr', {
14         icon: 'horizontal-rule',
15         tooltip: 'Insert horizontal line',
16         onAction() {
17             editor.execCommand('InsertHorizontalRule');
18         }
19     });
20 }
21
22
23 /**
24  * @param {WysiwygConfigOptions} options
25  * @return {register}
26  */
27 export function getPlugin(options) {
28     return register;
29 }