From f69247b24ab7dd135560f10fe4cfd07a0021105b Mon Sep 17 00:00:00 2001 From: Vanessa Date: Tue, 28 Nov 2023 23:27:04 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/9761 2 --- app/src/protyle/render/av/cell.ts | 11 +++++++++-- app/src/protyle/render/av/keydown.ts | 10 +++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts index 6d3ab975c..a1020a8de 100644 --- a/app/src/protyle/render/av/cell.ts +++ b/app/src/protyle/render/av/cell.ts @@ -161,7 +161,7 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type } cellRect = cellElements[0].getBoundingClientRect(); let html = ""; - const style = `style="position:absolute;left: ${cellRect.left}px;top: ${cellRect.top}px;width:${Math.max(cellRect.width, 25)}px;height: ${cellRect.height}px"`; + const style = `style="padding-top: 6.5px;position:absolute;left: ${cellRect.left}px;top: ${cellRect.top}px;width:${Math.max(cellRect.width, 25)}px;height: ${cellRect.height}px"`; if (["text", "url", "email", "phone", "block", "template"].includes(type)) { html = ``; } else if (type === "number") { @@ -212,7 +212,14 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type (event.key === "Enter" && !event.shiftKey && isNotCtrl(event))) { updateCellValue(protyle, type, cellElements); if (event.key === "Tab") { - protyle.wysiwyg.element.dispatchEvent(new KeyboardEvent("keydown", {key: "Tab", keyCode: 9})) + protyle.wysiwyg.element.dispatchEvent(new KeyboardEvent("keydown", { + shiftKey: event.shiftKey, + ctrlKey: event.ctrlKey, + altKey: event.altKey, + metaKey: event.metaKey, + key: "Tab", + keyCode: 9 + })); } event.preventDefault(); event.stopPropagation(); diff --git a/app/src/protyle/render/av/keydown.ts b/app/src/protyle/render/av/keydown.ts index ffc032751..d9387c833 100644 --- a/app/src/protyle/render/av/keydown.ts +++ b/app/src/protyle/render/av/keydown.ts @@ -3,6 +3,7 @@ import {selectRow} from "./row"; import {cellScrollIntoView, popTextCell} from "./cell"; import {avContextmenu} from "./action"; import {hasClosestByClassName} from "../../util/hasClosest"; +import {Constants} from "../../../constants"; export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyle: IProtyle) => { if (!nodeElement.classList.contains("av") || !window.siyuan.menus.menu.element.classList.contains("fn__none")) { @@ -97,8 +98,15 @@ export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyl event.preventDefault(); return true; } - } + if (!Constants.KEYCODELIST[event.keyCode] || + (Constants.KEYCODELIST[event.keyCode].length === 1 && + !event.metaKey && !event.ctrlKey && + !["⇧", "⌃", "⌥", "⌘"].includes(Constants.KEYCODELIST[event.keyCode]))) { + popTextCell(protyle, [selectCellElement]); + return true; + } + } const selectRowElements = nodeElement.querySelectorAll(".av__row--select:not(.av__row--header)"); if (selectRowElements.length > 0) { if (matchHotKey("⌘/", event)) {