mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
This commit is contained in:
parent
27da48354d
commit
3007364309
1 changed files with 32 additions and 6 deletions
|
|
@ -713,7 +713,30 @@ const fileTreeKeydown = (event: KeyboardEvent) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (event.key === "ArrowDown") {
|
if ((event.key === "ArrowRight" && !liElement.querySelector(".b3-list-item__arrow--open") && !liElement.querySelector(".b3-list-item__toggle").classList.contains("fn__hidden")) ||
|
||||||
|
(event.key === "ArrowLeft" && liElement.querySelector(".b3-list-item__arrow--open"))) {
|
||||||
|
files.getLeaf(liElement, notebookId);
|
||||||
|
event.preventDefault();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
const fileRect = files.element.getBoundingClientRect();
|
||||||
|
if (event.key === "ArrowLeft") {
|
||||||
|
let parentElement = liElement.parentElement.previousElementSibling;
|
||||||
|
if (parentElement) {
|
||||||
|
if (parentElement.tagName !== "LI") {
|
||||||
|
parentElement = files.element.querySelector(".b3-list-item");
|
||||||
|
}
|
||||||
|
liElement.classList.remove("b3-list-item--focus");
|
||||||
|
parentElement.classList.add("b3-list-item--focus");
|
||||||
|
const parentRect = parentElement.getBoundingClientRect();
|
||||||
|
if (parentRect.top < fileRect.top || parentRect.bottom > fileRect.bottom) {
|
||||||
|
parentElement.scrollIntoView(parentRect.top < fileRect.top);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (event.key === "ArrowDown" || event.key === "ArrowRight") {
|
||||||
let nextElement = liElement;
|
let nextElement = liElement;
|
||||||
while (nextElement) {
|
while (nextElement) {
|
||||||
if (nextElement.nextElementSibling) {
|
if (nextElement.nextElementSibling) {
|
||||||
|
|
@ -734,6 +757,10 @@ const fileTreeKeydown = (event: KeyboardEvent) => {
|
||||||
if (nextElement.classList.contains("b3-list-item")) {
|
if (nextElement.classList.contains("b3-list-item")) {
|
||||||
liElement.classList.remove("b3-list-item--focus");
|
liElement.classList.remove("b3-list-item--focus");
|
||||||
nextElement.classList.add("b3-list-item--focus");
|
nextElement.classList.add("b3-list-item--focus");
|
||||||
|
const nextRect = nextElement.getBoundingClientRect();
|
||||||
|
if (nextRect.top < fileRect.top || nextRect.bottom > fileRect.bottom) {
|
||||||
|
nextElement.scrollIntoView(nextRect.top < fileRect.top);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -760,15 +787,14 @@ const fileTreeKeydown = (event: KeyboardEvent) => {
|
||||||
if (previousElement.classList.contains("b3-list-item")) {
|
if (previousElement.classList.contains("b3-list-item")) {
|
||||||
liElement.classList.remove("b3-list-item--focus");
|
liElement.classList.remove("b3-list-item--focus");
|
||||||
previousElement.classList.add("b3-list-item--focus");
|
previousElement.classList.add("b3-list-item--focus");
|
||||||
|
const previousRect = previousElement.getBoundingClientRect();
|
||||||
|
if (previousRect.top < fileRect.top || previousRect.bottom > fileRect.bottom) {
|
||||||
|
previousElement.scrollIntoView(previousRect.top < fileRect.top);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (event.key === "ArrowRight" || event.key === "ArrowLeft") {
|
|
||||||
files.getLeaf(liElement, notebookId);
|
|
||||||
event.preventDefault();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (event.key === "Delete" || (event.key === "Backspace" && isMac())) {
|
if (event.key === "Delete" || (event.key === "Backspace" && isMac())) {
|
||||||
if (isFile) {
|
if (isFile) {
|
||||||
fetchPost("/api/block/getDocInfo", {
|
fetchPost("/api/block/getDocInfo", {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue