2022-05-26 15:18:53 +08:00
|
|
|
|
import {ToolbarItem} from "./ToolbarItem";
|
2022-07-27 00:03:33 +08:00
|
|
|
|
|
2022-05-26 15:18:53 +08:00
|
|
|
|
export class BlockRef extends ToolbarItem {
|
|
|
|
|
|
public element: HTMLElement;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(protyle: IProtyle, menuItem: IMenuItem) {
|
|
|
|
|
|
super(protyle, menuItem);
|
2022-07-27 00:03:33 +08:00
|
|
|
|
// 不能用 getEventName,否则会导致光标位置变动到点击的文档中
|
|
|
|
|
|
this.element.addEventListener("click", (event: MouseEvent & { changedTouches: MouseEvent[] }) => {
|
2022-05-26 15:18:53 +08:00
|
|
|
|
protyle.toolbar.setInlineMark(protyle, "blockRef", "add");
|
2022-07-27 00:03:33 +08:00
|
|
|
|
protyle.toolbar.element.classList.add("fn__none");
|
2022-05-26 15:18:53 +08:00
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|