Vanessa 2025-03-14 21:54:40 +08:00
parent b91432f996
commit af382ca0b3
6 changed files with 34 additions and 6 deletions

View file

@ -75,6 +75,7 @@ import {duplicateCompletely} from "../../protyle/render/av/action";
import {copyTextByType} from "../../protyle/toolbar/util"; import {copyTextByType} from "../../protyle/toolbar/util";
import {onlyProtyleCommand} from "./command/protyle"; import {onlyProtyleCommand} from "./command/protyle";
import {cancelDrag} from "./dragover"; import {cancelDrag} from "./dragover";
import {bindAVPanelKeydown} from "../../protyle/render/av/keydown";
const switchDialogEvent = (app: App, event: MouseEvent) => { const switchDialogEvent = (app: App, event: MouseEvent) => {
event.preventDefault(); event.preventDefault();
@ -1276,6 +1277,11 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
return; return;
} }
if (bindAVPanelKeydown(event)) {
event.preventDefault();
return;
}
if (["Home", "End", "ArrowUp", "ArrowDown"].includes(event.key)) { if (["Home", "End", "ArrowUp", "ArrowDown"].includes(event.key)) {
let matchDialog: Dialog; let matchDialog: Dialog;
// 需找到最顶层的,因此不能用 find // 需找到最顶层的,因此不能用 find

View file

@ -354,7 +354,7 @@ export const bindMenuKeydown = (event: KeyboardEvent) => {
if (!currentElement) { if (!currentElement) {
return false; return false;
} else { } else {
const subMenuElement = currentElement.querySelector(".b3-menu__submenu"); const subMenuElement = currentElement.querySelector(".b3-menu__submenu") as HTMLElement;
if (subMenuElement) { if (subMenuElement) {
currentElement.classList.remove("b3-menu__item--current"); currentElement.classList.remove("b3-menu__item--current");
currentElement.classList.add("b3-menu__item--show"); currentElement.classList.add("b3-menu__item--show");

View file

@ -71,7 +71,7 @@ export const bindDateEvent = (options: {
hasEndDate: inputElements[2].checked, hasEndDate: inputElements[2].checked,
isNotTime: !inputElements[3].checked, isNotTime: !inputElements[3].checked,
}, options.cellElements); }, options.cellElements);
document.querySelector(".av__panel")?.remove(); document.querySelector(".av__panel")?.dispatchEvent(new CustomEvent("click", {detail: "close"}));
} }
}); });
}); });

View file

@ -4,6 +4,7 @@ import {addDragFill, cellScrollIntoView, popTextCell, updateCellsValue} from "./
import {avContextmenu} from "./action"; import {avContextmenu} from "./action";
import {hasClosestByClassName} from "../../util/hasClosest"; import {hasClosestByClassName} from "../../util/hasClosest";
import {Constants} from "../../../constants"; import {Constants} from "../../../constants";
import {upDownHint} from "../../../util/upDownHint";
export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyle: IProtyle) => { export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyle: IProtyle) => {
if (!nodeElement.classList.contains("av") || !window.siyuan.menus.menu.element.classList.contains("fn__none")) { if (!nodeElement.classList.contains("av") || !window.siyuan.menus.menu.element.classList.contains("fn__none")) {
@ -199,3 +200,23 @@ export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyl
return false; return false;
}; };
export const bindAVPanelKeydown = (event: KeyboardEvent) => {
const avPanelElement = document.querySelector(".av__panel");
if (avPanelElement && avPanelElement.querySelector('[data-type="goSearchRollupCol"]') &&
!avPanelElement.querySelector(".b3-text-field") &&
window.siyuan.menus.menu.element.classList.contains("fn__none")) {
const menuElement = avPanelElement.querySelector(".b3-menu__items")
if (event.key === "Enter") {
const currentElement = menuElement.querySelector(".b3-menu__item--current");
if (currentElement) {
avPanelElement.dispatchEvent(new CustomEvent("click", {detail: currentElement.getAttribute("data-type")}));
}
} else if (event.key === "Escape") {
avPanelElement.dispatchEvent(new CustomEvent("click", {detail: "close"}));
} else {
upDownHint(menuElement, event, "b3-menu__item--current", menuElement.firstElementChild)
}
return true;
}
return false;
}

View file

@ -151,6 +151,7 @@ export const openMenuPanel = (options: {
}); });
} else if (options.type === "rollup") { } else if (options.type === "rollup") {
bindRollupData({protyle: options.protyle, data, menuElement}); bindRollupData({protyle: options.protyle, data, menuElement});
(avPanelElement.querySelector(".b3-menu__item") as HTMLButtonElement).focus();
} }
if (["select", "date", "relation", "rollup"].includes(options.type)) { if (["select", "date", "relation", "rollup"].includes(options.type)) {
const inputElement = menuElement.querySelector("input"); const inputElement = menuElement.querySelector("input");
@ -969,7 +970,7 @@ export const openMenuPanel = (options: {
break; break;
} else if (type === "goSearchRollupCol") { } else if (type === "goSearchRollupCol") {
goSearchRollupCol({ goSearchRollupCol({
target, target: avPanelElement.querySelector('[data-type="goSearchRollupCol"]'),
data, data,
isRelation: true, isRelation: true,
protyle: options.protyle, protyle: options.protyle,
@ -980,7 +981,7 @@ export const openMenuPanel = (options: {
break; break;
} else if (type === "goSearchRollupTarget") { } else if (type === "goSearchRollupTarget") {
goSearchRollupCol({ goSearchRollupCol({
target, target: avPanelElement.querySelector('[data-type="goSearchRollupTarget"]'),
data, data,
isRelation: false, isRelation: false,
protyle: options.protyle, protyle: options.protyle,
@ -990,7 +991,7 @@ export const openMenuPanel = (options: {
event.stopPropagation(); event.stopPropagation();
break; break;
} else if (type === "goSearchRollupCalc") { } else if (type === "goSearchRollupCalc") {
openCalcMenu(options.protyle, target, { openCalcMenu(options.protyle, avPanelElement.querySelector('[data-type="goSearchRollupTarget"]'), {
data, data,
colId: options.colId || menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id"), colId: options.colId || menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id"),
blockID blockID

View file

@ -589,7 +589,7 @@ export const addColOptionOrCell = (protyle: IProtyle, data: IAV, cellElements: H
transaction(protyle, cellDoOperations, cellUndoOperations); transaction(protyle, cellDoOperations, cellUndoOperations);
} }
if (colData.type === "select") { if (colData.type === "select") {
menuElement.parentElement.remove(); menuElement.parentElement.dispatchEvent(new CustomEvent("click", {detail: "close"}));
} else { } else {
const oldScroll = menuElement.querySelector(".b3-menu__items").scrollTop; const oldScroll = menuElement.querySelector(".b3-menu__items").scrollTop;
const oldChipsHeight = menuElement.querySelector(".b3-chips").clientHeight; const oldChipsHeight = menuElement.querySelector(".b3-chips").clientHeight;