diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts index 70b0c36fb..3d962c31b 100644 --- a/app/src/protyle/render/av/action.ts +++ b/app/src/protyle/render/av/action.ts @@ -320,12 +320,18 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi } menu.addItem({ icon: "iconBefore", - type: "readonly", label: `
-${window.siyuan.languages.insertRowBefore.replace("${x}", '')} +${window.siyuan.languages.insertRowBefore.replace("${x}", '')}
`, bind(element) { const inputElement = element.querySelector("input"); + element.addEventListener("click", () => { + if (document.activeElement.isSameNode(inputElement)) { + return; + } + insertRows(blockElement, protyle, parseInt(inputElement.value), rowElements[0].previousElementSibling.getAttribute("data-id")); + menu.close(); + }) inputElement.addEventListener("keydown", (event: KeyboardEvent) => { if (!event.isComposing && event.key === "Enter") { insertRows(blockElement, protyle, parseInt(inputElement.value), rowElements[0].previousElementSibling.getAttribute("data-id")); @@ -336,12 +342,18 @@ ${window.siyuan.languages.insertRowBefore.replace("${x}", ' -${window.siyuan.languages.insertRowAfter.replace("${x}", '')} +${window.siyuan.languages.insertRowAfter.replace("${x}", '')} `, bind(element) { const inputElement = element.querySelector("input"); + element.addEventListener("click", () => { + if (document.activeElement.isSameNode(inputElement)) { + return; + } + insertRows(blockElement, protyle, parseInt(inputElement.value), rowElements[0].getAttribute("data-id")); + menu.close(); + }); inputElement.addEventListener("keydown", (event: KeyboardEvent) => { if (!event.isComposing && event.key === "Enter") { insertRows(blockElement, protyle, parseInt(inputElement.value), rowElements[0].getAttribute("data-id"));