🎨 ctrl+p database table view cell
This commit is contained in:
parent
c3918a2a71
commit
9634480890
7 changed files with 20 additions and 21 deletions
|
@ -323,7 +323,7 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
|
|||
return true;
|
||||
}
|
||||
const target = event.target as HTMLElement;
|
||||
if (target.tagName !== "TABLE" && (target.tagName === "INPUT" || target.tagName === "TEXTAREA")) {
|
||||
if (target.tagName !== "TABLE" && ["INPUT", "TEXTAREA"].includes(target.tagName)) {
|
||||
return false;
|
||||
}
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.backlinks.custom, event)) {
|
||||
|
@ -653,7 +653,7 @@ const fileTreeKeydown = (app: App, event: KeyboardEvent) => {
|
|||
return true;
|
||||
}
|
||||
const target = event.target as HTMLElement;
|
||||
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" ||
|
||||
if (["INPUT", "TEXTAREA"].includes(target.tagName) ||
|
||||
hasClosestByAttribute(target, "contenteditable", null) ||
|
||||
hasClosestByClassName(target, "protyle", true)) {
|
||||
return false;
|
||||
|
@ -834,7 +834,7 @@ const fileTreeKeydown = (app: App, event: KeyboardEvent) => {
|
|||
const panelTreeKeydown = (app: App, event: KeyboardEvent) => {
|
||||
// 面板折叠展开操作
|
||||
const target = event.target as HTMLElement;
|
||||
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" ||
|
||||
if (["INPUT", "TEXTAREA"].includes(target.tagName) ||
|
||||
hasClosestByAttribute(target, "contenteditable", null) ||
|
||||
hasClosestByClassName(target, "protyle", true)) {
|
||||
return false;
|
||||
|
@ -1280,7 +1280,7 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
|
|||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (matchHotKey("⌘A", event) && target.tagName !== "INPUT" && target.tagName !== "TEXTAREA") {
|
||||
if (matchHotKey("⌘A", event) && !["INPUT", "TEXTAREA"].includes(target.tagName)) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -213,13 +213,7 @@ export const initWindow = async (app: App) => {
|
|||
ipcRenderer.on(Constants.SIYUAN_EVENT, (event, cmd) => {
|
||||
if (cmd === "focus") {
|
||||
if (getSelection().rangeCount > 0) {
|
||||
const range = getSelection().getRangeAt(0);
|
||||
const startNode = range.startContainer.childNodes[range.startOffset] as HTMLElement;
|
||||
if (startNode && startNode.nodeType !== 3 && (startNode.tagName === "TEXTAREA" || startNode.tagName === "INPUT")) {
|
||||
startNode.focus();
|
||||
} else {
|
||||
focusByRange(getSelection().getRangeAt(0));
|
||||
}
|
||||
focusByRange(getSelection().getRangeAt(0));
|
||||
}
|
||||
exportLayout({
|
||||
reload: false,
|
||||
|
|
|
@ -253,7 +253,7 @@ export const bindMenuKeydown = (event: KeyboardEvent) => {
|
|||
return false;
|
||||
}
|
||||
const target = event.target as HTMLElement;
|
||||
if (window.siyuan.menus.menu.element.contains(target) && (target.tagName === "INPUT" || target.tagName === "TEXTAREA")) {
|
||||
if (window.siyuan.menus.menu.element.contains(target) && ["INPUT", "TEXTAREA"].includes(target.tagName)) {
|
||||
return false;
|
||||
}
|
||||
const eventCode = Constants.KEYCODELIST[event.keyCode];
|
||||
|
|
|
@ -308,8 +308,7 @@ const renderKeyboardToolbar = () => {
|
|||
window.screen.height - window.innerHeight < 160 || // reloadSync 会导致 selectionchange,从而导致键盘没有弹起的情况下出现工具栏
|
||||
!document.activeElement || (
|
||||
document.activeElement &&
|
||||
document.activeElement.tagName !== "INPUT" &&
|
||||
document.activeElement.tagName !== "TEXTAREA" &&
|
||||
!["INPUT", "TEXTAREA"].includes(document.activeElement.tagName) &&
|
||||
!document.activeElement.classList.contains("protyle-wysiwyg") &&
|
||||
document.activeElement.getAttribute("contenteditable") !== "true"
|
||||
)) {
|
||||
|
@ -318,8 +317,7 @@ const renderKeyboardToolbar = () => {
|
|||
}
|
||||
// 编辑器设置界面点击空白或关闭,焦点不知何故会飘移到编辑器上
|
||||
if (document.activeElement &&
|
||||
document.activeElement.tagName !== "INPUT" &&
|
||||
document.activeElement.tagName !== "TEXTAREA" && (
|
||||
!["INPUT", "TEXTAREA"].includes(document.activeElement.tagName) && (
|
||||
document.getElementById("menu").style.transform === "translateX(0px)" ||
|
||||
document.getElementById("model").style.transform === "translateY(0px)"
|
||||
)) {
|
||||
|
|
|
@ -204,16 +204,13 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type
|
|||
});
|
||||
});
|
||||
}
|
||||
inputElement.addEventListener("blur", () => {
|
||||
updateCellValue(protyle, type, cellElements);
|
||||
});
|
||||
inputElement.addEventListener("keydown", (event) => {
|
||||
if (event.isComposing) {
|
||||
return;
|
||||
}
|
||||
if (event.key === "Escape" || event.key === "Tab" ||
|
||||
(event.key === "Enter" && !event.shiftKey && isNotCtrl(event))) {
|
||||
inputElement.blur();
|
||||
updateCellValue(protyle, type, cellElements);
|
||||
if (event.key === "Tab") {
|
||||
protyle.wysiwyg.element.dispatchEvent(new KeyboardEvent("keydown", {
|
||||
shiftKey: event.shiftKey,
|
||||
|
@ -231,6 +228,7 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type
|
|||
}
|
||||
avMaskElement.addEventListener("click", (event) => {
|
||||
if ((event.target as HTMLElement).classList.contains("av__mask")) {
|
||||
updateCellValue(protyle, type, cellElements);
|
||||
avMaskElement?.remove();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -296,7 +296,10 @@ ${cell.color ? `color:${cell.color};` : ""}">${text}</div>`;
|
|||
if (newCellElement) {
|
||||
newCellElement.classList.add("av__cell--select");
|
||||
}
|
||||
if (!document.querySelector(".av__panel")) {
|
||||
const avMaskElement = document.querySelector(".av__mask");
|
||||
if (avMaskElement) {
|
||||
(avMaskElement.querySelector(" textarea") as HTMLTextAreaElement).focus();
|
||||
} else if (!document.querySelector(".av__panel")) {
|
||||
focusBlock(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -475,6 +475,12 @@ export const focusByRange = (range: Range) => {
|
|||
if (!range) {
|
||||
return;
|
||||
}
|
||||
|
||||
const startNode = range.startContainer.childNodes[range.startOffset] as HTMLElement;
|
||||
if (startNode && startNode.nodeType !== 3 && ["INPUT", "TEXTAREA"].includes(startNode.tagName)) {
|
||||
startNode.focus();
|
||||
return;
|
||||
}
|
||||
const selection = window.getSelection();
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
|
|
Loading…
Add table
Reference in a new issue