Vanessa 2023-11-28 23:27:04 +08:00
parent a1328a6b4d
commit f69247b24a
2 changed files with 18 additions and 3 deletions

View file

@ -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 = `<textarea ${style} class="b3-text-field">${cellElements[0].firstElementChild.textContent}</textarea>`;
} 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();

View file

@ -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)) {