vditor
Version:
♏ 易于使用的 Markdown 编辑器,为适配不同的应用场景而生
19 lines (17 loc) • 668 B
text/typescript
import {Constants} from "../constants";
import {getEventName} from "../util/compatibility";
import {MenuItem} from "./MenuItem";
import {disableToolbar} from "./setToolbar";
export class Undo extends MenuItem {
constructor(vditor: IVditor, menuItem: IMenuItem) {
super(vditor, menuItem);
disableToolbar({undo: this.element}, ["undo"]);
this.element.children[0].addEventListener(getEventName(), (event) => {
event.preventDefault();
if (this.element.firstElementChild.classList.contains(Constants.CLASS_MENU_DISABLED)) {
return;
}
vditor.undo.undo(vditor);
});
}
}