Vanessa 2024-04-07 23:33:02 +08:00
parent 006cb533ac
commit fa0f062421
2 changed files with 20 additions and 12 deletions

View File

@ -861,5 +861,7 @@ export const addDragFill = (cellElement: Element) => {
return;
}
cellElement.classList.add("av__cell--active");
if (!cellElement.querySelector(".av__drag-fill")) {
cellElement.insertAdjacentHTML("beforeend", `<div aria-label="${window.siyuan.languages.dragFill}" class="av__drag-fill ariaLabel"></div>`);
}
};

View File

@ -28,15 +28,17 @@ export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyl
event.preventDefault();
return true;
}
// 复制、粘贴
if (!event.ctrlKey && !event.metaKey) {
nodeElement.querySelectorAll(".av__cell--active").forEach(item => {
item.classList.remove("av__cell--active");
item.querySelector(".av__drag-fill")?.remove();
});
const avPanelElement = document.querySelector(".av__panel")
if (avPanelElement &&
(event.key === "Escape" || event.key.startsWith("ArrowLeft") || event.key === "Enter" || matchHotKey("⇥", event) || matchHotKey("⇧⇥", event))) {
avPanelElement.remove();
event.preventDefault();
event.stopPropagation();
return true;
}
if (event.key === "Escape") {
selectCellElement.classList.remove("av__cell--select");
selectCellElement.classList.remove("av__cell--select", "av__cell--active");
selectCellElement.querySelector(".av__drag-fill")?.remove();
selectRow(rowElement.querySelector(".av__firstcol"), "select");
event.preventDefault();
return true;
@ -60,7 +62,8 @@ export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyl
newCellElement = previousCellElements[previousCellElements.length - 1];
}
if (newCellElement) {
selectCellElement.classList.remove("av__cell--select");
selectCellElement.classList.remove("av__cell--select", "av__cell--active");
selectCellElement.querySelector(".av__drag-fill")?.remove();
newCellElement.classList.add("av__cell--select");
addDragFill(newCellElement);
cellScrollIntoView(nodeElement, newCellElement, false);
@ -78,7 +81,8 @@ export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyl
newCellElement = nextRowElement.querySelector(".av__cell");
}
if (newCellElement) {
selectCellElement.classList.remove("av__cell--select");
selectCellElement.classList.remove("av__cell--select", "av__cell--active");
selectCellElement.querySelector(".av__drag-fill")?.remove();
newCellElement.classList.add("av__cell--select");
addDragFill(newCellElement);
cellScrollIntoView(nodeElement, newCellElement, false);
@ -92,7 +96,8 @@ export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyl
newCellElement = previousRowElement.querySelector(`.av__cell[data-col-id="${selectCellElement.dataset.colId}"]`);
}
if (newCellElement) {
selectCellElement.classList.remove("av__cell--select");
selectCellElement.classList.remove("av__cell--select", "av__cell--active");
selectCellElement.querySelector(".av__drag-fill")?.remove();
newCellElement.classList.add("av__cell--select");
addDragFill(newCellElement);
cellScrollIntoView(nodeElement, newCellElement);
@ -106,7 +111,8 @@ export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyl
newCellElement = nextRowElement.querySelector(`.av__cell[data-col-id="${selectCellElement.dataset.colId}"]`);
}
if (newCellElement) {
selectCellElement.classList.remove("av__cell--select");
selectCellElement.classList.remove("av__cell--select", "av__cell--active");
selectCellElement.querySelector(".av__drag-fill")?.remove();
newCellElement.classList.add("av__cell--select");
addDragFill(newCellElement);
cellScrollIntoView(nodeElement, newCellElement);