mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
This commit is contained in:
parent
b91432f996
commit
af382ca0b3
6 changed files with 34 additions and 6 deletions
|
|
@ -75,6 +75,7 @@ import {duplicateCompletely} from "../../protyle/render/av/action";
|
|||
import {copyTextByType} from "../../protyle/toolbar/util";
|
||||
import {onlyProtyleCommand} from "./command/protyle";
|
||||
import {cancelDrag} from "./dragover";
|
||||
import {bindAVPanelKeydown} from "../../protyle/render/av/keydown";
|
||||
|
||||
const switchDialogEvent = (app: App, event: MouseEvent) => {
|
||||
event.preventDefault();
|
||||
|
|
@ -1276,6 +1277,11 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
|
|||
return;
|
||||
}
|
||||
|
||||
if (bindAVPanelKeydown(event)) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
if (["Home", "End", "ArrowUp", "ArrowDown"].includes(event.key)) {
|
||||
let matchDialog: Dialog;
|
||||
// 需找到最顶层的,因此不能用 find
|
||||
|
|
|
|||
|
|
@ -354,7 +354,7 @@ export const bindMenuKeydown = (event: KeyboardEvent) => {
|
|||
if (!currentElement) {
|
||||
return false;
|
||||
} else {
|
||||
const subMenuElement = currentElement.querySelector(".b3-menu__submenu");
|
||||
const subMenuElement = currentElement.querySelector(".b3-menu__submenu") as HTMLElement;
|
||||
if (subMenuElement) {
|
||||
currentElement.classList.remove("b3-menu__item--current");
|
||||
currentElement.classList.add("b3-menu__item--show");
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ export const bindDateEvent = (options: {
|
|||
hasEndDate: inputElements[2].checked,
|
||||
isNotTime: !inputElements[3].checked,
|
||||
}, options.cellElements);
|
||||
document.querySelector(".av__panel")?.remove();
|
||||
document.querySelector(".av__panel")?.dispatchEvent(new CustomEvent("click", {detail: "close"}));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import {addDragFill, cellScrollIntoView, popTextCell, updateCellsValue} from "./
|
|||
import {avContextmenu} from "./action";
|
||||
import {hasClosestByClassName} from "../../util/hasClosest";
|
||||
import {Constants} from "../../../constants";
|
||||
import {upDownHint} from "../../../util/upDownHint";
|
||||
|
||||
export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyle: IProtyle) => {
|
||||
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;
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,6 +151,7 @@ export const openMenuPanel = (options: {
|
|||
});
|
||||
} else if (options.type === "rollup") {
|
||||
bindRollupData({protyle: options.protyle, data, menuElement});
|
||||
(avPanelElement.querySelector(".b3-menu__item") as HTMLButtonElement).focus();
|
||||
}
|
||||
if (["select", "date", "relation", "rollup"].includes(options.type)) {
|
||||
const inputElement = menuElement.querySelector("input");
|
||||
|
|
@ -969,7 +970,7 @@ export const openMenuPanel = (options: {
|
|||
break;
|
||||
} else if (type === "goSearchRollupCol") {
|
||||
goSearchRollupCol({
|
||||
target,
|
||||
target: avPanelElement.querySelector('[data-type="goSearchRollupCol"]'),
|
||||
data,
|
||||
isRelation: true,
|
||||
protyle: options.protyle,
|
||||
|
|
@ -980,7 +981,7 @@ export const openMenuPanel = (options: {
|
|||
break;
|
||||
} else if (type === "goSearchRollupTarget") {
|
||||
goSearchRollupCol({
|
||||
target,
|
||||
target: avPanelElement.querySelector('[data-type="goSearchRollupTarget"]'),
|
||||
data,
|
||||
isRelation: false,
|
||||
protyle: options.protyle,
|
||||
|
|
@ -990,7 +991,7 @@ export const openMenuPanel = (options: {
|
|||
event.stopPropagation();
|
||||
break;
|
||||
} else if (type === "goSearchRollupCalc") {
|
||||
openCalcMenu(options.protyle, target, {
|
||||
openCalcMenu(options.protyle, avPanelElement.querySelector('[data-type="goSearchRollupTarget"]'), {
|
||||
data,
|
||||
colId: options.colId || menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id"),
|
||||
blockID
|
||||
|
|
|
|||
|
|
@ -589,7 +589,7 @@ export const addColOptionOrCell = (protyle: IProtyle, data: IAV, cellElements: H
|
|||
transaction(protyle, cellDoOperations, cellUndoOperations);
|
||||
}
|
||||
if (colData.type === "select") {
|
||||
menuElement.parentElement.remove();
|
||||
menuElement.parentElement.dispatchEvent(new CustomEvent("click", {detail: "close"}));
|
||||
} else {
|
||||
const oldScroll = menuElement.querySelector(".b3-menu__items").scrollTop;
|
||||
const oldChipsHeight = menuElement.querySelector(".b3-chips").clientHeight;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue