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