2022-02-05 23:15:58 +00:00
|
|
|
/**
|
|
|
|
* @param {Editor} editor
|
|
|
|
*/
|
2023-04-19 10:46:13 +01:00
|
|
|
function register(editor) {
|
2023-04-18 22:20:02 +01:00
|
|
|
editor.addCommand('InsertHorizontalRule', () => {
|
|
|
|
const hrElem = document.createElement('hr');
|
|
|
|
const cNode = editor.selection.getNode();
|
|
|
|
const {parentNode} = cNode;
|
2022-02-05 23:15:58 +00:00
|
|
|
parentNode.insertBefore(hrElem, cNode);
|
|
|
|
});
|
|
|
|
|
2022-11-10 13:30:48 +00:00
|
|
|
editor.ui.registry.addButton('customhr', {
|
2022-02-05 23:15:58 +00:00
|
|
|
icon: 'horizontal-rule',
|
2022-02-06 21:17:08 +00:00
|
|
|
tooltip: 'Insert horizontal line',
|
2022-02-05 23:15:58 +00:00
|
|
|
onAction() {
|
|
|
|
editor.execCommand('InsertHorizontalRule');
|
2023-04-18 22:20:02 +01:00
|
|
|
},
|
2022-02-05 23:15:58 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {register}
|
|
|
|
*/
|
2023-04-19 10:46:13 +01:00
|
|
|
export function getPlugin() {
|
2022-02-05 23:15:58 +00:00
|
|
|
return register;
|
2023-04-18 22:20:02 +01:00
|
|
|
}
|