✨ feat: 新增 WYSIWYG 编辑器功能和相关工具栏事件处理
This commit is contained in:
18
web/include/vditor/src/ts/toolbar/InsertBefore.ts
Normal file
18
web/include/vditor/src/ts/toolbar/InsertBefore.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import {Constants} from "../constants";
|
||||
import {getEventName} from "../util/compatibility";
|
||||
import {insertEmptyBlock} from "../util/fixBrowserBehavior";
|
||||
import {MenuItem} from "./MenuItem";
|
||||
|
||||
export class InsertBefore extends MenuItem {
|
||||
constructor(vditor: IVditor, menuItem: IMenuItem) {
|
||||
super(vditor, menuItem);
|
||||
this.element.children[0].addEventListener(getEventName(), (event) => {
|
||||
event.preventDefault();
|
||||
if (this.element.firstElementChild.classList.contains(Constants.CLASS_MENU_DISABLED) ||
|
||||
vditor.currentMode === "sv") {
|
||||
return;
|
||||
}
|
||||
insertEmptyBlock(vditor, "beforebegin");
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user