]> BookStack Code Mirror - bookstack/blob - resources/js/wysiwyg/plugins-customhr.js
6aa1620da4d6d39b43b2b3cc80542f0ad6ec5fdf
[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', () => {
7         const hrElem = document.createElement('hr');
8         const cNode = editor.selection.getNode();
9         const {parentNode} = cNode;
10         parentNode.insertBefore(hrElem, cNode);
11     });
12
13     editor.ui.registry.addButton('customhr', {
14         icon: 'horizontal-rule',
15         tooltip: 'Insert horizontal line',
16         onAction() {
17             editor.execCommand('InsertHorizontalRule');
18         },
19     });
20 }
21
22 /**
23  * @param {WysiwygConfigOptions} options
24  * @return {register}
25  */
26 export function getPlugin(options) {
27     return register;
28 }