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