2022-02-06 07:15:58 +08:00
|
|
|
/**
|
|
|
|
* @param {Editor} editor
|
|
|
|
* @param {String} url
|
|
|
|
*/
|
|
|
|
function register(editor, url) {
|
|
|
|
editor.addCommand('InsertHorizontalRule', function () {
|
|
|
|
let hrElem = document.createElement('hr');
|
|
|
|
let cNode = editor.selection.getNode();
|
|
|
|
let parentNode = cNode.parentNode;
|
|
|
|
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');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {WysiwygConfigOptions} options
|
|
|
|
* @return {register}
|
|
|
|
*/
|
|
|
|
export function getPlugin(options) {
|
|
|
|
return register;
|
|
|
|
}
|