import {Menu} from "../../../plugin/Menu"; import {transaction} from "../../wysiwyg/transaction"; import {fetchPost} from "../../../util/fetch"; import {hideElements} from "../../ui/hideElements"; export const openMenuPanel = (protyle: IProtyle, blockElement: HTMLElement, type: "properties" | "config" = "config") => { let avMenuPanel = document.querySelector(".av__panel"); if (avMenuPanel) { avMenuPanel.remove(); return; } window.siyuan.menus.menu.remove(); fetchPost("/api/av/renderAttributeView", {id: blockElement.getAttribute("data-av-id")}, (response) => { const data = response.data.av; const tabRect = blockElement.querySelector(".layout-tab-bar").getBoundingClientRect() let html if (type === "config") { html = `
` } else if (type === "properties") { html = `
` } document.body.insertAdjacentHTML("beforeend", html); avMenuPanel = document.querySelector(".av__panel"); avMenuPanel.addEventListener("click", (event) => { event.preventDefault(); event.stopPropagation(); let target = event.target as HTMLElement; while (target && !target.isSameNode(avMenuPanel)) { const type = target.dataset.type; if (type === "close") { avMenuPanel.remove(); break; } target = target.parentElement; } }); }); }