From d517065f45430375c7160241ac8194fb4fc0d305 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 27 Mar 2024 11:32:35 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/10763 --- app/src/protyle/render/av/action.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) 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"));