import {MenuItem} from "./Menu"; import {Dialog} from "../dialog"; import {isMobile} from "../util/functions"; import {fetchPost} from "../util/fetch"; import {Constants} from "../constants"; export const transferBlockRef = (id: string) => { window.siyuan.menus.menu.append(new MenuItem({ id: "transferBlockRef", label: window.siyuan.languages.transferBlockRef, icon: "iconScrollHoriz", click() { const renameDialog = new Dialog({ title: window.siyuan.languages.transferBlockRef, content: `
${window.siyuan.languages.transferBlockRefTip}
`, width: isMobile() ? "92vw" : "520px", }); renameDialog.element.setAttribute("data-key", Constants.DIALOG_TRANSFERBLOCKREF); const inputElement = renameDialog.element.querySelector("input") as HTMLInputElement; const btnsElement = renameDialog.element.querySelectorAll(".b3-button"); renameDialog.bindInput(inputElement, () => { (btnsElement[1] as HTMLButtonElement).click(); }); inputElement.focus(); btnsElement[0].addEventListener("click", () => { renameDialog.destroy(); }); btnsElement[1].addEventListener("click", () => { fetchPost("/api/block/transferBlockRef", { fromID: id, toID: inputElement.value, }); renameDialog.destroy(); }); } }).element); };